From 956aaf8ad683c85fc723e73c54674c8108207c92 Mon Sep 17 00:00:00 2001 From: Paul Garlick Date: Tue, 1 Oct 2019 12:34:38 +0100 Subject: use ast module to evaluate items read from boundary definition file. --- boundaryDefinition.txt | 4 ++-- makeBoundary.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/boundaryDefinition.txt b/boundaryDefinition.txt index 2c3a021..36c74d5 100644 --- a/boundaryDefinition.txt +++ b/boundaryDefinition.txt @@ -2,8 +2,8 @@ # Boundary Definition File # -# Boundary location (top, bottom, left, right): -location: top +# Boundary location ("top", "bottom", "left", "right"): +location: "top" # Local gradient: slope: -0.003646 diff --git a/makeBoundary.py b/makeBoundary.py index 1fc6b69..21b1113 100755 --- a/makeBoundary.py +++ b/makeBoundary.py @@ -3,6 +3,7 @@ import matplotlib.pyplot as plt import numpy as np import bisect +import ast def read_definition(filename): ddict = {} @@ -10,7 +11,7 @@ def read_definition(filename): for line in f: items = line.split(': ', 1) if len(items) == 2: - ddict[items[0]] = eval(items[1]) + ddict[items[0]] = ast.literal_eval(items[1]) return ddict # read boundary definition file. -- cgit