From f2ab6ee9b1612fe41cc8925509d8df58e1ccaa5b Mon Sep 17 00:00:00 2001 From: Celande Date: Sun, 1 Dec 2019 20:17:58 +0100 Subject: [PATCH] [applications/boorpg] creating boorpg application This application is used to interact with CapRPG. --- setup.cfg | 1 + weboob/applications/boorpg/__init__.py | 23 +++++ weboob/applications/boorpg/boorpg.py | 136 +++++++++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100644 weboob/applications/boorpg/__init__.py create mode 100644 weboob/applications/boorpg/boorpg.py diff --git a/setup.cfg b/setup.cfg index 5574b4d427..78f5e71460 100644 --- a/setup.cfg +++ b/setup.cfg @@ -112,6 +112,7 @@ console_scripts = boobsize = weboob.applications.boobsize:Boobsize.run boobtracker = weboob.applications.boobtracker:BoobTracker.run boomoney = weboob.applications.boomoney:Boomoney.run + boorpg = weboob.applications.boorpg:BooRPG.run cineoob = weboob.applications.cineoob:Cineoob.run comparoob = weboob.applications.comparoob:Comparoob.run cookboob = weboob.applications.cookboob:Cookboob.run diff --git a/weboob/applications/boorpg/__init__.py b/weboob/applications/boorpg/__init__.py new file mode 100644 index 0000000000..bd673a72ec --- /dev/null +++ b/weboob/applications/boorpg/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +# Copyright(C) 2010-2011 Christophe Benz +# +# This file is part of weboob. +# +# weboob is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# weboob is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with weboob. If not, see . + + +from .boorpg import BooRPG + +__all__ = ['BooRPG'] diff --git a/weboob/applications/boorpg/boorpg.py b/weboob/applications/boorpg/boorpg.py new file mode 100644 index 0000000000..6d143f1784 --- /dev/null +++ b/weboob/applications/boorpg/boorpg.py @@ -0,0 +1,136 @@ +# -*- coding: utf-8 -*- + +# Copyright(C) 2019-2020 Célande Adrien +# +# This file is part of weboob. +# +# weboob is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# weboob is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with weboob. If not, see . + + +from weboob.capabilities.rpg import CapRPG, Character, Skill, CharacterClass, CollectableItem +from weboob.tools.application.repl import ReplApplication, defaultcount + + +class BooRPG(ReplApplication): + APPNAME = 'boorpg' + VERSION = '1.0' + COPYRIGHT = 'Copyright(C) 2019-YEAR Célande Adrien' + CAPS = CapRPG + DESCRIPTION = 'Console application allowing to list informations from a RPG.' + SHORT_DESCRIPTION = 'Manage RPG data' + DEFAULT_FORMATTER = 'table' + COLLECTION_OBJECTS = (Character, Skill, CharacterClass, CollectableItem, ) + + def do_characters(self, line): + """ + characters + + List all characters + """ + print('do characterS') + print(f'line: "{line}"') + return self.do_ls(line) + + def do_character(self, line): + """ + character ID + + Get data on one character + """ + character_id, = self.parse_command_args(line, 1, 1) + self.start_format() + # cannot use get_object because it can be skipped after a ls + for c in self.do('get_character', character_id): + self.format(c) + + @defaultcount(20) + def do_skills(self, line): + """ + skills [TYPE] + + List all skills + """ + print('do skills') + skill_type, = self.parse_command_args(line, 1, 0) + print('skill type', skill_type) + self.start_format() + for skill in self.do('iter_skills', skill_type): + self.format(skill) + + def do_skill(self, line): + """ + skill ID + + Details for one skill + """ + skill_id, = self.parse_command_args(line, 1, 1) + self.start_format() + skill = self.get_object(skill_id, 'get_skill', []) + self.format(skill) + + @defaultcount(20) + def do_skill_set(self, line): + """ + skill_set CHARACTER_ID [TYPE] + + List of skills for a character + """ + character_id, skill_type = self.parse_command_args(line, 2, 1) + self.start_format() + for skill in self.do('iter_skill_set', character_id, skill_type): + self.format(skill) + + @defaultcount(20) + def do_classes(self, line): + """ + classes + + List all character classes + """ + self.start_format() + for character_class in self.do('iter_character_classes'): + self.format(character_class) + + def do_class(self, line): + """ + class ID + + Details for one character class + """ + class_id, = self.parse_command_args(line, 1, 1) + self.start_format() + character_class = self.get_object(class_id, 'get_character_class', []) + self.format(character_class) + + @defaultcount(20) + def do_items(self, line): + """ + items + + List all collectable items + """ + self.start_format() + for item in self.do('iter_collectable_items'): + self.format(item) + + def do_item(self, line): + """ + item ID + + Details for one collectable item + """ + item_id, = self.parse_command_args(line, 1, 1) + self.start_format() + item = self.get_object(item_id, 'get_collectable_item', []) + self.format(item) -- GitLab