Ice.Properties¶
- final class Ice.Properties(args: list[str] | None = None, defaults: Self | None = None)¶
- final class Ice.Properties(*, properties: Properties)
Bases:
objectRepresents a set of properties used to configure Ice and Ice-based applications. A property is a key/value pair, where both the key and the value are strings. By convention, property keys should have the form
application-name[.category[.sub-category]].name.- getIceProperty(key: str) str¶
Gets an Ice property by key.
- Parameters:
key (str) – The property key.
- Returns:
The property value, or the default value for this property if the property is not set.
- Return type:
- Raises:
PropertyException – If the property is not a known Ice property.
- getPropertyAsInt(key: str) int¶
Gets a property as an integer.
- Parameters:
key (str) – The property key.
- Returns:
The property value interpreted as an integer, or
0if the property is not set.- Return type:
- Raises:
PropertyException – If the property value is not a valid integer.
- getIcePropertyAsInt(key: str) int¶
Gets an Ice property as an integer.
- Parameters:
key (str) – The property key.
- Returns:
The property value interpreted as an integer, or the default value if the property is not set.
- Return type:
- Raises:
PropertyException – If the property is not a known Ice property or the value is not a valid integer.
- getPropertyAsIntWithDefault(key: str, value: int) int¶
Gets a property as an integer.
- Parameters:
- Returns:
The property value interpreted as an integer, or the default value if the property is not set.
- Return type:
- Raises:
PropertyException – If the property value is not a valid integer.
- getPropertyAsList(key: str) list[str]¶
Gets a property as a list of strings.
The strings must be separated by whitespace or comma. The strings in the list can contain whitespace and commas if they are enclosed in single or double quotes. If quotes are mismatched, an empty list is returned. Within single quotes or double quotes, you can escape the quote in question with a backslash, e.g. O’Reilly can be written as O’Reilly, “O’Reilly” or ‘O’Reilly’.
- getIcePropertyAsList(key: str) list[str]¶
Gets an Ice property as a list of strings.
The strings must be separated by whitespace or comma. The strings in the list can contain whitespace and commas if they are enclosed in single or double quotes. If quotes are mismatched, the default list is returned. Within single quotes or double quotes, you can escape the quote in question with a backslash, e.g. O’Reilly can be written as O’Reilly, “O’Reilly” or ‘O’Reilly’.
- Parameters:
key (str) – The property key.
- Returns:
The property value interpreted as a list of strings, or the default value if the property is not set.
- Return type:
- Raises:
PropertyException – If the property is not a known Ice property.
- getPropertyAsListWithDefault(key: str, value: list[str]) list[str]¶
Gets a property as a list of strings.
The strings must be separated by whitespace or comma. The strings in the list can contain whitespace and commas if they are enclosed in single or double quotes. If quotes are mismatched, the default list is returned. Within single quotes or double quotes, you can escape the quote in question with a backslash, e.g. O’Reilly can be written as O’Reilly, “O’Reilly” or ‘O’Reilly’.
- getPropertiesForPrefix(prefix: str) dict[str, str]¶
Gets all properties whose keys begin with the given prefix. If
prefixis the empty string, then all properties are returned.
- setProperty(key: str, value: str) None¶
Sets a property. To unset a property, set it to the empty string.
- getCommandLineOptions() list[str]¶
Gets a sequence of command-line options that is equivalent to this property set. Each element of the returned sequence is a command-line option of the form
--key=value.
- parseCommandLineOptions(prefix: str, options: list[str]) list[str]¶
Converts a sequence of command-line options into properties.
All options that start with
--prefix.are converted into properties. If the prefix is empty, all options that begin with--are converted to properties.
- parseIceCommandLineOptions(options: list[str]) list[str]¶
Converts a sequence of command-line options into properties.
All options that start with one of the reserved Ice prefixes (
--Ice,--IceSSL, etc.) are converted into properties.
- load(file: str) None¶
Loads properties from a file.
- Parameters:
file (str) – The property file.
- Return type:
None
- clone() Properties¶
Creates a copy of this property set.
- Returns:
A copy of this property set.
- Return type: