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.
- clone() Properties¶
Create a copy of this property set.
- Returns:
A copy of this property set.
- Return type:
- getCommandLineOptions() list[str]¶
Get 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.
- getIceProperty(key: str) str¶
Get an Ice property by key.
If the property is not set, its default value is returned.
- Parameters:
key (str) – The property key.
- Returns:
The property value, or the default value if the property is not set.
- Return type:
- Raises:
PropertyException – When the property is not a known Ice property.
- getIcePropertyAsInt(key: str) int¶
Get an Ice property as an integer.
If the property is not set, its default value is returned.
- 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 – When the property is not a known Ice property or the property value is not a valid integer.
- getIcePropertyAsList(key: str) list[str]¶
Get an Ice property as a list of strings.
The strings must be separated by whitespace or comma. If the property is not set, its default value is returned. 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 value is returned. Within single 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 – When the property is not a known Ice property.
- getPropertiesForPrefix(prefix: str) dict[str, str]¶
Get all properties whose keys begin with the given prefix.
If the prefix is an empty string, then all properties are returned.
- getProperty(key: str) str¶
Get a property by key.
If the property is not set, an empty string is returned.
- getPropertyAsInt(key: str) int¶
Get a property as an integer.
If the property is not set, 0 is returned.
- Parameters:
key (str) – The property key.
- Returns:
The property value interpreted as an integer, or 0 if the property is not set.
- Return type:
- Raises:
PropertyException – When the property value is not a valid integer.
- getPropertyAsIntWithDefault(key: str, value: int) int¶
Get a property as an integer.
If the property is not set, the given default value is returned.
- Parameters:
- Returns:
The property value interpreted as an integer, or the default value if the property does not exist.
- Return type:
- Raises:
PropertyException – When the property value is not a valid integer.
- getPropertyAsList(key: str) list[str]¶
Get a property as a list of strings.
The strings must be separated by whitespace or comma. If the property is not set, an empty list is returned. 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 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’.
- getPropertyAsListWithDefault(key: str, value: list[str]) list[str]¶
Get a property as a list of strings.
The strings must be separated by whitespace or comma. If the property is not set, the default value is returned. 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 value is returned. Within single 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’.
- getPropertyWithDefault(key: str, value: str) str¶
Get a property by key.
If the property is not set, the given default value is returned.
- load(file: str) None¶
Load properties from a file.
- Parameters:
file (str) – The property file.
- Return type:
None
- parseCommandLineOptions(prefix: str, options: list[str]) list[str]¶
Convert a sequence of command-line options into properties.
All options that begin with –prefix. are converted into properties. If the prefix is empty, all options that begin with – are converted to properties.