From 43b2cd1433422ff96ba1424a4515db7344bff0ff Mon Sep 17 00:00:00 2001 From: Job Evers-Meltzer Date: Fri, 4 Nov 2016 11:39:52 -0500 Subject: [PATCH] cleanup whitespace and long-lines --- lbrynet/core/StreamCreator.py | 4 +--- lbrynet/cryptstream/CryptStreamCreator.py | 20 ++++++++-------- .../lbryfilemanager/EncryptedFileCreator.py | 23 ++++++++++--------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/lbrynet/core/StreamCreator.py b/lbrynet/core/StreamCreator.py index e0b2dab83..cc579865d 100644 --- a/lbrynet/core/StreamCreator.py +++ b/lbrynet/core/StreamCreator.py @@ -65,12 +65,10 @@ class StreamCreator(object): pass def write(self, data): - from twisted.internet import reactor - self._write(data) if self.stopped is False and self.streaming is False: reactor.callLater(0, self.producer.resumeProducing) def _write(self, data): - pass \ No newline at end of file + pass diff --git a/lbrynet/cryptstream/CryptStreamCreator.py b/lbrynet/cryptstream/CryptStreamCreator.py index 61d4d0270..9b2aa1770 100644 --- a/lbrynet/cryptstream/CryptStreamCreator.py +++ b/lbrynet/cryptstream/CryptStreamCreator.py @@ -18,22 +18,23 @@ log = logging.getLogger(__name__) class CryptStreamCreator(StreamCreator): """Create a new stream with blobs encrypted by a symmetric cipher. - Each blob is encrypted with the same key, but each blob has its own initialization vector - which is associated with the blob when the blob is associated with the stream.""" + Each blob is encrypted with the same key, but each blob has its + own initialization vector which is associated with the blob when + the blob is associated with the stream. + """ def __init__(self, blob_manager, name=None, key=None, iv_generator=None): - """ - @param blob_manager: Object that stores and provides access to blobs. + """@param blob_manager: Object that stores and provides access to blobs. @type blob_manager: BlobManager @param name: the name of the stream, which will be presented to the user @type name: string - @param key: the raw AES key which will be used to encrypt the blobs. If None, a random key will - be generated. + @param key: the raw AES key which will be used to encrypt the + blobs. If None, a random key will be generated. @type key: string - @param iv_generator: a generator which yields initialization vectors for the blobs. Will be called - once for each blob. + @param iv_generator: a generator which yields initialization + vectors for the blobs. Will be called once for each blob. @type iv_generator: a generator function which yields strings @return: None @@ -75,7 +76,6 @@ class CryptStreamCreator(StreamCreator): return d def _write(self, data): - def close_blob(blob): d = blob.close() d.addCallback(self._blob_finished) @@ -94,4 +94,4 @@ class CryptStreamCreator(StreamCreator): self.current_blob = None def _get_blob_maker(self, iv, blob_creator): - return CryptStreamBlobMaker(self.key, iv, self.blob_count, blob_creator) \ No newline at end of file + return CryptStreamBlobMaker(self.key, iv, self.blob_count, blob_creator) diff --git a/lbrynet/lbryfilemanager/EncryptedFileCreator.py b/lbrynet/lbryfilemanager/EncryptedFileCreator.py index 516259c82..77a168b96 100644 --- a/lbrynet/lbryfilemanager/EncryptedFileCreator.py +++ b/lbrynet/lbryfilemanager/EncryptedFileCreator.py @@ -24,10 +24,7 @@ class EncryptedFileStreamCreator(CryptStreamCreator): key=None, iv_generator=None, suggested_file_name=None): CryptStreamCreator.__init__(self, blob_manager, name, key, iv_generator) self.lbry_file_manager = lbry_file_manager - if suggested_file_name is None: - self.suggested_file_name = name - else: - self.suggested_file_name = suggested_file_name + self.suggested_file_name = suggested_file_name or name self.stream_hash = None self.blob_infos = [] @@ -82,8 +79,7 @@ class EncryptedFileStreamCreator(CryptStreamCreator): def create_lbry_file(session, lbry_file_manager, file_name, file_handle, key=None, iv_generator=None, suggested_file_name=None): - """ - Turn a plain file into an LBRY File. + """Turn a plain file into an LBRY File. An LBRY File is a collection of encrypted blobs of data and the metadata that binds them together which, when decrypted and put back together according to the metadata, results @@ -113,8 +109,8 @@ def create_lbry_file(session, lbry_file_manager, file_name, file_handle, key=Non be generated. @type key: string - @param iv_generator: a generator which yields initialization vectors for the blobs. Will be called - once for each blob. + @param iv_generator: a generator which yields initialization + vectors for the blobs. Will be called once for each blob. @type iv_generator: a generator function which yields strings @param suggested_file_name: what the file should be called when the LBRY File is saved to disk. @@ -130,7 +126,8 @@ def create_lbry_file(session, lbry_file_manager, file_name, file_handle, key=Non def make_stream_desc_file(stream_hash): log.debug("creating the stream descriptor file") - descriptor_file_path = os.path.join(session.db_dir, file_name + settings.CRYPTSD_FILE_EXTENSION) + descriptor_file_path = os.path.join( + session.db_dir, file_name + settings.CRYPTSD_FILE_EXTENSION) descriptor_writer = PlainStreamDescriptorWriter(descriptor_file_path) d = get_sd_info(lbry_file_manager.stream_info_manager, stream_hash, True) @@ -141,8 +138,12 @@ def create_lbry_file(session, lbry_file_manager, file_name, file_handle, key=Non base_file_name = os.path.basename(file_name) - lbry_file_creator = EncryptedFileStreamCreator(session.blob_manager, lbry_file_manager, base_file_name, - key, iv_generator, suggested_file_name) + lbry_file_creator = EncryptedFileStreamCreator( + session.blob_manager, + lbry_file_manager, + base_file_name, key, + iv_generator, + suggested_file_name) def start_stream(): file_sender = FileSender()