##// END OF EJS Templates
py3: replace "file" with "open"
Lars Kruse -
r6785:665dfa11 default
parent child Browse files
Show More
@@ -75,7 +75,7 b' class Command(BasePasterCommand):'
75
75
76 dispatchfile = os.path.join(os.getcwd(), 'dispatch.py')
76 dispatchfile = os.path.join(os.getcwd(), 'dispatch.py')
77 print 'Writing %s' % dispatchfile
77 print 'Writing %s' % dispatchfile
78 with file(dispatchfile, 'w') as f:
78 with open(dispatchfile, 'w') as f:
79 f.write(dispath_py_template % {
79 f.write(dispath_py_template % {
80 'inifile': config_file.replace('\\', '\\\\'),
80 'inifile': config_file.replace('\\', '\\\\'),
81 'virtualdir': args.virtualdir,
81 'virtualdir': args.virtualdir,
@@ -283,9 +283,9 b' class TestNotifications(TestController):'
283
283
284 outfn = os.path.join(os.path.dirname(__file__), 'test_dump_html_mails.out.html')
284 outfn = os.path.join(os.path.dirname(__file__), 'test_dump_html_mails.out.html')
285 reffn = os.path.join(os.path.dirname(__file__), 'test_dump_html_mails.ref.html')
285 reffn = os.path.join(os.path.dirname(__file__), 'test_dump_html_mails.ref.html')
286 with file(outfn, 'w') as f:
286 with open(outfn, 'w') as f:
287 f.write(out)
287 f.write(out)
288 with file(reffn) as f:
288 with open(reffn) as f:
289 ref = f.read()
289 ref = f.read()
290 assert ref == out # copy test_dump_html_mails.out.html to test_dump_html_mails.ref.html to update expectations
290 assert ref == out # copy test_dump_html_mails.out.html to test_dump_html_mails.ref.html to update expectations
291 os.unlink(outfn)
291 os.unlink(outfn)
@@ -32,7 +32,7 b" headermatch = re.compile(r'''\\n*(.+)\\n(["
32 def main():
32 def main():
33 for fn in subprocess.check_output(['hg', 'loc', 'set:**.rst+kallithea/i18n/how_to']).splitlines():
33 for fn in subprocess.check_output(['hg', 'loc', 'set:**.rst+kallithea/i18n/how_to']).splitlines():
34 print 'processing %s:' % fn
34 print 'processing %s:' % fn
35 s = file(fn).read()
35 s = open(fn).read()
36
36
37 # find levels and their styles
37 # find levels and their styles
38 lastpos = 0
38 lastpos = 0
@@ -71,7 +71,7 b' def main():'
71 s = s.strip() + '\n'
71 s = s.strip() + '\n'
72 s = re.sub(r'''\n+((?:\.\. _[^\n]*\n)+)$''', r'\n\n\n\1', s)
72 s = re.sub(r'''\n+((?:\.\. _[^\n]*\n)+)$''', r'\n\n\n\1', s)
73
73
74 file(fn, 'w').write(s)
74 open(fn, 'w').write(s)
75 print subprocess.check_output(['hg', 'diff', fn])
75 print subprocess.check_output(['hg', 'diff', fn])
76 print
76 print
77
77
@@ -90,12 +90,12 b' ini_files = ['
90 def main():
90 def main():
91 # make sure all mako lines starting with '#' (the '##' comments) are marked up as <text>
91 # make sure all mako lines starting with '#' (the '##' comments) are marked up as <text>
92 print 'reading:', makofile
92 print 'reading:', makofile
93 mako_org = file(makofile).read()
93 mako_org = open(makofile).read()
94 mako_no_text_markup = re.sub(r'</?%text>', '', mako_org)
94 mako_no_text_markup = re.sub(r'</?%text>', '', mako_org)
95 mako_marked_up = re.sub(r'\n(##.*)', r'\n<%text>\1</%text>', mako_no_text_markup, flags=re.MULTILINE)
95 mako_marked_up = re.sub(r'\n(##.*)', r'\n<%text>\1</%text>', mako_no_text_markup, flags=re.MULTILINE)
96 if mako_marked_up != mako_org:
96 if mako_marked_up != mako_org:
97 print 'writing:', makofile
97 print 'writing:', makofile
98 file(makofile, 'w').write(mako_marked_up)
98 open(makofile, 'w').write(mako_marked_up)
99
99
100 # select the right mako conditionals for the other less sophisticated formats
100 # select the right mako conditionals for the other less sophisticated formats
101 def sub_conditionals(m):
101 def sub_conditionals(m):
@@ -149,7 +149,7 b' def main():'
149 lines = re.sub(r'^([^#\n].*) = ?(.*)', process_line, lines, flags=re.MULTILINE)
149 lines = re.sub(r'^([^#\n].*) = ?(.*)', process_line, lines, flags=re.MULTILINE)
150 return sectionname + '\n' + lines
150 return sectionname + '\n' + lines
151 ini_lines = re.sub(r'^(\[.*\])\n((?:(?:[^[\n].*)?\n)*)', process_section, ini_lines, flags=re.MULTILINE)
151 ini_lines = re.sub(r'^(\[.*\])\n((?:(?:[^[\n].*)?\n)*)', process_section, ini_lines, flags=re.MULTILINE)
152 file(fn, 'w').write(ini_lines)
152 open(fn, 'w').write(ini_lines)
153
153
154 if __name__ == '__main__':
154 if __name__ == '__main__':
155 main()
155 main()
@@ -33,7 +33,7 b' res = ['
33 ]
33 ]
34
34
35 for f in sys.argv[1:]:
35 for f in sys.argv[1:]:
36 s = file(f).read()
36 s = open(f).read()
37 for r, t in res:
37 for r, t in res:
38 s = r.sub(t, s)
38 s = r.sub(t, s)
39 file(f, 'w').write(s)
39 open(f, 'w').write(s)
@@ -197,10 +197,10 b' def insert_entries('
197 for name, years in name_years.items()]
197 for name, years in name_years.items()]
198 l.sort(key=sortkey)
198 l.sort(key=sortkey)
199
199
200 with file(filename) as f:
200 with open(filename) as f:
201 pre, post = re.split(split_re, f.read())
201 pre, post = re.split(split_re, f.read())
202
202
203 with file(filename, 'w') as f:
203 with open(filename, 'w') as f:
204 f.write(pre +
204 f.write(pre +
205 ''.join(format_f(years, name) for years, name in l) +
205 ''.join(format_f(years, name) for years, name in l) +
206 post)
206 post)
General Comments 0
You need to be logged in to leave comments. Login now