X-Git-Url: https://projects.mako.cc/source/mw/blobdiff_plain/fb328c2757462c9a7ea8ee85075b5c1b68e5d396..a58c94092d906cad0611dda3b0fc2b18501b0299:/src/mw/clicommands.py diff --git a/src/mw/clicommands.py b/src/mw/clicommands.py index 7714893..c12663c 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 @@ -38,6 +37,7 @@ class CommandBase(object): dest='use_auth', help='force authentication ' 'even if not required') self.parser.add_option_group(global_options) + self.shortcuts = [] def main(self): (self.options, self.args) = self.parser.parse_args() @@ -75,6 +75,7 @@ class FetchCommand(CommandBase): def __init__(self): usage = '%prog fetch [options] PAGENAME ...' CommandBase.__init__(self, 'fetch', 'fetch remote pages', usage) + self.shortcuts.append('ft') def _do_command(self): self._die_if_no_init() @@ -90,12 +91,17 @@ class FetchCommand(CommandBase): } response = self.api.call(data)['query']['pages'] for pageid in response.keys(): + if 'missing' in response[pageid].keys(): + print '%s: %s: page does not exist, file not created' % \ + (self.me, response[pageid]['title']) + 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') + filename = response[pageid]['title'].replace(' ', '_') + filename = filename.replace('/', '!') + fd = file(os.path.join(self.metadir.root, filename + '.wiki'), + 'w') fd.write(response[pageid]['revisions'][0]['*'].encode('utf-8'))