override = os.environ.get('M5_OVERRIDE_PY_SOURCE', 'false').lower()
if override in ('true', 'yes') and os.path.exists(abspath):
- src = file(abspath, 'r').read()
+ src = open(abspath, 'r').read()
code = compile(src, abspath, 'exec')
if os.path.basename(srcfile) == '__init__.py':
sys.path = [ os.path.dirname(sys.argv[0]) ] + sys.path
filename = sys.argv[0]
- filedata = file(filename, 'r').read()
+ filedata = open(filename, 'r').read()
filecode = compile(filedata, filename, 'exec')
scope = { '__file__' : filename,
'__name__' : '__m5_main__' }
for obj in root.descendants(): obj.unproxyParams()
if options.dump_config:
- ini_file = file(os.path.join(options.outdir, options.dump_config), 'w')
+ ini_file = open(os.path.join(options.outdir, options.dump_config), 'w')
# Print ini sections in sorted order for easier diffing
for obj in sorted(root.descendants(), key=lambda o: o.path()):
obj.print_ini(ini_file)
if options.json_config:
try:
import json
- json_file = file(os.path.join(options.outdir, options.json_config), 'w')
+ json_file = open(
+ os.path.join(options.outdir, options.json_config), 'w')
d = root.get_config_as_dict()
json.dump(d, json_file, indent=4)
json_file.close()
self._data = []
def write(self, *args):
- f = file(os.path.join(*args), "w")
+ f = open(os.path.join(*args), "w")
for data in self._data:
f.write(data)
f.close()
def parse_file(self, f, **kwargs):
if isinstance(f, basestring):
source = f
- f = file(f, 'r')
+ f = open(f, 'r')
elif isinstance(f, file):
source = f.name
else: