Hello community, here is the log from the commit of package python-pathvalidate for openSUSE:Factory checked in at 2020-11-29 12:29:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pathvalidate (Old) and /work/SRC/openSUSE:Factory/.python-pathvalidate.new.5913 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pathvalidate" Sun Nov 29 12:29:21 2020 rev:5 rq:851317 version:2.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pathvalidate/python-pathvalidate.changes 2020-03-29 14:27:09.242142253 +0200 +++ /work/SRC/openSUSE:Factory/.python-pathvalidate.new.5913/python-pathvalidate.changes 2020-11-29 12:29:24.438061591 +0100 @@ -1,0 +2,7 @@ +Thu Nov 26 10:16:44 UTC 2020 - John Vandenberg <jay...@gmail.com> + +- Update to v2.3.0 + * Change not to process for "."/".." by sanitization functions + * Change to normalize with sanitize_filepath in default + +------------------------------------------------------------------- Old: ---- pathvalidate-2.2.2.tar.gz New: ---- pathvalidate-2.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pathvalidate.spec ++++++ --- /var/tmp/diff_new_pack.Ct4sAR/_old 2020-11-29 12:29:25.650062817 +0100 +++ /var/tmp/diff_new_pack.Ct4sAR/_new 2020-11-29 12:29:25.654062821 +0100 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-pathvalidate -Version: 2.2.2 +Version: 2.3.0 Release: 0 Summary: Python library to sanitize/validate a string such as filenames License: MIT ++++++ pathvalidate-2.2.2.tar.gz -> pathvalidate-2.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.2.2/PKG-INFO new/pathvalidate-2.3.0/PKG-INFO --- old/pathvalidate-2.2.2/PKG-INFO 2020-03-28 13:31:57.910138000 +0100 +++ new/pathvalidate-2.3.0/PKG-INFO 2020-05-03 17:39:06.286724300 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pathvalidate -Version: 2.2.2 +Version: 2.3.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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.2.2/pathvalidate/__version__.py new/pathvalidate-2.3.0/pathvalidate/__version__.py --- old/pathvalidate-2.2.2/pathvalidate/__version__.py 2020-03-28 13:17:03.000000000 +0100 +++ new/pathvalidate-2.3.0/pathvalidate/__version__.py 2020-05-03 17:27:25.000000000 +0200 @@ -1,6 +1,6 @@ __author__ = "Tsuyoshi Hombashi" __copyright__ = "Copyright 2016, {}".format(__author__) __license__ = "MIT License" -__version__ = "2.2.2" +__version__ = "2.3.0" __maintainer__ = __author__ __email__ = "tsuyoshi.homba...@gmail.com" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.2.2/pathvalidate/_base.py new/pathvalidate-2.3.0/pathvalidate/_base.py --- old/pathvalidate-2.2.2/pathvalidate/_base.py 2020-03-28 12:55:43.000000000 +0100 +++ new/pathvalidate-2.3.0/pathvalidate/_base.py 2020-05-03 16:45:20.000000000 +0200 @@ -24,7 +24,7 @@ @property def reserved_keywords(self) -> Tuple[str, ...]: - return (".", "..") + return tuple() @property def min_len(self) -> int: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.2.2/pathvalidate/_filename.py new/pathvalidate-2.3.0/pathvalidate/_filename.py --- old/pathvalidate-2.2.2/pathvalidate/_filename.py 2020-03-28 07:34:36.000000000 +0100 +++ new/pathvalidate-2.3.0/pathvalidate/_filename.py 2020-05-03 16:08:02.000000000 +0200 @@ -181,6 +181,9 @@ platform=Platform.WINDOWS, ) + if unicode_filename in (".", ".."): + return + if unicode_filename[-1] in (" ", "."): raise InvalidCharError( self._ERROR_MSG_TEMPLATE.format( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.2.2/pathvalidate/_filepath.py new/pathvalidate-2.3.0/pathvalidate/_filepath.py --- old/pathvalidate-2.2.2/pathvalidate/_filepath.py 2020-03-28 09:11:53.000000000 +0100 +++ new/pathvalidate-2.3.0/pathvalidate/_filepath.py 2020-05-03 17:19:50.000000000 +0200 @@ -43,6 +43,7 @@ max_len: Optional[int] = None, platform: PlatformType = None, check_reserved: bool = True, + normalize: bool = True, ) -> None: super().__init__( min_len=min_len, max_len=max_len, check_reserved=check_reserved, platform=platform, @@ -61,6 +62,7 @@ check_reserved=check_reserved, platform=self.platform, ) + self.__normalize = normalize if self._is_universal() or self._is_windows(): self.__split_drive = ntpath.splitdrive @@ -73,9 +75,13 @@ self.__fpath_validator.validate_abspath(value) - unicode_file_path = preprocess(value) - drive, unicode_file_path = self.__split_drive(unicode_file_path) - sanitized_path = self._sanitize_regexp.sub(replacement_text, unicode_file_path) + unicode_filepath = preprocess(value) + + if self.__normalize: + unicode_filepath = os.path.normpath(unicode_filepath) + + drive, unicode_filepath = self.__split_drive(unicode_filepath) + sanitized_path = self._sanitize_regexp.sub(replacement_text, unicode_filepath) if self._is_windows(): path_separator = "\\" else: @@ -158,9 +164,9 @@ if not value: return - file_path = os.path.normpath(value) - unicode_file_path = preprocess(file_path) - value_len = len(unicode_file_path) + filepath = os.path.normpath(value) + unicode_filepath = preprocess(filepath) + value_len = len(unicode_filepath) if value_len > self.max_len: raise InvalidLengthError( @@ -173,18 +179,18 @@ ) ) - self._validate_reserved_keywords(unicode_file_path) - unicode_file_path = unicode_file_path.replace("\\", "/") - for entry in unicode_file_path.split("/"): + self._validate_reserved_keywords(unicode_filepath) + unicode_filepath = unicode_filepath.replace("\\", "/") + for entry in unicode_filepath.split("/"): if not entry or entry in (".", ".."): continue self.__fname_validator._validate_reserved_keywords(entry) if self._is_universal() or self._is_windows(): - self.__validate_win_file_path(unicode_file_path) + self.__validate_win_filepath(unicode_filepath) else: - self.__validate_unix_file_path(unicode_file_path) + self.__validate_unix_filepath(unicode_filepath) def validate_abspath(self, value: PathType) -> None: value = str(value) @@ -225,26 +231,26 @@ if not self._is_windows() and drive and is_nt_abs: raise err_object - def __validate_unix_file_path(self, unicode_file_path: str) -> None: - match = _RE_INVALID_PATH.findall(unicode_file_path) + def __validate_unix_filepath(self, unicode_filepath: str) -> None: + match = _RE_INVALID_PATH.findall(unicode_filepath) if match: raise InvalidCharError( self._ERROR_MSG_TEMPLATE.format( - invalid=findall_to_str(match), value=repr(unicode_file_path) + invalid=findall_to_str(match), value=repr(unicode_filepath) ) ) - def __validate_win_file_path(self, unicode_file_path: str) -> None: - match = _RE_INVALID_WIN_PATH.findall(unicode_file_path) + def __validate_win_filepath(self, unicode_filepath: str) -> None: + match = _RE_INVALID_WIN_PATH.findall(unicode_filepath) if match: raise InvalidCharError( self._ERROR_MSG_TEMPLATE.format( - invalid=findall_to_str(match), value=repr(unicode_file_path) + invalid=findall_to_str(match), value=repr(unicode_filepath) ), platform=Platform.WINDOWS, ) - _drive, value = self.__split_drive(unicode_file_path) + _drive, value = self.__split_drive(unicode_filepath) if value: match_reserved = self._RE_NTFS_RESERVED.search(value) if match_reserved: @@ -334,6 +340,7 @@ platform: Optional[str] = None, max_len: Optional[int] = None, check_reserved: bool = True, + normalize: bool = True, ) -> PathType: """Make a valid file path from a string. @@ -363,7 +370,7 @@ max_len: Maximum length of the ``file_path`` length. Truncate the name if the ``file_path`` length exceedd this value. If the value is |None|, - automatically determined by the ``platform``: + ``max_len`` will automatically determined by the ``platform``: - ``Linux``: 4096 - ``macOS``: 1024 @@ -371,6 +378,8 @@ - ``universal``: 260 check_reserved: If |True|, sanitize reserved names of the ``platform``. + normalize: + If |True|, normalize the the file path. Returns: Same type as the argument (str or PathLike object): @@ -385,7 +394,7 @@ """ return FilePathSanitizer( - platform=platform, max_len=max_len, check_reserved=check_reserved + platform=platform, max_len=max_len, check_reserved=check_reserved, normalize=normalize ).sanitize(file_path, replacement_text) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.2.2/pathvalidate/_symbol.py new/pathvalidate-2.3.0/pathvalidate/_symbol.py --- old/pathvalidate-2.2.2/pathvalidate/_symbol.py 2020-03-28 07:29:05.000000000 +0100 +++ new/pathvalidate-2.3.0/pathvalidate/_symbol.py 2020-05-03 16:25:54.000000000 +0200 @@ -17,12 +17,14 @@ def validate_unprintable(text: str) -> None: + # deprecated match_list = __RE_UNPRINTABLE.findall(preprocess(text)) if match_list: raise InvalidCharError("unprintable character found: {}".format(match_list)) def replace_unprintable(text: str, replacement_text: str = "") -> str: + # deprecated try: return __RE_UNPRINTABLE.sub(replacement_text, preprocess(text)) except (TypeError, AttributeError): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.2.2/pathvalidate.egg-info/PKG-INFO new/pathvalidate-2.3.0/pathvalidate.egg-info/PKG-INFO --- old/pathvalidate-2.2.2/pathvalidate.egg-info/PKG-INFO 2020-03-28 13:31:57.000000000 +0100 +++ new/pathvalidate-2.3.0/pathvalidate.egg-info/PKG-INFO 2020-05-03 17:39:06.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pathvalidate -Version: 2.2.2 +Version: 2.3.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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.2.2/test/_common.py new/pathvalidate-2.3.0/test/_common.py --- old/pathvalidate-2.2.2/test/_common.py 2020-01-11 06:04:50.000000000 +0100 +++ new/pathvalidate-2.3.0/test/_common.py 2020-05-03 16:47:24.000000000 +0200 @@ -75,8 +75,6 @@ INVALID_PYTHON_VAR_CHARS = INVALID_JS_VAR_CHARS + ("$",) WIN_RESERVED_FILE_NAMES = [ - ".", - "..", "CON", "con", "PRN", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.2.2/test/test_filename.py new/pathvalidate-2.3.0/test/test_filename.py --- old/pathvalidate-2.2.2/test/test_filename.py 2020-03-28 13:13:02.000000000 +0100 +++ new/pathvalidate-2.3.0/test/test_filename.py 2020-05-03 16:51:10.000000000 +0200 @@ -69,8 +69,6 @@ [ "windows", ( - ".", - "..", "CON", "PRN", "AUX", @@ -96,8 +94,8 @@ "LPT9", ), ], - ["linux", (".", "..")], - ["macos", (".", "..", ":")], + ["linux", ()], + ["macos", (":",)], ], ) def test_normal_reserved_keywords(self, test_platform, expected): @@ -266,22 +264,24 @@ for reserved_keyword, platform in product( WIN_RESERVED_FILE_NAMES, ["windows", "universal"] ) - if reserved_keyword not in [".", ".."] ] + [ - [reserved_keyword, platform, ValidationError] + [reserved_keyword, platform, None] for reserved_keyword, platform in product([".", ".."], ["posix", "linux", "macos"]) ] + [[":", "posix", ValidationError], [":", "macos", ValidationError],], ) def test_exception_reserved_name(self, value, platform, expected): - with pytest.raises(expected) as e: + if expected is None: validate_filename(value, platform=platform) - assert e.value.reason == ErrorReason.RESERVED_NAME - assert e.value.reserved_name - assert e.value.reusable_name is False + else: + with pytest.raises(expected) as e: + validate_filename(value, platform=platform) + assert e.value.reason == ErrorReason.RESERVED_NAME + assert e.value.reserved_name + assert e.value.reusable_name is False - assert not is_valid_filename(value, platform=platform) + assert not is_valid_filename(value, platform=platform) @pytest.mark.parametrize( ["value", "platform"], @@ -444,7 +444,10 @@ [reserved.upper(), "windows", reserved.upper() + "_"] for reserved in WIN_RESERVED_FILE_NAMES ] - + [[reserved, "linux", reserved + "_"] for reserved in (".", "..")], + + [ + [reserved_keyword, platform, reserved_keyword] + for reserved_keyword, platform in product([".", ".."], ["windows", "universal"]) + ], ) def test_normal_reserved_name(self, value, test_platform, expected): filename = sanitize_filename(value, platform=test_platform) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.2.2/test/test_filepath.py new/pathvalidate-2.3.0/test/test_filepath.py --- old/pathvalidate-2.2.2/test/test_filepath.py 2020-03-28 13:24:54.000000000 +0100 +++ new/pathvalidate-2.3.0/test/test_filepath.py 2020-05-03 17:33:22.000000000 +0200 @@ -4,6 +4,7 @@ import platform as m_platform import random +import sys from collections import OrderedDict from itertools import chain, product from pathlib import Path @@ -60,12 +61,7 @@ @pytest.mark.parametrize( ["test_platform", "expected"], - [ - ["windows", (".", "..",),], - ["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 @@ -241,15 +237,15 @@ ["test_platform", "value", "expected"], [ ["linux", "a/b/c.txt", None], - ["linux", "a/b?/c.txt", None], + ["linux", "a//b?/c.txt", None], ["linux", "../a/./../b/c.txt", None], ["windows", "a/b/c.txt", None], - ["windows", "a/b?/c.txt", ValidationError], + ["windows", "a//b?/c.txt", ValidationError], ["windows", "../a/./../b/c.txt", None], ["universal", "a/b/c.txt", None], ["universal", "./a/b/c.txt", None], ["universal", "../a/./../b/c.txt", None], - ["universal", "a/b?/c.txt", ValidationError], + ["universal", "a//b?/c.txt", ValidationError], ], ) def test_normal_rel_path(self, test_platform, value, expected): @@ -506,7 +502,6 @@ "abc/{}_/xyz".format(reserved_keyword), ] for reserved_keyword, platform in product(WIN_RESERVED_FILE_NAMES, ["universal"]) - if reserved_keyword not in [".", ".."] ] + [ [ @@ -515,7 +510,6 @@ "/abc/{}/xyz".format(reserved_keyword), ] for reserved_keyword, platform in product(WIN_RESERVED_FILE_NAMES, ["linux"]) - if reserved_keyword not in [".", ".."] ] + [ [ @@ -524,7 +518,6 @@ "abc/{}_.txt".format(reserved_keyword), ] for reserved_keyword, platform in product(WIN_RESERVED_FILE_NAMES, ["universal"]) - if reserved_keyword not in [".", ".."] ] + [ [ @@ -533,7 +526,6 @@ "/abc/{}.txt".format(reserved_keyword), ] for reserved_keyword, platform in product(WIN_RESERVED_FILE_NAMES, ["linux"]) - if reserved_keyword not in [".", ".."] ] + [ [ @@ -542,7 +534,6 @@ "C:\\abc\\{}_.txt".format(reserved_keyword), ] for reserved_keyword, platform in product(WIN_RESERVED_FILE_NAMES, ["windows"]) - if reserved_keyword not in [".", ".."] ] + [ ["{}\\{}".format(drive, filename), platform, "{}\\{}_".format(drive, filename)] @@ -588,6 +579,44 @@ assert is_valid_filepath(sanitized_name) @pytest.mark.parametrize( + ["test_platform", "value", "expected"], + [ + ["linux", "a/b/c.txt", "a/b/c.txt"], + ["linux", "a//b?/c.txt", "a/b?/c.txt"], + ["linux", "../a/./../b/c.txt", "../b/c.txt"], + ["windows", "a/b/c.txt", "a\\b\\c.txt"], + ["windows", "a//b?/c.txt", "a\\b\\c.txt"], + ["windows", "../a/./../b/c.txt", "..\\b\\c.txt"], + ["universal", "a/b/c.txt", "a/b/c.txt"], + ["universal", "./", "."], + ["universal", "./a/b/c.txt", "a/b/c.txt"], + ["universal", "../a/./../b/c.txt", "../b/c.txt"], + ["universal", "a//b?/c.txt", "a/b/c.txt"], + ], + ) + def test_normal_rel_path(self, test_platform, value, expected): + assert sanitize_filepath(value, platform=test_platform) == expected + + @pytest.mark.parametrize( + ["test_platform", "value", "expected"], + [ + ["linux", "a/b/c.txt", "a/b/c.txt"], + ["linux", "a//b?/c.txt", "a/b?/c.txt"], + ["linux", "../a/./../b/c.txt", "../a/./../b/c.txt"], + ["windows", "a/b/c.txt", "a\\b\\c.txt"], + ["windows", "a//b?/c.txt", "a\\b\\c.txt"], + ["windows", "../a/./../b/c.txt", "..\\a\\.\\..\\b\\c.txt"], + ["universal", "a/b/c.txt", "a/b/c.txt"], + ["universal", "./", "."], + ["universal", "./a/b/c.txt", "./a/b/c.txt"], + ["universal", "../a/./../b/c.txt", "../a/./../b/c.txt"], + ["universal", "a//b?/c.txt", "a/b/c.txt"], + ], + ) + def test_normal_not_normalize(self, test_platform, value, expected): + assert sanitize_filepath(value, platform=test_platform, normalize=False) == expected + + @pytest.mark.parametrize( ["value", "expected"], [["", ""], [None, ""],], ) def test_normal_null_values(self, value, expected): @@ -653,6 +682,7 @@ with pytest.raises(expected): sanitize_filepath(value, platform="auto") + @pytest.mark.skipif(sys.version_info < (3, 6), reason="requires python3.6 or higher") @pytest.mark.parametrize( ["value", "expected"], [[1, TypeError], [True, TypeError], [nan, TypeError], [inf, TypeError]], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pathvalidate-2.2.2/tox.ini new/pathvalidate-2.3.0/tox.ini --- old/pathvalidate-2.2.2/tox.ini 2020-03-20 11:58:55.000000000 +0100 +++ new/pathvalidate-2.3.0/tox.ini 2020-04-27 13:07:15.000000000 +0200 @@ -24,11 +24,10 @@ wheel commands = python setup.py sdist bdist_wheel - twine check dist/* + twine check dist/*.whl dist/*.tar.gz python setup.py clean --all [testenv:clean] -basepython = python3.8 deps = cleanpy commands = @@ -70,12 +69,11 @@ commands = python setup.py check mypy pathvalidate --show-error-context --show-error-codes --python-version 3.5 - pytype --keep-going --jobs 2 --disable import-error pathvalidate - codespell pathvalidate docs examples test -q2 --check-filenames + pytype --keep-going --jobs 4 --disable import-error pathvalidate + codespell pathvalidate docs/pages examples test -q2 --check-filenames pylama [testenv:readme] -basepython = python3.8 changedir = docs deps = readmemaker>=1.0.0 @@ -83,7 +81,6 @@ python make_readme.py [testenv:release] -basepython = python3.8 deps = releasecmd>=0.3.1,<1 commands = _______________________________________________ openSUSE Commits mailing list -- commit@lists.opensuse.org To unsubscribe, email commit-le...@lists.opensuse.org List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette List Archives: https://lists.opensuse.org/archives/list/commit@lists.opensuse.org