Skip to content
Snippets Groups Projects
Commit 22587cf9 authored by mads's avatar mads
Browse files

fixed utf8 problem

parent cac56aeb
No related branches found
No related tags found
No related merge requests found
...@@ -51,7 +51,7 @@ class HTCFile(HTCContents, HTCDefaults): ...@@ -51,7 +51,7 @@ class HTCFile(HTCContents, HTCDefaults):
def readlines(self, filename): def readlines(self, filename):
self.htc_inputfiles.append(filename) self.htc_inputfiles.append(filename)
htc_lines = [] htc_lines = []
with open(filename, encoding='utf-8') as fid: with open(filename) as fid:
lines = fid.readlines() lines = fid.readlines()
for l in lines: for l in lines:
if l.lower().lstrip().startswith('continue_in_file'): if l.lower().lstrip().startswith('continue_in_file'):
......
begin Simulation; begin Simulation;
time_stop 10 ; time_stop 10 ;
solvertype 1 ; (newmark) solvertype 1 ; (newmark)
on_no_convergence continue ; on_no_convergence continue ;
......
...@@ -24,25 +24,25 @@ class TestHtcFile(unittest.TestCase): ...@@ -24,25 +24,25 @@ class TestHtcFile(unittest.TestCase):
def check_htc_file(self, f): def check_htc_file(self, f):
with open(f) as fid: with open(f) as fid:
orglines = fid.readlines() orglines = fid.readlines()
htcfile = HTCFile(f) htcfile = HTCFile(f)
newlines = str(htcfile).split("\n") newlines = str(htcfile).split("\n")
htcfile.save(self.testfilepath + 'tmp.htc') htcfile.save(self.testfilepath + 'tmp.htc')
#with open(self.testfilepath + 'tmp.htc') as fid: #with open(self.testfilepath + 'tmp.htc') as fid:
# newlines = fid.readlines() # newlines = fid.readlines()
for i, (org, new) in enumerate(zip(orglines, newlines), 1): for i, (org, new) in enumerate(zip(orglines, newlines), 1):
fmt = lambda x : x.strip().replace("\t", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ") fmt = lambda x : x.strip().replace("\t", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ")
if fmt(org) != fmt(new): if fmt(org) != fmt(new):
print ("----------%d-------------" % i) print ("----------%d-------------" % i)
print (fmt(org)) print (fmt(org))
print (fmt(new)) print (fmt(new))
self.assertEqual(fmt(org), fmt(new)) self.assertEqual(fmt(org), fmt(new))
break break
print () print ()
assert len(orglines) == len(newlines) assert len(orglines) == len(newlines)
def test_htc_files(self): def test_htc_files(self):
for f in ['test3.htc']: for f in ['test3.htc']:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment