http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10181
Revision: 10181
Author: xqt
Date: 2012-05-05 09:39:02 +0000 (Sat, 05 May 2012)
Log Message:
-----------
update from trunk r10178
Modified Paths:
--------------
branches/rewrite/scripts/version.py
Modified: branches/rewrite/scripts/version.py
===================================================================
--- branches/rewrite/scripts/version.py 2012-05-05 09:37:09 UTC (rev 10180)
+++ branches/rewrite/scripts/version.py 2012-05-05 09:39:02 UTC (rev 10181)
@@ -65,16 +65,16 @@
cur.execute( '''select local_relpath, repos_path, revision, changed_date from nodes order by revision desc, changed_date desc''')
name, tag, rev, date = cur.fetchone()
con.close()
- tag = tag[:len(tag) - len(name)]
+ tag = tag[:-len(name)]
date = time.gmtime(date/1000000)
else:
- for i in range(3):
+ for i in xrange(3):
entries.readline()
tag = entries.readline().strip()
t = tag.split('://')
t[1] = t[1].replace('svn.wikimedia.org/svnroot/pywikipedia/', '')
tag = '[%s] %s' % (t[0], t[1])
- for i in range(4):
+ for i in xrange(4):
entries.readline()
date = time.strptime(entries.readline()[:19],'%Y-%m-%dT%H:%M:%S')
rev = entries.readline()[:-1]
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10178
Revision: 10178
Author: xqt
Date: 2012-05-05 09:27:47 +0000 (Sat, 05 May 2012)
Log Message:
-----------
code optimations: use xrange iterator intead of range list; s[:-x] instead of s[:len(s)-x]. Follow up for r10160
Modified Paths:
--------------
trunk/pywikipedia/version.py
Modified: trunk/pywikipedia/version.py
===================================================================
--- trunk/pywikipedia/version.py 2012-05-05 07:02:53 UTC (rev 10177)
+++ trunk/pywikipedia/version.py 2012-05-05 09:27:47 UTC (rev 10178)
@@ -64,16 +64,16 @@
cur.execute( '''select local_relpath, repos_path, revision, changed_date from nodes order by revision desc, changed_date desc''')
name, tag, rev, date = cur.fetchone()
con.close()
- tag = tag[:len(tag) - len(name)]
+ tag = tag[:-len(name)]
date = time.gmtime(date/1000000)
else:
- for i in range(3):
+ for i in xrange(3):
entries.readline()
tag = entries.readline().strip()
t = tag.split('://')
t[1] = t[1].replace('svn.wikimedia.org/svnroot/pywikipedia/', '')
tag = '[%s] %s' % (t[0], t[1])
- for i in range(4):
+ for i in xrange(4):
entries.readline()
date = time.strptime(entries.readline()[:19],'%Y-%m-%dT%H:%M:%S')
rev = entries.readline()[:-1]
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10174
Revision: 10174
Author: xqt
Date: 2012-05-03 13:16:35 +0000 (Thu, 03 May 2012)
Log Message:
-----------
simulate actions_to_block is now user_configurable, follow-up for r10072
Modified Paths:
--------------
trunk/pywikipedia/config.py
trunk/pywikipedia/query.py
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/config.py
===================================================================
--- trunk/pywikipedia/config.py 2012-05-03 10:54:23 UTC (rev 10173)
+++ trunk/pywikipedia/config.py 2012-05-03 13:16:35 UTC (rev 10174)
@@ -464,11 +464,10 @@
retry_on_fail = True
# Defines what actions the bots are NOT allowed to do (e.g. 'edit') on wikipedia
-# servers. Setting this to:
-# actions_to_block = ['edit', 'watch', 'move', 'delete', 'undelete', 'protect']
-# allows simulation runs of bots to be carried out without changing any page on
-# the server side.
-actions_to_block = []
+# servers. Allows simulation runs of bots to be carried out without changing any
+# page on the server side. This setting may be overridden in user_config.py.
+actions_to_block = ['edit', 'watch', 'move', 'delete', 'undelete', 'protect',
+ 'emailuser']
# How many pages should be put to a queue in asynchroneous mode.
# If maxsize is <= 0, the queue size is infinite.
Modified: trunk/pywikipedia/query.py
===================================================================
--- trunk/pywikipedia/query.py 2012-05-03 10:54:23 UTC (rev 10173)
+++ trunk/pywikipedia/query.py 2012-05-03 13:16:35 UTC (rev 10174)
@@ -42,7 +42,8 @@
sysop=False, back_response=False):
"""Get data from the query api, and convert it into a data object
"""
- if ('action' in params) and (params['action'] in pywikibot.config.actions_to_block):
+ if ('action' in params) and pywikibot.simulate and \
+ (params['action'] in pywikibot.config.actions_to_block):
pywikibot.output(u'\03{lightyellow}SIMULATION: %s action blocked.\03{default}'%\
params['action'])
jsontext_dummy = {params['action']: {u'result':u''}}
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2012-05-03 10:54:23 UTC (rev 10173)
+++ trunk/pywikipedia/wikipedia.py 2012-05-03 13:16:35 UTC (rev 10174)
@@ -7731,7 +7731,7 @@
args may be passed as an argument, thereby overriding sys.argv
"""
- global default_code, default_family, verbose, debug
+ global default_code, default_family, verbose, debug, simulate
# get commandline arguments if necessary
if not args:
args = sys.argv[1:]
@@ -7776,9 +7776,9 @@
output(u'NOTE: option cosmetic_changes is %s\n' % config.cosmetic_changes)
elif arg == '-simulate':
if not getSite().has_api():
- raise NotImplementedError('-simulate option is implemented for API only')
- config.actions_to_block = ['edit', 'watch', 'move', 'delete',
- 'undelete', 'protect', 'emailuser']
+ raise NotImplementedError(
+ '-simulate option is implemented for API only')
+ simulate = True
# global debug option for development purposes. Normally does nothing.
elif arg == '-debug':
debug = True
@@ -7877,6 +7877,7 @@
ui = uiModule.UI()
verbose = 0
debug = False
+simulate = False
# TEST for bug #3081100
unicode_error = __import__('unicodedata').normalize(
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10173
Revision: 10173
Author: xqt
Date: 2012-05-03 10:54:23 +0000 (Thu, 03 May 2012)
Log Message:
-----------
q&d-fix. Unfortunatelly we have different timestamp formats on all scripts. It's a mess.
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2012-05-03 10:51:13 UTC (rev 10172)
+++ trunk/pywikipedia/wikipedia.py 2012-05-03 10:54:23 UTC (rev 10173)
@@ -1744,7 +1744,8 @@
# self.get() calls self._getEditPage without this parameter
self.get(force=True, change_edit_time=True)
newtime = self.editTime()
- if str(oldtime) != str(newtime): # page was changed
+ ### TODO: we have different timestamp formats
+ if re.sub('\D', '', str(oldtime)) != re.sub('\D', '', str(newtime)): # page was changed
raise EditConflict(u'Page has been changed after first read.')
self._editrestriction = False
# If no comment is given for the change, use the default