示例#1
0
def expYaml(d):

    fTmp = open(d)
    yTmp = yamlLoad(fTmp) # select for python dict
    fTmp.close()

    return yTmp
示例#2
0
def _expYaml(d):

    fTmp = open(d)
    yTmp = yamlLoad(fTmp) # select for python dict
    fTmp.close()

    return yTmp
示例#3
0
 def loadStickfaceFile(self,stickfaceFileLoc):
     load = pygame.image.load
     self.stickfaceZip = ZipFile(stickfaceFileLoc,'r')
     self.stickfaceIni = yamlLoad(self.stickfaceZip.read(self.iniName))
     self.controllerSize = tuple(self.stickfaceIni['controllerSize'])
     self.buttonImages = [load(StringIO(self.stickfaceZip.read(i))) for i in self.stickfaceIni['buttonImages']]
     self.controllerImg = load(StringIO(self.stickfaceZip.read(self.stickfaceIni['controllerImage'])))
     self.buttonLoc = [tuple(i) for i in self.stickfaceIni['buttonLocs']]
     self.buttonSize = [tuple(i) for i in self.stickfaceIni['buttonSizes']]
示例#4
0
 def loadStickfaceFile(self, stickfaceFileLoc):
     load = pygame.image.load
     self.stickfaceZip = ZipFile(stickfaceFileLoc, 'r')
     self.stickfaceIni = yamlLoad(self.stickfaceZip.read(self.iniName))
     self.controllerSize = tuple(self.stickfaceIni['controllerSize'])
     self.buttonImages = [
         load(StringIO(self.stickfaceZip.read(i)))
         for i in self.stickfaceIni['buttonImages']
     ]
     self.controllerImg = load(
         StringIO(
             self.stickfaceZip.read(self.stickfaceIni['controllerImage'])))
     self.buttonLoc = [tuple(i) for i in self.stickfaceIni['buttonLocs']]
     self.buttonSize = [tuple(i) for i in self.stickfaceIni['buttonSizes']]
示例#5
0
    def read_config(self, path):
        if not re.match(".+\\.(json|yaml)$", path):
            if os.path.exists(f'{path}.json'):
                path = f'{path}.json'
            elif os.path.exists(f'{path}.yaml'):
                path = f'{path}.yaml'

        config_data = None
        # The idea with none it could have a fallback default
        if os.path.exists(path):
            with open(path, 'r') as fstr:
                if re.match(".+\\.json$", path):
                    config_data = json.load(fstr)
                else:
                    config_data = yamlLoad(fstr, Loader=YamlLoader)

        if self.log_configs and config_data is not None:
            self.log_setup(data=config_data, name=path)

        return config_data
示例#6
0
                                failure(value, backend_value)
                            else:
                                success(value, backend_value)


for file in sys.argv[1:]:
    with open(file, 'r') as f:
        document = f.read()

    # Replace with the variables defined in SPECS
    for var in config['SPECS']:
        document = document.replace("$${}$$".format(var.upper()),
                                    config['SPECS'][var])

    # Parse the yaml file
    data = yamlLoad(document, Loader=Loader)

    try:
        mode = os.environ['MODE']
    except KeyError:
        mode = ""

    if(mode != defaults['MODE_MASTER'] and mode != defaults['MODE_SLAVE']):
        mode = get_mode()

    try:
        init(data)
        test(data, mode=mode)
    finally:
        finalize(data)
示例#7
0
                                failure(value, backend_value)
                            else:
                                success(value, backend_value)


for file in sys.argv[1:]:
    with open(file, 'r') as f:
        document = f.read()

    # Replace with the variables defined in SPECS
    for var in config['SPECS']:
        document = document.replace("$${}$$".format(var.upper()),
                                    config['SPECS'][var])

    # Parse the yaml file
    data = yamlLoad(document, Loader=Loader)

    try:
        mode = os.environ['MODE']
    except KeyError:
        mode = ""

    if (mode != defaults['MODE_MASTER'] and mode != defaults['MODE_SLAVE']):
        mode = get_mode()

    try:
        init(data)
        test(data, mode=mode)
    finally:
        finalize(data)
示例#8
0
from yaml import safe_load as yamlLoad
from jinja2 import Environment, PackageLoader, select_autoescape

env = Environment(loader=PackageLoader('biography', 'templates'),
                  autoescape=select_autoescape(['html', 'xml']))

template = env.get_template('index.html')
with open('configs/config.yaml') as fYaml:
    print(template.render(yamlLoad(fYaml)))
示例#9
0
import slack
import datetime
import os
from yaml import FullLoader, load as yamlLoad
from random import choice, randint
from titlecase import titlecase
from time import sleep

TOKEN = os.environ['SLACK_WORKSTATION_TOKEN']
CHANNEL = os.environ['SLACK_CHANNEL']

with open('exercises.yml') as f:
    exercises_raw = yamlLoad(f, Loader=FullLoader)

# Put into format ---
# {level: { exercise: {type: type} }}
exercises = {
    k: {x: {
        'type': type
    }
        for type, v in data.items() for x in v}
    for k, data in exercises_raw.items()
}
'''
Equivalent Code
exercises = {}
for k,data in exercises_raw.items():
	exercises[k] = {}
	for type, v in data.items():
		for x in v:
			exercises[k][x] = {'type': type}