Skip to content

Details

DatastoreResourceDetails

Bases: DomainObject

Object for holding datastore resource details, currently just the columns at each version.

Source code in ckanext/versioned_datastore/model/details.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class DatastoreResourceDetails(DomainObject):
    """
    Object for holding datastore resource details, currently just the columns at each
    version.
    """

    def get_columns(self, validate=None, skip_empty=True, fix_names=True):
        """
        Retrieve the columns contained in this resource's version.

        :param validate: for backwards compatibility; sets both skip_empty and fix_names
        :param skip_empty: if True, remove falsey (empty strings, Nones) columns
            (default True)
        :param fix_names: if True, change column names to match datastore/splitgill
            (default True)
        :returns: a list of column names in the order they were in the original data
            source
        """
        if validate is not None:
            skip_empty = validate
            fix_names = validate

        columns = []
        for column in json.loads(self.columns):
            if skip_empty and not column:
                continue
            if fix_names:
                column = prepare_field_name(column)
            columns.append(column)
        return columns

get_columns(validate=None, skip_empty=True, fix_names=True)

Retrieve the columns contained in this resource's version.

Parameters:

Name Type Description Default
validate

for backwards compatibility; sets both skip_empty and fix_names

None
skip_empty

if True, remove falsey (empty strings, Nones) columns (default True)

True
fix_names

if True, change column names to match datastore/splitgill (default True)

True

Returns:

Type Description

a list of column names in the order they were in the original data source

Source code in ckanext/versioned_datastore/model/details.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def get_columns(self, validate=None, skip_empty=True, fix_names=True):
    """
    Retrieve the columns contained in this resource's version.

    :param validate: for backwards compatibility; sets both skip_empty and fix_names
    :param skip_empty: if True, remove falsey (empty strings, Nones) columns
        (default True)
    :param fix_names: if True, change column names to match datastore/splitgill
        (default True)
    :returns: a list of column names in the order they were in the original data
        source
    """
    if validate is not None:
        skip_empty = validate
        fix_names = validate

    columns = []
    for column in json.loads(self.columns):
        if skip_empty and not column:
            continue
        if fix_names:
            column = prepare_field_name(column)
        columns.append(column)
    return columns