From 28cf2580d56a1ec47d595f27d022875967c6b165 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Sep 26 2018 13:54:56 +0000 Subject: Initial package Signed-off-by: Stephen Gallagher --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5499e61 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/ModulemdTranslationHelpers-0.5.tar.gz diff --git a/README.md b/README.md index d7fa99f..fd86045 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,72 @@ -# python-ModulemdTranslationHelpers +# ModulemdTranslationHelpers +## Prerequisites +* [libmodulemd](https://github.com/fedora-modularity/libmodulemd) +* [koji](https://pagure.io/koji) -The python-ModulemdTranslationHelpers package \ No newline at end of file +To install on Fedora 28+, run: +``` +dnf install libmodulemd koji +``` + +## Installation +With the prerequisites installed, the latest version can be installed with +`pip install ModulemdTranslationHelpers` or on Fedora 28+ with `dnf install +python3-ModulemdTranslationHelpers` (recommended). + +## CLI Usage + +### Extract Translatable Strings +To extract translatable strings from modules for a particular Fedora +release (e.g. f29): +``` +ModulemdTranslationHelpers --branch f29 extract [--pot-file ] +``` +This will read all of the module metadata from the Koji build-system and +convert the translatable strings to a portable object template (`.pot`) +document. + +Specify the destination for the output file with `--pot-file`. + + ### Produce modulemd-translations YAML + To convert portable object (`.po`) files into + modulemd-translations YAML documents that can be included in repodata: + ``` + ModulemdTranslationHelpers --branch f29 generate_metadata \ + [--pofile-dir ] \ + [--yaml-file ] + + ``` + + This will read all files with a `.po` suffix in the `pofile-dir` path and + write the modulemd YAML to `yaml-file`. + +## API +### ModulemdTranslationHelpers +The ModulemdTranslationHelpers package has two primary functions: +* get_module_catalog_from_tags() +* get_modulemd_translations() + +#### ModulemdTranslationHelpers.get_module_catalog_from_tags() +This returns a `babel.message.Catalog` object containing all of the +translatable strings from any module tagged with one of the passed tags. It +can be passed to `babel.messages.pofile.write_po()` to create a portable +object template (`.pot`) file. + +#### ModulemdTranslationHelpers.get_modulemd_translations() +This returns an iterable of modulemd-translation objects generated from a +set of paths to portable object (`.po`) files containing translation +information. + +### ModulemdTranslationHelpers.Fedora +This package provides helper routines for dealing with translations in Fedora +Modules. + +#### ModulemdTranslationHelpers.Fedora.KOJI_URL +The URL to the standard Fedora Koji instance. + +#### ModulemdTranslationHelpers.Fedora.get_fedora_rawhide_version() +Looks up which Fedora version the current Rawhide branch will become. + +#### ModulemdTranslationHelpers.Fedora.get_tags_for_fedora_branch() +Gets the list of tags for modules in a given Fedora branch. (For rawhide, +make sure to use the value returned from get_fedora_rawhide_version.) diff --git a/python-ModulemdTranslationHelpers.spec b/python-ModulemdTranslationHelpers.spec new file mode 100644 index 0000000..a5ed0d1 --- /dev/null +++ b/python-ModulemdTranslationHelpers.spec @@ -0,0 +1,107 @@ +%global pypi_name ModulemdTranslationHelpers + +Name: python-%{pypi_name} +Version: 0.5 +Release: 1%{?dist} +Summary: Tools for working with translations of modulemd + +License: MIT +URL: https://github.com/fedora-modularity/ModulemdTranslationHelpers +Source0: https://files.pythonhosted.org/packages/source/M/%{pypi_name}/%{pypi_name}-%{version}.tar.gz +BuildArch: noarch + +BuildRequires: python2-devel +BuildRequires: python2dist(setuptools) + +BuildRequires: python3-devel +BuildRequires: python3dist(setuptools) + +# The following are needed for generating the manpages which are only produced +# for the python3 package. +BuildRequires: python3dist(babel) +BuildRequires: python3dist(click) +BuildRequires: python3dist(click-man) +BuildRequires: python3dist(pygobject) +BuildRequires: python3dist(requests) + +BuildRequires: koji +BuildRequires: libmodulemd + +%{?python_enable_dependency_generator} + +%description +Provides a library and tools for dealing with translatable strings in modulemd +documents. + + +%package -n python2-%{pypi_name} +Summary: %{summary} +%{?python_provide:%python_provide python2-%{pypi_name}} + + +Requires: koji +Requires: libmodulemd +Requires: python2dist(pygobject) + +Obsoletes: python2-mmdzanata < 0.7-3 + +%description -n python2-%{pypi_name} +Provides a library and tools for dealing with translatable strings in modulemd +documents. + + +%package -n python3-%{pypi_name} +Summary: %{summary} +%{?python_provide:%python_provide python3-%{pypi_name}} + + +Requires: koji +Requires: libmodulemd +Requires: python3dist(pygobject) + +Obsoletes: python3-mmdzanata < 0.7-3 + +%description -n python3-%{pypi_name} +Provides a library and tools for dealing with translatable strings in modulemd +documents. + + +%prep +%autosetup -n %{pypi_name}-%{version} +# Remove bundled egg-info +rm -rf %{pypi_name}.egg-info + +%build +# Must do the default python version install last because +# the scripts in /usr/bin are overwritten with every setup.py install. +%py2_install +rm -rf %{buildroot}%{_bindir}/* + +%py3_build + +%install +%py2_install + +%py3_install +%{__python3} setup.py --command-packages=click_man.commands man_pages --target=%{buildroot}/%{_mandir}/man1 + +%files -n python2-%{pypi_name} +%doc README.md +%license LICENSE +%{python2_sitelib}/%{pypi_name} +%{python2_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info + +%files -n python3-%{pypi_name} +%doc README.md +%doc %{_mandir}/man1/* +%license LICENSE +%{_bindir}/ModulemdTranslationHelpers +%{python3_sitelib}/%{pypi_name} +%{python3_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info + +%changelog +* Tue Sep 25 2018 Stephen Gallagher - 0.5-1 +- Fixes from code review + +* Fri Sep 25 2018 Stephen Gallagher - 0.3-1 +- Initial package diff --git a/sources b/sources new file mode 100644 index 0000000..3b8d989 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (ModulemdTranslationHelpers-0.5.tar.gz) = ca44f4bc19aff27c9e6d83f80afd806eea75f042ed6723aebf8b645ae786b35768f8e19a0d9aea55a1d992b77b2ba45d74c2cb44401003828eb6987676d8afae