Revision c41eea6e lib/rapi/baserlib.py
b/lib/rapi/baserlib.py | ||
---|---|---|
32 | 32 |
def BuildUriList(ids, uri_format, uri_fields=("name", "uri")): |
33 | 33 |
"""Builds a URI list as used by index resources. |
34 | 34 |
|
35 |
Args: |
|
36 |
- ids: List of ids as strings |
|
37 |
- uri_format: Format to be applied for URI |
|
38 |
- uri_fields: Optional parameter for field ids |
|
35 |
@param ids: list of ids as strings |
|
36 |
@param uri_format: format to be applied for URI |
|
37 |
@param uri_fields: optional parameter for field IDs |
|
39 | 38 |
|
40 | 39 |
""" |
41 | 40 |
(field_id, field_uri) = uri_fields |
... | ... | |
53 | 52 |
def ExtractField(sequence, index): |
54 | 53 |
"""Creates a list containing one column out of a list of lists. |
55 | 54 |
|
56 |
Args: |
|
57 |
- sequence: Sequence of lists |
|
58 |
- index: Index of field |
|
55 |
@param sequence: sequence of lists |
|
56 |
@param index: index of field |
|
59 | 57 |
|
60 | 58 |
""" |
61 | 59 |
return map(lambda item: item[index], sequence) |
... | ... | |
64 | 62 |
def MapFields(names, data): |
65 | 63 |
"""Maps two lists into one dictionary. |
66 | 64 |
|
67 |
Args:
|
|
68 |
- names: Field names (list of strings)
|
|
69 |
- data: Field data (list)
|
|
65 |
Example::
|
|
66 |
>>> MapFields(["a", "b"], ["foo", 123])
|
|
67 |
{'a': 'foo', 'b': 123}
|
|
70 | 68 |
|
71 |
Example: |
|
72 |
>>> MapFields(["a", "b"], ["foo", 123]) |
|
73 |
{'a': 'foo', 'b': 123} |
|
69 |
@param names: field names (list of strings) |
|
70 |
@param data: field data (list) |
|
74 | 71 |
|
75 | 72 |
""" |
76 | 73 |
if len(names) != len(data): |
... | ... | |
108 | 105 |
def MapBulkFields(itemslist, fields): |
109 | 106 |
"""Map value to field name in to one dictionary. |
110 | 107 |
|
111 |
Args: |
|
112 |
- itemslist: A list of items values |
|
113 |
- instance: A list of items names |
|
108 |
@param itemslist: a list of items values |
|
109 |
@param fields: a list of items names |
|
110 |
|
|
111 |
@return: a list of mapped dictionaries |
|
114 | 112 |
|
115 |
Returns: |
|
116 |
A list of mapped dictionaries |
|
117 | 113 |
""" |
118 | 114 |
items_details = [] |
119 | 115 |
for item in itemslist: |
... | ... | |
123 | 119 |
|
124 | 120 |
|
125 | 121 |
def MakeParamsDict(opts, params): |
126 |
""" Makes params dictionary out of a option set.
|
|
122 |
"""Makes params dictionary out of a option set. |
|
127 | 123 |
|
128 | 124 |
This function returns a dictionary needed for hv or be parameters. But only |
129 | 125 |
those fields which provided in the option set. Takes parameters frozensets |
... | ... | |
156 | 152 |
def __init__(self, items, queryargs, req): |
157 | 153 |
"""Generic resource constructor. |
158 | 154 |
|
159 |
Args: |
|
160 |
items: a list with variables encoded in the URL |
|
161 |
queryargs: a dictionary with additional options from URL |
|
155 |
@param items: a list with variables encoded in the URL |
|
156 |
@param queryargs: a dictionary with additional options from URL |
|
162 | 157 |
|
163 | 158 |
""" |
164 | 159 |
self.items = items |
Also available in: Unified diff