Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented sorting of ReallyUserFriendlyTypes using unidecode #93

Merged
merged 8 commits into from
Jul 24, 2024

Conversation

rohnsha0
Copy link
Contributor

@mister-roboto
Copy link

@rohnsha0 thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@rohnsha0 rohnsha0 requested review from jensens and petschki July 17, 2024 11:12
@jensens
Copy link
Member

jensens commented Jul 19, 2024

+1 for sane sorting.

But: I vote against using the pyICU package, because of its lack of providing wheels together with it's need for the C-Library. Usage on several platforms may get a PITA.

There is pyUCA which works in a similar way but without having this problem. What do you think?

cc @zopyx @petschki

@zopyx
Copy link
Member

zopyx commented Jul 19, 2024

But: I vote against using the pyICU package, because of its lack of providing wheels together with it's need for the C-Library. Usage on several platforms may get a PITA.

+1

However, pyuca appears unmaintained, last release from 2017, future unclear.

Proposal:

  • provide a universal utility method for sorting a list of strings for a given language
  • default sorting using sorted()
  • if pyuca or pyICU is installed: facilitate the sort based on the collation provide by one of those packages.

@rohnsha0
Copy link
Contributor Author

Proposal:

  • provide a universal utility method for sorting a list of strings for a given language
  • default sorting using sorted()
  • if pyuca or pyICU is installed: facilitate the sort based on the collation provide by one of those packages.

@zopyx then according to you, we first need to check if pyicu or pyuca is installed then sorting using their collarator else using default sorting method?

@wesleybl
Copy link
Member

And if the unidecode package is used:

>>> from unidecode import unidecode
>>> unidecode("Águia").lower()
'aguia'

@rohnsha0
Copy link
Contributor Author

And if the unidecode package is used:

>>> from unidecode import unidecode
>>> unidecode("Águia").lower()
'aguia'

does unicode provide the same func? im actually unaware of it... @wesleybl

@jensens
Copy link
Member

jensens commented Jul 22, 2024

And if the unidecode package is used:

It is a dependency of the Plone universe anyway.

@rohnsha0
Copy link
Contributor Author

And if the unidecode package is used:

It is a dependency of the Plone universe anyway.

then performing the sorting using unicode is a better option... right?

@wesleybl
Copy link
Member

does unicode provide the same func? im actually unaware of it... @wesleybl

The unicode function no longer exists in Python 3. In any case, it was used for something different in Python 2.

You must use the unidecode function within the function passed in the key parameter of the sort method. For example:

>>> from unidecode import unidecode
>>> list = ['Café', 'Águia', 'Água']
>>> list.sort(key=lambda string: unidecode(string).lower())
>>> list
['Água', 'Águia', 'Café']

@wesleybl
Copy link
Member

It is a dependency of the Plone universe anyway.

Anyway, I think it's worth putting it as a dependency in setup.py

@rohnsha0
Copy link
Contributor Author

@wesleybl @jensens verify the changes... it worked for me!

@rohnsha0 rohnsha0 requested a review from wesleybl July 23, 2024 15:09
Copy link
Member

@wesleybl wesleybl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check for test errors.

@rohnsha0
Copy link
Contributor Author

autofix pushing was disabled in the configuration. to autofix this pr, comment or apply the label "pre-commit.ci autofix" to the pull request

it was the error found in one of failing test

@rohnsha0
Copy link
Contributor Author

pre-commit.ci autofix

@rohnsha0
Copy link
Contributor Author

@jenkins-plone-org please run jobs

@rohnsha0 rohnsha0 changed the title Implemented pyICU for sorting of ReallyUserFriendlyTypes Implemented sorting of ReallyUserFriendlyTypes using unidecode Jul 23, 2024
@rohnsha0
Copy link
Contributor Author

@jenkins-plone-org please run jobs

@rohnsha0
Copy link
Contributor Author

@jenkins-plone-org please run jobs

@rohnsha0 rohnsha0 requested a review from wesleybl July 23, 2024 17:02
Copy link
Member

@jensens jensens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member

@wesleybl wesleybl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rohnsha0 rohnsha0 merged commit 1da12d2 into master Jul 24, 2024
12 checks passed
@rohnsha0 rohnsha0 deleted the sorting-ReallyUserFriendlyTypes-using-pyicu branch July 24, 2024 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants