Esempio n. 1
0
 def test_open_normal(self):
     basepath = os.path.dirname(__file__)
     fd = apt_pkg.open_maybe_clear_signed_file(
         os.path.join(basepath, "./data/misc/foo_Release"))
     with os.fdopen(fd) as f:
         data = f.read()
     self.assertTrue(data.startswith("Origin: Ubuntu\n"))
Esempio n. 2
0
    def open(self, file):
        """Open the package."""
        depends_tags = ["Build-Depends", "Build-Depends-Indep"]
        conflicts_tags = ["Build-Conflicts", "Build-Conflicts-Indep"]
        fd = apt_pkg.open_maybe_clear_signed_file(file)
        fobj = os.fdopen(fd)
        tagfile = apt_pkg.TagFile(fobj)
        try:
            for sec in tagfile:
                for tag in depends_tags:
                    if tag not in sec:
                        continue
                    self._depends.extend(apt_pkg.parse_src_depends(sec[tag]))
                for tag in conflicts_tags:
                    if tag not in sec:
                        continue
                    self._conflicts.extend(apt_pkg.parse_src_depends(sec[tag]))
                if 'Source' in sec:
                    self.pkgname = sec['Source']
                if 'Binary' in sec:
                    self.binaries = [
                        b.strip() for b in sec['Binary'].split(',')
                    ]
                for tag in sec.keys():
                    if tag in sec:
                        self._sections[tag] = sec[tag]
        finally:
            del tagfile
            fobj.close()

        s = _("Install Build-Dependencies for "
              "source package '%s' that builds %s\n") % (
                  self.pkgname, " ".join(self.binaries))
        self._sections["Description"] = s
        self._check_was_run = False
Esempio n. 3
0
 def test_open_trivial(self):
     basepath = os.path.dirname(__file__)
     fd = apt_pkg.open_maybe_clear_signed_file(
         os.path.join(basepath, "./data/test_debs/hello_2.5-1.dsc"))
     with os.fdopen(fd) as f:
         data = f.read()
     self.assertTrue(data.startswith("Format: 1.0\n"))
Esempio n. 4
0
    def open(self, file):
        """Open the package."""
        depends_tags = ["Build-Depends", "Build-Depends-Indep"]
        conflicts_tags = ["Build-Conflicts", "Build-Conflicts-Indep"]
        fd = apt_pkg.open_maybe_clear_signed_file(file)
        fobj = os.fdopen(fd)
        tagfile = apt_pkg.TagFile(fobj)
        try:
            for sec in tagfile:
                for tag in depends_tags:
                    if tag not in sec:
                        continue
                    self._depends.extend(apt_pkg.parse_src_depends(sec[tag]))
                for tag in conflicts_tags:
                    if tag not in sec:
                        continue
                    self._conflicts.extend(apt_pkg.parse_src_depends(sec[tag]))
                if 'Source' in sec:
                    self.pkgname = sec['Source']
                if 'Binary' in sec:
                    self.binaries = [b.strip() for b in
                                     sec['Binary'].split(',')]
                for tag in sec.keys():
                    if tag in sec:
                        self._sections[tag] = sec[tag]
        finally:
            del tagfile
            fobj.close()

        s = _("Install Build-Dependencies for "
              "source package '%s' that builds %s\n") % (self.pkgname,
              " ".join(self.binaries))
        self._sections["Description"] = s
        self._check_was_run = False
Esempio n. 5
0
 def test_open_normal(self):
     basepath = os.path.dirname(__file__)
     fd = apt_pkg.open_maybe_clear_signed_file(
         os.path.join(basepath, "./data/misc/foo_Release"))
     with os.fdopen(fd) as f:
         data = f.read()
     self.assertTrue(data.startswith("Origin: Ubuntu\n"))
Esempio n. 6
0
 def test_open_trivial(self):
     basepath = os.path.dirname(__file__)
     fd = apt_pkg.open_maybe_clear_signed_file(
         os.path.join(basepath, "./data/test_debs/hello_2.5-1.dsc"))
     with os.fdopen(fd) as f:
         data = f.read()
     self.assertTrue(data.startswith("Format: 1.0\n"))
Esempio n. 7
0
def get_release_date_from_release_file(path):
    """
    return the release date as time_t for the given release file
    """
    if not path or not os.path.exists(path):
        return None

    with os.fdopen(apt_pkg.open_maybe_clear_signed_file(path)) as data:
        tag = apt_pkg.TagFile(data)
        section = next(tag)
        if "Date" not in section:
            return None
        date = section["Date"]
        return apt_pkg.str_to_time(date)
Esempio n. 8
0
 def xtest_open_does_not_exit(self):
     with self.assertRaises(SystemError):
         apt_pkg.open_maybe_clear_signed_file("does-not-exists")
Esempio n. 9
0
 def xtest_open_does_not_exit(self):
     with self.assertRaises(SystemError):
         apt_pkg.open_maybe_clear_signed_file("does-not-exists")