python/samba/gp_parse: PY3 file -> open
authorNoel Power <noel.power@suse.com>
Wed, 5 Sep 2018 11:46:44 +0000 (12:46 +0100)
committerNoel Power <npower@samba.org>
Mon, 5 Nov 2018 19:05:23 +0000 (20:05 +0100)
'file' no longer exists in PY3 replace with 'open'

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/gp_parse/__init__.py
python/samba/gp_parse/gp_csv.py
python/samba/gp_parse/gp_inf.py
python/samba/gp_parse/gp_ini.py
python/samba/gp_parse/gp_pol.py
python/samba/netcmd/gpo.py

index 911f7df3e7daeeb1dd8571bb87744f72f5364fa0..8ddd52d36571adce0e1396fa1a446e3fe33ce7fa 100644 (file)
@@ -61,7 +61,7 @@ class GPParser(object):
         pass
 
     def write_xml(self, filename):
-        with file(filename, 'w') as f:
+        with open(filename, 'w') as f:
             f.write('<?xml version="1.0" encoding="utf-8"?><UnknownFile/>')
 
     def load_xml(self, filename):
index b19f84c56f7d076d50e254844df20ec5879c7a87..cd30ef2bc0096114938deefc0b619d675e096482 100644 (file)
@@ -47,7 +47,7 @@ class GPAuditCsvParser(GPParser):
             # print line
 
     def write_xml(self, filename):
-        with file(filename, 'wb') as f:
+        with open(filename, 'wb') as f:
             root = Element('CsvFile')
             child = SubElement(root, 'Row')
             for e in self.header:
@@ -93,7 +93,7 @@ class GPAuditCsvParser(GPParser):
                 self.lines.append(line)
 
     def write_binary(self, filename):
-        with file(filename, 'wb') as f:
+        with open(filename, 'wb') as f:
             # This should be using a unicode writer, but it seems to be in the
             # right encoding at least by default.
             #
index e4bed26b2d90ddc04f7f3647dacefde8581a3c89..8fcd9d59d74964dc9b19fc70272464b51fb3aed8 100644 (file)
@@ -337,7 +337,7 @@ class GptTmplInfParser(GPParser):
                 self.sections[s].write_section(s, f)
 
     def write_xml(self, filename):
-        with file(filename, 'w') as f:
+        with open(filename, 'wb') as f:
             root = Element('GptTmplInfFile')
 
             for sec_inf in self.sections:
index 58aee88a1e1de3add1a73d7c7e4fc25eb6037dbc..575dee78727f1fdd19c5de95e1b640a05fa8023b 100644 (file)
@@ -70,7 +70,7 @@ class GPIniParser(GPParser):
         return section_name
 
     def write_xml(self, filename):
-        with open(filename, 'wb') as f:
+        with open(filename, 'w') as f:
             root = Element('IniFile')
 
             for sec_ini in self.ini_conf.sections():
index 563574713b32d48a8ad05875eaf7abe77b72e7f4..67ecd584dc01a3e27e3843b373666b6c62c26138 100644 (file)
@@ -99,7 +99,7 @@ class GPPolParser(GPParser):
         # print self.pol_file.__ndr_print__()
 
     def write_xml(self, filename):
-        with file(filename, 'w') as f:
+        with open(filename, 'wb') as f:
             root = Element('PolFile')
             root.attrib['signature'] = self.pol_file.header.signature
             root.attrib['version'] = str(self.pol_file.header.version)
@@ -142,6 +142,6 @@ class GPPolParser(GPParser):
         # self.load_xml(fromstring(contents))
 
     def write_binary(self, filename):
-        with file(filename, 'wb') as f:
+        with open(filename, 'wb') as f:
             binary_data = ndr_pack(self.pol_file)
             f.write(binary_data)
index 6a7efe8add879dc575c3de8e2be91b4a120a8fb5..07c31f3a0432d9e746db1ca73deb0e3e17be8238 100644 (file)
@@ -295,7 +295,7 @@ def backup_directory_remote_to_local(conn, remotedir, localdir):
                 os.mkdir(l_name)
             else:
                 data = conn.loadfile(r_name)
-                with file(l_name + SUFFIX, 'w') as f:
+                with open(l_name + SUFFIX, 'w') as f:
                     f.write(data)
 
                 parser = find_parser(e['name'])