How to use uppercase method in localstack

Best Python code snippet using localstack_python

qom_type_info.py

Source:qom_type_info.py Github

copy

Full Screen

...58 @property59 def classtype(self) -> Optional[str]:60 return self.group('classtype')61 @property62 def uppercase(self) -> Optional[str]:63 return self.group('uppercase')64 @property65 def parent_uppercase(self) -> str:66 return self.group('parent_uppercase')67 @property68 def initializers(self) -> Optional[TypeInfoInitializers]:69 if getattr(self, '_inititalizers', None):70 self._initializers: TypeInfoInitializers71 return self._initializers72 fields = self.group('fields')73 if fields is None:74 return None75 d = dict((fm.group('field'), fm)76 for fm in self.group_finditer(FieldInitializer, 'fields'))77 self._initializers = d # type: ignore78 return self._initializers79class TypeInfoVar(TypeDefinition):80 """TypeInfo variable declaration with initializer"""81 regexp = S(NAMED('begin', RE_TYPEINFO_START),82 M(NAMED('fields', RE_TI_FIELDS),83 NAMED('endcomments', SP, RE_COMMENTS),84 NAMED('end', r'};?\n'),85 n='?', name='fullspec'))86 def is_static(self) -> bool:87 return 'static' in self.group('modifiers')88 def is_const(self) -> bool:89 return 'const' in self.group('modifiers')90 def is_full(self) -> bool:91 return bool(self.group('fullspec'))92 def get_initializers(self) -> TypeInfoInitializers:93 """Helper for code that needs to deal with missing initializer info"""94 if self.initializers is None:95 return {}96 return self.initializers97 def get_raw_initializer_value(self, field: str, default: str = '') -> str:98 initializers = self.get_initializers()99 if field in initializers:100 return initializers[field].raw101 else:102 return default103 @property104 def typename(self) -> Optional[str]:105 return self.get_raw_initializer_value('name')106 @property107 def uppercase(self) -> Optional[str]:108 typename = self.typename109 if not typename:110 return None111 if not typename.startswith('TYPE_'):112 return None113 return typename[len('TYPE_'):]114 @property115 def classtype(self) -> Optional[str]:116 class_size = self.get_raw_initializer_value('class_size')117 if not class_size:118 return None119 m = re.fullmatch(RE_SIZEOF, class_size)120 if not m:121 return None122 return m.group('sizeoftype')123 @property124 def instancetype(self) -> Optional[str]:125 instance_size = self.get_raw_initializer_value('instance_size')126 if not instance_size:127 return None128 m = re.fullmatch(RE_SIZEOF, instance_size)129 if not m:130 return None131 return m.group('sizeoftype')132 #def extract_identifiers(self) -> Optional[TypeIdentifiers]:133 # """Try to extract identifiers from names being used"""134 # DBG("extracting idenfiers from %s", self.name)135 #uppercase = None136 #if typename and re.fullmatch(RE_IDENTIFIER, typename) and typename.startswith("TYPE_"):137 # uppercase = typename[len('TYPE_'):]138 #lowercase = None139 #funcs = set()140 #prefixes = set()141 #for field,suffix in [('instance_init', '_init'),142 # ('instance_finalize', '_finalize'),143 # ('class_init', '_class_init')]:144 # if field not in values:145 # continue146 # func = values[field].raw147 # funcs.add(func)148 # if func.endswith(suffix):149 # prefixes.add(func[:-len(suffix)])150 # else:151 # self.warn("function name %s doesn't have expected %s suffix",152 # func, suffix)153 #if len(prefixes) == 1:154 # lowercase = prefixes.pop()155 #elif len(prefixes) > 1:156 # self.warn("inconsistent function names: %s", ' '.join(funcs))157 #.parent = TYPE_##PARENT_MODULE_OBJ_NAME, \158 #return TypeIdentifiers(typename=typename,159 # uppercase=uppercase, lowercase=lowercase,160 # instancetype=instancetype, classtype=classtype)161 def append_field(self, field: str, value: str) -> Patch:162 """Generate patch appending a field initializer"""163 content = f' .{field} = {value},\n'164 fm = self.group_match('fields')165 assert fm166 return fm.append(content)167 def patch_field(self, field: str, replacement: str) -> Patch:168 """Generate patch replacing a field initializer"""169 initializers = self.initializers170 assert initializers171 value = initializers.get(field)172 assert value173 return value.make_patch(replacement)174 def remove_field(self, field: str) -> Iterable[Patch]:175 initializers = self.initializers176 assert initializers177 if field in initializers:178 yield self.patch_field(field, '')179 def remove_fields(self, *fields: str) -> Iterable[Patch]:180 for f in fields:181 yield from self.remove_field(f)182 def patch_field_value(self, field: str, replacement: str) -> Patch:183 """Replace just the value of a field initializer"""184 initializers = self.initializers185 assert initializers186 value = initializers.get(field)187 assert value188 vm = value.group_match('value')189 assert vm190 return vm.make_patch(replacement)191class RemoveRedundantClassSize(TypeInfoVar):192 """Remove class_size when using OBJECT_DECLARE_SIMPLE_TYPE"""193 def gen_patches(self) -> Iterable[Patch]:194 initializers = self.initializers195 if initializers is None:196 return197 if 'class_size' not in initializers:198 return199 self.debug("Handling %s", self.name)200 m = re.fullmatch(RE_SIZEOF, initializers['class_size'].raw)201 if not m:202 self.warn("%s class_size is not sizeof?", self.name)203 return204 classtype = m.group('sizeoftype')205 if not classtype.endswith('Class'):206 self.warn("%s class size type (%s) is not *Class?", self.name, classtype)207 return208 self.debug("classtype is %s", classtype)209 instancetype = classtype[:-len('Class')]210 self.debug("intanceypte is %s", instancetype)211 self.debug("searching for simpletype declaration using %s as InstanceType", instancetype)212 decl = self.allfiles.find_match(OldStyleObjectDeclareSimpleType,213 instancetype, 'instancetype')214 if not decl:215 self.debug("No simpletype declaration found for %s", instancetype)216 return217 self.debug("Found simple type declaration")218 decl.debug("declaration is here")219 yield from self.remove_field('class_size')220class RemoveDeclareSimpleTypeArg(OldStyleObjectDeclareSimpleType):221 """Remove class_size when using OBJECT_DECLARE_SIMPLE_TYPE"""222 def gen_patches(self) -> Iterable[Patch]:223 c = (f'OBJECT_DECLARE_SIMPLE_TYPE({self.group("instancetype")}, {self.group("lowercase")},\n'224 f' {self.group("uppercase")})\n')225 yield self.make_patch(c)226class UseDeclareTypeExtended(TypeInfoVar):227 """Replace TypeInfo variable with OBJECT_DEFINE_TYPE_EXTENDED"""228 def gen_patches(self) -> Iterable[Patch]:229 # this will just ensure the caches for find_match() and matches_for_type()230 # will be loaded in advance:231 find_type_checkers(self.allfiles, 'xxxxxxxxxxxxxxxxx')232 if not self.is_static():233 self.info("Skipping non-static TypeInfo variable")234 return235 type_info_macro = self.file.find_match(TypeInfoMacro, self.name)236 if not type_info_macro:237 self.warn("TYPE_INFO(%s) line not found", self.name)238 return239 values = self.initializers240 if values is None:241 return242 if 'name' not in values:243 self.warn("name not set in TypeInfo variable %s", self.name)244 return245 typename = values['name'].raw246 if 'parent' not in values:247 self.warn("parent not set in TypeInfo variable %s", self.name)248 return249 parent_typename = values['parent'].raw250 instancetype = None251 if 'instance_size' in values:252 m = re.fullmatch(RE_SIZEOF, values['instance_size'].raw)253 if m:254 instancetype = m.group('sizeoftype')255 else:256 self.warn("can't extract instance type in TypeInfo variable %s", self.name)257 self.warn("instance_size is set to: %r", values['instance_size'].raw)258 return259 classtype = None260 if 'class_size' in values:261 m = re.fullmatch(RE_SIZEOF, values['class_size'].raw)262 if m:263 classtype = m.group('sizeoftype')264 else:265 self.warn("can't extract class type in TypeInfo variable %s", self.name)266 self.warn("class_size is set to: %r", values['class_size'].raw)267 return268 #for t in (typename, parent_typename):269 # if not re.fullmatch(RE_IDENTIFIER, t):270 # self.info("type name is not a macro/constant")271 # if instancetype or classtype:272 # self.warn("macro/constant type name is required for instance/class type")273 # if not self.file.force:274 # return275 # Now, the challenge is to find out the right MODULE_OBJ_NAME for the276 # type and for the parent type277 self.info("TypeInfo variable for %s is here", typename)278 uppercase = find_typename_uppercase(self.allfiles, typename)279 if not uppercase:280 self.info("Can't find right uppercase name for %s", typename)281 if instancetype or classtype:282 self.warn("Can't find right uppercase name for %s", typename)283 self.warn("This will make type validation difficult in the future")284 return285 parent_uppercase = find_typename_uppercase(self.allfiles, parent_typename)286 if not parent_uppercase:287 self.info("Can't find right uppercase name for parent type (%s)", parent_typename)288 if instancetype or classtype:289 self.warn("Can't find right uppercase name for parent type (%s)", parent_typename)290 self.warn("This will make type validation difficult in the future")291 return292 ok = True293 #checkers: List[TypeCheckerDeclaration] = list(find_type_checkers(self.allfiles, uppercase))294 #for c in checkers:295 # c.info("instance type checker declaration (%s) is here", c.group('uppercase'))296 #if not checkers:297 # self.info("No type checkers declared for %s", uppercase)298 # if instancetype or classtype:299 # self.warn("Can't find where type checkers for %s (%s) are declared. We will need them to validate sizes of %s",...

