|
19 | 19 |
|
20 | 20 | Author: Brett G. Olivier |
21 | 21 | |
22 | | -Last edit: $Author: bgoli $ ($Id: CBModel.py 636 2017-12-13 20:05:01Z bgoli $) |
| 22 | +Last edit: $Author: bgoli $ ($Id: CBModel.py 640 2017-12-18 18:13:40Z bgoli $) |
23 | 23 |
|
24 | 24 | """ |
25 | 25 | ## gets rid of "invalid variable name" info |
|
34 | 34 | from __future__ import absolute_import |
35 | 35 | #from __future__ import unicode_literals |
36 | 36 |
|
37 | | -import numpy, re, time, weakref, copy, json, ast |
| 37 | +import numpy, re, time, weakref, copy, json, ast, os |
38 | 38 |
|
39 | 39 | try: |
40 | 40 | from urllib2 import quote as urlquote |
@@ -2886,6 +2886,33 @@ def exportFVAdata(self): |
2886 | 2886 | # investigate the use of numpy index arrays here |
2887 | 2887 | raise NotImplementedError |
2888 | 2888 |
|
| 2889 | + def importUserConstraints(self, filename): |
| 2890 | + """ |
| 2891 | + Exports user constraints in json |
| 2892 | +
|
| 2893 | + """ |
| 2894 | + F = open(filename, 'r') |
| 2895 | + #din = json.load(F) |
| 2896 | + self.user_constraints = json.load(F) |
| 2897 | + #key = os.path.split(self.sourcefile)[-1] |
| 2898 | + #F.close() |
| 2899 | + #if key in din: |
| 2900 | + #self.user_constraints = din[key] |
| 2901 | + #else: |
| 2902 | + #print('ERROR: constraints refers to file \"{}\" whereas this is file \"{}\"'.format(list(din.keys())[0], key)) |
| 2903 | + #return False |
| 2904 | + return True |
| 2905 | + |
| 2906 | + def exportUserConstraints(self, filename): |
| 2907 | + """ |
| 2908 | + Exports user constraints in json |
| 2909 | +
|
| 2910 | + """ |
| 2911 | + F = open(filename, 'w') |
| 2912 | + #json.dump({os.path.split(self.sourcefile)[-1] : self.user_constraints}, F, indent=2) |
| 2913 | + json.dump(self.user_constraints, F, indent=2) |
| 2914 | + F.close() |
| 2915 | + |
2889 | 2916 | def createGroup(self, gid): |
2890 | 2917 | """ |
2891 | 2918 | Create an empty group with |
|
0 commit comments