diff --git a/.gitignore b/.gitignore index e69de29..50be7b7 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,7 @@ +/toml-0.9.0.tar.gz +/toml-0.9.1.tar.gz +/toml-0.9.2.tar.gz +/toml-0.9.3.0.tar.gz +/toml-0.9.4.tar.gz +/toml-0.10.0.tar.gz +/toml-0.10.1.tar.gz diff --git a/python-toml.spec b/python-toml.spec new file mode 100644 index 0000000..41fa75d --- /dev/null +++ b/python-toml.spec @@ -0,0 +1,166 @@ +%global pypi_name toml +%global desc TOML aims to be a minimal configuration file format that's easy to read due to \ +obvious semantics. TOML is designed to map unambiguously to a hash table. TOML \ +should be easy to parse into data structures in a wide variety of languages. \ +This package loads toml file into python dictionary and dump dictionary into \ +toml file. + +Name: python-%{pypi_name} +Version: 0.10.1 +Release: 3%{?dist} +Summary: Python Library for Tom's Obvious, Minimal Language + +License: MIT +URL: https://pypi.python.org/pypi/%{pypi_name} +Source0: %{pypi_source} + +BuildArch: noarch + +BuildRequires: python%{python3_pkgversion}-devel +BuildRequires: pyproject-rpm-macros + +%bcond_without tests +%if %{with tests} +BuildRequires: /usr/bin/toml-test +%endif + +%description +%desc + + +%package -n python%{python3_pkgversion}-%{pypi_name} +Summary: %{summary} +%{?python_provide:%python_provide python%{python3_pkgversion}-%{pypi_name}} + +%description -n python%{python3_pkgversion}-%{pypi_name} +%desc + + +%prep +%autosetup -p1 -n %{pypi_name}-%{version} + + +%generate_buildrequires +%pyproject_buildrequires %{?with_tests:-t} + + +%build +%pyproject_wheel + + +%install +%pyproject_install +%pyproject_save_files %{pypi_name} + + +%if %{with tests} +%check +ln -s /usr/share/toml-test/ . # python tests require test cases here +%tox +# Also using the language independent toml-test suite to launch tests +ln -s /usr/share/toml-test/tests/* tests/ # toml-test requires them here +toml-test $(pwd)/tests/decoding_test3.sh +%endif + + +%files -n python%{python3_pkgversion}-%{pypi_name} -f %{pyproject_files} +%license LICENSE +%doc README.rst + + +%changelog +* Thu Sep 03 2020 Miro Hrončok - 0.10.1-3 +- Use pyproject-rpm-macros + +* Wed Jul 29 2020 Fedora Release Engineering - 0.10.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Fri Jun 19 2020 Miro Hrončok - 0.10.1-1 +- Update to 0.10.1 (#1835567) + +* Sat May 23 2020 Miro Hrončok - 0.10.0-8 +- Rebuilt for Python 3.9 + +* Thu Jan 30 2020 Fedora Release Engineering - 0.10.0-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Oct 03 2019 Miro Hrončok - 0.10.0-6 +- Rebuilt for Python 3.8.0rc1 (#1748018) + +* Fri Aug 16 2019 Miro Hrončok - 0.10.0-5 +- Rebuilt for Python 3.8 + +* Fri Jul 26 2019 Fedora Release Engineering - 0.10.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Mon Feb 11 2019 Miro Hrončok - 0.10.0-3 +- Subpackage python2-toml has been removed + See https://fedoraproject.org/wiki/Changes/Mass_Python_2_Package_Removal + +* Sat Feb 02 2019 Fedora Release Engineering - 0.10.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Sun Nov 25 2018 Julien Enselme - 0.10.0-1 +- Update to 0.10.0 (#1652946) + +* Sat Jul 14 2018 Fedora Release Engineering - 0.9.4-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Tue Jun 19 2018 Miro Hrončok - 0.9.4-4 +- Rebuilt for Python 3.7 + +* Wed Feb 21 2018 Sayan Chowdhury - 0.9.4-3 +- Make changes to build the package for EPEL + +* Fri Feb 09 2018 Fedora Release Engineering - 0.9.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Wed Dec 27 2017 Julien Enselme - 0.9.4-1 +- Update to 0.9.4 + +* Tue Sep 26 2017 Julien Enselme - 0.9.3-1 +- Update to 0.9.3 + +* Thu Jul 27 2017 Fedora Release Engineering - 0.9.2-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Sat Feb 11 2017 Fedora Release Engineering - 0.9.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Mon Dec 19 2016 Miro Hrončok - 0.9.2-2 +- Rebuild for Python 3.6 + +* Thu Sep 01 2016 Julien Enselme - 0.9.2-1 +- Update to 0.9.2 +- Improve spec with %%summary and %%desc macros + +* Tue Jul 19 2016 Fedora Release Engineering - 0.9.1-7 +- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages + +* Thu Feb 04 2016 Fedora Release Engineering - 0.9.1-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Nov 11 2015 Fedora Release Engineering - 0.9.1-5 +- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5 + +* Mon Nov 9 2015 Julien Enselme - 0.9.1-4 +- Correct %%python_provides for python3 + +* Thu Nov 5 2015 Julien Enselme - 0.9.1-3 +- Rebuilt for python 3.5 + +* Sat Aug 8 2015 Julien Enselme - 0.9.1-2 +- Enable tests suite +- Build python3 and python2 in the same directory +- Use %%py2_build, %%py3_build, %%py2_install and %%py2_install +- Move python2 package in its own subpackage + +* Sat Jul 11 2015 Fedora Release Monitoring - 0.9.1-1 +- Update to 0.9.1 (#1242131) + +* Sun Jun 28 2015 Julien Enselme - 0.9.0-2 +- Update description to explain what toml is +- Try to import the package in %%check + +* Mon Jun 15 2015 Julien Enselme - 0.9.0-1 +- Initial packaging diff --git a/sources b/sources new file mode 100644 index 0000000..f8d1a34 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (toml-0.10.1.tar.gz) = 9dc813f84b56bee6519c70efe49a834d6695c82d429f0b7cc6e6153a1fb14d3fb627dea24df2d2664354f27108389d51475609272d59fc7e4b64a2c17d74f33f diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..49b6d3d --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,26 @@ +--- +- hosts: localhost + roles: + - role: standard-test-basic + tags: + - classic + repositories: + - repo: "https://src.fedoraproject.org/rpms/pyproject-rpm-macros.git" + dest: "pyproject-rpm-macros" + tests: + - pyproject_pytest: + dir: pyproject-rpm-macros/tests + run: ./mocktest.sh python-pytest + - pyproject_entrypoints: + dir: pyproject-rpm-macros/tests + run: ./mocktest.sh python-entrypoints + - pyproject_pluggy: + dir: pyproject-rpm-macros/tests + run: ./mocktest.sh python-pluggy + - pyproject_clikit: + dir: pyproject-rpm-macros/tests + run: ./mocktest.sh python-clikit + required_packages: + - mock + - rpmdevtools + - rpm-build diff --git a/toml_test.py b/toml_test.py new file mode 100644 index 0000000..f399c05 --- /dev/null +++ b/toml_test.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python2 + +import datetime +import json +import sys +import toml + +try: + _range = xrange + iteritems = dict.iteritems +except NameError: + unicode = str + _range = range + basestring = str + unichr = chr + iteritems = dict.items + long = int + +def tag(value): + if isinstance(value, dict): + d = { } + for k, v in iteritems(value): + d[k] = tag(v) + return d + elif isinstance(value, list): + a = [] + for v in value: + a.append(tag(v)) + try: + a[0]["value"] + except KeyError: + return a + except IndexError: + pass + return {'type': 'array', 'value': a} + elif isinstance(value, basestring): + return {'type': 'string', 'value': value} + elif isinstance(value, bool): + return {'type': 'bool', 'value': str(value).lower()} + elif isinstance(value, int): + return {'type': 'integer', 'value': str(value)} + elif isinstance(value, long): + return {'type': 'integer', 'value': str(value)} + elif isinstance(value, float): + return {'type': 'float', 'value': repr(value)} + elif isinstance(value, datetime.datetime): + sdate = value.strftime('%Y-%m-%dT%H:%M:%SZ') + return {'type': 'datetime', 'value': sdate} + assert False, 'Unknown type: %s' % type(value) + + +if __name__ == '__main__': + tdata = toml.loads(sys.stdin.read()) + tagged = tag(tdata) + print(json.dumps(tagged)) + diff --git a/toml_test3.py b/toml_test3.py new file mode 100644 index 0000000..84b6351 --- /dev/null +++ b/toml_test3.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import toml_test +import toml +import sys +import json + +if __name__ == '__main__': + tdata = toml.loads(sys.stdin.read()) + tagged = toml_test.tag(tdata) + print(json.dumps(tagged))