From b6a81f1252531ff6ebe5b6563e6f17778f905eba Mon Sep 17 00:00:00 2001 From: lakshyacis Date: Wed, 15 Jan 2020 16:17:26 +0530 Subject: [PATCH] Formatting and fix License --- LICENSE | 24 ++++++++++++++++++++++++ src/addresses.py | 2 +- src/bitmessagemain.py | 4 ++-- src/bmconfigparser.py | 6 ++++-- src/class_singleWorker.py | 3 ++- src/class_smtpDeliver.py | 8 +++++--- src/class_smtpServer.py | 6 ++++-- src/class_sqlThread.py | 2 +- src/depends.py | 3 ++- src/namecoin.py | 23 +---------------------- src/shared.py | 4 ++-- src/tr.py | 5 +++-- 12 files changed, 51 insertions(+), 39 deletions(-) diff --git a/LICENSE b/LICENSE index 2c718643..c2eeff82 100644 --- a/LICENSE +++ b/LICENSE @@ -68,3 +68,27 @@ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +===== based on namecoin.py namecoin.py python implementation by Daniel Kraft + +Copyright (C) 2013 by Daniel Kraft + +This file is part of the Bitmessage project. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/src/addresses.py b/src/addresses.py index bb0c9ec5..04e80383 100644 --- a/src/addresses.py +++ b/src/addresses.py @@ -180,7 +180,7 @@ def decodeAddress(address): returns (status, address version number, stream number, data (almost certainly a ripe hash)) """ - # pylint: disable=too-many-return-statements,too-many-statements,too-many-return-statements,too-many-branches + # pylint: disable=too-many-return-statements,too-many-statements,too-many-branches address = str(address).strip() diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 48ed9738..17c08fc0 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -412,7 +412,7 @@ class Main(object): # wait until grandchild ready while True: time.sleep(1) - os._exit(0) # pylint: disable=protected-access + os._exit(0) # pylint: disable=protected-access except AttributeError: # fork not implemented pass @@ -433,7 +433,7 @@ class Main(object): # wait until child ready while True: time.sleep(1) - os._exit(0) # pylint: disable=protected-access + os._exit(0) # pylint: disable=protected-access except AttributeError: # fork not implemented pass diff --git a/src/bmconfigparser.py b/src/bmconfigparser.py index 1851144d..c08ba062 100644 --- a/src/bmconfigparser.py +++ b/src/bmconfigparser.py @@ -58,7 +58,8 @@ class BMConfigParser(ConfigParser.SafeConfigParser): raise ValueError("Invalid value %s" % value) return ConfigParser.ConfigParser.set(self, section, option, value) - def get(self, section, option, raw=False, variables=None): # pylint: disable=arguments-differ + def get(self, section, option, raw=False, variables=None): + # pylint: disable=arguments-differ try: if section == "bitmessagesettings" and option == "timeformat": return ConfigParser.ConfigParser.get( @@ -109,8 +110,9 @@ class BMConfigParser(ConfigParser.SafeConfigParser): ValueError, AttributeError): return default - def items(self, section, raw=False, variables=None): # pylint: disable=arguments-differ + def items(self, section, raw=False, variables=None): """Return section variables as parent, but override the "raw" argument to always True""" + # pylint: disable=arguments-differ return ConfigParser.ConfigParser.items(self, section, True, variables) @staticmethod diff --git a/src/class_singleWorker.py b/src/class_singleWorker.py index d035c092..e3f93ec6 100644 --- a/src/class_singleWorker.py +++ b/src/class_singleWorker.py @@ -1,7 +1,8 @@ """ Thread for performing PoW """ -# pylint: disable=protected-access,too-many-branches,too-many-statements,no-self-use,too-many-lines,too-many-locals +# pylint: disable=protected-access,too-many-branches,too-many-statements +# pylint: disable=no-self-use,too-many-lines,too-many-locals from __future__ import division diff --git a/src/class_smtpDeliver.py b/src/class_smtpDeliver.py index 14df14c9..4f8422cc 100644 --- a/src/class_smtpDeliver.py +++ b/src/class_smtpDeliver.py @@ -22,8 +22,9 @@ class smtpDeliver(StoppableThread): _instance = None def stopThread(self): + # pylint: disable=no-member try: - queues.UISignallerQueue.put(("stopThread", "data")) # pylint: disable=no-member + queues.UISignallerQueue.put(("stopThread", "data")) except: pass super(smtpDeliver, self).stopThread() @@ -37,6 +38,7 @@ class smtpDeliver(StoppableThread): def run(self): # pylint: disable=too-many-branches,too-many-statements,too-many-locals + # pylint: disable=deprecated-lambda while state.shutdown == 0: command, data = queues.UISignalQueue.get() if command == 'writeNewAddressToTable': @@ -59,9 +61,9 @@ class smtpDeliver(StoppableThread): msg = MIMEText(body, 'plain', 'utf-8') msg['Subject'] = Header(subject, 'utf-8') msg['From'] = fromAddress + '@' + SMTPDOMAIN - toLabel = map( # pylint: disable=deprecated-lambda + toLabel = map( lambda y: BMConfigParser().safeGet(y, "label"), - filter( # pylint: disable=deprecated-lambda + filter( lambda x: x == toAddress, BMConfigParser().addresses()) ) if toLabel: diff --git a/src/class_smtpServer.py b/src/class_smtpServer.py index cdf867a9..453ca640 100644 --- a/src/class_smtpServer.py +++ b/src/class_smtpServer.py @@ -76,8 +76,9 @@ class smtpServerPyBitmessage(smtpd.SMTPServer): # print >> DEBUGSTREAM, 'Incoming connection from %s' % repr(addr) self.channel = smtpServerChannel(self, conn, addr) - def send(self, fromAddress, toAddress, subject, message): # pylint: disable=arguments-differ + def send(self, fromAddress, toAddress, subject, message): """Send a bitmessage""" + # pylint: disable=arguments-differ streamNumber, ripe = decodeAddress(toAddress)[2:] stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel') ackdata = genAckPayload(streamNumber, stealthLevel) @@ -114,8 +115,9 @@ class smtpServerPyBitmessage(smtpd.SMTPServer): return ret - def process_message(self, peer, mailfrom, rcpttos, data): # pylint: disable=too-many-locals, too-many-branches + def process_message(self, peer, mailfrom, rcpttos, data): """Process an email""" + # pylint: disable=too-many-locals, too-many-branches # print 'Receiving message from:', peer p = re.compile(".*<([^>]+)>") if not hasattr(self.channel, "auth") or not self.channel.auth: diff --git a/src/class_sqlThread.py b/src/class_sqlThread.py index 3d59803c..78d70f79 100644 --- a/src/class_sqlThread.py +++ b/src/class_sqlThread.py @@ -27,7 +27,7 @@ class sqlThread(threading.Thread): def __init__(self): threading.Thread.__init__(self, name="SQL") - def run(self): # pylint: disable=too-many-locals, too-many-branches, too-many-statements + def run(self): # pylint: disable=too-many-locals, too-many-branches, too-many-statements """Process SQL queries from `.helper_sql.sqlSubmitQueue`""" self.conn = sqlite3.connect(state.appdata + 'messages.dat') self.conn.text_factory = str diff --git a/src/depends.py b/src/depends.py index 68fba01a..03e297f1 100755 --- a/src/depends.py +++ b/src/depends.py @@ -231,12 +231,13 @@ def check_sqlite(): conn.close() -def check_openssl(): # pylint: disable=too-many-branches, too-many-return-statements +def check_openssl(): """Do openssl dependency check. Here we are checking for openssl with its all dependent libraries and version checking. """ + # pylint: disable=too-many-branches, too-many-return-statements # pylint: disable=protected-access, redefined-outer-name ctypes = try_import('ctypes') if not ctypes: diff --git a/src/namecoin.py b/src/namecoin.py index c9238f63..63ca5653 100644 --- a/src/namecoin.py +++ b/src/namecoin.py @@ -1,28 +1,7 @@ -# pylint: disable=too-many-branches,protected-access """ -Copyright (C) 2013 by Daniel Kraft - Namecoin queries """ -# This file is part of the Bitmessage project. - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# pylint: disable=too-many-branches,protected-access import base64 import httplib diff --git a/src/shared.py b/src/shared.py index 90cea89d..dfc86ab6 100644 --- a/src/shared.py +++ b/src/shared.py @@ -118,7 +118,7 @@ def decodeWalletImportFormat(WIFstring): ' 6 characters of the PRIVATE key: %s', str(WIFstring)[:6] ) - os._exit(0) # pylint: disable=protected-access + os._exit(0) # pylint: disable=protected-access # return "" elif privkey[0] == '\x80': # checksum passed return privkey[1:] @@ -128,7 +128,7 @@ def decodeWalletImportFormat(WIFstring): ' the checksum passed but the key doesn\'t begin with hex 80.' ' Here is the PRIVATE key: %s', WIFstring ) - os._exit(0) # pylint: disable=protected-access + os._exit(0) # pylint: disable=protected-access def reloadMyAddressHashes(): diff --git a/src/tr.py b/src/tr.py index 87e67219..ac76ef4b 100644 --- a/src/tr.py +++ b/src/tr.py @@ -25,7 +25,8 @@ class translateClass: return self.text -def _translate(context, text, disambiguation=None, encoding=None, n=None): # pylint: disable=unused-argument +def _translate(context, text, disambiguation=None, encoding=None, n=None): + # pylint: disable=unused-argument return translateText(context, text, n) @@ -45,7 +46,7 @@ def translateText(context, text, n=None): ' or by searching Google for \'PyQt Download\'.'\ ' If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon' print 'Error message:', err - os._exit(0) # pylint: disable=protected-access + os._exit(0) # pylint: disable=protected-access if n is None: return QtGui.QApplication.translate(context, text) return QtGui.QApplication.translate(context, text, None, QtCore.QCoreApplication.CodecForTr, n)