Skip to content

Commit

Permalink
Merge pull request FrostyX#144 from FrostyX/api-and-unicode
Browse files Browse the repository at this point in the history
Fixing some of the unicode and API errors
  • Loading branch information
FrostyX committed Jun 5, 2020
2 parents d46627d + b7d6c69 commit 1ed2146
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
10 changes: 10 additions & 0 deletions tests/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,13 @@ def test_packages_intersection(self):
self.assertEqual(c1.intersection([p1, p3]).sorted("name"), PackagesCollection([p1, p3]).sorted("name"))
self.assertEqual(c1.intersection(None), c1)
self.assertIsNotNone(c1.intersection([p5])[0].modified)

def test_replace_values(self):
a1 = Application({"name": "foo"})
a2 = Application({"name": "bar"})
a3 = Application({"name": "baz"})
c1 = ApplicationsCollection([a1, a2, a3])

assert {a.name for a in c1} == {"foo", "bar", "baz"}
c1.replace_values("name", "foo", "qux")
assert {a.name for a in c1} == {"qux", "bar", "baz"}
14 changes: 7 additions & 7 deletions tracer/packageManagers/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ def _splitEvra(self, evra):
return epoch, ver, rel, arch

def _load_package_info_from_hdr(self, package, hdr):
package.description = hdr[rpm.RPMTAG_SUMMARY].decode()
package.category = hdr[rpm.RPMTAG_GROUP].decode()
package.description = hdr[rpm.RPMTAG_SUMMARY]
package.category = hdr[rpm.RPMTAG_GROUP]

epoch = hdr[rpm.RPMTAG_EPOCH]
if epoch:
package.epoch = epoch.decode()
package.epoch = epoch

package.version = hdr[rpm.RPMTAG_VERSION].decode()
package.release = hdr[rpm.RPMTAG_RELEASE].decode()
package.version = hdr[rpm.RPMTAG_VERSION]
package.release = hdr[rpm.RPMTAG_RELEASE]

def _file_provided_by(self, file):
"""Returns name of package which provides given file"""
Expand All @@ -216,8 +216,8 @@ def _file_provided_by(self, file):
return None

pkg = next(db)
p = Package(pkg[rpm.RPMTAG_NAME].decode())
p.category = pkg[rpm.RPMTAG_GROUP].decode()
p = Package(pkg[rpm.RPMTAG_NAME])
p.category = pkg[rpm.RPMTAG_GROUP]
return p

def _database_file(self):
Expand Down
2 changes: 1 addition & 1 deletion tracer/resources/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Collection(list):
def replace_values(self, attribute, source_value, required_value):
for app in self:
if getattr(app, attribute) == source_value:
app.update(attribute, required_value)
app.update({attribute: required_value})


def sorted(self, attribute):
Expand Down

0 comments on commit 1ed2146

Please sign in to comment.