Initial port to python3
[htsworkflow.git] / htsworkflow / submission / condorfastq.py
index 17e463351282b7b8091f922760e8b1fd69a2c934..65b6b69d9846786f4b53f8c74775c3a4c6b73432 100644 (file)
@@ -5,7 +5,7 @@ import os
 from pprint import pformat,pprint
 import sys
 import types
-from urlparse import urljoin, urlparse
+from urllib.parse import urljoin, urlparse
 
 from htsworkflow.pipelines.sequences import scan_for_sequences, \
      update_model_sequence_library
@@ -68,7 +68,7 @@ class CondorFastqExtract(object):
         if pythonpath is not None:
             env = "PYTHONPATH=%s" % (pythonpath,)
         condor_entries = self.build_condor_arguments(result_map)
-        for script_type in template_map.keys():
+        for script_type in list(template_map.keys()):
             template = loader.get_template(template_map[script_type])
             variables = {'python': sys.executable,
                          'logdir': self.log_path,
@@ -93,10 +93,10 @@ class CondorFastqExtract(object):
         sequences = self.find_archive_sequence_files(result_map)
         needed_targets = self.update_fastq_targets(result_map, sequences)
 
-        for target_pathname, available_sources in needed_targets.items():
+        for target_pathname, available_sources in list(needed_targets.items()):
             LOGGER.debug(' target : %s' % (target_pathname,))
             LOGGER.debug(' candidate sources: %s' % (available_sources,))
-            for condor_type in available_sources.keys():
+            for condor_type in list(available_sources.keys()):
                 conversion = conversion_funcs.get(condor_type, None)
                 if conversion is None:
                     errmsg = "Unrecognized type: {0} for {1}"
@@ -161,7 +161,7 @@ class CondorFastqExtract(object):
         return results
 
     def import_libraries(self, result_map):
-        for lib_id in result_map.keys():
+        for lib_id in list(result_map.keys()):
             lib_id_encoded = lib_id.encode('utf-8')
             liburl = urljoin(self.host, 'library/%s/' % (lib_id_encoded,))
             library = RDF.Node(RDF.Uri(liburl))
@@ -322,7 +322,7 @@ class SequenceResult(object):
         self.cycle = fromTypedNode(result['cycle'])
         self.lane_number = fromTypedNode(result['lane_number'])
         self.read = fromTypedNode(result['read'])
-        if type(self.read) in types.StringTypes:
+        if type(self.read) in str:
             self.read = 1
         self.library = result['library']
         self.library_id = fromTypedNode(result['library_id'])
@@ -355,8 +355,8 @@ class SequenceResult(object):
         if url.scheme == 'file':
             return url.path
         else:
-            errmsg = u"Unsupported scheme {0} for {1}"
-            raise ValueError(errmsg.format(url.scheme, unicode(url)))
+            errmsg = "Unsupported scheme {0} for {1}"
+            raise ValueError(errmsg.format(url.scheme, str(url)))
     path = property(_get_path)
 
     def __repr__(self):