Lines Matching refs:value
113 """Exception class used to indicate an invalid property value."""
116 value=None):
121 self.value = value
125 return _("'{value}' is less than the minimum "
130 return _("'{value}' is greater than the maximum "
135 return _("Invalid value '{value}' for property "
138 return _("Invalid value '{value}' for {prop}.").format(
156 """Exception class used to indicate that the value specified
159 def __init__(self, section=None, prop=None, value=None):
161 self.value = value
165 return _("Value '{value}' not found in the list of "
168 return _("Value '{value}' not found in the list of values "
237 # Last, set the property's initial value.
238 self.value = default
262 return self.value == other.value
269 return self.value != other.value
272 return hash((self.name, self.value))
275 return self.__class__(self.name, default=self.value,
279 # Assume that value can be represented in utf-8.
280 return misc.force_text(self.value)
282 def _is_allowed(self, value):
283 """Raises an InvalidPropertyValueError if 'value' is not allowed
286 if not isinstance(value, six.string_types):
289 value=value)
291 def _transform_string(self, value):
293 if isinstance(value, bytes):
297 value = value.encode("ascii")
300 value = value.decode("utf-8")
305 return value
313 def value(self):
314 """The value of the property."""
317 @value.setter
318 def value(self, value):
319 """Sets the property's value."""
320 if isinstance(value, six.string_types):
321 value = self._value_map.get(value, value)
322 if value is None:
323 value = ""
324 elif isinstance(value, (bool, int)):
325 value = str(value)
327 value = self._transform_string(value)
328 self._is_allowed(value)
329 self._value = value
393 """Class representing properties with a boolean value."""
399 @Property.value.setter
400 def value(self, value):
401 if isinstance(value, six.string_types):
402 value = self._value_map.get(value, value)
403 if value is None or value == "":
406 elif isinstance(value, six.string_types):
407 if value.lower() == "true":
410 elif value.lower() == "false":
413 elif isinstance(value, bool):
414 self._value = value
416 raise InvalidPropertyValueError(prop=self.name, value=value)
420 """Class representing a property with an integer value."""
439 """Minimum value permitted for this property or None."""
444 """Maximum value permitted for this property or None."""
447 @Property.value.setter
448 def value(self, value):
449 if isinstance(value, six.string_types):
450 value = self._value_map.get(value, value)
451 if value is None or value == "":
452 value = 0
455 nvalue = int(value)
458 value=value)
462 minimum=self.minimum, value=value)
465 maximum=self.maximum, value=value)
470 """Class representing properties with a publisher prefix/alias value."""
472 @Property.value.setter
473 def value(self, value):
474 if isinstance(value, six.string_types):
475 value = self._value_map.get(value, value)
476 if value is None or value == "":
480 if not isinstance(value, six.string_types) or \
481 not misc.valid_pub_prefix(value):
484 value=value)
485 self._value = value
503 def _is_allowed(self, value):
504 """Raises an InvalidPropertyValueError if 'value' is not allowed
509 Property._is_allowed(self, value)
515 if value == a:
518 value.startswith("exec:") and \
519 len(value) > 5:
521 # just that the value starts with 'exec:'.
523 if a == "<smffmri>" and value.startswith("svc:") and \
524 len(value) > 4:
526 # just that the value starts with 'svc:'.
528 if a == "<abspathname>" and os.path.isabs(value):
530 if a == "<pathname>" and len(value) > 1:
536 value=value)
548 def _parse_str(self, value):
552 value = ast.literal_eval(value)
557 value=value)
558 return value
560 @PropDefined.value.setter
561 def value(self, value):
562 # the value can be arbitrary 8-bit data, so we allow bytes here
563 if isinstance(value, (six.string_types, bytes)):
564 value = self._value_map.get(value, value)
565 if value is None or value == "":
566 value = []
567 elif isinstance(value, (six.string_types, bytes)):
568 value = self._parse_str(value)
569 if not isinstance(value, list):
572 value=value)
575 iter(value)
578 value=value)
581 for v in value:
589 value=value)
595 value=nvalue)
601 """Class representing properties with a value specified as a list of
602 dictionaries. Each dictionary must contain string key/value pairs, or
603 a string key, with None as a value.
606 @PropDefined.value.setter
607 def value(self, value):
608 if isinstance(value, six.string_types):
609 value = self._value_map.get(value, value)
610 if value is None or value == "":
611 value = []
612 elif isinstance(value, six.string_types):
613 value = self._parse_str(value)
614 if not isinstance(value, list):
617 value=value)
620 iter(value)
623 value=value)
625 self._is_allowed(value)
627 for v in value:
633 value=value)
645 value=nvalue)
648 def _is_allowed(self, value):
649 if not isinstance(value, list):
651 value=value)
654 for dic in value:
657 value=value)
662 # ensure that each dictionary in the value is allowed
663 for dic in value:
666 value=value)
669 value=value)
686 def _is_allowed(self, value):
687 """Raises an InvalidPropertyValueError if 'value' is not allowed
692 PropList._is_allowed(self, value)
694 if isinstance(value, bytes):
696 value.decode("utf-8")
701 value=value)
703 def _parse_str(self, value):
711 if isinstance(value, bytes):
712 value = value.split(b",")
714 value = value.split(",")
715 for v in value:
730 value=value)
735 if self.value and len(self.value):
738 return u",".join(self.value)
745 def _is_allowed(self, value):
746 """Raises an InvalidPropertyValueError if 'value' is not allowed
751 Property._is_allowed(self, value)
753 if value == "":
756 valid = misc.valid_pub_url(value)
759 value=value)
770 def _is_allowed(self, value):
771 """Raises an InvalidPropertyValueError if 'value' is not allowed
776 PropSimpleList._is_allowed(self, value)
778 valid = misc.valid_pub_url(value)
781 value=value)
787 def _is_allowed(self, value):
788 """Raises an InvalidPropertyValueError if 'value' is not allowed
793 PropList._is_allowed(self, value)
795 valid = misc.valid_pub_url(value)
798 value=value)
806 each dictionary must have a "uri" key with a valid URI as a value.
817 def _is_allowed(self, value):
818 """Raises an InvalidPropertyValueError if 'value' is not allowed
823 PropDictionaryList._is_allowed(self, value)
825 for dic in value:
828 value=value)
831 value=value)
837 def _is_allowed(self, value):
838 if value == "":
842 uuid.UUID(hex=str(value))
846 value=value)
851 value."""
858 return self.value.get_short_version()
860 @Property.value.setter
861 def value(self, value):
862 if isinstance(value, six.string_types):
863 value = self._value_map.get(value, value)
864 if value is None or value == "":
865 value = "0"
867 if isinstance(value, pkg.version.Version):
868 nvalue = value
871 nvalue = pkg.version.Version(value)
874 value=value)
946 (pname, p.value)
948 if hasattr(p, "value")
1051 'version' is an integer value that will be used to determine
1206 def add_property_value(self, section, name, value):
1207 """Adds the value to the property object matching the given
1210 the value is not valid for the given property or if the target
1215 if not isinstance(propobj.value, list):
1217 prop=name, value=value)
1219 # If a value was just appended directly, the property class
1220 # set method wouldn't be executed and the value added wouldn't
1221 # get verified, so append to a copy of the property's value and
1222 # then set the property to the new value. This allows the new
1223 # value to be verified and/or rejected without affecting the
1225 pval = copy.copy(propobj.value)
1226 pval.append(value)
1228 propobj.value = pval
1253 """Returns the value of the property object matching the given
1257 Be aware that references to the original value are returned;
1258 if the return value is not an immutable object (such as a list),
1260 value needs to be modified, consumers are advised to create a
1261 copy first, and then call set_property() to update the value.
1262 Calling set_property() with the updated value is the only way
1263 to ensure that changes to a property's value are persistent.
1272 return sec.get_property(name).value
1312 def remove_property_value(self, section, name, value):
1313 """Removes the value from the list of values for the property
1316 exist. Raises InvalidPropertyValueError if the value is not
1332 if not isinstance(propobj.value, list):
1334 prop=name, value=value)
1336 # Remove the value from a copy of the actual property object
1337 # value so that the property's set verification can happen.
1338 pval = copy.copy(propobj.value)
1340 pval.remove(value)
1343 prop=name, value=value)
1346 propobj.value = pval
1377 def set_property(self, section, name, value):
1378 """Sets the value of the property object matching the given
1381 the value is not valid for the given property."""
1388 propobj.value = value
1399 will be raised if the value is not valid for the given
1407 'property': value
1430 """Returns an integer value used to indicate what set of
1449 by a "[section]" header, and followed by "name = value" entries, with
1482 'version' is an integer value that will be used to determine
1551 for prop, value in cp.items(section):
1563 value = str(value)
1568 propobj.value = value
1762 'version' is an integer value that will be used to determine
1818 # if a property value has embedded newlines. As such,
1854 for prop, value in six.iteritems(props):
1863 for v in shlex.split(value):
1883 value = nvalue
1885 # Allow shlex to unescape the value,
1887 value = ''.join(shlex.split(value))
1889 # Finally, set the property value.
1891 propobj.value = value