Skip to content

Commit db21f3e

Browse files
committed
Revisit helper_startup: rewrite weird imports, fix W504 and line length
1 parent b75585f commit db21f3e

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

src/helper_startup.py

+15-18
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,15 @@
1010
import time
1111
from distutils.version import StrictVersion
1212

13-
import sys
14-
if sys.version_info[0] == 3:
15-
from . import defaults
16-
from . import helper_random
17-
from . import paths
18-
from . import state
19-
from .bmconfigparser import BMConfigParser
20-
else:
13+
try:
2114
import defaults
2215
import helper_random
2316
import paths
2417
import state
2518
from bmconfigparser import BMConfigParser
19+
except ImportError:
20+
from . import defaults, helper_random, paths, state
21+
from .bmconfigparser import BMConfigParser
2622

2723
try:
2824
from plugins.plugin import get_plugin
@@ -180,9 +176,9 @@ def updateConfig():
180176
# acts as a salt
181177
config.set(
182178
'bitmessagesettings', 'identiconsuffix', ''.join(
183-
helper_random.randomchoice("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
184-
for x in range(12)
185-
)
179+
helper_random.randomchoice(
180+
"123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
181+
"abcdefghijkmnopqrstuvwxyz") for x in range(12))
186182
) # a twelve character pseudo-password to salt the identicons
187183

188184
# Add settings to support no longer resending messages after
@@ -249,14 +245,15 @@ def updateConfig():
249245
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte') == 0:
250246
config.set(
251247
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte',
252-
str(defaults.ridiculousDifficulty *
253-
defaults.networkDefaultProofOfWorkNonceTrialsPerByte)
248+
str(defaults.ridiculousDifficulty
249+
* defaults.networkDefaultProofOfWorkNonceTrialsPerByte)
254250
)
255-
if config.safeGetInt('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes') == 0:
251+
if config.safeGetInt(
252+
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes') == 0:
256253
config.set(
257254
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes',
258-
str(defaults.ridiculousDifficulty *
259-
defaults.networkDefaultPayloadLengthExtraBytes)
255+
str(defaults.ridiculousDifficulty
256+
* defaults.networkDefaultPayloadLengthExtraBytes)
260257
)
261258

262259
if not config.has_option('bitmessagesettings', 'onionhostname'):
@@ -298,8 +295,8 @@ def adjustHalfOpenConnectionsLimit():
298295
# connections at a time.
299296
VER_THIS = StrictVersion(platform.version())
300297
is_limited = (
301-
StrictVersion("5.1.2600") <= VER_THIS and
302-
StrictVersion("6.0.6000") >= VER_THIS
298+
StrictVersion("5.1.2600") <= VER_THIS
299+
and StrictVersion("6.0.6000") >= VER_THIS
303300
)
304301
except ValueError:
305302
pass

0 commit comments

Comments
 (0)