mxcubecore.utils.conversion#

General data and functions, that can be shared between different HardwareObjects

Functions

camel_to_snake(name)

command_option(keyword, value[, prefix, ...])

Return argument list for command line option

convert_string_value(text)

Convert input string to int, float, or string (in order of priority)

ensure_text(chars[, encoding, errors])

Coerce chars to six.text_type. For Python 2: - unicode -> unicode - str -> unicode For Python 3: - str -> str - bytes -> decoded to str.

java_property(keyword, value[, quote_value])

Return argument list for command line invocation setting java property

make_table(column_names, rows)

Generate string with pretty-printed table

quoted_string(text)

Return quoted value of a (single-line) string

mxcubecore.utils.conversion.command_option(keyword, value, prefix='-', quote_value=False)[source]#

Return argument list for command line option

mxcubecore.utils.conversion.convert_string_value(text)[source]#

Convert input string to int, float, or string (in order of priority)

mxcubecore.utils.conversion.ensure_text(chars, encoding='utf-8', errors='strict')[source]#

Coerce chars to six.text_type. For Python 2:

  • unicode -> unicode

  • str -> unicode

For Python 3:
  • str -> str

  • bytes -> decoded to str

mxcubecore.utils.conversion.java_property(keyword, value, quote_value=False)[source]#

Return argument list for command line invocation setting java property

keyword, value are stringtypes

mxcubecore.utils.conversion.make_table(column_names, rows)[source]#

Generate string with pretty-printed table

Parameters:
  • column_names (Sequence[str]) – Column names

  • rows (Sequence[Sequence[str]]) – List of row data

Returns:

mxcubecore.utils.conversion.quoted_string(text)[source]#

Return quoted value of a (single-line) string

Intended for command line arguments. Will work for Python 2 str or unicode, OR Python 3 str and (some) bytes). Somewhat fragile, will definitely break for multiline strings or strings containing both single and double quotes