Full Screen

Full Screen

qom_macros.py

Source:qom_macros.py Github

copy

Full Screen

...409 @property410 def typename(self) -> str:411 return self.group('typename')412 @property413 def uppercase(self) -> str:414 return self.group('uppercase')415class DeclareInstanceChecker(TypeCheckerDeclaration):416 """DECLARE_INSTANCE_CHECKER use"""417 #TODO: replace lonely DECLARE_INSTANCE_CHECKER with DECLARE_OBJ_CHECKERS418 # if all types are found.419 # This will require looking up the correct class type in the TypeInfo420 # structs in another file421 regexp = S(r'^[ \t]*DECLARE_INSTANCE_CHECKER\s*\(\s*',422 NAMED('instancetype', RE_TYPE), r'\s*,\s*',423 NAMED('uppercase', RE_IDENTIFIER), r'\s*,\s*',424 OR(RE_IDENTIFIER, RE_STRING, RE_MACRO_CONCAT, RE_FUN_CALL, name='typename'), SP,425 r'\)[ \t]*;?[ \t]*\n')426 def required_identifiers(self) -> Iterable[RequiredIdentifier]:427 yield RequiredIdentifier('include', '"qom/object.h"')428 yield RequiredIdentifier('constant', self.group('typename'))429 yield RequiredIdentifier('type', self.group('instancetype'))430class DeclareInterfaceChecker(TypeCheckerDeclaration):431 """DECLARE_INTERFACE_CHECKER use"""432 regexp = S(r'^[ \t]*DECLARE_INTERFACE_CHECKER\s*\(\s*',433 NAMED('instancetype', RE_TYPE), r'\s*,\s*',434 NAMED('uppercase', RE_IDENTIFIER), r'\s*,\s*',435 OR(RE_IDENTIFIER, RE_STRING, RE_MACRO_CONCAT, RE_FUN_CALL, name='typename'), SP,436 r'\)[ \t]*;?[ \t]*\n')437 def required_identifiers(self) -> Iterable[RequiredIdentifier]:438 yield RequiredIdentifier('include', '"qom/object.h"')439 yield RequiredIdentifier('constant', self.group('typename'))440 yield RequiredIdentifier('type', self.group('instancetype'))441class DeclareInstanceType(TypeDeclaration):442 """DECLARE_INSTANCE_TYPE use"""443 regexp = S(r'^[ \t]*DECLARE_INSTANCE_TYPE\s*\(\s*',444 NAMED('uppercase', RE_IDENTIFIER), r'\s*,\s*',445 NAMED('instancetype', RE_TYPE), SP,446 r'\)[ \t]*;?[ \t]*\n')447 def required_identifiers(self) -> Iterable[RequiredIdentifier]:448 yield RequiredIdentifier('include', '"qom/object.h"')449 yield RequiredIdentifier('type', self.group('instancetype'))450class DeclareClassType(TypeDeclaration):451 """DECLARE_CLASS_TYPE use"""452 regexp = S(r'^[ \t]*DECLARE_CLASS_TYPE\s*\(\s*',453 NAMED('uppercase', RE_IDENTIFIER), r'\s*,\s*',454 NAMED('classtype', RE_TYPE), SP,455 r'\)[ \t]*;?[ \t]*\n')456 def required_identifiers(self) -> Iterable[RequiredIdentifier]:457 yield RequiredIdentifier('include', '"qom/object.h"')458 yield RequiredIdentifier('type', self.group('classtype'))459class DeclareClassCheckers(TypeCheckerDeclaration):460 """DECLARE_CLASS_CHECKER use"""461 regexp = S(r'^[ \t]*DECLARE_CLASS_CHECKERS\s*\(\s*',462 NAMED('classtype', RE_TYPE), r'\s*,\s*',463 NAMED('uppercase', RE_IDENTIFIER), r'\s*,\s*',464 OR(RE_IDENTIFIER, RE_STRING, RE_MACRO_CONCAT, RE_FUN_CALL, name='typename'), SP,465 r'\)[ \t]*;?[ \t]*\n')466 def required_identifiers(self) -> Iterable[RequiredIdentifier]:467 yield RequiredIdentifier('include', '"qom/object.h"')468 yield RequiredIdentifier('constant', self.group('typename'))469 yield RequiredIdentifier('type', self.group('classtype'))470class DeclareObjCheckers(TypeCheckerDeclaration):471 """DECLARE_OBJ_CHECKERS use"""472 #TODO: detect when OBJECT_DECLARE_SIMPLE_TYPE can be used473 regexp = S(r'^[ \t]*DECLARE_OBJ_CHECKERS\s*\(\s*',474 NAMED('instancetype', RE_TYPE), r'\s*,\s*',475 NAMED('classtype', RE_TYPE), r'\s*,\s*',476 NAMED('uppercase', RE_IDENTIFIER), r'\s*,\s*',477 OR(RE_IDENTIFIER, RE_STRING, RE_MACRO_CONCAT, RE_FUN_CALL, name='typename'), SP,478 r'\)[ \t]*;?[ \t]*\n')479 def required_identifiers(self) -> Iterable[RequiredIdentifier]:480 yield RequiredIdentifier('include', '"qom/object.h"')481 yield RequiredIdentifier('constant', self.group('typename'))482 yield RequiredIdentifier('type', self.group('classtype'))483 yield RequiredIdentifier('type', self.group('instancetype'))484class TypeDeclarationFixup(FileMatch):485 """Common base class for code that will look at a set of type declarations"""486 regexp = RE_FILE_BEGIN487 def gen_patches(self) -> Iterable[Patch]:488 if self.file.filename_matches('qom/object.h'):489 self.debug("skipping object.h")490 return491 # group checkers by uppercase name:492 decl_types: List[Type[TypeDeclaration]] = [DeclareInstanceChecker, DeclareInstanceType,493 DeclareClassCheckers, DeclareClassType,494 DeclareObjCheckers]495 checker_dict: Dict[str, List[TypeDeclaration]] = {}496 for t in decl_types:497 for m in self.file.matches_of_type(t):498 checker_dict.setdefault(m.group('uppercase'), []).append(m)499 self.debug("checker_dict: %r", checker_dict)500 for uppercase,checkers in checker_dict.items():501 fields = ('instancetype', 'classtype', 'uppercase', 'typename')502 fvalues = dict((field, set(getattr(m, field) for m in checkers503 if getattr(m, field, None) is not None))504 for field in fields)505 for field,values in fvalues.items():506 if len(values) > 1:507 for c in checkers:508 c.warn("%s mismatch (%s)", field, ' '.join(values))509 return510 field_dict = dict((f, v.pop() if v else None) for f,v in fvalues.items())511 yield from self.gen_patches_for_type(uppercase, checkers, field_dict)512 def find_conflicts(self, uppercase: str, checkers: List[TypeDeclaration]) -> bool:513 """Look for conflicting declarations that would make it unsafe to add new ones"""514 conflicting: List[FileMatch] = []515 # conflicts in the same file:516 conflicting.extend(chain(self.file.find_matches(DefineDirective, uppercase),517 self.file.find_matches(DeclareInterfaceChecker, uppercase, 'uppercase'),518 self.file.find_matches(DeclareClassType, uppercase, 'uppercase'),519 self.file.find_matches(DeclareInstanceType, uppercase, 'uppercase')))520 # conflicts in another file:521 conflicting.extend(o for o in chain(self.allfiles.find_matches(DeclareInstanceChecker, uppercase, 'uppercase'),522 self.allfiles.find_matches(DeclareClassCheckers, uppercase, 'uppercase'),523 self.allfiles.find_matches(DeclareInterfaceChecker, uppercase, 'uppercase'),524 self.allfiles.find_matches(DefineDirective, uppercase))525 if o is not None and o.file != self.file526 # if both are .c files, there's no conflict at all:527 and not (o.file.filename.suffix == '.c' and528 self.file.filename.suffix == '.c'))529 if conflicting:530 for c in checkers:531 c.warn("skipping due to conflicting %s macro", uppercase)532 for o in conflicting:533 if o is None:534 continue535 o.warn("conflicting %s macro is here", uppercase)536 return True537 return False538 def gen_patches_for_type(self, uppercase: str,539 checkers: List[TypeDeclaration],540 fields: Dict[str, Optional[str]]) -> Iterable[Patch]:541 """Should be reimplemented by subclasses"""542 return543 yield544class DeclareVoidTypes(TypeDeclarationFixup):545 """Add DECLARE_*_TYPE(..., void) when there's no declared type"""546 regexp = RE_FILE_BEGIN547 def gen_patches_for_type(self, uppercase: str,548 checkers: List[TypeDeclaration],549 fields: Dict[str, Optional[str]]) -> Iterable[Patch]:550 if self.find_conflicts(uppercase, checkers):551 return552 #_,last_checker = max((m.start(), m) for m in checkers)553 _,first_checker = min((m.start(), m) for m in checkers)554 if not any(m.instancetype for m in checkers):555 yield first_checker.prepend(f'DECLARE_INSTANCE_TYPE({uppercase}, void)\n')556 if not any(m.classtype for m in checkers):557 yield first_checker.prepend(f'DECLARE_CLASS_TYPE({uppercase}, void)\n')558 #if not all(len(v) == 1 for v in fvalues.values()):559 # return560 #561 #final_values = dict((field, values.pop())562 # for field,values in fvalues.items())563 #s = (f"DECLARE_OBJ_CHECKERS({final_values['instancetype']}, {final_values['classtype']},\n"+564 # f" {final_values['uppercase']}, {final_values['typename']})\n")565 #for c in checkers:566 # yield c.make_removal_patch()567 #yield last_checker.append(s)568class AddDeclareTypeName(TypeDeclarationFixup):569 """Add DECLARE_TYPE_NAME declarations if necessary"""570 def gen_patches_for_type(self, uppercase: str,571 checkers: List[TypeDeclaration],572 fields: Dict[str, Optional[str]]) -> Iterable[Patch]:573 typename = fields.get('typename')574 if typename is None:575 self.warn("typename unavailable")576 return577 if typename == f'TYPE_{uppercase}':578 self.info("already using TYPE_%s as type name", uppercase)579 return580 if self.file.find_match(DeclareTypeName, uppercase, 'uppercase'):581 self.info("type name for %s already declared", uppercase)582 return583 _,first_checker = min((m.start(), m) for m in checkers)584 s = f'DECLARE_TYPE_NAME({uppercase}, {typename})\n'585 yield first_checker.prepend(s)586class TrivialClassStruct(FileMatch):587 """Trivial class struct"""588 regexp = S(r'^[ \t]*struct\s*', NAMED('name', RE_IDENTIFIER),589 r'\s*{\s*', NAMED('parent_struct', RE_IDENTIFIER), r'\s*parent(_class)?\s*;\s*};\n')590class DeclareTypeName(FileMatch):591 """DECLARE_TYPE_NAME usage"""592 regexp = S(r'^[ \t]*DECLARE_TYPE_NAME\s*\(',593 NAMED('uppercase', RE_IDENTIFIER), r'\s*,\s*',594 OR(RE_IDENTIFIER, RE_STRING, RE_MACRO_CONCAT, RE_FUN_CALL, name='typename'),595 r'\s*\);?[ \t]*\n')596class ObjectDeclareType(TypeCheckerDeclaration):597 """OBJECT_DECLARE_TYPE usage598 Will be replaced with OBJECT_DECLARE_SIMPLE_TYPE if possible599 """600 regexp = S(r'^[ \t]*OBJECT_DECLARE_TYPE\s*\(',601 NAMED('instancetype', RE_TYPE), r'\s*,\s*',602 NAMED('classtype', RE_TYPE), r'\s*,\s*',603 NAMED('uppercase', RE_IDENTIFIER), SP,604 r'\)[ \t]*;?[ \t]*\n')605 def gen_patches(self):606 DBG("groups: %r", self.match.groupdict())607 trivial_struct = self.file.find_match(TrivialClassStruct, self.group('classtype'))608 if trivial_struct:609 d = self.match.groupdict().copy()610 d['parent_struct'] = trivial_struct.group("parent_struct")611 yield trivial_struct.make_removal_patch()612 c = ("OBJECT_DECLARE_SIMPLE_TYPE(%(instancetype)s, %(lowercase)s,\n"613 " %(uppercase)s, %(parent_struct)s)\n" % d)614 yield self.make_patch(c)615class ObjectDeclareSimpleType(TypeCheckerDeclaration):616 """OBJECT_DECLARE_SIMPLE_TYPE usage"""617 regexp = S(r'^[ \t]*OBJECT_DECLARE_SIMPLE_TYPE\s*\(',618 NAMED('instancetype', RE_TYPE), r'\s*,\s*',619 NAMED('uppercase', RE_IDENTIFIER), SP,620 r'\)[ \t]*;?[ \t]*\n')621class OldStyleObjectDeclareSimpleType(TypeCheckerDeclaration):622 """OBJECT_DECLARE_SIMPLE_TYPE usage (old API)"""623 regexp = S(r'^[ \t]*OBJECT_DECLARE_SIMPLE_TYPE\s*\(',624 NAMED('instancetype', RE_TYPE), r'\s*,\s*',625 NAMED('lowercase', RE_IDENTIFIER), r'\s*,\s*',626 NAMED('uppercase', RE_IDENTIFIER), r'\s*,\s*',627 NAMED('parent_classtype', RE_TYPE), SP,628 r'\)[ \t]*;?[ \t]*\n')629 @property630 def classtype(self) -> Optional[str]:631 instancetype = self.instancetype632 assert instancetype633 return f"{instancetype}Class"634def find_typename_uppercase(files: FileList, typename: str) -> Optional[str]:635 """Try to find what's the right MODULE_OBJ_NAME for a given type name"""636 decl = files.find_match(DeclareTypeName, name=typename, group='typename')637 if decl:638 return decl.group('uppercase')639 if typename.startswith('TYPE_'):640 return typename[len('TYPE_'):]641 return None642def find_type_checkers(files:FileList, name:str, group:str='uppercase') -> Iterable[TypeCheckerDeclaration]:643 """Find usage of DECLARE*CHECKER macro"""644 c: Type[TypeCheckerDeclaration]645 for c in (DeclareInstanceChecker, DeclareClassCheckers, DeclareObjCheckers, ObjectDeclareType, ObjectDeclareSimpleType):646 yield from files.find_matches(c, name=name, group=group)647class Include(FileMatch):648 """#include directive"""...

