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)

clone() Properties

Create a copy of this property set.

Returns:

A copy of this property set.

Return type:

Properties

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.

Returns:

The command line options for this property set.

Return type:

list of str

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:

str

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:

int

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:

list of str

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.

Parameters:

prefix (str) – The prefix to search for (empty string if none).

Returns:

The matching property set with keys and values as strings.

Return type:

dict[str, str]

getProperty(key: str) str

Get a property by key.

If the property is not set, an empty string is returned.

Parameters:

key (str) – The property key.

Returns:

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

Return type:

str

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:

int

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

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

Returns:

The property value interpreted as an integer, or the default value if the property does not exist.

Return type:

int

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

Parameters:

key (str) – The property key.

Returns:

The property value interpreted as a list of strings.

Return type:

list of str

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

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

  • value (list of 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 of str

getPropertyWithDefault(key: str, value: str) str

Get a property by key.

If the property is not set, the given default value is returned.

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

  • value (str) – The default value to use if the property does not exist.

Returns:

The property value, or the default value if the property does not exist.

Return type:

str

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.

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

  • options (list of 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 of str

parseIceCommandLineOptions(options: list[str]) list[str]

Convert a sequence of command-line options into properties.

All options that begin with one of the following prefixes are converted into properties: –Ice, –IceBox, –IceGrid, –IceSSL, –IceStorm, and –Glacier2.

Parameters:

options (list of str) – The command-line options.

Returns:

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

Return type:

list of str

setProperty(key: str, value: str) None

Set 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