How to use _encode_table method in autotest

Best Python code snippet using autotest_python

crypt.py

Source:crypt.py Github

copy

Full Screen

1# Purpose: decode/encode DXF proprietary data2# Created: 01.05.20143# Copyright (C) 2014, Manfred Moitzi4# License: MIT License5from __future__ import unicode_literals6__author__ = "mozman <mozman@gmx.at>"7from .c23 import PY38_decode_table = {9 0x20: ' ',10 0x40: '_',11 0x5F: '@',12}13for c in range(0x41, 0x5F):14 _decode_table[c] = chr(0x41 + (0x5E - c)) # 0x5E -> 'A', 0x5D->'B', ...15def decode(text_lines):16 def _decode(text):17 dectab = _decode_table # fast local var18 s = []19 if PY3:20 text = bytes(text, 'ascii')21 else:22 text = map(ord, text)23 skip = False24 for c in text:25 if skip:26 skip = False27 continue28 if c in dectab:29 s += dectab[c]30 skip = (c == 0x5E) # skip space after 'A'31 else:32 s += chr(c ^ 0x5F)33 return ''.join(s)34 return (_decode(line) for line in text_lines)35_encode_table = {36 ' ': ' ', # 0x2037 '_': '@', # 0x4038 '@': '_', # 0x5F39}40for c in range(0x41, 0x5F):41 _encode_table[chr(c)] = chr(0x5E - (c - 0x41)) # 0x5E->'A', 'B'->0x5D, ...42def encode(text_lines):43 def _encode(text):44 s = []45 enctab = _encode_table # fast local var46 for c in text:47 if c in enctab:48 s += enctab[c]49 if c == 'A':50 s += ' ' # append a space for an 'A' -> cryptography51 else:52 s += chr(ord(c) ^ 0x5F)53 return ''.join(s)...

Full Screen

Full Screen

url_as_file.py

Source:url_as_file.py Github

copy

Full Screen

1import codecs2import string3from typing import Tuple4escape_char = "!"5_encode_table = {6 escape_char: escape_char,7 #replace illegal chars8 "\\": "{",9 "/": "}",10 "<": "[",11 ">": "]",12 ":": ";",13 "*": "+",14 "?": "`",15 "\"": "'",16 "|": "~",17 #avoid filename extension confusion18 ".": ","19}20_decode_table = {v: k for k, v in _encode_table.items()}21#Put the escape character in front of literal characters.22def url_as_file_encode(url: str) -> Tuple[str, int]:23 l = []24 for x in url:25 if x in _decode_table.keys():26 l.append(escape_char + x)27 elif x in _encode_table.keys():28 l.append(_encode_table[x])29 else:30 l.append(x)31 return ''.join(l), len(url)32def url_as_file_decode(text: str) -> Tuple[str, int]:33 out = []34 is_escaped = False35 for c in text:36 if c in _decode_table:37 if is_escaped:38 out.append(c)39 is_escaped = False40 elif c == escape_char:41 is_escaped = True42 else:43 out.append(_decode_table[c])44 else:45 out.append(c)46 #is_escaped = False47 return ''.join(out), len(text)48def url_as_file_search_function(encoding_name):49 return codecs.CodecInfo(url_as_file_encode, url_as_file_decode, name='url-as-file')...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful