Commit fcfb8126 authored by Savva Golubitsky's avatar Savva Golubitsky

array of objects changed to dict

parent 3b1e99df
...@@ -10,7 +10,6 @@ scope = [ ...@@ -10,7 +10,6 @@ scope = [
class Stmt(): class Stmt():
__slots__=( __slots__=(
'name',
'module', 'module',
'entry_func', 'entry_func',
'predicate', 'predicate',
...@@ -19,10 +18,9 @@ class Stmt(): ...@@ -19,10 +18,9 @@ class Stmt():
'morphism', 'morphism',
'parallelism' 'parallelism'
) )
def __init__(self, name): def __init__(self):
for slot in self.__slots__: for slot in self.__slots__:
setattr(self, slot, None) setattr(self, slot, None)
self.name = name
def __str__(self): def __str__(self):
stri = "" stri = ""
...@@ -42,18 +40,21 @@ if graphcheck is None: ...@@ -42,18 +40,21 @@ if graphcheck is None:
# Все что до __BEGIN__ считается объявлением # Все что до __BEGIN__ считается объявлением
beg = re.search((scope[0]), dotfile).start() beg = re.search((scope[0]), dotfile).start()
stmts = [] stmts = {}
rawstmts = re.findall(r"\w+\s\[.*\]", dotfile[:beg]) rawstmts = re.findall(r"\w+\s\[.*\]", dotfile[:beg])
for raw in rawstmts: for raw in rawstmts:
res = raw.split(r" ", 1) res = raw.split(r" ", 1)
st = Stmt(res[0]) st = Stmt()
rs =res[1][1:-1].split(r", ") rs =res[1][1:-1].split(r", ")
for r in rs: for r in rs:
r=r.split(r"=", 1) r=r.split(r"=", 1)
for s in st.__slots__: for s in st.__slots__:
if s == r[0]: if s == r[0]:
setattr(st, s, r[1]) setattr(st, s, r[1])
print(st) stmts[res[0]] = st
stmts.append(st)
for s in stmts:
print(s, stmts[s])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment