Exemplo n.º 1
0
def partial_to_dict(p: functools.partial, version="3"):
    assert not p.args, "So far only keyword arguments are supported, here"
    fields = {
        k: v.default
        for k, v in inspect.signature(p.func).parameters.items()
    }
    fields = {
        k: v
        for k, v in fields.items() if v is not inspect.Parameter.empty
    }
    diff = p.keywords.keys() - fields.keys()
    assert not diff, f"There are invalid keywords present: {diff}"
    fields.update(p.keywords)
    nested = {
        k: partial_to_dict(partial(v), version="")
        for k, v in fields.items() if callable(v)
    }
    simple = {k: v for k, v in fields.items() if k not in nested}
    output = {
        FKEY: p.func.__module__ + ":" + p.func.__qualname__,
        **simple,
        **nested
    }
    return dict(output, __format_version__=version) if version else output
def _generate_fact_table_sql(table_name, data_class):
    """

    :param table_name:
    :return:

    """
    fields = _get_fields_and_types(data_class)
    sql_fields = ',\n'.join(
        f"{column_name} {_SQL_TYPE_MAPPING[column_type]}" for column_name, column_type in fields.items()
    )
    return f"""
Exemplo n.º 3
0
def rec(fields):
    for n, f in fields.items():
        yield n, show_obj(f)