Bug 1364504 - [api] Utility functions have been removed without replacements
Summary: [api] Utility functions have been removed without replacements
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 25
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: rpm-software-management
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-08-05 13:57 UTC by Avram Lubkin
Modified: 2017-06-14 12:59 UTC (History)
9 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2017-06-14 12:59:14 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1452801 0 unspecified CLOSED [api] add dnf.rpm.miscutils.splitFilename() method for yum compatibility 2021-02-22 00:41:40 UTC

Internal Links: 1452801

Description Avram Lubkin 2016-08-05 13:57:51 UTC
Description of problem:

It seems a the stringToVersion() utility functions was removed from dnf/rpmUtils/miscutils.py without being provided elsewhere.

Commit 4e00d6481f028495dc0ddbd353826f47d52b8f2c [1] removed stringToVersion(), but there doesn't seem to be another source for this function. The commit marks the function as unused, but doesn't provide a path for Python 2 code using this function to be ported to Python 3 without reimplementing the functionality.

Additional info:

[1] https://github.com/rpm-software-management/dnf/commit/4e00d6481f028495dc0ddbd353826f47d52b8f2c

Comment 1 Avram Lubkin 2016-08-05 14:04:59 UTC
It turns out that function is also buggy, so should be fixed as well as reimplemented.

    >>> rpmUtils.miscutils.stringToVersion('fedora-review-0.6.1-1.fc24.noarch')
    ('0', 'fedora', 'review-0.6.1-1.fc24.noarch')

Comment 2 Avram Lubkin 2016-08-05 14:18:54 UTC
Nevermind that last comment, works fine, but still should be available in DNF for Python 3.

    >>> rpmUtils.miscutils.stringToVersion('0.6.1-1.fc24.noarch')
    ('0', '0.6.1', '1.fc24.noarch')

Comment 3 Igor Gnatenko 2016-08-05 17:55:42 UTC
That was never API.

Comment 4 Avram Lubkin 2016-08-05 22:20:10 UTC
According to the docs it is for yum:

http://yum.baseurl.org/api/yum-3.2.27/

$ dnf provides /usr/lib/python2.7/site-packages/rpmUtils/miscutils.py
Last metadata expiration check: 2 days, 1:56:36 ago on Wed Aug  3 16:16:57 2016.
yum-3.4.3-509.fc24.noarch : RPM package installer/updater/manager
Repo        : @System

yum-3.4.3-509.fc24.noarch : RPM package installer/updater/manager
Repo        : fedora


Capability exists in Yum for Python 2 and is not provided by DNF.

Comment 5 Ken Dreyer (Red Hat) 2017-05-19 16:08:03 UTC
We need this method for Python 3 support in rdopkg. (discussed at https://review.rdoproject.org/r/6705)

Comment 6 Jaroslav Mracek 2017-05-24 15:13:13 UTC
I create pull request that should provide a functionality (https://github.com/rpm-software-management/dnf/pull/828). Hope that it is what was requested

Comment 7 Jaroslav Mracek 2017-05-24 15:23:12 UTC
Example how to use it:

```
subject = dnf.subjet.Subject("my_nevra_string")
possible_nevra = subject.get_nevra_possibilities()
```
If I want to print all possible names just use:
```
for nevra in possible_nevra:
     print(nevra.name)
```

Comment 8 Ken Dreyer (Red Hat) 2017-05-24 15:39:50 UTC
Thank you! Especially for providing an example.

Would you mind putting that example into the DNF documentation, so it will be easy for developers to discover?

Comment 9 Jaroslav Mracek 2017-05-25 10:23:03 UTC
Examples added

Comment 10 Jaroslav Mracek 2017-06-14 12:59:14 UTC
The patch was released in dnf-2.5.1-1 into rawhide and fc26.


Note You need to log in before you can comment on or make changes to this bug.