Ejemplo n.º 1
0
 def openIn(self, autoDecompress=True):
     """open the input file for reading in the ExRun process"""
     path = self.__setupIn()
     if fileOps.isCompressed(path) and autoDecompress:
         return fileOps.openz(path)
     else:
         return open(path)
Ejemplo n.º 2
0
 def openOut(self, autoCompress=True):
     """open the output file for writing from the ExRun process"""
     path = self.__setupOut(autoCompress)
     if fileOps.isCompressed(path) and autoCompress:
         return fileOps.openz(path, "w")
     else:
         return open(path, "w")
Ejemplo n.º 3
0
 def openIn(self, autoDecompress=True):
     """open the input file for reading in the ExRun process"""
     path = self.__setupIn()
     if fileOps.isCompressed(path) and autoDecompress:
         return fileOps.openz(path)
     else:
         return open(path)
Ejemplo n.º 4
0
 def openOut(self, autoCompress=True):
     """open the output file for writing from the ExRun process"""
     path = self.__setupOut(autoCompress)
     if fileOps.isCompressed(path) and autoCompress:
         return fileOps.openz(path, "w")
     else:
         return open(path, "w")
Ejemplo n.º 5
0
    def __getOutput(self, pdag, fspec):
        """Get an output file. If fspec can be None, File or FileOut, or any
        object that can be converted to a string.  Return the appropriate Pout
        object, None, or a string. Adds compression process if needed."""
        if fspec == None:
            return None
        if isinstance(fspec, File):
            fspec = FileOut(fspec)
        if not isinstance(fspec, FileOut):
            return str(fspec)

        # handle File object, include arg prefix
        path = fspec.file.getOutPath()
        if fileOps.isCompressed(path) and fspec.autoCompress:
            pdev = Pipeline.Pipe()
            pdag.create((fileOps.compressCmd(path),), stdin=pdev, stdout=path)
            return Pipeline.POut(pdev, fspec.prefix)
        else:
            return Pipeline.POut(Pipeline.File(path), fspec.prefix)
Ejemplo n.º 6
0
    def __getOutput(self, pdag, fspec):
        """Get an output file. If fspec can be None, File or FileOut, or any
        object that can be converted to a string.  Return the appropriate Pout
        object, None, or a string. Adds compression process if needed."""
        if fspec == None:
            return None
        if isinstance(fspec, File):
            fspec = FileOut(fspec)
        if not isinstance(fspec, FileOut):
            return str(fspec)

        # handle File object, include arg prefix
        path = fspec.file.getOutPath()
        if fileOps.isCompressed(path) and fspec.autoCompress:
            pdev = Pipeline.Pipe()
            pdag.create((fileOps.compressCmd(path), ), stdin=pdev, stdout=path)
            return Pipeline.POut(pdev, fspec.prefix)
        else:
            return Pipeline.POut(Pipeline.File(path), fspec.prefix)
Ejemplo n.º 7
0
    def __getInput(pdag, fspec):
        """Get an input file. If fspec can be None, File or FileIn, or any
        object that can be converted to a string.  Return the appropriate PIn
        object, None, or a string. Adds decompression process if needed."""
        if fspec is None:
            return None
        if isinstance(fspec, File):
            fspec = FileIn(fspec)
        if not isinstance(fspec, FileIn):
            return str(fspec)

        # handle File object, include arg prefix
        path = fspec.file.getInPath()
        if fileOps.isCompressed(path) and fspec.autoDecompress:
            pdev = pipeline.Pipe()
            pdag.create((fileOps.decompressCmd(path), path), stdout=pdev)
            return pipeline.PIn(pdev, fspec.prefix)
        else:
            return pipeline.PIn(pipeline.File(path), fspec.prefix)
Ejemplo n.º 8
0
def _getExt(gxfFile):
    if fileOps.isCompressed(gxfFile):
        return os.path.splitext(os.path.splitext(gxfFile)[0])[1]
    else:
        return os.path.splitext(gxfFile)[1]