Best Python code snippet using localstack_python
codings.py
Source:codings.py
...21 def text_to_base64(self, text):22 return self.hex_to_base64(self.text_to_hex(text))23 24 def base64_to_text(self, b):25 return self.hex_to_text(self.base64_to_hex(b))26 27 def text_to_base85(self, text):28 return self.hex_to_base85(self.text_to_hex(text))29 30 def base85_to_text(self, b):31 return self.hex_to_text(self.base85_to_hex(b))32 33 def binary_to_base64(self, binary):34 return self.hex_to_base64(self.binary_to_hex(binary))35 36 def base64_to_binary(self, b):37 return self.hex_to_binary(self.base64_to_hex(b))38 39 def binary_to_base85(self, binary):40 return self.hex_to_base85(self.binary_to_hex(binary))41 42 def base85_to_binary(self, b):43 return self.hex_to_binary(self.base85_to_hex(b))44 45 def base64_to_base85(self, b):46 return self.hex_to_base85(self.base64_to_hex(b))47 48 def base85_to_base64(self, b):49 return self.hex_to_base64(self.base85_to_hex(b))5051 def binary_to_hex(self, binary):52 t, z = ("", re.search("^0+", binary))53 if not z is None: 54 t = "{}:".format(len(z.group()))55 binary = binary[len(z.group()):]56 s = co.bin_to_hex(binary) if binary != "" else ""57 if s != "" and len(s) % 2 != 0: s = "0" + s58 return t + s59 60 def hex_to_binary(self, h):61 t, z = ("", re.search("^(\d+):", h))62 if not z is None: 63 t = "0" * int(z.group(1))64 h = h[len(z.group()):]65 return t + (str(co.hex_to_bin(h)) if h != "" else "")66 67 def __extract_custom_bin(self, text):68 t, z = ("", re.search("^\d+:", text))69 if not z is None:70 t = z.group()71 text = text[len(z.group()):]72 return (t, text)73 74 def hex_to_base64(self, h):75 t, h = self.__extract_custom_bin(h)76 return t + (b64.b64encode(bytes.fromhex(h)).decode() if h != "" else "")77 78 def base64_to_hex(self, b):79 t, b = self.__extract_custom_bin(b) 80 return t + (b64.b64decode(b.encode()).hex() if b != "" else "")81 82 def hex_to_base85(self, h):83 t, h = self.__extract_custom_bin(h)84 return t + (b64.b85encode(bytes.fromhex(h)).decode() if h != "" else "")85 86 def base85_to_hex(self, b):87 t, b = self.__extract_custom_bin(b)
...
test_metadata.py
Source:test_metadata.py
...4 assert get_seconds_from_epoch("Sat, 07 Mar 2020 21:03:07 GMT") == 1583614987.05 assert get_seconds_from_epoch("Sat Mar 7 15:05:07 PST 2020") == 1583622307.06 assert get_seconds_from_epoch("2017-07-01T14:59:55.711Z") == 1498921195.7117 assert get_seconds_from_epoch("2017-03-10 14:30:12,655+0000") == 1489156212.6558def test_base64_to_hex():9 assert base64_to_hex("aGVsbG8gd29ybGQ=") == hexlify("hello world".encode()).decode()10 assert (11 base64_to_hex("YXNkZnNkZnNhZGYjQEtKV0xLSkFTRDw+S0ZKQCNBU0RDQ0FTREBAIyRSIQ==")12 == hexlify("asdfsdfsadf#@KJWLKJASD<>KFJ@#ASDCCASD@@#$R!".encode()).decode()13 )14 assert (15 base64_to_hex("NWEyNjUzYTY2Zjk1OGY5ZmNiODYwMGUyMDI4MTFiMjc=")16 == hexlify("5a2653a66f958f9fcb8600e202811b27".encode()).decode()17 )18def test_parse_md5_str():19 assert (20 parse_md5_str("WiZTpm+Vj5/LhgDiAoEbJw==") == "5a2653a66f958f9fcb8600e202811b27"21 )22 assert (23 parse_md5_str("5a2653a66f958f9fcb8600e202811b27")24 == "5a2653a66f958f9fcb8600e202811b27"...
0014_auto_20150314_0331.py
Source:0014_auto_20150314_0331.py
1# -*- coding: utf-8 -*-2from __future__ import unicode_literals3from django.db import models, migrations4from binascii import a2b_base64, b2a_hex5def base64_to_hex(apps, schema_editor):6 """7 Convert users' device tokens from base 64 to hex.8 """9 APNSDevice = apps.get_model('push_notifications', 'APNSDevice')10 for device in APNSDevice.objects.all():11 device.registration_id = b2a_hex(a2b_base64(device.registration_id))12 device.save()13 14class Migration(migrations.Migration):15 dependencies = [16 ('down_auth', '0013_remove_user_notify_token'),17 # Add dependency to use APNSDevice.18 ('push_notifications', '0001_initial'),19 ]...
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!!