Full Screen

Full Screen

functions.py

Source:functions.py Github

copy

Full Screen

1import random23def full():4 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"5 lowercase_letters = uppercase_letters.lower()6 digits = "0123456789"7 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"8 upper, lower, nums, syms = True, True, True, True9 all = ""1011 if upper:12 all += uppercase_letters13 if lower:14 all += lowercase_letters15 if nums:16 all += digits17 if syms:18 all += symbols19 length = int(input("What Is The Length Of Password:"))20 amount = int(input("How Much Password?:"))21 for x in range(amount):22 password = "".join(random.sample(all, length))23 print(password)24def only_upper():25 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"26 lowercase_letters = uppercase_letters.lower()27 digits = "0123456789"28 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"2930 upper, lower, nums, symbols = True, False, False, False3132 all = ""3334 if upper:35 all += uppercase_letters36 if lower:37 all += lowercase_letters38 if nums:39 all += digits40 if symbols:41 all += symbols42 length = int(input("What Is The Length Of Password:"))43 amount = int(input("How Much Password?:"))44 for x in range(amount):45 password = "".join(random.sample(all, length))46 print(password)47def only_lower():48 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"49 lowercase_letters = uppercase_letters.lower()50 digits = "0123456789"51 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"52 length = int(input("What Is The Length Of Password:"))53 amount = int(input("How Much Password?:"))5455 upper, lower, nums, symbols = False, True, False, False5657 all = ""5859 if upper:60 all += uppercase_letters61 if lower:62 all += lowercase_letters63 if nums:64 all += digits65 if symbols:66 all += symbols67 for x in range(amount):68 password = "".join(random.sample(all, length))69 print(password)70def only_nums():71 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"72 lowercase_letters = uppercase_letters.lower()73 digits = "0123456789"74 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"75 length = int(input("What Is The Length Of Password:"))76 amount = int(input("How Much Password?:"))7778 upper, lower, nums, symbols = False, False, True, False7980 all = ""8182 if upper:83 all += uppercase_letters84 if lower:85 all += lowercase_letters86 if nums:87 all += digits88 if symbols:89 all += symbols90 for x in range(amount):91 password = "".join(random.sample(all, length))92 print(password)93def only_syms():94 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"95 lowercase_letters = uppercase_letters.lower()96 digits = "0123456789"97 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"98 length = int(input("What Is The Length Of Password:"))99 amount = int(input("How Much Password?:"))100101 upper, lower, nums, syms = False, False, False, True102103 all = ""104105 if upper:106 all += uppercase_letters107 if lower:108 all += lowercase_letters109 if nums:110 all += digits111 if syms:112 all += symbols113 for x in range(amount):114 password = "".join(random.sample(all, length))115 print(password)116def upper_lower():117 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"118 lowercase_letters = uppercase_letters.lower()119 digits = "0123456789"120 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"121 length = int(input("What Is The Length Of Password:"))122 amount = int(input("How Much Password?:"))123 upper, lower, nums, symbols = True, True, False, False124125 all = ""126127 if upper:128 all += uppercase_letters129 if lower:130 all += lowercase_letters131 if nums:132 all += digits133 if symbols:134 all += symbols135 for x in range(amount):136 password = "".join(random.sample(all, length))137 print(password)138def upper_nums():139 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"140 lowercase_letters = uppercase_letters.lower()141 digits = "0123456789"142 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"143 length = int(input("What Is The Length Of Password:"))144 amount = int(input("How Much Password?:"))145 upper, lower, nums, symbols = True, False, True, False146147 all = ""148149 if upper:150 all += uppercase_letters151 if lower:152 all += lowercase_letters153 if nums:154 all += digits155 if symbols:156 all += symbols157 for x in range(amount):158 password = "".join(random.sample(all, length))159 print(password)160def upper_symbols():161 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"162 lowercase_letters = uppercase_letters.lower()163 digits = "0123456789"164 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"165 length = int(input("What Is The Length Of Password:"))166 amount = int(input("How Much Password?:"))167 upper, lower, nums, symbols = True, False, False, True168169 all = ""170171 if upper:172 all += uppercase_letters173 if lower:174 all += lowercase_letters175 if nums:176 all += digits177 if symbols:178 all += symbols179 for x in range(amount):180 password = "".join(random.sample(all, length))181 print(password)182def lower_nums():183 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"184 lowercase_letters = uppercase_letters.lower()185 digits = "0123456789"186 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"187 length = int(input("What Is The Length Of Password:"))188 amount = int(input("How Much Password?:"))189 upper, lower, nums, symbols = False, True, True, False190191 all = ""192193 if upper:194 all += uppercase_letters195 if lower:196 all += lowercase_letters197 if nums:198 all += digits199 if symbols:200 all += symbols201 for x in range(amount):202 password = "".join(random.sample(all, length))203 print(password)204def lower_symbols():205 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"206 lowercase_letters = uppercase_letters.lower()207 digits = "0123456789"208 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"209 length = int(input("What Is The Length Of Password:"))210 amount = int(input("How Much Password?:"))211 upper, lower, nums, syms = False, True, False, True212213 all = ""214215 if upper:216 all += uppercase_letters217 if lower:218 all += lowercase_letters219 if nums:220 all += digits221 if syms:222 all += symbols223 for x in range(amount):224 password = "".join(random.sample(all, length))225 print(password)226def nums_symbols():227 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"228 lowercase_letters = uppercase_letters.lower()229 digits = "0123456789"230 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"231 length = int(input("What Is The Length Of Password:"))232 amount = int(input("How Much Password?:"))233 upper, lower, nums, syms = False, False, True, True234235 all = ""236237 if upper:238 all += uppercase_letters239 if lower:240 all += lowercase_letters241 if nums:242 all += digits243 if syms:244 all += symbols245 for x in range(amount):246 password = "".join(random.sample(all, length))247 print(password)248def upper_lower_nums():249 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"250 lowercase_letters = uppercase_letters.lower()251 digits = "0123456789"252 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"253 length = int(input("What Is The Length Of Password:"))254 amount = int(input("How Much Password?:"))255 upper, lower, nums, symbols = True, True, True, False256257 all = ""258259 if upper:260 all += uppercase_letters261 if lower:262 all += lowercase_letters263 if nums:264 all += digits265 if symbols:266 all += symbols267 for x in range(amount):268 password = "".join(random.sample(all, length))269 print(password)270def lower_nums_symbols():271 uppercase_letters = "ABCDEFGHIJKLMNOPRSTUVYZQW"272 lowercase_letters = uppercase_letters.lower()273 digits = "0123456789"274 symbols = "!'^#+$%&/{([)]=}?\\*-_,;`´<>|"275 length = int(input("What Is The Length Of Password:"))276 amount = int(input("How Much Password?:"))277 upper, lower, nums, syms = False, True, True, True278279 all = ""280281 if upper:282 all += uppercase_letters283 if lower:284 all += lowercase_letters285 if nums:286 all += digits287 if syms:288 all += (symbols)289 for x in range(amount):290 password = "".join(random.sample(all, length))291 print(password) ...

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