Ejemplo n.º 1
0
	def add_test_files(root_dir):
		# add some test files to the directory
		fname = os.path.join(root_dir, "info.txt")
		with open(fname, "w") as f:
			f.write("This is file %s\n" % fname)
			f.write("It contains info about the model output\n")

		fname = os.path.join(root_dir, 'punches.csv')
		holes = [(10.0, 10.0), (100.0, 10.0), (10.0, 100.0), (100.0, 100.0)]
		with open(fname, "w") as f:
			pl = PunchList(holes)
			pl.save(fname)

		# add fake layers directory and files
		layer_dir = os.path.join(root_dir, 'layers')
		os.mkdir(layer_dir)
		for n in range(5):
			fname = os.path.join(layer_dir, "output_{:03d}.bmp".format(n))
			with open(fname, "w") as f:
				f.write("This is file %s" % fname)
Ejemplo n.º 2
0
			fname = os.path.join(layer_dir, "output_{:03d}.bmp".format(n))
			with open(fname, "w") as f:
				f.write("This is file %s" % fname)

	archive_name = "ziptest"
	root_dir = tempfile.mkdtemp()
	extract_dir = os.path.join(os.getcwd(), "zipdir2")

	# create the archive
	add_test_files(root_dir)
	create_manifest_file(archive_name, root_dir)

	# clean up temporary directory
	rmtree(root_dir)

	# read the archive
	extract_dir = tempfile.mkdtemp()
	names = extract_manifest_file(archive_name, os.getcwd(), extract_dir)

	# get holes (should use punchlist)
	holes = PunchList()
	holes.load( os.path.join(extract_dir, 'punches.csv') )

	# get sorted layer list
	layers = filter(lambda x: 'layers' in x, names)
	for i in sorted(layers, key=layer_name_key):
		print(i)

	# clean up temporary directory
	rmtree(extract_dir)