Skip to content

Commit

Permalink
Black formatting fluentm.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hyakuhei committed Jul 22, 2021
1 parent 3e73c0a commit a5d7526
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions fluentm.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,20 @@ class Asset(object):
def __init__(self, name):
self.name = name

if self.__class__.__name__ in Asset._instances: #e.g Boundary
if self.name in Asset._instances[self.__class__.__name__]: # eg Boundary.name == "Internet"
self.__dict__ = Asset._instances[self.__class__.__name__][self.name].__dict__ # Make both Boundary objects of "internet" have the same dict
if self.__class__.__name__ in Asset._instances: # e.g Boundary
if (
self.name in Asset._instances[self.__class__.__name__]
): # eg Boundary.name == "Internet"
self.__dict__ = Asset._instances[self.__class__.__name__][
self.name
].__dict__ # Make both Boundary objects of "internet" have the same dict
else:
Asset._instances[self.__class__.__name__][self.name] = self
else:
Asset._instances[self.__class__.__name__] = {self.name: self}

# Magic str/object function
def inBoundary(self, boundary: Union[Boundary,str]):
def inBoundary(self, boundary: Union[Boundary, str]):
if isinstance(boundary, Boundary):
self.boundary = boundary
elif isinstance(boundary, str):
Expand Down Expand Up @@ -549,7 +553,7 @@ def __repr__(self):

def renderDfd(graph: Digraph, title: str, outputDir: str):
graph.render(f"{outputDir}/{title}-dfd", format="png", view=False)
#print(graph)
# print(graph)
return f"{title}-dfd.png"


Expand Down Expand Up @@ -587,7 +591,7 @@ def dfd(scenes: dict, title: str, dfdLabels=True, render=False, simplified=False
graph_attr=clusterAttr | {"label": ptr.boundary.name},
)
ptr = ptr.boundary

placements[e.name] = boundaryClusters[e.boundary.name]
# print(f"Placing {e.name} in {boundaryClusters[e.boundary]}")
else:
Expand All @@ -597,11 +601,11 @@ def dfd(scenes: dict, title: str, dfdLabels=True, render=False, simplified=False
# Place nodes in Graphs, ready for subgraphing
for n in placements:
placements[n].node(n)
#print(f"{n} : {id(placements[n])} : {placements[n]}")
# print(f"{n} : {id(placements[n])} : {placements[n]}")

# Subgraph the nodes
for c in boundaryClusters:
b = Boundary(c) # The boundary name
b = Boundary(c) # The boundary name
if hasattr(b, "boundary"):
boundaryClusters[b.boundary.name].subgraph(boundaryClusters[c])
else:
Expand Down Expand Up @@ -641,7 +645,7 @@ def dfd(scenes: dict, title: str, dfdLabels=True, render=False, simplified=False
else:
graph.edge(flow.pitcher.name, flow.catcher.name, f"({flowCounter})")
flowCounter += 1

print("Exiting DFD")

return graph
Expand Down

0 comments on commit a5d7526

Please sign in to comment.