Hello community,
here is the log from the commit of package python-pathvalidate for
openSUSE:Factory checked in at 2020-02-18 10:35:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pathvalidate (Old)
and /work/SRC/openSUSE:Factory/.python-pathvalidate.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pathvalidate"
Tue Feb 18 10:35:52 2020 rev:2 rq:774695 version:2.2.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pathvalidate/python-pathvalidate.changes
2020-02-10 21:54:20.882221657 +0100
+++
/work/SRC/openSUSE:Factory/.python-pathvalidate.new.26092/python-pathvalidate.changes
2020-02-18 10:37:00.336528300 +0100
@@ -1,0 +2,8 @@
+Sun Feb 16 09:54:22 UTC 2020 - Martin Hauke <[email protected]>
+
+- Update to version 2.2.0
+ * Add POSIX as a platform
+ * Change platform of validate_filepath_arg/sanitize_filepath_arg
+ to 'auto':
+
+-------------------------------------------------------------------
Old:
----
pathvalidate-2.1.0.tar.gz
New:
----
pathvalidate-2.2.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pathvalidate.spec ++++++
--- /var/tmp/diff_new_pack.jklYqN/_old 2020-02-18 10:37:01.504530683 +0100
+++ /var/tmp/diff_new_pack.jklYqN/_new 2020-02-18 10:37:01.504530683 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-pathvalidate
#
-# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,13 +12,14 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
+#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-pathvalidate
-Version: 2.1.0
+Version: 2.2.0
Release: 0
Summary: Python library to sanitize/validate a string such as filenames
License: MIT
@@ -30,6 +31,7 @@
BuildRequires: python-rpm-macros
# SECTION test requirements
BuildRequires: %{python_module Faker}
+BuildRequires: %{python_module allpairspy}
BuildRequires: %{python_module click}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools >= 38.3.0}
++++++ pathvalidate-2.1.0.tar.gz -> pathvalidate-2.2.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/PKG-INFO
new/pathvalidate-2.2.0/PKG-INFO
--- old/pathvalidate-2.1.0/PKG-INFO 2020-02-01 11:32:39.472019000 +0100
+++ new/pathvalidate-2.2.0/PKG-INFO 2020-02-12 10:56:16.420759700 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: pathvalidate
-Version: 2.1.0
+Version: 2.2.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
@@ -170,6 +170,9 @@
usage: argparse_validate.py [-h] [--filepath FILEPATH]
[--filename FILENAME]
argparse_validate.py: error: argument --filepath: invalid char
found: invalids=('?'), value='e?g', reason=INVALID_CHARACTER,
target-platform=Windows
+ .. note::
+ ``validate_filepath_arg`` is set platform as ``"auto"``.
+
filename/filepath sanitizer for argparse
------------------------------------------
:Sample Code:
@@ -197,6 +200,9 @@
$ ./examples/argparse_sanitize.py --filename e/g
filename: eg
+ .. note::
+ ``sanitize_filepath_arg`` is set platform as ``"auto"``.
+
filename/filepath validator for click
---------------------------------------
:Sample Code:
@@ -296,7 +302,6 @@
Test dependencies
-----------------
- `pytest <https://docs.pytest.org/en/latest/>`__
- - `pytest-runner <https://github.com/pytest-dev/pytest-runner>`__
- `tox <https://testrun.org/tox/latest/>`__
Documentation
@@ -316,10 +321,14 @@
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
+Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: System :: Filesystems
Classifier: Topic :: Text Processing
Requires-Python: >=3.5
Description-Content-Type: text/x-rst
+Provides-Extra: test
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/README.rst
new/pathvalidate-2.2.0/README.rst
--- old/pathvalidate-2.1.0/README.rst 2020-02-01 11:28:01.000000000 +0100
+++ new/pathvalidate-2.2.0/README.rst 2020-02-12 09:21:38.000000000 +0100
@@ -159,6 +159,9 @@
usage: argparse_validate.py [-h] [--filepath FILEPATH] [--filename
FILENAME]
argparse_validate.py: error: argument --filepath: invalid char found:
invalids=('?'), value='e?g', reason=INVALID_CHARACTER, target-platform=Windows
+.. note::
+ ``validate_filepath_arg`` is set platform as ``"auto"``.
+
filename/filepath sanitizer for argparse
------------------------------------------
:Sample Code:
@@ -186,6 +189,9 @@
$ ./examples/argparse_sanitize.py --filename e/g
filename: eg
+.. note::
+ ``sanitize_filepath_arg`` is set platform as ``"auto"``.
+
filename/filepath validator for click
---------------------------------------
:Sample Code:
@@ -285,7 +291,6 @@
Test dependencies
-----------------
- `pytest <https://docs.pytest.org/en/latest/>`__
-- `pytest-runner <https://github.com/pytest-dev/pytest-runner>`__
- `tox <https://testrun.org/tox/latest/>`__
Documentation
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/pathvalidate/__version__.py
new/pathvalidate-2.2.0/pathvalidate/__version__.py
--- old/pathvalidate-2.1.0/pathvalidate/__version__.py 2020-02-01
11:30:00.000000000 +0100
+++ new/pathvalidate-2.2.0/pathvalidate/__version__.py 2020-02-12
09:22:12.000000000 +0100
@@ -1,9 +1,6 @@
-from datetime import datetime
-
-
__author__ = "Tsuyoshi Hombashi"
-__copyright__ = "Copyright 2016-{}, {}".format(datetime.now().year, __author__)
+__copyright__ = "Copyright 2016, {}".format(__author__)
__license__ = "MIT License"
-__version__ = "2.1.0"
+__version__ = "2.2.0"
__maintainer__ = __author__
__email__ = "[email protected]"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/pathvalidate/_base.py
new/pathvalidate-2.2.0/pathvalidate/_base.py
--- old/pathvalidate-2.1.0/pathvalidate/_base.py 2020-02-01
10:48:31.000000000 +0100
+++ new/pathvalidate-2.2.0/pathvalidate/_base.py 2020-02-12
05:29:02.000000000 +0100
@@ -4,8 +4,7 @@
import abc
import os
-import re
-from typing import Any, List, Optional, Tuple, cast
+from typing import Optional, Tuple, cast
from ._common import PathType, Platform, PlatformType, normalize_platform,
unprintable_ascii_chars
from .error import ReservedNameError, ValidationError
@@ -17,18 +16,6 @@
_INVALID_WIN_PATH_CHARS = _INVALID_PATH_CHARS + ':*?"<>|\t\n\r\x0b\x0c'
_INVALID_WIN_FILENAME_CHARS = _INVALID_FILENAME_CHARS +
_INVALID_WIN_PATH_CHARS + "\\"
- _RE_INVALID_FILENAME = re.compile(
- "[{:s}]".format(re.escape(_INVALID_FILENAME_CHARS)), re.UNICODE
- )
- _RE_INVALID_WIN_FILENAME = re.compile(
- "[{:s}]".format(re.escape(_INVALID_WIN_FILENAME_CHARS)), re.UNICODE
- )
-
- _RE_INVALID_PATH =
re.compile("[{:s}]".format(re.escape(_INVALID_PATH_CHARS)), re.UNICODE)
- _RE_INVALID_WIN_PATH = re.compile(
- "[{:s}]".format(re.escape(_INVALID_WIN_PATH_CHARS)), re.UNICODE
- )
-
_ERROR_MSG_TEMPLATE = "invalid char found: invalids=({invalid}),
value={value}"
@property
@@ -73,6 +60,9 @@
self._max_len = min(self._max_len, platform_max_len)
self._validate_max_len()
+ def _is_posix(self) -> bool:
+ return self.platform == Platform.POSIX
+
def _is_universal(self) -> bool:
return self.platform == Platform.UNIVERSAL
@@ -99,15 +89,11 @@
if self._is_windows():
return 260
- if self._is_macos():
+ if self._is_posix() or self._is_macos():
return 1024
return 260 # universal
- @staticmethod
- def _findall_to_str(match: List[Any]) -> str:
- return ", ".join([repr(text) for text in match])
-
class AbstractValidator(BaseFile, metaclass=abc.ABCMeta):
@abc.abstractmethod
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/pathvalidate/_common.py
new/pathvalidate-2.2.0/pathvalidate/_common.py
--- old/pathvalidate-2.1.0/pathvalidate/_common.py 2020-02-01
08:32:13.000000000 +0100
+++ new/pathvalidate-2.2.0/pathvalidate/_common.py 2020-02-12
04:39:40.000000000 +0100
@@ -12,7 +12,9 @@
@enum.unique
class Platform(enum.Enum):
+ POSIX = "POSIX"
UNIVERSAL = "universal"
+
LINUX = "Linux"
WINDOWS = "Windows"
MACOS = "macOS"
@@ -70,14 +72,14 @@
return False
-def _get_unprintable_ascii_char_list() -> List[str]:
+def _get_unprintable_ascii_chars() -> List[str]:
return [chr(c) for c in range(128) if chr(c) not in string.printable]
-unprintable_ascii_chars = tuple(_get_unprintable_ascii_char_list())
+unprintable_ascii_chars = tuple(_get_unprintable_ascii_chars())
-def _get_ascii_symbol_list() -> List[str]:
+def _get_ascii_symbols() -> List[str]:
symbol_list = [] # type: List[str]
for i in range(128):
@@ -91,7 +93,7 @@
return symbol_list
-ascii_symbols = tuple(_get_ascii_symbol_list())
+ascii_symbols = tuple(_get_ascii_symbols())
__RE_UNPRINTABLE_CHARS = re.compile(
"[{}]".format(re.escape("".join(unprintable_ascii_chars))), re.UNICODE
@@ -112,6 +114,9 @@
if name:
name = name.strip().lower()
+ if name == "posix":
+ return Platform.POSIX
+
if name == "auto":
name = platform.system().lower()
@@ -125,3 +130,7 @@
return Platform.MACOS
return Platform.UNIVERSAL
+
+
+def findall_to_str(match: List[Any]) -> str:
+ return ", ".join([repr(text) for text in match])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/pathvalidate/_filename.py
new/pathvalidate-2.2.0/pathvalidate/_filename.py
--- old/pathvalidate-2.1.0/pathvalidate/_filename.py 2020-02-01
11:27:30.000000000 +0100
+++ new/pathvalidate-2.2.0/pathvalidate/_filename.py 2020-02-12
06:42:00.000000000 +0100
@@ -9,11 +9,12 @@
from pathlib import Path
from typing import Optional, Pattern, Tuple
-from ._base import AbstractSanitizer, BaseValidator
+from ._base import AbstractSanitizer, BaseFile, BaseValidator
from ._common import (
PathType,
Platform,
PlatformType,
+ findall_to_str,
is_pathlike_obj,
preprocess,
validate_pathtype,
@@ -28,6 +29,12 @@
_DEFAULT_MAX_FILENAME_LEN = 255
+_RE_INVALID_FILENAME = re.compile(
+ "[{:s}]".format(re.escape(BaseFile._INVALID_FILENAME_CHARS)), re.UNICODE
+)
+_RE_INVALID_WIN_FILENAME = re.compile(
+ "[{:s}]".format(re.escape(BaseFile._INVALID_WIN_FILENAME_CHARS)),
re.UNICODE
+)
class FileNameSanitizer(AbstractSanitizer):
@@ -38,7 +45,7 @@
platform: PlatformType = None,
check_reserved: bool = True,
) -> None:
- super(FileNameSanitizer, self).__init__(
+ super().__init__(
min_len=min_len,
max_len=max_len,
check_reserved=check_reserved,
@@ -83,9 +90,9 @@
def _get_sanitize_regexp(self) -> Pattern:
if self.platform in [Platform.UNIVERSAL, Platform.WINDOWS]:
- return self._RE_INVALID_WIN_FILENAME
+ return _RE_INVALID_WIN_FILENAME
- return self._RE_INVALID_FILENAME
+ return _RE_INVALID_FILENAME
class FileNameValidator(BaseValidator):
@@ -93,14 +100,25 @@
"{:s}{:d}".format(name, num)
for name, num in itertools.product(("COM", "LPT"), range(1, 10))
)
+ _MACOS_RESERVED_FILE_NAMES = (":",)
@property
def reserved_keywords(self) -> Tuple[str, ...]:
- common_keywords = super(FileNameValidator, self).reserved_keywords
+ common_keywords = super().reserved_keywords
- if self._is_universal() or self._is_windows():
+ if self._is_universal():
+ return (
+ common_keywords
+ + self._WINDOWS_RESERVED_FILE_NAMES
+ + self._MACOS_RESERVED_FILE_NAMES
+ )
+
+ if self._is_windows():
return common_keywords + self._WINDOWS_RESERVED_FILE_NAMES
+ if self._is_posix() or self._is_macos():
+ return common_keywords + self._MACOS_RESERVED_FILE_NAMES
+
return common_keywords
def __init__(
@@ -110,7 +128,7 @@
platform: PlatformType = None,
check_reserved: bool = True,
) -> None:
- super(FileNameValidator, self).__init__(
+ super().__init__(
min_len=min_len,
max_len=max_len,
check_reserved=check_reserved,
@@ -151,20 +169,20 @@
)
def __validate_unix_filename(self, unicode_filename: str) -> None:
- match = self._RE_INVALID_FILENAME.findall(unicode_filename)
+ match = _RE_INVALID_FILENAME.findall(unicode_filename)
if match:
raise InvalidCharError(
self._ERROR_MSG_TEMPLATE.format(
- invalid=self._findall_to_str(match),
value=repr(unicode_filename)
+ invalid=findall_to_str(match), value=repr(unicode_filename)
)
)
def __validate_win_filename(self, unicode_filename: str) -> None:
- match = self._RE_INVALID_WIN_FILENAME.findall(unicode_filename)
+ match = _RE_INVALID_WIN_FILENAME.findall(unicode_filename)
if match:
raise InvalidCharError(
self._ERROR_MSG_TEMPLATE.format(
- invalid=self._findall_to_str(match),
value=repr(unicode_filename)
+ invalid=findall_to_str(match), value=repr(unicode_filename)
),
platform=Platform.WINDOWS,
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/pathvalidate/_filepath.py
new/pathvalidate-2.2.0/pathvalidate/_filepath.py
--- old/pathvalidate-2.1.0/pathvalidate/_filepath.py 2020-02-01
11:27:02.000000000 +0100
+++ new/pathvalidate-2.2.0/pathvalidate/_filepath.py 2020-02-12
09:12:46.000000000 +0100
@@ -9,11 +9,12 @@
from pathlib import Path
from typing import List, Optional, Pattern, Tuple # noqa
-from ._base import AbstractSanitizer, BaseValidator
+from ._base import AbstractSanitizer, BaseFile, BaseValidator
from ._common import (
PathType,
Platform,
PlatformType,
+ findall_to_str,
is_pathlike_obj,
preprocess,
validate_pathtype,
@@ -29,6 +30,12 @@
)
+_RE_INVALID_PATH =
re.compile("[{:s}]".format(re.escape(BaseFile._INVALID_PATH_CHARS)), re.UNICODE)
+_RE_INVALID_WIN_PATH = re.compile(
+ "[{:s}]".format(re.escape(BaseFile._INVALID_WIN_PATH_CHARS)), re.UNICODE
+)
+
+
class FilePathSanitizer(AbstractSanitizer):
def __init__(
self,
@@ -37,7 +44,7 @@
platform: PlatformType = None,
check_reserved: bool = True,
) -> None:
- super(FilePathSanitizer, self).__init__(
+ super().__init__(
min_len=min_len, max_len=max_len, check_reserved=check_reserved,
platform=platform,
)
@@ -99,9 +106,9 @@
def _get_sanitize_regexp(self) -> Pattern:
if self.platform in [Platform.UNIVERSAL, Platform.WINDOWS]:
- return self._RE_INVALID_WIN_PATH
+ return _RE_INVALID_WIN_PATH
- return self._RE_INVALID_PATH
+ return _RE_INVALID_PATH
class FilePathValidator(BaseValidator):
@@ -109,12 +116,16 @@
"|".join("^/{}$".format(re.escape(pattern)) for pattern in
_NTFS_RESERVED_FILE_NAMES),
re.IGNORECASE,
)
+ _MACOS_RESERVED_FILE_PATHS = ("/", ":")
@property
def reserved_keywords(self) -> Tuple[str, ...]:
- common_keywords = super(FilePathValidator, self).reserved_keywords
+ common_keywords = super().reserved_keywords
+
+ if any([self._is_universal(), self._is_posix(), self._is_macos()]):
+ return common_keywords + self._MACOS_RESERVED_FILE_PATHS
- if any([self._is_universal(), self._is_linux(), self._is_macos()]):
+ if self._is_linux():
return common_keywords + ("/",)
return common_keywords
@@ -126,7 +137,7 @@
platform: PlatformType = None,
check_reserved: bool = True,
) -> None:
- super(FilePathValidator, self).__init__(
+ super().__init__(
min_len=min_len, max_len=max_len, check_reserved=check_reserved,
platform=platform,
)
@@ -184,7 +195,8 @@
"an invalid absolute file path ({}) for the platform
({}).".format(
value, self.platform.value
)
- + " specify an appropriate platform or 'auto'."
+ + " to avoid the error, specify an appropriate platform
correspond"
+ + " with the path format, or 'auto'."
),
platform=self.platform,
reason=ErrorReason.MALFORMED_ABS_PATH,
@@ -201,20 +213,20 @@
raise err_object
def __validate_unix_file_path(self, unicode_file_path: str) -> None:
- match = self._RE_INVALID_PATH.findall(unicode_file_path)
+ match = _RE_INVALID_PATH.findall(unicode_file_path)
if match:
raise InvalidCharError(
self._ERROR_MSG_TEMPLATE.format(
- invalid=self._findall_to_str(match),
value=repr(unicode_file_path)
+ invalid=findall_to_str(match),
value=repr(unicode_file_path)
)
)
def __validate_win_file_path(self, unicode_file_path: str) -> None:
- match = self._RE_INVALID_WIN_PATH.findall(unicode_file_path)
+ match = _RE_INVALID_WIN_PATH.findall(unicode_file_path)
if match:
raise InvalidCharError(
self._ERROR_MSG_TEMPLATE.format(
- invalid=self._findall_to_str(match),
value=repr(unicode_file_path)
+ invalid=findall_to_str(match),
value=repr(unicode_file_path)
),
platform=Platform.WINDOWS,
)
@@ -315,7 +327,7 @@
To make a valid file path the function does:
- replace invalid characters for a file path within the ``file_path``
- with the ``replacement_text``. Invalid characters are as followings:
+ with the ``replacement_text``. Invalid characters are as follows:
- unprintable characters
- |invalid_file_path_chars|
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/pathvalidate/argparse.py
new/pathvalidate-2.2.0/pathvalidate/argparse.py
--- old/pathvalidate-2.1.0/pathvalidate/argparse.py 2020-02-01
08:44:26.000000000 +0100
+++ new/pathvalidate-2.2.0/pathvalidate/argparse.py 2020-02-12
09:04:19.000000000 +0100
@@ -27,7 +27,7 @@
return ""
try:
- validate_filepath(value)
+ validate_filepath(value, platform="auto")
except ValidationError as e:
raise ArgumentTypeError(e)
@@ -45,7 +45,7 @@
if not value:
return ""
- return sanitize_filepath(value)
+ return sanitize_filepath(value, platform="auto")
def filename(value: PathType) -> PathType: # pragma: no cover
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/pathvalidate/error.py
new/pathvalidate-2.2.0/pathvalidate/error.py
--- old/pathvalidate-2.1.0/pathvalidate/error.py 2020-01-13
03:02:39.000000000 +0100
+++ new/pathvalidate-2.2.0/pathvalidate/error.py 2020-02-05
22:45:13.000000000 +0100
@@ -46,9 +46,9 @@
self.__reusable_name = kwargs.pop("reusable_name", None)
try:
- super(ValidationError, self).__init__(*args[0], **kwargs)
+ super().__init__(*args[0], **kwargs)
except IndexError:
- super(ValidationError, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
def __str__(self) -> str:
item_list = []
@@ -79,7 +79,7 @@
def __init__(self, *args, **kwargs) -> None:
kwargs["reason"] = ErrorReason.NULL_NAME
- super(NullNameError, self).__init__(args, **kwargs)
+ super().__init__(args, **kwargs)
class InvalidCharError(ValidationError):
@@ -90,7 +90,7 @@
def __init__(self, *args, **kwargs) -> None:
kwargs["reason"] = ErrorReason.INVALID_CHARACTER
- super(InvalidCharError, self).__init__(args, **kwargs)
+ super().__init__(args, **kwargs)
class InvalidLengthError(ValidationError):
@@ -101,7 +101,7 @@
def __init__(self, *args, **kwargs) -> None:
kwargs["reason"] = ErrorReason.INVALID_LENGTH
- super(InvalidLengthError, self).__init__(args, **kwargs)
+ super().__init__(args, **kwargs)
class ReservedNameError(ValidationError):
@@ -118,7 +118,7 @@
kwargs["reason"] = ErrorReason.RESERVED_NAME
- super(ReservedNameError, self).__init__(args, **kwargs)
+ super().__init__(args, **kwargs)
class ValidReservedNameError(ReservedNameError):
@@ -130,7 +130,7 @@
def __init__(self, *args, **kwargs) -> None:
kwargs["reusable_name"] = True
- super(ValidReservedNameError, self).__init__(args, **kwargs)
+ super().__init__(args, **kwargs)
class InvalidReservedNameError(ReservedNameError):
@@ -142,4 +142,4 @@
def __init__(self, *args, **kwargs) -> None:
kwargs["reusable_name"] = False
- super(InvalidReservedNameError, self).__init__(args, **kwargs)
+ super().__init__(args, **kwargs)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/pathvalidate.egg-info/PKG-INFO
new/pathvalidate-2.2.0/pathvalidate.egg-info/PKG-INFO
--- old/pathvalidate-2.1.0/pathvalidate.egg-info/PKG-INFO 2020-02-01
11:32:39.000000000 +0100
+++ new/pathvalidate-2.2.0/pathvalidate.egg-info/PKG-INFO 2020-02-12
10:56:16.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: pathvalidate
-Version: 2.1.0
+Version: 2.2.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
@@ -170,6 +170,9 @@
usage: argparse_validate.py [-h] [--filepath FILEPATH]
[--filename FILENAME]
argparse_validate.py: error: argument --filepath: invalid char
found: invalids=('?'), value='e?g', reason=INVALID_CHARACTER,
target-platform=Windows
+ .. note::
+ ``validate_filepath_arg`` is set platform as ``"auto"``.
+
filename/filepath sanitizer for argparse
------------------------------------------
:Sample Code:
@@ -197,6 +200,9 @@
$ ./examples/argparse_sanitize.py --filename e/g
filename: eg
+ .. note::
+ ``sanitize_filepath_arg`` is set platform as ``"auto"``.
+
filename/filepath validator for click
---------------------------------------
:Sample Code:
@@ -296,7 +302,6 @@
Test dependencies
-----------------
- `pytest <https://docs.pytest.org/en/latest/>`__
- - `pytest-runner <https://github.com/pytest-dev/pytest-runner>`__
- `tox <https://testrun.org/tox/latest/>`__
Documentation
@@ -316,10 +321,14 @@
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
+Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: System :: Filesystems
Classifier: Topic :: Text Processing
Requires-Python: >=3.5
Description-Content-Type: text/x-rst
+Provides-Extra: test
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/pathvalidate.egg-info/SOURCES.txt
new/pathvalidate-2.2.0/pathvalidate.egg-info/SOURCES.txt
--- old/pathvalidate-2.1.0/pathvalidate.egg-info/SOURCES.txt 2020-02-01
11:32:39.000000000 +0100
+++ new/pathvalidate-2.2.0/pathvalidate.egg-info/SOURCES.txt 2020-02-12
10:56:16.000000000 +0100
@@ -2,7 +2,6 @@
MANIFEST.in
README.rst
pyproject.toml
-setup.cfg
setup.py
tox.ini
docs/pages/introduction/summary.txt
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pathvalidate-2.1.0/pathvalidate.egg-info/requires.txt
new/pathvalidate-2.2.0/pathvalidate.egg-info/requires.txt
--- old/pathvalidate-2.1.0/pathvalidate.egg-info/requires.txt 2020-02-01
11:32:39.000000000 +0100
+++ new/pathvalidate-2.2.0/pathvalidate.egg-info/requires.txt 2020-02-12
10:56:16.000000000 +0100
@@ -1 +1,6 @@
-setuptools>=38.3.0
+
+[test]
+allpairspy
+click
+faker
+pytest
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/pyproject.toml
new/pathvalidate-2.2.0/pyproject.toml
--- old/pathvalidate-2.1.0/pyproject.toml 2020-01-11 10:36:10.000000000
+0100
+++ new/pathvalidate-2.2.0/pyproject.toml 2020-02-12 08:12:31.000000000
+0100
@@ -17,12 +17,13 @@
'''
[tool.isort]
-dont_skip = "*/**/__init__.py"
+dont_skip = '*/**/__init__.py'
known_third_party = [
- "path",
- "pytest",
- "readmemaker",
- "sphinx_rtd_theme",
+ 'allpairspy',
+ 'path',
+ 'pytest',
+ 'readmemaker',
+ 'sphinx_rtd_theme',
]
include_trailing_comma = true
line_length = 100
@@ -35,7 +36,7 @@
]
[tool.coverage.run]
-source = ["pathvalidate"]
+source = ['pathvalidate']
branch = true
[tool.coverage.report]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pathvalidate-2.1.0/requirements/test_requirements.txt
new/pathvalidate-2.2.0/requirements/test_requirements.txt
--- old/pathvalidate-2.1.0/requirements/test_requirements.txt 2020-01-11
04:37:45.000000000 +0100
+++ new/pathvalidate-2.2.0/requirements/test_requirements.txt 2020-02-12
06:39:38.000000000 +0100
@@ -1,3 +1,4 @@
+allpairspy
click
faker
pytest
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/setup.cfg
new/pathvalidate-2.2.0/setup.cfg
--- old/pathvalidate-2.1.0/setup.cfg 2020-02-01 11:32:39.472019000 +0100
+++ new/pathvalidate-2.2.0/setup.cfg 2020-02-12 10:56:16.420759700 +0100
@@ -1,6 +1,3 @@
-[aliases]
-test = pytest
-
[egg_info]
tag_build =
tag_date = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/setup.py
new/pathvalidate-2.2.0/setup.py
--- old/pathvalidate-2.1.0/setup.py 2020-02-01 02:17:27.000000000 +0100
+++ new/pathvalidate-2.2.0/setup.py 2020-02-11 08:48:34.000000000 +0100
@@ -3,7 +3,6 @@
"""
import os.path
-import sys
from typing import Dict, List # noqa
import setuptools
@@ -17,14 +16,7 @@
pkg_info = {} # type: Dict[str, str]
-def pytest_runner_requires() -> List[str]:
- if set(["pytest", "test", "ptr"]).intersection(sys.argv):
- return ["pytest-runner"]
-
- return []
-
-
-def get_release_command_class():
+def get_release_command_class() -> Dict[str, setuptools.Command]:
try:
from releasecmd import ReleaseCommand
except ImportError:
@@ -42,9 +34,6 @@
with open(os.path.join("docs", "pages", "introduction", "summary.txt"),
encoding=ENCODING) as f:
summary = f.read().strip()
-with open(os.path.join(REQUIREMENT_DIR, "requirements.txt")) as f:
- install_requires = [line.strip() for line in f if line.strip()]
-
with open(os.path.join(REQUIREMENT_DIR, "test_requirements.txt")) as f:
TESTS_REQUIRES = [line.strip() for line in f if line.strip()]
@@ -70,9 +59,7 @@
"Tracker": "{:s}/issues".format(REPOSITORY_URL),
},
python_requires=">=3.5",
- install_requires=SETUPTOOLS_REQUIRES + install_requires,
- setup_requires=SETUPTOOLS_REQUIRES + pytest_runner_requires(),
- tests_require=TESTS_REQUIRES,
+ extras_require={"test": TESTS_REQUIRES},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
@@ -84,10 +71,13 @@
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
+ "Topic :: System :: Filesystems",
"Topic :: Text Processing",
],
cmdclass=get_release_command_class(),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/test/test_argparse.py
new/pathvalidate-2.2.0/test/test_argparse.py
--- old/pathvalidate-2.1.0/test/test_argparse.py 2020-01-11
10:35:48.000000000 +0100
+++ new/pathvalidate-2.2.0/test/test_argparse.py 2020-02-12
09:27:33.000000000 +0100
@@ -1,3 +1,4 @@
+import platform
from argparse import ArgumentError, ArgumentParser
import pytest
@@ -39,8 +40,22 @@
assert parser.parse_args([value]).filepath == value
- @pytest.mark.parametrize(["value"], [["foo/a?c"], ["COM1"], ["a" * 8000]])
- def test_exception(self, value):
+ @pytest.mark.skipif(platform.system() == "Windows", reason="platform
dependent tests")
+ @pytest.mark.parametrize(["value"], [["a" * 8000]])
+ def test_exception_posix(self, value):
+ parser = ArgumentParser()
+ parser.add_argument("filepath", type=validate_filepath_arg)
+
+ try:
+ parser.parse_args([value])
+ except SystemExit as e:
+ assert isinstance(e.__context__, ArgumentError)
+ else:
+ raise RuntimeError()
+
+ @pytest.mark.skipif(platform.system() != "Windows", reason="platform
dependent tests")
+ @pytest.mark.parametrize(["value"], [["foo/a?c"], ["COM1"]])
+ def test_exception_windows(self, value):
parser = ArgumentParser()
parser.add_argument("filepath", type=validate_filepath_arg)
@@ -71,6 +86,7 @@
class Test_sanitize_filepath_arg:
+ @pytest.mark.skipif(platform.system() == "Windows", reason="platform
dependent tests")
@pytest.mark.parametrize(
["value", "expected"],
[
@@ -78,11 +94,28 @@
["abc", "abc"],
["abc.txt", "abc.txt"],
["foo/abc", "foo/abc"],
+ ["a?c", "a?c"],
+ ["COM1", "COM1"],
+ ],
+ )
+ def test_normal_posix(self, value, expected):
+ parser = ArgumentParser()
+ parser.add_argument("filepath", type=sanitize_filepath_arg)
+ assert parser.parse_args([value]).filepath == expected
+
+ @pytest.mark.skipif(platform.system() != "Windows", reason="platform
dependent tests")
+ @pytest.mark.parametrize(
+ ["value", "expected"],
+ [
+ ["", ""],
+ ["abc", "abc"],
+ ["abc.txt", "abc.txt"],
+ ["foo/abc", "foo\\abc"],
["a?c", "ac"],
["COM1", "COM1_"],
],
)
- def test_normal(self, value, expected):
+ def test_normal_windows(self, value, expected):
parser = ArgumentParser()
parser.add_argument("filepath", type=sanitize_filepath_arg)
assert parser.parse_args([value]).filepath == expected
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/test/test_filename.py
new/pathvalidate-2.2.0/test/test_filename.py
--- old/pathvalidate-2.1.0/test/test_filename.py 2020-02-01
11:01:04.000000000 +0100
+++ new/pathvalidate-2.2.0/test/test_filename.py 2020-02-12
06:47:39.000000000 +0100
@@ -5,10 +5,12 @@
import platform as m_platform # noqa: W0611
import random
import sys # noqa: W0611
+from collections import OrderedDict
from itertools import chain, product
from pathlib import Path
import pytest
+from allpairspy import AllPairs
from pathvalidate import (
ErrorReason,
@@ -99,7 +101,7 @@
),
],
["linux", (".", "..")],
- ["macos", (".", "..")],
+ ["macos", (".", "..", ":")],
],
)
def test_normal_reserved_keywords(self, test_platform, expected):
@@ -261,8 +263,9 @@
]
+ [
[reserved_keyword, platform, ReservedNameError]
- for reserved_keyword, platform in product([".", ".."], ["linux",
"macos"])
- ],
+ for reserved_keyword, platform in product([".", ".."], ["posix",
"linux", "macos"])
+ ]
+ + [[":", "posix", ReservedNameError], [":", "macos",
ReservedNameError],],
)
def test_exception_reserved_name(self, value, platform, expected):
with pytest.raises(expected) as e:
@@ -340,14 +343,28 @@
for c, rep in product(NOT_SANITIZE_CHARS, REPLACE_TEXT_LIST)
]
+ [
- ["linux", "A" + c + "B", rep, "A" + rep + "B"]
- for c, rep in product(
- INVALID_FILENAME_CHARS + unprintable_ascii_chars,
REPLACE_TEXT_LIST
+ [pair.platform, "A" + pair.c + "B", pair.repl, "A" + pair.repl +
"B"]
+ for pair in AllPairs(
+ OrderedDict(
+ {
+ "platform": ["posix", "linux", "macos"],
+ "c": INVALID_PATH_CHARS + unprintable_ascii_chars,
+ "repl": REPLACE_TEXT_LIST,
+ }
+ )
)
]
+ [
- ["linux", "A" + c + "B", rep, "A" + c + "B"]
- for c, rep in product([":", "*", "?", '"', "<", ">", "|"],
REPLACE_TEXT_LIST)
+ [pair.platform, "A" + pair.c + "B", pair.repl, "A" + pair.c + "B"]
+ for pair in AllPairs(
+ OrderedDict(
+ {
+ "platform": ["posix", "linux", "macos"],
+ "c": [":", "*", "?", '"', "<", ">", "|"],
+ "repl": REPLACE_TEXT_LIST,
+ }
+ )
+ )
],
)
def test_normal_str(self, platform, value, replace_text, expected):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/test/test_filepath.py
new/pathvalidate-2.2.0/test/test_filepath.py
--- old/pathvalidate-2.1.0/test/test_filepath.py 2020-02-01
11:06:01.000000000 +0100
+++ new/pathvalidate-2.2.0/test/test_filepath.py 2020-02-12
07:32:04.000000000 +0100
@@ -2,13 +2,14 @@
.. codeauthor:: Tsuyoshi Hombashi <[email protected]>
"""
-import platform as m_platform # noqa: W0611
+import platform as m_platform
import random
-import sys # noqa: W0611
+from collections import OrderedDict
from itertools import chain, product
from pathlib import Path
import pytest
+from allpairspy import AllPairs
from pathvalidate import (
ErrorReason,
@@ -62,7 +63,12 @@
@pytest.mark.parametrize(
["test_platform", "expected"],
- [["windows", (".", "..",),], ["linux", (".", "..", "/")], ["macos",
(".", "..", "/")]],
+ [
+ ["windows", (".", "..",),],
+ ["posix", (".", "..", "/", ":")],
+ ["linux", (".", "..", "/")],
+ ["macos", (".", "..", "/", ":")],
+ ],
)
def test_normal_reserved_keywords(self, test_platform, expected):
assert FilePathValidator(255,
platform=test_platform).reserved_keywords == expected
@@ -75,9 +81,9 @@
"D:\\新しいフォルダー\\ユーザ属性.txt",
]
WIN_VALID_PATH_LIST = [
-
"D:\\Users\\\est\\AppData\\Local\\Temp\\pytest-of-test\\pytest-0\\\hoge.csv",
+
"D:\\Users\\\\est\\AppData\\Local\\Temp\\pytest-of-test\\pytest-0\\\\hoge.csv",
"D:/Users/test/AppData/Local/Temp/pytest-of-test/pytest-0/test_exception__hoge_csv_heade1/hoge.csv",
# noqa
-
"C:\\Users\\est\\AppData/Local\\Temp/pytest-of-test\\pytest-0/\hoge.csv",
+
"C:\\Users\\est\\AppData/Local\\Temp/pytest-of-test\\pytest-0/\\hoge.csv",
"C:\\Users",
"C:\\",
"\\Users",
@@ -141,6 +147,8 @@
[
["a" * 4096, "linux", None, None],
["a" * 4097, "linux", None, InvalidLengthError],
+ ["a" * 1024, "posix", None, None],
+ ["a" * 1025, "posix", None, InvalidLengthError],
["a" * 4097, Platform.LINUX, None, InvalidLengthError],
["a" * 255, "linux", 100, InvalidLengthError],
["a" * 5000, "windows", 10000, ValidationError],
@@ -201,7 +209,7 @@
with pytest.raises(expected):
validate_filepath(value, platform=test_platform)
- @pytest.mark.skipif("m_platform.system() != 'Windows'")
+ @pytest.mark.skipif(m_platform.system() != "Windows", reason="platform
dependent tests")
@pytest.mark.parametrize(
["value", "expected"], [["/a/b/c.txt", ValidationError],
["C:\\a\\b\\c.txt", None],],
)
@@ -213,7 +221,7 @@
with pytest.raises(expected):
validate_filepath(value, platform="auto")
- @pytest.mark.skipif("m_platform.system() != 'Linux'")
+ @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],],
)
@@ -395,7 +403,7 @@
@pytest.mark.parametrize(
["value"],
[
-
["C:\\Users\\est\\AppData\\Local\\Temp\\pytest-of-test\\pytest-0\\\hoge.csv"],
+
["C:\\Users\\est\\AppData\\Local\\Temp\\pytest-of-test\\pytest-0\\\\hoge.csv"],
["Z:\\Users\\est\\AppData\\Local\\Temp\\pytest-of-test\\pytest-0\\hoge.csv"],
[
"C:/Users/est/AppData/Local/Temp/pytest-of-test/pytest-0/test_exception__hoge_csv_heade1/hoge.csv"
# noqa
@@ -440,12 +448,28 @@
for c, rep in product(NOT_SANITIZE_CHARS, REPLACE_TEXT_LIST)
]
+ [
- ["linux", "A" + c + "B", rep, "A" + rep + "B"]
- for c, rep in product(INVALID_PATH_CHARS +
unprintable_ascii_chars, REPLACE_TEXT_LIST)
+ [pair.platform, "A" + pair.c + "B", pair.repl, "A" + pair.repl +
"B"]
+ for pair in AllPairs(
+ OrderedDict(
+ {
+ "platform": ["posix", "linux", "macos"],
+ "c": INVALID_PATH_CHARS + unprintable_ascii_chars,
+ "repl": REPLACE_TEXT_LIST,
+ }
+ )
+ )
]
+ [
- ["linux", "A" + c + "B", rep, "A" + c + "B"]
- for c, rep in product([":", "*", "?", '"', "<", ">", "|"],
REPLACE_TEXT_LIST)
+ [pair.platform, "A" + pair.c + "B", pair.repl, "A" + pair.c + "B"]
+ for pair in AllPairs(
+ OrderedDict(
+ {
+ "platform": ["posix", "linux", "macos"],
+ "c": [":", "*", "?", '"', "<", ">", "|"],
+ "repl": REPLACE_TEXT_LIST,
+ }
+ )
+ )
],
)
def test_normal_str(self, platform, value, replace_text, expected):
@@ -566,7 +590,7 @@
validate_filepath(sanitized_name, platform=test_platform)
assert is_valid_filepath(sanitized_name, platform=test_platform)
- @pytest.mark.skipif("m_platform.system() != 'Windows'")
+ @pytest.mark.skipif(m_platform.system() != "Windows", reason="platform
dependent tests")
@pytest.mark.parametrize(
["value", "expected"],
[["/a/b/c.txt", ValidationError], ["C:\\a\\b|c.txt",
"C:\\a\\bc.txt"],],
@@ -579,7 +603,7 @@
with pytest.raises(expected):
sanitize_filepath(value, platform="auto")
- @pytest.mark.skipif("m_platform.system() != 'Linux'")
+ @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],],
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pathvalidate-2.1.0/tox.ini
new/pathvalidate-2.2.0/tox.ini
--- old/pathvalidate-2.1.0/tox.ini 2020-02-01 10:07:23.000000000 +0100
+++ new/pathvalidate-2.2.0/tox.ini 2020-02-12 10:53:53.000000000 +0100
@@ -3,6 +3,7 @@
py{35,36,37,38,39}
pypy3
build
+ clean
cov
docs
fmt
@@ -11,8 +12,15 @@
release
[testenv]
+deps =
+ .[test]
+ coverage[toml]
+ pytest-cov
commands =
- python setup.py test
+ pytest {posargs}
+
+
+# pytest --cov --cov-append {posargs}
[testenv:build]
basepython = python3.8
@@ -24,13 +32,20 @@
twine check dist/*
python setup.py clean --all
+[testenv:clean]
+basepython = python3.8
+deps =
+ cleanpy
+commands =
+ cleanpy --all .
+
[testenv:cov]
-basepython = python3.7
deps =
+ .[test]
coverage[toml]
pytest-cov
commands =
- python setup.py test --addopts "-v --cov"
+ pytest --cov {posargs:-vv}
[testenv:docs]
basepython = python3.8
@@ -46,12 +61,12 @@
black
isort
commands =
- black setup.py test pathvalidate
autoflake --in-place --recursive --remove-all-unused-imports
--ignore-init-module-imports --exclude ".pytype" .
isort --apply --recursive
+ black setup.py test pathvalidate
[testenv:lint]
-basepython = python3.5
+basepython = python3.7
deps =
codespell
mypy>=0.761
@@ -60,8 +75,8 @@
commands =
python setup.py check
mypy pathvalidate --show-error-context --show-error-codes --python-version
3.5
- pytype pathvalidate
- codespell pathvalidate docs examples test -q2 --check-filenames
--ignore-words-list followings
+ pytype --keep-going --jobs 2 --disable import-error pathvalidate
+ codespell pathvalidate docs examples test -q2 --check-filenames
pylama
[testenv:readme]
@@ -77,4 +92,4 @@
deps =
releasecmd>=0.2.0
commands =
- python setup.py release --sign
+ python setup.py release --sign {posargs}