Created
August 28, 2024 20:23
-
-
Save 7shi/6d70225ba3ea985c9870146cb79d95c4 to your computer and use it in GitHub Desktop.
[py] XML Archiver for Claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, html | |
def wrap_files_in_xml(file_names): | |
print('<?xml version="1.0" encoding="UTF-8"?>') | |
print('<files>') | |
for file_name in file_names: | |
print(f'<file name="{file_name}">') | |
with open(file_name, 'r') as file: | |
print(html.escape(file.read().rstrip())) | |
print('</file>') | |
print('</files>') | |
if __name__ == '__main__': | |
if len(sys.argv) < 2: | |
print(f'Usage: python {sys.argv[0]} file1 [file2 ...]') | |
else: | |
wrap_files_in_xml(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment