Utils
CaseAndSpaceInsensitiveDict(data=None, **kwargs)
Bases: MutableMapping
A case-and-space-insensitive dict-like object with string keys.
This class implements all methods and operations of collections.abc.MutableMapping,
as well as dict's copy. It also provides adjusted_items and adjusted_keys.
All keys are expected to be strings.
The structure remembers the case of the last key set, and methods like __iter__,
keys(), items(), etc., will contain case-sensitive keys.
However, querying and membership tests are case-and-space-insensitive: data = CaseAndSpaceInsensitiveDict() data['Travel Expenses'] = 100 assert data['travelexpenses'] == 100 # True
Entries are ordered.
Initialize the dictionary with optional initial data.
Source code in TM1py/Utils/Utils.py
__contains__(key)
__delitem__(key)
Delete the item associated with the key.
__eq__(other)
Check equality with another dictionary.
Source code in TM1py/Utils/Utils.py
__getitem__(key)
Retrieve the value for a key, using the adjusted key.
Source code in TM1py/Utils/Utils.py
__iter__()
__repr__()
__setitem__(key, value)
__str__()
adjusted_items()
adjusted_keys()
clear()
copy()
get(key, default=None)
Return the value for key if key is in the dictionary, else default.
Parameters: key (str): The key to look up. default: The value to return if the key is not found.
Source code in TM1py/Utils/Utils.py
items()
keys()
pop(key, default=None)
Remove the specified key and return the corresponding value. If key is not found, default is returned if provided, otherwise KeyError is raised.
Parameters: key (str): The key to remove. default: The value to return if the key is not found.
Source code in TM1py/Utils/Utils.py
popitem()
Remove and return a (key, value) pair from the dictionary. Pairs are returned in LIFO order.
Raises: KeyError: If the dictionary is empty.
Source code in TM1py/Utils/Utils.py
setdefault(key, default=None)
If key is in the dictionary, return its value. If not, insert key with a value of default and return default.
Parameters: key (str): The key to look up or insert. default: The value to set if the key is not found.
Source code in TM1py/Utils/Utils.py
update(other=(), **kwargs)
Update the dictionary with key/value pairs from other, overwriting existing keys.
Parameters: other (Mapping or Iterable): A mapping or iterable of key-value pairs. **kwargs: Additional key-value pairs.
Source code in TM1py/Utils/Utils.py
CaseAndSpaceInsensitiveSet(*values)
Bases: MutableSet
A case-and-space-insensitive set-like object for strings.
This class implements all methods and operations of collections.abc.MutableSet.
All values are expected to be strings. The set remembers the case of the last
value added, and methods like __iter__ and __str__ will contain case-sensitive values.
However, membership tests are case-and-space-insensitive: data = CaseAndSpaceInsensitiveSet('Apple', 'Banana') assert 'apple' in data # True assert ' BANANA ' in data # True
Entries are ordered based on insertion order.
Source code in TM1py/Utils/Utils.py
__and__(other)
__contains__(value)
__delitem__(key)
__eq__(other)
Check equality with another set.
__ge__(other)
__gt__(other)
__iter__()
__le__(other)
__lt__(other)
__ne__(other)
__or__(other)
__repr__()
__str__()
__sub__(other)
add(value)
copy()
difference(*others)
Return a new set with elements in the set that are not in the others.
difference_update(*others)
discard(value)
intersection(*others)
Return a new set with elements common to the set and all others.
Source code in TM1py/Utils/Utils.py
pop()
Remove and return an arbitrary element from the set. Raises KeyError if the set is empty.
Source code in TM1py/Utils/Utils.py
union(*others)
CaseAndSpaceInsensitiveTuplesDict(data=None, **kwargs)
Bases: MutableMapping
A case-and-space-insensitive dict-like object with tuple of strings as keys.
This class implements all methods and operations of collections.abc.MutableMapping,
as well as dict's copy. It also provides adjusted_items and adjusted_keys.
All keys are expected to be tuples of strings.
The structure remembers the case of the last key set, and methods like __iter__,
keys(), items(), etc., will contain case-sensitive keys.
However, querying and membership tests are case-and-space-insensitive: data = CaseAndSpaceInsensitiveTuplesDict() data[('[Business Unit].[UK]', '[Scenario].[Worst Case]')] = 1000 assert data[('[BusinessUnit].[UK]', '[Scenario].[worstcase]')] == 1000 assert data[('[Business Unit].[UK]', '[Scenario].[Worst Case]')] == 1000
Entries are ordered.
Initialize the dictionary with optional initial data.
Source code in TM1py/Utils/Utils.py
__contains__(key)
__delitem__(key)
Delete the item associated with the key.
__eq__(other)
Check equality with another dictionary.
Source code in TM1py/Utils/Utils.py
__getitem__(key)
Retrieve the value for a key, using the adjusted key.
Source code in TM1py/Utils/Utils.py
__iter__()
__len__()
__repr__()
__setitem__(key, value)
__str__()
adjusted_items()
adjusted_keys()
clear()
copy()
get(key, default=None)
Return the value for key if key is in the dictionary, else default.
Parameters: key (tuple): The key to look up. default: The value to return if the key is not found.
Source code in TM1py/Utils/Utils.py
items()
join(other)
Merge another mapping or iterable of key-value pairs into this dictionary.
Parameters: other (Mapping or Iterable): A mapping or iterable of key-value pairs.
keys()
pop(key, default=None)
Remove the specified key and return the corresponding value. If key is not found, default is returned if provided, otherwise KeyError is raised.
Parameters: key (tuple): The key to remove. default: The value to return if the key is not found.
Source code in TM1py/Utils/Utils.py
popitem()
Remove and return a (key, value) pair from the dictionary. Pairs are returned in LIFO order.
Raises: KeyError: If the dictionary is empty.
Source code in TM1py/Utils/Utils.py
setdefault(key, default=None)
If key is in the dictionary, return its value. If not, insert key with a value of default and return default.
Parameters: key (tuple): The key to look up or insert. default: The value to set if the key is not found.
Source code in TM1py/Utils/Utils.py
update(other=(), **kwargs)
Update the dictionary with key/value pairs from other, overwriting existing keys.
Parameters: other (Mapping or Iterable): A mapping or iterable of key-value pairs. **kwargs: Additional key-value pairs.
Source code in TM1py/Utils/Utils.py
CellUpdateableProperty
Bases: Enum
CELL_IS_NOT_UPDATEABLE = 29
class-attribute
instance-attribute
CONSOLIDATION_SPREADING_HOLD = 11
class-attribute
instance-attribute
LEAF_HOLD = 10
class-attribute
instance-attribute
NO_SPREADING_HOLD = 9
class-attribute
instance-attribute
PICKLIST_EXISTS = 4
class-attribute
instance-attribute
RULE_IS_APPLIED = 3
class-attribute
instance-attribute
SANDBOX_VALUE_IS_DIFFERENT_TO_BASE = 5
class-attribute
instance-attribute
SECURITY_RESTRICTED = 1
class-attribute
instance-attribute
TEMPORARY_SPREADING_HOLD = 12
class-attribute
instance-attribute
UPDATE_CUBE_APPLICABLE = 2
class-attribute
instance-attribute
HTTPAdapterWithSocketOptions(*args, **kwargs)
Bases: HTTPAdapter
Source code in TM1py/Utils/Utils.py
socket_options = kwargs.pop('socket_options', None)
instance-attribute
ssl_context = kwargs.pop('ssl_context', None)
instance-attribute
init_poolmanager(*args, **kwargs)
Source code in TM1py/Utils/Utils.py
abbreviate_mdx(mdx, size=100)
add_url_parameters(url, **kwargs)
Append parameters to url string passed in kwargs
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str |
required | |
kwargs
|
str
|
key:value pairs of url parameters. For example, {'$select':'Name'} |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
str |
Source code in TM1py/Utils/Utils.py
aggregate_duplicate_intersections(df, dimension_headers, value_header)
build_cellset_from_pandas_dataframe(df, sum_numeric_duplicates=True)
param sum_numeric_duplicates: Aggregate numerical values for duplicated intersections param df: a Pandas Dataframe, with dimension-column mapping in correct order. As created in build_pandas_dataframe_from_cellset
Returns:
| Type | Description |
|---|---|
CaseAndSpaceInsensitiveTuplesDict
|
a CaseAndSpaceInsensitiveTuplesDict |
Source code in TM1py/Utils/Utils.py
build_content_from_cellset_dict(raw_cellset_as_dict, top=None, element_unique_names=True, skip_cell_properties=False, skip_sandbox_dimension=False)
transform raw cellset data into concise dictionary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_cellset_as_dict
|
Dict
|
|
required |
top
|
Optional[int]
|
Int, number of cells to return (counting from top) |
None
|
element_unique_names
|
bool
|
'[d1].[h1].[e1]' or 'e1' |
True
|
skip_cell_properties
|
bool
|
cell values in result dictionary, instead of cell_properties dictionary |
False
|
skip_sandbox_dimension
|
bool
|
skip sandbox dimension |
False
|
Returns:
| Type | Description |
|---|---|
CaseAndSpaceInsensitiveTuplesDict
|
|
Source code in TM1py/Utils/Utils.py
build_csv_from_cellset_dict(row_dimensions, column_dimensions, raw_cellset_as_dict, top=None, csv_dialect=None, line_separator='\r\n', value_separator=',', include_attributes=False, include_headers=True, mdx_headers=False)
transform raw cellset data into concise dictionary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column_dimensions
|
List[str]
|
|
required |
row_dimensions
|
List[str]
|
|
required |
raw_cellset_as_dict
|
Dict
|
|
required |
top
|
Optional[int]
|
Maximum Number of cells |
None
|
csv_dialect
|
Dialect
|
provide all csv output settings through standard library csv.Dialect If not provided dialect is created based on line_separator and value_separator arguments. |
None
|
line_separator
|
str
|
|
'\r\n'
|
value_separator
|
str
|
|
','
|
include_attributes
|
bool
|
include attribute columns |
False
|
include_headers
|
bool
|
bool |
True
|
mdx_headers
|
bool
|
boolean. Fully qualified hierarchy name as header instead of simple dimension name |
False
|
Returns:
| Type | Description |
|---|---|
str
|
|
Source code in TM1py/Utils/Utils.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 | |
build_dataframe_aggregate_intersections(df, sum_numeric_duplicates=True)
param sum_numeric_duplicates: Aggregate numerical values for duplicated intersections param df: A Dataframe, with dimension-column mapping in correct order.
Returns:
| Type | Description |
|---|---|
DataFrame
|
A Dataframe |
Source code in TM1py/Utils/Utils.py
build_dataframe_from_csv(raw_csv, sep='~', shaped=False, fillna_numeric_attributes=False, fillna_numeric_attributes_value=0, fillna_string_attributes=False, fillna_string_attributes_value='', attribute_types_by_dimension=None, **kwargs)
Source code in TM1py/Utils/Utils.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | |
build_element_unique_names(dimension_names, element_names, hierarchy_names=None)
Create tuple of unique names from dimension, hierarchy and elements
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension_names
|
Iterable[str]
|
|
required |
element_names
|
Iterable[str]
|
|
required |
hierarchy_names
|
Optional[Iterable[str]]
|
|
None
|
Returns:
| Type | Description |
|---|---|
Generator
|
Generator |
Source code in TM1py/Utils/Utils.py
build_headers_from_cellset(raw_cellset_as_dict, force_header_dimensionality=1)
Extract dimension headers from cellset into dictionary of titles (slicers) and headers (row,column,page) * Title dimensions are in a single list of dicts * Header dimensions are a 2-dimensional list of the element dicts * The first dimension in the header list is the axis * The second dimension is the list of elements on the axis * Dict format: {'name': 'element or compound name', 'members': [ {dict of dimension properties}, ... ] } * Stacked headers on an axis will have a compount 'name' created by joining the member's 'Name' properties with a '/' * Stacked headers will each be listed in the 'memebers' list; Single-element headers will only have one element in list
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_cellset_as_dict
|
Dict
|
raw data from TM1 |
required |
force_header_dimensionality
|
int
|
An optional integer (1,2 or 3) to force headers array to be at least that long |
1
|
Returns:
| Type | Description |
|---|---|
Dict
|
dict : |
Source code in TM1py/Utils/Utils.py
build_mdx_and_values_from_cellset(cells, cube_name, dimensions)
Source code in TM1py/Utils/Utils.py
build_mdx_from_cellset(cells, cube_name, dimensions)
Source code in TM1py/Utils/Utils.py
build_pandas_dataframe_from_cellset(cellset, multiindex=True, sort_values=True)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cellset
|
Dict
|
|
required |
multiindex
|
bool
|
True or False |
True
|
sort_values
|
bool
|
Boolean to control sorting in result DataFrame |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Source code in TM1py/Utils/Utils.py
build_ui_arrays_from_cellset(raw_cellset_as_dict, value_precision, top=None)
Transform raw 1,2 or 3-dimension cellset data into concise dictionary * Useful for grids or charting libraries that want an array of cell values per row * Returns 3-dimensional cell structure for tabbed grids or multiple charts * Rows and pages are dicts, addressable by their name. Proper order of rows can be obtained in headers[1] * Example 'cells' return format:
'cells': {
'10100': {
'Net Operating Income': [ 19832724.72429739,
20365654.788303416,
20729201.329183243,
20480205.20121749],
'Revenue': [ 28981046.50724231,
29512482.207418434,
29913730.038971487,
29563345.9542385]},
'10200': {
'Net Operating Income': [ 9853293.623709997,
10277650.763958748,
10466934.096533755,
10333095.839474997],
'Revenue': [ 13888143.710000003,
14300216.43,
14502421.63,
14321501.940000001]}
},
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_cellset_as_dict
|
Dict
|
raw data from TM1 |
required |
value_precision
|
int
|
Integer (optional) specifying number of decimal places to return |
required |
top
|
int
|
Int, number of cells to return (counting from top) |
None
|
Returns:
| Type | Description |
|---|---|
|
dict : |
Source code in TM1py/Utils/Utils.py
build_ui_dygraph_arrays_from_cellset(raw_cellset_as_dict, value_precision=None)
Transform raw 1,2 or 3-dimension cellset data into dygraph-friendly format * Useful for grids or charting libraries that want an array of cell values per column * Returns 3-dimensional cell structure for tabbed grids or multiple charts * Example 'cells' return format:
'cells': {
'10100': [
['Q1-2004', 28981046.50724231, 19832724.72429739],
['Q2-2004', 29512482.207418434, 20365654.788303416],
['Q3-2004', 29913730.038971487, 20729201.329183243],
['Q4-2004', 29563345.9542385, 20480205.20121749]],
'10200': [
['Q1-2004', 13888143.710000003, 9853293.623709997],
['Q2-2004', 14300216.43, 10277650.763958748],
['Q3-2004', 14502421.63, 10466934.096533755],
['Q4-2004', 14321501.940000001, 10333095.839474997]]
},
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_cellset_as_dict
|
Dict
|
raw data from TM1 |
required |
value_precision
|
int
|
Integer (optional) specifying number of decimal places to return |
None
|
Returns:
| Type | Description |
|---|---|
|
dict : |
Source code in TM1py/Utils/Utils.py
build_url_friendly_object_name(object_name)
case_and_space_insensitive_equals(item1, item2)
cell_is_updateable(cell)
Function checks if the cell can be updated
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cell
|
dict
|
dict cell including Updateable property |
required |
Returns:
| Type | Description |
|---|---|
bool
|
bool |
Source code in TM1py/Utils/Utils.py
create_server_on_adminhost(adminhost='localhost', server_as_dict=None)
Source code in TM1py/Utils/Utils.py
decohints(decorator)
Decorator for decorators to see parameters of decorated functions in PyCharm
Implementation of https://github.com/gri-gus/decohints
delete_server_on_adminhost(adminhost=None, server_name=None)
Source code in TM1py/Utils/Utils.py
deprecated_in_version(version)
Higher order function to check required version for TM1py function
Source code in TM1py/Utils/Utils.py
dimension_hierarchy_element_tuple_from_unique_name(element_unique_name)
Extract dimension name, hierarchy name and element name from element unique name. Works with explicit and implicit hierarchy references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element_unique_name
|
str
|
e.g. [d1].[e1] or [d1].[leaves].[e1] |
required |
Returns:
| Type | Description |
|---|---|
Tuple[str, str, str]
|
tuple of dimension name, hierarchy name, element name |
Source code in TM1py/Utils/Utils.py
dimension_name_from_element_unique_name(element_unique_name)
dimension_names_from_element_unique_names(element_unique_names)
Get tuple of simple element names from the full element unique names
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element_unique_names
|
Iterable[str]
|
tuple of element unique names ([dim1].[hier1].[elem1], ... ) |
required |
Returns:
| Type | Description |
|---|---|
Tuple[str]
|
tuple of element names: (elem1, elem2, ... ) |
Source code in TM1py/Utils/Utils.py
drop_dimension_properties(mdx)
element_name_from_element_unique_name(element_unique_name)
element_names_from_element_unique_names(element_unique_names)
Get tuple of simple element names from the full element unique names
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element_unique_names
|
Iterable[str]
|
tuple of element unique names ([dim1].[hier1].[elem1], ... ) |
required |
Returns:
| Type | Description |
|---|---|
Tuple[str]
|
tuple of element names: (elem1, elem2, ... ) |
Source code in TM1py/Utils/Utils.py
extract_axes_from_cellset(raw_cellset_as_dict)
Source code in TM1py/Utils/Utils.py
extract_cell_properties_from_odata_context(context)
Takes in an odata_context and returns a list of properties e.g [Ordinal, Value, RuleDerived, ...]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
str
|
A valid odata_context returned when querying cells |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
|
Source code in TM1py/Utils/Utils.py
extract_cell_updateable_property(decimal_value, cell_property)
Function converts passed decimal (integer) value to binary and extracts specified (cell_property) bit counting from the right. It will return TRUE if bit is set, and FALSE if bit is not set Each cell has 'Updateable' property - a decimal value, which needs to be converted to binary to get information about the cell
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
decimal_value
|
int
|
int Decimal number |
required |
cell_property
|
CellUpdateableProperty
|
CellUpdateableProperty enum property to extract from decimal value |
required |
Returns:
| Type | Description |
|---|---|
bool
|
bool |
Source code in TM1py/Utils/Utils.py
extract_compact_json_cellset(context, response, return_as_dict)
Translates odata compact response json into default dictionary response or plain list (e.g., list of values)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
str
|
The context field from the TM1 response JSON |
required |
response
|
Dict
|
The JSON response |
required |
return_as_dict
|
bool
|
boolean |
required |
Returns:
| Type | Description |
|---|---|
Union[Dict, List]
|
|
Source code in TM1py/Utils/Utils.py
extract_element_names_from_members(members)
Extract list of unique names from part of the cellset response in: [{'UniqueName': '[dim1].[dim1].[elem1]', 'Element': {'UniqueName': '[dim1].[dim1].[elem1]'}}, {'UniqueName': '[dim2].[dim2].[elem3]', 'Element': {'UniqueName': '[dim2].[dim2].[elem3]'}}] out: ["elem1", "elem3"]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
members
|
Iterable[Dict]
|
dictionary |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
list of unique names |
Source code in TM1py/Utils/Utils.py
extract_unique_names_from_members(members)
Extract list of unique names from part of the cellset response in: [{'UniqueName': '[dim1].[dim1].[elem1]', 'Element': {'UniqueName': '[dim1].[dim1].[elem1]'}}, {'UniqueName': '[dim2].[dim2].[elem3]', 'Element': {'UniqueName': '[dim2].[dim2].[elem3]'}}] out: ["[dim1].[dim1].[elem1]", "[dim2].[dim2].[elem3]"]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
members
|
Iterable[Dict]
|
dictionary |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
list of unique names |
Source code in TM1py/Utils/Utils.py
format_url(url, *args, **kwargs)
build url and escape single quotes in args and kwargs
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
url with {} placeholders |
required | |
args
|
str
|
arguments to placeholders |
()
|
Returns:
| Type | Description |
|---|---|
str
|
|
Source code in TM1py/Utils/Utils.py
frame_to_significant_digits(x, digits=15)
get_all_servers_from_adminhost(adminhost='localhost', port=None, use_ssl=False)
Source code in TM1py/Utils/Utils.py
get_cube(mdx)
Source code in TM1py/Utils/Utils.py
get_dimensions_from_where_clause(mdx)
Source code in TM1py/Utils/Utils.py
get_seconds_from_duration(time_str)
This function will convert the TM1 time to seconds
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_str
|
str
|
P0DT00H01M43S |
required |
Returns:
| Type | Description |
|---|---|
int
|
int |
Source code in TM1py/Utils/Utils.py
get_tm1_time_value_now(use_excel_serial_date=False)
This function can be used to replicate TM1's NOW function to return current date/time value in serial number format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
use_excel_serial_date
|
bool
|
Boolean |
False
|
Returns:
| Type | Description |
|---|---|
float
|
serial number |
Source code in TM1py/Utils/Utils.py
hierarchy_name_from_element_unique_name(element_unique_name)
integerize_version(version, precision=4)
lower_and_drop_spaces(item)
map_cell_properties_to_compact_json_response(properties, compact_cells_response)
Map cell properties to compact json response e.g properties = [Ordinal, Value, RuleDerived] compact_cells_response = [[0, 258, 100], [1, 258, 500]] result: {Cells: [ { Ordinal: 0, Value: 100, RuleDerived: 258}, { Ordinal: 1, Value: 500, RuleDerived: 258} ]}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
properties
|
List
|
list of |
required |
compact_cells_response
|
List
|
list of cells returned in compact json format |
required |
Returns:
| Type | Description |
|---|---|
Dict
|
dict with properties mapped to compact json response |
Source code in TM1py/Utils/Utils.py
odata_track_changes_header(func)
Higher Order function to handle addition and removal of odata.track-changes HTTP Header
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
|
required |
Returns:
| Type | Description |
|---|---|
|
|
Source code in TM1py/Utils/Utils.py
read_object_name_from_url(url, pattern)
reorder_with_priority(original_items, priority_items=None, exclude_items=None, sort_remaining=True, **kwargs)
Reorder a list of original items so that items in 'priority_items' list appear first (in specified order), followed by the remaining items of original items. The order of the remaining items depends on the 'sort_remaining' parameter: if True, the original order is preserved; if False, the items are sorted alphabetically. Items in the 'exclude_items' list are omitted. Missing priority items and exclude items are ignored.
Example case: hierarchy names "correct" order: first the main hierarchy name (matching the dimension name), then the Leaves hierarchy, then the other hierarchy names (sorted or not). When trying to create the Leaves hierarchy when it already exists (because of creating a different alternate hierarchy), an error pops up. Set exclude_items equal to ['Leaves'].
Source code in TM1py/Utils/Utils.py
require_admin(func)
require_data_admin(func)
require_ops_admin(func)
require_pandas(func)
Source code in TM1py/Utils/Utils.py
require_security_admin(func)
Source code in TM1py/Utils/Utils.py
require_version(version)
Higher order function to check required version for TM1py function
Source code in TM1py/Utils/Utils.py
resembles_mdx(mdx)
sort_coordinates(cube_dimensions, unsorted_coordinates, element_unique_names)
Source code in TM1py/Utils/Utils.py
update_server_on_adminhost(adminhost='localhost', server_as_dict=None)
Source code in TM1py/Utils/Utils.py
utc_localize_time(timestamp)
verify_version(required_version, version)
wrap_in_curly_braces(expression)
Put curly braces around a string
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
str
|
|
required |
Returns:
| Type | Description |
|---|---|
str
|
|