|
|
|
|
@ -14,16 +14,26 @@ def parse_xml(file_path):
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def update_target_file(source_tree, target_tree):
|
|
|
|
|
"""Update XML properties in the target file only if they exist in the source file."""
|
|
|
|
|
"""Update XML properties in the target file only if they exist in the source file,
|
|
|
|
|
and add elements from the source file that do not already exist in the target file."""
|
|
|
|
|
source_root = source_tree.getroot()
|
|
|
|
|
target_root = target_tree.getroot()
|
|
|
|
|
|
|
|
|
|
source_elements = {elem.tag: elem for elem in source_root}
|
|
|
|
|
|
|
|
|
|
# Update existing elements in the target file
|
|
|
|
|
for target_elem in target_root:
|
|
|
|
|
if target_elem.tag in source_elements:
|
|
|
|
|
target_elem.text = source_elements[target_elem.tag].text
|
|
|
|
|
|
|
|
|
|
# Add missing elements from the source file to the target file
|
|
|
|
|
for source_elem in source_elements.values():
|
|
|
|
|
if not any(target_elem.tag == source_elem.tag for target_elem in target_root):
|
|
|
|
|
# If the element is not in target, append it
|
|
|
|
|
target_root.append(source_elem)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_files(source_dir, target_dir):
|
|
|
|
|
"""Process all .nfo files in source_dir and update matching files in target_dir."""
|
|
|
|
|
source_files = glob.glob(os.path.join(source_dir, "*.nfo"))
|
|
|
|
|
|