diff --git a/trytond/backend/postgresql/database.py b/trytond/backend/postgresql/database.py index f9d7cc9a7a..f49cf3e419 100644 --- a/trytond/backend/postgresql/database.py +++ b/trytond/backend/postgresql/database.py @@ -124,7 +124,7 @@ class Database(DatabaseInterface): if os.name == "nt": tmpfile = (os.environ['TMP'] or 'C:\\') + os.tmpnam() - file(tmpfile, 'wb').write(data) + open(tmpfile, 'wb').write(data) args2 = list(args2) args2.append(' ' + tmpfile) args2 = tuple(args2) @@ -207,7 +207,7 @@ class Database(DatabaseInterface): def init(cursor): from trytond.tools import safe_eval sql_file = os.path.join(os.path.dirname(__file__), 'init.sql') - for line in file(sql_file).read().split(';'): + for line in open(sql_file).read().split(';'): if (len(line)>0) and (not line.isspace()): cursor.execute(line) @@ -215,7 +215,7 @@ class Database(DatabaseInterface): root_path = os.path.join(os.path.dirname(__file__), '..', '..') tryton_file = os.path.join(root_path, i, '__tryton__.py') mod_path = os.path.join(root_path, i) - info = safe_eval(file(tryton_file).read()) + info = safe_eval(open(tryton_file).read()) active = info.get('active', False) if active: state = 'to install' diff --git a/trytond/backend/sqlite/database.py b/trytond/backend/sqlite/database.py index 73e8a1d1e6..e27eee4deb 100644 --- a/trytond/backend/sqlite/database.py +++ b/trytond/backend/sqlite/database.py @@ -157,7 +157,7 @@ class Database(DatabaseInterface): raise Exception('Wrong database name!') path = os.path.join(CONFIG['data_path'], database_name + '.sqlite') - file_p = file(path, 'rb') + file_p = open(path, 'rb') data = file_p.read() file_p.close() return data @@ -172,7 +172,7 @@ class Database(DatabaseInterface): database_name + '.sqlite') if os.path.isfile(path): raise Exception('Database already exists!') - file_p = file(path, 'wb') + file_p = open(path, 'wb') file_p.write(data) file_p.close() @@ -199,7 +199,7 @@ class Database(DatabaseInterface): def init(cursor): from trytond.tools import safe_eval sql_file = os.path.join(os.path.dirname(__file__), 'init.sql') - for line in file(sql_file).read().split(';'): + for line in open(sql_file).read().split(';'): if (len(line)>0) and (not line.isspace()): cursor.execute(line) @@ -207,7 +207,7 @@ class Database(DatabaseInterface): root_path = os.path.join(os.path.dirname(__file__), '..', '..') tryton_file = os.path.join(root_path, i, '__tryton__.py') mod_path = os.path.join(root_path, i) - info = safe_eval(file(tryton_file).read()) + info = safe_eval(open(tryton_file).read()) active = info.get('active', False) if active: state = 'to install' diff --git a/trytond/ir/attachment.py b/trytond/ir/attachment.py index 28412fded4..4a693ed359 100644 --- a/trytond/ir/attachment.py +++ b/trytond/ir/attachment.py @@ -56,7 +56,7 @@ class Attachment(ModelSQL, ModelView): value = statinfo.st_size else: try: - file_p = file(filename, 'rb') + file_p = open(filename, 'rb') value = base64.encodestring(file_p.read()) file_p.close() except IOError: @@ -82,7 +82,7 @@ class Attachment(ModelSQL, ModelView): filename = os.path.join(directory, digest) collision = 0 if os.path.isfile(filename): - file_p = file(filename, 'rb') + file_p = open(filename, 'rb') data2 = file_p.read() file_p.close() if data != data2: @@ -96,7 +96,7 @@ class Attachment(ModelSQL, ModelView): filename = os.path.join(directory, digest + '-' + str(collision2)) if os.path.isfile(filename): - file_p = file(filename, 'rb') + file_p = open(filename, 'rb') data2 = file_p.read() file_p.close() if data == data2: @@ -106,11 +106,11 @@ class Attachment(ModelSQL, ModelView): collision = collision2 + 1 filename = os.path.join(directory, digest + '-' + str(collision)) - file_p = file(filename, 'wb') + file_p = open(filename, 'wb') file_p.write(data) file_p.close() else: - file_p = file(filename, 'wb') + file_p = open(filename, 'wb') file_p.write(data) file_p.close() cursor.execute('UPDATE ir_attachment ' \ diff --git a/trytond/ir/gen_time_locale.py b/trytond/ir/gen_time_locale.py index 1e84307bff..500c80e88b 100644 --- a/trytond/ir/gen_time_locale.py +++ b/trytond/ir/gen_time_locale.py @@ -180,7 +180,7 @@ def locale_strftime(lang): return time_locale if __name__ == '__main__': - fp = file(os.path.join(os.path.dirname(__file__), 'time_locale.py'), 'w') + fp = open(os.path.join(os.path.dirname(__file__), 'time_locale.py'), 'w') fp.write('''# -*- coding: utf-8 -*- #This file is part of Tryton. The COPYRIGHT file at the top level of') #this repository contains the full copyright notices and license terms.') diff --git a/trytond/tools/misc.py b/trytond/tools/misc.py index 1408b384cd..5012b537be 100644 --- a/trytond/tools/misc.py +++ b/trytond/tools/misc.py @@ -123,7 +123,7 @@ def file_open(name, mode="r", subdir='modules'): name2 = os.path.normpath(os.path.join(head + '.zip', zipname)) for i in (name2, name, name3): if i and os.path.isfile(i): - return file(i, mode) + return open(i, mode) raise IOError, 'File not found : '+str(name)