History¶
10.6¶
11 Feb 2018
Renamed
namebase
tostem
to match API of pathlib. Keptnamebase
as a deprecated alias for compatibility.Added new
with_suffix
method, useful for renaming the extension on a Path:orig = Path('mydir/mypath.bat') renamed = orig.rename(orig.with_suffix('.cmd'))
10.3.1¶
17 Apr 2017
- #124: Fixed
rmdir_p
raisingFileNotFoundError
when directory does not exist on Windows.
10.3¶
16 Apr 2017
#115: Added a new performance-optimized implementation for listdir operations, optimizing
listdir
,walk
,walkfiles
,walkdirs
, andfnmatch
, presented as theFastPath
class.Please direct feedback on this implementation to the ticket, especially if the performance benefits justify it replacing the default
Path
class.
10.2¶
16 Apr 2017
- Symlink no longer requires the
newlink
parameter and will default to the basename of the target in the current working directory.
9.1¶
02 Jan 2017
9.0¶
19 Nov 2016
- Drop support for Python 2.6 and 3.2 as integration dependencies (pip) no longer support these versions.
8.3¶
19 Nov 2016
- Merge with latest skeleton, adding badges and test runs by default under tox instead of pytest-runner.
- Documentation is no longer hosted with PyPI.
8.2¶
08 Apr 2016
- Refreshed project metadata based on `jaraco’s project skeleton <https://github.com/jaraco/skeleton/tree/spaces>_.
- Releases are now automatically published via Travis-CI.
- #111: More aggressively trap errors when importing
pkg_resources
.
8.1.2¶
04 Oct 2015
- #105: By using unicode literals, avoid errors rendering the backslash in __get_owner_windows.
8.0¶
27 Aug 2015
Removed path.path
. Clients must now refer to the canonical
name, path.Path
as introduced in 6.2.
7.7¶
23 Aug 2015
#88: Added support for resolving certain directories on a system to platform-friendly locations using the appdirs library. The
Path.special
method returns anSpecialResolver
instance that will resolve a path in a scope (i.e. ‘site’ or ‘user’) and class (i.e. ‘config’, ‘cache’, ‘data’). For example, to create a config directory for “My App”:config_dir = Path.special("My App").user.config.makedirs_p()
config_dir
will exist in a user context and will be in a suitable platform-friendly location.As
path.py
does not currently have any dependencies, and to retain that expectation for a compatible upgrade path,appdirs
must be installed to avoid an ImportError when invokingspecial
.#88: In order to support “multipath” results, where multiple paths are returned in a single,
os.pathsep
-separated string, a new class MultiPath now represents those special results. This functionality is experimental and may change. Feedback is invited.
7.6¶
09 Aug 2015
- Pull Request #100: Add
merge_tree
method for merging two existing directory trees. - Uses setuptools_scm for version management.
7.4¶
12 Jul 2015
7.2¶
29 Jan 2015
- In chmod, added support for multiple symbolic masks (separated by commas).
- In chmod, fixed issue in setting of symbolic mask with ‘=’ where unreferenced permissions were cleared.
7.0¶
05 Oct 2014
- The
open
method now usesio.open
and supports all of the parameters to that function.open
will always raise anOSError
on failure, even on Python 2.- Updated
write_text
to support additional newline patterns.- The
text
method now always returns text (never bytes), and thus requires an encoding parameter be supplied if the default encoding is not sufficient to decode the content of the file.
6.0¶
22 Sep 2014
- Drop support for Python 2.5. Python 2.6 or later required.
- Installation now requires setuptools.
5.2¶
12 Jun 2014
- #61: path.listdir now decodes filenames from os.listdir when loading characters from a file. On Python 3, the behavior is unchanged. On Python 2, the behavior will now mimick that of Python 3, attempting to decode all filenames and paths using the encoding indicated by
sys.getfilesystemencoding()
, and escaping any undecodable characters using the ‘surrogateescape’ handler.
5.0¶
08 Nov 2013
path.fnmatch
now takes an optional parameternormcase
and this parameter defaults to self.module.normcase (using case normalization most pertinent to the path object itself). Note that this change means that any paths using a custom ntpath module on non-Windows systems will have different fnmatch behavior. Before:# on Unix >>> p = path('Foo') >>> p.module = ntpath >>> p.fnmatch('foo') FalseAfter:
# on any OS >>> p = path('Foo') >>> p.module = ntpath >>> p.fnmatch('foo') TrueTo maintain the original behavior, either don’t define the ‘module’ for the path or supply explicit normcase function:
>>> p.fnmatch('foo', normcase=os.path.normcase) # result always varies based on OS, same as fnmatch.fnmatchFor most use-cases, the default behavior should remain the same.
Issue #50: Methods that accept patterns (
listdir
,files
,dirs
,walk
,walkdirs
,walkfiles
, andfnmatch
) will now use anormcase
attribute if it is present on thepattern
parameter. The path module now provides aCaseInsensitivePattern
wrapper for strings suitable for creating case-insensitive patterns for those methods.
4.4¶
27 Oct 2013
- Issue #44: _hash method would open files in text mode, producing invalid results on Windows. Now files are opened in binary mode, producing consistent results.
- Issue #47: Documentation is dramatically improved with Intersphinx links to the Python os.path functions and documentation for all methods and properties.
4.2¶
02 Jul 2013
open()
now passes all positional and keyword arguments through to the underlyingbuiltins.open
call.
4.0¶
26 May 2013
- Added a
chunks()
method to a allow quick iteration over pieces of a file at a given path.- Issue #28: Fix missing argument to
samefile
.- Initializer no longer enforces isinstance basestring for the source object. Now any object that supplies
__unicode__
can be used by apath
(except None). Clients that depend on a ValueError being raised forint
and other non-string objects should trap these types internally.- Issue #30:
chown
no longer requires both uid and gid to be provided and will not mutate the ownership if nothing is provided.
3.1¶
15 Apr 2013
- Issue #20: relpath now supports a “start” parameter to match the signature of os.path.relpath.
2.6¶
15 Jan 2013
Issue #5: Implemented path.tempdir, which returns a path object which is a temporary directory and context manager for cleaning up the directory.
Issue #12: One can now construct path objects from a list of strings by simply using path.joinpath. For example:
path.joinpath('a', 'b', 'c') # or path.joinpath(*path_elements)