Skip to content
Myr

Base from_json on from_mapping

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Daniel Neuhäuser · committed by Daniel Neuhäuser · parent aa40b17 · Browse files · 1 file+4 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−6 removed

  • other:+4 added−6 removed

1 file+4 added−6 removed

modified:flask/config.py+4 added-6 removed
165 unmodified lines
166 self[key] = getattr(obj, key)167168 def from_json(self, filename, silent=False):169 """Updates the values in the config from a JSON file. This function170 behaves as if the JSON object was a dictionary and passed ot the171 :meth:`from_object` function.170 behaves as if the JSON object was a dictionary and passed to the171 :meth:`from_mapping` function.172173 :param filename: the filename of the JSON file. This can either be an174 absolute filename or a filename relative to the175 root path.
11 unmodified lines
187 if silent and e.errno in (errno.ENOENT, errno.EISDIR):188 return False189 e.strerror = 'Unable to load configuration file (%s)' % e.strerror190 raise191 for key in obj.keys():192 if key.isupper():193 self[key] = obj[key]194 return True191 return self.from_mapping(obj)192193 def from_mapping(self, *mapping, **kwargs):194 """Updates the config like :meth:`update` ignoring items with non-upper195 keys.
14 unmodified lines
210 for mapping in mappings:211 for (key, value) in mapping:212 if key.isupper():213 self[key] = value214 return True215216 def get_namespace(self, namespace, lowercase=True):217 """Returns a dictionary containing a subset of configuration options218 that match the specified namespace/prefix. Example usage::
35 unmodified lines