Skip to content

Commit

Permalink
Remaining flakes in pywikibot/
Browse files Browse the repository at this point in the history
Add __all__ to __init__.py to define the list of exported
symbols.

Change-Id: I40a0f4d389cc039a371ec51d5ef05f96f84e1889
  • Loading branch information
jayvdb committed Aug 3, 2014
1 parent a417435 commit 2cddfcd
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 26 deletions.
64 changes: 54 additions & 10 deletions pywikibot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import datetime
import difflib
import logging
import math
import re
import sys
Expand All @@ -28,11 +27,56 @@
# who want to continue using both

from pywikibot import config2 as config
from pywikibot.bot import *
from pywikibot.exceptions import *
from pywikibot.textlib import *
from pywikibot.bot import (
output, warning, error, critical, debug, stdout, exception,
input, inputChoice, handleArgs, showHelp, ui, log,
calledModuleName, Bot, WikidataBot,
)
from pywikibot.exceptions import (
Error, InvalidTitle, BadTitle, NoPage, SectionError,
NoSuchSite, NoUsername, UserBlocked,
PageRelatedError, IsRedirectPage, IsNotRedirectPage,
PageNotSaved, UploadWarning, LockedPage, EditConflict,
ServerError, FatalServerError, Server504Error,
CaptchaError, SpamfilterError, CircularRedirect,
WikiBaseError, CoordinateGlobeUnknownException,
)
from pywikibot.textlib import (
unescape, replaceExcept, removeDisabledParts, removeHTMLParts,
isDisabled, interwikiFormat, interwikiSort,
getLanguageLinks, replaceLanguageLinks,
removeLanguageLinks, removeLanguageLinksAndSeparator,
getCategoryLinks, categoryFormat, replaceCategoryLinks,
removeCategoryLinks, removeCategoryLinksAndSeparator,
replaceCategoryInPlace, compileLinkR, extract_templates_and_params,
)
from pywikibot.tools import UnicodeMixin
from pywikibot.i18n import translate

__all__ = [
'config', 'ui', 'UnicodeMixin', 'translate',
'Page', 'ImagePage', 'Category', 'Link', 'User',
'ItemPage', 'PropertyPage', 'Claim', 'TimeStripper',
'html2unicode', 'url2unicode', 'unicode2html',
'stdout', 'output', 'warning', 'error', 'critical', 'debug', 'exception',
'input', 'inputChoice', 'handleArgs', 'showHelp', 'ui', 'log',
'calledModuleName', 'Bot', 'WikidataBot',
'Error', 'InvalidTitle', 'BadTitle', 'NoPage', 'SectionError',
'NoSuchSite', 'NoUsername', 'UserBlocked',
'PageRelatedError', 'IsRedirectPage', 'IsNotRedirectPage',
'PageNotSaved', 'UploadWarning', 'LockedPage', 'EditConflict',
'ServerError', 'FatalServerError', 'Server504Error',
'CaptchaError', 'SpamfilterError', 'CircularRedirect',
'WikiBaseError', 'CoordinateGlobeUnknownException',
'unescape', 'replaceExcept', 'removeDisabledParts', 'removeHTMLParts',
'isDisabled', 'interwikiFormat', 'interwikiSort',
'getLanguageLinks', 'replaceLanguageLinks',
'removeLanguageLinks', 'removeLanguageLinksAndSeparator',
'getCategoryLinks', 'categoryFormat', 'replaceCategoryLinks',
'removeCategoryLinks', 'removeCategoryLinksAndSeparator',
'replaceCategoryInPlace', 'compileLinkR', 'extract_templates_and_params',
]


class Timestamp(datetime.datetime):

