Skip to content

Commit

Permalink
os-path: Implement os.path.isfile().
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Hirsch <[email protected]>
  • Loading branch information
scivision authored and dpgeorge committed Dec 20, 2023
1 parent f672baa commit ae8ea8d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python-stdlib/os-path/manifest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
metadata(version="0.1.4")
metadata(version="0.2.0")

# Originally written by Paul Sokolovsky.

Expand Down
7 changes: 7 additions & 0 deletions python-stdlib/os-path/os/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ def isdir(path):
return False


def isfile(path):
try:
return bool(os.stat(path)[0] & 0x8000)
except OSError:
return False


def expanduser(s):
if s == "~" or s.startswith("~/"):
h = os.getenv("HOME")
Expand Down
4 changes: 4 additions & 0 deletions python-stdlib/os-path/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
assert isdir(dir + "/os")
assert not isdir(dir + "/os--")
assert not isdir(dir + "/test_path.py")

assert not isfile(dir + "/os")
assert isfile(dir + "/test_path.py")
assert not isfile(dir + "/test_path.py--")

0 comments on commit ae8ea8d

Please sign in to comment.