aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debian/changelog1
-rw-r--r--debian/lib/python/debian_linux/utils.py25
2 files changed, 19 insertions, 7 deletions
diff --git a/debian/changelog b/debian/changelog
index e3c4aaae89aa..005648c539cd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,7 @@ linux (5.3.7-2) UNRELEASED; urgency=medium
* Add maint scripts to meta-packages to convert doc directories to symlinks
(Closes: #942861)
* debian/lib/python/debian_linux/utils.py: Use 'with' to manage file handles
+ * debian/lib/python/debian_linux/utils.py: Store file mode for templates
-- Ben Hutchings <ben@decadent.org.uk> Wed, 23 Oct 2019 18:32:15 +0100
diff --git a/debian/lib/python/debian_linux/utils.py b/debian/lib/python/debian_linux/utils.py
index 577ad319c55d..a43e986982b2 100644
--- a/debian/lib/python/debian_linux/utils.py
+++ b/debian/lib/python/debian_linux/utils.py
@@ -24,20 +24,31 @@ class Templates(object):
filename = "%s/%s%s" % (dir, name, suffix)
if os.path.exists(filename):
with codecs.open(filename, 'r', 'utf-8') as f:
+ mode = os.stat(f.fileno()).st_mode
if prefix == 'control':
- return read_control(f)
+ return (read_control(f), mode)
if prefix == 'tests-control':
- return read_tests_control(f)
- return f.read()
+ return (read_tests_control(f), mode)
+ return (f.read(), mode)
- def get(self, key, default=None):
- if key in self._cache:
+ def _get(self, key):
+ try:
return self._cache[key]
+ except KeyError:
+ self._cache[key] = value = self._read(key)
+ return value
- value = self._cache.setdefault(key, self._read(key))
+ def get(self, key, default=None):
+ value = self._get(key)
if value is None:
return default
- return value
+ return value[0]
+
+ def get_mode(self, key):
+ value = self._get(key)
+ if value is None:
+ return None
+ return value[1]
def read_control(f):