return True
return False
-
-
-# XXX DEAD CODE
-
-class __File(base.Object):
- def __init__(self, pakfire, path):
- base.Object.__init__(self, pakfire)
-
- assert os.path.exists(path)
- self.path = path
-
- def calc_hash(self, method="sha512"):
- h = None
-
- if method == "sha512":
- h = hashlib.sha512()
-
- if h is None:
- raise Exception, "Not a valid hash method: %s" % method
-
- logging.debug("Calculating %s hash for %s" % (method, self.path))
-
- f = open(self.path, "rb")
- while True:
- buf = f.read(BUFFER_SIZE)
- if not buf:
- break
-
- h.update(buf)
- f.close()
-
- return h.hexdigest()
-
-
-class DatabaseFile(File):
- def __init__(self, pakfire, id):
- base.Object.__init__(self, pakfire)
-
- self.id = id
-
- # Cache.
- self._data = None
-
- def fetch_data(self):
- raise NotImplementedError
-
- @property
- def data(self):
- if self._data is None:
- self._data = self.fetch_data()
-
- return self._data
-
-
-class DatabaseSourceFile(DatabaseFile):
- def fetch_data(self):
- return self.db.get("SELECT * FROM files_src WHERE id = %s", self.id)
-
-
-
-class PackageFile(File):
- type = None
-
- def __init__(self, pakfire, path):
- File.__init__(self, pakfire, path)
-
- # Open the package file for reading.
- self.pkg = packages.open(None, None, self.path)
- assert self.pkg.type == self.type
-
- def to_database(self):
- raise NotImplementedError
-
- @property
- def uuid(self):
- return self.pkg.uuid
-
- @property
- def requires(self):
- return self.pkg.requires
-
- @property
- def build_host(self):
- return self.pkg.build_host
-
- @property
- def build_id(self):
- return self.pkg.build_id
-
- @property
- def build_time(self):
- build_time = self.pkg.build_time
-
- return datetime.datetime.utcfromtimestamp(build_time)
-
-
-class PackageSourceFile(PackageFile):
- type = "source"
-
- def to_database(self):
- # MUST BE RELATIVE TO BASEDIR
- path = self.path
-
- id = self.db.execute("""
- INSERT INTO packages(path, uuid, requires, hash_sha512,
- build_host, build_id, build_time)
- VALUES(%s, %s, %s, %s, %s, %s, %s)""",
- path, self.uuid, "\n".join(self.requires), self.calc_hash("sha512"),
- self.build_host, self.build_id, self.build_time
- )
-
- # Return the newly created object.
- return DatabaseSourceFile(self.pakfire, id)
-
-
-class PackageBinaryFile(PackageFile):
- type = "binary"
-
-