Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-pathvalidate for openSUSE:Factory checked in at 2021-03-24 16:13:51 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pathvalidate (Old) and /work/SRC/openSUSE:Factory/.python-pathvalidate.new.2401 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pathvalidate" Wed Mar 24 16:13:51 2021 rev:6 rq:880616 version:2.4.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pathvalidate/python-pathvalidate.changes 2020-11-29 12:29:24.438061591 +0100 +++ /work/SRC/openSUSE:Factory/.python-pathvalidate.new.2401/python-pathvalidate.changes 2021-03-24 16:13:52.611997212 +0100 @@ -1,0 +2,7 @@ +Sun Mar 21 13:33:57 UTC 2021 - Martin Hauke <mar...@gmx.de> + +- Update to version 2.4.0 + * Add exclude_symbols argument to replace_symbol function. + * Fix permissions of files included in sdist package binary. + +------------------------------------------------------------------- Old: ---- pathvalidate-2.3.0.tar.gz New: ---- pathvalidate-2.4.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pathvalidate.spec ++++++ --- /var/tmp/diff_new_pack.vtTZxX/_old 2021-03-24 16:13:53.123997750 +0100 +++ /var/tmp/diff_new_pack.vtTZxX/_new 2021-03-24 16:13:53.127997754 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-pathvalidate # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-pathvalidate -Version: 2.3.0 +Version: 2.4.0 Release: 0 Summary: Python library to sanitize/validate a string such as filenames License: MIT ++++++ pathvalidate-2.3.0.tar.gz -> pathvalidate-2.4.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/PKG-INFO new/pathvalidate-2.4.0/PKG-INFO --- old/pathvalidate-2.3.0/PKG-INFO 2020-05-03 17:39:06.286724300 +0200 +++ new/pathvalidate-2.4.0/PKG-INFO 2021-03-21 14:20:43.249165800 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pathvalidate -Version: 2.3.0 +Version: 2.4.0 Summary: pathvalidate is a Python library to sanitize/validate a string such as filenames/file-paths/etc. Home-page: https://github.com/thombashi/pathvalidate Author: Tsuyoshi Hombashi @@ -33,16 +33,12 @@ :target: https://pypi.org/project/pathvalidate :alt: Supported Python implementations - .. image:: https://img.shields.io/travis/thombashi/pathvalidate/master.svg?label=Linux/macOS%20CI - :target: https://travis-ci.org/thombashi/pathvalidate - :alt: Linux/macOS CI status - - .. image:: https://img.shields.io/appveyor/ci/thombashi/pathvalidate/master.svg?label=Windows%20CI - :target: https://ci.appveyor.com/project/thombashi/pathvalidate/branch/master - :alt: Windows CI status + .. image:: https://github.com/thombashi/pathvalidate/workflows/Tests/badge.svg + :target: https://github.com/thombashi/pathvalidate/actions?query=workflow%3ATests + :alt: Linux/macOS/Windows CI status - .. image:: https://coveralls.io/repos/github/thombashi/pathvalidate/badge.svg?branch=master - :target: https://coveralls.io/github/thombashi/pathvalidate?branch=master + .. image:: https://codecov.io/gh/thombashi/pathvalidate/branch/master/graph/badge.svg + :target: https://codecov.io/gh/thombashi/pathvalidate :alt: Test coverage .. image:: https://img.shields.io/github/stars/thombashi/pathvalidate.svg?style=social&label=Star @@ -306,16 +302,18 @@ Python 3.5+ No external dependencies. - - Test dependencies - ----------------- - - `pytest <https://docs.pytest.org/en/latest/>`__ - - `tox <https://testrun.org/tox/latest/>`__ - Documentation =============== https://pathvalidate.rtfd.io/ + Sponsors + ==================================== + .. image:: https://avatars0.githubusercontent.com/u/44389260?s=48&u=6da7176e51ae2654bcfd22564772ef8a3bb22318&v=4 + :target: https://github.com/chasbecker + :alt: Charles Becker (chasbecker) + + `Become a sponsor <https://github.com/sponsors/thombashi>`__ + Keywords: file,path,validation,validator,sanitization,sanitizer Platform: UNKNOWN diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/README.rst new/pathvalidate-2.4.0/README.rst --- old/pathvalidate-2.3.0/README.rst 2020-03-28 13:14:15.000000000 +0100 +++ new/pathvalidate-2.4.0/README.rst 2021-03-20 05:14:30.000000000 +0100 @@ -22,16 +22,12 @@ :target: https://pypi.org/project/pathvalidate :alt: Supported Python implementations -.. image:: https://img.shields.io/travis/thombashi/pathvalidate/master.svg?label=Linux/macOS%20CI - :target: https://travis-ci.org/thombashi/pathvalidate - :alt: Linux/macOS CI status - -.. image:: https://img.shields.io/appveyor/ci/thombashi/pathvalidate/master.svg?label=Windows%20CI - :target: https://ci.appveyor.com/project/thombashi/pathvalidate/branch/master - :alt: Windows CI status +.. image:: https://github.com/thombashi/pathvalidate/workflows/Tests/badge.svg + :target: https://github.com/thombashi/pathvalidate/actions?query=workflow%3ATests + :alt: Linux/macOS/Windows CI status -.. image:: https://coveralls.io/repos/github/thombashi/pathvalidate/badge.svg?branch=master - :target: https://coveralls.io/github/thombashi/pathvalidate?branch=master +.. image:: https://codecov.io/gh/thombashi/pathvalidate/branch/master/graph/badge.svg + :target: https://codecov.io/gh/thombashi/pathvalidate :alt: Test coverage .. image:: https://img.shields.io/github/stars/thombashi/pathvalidate.svg?style=social&label=Star @@ -295,13 +291,15 @@ Python 3.5+ No external dependencies. - -Test dependencies ------------------ -- `pytest <https://docs.pytest.org/en/latest/>`__ -- `tox <https://testrun.org/tox/latest/>`__ - Documentation =============== https://pathvalidate.rtfd.io/ +Sponsors +==================================== +.. image:: https://avatars0.githubusercontent.com/u/44389260?s=48&u=6da7176e51ae2654bcfd22564772ef8a3bb22318&v=4 + :target: https://github.com/chasbecker + :alt: Charles Becker (chasbecker) + +`Become a sponsor <https://github.com/sponsors/thombashi>`__ + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/pathvalidate/__version__.py new/pathvalidate-2.4.0/pathvalidate/__version__.py --- old/pathvalidate-2.3.0/pathvalidate/__version__.py 2020-05-03 17:27:25.000000000 +0200 +++ new/pathvalidate-2.4.0/pathvalidate/__version__.py 2021-03-21 10:21:39.000000000 +0100 @@ -1,6 +1,6 @@ __author__ = "Tsuyoshi Hombashi" __copyright__ = "Copyright 2016, {}".format(__author__) __license__ = "MIT License" -__version__ = "2.3.0" +__version__ = "2.4.0" __maintainer__ = __author__ __email__ = "tsuyoshi.homba...@gmail.com" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/pathvalidate/_common.py new/pathvalidate-2.4.0/pathvalidate/_common.py --- old/pathvalidate-2.3.0/pathvalidate/_common.py 2020-03-28 08:20:03.000000000 +0100 +++ new/pathvalidate-2.4.0/pathvalidate/_common.py 2021-03-20 05:14:30.000000000 +0100 @@ -10,6 +10,9 @@ from typing import Any, List, Optional, Union, cast +_re_whitespaces = re.compile(r"^[\s]+$") + + @enum.unique class Platform(enum.Enum): POSIX = "POSIX" @@ -28,18 +31,24 @@ return isinstance(value, Path) -def validate_pathtype(text: PathType, error_msg: Optional[str] = None) -> None: - from .error import ValidationError, ErrorReason +def validate_pathtype( + text: PathType, allow_whitespaces: bool = False, error_msg: Optional[str] = None +) -> None: + from .error import ErrorReason, ValidationError if _is_not_null_string(text) or is_pathlike_obj(text): return + if allow_whitespaces and _re_whitespaces.search(str(text)): + return + if is_null_string(text): if not error_msg: error_msg = "the value must be a not empty" raise ValidationError( - description=error_msg, reason=ErrorReason.NULL_NAME, + description=error_msg, + reason=ErrorReason.NULL_NAME, ) raise TypeError("text must be a string: actual={}".format(type(text))) @@ -47,7 +56,7 @@ def validate_null_string(text: PathType, error_msg: Optional[str] = None) -> None: # Deprecated: alias to validate_pathtype - validate_pathtype(text, error_msg) + validate_pathtype(text, False, error_msg) def preprocess(name: PathType) -> str: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/pathvalidate/_filename.py new/pathvalidate-2.4.0/pathvalidate/_filename.py --- old/pathvalidate-2.3.0/pathvalidate/_filename.py 2020-05-03 16:08:02.000000000 +0200 +++ new/pathvalidate-2.4.0/pathvalidate/_filename.py 2021-03-21 10:29:10.000000000 +0100 @@ -2,6 +2,7 @@ .. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.homba...@gmail.com> """ +import enum import itertools import ntpath import posixpath @@ -31,12 +32,20 @@ ) +@enum.unique +class ShellSafe(enum.Enum): + NONE = "no operation" + REPLACE = "" + REPLACE_UNICODE = "replace to equivalent unicode characters" + + class FileNameSanitizer(AbstractSanitizer): def __init__( self, min_len: Optional[int] = 1, max_len: Optional[int] = _DEFAULT_MAX_FILENAME_LEN, platform: PlatformType = None, + shell_safe: ShellSafe = ShellSafe.NONE, check_reserved: bool = True, ) -> None: super().__init__( @@ -57,7 +66,7 @@ def sanitize(self, value: PathType, replacement_text: str = "") -> PathType: try: - validate_pathtype(value) + validate_pathtype(value, allow_whitespaces=True if not self._is_windows() else False) except ValidationError as e: if e.reason == ErrorReason.NULL_NAME: return "" @@ -131,7 +140,12 @@ ) def validate(self, value: PathType) -> None: - validate_pathtype(value) + validate_pathtype( + value, + allow_whitespaces=False + if self.platform in [Platform.UNIVERSAL, Platform.WINDOWS] + else True, + ) unicode_filename = preprocess(value) value_len = len(unicode_filename) @@ -258,6 +272,19 @@ max_len: Optional[int] = None, check_reserved: bool = True, ) -> bool: + """Check whether the ``filename`` is a valid name or not. + + Args: + filename: + A filename to be checked. + + Example: + :ref:`example-is-valid-filename` + + See Also: + :py:func:`.validate_filename()` + """ + return FileNameValidator( platform=platform, min_len=min_len, max_len=max_len, check_reserved=check_reserved ).is_valid(filename) @@ -282,7 +309,7 @@ - for Windows (or universal) only: |invalid_win_filename_chars| - Append underscore (``"_"``) at the tail of the name if sanitized name - is one of the reserved names by the operating system + is one of the reserved names by operating systems (only when ``check_reserved`` is |True|). Args: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/pathvalidate/_filepath.py new/pathvalidate-2.4.0/pathvalidate/_filepath.py --- old/pathvalidate-2.3.0/pathvalidate/_filepath.py 2020-05-03 17:19:50.000000000 +0200 +++ new/pathvalidate-2.4.0/pathvalidate/_filepath.py 2021-03-21 07:13:32.000000000 +0100 @@ -46,7 +46,10 @@ normalize: bool = True, ) -> None: super().__init__( - min_len=min_len, max_len=max_len, check_reserved=check_reserved, platform=platform, + min_len=min_len, + max_len=max_len, + check_reserved=check_reserved, + platform=platform, ) self._sanitize_regexp = self._get_sanitize_regexp() @@ -144,7 +147,10 @@ check_reserved: bool = True, ) -> None: super().__init__( - min_len=min_len, max_len=max_len, check_reserved=check_reserved, platform=platform, + min_len=min_len, + max_len=max_len, + check_reserved=check_reserved, + platform=platform, ) self.__fname_validator = FileNameValidator( @@ -157,7 +163,12 @@ self.__split_drive = posixpath.splitdrive def validate(self, value: PathType) -> None: - validate_pathtype(value) + validate_pathtype( + value, + allow_whitespaces=False + if self.platform in [Platform.UNIVERSAL, Platform.WINDOWS] + else True, + ) self.validate_abspath(value) _drive, value = self.__split_drive(str(value)) @@ -329,6 +340,19 @@ max_len: Optional[int] = None, check_reserved: bool = True, ) -> bool: + """Check whether the ``file_path`` is a valid name or not. + + Args: + file_path: + A filepath to be checked. + + Example: + :ref:`example-is-valid-filepath` + + See Also: + :py:func:`.validate_filepath()` + """ + return FilePathValidator( platform=platform, min_len=min_len, max_len=max_len, check_reserved=check_reserved ).is_valid(file_path) @@ -354,7 +378,7 @@ - for Windows (or universal) only: |invalid_win_file_path_chars| - Append underscore (``"_"``) at the tail of the name if sanitized name - is one of the reserved names by the operating system + is one of the reserved names by operating systems (only when ``check_reserved`` is |True|). Args: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/pathvalidate/_ltsv.py new/pathvalidate-2.4.0/pathvalidate/_ltsv.py --- old/pathvalidate-2.3.0/pathvalidate/_ltsv.py 2020-03-28 07:18:25.000000000 +0100 +++ new/pathvalidate-2.4.0/pathvalidate/_ltsv.py 2021-03-20 05:14:30.000000000 +0100 @@ -21,7 +21,7 @@ If invalid character(s) found in the ``label`` for a LTSV format label. """ - validate_pathtype(label, error_msg="label is empty") + validate_pathtype(label, allow_whitespaces=False, error_msg="label is empty") match_list = __RE_INVALID_LTSV_LABEL.findall(preprocess(label)) if match_list: @@ -40,6 +40,6 @@ :rtype: str """ - validate_pathtype(label, error_msg="label is empty") + validate_pathtype(label, allow_whitespaces=False, error_msg="label is empty") return __RE_INVALID_LTSV_LABEL.sub(replacement_text, preprocess(label)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/pathvalidate/_symbol.py new/pathvalidate-2.4.0/pathvalidate/_symbol.py --- old/pathvalidate-2.3.0/pathvalidate/_symbol.py 2020-05-03 16:25:54.000000000 +0200 +++ new/pathvalidate-2.4.0/pathvalidate/_symbol.py 2021-03-21 09:57:13.000000000 +0100 @@ -3,6 +3,7 @@ """ import re +from typing import Sequence from ._common import ascii_symbols, preprocess, unprintable_ascii_chars from .error import InvalidCharError @@ -52,24 +53,48 @@ def replace_symbol( text: str, replacement_text: str = "", + exclude_symbols: Sequence[str] = [], is_replace_consecutive_chars: bool = False, is_strip: bool = False, ) -> str: """ Replace all of the symbols in the ``text``. - :param text: Input text. - :param replacement_text: Replacement text. - :return: A replacement string. - :rtype: str + Args: + text: + Input text. + replacement_text: + Replacement text. + exclude_symbols: + Symbols that exclude from the replacement. + is_replace_consecutive_chars: + If |True|, replace consecutive multiple ``replacement_text`` characters + to a single character. + is_strip: + If |True|, strip ``replacement_text`` from the beginning/end of the replacement text. - :Examples: + Returns: + A replacement string. + + Example: :ref:`example-sanitize-symbol` """ + if exclude_symbols: + regexp = re.compile( + "[{}]".format( + re.escape( + "".join(set(ascii_symbols + unprintable_ascii_chars) - set(exclude_symbols)) + ) + ), + re.UNICODE, + ) + else: + regexp = __RE_SYMBOL + try: - new_text = __RE_SYMBOL.sub(replacement_text, preprocess(text)) + new_text = regexp.sub(replacement_text, preprocess(text)) except TypeError: raise TypeError("text must be a string") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/pathvalidate.egg-info/PKG-INFO new/pathvalidate-2.4.0/pathvalidate.egg-info/PKG-INFO --- old/pathvalidate-2.3.0/pathvalidate.egg-info/PKG-INFO 2020-05-03 17:39:06.000000000 +0200 +++ new/pathvalidate-2.4.0/pathvalidate.egg-info/PKG-INFO 2021-03-21 14:20:43.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pathvalidate -Version: 2.3.0 +Version: 2.4.0 Summary: pathvalidate is a Python library to sanitize/validate a string such as filenames/file-paths/etc. Home-page: https://github.com/thombashi/pathvalidate Author: Tsuyoshi Hombashi @@ -33,16 +33,12 @@ :target: https://pypi.org/project/pathvalidate :alt: Supported Python implementations - .. image:: https://img.shields.io/travis/thombashi/pathvalidate/master.svg?label=Linux/macOS%20CI - :target: https://travis-ci.org/thombashi/pathvalidate - :alt: Linux/macOS CI status - - .. image:: https://img.shields.io/appveyor/ci/thombashi/pathvalidate/master.svg?label=Windows%20CI - :target: https://ci.appveyor.com/project/thombashi/pathvalidate/branch/master - :alt: Windows CI status + .. image:: https://github.com/thombashi/pathvalidate/workflows/Tests/badge.svg + :target: https://github.com/thombashi/pathvalidate/actions?query=workflow%3ATests + :alt: Linux/macOS/Windows CI status - .. image:: https://coveralls.io/repos/github/thombashi/pathvalidate/badge.svg?branch=master - :target: https://coveralls.io/github/thombashi/pathvalidate?branch=master + .. image:: https://codecov.io/gh/thombashi/pathvalidate/branch/master/graph/badge.svg + :target: https://codecov.io/gh/thombashi/pathvalidate :alt: Test coverage .. image:: https://img.shields.io/github/stars/thombashi/pathvalidate.svg?style=social&label=Star @@ -306,16 +302,18 @@ Python 3.5+ No external dependencies. - - Test dependencies - ----------------- - - `pytest <https://docs.pytest.org/en/latest/>`__ - - `tox <https://testrun.org/tox/latest/>`__ - Documentation =============== https://pathvalidate.rtfd.io/ + Sponsors + ==================================== + .. image:: https://avatars0.githubusercontent.com/u/44389260?s=48&u=6da7176e51ae2654bcfd22564772ef8a3bb22318&v=4 + :target: https://github.com/chasbecker + :alt: Charles Becker (chasbecker) + + `Become a sponsor <https://github.com/sponsors/thombashi>`__ + Keywords: file,path,validation,validator,sanitization,sanitizer Platform: UNKNOWN diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/pathvalidate.egg-info/requires.txt new/pathvalidate-2.4.0/pathvalidate.egg-info/requires.txt --- old/pathvalidate-2.3.0/pathvalidate.egg-info/requires.txt 2020-05-03 17:39:06.000000000 +0200 +++ new/pathvalidate-2.4.0/pathvalidate.egg-info/requires.txt 2021-03-21 14:20:43.000000000 +0100 @@ -3,4 +3,6 @@ allpairspy click faker -pytest +pytest>=6.0.1 +pytest-discord>=0.0.6 +pytest-md-report>=0.0.12 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/pyproject.toml new/pathvalidate-2.4.0/pyproject.toml --- old/pathvalidate-2.3.0/pyproject.toml 2020-02-12 08:12:31.000000000 +0100 +++ new/pathvalidate-2.4.0/pyproject.toml 2021-03-21 07:48:25.000000000 +0100 @@ -1,3 +1,6 @@ +[build-system] +requires = ["setuptools", "wheel"] + [tool.black] line-length = 100 exclude = ''' @@ -17,7 +20,6 @@ ''' [tool.isort] -dont_skip = '*/**/__init__.py' known_third_party = [ 'allpairspy', 'path', @@ -52,3 +54,14 @@ 'abstractclassmethod', 'warnings.warn', ] + +[tool.pytest.ini_options] +testpaths = [ + "test", +] + +md_report = true +md_report_verbose = 0 +md_report_color = "auto" + +discord_verbose = 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/requirements/docs_requirements.txt new/pathvalidate-2.4.0/requirements/docs_requirements.txt --- old/pathvalidate-2.3.0/requirements/docs_requirements.txt 2020-01-15 16:02:07.000000000 +0100 +++ new/pathvalidate-2.4.0/requirements/docs_requirements.txt 2021-03-20 05:14:30.000000000 +0100 @@ -1,2 +1,2 @@ sphinx_rtd_theme -Sphinx +Sphinx>=2.4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/requirements/test_requirements.txt new/pathvalidate-2.4.0/requirements/test_requirements.txt --- old/pathvalidate-2.3.0/requirements/test_requirements.txt 2020-02-12 06:39:38.000000000 +0100 +++ new/pathvalidate-2.4.0/requirements/test_requirements.txt 2021-03-20 05:14:30.000000000 +0100 @@ -1,4 +1,6 @@ allpairspy click faker -pytest +pytest>=6.0.1 +pytest-discord>=0.0.6 +pytest-md-report>=0.0.12 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/setup.py new/pathvalidate-2.4.0/setup.py --- old/pathvalidate-2.3.0/setup.py 2020-03-14 10:50:25.000000000 +0100 +++ new/pathvalidate-2.4.0/setup.py 2021-03-20 05:14:30.000000000 +0100 @@ -37,8 +37,6 @@ with open(os.path.join(REQUIREMENT_DIR, "test_requirements.txt")) as f: TESTS_REQUIRES = [line.strip() for line in f if line.strip()] -SETUPTOOLS_REQUIRES = ["setuptools>=38.3.0"] - setuptools.setup( name=MODULE_NAME, version=pkg_info["__version__"], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/test/test_filename.py new/pathvalidate-2.4.0/test/test_filename.py --- old/pathvalidate-2.3.0/test/test_filename.py 2020-05-03 16:51:10.000000000 +0200 +++ new/pathvalidate-2.4.0/test/test_filename.py 2021-03-21 07:16:00.000000000 +0100 @@ -129,6 +129,26 @@ assert is_valid_filename(value, platform=platform) @pytest.mark.parametrize( + ["platform"], + [["linux"], ["macos"], ["posix"]], + ) + def test_normal_only_whitespaces(self, platform): + value = " " + validate_filename(value, platform) + assert is_valid_filename(value, platform=platform) + + @pytest.mark.parametrize( + ["platform"], + [["windows"], ["universal"]], + ) + def test_abnormal_only_whitespaces(self, platform): + value = " " + with pytest.raises(ValidationError) as e: + validate_filename(value, platform=platform) + assert e.value.reason == ErrorReason.NULL + assert not is_valid_filename(value, platform) + + @pytest.mark.parametrize( ["value", "platform"], chain.from_iterable( [ @@ -179,7 +199,10 @@ assert e.value.reason == expected @pytest.mark.parametrize( - ["value", "platform", "max_len", "expected"], [["invalid_max_len", None, 0, ValueError],], + ["value", "platform", "max_len", "expected"], + [ + ["invalid_max_len", None, 0, ValueError], + ], ) def test_abnormal_max_len(self, value, platform, max_len, expected): with pytest.raises(expected): @@ -269,9 +292,12 @@ [reserved_keyword, platform, None] for reserved_keyword, platform in product([".", ".."], ["posix", "linux", "macos"]) ] - + [[":", "posix", ValidationError], [":", "macos", ValidationError],], + + [ + [":", "posix", ValidationError], + [":", "macos", ValidationError], + ], ) - def test_exception_reserved_name(self, value, platform, expected): + def test_reserved_name(self, value, platform, expected): if expected is None: validate_filename(value, platform=platform) else: @@ -403,7 +429,11 @@ assert is_valid_filename(sanitized_name) @pytest.mark.parametrize( - ["value", "expected"], [["", ""], [None, ""],], + ["value", "expected"], + [ + ["", ""], + [None, ""], + ], ) def test_normal_null_values(self, value, expected): assert sanitize_filename(value) == expected @@ -455,7 +485,11 @@ assert is_valid_filename(filename, platform=test_platform) @pytest.mark.parametrize( - ["value", "check_reserved", "expected"], [["CON", True, "CON_"], ["CON", False, "CON"],] + ["value", "check_reserved", "expected"], + [ + ["CON", True, "CON_"], + ["CON", False, "CON"], + ], ) def test_normal_check_reserved(self, value, check_reserved, expected): assert ( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/test/test_filepath.py new/pathvalidate-2.4.0/test/test_filepath.py --- old/pathvalidate-2.3.0/test/test_filepath.py 2020-05-03 17:33:22.000000000 +0200 +++ new/pathvalidate-2.4.0/test/test_filepath.py 2021-03-21 09:44:40.000000000 +0100 @@ -61,7 +61,12 @@ @pytest.mark.parametrize( ["test_platform", "expected"], - [["windows", tuple()], ["posix", ("/", ":")], ["linux", ("/",)], ["macos", ("/", ":")],], + [ + ["windows", tuple()], + ["posix", ("/", ":")], + ["linux", ("/",)], + ["macos", ("/", ":")], + ], ) def test_normal_reserved_keywords(self, test_platform, expected): assert FilePathValidator(255, platform=test_platform).reserved_keywords == expected @@ -101,6 +106,26 @@ assert is_valid_filepath(value, platform=platform) @pytest.mark.parametrize( + ["platform"], + [["linux"], ["macos"], ["posix"]], + ) + def test_normal_only_whitespaces(self, platform): + value = " " + validate_filepath(value, platform) + assert is_valid_filepath(value, platform=platform) + + @pytest.mark.parametrize( + ["platform"], + [["windows"], ["universal"]], + ) + def test_abnormal_only_whitespaces(self, platform): + value = " " + with pytest.raises(ValidationError) as e: + validate_filepath(value, platform=platform) + assert e.value.reason == ErrorReason.NULL + assert not is_valid_filepath(value, platform) + + @pytest.mark.parametrize( ["value", "platform"], chain.from_iterable( [ @@ -198,7 +223,7 @@ ["universal", "C:\\a\\b\\c.txt", ValidationError], ], ) - def test_normal_abs_path(self, test_platform, value, expected): + def test_abs_path(self, test_platform, value, expected): if expected is None: validate_filepath(value, platform=test_platform) assert is_valid_filepath(value, platform=test_platform) @@ -209,9 +234,12 @@ @pytest.mark.skipif(m_platform.system() != "Windows", reason="platform dependent tests") @pytest.mark.parametrize( - ["value", "expected"], [["C:\\a\\b\\c.txt", None],], + ["value", "expected"], + [ + ["C:\\a\\b\\c.txt", None], + ], ) - def test_normal_auto_platform_win(self, value, expected): + def test_auto_platform_win(self, value, expected): if expected is None: validate_filepath(value, platform="auto") assert is_valid_filepath(value, platform="auto") @@ -222,9 +250,13 @@ @pytest.mark.skipif(m_platform.system() != "Linux", reason="platform dependent tests") @pytest.mark.parametrize( - ["value", "expected"], [["/a/b/c.txt", None], ["C:\\a\\b\\c.txt", ValidationError],], + ["value", "expected"], + [ + ["/a/b/c.txt", None], + ["C:\\a\\b\\c.txt", ValidationError], + ], ) - def test_normal_auto_platform_linux(self, value, expected): + def test_auto_platform_linux(self, value, expected): if expected is None: validate_filepath(value, platform="auto") assert is_valid_filepath(value, platform="auto") @@ -248,7 +280,7 @@ ["universal", "a//b?/c.txt", ValidationError], ], ) - def test_normal_rel_path(self, test_platform, value, expected): + def test_relative_path(self, test_platform, value, expected): if expected is None: validate_filepath(value, platform=test_platform) assert is_valid_filepath(value, platform=test_platform) @@ -548,7 +580,11 @@ assert is_valid_filepath(filename, platform=test_platform) @pytest.mark.parametrize( - ["value", "check_reserved", "expected"], [["CON", True, "CON_"], ["CON", False, "CON"],] + ["value", "check_reserved", "expected"], + [ + ["CON", True, "CON_"], + ["CON", False, "CON"], + ], ) def test_normal_check_reserved(self, value, check_reserved, expected): assert ( @@ -594,7 +630,7 @@ ["universal", "a//b?/c.txt", "a/b/c.txt"], ], ) - def test_normal_rel_path(self, test_platform, value, expected): + def test_normal_relative_path(self, test_platform, value, expected): assert sanitize_filepath(value, platform=test_platform) == expected @pytest.mark.parametrize( @@ -617,7 +653,11 @@ assert sanitize_filepath(value, platform=test_platform, normalize=False) == expected @pytest.mark.parametrize( - ["value", "expected"], [["", ""], [None, ""],], + ["value", "expected"], + [ + ["", ""], + [None, ""], + ], ) def test_normal_null_values(self, value, expected): assert sanitize_filepath(value) == expected @@ -658,11 +698,27 @@ assert sanitized == expected assert is_valid_filepath(sanitized, platform=platform) + """ + @pytest.mark.parametrize( + ["value", "expected"], + [ + ['/tmp/fi:l*ep"a?t>h|.t<xt', "aavvva"], + ], + ) + def test_sanitize_abspath(self, value, expected): + sanitized = sanitize_filepath(value, platform="posix") + assert is_valid_filepath(sanitized, platform="posix") + assert sanitized == expected + """ + @pytest.mark.skipif(m_platform.system() != "Windows", reason="platform dependent tests") @pytest.mark.parametrize( - ["value", "expected"], [["C:\\a\\b|c.txt", "C:\\a\\bc.txt"],], + ["value", "expected"], + [ + ["C:\\a\\b|c.txt", "C:\\a\\bc.txt"], + ], ) - def test_normal_auto_platform_win(self, value, expected): + def test_auto_platform_win(self, value, expected): if isinstance(expected, str): sanitized = sanitize_filepath(value, platform="auto") assert is_valid_filepath(sanitized, platform="auto") @@ -672,9 +728,12 @@ @pytest.mark.skipif(m_platform.system() != "Linux", reason="platform dependent tests") @pytest.mark.parametrize( - ["value", "expected"], [["/a/b:c.txt", "/a/bc.txt"], ["C:\\a\\b\\c.txt", ValidationError],], + ["value", "expected"], + [ + ["C:\\a\\b\\c.txt", ValidationError], + ], ) - def test_normal_auto_platform_linux(self, value, expected): + def test_auto_platform_linux(self, value, expected): if isinstance(expected, str): sanitized = sanitize_filepath(value, platform="auto") assert is_valid_filepath(sanitized, platform="auto") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/test/test_symbol.py new/pathvalidate-2.4.0/test/test_symbol.py --- old/pathvalidate-2.3.0/test/test_symbol.py 2020-03-28 11:59:31.000000000 +0100 +++ new/pathvalidate-2.4.0/test/test_symbol.py 2021-03-21 10:07:25.000000000 +0100 @@ -63,6 +63,17 @@ assert replace_symbol(value, replace_text) == expected @pytest.mark.parametrize( + ["value", "exclude_symbols", "expected"], + [ + ["/tmp/h!o|g$e.txt", ["/", "."], "/tmp/hoge.txt"], + ["/tmp/h!o|g$e.txt", [], "tmphogetxt"], + ["/tmp/h!o|g$e.txt", ["n", "o", "p"], "tmphogetxt"], + ], + ) + def test_normal_exclude_symbols(self, value, exclude_symbols, expected): + assert replace_symbol(value, exclude_symbols=exclude_symbols) == expected + + @pytest.mark.parametrize( ["value", "replace_text", "is_replace_consecutive_chars", "is_strip", "expected"], [ ["!a##b$$$c((((d]]]])", "_", True, True, "a_b_c_d"], @@ -75,7 +86,13 @@ self, value, replace_text, is_replace_consecutive_chars, is_strip, expected ): assert ( - replace_symbol(value, replace_text, is_replace_consecutive_chars, is_strip) == expected + replace_symbol( + value, + replace_text, + is_replace_consecutive_chars=is_replace_consecutive_chars, + is_strip=is_strip, + ) + == expected ) @pytest.mark.parametrize( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.3.0/tox.ini new/pathvalidate-2.4.0/tox.ini --- old/pathvalidate-2.3.0/tox.ini 2020-04-27 13:07:15.000000000 +0200 +++ new/pathvalidate-2.4.0/tox.ini 2021-03-20 18:08:13.000000000 +0100 @@ -9,9 +9,9 @@ fmt lint readme - release [testenv] +passenv = * deps = .[test] commands = @@ -28,6 +28,7 @@ python setup.py clean --all [testenv:clean] +skip_install = true deps = cleanpy commands = @@ -36,10 +37,10 @@ [testenv:cov] deps = .[test] - coverage[toml] - pytest-cov + coverage[toml]>=5 commands = - pytest --cov {posargs:-vv} + coverage run -m pytest {posargs:-vv} + coverage report -m [testenv:docs] basepython = python3.8 @@ -50,17 +51,19 @@ [testenv:fmt] basepython = python3.8 +skip_install = true deps = autoflake black - isort[pyproject] + isort>=5 commands = autoflake --in-place --recursive --remove-all-unused-imports --ignore-init-module-imports --exclude ".pytype" . - isort --apply --recursive + isort . black setup.py test pathvalidate [testenv:lint] -basepython = python3.7 +basepython = python3.8 +skip_install = true deps = codespell mypy>=0.761 @@ -68,20 +71,15 @@ pytype commands = python setup.py check - mypy pathvalidate --show-error-context --show-error-codes --python-version 3.5 + mypy pathvalidate setup.py pytype --keep-going --jobs 4 --disable import-error pathvalidate codespell pathvalidate docs/pages examples test -q2 --check-filenames pylama [testenv:readme] +skip_install = true changedir = docs deps = readmemaker>=1.0.0 commands = python make_readme.py - -[testenv:release] -deps = - releasecmd>=0.3.1,<1 -commands = - python setup.py release --sign {posargs}