Name variables for files f
fd sounds more like file descriptions. prop doesn't sound like a file at all.
This commit is contained in:
parent
f5650df5f7
commit
cd9f789294
@ -626,8 +626,8 @@ class Collection(BaseCollection):
|
|||||||
path = path_to_filesystem(self._filesystem_path, href)
|
path = path_to_filesystem(self._filesystem_path, href)
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
return None
|
return None
|
||||||
with open(path, encoding=self.encoding, newline="") as fd:
|
with open(path, encoding=self.encoding, newline="") as f:
|
||||||
text = fd.read()
|
text = f.read()
|
||||||
last_modified = time.strftime(
|
last_modified = time.strftime(
|
||||||
"%a, %d %b %Y %H:%M:%S GMT",
|
"%a, %d %b %Y %H:%M:%S GMT",
|
||||||
time.gmtime(os.path.getmtime(path)))
|
time.gmtime(os.path.getmtime(path)))
|
||||||
@ -671,18 +671,18 @@ class Collection(BaseCollection):
|
|||||||
|
|
||||||
def get_meta(self, key):
|
def get_meta(self, key):
|
||||||
if os.path.exists(self._props_path):
|
if os.path.exists(self._props_path):
|
||||||
with open(self._props_path, encoding=self.encoding) as prop:
|
with open(self._props_path, encoding=self.encoding) as f:
|
||||||
return json.load(prop).get(key)
|
return json.load(f).get(key)
|
||||||
|
|
||||||
def set_meta(self, props):
|
def set_meta(self, props):
|
||||||
if os.path.exists(self._props_path):
|
if os.path.exists(self._props_path):
|
||||||
with open(self._props_path, encoding=self.encoding) as prop:
|
with open(self._props_path, encoding=self.encoding) as f:
|
||||||
old_props = json.load(prop)
|
old_props = json.load(f)
|
||||||
old_props.update(props)
|
old_props.update(props)
|
||||||
props = old_props
|
props = old_props
|
||||||
props = {key: value for key, value in props.items() if value}
|
props = {key: value for key, value in props.items() if value}
|
||||||
with self._atomic_write(self._props_path, "w+") as prop:
|
with self._atomic_write(self._props_path, "w+") as f:
|
||||||
json.dump(props, prop)
|
json.dump(props, f)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def last_modified(self):
|
def last_modified(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user