def clean_js(self, jsfile): try: res = jsbeautifier.beautify_file(jsfile) if res: fileWriter = open(jsfile, 'w') fileWriter.write(res) fileWriter.close() print "Cleaned", jsfile except Exception, e: print e
def test_compare_generated_files_from_project(cookies): result = cookies.bake(extra_context={ "project_slug": "commonstest", "extra_dockerfile": "y", "project_type": "default" }, template="cookiecutter-project") assert result.exit_code == 0 assert result.exception is None assert filecmp.cmp( result.project.join('.devcontainer/Dockerfile'), 'cookiecutter-project/tests/golden_files/minimal/commons/Dockerfile', shallow=True) assert filecmp.cmp( result.project.join('.devcontainer/docker-compose.yml'), 'cookiecutter-project/tests/golden_files/minimal/commons/docker-compose.yml', shallow=True) # assert filecmp.cmp(result.project.join( # '.devcontainer/devcontainer.json'), 'cookiecutter-project/tests/golden_files/minimal/commons/devcontainer.json', shallow=True) json_data = jsbeautifier.beautify_file( result.project.join('.devcontainer/devcontainer.json')) jsonGoldenFile = jsbeautifier.beautify_file( 'cookiecutter-project/tests/golden_files/minimal/commons/devcontainer.json' ) assert jsonGoldenFile == json_data
def create_Constants(self): f = open(self.path + "/constants.js", "w") for action in self.data["action"]: f.write( 'export const ' + action.upper() + "_" + self.alias.upper() + ' = "form/' + self.alias + "/" + action.upper() + '";\n') self.actions.append(action.upper() + "_" + self.alias.upper()) f.close() jsbeautifier.beautify_file(self.path + "/constants.js", '__replace') pass
def create_config(self): f = open(self.path + "/config.js", "w") export_str = "" for i in self.data["formStruct"]: f.write("const " + i + " = ") write_block_code("", f) export_str = export_str + i + ",\n" f.write("export default") write_block_code(export_str, f) f.close() jsbeautifier.beautify_file(self.path + "/config.js", '__replace')
def createApp(appdef, deployData, folder, progress): checkAppCanBeCreated(appdef) if deployData: usesGeoServer = False usesPostgis = False layers = appdef["Layers"] for layer in layers: if layer.method != utils.METHOD_FILE: if layer.layer.type() == layer.layer.VectorLayer and layer.layer.providerType().lower() != "wfs": usesPostgis = True usesGeoServer = True elif layer.layer.type() == layer.layer.RasterLayer and layer.layer.providerType().lower() != "wms": usesGeoServer = True if usesPostgis: importPostgis(appdef, progress) if usesGeoServer: publishGeoserver(appdef, progress) writeOL(appdef, folder, deployData, progress) files = [os.path.join(folder, "layers/layers.js"), os.path.join(folder, "index.js")] for root, dirs, fs in os.walk(os.path.join(folder, "styles")): for f in fs: if f.endswith("js"): files.append(os.path.join(root, f)) for path in files: try: beauty = jsbeautifier.beautify_file(path) with open(path, "w") as f: f.write(beauty) except: pass #jsbeautifier gives some random errors sometimes due to imports projFile = QgsProject.instance().fileName() if projFile: appdefFile = projFile + ".appdef" saveAppdef(appdef, appdefFile)
def main(): fileLink = sys.argv[1] start = time.time() signal.signal(signal.SIGALRM, handler) signal.alarm(60) try: fileName = wget.download(fileLink, bar=None) except (ValueError, IOError) as e: addFailed(fileLink) return None h = getHash(fileName) if (checkHash(h)): addDuplicate(fileLink) os.remove(fileName) return None else: addHash(h) with open('current.txt', 'w') as f: f.write( jsbeautifier.beautify_file(fileName).encode('ascii', errors='ignore')) f.flush() f.close() with open('current.txt', 'rb') as f: f.flush() f.close() count = getRawCount() os.remove(fileName) print(count) print(fileLink) return count, fileLink
def create_selectors(self): props = self.data["props"] f = open(self.path + '/selectors.js', "w") write_import(f, ["createSelector"], "reselect") write_function(f, "selectGlobal", "state." + self.base_path.lower() + "." + self.alias + "|| {};", ["state"], False) exportstr = "" for prop in props: write_function(f, "makeSelect" + prop.capitalize(), "createSelector(selectGlobal, (state) => state." + prop + ");", [], False) exportstr += "makeSelect" + prop.capitalize() + ",\n" self.selectors.append("makeSelect" + prop.capitalize()) f.write("export ") write_block_code(exportstr, f) f.close() jsbeautifier.beautify_file(self.path + '/selectors.js', '__replace')
def decompress_mini_js(self, js_file): """ 解压被压缩的JS文件 :param js_file: :return: """ js_options = BeautifierOptions() replace = True outfile = js_file try: if replace: outfile = js_file pretty = beautify_file(js_file, js_options) if outfile == 'stdout': sys.stdout.write(pretty) else: if isFileDifferent(outfile, pretty): mkdir_p(os.path.dirname(outfile)) with open(outfile, 'w') as f: f.write(pretty) except Exception as ex: raise H5DetectorException( 'There is an exception when' ' decompressing js file: {}'.format(js_file))
def decompress_mini_js(self, js_file): """ 解压被压缩的JS文件 :param js_file: :return: """ js_options = BeautifierOptions() replace = True outfile = js_file try: if replace: outfile = js_file pretty = beautify_file(js_file, js_options) if outfile == 'stdout': sys.stdout.write(pretty) else: if isFileDifferent(outfile, pretty): mkdir_p(os.path.dirname(outfile)) with open(outfile, 'w') as f: f.write(pretty) except Exception as ex: raise H5DetectorException('There is an exception when' ' decompressing js file: {}'.format(js_file))
def beautify_js_program(file_path_name, create_new_file=False): """ @param {string} file_path_name: input system path to a JS code @param {bool} create_new_file: if set to False, overwrites the input JS file with the beautify version, otherwise, it creates a new file with the name set in constantsModule.NAME_JS_PROGRAM_INSTRUMENTED @description: beautifies a given JS program @return None """ beautified_out_is_not_corrupted = True try: res = jsbeautifier.beautify_file(file_path_name) except: beautified_out_is_not_corrupted = False logger.warning('beautifying failed for the input program at: %s' % file_path_name) if beautified_out_is_not_corrupted: if create_new_file: output = constantsModule.NAME_JS_PROGRAM_INSTRUMENTED else: output = file_path_name with open(output, 'w+') as fd: fd.write(res)
def beautifyFiles (path, name) : fPath = os.path.join(path, name) res = jsbeautifier.beautify_file(fPath) output = open(fPath, "w+") output.write(res) output.close() print fPath
def beautify_js(file, inplace=True): print('Format: ' + file) fileFormatted = file + '.formatted' res = jsbeautifier.beautify_file(file) with open(fileFormatted, 'w', encoding='utf-8') as f: f.write(res) if inplace: shutil.move(fileFormatted, file)
def variableSearch(file, output_file, verbose): code = jsbeautifier.beautify_file(file) i = 0 res = [] while i < len(code): # this is done to avoid redunduncy while comparing let and var name = code[i:i + 3] if name == "var" or name == "let" or code[i:i + 5] == "const": if name == "var": i += 3 else: i += 5 if code[i] != "=" and code[i] != " " and code[i] != ";": continue var_name = "" while 1: if code[i] == " ": i += 1 continue if code[i] == "=" or code[i] == ";": break var_name += code[i] i += 1 if "," in var_name: for name in var_name.split(","): res.append(name) # print(name) else: res.append(var_name) # print(var_name) else: i += 1 # removes duplicates res = list(dict.fromkeys(res)) verbose_message = "" if verbose == True and res != []: verbose_message = "URL " + \ getEndpointFromFile(file) + " contains the variables: " print(verbose_message) for word in res: print(word) if output_file != None: out = open(output_file, "a") if verbose != None: out.write(verbose_message + "\n") for word in res: out.write(word + "\n") out.write("\n") out.close()
def create_actions(self): f = open(self.path + '/actions.js', "w") write_import(f, ["axios"], "axios", True) write_import(f, self.actions, "./constants") write_import(f, ["API"], "constants") write_import(f, ["BearerToken"], "token") for i in range(len(self.actions)): if self.data["action"][i] == "request" or self.data["action"][i] == "response": write_function(f, self.alias.lower() + self.data["action"][i].capitalize(), "type: " + self.actions[i] + ",data ", ["data"]) elif self.data["action"][i] == "error": write_function(f, self.alias.lower() + self.data["action"][i].capitalize(), "type: " + self.actions[i] + ",error ", ["error"]) else: write_function(f, self.alias.lower() + self.data["action"][i].capitalize(), "type: " + self.actions[i], ["_"]) f.close() jsbeautifier.beautify_file(self.path + '/actions.js', '__replace')
def get_strings(fromfile): fixed = jsbeautifier.beautify_file(fromfile) matches = set() for line in fixed.split("\n"): for match in re.finditer("\"[^\"]*\"", line): matches.add(match.group(0)) for match in re.finditer("'[^']*'", line): matches.add(match.group(0)) listed = list(matches) listed.sort() return listed, fixed
def create_index(self): f = open(self.path + '/index.js', "w") f.write('import React, { useEffect, memo, useState } from "react";\n') write_import_index(f, self.selectors) props = copy.deepcopy(self.data['props']) props[-1] = props[-1] + "}" write_function(f, self.alias, "", ["{history"] + props, False) write_block_code("", f) f.write(self.alias + ".propTypes = ") write_block_code(prop_type(self.data), f) f.write("const mapStateToProps = \n") f.write("createStructuredSelector({") for i in range(len(self.data['props'])): f.write(self.data['props'][i] + ": " + self.selectors[i] + "(),\n") f.write("});\n") write_function(f, "mapDispatchToProps", "dispatch", ["dispatch"]) f.write("const withConnect = connect(mapStateToProps, mapDispatchToProps);\n") f.write("export default compose(withConnect, memo)(withRouter(" + self.alias + "));\n") f.close() jsbeautifier.beautify_file(self.path + '/index.js', '__replace')
def get_code(self, tree, feature_names, class_names, filename, data_type): left = tree.tree_.children_left right = tree.tree_.children_right threshold = tree.tree_.threshold value = tree.tree_.value features = [] for i in tree.tree_.feature: if i != -2 or i <= 200: features.append(feature_names[i]) rules_array = [] def recurse(left, right, threshold, features, node): if (threshold[node] != -2): line = "IF ( " + features[node] + " <= " + str( threshold[node]) + " ) {" rules_array.append(line) if left[node] != -1: recurse(left, right, threshold, features, left[node]) line = "} ELSE {" rules_array.append(line) if right[node] != -1: recurse(left, right, threshold, features, right[node]) line = "}" rules_array.append(line) else: if value[node][0][0] >= value[node][0][1]: line = "return", class_names[0] rules_array.append(line) else: line = "return", class_names[1] rules_array.append(line) recurse(left, right, threshold, features, 0) dt.write1dArray( rules_array, "../data/" + data_type + "/rules/text_rules/" + filename + ".txt") cleaned = jsbeautifier.beautify_file("../data/" + data_type + "/rules/text_rules/" + filename + ".txt") try: file = open( "../data/" + data_type + "/rules/text_rules/" + filename + ".txt", "w") file.write(cleaned) file.close() file = open( "../data/" + data_type + "/rules/tree_temp/" + filename + ".txt", "w") file.write(cleaned) file.close() except OSError: print("Couldn't save")
def jsbeautifier_driver(): # Set options for root, _, files in os.walk("."): for file in files: if file.endswith(".js"): print(os.path.join(root, file)) full_path = os.path.join(root, file) res = jsbeautifier.beautify_file(full_path, opts) with open(full_path, "w") as f: f.write(res)
def get_code(self, tree, feature_names, class_names, filename, data_type): rules_array = [] dt.write1dArray( rules_array, "../data/" + data_type + "/rules/text_rules/" + filename + ".txt") # Probably not needed cleaned = jsbeautifier.beautify_file("../data/" + data_type + "/rules/text_rules/" + filename + ".txt") file = open( "../data/" + data_type + "/rules/text_rules/" + filename + ".txt", "w") file.write(cleaned) file.close()
def listingf(dirList): filesToBeProcessed = [] for paths,dirs,files in os.walk(dirList): for file in files: filesToBeProcessed.append(os.path.join(os.path.abspath(paths), file)) opts = default_options() opts.wrap_line_length = 80 for file in filesToBeProcessed: res = beautify_file(file,opts); fnew = open(file, "w") fnew.write(res)
def beautify_injects(storage_name): inject_beautified = jsbeautifier.beautify_file( storage_name) # Beautifies the js inject file and stores it inject_beautified_list = [ ] # List to store each beautified line of the inject # Writing to and reading from files to get inject into a workable format with open(storage_name, "w+") as raw_inject: for line in inject_beautified: raw_inject.write(line) with open(storage_name, 'r') as raw_inject: for line in raw_inject: inject_beautified_list.append(line) return inject_beautified_list # Return the inject_beautified_list
def main(): # Read environment variables import os cwd = os.getcwd() stateFilePath = cwd + "/../terraform/terraform.tfstate" varsFilePath = cwd + "/group_vars/all" hostsFileName = cwd + "/hosts" response = jsbeautifier.beautify_file(stateFilePath) data = json.loads(response) #Update ansible group variables & hosts data updateAnsiblehosts(data, hostsFileName) updateAnsibleVars(data, varsFilePath)
def build_theme(theme, output): min_file_name = os.path.join(output, theme + '.min.js') file_name = os.path.join(output, theme + '.js') (err, output) = __compile(__get_theme_entry_point(theme), min_file_name, flag_file=CHECKS_FLAGS) if len(output) > 0: print output try: import jsbeautifier res = jsbeautifier.beautify_file(min_file_name) with open(file_name, 'w') as f: f.write(res) except ImportError: raise ImportError('Please install jsbeautifier manually first.')
def beautify_js_files(download_dir, beautified_dir): log.info("Beautifying JS files") create_dir(beautified_dir) downloaded_files = pathlib.Path(download_dir).iterdir() opts = jsbeautifier.default_options() opts.end_with_newline = True for in_file in downloaded_files: if not in_file.suffix == '.js': continue out_path = os.path.join(beautified_dir, in_file.name) with open(in_file, 'r') as f: res = jsbeautifier.beautify_file(in_file, opts) with open(out_path, 'w') as f: f.write(res) log.info("All files have been beautified") return beautified_dir
def beautify_js(): try: if not os.path.isfile("libraryroot.beaut.js"): print("Opening JS file and beautifying...") if not os.path.isfile("libraryroot.js"): shutil.copy2(library_dir() + "/libraryroot.js", "libraryroot.js") library = jsbeautifier.beautify_file("libraryroot.js") f = open("libraryroot.beaut.js", "wt", newline='', encoding="UTF-8") print("Writing beautified file... please do not close") f.write(library) f.close() print("Beautified file write finished") except: error_exit("libraryroot.js not found")
def _beautify_js(program_path_name): """ beautifies the given js program @param {string} program_path_name: input system path to a JS code @description: beautifies the target JS code @return {None} """ if CrawlerConfig.BEAUTIFY_FILES: overwrite = True try: res = jsbeautifier.beautify_file(program_path_name) except: overwrite = False if overwrite: with open(program_path_name, 'w') as fp: fp.write(res)
def perform_detection(file: str): entropy_before = calculate_entropy(file) contents = str() with open(file, mode='r', encoding='utf-8', errors='ignore') as f: contents = f.read() with open(file, 'w', encoding='utf-8', errors='ignore') as f: f.write(contents) res = jsbeautifier.beautify_file(file) with open('temp.js', 'w', encoding='utf-8', errors='ignore') as f: f.write(res) entropy_after = calculate_entropy('temp.js') if abs(entropy_before - entropy_after) > 0.5: print("Warning! JS code was obfuscated, which can be a sign of malware.") else: print("Code was not obfuscated.") clamscan_file('temp.js') yara_scan('temp.js')
def prettyjs(self,direc): # path = '/Users/matin/Documents/ReposCheckout/test/Angular.js' opts = jsbeautifier.default_options() opts.max_preserve_newlines = 1 for subdir, dirs, files in os.walk(direc): for file in files: path = os.path.join(subdir, file) if (path.endswith(".js")): res = jsbeautifier.beautify_file(path, opts) jsfile = open(path, 'wb') jsfile.write(res) jsfile.close() print path
def get_code(self, tree, feature_names, class_names, filename): left = tree.tree_.children_left right = tree.tree_.children_right threshold = tree.tree_.threshold value = tree.tree_.value #print tree.tree_.feature, len(tree.tree_.feature # ) features = [] for i in tree.tree_.feature: if i != -2 or i <= 200: features.append(feature_names[i]) rules_array = [] def recurse(left, right, threshold, features, node): if (threshold[node] != -2): line = "IF ( " + features[node] + " <= " + str( threshold[node]) + " ) {" rules_array.append(line) if left[node] != -1: recurse(left, right, threshold, features, left[node]) line = "} ELSE {" rules_array.append(line) if right[node] != -1: recurse(left, right, threshold, features, right[node]) line = "}" rules_array.append(line) else: if value[node][0][0] >= value[node][0][1]: line = "return", class_names[0] rules_array.append(line) else: line = "return", class_names[1] rules_array.append(line) recurse(left, right, threshold, features, 0) dt.write1dArray(rules_array, "Rules/Statements/" + filename + ".rules") cleaned = jsbeautifier.beautify_file("Rules/Statements/" + filename + ".rules") file = open("Rules/Statements/" + filename + ".rules", "w") file.write(cleaned) file.close()
def createApp(appdef, deployData, folder, progress): checkAppCanBeCreated(appdef) if deployData: usesGeoServer = False usesPostgis = False layers = appdef["Layers"] for layer in layers: if layer.method != utils.METHOD_FILE: if layer.layer.type( ) == layer.layer.VectorLayer and layer.layer.providerType( ).lower() != "wfs": usesPostgis = True usesGeoServer = True elif layer.layer.type( ) == layer.layer.RasterLayer and layer.layer.providerType( ).lower() != "wms": usesGeoServer = True if usesPostgis: importPostgis(appdef, progress) if usesGeoServer: publishGeoserver(appdef, progress) writeOL(appdef, folder, deployData, progress) files = [ os.path.join(folder, "layers/layers.js"), os.path.join(folder, "index.js") ] for root, dirs, fs in os.walk(os.path.join(folder, "styles")): for f in fs: if f.endswith("js"): files.append(os.path.join(root, f)) for path in files: try: beauty = jsbeautifier.beautify_file(path) with open(path, "w") as f: f.write(beauty) except: pass #jsbeautifier gives some random errors sometimes due to imports projFile = QgsProject.instance().fileName() if projFile: appdefFile = projFile + ".appdef" saveAppdef(appdef, appdefFile)
def get_code(self, tree, feature_names, class_names, filename): left = tree.tree_.children_left right = tree.tree_.children_right threshold = tree.tree_.threshold value = tree.tree_.value #print tree.tree_.feature, len(tree.tree_.feature # ) features = [] for i in tree.tree_.feature: if i != -2 or i <= 200: features.append(feature_names[i]) rules_array = [] def recurse(left, right, threshold, features, node): if (threshold[node] != -2): line = "IF ( " + features[node] + " <= " + str(threshold[node]) + " ) {" rules_array.append(line) if left[node] != -1: recurse (left, right, threshold, features,left[node]) line = "} ELSE {" rules_array.append(line) if right[node] != -1: recurse (left, right, threshold, features,right[node]) line = "}" rules_array.append(line) else: if value[node][0][0] >= value[node][0][1]: line = "return", class_names[0] rules_array.append(line) else: line = "return", class_names[1] rules_array.append(line) recurse(left, right, threshold, features, 0) dt.write1dArray(rules_array, "Rules/Statements/"+filename+".rules") cleaned = jsbeautifier.beautify_file("Rules/Statements/"+filename+".rules") file = open("Rules/Statements/"+filename+".rules", "w") file.write(cleaned) file.close()
# pip install jsbeautifier import jsbeautifier import sys if len(sys.argv) < 2: print "Please specify the js file to beautify as a command line argument!" sys.exit(1) fileName = sys.argv[1] print "Beautifying " + fileName opts = jsbeautifier.default_options() opts.indent_size = 2 opts.break_chained_methods = True opts.wrap_line_length = 120 opts.end_with_newline = True beautified = jsbeautifier.beautify_file(fileName, opts) f = open(fileName, 'w') f.write(beautified) f.close()
def prettyJsonLocationDict(): # Parse it formattedJson = jsbeautifier.beautify_file(locationDictFile) with open(locationDictFile, 'w') as f: f.write(formattedJson) f.close()
def main(self, file, argvs): path = sys.path[0] print("****************************") print(file) res = jsbeautifier.beautify_file(file) preFile = "preformat_" + file op = open(preFile, "w+") op.write(res) op.close() oFileContent = getContent(preFile) formatFile = Formatter() formatFile.formatter(file, oFileContent) fFile = "formatted_" + file fFileContent = getContent(fFile) isAbnormal = False isHighRisk = False mergeFile = Merge() isAbnormal, isHighRisk = mergeFile.mergeReduce(file, fFileContent, argvs) print(isAbnormal, isHighRisk) srcProcessedPath = path + "/" + file if not isAbnormal and not isHighRisk: #classify processible contract classify = Classifier() mFile = "merged_" + file mFileContent = getContent(mFile) isProcessible = classify.classifier(mFileContent) print(isProcessible) srcProcessiblePath = path + "/" + mFile if isProcessible: dstProcessiblePath = path + "/Processible/" + mFile shutil.copy(srcProcessiblePath, dstProcessiblePath) print( mFile, " is processible and has been put in the Processible directory." ) os.remove(srcProcessiblePath) else: os.remove(srcProcessiblePath) desProcessedPath = path + "/ProcessedContracts/" + file noteStr = "ProcessedContracts" elif not isAbnormal and isHighRisk: desProcessedPath = path + "/varRepeatContracts/" + file noteStr = "varRepeatContracts" elif isAbnormal and not isHighRisk: desProcessedPath = path + "/abnormalContracts/" + file noteStr = "abnormalContracts" shutil.copy(srcProcessedPath, desProcessedPath) print(file, " has been moved to the " + noteStr + " directory.") #remove formatted contract formattedFile = path + "/" + fFile os.remove(formattedFile) os.remove(preFile) os.remove(srcProcessedPath)
def format_js(input, options): import jsbeautifier string = jsbeautifier.beautify_file(input) options.output.write(string)
#!/usr/bin/env python import os import sys sys.path.append(os.path.join(os.environ["TM_BUNDLE_SUPPORT"], "lib")) import jsbeautifier opts = jsbeautifier.default_options() if os.environ["TM_SOFT_TABS"] == 'NO': opts.indent_size = 1 opts.indent_char = '\t' else: opts.indent_size = int(os.environ["TM_TAB_SIZE"]) print jsbeautifier.beautify_file('-', opts)
def jsdeobfuscatefile(inputfile, outputfile): try: res = jsbeautifier.beautify_file(inputfile) except: res = open(inputfile, 'r').read() open(outputfile, 'w').write(res)
"""Run js-beautify on all .js files https://github.com/einars/js-beautify """ import jsbeautifier import os import shutil js_files = [f for f in os.listdir(os.getcwd()) if f.endswith('.js')] for js_file in js_files: print('Beautifying ' + js_file) shutil.copy2(js_file, js_file+'.bak') new_js = jsbeautifier.beautify_file(js_file) new_file = open(js_file, 'w') new_file.write(new_js) new_file.close()
def prettify(self): opts = jsbeautifier.default_options() res = jsbeautifier.beautify_file(self.path_to_file, opts) print(res) return True
__author__ = "Valentin Giannini" __copyright__ = "Copyright 2016, LAMA" __credits__ = [""] __license__ = "GPL" __version__ = "3" __maintainer__ = "Valentin Giannini - CSE Team" __email__ = "cse.contact -at- post.lu" __status__ = "Production" import jsbeautifier import json import base64 result_dict = dict() try: res = jsbeautifier.beautify_file('/lama/sample') res = res.encode('utf-8') result_dict['code'] = base64.b64encode(res) except (UnicodeDecodeError, UnicodeEncodeError) as e: result_dict['error'] = base64.b64encode(str(e)) except Exception as e: result_dict['error'] = base64.b64encode(str(e)) print(json.dumps(result_dict))
print("UnicodeDecodeError.") strings = re.findall('"[^"]*"', file_bytes) strings += re.findall("'.*'", file_bytes) opened_file.close() if strings: entropies = list() for string in strings: prob = [ float(string.count(c)) / len(string) for c in dict.fromkeys(list(string)) ] entropy = -sum([p * log(p) / log(2.0) for p in prob]) entropies.append(entropy) return sum(entropies) / len(entropies) else: return 0 if __name__ == '__main__': print( f'Entropija stringova u {sys.argv[1]} je {calculate_entropy(sys.argv[1])}' ) res = jsbeautifier.beautify_file(sys.argv[1]) with open('temp.js', 'w') as f: f.write(res) file = 'temp.js' print( f'Entropija stringova u {sys.argv[1]} nakon deobfuskacije je {calculate_entropy(file)}' )