def replace_region_in_article(article_name, regular_expression_pattern, actually_edit, dot_all=False): # needed because # One of the lists of communes is formated such that both # the communes and the catons of the department are picked up # so we neeed to skip the Canton articels # finally a few of the communes are only historical communes and lack the info box # a few others also are already edited # note these still get added to the article list articles_to_skip = ['Saint Barthélemy', 'Acoua'] if article_name[:6] == 'Canton' or article_name in articles_to_skip: return None article_text = get_page_markup(article_name) if not allow_bots(article_text, user_name): return 'blocked for bot edits' new_text, error = replace_region_in_text(article_text, regular_expression_pattern, dot_all=dot_all) if error is not None: return error if actually_edit: edit_page(new_text, article_name, EDIT_PAGE_MESSAGE) return None
def communes_from_list_of_communes(article_name): markup = get_page_markup(article_name) return communes_from_list_of_communes_markup(markup)