f | import sys | f | import sys |
| import tarfile | | import tarfile |
| import io | | import io |
| | | |
n | def hex_to_bytes(hex_str): | n | def decode_hex_string(hex_string): |
| hex_str = hex_str.replace('\n', '').replace(' ', '') | | sanitized_hex = hex_string.replace('\n', '').replace(' ', '') |
| return bytes.fromhex(hex_str) | | return bytes.fromhex(sanitized_hex) |
| | | |
n | def extract_tar_info(dump_data): | n | def analyze_tar(dump_content): |
| tar_data = io.BytesIO(dump_data) | | byte_stream = io.BytesIO(dump_content) |
| try: | | try: |
n | with tarfile.open(fileobj=tar_data, mode='r') as tar: | n | with tarfile.open(fileobj=byte_stream, mode='r') as archive: |
| file_count = 0 | | num_files = 0 |
| total_size = 0 | | accumulated_size = 0 |
| for member in tar.getmembers(): | | for item in archive.getmembers(): |
| if member.isreg(): | | if item.isreg(): |
| file_count += 1 | | num_files += 1 |
| total_size += member.size | | accumulated_size += item.size |
| return (file_count, total_size) | | return (num_files, accumulated_size) |
| except Exception as e: | | except Exception as error: |
| print(f'Error: {e}') | | print(f'An error occurred: {error}') |
| return (0, 0) | | return (0, 0) |
| if __name__ == '__main__': | | if __name__ == '__main__': |
t | input_data = sys.stdin.read() | t | raw_input = sys.stdin.read() |
| dump_data = hex_to_bytes(input_data) | | decoded_data = decode_hex_string(raw_input) |
| file_count, total_size = extract_tar_info(dump_data) | | file_count, total_file_size = analyze_tar(decoded_data) |
| print(total_size, file_count) | | print(total_file_size, file_count) |