%global _empty_manifest_terminate_build 0 Name: python-rec-avro Version: 0.0.4 Release: 1 Summary: Avro schema and data converters supporting storing arbitrary nested python data structures. License: MIT URL: https://github.com/bmizhen/rec-avro Source0: https://mirrors.nju.edu.cn/pypi/web/packages/e4/c1/6f85a5b6fce4f04bd5e1546e02ccb99c3699cc7d96e2826be044a5e395bb/rec-avro-0.0.4.tar.gz BuildArch: noarch %description # rec-avro: Avro support for JSON and other nested data structures. Rec-avro provides a generic Avro schema and converter functions that allow for storing nested python data structures in avro. Tested in Python 3 only. ## Installation: ```sh $ pip3 install rec-avro ``` ## Usage: ### With fastavro: ```python from fastavro import writer, reader, schema from rec_avro import to_rec_avro_destructive, from_rec_avro_destructive, rec_avro_schema def json_objects(): return [{'a': 'a'}, {'b':'b'}] # For efficiency, to_rec_avro_destructive() destroys rec, and reuses it's # data structures to construct avro_objects avro_objects = (to_rec_avro_destructive(rec) for rec in json_objects()) # store records in avro with open('json_in_avro.avro', 'wb') as f_out: writer(f_out, schema.parse_schema(rec_avro_schema()), avro_objects) #load records from avro with open('json_in_avro.avro', 'rb') as f_in: # For efficiency, from_rec_avro_destructive(rec) destroys rec, and # reuses it's data structures to construct it's output loaded_json = [from_rec_avro_destructive(rec) for rec in reader(f_in)] assert loaded_json == json_objects() ``` ## Development: ```sh # Running all tests: $ python setup.py pytest # Running tests manually $ pip3 install fastavro pytest $ python setup.py develop $ pytest tests/test_rec_avro.py ``` %package -n python3-rec-avro Summary: Avro schema and data converters supporting storing arbitrary nested python data structures. Provides: python-rec-avro BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-rec-avro # rec-avro: Avro support for JSON and other nested data structures. Rec-avro provides a generic Avro schema and converter functions that allow for storing nested python data structures in avro. Tested in Python 3 only. ## Installation: ```sh $ pip3 install rec-avro ``` ## Usage: ### With fastavro: ```python from fastavro import writer, reader, schema from rec_avro import to_rec_avro_destructive, from_rec_avro_destructive, rec_avro_schema def json_objects(): return [{'a': 'a'}, {'b':'b'}] # For efficiency, to_rec_avro_destructive() destroys rec, and reuses it's # data structures to construct avro_objects avro_objects = (to_rec_avro_destructive(rec) for rec in json_objects()) # store records in avro with open('json_in_avro.avro', 'wb') as f_out: writer(f_out, schema.parse_schema(rec_avro_schema()), avro_objects) #load records from avro with open('json_in_avro.avro', 'rb') as f_in: # For efficiency, from_rec_avro_destructive(rec) destroys rec, and # reuses it's data structures to construct it's output loaded_json = [from_rec_avro_destructive(rec) for rec in reader(f_in)] assert loaded_json == json_objects() ``` ## Development: ```sh # Running all tests: $ python setup.py pytest # Running tests manually $ pip3 install fastavro pytest $ python setup.py develop $ pytest tests/test_rec_avro.py ``` %package help Summary: Development documents and examples for rec-avro Provides: python3-rec-avro-doc %description help # rec-avro: Avro support for JSON and other nested data structures. Rec-avro provides a generic Avro schema and converter functions that allow for storing nested python data structures in avro. Tested in Python 3 only. ## Installation: ```sh $ pip3 install rec-avro ``` ## Usage: ### With fastavro: ```python from fastavro import writer, reader, schema from rec_avro import to_rec_avro_destructive, from_rec_avro_destructive, rec_avro_schema def json_objects(): return [{'a': 'a'}, {'b':'b'}] # For efficiency, to_rec_avro_destructive() destroys rec, and reuses it's # data structures to construct avro_objects avro_objects = (to_rec_avro_destructive(rec) for rec in json_objects()) # store records in avro with open('json_in_avro.avro', 'wb') as f_out: writer(f_out, schema.parse_schema(rec_avro_schema()), avro_objects) #load records from avro with open('json_in_avro.avro', 'rb') as f_in: # For efficiency, from_rec_avro_destructive(rec) destroys rec, and # reuses it's data structures to construct it's output loaded_json = [from_rec_avro_destructive(rec) for rec in reader(f_in)] assert loaded_json == json_objects() ``` ## Development: ```sh # Running all tests: $ python setup.py pytest # Running tests manually $ pip3 install fastavro pytest $ python setup.py develop $ pytest tests/test_rec_avro.py ``` %prep %autosetup -n rec-avro-0.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-rec-avro -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Tue Apr 11 2023 Python_Bot - 0.0.4-1 - Package Spec generated