diff options
Diffstat (limited to 'python-ndd-tools.spec')
| -rw-r--r-- | python-ndd-tools.spec | 281 |
1 files changed, 281 insertions, 0 deletions
diff --git a/python-ndd-tools.spec b/python-ndd-tools.spec new file mode 100644 index 0000000..db28640 --- /dev/null +++ b/python-ndd-tools.spec @@ -0,0 +1,281 @@ +%global _empty_manifest_terminate_build 0 +Name: python-ndd-tools +Version: 1.2.6 +Release: 1 +Summary: My Collection of Tools +License: MIT +URL: https://github.com/hpduongducnhan/ndd_tools +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/2b/1e/e822ff25aa893da68f896176062d854eda3fb48c37dabe7a177b2793dece/ndd_tools-1.2.6.tar.gz +BuildArch: noarch + +Requires: python3-requests +Requires: python3-pydantic +Requires: python3-dotenv +Requires: python3-PyYAML +Requires: python3-dateutil + +%description +# LoggerMixin +## usage +``` +from ndd_tools import LoggerConfig, LoggerMixin +class A(LoggerMixin): + def __init__(self, logger_config: LoggerConfig, *args, **kwargs): + self.set_logger_up(logger_config) + + # to enable debug mode: log message send to console + self.set_logger_debug_mode(True) + + # to disable debug mode: + self.set_logger_debug_mode(False) + + # to change log level, change in config or method + self.set_logger_level(loggingLevel) + + # to add file handler + self.add_logger_file_handler(file_path: str, file_name: str, [formatter]) + + # get current logger config + self.get_logger_config() + + # incase you want create new logger + # recreate new logger_config then use + self.set_logger_up(new_logger_config) + + + + def run(self): + self.debug('this is debug log message') + self.info('this is info log message') + self.warn('this is warn log message') + self.error('this is error log message') + self.critical('this is critical log message') + +``` +## example + +# ApiClient +## usage +``` +json_config_file_path = "/path/to/file/json" +client = ApiClient(json_config_file_path) +data = client.make_request('example1', header_dict, body_dict) +``` + +# json format example +```yaml +{ + "name": "api endpoints", + "description": "hello", + "config": { + "example1": { + "method": "GET", + "url": "https://gorest.co.in/public/v1/users", + "header": { + "Content-Type": "application/json" + }, + "parameters": { + "hello": "world" + }, + "save_response": false + } + } +} + + + + +%package -n python3-ndd-tools +Summary: My Collection of Tools +Provides: python-ndd-tools +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-ndd-tools +# LoggerMixin +## usage +``` +from ndd_tools import LoggerConfig, LoggerMixin +class A(LoggerMixin): + def __init__(self, logger_config: LoggerConfig, *args, **kwargs): + self.set_logger_up(logger_config) + + # to enable debug mode: log message send to console + self.set_logger_debug_mode(True) + + # to disable debug mode: + self.set_logger_debug_mode(False) + + # to change log level, change in config or method + self.set_logger_level(loggingLevel) + + # to add file handler + self.add_logger_file_handler(file_path: str, file_name: str, [formatter]) + + # get current logger config + self.get_logger_config() + + # incase you want create new logger + # recreate new logger_config then use + self.set_logger_up(new_logger_config) + + + + def run(self): + self.debug('this is debug log message') + self.info('this is info log message') + self.warn('this is warn log message') + self.error('this is error log message') + self.critical('this is critical log message') + +``` +## example + +# ApiClient +## usage +``` +json_config_file_path = "/path/to/file/json" +client = ApiClient(json_config_file_path) +data = client.make_request('example1', header_dict, body_dict) +``` + +# json format example +```yaml +{ + "name": "api endpoints", + "description": "hello", + "config": { + "example1": { + "method": "GET", + "url": "https://gorest.co.in/public/v1/users", + "header": { + "Content-Type": "application/json" + }, + "parameters": { + "hello": "world" + }, + "save_response": false + } + } +} + + + + +%package help +Summary: Development documents and examples for ndd-tools +Provides: python3-ndd-tools-doc +%description help +# LoggerMixin +## usage +``` +from ndd_tools import LoggerConfig, LoggerMixin +class A(LoggerMixin): + def __init__(self, logger_config: LoggerConfig, *args, **kwargs): + self.set_logger_up(logger_config) + + # to enable debug mode: log message send to console + self.set_logger_debug_mode(True) + + # to disable debug mode: + self.set_logger_debug_mode(False) + + # to change log level, change in config or method + self.set_logger_level(loggingLevel) + + # to add file handler + self.add_logger_file_handler(file_path: str, file_name: str, [formatter]) + + # get current logger config + self.get_logger_config() + + # incase you want create new logger + # recreate new logger_config then use + self.set_logger_up(new_logger_config) + + + + def run(self): + self.debug('this is debug log message') + self.info('this is info log message') + self.warn('this is warn log message') + self.error('this is error log message') + self.critical('this is critical log message') + +``` +## example + +# ApiClient +## usage +``` +json_config_file_path = "/path/to/file/json" +client = ApiClient(json_config_file_path) +data = client.make_request('example1', header_dict, body_dict) +``` + +# json format example +```yaml +{ + "name": "api endpoints", + "description": "hello", + "config": { + "example1": { + "method": "GET", + "url": "https://gorest.co.in/public/v1/users", + "header": { + "Content-Type": "application/json" + }, + "parameters": { + "hello": "world" + }, + "save_response": false + } + } +} + + + + +%prep +%autosetup -n ndd-tools-1.2.6 + +%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-ndd-tools -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon May 29 2023 Python_Bot <Python_Bot@openeuler.org> - 1.2.6-1 +- Package Spec generated |
