Esempio n. 1
0
def extract_properties_from_export(export,
                                   props: PriorityPropDict,
                                   recurse=False):
    '''Restricted version of gather_properties that only act on a single export (and optionally its parents).'''
    if recurse:
        parent = ark.tree.get_parent_of_export(export)
        if parent:
            extract_properties_from_export(parent, props, recurse=recurse)

    for prop in export.properties.values:
        propname = get_clean_name(prop.header.name)
        if propname:
            propindex = prop.header.index or 0
            props[propname][propindex].append(prop.value)
Esempio n. 2
0
def clean_value_str(value, fallback=None):
    if value is None or isinstance(value, (int, str, bool)):
        return str(value)
    if isinstance(value, float) and value == int(value):
        return str(int(value))
    if isinstance(value, float):
        return str(value)
    if value.__class__.__name__ == 'FloatProperty':
        return clean_value_str(value.rounded_value)
    if value.__class__.__name__ in ('StringProperty', 'NameIndex',
                                    'NameProperty'):
        return get_clean_name(value)
    if value.__class__.__name__ in ('ByteProperty', 'IntProperty',
                                    'BoolProperty'):
        return str(value.value)
    if fallback:
        return fallback
    raise ValueError("Don't know how to handle a " + value.__class__.__name__)
Esempio n. 3
0
def show_value(msg, obj, indent=0):
    value = get_clean_name(obj)
    if value:
        pkg = calc_pkg(obj) or ''
        print(f'{"  "*indent}{msg} {value} {pkg}')