-
Notifications
You must be signed in to change notification settings - Fork 1
/
fileOperations.py
39 lines (30 loc) · 967 Bytes
/
fileOperations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash/python
from __future__ import print_function
import networkx as nx
from copy import deepcopy
import configurationClassErrors
from configurationClassErrors import *
import nodeAttributes
from nodeAttributes import *
import edgeAttributes
from edgeAttributes import *
import json
import os
import sys
class fileOperations:
def __init__(self):
self.errors = configurationClassErrors()
# Open a configuration file and store the contents of the file in the
# configuration dictionary.
def readConfigurationFile(self, filename, allowTermination = True):
try: jsonData = open(filename)
except:
if allowTermination: self.errors.missingFile(filename)
else: return False
try: configurationData = json.load(jsonData)
except:
if allowTermination:
exc_type, exc_value, exc_traceback = sys.exc_info()
self.errors.jsonError(exc_value, filename)
else: return False
return configurationData