def safe_add_file(filename, app):
data_file = filename<EOL>static_data_file = os.path.join("<STR_LIT>", data_file)<EOL>if data_file.split("<STR_LIT:.>")[-<NUM_LIT:1>] == "<STR_LIT>":<EOL><INDENT>if hasattr(app.builder, "<STR_LIT>") and static_data_file not in app.builder.script_files:<EOL><INDENT>app.add_javascript(data_file)<EOL><DEDENT><DEDENT>elif data_file.split("<STR_LIT:.>")[-<NUM_LIT:1>] == "<STR_LIT>":<EOL><INDENT>if hasattr(app.builder, "<STR_LIT>") and static_data_file not in app.builder.css_files:<EOL><INDENT>app.add_stylesheet(data_file)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise NotImplementedError("<STR_LIT>".format(data_file.split("<STR_LIT:.>")[-<NUM_LIT:1>]))<EOL><DEDENT>
Adds files to builder resources only, if the given filename was not already registered.
Needed mainly for tests to avoid multiple registration of the same file and therefore also multiple execution
of e.g. a javascript file during page load.

:param filename: filename to remove
:param app: app object
:return: None