Changeset - 665dfa112f2c
[Not reviewed]
default
0 6 0
Lars Kruse - 8 years ago 2017-08-25 14:30:57
devel@sumpfralle.de
py3: replace "file" with "open"
6 files changed with 12 insertions and 12 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/paster_commands/install_iis.py
Show inline comments
 
@@ -72,13 +72,13 @@ class Command(BasePasterCommand):
 
            import isapi_wsgi
 
        except ImportError:
 
            self.error('missing requirement: isapi-wsgi not installed')
 

	
 
        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,
 
                })
 

	
 
        print ('Run \'python "%s" install\' with administrative privileges '
kallithea/tests/models/test_notifications.py
Show inline comments
 
@@ -280,12 +280,12 @@ class TestNotifications(TestController):
 

	
 
        out = '<!doctype html>\n<html lang="en">\n<head><title>Notifications</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>\n<body>\n%s\n</body>\n</html>\n' % \
 
            re.sub(r'<(/?(?:!doctype|html|head|title|meta|body)\b[^>]*)>', r'<!--\1-->', ''.join(l))
 

	
 
        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)
scripts/docs-headings.py
Show inline comments
 
@@ -29,13 +29,13 @@ pystyles = ['#', '*', '=', '-', '^', '"'
 
headermatch = re.compile(r'''\n*(.+)\n([][!"#$%&'()*+,./:;<=>?@\\^_`{|}~-])\2{2,}\n+''', flags=re.MULTILINE)
 

	
 

	
 
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
 
        styles = []
 
        for markup in headermatch.findall(s):
 
            style = markup[1]
 
@@ -68,12 +68,12 @@ def main():
 
        # remove superfluous spacing when headers are adjacent
 
        s = re.sub(r'''(\n.+\n([][!"#$%&'()*+,./:;<=>?@\\^_`{|}~-])\2{2,}\n\n\n)\n*''', r'\1', s, flags=re.MULTILINE)
 
        # fix trailing space and spacing before link sections
 
        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
 

	
 
if __name__ == '__main__':
 
    main()
scripts/generate-ini.py
Show inline comments
 
@@ -87,18 +87,18 @@ ini_files = [
 
]
 

	
 

	
 
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):
 
        """given a %if...%endif match, replace with just the selected
 
        conditional sections enabled and the rest as comments
 
        """
 
@@ -146,10 +146,10 @@ def main():
 
                        if '$' not in value:
 
                            line = '#%s = %s\n%s' % (setting, value, line)
 
                    return line.rstrip()
 
                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()
scripts/logformat.py
Show inline comments
 
@@ -30,10 +30,10 @@ res = [
 
    (re.compile(logre % r'''("[^"]*"|'[^']*') , [ ]+  () (   [\n ]+)    ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* )    ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
 
    # remove trailing , and space
 
    (re.compile(logre % r'''("[^"]*"|'[^']*') ,       () (   [\n ]*)    ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* [^(), \n] ) [ ,]*''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
 
    ]
 

	
 
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)
scripts/update-copyrights.py
Show inline comments
 
@@ -194,16 +194,16 @@ def insert_entries(
 
        name_years[normalize_name(name)].add(year)
 

	
 
    l = [(list(sorted(year for year in years if year)), name)
 
         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)
 

	
 

	
 
def main():
0 comments (0 inline, 0 general)