diff options
author | Guido Günther <agx@sigxcpu.org> | 2013-08-28 19:30:12 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2013-08-28 19:30:12 +0200 |
commit | c9d3d93d28f2a1f839770672f5846115d8d0e3c3 (patch) | |
tree | 2b0415593a8ad00a6110134dbdbaee7046481c01 | |
parent | 8f073ebccd35f331981c8e2a396c0999de25a0b2 (diff) |
Use open() instead of file()
since the later doesn't exist in python3
-rw-r--r-- | gbp/deb/changelog.py | 2 | ||||
-rw-r--r-- | gbp/deb/control.py | 2 | ||||
-rw-r--r-- | gbp/deb/dscfile.py | 2 | ||||
-rw-r--r-- | gbp/deb/format.py | 4 | ||||
-rw-r--r-- | gbp/deb/source.py | 2 | ||||
-rw-r--r-- | gbp/git/repository.py | 2 | ||||
-rw-r--r-- | gbp/patch_series.py | 2 | ||||
-rw-r--r-- | gbp/scripts/common/pq.py | 8 | ||||
-rw-r--r-- | gbp/scripts/dch.py | 4 | ||||
-rwxr-xr-x | gbp/scripts/pq.py | 2 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | tests/07_test_fastimport.py | 2 | ||||
-rw-r--r-- | tests/09_test_write_tree.py | 2 | ||||
-rw-r--r-- | tests/11_test_dch_main.py | 2 | ||||
-rw-r--r-- | tests/15_test_DebianSource.py | 2 | ||||
-rw-r--r-- | tests/16_test_supercommand.py | 2 | ||||
-rw-r--r-- | tests/test_Config.py | 6 | ||||
-rw-r--r-- | tests/test_GitVfs.py | 2 | ||||
-rw-r--r-- | tests/testutils.py | 2 |
19 files changed, 26 insertions, 26 deletions
diff --git a/gbp/deb/changelog.py b/gbp/deb/changelog.py index 2857431f..356f74d7 100644 --- a/gbp/deb/changelog.py +++ b/gbp/deb/changelog.py @@ -115,7 +115,7 @@ class ChangeLog(object): self._cp = cp def _read(self): - with file(self.filename) as f: + with open(self.filename) as f: self._contents = f.read() def __getitem__(self, item): diff --git a/gbp/deb/control.py b/gbp/deb/control.py index b15d3601..a4cef2fa 100644 --- a/gbp/deb/control.py +++ b/gbp/deb/control.py @@ -47,7 +47,7 @@ class Control(object): if not os.access(filename, os.F_OK): raise NoControlError("Control file %s does not exist" % filename) - with file(filename) as f: + with open(filename) as f: control = email.message_from_file(f) if not control.items(): diff --git a/gbp/deb/dscfile.py b/gbp/deb/dscfile.py index abaf6901..e2492dcc 100644 --- a/gbp/deb/dscfile.py +++ b/gbp/deb/dscfile.py @@ -49,7 +49,7 @@ class DscFile(object): self.native = False self.dscfile = os.path.abspath(dscfile) - f = file(self.dscfile) + f = open(self.dscfile) fromdir = os.path.dirname(os.path.abspath(dscfile)) for line in f: m = self.version_re.match(line) diff --git a/gbp/deb/format.py b/gbp/deb/format.py index 9abba739..3a4c8ab3 100644 --- a/gbp/deb/format.py +++ b/gbp/deb/format.py @@ -92,7 +92,7 @@ class DebianSourceFormat(object): 'quilt' >>> os.unlink(t.name) """ - with file(filename) as f: + with open(filename) as f: return klass(f.read()) @classmethod @@ -107,7 +107,7 @@ class DebianSourceFormat(object): the above parameters """ format_file = format_file or klass.format_file - with file(klass.format_file, 'w') as f: + with open(klass.format_file, 'w') as f: f.write("%s (%s)" % (version, type)) return klass.parse_file(klass.format_file) diff --git a/gbp/deb/source.py b/gbp/deb/source.py index 1e873129..c7403613 100644 --- a/gbp/deb/source.py +++ b/gbp/deb/source.py @@ -32,7 +32,7 @@ class FileVfs(object): def open(self, path, flags=None): flags = flags or 'r' - return file(os.path.join(self._dir, path), flags) + return open(os.path.join(self._dir, path), flags) class DebianSourceError(Exception): pass diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 3fe8d6f7..a9204c56 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1653,7 +1653,7 @@ class GitRepository(object): raise GitRepositoryError("Error running git init: %s" % stderr) if description: - with file(os.path.join(abspath, git_dir, "description"), 'w') as f: + with open(os.path.join(abspath, git_dir, "description"), 'w') as f: description += '\n' if description[-1] != '\n' else '' f.write(description) return klass(abspath) diff --git a/gbp/patch_series.py b/gbp/patch_series.py index 6a654469..10fccfc6 100644 --- a/gbp/patch_series.py +++ b/gbp/patch_series.py @@ -167,7 +167,7 @@ class PatchSeries(list): return [] try: - s = file(seriesfile) + s = open(seriesfile) except Exception as err: raise GbpError("Cannot open series file: %s" % err) diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py index ce063536..7e6e210b 100644 --- a/gbp/scripts/common/pq.py +++ b/gbp/scripts/common/pq.py @@ -148,14 +148,14 @@ def patch_write_header(srcname, dstname): """ topic = None - with file(srcname) as src: + with open(srcname) as src: header = patch_read_header(src) header_len = len(''.join(header)) topic = patch_header_parse_topic(header) patch_header_mangle_newline(header) - with file(dstname, 'w') as dst: + with open(dstname, 'w') as dst: dst.write(''.join(header[1:])) return (header_len, topic) @@ -165,9 +165,9 @@ def patch_write_content(srcname, dstname, header_len): """ Write out the patch body skipping the header """ - with file(srcname) as src: + with open(srcname) as src: src.seek(header_len, 0) - with file(dstname, 'a') as dst: + with open(dstname, 'a') as dst: dst.write(src.read()) diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py index eb4de5a4..a848d6d2 100644 --- a/gbp/scripts/dch.py +++ b/gbp/scripts/dch.py @@ -126,8 +126,8 @@ def mangle_changelog(changelog, cp, snapshot=''): """ try: tmpfile = '%s.%s' % (changelog, snapshot) - cw = file(tmpfile, 'w') - cr = file(changelog, 'r') + cw = open(tmpfile, 'w') + cr = open(changelog, 'r') print >>cw, ("%(Source)s (%(MangledVersion)s) " "%(Distribution)s; urgency=%(urgency)s\n" % cp) diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index 78f061a0..68850787 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -59,7 +59,7 @@ def export_patches(repo, branch, options): signature=False, symmetric=False) if patches: - f = file(SERIES_FILE, 'w') + f = open(SERIES_FILE, 'w') gbp.log.info("Regenerating patch queue in '%s'." % PATCH_DIR) for patch in patches: filename = write_patch(patch, PATCH_DIR, options) @@ -36,7 +36,7 @@ def fetch_version(): except OSError: pass # Failing is fine, we just can't print the version then - with file('gbp/version.py', 'w') as f: + with open('gbp/version.py', 'w') as f: f.write('"The current gbp version number"\n') f.write('gbp_version="%s"\n' % version) diff --git a/tests/07_test_fastimport.py b/tests/07_test_fastimport.py index 42824f94..0a14d38d 100644 --- a/tests/07_test_fastimport.py +++ b/tests/07_test_fastimport.py @@ -38,7 +38,7 @@ def test_add_file(): fastimport.deleteall() testfile = os.path.join(repo.path, '.git', 'description') fastimport.add_file('./testfile', - file(testfile), + open(testfile), os.path.getsize(testfile)) def test_add_symlink(): diff --git a/tests/09_test_write_tree.py b/tests/09_test_write_tree.py index 3534f77e..7147da50 100644 --- a/tests/09_test_write_tree.py +++ b/tests/09_test_write_tree.py @@ -19,7 +19,7 @@ class TestWriteTree(testutils.DebianGitTestRepo): paths = [] for i in range(4): path = os.path.join(self.repo.path, 'testfile%d' % i) - with file(path, 'w') as f: + with open(path, 'w') as f: print >>f, "testdata %d" % i paths.append(path) return paths diff --git a/tests/11_test_dch_main.py b/tests/11_test_dch_main.py index 1849a3df..2ce99063 100644 --- a/tests/11_test_dch_main.py +++ b/tests/11_test_dch_main.py @@ -79,7 +79,7 @@ class TestScriptDch(DebianGitTestRepo): options.extend(dch_options) ret = dch.main(options) self.assertEqual(ret, 0) - return file("debian/changelog").readlines() + return open("debian/changelog").readlines() def test_dch_main_new_upstream_version(self): diff --git a/tests/15_test_DebianSource.py b/tests/15_test_DebianSource.py index 4896b319..feca6256 100644 --- a/tests/15_test_DebianSource.py +++ b/tests/15_test_DebianSource.py @@ -52,7 +52,7 @@ class TestDebianSource(testutils.DebianGitTestRepo): self.assertRaises(DebianSourceError, source.is_native) - with file('debian/changelog', 'w') as f: + with open('debian/changelog', 'w') as f: f.write("""git-buildpackage (0.2.3) git-buildpackage; urgency=low * git doesn't like '~' in tag names so replace this with a dot when tagging diff --git a/tests/16_test_supercommand.py b/tests/16_test_supercommand.py index 884437bc..f72bb562 100644 --- a/tests/16_test_supercommand.py +++ b/tests/16_test_supercommand.py @@ -37,7 +37,7 @@ class TestSuperCommand(unittest.TestCase): def test_invalid_command(self): """Test if we fail correctly with an invalid command""" old_stderr = sys.stderr - with file('/dev/null', 'w') as sys.stderr: + with open('/dev/null', 'w') as sys.stderr: self.assertEqual(gbp.scripts.supercommand.supercommand( ['argv0', 'asdf']), 2) self.assertEqual(gbp.scripts.supercommand.supercommand( diff --git a/tests/test_Config.py b/tests/test_Config.py index 995d6196..9a68f8cc 100644 --- a/tests/test_Config.py +++ b/tests/test_Config.py @@ -71,7 +71,7 @@ def test_parser_fallback(): >>> tmpdir = str(context.new_tmpdir('foo')) >>> confname = os.path.join(tmpdir, 'gbp.conf') >>> parser.config_files = [confname] - >>> f = file(confname, 'w') + >>> f = open(confname, 'w') >>> f.write('[foo]\\nthere = is\\n[git-foo]\\nno = truth\\n') >>> f.close() >>> parser._parse_config_files() @@ -90,13 +90,13 @@ def test_filter(): >>> tmpdir = str(context.new_tmpdir('bar')) >>> confname = os.path.join(tmpdir, 'gbp.conf') >>> parser.config_files = [confname] - >>> f = file(confname, 'w') + >>> f = open(confname, 'w') >>> f.write('[bar]\\nfilter = asdf\\n') >>> f.close() >>> parser._parse_config_files() >>> parser.config['filter'] ['asdf'] - >>> f = file(confname, 'w') + >>> f = open(confname, 'w') >>> f.write("[bar]\\nfilter = ['this', 'is', 'a', 'list']\\n") >>> f.close() >>> parser._parse_config_files() diff --git a/tests/test_GitVfs.py b/tests/test_GitVfs.py index dda156d5..7004db1f 100644 --- a/tests/test_GitVfs.py +++ b/tests/test_GitVfs.py @@ -26,7 +26,7 @@ def test_read(): >>> import os, gbp.git.vfs >>> repo_dir = context.new_tmpdir(__name__) >>> repo = gbp.git.GitRepository.create(str(repo_dir)) - >>> f = file(os.path.join(repo.path, 'foo.txt'), 'w') + >>> f = open(os.path.join(repo.path, 'foo.txt'), 'w') >>> content = 'al pha\\na\\nb\\nc' >>> f.write('al pha\\na\\nb\\nc') >>> f.close() diff --git a/tests/testutils.py b/tests/testutils.py index 617a7abc..c8631955 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -38,7 +38,7 @@ class DebianGitTestRepo(unittest.TestCase): if not os.path.exists(d): os.makedirs(d) - with file(path, 'w+') as f: + with open(path, 'w+') as f: content == None or f.write(content) self.repo.add_files(name, force=True) self.repo.commit_files(path, msg or "added %s" % name) |