def compress_subproperties(properties): """ Combine all subproperties into their parent properties Requires: for every subproperty, there is a parent property. All features are explicitly expressed. This rule probably shouldn't be needed, but build-request.expand-no-defaults is being abused for unintended purposes and it needs help """ result = [] matched_subs = [] for p in properties: pg = get_grist(p) if not pg: raise BaseException("Gristed variable exppected. Got '%s'." % p) if not 'subfeature' in __all_features[pg]['attributes']: subs = __select_subproperties(p, properties) matched_subs.extend(subs) subvalues = '-'.join(get_value(subs)) if subvalues: subvalues = '-' + subvalues result.append(p + subvalues) else: all_subs.append(p) # TODO: this variables are used just for debugging. What's the overhead? assert (set.equal(all_subs, matched_subs)) return result
def compress_subproperties (properties): """ Combine all subproperties into their parent properties Requires: for every subproperty, there is a parent property. All features are explicitly expressed. This rule probably shouldn't be needed, but build-request.expand-no-defaults is being abused for unintended purposes and it needs help """ result = [] matched_subs = [] for p in properties: pg = get_grist (p) if not pg: raise BaseException ("Gristed variable exppected. Got '%s'." % p) if not 'subfeature' in __all_features [pg]['attributes']: subs = __select_subproperties (p, properties) matched_subs.extend (subs) subvalues = '-'.join (get_value (subs)) if subvalues: subvalues = '-' + subvalues result.append (p + subvalues) else: all_subs.append (p) # TODO: this variables are used just for debugging. What's the overhead? assert (set.equal (all_subs, matched_subs)) return result