Initializing help system before first use

xpressinsight.AppInterface.add_item_info

Purpose
Adds the given ItemInfo object to the repository of item infos that are used in test mode.
Synopsis
add_item_info(self, item_info: xpressinsight.ItemInfo) -> None
Argument
item_info: ItemInfo 
The item information object to add. All object attributes must be populated and the path and parent_path must both be absolute paths.
Example
Demonstration of adding an item info and clearing the item info dictionary.
>>> import sys
... import xpressinsight as xi
...
... @xi.AppConfig(name="Item Info Test", scen_types=["SIMULATION"])
... class InsightApp(xi.AppBase):
...     @staticmethod
...     def print_info(info: xi.ItemInfo):
...         print('  ItemInfo:')
...         print('    name:        ', info.name)
...         print('    type:        ', info.type)
...         print('    path:        ', info.path)
...         print('    parent_path: ', info.parent_path)
...
...     @xi.ExecModeLoad(descr="Loads input data.")
...     def load(self):
...         print('Current scenario item info:')
...         self.print_info(self.insight.get_item_info("."))
...         print('Item infos in application root folder:')
...         for item in self.insight.get_item_infos(
...                 str(xi.RepositoryPath.encode(
...                     [self.insight.app_name]))):
...             self.print_info(item)
...
...     @xi.ExecModeRun(descr="Takes input and computes results.")
...     def run(self):
...         print("Run mode finished.")
...
... if __name__ == "__main__":
...     # When the application is run in test mode, first initialize
...     # the test environment, then execute the load and run modes.
...     def add_default_app_folder_item(insight: xi.AppInterface):
...         insight.add_item_info(xi.ItemInfo(
...             id=insight.app_id,
...             name='Root',
...             type='FOLDER',
...             path=str(xi.RepositoryPath.encode(
...                  [insight.app_name])),
...             parent_path=str(xi.RepositoryPath.encode(
...                  [insight.app_name]))))
...
...     def add_default_scenario_item(insight: xi.AppInterface,
...                                   scen_type: str = 'SCENARIO'):
...         insight.add_item_info(xi.ItemInfo(
...             id=insight.scenario_id,
...             name=insight.scenario_name,
...             type=scen_type,
...             path=insight.scenario_path,
...             parent_path=insight.scenario_parent_path))
...
...     app = InsightApp()
...     add_default_app_folder_item(app.insight)
...     add_default_scenario_item(app.insight)
...     app.call_exec_mode('LOAD')
...
...     app.insight.clear_item_infos()
...     app.insight.app_name = 'app 1'
...     app.insight.scenario_name = 'my_simulation 2021/09'
...     app.insight.scenario_path = str(xi.RepositoryPath.encode(
...         [app.insight.app_name, 'my_folder',
...          app.insight.scenario_name]))
...
...     add_default_app_folder_item(app.insight)
...     app.insight.add_item_info(xi.ItemInfo(
...         id='00000000-0000-0000-0000-000000000001',
...         name='my_folder',
...         type='FOLDER',
...         path=str(xi.RepositoryPath.encode(
...             [app.insight.app_name, 'my_folder'])),
...         parent_path=str(xi.RepositoryPath.encode(
...             [app.insight.app_name]))))
...     add_default_scenario_item(app.insight, 'SIMULATION')
...     app.call_exec_mode('LOAD')		
Further information
1. Used to mock the Insight repository item info when testing code in test mode.
2. The model will abort with a runtime error if an item info with the given name or path already exists.
3. Calling this procedure when AppInterface.test_mode is <tt>False</tt> will cause the model to abort with a runtime error.
Related topics

© 2001-2023 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.