499 filesonly=False, |
499 filesonly=False, |
500 pattern=None, |
500 pattern=None, |
501 followsymlinks=True, |
501 followsymlinks=True, |
502 checkStop=None, |
502 checkStop=None, |
503 ignore=None, |
503 ignore=None, |
|
504 recursive=True, |
|
505 dirsonly=False, |
504 ): |
506 ): |
505 """ |
507 """ |
506 Function returning a list of all files and directories. |
508 Function returning a list of all files and directories. |
507 |
509 |
508 @param path root of the tree to check |
510 @param path root of the tree to check |
509 @type str |
511 @type str |
510 @param filesonly flag indicating that only files are wanted |
512 @param filesonly flag indicating that only files are wanted (defaults to False) |
|
513 @type bool (optional) |
|
514 @param pattern a filename pattern or list of filename patterns to check |
|
515 against (defaults to None) |
|
516 @type str or list of str (optional) |
|
517 @param followsymlinks flag indicating whether symbolic links |
|
518 should be followed (defaults to True) |
|
519 @type bool (optional) |
|
520 @param checkStop function to be called to check for a stop (defaults to None) |
|
521 @type function (optional) |
|
522 @param ignore list of entries to be ignored (defaults to None) |
|
523 @type list of str (optional) |
|
524 @param recursive flag indicating a recursive search (defaults to True) |
|
525 @type bool (optional) |
|
526 @param dirsonly flag indicating to return only directories. When True it has |
|
527 precedence over the 'filesonly' parameter ((defaults to False) |
511 @type bool |
528 @type bool |
512 @param pattern a filename pattern or list of filename patterns to check |
|
513 against |
|
514 @type str or list of str |
|
515 @param followsymlinks flag indicating whether symbolic links |
|
516 should be followed |
|
517 @type bool |
|
518 @param checkStop function to be called to check for a stop |
|
519 @type function |
|
520 @param ignore list of entries to be ignored |
|
521 @type list of str |
|
522 @return list of all files and directories in the tree rooted |
529 @return list of all files and directories in the tree rooted |
523 at path. The names are expanded to start with path. |
530 at path. The names are expanded to start with path. |
524 @rtype list of str |
531 @rtype list of str |
525 """ |
532 """ |
526 patterns = pattern if isinstance(pattern, list) else [pattern] |
533 patterns = pattern if isinstance(pattern, list) else [pattern] |
527 files = [] if filesonly else [path] |
534 files = [] if (filesonly and not dirsonly) else [path] |
528 ignoreList = [ |
535 ignoreList = [ |
529 ".svn", |
536 ".svn", |
530 ".hg", |
537 ".hg", |
531 ".git", |
538 ".git", |
532 ".ropeproject", |
539 ".ropeproject", |
554 ): |
561 ): |
555 # entry doesn't fit the given pattern |
562 # entry doesn't fit the given pattern |
556 continue |
563 continue |
557 |
564 |
558 if dirEntry.is_dir(): |
565 if dirEntry.is_dir(): |
559 if dirEntry.path in ignoreList: |
566 if ( |
|
567 dirEntry.path in ignoreList |
|
568 or dirEntry.is_symlink() and not followsymlinks |
|
569 ): |
560 continue |
570 continue |
561 if dirEntry.is_symlink() and not followsymlinks: |
571 if recursive: |
562 continue |
572 files += direntries( |
563 files += direntries( |
573 dirEntry.path, |
564 dirEntry.path, |
574 filesonly=filesonly, |
565 filesonly=filesonly, |
575 pattern=pattern, |
566 pattern=pattern, |
576 followsymlinks=followsymlinks, |
567 followsymlinks=followsymlinks, |
577 checkStop=checkStop, |
568 checkStop=checkStop, |
578 ignore=ignore, |
569 ignore=ignore, |
579 ) |
570 ) |
580 elif dirsonly: |
|
581 files.append(dirEntry.path) |
571 else: |
582 else: |
572 files.append(dirEntry.path) |
583 files.append(dirEntry.path) |
573 return files |
584 return files |
574 |
585 |
575 |
586 |