Use is_leaf and is_node instead of is_item and is_collection

This commit is contained in:
Guillaume Ayoub
2012-02-23 15:17:59 +01:00
parent 5e8dec6683
commit 128a20714b
3 changed files with 26 additions and 15 deletions

View File

@ -81,16 +81,16 @@ class Collection(ical.Collection):
_, directories, files = next(os.walk(abs_path))
for filename in directories + files:
rel_filename = posixpath.join(path, filename)
if cls.is_collection(rel_filename) or cls.is_item(rel_filename):
if cls.is_node(rel_filename) or cls.is_leaf(rel_filename):
yield cls(rel_filename)
@classmethod
def is_collection(cls, path):
def is_node(cls, path):
abs_path = os.path.join(FOLDER, path.replace("/", os.sep))
return os.path.isdir(abs_path)
@classmethod
def is_item(cls, path):
def is_leaf(cls, path):
abs_path = os.path.join(FOLDER, path.replace("/", os.sep))
return os.path.isfile(abs_path) and not abs_path.endswith(".props")