|
0 |
--- a/common/utils.py
|
|
1 |
+++ b/common/utils.py
|
|
2 |
@@ -4,7 +4,7 @@ import ntpath
|
|
3 |
import os
|
|
4 |
|
|
5 |
from lxml import etree
|
|
6 |
-from logger import info, error, warning
|
|
7 |
+from .logger import info, error, warning
|
|
8 |
|
|
9 |
from common.exceptions import ApplicationException
|
|
10 |
from CTDopts.CTDopts import CTDModel, ParameterGroup
|
|
11 |
@@ -100,7 +100,7 @@ def parse_input_ctds(xsd_location, input
|
|
12 |
try:
|
|
13 |
info("Loading validation schema from %s" % xsd_location, 0)
|
|
14 |
schema = etree.XMLSchema(etree.parse(xsd_location))
|
|
15 |
- except Exception, e:
|
|
16 |
+ except Exception as e:
|
|
17 |
error("Could not load validation schema %s. Reason: %s" % (xsd_location, str(e)), 0)
|
|
18 |
else:
|
|
19 |
warning("Validation against a schema has not been enabled.", 0)
|
|
20 |
@@ -127,7 +127,7 @@ def validate_against_schema(ctd_file, sc
|
|
21 |
try:
|
|
22 |
parser = etree.XMLParser(schema=schema)
|
|
23 |
etree.parse(ctd_file, parser=parser)
|
|
24 |
- except etree.XMLSyntaxError, e:
|
|
25 |
+ except etree.XMLSyntaxError as e:
|
|
26 |
raise ApplicationException("Invalid CTD file %s. Reason: %s" % (ctd_file, str(e)))
|
|
27 |
|
|
28 |
|
|
29 |
@@ -195,9 +195,9 @@ def parse_hardcoded_parameters(hardcoded
|
|
30 |
def extract_tool_help_text(ctd_model):
|
|
31 |
manual = ""
|
|
32 |
doc_url = None
|
|
33 |
- if "manual" in ctd_model.opt_attribs.keys():
|
|
34 |
+ if "manual" in list(ctd_model.opt_attribs.keys()):
|
|
35 |
manual += "%s\n\n" % ctd_model.opt_attribs["manual"]
|
|
36 |
- if "docurl" in ctd_model.opt_attribs.keys():
|
|
37 |
+ if "docurl" in list(ctd_model.opt_attribs.keys()):
|
|
38 |
doc_url = ctd_model.opt_attribs["docurl"]
|
|
39 |
|
|
40 |
help_text = "No help available"
|
|
41 |
@@ -258,7 +258,7 @@ def extract_and_flatten_parameters(ctd_m
|
|
42 |
parameters.append(parameter)
|
|
43 |
else:
|
|
44 |
# append the first-level children of this ParameterGroup
|
|
45 |
- pending.extend(parameter.parameters.values())
|
|
46 |
+ pending.extend(list(parameter.parameters.values()))
|
|
47 |
# returned the reversed list of parameters (as it is now,
|
|
48 |
# we have the last parameter in the CTD as first in the list)
|
|
49 |
return reversed(parameters)
|
|
50 |
--- a/convert.py
|
|
51 |
+++ b/convert.py
|
|
52 |
@@ -224,19 +224,19 @@ def main(argv=None):
|
|
53 |
print("Interrupted...")
|
|
54 |
return 0
|
|
55 |
|
|
56 |
- except ApplicationException, e:
|
|
57 |
+ except ApplicationException as e:
|
|
58 |
traceback.print_exc()
|
|
59 |
utils.error("CTDConverter could not complete the requested operation.", 0)
|
|
60 |
utils.error("Reason: " + e.msg, 0)
|
|
61 |
return 1
|
|
62 |
|
|
63 |
- except ModelError, e:
|
|
64 |
+ except ModelError as e:
|
|
65 |
traceback.print_exc()
|
|
66 |
utils.error("There seems to be a problem with one of your input CTDs.", 0)
|
|
67 |
utils.error("Reason: " + e.msg, 0)
|
|
68 |
return 1
|
|
69 |
|
|
70 |
- except Exception, e:
|
|
71 |
+ except Exception as e:
|
|
72 |
traceback.print_exc()
|
|
73 |
utils.error("CTDConverter could not complete the requested operation.", 0)
|
|
74 |
utils.error("Reason: " + e.msg, 0)
|
|
75 |
--- a/galaxy/converter.py
|
|
76 |
+++ b/galaxy/converter.py
|
|
77 |
@@ -134,10 +134,10 @@ def parse_macros_files(macros_file_names
|
|
78 |
else:
|
|
79 |
logger.info("Macro %s found" % name, 1)
|
|
80 |
macros_to_expand.add(name)
|
|
81 |
- except ParseError, e:
|
|
82 |
+ except ParseError as e:
|
|
83 |
raise ApplicationException("The macros file " + macros_file_name + " could not be parsed. Cause: " +
|
|
84 |
str(e))
|
|
85 |
- except IOError, e:
|
|
86 |
+ except IOError as e:
|
|
87 |
raise ApplicationException("The macros file " + macros_file_name + " could not be opened. Cause: " +
|
|
88 |
str(e))
|
|
89 |
|
|
90 |
@@ -281,7 +281,7 @@ def generate_tool_conf(parsed_ctds, tool
|
|
91 |
if galaxy_tool_path is None:
|
|
92 |
galaxy_tool_path = ""
|
|
93 |
|
|
94 |
- for category, file_names in categories_to_tools.iteritems():
|
|
95 |
+ for category, file_names in categories_to_tools.items():
|
|
96 |
section_node = add_child_node(toolbox_node, "section")
|
|
97 |
section_node.attrib["id"] = "section-id-" + "".join(category.split())
|
|
98 |
section_node.attrib["name"] = category
|
|
99 |
@@ -322,7 +322,7 @@ def create_tool(model):
|
|
100 |
|
|
101 |
|
|
102 |
def create_description(tool, model):
|
|
103 |
- if "description" in model.opt_attribs.keys() and model.opt_attribs["description"] is not None:
|
|
104 |
+ if "description" in list(model.opt_attribs.keys()) and model.opt_attribs["description"] is not None:
|
|
105 |
description = SubElement(tool,"description")
|
|
106 |
description.text = model.opt_attribs["description"]
|
|
107 |
|
|
108 |
@@ -667,7 +667,7 @@ def create_param_attribute_list(param_no
|
|
109 |
def generate_label_and_help(desc):
|
|
110 |
help_text = ""
|
|
111 |
# This tag is found in some descriptions
|
|
112 |
- if not isinstance(desc, basestring):
|
|
113 |
+ if not isinstance(desc, str):
|
|
114 |
desc = str(desc)
|
|
115 |
desc = desc.encode("utf8").replace("#br#", " <br>")
|
|
116 |
# Get rid of dots in the end
|
|
117 |
@@ -734,9 +734,9 @@ def is_selection_parameter(param):
|
|
118 |
|
|
119 |
|
|
120 |
def get_lowercase_list(some_list):
|
|
121 |
- lowercase_list = map(str, some_list)
|
|
122 |
- lowercase_list = map(string.lower, lowercase_list)
|
|
123 |
- lowercase_list = map(strip, lowercase_list)
|
|
124 |
+ lowercase_list = list(map(str, some_list))
|
|
125 |
+ lowercase_list = list(map(string.lower, lowercase_list))
|
|
126 |
+ lowercase_list = list(map(strip, lowercase_list))
|
|
127 |
return lowercase_list
|
|
128 |
|
|
129 |
|
|
130 |
@@ -800,7 +800,7 @@ def create_output_node(parent, param, mo
|
|
131 |
# check if there are formats that have not been registered yet...
|
|
132 |
output = list()
|
|
133 |
for format_name in param.restrictions.formats:
|
|
134 |
- if not format_name in supported_file_formats.keys():
|
|
135 |
+ if not format_name in list(supported_file_formats.keys()):
|
|
136 |
output.append(str(format_name))
|
|
137 |
|
|
138 |
# warn only if there's about to complain
|
|
139 |
@@ -833,7 +833,7 @@ def create_output_node(parent, param, mo
|
|
140 |
|
|
141 |
# Get the supported file format for one given format
|
|
142 |
def get_supported_file_type(format_name, supported_file_formats):
|
|
143 |
- if format_name in supported_file_formats.keys():
|
|
144 |
+ if format_name in list(supported_file_formats.keys()):
|
|
145 |
return supported_file_formats.get(format_name, DataType(format_name, format_name)).galaxy_extension
|
|
146 |
else:
|
|
147 |
return None
|
|
148 |
@@ -841,7 +841,7 @@ def get_supported_file_type(format_name,
|
|
149 |
|
|
150 |
def get_supported_file_types(formats, supported_file_formats):
|
|
151 |
return set([supported_file_formats.get(format_name, DataType(format_name, format_name)).galaxy_extension
|
|
152 |
- for format_name in formats if format_name in supported_file_formats.keys()])
|
|
153 |
+ for format_name in formats if format_name in list(supported_file_formats.keys())])
|
|
154 |
|
|
155 |
|
|
156 |
def create_change_format_node(parent, data_formats, input_ref):
|