massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
This commit is contained in:
parent
d50412c7f7
commit
6a6f15707a
1 changed files with 9945 additions and 9945 deletions
|
|
@ -37,7 +37,7 @@ log = getLogger(__name__)
|
|||
|
||||
|
||||
class IStreamProducer(interface.Interface):
|
||||
def startStream(consumer):
|
||||
def start_stream(consumer):
|
||||
"""start producing the stream
|
||||
|
||||
@return (D): deferred fired when stream is finished
|
||||
|
|
@ -68,18 +68,18 @@ class SatFile:
|
|||
@param path(Path, str): path to the file to get or write to
|
||||
@param mode(str): same as for built-in "open" function
|
||||
@param uid(unicode, None): unique id identifing this progressing element
|
||||
This uid will be used with self.host.progressGet
|
||||
This uid will be used with self.host.progress_get
|
||||
will be automaticaly generated if None
|
||||
@param size(None, int): size of the file (when known in advance)
|
||||
@param data_cb(None, callable): method to call on each data read/write
|
||||
can be used to do processing like calculating hash.
|
||||
if data_cb return a non None value, it will be used instead of the
|
||||
data read/to write
|
||||
@param auto_end_signals(bool): if True, progressFinished and progressError signals
|
||||
@param auto_end_signals(bool): if True, progress_finished and progress_error signals
|
||||
are automatically sent.
|
||||
if False, you'll have to call self.progressFinished and self.progressError
|
||||
if False, you'll have to call self.progress_finished and self.progress_error
|
||||
yourself.
|
||||
progressStarted signal is always sent automatically
|
||||
progress_started signal is always sent automatically
|
||||
@param check_size_with_read(bool): if True, size will be checked using number of
|
||||
bytes read or written. This is useful when data_cb modifiy len of file.
|
||||
@param pre_close_cb:
|
||||
|
|
@ -92,11 +92,11 @@ class SatFile:
|
|||
self.data_cb = data_cb
|
||||
self.auto_end_signals = auto_end_signals
|
||||
self.pre_close_cb = pre_close_cb
|
||||
metadata = self.getProgressMetadata()
|
||||
self.host.registerProgressCb(
|
||||
self.uid, self.getProgress, metadata, profile=client.profile
|
||||
metadata = self.get_progress_metadata()
|
||||
self.host.register_progress_cb(
|
||||
self.uid, self.get_progress, metadata, profile=client.profile
|
||||
)
|
||||
self.host.bridge.progressStarted(self.uid, metadata, client.profile)
|
||||
self.host.bridge.progress_started(self.uid, metadata, client.profile)
|
||||
|
||||
self._transfer_count = 0 if check_size_with_read else None
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ class SatFile:
|
|||
else:
|
||||
self._transfer_count = None
|
||||
|
||||
def checkSize(self):
|
||||
def check_size(self):
|
||||
"""Check that current size correspond to given size
|
||||
|
||||
must be used when the transfer is supposed to be finished
|
||||
|
|
@ -142,7 +142,7 @@ class SatFile:
|
|||
self.pre_close_cb()
|
||||
if error is None:
|
||||
try:
|
||||
size_ok = self.checkSize()
|
||||
size_ok = self.check_size()
|
||||
except exceptions.NotFound:
|
||||
size_ok = True
|
||||
if not size_ok:
|
||||
|
|
@ -154,12 +154,12 @@ class SatFile:
|
|||
|
||||
if self.auto_end_signals:
|
||||
if error is None:
|
||||
self.progressFinished(progress_metadata)
|
||||
self.progress_finished(progress_metadata)
|
||||
else:
|
||||
assert progress_metadata is None
|
||||
self.progressError(error)
|
||||
self.progress_error(error)
|
||||
|
||||
self.host.removeProgressCb(self.uid, self.profile)
|
||||
self.host.remove_progress_cb(self.uid, self.profile)
|
||||
if error is not None:
|
||||
log.error(f"file {self._file} closed with an error: {error}")
|
||||
|
||||
|
|
@ -167,13 +167,13 @@ class SatFile:
|
|||
def closed(self):
|
||||
return self._file.closed
|
||||
|
||||
def progressFinished(self, metadata=None):
|
||||
def progress_finished(self, metadata=None):
|
||||
if metadata is None:
|
||||
metadata = {}
|
||||
self.host.bridge.progressFinished(self.uid, metadata, self.profile)
|
||||
self.host.bridge.progress_finished(self.uid, metadata, self.profile)
|
||||
|
||||
def progressError(self, error):
|
||||
self.host.bridge.progressError(self.uid, error, self.profile)
|
||||
def progress_error(self, error):
|
||||
self.host.bridge.progress_error(self.uid, error, self.profile)
|
||||
|
||||
def flush(self):
|
||||
self._file.flush()
|
||||
|
|
@ -207,8 +207,8 @@ class SatFile:
|
|||
def mode(self):
|
||||
return self._file.mode
|
||||
|
||||
def getProgressMetadata(self):
|
||||
"""Return progression metadata as given to progressStarted
|
||||
def get_progress_metadata(self):
|
||||
"""Return progression metadata as given to progress_started
|
||||
|
||||
@return (dict): metadata (check bridge for documentation)
|
||||
"""
|
||||
|
|
@ -230,7 +230,7 @@ class SatFile:
|
|||
|
||||
return metadata
|
||||
|
||||
def getProgress(self, progress_id, profile):
|
||||
def get_progress(self, progress_id, profile):
|
||||
ret = {"position": self._file.tell()}
|
||||
if self.size:
|
||||
ret["size"] = self.size
|
||||
|
|
@ -252,7 +252,7 @@ class FileStreamObject(basic.FileSender):
|
|||
def registerProducer(self, producer, streaming):
|
||||
pass
|
||||
|
||||
def startStream(self, consumer):
|
||||
def start_stream(self, consumer):
|
||||
return self.beginFileTransfer(self.file_obj, consumer)
|
||||
|
||||
def write(self, data):
|
||||
|
|
|
|||
Loading…
Reference in a new issue