Skip to content

Commit

Permalink
Add Extension Exclusion Functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
BerkinAKKAYA committed Mar 27, 2021
1 parent 4974171 commit 4ba777c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Colored output with icons
- Fully customizable (see `config.py`)
- Under 150 lines of code
- Hide Unwanted Extensions (Source Maps or Movie Subtitles, for example)

![SS1](https://github.com/BerkinAKKAYA/pythonls/blob/main/SS.jpg?raw=true)
![SS2](https://github.com/BerkinAKKAYA/pythonls/blob/main/SS.png?raw=true)
9 changes: 8 additions & 1 deletion src/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
directoriesToList = list(filter(lambda x: x[0] != "-", args)) or ["."]
depth = 1
sortBy = "fileType"
exclude = []

for arg in args:
splitted = arg.split("=")
Expand All @@ -26,6 +27,10 @@
if splitted[0] in ["-n", "--name"]:
sortBy = "name"

if splitted[0] in ["-x", "--exclude"]:
exclude = splitted[1].split(",")
exclude = list(map(lambda ext: ext.strip(), exclude))

def ToFullPath(path):
result = path

Expand Down Expand Up @@ -86,7 +91,9 @@ def PrintDirectory(path, indent=0, depth=1):
# Print Files
for file in files:
extension = file.split(".")[-1] if "." in file else ""
PrintItem(extension, file, indent)

if extension not in exclude:
PrintItem(extension, file, indent)

for directory in directoriesToList:
if depth < 1:
Expand Down

0 comments on commit 4ba777c

Please sign in to comment.