Ejemplo n.º 1
0
def update_sign_library_rel_path(scs_sign_model_inventory,
                                 sign_library_rel_path,
                                 readonly=False):
    """The function deletes and populates again a list of Sign names in inventory. It also updates corresponding record in config file.

    :param sign_library_rel_path: Relative path to the directory with Sign files
    :type sign_library_rel_path: str
    """
    sign_library_filepath = _path_utils.get_abs_path(sign_library_rel_path)
    if sign_library_filepath:

        if _get_scs_globals().sign_library_use_infixed:
            sign_library_filepaths = _path_utils.get_all_infixed_file_paths(
                sign_library_filepath)
        else:
            sign_library_filepaths = [sign_library_filepath]

        # CLEAR INVENTORY
        scs_sign_model_inventory.clear()

        for sign_library_filepath in sign_library_filepaths:

            sign_container = _sii.get_data_from_file(sign_library_filepath)
            if sign_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in sign_container:
                    if item.type == 'sign_model':
                        if item.id.startswith('sign.'):
                            if 'sign_name' in item.props:
                                sign_name = item.props['sign_name']
                            else:
                                continue

                            sign_item = scs_sign_model_inventory.add()
                            sign_item.name = sign_name + " : " + item.id[5:]
                            sign_item.item_id = item.id[5:]

                            if 'model_desc' in item.props:
                                sign_item.model_desc = item.props['model_desc']

                            if 'look_name' in item.props:
                                sign_item.look_name = item.props['look_name']

                            if 'category' in item.props:
                                sign_item.category = item.props['category']

                            if 'dynamic' in item.props:
                                if item.props['dynamic'] == 'true':
                                    sign_item.dynamic = True

    if not readonly:
        update_item_in_file('Paths.SignRelFilePath', sign_library_rel_path)
Ejemplo n.º 2
0
def update_sign_library_rel_path(scs_sign_model_inventory, sign_library_rel_path, readonly=False):
    """The function deletes and populates again a list of Sign names in inventory. It also updates corresponding record in config file.

    :param sign_library_rel_path: Relative path to the directory with Sign files
    :type sign_library_rel_path: str
    """
    sign_library_filepath = _path_utils.get_abs_path(sign_library_rel_path)
    if sign_library_filepath:

        if _get_scs_globals().sign_library_use_infixed:
            sign_library_filepaths = _path_utils.get_all_infixed_file_paths(sign_library_filepath)
        else:
            sign_library_filepaths = [sign_library_filepath]

        # CLEAR INVENTORY
        scs_sign_model_inventory.clear()

        for sign_library_filepath in sign_library_filepaths:

            sign_container = _sii.get_data_from_file(sign_library_filepath)
            if sign_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in sign_container:
                    if item.type == 'sign_model':
                        if item.id.startswith('sign.'):
                            if 'sign_name' in item.props:
                                sign_name = item.props['sign_name']
                            else:
                                continue

                            sign_item = scs_sign_model_inventory.add()
                            sign_item.name = sign_name + " : " + item.id[5:]
                            sign_item.item_id = item.id[5:]

                            if 'model_desc' in item.props:
                                sign_item.model_desc = item.props['model_desc']

                            if 'look_name' in item.props:
                                sign_item.look_name = item.props['look_name']

                            if 'category' in item.props:
                                sign_item.category = item.props['category']

                            if 'dynamic' in item.props:
                                if item.props['dynamic'] == 'true':
                                    sign_item.dynamic = True

    if not readonly:
        update_item_in_file('Paths.SignRelFilePath', sign_library_rel_path)
