Skip to content

Commit

Permalink
Add extend behavior to IndexIgnore.
Browse files Browse the repository at this point in the history
  • Loading branch information
skytreader committed Jul 5, 2021
1 parent 81cac86 commit 82a3d79
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions main.py
Expand Up @@ -2,11 +2,12 @@

class IndexIgnore(object):

def __init__(self, ignorefilename):
def __init__(self, ignorefilename=None):
self.ignores = set()
with open(ignorefilename) as ignorefile:
for line in ignorefile:
self.ignores.add(self.__normalize_dirname(line))
if ignorefilename:
with open(ignorefilename) as ignorefile:
for line in ignorefile:
self.ignores.add(self.__normalize_dirname(line))

def __normalize_dirname(self, dirname):
dir_stripped = dirname.strip()
Expand All @@ -17,6 +18,12 @@ def __normalize_dirname(self, dirname):

def should_ignore(self, dirname):
return self.__normalize_dirname(dirname) in self.ignores

def extend(self, ignorefilename):
new_indexignore = IndexIgnore(ignorefilename)
for item in self.ignores:
new_indexignore.add(item)
return new_indexignore

@route("/")
def root():
Expand Down

0 comments on commit 82a3d79

Please sign in to comment.