def main()

in Mosh/MoshVersioner.py [0:0]


    def main(self):
        filepath = self.env["pathname"]
        pkgtmp = tempfile.mkdtemp()
        os.chdir(pkgtmp)
        cmd_extract = ["/usr/bin/xar", "-xf", filepath, "Distribution"]
        result = subprocess.call(cmd_extract)
        if result == 0:
            dom = minidom.parse(os.path.join(pkgtmp, "Distribution"))
            pkgrefs = dom.getElementsByTagName("pkg-ref")
            unfixed = pkgrefs[1].attributes["version"].value.encode("UTF-8")
            # At this point, unfixed_version is typically "mosh-1.x.x"
            self.env["version"] = unfixed.lstrip(b"mosh-").decode()
            self.output("Found version: %s" % self.env["version"])
        else:
            raise ProcessorError(
                "An error occurred while extracting Distribution file"
            )