X-Git-Url: https://projects.mako.cc/source/mw/blobdiff_plain/9a2566b262128695551d61f56f0eb3564a2b0fe5..e20392dd7415616f40ec65b4b5e2f9a2dc6efe4d:/src/mw/clicommands.py diff --git a/src/mw/clicommands.py b/src/mw/clicommands.py index eaadb7c..9efffd4 100644 --- a/src/mw/clicommands.py +++ b/src/mw/clicommands.py @@ -17,12 +17,13 @@ ### import codecs +import cookielib import getpass import hashlib -import mw.api import mw.metadir from optparse import OptionParser, OptionGroup import os +import simplemediawiki import sys import time @@ -77,8 +78,10 @@ class CommandBase(object): sys.exit(1) def _api_setup(self): + cookie_file = os.path.join(self.metadir.location, 'cookies') self.api_url = self.metadir.config.get('remote', 'api_url') - self.api = mw.api.API(self.api_url, self.metadir) + self.api = simplemediawiki.MediaWiki(self.api_url, + cookie_file=cookie_file) class InitCommand(CommandBase): @@ -176,7 +179,7 @@ class PullCommand(CommandBase): self.metadir.pagedict_add(pagename, pageid, revids[-1]) self.metadir.pages_add_rv(int(pageid), response[pageid]['revisions'][0]) - filename = mw.api.pagename_to_filename(pagename) + filename = mw.metadir.pagename_to_filename(pagename) with file(os.path.join(self.metadir.root, filename + '.wiki'), 'w') as fd: data = response[pageid]['revisions'][0]['*'] @@ -208,7 +211,7 @@ class DiffCommand(CommandBase): for file in status: if status[file] == 'U': print self.metadir.diff_rv_to_working( - mw.api.filename_to_pagename(file[:-5])), + mw.metadir.filename_to_pagename(file[:-5])), class CommitCommand(CommandBase): @@ -249,7 +252,7 @@ class CommitCommand(CommandBase): 'action': 'query', 'prop': 'info|revisions', 'intoken': 'edit', - 'titles': mw.api.filename_to_pagename(file[:-5]), + 'titles': mw.metadir.filename_to_pagename(file[:-5]), } response = self.api.call(data) pageid = response['query']['pages'].keys()[0] @@ -272,7 +275,7 @@ class CommitCommand(CommandBase): textmd5 = md5.hexdigest() data = { 'action': 'edit', - 'title': mw.api.filename_to_pagename(file[:-5]), + 'title': mw.metadir.filename_to_pagename(file[:-5]), 'token': edittoken, 'text': text, 'md5': textmd5,