jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668698 )
Change subject: [cleanup] deprecate register_family_file function() ......................................................................
[cleanup] deprecate register_family_file function()
deprecate config2.register_family_file function() It can be easily replaced by this setting: 'family_files[family_name] = file_path'
Also drop recently introduced user_families dict
Change-Id: I91662836c735e85d545a4c5c221306cb9f81dd69 --- M pywikibot/config2.py 1 file changed, 11 insertions(+), 12 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py index 91204be..022d88d 100644 --- a/pywikibot/config2.py +++ b/pywikibot/config2.py @@ -47,9 +47,9 @@ from warnings import warn
from pywikibot.__metadata__ import __version__ as pwb_version -from pywikibot.backports import Dict, List, Tuple +from pywikibot.backports import Dict, List, removesuffix, Tuple from pywikibot.logging import error, output, warning -from pywikibot.tools import issue_deprecation_warning +from pywikibot.tools import issue_deprecation_warning, deprecated
OSWIN32 = (sys.platform == 'win32') @@ -388,6 +388,7 @@ family_files = {}
+@deprecated('family_files[family_name] = file_path', since='20210305') def register_family_file(family_name, file_path): """Register a single family class file.
@@ -399,11 +400,11 @@
def register_families_folder(folder_path): """Register all family class files contained in a directory.""" + suffix = '_family.py' for file_name in os.listdir(folder_path): - if file_name.endswith('_family.py'): - family_name = file_name[:-len('_family.py')] - register_family_file(family_name, os.path.join(folder_path, - file_name)) + if file_name.endswith(suffix): + family_name = removesuffix(file_name, suffix) + family_files[family_name] = os.path.join(folder_path, file_name)
# Get the names of all known families, and initialize with empty dictionaries. @@ -568,14 +569,14 @@ # Your private family path may be either an absolute or a relative path. # You may have multiple paths defined in user_families_paths list. # -# You may also define various family files stored in the user_families -# dict. Use the family name as dict key and the path or an url als value. +# You may also define various family files stored directly in +# family_files dict. Use the family name as dict key and the path or an +# url as value. # # samples: +# family_files['mywiki'] = 'https://de.wikipedia.org' # user_families_paths = ['data/families'] -# user_families = {'mywiki': 'https://de.wikipedia.org%27%7D user_families_paths = [] # type: List[str] -user_families = {} # type: dict
# ############# SOLVE_DISAMBIGUATION SETTINGS ############ # @@ -1020,8 +1021,6 @@ # Setup custom family files for file_path in user_families_paths: register_families_folder(file_path) -for name, path in user_families.items(): - register_family_file(name, path) # # When called as main program, list all configuration variables #
pywikibot-commits@lists.wikimedia.org