#!/usr/bin/env python3.5 # Copyright 2017 Digital # # This file is part of DigiLib. # # DigiLib is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # DigiLib 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with DigiLib. If not, see . import logging import random import string import sys import time import yaml log = logging.getLogger(__name__+"") LOREM_IPSUM = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque vel mauris non odio pharetra ultricies quis eu turpis. Proin et tortor eu magna ultricies facilisis tincidunt vehicula nisi. Donec hendrerit massa id viverra lobortis. In sed nisl a metus gravida faucibus. Praesent bibendum mi semper, sagittis mi sit amet, auctor dui. Sed ac dui sagittis quam ultricies dapibus. In non elit non felis convallis vestibulum. Vivamus ornare ante suscipit faucibus pulvinar. Cras consequat nulla quis quam faucibus mollis. Nulla dictum sapien in justo sagittis malesuada. Sed ornare orci quis laoreet elementum. Sed ornare lacus ac ipsum vulputate vulputate. Sed accumsan ante nec magna sollicitudin maximus. Aliquam condimentum magna nec convallis efficitur. Nam posuere mauris et dui pulvinar, quis iaculis leo aliquam. Nunc cursus arcu et leo vehicula, quis feugiat mi semper. """ class Container(): # This class should only be used as a storage space for variables. pass config_files = [ "config/controllers.yaml", "config/commands.yaml", ] def load_files(file_list,call): if not type(file_list) is list: file_list = [file_list] for file_ in file_list: with open(file_,"r") as f: data = f.read() config = yaml.safe_load(data) call(config) def parse_to_int_list( parse,*args, delimeter=",", true_list=["true"], false_list=["false"]): if type(parse) is list: return parse elif type(parse) is int: return [parse] elif type(parse) is bool: return [int(parse)] elif type(parse) is not str: raise ValueError("Failed to parse value {}".format(parse)) if parse.lower() in true_list: return [1] elif parse.lower() in false_list: return [0] parse = parse.split(delimeter) for part in parse.copy(): parse.remove(part) parse.append(int(part)) return parse #