Best Python code snippet using autotest_python
writer.py
Source:writer.py
...87 return cbor.dumps(x)88def mp_dumps(x):89 import msgpack90 return msgpack.packb(x)91def add_handlers(d, keys, value):92 if isinstance(keys, str):93 keys = keys.split()94 for k in keys:95 d[k] = value96def make_handlers():97 """Create a list of handlers for encoding data."""98 handlers = {}99 add_handlers(100 handlers, "cls cls2 class count index inx id", lambda x: str(x).encode("ascii")101 )102 add_handlers(handlers, "txt text transcript", lambda x: x.encode("utf-8"))103 add_handlers(handlers, "html htm", lambda x: x.encode("utf-8"))104 add_handlers(handlers, "pyd pickle", pickle.dumps)105 add_handlers(handlers, "pth", torch_dumps)106 add_handlers(handlers, "npy", numpy_dumps)107 add_handlers(handlers, "npz", numpy_npz_dumps)108 add_handlers(handlers, "ten tenbin tb", tenbin_dumps)109 add_handlers(handlers, "json jsn", lambda x: json.dumps(x).encode("utf-8"))110 add_handlers(handlers, "mp msgpack msg", mp_dumps)111 add_handlers(handlers, "cbor", cbor_dumps)112 add_handlers(handlers, "jpg jpeg img image", lambda data: imageencoder(data, "jpg"))113 add_handlers(handlers, "png", lambda data: imageencoder(data, "png"))114 add_handlers(handlers, "pbm", lambda data: imageencoder(data, "pbm"))115 add_handlers(handlers, "pgm", lambda data: imageencoder(data, "pgm"))116 add_handlers(handlers, "ppm", lambda data: imageencoder(data, "ppm"))117 return handlers118default_handlers = make_handlers()119def encode_based_on_extension1(data: Any, tname: str, handlers: dict):120 """Encode data based on its extension and a dict of handlers.121 :param data: data122 :param tname: file extension123 :param handlers: handlers124 """125 if tname[0] == "_":126 if not isinstance(data, str):127 raise ValueError("the values of metadata must be of string type")128 return data129 extension = re.sub(r".*\.", "", tname).lower()130 if isinstance(data, bytes):...
__init__.py
Source:__init__.py
...32 host_pattern = '.*$'33 # create the route mappings for our handlers34 route_pattern_sword = url_path_join(web_app.settings['base_url'],35 '/sword')36 web_app.add_handlers(host_pattern, [(route_pattern_sword, SWORDHandler)])37 route_pattern_uploadbundle = url_path_join(web_app.settings['base_url'],38 '/uploadbundle')39 web_app.add_handlers(host_pattern, [(route_pattern_uploadbundle,40 UploadBundleHandler)])41 route_pattern_find_id = url_path_join(web_app.settings['base_url'],42 '/dspace/findid')43 web_app.add_handlers(host_pattern, [(route_pattern_find_id,44 FindIDViaMetadata)])45 route_pattern_delete = url_path_join(web_app.settings['base_url'],46 '/dspace/delete')47 web_app.add_handlers(host_pattern, [(route_pattern_delete,48 DeleteItem)])49 route_pattern_get_bitstreams = url_path_join(web_app.settings['base_url'],50 '/dspace/getbitstreams')51 web_app.add_handlers(host_pattern, [(route_pattern_get_bitstreams,52 GetBitstreams)])53 route_pattern_get_bitstream_data = url_path_join(web_app.settings['base_url'],54 '/dspace/getbitstreamdata')55 web_app.add_handlers(host_pattern, [(route_pattern_get_bitstream_data,56 GetBitstreamData)])57 route_pattern_find_id = url_path_join(web_app.settings['base_url'],58 '/dspace/listitems')59 web_app.add_handlers(host_pattern, [(route_pattern_find_id,60 ListAllItems)])61 route_pattern_dspace = url_path_join(web_app.settings['base_url'],62 '/dspace')63 web_app.add_handlers(host_pattern, [(route_pattern_dspace, DSpaceHandler)])64 route_pattern_ldap = url_path_join(web_app.settings['base_url'],65 '/ldap')66 web_app.add_handlers(host_pattern, [(route_pattern_ldap, LDAPHandler)])67 route_pattern_config = url_path_join(web_app.settings['base_url'],68 '/linker_config')69 web_app.add_handlers(host_pattern, [(route_pattern_config, ConfigHandler)])70 route_pattern_download = url_path_join(web_app.settings['base_url'],71 '/dspace_download')72 web_app.add_handlers(host_pattern, [(route_pattern_download, DownloadHandler)])73 route_pattern_import = url_path_join(web_app.settings['base_url'],74 '/file_import')75 web_app.add_handlers(host_pattern, [(route_pattern_import, ImportHandler)])76 route_pattern_redownload = url_path_join(web_app.settings['base_url'],77 '/dspace_redownload')78 web_app.add_handlers(host_pattern, [(route_pattern_redownload, RedownloadHandler)])79 route_pattern_contents = url_path_join(web_app.settings['base_url'],80 '/dspace_contents')81 web_app.add_handlers(host_pattern, [(route_pattern_contents, ContentsHandler)])82 route_pattern_nbconvert = url_path_join(web_app.settings['base_url'],83 r"/customnbconvert/%s%s%s"84 % (_format_regex,85 _template_regex,86 path_regex))87 web_app.add_handlers(host_pattern, [(route_pattern_nbconvert,...
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!!