1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

python: bulk replace file to open for py3

The builtin function `file` was removed in py3. Use `open` instead.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
Joe Guo 2018-04-11 16:03:34 +12:00 committed by Douglas Bagnall
parent 9d79329d3d
commit 8432ca2b48
3 changed files with 5 additions and 5 deletions

View File

@ -252,7 +252,7 @@ def copy_directory_remote_to_local(conn, remotedir, localdir):
os.mkdir(l_name)
else:
data = conn.loadfile(r_name)
file(l_name, 'w').write(data)
open(l_name, 'w').write(data)
def copy_directory_local_to_remote(conn, localdir, remotedir):
@ -274,7 +274,7 @@ def copy_directory_local_to_remote(conn, localdir, remotedir):
r_dirs.append(r_name)
conn.mkdir(r_name)
else:
data = file(l_name, 'r').read()
data = open(l_name, 'r').read()
conn.savefile(r_name, data)
@ -943,7 +943,7 @@ class cmd_create(Command):
os.mkdir(os.path.join(gpodir, "Machine"))
os.mkdir(os.path.join(gpodir, "User"))
gpt_contents = "[General]\r\nVersion=0\r\n"
file(os.path.join(gpodir, "GPT.INI"), "w").write(gpt_contents)
open(os.path.join(gpodir, "GPT.INI"), "w").write(gpt_contents)
except Exception as e:
raise CommandError("Error Creating GPO files", e)

View File

@ -806,7 +806,7 @@ def create_samdb_copy(samdb, logger, paths, names, domainsid, domainguid):
domainpart_file = os.path.join(dns_dir, partfile[domaindn])
try:
os.mkdir(dns_samldb_dir)
file(domainpart_file, 'w').close()
open(domainpart_file, 'w').close()
# Fill the basedn and @OPTION records in domain partition
dom_url = "%s://%s" % (backend_store, domainpart_file)

View File

@ -79,7 +79,7 @@ class TestProtocolClient(unittest.TestResult):
suite = make_suite()
# Create a stream (any object with a 'write' method). This should accept
# bytes not strings: subunit is a byte orientated protocol.
stream = file('tests.log', 'wb')
stream = open('tests.log', 'wb')
# Create a subunit result object which will output to the stream
result = subunit.TestProtocolClient(stream)
# Optionally, to get timing data for performance analysis, wrap the