# marc.py # Easily extract Sora no Woto's MARC archives. # Usage: marc.py [] # Copyright (C) 2013 Shiz. # Released under the terms of the WTFPL: see http://www.wtfpl.net/txt/copying/ for details. import os import os.path as path import sys import struct import collections class MARCArchive: MAGIC = 0x4352414D def __init__(self, filename=None): self.verbose = 0 self.file_count = 0 self.handle = None self.filename = None self.offsets = [] self.changed_files = {} self.added_files = [] if filename: self.open(filename) def open(self, filename): if self.handle: self.close() self.handle = None self.filename = filename self.handle = open(filename, 'rb') magic = struct.unpack(' 2: target = sys.argv[2] else: target = sys.argv[1] if target.endswith('.marc'): target = target[:-5] else: target += '_files' arc = MARCArchive(sys.argv[1]) arc.extract(target)