Mercurial > treepkg > treepkg
view treepkg/info/package.py @ 402:01c059298906 treepkg-status
moved packages and logs to revision tag
implemented os and arch info
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Mon, 12 Jul 2010 15:47:42 +0000 |
parents | |
children |
line wrap: on
line source
# Copyright (C) 2010 by Intevation GmbH # Authors: # Bjoern Ricks <bjoern.ricks@intevation.de> # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with the software for details. """Classes to read information from binary packages """ import os.path from treepkg import run from treepkg.cmdexpand import cmdexpand class DebianPackage: def __init__(self, filename): self.filename = filename def is_package(self): extension = os.path.splitext(self.filename)[1] return extension.lower() == ".deb" def get_architecture(self): if not self.is_package(): return None arch = run.capture_output(cmdexpand("dpkg-deb -f $debfile Architecture", debfile=self.filename)) return arch.strip() class BinaryPackage: def __init__(self, filename): self.filename = filename self.packagetypes = [] self.packagetypes.append(DebianPackage(self.filename)) def get_architecture(self): for packagetype in self.packagetypes: retval = packagetype.get_architecture() if not retval is None: return retval