summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Laska <jlaska@redhat.com>2011-08-29 08:00:18 -0400
committerJames Laska <jlaska@redhat.com>2011-08-29 08:00:18 -0400
commitc6ec50ccdfbdb48adf68282463f673150283c560 (patch)
treedeed201a096073599021ee2d21987805bc90360c
parentd32c2312832d44e555a2487a0c4f74b92c76dd0f (diff)
downloadscripts-c6ec50ccdfbdb48adf68282463f673150283c560.tar.gz
scripts-c6ec50ccdfbdb48adf68282463f673150283c560.tar.xz
scripts-c6ec50ccdfbdb48adf68282463f673150283c560.zip
Detect the older time and adjust start/end date appropriately
-rwxr-xr-xget-mediawiki-data12
1 files changed, 12 insertions, 0 deletions
diff --git a/get-mediawiki-data b/get-mediawiki-data
index da80642..a525206 100755
--- a/get-mediawiki-data
+++ b/get-mediawiki-data
@@ -167,6 +167,18 @@ def list_usercontribs(wiki, user, date_start='', date_end='', namespaces=""):
query['ucend'] = date_end
if namespaces != '':
query['ucnamespace'] = namespaces
+ if date_start != '' and date_end != '':
+ # if we can recognize the date format, see if we need to add ucdir
+ try:
+ date_start = re.sub('[TZ]', ' ', date_start).strip()
+ date_end = re.sub('[TZ]', ' ', date_end).strip()
+ ds = datetime.datetime.strptime(date_start, '%Y-%m-%d %H:%M:%S')
+ de = datetime.datetime.strptime(date_end, '%Y-%m-%d %H:%M:%S')
+ if ds < de:
+ query['ucdir'] = 'newer'
+ except ValueError:
+ pass
+
if opts.debug: print query
response = wiki.call(query)