Example #1
0
def write_aa(aa_name):
	parts = load_madspack(aa_name)
	
	if verbose:
		print(len(parts))
	
	if len(parts) > 1:
		part1 = BytesIO()	
		write_aa_messages(part1, load_aa_messages(aa_name))
		part1.seek(0)
		parts[1] = part1
		if verbose:
			print('aa messages modified')
	
	write_madspack(aa_name, parts)		
	output(aa_name)
Example #2
0
def write_aa(aa_name):
    check_ext(aa_name, '.AA')

    parts = load_madspack(aa_name)

    if verbose:
        print(len(parts))

    if len(parts) > 1:
        part1 = BytesIO()
        write_aa_messages(part1, load_aa_messages(aa_name))
        part1.seek(0)
        parts[1] = part1
        if verbose:
            print('aa messages modified')

    write_madspack(aa_name, parts)
    output(aa_name)
Example #3
0
def call(fmt,cmd,path):
	
	odd = os.getcwd()
	
	ndd,arg1 = os.path.split(path)
	
	
	common.g_curr_dir = ndd
	
	if ndd:
		os.chdir(ndd)
		
	try:
		
		if cmd not in ['pack','unpack']:
			print('invalid command; use "pack" or "unpack"')
			sys.exit(1)
		
		
		if fmt == 'dat':
			
			if cmd == 'unpack':
				read_messagesdat(open(arg1, 'rb'), arg1)
			elif cmd == 'pack':
				write_messagesdat(open(arg1, 'wb'), arg1)
			
		elif fmt == 'hag':
		
			if cmd == 'unpack':
				read_madsconcat(open(arg1, 'rb'), arg1)
			elif cmd == 'pack':
				write_madsconcat(arg1)
		
		
		elif fmt == 'ss':
			if cmd == 'unpack':
				read_ss(open(arg1, 'rb'), arg1)
			elif cmd == 'pack':
				write_ss(arg1)
			else:
				print(usage)
				sys.exit(1)
				
		elif fmt == 'fab':
			if cmd == 'unpack':
				read_fab_unrestricted(arg1)			
			elif cmd == 'pack':
				print("fab compression? what for?")
				# write_fab_unrestricted(arg1)		
			else:
				print(usage)
				sys.exit(1)
			
		elif fmt == 'madspack':
			if cmd == 'unpack':			
				save_madspack(arg1, read_madspack(open(arg1, 'rb')))
				
			elif cmd == 'pack':
				write_madspack(arg1, load_madspack(arg1))
							
			else:
				print(usage)
				sys.exit(1)
		
		elif fmt == 'aa':
			if cmd == 'unpack':			
				read_aa(arg1)
				
			elif cmd == 'pack':
				write_aa(arg1)
							
			else:
				print(usage)
				sys.exit(1)
			
		
		elif fmt == 'ff':
			if cmd == 'unpack':			
				read_ff(arg1)
				
			elif cmd == 'pack':
				write_ff(arg1)
							
			else:
				print(usage)
				sys.exit(1)
			
		else:
			raise External('invalid format specification')
			
	finally:
		os.chdir(odd)
		common.g_curr_dir = ''