コード例 #1
0
def dict_to_keys(data):
    """
    Returns a list of the keys for this pattern.
    The list is sorted by appearance in the pattern.

    This list is used to sort the data dict as the sid pattern.

    :param data:
    :return:
    """

    data = data.copy()

    if not data:
        raise SpilException('[dict_to_keys] Data is empty')
    _type = get_sidtype(data)
    basetype = _type.split('_')[0]
    pattern = sid_templates.get(_type)

    if not pattern:
        raise SpilException(
            '[dict_to_keys] Unable to find pattern for sidtype: "{}" \nGiven data: "{}"'
            .format(_type, data))

    template = lucidity.Template(_type, pattern)

    if not template:
        raise SpilException('toe')

    keys = values_sorted.get(basetype).get('keys')
    keys = filter(lambda x: x in template.keys(), keys)
    return keys
コード例 #2
0
ファイル: location.py プロジェクト: flavienliger/gazu
 def get_file_name_map(self):
     templates = [
         lucidity.Template(
             "asset_build",
             "{asset_build}_{asset}_{component_name}_{asset_version}{seq}{ext}",
         ),
         lucidity.Template(
             "asset_only",
             "{asset}_{component_name}_{asset_version}{seq}{ext}"),
         lucidity.Template(
             "shot",
             "{shot}_{asset}_{component_name}_{asset_version}{seq}{ext}"),
         lucidity.Template(
             "sequence",
             "{sequence}_{asset}_{component_name}_{asset_version}{seq}{ext}",
         ),
     ]
     return lucidity_resolver(templates)
コード例 #3
0
def texture_file_template(custom_pattern=None):
    """
    Get a lucidity Template object using a custom template.

    Kwargs:
       custom_pattern (str):  Custom lucidity file pattern.

    Returns:
        lucity.Template object with the custom partern

    """
    logger.info('Loading lucidity with:\n    %s' % custom_pattern)
    texture_file_template = lucidity.Template(
        'textureset_element',
        custom_pattern,
        anchor=lucidity.Template.ANCHOR_END
        # TODO (Eze) Add STRICT?
    )
    return texture_file_template
コード例 #4
0
def dict_to_sid(data):

    data = data.copy()

    if not data:
        raise SpilException('[dict_to_sid] Data is empty')
    _type = get_sidtype(data)
    pattern = sid_templates.get(_type)

    if not pattern:
        raise SpilException(
            '[dict_to_sid] Unable to find pattern for sidtype: "{}" \nGiven data: "{}"'
            .format(_type, data))

    template = lucidity.Template(_type, pattern)

    if not template:
        raise SpilException('toe')
    sid = template.format(data).rstrip(sip)
    return sid
コード例 #5
0
def parse_sid(sid, pattern, name='template'):

    template = lucidity.Template(
        name,
        pattern,
        default_placeholder_expression=
        '[^/]*',  # allows for empty keys // should it be '[^|]*' ?
        anchor=lucidity.Template.ANCHOR_BOTH)

    diff = template.pattern.count(sip) - sid.count(
        sip)  # allowing sids to be open at the end
    if diff > 0:
        sid = sid + sip * diff

    try:
        data = template.parse(sid)
        debug('{} matched template "{}"'.format(sid, name))
        return data

    except Exception as e:
        debug('{} did not match template "{}" (error:{})'.format(sid, name, e))
        return None
コード例 #6
0
    def parsing_config_file(self, config_file):
        """parse the yaml file and return some lucidity patterns """
        path = framework_config.get_framework_path(
        ) + os.sep + "pipeline" + os.sep + config_file
        #print("path = "+path)
        templates = {}
        #parsing the config yml file
        yaml_file = open(path, 'r')
        yaml_content = yaml.safe_load(yaml_file)

        #print("key : value")
        for key, value in yaml_content.items():
            #print(f"Key value = {key}: {value}")
            raw_value = value
            for i in range(
                    0,
                    value.count('$')):  #loop over all keywork begining with $
                #print("dolar word = "+str(i))
                for key_word in self.key_value:  # determine wich key is it
                    if key_word in value:  #if the detected key has been found
                        #print("detected key_word = " + key_word)
                        detected_key = key_word.replace(
                            "$", '')  # delete the "$" symbol
                        raw_value = raw_value.replace(
                            key_word, yaml_content[detected_key])
                        #print("raw_value = "+raw_value)
                        yaml_content[
                            key] = raw_value  #value.replace(key_word, yaml_content[detected_key])  # assign the new value
            """if("$" in value): #detect a keyvalue in the string
                for i in self.key_value: #determine wich key is it
                    if i in value: #if the detected key has been found
                        print("detect i = "+i)
                        detected_key = i.replace("$", '') #delete the "$" symbol
                        print("yaml_content[key] = "+yaml_content[key])
                        yaml_content[key] = value.replace(i,yaml_content[detected_key] ) #assign the new value
                        print("yaml_content[key]2 = "+yaml_content[key])
                        #print("new value = "+yaml_content[key])"""
            templates[key] = lucidity.Template(key, yaml_content[key])
        return templates
コード例 #7
0
    def parsing_config_file(self, config_file):
        """parse the yaml file and return some lucidity patterns """
        templates = {}
        #parsing the config yml file
        yaml_file = open(config_file, 'r')
        yaml_content = yaml.safe_load(yaml_file)

        print("key : value")
        for key, value in yaml_content.items():
            print(f"{key}: {value}")
            if ("$" in value):  #detect a keyvalue in the string
                for i in self.key_value:  #determine wich key is it
                    if i in value:  #if the detected key has been found
                        detected_key = i.replace("$",
                                                 '')  #delete the "$" symbol
                        value = value.replace(
                            i,
                            yaml_content[detected_key])  #assign the new value
                        yaml_content[key] = value
                        #print("new value = "+yaml_content[key])
            templates[key] = lucidity.Template(key, yaml_content[key])
        return templates
コード例 #8
0
def templates():
    '''Return candidate templates.'''
    return [
        lucidity.Template('model', '/jobs/{job.code}/assets/model/{lod}'),
        lucidity.Template('rig', '/jobs/{job.code}/assets/rig/{rig_type}')
    ]
コード例 #9
0
def register():
    '''Register templates.'''
    return [
        lucidity.Template('c', '/c/pattern'),
        lucidity.Template('d', '/d/pattern')
    ]
コード例 #10
0
def register():
    '''Register templates.'''
    return [
        lucidity.Template('a', '/a/pattern'),
        lucidity.Template('b', '/b/pattern')
    ]