summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian May <brian@linuxpenguins.xyz>2019-03-04 17:21:45 +1100
committerBrian May <brian@linuxpenguins.xyz>2019-03-04 17:31:32 +1100
commitdbeca9f785cb90139fde37ad0aaad61f70b5506f (patch)
treefaa44ee8494b4adb0d54a3f990cc7f1b2a4c16f0
parenta0eedec07ab55e1a7ccf3b0892fe991150cef5b1 (diff)
Replace file() with open() for Python 3 compatability
-rwxr-xr-xbin/check-syntax2
-rwxr-xr-xbin/list-queue2
-rwxr-xr-xbin/mass-bug-filer2
-rwxr-xr-xbin/update-nvd2
-rw-r--r--lib/python/debian_support.py8
-rw-r--r--lib/python/nvd.py2
-rw-r--r--lib/python/secmaster.py2
-rw-r--r--lib/python/sectracker/repo.py6
-rw-r--r--lib/python/sectracker/xpickle.py4
-rw-r--r--lib/python/security_db.py2
10 files changed, 16 insertions, 16 deletions
diff --git a/bin/check-syntax b/bin/check-syntax
index 11a48059eb..2daaeaefde 100755
--- a/bin/check-syntax
+++ b/bin/check-syntax
@@ -49,7 +49,7 @@ def construct(c, name):
f = sys.stdin
name = '<stdin>'
else:
- f = file(name)
+ f = open(name)
return c(name, f)
sources = debian_support.getconfig()["sources"]
diff --git a/bin/list-queue b/bin/list-queue
index 556b7f5b27..2ac1e2f1de 100755
--- a/bin/list-queue
+++ b/bin/list-queue
@@ -176,7 +176,7 @@ def updatechanges(db, ondisk):
need_update = prepareupdate(db, ondisk, indb, "changes")
def do_update():
for (path, stat) in need_update:
- changes = Changes(file(path))
+ changes = Changes(open(path))
try:
dist = changes["Distribution"]
debs = set(pkg["name"] for pkg in changes["Checksums-Sha1"])
diff --git a/bin/mass-bug-filer b/bin/mass-bug-filer
index e7dfb5e310..0c1d3d9dec 100755
--- a/bin/mass-bug-filer
+++ b/bin/mass-bug-filer
@@ -11,7 +11,7 @@ if len(sys.argv) < 3:
print("usage: %s FILE PACKAGE..." % sys.argv[0], file=sys.stderr)
sys.exit(1)
-message_file = file(sys.argv[1])
+message_file = open(sys.argv[1])
packages = sys.argv[2:]
cache = apt.Cache()
diff --git a/bin/update-nvd b/bin/update-nvd
index 40e0f51bf9..9a07e78887 100755
--- a/bin/update-nvd
+++ b/bin/update-nvd
@@ -30,7 +30,7 @@ for name in sys.argv[1:]:
if name == '-i':
incremental = True
continue
- f = file(name)
+ f = open(name)
data += nvd.parse(f)
f.close()
diff --git a/lib/python/debian_support.py b/lib/python/debian_support.py
index 8bece17da3..8657be82f2 100644
--- a/lib/python/debian_support.py
+++ b/lib/python/debian_support.py
@@ -131,7 +131,7 @@ class PackageFile:
file with the indicated name.
"""
if fileObj is None:
- fileObj = file(name)
+ fileObj = open(name)
self.name = name
self.file = fileObj
self.lineno = 0
@@ -274,7 +274,7 @@ def replaceFile(lines, local):
import os.path
local_new = local + '.new'
- new_file = file(local_new, 'w+')
+ new_file = open(local_new, 'w+')
try:
for l in lines:
@@ -318,7 +318,7 @@ def updateFile(remote, local, verbose=None):
"""
try:
- local_file = file(local)
+ local_file = open(local)
except IOError:
if verbose:
print("updateFile: no local copy, downloading full file")
@@ -521,7 +521,7 @@ def getconfig():
global _config
if _config is not None:
return _config
- _config = json.load(file(findresource("data", "config.json")))
+ _config = json.load(open(findresource("data", "config.json")))
return _config
_releasecodename = None
diff --git a/lib/python/nvd.py b/lib/python/nvd.py
index 1e0771e13d..f62acdfb0d 100644
--- a/lib/python/nvd.py
+++ b/lib/python/nvd.py
@@ -125,4 +125,4 @@ def parse(file):
if __name__ == "__main__":
import sys
for name in sys.argv[1:]:
- parse(file(name))
+ parse(open(name))
diff --git a/lib/python/secmaster.py b/lib/python/secmaster.py
index f87cdfd1e4..f1f17303ee 100644
--- a/lib/python/secmaster.py
+++ b/lib/python/secmaster.py
@@ -34,7 +34,7 @@ def listqueue():
"""
ssh = subprocess.Popen(
("ssh", HOST, "secure-testing/bin/list-queue"),
- stdin=file("/dev/null"),
+ stdin=open("/dev/null"),
stdout=subprocess.PIPE)
data = ssh.stdout.read()
ssh.wait()
diff --git a/lib/python/sectracker/repo.py b/lib/python/sectracker/repo.py
index 7e6d454f51..bbe25822f6 100644
--- a/lib/python/sectracker/repo.py
+++ b/lib/python/sectracker/repo.py
@@ -132,7 +132,7 @@ class RepoCollection(object):
_os.makedirs(root)
l = _os.listdir(root)
if len(l) == 0:
- file(root + "/" + MARKER_NAME, "w").close()
+ open(root + "/" + MARKER_NAME, "w").close()
elif MARKER_NAME not in l:
raise ValueError("not a Debian repository mirror directory: "
+ repr(root))
@@ -197,7 +197,7 @@ class RepoCollection(object):
def release(self, name):
if name not in self.repos:
raise ValueError("name not registered: " + repr(name))
- with file(self._relname(name)) as f:
+ with open(self._relname(name)) as f:
return _parserelease(name, f)
def filemap(self, load=False):
@@ -255,7 +255,7 @@ class RepoCollection(object):
class Config(object):
def __init__(self, config, root):
- with file(config) as f:
+ with open(config) as f:
self.config = _cjson.decode(f.read())
self.repositories = self.config["repositories"]
self.distributions = self.config["distributions"]
diff --git a/lib/python/sectracker/xpickle.py b/lib/python/sectracker/xpickle.py
index 9a7296e4cc..78a8e95075 100644
--- a/lib/python/sectracker/xpickle.py
+++ b/lib/python/sectracker/xpickle.py
@@ -63,7 +63,7 @@ def _wraploader(typ, parser):
def safeload(path):
try:
- with file(path + EXTENSION) as f:
+ with open(path + EXTENSION, "rb") as f:
return (_pickle.load(f), True)
except (EOFError, IOError, _pickle.PickleError):
return (None, False)
@@ -78,7 +78,7 @@ def _wraploader(typ, parser):
return (None, False)
def reparse(path, st):
- with file(path) as f:
+ with open(path) as f:
obj = parser(path, f)
data = _pickle.dumps(
((typ, st.st_size, st.st_mtime, st.st_ino), obj), -1)
diff --git a/lib/python/security_db.py b/lib/python/security_db.py
index 72a4308668..5b94e74774 100644
--- a/lib/python/security_db.py
+++ b/lib/python/security_db.py
@@ -1921,7 +1921,7 @@ class DB:
"""Reads a file of removed packages and stores it in the database.
The original contents of the removed_packages table is preserved."""
- f = file(filename)
+ f = open(filename)
re_package = re.compile(r'^\s*([a-z0-9]\S+)\s*$')

© 2014-2024 Faster IT GmbH | imprint | privacy policy