changeset 6860:665dfa112f2c

py3: replace "file" with "open"
author Lars Kruse <devel@sumpfralle.de>
date Fri, 25 Aug 2017 14:30:57 +0200
parents b9e10022ad4e
children e0b1c45eb117
files kallithea/lib/paster_commands/install_iis.py kallithea/tests/models/test_notifications.py scripts/docs-headings.py scripts/generate-ini.py scripts/logformat.py scripts/update-copyrights.py
diffstat 6 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/paster_commands/install_iis.py	Thu Aug 17 21:46:10 2017 +0200
+++ b/kallithea/lib/paster_commands/install_iis.py	Fri Aug 25 14:30:57 2017 +0200
@@ -75,7 +75,7 @@
 
         dispatchfile = os.path.join(os.getcwd(), 'dispatch.py')
         print 'Writing %s' % dispatchfile
-        with file(dispatchfile, 'w') as f:
+        with open(dispatchfile, 'w') as f:
             f.write(dispath_py_template % {
                 'inifile': config_file.replace('\\', '\\\\'),
                 'virtualdir': args.virtualdir,
--- a/kallithea/tests/models/test_notifications.py	Thu Aug 17 21:46:10 2017 +0200
+++ b/kallithea/tests/models/test_notifications.py	Fri Aug 25 14:30:57 2017 +0200
@@ -283,9 +283,9 @@
 
         outfn = os.path.join(os.path.dirname(__file__), 'test_dump_html_mails.out.html')
         reffn = os.path.join(os.path.dirname(__file__), 'test_dump_html_mails.ref.html')
-        with file(outfn, 'w') as f:
+        with open(outfn, 'w') as f:
             f.write(out)
-        with file(reffn) as f:
+        with open(reffn) as f:
             ref = f.read()
         assert ref == out # copy test_dump_html_mails.out.html to test_dump_html_mails.ref.html to update expectations
         os.unlink(outfn)
--- a/scripts/docs-headings.py	Thu Aug 17 21:46:10 2017 +0200
+++ b/scripts/docs-headings.py	Fri Aug 25 14:30:57 2017 +0200
@@ -32,7 +32,7 @@
 def main():
     for fn in subprocess.check_output(['hg', 'loc', 'set:**.rst+kallithea/i18n/how_to']).splitlines():
         print 'processing %s:' % fn
-        s = file(fn).read()
+        s = open(fn).read()
 
         # find levels and their styles
         lastpos = 0
@@ -71,7 +71,7 @@
         s = s.strip() + '\n'
         s = re.sub(r'''\n+((?:\.\. _[^\n]*\n)+)$''', r'\n\n\n\1', s)
 
-        file(fn, 'w').write(s)
+        open(fn, 'w').write(s)
         print subprocess.check_output(['hg', 'diff', fn])
         print
 
--- a/scripts/generate-ini.py	Thu Aug 17 21:46:10 2017 +0200
+++ b/scripts/generate-ini.py	Fri Aug 25 14:30:57 2017 +0200
@@ -90,12 +90,12 @@
 def main():
     # make sure all mako lines starting with '#' (the '##' comments) are marked up as <text>
     print 'reading:', makofile
-    mako_org = file(makofile).read()
+    mako_org = open(makofile).read()
     mako_no_text_markup = re.sub(r'</?%text>', '', mako_org)
     mako_marked_up = re.sub(r'\n(##.*)', r'\n<%text>\1</%text>', mako_no_text_markup, flags=re.MULTILINE)
     if mako_marked_up != mako_org:
         print 'writing:', makofile
-        file(makofile, 'w').write(mako_marked_up)
+        open(makofile, 'w').write(mako_marked_up)
 
     # select the right mako conditionals for the other less sophisticated formats
     def sub_conditionals(m):
@@ -149,7 +149,7 @@
                 lines = re.sub(r'^([^#\n].*) = ?(.*)', process_line, lines, flags=re.MULTILINE)
             return sectionname + '\n' + lines
         ini_lines = re.sub(r'^(\[.*\])\n((?:(?:[^[\n].*)?\n)*)', process_section, ini_lines, flags=re.MULTILINE)
-        file(fn, 'w').write(ini_lines)
+        open(fn, 'w').write(ini_lines)
 
 if __name__ == '__main__':
     main()
--- a/scripts/logformat.py	Thu Aug 17 21:46:10 2017 +0200
+++ b/scripts/logformat.py	Fri Aug 25 14:30:57 2017 +0200
@@ -33,7 +33,7 @@
     ]
 
 for f in sys.argv[1:]:
-    s = file(f).read()
+    s = open(f).read()
     for r, t in res:
         s = r.sub(t, s)
-    file(f, 'w').write(s)
+    open(f, 'w').write(s)
--- a/scripts/update-copyrights.py	Thu Aug 17 21:46:10 2017 +0200
+++ b/scripts/update-copyrights.py	Fri Aug 25 14:30:57 2017 +0200
@@ -197,10 +197,10 @@
          for name, years in name_years.items()]
     l.sort(key=sortkey)
 
-    with file(filename) as f:
+    with open(filename) as f:
         pre, post = re.split(split_re, f.read())
 
-    with file(filename, 'w') as f:
+    with open(filename, 'w') as f:
         f.write(pre +
                 ''.join(format_f(years, name) for years, name in l) +
                 post)