<commit_before># -*- coding: utf-8  -*-
"""The initialization file for the Pywikibot framework."""
#
# (C) Pywikibot team, 2008-2014
#
# Distributed under the terms of the MIT license.
#
from __future__ import unicode_literals

__release__ = '2.0b3'
__version__ = '$Id$'

import datetime
import math
import re
import sys
import threading
import json

if sys.version_info[0] > 2:
    from queue import Queue
    long = int
else:
    from Queue import Queue

from warnings import warn

# Use pywikibot. prefix for all in-package imports; this is to prevent
# confusion with similarly-named modules in version 1 framework, for users
# who want to continue using both

from pywikibot import config2 as config
from pywikibot.bot import (
    output, warning, error, critical, debug, stdout, exception,
    input, input_choice, input_yn, inputChoice, handle_args, showHelp, ui, log,
    calledModuleName, Bot, CurrentPageBot, WikidataBot,
    # the following are flagged as deprecated on usage
    handleArgs,
)
from pywikibot.exceptions import (
    Error, InvalidTitle, BadTitle, NoPage, NoMoveTarget, SectionError,
    SiteDefinitionError, NoSuchSite, UnknownSite, UnknownFamily,
    UnknownExtension,
    NoUsername, UserBlocked,
    PageRelatedError, IsRedirectPage, IsNotRedirectPage,
    PageSaveRelatedError, PageNotSaved, OtherPageSaveError,
    LockedPage, CascadeLockedPage, LockedNoPage, NoCreateError,
    EditConflict, PageDeletedConflict, PageCreatedConflict,
    ServerError, FatalServerError, Server504Error,
    CaptchaError, SpamfilterError, CircularRedirect, InterwikiRedirectPage,
    WikiBaseError, CoordinateGlobeUnknownException,
)
from pywikibot.tools import UnicodeMixin, redirect_func
from pywikibot.i18n import translate
from pywikibot.data.api import UploadWarning
from pywikibot.diff import PatchManager
import pywikibot.textlib as textlib
import pywikibot.tools

textlib_methods = (
    'unescape', 'replaceExcept', 'removeDisabledParts', 'removeHTMLParts',
    'isDisabled', 'interwikiFormat', 'interwikiSort',
    'getLanguageLinks', 'replaceLanguageLinks',
    'removeLanguageLinks', 'removeLanguageLinksAndSeparator',
    'getCategoryLinks', 'categoryFormat', 'replaceCategoryLinks',
    'removeCategoryLinks', 'removeCategoryLinksAndSeparator',
    'replaceCategoryInPlace', 'compileLinkR', 'extract_templates_and_params',
)

# pep257 doesn't understand when the first entry is on the next line
__all__ = ('config', 'ui', 'UnicodeMixin', 'translate',
           'Page', 'FilePage', 'Category', 'Link', 'User',
           'ItemPage', 'PropertyPage', 'Claim', 'TimeStripper',
           'html2unicode', 'url2unicode', 'unicode2html',
           'stdout', 'output', 'warning', 'error', 'critical', 'debug',
           'exception', 'input_choice', 'input', 'input_yn', 'inputChoice',
           'handle_args', 'handleArgs', 'showHelp', 'ui', 'log',
           'calledModuleName', 'Bot', 'CurrentPageBot', 'WikidataBot',
           'Error', 'InvalidTitle', 'BadTitle', 'NoPage', 'NoMoveTarget',
           'SectionError',
           'SiteDefinitionError', 'NoSuchSite', 'UnknownSite', 'UnknownFamily',
           'UnknownExtension',
           'NoUsername', 'UserBlocked', 'UserActionRefuse',
           'PageRelatedError', 'IsRedirectPage', 'IsNotRedirectPage',
           'PageSaveRelatedError', 'PageNotSaved', 'OtherPageSaveError',
           'LockedPage', 'CascadeLockedPage', 'LockedNoPage', 'NoCreateError',
           'EditConflict', 'PageDeletedConflict', 'PageCreatedConflict',
           'UploadWarning',
           'ServerError', 'FatalServerError', 'Server504Error',
           'CaptchaError', 'SpamfilterError', 'CircularRedirect',
           'InterwikiRedirectPage',
           'WikiBaseError', 'CoordinateGlobeUnknownException',
           'QuitKeyboardInterrupt',
           )
# flake8 is unable to detect concatenation in the same operation
# like:
# ) + textlib_methods
# pep257 also doesn't support __all__ multiple times in a document
# so instead use this trick
globals()['__all__'] = globals()['__all__'] + textlib_methods

for _name in textlib_methods:
    target = getattr(textlib, _name)
    wrapped_func = redirect_func(target)
    globals()[_name] = wrapped_func


deprecated = redirect_func(pywikibot.tools.deprecated)
deprecate_arg = redirect_func(pywikibot.tools.deprecate_arg)


class Timestamp(datetime.datetime):

    """Class for handling MediaWiki timestamps.

    This inherits from datetime.datetime, so it can use all of the methods
    and operations of a datetime object.  To ensure that the results of any
    operation are also a Timestamp object, be sure to use only Timestamp
    objects (and datetime.timedeltas) in any operation.

    Use Timestamp.fromISOformat() and Timestamp.fromtimestampformat() to
    create Timestamp objects from MediaWiki string formats.
    As these constructors are typically used to create objects using data
    passed provided by site and page methods, some of which return a Timestamp
    when previously they returned a MediaWiki string representation, these
    methods also accept a Timestamp object, in which case they return a clone.

    Use Site.getcurrenttime() for the current time; this is more reliable<commit_msg>__all__ items must be bytes on Python 2<commit_after># -*- coding: utf-8  -*-
"""The initialization file for the Pywikibot framework."""
#
# (C) Pywikibot team, 2008-2014
#
# Distributed under the terms of the MIT license.
#
from __future__ import unicode_literals

__release__ = '2.0b3'
__version__ = '$Id$'

import datetime
import math
import re
import sys
import threading
import json

if sys.version_info[0] > 2:
    from queue import Queue
    long = int
else:
    from Queue import Queue

from warnings import warn

# Use pywikibot. prefix for all in-package imports; this is to prevent
# confusion with similarly-named modules in version 1 framework, for users
# who want to continue using both

from pywikibot import config2 as config
from pywikibot.bot import (
    output, warning, error, critical, debug, stdout, exception,
    input, input_choice, input_yn, inputChoice, handle_args, showHelp, ui, log,
    calledModuleName, Bot, CurrentPageBot, WikidataBot,
    # the following are flagged as deprecated on usage
    handleArgs,
)
from pywikibot.exceptions import (
    Error, InvalidTitle, BadTitle, NoPage, NoMoveTarget, SectionError,
    SiteDefinitionError, NoSuchSite, UnknownSite, UnknownFamily,
    UnknownExtension,
    NoUsername, UserBlocked,
    PageRelatedError, IsRedirectPage, IsNotRedirectPage,
    PageSaveRelatedError, PageNotSaved, OtherPageSaveError,
    LockedPage, CascadeLockedPage, LockedNoPage, NoCreateError,
    EditConflict, PageDeletedConflict, PageCreatedConflict,
    ServerError, FatalServerError, Server504Error,
    CaptchaError, SpamfilterError, CircularRedirect, InterwikiRedirectPage,
    WikiBaseError, CoordinateGlobeUnknownException,
)
from pywikibot.tools import PY2, UnicodeMixin, redirect_func
from pywikibot.i18n import translate
from pywikibot.data.api import UploadWarning
from pywikibot.diff import PatchManager
import pywikibot.textlib as textlib
import pywikibot.tools

textlib_methods = (
    'unescape', 'replaceExcept', 'removeDisabledParts', 'removeHTMLParts',
    'isDisabled', 'interwikiFormat', 'interwikiSort',
    'getLanguageLinks', 'replaceLanguageLinks',
    'removeLanguageLinks', 'removeLanguageLinksAndSeparator',
    'getCategoryLinks', 'categoryFormat', 'replaceCategoryLinks',
    'removeCategoryLinks', 'removeCategoryLinksAndSeparator',
    'replaceCategoryInPlace', 'compileLinkR', 'extract_templates_and_params',
)

# pep257 doesn't understand when the first entry is on the next line
__all__ = ('config', 'ui', 'UnicodeMixin', 'translate',
           'Page', 'FilePage', 'Category', 'Link', 'User',
           'ItemPage', 'PropertyPage', 'Claim', 'TimeStripper',
           'html2unicode', 'url2unicode', 'unicode2html',
           'stdout', 'output', 'warning', 'error', 'critical', 'debug',
           'exception', 'input_choice', 'input', 'input_yn', 'inputChoice',
           'handle_args', 'handleArgs', 'showHelp', 'ui', 'log',
           'calledModuleName', 'Bot', 'CurrentPageBot', 'WikidataBot',
           'Error', 'InvalidTitle', 'BadTitle', 'NoPage', 'NoMoveTarget',
           'SectionError',
           'SiteDefinitionError', 'NoSuchSite', 'UnknownSite', 'UnknownFamily',
           'UnknownExtension',
           'NoUsername', 'UserBlocked', 'UserActionRefuse',
           'PageRelatedError', 'IsRedirectPage', 'IsNotRedirectPage',
           'PageSaveRelatedError', 'PageNotSaved', 'OtherPageSaveError',
           'LockedPage', 'CascadeLockedPage', 'LockedNoPage', 'NoCreateError',
           'EditConflict', 'PageDeletedConflict', 'PageCreatedConflict',
           'UploadWarning',
           'ServerError', 'FatalServerError', 'Server504Error',
           'CaptchaError', 'SpamfilterError', 'CircularRedirect',
           'InterwikiRedirectPage',
           'WikiBaseError', 'CoordinateGlobeUnknownException',
           'QuitKeyboardInterrupt',
           )
# flake8 is unable to detect concatenation in the same operation
# like:
# ) + textlib_methods
# pep257 also doesn't support __all__ multiple times in a document
# so instead use this trick
globals()['__all__'] = globals()['__all__'] + textlib_methods

if PY2:
    # T111615: Python 2 requires __all__ is bytes
    globals()['__all__'] = tuple(bytes(item) for item in __all__)

for _name in textlib_methods:
    target = getattr(textlib, _name)
    wrapped_func = redirect_func(target)
    globals()[_name] = wrapped_func


deprecated = redirect_func(pywikibot.tools.deprecated)
deprecate_arg = redirect_func(pywikibot.tools.deprecate_arg)


class Timestamp(datetime.datetime):

    """Class for handling MediaWiki timestamps.

    This inherits from datetime.datetime, so it can use all of the methods
    and operations of a datetime object.  To ensure that the results of any
    operation are also a Timestamp object, be sure to use only Timestamp
    objects (and datetime.timedeltas) in any operation.

    Use Timestamp.fromISOformat() and Timestamp.fromtimestampformat() to
    create Timestamp objects from MediaWiki string formats.
    As these constructors are typically used to create objects using data
    passed provided by site and page methods, some of which return a Timestamp
    when previously they returned a MediaWiki string representation, these
    methods also accept a Timestamp object, in which case they return a clone.

    Use Site.getcurrenttime() for the current time; this is more reliable
{'fraction_non_alphanumeric': 0.09317882042585265, 'fraction_numerical': 0.007348784624081402, 'mean_word_length': 4.396542958820539, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5485512', 'n_tokens_mistral': 3045, 'n_tokens_neox': 2971, 'n_words': 932}