Skip to content

manage_04_deleting_property_templates

cspayne edited this page Sep 22, 2023 · 8 revisions

Deleting resource template property templates from prop sets

This is done with delete_pts.py

This script:

  • Accepts an RT id as input
  • Iterates through each prop_set and removes implementation_set elements containing that id

Note: This script only deletes property templates from prop_set files. If you are trying to delete an RT completely, deleting RT serializations from sinopia_maps must be done manually. RTs can be deleted from Sinopia environments using 002_delete_loaded_RTs_resources.py.

Dependencies

Installing Python packages may require pip in place of pip3 for some systems

  • Python for Windows or WSL (recommend v3.8 or above)
  • lxml.etree
    • $ pip3 install lxml
  • Java

Running the script

Running scripts with certain Python versions may require python in place of python3 for some systems
Run the script from the map_storage top-level folder

$ python3 py/delete_pts.py

Enter the id of the resource template you wish to remove from the prop_set files when prompted.

This will be in the format UWSINOPIA_Institution_Resource_Format_User

Workflow

This script:

  • Creates a tree out of each prop_set file
  • Iterates through the tree to find each sinopia element
  • Uses check_sinopia() function to determine if the implementation_set element(s) within the sinopia element contain more than one RT id (and are therefore used in more than one resource template)
  • Calls remove_single_id() or remove_multi_id() functions to remove the matching implementation_sets from the prop_set tree
  • Writes the updated tree to the prop_set file

remove_single_id()

This function:

  • Is called if there is only one instance of each RT id element within the implementation_set
  • Determines if the implementation_set id elements match the given RT id
  • If it is a match and the implementation_set is the only implementation_set within the sinopia element, the entire sinopia element is deleted
  • If it is a match but there are multiple implementation_set elements within this sinopia element, only the matching implementation_set is deleted, along with any specific guidance for this RT using the check_guidance() function

remove_multi_id()

This function:

  • Is called if there is more than one instance of any of the id elements within the implementation_set (institution, resource, format, and user)
  • Determines if the implementation_set id elements match the given RT id
  • If there is a match, removes the matching id element if there are multiple id elements of that type (e.g. if there are two resource elements, it will remove the resource element that matches the RT id) and any specific guidance for this RT using the check_guidance() function