def test_pyrpm_basic(self): test_file = self.get_test_loc('rpm/header/python-glc-0.7.1-1.src.rpm') from packagedcode.pyrpm import RPM raw_rpm = RPM(open(test_file, 'rb')) alltags = raw_rpm.get_tags() expected = { 'arch': 'noarch', 'epoch': None, 'description': 'These bindings permit access to QuesoGLC, an ' 'open source\nimplementation of TrueType font ' 'rendering for OpenGL.', 'dist_url': None, 'distribution': None, 'group': 'Development/Libraries', 'license': 'LGPL', 'name': 'python-glc', 'os': 'linux', 'packager': None, 'release': '1', 'patch': None, 'source_rpm': None, 'summary': 'ctypes Python bindings for QuesoGLC', 'url': 'ftp://ftp.graviscom.de/pub/python-glc/', 'vendor': 'Arno Pähler <*****@*****.**>', 'version': '0.7.1', } assert expected == alltags # tests that tags are all unicode assert all([isinstance(v, compat.unicode) for v in alltags.values() if v])
def get_rpm_tags(location, include_desc=False): """ Return an RPMtags object for the file at location or None. Include the long RPM description value if `include_desc` is True. """ with open(location, 'rb') as rpmf: rpm = RPM(rpmf) tags = {k: v for k, v in rpm.to_dict().items() if k in RPM_TAGS} if not include_desc: tags['description'] = None return RPMtags(**tags)
def get_rpm_tags(location, include_desc=False): """ Return an RPMtags object for the file at location or None. Include the long RPM description value if `include_desc` is True. """ T = typecode.contenttype.get_type(location) if 'rpm' not in T.filetype_file.lower(): return with open(location, 'rb') as rpmf: rpm = RPM(rpmf) tags = {k: v for k, v in rpm.to_dict().items() if k in RPM_TAGS} if not include_desc: tags['description'] = None return RPMtags(**tags)