164 def __init__(self, key=None, value=None, defaults_map=None, defaults_str=None, num=None, prop=None):
176 keys = prop.propertyNames()
179 node = prop.getNode(_key)
202 for key, value
in defaults_map.items():
233 self.
name = prop.name
234 self.
value = prop.value
237 keys = prop.propertyNames()
241 node = prop.getNode(key)
389 self.
split(key,
".", keys)
397 return node.default_value
426 self.
split(key,
".", keys)
430 return node.default_value
464 if value
is not None:
467 self.
split(key,
".", keys)
470 next = curr.hasKey(_key)
474 curr.leaf.append(next)
503 self.
split(key,
".", keys)
508 next = curr.hasKey(_key)
512 curr.leaf.append(next)
514 if value !=
"" and value[-1] ==
"\n":
515 value = value[0:len(value)-1]
516 curr.default_value = value
543 if i > num
or i > (len_ - 1)
or defaults[i] ==
"":
547 value = [defaults[i+1]]
549 OpenRTM_aist.eraseHeadBlank(key)
550 OpenRTM_aist.eraseTailBlank(key)
552 OpenRTM_aist.eraseHeadBlank(value)
553 OpenRTM_aist.eraseTailBlank(value)
587 self.
_store(out,
"", self)
755 for readStr
in inStream:
760 OpenRTM_aist.eraseHeadBlank(tmp)
763 if _str[0] ==
"#" or _str[0] ==
"!" or _str[0] ==
"\n":
766 _str = _str.rstrip(
'\r\n')
768 if _str[len(_str)-1] ==
"\\" and not OpenRTM_aist.isEscaped(_str, len(_str)-1):
770 tmp = [_str[0:len(_str)-1]]
771 OpenRTM_aist.eraseTailBlank(tmp)
782 key[0] = OpenRTM_aist.unescape(key)
783 OpenRTM_aist.eraseHeadBlank(key)
784 OpenRTM_aist.eraseTailBlank(key)
786 value[0] = OpenRTM_aist.unescape(value)
787 OpenRTM_aist.eraseHeadBlank(value)
788 OpenRTM_aist.eraseTailBlank(value)
818 self.
store(out, header)
906 out.write(
"#"+header+
"\n")
907 self.
_store(out,
"", self)
942 for leaf
in self.
leaf:
976 self.
split(key,
'.', keys)
1049 len_ = len(self.
leaf)
1050 for i
in range(len_):
1051 idx = (len_ - 1) - i
1052 if self.
leaf[idx].name == leaf_name:
1053 prop = self.
leaf[idx]
1075 for leaf
in self.
leaf:
1076 if leaf.name == key:
1092 len_ = len(self.
leaf)
1093 for i
in range(len_):
1115 keys = prop.propertyNames()
1117 for i
in range(prop.size()):
1118 self.
setProperty(keys[i], prop.getProperty(keys[i]))
1149 if (_str[i] ==
":" or _str[i] ==
"=")
and not OpenRTM_aist.isEscaped(_str, i):
1150 key.append(_str[0:i])
1151 value.append(_str[i+1:])
1158 if (_str[i] ==
" ")
and not OpenRTM_aist.isEscaped(_str, i):
1159 key.append(_str[0:i])
1160 value.append(_str[i+1:])
1192 begin_it = end_it = 0
1196 while end_it < length:
1197 if _str[end_it] == delim
and not OpenRTM_aist.isEscaped(_str, end_it):
1198 value.append(_str[begin_it:end_it])
1199 begin_it = end_it + 1
1202 value.append(_str[begin_it:end_it])
1226 next = curr.hasKey(keys[index])
1230 if index < (len(keys) - 1):
1232 return next._getNode(keys, index, next)
1254 if len(curr.leaf) > 0:
1255 for i
in range(len(curr.leaf)):
1256 next_name = curr_name+
"."+curr.leaf[i].name
1259 names.append(curr_name)
1279 if len(curr.leaf) > 0:
1280 for i
in range(len(curr.leaf)):
1282 next_name = curr.leaf[i].name
1284 next_name = curr_name+
"."+curr.leaf[i].name
1285 self.
_store(out, next_name, curr.leaf[i])
1290 val = curr.default_value
1291 out.write(curr_name+
": "+val+
"\n")
1314 for i
in range(index-1):
1339 out[0]+=self.
indent(index)+
"- "+curr.name
1342 if curr.value ==
"":
1344 out[0]+=
": "+curr.default_value+
"\n" 1347 out[0]+=
": "+str(curr.value)+
"\n" 1354 for i
in range(len(curr.leaf)):
1355 self.
_dump(out, curr.leaf[i], index + 1)
1377 return self.
_dump(string, self, 0)
def removeNode(self, leaf_name)
Get node of Properties.
def splitKeyValue(self, _str, key, value)
def clear(self)
If key exists in the children.
def store(self, out, header)
Stores property list to the output stream.
def assigmentOperator(self, prop)
Assignment operator.
def size(self)
Get number of Properties.
def split(self, _str, delim, value)
def hasKey(self, key)
If key exists in the children.
def list(self, out)
Prints this property list out to the specified output stream.
def getDefault(self, key)
Set value as the default value to specified key's property.
The Properties class represents a persistent set of properties.
def getDefaultValue(self)
def getProperty(self, key, default=None)
Searches for the property with the specified key in this property.
def save(self, out, header)
Save the properties list to the stream.
def load(self, inStream)
Loads property list consists of key:value from input stream.
def __init__(self, key=None, value=None, defaults_map=None, defaults_str=None, num=None, prop=None)
Constructor.
def mergeProperties(self, prop)
Merge properties.
def _getNode(self, keys, index, curr)
def _dump(self, out, curr, index)
def setDefault(self, key, value)
Sets a default value associated with key in the property list.
def __del__(self)
Destructor.
def findNode(self, key)
Find node of properties Properties* const Properties::findNode(const std::string& key) const...
def propertyNames(self)
Returns an vector of all the keys in this property.
def _store(self, out, curr_name, curr)
def setProperty(self, key, value=None)
Sets a value associated with key in the property list.
def getNode(self, key)
Get node of Properties.
def createNode(self, key)
def _propertyNames(self, names, curr_name, curr)
def setDefaults(self, defaults, num=None)
Sets a default value associated with key in the property list.