@@ -27,6 +27,12 @@ def is_git_dir(d):
2727
2828
2929class LazyMixin (object ):
30+ """
31+ Base class providing an interface to lazily retrieve attribute values upon
32+ first access. If slots are used, memory will only be reserved once the attribute
33+ is actually accessed and retrieved the first time. All future accesses will
34+ return the cached value as stored in the Instance's dict or slot.
35+ """
3036__slots__ = tuple ()
3137
3238def __getattr__ (self ,attr ):
@@ -49,3 +55,35 @@ def _set_cache_(self, attr):
4955in the single attribute."""
5056pass
5157
58+
59+ class Iterable (object ):
60+ """
61+ Defines an interface for iterable items which is to assure a uniform
62+ way to retrieve and iterate items within the git repository
63+ """
64+ __slots__ = tuple ()
65+
66+ @classmethod
67+ def list_items (cls ,repo ,* args ,** kwargs ):
68+ """
69+ Find all items of this type - subclasses can specify args and kwargs differently.
70+ If no args are given, subclasses are obliged to return all items if no additional
71+ arguments arg given.
72+
73+ Note: Favor the iter_items method as it will
74+
75+ Returns:
76+ list(Item,...) list of item instances
77+ """
78+ return list (cls .iter_items ,repo ,* args ,** kwargs )
79+
80+
81+ @classmethod
82+ def iter_items (cls ,repo ,* args ,** kwargs ):
83+ """
84+ For more information about the arguments, see find_all
85+ Return:
86+ iterator yielding Items
87+ """
88+ raise NotImplementedError ("To be implemented by Subclass" )
89+