コード例 #1
0
def create_files(components: list):
    path = "output/rel/"
    print('dumping files to {0}'.format(path))
    if not os.path.exists(path):
        os.makedirs(path)

    user_strings = []

    Helpers.append_line(
        user_strings,
        '{0},{1},{2},{3},{4}'.format('Component Type', 'Sub Component Type',
                                     'Attribute', 'Type', 'Component'))
    for type, json_definition in components:
        if json_definition:
            response = cs.Response(json_definition)
            if response.component:
                component = response.component
                append_attribute_user_string_row(user_strings,
                                                 component.attributes,
                                                 component.name, '')

                for sub in component.sub_components:
                    append_attribute_user_string_row(user_strings,
                                                     sub.attributes,
                                                     component.name, sub.name)

    Helpers.save_as_file('relationships', to_string(user_strings), path, 'csv')
コード例 #2
0
ファイル: spec_component.py プロジェクト: defaultbob/Vault
def convert_json_to_markdown(json_definition):

    markdown = []
    words = dict(get_common_strings())

    if json_definition:
        response = cs.Response(json_definition)
        if response.component:
            component = response.component
            append_line(markdown, "# " + component.name)

            append_line(markdown,
                        get_string_replacement_tag(component.name, 'overview'))
            append_line(markdown, '')
            append_line(
                markdown,
                get_string_replacement_tag(component.name,
                                           'overview_description'))

            append_line(markdown, '')
            append_line(
                markdown, words["abbreviation"] + words["separator"] +
                component.abbreviation)

            append_line(markdown, '## ' + words['component'])

            component_attribute_markdown = build_attribute_markdown(
                component, words)
            append_line(markdown, component_attribute_markdown)

            for sub in component.sub_components:
                append_line(
                    markdown, '### ' + words['sub_component'] +
                    words["separator"] + sub.name)
                sub_component_attribute_markdown = build_attribute_markdown(
                    sub, words)
                append_line(markdown, sub_component_attribute_markdown)

            return to_string(markdown)
        else:
            append_line(markdown, "# " + response.name)

    append_line(markdown, "*" + words["no_docs"] + "*")
    return to_string(markdown)
コード例 #3
0
ファイル: spec_component.py プロジェクト: defaultbob/Vault
def create_user_strings_json(type: str, path: str, json_definition):

    user_strings = default_component_user_strings()

    if json_definition:
        response = cs.Response(json_definition)
        if response.component:
            component = response.component

            for attr in component.attributes:
                user_strings[attr.name] = ''

            for sub in component.sub_components:
                sub_comp_strings = default_component_user_strings()
                for sub_attr in sub.attributes:
                    sub_comp_strings[sub_attr.name] = ''
                user_strings[sub.name] = sub_comp_strings

    Helpers.dump_json_file(type, user_strings, path)
コード例 #4
0
ファイル: spec_component.py プロジェクト: defaultbob/Vault
def create_user_strings(type: str, path: str, json_definition):

    user_strings = []

    if json_definition:
        response = cs.Response(json_definition)
        if response.component:
            component = response.component

            append_attribute_user_string_row(user_strings,
                                             component.attributes,
                                             component.name)

            for sub in component.sub_components:
                append_attribute_user_string_row(user_strings, sub.attributes,
                                                 sub.name)

    file_name = get_string_filename(type)
    Helpers.save_as_file(file_name, to_string(user_strings), path, 'yml')
コード例 #5
0
def convert_json_to_markdown(json_definition):

    markdown = []
    words = dict(mdh.get_common_strings())

    if json_definition:
        response = cs.Response(json_definition)
        
        #Helpers.append_line(markdown, '## ' + words['component'])
        if response.component:
            component = response.component

            component_attribute_markdown = build_attribute_markdown(component, words, component.name)
            Helpers.append_line(markdown, component_attribute_markdown)

            for sub in component.sub_components:            
                Helpers.append_line(markdown, '### ' + sub.name)
                sub_component_attribute_markdown = build_attribute_markdown(sub, words, component.name)
                Helpers.append_line(markdown, sub_component_attribute_markdown)

            return to_string(markdown)

    Helpers.append_line(markdown, "*" + words["no_docs"] + "*")
    return to_string(markdown)