Beispiel #1
0
	def test_template_extract(self):
		t_template = pyplate.template(name=self.template_name)(
			(pyplate.CHAR)(name=self.data_name),
			pyplate.template(name="test2")(
				(pyplate.INT)(name="datatest2")
			)
		)
		compiled_strings = pyplate.String(str(self.test_char) + str(self.test_int))
		t_template.extract(compiled_strings)
		self.assertTrue(
			t_template["templates"]["test2"]["variables"]["datatest2"]["length"] == calcsize("i"),
			t_template["variables"][self.data_name]["length"] == 1
		)
Beispiel #2
0
	def test_template_cast(self):
		t_template = pyplate.template(name=self.template_name)(
			(pyplate.CHAR)(name=self.data_name)
		)
		t_template.cast(self.test_char)
		self.assertTrue(
			t_template.data_objects[0].casted
		)
Beispiel #3
0
	def test_template_fseek(self):
		t_template = pyplate.template(name=self.template_name)(
			(pyplate.FSeek)(1),
			(pyplate.CHAR)(name=self.data_name)
		)
		compiled_strings = pyplate.String(str(self.test_char) + str(self.test_char))
		t_template.extract(compiled_strings)
		self.assertTrue(
			t_template["variables"][self.data_name]["offset"] == 1
		)
Beispiel #4
0
	def test_file_extract(self):
		with pyplate.File(self.test_file_path, 'rb') as t_file:
			t_template = pyplate.template(name=self.template_name)(
				(pyplate.CHAR)(name=self.data_name, repeat=4, extract_as_string = True),
				(pyplate.SHORT)(name=self.data_name+"short")
			)
			t_template.extract(t_file)
			self.assertTrue(
				t_template["variables"][self.data_name]["value"] != None,
				t_template["variables"][self.data_name+"short"]["value"] != None
			)