Commit e9531ee8 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

py2/py3: file() -> open().

parent 7e63228e
......@@ -224,7 +224,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
file_path = os.path.join(cfg.instancehome, 'tests', test_title+'.py')
if os.path.exists(file_path):
os.remove(file_path)
f = file(file_path, 'w')
f = open(file_path, 'w')
f.write(test_data)
f.close()
self.assertTrue(os.path.exists(file_path))
......@@ -2371,7 +2371,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
file_path = os.path.join(cfg.instancehome, 'PropertySheet', ps_title+'.py')
if os.path.exists(file_path):
os.remove(file_path)
f = file(file_path, 'w')
f = open(file_path, 'w')
f.write(ps_data)
f.close()
self.assertTrue(os.path.exists(file_path))
......@@ -2463,7 +2463,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
file_path = os.path.join(cfg.instancehome, 'PropertySheet', ps_title+'.py')
if os.path.exists(file_path):
os.remove(file_path)
f = file(file_path, 'w')
f = open(file_path, 'w')
f.write(ps_data)
f.close()
self.assertTrue(os.path.exists(file_path))
......@@ -8036,7 +8036,7 @@ class _LocalTemplateItemMixin:
file_path = os.path.join(self.document_base_path, self.document_title+'.py')
if os.path.exists(file_path):
os.remove(file_path)
f = file(file_path, 'w')
f = open(file_path, 'w')
f.write(self.document_data)
f.close()
self.assertTrue(os.path.exists(file_path))
......@@ -8048,7 +8048,7 @@ class _LocalTemplateItemMixin:
file_path = os.path.join(self.document_base_path, self.document_title+'.py')
if os.path.exists(file_path):
os.remove(file_path)
f = file(file_path, 'w')
f = open(file_path, 'w')
f.write(self.document_data_updated)
f.close()
self.assertTrue(os.path.exists(file_path))
......@@ -8070,12 +8070,12 @@ class _LocalTemplateItemMixin:
def stepCheckDocumentExists(self, sequence=None, **kw):
self.assertFalse(not os.path.exists(sequence['document_path']))
self.assertEqual(file(sequence['document_path']).read(),
self.assertEqual(open(sequence['document_path']).read(),
sequence['document_data'])
def stepCheckUpdatedDocumentExists(self, sequence=None, **kw):
self.assertFalse(not os.path.exists(sequence['document_path']))
self.assertEqual(file(sequence['document_path']).read(),
self.assertEqual(open(sequence['document_path']).read(),
sequence['document_data_updated'])
def stepCheckDocumentRemoved(self, sequence=None, **kw):
......
......@@ -693,7 +693,7 @@ class TestCRMMailIngestion(BaseTestCRM):
def _readTestData(self, filename):
"""read test data from data directory."""
return file(makeFilePath(filename)).read()
return open(makeFilePath(filename)).read()
def _ingestMail(self, filename=None, data=None):
"""ingest an email from the mail in data dir named `filename`"""
......
......@@ -32,7 +32,7 @@ class FileTransport:
def send(self, to_url, data, sync_id, content_type):
filename = to_url[len('file:/'):]
try:
stream = file(filename, 'w')
stream = open(filename, 'w')
stream.write(data)
stream.close()
except IOError:
......
......@@ -262,7 +262,7 @@ class SynchronizationTool(BaseTool):
filename = from_url[len('file:'):]
xml = None
try:
stream = file(filename, 'r')
stream = open(filename, 'r')
except IOError:
# XXX-Aurel : Why raising here make unit tests to fail ?
# raise ValueError("Impossible to read file %s, error is %s"
......
......@@ -63,7 +63,7 @@ class ExtractMessageCatalog(TestXHTML):
messages = dict(getattr(self.portal.Localizer, i)._messages)
result[i].update(messages)
f = file('%s.pot' % i, 'w')
f = open('%s.pot' % i, 'w')
for msgid in result[i].keys():
f.write('msgid "%s"\nmsgstr ""\n\n' % msgid)
......
......@@ -186,4 +186,4 @@ class BusinessTemplateInfoDir(BusinessTemplateInfoBase):
return fileinfo
def readFileInfo(self, fileinfo):
return file(fileinfo).read()
return open(fileinfo).read()
......@@ -36,7 +36,7 @@ def DA_fromFile(self, filename):
"""
Read the file and update self
"""
f = file(filename)
f = open(filename)
s = f.read()
f.close()
self.fromText(s)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment