diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-05-29 11:13:15 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-05-29 11:13:15 +0000 |
| commit | ecd1da18e4a36da77c8ebe7b8c04d0582557e399 (patch) | |
| tree | 6178fd5a62b767f83ad6706fe78c8352e690afc0 | |
| parent | b4c9c0e31b258b75c68adf658e8ae37bfec4ff2d (diff) | |
automatic import of python-research-data-services-common
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-research-data-services-common.spec | 388 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 390 insertions, 0 deletions
@@ -0,0 +1 @@ +/research-data-services-common-0.53.tar.gz diff --git a/python-research-data-services-common.spec b/python-research-data-services-common.spec new file mode 100644 index 0000000..b0c9848 --- /dev/null +++ b/python-research-data-services-common.spec @@ -0,0 +1,388 @@ +%global _empty_manifest_terminate_build 0 +Name: python-research-data-services-common +Version: 0.53 +Release: 1 +Summary: The token and service implementation of sciebo RDS +License: MIT +URL: https://github.com/Sciebo-RDS/py-research-data-services-common +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/04/e2/7cf3e1f98f79f268fe20a774be4a2ddd6e38e8833290dde182390b241881/research-data-services-common-0.53.tar.gz +BuildArch: noarch + +Requires: python3-flask + +%description +[](https://codeclimate.com/github/Sciebo-RDS/py-research-data-services-common/maintainability)[](https://codeclimate.com/github/Sciebo-RDS/py-research-data-services-common/test_coverage)[](https://badge.fury.io/py/research-data-services-common) + +# Research Data Services Common Package + +This package make the most common modules in Sciebo RDS available in one place, so we do not have to maintain them in several places. +In the RDS project, we use OAuth2 for authentication between numerious services, so we need a datastructure with methods, which supports this. + +So this package implement 3 basic classes (User, Service, Token), which handles standard user-password authentication. +If you need this classes with oauth2-support, you have to use the corresponding version (e.g. Service => Oauth2Service). (Notice: User does not have an oauth2-version, because token takes care of password or token and service takes care of everything else for oauth2.) + +## Usage + +You can find some examples to use this package below. If you need more, please take a look into the tests or [sciebo RDS](https://github.com/Sciebo-RDS/Sciebo-RDS) (e.g. [Token Storage](https://github.com/Sciebo-RDS/Sciebo-RDS/blob/master/RDS/circle3_central_services/token_storage/src/lib/Storage.py)). + +```python +from RDS import User +user1 = User("Max Mustermann") +``` + +## Installation + +```bash +pip install research-data-services-common +``` + +### Optional dependencies + +If you want to work with flask, you can use some additional features, when it is installed. + +```bash +pip install "research-data-services-common[flask]" +``` + +## JSONEncoder + +With flask installed, you can use the JSONEncoder for flask. + +```python +from flask import Flask, jsonify +from RDS import Util + +app = Flask(__name__) +app.json_encoder = Util.get_encoder(func_name="to_dict") + +class Storage(): + def to_dict(self): + return {"foo": "bar"} + +@app.route("/") +def hello(): + return jsonify(Storage()) +``` + +If you want to use builtin json, you do not need flask. Then you can use *monkeypatch*-method. + +```python +from RDS import Util +import json + +class Storage(): + def to_dict(self): + return {"foo": "bar"} + +Util.monkeypatch(func_name="to_dict") + +print(json.dumps(Storage())) # expects: '{"foo":"bar"}' +``` + +**Notice**: func_name defaults to *to_json*. + +### Monkeypatch JSONEncoder in Flask + +If you want to monkeypatch json and flask, you can use the helper function *monkeypatch* from RDS. + +```python +from RDS import Util +Util.monkeypatch() +``` + +If it runs in a flask app context, it patches the app by itself. Otherwise you have to set the *app*-argument. + +```python +from flask import Flask +app = Flask(__name__) + +@app.route('/') +def hello_world(): + return 'Hello, World!' + +from RDS import Util +Util.monkeypatch("getDict", app=app) +``` + +The first argument in the previous example, you can see how to set the method, which should be used for json encoding from your object. The *monkeypatch*-method patches JSONEncoder in your python installation and your app flask. + +# RO-Crate Parser + +This helps you to work with ro-crate-metadata files. Take a look in the [tests](https://github.com/Sciebo-RDS/py-research-data-services-common/blob/0a0e8bda0eaec1b539a5d5884feba4812b2d37db/tests/test_roparser.py#L19) to see, how this can be used. + +## Available Modules + +- User +- Service (Oauth2Service) +- Token (Oauth2Token) +- ROParser + + +%package -n python3-research-data-services-common +Summary: The token and service implementation of sciebo RDS +Provides: python-research-data-services-common +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-research-data-services-common +[](https://codeclimate.com/github/Sciebo-RDS/py-research-data-services-common/maintainability)[](https://codeclimate.com/github/Sciebo-RDS/py-research-data-services-common/test_coverage)[](https://badge.fury.io/py/research-data-services-common) + +# Research Data Services Common Package + +This package make the most common modules in Sciebo RDS available in one place, so we do not have to maintain them in several places. +In the RDS project, we use OAuth2 for authentication between numerious services, so we need a datastructure with methods, which supports this. + +So this package implement 3 basic classes (User, Service, Token), which handles standard user-password authentication. +If you need this classes with oauth2-support, you have to use the corresponding version (e.g. Service => Oauth2Service). (Notice: User does not have an oauth2-version, because token takes care of password or token and service takes care of everything else for oauth2.) + +## Usage + +You can find some examples to use this package below. If you need more, please take a look into the tests or [sciebo RDS](https://github.com/Sciebo-RDS/Sciebo-RDS) (e.g. [Token Storage](https://github.com/Sciebo-RDS/Sciebo-RDS/blob/master/RDS/circle3_central_services/token_storage/src/lib/Storage.py)). + +```python +from RDS import User +user1 = User("Max Mustermann") +``` + +## Installation + +```bash +pip install research-data-services-common +``` + +### Optional dependencies + +If you want to work with flask, you can use some additional features, when it is installed. + +```bash +pip install "research-data-services-common[flask]" +``` + +## JSONEncoder + +With flask installed, you can use the JSONEncoder for flask. + +```python +from flask import Flask, jsonify +from RDS import Util + +app = Flask(__name__) +app.json_encoder = Util.get_encoder(func_name="to_dict") + +class Storage(): + def to_dict(self): + return {"foo": "bar"} + +@app.route("/") +def hello(): + return jsonify(Storage()) +``` + +If you want to use builtin json, you do not need flask. Then you can use *monkeypatch*-method. + +```python +from RDS import Util +import json + +class Storage(): + def to_dict(self): + return {"foo": "bar"} + +Util.monkeypatch(func_name="to_dict") + +print(json.dumps(Storage())) # expects: '{"foo":"bar"}' +``` + +**Notice**: func_name defaults to *to_json*. + +### Monkeypatch JSONEncoder in Flask + +If you want to monkeypatch json and flask, you can use the helper function *monkeypatch* from RDS. + +```python +from RDS import Util +Util.monkeypatch() +``` + +If it runs in a flask app context, it patches the app by itself. Otherwise you have to set the *app*-argument. + +```python +from flask import Flask +app = Flask(__name__) + +@app.route('/') +def hello_world(): + return 'Hello, World!' + +from RDS import Util +Util.monkeypatch("getDict", app=app) +``` + +The first argument in the previous example, you can see how to set the method, which should be used for json encoding from your object. The *monkeypatch*-method patches JSONEncoder in your python installation and your app flask. + +# RO-Crate Parser + +This helps you to work with ro-crate-metadata files. Take a look in the [tests](https://github.com/Sciebo-RDS/py-research-data-services-common/blob/0a0e8bda0eaec1b539a5d5884feba4812b2d37db/tests/test_roparser.py#L19) to see, how this can be used. + +## Available Modules + +- User +- Service (Oauth2Service) +- Token (Oauth2Token) +- ROParser + + +%package help +Summary: Development documents and examples for research-data-services-common +Provides: python3-research-data-services-common-doc +%description help +[](https://codeclimate.com/github/Sciebo-RDS/py-research-data-services-common/maintainability)[](https://codeclimate.com/github/Sciebo-RDS/py-research-data-services-common/test_coverage)[](https://badge.fury.io/py/research-data-services-common) + +# Research Data Services Common Package + +This package make the most common modules in Sciebo RDS available in one place, so we do not have to maintain them in several places. +In the RDS project, we use OAuth2 for authentication between numerious services, so we need a datastructure with methods, which supports this. + +So this package implement 3 basic classes (User, Service, Token), which handles standard user-password authentication. +If you need this classes with oauth2-support, you have to use the corresponding version (e.g. Service => Oauth2Service). (Notice: User does not have an oauth2-version, because token takes care of password or token and service takes care of everything else for oauth2.) + +## Usage + +You can find some examples to use this package below. If you need more, please take a look into the tests or [sciebo RDS](https://github.com/Sciebo-RDS/Sciebo-RDS) (e.g. [Token Storage](https://github.com/Sciebo-RDS/Sciebo-RDS/blob/master/RDS/circle3_central_services/token_storage/src/lib/Storage.py)). + +```python +from RDS import User +user1 = User("Max Mustermann") +``` + +## Installation + +```bash +pip install research-data-services-common +``` + +### Optional dependencies + +If you want to work with flask, you can use some additional features, when it is installed. + +```bash +pip install "research-data-services-common[flask]" +``` + +## JSONEncoder + +With flask installed, you can use the JSONEncoder for flask. + +```python +from flask import Flask, jsonify +from RDS import Util + +app = Flask(__name__) +app.json_encoder = Util.get_encoder(func_name="to_dict") + +class Storage(): + def to_dict(self): + return {"foo": "bar"} + +@app.route("/") +def hello(): + return jsonify(Storage()) +``` + +If you want to use builtin json, you do not need flask. Then you can use *monkeypatch*-method. + +```python +from RDS import Util +import json + +class Storage(): + def to_dict(self): + return {"foo": "bar"} + +Util.monkeypatch(func_name="to_dict") + +print(json.dumps(Storage())) # expects: '{"foo":"bar"}' +``` + +**Notice**: func_name defaults to *to_json*. + +### Monkeypatch JSONEncoder in Flask + +If you want to monkeypatch json and flask, you can use the helper function *monkeypatch* from RDS. + +```python +from RDS import Util +Util.monkeypatch() +``` + +If it runs in a flask app context, it patches the app by itself. Otherwise you have to set the *app*-argument. + +```python +from flask import Flask +app = Flask(__name__) + +@app.route('/') +def hello_world(): + return 'Hello, World!' + +from RDS import Util +Util.monkeypatch("getDict", app=app) +``` + +The first argument in the previous example, you can see how to set the method, which should be used for json encoding from your object. The *monkeypatch*-method patches JSONEncoder in your python installation and your app flask. + +# RO-Crate Parser + +This helps you to work with ro-crate-metadata files. Take a look in the [tests](https://github.com/Sciebo-RDS/py-research-data-services-common/blob/0a0e8bda0eaec1b539a5d5884feba4812b2d37db/tests/test_roparser.py#L19) to see, how this can be used. + +## Available Modules + +- User +- Service (Oauth2Service) +- Token (Oauth2Token) +- ROParser + + +%prep +%autosetup -n research-data-services-common-0.53 + +%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-research-data-services-common -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon May 29 2023 Python_Bot <Python_Bot@openeuler.org> - 0.53-1 +- Package Spec generated @@ -0,0 +1 @@ +dcea8d408c9586c80ec726ea38fb924c research-data-services-common-0.53.tar.gz |
