123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- #!/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 <http://www.gnu.org/licenses/>.
- 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
- #
|