%global _empty_manifest_terminate_build 0 Name: python-sanitize-filename Version: 1.2.0 Release: 1 Summary: A permissive filename sanitizer. License: MIT License URL: https://gitlab.com/jplusplus/sanitize-filename Source0: https://mirrors.nju.edu.cn/pypi/web/packages/a3/1c/2757fe1d119304407c501236de0fa7482975f4fbef3d955abc3f7d88c986/sanitize_filename-1.2.0.tar.gz BuildArch: noarch %description A simple, dependency-free, blacklist-based filename sanitizer, for when you want to keep the original filename. Note that a blacklist based sanitizer will _never_ be as safe as a whitelist based one. In most cases, your best option is to create a safe filename yourself. Your second safest option is to use a whitelist approach (allowing only certain characters). This sanitizer is useful when you want to keep the original filename, including non ascii characters, whenever possible. ## Installation ```sh pip install sanitize_filename ``` ## Usage ```python3 from sanitize_filename import sanitize filename = input("Enter a file name:") filename = sanitize(filename) ``` Examples: ```python3 > sanitize("A/B/C.txt") 'ABC.txt' > sanitize("this𓀦filenameḜisあactually...valid.txt") 'this𓀦filenameḜisあactually...valid.txt' > sanitize("def.") 'def' > sanitize("NUL") '__NUL' > sanitize("..") '__' ``` ## Changelog - 1.2.0 - Get rid of os dependent checks; ensure uniform behaviour - Now works on long filenames where the non-extensions part consists of only dots - 1.1.0 - Try to preserve filename extensions if possible - 1.0.1 - First release (as 1.0.1 due to a version number mix-up in 1.0.0) - 1.0.0-dev3 - Black list low code point characters (<32) - 1.0.0-dev1 - First version %package -n python3-sanitize-filename Summary: A permissive filename sanitizer. Provides: python-sanitize-filename BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-sanitize-filename A simple, dependency-free, blacklist-based filename sanitizer, for when you want to keep the original filename. Note that a blacklist based sanitizer will _never_ be as safe as a whitelist based one. In most cases, your best option is to create a safe filename yourself. Your second safest option is to use a whitelist approach (allowing only certain characters). This sanitizer is useful when you want to keep the original filename, including non ascii characters, whenever possible. ## Installation ```sh pip install sanitize_filename ``` ## Usage ```python3 from sanitize_filename import sanitize filename = input("Enter a file name:") filename = sanitize(filename) ``` Examples: ```python3 > sanitize("A/B/C.txt") 'ABC.txt' > sanitize("this𓀦filenameḜisあactually...valid.txt") 'this𓀦filenameḜisあactually...valid.txt' > sanitize("def.") 'def' > sanitize("NUL") '__NUL' > sanitize("..") '__' ``` ## Changelog - 1.2.0 - Get rid of os dependent checks; ensure uniform behaviour - Now works on long filenames where the non-extensions part consists of only dots - 1.1.0 - Try to preserve filename extensions if possible - 1.0.1 - First release (as 1.0.1 due to a version number mix-up in 1.0.0) - 1.0.0-dev3 - Black list low code point characters (<32) - 1.0.0-dev1 - First version %package help Summary: Development documents and examples for sanitize-filename Provides: python3-sanitize-filename-doc %description help A simple, dependency-free, blacklist-based filename sanitizer, for when you want to keep the original filename. Note that a blacklist based sanitizer will _never_ be as safe as a whitelist based one. In most cases, your best option is to create a safe filename yourself. Your second safest option is to use a whitelist approach (allowing only certain characters). This sanitizer is useful when you want to keep the original filename, including non ascii characters, whenever possible. ## Installation ```sh pip install sanitize_filename ``` ## Usage ```python3 from sanitize_filename import sanitize filename = input("Enter a file name:") filename = sanitize(filename) ``` Examples: ```python3 > sanitize("A/B/C.txt") 'ABC.txt' > sanitize("this𓀦filenameḜisあactually...valid.txt") 'this𓀦filenameḜisあactually...valid.txt' > sanitize("def.") 'def' > sanitize("NUL") '__NUL' > sanitize("..") '__' ``` ## Changelog - 1.2.0 - Get rid of os dependent checks; ensure uniform behaviour - Now works on long filenames where the non-extensions part consists of only dots - 1.1.0 - Try to preserve filename extensions if possible - 1.0.1 - First release (as 1.0.1 due to a version number mix-up in 1.0.0) - 1.0.0-dev3 - Black list low code point characters (<32) - 1.0.0-dev1 - First version %prep %autosetup -n sanitize-filename-1.2.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-sanitize-filename -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Mon Apr 10 2023 Python_Bot - 1.2.0-1 - Package Spec generated