- update to Unidecode 0.04.20 - change source url to pythonhosted.org OBS-URL: https://build.opensuse.org/request/show/449591 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Unidecode?expand=0&rev=11
114 lines
4.3 KiB
RPMSpec
114 lines
4.3 KiB
RPMSpec
#
|
|
# spec file for package python-Unidecode
|
|
#
|
|
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
|
#
|
|
# All modifications and additions to the file contributed by third parties
|
|
# remain the property of their copyright owners, unless otherwise agreed
|
|
# upon. The license for this file, and modifications and additions to the
|
|
# file, is the same license as for the pristine package itself (unless the
|
|
# license for the pristine package is not an Open Source License, in which
|
|
# case the license is the MIT License). An "Open Source License" is a
|
|
# license that conforms to the Open Source Definition (Version 1.9)
|
|
# published by the Open Source Initiative.
|
|
|
|
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
|
#
|
|
|
|
|
|
Name: python-Unidecode
|
|
Version: 0.04.20
|
|
Release: 0
|
|
Summary: ASCII transliterations of Unicode text
|
|
License: GPL-2.0+
|
|
Group: Development/Languages/Python
|
|
Url: https://pypi.python.org/pypi/Unidecode
|
|
Source: https://files.pythonhosted.org/packages/source/U/Unidecode/Unidecode-%{version}.tar.gz
|
|
BuildRequires: fdupes
|
|
BuildRequires: python-devel
|
|
BuildRequires: python-setuptools
|
|
Requires(post): update-alternatives
|
|
Requires(postun): update-alternatives
|
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
|
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
|
|
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
|
|
%else
|
|
BuildArch: noarch
|
|
%endif
|
|
|
|
%description
|
|
It often happens that you have text data in Unicode, but you need to
|
|
represent it in ASCII. For example when integrating with legacy code that
|
|
doesn't support Unicode, or for ease of entry of non-Roman names on a US
|
|
keyboard, or when constructing ASCII machine identifiers from
|
|
human-readable Unicode strings that should still be somewhat intelligible
|
|
(a popular example of this is when making an URL slug from an article
|
|
title).
|
|
|
|
In most of these examples you could represent Unicode characters as
|
|
"???" or "\\15BA\\15A0\\1610", to mention two extreme cases. But that's
|
|
nearly useless to someone who actually wants to read what the text says.
|
|
|
|
What Unidecode provides is a middle road: function unidecode() takes
|
|
Unicode data and tries to represent it in ASCII characters (i.e., the
|
|
universally displayable characters between 0x00 and 0x7F), where the
|
|
compromises taken when mapping between two character sets are chosen to be
|
|
near what a human with a US keyboard would choose.
|
|
|
|
The quality of resulting ASCII representation varies. For languages of
|
|
western origin it should be between perfect and good. On the other hand
|
|
transliteration (i.e., conveying, in Roman letters, the pronunciation
|
|
expressed by the text in some other writing system) of languages like
|
|
Chinese, Japanese or Korean is a very complex issue and this library does
|
|
not even attempt to address it. It draws the line at context-free
|
|
character-by-character mapping. So a good rule of thumb is that the further
|
|
the script you are transliterating is from Latin alphabet, the worse the
|
|
transliteration will be.
|
|
|
|
Note that this module generally produces better results than simply
|
|
stripping accents from characters (which can be done in Python with
|
|
built-in functions). It is based on hand-tuned character mappings that for
|
|
example also contain ASCII approximations for symbols and non-Latin
|
|
alphabets.
|
|
|
|
This is a Python port of Text::Unidecode Perl module by
|
|
Sean M. Burke <sburke@cpan.org>.
|
|
|
|
%prep
|
|
%setup -q -n Unidecode-%{version}
|
|
|
|
%build
|
|
python setup.py build
|
|
|
|
%install
|
|
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
|
|
%fdupes %buildroot/%_prefix
|
|
|
|
# update-alternatives
|
|
mv %{buildroot}%{_bindir}/unidecode %{buildroot}%{_bindir}/unidecode-%{py_ver}
|
|
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
|
|
touch %{buildroot}%{_sysconfdir}/alternatives/unidecode
|
|
ln -sf %{_sysconfdir}/alternatives/unidecode %{buildroot}%{_bindir}/unidecode
|
|
|
|
%check
|
|
LANG=en_US.UTF-8 python setup.py test
|
|
|
|
%post
|
|
update-alternatives \
|
|
--install %{_bindir}/unidecode unidecode %{_bindir}/unidecode-%{py_ver} 20
|
|
|
|
%postun
|
|
if [ $1 -eq 0 ] ; then
|
|
update-alternatives --remove unidecode %{_bindir}/unidecode-%{py_ver}
|
|
fi
|
|
|
|
%files
|
|
%defattr(-,root,root,-)
|
|
%doc LICENSE ChangeLog
|
|
%{python_sitelib}/*
|
|
%ghost %{_sysconfdir}/alternatives/unidecode
|
|
%{_bindir}/unidecode
|
|
%{_bindir}/unidecode-%{py_ver}
|
|
|
|
%changelog
|