X-Git-Url: https://projects.mako.cc/source/mw/blobdiff_plain/b30dcd7f4a701370778956d4e1b60947a853f639..e89bbd939f4d0a1267a414438769418965329cf0:/src/mw/clicommands.py diff --git a/src/mw/clicommands.py b/src/mw/clicommands.py index 4f5fc48..73322bc 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 @@ -76,8 +77,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): @@ -148,7 +151,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]['*'] @@ -180,7 +183,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): @@ -221,7 +224,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] @@ -244,7 +247,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,