summaryrefslogtreecommitdiff
path: root/python-mongoengine-goodjson.spec
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-05-05 09:01:43 +0000
committerCoprDistGit <infra@openeuler.org>2023-05-05 09:01:43 +0000
commitca9b9810be9c82c584fce7ff892a2659341699b5 (patch)
tree19ef382a89780da0882b10f05064b7db841d1126 /python-mongoengine-goodjson.spec
parent44178cd26a3c573e70b275cb2426543c867ca84b (diff)
automatic import of python-mongoengine-goodjsonopeneuler20.03
Diffstat (limited to 'python-mongoengine-goodjson.spec')
-rw-r--r--python-mongoengine-goodjson.spec537
1 files changed, 537 insertions, 0 deletions
diff --git a/python-mongoengine-goodjson.spec b/python-mongoengine-goodjson.spec
new file mode 100644
index 0000000..fe141ae
--- /dev/null
+++ b/python-mongoengine-goodjson.spec
@@ -0,0 +1,537 @@
+%global _empty_manifest_terminate_build 0
+Name: python-mongoengine-goodjson
+Version: 1.1.8
+Release: 1
+Summary: More human readable JSON serializer/de-serializer for MongoEngine
+License: MIT
+URL: https://github.com/hiroaki-yamamoto/mongoengine-goodjson
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/9a/cb/d0468651ed17d613e3bf49e8c49f51553ac9f0113699e808c919d471b4c8/mongoengine_goodjson-1.1.8.tar.gz
+BuildArch: noarch
+
+
+%description
+# More human readable JSON serializer/de-serializer for MongoEngine
+[![Build Status]][Status Link]
+[![Test Coverage]][Test Coverage Link]
+[![Maintainability]][Maintainability Link]
+[![Documentation Status Image]][DocLink]
+
+[Build Status]: https://circleci.com/gh/hiroaki-yamamoto/mongoengine-goodjson.svg?style=svg
+[Status Link]: https://circleci.com/gh/hiroaki-yamamoto/mongoengine-goodjson
+[Test Coverage]: https://api.codeclimate.com/v1/badges/7efc2a1bb3040cda0d4f/test_coverage
+[Test Coverage Link]: https://codeclimate.com/github/hiroaki-yamamoto/mongoengine-goodjson/test_coverage
+[Maintainability]: https://api.codeclimate.com/v1/badges/7efc2a1bb3040cda0d4f/maintainability
+[Maintainability Link]: https://codeclimate.com/github/hiroaki-yamamoto/mongoengine-goodjson/maintainability
+[Documentation Status Image]: https://readthedocs.org/projects/mongoengine-goodjson/badge/?version=latest
+[DocLink]: https://mongoengine-goodjson.readthedocs.io/en/latest/?badge=latest
+
+## What This?
+This script has MongoEngine Document json serialization more-natural.
+
+## Why this invented?
+
+Using MongoEngine to create something (e.g. RESTful API), sometimes you
+might want to serialize the data from the db into JSON, but some fields
+are weird and not suitable for frontend/api:
+
+```JSON
+{
+ "_id": {
+ "$oid": "5700c32a1cbd5856815051ce"
+ },
+ "name": "Hiroaki Yamamoto",
+ "registered_date": {
+ "$date": 1459667811724
+ }
+}
+```
+
+The points are 2 points:
+
+* `_id` might not be wanted because jslint disagrees `_` character unless
+ declaring `jslint nomen:true`
+* There are sub-fields such `$oid` and `$date`. These fields are known as
+ [MongoDB Extended JSON]. However, considering MongoEngine is ODM and
+ therefore it has schema-definition methods, the fields shouldn't have the
+ special fields. In particular problems, you might get
+ `No such property $oid of undefined` error when you handle above generated
+ data on frontend.
+
+To solve the problems, the generated data should be like this:
+
+```JSON
+{
+ "id": "5700c32a1cbd5856815051ce",
+ "name": "Hiroaki Yamamoto",
+ "registered_date": 1459667811724
+}
+```
+
+Making above structure can be possible by doing re-mapping, but if we do it on
+[API's controller object], the code might get super-dirty:
+
+```Python
+"""Dirty code."""
+import mongoengine as db
+
+
+class User(db.Document):
+ """User class."""
+ name = db.StringField(required=True, unique=True)
+ registered_date = db.DateTimeField()
+
+
+def get_user(self):
+ """Get user."""
+ models = [
+ {
+ ("id" if key == "_id" else key): (
+ value.pop("$oid") if "$oid" in value and isinstance(value, dict)
+ else value.pop("$date") if "$date" in value and isinstance(value, dict)
+ else value #What if there are the special fields in child dict?
+ )
+ for (key, value) in doc.items()
+ } for doc in User.objects(pk=ObjectId("5700c32a1cbd5856815051ce"))
+ ]
+ return json.dumps(models, indent=2)
+```
+
+To give the solution of this problem, I developed this scirpt. By using this
+script, you will not need to make the transform like above. i.e.
+
+```Python
+
+"""A little-bit clean code."""
+
+import mongoengine as db
+import mongoengine_goodjson as gj
+
+
+class User(gj.Document):
+ """User class."""
+ name = db.StringField(required=True, unique=True)
+ registered_date = db.DateTimeField()
+
+
+def get_user(self):
+ """Get user."""
+ return model_cls.objects(
+ pk=ObjectId("5700c32a1cbd5856815051ce")
+ ).to_json(indent=2)
+```
+
+
+[MongoEngine]: http://mongoengine.org/
+[MongoDB Extended JSON]: https://docs.mongodb.org/manual/reference/mongodb-extended-json/
+[API's controller object]: https://developer.apple.com/library/ios/documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html
+
+## How to use it
+
+Generally you can define the document as usual, but you might want to inherits
+`mongoengine_goodjson.Document` or `mongoengine_goodjson.EmbeddedDocument`.
+
+Here is the example:
+
+```Python
+"""Example schema."""
+
+import mongoengine_goodjson as gj
+import mongoengine as db
+
+
+class Address(gj.EmbeddedDocument):
+ """Address schema."""
+
+ street = db.StringField()
+ city = db.StringField()
+ state = db.StringField()
+
+
+class User(gj.Document):
+ """User data schema."""
+
+ name = db.StringField()
+ email = db.EmailField()
+ address = db.EmbeddedDocumentListField(Address)
+```
+
+## More details... there's the doc!
+If you want to know more, there's [read the doc] that you want to read.
+You can now [read the doc] with drinking a cup of coffee!!
+
+## Contribute
+Please [read the doc] for the detail.
+
+[read the doc]: https://mongoengine-goodjson.readthedocs.io/
+
+## License (MIT License)
+See [LICENSE.md](LICENSE.md)
+
+%package -n python3-mongoengine-goodjson
+Summary: More human readable JSON serializer/de-serializer for MongoEngine
+Provides: python-mongoengine-goodjson
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-mongoengine-goodjson
+# More human readable JSON serializer/de-serializer for MongoEngine
+[![Build Status]][Status Link]
+[![Test Coverage]][Test Coverage Link]
+[![Maintainability]][Maintainability Link]
+[![Documentation Status Image]][DocLink]
+
+[Build Status]: https://circleci.com/gh/hiroaki-yamamoto/mongoengine-goodjson.svg?style=svg
+[Status Link]: https://circleci.com/gh/hiroaki-yamamoto/mongoengine-goodjson
+[Test Coverage]: https://api.codeclimate.com/v1/badges/7efc2a1bb3040cda0d4f/test_coverage
+[Test Coverage Link]: https://codeclimate.com/github/hiroaki-yamamoto/mongoengine-goodjson/test_coverage
+[Maintainability]: https://api.codeclimate.com/v1/badges/7efc2a1bb3040cda0d4f/maintainability
+[Maintainability Link]: https://codeclimate.com/github/hiroaki-yamamoto/mongoengine-goodjson/maintainability
+[Documentation Status Image]: https://readthedocs.org/projects/mongoengine-goodjson/badge/?version=latest
+[DocLink]: https://mongoengine-goodjson.readthedocs.io/en/latest/?badge=latest
+
+## What This?
+This script has MongoEngine Document json serialization more-natural.
+
+## Why this invented?
+
+Using MongoEngine to create something (e.g. RESTful API), sometimes you
+might want to serialize the data from the db into JSON, but some fields
+are weird and not suitable for frontend/api:
+
+```JSON
+{
+ "_id": {
+ "$oid": "5700c32a1cbd5856815051ce"
+ },
+ "name": "Hiroaki Yamamoto",
+ "registered_date": {
+ "$date": 1459667811724
+ }
+}
+```
+
+The points are 2 points:
+
+* `_id` might not be wanted because jslint disagrees `_` character unless
+ declaring `jslint nomen:true`
+* There are sub-fields such `$oid` and `$date`. These fields are known as
+ [MongoDB Extended JSON]. However, considering MongoEngine is ODM and
+ therefore it has schema-definition methods, the fields shouldn't have the
+ special fields. In particular problems, you might get
+ `No such property $oid of undefined` error when you handle above generated
+ data on frontend.
+
+To solve the problems, the generated data should be like this:
+
+```JSON
+{
+ "id": "5700c32a1cbd5856815051ce",
+ "name": "Hiroaki Yamamoto",
+ "registered_date": 1459667811724
+}
+```
+
+Making above structure can be possible by doing re-mapping, but if we do it on
+[API's controller object], the code might get super-dirty:
+
+```Python
+"""Dirty code."""
+import mongoengine as db
+
+
+class User(db.Document):
+ """User class."""
+ name = db.StringField(required=True, unique=True)
+ registered_date = db.DateTimeField()
+
+
+def get_user(self):
+ """Get user."""
+ models = [
+ {
+ ("id" if key == "_id" else key): (
+ value.pop("$oid") if "$oid" in value and isinstance(value, dict)
+ else value.pop("$date") if "$date" in value and isinstance(value, dict)
+ else value #What if there are the special fields in child dict?
+ )
+ for (key, value) in doc.items()
+ } for doc in User.objects(pk=ObjectId("5700c32a1cbd5856815051ce"))
+ ]
+ return json.dumps(models, indent=2)
+```
+
+To give the solution of this problem, I developed this scirpt. By using this
+script, you will not need to make the transform like above. i.e.
+
+```Python
+
+"""A little-bit clean code."""
+
+import mongoengine as db
+import mongoengine_goodjson as gj
+
+
+class User(gj.Document):
+ """User class."""
+ name = db.StringField(required=True, unique=True)
+ registered_date = db.DateTimeField()
+
+
+def get_user(self):
+ """Get user."""
+ return model_cls.objects(
+ pk=ObjectId("5700c32a1cbd5856815051ce")
+ ).to_json(indent=2)
+```
+
+
+[MongoEngine]: http://mongoengine.org/
+[MongoDB Extended JSON]: https://docs.mongodb.org/manual/reference/mongodb-extended-json/
+[API's controller object]: https://developer.apple.com/library/ios/documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html
+
+## How to use it
+
+Generally you can define the document as usual, but you might want to inherits
+`mongoengine_goodjson.Document` or `mongoengine_goodjson.EmbeddedDocument`.
+
+Here is the example:
+
+```Python
+"""Example schema."""
+
+import mongoengine_goodjson as gj
+import mongoengine as db
+
+
+class Address(gj.EmbeddedDocument):
+ """Address schema."""
+
+ street = db.StringField()
+ city = db.StringField()
+ state = db.StringField()
+
+
+class User(gj.Document):
+ """User data schema."""
+
+ name = db.StringField()
+ email = db.EmailField()
+ address = db.EmbeddedDocumentListField(Address)
+```
+
+## More details... there's the doc!
+If you want to know more, there's [read the doc] that you want to read.
+You can now [read the doc] with drinking a cup of coffee!!
+
+## Contribute
+Please [read the doc] for the detail.
+
+[read the doc]: https://mongoengine-goodjson.readthedocs.io/
+
+## License (MIT License)
+See [LICENSE.md](LICENSE.md)
+
+%package help
+Summary: Development documents and examples for mongoengine-goodjson
+Provides: python3-mongoengine-goodjson-doc
+%description help
+# More human readable JSON serializer/de-serializer for MongoEngine
+[![Build Status]][Status Link]
+[![Test Coverage]][Test Coverage Link]
+[![Maintainability]][Maintainability Link]
+[![Documentation Status Image]][DocLink]
+
+[Build Status]: https://circleci.com/gh/hiroaki-yamamoto/mongoengine-goodjson.svg?style=svg
+[Status Link]: https://circleci.com/gh/hiroaki-yamamoto/mongoengine-goodjson
+[Test Coverage]: https://api.codeclimate.com/v1/badges/7efc2a1bb3040cda0d4f/test_coverage
+[Test Coverage Link]: https://codeclimate.com/github/hiroaki-yamamoto/mongoengine-goodjson/test_coverage
+[Maintainability]: https://api.codeclimate.com/v1/badges/7efc2a1bb3040cda0d4f/maintainability
+[Maintainability Link]: https://codeclimate.com/github/hiroaki-yamamoto/mongoengine-goodjson/maintainability
+[Documentation Status Image]: https://readthedocs.org/projects/mongoengine-goodjson/badge/?version=latest
+[DocLink]: https://mongoengine-goodjson.readthedocs.io/en/latest/?badge=latest
+
+## What This?
+This script has MongoEngine Document json serialization more-natural.
+
+## Why this invented?
+
+Using MongoEngine to create something (e.g. RESTful API), sometimes you
+might want to serialize the data from the db into JSON, but some fields
+are weird and not suitable for frontend/api:
+
+```JSON
+{
+ "_id": {
+ "$oid": "5700c32a1cbd5856815051ce"
+ },
+ "name": "Hiroaki Yamamoto",
+ "registered_date": {
+ "$date": 1459667811724
+ }
+}
+```
+
+The points are 2 points:
+
+* `_id` might not be wanted because jslint disagrees `_` character unless
+ declaring `jslint nomen:true`
+* There are sub-fields such `$oid` and `$date`. These fields are known as
+ [MongoDB Extended JSON]. However, considering MongoEngine is ODM and
+ therefore it has schema-definition methods, the fields shouldn't have the
+ special fields. In particular problems, you might get
+ `No such property $oid of undefined` error when you handle above generated
+ data on frontend.
+
+To solve the problems, the generated data should be like this:
+
+```JSON
+{
+ "id": "5700c32a1cbd5856815051ce",
+ "name": "Hiroaki Yamamoto",
+ "registered_date": 1459667811724
+}
+```
+
+Making above structure can be possible by doing re-mapping, but if we do it on
+[API's controller object], the code might get super-dirty:
+
+```Python
+"""Dirty code."""
+import mongoengine as db
+
+
+class User(db.Document):
+ """User class."""
+ name = db.StringField(required=True, unique=True)
+ registered_date = db.DateTimeField()
+
+
+def get_user(self):
+ """Get user."""
+ models = [
+ {
+ ("id" if key == "_id" else key): (
+ value.pop("$oid") if "$oid" in value and isinstance(value, dict)
+ else value.pop("$date") if "$date" in value and isinstance(value, dict)
+ else value #What if there are the special fields in child dict?
+ )
+ for (key, value) in doc.items()
+ } for doc in User.objects(pk=ObjectId("5700c32a1cbd5856815051ce"))
+ ]
+ return json.dumps(models, indent=2)
+```
+
+To give the solution of this problem, I developed this scirpt. By using this
+script, you will not need to make the transform like above. i.e.
+
+```Python
+
+"""A little-bit clean code."""
+
+import mongoengine as db
+import mongoengine_goodjson as gj
+
+
+class User(gj.Document):
+ """User class."""
+ name = db.StringField(required=True, unique=True)
+ registered_date = db.DateTimeField()
+
+
+def get_user(self):
+ """Get user."""
+ return model_cls.objects(
+ pk=ObjectId("5700c32a1cbd5856815051ce")
+ ).to_json(indent=2)
+```
+
+
+[MongoEngine]: http://mongoengine.org/
+[MongoDB Extended JSON]: https://docs.mongodb.org/manual/reference/mongodb-extended-json/
+[API's controller object]: https://developer.apple.com/library/ios/documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html
+
+## How to use it
+
+Generally you can define the document as usual, but you might want to inherits
+`mongoengine_goodjson.Document` or `mongoengine_goodjson.EmbeddedDocument`.
+
+Here is the example:
+
+```Python
+"""Example schema."""
+
+import mongoengine_goodjson as gj
+import mongoengine as db
+
+
+class Address(gj.EmbeddedDocument):
+ """Address schema."""
+
+ street = db.StringField()
+ city = db.StringField()
+ state = db.StringField()
+
+
+class User(gj.Document):
+ """User data schema."""
+
+ name = db.StringField()
+ email = db.EmailField()
+ address = db.EmbeddedDocumentListField(Address)
+```
+
+## More details... there's the doc!
+If you want to know more, there's [read the doc] that you want to read.
+You can now [read the doc] with drinking a cup of coffee!!
+
+## Contribute
+Please [read the doc] for the detail.
+
+[read the doc]: https://mongoengine-goodjson.readthedocs.io/
+
+## License (MIT License)
+See [LICENSE.md](LICENSE.md)
+
+%prep
+%autosetup -n mongoengine-goodjson-1.1.8
+
+%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-mongoengine-goodjson -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 1.1.8-1
+- Package Spec generated