Actually comare an integer (length of list) to an integer 0.
[htsworkflow.git] / htsworkflow / pipelines / firecrest.py
index 7d92050866369f70892b4e2b969f5a3bc16af4cf..fba83f9d97c782b349f5021d6bbbe0919e65b5e4 100644 (file)
@@ -9,6 +9,7 @@ fromxml
   Firecrest factory function initalized from an xml dump from
   the Firecrest object.
 """
+from __future__ import print_function
 
 from datetime import date
 from glob import glob
@@ -17,16 +18,16 @@ import os
 import re
 import time
 
-from htsworkflow.pipelines.runfolder import \
+from htsworkflow.pipelines import \
    ElementTree, \
    VERSION_RE, \
    EUROPEAN_STRPTIME
 
 LOGGER = logging.getLogger(__name__)
 
-__docformat__ = "restructuredtext en"
-
 class Firecrest(object):
+    """Gather information about older firecrest runs
+    """
     XML_VERSION=1
 
     # xml tag names
@@ -39,6 +40,12 @@ class Firecrest(object):
     MATRIX = 'matrix'
 
     def __init__(self, xml=None):
+        """Initialize a Firecrest object
+        
+        consider using factory :function:firecrest
+        
+        :param xml: xml serialzation element to initialze from [optional]
+        """
         self.start = None
         self.stop = None
         self.version = None
@@ -49,18 +56,26 @@ class Firecrest(object):
         if xml is not None:
             self.set_elements(xml)
 
+    def _get_software(self):
+        return "Firecrest"
+    software = property(_get_software)
+
     def _get_time(self):
         return time.mktime(self.date.timetuple())
     time = property(_get_time, doc='return run time as seconds since epoch')
 
     def dump(self):
-        print "Starting cycle:", self.start
-        print "Ending cycle:", self.stop
-        print "Firecrest version:", self.version
-        print "Run date:", self.date
-        print "user:", self.user
+        """Report debugginf information
+        """
+        print("Starting cycle:", self.start)
+        print("Ending cycle:", self.stop)
+        print("Firecrest version:", self.version)
+        print("Run date:", self.date)
+        print("user:", self.user)
 
     def get_elements(self):
+        """Return XML serialization structure.
+        """
         attribs = {'version': str(Firecrest.XML_VERSION) }
         root = ElementTree.Element(Firecrest.FIRECREST, attrib=attribs)
         version = ElementTree.SubElement(root, Firecrest.SOFTWARE_VERSION)
@@ -130,7 +145,7 @@ def firecrest(pathname):
     if os.path.exists(matrix_pathname):
         # this is for firecrest < 1.3.2
         f.matrix = open(matrix_pathname, 'r').read()
-    elif glob(bustard_pattern) > 0:
+    elif len(glob(bustard_pattern)) > 0:
         f.matrix = None
         # there are runs here. Bustard should save the matrix.
     else: