Source code for schrodinger.test.squish.matsci.matsci

"""
Materials Science utils.  Functions to help with specific features with MATSCI such as BASE64 decryption.

To use, add the following to the top of your test.py:
    source(findFile("scripts", "matsci/matsci.py"))

@copyright: (c) Schrodinger, LLC. All rights reserved
"""

from schrodinger.application.matsci import textlogger


[docs]def extract_base64(file): ''' Extract a human readable command from an input file with a BASE64 encoded command. :param file: The input .sh file path you want to decode. :return: string of the decoded commands. :Example: file_sh = os.path.join(maestro.cwd, 'input.sh') cmds = extract_base64(file_sh) Then you can use assert statement to compare the output: assert cmds == ref_cmds, "The written input file is not correct!" assert "optoelectronics" in cmds ''' decrypted_cmds = "" with open(file, 'r') as infile: for line in infile: final_cmd, raw_command = textlogger.decode_base64_cmd(line) decrypted_cmds += final_cmd return decrypted_cmds