Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding: utf-8
- from argparse import ArgumentTypeError
- from pathlib import Path
- from cement.core import backend, foundation, controller, handler
- from . import logic
- def directory(path):
- p = Path(path)
- if p.is_dir():
- return p
- ArgumentTypeError('Path "%s" is not a directory' % path)
- ARG_UID = (['--uid', '-u'], dict(action='store', type=str, help='profile uid'))
- ARG_DIR = (['--dir', '-d'], dict(action='store', type=directory,
- help='Directory to export to'))
- class BaseController(controller.CementBaseController):
- class Meta:
- label = 'base'
- @controller.expose(help='Show current granted permissions')
- def permissions(self):
- logic.show_perms()
- class LoginController(controller.CementBaseController):
- class Meta:
- label = 'login'
- stacked_on = 'base'
- stacked_type = 'nested'
- description = ('Request and store authentication token'
- ' for given username and password')
- arguments = [
- (['username'], dict(action='store', type=str)),
- (['password'], dict(action='store', type=str)),
- ]
- @controller.expose(hide=True)
- def default(self):
- logic.login(username=self.app.pargs.username,
- password=self.app.pargs.password)
- class ProfileController(controller.CementBaseController):
- class Meta:
- label = 'profile'
- stacked_on = 'base'
- stacked_type = 'nested'
- description = 'Manipulate basic profile information'
- config_defaults = {'uid': None}
- arguments = [
- ARG_UID,
- ]
- @controller.expose()
- def list(self):
- logic.list_users()
- @controller.expose()
- def save(self):
- logic.save_profile(self.app.pargs.uid)
- @controller.expose()
- def show(self):
- logic.get_user(self.app.pargs.uid)
- class FrieldsController(controller.CementBaseController):
- class Meta:
- label = 'friends'
- stacked_on = 'base'
- stacked_type = 'nested'
- description = 'Manipulate friends'
- arguments = [
- ARG_UID,
- (['--sleep', '-s'], dict(action='store', type=float, default=.5,
- help='delay between requests'))
- ]
- @controller.expose(help='Save friends of a user')
- def save(self):
- # raise NotImplementedError()
- logic.save_friends(self.app.pargs.uid, self.app.pargs.sleep)
- @controller.expose(help='Show friends of a user')
- def show(self):
- logic.show_friends(self.app.pargs.uid)
- class PhotoController(controller.CementBaseController):
- class Meta:
- label = 'photos'
- stacked_on = 'base'
- stacked_type = 'nested'
- description = 'manipulate photos and albums'
- arguments = [
- ARG_UID,
- ARG_DIR,
- ]
- @controller.expose(help='Save photos of a user')
- def save(self):
- logic.save_photos(self.app.pargs.uid)
- @controller.expose(help='Export photos of a user to dir')
- def export(self):
- logic.export_photos(self.app.pargs.uid, self.app.pargs.dir)
- class VideoController(controller.CementBaseController):
- class Meta:
- label = 'videos'
- stacked_on = 'base'
- stacked_type = 'nested'
- description = 'manipulate videos'
- arguments = [
- ARG_UID,
- ]
- @controller.expose(help='Save videos of a user')
- def save(self):
- logic.save_videos(self.app.pargs.uid)
- @controller.expose(help='Show links to videos of a user')
- def list(self):
- logic.list_videos(self.app.pargs.uid)
- # class DocsController(controller.CementBaseController):
- # class Meta:
- # label = 'docs'
- # stacked_on = 'base'
- # stacked_type = 'nested'
- # description = 'manipulate docs'
- # arguments = [
- # ARG_UID,
- # ]
- # @controller.expose(help='Save docs of a user')
- # def save(self):
- # logic.save_docs(self.app.pargs.uid)
- # @controller.expose(help='Show links to docs of a user')
- # def list(self):
- # logic.list_docs(self.app.pargs.uid)
- class NotesController(controller.CementBaseController):
- class Meta:
- label = 'notes'
- stacked_on = 'base'
- stacked_type = 'nested'
- description = 'manipulate notes'
- arguments = [
- ARG_UID,
- ]
- @controller.expose(help='Save notes of a user')
- def save(self):
- logic.save_notes(self.app.pargs.uid)
- @controller.expose(help='Show notes of a user')
- def list(self):
- logic.list_notes(self.app.pargs.uid)
- class WallController(controller.CementBaseController):
- class Meta:
- label = 'wall'
- stacked_on = 'base'
- stacked_type = 'nested'
- description = 'manipulate wall'
- arguments = [
- ARG_UID,
- ]
- @controller.expose(help='Save wall of a user')
- def save(self):
- logic.save_wall(self.app.pargs.uid)
- class MessagesController(controller.CementBaseController):
- class Meta:
- label = 'messages'
- stacked_on = 'base'
- stacked_type = 'nested'
- description = 'manipulate messages'
- @controller.expose(help='Save messages of a user')
- def save(self):
- logic.save_messages()
- class FavesController(controller.CementBaseController):
- class Meta:
- label = 'faves'
- stacked_on = 'base'
- stacked_type = 'nested'
- description = 'manipulate faves'
- @controller.expose(help='Save faves of a user')
- def save(self):
- logic.save_faves()
- class EverythingController(controller.CementBaseController):
- class Meta:
- label = 'everything'
- stacked_on = 'base'
- stacked_type = 'nested'
- description = 'manipulate everything'
- arguments = [
- ARG_UID,
- ]
- @controller.expose(help='Save everything of a user')
- def save(self):
- logic.save_everything(self.app.pargs.uid)
- class VKDumpApp(foundation.CementApp):
- class Meta:
- label = 'vkdump'
- handlers = [
- BaseController,
- LoginController,
- ProfileController,
- FrieldsController,
- PhotoController,
- VideoController,
- # DocsController,
- NotesController,
- WallController,
- MessagesController,
- FavesController,
- EverythingController,
- ]
Add Comment
Please, Sign In to add comment