-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from thombashi/fix_validate_filepath
Fix validation functions of filepaths
- Loading branch information
Showing
7 changed files
with
77 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,11 @@ | |
.. codeauthor:: Tsuyoshi Hombashi <[email protected]> | ||
""" | ||
|
||
import ntpath | ||
import platform | ||
import re | ||
import string | ||
import sys | ||
from pathlib import PurePath | ||
from typing import Any, List, Optional | ||
|
||
|
@@ -39,6 +41,19 @@ def to_str(name: PathType) -> str: | |
return name | ||
|
||
|
||
def is_nt_abspath(value: str) -> bool: | ||
ver_info = sys.version_info[:2] | ||
if ver_info <= (3, 10): | ||
if value.startswith("\\\\"): | ||
return True | ||
elif ver_info >= (3, 13): | ||
return ntpath.isabs(value) | ||
|
||
drive, _tail = ntpath.splitdrive(value) | ||
|
||
return ntpath.isabs(value) and len(drive) > 0 | ||
|
||
|
||
def is_null_string(value: Any) -> bool: | ||
if value is None: | ||
return True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters