Пример #1
0
def print_everything(some_json, alias_name):
    stuff = json.loads(some_json)
    aliases = create_type_alias(stuff, type_alias_name=alias_name)
    decoders = [create_decoder(alias, has_snakecase=True, prefix='decode') for alias in aliases ]
    encoders = [create_encoder(alias, has_snakecase=True, prefix='encode') for alias in aliases ]

    print('\n'.join(aliases))
    print('\n'.join(decoders))
    print('\n'.join(encoders))
Пример #2
0
def from_elm_file(file_text):
    aliases = find_type_aliases(file_text)
    unions = find_union_types(file_text)


    decoders = [create_decoder(alias, has_snakecase=True, prefix='decode') for alias in aliases ]
    decoders.extend(create_union_type_decoder(union_type) for union_type in unions)
    encoders = [create_encoder(alias, has_snakecase=True, prefix='encode') for alias in aliases ]
    encoders.extend(create_union_type_encoder(union_type) for union_type in unions)

    print('\n'.join(decoders))
    print('\n'.join(encoders))
Пример #3
0
def print_everything(some_json, alias_name):
    stuff = json.loads(some_json)
    aliases = create_type_alias(stuff, type_alias_name=alias_name)
    decoders = [
        create_decoder(alias, has_snakecase=True, prefix='decode')
        for alias in aliases
    ]
    encoders = [
        create_encoder(alias, has_snakecase=True, prefix='encode')
        for alias in aliases
    ]

    print('\n'.join(aliases))
    print('\n'.join(decoders))
    print('\n'.join(encoders))
Пример #4
0
def from_elm_file(file_text):
    aliases = find_type_aliases(file_text)
    unions = find_union_types(file_text)

    decoders = [
        create_decoder(alias, has_snakecase=True, prefix='decode')
        for alias in aliases
    ]
    decoders.extend(
        create_union_type_decoder(union_type) for union_type in unions)
    encoders = [
        create_encoder(alias, has_snakecase=True, prefix='encode')
        for alias in aliases
    ]
    encoders.extend(
        create_union_type_encoder(union_type) for union_type in unions)

    print('\n'.join(decoders))
    print('\n'.join(encoders))