# HG changeset patch # User Rémi Cardona # Date 1442324027 -7200 # Node ID 57dfde80df112f1f7e38f36ecb0f9136a68cc3d1 # Parent 8d9fe02387e3664e5cfd1b1919c70b902d58c2ef [py3k] file → open diff -r 8d9fe02387e3 -r 57dfde80df11 cwconfig.py --- a/cwconfig.py Thu Sep 17 09:52:06 2015 +0200 +++ b/cwconfig.py Tue Sep 15 15:33:47 2015 +0200 @@ -961,7 +961,7 @@ i = 1 while exists(path) and i < 100: # arbitrary limit to avoid infinite loop try: - file(path, 'a') + open(path, 'a') break except IOError: path = '%s-%s.log' % (basepath, i) diff -r 8d9fe02387e3 -r 57dfde80df11 cwctl.py --- a/cwctl.py Thu Sep 17 09:52:06 2015 +0200 +++ b/cwctl.py Tue Sep 15 15:33:47 2015 +0200 @@ -115,7 +115,7 @@ _allinstances = list_instances(regdir) if isfile(join(regdir, 'startorder')): allinstances = [] - for line in file(join(regdir, 'startorder')): + for line in open(join(regdir, 'startorder')): line = line.strip() if line and not line.startswith('#'): try: diff -r 8d9fe02387e3 -r 57dfde80df11 devtools/devctl.py --- a/devtools/devctl.py Thu Sep 17 09:52:06 2015 +0200 +++ b/devtools/devctl.py Tue Sep 15 15:33:47 2015 +0200 @@ -322,7 +322,7 @@ potfiles.append(schemapot) # explicit close necessary else the file may not be yet flushed when # we'll using it below - schemapotstream = file(schemapot, 'w') + schemapotstream = open(schemapot, 'w') generate_schema_pot(schemapotstream.write, cubedir=None) schemapotstream.close() print('TAL', end=' ') @@ -446,7 +446,7 @@ potfiles.append(schemapot) # explicit close necessary else the file may not be yet flushed when # we'll using it below - schemapotstream = file(schemapot, 'w') + schemapotstream = open(schemapot, 'w') generate_schema_pot(schemapotstream.write, cubedir) schemapotstream.close() print('TAL', end=' ') @@ -712,7 +712,7 @@ requests = {} for filepath in args: try: - stream = file(filepath) + stream = open(filepath) except OSError as ex: raise BadCommandUsage("can't open rql log file %s: %s" % (filepath, ex)) diff -r 8d9fe02387e3 -r 57dfde80df11 devtools/stresstester.py --- a/devtools/stresstester.py Thu Sep 17 09:52:06 2015 +0200 +++ b/devtools/stresstester.py Tue Sep 15 15:33:47 2015 +0200 @@ -156,7 +156,7 @@ elif opt in ('-P', '--profile'): prof_file = val elif opt in ('-o', '--report-output'): - report_output = file(val, 'w') + report_output = open(val, 'w') if len(args) != 2: usage(1) queries = [query for query in lines(args[1]) if not query.startswith('#')] diff -r 8d9fe02387e3 -r 57dfde80df11 devtools/test/unittest_dbfill.py --- a/devtools/test/unittest_dbfill.py Thu Sep 17 09:52:06 2015 +0200 +++ b/devtools/test/unittest_dbfill.py Tue Sep 15 15:33:47 2015 +0200 @@ -52,7 +52,7 @@ return None def _available_Person_firstname(self, etype, attrname): - return [f.strip() for f in file(osp.join(DATADIR, 'firstnames.txt'))] + return [f.strip() for f in open(osp.join(DATADIR, 'firstnames.txt'))] def setUp(self): config = ApptestConfiguration('data', apphome=DATADIR) diff -r 8d9fe02387e3 -r 57dfde80df11 devtools/testlib.py --- a/devtools/testlib.py Thu Sep 17 09:52:06 2015 +0200 +++ b/devtools/testlib.py Tue Sep 15 15:33:47 2015 +0200 @@ -63,7 +63,7 @@ def do_view(self, arg): import webbrowser data = self._getval(arg) - with file('/tmp/toto.html', 'w') as toto: + with open('/tmp/toto.html', 'w') as toto: toto.write(data) webbrowser.open('file:///tmp/toto.html') diff -r 8d9fe02387e3 -r 57dfde80df11 ext/tal.py --- a/ext/tal.py Thu Sep 17 09:52:06 2015 +0200 +++ b/ext/tal.py Tue Sep 15 15:33:47 2015 +0200 @@ -206,7 +206,7 @@ :type filepath: str :param template: path of the file to compile """ - fp = file(filepath) + fp = open(filepath) file_content = unicode(fp.read()) # template file should be pure ASCII fp.close() return compile_template(file_content) diff -r 8d9fe02387e3 -r 57dfde80df11 misc/cwfs/cwfs_test.py --- a/misc/cwfs/cwfs_test.py Thu Sep 17 09:52:06 2015 +0200 +++ b/misc/cwfs/cwfs_test.py Tue Sep 15 15:33:47 2015 +0200 @@ -30,7 +30,7 @@ sections = [] buffer = "" in_section = False - for line in file(filename) : + for line in open(filename) : if line.startswith('Test::'): in_section = True buffer = "" diff -r 8d9fe02387e3 -r 57dfde80df11 server/serverconfig.py --- a/server/serverconfig.py Thu Sep 17 09:52:06 2015 +0200 +++ b/server/serverconfig.py Tue Sep 15 15:33:47 2015 +0200 @@ -235,7 +235,7 @@ def bootstrap_cubes(self): from logilab.common.textutils import splitstrip - for line in file(join(self.apphome, 'bootstrap_cubes')): + for line in open(join(self.apphome, 'bootstrap_cubes')): line = line.strip() if not line or line.startswith('#'): continue @@ -246,7 +246,7 @@ self.init_cubes(()) def write_bootstrap_cubes_file(self, cubes): - stream = file(join(self.apphome, 'bootstrap_cubes'), 'w') + stream = open(join(self.apphome, 'bootstrap_cubes'), 'w') stream.write('# this is a generated file only used for bootstraping\n') stream.write('# you should not have to edit this\n') stream.write('%s\n' % ','.join(cubes)) diff -r 8d9fe02387e3 -r 57dfde80df11 server/test/unittest_ldapsource.py --- a/server/test/unittest_ldapsource.py Thu Sep 17 09:52:06 2015 +0200 +++ b/server/test/unittest_ldapsource.py Tue Sep 15 15:33:47 2015 +0200 @@ -55,8 +55,8 @@ slapddir = tempfile.mkdtemp('cw-unittest-ldap') config = cls.config slapdconf = join(config.apphome, "slapd.conf") - confin = file(join(config.apphome, "slapd.conf.in")).read() - confstream = file(slapdconf, 'w') + confin = open(join(config.apphome, "slapd.conf.in")).read() + confstream = open(slapdconf, 'w') confstream.write(confin % {'apphome': config.apphome, 'testdir': slapddir}) confstream.close() # fill ldap server with some data diff -r 8d9fe02387e3 -r 57dfde80df11 server/test/unittest_storage.py --- a/server/test/unittest_storage.py Thu Sep 17 09:52:06 2015 +0200 +++ b/server/test/unittest_storage.py Tue Sep 15 15:33:47 2015 +0200 @@ -215,7 +215,7 @@ f1 = cnx.create_entity('File', data=Binary(filepath), data_format=u'text/plain', data_name=u'foo') cw_value = f1.data.getvalue() - fs_value = file(filepath).read() + fs_value = open(filepath).read() if cw_value != fs_value: self.fail('cw value %r is different from file content' % cw_value) @@ -304,7 +304,7 @@ old_fspath = self.fspath(cnx, f1) cnx.transaction_data['fs_importing'] = True new_fspath = osp.join(self.tempdir, 'newfile.txt') - file(new_fspath, 'w').write('the new data') + open(new_fspath, 'w').write('the new data') cnx.execute('SET F data %(d)s WHERE F eid %(f)s', {'d': Binary(new_fspath), 'f': f1.eid}) cnx.commit() diff -r 8d9fe02387e3 -r 57dfde80df11 setup.py --- a/setup.py Thu Sep 17 09:52:06 2015 +0200 +++ b/setup.py Tue Sep 15 15:33:47 2015 +0200 @@ -42,7 +42,7 @@ from __pkginfo__ import modname, version, license, description, web, \ author, author_email -long_description = file('README').read() +long_description = open('README').read() # import optional features import __pkginfo__ diff -r 8d9fe02387e3 -r 57dfde80df11 skeleton/setup.py --- a/skeleton/setup.py Thu Sep 17 09:52:06 2015 +0200 +++ b/skeleton/setup.py Tue Sep 15 15:33:47 2015 +0200 @@ -44,7 +44,7 @@ author, author_email, classifiers if exists('README'): - long_description = file('README').read() + long_description = open('README').read() else: long_description = '' diff -r 8d9fe02387e3 -r 57dfde80df11 sobjects/__init__.py --- a/sobjects/__init__.py Thu Sep 17 09:52:06 2015 +0200 +++ b/sobjects/__init__.py Tue Sep 15 15:33:47 2015 +0200 @@ -26,5 +26,5 @@ if vreg.config.apphome: url_mapping_file = osp.join(vreg.config.apphome, 'urlmapping.py') if osp.exists(url_mapping_file): - URL_MAPPING = eval(file(url_mapping_file).read()) + URL_MAPPING = eval(open(url_mapping_file).read()) vreg.info('using url mapping %s from %s', URL_MAPPING, url_mapping_file) diff -r 8d9fe02387e3 -r 57dfde80df11 toolsutils.py --- a/toolsutils.py Thu Sep 17 09:52:06 2015 +0200 +++ b/toolsutils.py Tue Sep 15 15:33:47 2015 +0200 @@ -112,7 +112,7 @@ sys.exit(0) else: copy_file = appl_file + '.default' - copy = file(copy_file, 'w') + copy = open(copy_file, 'w') copy.write(open(ref_file).read()) copy.close() print('keep current version, the new file has been written to', copy_file) @@ -151,8 +151,8 @@ shutil.copyfile(fpath, tfpath) def fill_templated_file(fpath, tfpath, context): - fobj = file(tfpath, 'w') - templated = file(fpath).read() + fobj = open(tfpath, 'w') + templated = open(fpath).read() fobj.write(templated % context) fobj.close() diff -r 8d9fe02387e3 -r 57dfde80df11 web/propertysheet.py --- a/web/propertysheet.py Thu Sep 17 09:52:06 2015 +0200 +++ b/web/propertysheet.py Tue Sep 15 15:33:47 2015 +0200 @@ -96,7 +96,7 @@ if not osp.exists(rcachedir): os.makedirs(rcachedir) sourcefile = osp.join(rdirectory, rid) - content = file(sourcefile).read() + content = open(sourcefile).read() # XXX replace % not followed by a paren by %% to avoid having to do # this in the source css file ? try: @@ -105,7 +105,7 @@ self.error("can't process %s/%s: %s", rdirectory, rid, ex) adirectory = rdirectory else: - stream = file(cachefile, 'w') + stream = open(cachefile, 'w') stream.write(content) stream.close() adirectory = self._cache_directory diff -r 8d9fe02387e3 -r 57dfde80df11 web/webconfig.py --- a/web/webconfig.py Thu Sep 17 09:52:06 2015 +0200 +++ b/web/webconfig.py Tue Sep 15 15:33:47 2015 +0200 @@ -460,7 +460,7 @@ staticdir = join(staticdir, rdir) if not isdir(staticdir) and 'w' in mode: os.makedirs(staticdir) - return file(join(staticdir, filename), mode) + return open(join(staticdir, filename), mode) def static_file_add(self, rpath, data): stream = self.static_file_open(rpath)