diff --git a/campbot/__main__.py b/campbot/__main__.py index c08876a..8fb35c3 100644 --- a/campbot/__main__.py +++ b/campbot/__main__.py @@ -99,7 +99,8 @@ def main(args): elif args["report"]: get_campbot(args).report( - args[""], lang=args[""], + args[""], + lang=args[""], ) elif args["clean"]: diff --git a/campbot/checkers.py b/campbot/checkers.py index e4c3ee5..6dfa841 100644 --- a/campbot/checkers.py +++ b/campbot/checkers.py @@ -280,7 +280,7 @@ def get_fixed_tests(lang): def get_document_tests(lang): - """ Returns a list of tests that can be run on a single document""" + """Returns a list of tests that can be run on a single document""" return [ HistoryTest(lang), diff --git a/campbot/core.py b/campbot/core.py index eb7efe5..8aa49be 100644 --- a/campbot/core.py +++ b/campbot/core.py @@ -97,7 +97,7 @@ def put(self, url, data): class WikiBot(BaseBot): """ - Get functions for all camptocamp.org wiki + Get functions for all camptocamp.org wiki """ @property @@ -414,7 +414,7 @@ def get_participants(self, url): class CampBot(object): """ CampBot() object is the main class. You must instanciate only one instance of it. - It contains two property : + It contains two property : * ``wiki`` for interacting with camptocamp.org wiki * ``forum`` for interacting with camptocamp.org forum @@ -422,14 +422,14 @@ class CampBot(object): def __init__(self, min_delay=None, proxies=None, use_demo=False): """ - :param min_delay: in seconds, minimum delay between each request - :param proxies: key-url dictionary - :param use_demo: Boolean, True if you want to use C2C demo API - - :Example: - - >>> bot = CampBot(min_delay=10, proxies={"https": "https://login:password@proxy.com"}) - + :param min_delay: in seconds, minimum delay between each request + :param proxies: key-url dictionary + :param use_demo: Boolean, True if you want to use C2C demo API + + :Example: + + >>> bot = CampBot(min_delay=10, proxies={"https": "https://login:password@proxy.com"}) + """ domain = "camptocamp" if not use_demo else "demov6.camptocamp" @@ -459,12 +459,12 @@ def __init__(self, min_delay=None, proxies=None, use_demo=False): def login(self, login, password): """ - Login to camptocamp.org, mandatory for write actions. - It also sign-in to forum. + Login to camptocamp.org, mandatory for write actions. + It also sign-in to forum. + + :param login: bot login used to sign-in (not the numerical ID) + :param password: bot password - :param login: bot login used to sign-in (not the numerical ID) - :param password: bot password - """ logging.info(f"Logging to wiki with account {login}...") @@ -527,12 +527,12 @@ def clean( self, url_or_filename, lang, ask_before_saving, thread_url, clean_bbcode=False ): """ - Clean a set of document. + Clean a set of document. - :param url_or_filename: Camptocamp.org URL, or filename - :param lang: lang identifier - :param ask_before_saving: Boolean - :param clean_bbcode: Boolean + :param url_or_filename: Camptocamp.org URL, or filename + :param lang: lang identifier + :param ask_before_saving: Boolean + :param clean_bbcode: Boolean """ @@ -545,10 +545,10 @@ def clean( def report(self, url_or_filename, lang): """ - Make quality report on a set of document. + Make quality report on a set of document. - :param url_or_filename: Camptocamp.org URL, or filename - :param langs: comma-separated list of lang identifiers + :param url_or_filename: Camptocamp.org URL, or filename + :param langs: comma-separated list of lang identifiers """ documents = [d for d in self.get_documents(url_or_filename)] @@ -627,7 +627,12 @@ def _process_documents( for processor in processors: if processor.ready_for_production: - if processor(document, [lang,]): + if processor( + document, + [ + lang, + ], + ): messages.append(processor.comment) must_save = True @@ -655,10 +660,10 @@ def _process_documents( def export(self, url, filename=None): """ - Export all document given by a camptocamp.org url + Export all document given by a camptocamp.org url - :param url: Camptocamp.org URL - :param filename: Output file name. Defaut : .csv + :param url: Camptocamp.org URL + :param filename: Output file name. Defaut : .csv """ @@ -702,11 +707,11 @@ def export(self, url, filename=None): def export_contributions(self, starts=None, ends=None, filename=None): """ - Export all document given by a camptocamp.org url + Export all document given by a camptocamp.org url - :param starts: Start date, default is now minus 24 hours - :param ends: default is now - :param filename: Output file name. Defaut : contributions.csv + :param starts: Start date, default is now minus 24 hours + :param ends: default is now + :param filename: Output file name. Defaut : contributions.csv """ diff --git a/campbot/objects.py b/campbot/objects.py index 1b5acdf..281550c 100644 --- a/campbot/objects.py +++ b/campbot/objects.py @@ -149,7 +149,7 @@ class Locale(BotObject): def get_title(self): """ Get the title, with prefix if it exists. - + :return: String, pretty title """ @@ -178,7 +178,7 @@ def get_locale_fields(self): def get_length(self): """ Get text length - + :return: Integer, number of characters """ @@ -209,7 +209,7 @@ def __init__(self, campbot, data): def get_url(self, lang=None): """ - :return: camptocamp.org URL. + :return: camptocamp.org URL. """ return "{}/{}/{}{}".format( @@ -221,7 +221,7 @@ def get_url(self, lang=None): def get_history_url(self, lang): """ - + :return: camptocamp.org version list URL """ @@ -236,8 +236,8 @@ def get_title(self, lang): def get_locale(self, lang): """ :param lang: fr, en, de ... - - :return: String, or None if locale does not exists in this lang + + :return: String, or None if locale does not exists in this lang """ if "locales" not in self: @@ -250,9 +250,9 @@ def get_locale(self, lang): def search(self, patterns, lang): """ Search a pattern (regular expression) - + :param lang: fr, de, en... - + :return: True if pattern is found, False otherwise """ @@ -277,10 +277,10 @@ def _build_payload(self, message): def save(self, message, ask_before_saving=True): """ Save object to camptocamp.org. Bot must be authentified. - + :param message: Modification comment :param ask_before_saving: Boolean, ask user before saing document - + :return: raw request response, useless. """ diff --git a/campbot/processors/cleaners.py b/campbot/processors/cleaners.py index 29fba65..58bf28e 100644 --- a/campbot/processors/cleaners.py +++ b/campbot/processors/cleaners.py @@ -173,11 +173,18 @@ def build_pattern(url_ending): ) self.modifiers = [ - Converter(build_pattern(r"(\d+)/?#?\)"), r"[[\2/\3|\1]]",), Converter( - build_pattern(r"(\d+)/([a-z]{2})(/[\w-]*)?#?\)"), r"[[\2/\3|\1]]", + build_pattern(r"(\d+)/?#?\)"), + r"[[\2/\3|\1]]", + ), + Converter( + build_pattern(r"(\d+)/([a-z]{2})(/[\w-]*)?#?\)"), + r"[[\2/\3|\1]]", + ), + Converter( + build_pattern(r"(\d+)#([a-z0-9\-]+)\)"), + r"[[\2/\3#\4|\1]]", ), - Converter(build_pattern(r"(\d+)#([a-z0-9\-]+)\)"), r"[[\2/\3#\4|\1]]",), Converter( build_pattern(r"(\d+)/([a-z]{2})(/[\w-]*)?#([a-z0-9\-]+)\)"), r"[[\2/\3/\4#\6|\1]]", diff --git a/dev-requirements.txt b/dev-requirements.txt index c724ec4..8f372a3 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -2,4 +2,4 @@ pytest pytest-cov wheel setuptools -black==19.10b0 \ No newline at end of file +black==22.1.0 \ No newline at end of file