Exemplo n.º 1
0
def init_settings(exec_params):
    settings = dict()

    PROJECT_ROOT = Path(__file__).resolve().parent.parent
    CONFIGS_PATH = PROJECT_ROOT / 'configs'

    CONFIG_FILES_PATHS = {
        'creds': CONFIGS_PATH / exec_params['creds_path'],
        'filtration_rules': CONFIGS_PATH / exec_params['filtration_path'],
        'db_connection': CONFIGS_PATH / 'db.yml',
        'sheets_data': CONFIGS_PATH / 'sheets_data.yml',
    }

    settings['PROJECT_ROOT'] = PROJECT_ROOT
    settings['CONFIGS_PATH'] = CONFIGS_PATH
    settings['CONFIG_FILES_PATHS'] = CONFIG_FILES_PATHS

    settings.update(
        {section:load_yml(path) for (section, path) in CONFIG_FILES_PATHS.items()}
    )

    # stored in json and parsed by oauth2
    settings['sheets_creds_path'] = CONFIGS_PATH / 'flatty_spreadsheets.json'

    settings['filter_query'] = build_query_tree(settings['filtration_rules'])

    # write to google sheet when number of voters exceed this threshold
    settings['sheet_write_threshold'] = 1

    settings['tel_regex'] = '\+\s\d+\s\d{2}\s\d{3}-\d{2}-\d{2}'
    settings['url_regex'] = 'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)'


    module = sys.modules[__name__]
    for (key, val) in settings.items():
        setattr(module, key.upper(), val)


    return settings
def test_factory():
    config = load_yml('factory_pattern/config.yml')
    factory_pattern = config['factory_pattern']
    factory = get_instance_of_attr(factory_pattern['factory'])
    chart = factory.get_chart(factory_pattern['chart_type'])
    chart.display()
Exemplo n.º 3
0
def test_facade():
    config = load_yml('facade_pattern/config.yml')
    facade_pattern = config['facade']
    facade = get_instance_of_attr(facade_pattern)('test_file')
    facade.encrypt()
Exemplo n.º 4
0
import os
import glob
import socket
import tensorflow as tf
import time
import datetime
import neuralgym as ng

from model import HinpaintModel
from utils import load_yml
from trainer import HiTrainer, d_graph_deploy, get_batch, g_graph_deploy, get_input_queue 									  

if __name__ == "__main__":
    config = load_yml('config.yml')
    if config.GPU_ID != -1:
        gpu_ids = config.GPU_ID
    else:
        gpu_ids = [0]

    print('building networks and losses...')
    enq_ops = []
    # load training data
    with open(config.TRAIN_LIST) as f:
        fnames = f.read().splitlines()
        endnd = (len(fnames) // config.BATCH_SIZE) * config.BATCH_SIZE
        fnames = fnames[:endnd]
        
    #input_queue, enq_op = get_input_queue(fnames)
    data = ng.data.DataFromFNames(fnames, config.IMG_SHAPE, random_crop=config.RANDOM_CROP, \
                           enqueue_size=32, queue_size=256, nthreads=config.N_THREADS)
    #enq_ops.append(enq_op)
def test_abstract_factory():

    config = load_yml('factory_pattern/config.yml')
    factory_pattern = config['abstract_factory']
    chart = get_instance_of_attr(factory_pattern['chart'])()
    chart.draw_chart()
Exemplo n.º 6
0
def test_bridge():
    config = load_yml('bridge_pattern/config.yml')
    os = get_instance_of_attr(config['os'])()
    image = get_instance_of_attr(config['image'])()
    image.setImageImp(os)
    image.parseFile('leo.jpg')