Пример #1
0
def to_expressions(activity, activity_code):
    expressions = OrderedDict()
    prefix = ''
    if activity_code:
        prefix = activity_code+"_"
    for state_code, state in Descriptor.as_items(activity.states):
        for source_code, source in Descriptor.as_items(state.sources):
            suffix = "_"+source_code
            if len(source.uids) > 1:
                state_expressions = []
                for idx in range(len(source.uids)):
                    state_expressions.append(
                        prefix+state_code+"_"+str(idx+1)+suffix)
                expressions[prefix+state_code+suffix] = state_expressions
    return expressions
Пример #2
0
def to_mappings(activity, activity_code):
    mappings = OrderedDict()
    prefix = ''
    if activity_code:
        prefix = activity_code+"_"
    for state_code, state in Descriptor.as_items(activity.states):
        for source_code, source in Descriptor.as_items(state.sources):
            suffix = "_"+source_code
            if len(source.uids) == 1:
                mappings[source.uids[0]] = prefix+state_code+suffix
            else:
                for idx, uid in enumerate(source.uids):
                    mappings[uid] = prefix+state_code + \
                        "_" + str(idx+1) + suffix
    return mappings
Пример #3
0
    def dump_to_s3(self):
        for activity_code, activity in Descriptor.as_items(self.config.activities):
            if activity_code.startswith("DISABLED_"):
                continue

            self.dump(activity, activity_code)
Пример #4
0
def to_data_elements(activity):
    data_elements = []
    for _state_code, state in Descriptor.as_items(activity.states):
        for _source_code, source in Descriptor.as_items(state.sources):
            data_elements.extend(source.uids)
    return data_elements