-
Story
-
Resolution: Done
-
Undefined
-
None
-
False
-
False
-
-
rhel-cle-nexus
-
-
-
-
-
- Problem
-
Currently, fedora-easy-karma uses a PkgHelper class that modifies the global behavior of the `dnf.package.Package` class by dynamically injecting a `_getitem_` method:
```
dnf.package.Package._getitem_ = lambda self, key: getattr(self, key)
```
This practice is dangerous and can lead to unexpected side effects elsewhere in the application or any libraries using DNF.
-
-
- Possible solution
-
Refactor PkgHelper into a new design that wraps the `dnf.package.Package` object in a safe local wrapper class.
The wrapper should:
- provide the same convenience (pkg["name"] and pkg.name both work),
- avoid modifying any DNF internal objects globally.
`PackageWrapper` will be a small wrapper class that proxies both attribute access and index access to the underlying dnf.package.Package instance.
`Packages`: the `PkgHelper` will be renamed so that the name tells more about what we can expext from this class. It will stay the same, but will use the `PackageWrapper` to enable the previous functionality.