Skip to content
Permalink
Browse files
[processing] Use with ... when opening files
(partially cherry-picked from 6a99017)
  • Loading branch information
alexbruy committed May 24, 2017
1 parent 65f571c commit 2a9248103ec76b3879156384a90583cc25ea339c
@@ -127,8 +127,8 @@ def get_list_from_node(self, myet):
return all_params

def defineCharacteristicsFromFile(self):
content = open(self.descriptionFile).read()
dom_model = ET.fromstring(content)
with open(self.descriptionFile) as content:
dom_model = ET.fromstring(content.read())

self.appkey = dom_model.find('key').text
self.cliName = dom_model.find('exec').text
@@ -274,10 +274,9 @@ def remove_parameter_by_criteria(doc, criteria):


def defaultWrite(available_app, original_dom_document):
fh = open("description/%s.xml" % available_app, "w")
the_root = original_dom_document
ET.ElementTree(the_root).write(fh)
fh.close()
with open("description/%s.xml" % available_app, "w") as fh:
the_root = original_dom_document
ET.ElementTree(the_root).write(fh)


def defaultSplit(available_app, original_dom_document, parameter):
@@ -656,16 +656,15 @@ def create_xml_descriptors():
if available_app in white_list and available_app not in black_list:
logger.warning("There is no adaptor for %s, check white list and versions" % available_app)
# TODO Remove this default code when all apps are tested...
fh = open("description/%s.xml" % available_app, "w")
the_root = get_xml_description_from_application_name(available_app)
ET.ElementTree(the_root).write(fh)
fh.close()
with open("description/%s.xml" % available_app, "w") as fh:
the_root = get_xml_description_from_application_name(available_app)
ET.ElementTree(the_root).write(fh)
try:
get_automatic_ut_from_xml_description(the_root)
except:
logger.error("Unit test for command %s must be fixed: %s" % (available_app, traceback.format_exc()))
else:
logger.warning("%s (not custom app) is not in white list." % available_app)
logger.warning("%s (not custom app) is not in white list." % available_app)
# except Exception, e:
# logger.error(traceback.format_exc())

@@ -678,12 +677,11 @@ def create_html_description():

for available_app in otbApplication.Registry.GetAvailableApplications():
try:
fh = open("description/doc/%s.html" % available_app, "w")
app_instance = otbApplication.Registry.CreateApplication(available_app)
app_instance.UpdateParameters()
ct = describe_app(app_instance)
fh.write(ct)
fh.close()
with open("description/doc/%s.html" % available_app, "w") as fh:
app_instance = otbApplication.Registry.CreateApplication(available_app)
app_instance.UpdateParameters()
ct = describe_app(app_instance)
fh.write(ct)
except Exception:
logger.error(traceback.format_exc())

@@ -694,7 +692,7 @@ def create_html_description():
if __name__ == "__main__":
# Prepare the environment
from qgis.core import QgsApplication

app = QgsApplication([], True)
QgsApplication.initQgis()

@@ -120,7 +120,8 @@ def templatize(item):
self.fail(unicode(e))

def add_make(self, previous_context, new_file):
input = open(new_file).read()
with open(new_file) as f:
input = f.read()
output = parse(input)
apps = [each for each in output if 'Command' in unicode(type(each))]
setcommands = [each for each in apps if 'SET' in each.name.upper()]
@@ -163,21 +164,24 @@ def mini_clean(item):
return environment

def get_apps(self, the_makefile, the_dict):
input = open(the_makefile).read()
with open(the_makefile) as f:
input = f.read()
output = parse(input)
apps = [each for each in output if 'Command' in unicode(type(each))]
otb_apps = [each for each in apps if 'OTB_TEST_APPLICATION' in each.name.upper()]
return otb_apps

def get_tests(self, the_makefile, the_dict):
input = open(the_makefile).read()
with open(the_makefile) as f:
input = f.read()
output = parse(input)
apps = [each for each in output if 'Command' in unicode(type(each))]
otb_tests = [each for each in apps if 'ADD_TEST' in each.name.upper()]
return otb_tests

def get_apps_with_context(self, the_makefile, the_dict):
input = open(the_makefile).read()
with open(the_makefile) as f:
input = f.read()
output = parse(input)

def is_a_command(item):

0 comments on commit 2a92481

Please sign in to comment.