Skip to content

Commit

Permalink
Finding Python files in project now ignores 'venv' folder
Browse files Browse the repository at this point in the history
  • Loading branch information
bvobart committed Jun 3, 2021
1 parent 498dedd commit f59c814
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions utils/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func FindIPynbFilesIn(dir string) (Filenames, error) {
// a certain file extension. File extension must start with a '.', e.g. ".py" or ".ipynb"
// Returns filepaths relative to the given directory.
// Ignores hidden folders (folders whose names start with a '.'), but not hidden files.
// Also explicitly ignores `venv` folders
func FindFilesByExtInDir(dir string, extension string) (Filenames, error) {
files := Filenames{}
err := filepath.Walk(dir, func(path string, file os.FileInfo, err error) error {
Expand All @@ -102,6 +103,10 @@ func FindFilesByExtInDir(dir string, extension string) (Filenames, error) {
return filepath.SkipDir
}

if file.IsDir() && file.Name() == "venv" {
return filepath.SkipDir
}

if !file.IsDir() && filepath.Ext(path) == extension {
relpath, _ := filepath.Rel(dir, path)
files = append(files, relpath)
Expand Down
Empty file.
Empty file.

0 comments on commit f59c814

Please sign in to comment.