fosKeyMan
|
Handle reading JSON files (userProperties.json and gageSegment.json) from keyfile folders located in activated or deactivated directories. More...
Public Member Functions | |
__init__ (self, activated_path, deactivated_path) | |
Initialize the FolderContent with paths for activated and deactivated keyfile directories. | |
edit_sensor_name_for_key (self, key, new_sensor_name) | |
Edit the userSensorName for a specified key in the userProperties.json file and synchronize the lastEditDate. | |
full_text_search (self, search_term, keyfile=None) | |
Full-text search inside all JSON files. | |
get_last_edit_date (self, key) | |
Retrieve the lastEditDate from the userProperties.json file of the specified key's ZIP file. | |
load_json (self, file_path) | |
Load and parse a JSON file from within a key file. | |
read_gage_segment (self, key) | |
Read the content of the gageSegment.json file from the specified key's keyfile folder. | |
read_metadata (self, key) | |
Read the content of the metadata.json file from the specified key file. | |
read_od6ref_file (self, key) | |
Read the first line of the .od6ref file from the specified key's keyfile folder. | |
read_sensor_length_for_key (self, key) | |
Read the "sensorLength (m)" value from the .od6ref file in the specified key's folder. | |
read_sensor_name_for_key (self, key) | |
Read the userSensorName from the userProperties.json file in the specified key's folder. | |
read_user_properties (self, key) | |
Read the content of the userProperties.json file from the specified key's folder. | |
search_in_folder (self, folder_path, search_term) | |
Search inside a key file folder for the given search term in the JSON files. | |
search_in_json (self, data, search_term) | |
Recursively search through a JSON for the search term, case-insensitive, with partial matching. | |
update_metadata (self, key, metadata) | |
Update the metadata.json for a given key (serial number). | |
Public Attributes | |
activated_path = activated_path | |
deactivated_path = deactivated_path | |
Handle reading JSON files (userProperties.json and gageSegment.json) from keyfile folders located in activated or deactivated directories.
Also reads and updates the metadata.json file.
Definition at line 15 of file foldercontent.py.
src.backend.foldercontent.FolderContent.__init__ | ( | self, | |
activated_path, | |||
deactivated_path ) |
Initialize the FolderContent with paths for activated and deactivated keyfile directories.
activated_path | (str): The path to the directory containing activated keyfiles. |
deactivated_path | (str): The path to the directory containing deactivated keyfiles. |
Definition at line 20 of file foldercontent.py.
src.backend.foldercontent.FolderContent.edit_sensor_name_for_key | ( | self, | |
key, | |||
new_sensor_name ) |
Edit the userSensorName for a specified key in the userProperties.json file and synchronize the lastEditDate.
key | (str): The key whose userSensorName needs to be updated. |
new_sensor_name | (str): The new sensor name to set. |
Definition at line 203 of file foldercontent.py.
src.backend.foldercontent.FolderContent.full_text_search | ( | self, | |
search_term, | |||
keyfile = None ) |
Full-text search inside all JSON files.
search_term | (str): The term to search within the JSON files. |
keyfile | (str or None): The specific key for keyfile to search within. If None, search in all keyfile folders. |
Definition at line 96 of file foldercontent.py.
src.backend.foldercontent.FolderContent.get_last_edit_date | ( | self, | |
key ) |
Retrieve the lastEditDate from the userProperties.json file of the specified key's ZIP file.
key | (str): The name of the key to locate its corresponding ZIP file. |
Definition at line 174 of file foldercontent.py.
src.backend.foldercontent.FolderContent.load_json | ( | self, | |
file_path ) |
Load and parse a JSON file from within a key file.
file_path | (str): The path to the JSON or binary file. |
Definition at line 78 of file foldercontent.py.
src.backend.foldercontent.FolderContent.read_gage_segment | ( | self, | |
key ) |
Read the content of the gageSegment.json file from the specified key's keyfile folder.
Similar to read_user_properties
, this method checks if the key's keyfile folder exists in the activated or deactivated directories and attempts to load the 'gageSegment.json' file from within the folder.
key | (str): The name of the key to locate its corresponding key file folder. |
Definition at line 46 of file foldercontent.py.
src.backend.foldercontent.FolderContent.read_metadata | ( | self, | |
key ) |
Read the content of the metadata.json file from the specified key file.
key | The name of the key to locate its corresponding folder. |
Definition at line 240 of file foldercontent.py.
src.backend.foldercontent.FolderContent.read_od6ref_file | ( | self, | |
key ) |
Read the first line of the .od6ref file from the specified key's keyfile folder.
key | (str): The name of the key to locate its corresponding folder. |
Definition at line 63 of file foldercontent.py.
src.backend.foldercontent.FolderContent.read_sensor_length_for_key | ( | self, | |
key ) |
Read the "sensorLength (m)" value from the .od6ref file in the specified key's folder.
key | (str): The name of the key to locate its corresponding folder. |
Definition at line 228 of file foldercontent.py.
src.backend.foldercontent.FolderContent.read_sensor_name_for_key | ( | self, | |
key ) |
Read the userSensorName from the userProperties.json file in the specified key's folder.
key | (str): The name of the key to locate its corresponding folder. |
Definition at line 191 of file foldercontent.py.
src.backend.foldercontent.FolderContent.read_user_properties | ( | self, | |
key ) |
Read the content of the userProperties.json file from the specified key's folder.
The method checks if the key's folder exists in the activated or deactivated directories, and attempts to load the 'userProperties.json' file from within the folder.
key | (str): The name of the key to locate its corresponding key file folder. |
Definition at line 29 of file foldercontent.py.
src.backend.foldercontent.FolderContent.search_in_folder | ( | self, | |
folder_path, | |||
search_term ) |
Search inside a key file folder for the given search term in the JSON files.
folder_path | (str): The path to the key file. |
search_term | (str): The term to search for. |
Definition at line 122 of file foldercontent.py.
src.backend.foldercontent.FolderContent.search_in_json | ( | self, | |
data, | |||
search_term ) |
Recursively search through a JSON for the search term, case-insensitive, with partial matching.
data | (dict or list): The JSON data to search through. |
search_term | (str): The term to search for. |
Definition at line 149 of file foldercontent.py.
src.backend.foldercontent.FolderContent.update_metadata | ( | self, | |
key, | |||
metadata ) |
Update the metadata.json for a given key (serial number).
key | The name of the key to locate its corresponding folder. |
metadata | Dictionary to save. |
Definition at line 260 of file foldercontent.py.
src.backend.foldercontent.FolderContent.activated_path = activated_path |
Definition at line 26 of file foldercontent.py.
src.backend.foldercontent.FolderContent.deactivated_path = deactivated_path |
Definition at line 27 of file foldercontent.py.