Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf4fa1cb

Browse files
committed
Added base for all iteratable objects
1 parent5eb0f2c commitf4fa1cb

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

‎lib/git/utils.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ def is_git_dir(d):
2727

2828

2929
classLazyMixin(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

3238
def__getattr__(self,attr):
@@ -49,3 +55,35 @@ def _set_cache_(self, attr):
4955
in the single attribute."""
5056
pass
5157

58+
59+
classIterable(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+
deflist_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+
returnlist(cls.iter_items,repo,*args,**kwargs)
79+
80+
81+
@classmethod
82+
defiter_items(cls,repo,*args,**kwargs):
83+
"""
84+
For more information about the arguments, see find_all
85+
Return:
86+
iterator yielding Items
87+
"""
88+
raiseNotImplementedError("To be implemented by Subclass")
89+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp