From 5256fec126878ea4cff5b4974c3f9461c2d65aaf Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Mon, 29 May 2023 12:25:41 +0000 Subject: automatic import of python-pipen-filters --- .gitignore | 1 + python-pipen-filters.spec | 367 ++++++++++++++++++++++++++++++++++++++++++++++ sources | 1 + 3 files changed, 369 insertions(+) create mode 100644 python-pipen-filters.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore index e69de29..3f0c8f8 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/pipen_filters-0.7.0.tar.gz diff --git a/python-pipen-filters.spec b/python-pipen-filters.spec new file mode 100644 index 0000000..e98c2c9 --- /dev/null +++ b/python-pipen-filters.spec @@ -0,0 +1,367 @@ +%global _empty_manifest_terminate_build 0 +Name: python-pipen-filters +Version: 0.7.0 +Release: 1 +Summary: Add a set of useful filters for pipen templates +License: MIT +URL: https://github.com/pwwang/pipen-filters +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/ec/97/2f5ddd8629e9df2c0b59ce8c1412dacc1058d09656d1b206a2bb8d4ad36a/pipen_filters-0.7.0.tar.gz +BuildArch: noarch + +Requires: python3-pipen + +%description +# pipen-filters + +Add a set of useful filters for [pipen][1] templates. + +These filters can be used for both liquid and jinja2 templating in pipen. + +## Installation + +```shell +pip install -U pipen-filters +``` + +## Enabling/Disabling the plugin + +The plugin is registered via entrypoints. It's by default enabled. To disable it: +`plugins=[..., "no:filters"]`, or uninstall this plugin. + +## Usage + +```python +from pipen import Proc + +class MyProc(Proc): + input = "infile:file" + output = "outfile:file:{{in.infile | stem}}.txt" + ... +``` + +## Filters + +- Parse the symbolic links + + - `realpath`: `os.path.realpath` + - `readlink`: `os.readlink` + +- Find common prefix of given paths + + - `commonprefix`: + + ```python + >>> commonprefix("/a/b/abc.txt", "/a/b/abc.png") + >>> # "abc." + >>> commonprefix("/a/b/abc.txt", "/a/b/abc.png", basename_only=False) + >>> # "/a/b/abc." + ``` + +- Get parts of the path + + - `dirname`: `path.dirname` + - `basename`: `path.basename` + - `ext`: get the extension (`/a/b/c.txt -> .txt`) + - `ext0`: get the extension without dot (`/a/b/c.txt -> txt`) + - `prefix`: get the prefix of a path (`/a/b/c.d.txt -> /a/b/c.d`) + - `prefix0`: get the prefix of a path without dot in basename (`/a/b/c.d.txt -> /a/b/c`) + - `filename`, `fn`, `stem`: get the stem of a path (`/a/b.c.txt -> b.c`) + - `filename0`, `fn0`, `stem0`: get the stem of a path without dot (`/a/b.c.txt -> b`) + - `joinpaths`: join path parts (`os.path.join`) + - `as_path`: convert a string into a `pathlib.Path` object + +- Path stat + + - `isdir`: `os.path.isdir` + - `isfile`: `os.path.isfile` + - `islink`: `os.path.islink` + - `exists`: `os.path.exists` + - `getsize`: `os.path.getsize`, return -1 if the path doesn't exist + - `getmtime`: `os.path.getmtime`, return -1 if the path doesn't exist + - `getctime`: `os.path.getctime`, return -1 if the path doesn't exist + - `getatime`: `os.path.getatime`, return -1 if the path doesn't exist + - `isempty`: check if a file is empty + +- Quote data + + - `quote`: put double quotes around data (`1 -> "1"`) + - `squote`: put single quotes around data (`1 -> '1'`) + +- Configurations + - `json`: `json.dumps` + - `json_dump`: Load json froma file + - `json_dumps`: Alias of `json` + - `json_loads`: `json.loads` + - `toml`: `toml.dumps` + - `toml_dump`: Load toml from a file + - `toml_dumps`: Alias of `toml` + - `toml_loads`: `toml.loads` + - `config`: Load configuration from an object, a string or a file + +- Globs + + - `glob`: Like `glob.glob`, but allows passing multiple parts of a path + - `glob0`: Like `glob`, but only returns the first matched path + +- Read file contents + + - `read`: Read file content. You can also pass arguments to `open` + - `readlines`: Read file content as a list of lines. Additional arguments will be passed to `open` + +[1]: https://github.com/pwwang/pipen + + +%package -n python3-pipen-filters +Summary: Add a set of useful filters for pipen templates +Provides: python-pipen-filters +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-pipen-filters +# pipen-filters + +Add a set of useful filters for [pipen][1] templates. + +These filters can be used for both liquid and jinja2 templating in pipen. + +## Installation + +```shell +pip install -U pipen-filters +``` + +## Enabling/Disabling the plugin + +The plugin is registered via entrypoints. It's by default enabled. To disable it: +`plugins=[..., "no:filters"]`, or uninstall this plugin. + +## Usage + +```python +from pipen import Proc + +class MyProc(Proc): + input = "infile:file" + output = "outfile:file:{{in.infile | stem}}.txt" + ... +``` + +## Filters + +- Parse the symbolic links + + - `realpath`: `os.path.realpath` + - `readlink`: `os.readlink` + +- Find common prefix of given paths + + - `commonprefix`: + + ```python + >>> commonprefix("/a/b/abc.txt", "/a/b/abc.png") + >>> # "abc." + >>> commonprefix("/a/b/abc.txt", "/a/b/abc.png", basename_only=False) + >>> # "/a/b/abc." + ``` + +- Get parts of the path + + - `dirname`: `path.dirname` + - `basename`: `path.basename` + - `ext`: get the extension (`/a/b/c.txt -> .txt`) + - `ext0`: get the extension without dot (`/a/b/c.txt -> txt`) + - `prefix`: get the prefix of a path (`/a/b/c.d.txt -> /a/b/c.d`) + - `prefix0`: get the prefix of a path without dot in basename (`/a/b/c.d.txt -> /a/b/c`) + - `filename`, `fn`, `stem`: get the stem of a path (`/a/b.c.txt -> b.c`) + - `filename0`, `fn0`, `stem0`: get the stem of a path without dot (`/a/b.c.txt -> b`) + - `joinpaths`: join path parts (`os.path.join`) + - `as_path`: convert a string into a `pathlib.Path` object + +- Path stat + + - `isdir`: `os.path.isdir` + - `isfile`: `os.path.isfile` + - `islink`: `os.path.islink` + - `exists`: `os.path.exists` + - `getsize`: `os.path.getsize`, return -1 if the path doesn't exist + - `getmtime`: `os.path.getmtime`, return -1 if the path doesn't exist + - `getctime`: `os.path.getctime`, return -1 if the path doesn't exist + - `getatime`: `os.path.getatime`, return -1 if the path doesn't exist + - `isempty`: check if a file is empty + +- Quote data + + - `quote`: put double quotes around data (`1 -> "1"`) + - `squote`: put single quotes around data (`1 -> '1'`) + +- Configurations + - `json`: `json.dumps` + - `json_dump`: Load json froma file + - `json_dumps`: Alias of `json` + - `json_loads`: `json.loads` + - `toml`: `toml.dumps` + - `toml_dump`: Load toml from a file + - `toml_dumps`: Alias of `toml` + - `toml_loads`: `toml.loads` + - `config`: Load configuration from an object, a string or a file + +- Globs + + - `glob`: Like `glob.glob`, but allows passing multiple parts of a path + - `glob0`: Like `glob`, but only returns the first matched path + +- Read file contents + + - `read`: Read file content. You can also pass arguments to `open` + - `readlines`: Read file content as a list of lines. Additional arguments will be passed to `open` + +[1]: https://github.com/pwwang/pipen + + +%package help +Summary: Development documents and examples for pipen-filters +Provides: python3-pipen-filters-doc +%description help +# pipen-filters + +Add a set of useful filters for [pipen][1] templates. + +These filters can be used for both liquid and jinja2 templating in pipen. + +## Installation + +```shell +pip install -U pipen-filters +``` + +## Enabling/Disabling the plugin + +The plugin is registered via entrypoints. It's by default enabled. To disable it: +`plugins=[..., "no:filters"]`, or uninstall this plugin. + +## Usage + +```python +from pipen import Proc + +class MyProc(Proc): + input = "infile:file" + output = "outfile:file:{{in.infile | stem}}.txt" + ... +``` + +## Filters + +- Parse the symbolic links + + - `realpath`: `os.path.realpath` + - `readlink`: `os.readlink` + +- Find common prefix of given paths + + - `commonprefix`: + + ```python + >>> commonprefix("/a/b/abc.txt", "/a/b/abc.png") + >>> # "abc." + >>> commonprefix("/a/b/abc.txt", "/a/b/abc.png", basename_only=False) + >>> # "/a/b/abc." + ``` + +- Get parts of the path + + - `dirname`: `path.dirname` + - `basename`: `path.basename` + - `ext`: get the extension (`/a/b/c.txt -> .txt`) + - `ext0`: get the extension without dot (`/a/b/c.txt -> txt`) + - `prefix`: get the prefix of a path (`/a/b/c.d.txt -> /a/b/c.d`) + - `prefix0`: get the prefix of a path without dot in basename (`/a/b/c.d.txt -> /a/b/c`) + - `filename`, `fn`, `stem`: get the stem of a path (`/a/b.c.txt -> b.c`) + - `filename0`, `fn0`, `stem0`: get the stem of a path without dot (`/a/b.c.txt -> b`) + - `joinpaths`: join path parts (`os.path.join`) + - `as_path`: convert a string into a `pathlib.Path` object + +- Path stat + + - `isdir`: `os.path.isdir` + - `isfile`: `os.path.isfile` + - `islink`: `os.path.islink` + - `exists`: `os.path.exists` + - `getsize`: `os.path.getsize`, return -1 if the path doesn't exist + - `getmtime`: `os.path.getmtime`, return -1 if the path doesn't exist + - `getctime`: `os.path.getctime`, return -1 if the path doesn't exist + - `getatime`: `os.path.getatime`, return -1 if the path doesn't exist + - `isempty`: check if a file is empty + +- Quote data + + - `quote`: put double quotes around data (`1 -> "1"`) + - `squote`: put single quotes around data (`1 -> '1'`) + +- Configurations + - `json`: `json.dumps` + - `json_dump`: Load json froma file + - `json_dumps`: Alias of `json` + - `json_loads`: `json.loads` + - `toml`: `toml.dumps` + - `toml_dump`: Load toml from a file + - `toml_dumps`: Alias of `toml` + - `toml_loads`: `toml.loads` + - `config`: Load configuration from an object, a string or a file + +- Globs + + - `glob`: Like `glob.glob`, but allows passing multiple parts of a path + - `glob0`: Like `glob`, but only returns the first matched path + +- Read file contents + + - `read`: Read file content. You can also pass arguments to `open` + - `readlines`: Read file content as a list of lines. Additional arguments will be passed to `open` + +[1]: https://github.com/pwwang/pipen + + +%prep +%autosetup -n pipen-filters-0.7.0 + +%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-pipen-filters -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon May 29 2023 Python_Bot - 0.7.0-1 +- Package Spec generated diff --git a/sources b/sources new file mode 100644 index 0000000..eeb7544 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +416d085a410cb7280bf7a4a14e6f2f2f pipen_filters-0.7.0.tar.gz -- cgit v1.2.3