From 590a1ceef54834bdffc6963dcdc4b95318fd757e Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 26 Jan 2017 10:54:07 -0600 Subject: [PATCH] Fix pertinant children in graph --- src/entity.py | 5 +++++ src/irpy_files.py | 4 ++-- src/parsed_text.py | 20 +++++++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/entity.py b/src/entity.py index 1d49957..98b8bef 100644 --- a/src/entity.py +++ b/src/entity.py @@ -691,6 +691,11 @@ class Entity(object): #Set by parsed_text.build_needs(...) raise AttributeError + @irpy.lazy_property_mutable + def needed_by(self): + #Set by parsed_text.build_needs(...) + return [] + @irpy.lazy_property def children(self): diff --git a/src/irpy_files.py b/src/irpy_files.py index 3632a2d..dc0a19b 100644 --- a/src/irpy_files.py +++ b/src/irpy_files.py @@ -114,7 +114,7 @@ class Irpy_comm_world(object): Ent_part = partial(Entity,buf,icount,comm_world=self) ent = Ent_part() - l_ent += [ent] + [Ent_part(other) for other in ent.others_entity_name] + l_ent += [ent] + [Ent_part(name) for name in ent.others_entity_name] # O(2) but who care l_duplicate = [x for x in l_ent if l_ent.count(x) > 1] @@ -227,7 +227,7 @@ class Irpy_comm_world(object): d_routine = self.d_routine import parsed_text - vtuple = [(v, s.same_as, s.regexp) for v, s in d_entity.iteritems()] + vtuple = [(v, s.regexp) for v, s in d_entity.iteritems()] def worker_parsed(filename_text): filename, text = filename_text return parsed_text.get_parsed_text(filename, text, d_entity, d_routine, vtuple) diff --git a/src/parsed_text.py b/src/parsed_text.py index be9dd7c..0731797 100644 --- a/src/parsed_text.py +++ b/src/parsed_text.py @@ -34,7 +34,7 @@ regexps_re_string_sub = regexps.re_string.sub def find_variables_in_line(line, vtuple): line_lower = regexps_re_string_sub('', line.lower) - return [same_as for v, same_as, regexp in vtuple if v in line_lower and regexp(line_lower)] + return [v for v, regexp in vtuple if v in line_lower and regexp(line_lower)] def find_funcs_in_line(line, stuple): @@ -96,7 +96,7 @@ def get_parsed_text(filename, text, variables, subroutines, vtuple): varlist.append(v) variable_list = find_variables_in_line(line, vtuple) - variable_list.remove(variables[v].same_as) + variable_list.remove(v) append(Parsed_text(variable_list, line)) @@ -459,6 +459,7 @@ def build_needs(parsed_text, subroutines, stuple, variables): # Needs and to_provide # ~#~#~#~#~# + # Loop of the main Entity for filename, text in parsed_text: l_begin = [i for i, (_, line) in enumerate(text) if isinstance(line, Begin_provider)] @@ -485,6 +486,8 @@ def build_needs(parsed_text, subroutines, stuple, variables): entity.needs = uniquify(l_needs) + + # Now do the Other entity for v in variables: main = variables[v].same_as if main != v: @@ -492,11 +495,15 @@ def build_needs(parsed_text, subroutines, stuple, variables): variables[v].to_provide = variables[main].to_provide # ~#~#~#~#~# - # Needs and to_provide + # Needs_by # ~#~#~#~#~# - for v in variables: - variables[v].needed_by = [] + # This a some dark vodou magic. + # The algo is: + # - Initialise needed_by + # - Create the pointer copy + # - Add the value (so it add also to the pointer reference...) + for v in variables: main = variables[v].same_as if main != v: @@ -508,8 +515,7 @@ def build_needs(parsed_text, subroutines, stuple, variables): for x in var.needs: variables[x].needed_by.append(var.same_as) - for v in variables: - var = variables[v] + for var in variables.values(): var.needed_by = uniquify(var.needed_by) ######################################################################