Ejemplo n.º 3
0
def update_traffic_rules_library_rel_path(scs_traffic_rules_inventory,
                                          traffic_rules_library_rel_path,
                                          readonly=False):
    """The function deletes and populates again a list of Traffic Rules names in inventory. It also updates corresponding record in config file.

    :param traffic_rules_library_rel_path: Relative path to the directory with Traffic Rules files
    :type traffic_rules_library_rel_path: str
    """
    traffic_rules_library_filepath = _path_utils.get_abs_path(
        traffic_rules_library_rel_path)
    if traffic_rules_library_filepath:

        if _get_scs_globals().traffic_rules_library_use_infixed:
            traffic_rules_library_filepaths = _path_utils.get_all_infixed_file_paths(
                traffic_rules_library_filepath)
        else:
            traffic_rules_library_filepaths = [traffic_rules_library_filepath]

        # CLEAR INVENTORY
        scs_traffic_rules_inventory.clear()

        for traffic_rules_library_filepath in traffic_rules_library_filepaths:

            trul_container = _sii.get_data_from_file(
                traffic_rules_library_filepath)
            if trul_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in trul_container:
                    if item.type == 'traffic_rule_data':
                        if item.id.startswith('traffic_rule.'):
                            traffic_rule_item = scs_traffic_rules_inventory.add(
                            )
                            traffic_rule_item.name = item.id[13:]
                            # traffic_rule_item.item_id = item.id[13:]

                            if 'rule' in item.props:
                                traffic_rule_item.rule = item.props['rule']

                            if 'num_params' in item.props:
                                traffic_rule_item.num_params = str(
                                    item.props['num_params'])

    if not readonly:
        update_item_in_file('Paths.TrafficRulesRelFilePath',
                            traffic_rules_library_rel_path)
Ejemplo n.º 4
0
def update_tsem_library_rel_path(scs_tsem_profile_inventory,
                                 tsem_library_rel_path,
                                 readonly=False):
    """The function deletes and populates again a list of Traffic Semaphore Profile names in inventory. It also updates corresponding record in
    config file.

    :param tsem_library_rel_path: Relative path to the directory with Traffic Semaphore Profile files
    :type tsem_library_rel_path: str
    """
    tsem_library_filepath = _path_utils.get_abs_path(tsem_library_rel_path)
    if tsem_library_filepath:

        if _get_scs_globals().tsem_library_use_infixed:
            tsem_library_filepaths = _path_utils.get_all_infixed_file_paths(
                tsem_library_filepath)
        else:
            tsem_library_filepaths = [tsem_library_filepath]

        # CLEAR INVENTORY
        scs_tsem_profile_inventory.clear()

        for tsem_library_filepath in tsem_library_filepaths:

            tsem_container = _sii.get_data_from_file(tsem_library_filepath)
            if tsem_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in tsem_container:
                    if item.type == 'tr_semaphore_profile':
                        if item.id.startswith('tr_sem_prof.'):
                            if 'name' in item.props:
                                tsem_name = item.props['name']
                            else:
                                continue

                            tsem_item = scs_tsem_profile_inventory.add()
                            tsem_item.name = tsem_name + " : " + item.id[12:]
                            tsem_item.item_id = item.id[12:]

                            if 'model' in item.props:
                                tsem_item.model = item.props['model'][0]

    if not readonly:
        update_item_in_file('Paths.TSemProfileRelFilePath',
                            tsem_library_rel_path)
Ejemplo n.º 5
0
def update_trigger_actions_rel_path(scs_trigger_actions_inventory,
                                    trigger_actions_rel_path,
                                    readonly=False):
    """The function deletes and populates again a list of Trigger Actions in inventory. It also updates corresponding record in config file.

    :param trigger_actions_rel_path: Relative path to the directory with Trigger Action files
    :type trigger_actions_rel_path: str
    """
    trig_actions_path = _path_utils.get_abs_path(trigger_actions_rel_path)
    if trig_actions_path:

        if _get_scs_globals().trigger_actions_use_infixed:
            trig_actions_paths = _path_utils.get_all_infixed_file_paths(
                trig_actions_path)
        else:
            trig_actions_paths = [trig_actions_path]

        # CLEAR INVENTORY
        scs_trigger_actions_inventory.clear()

        for trig_actions_path in trig_actions_paths:

            trig_actions_container = _sii.get_data_from_file(trig_actions_path)
            if trig_actions_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in trig_actions_container:
                    if item.type == 'trigger_action':
                        if item.id.startswith('trig_action.'):
                            if 'name' in item.props:
                                trg_action_name = item.props['name']
                            else:
                                continue

                            trig_item = scs_trigger_actions_inventory.add()
                            trig_item.name = trg_action_name + " : " + item.id[
                                12:]
                            trig_item.item_id = item.id[12:]

    if not readonly:
        update_item_in_file('Paths.TriggerActionsRelFilePath',
                            trigger_actions_rel_path)
