File: _path.py

package info (click to toggle)
python-parse-type 0.6.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 772 kB
  • sloc: python: 5,273; sh: 9; makefile: 6
file content (32 lines) | stat: -rw-r--r-- 982 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Fixes :mod:`path` breaking API changes.

Newer versions of :mod:`path` no longer support:

* :func:`Path.abspath()`: Use :func:`Path.absolute()`
* :func:`Path.isdir()`: Use :func:`Path.is_dir()`
* :func:`Path.isfile()`: Use :func:`Path.is_file()`
* ...

.. seealso:: https://github.com/jaraco/path
"""

from path import Path


# -----------------------------------------------------------------------------
# MONKEYPATCH (if needed)
# -----------------------------------------------------------------------------
def monkeypatch_path_if_needed():
    if not hasattr(Path, "abspath"):
        Path.abspath = Path.absolute
    if not hasattr(Path, "isdir"):
        Path.isdir = Path.is_dir
    if not hasattr(Path, "isfile"):
        Path.isfile = Path.is_file


# -----------------------------------------------------------------------------
# MODULE SETUP
# -----------------------------------------------------------------------------
# DISABLED: monkeypatch_path_if_needed()