Skip to content

Commit 0b5d21d

Browse files
authored
Merge pull request #48 from c2corg/update-black
Update black to its last version
2 parents f2683e7 + 50080d7 commit 0b5d21d

6 files changed

Lines changed: 60 additions & 47 deletions

File tree

campbot/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ def main(args):
9999

100100
elif args["report"]:
101101
get_campbot(args).report(
102-
args["<url_or_file>"], lang=args["<lang>"],
102+
args["<url_or_file>"],
103+
lang=args["<lang>"],
103104
)
104105

105106
elif args["clean"]:

campbot/checkers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def get_fixed_tests(lang):
280280

281281

282282
def get_document_tests(lang):
283-
""" Returns a list of tests that can be run on a single document"""
283+
"""Returns a list of tests that can be run on a single document"""
284284

285285
return [
286286
HistoryTest(lang),

campbot/core.py

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def put(self, url, data):
9797

9898
class WikiBot(BaseBot):
9999
"""
100-
Get functions for all camptocamp.org wiki
100+
Get functions for all camptocamp.org wiki
101101
"""
102102

103103
@property
@@ -414,22 +414,22 @@ def get_participants(self, url):
414414
class CampBot(object):
415415
"""
416416
CampBot() object is the main class. You must instanciate only one instance of it.
417-
It contains two property :
417+
It contains two property :
418418
419419
* ``wiki`` for interacting with camptocamp.org wiki
420420
* ``forum`` for interacting with camptocamp.org forum
421421
"""
422422

423423
def __init__(self, min_delay=None, proxies=None, use_demo=False):
424424
"""
425-
:param min_delay: in seconds, minimum delay between each request
426-
:param proxies: key-url dictionary
427-
:param use_demo: Boolean, True if you want to use C2C demo API
428-
429-
:Example:
430-
431-
>>> bot = CampBot(min_delay=10, proxies={"https": "https://login:password@proxy.com"})
432-
425+
:param min_delay: in seconds, minimum delay between each request
426+
:param proxies: key-url dictionary
427+
:param use_demo: Boolean, True if you want to use C2C demo API
428+
429+
:Example:
430+
431+
>>> bot = CampBot(min_delay=10, proxies={"https": "https://login:password@proxy.com"})
432+
433433
"""
434434

435435
domain = "camptocamp" if not use_demo else "demov6.camptocamp"
@@ -459,12 +459,12 @@ def __init__(self, min_delay=None, proxies=None, use_demo=False):
459459

460460
def login(self, login, password):
461461
"""
462-
Login to camptocamp.org, mandatory for write actions.
463-
It also sign-in to forum.
462+
Login to camptocamp.org, mandatory for write actions.
463+
It also sign-in to forum.
464+
465+
:param login: bot login used to sign-in (not the numerical ID)
466+
:param password: bot password
464467
465-
:param login: bot login used to sign-in (not the numerical ID)
466-
:param password: bot password
467-
468468
"""
469469

470470
logging.info(f"Logging to wiki with account {login}...")
@@ -527,12 +527,12 @@ def clean(
527527
self, url_or_filename, lang, ask_before_saving, thread_url, clean_bbcode=False
528528
):
529529
"""
530-
Clean a set of document.
530+
Clean a set of document.
531531
532-
:param url_or_filename: Camptocamp.org URL, or filename
533-
:param lang: lang identifier
534-
:param ask_before_saving: Boolean
535-
:param clean_bbcode: Boolean
532+
:param url_or_filename: Camptocamp.org URL, or filename
533+
:param lang: lang identifier
534+
:param ask_before_saving: Boolean
535+
:param clean_bbcode: Boolean
536536
537537
"""
538538

@@ -545,10 +545,10 @@ def clean(
545545

546546
def report(self, url_or_filename, lang):
547547
"""
548-
Make quality report on a set of document.
548+
Make quality report on a set of document.
549549
550-
:param url_or_filename: Camptocamp.org URL, or filename
551-
:param langs: comma-separated list of lang identifiers
550+
:param url_or_filename: Camptocamp.org URL, or filename
551+
:param langs: comma-separated list of lang identifiers
552552
"""
553553

554554
documents = [d for d in self.get_documents(url_or_filename)]
@@ -627,7 +627,12 @@ def _process_documents(
627627

628628
for processor in processors:
629629
if processor.ready_for_production:
630-
if processor(document, [lang,]):
630+
if processor(
631+
document,
632+
[
633+
lang,
634+
],
635+
):
631636
messages.append(processor.comment)
632637
must_save = True
633638

@@ -655,10 +660,10 @@ def _process_documents(
655660

656661
def export(self, url, filename=None):
657662
"""
658-
Export all document given by a camptocamp.org url
663+
Export all document given by a camptocamp.org url
659664
660-
:param url: Camptocamp.org URL
661-
:param filename: Output file name. Defaut : <document_type>.csv
665+
:param url: Camptocamp.org URL
666+
:param filename: Output file name. Defaut : <document_type>.csv
662667
663668
"""
664669

@@ -702,11 +707,11 @@ def export(self, url, filename=None):
702707

703708
def export_contributions(self, starts=None, ends=None, filename=None):
704709
"""
705-
Export all document given by a camptocamp.org url
710+
Export all document given by a camptocamp.org url
706711
707-
:param starts: Start date, default is now minus 24 hours
708-
:param ends: default is now
709-
:param filename: Output file name. Defaut : contributions.csv
712+
:param starts: Start date, default is now minus 24 hours
713+
:param ends: default is now
714+
:param filename: Output file name. Defaut : contributions.csv
710715
711716
"""
712717

campbot/objects.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class Locale(BotObject):
149149
def get_title(self):
150150
"""
151151
Get the title, with prefix if it exists.
152-
152+
153153
:return: String, pretty title
154154
"""
155155

@@ -178,7 +178,7 @@ def get_locale_fields(self):
178178
def get_length(self):
179179
"""
180180
Get text length
181-
181+
182182
:return: Integer, number of characters
183183
"""
184184

@@ -209,7 +209,7 @@ def __init__(self, campbot, data):
209209

210210
def get_url(self, lang=None):
211211
"""
212-
:return: camptocamp.org URL.
212+
:return: camptocamp.org URL.
213213
"""
214214

215215
return "{}/{}/{}{}".format(
@@ -221,7 +221,7 @@ def get_url(self, lang=None):
221221

222222
def get_history_url(self, lang):
223223
"""
224-
224+
225225
:return: camptocamp.org version list URL
226226
"""
227227

@@ -236,8 +236,8 @@ def get_title(self, lang):
236236
def get_locale(self, lang):
237237
"""
238238
:param lang: fr, en, de ...
239-
240-
:return: String, or None if locale does not exists in this lang
239+
240+
:return: String, or None if locale does not exists in this lang
241241
"""
242242

243243
if "locales" not in self:
@@ -250,9 +250,9 @@ def get_locale(self, lang):
250250
def search(self, patterns, lang):
251251
"""
252252
Search a pattern (regular expression)
253-
253+
254254
:param lang: fr, de, en...
255-
255+
256256
:return: True if pattern is found, False otherwise
257257
"""
258258

@@ -277,10 +277,10 @@ def _build_payload(self, message):
277277
def save(self, message, ask_before_saving=True):
278278
"""
279279
Save object to camptocamp.org. Bot must be authentified.
280-
280+
281281
:param message: Modification comment
282282
:param ask_before_saving: Boolean, ask user before saing document
283-
283+
284284
:return: raw request response, useless.
285285
"""
286286

campbot/processors/cleaners.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,18 @@ def build_pattern(url_ending):
173173
)
174174

175175
self.modifiers = [
176-
Converter(build_pattern(r"(\d+)/?#?\)"), r"[[\2/\3|\1]]",),
177176
Converter(
178-
build_pattern(r"(\d+)/([a-z]{2})(/[\w-]*)?#?\)"), r"[[\2/\3|\1]]",
177+
build_pattern(r"(\d+)/?#?\)"),
178+
r"[[\2/\3|\1]]",
179+
),
180+
Converter(
181+
build_pattern(r"(\d+)/([a-z]{2})(/[\w-]*)?#?\)"),
182+
r"[[\2/\3|\1]]",
183+
),
184+
Converter(
185+
build_pattern(r"(\d+)#([a-z0-9\-]+)\)"),
186+
r"[[\2/\3#\4|\1]]",
179187
),
180-
Converter(build_pattern(r"(\d+)#([a-z0-9\-]+)\)"), r"[[\2/\3#\4|\1]]",),
181188
Converter(
182189
build_pattern(r"(\d+)/([a-z]{2})(/[\w-]*)?#([a-z0-9\-]+)\)"),
183190
r"[[\2/\3/\4#\6|\1]]",

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ pytest
22
pytest-cov
33
wheel
44
setuptools
5-
black==19.10b0
5+
black==22.1.0

0 commit comments

Comments
 (0)