Validating destination file paths courtship vs dating joshua harris

try: if not isinstance(pathname, str) or not pathname: return False # Strip this pathname's Windows-specific drive specifier (e.g., `C:\`) # if any.

Since Windows prohibits path components from containing `:` # characters, failing to strip this `:`-suffixed prefix would # erroneously invalidate all valid absolute Windows pathnames.

W_OK) def is_path_exists_or_creatable(pathname: str) - bool: ''' `True` if the passed pathname is a valid pathname for the current OS _and_ either currently exists or is hypothetically creatable; `False` otherwise.root_dirname = os.environ.get('HOMEDRIVE', 'C:') \ if sys.platform == 'win32' else sep assert isdir(root_dirname) # ...Murphy and her ironclad Law # Append a path separator to this directory if needed.This function is guaranteed to _never_ raise exceptions.''' try: # To prevent "os" module calls from raising undesirable exceptions on # invalid pathnames, is_pathname_valid() is explicitly called first.

Leave a Reply