MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / Settings

Class Settings

service/settings.py:89–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87
88
89class Settings:
90 def __init__(self, location, info):
91 # type: (basestring, dict) -> None
92 # path string or empty string.
93 self.location = location
94 self.info = info
95
96 # def save(self):
97 # f = open(self.location, "wb")
98 # cPickle.dump(self.info, f, cPickle.HIGHEST_PROTOCOL)
99
100 def save(self):
101 # NOTE: needed to change for tests
102 if self.location is None or not self.location:
103 return
104 # NOTE: with + open -> file handle auto close
105 with open(self.location, "wb") as f:
106 pickle.dump(self.info, f, pickle.HIGHEST_PROTOCOL)
107
108 def __getitem__(self, k):
109 try:
110 return self.info[k]
111 except KeyError as e:
112 pyfalog.warning("Failed to get setting for '{0}'. Exception: {1}", k, e)
113 return None
114
115 def __setitem__(self, k, v):
116 self.info[k] = v
117
118 def __iter__(self):
119 return self.info.__iter__()
120
121 def iterkeys(self):
122 return iter(self.info.keys())
123
124 def itervalues(self):
125 return iter(self.info.values())
126
127 def iteritems(self):
128 return iter(self.info.items())
129
130 def keys(self):
131 return list(self.info.keys())
132
133 def values(self):
134 return list(self.info.values())
135
136 def items(self):
137 return list(self.info.items())
138
139
140class NetworkSettings:

Callers 1

getSettingsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected