Skip to content

Commit

Permalink
Adds documentation for undocumented functions
Browse files Browse the repository at this point in the history
Signed-off-by: Gora Khargosh <gora.khargosh@gmail.com>
  • Loading branch information
gorakhargosh committed Dec 30, 2010
1 parent 679e9c9 commit 7e210ed
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 10 deletions.
1 change: 0 additions & 1 deletion nose.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ with-doctest=1
#with-color=1
#with-noseexclude=1
#exclude-dir-file=tests/nose-exclude.txt

71 changes: 63 additions & 8 deletions pathtools/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,40 +60,95 @@ def walk(path, topdown=topdown, followlinks=followlinks):
return walk


def walk(pathname, topdown=True, followlinks=False, recursive=True):
def walk(dir_pathname, recursive=True, topdown=True, followlinks=False):
"""
Walks a directory tree optionally recursively. Works exactly like
:func:`os.walk` only adding the `recursive` argument.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for walking recursively walking through the directory tree;
``False`` otherwise.
:param topdown:
Please see the documentation for :func:`os.walk`
:param followlinks:
Please see the documentation for :func:`os.walk`
"""
walk_func = get_dir_walker(recursive, topdown, followlinks)
for root, dirnames, filenames in walk_func(pathname):
for root, dirnames, filenames in walk_func(dir_pathname):
yield (root, dirnames, filenames)


def listdir(pathname,
def listdir(dir_pathname,
recursive=True,
topdown=True,
followlinks=False):
"""
Enlists all items in a directory optionally recursively.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for walking recursively walking through the directory tree;
``False`` otherwise.
:param topdown:
Please see the documentation for :func:`os.walk`
:param followlinks:
Please see the documentation for :func:`os.walk`
"""
for root, dirnames, filenames\
in walk(pathname, recursive, topdown, followlinks):
in walk(dir_pathname, recursive, topdown, followlinks):
for dirname in dirnames:
yield absolute_path(os.path.join(root, dirname))
for filename in filenames:
yield absolute_path(os.path.join(root, filename))


def list_directories(pathname,
def list_directories(dir_pathname,
recursive=True,
topdown=True,
followlinks=False):
"""
Enlists all the directories within the specified directory optionally
recursively.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for walking recursively walking through the directory tree;
``False`` otherwise.
:param topdown:
Please see the documentation for :func:`os.walk`
:param followlinks:
Please see the documentation for :func:`os.walk`
"""
for root, dirnames, filenames\
in walk(pathname, recursive, topdown, followlinks):
in walk(dir_pathname, recursive, topdown, followlinks):
for dirname in dirnames:
yield absolute_path(os.path.join(root, dirname))


def list_files(pathname,
def list_files(dir_pathname,
recursive=True,
topdown=True,
followlinks=False):
"""
Enlists all the files within the specified directory optionally
recursively.
:param dir_pathname:
The directory to traverse.
:param recursive:
``True`` for walking recursively walking through the directory tree;
``False`` otherwise.
:param topdown:
Please see the documentation for :func:`os.walk`
:param followlinks:
Please see the documentation for :func:`os.walk`
"""
for root, dirnames, filenames\
in walk(pathname, recursive, topdown, followlinks):
in walk(dir_pathname, recursive, topdown, followlinks):
for filename in filenames:
yield absolute_path(os.path.join(root, filename))

Expand Down
5 changes: 4 additions & 1 deletion pathtools/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
:module: `pathtools.patterns`
:author: Gora Khargosh <gora.khargosh@gmail.com>
Utility functions to match_path and filter pathnames based on patterns.
Utility functions to match against and filter pathnames based on wildcard
patterns.
"""

from fnmatch import fnmatch, fnmatchcase

__all__ = ['match_path', 'match_path_against', 'filter_paths']


def _string_lower(s):
"""
Convenience function to lowercase a string (the :mod:`string` module is
Expand All @@ -45,6 +47,7 @@ def _string_lower(s):
"""
return s.lower()


def match_path_against(pathname, patterns, case_sensitive=True):
"""
Determines whether the pathname matches any of the given wildcard patterns,
Expand Down

0 comments on commit 7e210ed

Please sign in to comment.