jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/430895 )
Change subject: [IMPR] Remove unused private variables
......................................................................
[IMPR] Remove unused private variables
- _get_base_dir was held for backward compatibility but it is private and
can be removed
- _base_dir is also private and only used inside config2.py; it can be
replaced by the correspninding public base_dir
Change-Id: I99ebce0ac2edfbb43245001a4eba579fd1800b8d
---
M pywikibot/config2.py
1 file changed, 2 insertions(+), 4 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index f621da6..fb85461 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -376,10 +376,8 @@
return base_dir
-_get_base_dir = get_base_dir # for backward compatibility
-_base_dir = get_base_dir()
# Save base_dir for use by other modules
-base_dir = _base_dir
+base_dir = get_base_dir()
for arg in sys.argv[1:]:
if arg.startswith(str('-verbose')) or arg == str('-v'):
@@ -1023,7 +1021,7 @@
warning('Skipping loading of user-config.py.')
_fns = []
else:
- _fns = [os.path.join(_base_dir, "user-config.py")]
+ _fns = [os.path.join(base_dir, 'user-config.py')]
for _filename in _fns:
_thislevel += 1
if os.path.exists(_filename):
--
To view, visit https://gerrit.wikimedia.org/r/430895
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I99ebce0ac2edfbb43245001a4eba579fd1800b8d
Gerrit-Change-Number: 430895
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/430877 )
Change subject: [IMPR] Simplify Throttle.drop()
......................................................................
[IMPR] Simplify Throttle.drop()
- drop() is exited by the first IOError exception. It does not make any sense
to have some code parts in the else clause and whereas other parts of the
same logic are dedented. The else is superfluous here.
Change-Id: I65be0367e04dd30be646348c70d94b6912c3282d
---
M pywikibot/throttle.py
1 file changed, 17 insertions(+), 16 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index ab56ac7..abba04f 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -204,22 +204,23 @@
lines = f.readlines()
except IOError:
return
- else:
- now = time.time()
- for line in lines:
- try:
- line = line.split(' ')
- this_pid = int(line[0])
- ptime = int(line[1].split('.')[0])
- this_site = line[2].rstrip()
- except (IndexError, ValueError):
- # Sometimes the file gets corrupted ignore that line
- continue
- if now - ptime <= self.releasepid \
- and this_pid != pid:
- processes.append({'pid': this_pid,
- 'time': ptime,
- 'site': this_site})
+
+ now = time.time()
+ for line in lines:
+ try:
+ line = line.split(' ')
+ this_pid = int(line[0])
+ ptime = int(line[1].split('.')[0])
+ this_site = line[2].rstrip()
+ except (IndexError, ValueError):
+ # Sometimes the file gets corrupted ignore that line
+ continue
+ if now - ptime <= self.releasepid \
+ and this_pid != pid:
+ processes.append({'pid': this_pid,
+ 'time': ptime,
+ 'site': this_site})
+
processes.sort(key=lambda p: p['pid'])
try:
with open(self.ctrlfilename, 'w') as f:
--
To view, visit https://gerrit.wikimedia.org/r/430877
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I65be0367e04dd30be646348c70d94b6912c3282d
Gerrit-Change-Number: 430877
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/430579 )
Change subject: generate_user_files.py: Apply minor code clean-up
......................................................................
generate_user_files.py: Apply minor code clean-up
The global decleration in main function is not needed because base_dir is
not used in that function.
Typo: Change (has_userfile or has_userfile) to (has_userfile or has_passfile).
Change-Id: Ia70323fd2b8c336abb8c6b6f28c00d1ab7c6986e
---
M generate_user_files.py
1 file changed, 1 insertion(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py
index 77bd611..a07abdf 100755
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -414,8 +414,6 @@
@param args: command line arguments
@type args: list of unicode
"""
- global base_dir
-
# set the config family and mylang values to an invalid state so that
# the script can detect that the command line arguments -family & -lang
# were used and and handle_args has updated these config values,
@@ -440,7 +438,7 @@
try:
has_userfile, has_passfile = ask_for_dir_change(force)
- if not (has_userfile or has_userfile):
+ if not (has_userfile or has_passfile):
create_user_config(config.family, config.mylang, username,
force=force)
except KeyboardInterrupt:
--
To view, visit https://gerrit.wikimedia.org/r/430579
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia70323fd2b8c336abb8c6b6f28c00d1ab7c6986e
Gerrit-Change-Number: 430579
Gerrit-PatchSet: 3
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/430835 )
Change subject: Fix regression in generate_user_files.py and generate_family_file.py
......................................................................
Fix regression in generate_user_files.py and generate_family_file.py
The regression was introduced in d3cd1f4e9904e153ac58ca6d12d5c2f57a44d1a3.
Change-Id: Iebc7188f387c7860122417a23925a2432d68d126
---
M generate_family_file.py
M generate_user_files.py
2 files changed, 3 insertions(+), 7 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_family_file.py b/generate_family_file.py
index 80a62d2..2abb768 100755
--- a/generate_family_file.py
+++ b/generate_family_file.py
@@ -15,8 +15,6 @@
import os
import sys
-from pywikibot.site_detect import MWSite as Wiki
-
# creating & retrieving urls
if sys.version_info[0] > 2:
from urllib.parse import urlparse
@@ -24,11 +22,11 @@
else:
from urlparse import urlparse
-
# Disable user-config checks so the family can be created first,
# and then used when generating the user-config
_orig_no_user_config = os.environ.get('PYWIKIBOT2_NO_USER_CONFIG')
os.environ['PYWIKIBOT2_NO_USER_CONFIG'] = '2'
+from pywikibot.site_detect import MWSite as Wiki # noqa: E402
# Reset this flag in case another script is run by pwb after this script
if not _orig_no_user_config:
diff --git a/generate_user_files.py b/generate_user_files.py
index 6ddb9f6..0f46b8c 100755
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -17,13 +17,11 @@
from textwrap import fill
from warnings import warn
-import pywikibot
-from pywikibot import config
-
-
# Disable user-config usage as we are creating it here
_orig_no_user_config = os.environ.get('PYWIKIBOT2_NO_USER_CONFIG')
os.environ['PYWIKIBOT2_NO_USER_CONFIG'] = '2'
+import pywikibot # noqa: E402
+from pywikibot import config # noqa: E402
# Reset this flag in case another script is run by pwb after this script
if not _orig_no_user_config:
--
To view, visit https://gerrit.wikimedia.org/r/430835
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iebc7188f387c7860122417a23925a2432d68d126
Gerrit-Change-Number: 430835
Gerrit-PatchSet: 4
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>