From bd69936da8e1f59147b7e2dde0f53067ee1ff94a Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Thu, 03 Mar 2016 16:53:58 +0000 Subject: [PATCH] Reading type in python --- python/trisurf/trisurf.py | 24 ++++++++++++++++++++---- python/trisurf/__pycache__/trisurf.cpython-34.pyc | 0 python/tsmgr | 3 ++- python/trisurf/.trisurf.py.swp | 0 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/python/trisurf/.trisurf.py.swp b/python/trisurf/.trisurf.py.swp index 1bcbfdb..b897158 100644 --- a/python/trisurf/.trisurf.py.swp +++ b/python/trisurf/.trisurf.py.swp Binary files differ diff --git a/python/trisurf/__pycache__/trisurf.cpython-34.pyc b/python/trisurf/__pycache__/trisurf.cpython-34.pyc index ea75c60..310179a 100644 --- a/python/trisurf/__pycache__/trisurf.cpython-34.pyc +++ b/python/trisurf/__pycache__/trisurf.cpython-34.pyc Binary files differ diff --git a/python/trisurf/trisurf.py b/python/trisurf/trisurf.py index 6a86b6e..d777610 100644 --- a/python/trisurf/trisurf.py +++ b/python/trisurf/trisurf.py @@ -1,6 +1,11 @@ #!/usr/bin/python3 import configobj +import xml.etree.ElementTree as ET +import base64 +import zlib +import io + ''' This is a trisurf instance manager written in python @@ -30,7 +35,7 @@ def setTape(self, string): - self.tape=string + self.config=configobj.ConfigObj(io.StringIO(string)) return def getValue(self,key): @@ -45,10 +50,21 @@ def initFromTape(self, tape): self.tape=Tape() self.tape.readTape(tape) - pass - def initFromSnapshot(self, tape='snapshot.vtu'): - pass + def initFromSnapshot(self, snapshotfile): + try: + tree = ET.parse(snapshotfile) + except: + print("Error reading snapshot file") + exit(1) + + root = tree.getroot() + tapetxt=root.find('tape') + version=root.find('trisurfversion') + #print("Reading snapshot made from: "+version.text) + self.tape=Tape() + #print(tapetxt.text) + self.tape.setTape(tapetxt.text) def __init__(self, subdir='run0', tape='', snapshot=''): self.subdir=subdir diff --git a/python/tsmgr b/python/tsmgr index f82906a..d69312c 100755 --- a/python/tsmgr +++ b/python/tsmgr @@ -4,6 +4,7 @@ -run1=trisurf.Runner(tape='tape') +run1=trisurf.Runner(snapshot='snapshot.vtu') print(run1) +#print(run1.tape.config) print(run1.tape.getValue('nshell')) -- Gitblit v1.9.3