Expand Down Expand Up @@ -416,16 +460,16 @@ def wrapper(*__args, **__kw):
if old_arg in __kw:
if new_arg:
if new_arg in __kw:
pywikibot.warning(
warning(
u"%(new_arg)s argument of %(meth_name)s replaces %(old_arg)s; cannot use both."
% locals())
else:
pywikibot.warning(
warning(
u"%(old_arg)s argument of %(meth_name)s is deprecated; use %(new_arg)s instead."
% locals())
__kw[new_arg] = __kw[old_arg]
else:
pywikibot.debug(
debug(
u"%(old_arg)s argument of %(meth_name)s is deprecated."
% locals(), _logger)
del __kw[old_arg]
Expand Down Expand Up @@ -481,7 +525,7 @@ def Site(code=None, fam=None, user=None, sysop=None, interface=None):
key = '%s:%s:%s' % (fam, code, user)
if key not in _sites or not isinstance(_sites[key], __Site):
_sites[key] = __Site(code=code, fam=fam, user=user, sysop=sysop)
pywikibot.debug(u"Instantiating Site object '%(site)s'"
debug(u"Instantiating Site object '%(site)s'"
% {'site': _sites[key]}, _logger)
return _sites[key]

Expand Down Expand Up @@ -581,7 +625,7 @@ def stopme():
_logger = "wiki"

if not stopped:
pywikibot.debug(u"stopme() called", _logger)
debug(u"stopme() called", _logger)

def remaining():
remainingPages = page_put_queue.qsize() - 1
Expand Down Expand Up @@ -616,7 +660,7 @@ def remaining():
# only need one drop() call because all throttles use the same global pid
try:
list(_sites.values())[0].throttle.drop()
pywikibot.log(u"Dropped throttle(s).")
log(u"Dropped throttle(s).")
except IndexError:
pass

Expand Down
10 changes: 0 additions & 10 deletions pywikibot/botirc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,12 @@
# scripts, instead of writing each one from scratch.


import logging.handlers
# all output goes thru python std library "logging" module

import re

from ircbot import SingleServerIRCBot
from irclib import nm_to_n

_logger = "botirc"

# logging levels
from logging import DEBUG, INFO, WARNING, ERROR, CRITICAL
STDOUT = 16
VERBOSE = 18
INPUT = 25

import pywikibot


Expand Down
2 changes: 1 addition & 1 deletion pywikibot/textlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ def interwikiFormat(links, insite=None):
link = title.replace('[[:', '[[')
s.append(link)
except AttributeError:
s.append(getSite(site).linkto(links[site], othersite=insite))
s.append(pywikibot.Site(code=site).linkto(links[site], othersite=insite))
if insite.lang in insite.family.interwiki_on_one_line:
sep = u' '
else:
Expand Down
2 changes: 1 addition & 1 deletion pywikibot/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def getfileversion(filename):
"""
_program_dir = _get_program_dir()
__version__ = None
size, mtime = None, None
mtime = None
fn = os.path.join(_program_dir, filename)
if os.path.exists(fn):
for line in open(fn, 'r').readlines():
Expand Down
2 changes: 1 addition & 1 deletion pywikibot/weblib.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def getWebCitationURL(url, timestamp=None):
query = {'returnxml': 'true',
'url': url}

if not timestamp is None:
if timestamp is not None:
query['date'] = timestamp

uri = uri + urllib.urlencode(query)
Expand Down
1 change: 1 addition & 0 deletions scripts/blockreview.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import pywikibot
from pywikibot.compat import query
from pywikibot import i18n


class BlockreviewBot:
Expand Down
8 changes: 5 additions & 3 deletions scripts/replicate_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
#

import sys
from pywikibot import *
from itertools import imap

import pywikibot
from pywikibot import config, Page


def namespaces(site):
"""dict from namespace number to prefix"""
Expand Down Expand Up @@ -67,7 +69,7 @@ def __init__(self, options):

sites = options.destination_wiki

self.original = Site(original_wiki, family)
self.original = pywikibot.Site(original_wiki, family)
self.original.login()

if options.namespace and 'help' in options.namespace:
Expand All @@ -76,7 +78,7 @@ def __init__(self, options):
pywikibot.output('%s %s' % (k, nsd[k]))
sys.exit()

self.sites = map(lambda s: Site(s, family), sites)
self.sites = map(lambda s: pywikibot.Site(s, family), sites)

self.differences = {}
self.user_diff = {}
Expand Down

0 comments on commit 2cddfcd

Please sign in to comment.