src/eric7/SystemUtilities/FileSystemUtilities.py

branch
eric7
changeset 9639
9e66fd88193c
parent 9624
b47dfa7a137d
child 9645
31aaa11672d3
equal deleted inserted replaced
9638:6ee095b9d3bd 9639:9e66fd88193c
423 tail = tail[1:] 423 tail = tail[1:]
424 return "" 424 return ""
425 425
426 426
427 def direntries( 427 def direntries(
428 path, filesonly=False, pattern=None, followsymlinks=True, checkStop=None 428 path,
429 filesonly=False,
430 pattern=None,
431 followsymlinks=True,
432 checkStop=None,
433 ignore=None,
429 ): 434 ):
430 """ 435 """
431 Function returning a list of all files and directories. 436 Function returning a list of all files and directories.
432 437
433 @param path root of the tree to check 438 @param path root of the tree to check
440 @param followsymlinks flag indicating whether symbolic links 445 @param followsymlinks flag indicating whether symbolic links
441 should be followed 446 should be followed
442 @type bool 447 @type bool
443 @param checkStop function to be called to check for a stop 448 @param checkStop function to be called to check for a stop
444 @type function 449 @type function
450 @param ignore list of entries to be ignored
451 @type list of str
445 @return list of all files and directories in the tree rooted 452 @return list of all files and directories in the tree rooted
446 at path. The names are expanded to start with path. 453 at path. The names are expanded to start with path.
447 @rtype list of strs 454 @rtype list of strs
448 """ 455 """
449 patterns = pattern if isinstance(pattern, list) else [pattern] 456 patterns = pattern if isinstance(pattern, list) else [pattern]
450 files = [] if filesonly else [path] 457 files = [] if filesonly else [path]
458 ignoreList = [
459 ".svn",
460 ".hg",
461 ".git",
462 ".ropeproject",
463 ".eric7project",
464 ".jedi",
465 ]
466 if ignore is not None:
467 ignoreList.extend(ignore)
468
451 try: 469 try:
452 entries = os.listdir(path) 470 entries = os.listdir(path)
453 for entry in entries: 471 for entry in entries:
454 if checkStop and checkStop(): 472 if checkStop and checkStop():
455 break 473 break
456 474
457 if entry in [ 475 if entry in ignoreList:
458 ".svn",
459 ".hg",
460 ".git",
461 ".ropeproject",
462 ".eric7project",
463 ".jedi",
464 ]:
465 continue 476 continue
466 477
467 fentry = os.path.join(path, entry) 478 fentry = os.path.join(path, entry)
468 if ( 479 if (
469 pattern 480 pattern

eric ide

mercurial