How to use keys_to_lower method in localstack

Best Python code snippet using localstack_python

_args.py

Source:_args.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2#3# Tencent is pleased to support the open source community by making QTA available.4# Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved.5# Licensed under the BSD 3-Clause License (the "License"); you may not use this 6# file except in compliance with the License. You may obtain a copy of the License at7# 8# https://opensource.org/licenses/BSD-3-Clause9# 10# Unless required by applicable law or agreed to in writing, software distributed 11# under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS12# OF ANY KIND, either express or implied. See the License for the specific language13# governing permissions and limitations under the License.14#15'''命令行参数解析16'''17import sys18import re19import six20class Args(dict):21 '''@desc: 命令行参数解析为字典(支持格式: -key "value" -key=value --key "value" --key=value)22 '''23 RegPattern1 = '^\-{1,2}\w+\=.+$'24 RegPattern2 = '^\-{1,2}\w+$'25 RegPatternAll = '|'.join([RegPattern1, RegPattern2])26 27 def __init__(self, keys_to_lower=True):28 dict.__init__(self)29 self.keys_to_lower = keys_to_lower30 self.parse()31 32 def __convert__(self, item):33 if re.match('^\d+\.\d+$', item) : return float(item)34 if re.match('^\d+$', item) : return int(item)35 if re.match('^True$', item, re.I) : return True36 if re.match('^False$', item, re.I) : return False37 if re.match('|'.join(['^None$', '^NULL$']), item, re.I) : return None38 return item39 40 def update(self, _dict):41 if self.keys_to_lower:42 for (key, value) in six.iteritems(_dict):43 self[key.lower()] = value44 else:super(self.__class__, self).update(_dict)45 46 def parse(self):47 for i, item in enumerate(sys.argv):48 if re.match(self.RegPatternAll, item):49 if re.match(self.RegPattern1, item):50 item = re.sub('^-+', '', item)51 key = re.sub('=.+$', '', item)52 value = re.sub('^\w+=', '', item)53 if self.keys_to_lower : key = key.lower()54 self.update({key:self.__convert__(value)})55 continue56 if re.match(self.RegPattern2, item):57 key = re.sub('^-+', '', item)58 value = sys.argv[i + 1]59 if self.keys_to_lower : key = key.lower()60 self.update({key:self.__convert__(value)})...

Full Screen

Full Screen

env_extension.py

Source:env_extension.py Github

copy

Full Screen

1import os2from .extension import Extension3class EnvExtension(Extension):4 def __init__(self, keys_to_lower: bool = True):5 self.keys_to_lower = keys_to_lower6 super().__init__()7 def define(self):8 for k, v in os.environ.items():...

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 localstack 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