Skip to content

Commit

Permalink
Merge c150da2 into 9672cfd
Browse files Browse the repository at this point in the history
  • Loading branch information
arcivanov committed Feb 25, 2023
2 parents 9672cfd + c150da2 commit ffffa9c
Show file tree
Hide file tree
Showing 139 changed files with 6,534 additions and 12,992 deletions.
2 changes: 1 addition & 1 deletion build.py
Expand Up @@ -122,7 +122,7 @@ def initialize(project):
"setup"])

project.set_property("flake8_break_build", True)
project.set_property("flake8_extend_ignore", "E303")
project.set_property("flake8_extend_ignore", "E303, F401")
project.set_property("flake8_include_test_sources", True)
project.set_property("flake8_include_scripts", True)
project.set_property("flake8_exclude_patterns", ",".join([
Expand Down
60 changes: 4 additions & 56 deletions src/main/python/pybuilder/_vendor/LICENSES
Expand Up @@ -204,59 +204,7 @@ importlib_metadata-4.13.0
limitations under the License.


virtualenv-20.16.6
==========
Copyright (c) 2020-202x The virtualenv developers

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


filelock-3.8.0
==========
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org>


importlib_resources-5.10.0
importlib_resources-5.12.0
==========

Apache License
Expand Down Expand Up @@ -462,7 +410,7 @@ importlib_resources-5.10.0
limitations under the License.


setuptools-65.5.0
setuptools-67.4.0
==========
Copyright Jason R. Coombs

Expand Down Expand Up @@ -509,7 +457,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


zipp-3.10.0
zipp-3.14.0
==========
Copyright Jason R. Coombs

Expand Down Expand Up @@ -841,7 +789,7 @@ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

typing_extensions-4.4.0
typing_extensions-4.5.0
==========
A. HISTORY OF THE SOFTWARE
==========================
Expand Down
6 changes: 5 additions & 1 deletion src/main/python/pybuilder/_vendor/filelock/__init__.py
Expand Up @@ -9,6 +9,7 @@

import sys
import warnings
from typing import TYPE_CHECKING

from ._api import AcquireReturnProxy, BaseFileLock
from ._error import Timeout
Expand All @@ -33,7 +34,10 @@

#: Alias for the lock, which should be used for the current platform. On Windows, this is an alias for
# :class:`WindowsFileLock`, on Unix for :class:`UnixFileLock` and otherwise for :class:`SoftFileLock`.
FileLock: type[BaseFileLock] = _FileLock
if TYPE_CHECKING:
FileLock = SoftFileLock
else:
FileLock = _FileLock


__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion src/main/python/pybuilder/_vendor/filelock/_api.py
Expand Up @@ -56,7 +56,7 @@ def __init__(self, lock_file: str | os.PathLike[Any], timeout: float = -1) -> No
self._lock_file_fd: int | None = None

# The default timeout value.
self.timeout: float = timeout
self._timeout: float = timeout

# We use this lock primarily for the lock counter.
self._thread_lock: Lock = Lock()
Expand Down
5 changes: 2 additions & 3 deletions src/main/python/pybuilder/_vendor/filelock/version.py
@@ -1,5 +1,4 @@
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = '3.8.0'
__version_tuple__ = version_tuple = (3, 8, 0)
__version__ = version = '3.9.0'
__version_tuple__ = version_tuple = (3, 9, 0)
Expand Up @@ -34,9 +34,7 @@ def _io_wrapper(file, mode='r', *args, **kwargs):
return TextIOWrapper(file, *args, **kwargs)
elif mode == 'rb':
return file
raise ValueError(
"Invalid mode value '{}', only 'r' and 'rb' are supported".format(mode)
)
raise ValueError(f"Invalid mode value '{mode}', only 'r' and 'rb' are supported")


class CompatibilityFiles:
Expand Down
Expand Up @@ -203,5 +203,5 @@ def _write_contents(target, source):
for item in source.iterdir():
_write_contents(child, item)
else:
child.open('wb').write(source.read_bytes())
child.write_bytes(source.read_bytes())
return child
Expand Up @@ -72,9 +72,6 @@ def _file_reader(spec):
return readers.FileReader(self)

return (
# native reader if it supplies 'files'
_native_reader(self.spec)
or
# local ZipReader if a zip module
_zip_reader(self.spec)
or
Expand All @@ -83,8 +80,12 @@ def _file_reader(spec):
or
# local FileReader
_file_reader(self.spec)
or
# native reader if it supplies 'files'
_native_reader(self.spec)
or
# fallback - adapt the spec ResourceReader to TraversableReader
or _adapters.CompatibilityFiles(self.spec)
_adapters.CompatibilityFiles(self.spec)
)


Expand Down
69 changes: 36 additions & 33 deletions src/main/python/pybuilder/_vendor/importlib_resources/_itertools.py
@@ -1,35 +1,38 @@
from itertools import filterfalse
# from more_itertools 9.0
def only(iterable, default=None, too_long=None):
"""If *iterable* has only one item, return it.
If it has zero items, return *default*.
If it has more than one item, raise the exception given by *too_long*,
which is ``ValueError`` by default.
>>> only([], default='missing')
'missing'
>>> only([1])
1
>>> only([1, 2]) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError: Expected exactly one item in iterable, but got 1, 2,
and perhaps more.'
>>> only([1, 2], too_long=TypeError) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
TypeError
Note that :func:`only` attempts to advance *iterable* twice to ensure there
is only one item. See :func:`spy` or :func:`peekable` to check
iterable contents less destructively.
"""
it = iter(iterable)
first_value = next(it, default)

from typing import (
Callable,
Iterable,
Iterator,
Optional,
Set,
TypeVar,
Union,
)

# Type and type variable definitions
_T = TypeVar('_T')
_U = TypeVar('_U')


def unique_everseen(
iterable: Iterable[_T], key: Optional[Callable[[_T], _U]] = None
) -> Iterator[_T]:
"List unique elements, preserving order. Remember all elements ever seen."
# unique_everseen('AAAABBBCCDAABBB') --> A B C D
# unique_everseen('ABBCcAD', str.lower) --> A B C D
seen: Set[Union[_T, _U]] = set()
seen_add = seen.add
if key is None:
for element in filterfalse(seen.__contains__, iterable):
seen_add(element)
yield element
try:
second_value = next(it)
except StopIteration:
pass
else:
for element in iterable:
k = key(element)
if k not in seen:
seen_add(k)
yield element
msg = (
'Expected exactly one item in iterable, but got {!r}, {!r}, '
'and perhaps more.'.format(first_value, second_value)
)
raise too_long or ValueError(msg)

return first_value
34 changes: 29 additions & 5 deletions src/main/python/pybuilder/_vendor/importlib_resources/readers.py
@@ -1,10 +1,11 @@
import collections
import itertools
import pathlib
import operator

from . import abc

from ._itertools import unique_everseen
from ._itertools import only
from ._compat import ZipPath


Expand Down Expand Up @@ -41,8 +42,10 @@ def open_resource(self, resource):
raise FileNotFoundError(exc.args[0])

def is_resource(self, path):
# workaround for `zipfile.Path.is_file` returning true
# for non-existent paths.
"""
Workaround for `zipfile.Path.is_file` returning true
for non-existent paths.
"""
target = self.files().joinpath(path)
return target.is_file() and target.exists()

Expand All @@ -67,8 +70,10 @@ def __init__(self, *paths):
raise NotADirectoryError('MultiplexedPath only supports directories')

def iterdir(self):
files = (file for path in self._paths for file in path.iterdir())
return unique_everseen(files, key=operator.attrgetter('name'))
children = (child for path in self._paths for child in path.iterdir())
by_name = operator.attrgetter('name')
groups = itertools.groupby(sorted(children, key=by_name), key=by_name)
return map(self._follow, (locs for name, locs in groups))

def read_bytes(self):
raise FileNotFoundError(f'{self} is not a file')
Expand All @@ -90,6 +95,25 @@ def joinpath(self, *descendants):
# Just return something that will not exist.
return self._paths[0].joinpath(*descendants)

@classmethod
def _follow(cls, children):
"""
Construct a MultiplexedPath if needed.
If children contains a sole element, return it.
Otherwise, return a MultiplexedPath of the items.
Unless one of the items is not a Directory, then return the first.
"""
subdirs, one_dir, one_file = itertools.tee(children, 3)

try:
return only(one_dir)
except ValueError:
try:
return cls(*subdirs)
except NotADirectoryError:
return next(one_file)

def open(self, *args, **kwargs):
raise FileNotFoundError(f'{self} is not a file')

Expand Down
@@ -1,12 +1,16 @@
import pathlib
import functools

from typing import Dict, Union


####
# from jaraco.path 3.4
# from jaraco.path 3.4.1

FilesSpec = Dict[str, Union[str, bytes, 'FilesSpec']] # type: ignore


def build(spec, prefix=pathlib.Path()):
def build(spec: FilesSpec, prefix=pathlib.Path()):
"""
Build a set of files/directories, as described by the spec.
Expand All @@ -23,15 +27,17 @@ def build(spec, prefix=pathlib.Path()):
... "baz.py": "# Some code",
... }
... }
>>> tmpdir = getfixture('tmpdir')
>>> build(spec, tmpdir)
>>> target = getfixture('tmp_path')
>>> build(spec, target)
>>> target.joinpath('foo/baz.py').read_text(encoding='utf-8')
'# Some code'
"""
for name, contents in spec.items():
create(contents, pathlib.Path(prefix) / name)


@functools.singledispatch
def create(content, path):
def create(content: Union[str, bytes, FilesSpec], path):
path.mkdir(exist_ok=True)
build(content, prefix=path) # type: ignore

Expand All @@ -43,7 +49,7 @@ def _(content: bytes, path):

@create.register
def _(content: str, path):
path.write_text(content)
path.write_text(content, encoding='utf-8')


# end from jaraco.path
Expand Down
@@ -0,0 +1 @@
a resource
Expand Up @@ -64,11 +64,13 @@ def test_orphan_path_name(self):

def test_spec_path_open(self):
self.assertEqual(self.files.read_bytes(), b'Hello, world!')
self.assertEqual(self.files.read_text(), 'Hello, world!')
self.assertEqual(self.files.read_text(encoding='utf-8'), 'Hello, world!')

def test_child_path_open(self):
self.assertEqual((self.files / 'a').read_bytes(), b'Hello, world!')
self.assertEqual((self.files / 'a').read_text(), 'Hello, world!')
self.assertEqual(
(self.files / 'a').read_text(encoding='utf-8'), 'Hello, world!'
)

def test_orphan_path_open(self):
with self.assertRaises(FileNotFoundError):
Expand Down

0 comments on commit ffffa9c

Please sign in to comment.