X-Git-Url: https://projects.mako.cc/source/mw/blobdiff_plain/bc37c596074d390ecfdd3eb746e548bccd0d87aa..4a350e948aa21b25d74b618c8050755bb1b26d4c:/src/mw/clicommands.py diff --git a/src/mw/clicommands.py b/src/mw/clicommands.py index 3657d53..5bddd62 100644 --- a/src/mw/clicommands.py +++ b/src/mw/clicommands.py @@ -13,8 +13,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# with this program. If not, see . ### import getpass @@ -92,12 +91,16 @@ class FetchCommand(CommandBase): } response = self.api.call(data)['query']['pages'] for pageid in response.keys(): + pagename = response[pageid]['title'] + if 'missing' in response[pageid].keys(): + print '%s: %s: page does not exist, file not created' % \ + (self.me, pagename) + continue revid = [x['revid'] for x in response[pageid]['revisions']] - self.metadir.add_page_info(int(pageid), - response[pageid]['title'], - revid) - self.metadir.add_rv_info(response[pageid]['revisions'][0]) - fd = file(os.path.join(self.metadir.root, \ - response[pageid]['title'].replace(' ', '_') + \ - '.wiki'), 'w') + self.metadir.pagedict_add(pagename, int(pageid)) + self.metadir.pages_add_rv(int(pageid), + response[pageid]['revisions'][0]) + filename = mw.api.pagename_to_filename(pagename) + fd = file(os.path.join(self.metadir.root, filename + '.wiki'), + 'w') fd.write(response[pageid]['revisions'][0]['*'].encode('utf-8'))