diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-05 07:51:14 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 07:51:14 +0000 |
commit | 7bee6a2bc8a05cfffe36f77ac075be2494ddc62a (patch) | |
tree | edfdb4cd5855feec927ac9841bfbbf5c96e177b4 | |
parent | 0b0240c9f6903cb004129ea6da3c73c7cfbda84f (diff) |
automatic import of python-homoglyphsopeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-homoglyphs.spec | 543 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 545 insertions, 0 deletions
@@ -0,0 +1 @@ +/homoglyphs-2.0.4.tar.gz diff --git a/python-homoglyphs.spec b/python-homoglyphs.spec new file mode 100644 index 0000000..356187f --- /dev/null +++ b/python-homoglyphs.spec @@ -0,0 +1,543 @@ +%global _empty_manifest_terminate_build 0 +Name: python-homoglyphs +Version: 2.0.4 +Release: 1 +Summary: Homoglyphs +License: MIT +URL: https://github.com/life4/homoglyphs +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/42/a8/33ee2cc828318714563991144c56c42f4d1126487b6f166fe8f80800652b/homoglyphs-2.0.4.tar.gz +BuildArch: noarch + + +%description +# Homoglyphs + + +[](https://travis-ci.org/orsinium/homoglyphs) [](https://pypi.python.org/pypi/homoglyphs) [](https://pypi.python.org/pypi/homoglyphs) [](https://github.com/orsinium/homoglyphs) [](LICENSE) + +Homoglyphs -- python library for getting [homoglyphs](https://en.wikipedia.org/wiki/Homoglyph) and converting to ASCII. + + +## Features + +It's smarter version of [confusable_homoglyphs](https://github.com/vhf/confusable_homoglyphs): + +* Autodect or manual choosing category ([aliases from ISO 15924](https://en.wikipedia.org/wiki/ISO_15924#List_of_codes)). +* Auto or manual load only needed alphabets in memory. +* Converting to ASCII. +* More configurable. +* More stable. + + +## Installation + +```bash +sudo pip install homoglyphs +``` + + +## Usage + +Best way to explain something is show how it works. So, let's have a look on the real usage. + +Importing: + +```python +import homoglyphs as hg +``` + +### Languages + +```python +#detect +hg.Languages.detect('w') +# {'pl', 'da', 'nl', 'fi', 'cz', 'sr', 'pt', 'it', 'en', 'es', 'sk', 'de', 'fr', 'ro'} +hg.Languages.detect('т') +# {'mk', 'ru', 'be', 'bg', 'sr'} +hg.Languages.detect('.') +# set() + +# get alphabet for languages +hg.Languages.get_alphabet(['ru']) +# {'в', 'Ё', 'К', 'Т', ..., 'Р', 'З', 'Э'} + +# get all languages +hg.Languages.get_all() +# {'nl', 'lt', ..., 'de', 'mk'} +``` + +### Categories + +Categories -- ([aliases from ISO 15924](https://en.wikipedia.org/wiki/ISO_15924#List_of_codes)). + +```python +#detect +hg.Categories.detect('w') +# 'LATIN' +hg.Categories.detect('т') +# 'CYRILLIC' +hg.Categories.detect('.') +# 'COMMON' + +# get alphabet for categories +hg.Categories.get_alphabet(['CYRILLIC']) +# {'ӗ', 'Ԍ', 'Ґ', 'Я', ..., 'Э', 'ԕ', 'ӻ'} + +# get all categories +hg.Categories.get_all() +# {'RUNIC', 'DESERET', ..., 'SOGDIAN', 'TAI_LE'} +``` + +### Homoglyphs + +Get homoglyphs: + +```python +# get homoglyphs (latin alphabet initialized by default) +hg.Homoglyphs().get_combinations('q') +# ['q', '𝐪', '𝑞', '𝒒', '𝓆', '𝓺', '𝔮', '𝕢', '𝖖', '𝗊', '𝗾', '𝘲', '𝙦', '𝚚'] +``` + +Alphabet loading: + +```python +# load alphabet on init by categories +homoglyphs = hg.Homoglyphs(categories=('LATIN', 'COMMON', 'CYRILLIC')) # alphabet loaded here +homoglyphs.get_combinations('гы') +# ['rы', 'гы', 'ꭇы', 'ꭈы', '𝐫ы', '𝑟ы', '𝒓ы', '𝓇ы', '𝓻ы', '𝔯ы', '𝕣ы', '𝖗ы', '𝗋ы', '𝗿ы', '𝘳ы', '𝙧ы', '𝚛ы'] + +# load alphabet on init by languages +homoglyphs = hg.Homoglyphs(languages={'ru', 'en'}) # alphabet will be loaded here +homoglyphs.get_combinations('гы') +# ['rы', 'гы'] + +# manual set alphabet on init # eng rus +homoglyphs = hg.Homoglyphs(alphabet='abc абс') +homoglyphs.get_combinations('с') +# ['c', 'с'] + +# load alphabet on demand +homoglyphs = hg.Homoglyphs(languages={'en'}, strategy=hg.STRATEGY_LOAD) +# ^ alphabet will be loaded here for "en" language +homoglyphs.get_combinations('гы') +# ^ alphabet will be loaded here for "ru" language +# ['rы', 'гы'] +``` + +You can combine `categories`, `languages`, `alphabet` and any strategies as you want. The strategies specify how to handle any characters not already loaded: + +* `STRATEGY_LOAD`: load category for this character +* `STRATEGY_IGNORE`: add character to result +* `STRATEGY_REMOVE`: remove character from result + + +### Converting glyphs to ASCII chars + +```python +homoglyphs = hg.Homoglyphs(languages={'en'}, strategy=hg.STRATEGY_LOAD) + +# convert +homoglyphs.to_ascii('ТЕСТ') +# ['TECT'] +homoglyphs.to_ascii('ХР123.') # this is cyrillic "х" and "р" +# ['XP123.', 'XPI23.', 'XPl23.'] + +# string with chars which can't be converted by default will be ignored +homoglyphs.to_ascii('лол') +# [] + +# you can set strategy for removing not converted non-ASCII chars from result +homoglyphs = hg.Homoglyphs( + languages={'en'}, + strategy=hg.STRATEGY_LOAD, + ascii_strategy=hg.STRATEGY_REMOVE, +) +homoglyphs.to_ascii('лол') +# ['o'] + +# also you can set up range of allowed char codes for ascii (0-128 by default): +homoglyphs = hg.Homoglyphs( + languages={'en'}, + strategy=hg.STRATEGY_LOAD, + ascii_strategy=hg.STRATEGY_REMOVE, + ascii_range=range(ord('a'), ord('z')), +) +homoglyphs.to_ascii('ХР123.') +# ['l'] +homoglyphs.to_ascii('хр123.') +# ['xpl'] +``` + + +%package -n python3-homoglyphs +Summary: Homoglyphs +Provides: python-homoglyphs +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-homoglyphs +# Homoglyphs + + +[](https://travis-ci.org/orsinium/homoglyphs) [](https://pypi.python.org/pypi/homoglyphs) [](https://pypi.python.org/pypi/homoglyphs) [](https://github.com/orsinium/homoglyphs) [](LICENSE) + +Homoglyphs -- python library for getting [homoglyphs](https://en.wikipedia.org/wiki/Homoglyph) and converting to ASCII. + + +## Features + +It's smarter version of [confusable_homoglyphs](https://github.com/vhf/confusable_homoglyphs): + +* Autodect or manual choosing category ([aliases from ISO 15924](https://en.wikipedia.org/wiki/ISO_15924#List_of_codes)). +* Auto or manual load only needed alphabets in memory. +* Converting to ASCII. +* More configurable. +* More stable. + + +## Installation + +```bash +sudo pip install homoglyphs +``` + + +## Usage + +Best way to explain something is show how it works. So, let's have a look on the real usage. + +Importing: + +```python +import homoglyphs as hg +``` + +### Languages + +```python +#detect +hg.Languages.detect('w') +# {'pl', 'da', 'nl', 'fi', 'cz', 'sr', 'pt', 'it', 'en', 'es', 'sk', 'de', 'fr', 'ro'} +hg.Languages.detect('т') +# {'mk', 'ru', 'be', 'bg', 'sr'} +hg.Languages.detect('.') +# set() + +# get alphabet for languages +hg.Languages.get_alphabet(['ru']) +# {'в', 'Ё', 'К', 'Т', ..., 'Р', 'З', 'Э'} + +# get all languages +hg.Languages.get_all() +# {'nl', 'lt', ..., 'de', 'mk'} +``` + +### Categories + +Categories -- ([aliases from ISO 15924](https://en.wikipedia.org/wiki/ISO_15924#List_of_codes)). + +```python +#detect +hg.Categories.detect('w') +# 'LATIN' +hg.Categories.detect('т') +# 'CYRILLIC' +hg.Categories.detect('.') +# 'COMMON' + +# get alphabet for categories +hg.Categories.get_alphabet(['CYRILLIC']) +# {'ӗ', 'Ԍ', 'Ґ', 'Я', ..., 'Э', 'ԕ', 'ӻ'} + +# get all categories +hg.Categories.get_all() +# {'RUNIC', 'DESERET', ..., 'SOGDIAN', 'TAI_LE'} +``` + +### Homoglyphs + +Get homoglyphs: + +```python +# get homoglyphs (latin alphabet initialized by default) +hg.Homoglyphs().get_combinations('q') +# ['q', '𝐪', '𝑞', '𝒒', '𝓆', '𝓺', '𝔮', '𝕢', '𝖖', '𝗊', '𝗾', '𝘲', '𝙦', '𝚚'] +``` + +Alphabet loading: + +```python +# load alphabet on init by categories +homoglyphs = hg.Homoglyphs(categories=('LATIN', 'COMMON', 'CYRILLIC')) # alphabet loaded here +homoglyphs.get_combinations('гы') +# ['rы', 'гы', 'ꭇы', 'ꭈы', '𝐫ы', '𝑟ы', '𝒓ы', '𝓇ы', '𝓻ы', '𝔯ы', '𝕣ы', '𝖗ы', '𝗋ы', '𝗿ы', '𝘳ы', '𝙧ы', '𝚛ы'] + +# load alphabet on init by languages +homoglyphs = hg.Homoglyphs(languages={'ru', 'en'}) # alphabet will be loaded here +homoglyphs.get_combinations('гы') +# ['rы', 'гы'] + +# manual set alphabet on init # eng rus +homoglyphs = hg.Homoglyphs(alphabet='abc абс') +homoglyphs.get_combinations('с') +# ['c', 'с'] + +# load alphabet on demand +homoglyphs = hg.Homoglyphs(languages={'en'}, strategy=hg.STRATEGY_LOAD) +# ^ alphabet will be loaded here for "en" language +homoglyphs.get_combinations('гы') +# ^ alphabet will be loaded here for "ru" language +# ['rы', 'гы'] +``` + +You can combine `categories`, `languages`, `alphabet` and any strategies as you want. The strategies specify how to handle any characters not already loaded: + +* `STRATEGY_LOAD`: load category for this character +* `STRATEGY_IGNORE`: add character to result +* `STRATEGY_REMOVE`: remove character from result + + +### Converting glyphs to ASCII chars + +```python +homoglyphs = hg.Homoglyphs(languages={'en'}, strategy=hg.STRATEGY_LOAD) + +# convert +homoglyphs.to_ascii('ТЕСТ') +# ['TECT'] +homoglyphs.to_ascii('ХР123.') # this is cyrillic "х" and "р" +# ['XP123.', 'XPI23.', 'XPl23.'] + +# string with chars which can't be converted by default will be ignored +homoglyphs.to_ascii('лол') +# [] + +# you can set strategy for removing not converted non-ASCII chars from result +homoglyphs = hg.Homoglyphs( + languages={'en'}, + strategy=hg.STRATEGY_LOAD, + ascii_strategy=hg.STRATEGY_REMOVE, +) +homoglyphs.to_ascii('лол') +# ['o'] + +# also you can set up range of allowed char codes for ascii (0-128 by default): +homoglyphs = hg.Homoglyphs( + languages={'en'}, + strategy=hg.STRATEGY_LOAD, + ascii_strategy=hg.STRATEGY_REMOVE, + ascii_range=range(ord('a'), ord('z')), +) +homoglyphs.to_ascii('ХР123.') +# ['l'] +homoglyphs.to_ascii('хр123.') +# ['xpl'] +``` + + +%package help +Summary: Development documents and examples for homoglyphs +Provides: python3-homoglyphs-doc +%description help +# Homoglyphs + + +[](https://travis-ci.org/orsinium/homoglyphs) [](https://pypi.python.org/pypi/homoglyphs) [](https://pypi.python.org/pypi/homoglyphs) [](https://github.com/orsinium/homoglyphs) [](LICENSE) + +Homoglyphs -- python library for getting [homoglyphs](https://en.wikipedia.org/wiki/Homoglyph) and converting to ASCII. + + +## Features + +It's smarter version of [confusable_homoglyphs](https://github.com/vhf/confusable_homoglyphs): + +* Autodect or manual choosing category ([aliases from ISO 15924](https://en.wikipedia.org/wiki/ISO_15924#List_of_codes)). +* Auto or manual load only needed alphabets in memory. +* Converting to ASCII. +* More configurable. +* More stable. + + +## Installation + +```bash +sudo pip install homoglyphs +``` + + +## Usage + +Best way to explain something is show how it works. So, let's have a look on the real usage. + +Importing: + +```python +import homoglyphs as hg +``` + +### Languages + +```python +#detect +hg.Languages.detect('w') +# {'pl', 'da', 'nl', 'fi', 'cz', 'sr', 'pt', 'it', 'en', 'es', 'sk', 'de', 'fr', 'ro'} +hg.Languages.detect('т') +# {'mk', 'ru', 'be', 'bg', 'sr'} +hg.Languages.detect('.') +# set() + +# get alphabet for languages +hg.Languages.get_alphabet(['ru']) +# {'в', 'Ё', 'К', 'Т', ..., 'Р', 'З', 'Э'} + +# get all languages +hg.Languages.get_all() +# {'nl', 'lt', ..., 'de', 'mk'} +``` + +### Categories + +Categories -- ([aliases from ISO 15924](https://en.wikipedia.org/wiki/ISO_15924#List_of_codes)). + +```python +#detect +hg.Categories.detect('w') +# 'LATIN' +hg.Categories.detect('т') +# 'CYRILLIC' +hg.Categories.detect('.') +# 'COMMON' + +# get alphabet for categories +hg.Categories.get_alphabet(['CYRILLIC']) +# {'ӗ', 'Ԍ', 'Ґ', 'Я', ..., 'Э', 'ԕ', 'ӻ'} + +# get all categories +hg.Categories.get_all() +# {'RUNIC', 'DESERET', ..., 'SOGDIAN', 'TAI_LE'} +``` + +### Homoglyphs + +Get homoglyphs: + +```python +# get homoglyphs (latin alphabet initialized by default) +hg.Homoglyphs().get_combinations('q') +# ['q', '𝐪', '𝑞', '𝒒', '𝓆', '𝓺', '𝔮', '𝕢', '𝖖', '𝗊', '𝗾', '𝘲', '𝙦', '𝚚'] +``` + +Alphabet loading: + +```python +# load alphabet on init by categories +homoglyphs = hg.Homoglyphs(categories=('LATIN', 'COMMON', 'CYRILLIC')) # alphabet loaded here +homoglyphs.get_combinations('гы') +# ['rы', 'гы', 'ꭇы', 'ꭈы', '𝐫ы', '𝑟ы', '𝒓ы', '𝓇ы', '𝓻ы', '𝔯ы', '𝕣ы', '𝖗ы', '𝗋ы', '𝗿ы', '𝘳ы', '𝙧ы', '𝚛ы'] + +# load alphabet on init by languages +homoglyphs = hg.Homoglyphs(languages={'ru', 'en'}) # alphabet will be loaded here +homoglyphs.get_combinations('гы') +# ['rы', 'гы'] + +# manual set alphabet on init # eng rus +homoglyphs = hg.Homoglyphs(alphabet='abc абс') +homoglyphs.get_combinations('с') +# ['c', 'с'] + +# load alphabet on demand +homoglyphs = hg.Homoglyphs(languages={'en'}, strategy=hg.STRATEGY_LOAD) +# ^ alphabet will be loaded here for "en" language +homoglyphs.get_combinations('гы') +# ^ alphabet will be loaded here for "ru" language +# ['rы', 'гы'] +``` + +You can combine `categories`, `languages`, `alphabet` and any strategies as you want. The strategies specify how to handle any characters not already loaded: + +* `STRATEGY_LOAD`: load category for this character +* `STRATEGY_IGNORE`: add character to result +* `STRATEGY_REMOVE`: remove character from result + + +### Converting glyphs to ASCII chars + +```python +homoglyphs = hg.Homoglyphs(languages={'en'}, strategy=hg.STRATEGY_LOAD) + +# convert +homoglyphs.to_ascii('ТЕСТ') +# ['TECT'] +homoglyphs.to_ascii('ХР123.') # this is cyrillic "х" and "р" +# ['XP123.', 'XPI23.', 'XPl23.'] + +# string with chars which can't be converted by default will be ignored +homoglyphs.to_ascii('лол') +# [] + +# you can set strategy for removing not converted non-ASCII chars from result +homoglyphs = hg.Homoglyphs( + languages={'en'}, + strategy=hg.STRATEGY_LOAD, + ascii_strategy=hg.STRATEGY_REMOVE, +) +homoglyphs.to_ascii('лол') +# ['o'] + +# also you can set up range of allowed char codes for ascii (0-128 by default): +homoglyphs = hg.Homoglyphs( + languages={'en'}, + strategy=hg.STRATEGY_LOAD, + ascii_strategy=hg.STRATEGY_REMOVE, + ascii_range=range(ord('a'), ord('z')), +) +homoglyphs.to_ascii('ХР123.') +# ['l'] +homoglyphs.to_ascii('хр123.') +# ['xpl'] +``` + + +%prep +%autosetup -n homoglyphs-2.0.4 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-homoglyphs -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 2.0.4-1 +- Package Spec generated @@ -0,0 +1 @@ +fd0fffc19e15196c1e01c95a499e984c homoglyphs-2.0.4.tar.gz |