family
— MediaWiki families#
Objects representing MediaWiki families.
- family.AutoFamily(name, url)[source]#
Family that automatically loads the site configuration.
- Parameters:
name (str) – Name for the family
url (str) – API endpoint URL of the wiki
- Returns:
Generated family class
- Return type:
- class family.Family[source]#
Bases:
object
Parent singleton class for all wiki families.
Allocator.
- alphabetic = ['ace', 'kbd', 'ady', 'af', 'ak', 'als', 'alt', 'am', 'smn', 'ang', 'ab', 'ar', 'an', 'arc', 'roa-rup', 'frp', 'as', 'ast', 'atj', 'awa', 'gn', 'av', 'ay', 'az', 'ban', 'bm', 'bn', 'bjn', 'zh-min-nan', 'nan', 'map-bms', 'ba', 'be', 'be-tarask', 'mnw', 'bh', 'bcl', 'bi', 'bg', 'bar', 'blk', 'bo', 'bs', 'br', 'bxr', 'ca', 'cv', 'ceb', 'cs', 'ch', 'cbk-zam', 'ny', 'sn', 'tum', 'cho', 'co', 'cy', 'dag', 'da', 'dk', 'ary', 'pdc', 'de', 'dv', 'nv', 'dsb', 'dty', 'dz', 'mh', 'et', 'el', 'eml', 'en', 'myv', 'es', 'eo', 'ext', 'eu', 'ee', 'fa', 'hif', 'fo', 'fr', 'fy', 'ff', 'fur', 'ga', 'gv', 'gag', 'gd', 'gl', 'gan', 'ki', 'glk', 'guw', 'gu', 'gor', 'got', 'hak', 'xal', 'ko', 'ha', 'haw', 'hy', 'hi', 'ho', 'hsb', 'hr', 'hyw', 'io', 'ig', 'ilo', 'inh', 'bpy', 'id', 'ia', 'ie', 'iu', 'ik', 'os', 'xh', 'zu', 'is', 'it', 'he', 'jv', 'kbp', 'kl', 'kn', 'kr', 'pam', 'krc', 'ka', 'ks', 'csb', 'kk', 'kw', 'rw', 'rn', 'sw', 'kv', 'kg', 'gom', 'avk', 'ht', 'gcr', 'ku', 'kj', 'ky', 'mrj', 'lld', 'lad', 'lbe', 'lo', 'ltg', 'la', 'lv', 'lb', 'lez', 'lfn', 'lt', 'lij', 'li', 'ln', 'olo', 'jbo', 'lg', 'lmo', 'lrc', 'mad', 'hu', 'mai', 'mk', 'mg', 'ml', 'mt', 'mi', 'mr', 'xmf', 'arz', 'mzn', 'mni', 'ms', 'min', 'cdo', 'mwl', 'mdf', 'mo', 'mn', 'mus', 'my', 'nah', 'na', 'fj', 'nl', 'nds-nl', 'cr', 'ne', 'new', 'nia', 'ja', 'nqo', 'nap', 'ce', 'frr', 'pih', 'no', 'nb', 'nn', 'nrm', 'nov', 'ii', 'oc', 'mhr', 'or', 'om', 'ng', 'hz', 'uz', 'pa', 'pi', 'pfl', 'pag', 'ami', 'pnb', 'pap', 'ps', 'jam', 'koi', 'km', 'pcd', 'pcm', 'pms', 'pwn', 'tpi', 'nds', 'pl', 'pnt', 'pt', 'aa', 'kaa', 'crh', 'ty', 'ksh', 'ro', 'rmy', 'rm', 'qu', 'rue', 'ru', 'sah', 'szy', 'se', 'sm', 'sa', 'sg', 'sat', 'skr', 'sc', 'sco', 'trv', 'stq', 'st', 'nso', 'tn', 'sq', 'scn', 'si', 'simple', 'sd', 'ss', 'sk', 'sl', 'cu', 'szl', 'so', 'ckb', 'srn', 'sr', 'sh', 'su', 'fi', 'sv', 'shi', 'tl', 'shn', 'ta', 'kab', 'roa-tara', 'tt', 'tay', 'te', 'tet', 'th', 'ti', 'tg', 'to', 'chr', 'chy', 've', 'tcy', 'tr', 'azb', 'tk', 'tw', 'kcg', 'tyv', 'din', 'udm', 'bug', 'uk', 'ur', 'ug', 'za', 'vec', 'vep', 'vi', 'vo', 'fiu-vro', 'wa', 'zh-classical', 'vls', 'war', 'wo', 'wuu', 'ts', 'yi', 'yo', 'zh-yue', 'diq', 'zea', 'bat-smg', 'zh', 'zh-tw', 'zh-cn']#
- alphabetic_revised = ['ace', 'ady', 'kbd', 'af', 'ak', 'als', 'alt', 'kcg', 'am', 'smn', 'ang', 'ab', 'ar', 'an', 'arc', 'roa-rup', 'frp', 'as', 'ast', 'atj', 'awa', 'gn', 'av', 'ay', 'az', 'bjn', 'id', 'ms', 'ban', 'bm', 'bn', 'zh-min-nan', 'nan', 'map-bms', 'jv', 'su', 'ba', 'min', 'be', 'be-tarask', 'mnw', 'mad', 'bh', 'bcl', 'bi', 'bar', 'blk', 'bo', 'bs', 'br', 'bug', 'bg', 'bxr', 'ca', 'ceb', 'cv', 'cs', 'ch', 'cbk-zam', 'ny', 'sn', 'tum', 'cho', 'co', 'cy', 'dag', 'da', 'dk', 'ary', 'pdc', 'de', 'dv', 'nv', 'dsb', 'na', 'dty', 'dz', 'mh', 'et', 'el', 'eml', 'en', 'myv', 'es', 'eo', 'ext', 'eu', 'ee', 'fa', 'hif', 'fo', 'fr', 'fy', 'ff', 'fur', 'ga', 'gv', 'sm', 'gag', 'gd', 'gl', 'gan', 'ki', 'glk', 'guw', 'gu', 'got', 'hak', 'xal', 'ko', 'ha', 'haw', 'hy', 'hi', 'ho', 'hsb', 'hr', 'hyw', 'io', 'ig', 'ilo', 'inh', 'bpy', 'ia', 'ie', 'iu', 'ik', 'os', 'xh', 'zu', 'is', 'it', 'he', 'kl', 'kn', 'kr', 'pam', 'ka', 'ks', 'csb', 'kk', 'kw', 'rw', 'ky', 'rn', 'mrj', 'sw', 'kv', 'kg', 'gom', 'avk', 'gor', 'ht', 'gcr', 'ku', 'shn', 'kj', 'lld', 'lad', 'lbe', 'lez', 'lfn', 'lo', 'la', 'ltg', 'lv', 'to', 'lb', 'lt', 'lij', 'li', 'ln', 'nia', 'olo', 'jbo', 'lg', 'lmo', 'lrc', 'hu', 'mai', 'mk', 'mg', 'ml', 'krc', 'mt', 'mi', 'mr', 'xmf', 'arz', 'mzn', 'mni', 'cdo', 'mwl', 'koi', 'mdf', 'mo', 'mn', 'mus', 'my', 'nah', 'fj', 'nl', 'nds-nl', 'cr', 'ne', 'new', 'ja', 'nqo', 'nap', 'ce', 'frr', 'pih', 'no', 'nb', 'nn', 'nrm', 'nov', 'ii', 'oc', 'mhr', 'or', 'om', 'ng', 'hz', 'uz', 'pa', 'pi', 'pfl', 'pag', 'ami', 'pnb', 'pap', 'ps', 'jam', 'km', 'pcd', 'pcm', 'pms', 'pwn', 'nds', 'pl', 'pnt', 'pt', 'aa', 'kaa', 'crh', 'ty', 'ksh', 'ro', 'rmy', 'rm', 'qu', 'ru', 'rue', 'sah', 'szy', 'se', 'sa', 'sg', 'sat', 'skr', 'sc', 'sco', 'trv', 'stq', 'st', 'nso', 'tn', 'sq', 'scn', 'si', 'simple', 'sd', 'ss', 'sk', 'sl', 'cu', 'szl', 'so', 'ckb', 'srn', 'sr', 'sh', 'fi', 'sv', 'shi', 'tl', 'ta', 'kab', 'kbp', 'roa-tara', 'tt', 'tay', 'te', 'tet', 'th', 'vi', 'ti', 'tg', 'tpi', 'chr', 'chy', 've', 'tcy', 'tr', 'azb', 'tk', 'tw', 'tyv', 'din', 'udm', 'uk', 'ur', 'ug', 'za', 'vec', 'vep', 'vo', 'fiu-vro', 'wa', 'zh-classical', 'vls', 'war', 'wo', 'wuu', 'ts', 'yi', 'yo', 'zh-yue', 'diq', 'zea', 'bat-smg', 'zh', 'zh-tw', 'zh-cn']#
- archived_page_templates: Dict[str, Tuple[str, ...]] = {}#
- base_url(code, uri, protocol=None)[source]#
Prefix uri with port and hostname.
- Parameters:
code (str) – The site code
uri (str) – The absolute path after the hostname
protocol – The protocol which is used. If None it’ll determine the protocol from the code.
- Returns:
The full URL ending with uri
- Return type:
str
- categories_last: List[str] = []#
- category_attop: List[str] = []#
- category_on_one_line: List[str] = []#
- category_redirect_templates = {'_default': []}#
- category_redirects(code, fallback='_default')[source]#
Return list of category redirect templates.
- Parameters:
fallback (str) –
- category_text_separator = '\n\n'#
- codes = {}#
- cross_allowed: List[str] = []#
- cross_projects = []#
- cross_projects_cookie_username = 'centralauth_User'#
- cross_projects_cookies = ['centralauth_Session', 'centralauth_Token', 'centralauth_User']#
- crossnamespace = {}#
- disambcatname: Dict[str, str] = {}#
- disambig(code, fallback='_default')[source]#
Return list of disambiguation templates.
- Parameters:
fallback (str) –
- disambiguationTemplates = {'_default': []}#
- domains = {}#
- edit_restricted_templates: Dict[str, Tuple[str, ...]] = {}#
- from_url(url)[source]#
Return whether this family matches the given url.
It is first checking if a domain of this family is in the domain of the URL. If that is the case it’s checking all codes and verifies that a path generated via
APISite.articlepath
andFamily.path
matches the path of the URL together with the hostname for that code.It is using
Family.domains
to first check if a domain applies and then iterates overFamily.codes
to actually determine which code applies.- Parameters:
url (str) – the URL which may contain a
$1
. If it’s missing it is assumed to be at the end.- Returns:
The language code of the url. None if that url is not from this family.
- Raises:
RuntimeError – When there are multiple languages in this family which would work with the given URL.
- Return type:
Optional[str]
- fyinterwiki = ['aa', 'ab', 'ace', 'ady', 'af', 'ay', 'ak', 'als', 'alt', 'am', 'ami', 'an', 'ang', 'ar', 'arc', 'ary', 'arz', 'as', 'ast', 'atj', 'av', 'avk', 'awa', 'az', 'azb', 'ba', 'ban', 'bar', 'bat-smg', 'bcl', 'be', 'be-tarask', 'bg', 'bh', 'bi', 'bjn', 'blk', 'bm', 'bn', 'bo', 'bpy', 'br', 'bs', 'bug', 'bxr', 'ca', 'cbk-zam', 'cdo', 'ce', 'ceb', 'ch', 'chy', 'cho', 'chr', 'cy', 'ckb', 'co', 'cr', 'crh', 'cs', 'csb', 'cu', 'cv', 'da', 'dag', 'de', 'din', 'diq', 'dk', 'dsb', 'dty', 'dv', 'dz', 'ee', 'el', 'eml', 'en', 'eo', 'es', 'et', 'eu', 'ext', 'fa', 'ff', 'fi', 'fy', 'fiu-vro', 'fj', 'fo', 'fr', 'frp', 'frr', 'fur', 'ga', 'gag', 'gan', 'gcr', 'gd', 'gl', 'glk', 'gn', 'gom', 'gor', 'got', 'gu', 'guw', 'gv', 'ha', 'hak', 'haw', 'he', 'hi', 'hy', 'hif', 'hyw', 'ho', 'hr', 'hsb', 'ht', 'hu', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'yi', 'ik', 'ilo', 'inh', 'io', 'yo', 'is', 'it', 'iu', 'ja', 'jam', 'jbo', 'jv', 'ka', 'kaa', 'kab', 'kbd', 'kbp', 'kcg', 'kg', 'ki', 'ky', 'kj', 'kk', 'kl', 'km', 'kn', 'ko', 'koi', 'kr', 'krc', 'ks', 'ksh', 'ku', 'kv', 'kw', 'la', 'lad', 'lb', 'lbe', 'lez', 'lfn', 'lg', 'li', 'lij', 'lld', 'lmo', 'ln', 'lo', 'lrc', 'lt', 'ltg', 'lv', 'mad', 'mai', 'map-bms', 'mdf', 'mg', 'mh', 'mhr', 'mi', 'my', 'min', 'myv', 'mk', 'ml', 'mn', 'mni', 'mnw', 'mo', 'mr', 'mrj', 'ms', 'mt', 'mus', 'mwl', 'mzn', 'na', 'nah', 'nan', 'nap', 'nds', 'nds-nl', 'ne', 'new', 'ng', 'ny', 'nia', 'nl', 'nn', 'no', 'nov', 'nqo', 'nrm', 'nso', 'nv', 'oc', 'olo', 'om', 'or', 'os', 'pa', 'pag', 'pam', 'pap', 'pcd', 'pcm', 'pdc', 'pfl', 'pi', 'pih', 'pl', 'pms', 'pnb', 'pnt', 'ps', 'pt', 'pwn', 'qu', 'rm', 'rmy', 'rn', 'ro', 'roa-rup', 'roa-tara', 'ru', 'rue', 'rw', 'sa', 'sah', 'sat', 'sc', 'scn', 'sco', 'sd', 'se', 'sg', 'sh', 'shi', 'shn', 'si', 'simple', 'sk', 'skr', 'sl', 'sm', 'smn', 'sn', 'so', 'sq', 'sr', 'srn', 'ss', 'st', 'stq', 'su', 'sv', 'sw', 'szy', 'szl', 'ta', 'tay', 'tcy', 'te', 'tet', 'tg', 'th', 'ti', 'ty', 'tyv', 'tk', 'tl', 'tn', 'to', 'tpi', 'tr', 'trv', 'ts', 'tt', 'tum', 'tw', 'udm', 'ug', 'uk', 'ur', 'uz', 've', 'vec', 'vep', 'vi', 'vls', 'vo', 'wa', 'war', 'wo', 'wuu', 'xal', 'xh', 'xmf', 'za', 'zea', 'zh', 'zh-classical', 'zh-cn', 'zh-yue', 'zh-min-nan', 'zh-tw', 'zu']#
- get_address(code, title)[source]#
Return the path to title using index.php with redirects disabled.
- Return type:
str
- get_archived_page_templates(code)[source]#
Return tuple of archived page templates.
New in version 3.0.
- get_edit_restricted_templates(code)[source]#
Return tuple of edit restricted templates.
New in version 3.0.
- instance#
Get the singleton instance.
- interwiki_attop: List[str] = []#
- interwiki_forward = None#
- interwiki_on_one_line: List[str] = []#
- interwiki_putfirst = {}#
- interwiki_removals: List[str] = []#
- interwiki_replacements: Dict[str, str] = {}#
- interwiki_text_separator = '\n\n'#
- langs: Dict[str, str] = {}#
- language_groups = {'arab': ['ar', 'ary', 'arz', 'azb', 'ckb', 'fa', 'glk', 'ks', 'lrc', 'mzn', 'ps', 'sd', 'ur', 'ha', 'kk', 'ku', 'pnb', 'ug'], 'chinese': ['wuu', 'zh', 'zh-classical', 'zh-yue', 'gan', 'ii', 'ja', 'za'], 'cyril': ['ab', 'av', 'ba', 'be', 'be-tarask', 'bg', 'bxr', 'ce', 'cu', 'cv', 'kbd', 'koi', 'kv', 'ky', 'mk', 'lbe', 'mdf', 'mn', 'mo', 'myv', 'mhr', 'mrj', 'os', 'ru', 'rue', 'sah', 'tg', 'tk', 'udm', 'uk', 'xal', 'ha', 'kk', 'sh', 'sr', 'tt'], 'grec': ['el', 'grc', 'pnt'], 'latin': ['aa', 'ace', 'af', 'ak', 'als', 'an', 'ang', 'ast', 'ay', 'bar', 'bat-smg', 'bcl', 'bi', 'bm', 'br', 'bs', 'ca', 'cbk-zam', 'cdo', 'ceb', 'ch', 'cho', 'chy', 'co', 'crh', 'cs', 'csb', 'cy', 'da', 'de', 'diq', 'dsb', 'ee', 'eml', 'en', 'eo', 'es', 'et', 'eu', 'ext', 'ff', 'fi', 'fiu-vro', 'fj', 'fo', 'fr', 'frp', 'frr', 'fur', 'fy', 'ga', 'gag', 'gd', 'gl', 'gn', 'gv', 'hak', 'haw', 'hif', 'ho', 'hr', 'hsb', 'ht', 'hu', 'hz', 'ia', 'id', 'ie', 'ig', 'ik', 'ilo', 'io', 'is', 'it', 'jbo', 'jv', 'kaa', 'kab', 'kg', 'ki', 'kj', 'kl', 'kr', 'ksh', 'kw', 'la', 'lad', 'lb', 'lg', 'li', 'lij', 'lmo', 'ln', 'lt', 'ltg', 'lv', 'map-bms', 'mg', 'mh', 'mi', 'ms', 'mt', 'mus', 'mwl', 'na', 'nah', 'nap', 'nds', 'nds-nl', 'ng', 'nl', 'nn', 'no', 'nov', 'nrm', 'nv', 'ny', 'oc', 'om', 'pag', 'pam', 'pap', 'pcd', 'pdc', 'pfl', 'pih', 'pl', 'pms', 'pt', 'qu', 'rm', 'rn', 'ro', 'roa-rup', 'roa-tara', 'rw', 'sc', 'scn', 'sco', 'se', 'sg', 'simple', 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'srn', 'ss', 'st', 'stq', 'su', 'sv', 'sw', 'szl', 'tet', 'tl', 'tn', 'to', 'tpi', 'tr', 'ts', 'tum', 'tw', 'ty', 'uz', 've', 'vec', 'vi', 'vls', 'vo', 'wa', 'war', 'wo', 'xh', 'yo', 'zea', 'zh-min-nan', 'zu', 'az', 'chr', 'ckb', 'ha', 'iu', 'kk', 'ku', 'rmy', 'sh', 'sr', 'tt', 'ug', 'za'], 'scand': ['da', 'fo', 'is', 'nb', 'nn', 'no', 'sv']}#
- languages_by_size: List[str] = []#
- ldapDomain = ()#
- linktrail(code)[source]#
Return regex for trailing chars displayed as part of a link.
Returns a string, not a compiled regular expression object.
Deprecated since version 7.3.
- Parameters:
code (str) –
- Return type:
str
- static load(fam=None)[source]#
Import the named family.
- Parameters:
fam (Optional[str]) – family name (if omitted, uses the configured default)
- Returns:
a Family instance configured for the named family.
- Raises:
pywikibot.exceptions.UnknownFamilyError – family not known
- name = None#
- property obsolete: Dict[str, Optional[str]]#
Old codes that are not part of the family.
Interwiki replacements override removals for the same code.
- Returns:
mapping of old codes to new codes (or None)
- post_get_convert(site, getText)[source]#
Do a conversion on the retrieved text from the Wiki.
For example a X-conversion in Esperanto https://en.wikipedia.org/wiki/Esperanto_orthography#X-system.
- pre_put_convert(site, putText)[source]#
Do a conversion on the text to insert on the Wiki.
For example a X-conversion in Esperanto https://en.wikipedia.org/wiki/Esperanto_orthography#X-system.
- protocol(code)[source]#
The protocol to use to connect to the site.
May be overridden to return ‘https’. Other protocols are not supported.
- Parameters:
code (str) – language code
- Returns:
protocol that this family uses
- Return type:
str
- scriptpath(code)[source]#
The prefix used to locate scripts on this wiki.
This is the value displayed when you enter {{SCRIPTPATH}} on a wiki page (often displayed at [[Help:Variables]] if the wiki has copied the master help page correctly).
The default value is the one used on Wikimedia Foundation wikis, but needs to be overridden in the family file for any wiki that uses a different value.
- Parameters:
code (str) – Site code
- Raises:
KeyError – code is not recognised
- Returns:
URL path without ending ‘/’
- Return type:
str
Return the shared image repository, if any.
- title_delimiter_and_aliases = ' _'#
Titles usually are delimited by a space and the alias is replaced to this delimiter; e.g. “Main page” is the title with spaces as delimiters but “Main_page” also works. Other families may have different settings.
Note
The first character is used as delimiter, the others are aliases.
Warning
This attribute is used within
re.sub()
method. Use escape sequence if necessaryNew in version 7.0.
- use_hard_category_redirects = []#
- verify_SSL_certificate(code)[source]#
Return whether a HTTPS certificate should be verified.
New in version 5.3: renamed from ignore_certificate_error
- Parameters:
code (str) – language code
- Returns:
flag to verify the SSL certificate; set it to False to allow access if certificate has an error.
- Return type:
bool
- class family.FandomFamily[source]#
Bases:
Family
Common features of Fandom families.
New in version 3.0: renamed from WikiaFamily
Allocator.
- langs: Dict[str, str]#
Property listing family languages.
- class family.SingleSiteFamily[source]#
Bases:
Family
Single site family.
- domains#
Return the full domain name of the site.
- class family.SubdomainFamily[source]#
Bases:
Family
Multi site wikis that are subdomains of the same top level domain.
- codes#
Property listing family codes.
- domains#
Return the domain name of the sites in this family.
- langs: Dict[str, str]#
Property listing family languages.
- class family.WikimediaFamily[source]#
Bases:
Family
Class for all wikimedia families.
Allocator.
- closed_wikis: List[str] = []#
- code_aliases = {'be-x-old': 'be-tarask', 'dk': 'da', 'jp': 'ja', 'minnan': 'zh-min-nan', 'mo': 'ro', 'nan': 'zh-min-nan', 'nb': 'no', 'nds_nl': 'nds-nl', 'zh-cn': 'zh', 'zh-tw': 'zh'}#
- content_families = {'commons', 'incubator', 'lingualibre', 'mediawiki', 'species', 'wikibooks', 'wikidata', 'wikinews', 'wikipedia', 'wikiquote', 'wikisource', 'wikiversity', 'wikivoyage', 'wiktionary'}#
- cross_projects = {'commons', 'incubator', 'lingualibre', 'mediawiki', 'meta', 'outreach', 'species', 'strategy', 'wikibooks', 'wikidata', 'wikimania', 'wikimediachapter', 'wikinews', 'wikipedia', 'wikiquote', 'wikisource', 'wikiversity', 'wikivoyage', 'wiktionary'}#
- disambcatname: Dict[str, str] = {'wikidata': 'Q1982926'}#
- domain#
Domain property.
- eventstreams_host(code)[source]#
Return ‘https://stream.wikimedia.org’ as the stream hostname.
- Return type:
str
- interwiki_removals: List[str] = frozenset({})#
- interwiki_replacements: Dict[str, str] = mappingproxy({'dk': 'da', 'jp': 'ja', 'nb': 'no', 'mo': 'ro', 'minnan': 'zh-min-nan', 'nan': 'zh-min-nan', 'zh-tw': 'zh', 'zh-cn': 'zh', 'nds_nl': 'nds-nl', 'be-x-old': 'be-tarask'})#
- multi_language_content_families = ['wikipedia', 'wiktionary', 'wikisource', 'wikibooks', 'wikinews', 'wikiquote', 'wikiversity', 'wikivoyage']#
- other_content_families = ['wikidata', 'mediawiki', 'lingualibre']#
- removed_wikis: List[str] = []#
Return Wikimedia Commons as the shared image repository.
- wikimedia_org_content_families = ['commons', 'incubator', 'species']#
- wikimedia_org_families = {'commons', 'incubator', 'meta', 'outreach', 'species', 'strategy', 'wikimania', 'wikimediachapter', 'wikitech'}#
- wikimedia_org_meta_families = ['meta', 'outreach', 'strategy', 'wikimediachapter', 'wikimania']#
- wikimedia_org_other_families = ['wikitech']#
- class family.WikimediaOrgFamily[source]#
Bases:
SingleSiteFamily
,WikimediaFamily
Single site family for sites hosted at
*.wikimedia.org
.- domain = 'None.wikimedia.org'#
- langs: Dict[str, str] = {None: 'None.wikimedia.org'}#