From b5df2421417e4460f3ef6791316616d25454ce0f Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Thu, 10 Oct 2019 16:38:13 +0300 Subject: [PATCH] Fixed badly formatted docstrings and some wrong text --- src/api.py | 6 +----- src/class_singleCleaner.py | 17 ++++++++-------- src/highlevelcrypto.py | 6 +++--- src/namecoin.py | 41 ++++++++++++++++++-------------------- src/network/bmobject.py | 4 +--- src/protocol.py | 10 +++------- src/pyelliptic/__init__.py | 13 +++++++----- src/pyelliptic/hash.py | 5 +---- src/pyelliptic/openssl.py | 10 ++++------ 9 files changed, 49 insertions(+), 63 deletions(-) diff --git a/src/api.py b/src/api.py index fad5d623..f92abeb4 100644 --- a/src/api.py +++ b/src/api.py @@ -1,19 +1,15 @@ # pylint: disable=too-many-locals,too-many-lines,no-self-use,too-many-public-methods,too-many-branches # pylint: disable=too-many-statements -""" -src/api.py -========== # Copyright (c) 2012-2016 Jonathan Warren # Copyright (c) 2012-2019 The Bitmessage developers +""" This is not what you run to run the Bitmessage API. Instead, enable the API ( https://bitmessage.org/wiki/API ) and optionally enable daemon mode ( https://bitmessage.org/wiki/Daemon ) then run bitmessagemain.py. """ -from __future__ import absolute_import - import base64 import errno import hashlib diff --git a/src/class_singleCleaner.py b/src/class_singleCleaner.py index a5938716..49e15f49 100644 --- a/src/class_singleCleaner.py +++ b/src/class_singleCleaner.py @@ -2,19 +2,20 @@ The singleCleaner class is a timer-driven thread that cleans data structures to free memory, resends messages when a remote node doesn't respond, and sends pong messages to keep connections alive if the network isn't busy. + It cleans these data structures in memory: -inventory (moves data to the on-disk sql database) -inventorySets (clears then reloads data out of sql database) + - inventory (moves data to the on-disk sql database) + - inventorySets (clears then reloads data out of sql database) It cleans these tables on the disk: -inventory (clears expired objects) -pubkeys (clears pubkeys older than 4 weeks old which we have not used - personally) -knownNodes (clears addresses which have not been online for over 3 days) + - inventory (clears expired objects) + - pubkeys (clears pubkeys older than 4 weeks old which we have not used + personally) + - knownNodes (clears addresses which have not been online for over 3 days) It resends messages when there has been no response: -resends getpubkey messages in 5 days (then 10 days, then 20 days, etc...) -resends msg messages in 5 days (then 10 days, then 20 days, etc...) + - resends getpubkey messages in 5 days (then 10 days, then 20 days, etc...) + - resends msg messages in 5 days (then 10 days, then 20 days, etc...) """ diff --git a/src/highlevelcrypto.py b/src/highlevelcrypto.py index 02fb85ab..3d894ae8 100644 --- a/src/highlevelcrypto.py +++ b/src/highlevelcrypto.py @@ -100,9 +100,9 @@ def pointMult(secret): Evidently, this type of error can occur very rarely: - File "highlevelcrypto.py", line 54, in pointMult - group = OpenSSL.EC_KEY_get0_group(k) - WindowsError: exception: access violation reading 0x0000000000000008 + >>> File "highlevelcrypto.py", line 54, in pointMult + >>> group = OpenSSL.EC_KEY_get0_group(k) + >>> WindowsError: exception: access violation reading 0x0000000000000008 """ while True: try: diff --git a/src/namecoin.py b/src/namecoin.py index 579fb0ab..c9238f63 100644 --- a/src/namecoin.py +++ b/src/namecoin.py @@ -1,31 +1,28 @@ # pylint: disable=too-many-branches,protected-access """ 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. - -.. todo:: from debug import logger crashes PyBitmessage due to a circular dependency. The debug module will also -override/disable logging.getLogger() # loggers so module level logging functions are used instead +Namecoin queries """ +# This file is part of the Bitmessage project. -from __future__ import absolute_import +# 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. import base64 import httplib diff --git a/src/network/bmobject.py b/src/network/bmobject.py index 0a4c12b7..e19eaac9 100644 --- a/src/network/bmobject.py +++ b/src/network/bmobject.py @@ -1,7 +1,5 @@ """ -src/network/bmobject.py -====================== - +BMObject and it's exceptions. """ import time diff --git a/src/protocol.py b/src/protocol.py index 1031b950..ef101a72 100644 --- a/src/protocol.py +++ b/src/protocol.py @@ -1,13 +1,8 @@ # pylint: disable=too-many-boolean-expressions,too-many-return-statements,too-many-locals,too-many-statements """ -protocol.py -=========== - Low-level protocol-related functions. """ -from __future__ import absolute_import - import base64 import hashlib import random @@ -205,12 +200,13 @@ def isProofOfWorkSufficient(data, recvTime=0): """ Validate an object's Proof of Work using method described in: - https://bitmessage.org/wiki/Proof_of_work + https://bitmessage.org/wiki/Proof_of_work + Arguments: int nonceTrialsPerByte (default: from default.py) int payloadLengthExtraBytes (default: from default.py) float recvTime (optional) UNIX epoch time when object was - received from the network (default: current system time) + received from the network (default: current system time) Returns: True if PoW valid and sufficient, False in all other cases """ diff --git a/src/pyelliptic/__init__.py b/src/pyelliptic/__init__.py index 7aa666e0..65279ded 100644 --- a/src/pyelliptic/__init__.py +++ b/src/pyelliptic/__init__.py @@ -1,10 +1,13 @@ """ -src/pyelliptic/__init__.py -===================================== +Copyright (C) 2010 +Author: Yann GUIBET +Contact: + +Python OpenSSL wrapper. +For modern cryptography with ECC, AES, HMAC, Blowfish, ... + +This is an abandoned package maintained inside of the PyBitmessage. """ -# Copyright (C) 2010 -# Author: Yann GUIBET -# Contact: from .openssl import OpenSSL from .ecc import ECC diff --git a/src/pyelliptic/hash.py b/src/pyelliptic/hash.py index c21dd6a4..f098d631 100644 --- a/src/pyelliptic/hash.py +++ b/src/pyelliptic/hash.py @@ -1,8 +1,5 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- """ -src/pyelliptic/hash.py -===================== +Wrappers for hash functions from OpenSSL. """ # Copyright (C) 2011 Yann GUIBET # See LICENSE for details. diff --git a/src/pyelliptic/openssl.py b/src/pyelliptic/openssl.py index fcde01ec..152a780c 100644 --- a/src/pyelliptic/openssl.py +++ b/src/pyelliptic/openssl.py @@ -1,14 +1,12 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -""" -src/pyelliptic/openssl.py -===================== -""" # Copyright (C) 2011 Yann GUIBET # See LICENSE for details. # # Software slightly changed by Jonathan Warren # pylint: disable=protected-access +""" +This module loads openssl libs with ctypes and incapsulates +needed openssl functionality in class _OpenSSL. +""" import sys import ctypes