INNER CODE UNIT · Python

get_file_contents

biowasm/biowasm · bin/compile.py:52

def get_file_contents(path):
	"""
	Get file contents as text if .js, or base64 if .wasm/.data
	"""
	if args.dry_run:
		return f"<path>"

	if path.endswith(".wasm") or path.endswith(".data"):
		with open(path, "rb") as f:
			return base64.b64encode(f.read()).decode("utf-8"), True
	elif path.endswith(".js"):
		with open(path, "r") as f:
			return f.read(), False
	else:
		raise f"Unexpected file extension for file '{path}'."


def compile(tool, versions=[], level=0):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…