Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
strings_for_ncfile.py 882 B
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def features_to_char(feat):

    """
        Turn list of features to chars so it can be stored in the nc-file.
    """

    char_features = []
    for feature in feat:
        for letter in feature:
            char_features.append(letter)
        char_features.append('/')
    char_features = char_features[0:-1]

    return char_features


def char_to_string(features):

    """
        Input:
            features: list of features as chars

        Return:
            features as strings

        Turns list of chars into strings providing information on
        contained features in nc-file. Feature names have to be separated
        by '/'.
    """

    features_decode = []
    for feature in features:

        features_decode.append(feature.decode('UTF-8'))

    tmp = ''.join(features_decode)

    return tmp.split('/')