Ice.Properties

final class Ice.Properties(args: list[str] | None = None, defaults: Self | None = None)
final class Ice.Properties(*, properties: Properties)

Bases: object

Represents 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.

Parameters:
  • args (list[str] | None)

  • defaults (Self | None)

  • properties (Properties | None)

getProperty(key: str) str

Gets a property by key.

Parameters:

key (str) – The property key.

Returns:

The property value, or the empty string if the property is not set.

Return type:

str

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:

str

Raises:

PropertyException – If the property is not a known Ice property.

getPropertyWithDefault(key: str, value: str) str

Gets a property by key.

Parameters:
  • key (str) – The property key.

  • value (str) – The default value to return if the property is not set.

Returns:

The property value or the default value if the property is not set.

Return type:

str

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 0 if the property is not set.

Return type:

int

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:

int

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:
  • key (str) – The property key.

  • value (int) – The default value to return if the property does not exist.

Returns:

The property value interpreted as an integer, or the default value if the property is not set.

Return type:

int

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’.

Parameters:

key (str) – The property key.

Returns:

The property value interpreted as a list of strings, or an empty list if the property is not set.

Return type:

list[str]

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:

list[str]

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’.

Parameters:
  • key (str) – The property key.

  • value (list[str]) – The default value to use if the property is not set.

Returns:

The property value interpreted as a list of strings, or the default value if the property is not set.

Return type:

list[str]

getPropertiesForPrefix(prefix: str) dict[str, str]

Gets all properties whose keys begin with the given prefix. If prefix is the empty string, then all properties are returned.

Parameters:

prefix (str) – The prefix to search for.

Returns:

The matching property set.

Return type:

dict[str, str]

setProperty(key: str, value: str) None

Sets a property. To unset a property, set it to the empty string.

Parameters:
  • key (str) – The property key.

  • value (str) – The property value.

Return type:

None

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.

Returns:

The command line options for this property set.

Return type:

list[str]

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.

Parameters:
  • prefix (str) – The property prefix, or the empty string to convert all options starting with --.

  • options (list[str]) – The command-line options.

Returns:

The command-line options that do not start with the specified prefix, in their original order.

Return type:

list[str]

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.

Parameters:

options (list[str]) – The command-line options.

Returns:

The command-line options that do not start with one of the reserved prefixes, in their original order.

Return type:

list[str]

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:

Properties