This project follows PEP 440 and Semantic Versioning (SemVer). In addition to the guarantees specified by SemVer, for versions before 1.0, this project guarantees backwards compatibility of the API for patch version updates (0.y.z).
The recommended version specifier is generic-path ~= x.y
for version 1.0 and later, and generic-path ~= 0.y.z
for versions prior to 1.0.
- Improved documentation
- Added the ability to force GPath to interpret a path string as originating from a specific operating system, which prevents problems in edge cases, using the new
platform
argument inGPath.__init__()
; this also propagates to new GPaths returned by operations- Added the read-only property
g.platform
for this propagating platform parameter - Added static methods
from_posix()
,from_windows()
(and aliasesfrom_linux()
andfrom_macos()
) as alternative interfaces to call the constructor for a specific platform - Added submodule
gpath.platform
with aPlatform
enum for specifying platforms (either as a string given ingpath.platform.platform_names
or as agpath.Platform
object)
- Added the read-only property
- Added
g.render()
, which returns aRenderedPath
object for printing and sorting in a platform-specific manner- Added submodule
gpath.render
containing subclasses ofRenderedPath
that define the render behaviour for each platform - GenericRenderedPath resembles the previous behaviour of GPath, and prints with forward slashes
/
- PosixRenderedPath ignores drive names when sorting and printing, and always prints with forward slashes
/
- WindowsRenderedPath always prints with backslashes
\
- Added submodule
- Fixed bug with encoding propagation in the copy constructor
- Fixed support for bytes in older versions of Python
- Fixed documentation and readme
- Replaced the following instance methods with read-only properties:
g.get_parent_level()
→g.parent_level
g.get_parent_parts()
→g.parent_parts
g.get_device()
→g.drive
(renameddevice
todrive
)g.is_absolute()
→g.absolute
g.is_root()
→g.root
- Replaced
g.get_parts()
andg.from_parts()
with the read-only propertiesg.named_parts
andg.relative_parts
- Replaced
GPath.find_common()
withg.common_with()
and addedg1 & g2
as an alias forg.common_with()
with default options - Removed the ability to sort GPaths, and removed the following comparison operators:
g1 < g2
g1 <= g2
g1 > g2
g1 >= g2
- Removed package constants
PATH_SEPARATOR
,PATH_CURRENT
,PATH_PARENT
, and typedefPathLike
- Changed
g1 + g2
,g1 / g2
andg.join()
so that appending an absolute path overwrites the left operand; previously the left operand would be returned unchanged - Changed
g1 == g2
so that it can return True even when the left operand is GPath-like but not a GPath object
- Added
g.as_absolute()
,g.as_relative()
,g.with_drive()
,g.without_drive()
for returning modified copies of the path - Added support for drive names in relative paths
- Added support for instantiating a GPath with a bytes-like object,
GPath(byteslike)
(or, fixed the constructor that was previously broken for bytes-like objects) - Added an argument to
GPath.__init__()
to allow specifying encoding (default'utf-8'
), which propagates to new GPaths when performing operations with other bytes-like operands - Added the read-only property
g.encoding
for this propagating encoding - Added abstract base classes for GPath, from
collections.abc
- Fixed
g1 / g2
- Fixed small errors in web documentation
- Renamed
GPath.current
toGPath.current_dir
andGPath.parent
toGPath.parent_dir
- Renamed
g.is_root()
tog.is_absolute()
- Renamed the optional arguments in
g.find_common()
andg.partition()
, fromcommon_current
andcommon_parent
toallow_current
andallow_parent
- Added a new
g.is_root()
that checks whether the path is exactly root - Added
g.__div__()
as an alias ofg.__add__()
- Added web documentation at https://gpath.gnayihs.uy/
- Fixed basic example in README
- Added support for Python versions 3.7 through 3.9; previously only 3.10 and 3.11 were supported
- Initial version