1
2 """module with interfaces to define contracts"""
3 __docformat__ = "restructuredtext"
4 from mrv.interface import Interface
5
6 __all__ = ('iFinderProvider', 'iOptions', 'iFinderFilter')
7
9 """Interface defining the capabilities of a provider to be usable by a Finder
10 control. Every finder as a root, which is used as basis for listing urls.
11
12 Besides its function to provide sub-items for given urls, it is also used
13 to store recently selected items on a given level of a url. This memory
14 allows the finder to restore common portions of URLs accordingly.
15
16 The base implementation of the memorization feature already. """
17
18 __slots__ = '_mem_items'
19
20
21
22
23 memorize_urlItems = True
24
25
27 self._root = root
28 self._mem_items = dict()
29
30
31
33 """
34 :return: list of string-like items which can be found at the given url.
35 If this url is combined with one of the returned items separated by a slash,
36 a valid url is formed, i.e. url/item
37 :param url: A given slash-separated url like base/subitem or '', which
38 requests items at the root of all urls"""
39 raise NotImplementedError("To be implemented by subclass")
40
52
54 """Stores and associates a given url_index with a url_item. Makes the stored
55 item queryable by the ``storedUrlItemByIndex`` method
56 :param url_index: index from 0 to n, where 0 corresponds to the first item
57 in the url
58 :param url_item: the string item to store at the given index"""
59 if not self.memorize_urlItems:
60 return
61
62 self._mem_items[url_index] = url_item
63
65 """:return: string item previously stored at the given index, or None
66 if there is no information available"""
67 return self._mem_items.get(url_index, None)
68
70 """:return: string representing the file root"""
71 return self._root
72
73
74
76 """Filter interface suitable to perform item filter operations for Finder controls"""
77
78
79
80 - def filtered(self, finder, element_index, base_url, items):
81 """:return: list of items which may be shown in the element at element_index
82 :param finder: finder instance issueing the call
83 :param element_index: index of the element which is to be filled with items
84 :param base_url: url at which the given items exist
85 :param items: list of relative item ids which are to be shown in the finder element"""
86 return items
87
88
89
90
92 """Interface for all custom options layouts to be used with the FinderLayout.
93 They take a weak-reference to their parent FinderLayout allowing them to
94 set themselves up if necessary.
95 The options they represent must be read by a custom implementation of the
96 FinderLayout"""
97
98
99
100
101