From cebdecfa70a99a88ee93497ae7dd03f4a1064b37 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 5 Jul 2018 11:04:39 +0200 Subject: [PATCH] if-else got reversed more readable now: --- lib/damask/config/material.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/damask/config/material.py b/lib/damask/config/material.py index 1f97561af..bb184b4d2 100644 --- a/lib/damask/config/material.py +++ b/lib/damask/config/material.py @@ -173,15 +173,17 @@ class Material(): def read(self,filename=None): - + """Reads material.config file""" def recursiveRead(filename): + """Takes care of include statements like '{}'""" result = [] re_include = re.compile(r'^{(.+)}$') with open(filename) as f: lines = f.readlines() for line in lines: match = re_include.match(line.split()[0]) if line.strip() else False - result += [line] if match else recursiveRead(match.group(1) if match.group(1).startswith('/') else - os.path.normpath(os.path.join(os.path.dirname(filename),match.group(1)))) + result += [line] if not match else \ + recursiveRead(match.group(1) if match.group(1).startswith('/') else + os.path.normpath(os.path.join(os.path.dirname(filename),match.group(1)))) return result c = recursiveRead(filename) @@ -189,6 +191,7 @@ class Material(): self.parse(part=p, content=c) def write(self,filename='material.config', overwrite=False): + """Writes to material.config""" i = 0 outname = filename while os.path.exists(outname) and not overwrite: