Permalink
Browse files

Adds documentation for undocumented functions

Signed-off-by: Gora Khargosh <gora.khargosh@gmail.com>
  • Loading branch information...
1 parent 679e9c9 commit 7e210ed27e00c802e76a006bbdd2990693cd0159 @gorakhargosh committed Dec 30, 2010
Showing with 67 additions and 10 deletions.
  1. +0 −1 nose.cfg
  2. +63 −8 pathtools/path.py
  3. +4 −1 pathtools/patterns.py
View
@@ -4,4 +4,3 @@ with-doctest=1
#with-color=1
#with-noseexclude=1
#exclude-dir-file=tests/nose-exclude.txt
-
View
@@ -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))
@@ -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
@@ -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,

0 comments on commit 7e210ed

Please sign in to comment.