def add_handler_by_type(types: str, handler_method): if types in plugin_import.returns: function = plugin_import.returns.get(types).get('func') filters = plugin_import.returns.get(types).get('filters') performer = plugin_import.returns.get(types).get('performer') print('{} -> {}.{}'.format(plugin, performer, types)) if performer == 'api': app = api elif performer == 'cli': app = cli else: if types == 'msg': app = api or cli elif types == 'callback': app = api else: app = cli if types == 'update': handler = handler_method(function) else: handler = handler_method(function, filters) try: app.add_handler(handler, groups.get(types)) groups[types] += 1 except: pass
def create_config(): print('\t>> Creating Config...', 'cyan') config = ConfigParser(interpolation=ExtendedInterpolation()) config.add_section('Plugins') for i in plugins_dir_list(): config['Plugins'][i] = 'enabled' with open(path.join(rp, 'data', 'config.ini'), 'w') as file: config.write(file)
def start(**kwargs: Client): if ('api' not in kwargs) and ('cli' not in kwargs): print('App Is Not Set', 'red') return if 'api' in kwargs: app = kwargs['api'] if app.is_started: app.stop() app.start() if 'cli' in kwargs: app = kwargs['cli'] if app.is_started: app.stop() app.start()
def check_config(): print('\nChecking Config...', 'green') config = ConfigParser(interpolation=ExtendedInterpolation()) if not path.exists(path.join(rp, 'data', 'config.ini')): create_config() update_config_plugins() config.read(path.join(rp, 'data', 'config.ini')) if 'Plugins' not in config.sections(): print('#! ["Plugins"] not in config sections. !#', 'red') print('Done!', 'magenta')
# response and status response = conn.getresponse() # .getresponse() method that returns the reSponse information from the server #Print the status line -- OK tc.cprint(f"Response received!: {response.status} {response.reason}\n", 'blue') data = response.read().decode( "utf-8") # It is necessary to decode the information # read JSON info_api = json.loads( data) # loads(). is a method from JSON library (read JSON response) # Obtain information . We use 'seq' and 'desc' as keys sequence = info_api['seq'] description = info_api['desc'] # PRINTING info tc.cprint("Gene: ", 'green', end="") print(gene) tc.cprint("Description: ", 'green', end="") print(description) tc.cprint("Total length: ", 'green', end="") #stored function in seq_information print(len(seq_info)) tc.print("Most frequent Base: ", 'green', end="") print(most_frecuent_base)