Ejemplo n.º 6
0
def update_tsem_library_rel_path(scs_tsem_profile_inventory, tsem_library_rel_path, readonly=False):
    """The function deletes and populates again a list of Traffic Semaphore Profile names in inventory. It also updates corresponding record in
    config file.

    :param tsem_library_rel_path: Relative path to the directory with Traffic Semaphore Profile files
    :type tsem_library_rel_path: str
    """
    tsem_library_filepath = _path_utils.get_abs_path(tsem_library_rel_path)
    if tsem_library_filepath:

        if _get_scs_globals().tsem_library_use_infixed:
            tsem_library_filepaths = _path_utils.get_all_infixed_file_paths(tsem_library_filepath)
        else:
            tsem_library_filepaths = [tsem_library_filepath]

        # CLEAR INVENTORY
        scs_tsem_profile_inventory.clear()

        for tsem_library_filepath in tsem_library_filepaths:

            tsem_container = _sii.get_data_from_file(tsem_library_filepath)
            if tsem_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in tsem_container:
                    if item.type == 'tr_semaphore_profile':
                        if item.id.startswith('tr_sem_prof.'):
                            if 'name' in item.props:
                                tsem_name = item.props['name']
                            else:
                                continue

                            tsem_item = scs_tsem_profile_inventory.add()
                            tsem_item.name = tsem_name + " : " + item.id[12:]
                            tsem_item.item_id = item.id[12:]

                            if 'model' in item.props:
                                tsem_item.model = item.props['model'][0]

    if not readonly:
        update_item_in_file('Paths.TSemProfileRelFilePath', tsem_library_rel_path)
Ejemplo n.º 7
0
def update_traffic_rules_library_rel_path(scs_traffic_rules_inventory, traffic_rules_library_rel_path, readonly=False):
    """The function deletes and populates again a list of Traffic Rules names in inventory. It also updates corresponding record in config file.

    :param traffic_rules_library_rel_path: Relative path to the directory with Traffic Rules files
    :type traffic_rules_library_rel_path: str
    """
    traffic_rules_library_filepath = _path_utils.get_abs_path(traffic_rules_library_rel_path)
    if traffic_rules_library_filepath:

        if _get_scs_globals().traffic_rules_library_use_infixed:
            traffic_rules_library_filepaths = _path_utils.get_all_infixed_file_paths(traffic_rules_library_filepath)
        else:
            traffic_rules_library_filepaths = [traffic_rules_library_filepath]

        # CLEAR INVENTORY
        scs_traffic_rules_inventory.clear()

        for traffic_rules_library_filepath in traffic_rules_library_filepaths:

            trul_container = _sii.get_data_from_file(traffic_rules_library_filepath)
            if trul_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in trul_container:
                    if item.type == 'traffic_rule_data':
                        if item.id.startswith('traffic_rule.'):
                            traffic_rule_item = scs_traffic_rules_inventory.add()
                            traffic_rule_item.name = item.id[13:]
                            # traffic_rule_item.item_id = item.id[13:]

                            if 'rule' in item.props:
                                traffic_rule_item.rule = item.props['rule']

                            if 'num_params' in item.props:
                                traffic_rule_item.num_params = str(item.props['num_params'])

    if not readonly:
        update_item_in_file('Paths.TrafficRulesRelFilePath', traffic_rules_library_rel_path)
Ejemplo n.º 8
0
def update_trigger_actions_rel_path(scs_trigger_actions_inventory, trigger_actions_rel_path, readonly=False):
    """The function deletes and populates again a list of Trigger Actions in inventory. It also updates corresponding record in config file.

    :param trigger_actions_rel_path: Relative path to the directory with Trigger Action files
    :type trigger_actions_rel_path: str
    """
    trig_actions_path = _path_utils.get_abs_path(trigger_actions_rel_path)
    if trig_actions_path:

        if _get_scs_globals().trigger_actions_use_infixed:
            trig_actions_paths = _path_utils.get_all_infixed_file_paths(trig_actions_path)
        else:
            trig_actions_paths = [trig_actions_path]

        # CLEAR INVENTORY
        scs_trigger_actions_inventory.clear()

        for trig_actions_path in trig_actions_paths:

            trig_actions_container = _sii.get_data_from_file(trig_actions_path)
            if trig_actions_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in trig_actions_container:
                    if item.type == 'trigger_action':
                        if item.id.startswith('trig_action.'):
                            if 'name' in item.props:
                                trg_action_name = item.props['name']
                            else:
                                continue

                            trig_item = scs_trigger_actions_inventory.add()
                            trig_item.name = trg_action_name + " : " + item.id[12:]
                            trig_item.item_id = item.id[12:]

    if not readonly:
        update_item_in_file('Paths.TriggerActionsRelFilePath', trigger_actions_rel_path)