[Rpm-maint] [rpm-software-management/rpm] pythondistdeps: Switch to importlib.metadata (#1317)

Miro Hrončok notifications at github.com
Thu Sep 24 11:27:29 UTC 2020


@hroncok commented on this pull request.



>  from warnings import warn
 
+try:
+    from importlib.metadata import PathDistribution
+except ImportError:
+    from importlib_metadata import PathDistribution
+
+try:
+    from pathlib import Path
+except ImportError:
+    from pathlib2 import Path
+
+
+class Req(Requirement):
+    @property
+    def key(self):
+        return self.name.lower().replace('_', '-')

Instead, I'd create two properties here:

```python
class Req(Requirement):
    @property
    def legacy_normalized_name(self):
        """Like pkg_resources key property"""
        if not self._legacy_normalized_name:
            self._legacy_normalized_name = re.sub(r'[-_]+', '-', self.name).lower()
       return self._legacy_normalized_name

    @property
   def normalized_name(self):
        """PEP 503 normalized name"""
        if not self._normalized_name:
            self._normalized_name = re.sub(r'[-_.]+', '-', self.name).lower()
       return self._normalized_name
```

"key" is not very descriptive.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/1317#discussion_r494237504
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20200924/6e14d4a6/attachment.html>


More information about the Rpm-maint mailing list