INNER CODE UNIT · Python

open

theyosh/TerrariumPI · contrib/pipes/__init__.py:151

    def open(self, file, rw):
        """t.open(file, rw) returns a pipe or file object open for
        reading or writing; the file is the other end of the pipeline."""
        if rw == "r":
            return self.open_r(file)
        if rw == "w":
            return self.open_w(file)
        raise ValueError("Template.open: rw must be 'r' or 'w', not %r" % (rw,))

    def open_r(self, file):
        """t.open_r(file) and t.open_w(file) implement
        t.open(file, 'r') and t.open(file, 'w') respectively."""
        if not self.steps:
            return open(file, "r")
        if self.steps[-1][1] == SINK:
            raise ValueError("Template.open_r: pipeline ends width SINK")
        cmd = self.makepipeline(file, "")
        return os.popen(cmd, "r")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…