コード例 #1
0
ファイル: mapping.py プロジェクト: jagarcias/openspending.etl
def date_schema(name, state):
    schema = property_schema(name, state)
    schema.add(key('column', validator=chained(
            nonempty_string,
        )))
    schema.add(key('datatype', validator=chained(
            nonempty_string,
            specific_datatype('date')
        )))
    return schema
コード例 #2
0
ファイル: mapping.py プロジェクト: jagarcias/openspending.etl
def attribute_dimension_schema(name, state):
    schema = property_schema(name, state)
    schema.add(key('column', validator=chained(
            nonempty_string,
        )))
    schema.add(key('datatype', validator=chained(
            nonempty_string,
            valid_datatype,
        )))
    return schema
コード例 #3
0
ファイル: mapping.py プロジェクト: jagarcias/openspending.etl
def property_schema(name, state):
    """ This is validation which is common to all properties,
    i.e. both dimensions and measures. """
    schema = mapping(name, validator=chained(
        name_wrap(reserved_name, name),
        name_wrap(database_name, name),
        no_dimension_id_overlap(name, state)
        ))
    schema.add(key('label', validator=chained(
            nonempty_string,
        )))
    schema.add(key('description', validator=chained(
            nonempty_string,
        ), missing=None))
    return schema
コード例 #4
0
ファイル: views.py プロジェクト: jagarcias/openspending.etl
def view_schema(state):
    schema = mapping('view')
    schema.add(key('name', validator=chained(
            nonempty_string,
            database_name
        )))
    schema.add(key('label', validator=nonempty_string))
    schema.add(key('dimension', 
                   validator=dimension_or_dataset(state)))
    schema.add(key('drilldown', 
                   validator=dimension_or_not(state),
                   missing=None))
    schema.add(mapping('cuts', 
                       validator=key_is_attribute(state),
                       missing={}))
    return schema
コード例 #5
0
ファイル: mapping.py プロジェクト: jagarcias/openspending.etl
def dimension_attribute_schema(state):
    schema = mapping('field', validator=chained(
            compound_attribute_name_is_id_type,
            compound_attribute_label_is_string_type
        ))
    schema.add(key('name', validator=chained(
            nonempty_string,
            reserved_name,
            database_name
        )))
    schema.add(key('column', validator=chained(
            nonempty_string,
        )))
    schema.add(key('datatype', validator=chained(
            nonempty_string,
            valid_datatype
        )))
    return schema
コード例 #6
0
ファイル: dataset.py プロジェクト: jagarcias/openspending.etl
def dataset_schema(state):
    schema = mapping('dataset')
    schema.add(key('name', validator=chained(
            nonempty_string,
            reserved_name,
            database_name,
            no_double_underscore
        )))
    schema.add(key('currency', validator=chained(
            valid_currency
        )))
    schema.add(key('label', validator=chained(
            nonempty_string,
        )))
    schema.add(key('description', validator=chained(
            nonempty_string,
        )))
    schema.add(sequence('unique_keys',
        key('key', validator=chained(
            unique_keys_are_attributes(state),
        )), missing=[]))
    return schema