Initial port to python3
[htsworkflow.git] / htsworkflow / frontend / samples / views.py
index 5ab54a9e4fafd49b9fdfc1df1131bf1120a42766..5ddad93c02fdb99c6366ee4bc21a73f95681d24e 100644 (file)
@@ -1,12 +1,12 @@
 # Create your views here.
-import StringIO
+import io
 import logging
 import os
 import sys
 
 try:
     import json
-except ImportError, e:
+except ImportError as e:
     import simplejson as json
 
 from django.views.decorators.csrf import csrf_exempt
@@ -84,14 +84,14 @@ def create_library_context(cl):
            summary['amplified_from'] = ''
        lanes_run = count_lanes(lib.lane_set)
        # suppress zeros
-       for row in xrange(len(lanes_run)):
-           for col in xrange(len(lanes_run[row])):
+       for row in range(len(lanes_run)):
+           for col in range(len(lanes_run[row])):
                if lanes_run[row][col] == 0:
                    lanes_run[row][col] = ''
        summary['lanes_run'] = lanes_run
        summary['is_archived'] = lib.is_archived()
        records.append(summary)
-    cl.result_count = unicode(cl.paginator._count)
+    cl.result_count = str(cl.paginator._count)
     return {'library_list': records }
 
 
@@ -379,7 +379,7 @@ def _make_eland_results(flowcell_id, lane_number, interesting_flowcells):
         storage_ids = ', '.join([ '<a href="/inventory/%s/">%s</a>' % (s,s) for s in storage_id_list ])
 
     results = []
-    for cycle in cur_fc.keys():
+    for cycle in list(cur_fc.keys()):
         result_path = cur_fc[cycle]['eland_results'].get(lanes[0], None)
         result_link = make_result_link(fc_id, cycle, lanes[0], result_path)
         results.append({'flowcell_id': fc_id,
@@ -459,7 +459,7 @@ def library_dict(library_id):
     """
     try:
         lib = Library.objects.get(id = library_id)
-    except Library.DoesNotExist, e:
+    except Library.DoesNotExist as e:
         return None
 
     #lane_info = lane_information(lib.lane_set)