Commit e9531ee8 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

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

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