コード例 #1
0
ファイル: utils.py プロジェクト: tbweng/C-PAC
def merge_boxplots(base_dir):
    '''
    Function which merges the pre-computed box-plots via the
    merged_paths.yml files in the working directory
    '''

    # Import packages
    import os
    import yaml

    # Init variables
    yamls = []
    rho_dicts = {}
    merged_dict = {}

    # Collect yamls in base directory
    for root, dirs, files in os.walk(base_dir):
        yamls.extend([os.path.join(root, file) for file in files \
                      if file.endswith('merged_paths.yml')])

    # For each yaml
    for yaml in yamls:
        img_type = yaml.split(os.path.sep)[-3].rstrip('_test')
        rho_dicts[img_type] = read_and_correlate(yaml)

    # Expand dict
    for centrality, rho_dict in rho_dicts.items():
        for img_type, rhos in rho_dict.items():
            merged_dict['_'.join([centrality, img_type])] = rhos

    # Generate and return the output
    out_png = gen_boxplots(base_dir, merged_dict, 'merged')
    return out_png
コード例 #2
0
ファイル: utils.py プロジェクト: FCP-INDI/C-PAC
def merge_boxplots(base_dir):
    '''
    Function which merges the pre-computed box-plots via the
    merged_paths.yml files in the working directory
    '''

    # Import packages
    import os
    import yaml

    # Init variables
    yamls = []
    rho_dicts = {}
    merged_dict = {}

    # Collect yamls in base directory
    for root, dirs, files in os.walk(base_dir):
        yamls.extend([os.path.join(root, file) for file in files \
                      if file.endswith('merged_paths.yml')])

    # For each yaml
    for yaml in yamls:
        img_type = yaml.split(os.path.sep)[-3].rstrip('_test')
        rho_dicts[img_type] = read_and_correlate(yaml)

    # Expand dict
    for centrality, rho_dict in rho_dicts.items():
        for img_type, rhos in rho_dict.items():
            merged_dict['_'.join([centrality, img_type])] = rhos

    # Generate and return the output
    out_png = gen_boxplots(base_dir, merged_dict, 'merged')
    return out_png
コード例 #3
0
ファイル: SwBuilder.py プロジェクト: dean5450/iVisDesigner
def mustache_scanner(node, env, path):
    files = [];
    text = ensure_unicode(node.get_text_contents(), 'utf-8')
    result = regex_mustache_render_first.findall(text)
    for mustache in result:
        files.append(get_mustache_path(mustache.split(".")[0]))
    result = regex_mustache_render_yaml_include.findall(text)
    for yaml in result:
        files.append(get_yaml_path(yaml.split(" ")[0]))
    return env.File(files);
コード例 #4
0
ファイル: SwBuilder.py プロジェクト: nirmal-wack/SwBuilder
def mustache_scanner(node, env, path):
    files = [];
    text = ensure_unicode(node.get_text_contents(), 'utf-8')
    result = regex_mustache_render_first.findall(text)
    for mustache in result:
        files.append(get_mustache_path(mustache.split(".")[0]))
    result = regex_mustache_render_yaml_include.findall(text)
    for yaml in result:
        files.append(get_yaml_path(yaml.split(" ")[0]))
    return env.File(files);
コード例 #5
0
ファイル: util_.py プロジェクト: kurtespinosa/eventmodels
def extract_yaml_name(yaml):
    '''
    Extracts the yaml filename.

    :param yaml: filepath of yaml file
    :return: filename
    '''
    temp1 = yaml.split("/")
    name = temp1[-1].split(".yaml")[0]
    return name
コード例 #6
0
def splitIntoFiles(fileName):
    yaml = ""
    with open(fileName) as file:
        yaml = file.read()
    return yaml.split("---")
コード例 #7
0
def extract_sprites(style, local, resolution):
    if local:
        src_yaml = "spritesheet/%s@%sx.yaml" % (style, resolution)
        # note, Mac new lines, omg
        f = open(src_yaml, 'rU')
        yaml = f.read()
        f.close()
    else:
        if style == "bubble-wrap":
            src_yaml = "https://mapzen.com/carto/%s-style/%s.yaml" % (style,
                                                                      style)
        else:
            src_yaml = "https://mapzen.com/carto/%s-style/%s-style.yaml" % (
                style, style)
        rsp = requests.get(src_yaml)
        yaml = rsp.content

    #print yaml

    # See notes and comments in here. Parsers, yeah?
    # https://github.com/whosonfirst/whosonfirst-www-boundaryissues/issues/73
    # (20160323/thisisaaronland)
    """
    data = yaml.safe_load(rsp.content)
    print data
    sys.exit()
    """

    textures = False
    pois = False
    sprites = False

    sprite = {}
    url = None

    for ln in yaml.split("\n"):

        ln = ln.strip()

        if ln.startswith("#"):
            continue

        if ln == 'textures:':
            textures = True

        if not textures:
            continue

        if ln == 'pois:':
            pois = True

        if not pois:
            continue

        if ln.startswith('url:'):

            ignore, url = ln.split(': ')

        if ln == 'sprites:':
            sprites = True

        if not sprites:
            continue

        if ln == '':
            break

        m = pat.match(ln)

        if not m:
            continue

        g = m.groups()

        name = g[0]
        dims = map(int, g[1:])

        sprite[name] = dims

    return sprite, url
コード例 #8
0
ファイル: extract.py プロジェクト: tangrams/icons
def extract_sprites(style, local, resolution):
    if local:
        src_yaml = "spritesheet/%s@%sx.yaml" % (style, resolution)
        # note, Mac new lines, omg
        f = open(src_yaml, 'rU')
        yaml = f.read()
        f.close()
    else:
        if style == "bubble-wrap":
            src_yaml = "https://mapzen.com/carto/%s-style/%s.yaml"  % (style, style)
        else:
            src_yaml = "https://mapzen.com/carto/%s-style/%s-style.yaml"  % (style, style)
        rsp = requests.get(src_yaml)
        yaml = rsp.content

    #print yaml

    # See notes and comments in here. Parsers, yeah?
    # https://github.com/whosonfirst/whosonfirst-www-boundaryissues/issues/73
    # (20160323/thisisaaronland)

    """
    data = yaml.safe_load(rsp.content)
    print data
    sys.exit()
    """

    textures = False
    pois = False
    sprites = False

    sprite = {}
    url = None

    for ln in yaml.split("\n"):

        ln = ln.strip()

        if ln.startswith("#"):
            continue

        if ln == 'textures:':
            textures = True

        if not textures:
            continue

        if ln == 'pois:':
            pois = True

        if not pois:
            continue

        if ln.startswith('url:'):

            ignore, url = ln.split(': ')

        if ln == 'sprites:':
            sprites = True

        if not sprites:
            continue

        if ln == '':
            break

        m = pat.match(ln)

        if not m:
            continue

        g = m.groups()

        name = g[0]
        dims = map(int, g[1:])

        sprite[name] = dims

        #print( name, sprite[name] )

    return sprite, url