Best Python code snippet using localstack_python
batocera-systems
Source:batocera-systems  
...745class BiosStatus:746    MISSING = "MISSING"747    UNTESTED = "UNTESTED"748def md5sum(filename, blocksize=65536):749    hash = md5()750    with open(filename, "rb") as f:751        for block in iter(lambda: f.read(blocksize), b""):752            hash.update(block)753    return hash.hexdigest()754def checkBios(systems, prefix):755    missingBios = {}756    for system in systems.keys():757        for file in systems[system]["biosFiles"]:758            filepath = prefix + "/" + file["file"]759            if isfile(filepath):760                md5 = md5sum(filepath)761                if md5 != file["md5"] and file["md5"] != "":762                    if system not in missingBios:763                        missingBios[system] = {}...bl_test.py
Source:bl_test.py  
...35    import bpy36    for scene in bpy.data.scenes:37        for obj in scene.objects:38            scene.objects.unlink(obj)39def blend_to_md5():40    import bpy41    scene = bpy.context.scene42    ROUND = 443    def matrix2str(matrix):44        return "".join([str(round(axis, ROUND)) for vector in matrix for axis in vector]).encode('ASCII')45    def coords2str(seq, attr):46        return "".join([str(round(axis, ROUND)) for vertex in seq for axis in getattr(vertex, attr)]).encode('ASCII')47    import hashlib48    md5 = hashlib.new("md5")49    md5_update = md5.update50    for obj in scene.objects:51        md5_update(matrix2str(obj.matrix_world))52        data = obj.data53        if type(data) == bpy.types.Mesh:54            md5_update(coords2str(data.vertices, "co"))55        elif type(data) == bpy.types.Curve:56            for spline in data.splines:57                md5_update(coords2str(spline.bezier_points, "co"))58                md5_update(coords2str(spline.points, "co"))59    return md5.hexdigest()60def main():61    argv = sys.argv62    print("  args:", " ".join(argv))63    argv = argv[argv.index("--") + 1:]64    def arg_extract(arg, optional=True, array=False):65        arg += "="66        if array:67            value = []68        else:69            value = None70        i = 071        while i < len(argv):72            if argv[i].startswith(arg):73                item = argv[i][len(arg):]74                del argv[i]75                i -= 176                if array:77                    value.append(item)78                else:79                    value = item80                    break81            i += 182        if (not value) and (not optional):83            print("  '%s' not set" % arg)84            sys.exit(1)85        return value86    run = arg_extract("--run", optional=False)87    md5 = arg_extract("--md5", optional=False)88    md5_method = arg_extract("--md5_method", optional=False)  # 'SCENE' / 'FILE'89    # only when md5_method is 'FILE'90    md5_source = arg_extract("--md5_source", optional=True, array=True)91    # save blend file, for testing92    write_blend = arg_extract("--write-blend", optional=True)93    # ensure files are written anew94    for f in md5_source:95        if os.path.exists(f):96            os.remove(f)97    import bpy98    replace_bpy_app_version()99    if not bpy.data.filepath:100        clear_startup_blend()101    print("  Running: '%s'" % run)102    print("  MD5: '%s'!" % md5)103    try:104        result = eval(run)105    except:106        import traceback107        traceback.print_exc()108        sys.exit(1)109    if write_blend is not None:110        print("  Writing Blend: %s" % write_blend)111        bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=write_blend)112    print("  Result: '%s'" % str(result))113    if not result:114        print("  Running: %s -> False" % run)115        sys.exit(1)116    if md5_method == 'SCENE':117        md5_new = blend_to_md5()118    elif md5_method == 'FILE':119        if not md5_source:120            print("  Missing --md5_source argument")121            sys.exit(1)122        for f in md5_source:123            if not os.path.exists(f):124                print("  Missing --md5_source=%r argument does not point to a file")125                sys.exit(1)126        import hashlib127        md5_instance = hashlib.new("md5")128        md5_update = md5_instance.update129        for f in md5_source:130            filehandle = open(f, "rb")131            md5_update(filehandle.read())...md5.js
Source:md5.js  
...10var util = Crypto.util;1112// Public API13var MD5 = Crypto.MD5 = function (message, options) {14	var digestbytes = util.wordsToBytes(MD5._md5(message));15	return options && options.asBytes ? digestbytes :16	       options && options.asString ? util.bytesToString(digestbytes) :17	       util.bytesToHex(digestbytes);18};1920// The core21MD5._md5 = function (message) {2223	var m = util.stringToWords(message),24	    l = message.length * 8,25	    a =  1732584193,26	    b = -271733879,27	    c = -1732584194,28	    d =  271733878;
...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
