How to use __new__ method in Robotframework-anywherelibrary

Best Python code snippet using robotframework-anywherelibrary

aenum.py

Source:aenum.py Github

copy

Full Screen

...112 """Metaclass for Enum"""113 @classmethod114 def __prepare__(metacls, cls, bases):115 return _EnumDict()116 def __new__(metacls, cls, bases, classdict):117 # an Enum class is final once enumeration items have been defined; it118 # cannot be mixed with other types (int, float, etc.) if it has an119 # inherited __new__ unless a new __new__ is defined (or the resulting120 # class will fail).121 if type(classdict) is dict:122 original_dict = classdict123 classdict = _EnumDict()124 for k, v in original_dict.items():125 classdict[k] = v126 member_type, first_enum = metacls._get_mixins_(bases)127 __new__, save_new, use_args = metacls._find_new_(classdict, member_type,128 first_enum)129 # save enum items into separate mapping so they don't get baked into130 # the new class131 members = dict((k, classdict[k]) for k in classdict._member_names)132 for name in classdict._member_names:133 del classdict[name]134 # py2 support for definition order135 _order_ = classdict.get('_order_')136 if _order_ is None:137 if pyver < 3.0:138 try:139 _order_ = [name for (name, value) in sorted(members.items(), key=lambda item: item[1])]140 except TypeError:141 _order_ = [name for name in sorted(members.keys())]142 else:143 _order_ = classdict._member_names144 else:145 del classdict['_order_']146 if pyver < 3.0:147 _order_ = _order_.replace(',', ' ').split()148 aliases = [name for name in members if name not in _order_]149 _order_ += aliases150 # check for illegal enum names (any others?)151 invalid_names = set(members) & set(['mro'])152 if invalid_names:153 raise ValueError('Invalid enum member name(s): %s' % (154 ', '.join(invalid_names), ))155 # save attributes from super classes so we know if we can take156 # the shortcut of storing members in the class dict157 base_attributes = set([a for b in bases for a in b.__dict__])158 # create our new Enum type159 enum_class = super(EnumMeta, metacls).__new__(metacls, cls, bases, classdict)160 enum_class._member_names_ = [] # names in random order161 if OrderedDict is not None:162 enum_class._member_map_ = OrderedDict()163 else:164 enum_class._member_map_ = {} # name->value map165 enum_class._member_type_ = member_type166 # Reverse value->name map for hashable values.167 enum_class._value2member_map_ = {}168 # instantiate them, checking for duplicates as we go169 # we instantiate first instead of checking for duplicates first in case170 # a custom __new__ is doing something funky with the values -- such as171 # auto-numbering ;)172 if __new__ is None:173 __new__ = enum_class.__new__174 for member_name in _order_:175 value = members[member_name]176 if not isinstance(value, tuple):177 args = (value, )178 else:179 args = value180 if member_type is tuple: # special case for tuple enums181 args = (args, ) # wrap it one more time182 if not use_args or not args:183 enum_member = __new__(enum_class)184 if not hasattr(enum_member, '_value_'):185 enum_member._value_ = value186 else:187 enum_member = __new__(enum_class, *args)188 if not hasattr(enum_member, '_value_'):189 enum_member._value_ = member_type(*args)190 value = enum_member._value_191 enum_member._name_ = member_name192 enum_member.__objclass__ = enum_class193 enum_member.__init__(*args)194 # If another member with the same value was already defined, the195 # new member becomes an alias to the existing one.196 for name, canonical_member in enum_class._member_map_.items():197 if canonical_member.value == enum_member._value_:198 enum_member = canonical_member199 break200 else:201 # Aliases don't appear in member names (only in __members__).202 enum_class._member_names_.append(member_name)203 # performance boost for any member that would not shadow204 # a DynamicClassAttribute (aka _RouteClassAttributeToGetattr)205 if member_name not in base_attributes:206 setattr(enum_class, member_name, enum_member)207 # now add to _member_map_208 enum_class._member_map_[member_name] = enum_member209 try:210 # This may fail if value is not hashable. We can't add the value211 # to the map, and by-value lookups for this value will be212 # linear.213 enum_class._value2member_map_[value] = enum_member214 except TypeError:215 pass216 # If a custom type is mixed into the Enum, and it does not know how217 # to pickle itself, pickle.dumps will succeed but pickle.loads will218 # fail. Rather than have the error show up later and possibly far219 # from the source, sabotage the pickle protocol for this class so220 # that pickle.dumps also fails.221 #222 # However, if the new class implements its own __reduce_ex__, do not223 # sabotage -- it's on them to make sure it works correctly. We use224 # __reduce_ex__ instead of any of the others as it is preferred by225 # pickle over __reduce__, and it handles all pickle protocols.226 unpicklable = False227 if '__reduce_ex__' not in classdict:228 if member_type is not object:229 methods = ('__getnewargs_ex__', '__getnewargs__',230 '__reduce_ex__', '__reduce__')231 if not any(m in member_type.__dict__ for m in methods):232 _make_class_unpicklable(enum_class)233 unpicklable = True234 # double check that repr and friends are not the mixin's or various235 # things break (such as pickle)236 for name in ('__repr__', '__str__', '__format__', '__reduce_ex__'):237 class_method = getattr(enum_class, name)238 obj_method = getattr(member_type, name, None)239 enum_method = getattr(first_enum, name, None)240 if name not in classdict and class_method is not enum_method:241 if name == '__reduce_ex__' and unpicklable:242 continue243 setattr(enum_class, name, enum_method)244 # method resolution and int's are not playing nice245 # Python's less than 2.6 use __cmp__246 if pyver < 2.6:247 if issubclass(enum_class, int):248 setattr(enum_class, '__cmp__', getattr(int, '__cmp__'))249 elif pyver < 3.0:250 if issubclass(enum_class, int):251 for method in (252 '__le__',253 '__lt__',254 '__gt__',255 '__ge__',256 '__eq__',257 '__ne__',258 '__hash__',259 ):260 setattr(enum_class, method, getattr(int, method))261 # replace any other __new__ with our own (as long as Enum is not None,262 # anyway) -- again, this is to support pickle263 if Enum is not None:264 # if the user defined their own __new__, save it before it gets265 # clobbered in case they subclass later266 if save_new:267 setattr(enum_class, '__member_new__', enum_class.__dict__['__new__'])268 setattr(enum_class, '__new__', Enum.__dict__['__new__'])269 return enum_class270 def __bool__(cls):271 """272 classes/types should always be True.273 """274 return True275 def __call__(cls, value, names=None, module=None, type=None, start=1):276 """Either returns an existing member, or creates a new enum class.277 This method is used both when an enum class is given a value to match278 to an enumeration member (i.e. Color(3)) and for the functional API279 (i.e. Color = Enum('Color', names='red green blue')).280 When used for the functional API: `module`, if set, will be stored in281 the new class' __module__ attribute; `type`, if set, will be mixed in282 as the first base class.283 Note: if `module` is not set this routine will attempt to discover the284 calling module by walking the frame stack; if this is unsuccessful285 the resulting class will not be pickleable.286 """287 if names is None: # simple value lookup288 return cls.__new__(cls, value)289 # otherwise, functional API: we're creating a new Enum type290 return cls._create_(value, names, module=module, type=type, start=start)291 def __contains__(cls, member):292 return isinstance(member, cls) and member.name in cls._member_map_293 def __delattr__(cls, attr):294 # nicer error message when someone tries to delete an attribute295 # (see issue19025).296 if attr in cls._member_map_:297 raise AttributeError(298 "%s: cannot delete Enum member." % cls.__name__)299 super(EnumMeta, cls).__delattr__(attr)300 def __dir__(self):301 return (['__class__', '__doc__', '__members__', '__module__'] +302 self._member_names_)303 @property304 def __members__(cls):305 """Returns a mapping of member name->value.306 This mapping lists all enum members, including aliases. Note that this307 is a copy of the internal mapping.308 """309 return cls._member_map_.copy()310 def __getattr__(cls, name):311 """Return the enum member matching `name`312 We use __getattr__ instead of descriptors or inserting into the enum313 class' __dict__ in order to support `name` and `value` being both314 properties for enum members (which live in the class' __dict__) and315 enum members themselves.316 """317 if _is_dunder(name):318 raise AttributeError(name)319 try:320 return cls._member_map_[name]321 except KeyError:322 raise AttributeError(name)323 def __getitem__(cls, name):324 return cls._member_map_[name]325 def __iter__(cls):326 return (cls._member_map_[name] for name in cls._member_names_)327 def __reversed__(cls):328 return (cls._member_map_[name] for name in reversed(cls._member_names_))329 def __len__(cls):330 return len(cls._member_names_)331 __nonzero__ = __bool__332 def __repr__(cls):333 return "<enum %r>" % cls.__name__334 def __setattr__(cls, name, value):335 """Block attempts to reassign Enum members.336 A simple assignment to the class namespace only changes one of the337 several possible ways to get an Enum member from the Enum class,338 resulting in an inconsistent Enumeration.339 """340 member_map = cls.__dict__.get('_member_map_', {})341 if name in member_map:342 raise AttributeError('Cannot reassign members.')343 super(EnumMeta, cls).__setattr__(name, value)344 def _create_(cls, class_name, names=None, module=None, type=None, start=1):345 """Convenience method to create a new Enum class.346 `names` can be:347 * A string containing member names, separated either with spaces or348 commas. Values are auto-numbered from 1.349 * An iterable of member names. Values are auto-numbered from 1.350 * An iterable of (member name, value) pairs.351 * A mapping of member name -> value.352 """353 if pyver < 3.0:354 # if class_name is unicode, attempt a conversion to ASCII355 if isinstance(class_name, unicode):356 try:357 class_name = class_name.encode('ascii')358 except UnicodeEncodeError:359 raise TypeError('%r is not representable in ASCII' % class_name)360 metacls = cls.__class__361 if type is None:362 bases = (cls, )363 else:364 bases = (type, cls)365 classdict = metacls.__prepare__(class_name, bases)366 _order_ = []367 # special processing needed for names?368 if isinstance(names, basestring):369 names = names.replace(',', ' ').split()370 if isinstance(names, (tuple, list)) and isinstance(names[0], basestring):371 names = [(e, i+start) for (i, e) in enumerate(names)]372 # Here, names is either an iterable of (name, value) or a mapping.373 item = None # in case names is empty374 for item in names:375 if isinstance(item, basestring):376 member_name, member_value = item, names[item]377 else:378 member_name, member_value = item379 classdict[member_name] = member_value380 _order_.append(member_name)381 # only set _order_ in classdict if name/value was not from a mapping382 if not isinstance(item, basestring):383 classdict['_order_'] = ' '.join(_order_)384 enum_class = metacls.__new__(metacls, class_name, bases, classdict)385 # TODO: replace the frame hack if a blessed way to know the calling386 # module is ever developed387 if module is None:388 try:389 module = _sys._getframe(2).f_globals['__name__']390 except (AttributeError, ValueError):391 pass392 if module is None:393 _make_class_unpicklable(enum_class)394 else:395 enum_class.__module__ = module396 return enum_class397 @staticmethod398 def _get_mixins_(bases):399 """Returns the type for creating enum members, and the first inherited400 enum class.401 bases: the tuple of bases that was given to __new__402 """403 if not bases or Enum is None:404 return object, Enum405 # double check that we are not subclassing a class with existing406 # enumeration members; while we're at it, see if any other data407 # type has been mixed in so we can use the correct __new__408 member_type = first_enum = None409 for base in bases:410 if (base is not Enum and411 issubclass(base, Enum) and412 base._member_names_):413 raise TypeError("Cannot extend enumerations")414 # base is now the last base in bases415 if not issubclass(base, Enum):416 raise TypeError("new enumerations must be created as "417 "`ClassName([mixin_type,] enum_type)`")418 # get correct mix-in type (either mix-in type of Enum subclass, or419 # first base if last base is Enum)420 if not issubclass(bases[0], Enum):421 member_type = bases[0] # first data type422 first_enum = bases[-1] # enum type423 else:424 for base in bases[0].__mro__:425 # most common: (IntEnum, int, Enum, object)426 # possible: (<Enum 'AutoIntEnum'>, <Enum 'IntEnum'>,427 # <class 'int'>, <Enum 'Enum'>,428 # <class 'object'>)429 if issubclass(base, Enum):430 if first_enum is None:431 first_enum = base432 else:433 if member_type is None:434 member_type = base435 return member_type, first_enum436 if pyver < 3.0:437 @staticmethod438 def _find_new_(classdict, member_type, first_enum):439 """Returns the __new__ to be used for creating the enum members.440 classdict: the class dictionary given to __new__441 member_type: the data type whose __new__ will be used by default442 first_enum: enumeration to check for an overriding __new__443 """444 # now find the correct __new__, checking to see of one was defined445 # by the user; also check earlier enum classes in case a __new__ was446 # saved as __member_new__447 __new__ = classdict.get('__new__', None)448 if __new__:449 return None, True, True # __new__, save_new, use_args450 N__new__ = getattr(None, '__new__')451 O__new__ = getattr(object, '__new__')452 if Enum is None:453 E__new__ = N__new__454 else:455 E__new__ = Enum.__dict__['__new__']456 # check all possibles for __member_new__ before falling back to457 # __new__458 for method in ('__member_new__', '__new__'):459 for possible in (member_type, first_enum):460 try:461 target = possible.__dict__[method]462 except (AttributeError, KeyError):463 target = getattr(possible, method, None)464 if target not in [465 None,466 N__new__,467 O__new__,468 E__new__,469 ]:470 if method == '__member_new__':471 classdict['__new__'] = target472 return None, False, True473 if isinstance(target, staticmethod):474 target = target.__get__(member_type)475 __new__ = target476 break477 if __new__ is not None:478 break479 else:480 __new__ = object.__new__481 # if a non-object.__new__ is used then whatever value/tuple was482 # assigned to the enum member name will be passed to __new__ and to the483 # new enum member's __init__484 if __new__ is object.__new__:485 use_args = False486 else:487 use_args = True488 return __new__, False, use_args489 else:490 @staticmethod491 def _find_new_(classdict, member_type, first_enum):492 """Returns the __new__ to be used for creating the enum members.493 classdict: the class dictionary given to __new__494 member_type: the data type whose __new__ will be used by default495 first_enum: enumeration to check for an overriding __new__496 """497 # now find the correct __new__, checking to see of one was defined498 # by the user; also check earlier enum classes in case a __new__ was499 # saved as __member_new__500 __new__ = classdict.get('__new__', None)501 # should __new__ be saved as __member_new__ later?502 save_new = __new__ is not None503 if __new__ is None:504 # check all possibles for __member_new__ before falling back to505 # __new__506 for method in ('__member_new__', '__new__'):507 for possible in (member_type, first_enum):508 target = getattr(possible, method, None)509 if target not in (510 None,511 None.__new__,512 object.__new__,513 Enum.__new__,514 ):515 __new__ = target516 break517 if __new__ is not None:518 break519 else:520 __new__ = object.__new__521 # if a non-object.__new__ is used then whatever value/tuple was522 # assigned to the enum member name will be passed to __new__ and to the523 # new enum member's __init__524 if __new__ is object.__new__:525 use_args = False526 else:527 use_args = True528 return __new__, save_new, use_args529########################################################530# In order to support Python 2 and 3 with a single531# codebase we have to create the Enum methods separately532# and then use the `type(name, bases, dict)` method to533# create the class.534########################################################535temp_enum_dict = {}536temp_enum_dict['__doc__'] = "Generic enumeration.\n\n Derive from this class to define new enumerations.\n\n"537def __new__(cls, value):538 # all enum instances are actually created during class construction539 # without calling this method; this method is called by the metaclass'540 # __call__ (i.e. Color(3) ), and by pickle541 if type(value) is cls:542 # For lookups like Color(Color.red)543 value = value.value544 #return value545 # by-value search for a matching enum member546 # see if it's in the reverse mapping (for hashable values)547 try:548 if value in cls._value2member_map_:549 return cls._value2member_map_[value]550 except TypeError:551 # not there, now do long search -- O(n) behavior...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...28@register('cv2')29class GOpaque():30 # NB: Inheritance from c++ class cause segfault.31 # So just aggregate cv.GOpaqueT instead of inheritance32 def __new__(cls, argtype):33 return cv.GOpaqueT(argtype)34 class Bool():35 def __new__(self):36 return cv.GOpaqueT(cv.gapi.CV_BOOL)37 class Int():38 def __new__(self):39 return cv.GOpaqueT(cv.gapi.CV_INT)40 class Double():41 def __new__(self):42 return cv.GOpaqueT(cv.gapi.CV_DOUBLE)43 class Float():44 def __new__(self):45 return cv.GOpaqueT(cv.gapi.CV_FLOAT)46 class String():47 def __new__(self):48 return cv.GOpaqueT(cv.gapi.CV_STRING)49 class Point():50 def __new__(self):51 return cv.GOpaqueT(cv.gapi.CV_POINT)52 class Point2f():53 def __new__(self):54 return cv.GOpaqueT(cv.gapi.CV_POINT2F)55 class Size():56 def __new__(self):57 return cv.GOpaqueT(cv.gapi.CV_SIZE)58 class Rect():59 def __new__(self):60 return cv.GOpaqueT(cv.gapi.CV_RECT)61 class Prim():62 def __new__(self):63 return cv.GOpaqueT(cv.gapi.CV_DRAW_PRIM)64 class Any():65 def __new__(self):66 return cv.GOpaqueT(cv.gapi.CV_ANY)67@register('cv2')68class GArray():69 # NB: Inheritance from c++ class cause segfault.70 # So just aggregate cv.GArrayT instead of inheritance71 def __new__(cls, argtype):72 return cv.GArrayT(argtype)73 class Bool():74 def __new__(self):75 return cv.GArrayT(cv.gapi.CV_BOOL)76 class Int():77 def __new__(self):78 return cv.GArrayT(cv.gapi.CV_INT)79 class Double():80 def __new__(self):81 return cv.GArrayT(cv.gapi.CV_DOUBLE)82 class Float():83 def __new__(self):84 return cv.GArrayT(cv.gapi.CV_FLOAT)85 class String():86 def __new__(self):87 return cv.GArrayT(cv.gapi.CV_STRING)88 class Point():89 def __new__(self):90 return cv.GArrayT(cv.gapi.CV_POINT)91 class Point2f():92 def __new__(self):93 return cv.GArrayT(cv.gapi.CV_POINT2F)94 class Size():95 def __new__(self):96 return cv.GArrayT(cv.gapi.CV_SIZE)97 class Rect():98 def __new__(self):99 return cv.GArrayT(cv.gapi.CV_RECT)100 class Scalar():101 def __new__(self):102 return cv.GArrayT(cv.gapi.CV_SCALAR)103 class Mat():104 def __new__(self):105 return cv.GArrayT(cv.gapi.CV_MAT)106 class GMat():107 def __new__(self):108 return cv.GArrayT(cv.gapi.CV_GMAT)109 class Prim():110 def __new__(self):111 return cv.GArray(cv.gapi.CV_DRAW_PRIM)112 class Any():113 def __new__(self):114 return cv.GArray(cv.gapi.CV_ANY)115# NB: Top lvl decorator takes arguments116def op(op_id, in_types, out_types):117 garray_types= {118 cv.GArray.Bool: cv.gapi.CV_BOOL,119 cv.GArray.Int: cv.gapi.CV_INT,120 cv.GArray.Double: cv.gapi.CV_DOUBLE,121 cv.GArray.Float: cv.gapi.CV_FLOAT,122 cv.GArray.String: cv.gapi.CV_STRING,123 cv.GArray.Point: cv.gapi.CV_POINT,124 cv.GArray.Point2f: cv.gapi.CV_POINT2F,125 cv.GArray.Size: cv.gapi.CV_SIZE,126 cv.GArray.Rect: cv.gapi.CV_RECT,127 cv.GArray.Scalar: cv.gapi.CV_SCALAR,...

Full Screen

Full Screen

exceptions.py

Source:exceptions.py Github

copy

Full Screen

1import __builtin__23class BaseException(__builtin__.object):4 def __delattr__(): pass5 def __getattribute__(): pass6 def __getitem__(): pass7 def __getslice__(): pass8 def __init__(): pass9 def __reduce__(): pass10 def __repr__(): pass11 def __setattr__(): pass12 def __setstate__(): pass13 def __str__(): pass14 def __unicode__(): pass15 16 __dict__ = 017 args = 018 message = 019 __new__ = 020 21class Exception(BaseException):22 def __init__(): pass23 __new__ = 024 25class StandardError(Exception):26 def __init__(): pass27 __new__ = 02829class ArithmeticError(StandardError):30 def __init__(): pass31 __new__ = 032 33class AssertionError(StandardError):34 def __init__(): pass35 __new__ = 036 37class AttributeError(StandardError):38 def __init__(): pass39 __new__ = 040 41class BufferError(StandardError):42 def __init__(): pass43 __new__ = 044 45class Warning(Exception):46 def __init__(): pass47 __new__ = 048 49class BytesWarning(Warning):50 def __init__(): pass51 __new__ = 052 53class DeprecationWarning(Warning):54 def __init__(): pass55 __new__ = 056 57class EOFError(StandardError):58 def __init__(): pass59 __new__ = 060 61class EnvironmentError(StandardError):62 def __init__(): pass63 def __reduce__(): pass64 def __str__(): pass65 errno = 066 filename = ''67 strerror = 068 __new__ = 069 70class FloatingPointError(ArithmeticError):71 def __init__(): pass72 __new__ = 073 74class FutureWarning(Warning):75 def __init__(): pass76 __new__ = 077 78class GeneratorExit(BaseException):79 def __init__(): pass80 __new__ = 081 82 83class IOError(EnvironmentError):84 def __init__(): pass85 __new__ = 086 87class ImportError(StandardError):88 def __init__(): pass89 __new__ = 090 91class ImportWarning(Warning):92 def __init__(): pass93 __new__ = 094 95class IndentationError(SyntaxError):96 def __init__(): pass97 __new__ = 098 99class IndexError(LookupError):100 def __init__(): pass101 __new__ = 0102 103class KeyError(LookupError):104 def __init__(): pass105 def __str__(): pass106 __new__ = 0107 108class KeyboardInterrupt(BaseException):109 def __init__(): pass110 __new__ = 0111 112 113class LookupError(StandardError):114 def __init__(): pass115 __new__ = 0116 117class MemoryError(StandardError):118 def __init__(): pass119 __new__ = 0120 121class NameError(StandardError):122 def __init__(): pass123 __new__ = 0124125class NotImplementedError(RuntimeError):126 def __init__(): pass127 __new__ = 0128 129class OSError(EnvironmentError):130 def __init__(): pass131 __new__ = 0132 133class OverflowError(ArithmeticError):134 def __init__(): pass135 __new__ = 0136137class PendingDeprecationWarning(Warning):138 def __init__(): pass139 __new__ = 0140 141class ReferenceError(StandardError):142 def __init__(): pass143 __new__ = 0144 145class RuntimeError(StandardError):146 def __init__(): pass147 __new__ = 0148 149class RuntimeWarning(Warning):150 def __init__(): pass151 __new__ = 0152 153class StopIteration(Exception):154 def __init__(): pass155 __new__ = 0156 157class SyntaxError(StandardError):158 def __init__(): pass159 def __str__(): pass160 filename = ''161 lineno = 0162 msg = ''163 offset = 0164 print_file_and_line = 0165 text = ''166 __new__ = 0167 168class SyntaxWarning(Warning):169 def __init__(): pass170 __new__ = 0171 172class SystemError(StandardError):173 def __init__(): pass174 __new__ = 0175 176class SystemExit(BaseException):177 def __init__(): pass178 code = 0179 __new__ = 0180 181class TabError(IndentationError):182 def __init__(): pass183 __new__ = 0184 185class TypeError(StandardError):186 def __init__(): pass187 __new__ = 0188 189 190class UnboundLocalError(NameError):191 def __init__(): pass192 __new__ = 0193 194class UnicodeDecodeError(UnicodeError):195 def __init__(): pass196 def __str__(): pass197 encoding = 0198 end = 0199 object = 0200 reason = 0201 start = 0202 __new__ = 0203204class UnicodeEncodeError(UnicodeError):205 def __init__(): pass206 def __str__(): pass207 encoding = 0208 end = 0209 object = 0210 reason = 0211 start = 0212 __new__ = 0213 214class UnicodeError(ValueError):215 def __init__(): pass216 __new__ = 0217 218class UnicodeTranslateError(UnicodeError):219 def __init__(): pass220 def __str__(): pass221 encoding = 0222 end = 0223 object = 0224 reason = 0225 start = 0226 __new__ = 0227 228class UnicodeWarning(Warning):229 def __init__(): pass230 __new__ = 0231 232class UserWarning(Warning):233 def __init__(): pass234 __new__ = 0235 236class ValueError(StandardError):237 def __init__(): pass238 __new__ = 0239 240 241class WindowsError(OSError):242 def __init__(): pass243 def __str__(): pass244 errno = 0245 filename = ''246 strerror = 0247 winerror = 0248 __new__ = 0249250class ZeroDivisionError(ArithmeticError):251 def __init__(): pass252 __new__ = 0 ...

Full Screen

Full Screen

gameboard1.py

Source:gameboard1.py Github

copy

Full Screen

...80class Piece(str):81 __slots__ = ()82class BlackDraught(Piece):83 __slots__ = ()84 def __new__(Class):85 return super().__new__(Class, "\N{black draughts man}")86class WhiteDraught(Piece):87 __slots__ = ()88 89 def __new__(Class):90 return super().__new__(Class, "\N{white draughts man}")91class BlackChessKing(Piece):92 __slots__ = ()93 94 def __new__(Class):95 return super().__new__(Class, "\N{black chess king}")96class WhiteChessKing(Piece):97 __slots__ = ()98 99 def __new__(Class):100 return super().__new__(Class, "\N{white chess king}")101class BlackChessQueen(Piece):102 __slots__ = ()103 104 def __new__(Class):105 return super().__new__(Class, "\N{black chess queen}")106class WhiteChessQueen(Piece):107 __slots__ = ()108 109 def __new__(Class):110 return super().__new__(Class, "\N{white chess queen}")111class BlackChessRook(Piece):112 __slots__ = ()113 114 def __new__(Class):115 return super().__new__(Class, "\N{black chess rook}")116class WhiteChessRook(Piece):117 __slots__ = ()118 119 def __new__(Class):120 return super().__new__(Class, "\N{white chess rook}")121class BlackChessBishop(Piece):122 __slots__ = ()123 124 def __new__(Class):125 return super().__new__(Class, "\N{black chess bishop}")126class WhiteChessBishop(Piece):127 __slots__ = ()128 129 def __new__(Class):130 return super().__new__(Class, "\N{white chess bishop}")131class BlackChessKnight(Piece):132 __slots__ = ()133 134 def __new__(Class):135 return super().__new__(Class, "\N{black chess knight}")136class WhiteChessKnight(Piece):137 __slots__ = ()138 139 def __new__(Class):140 return super().__new__(Class, "\N{white chess knight}")141class BlackChessPawn(Piece):142 __slots__ = ()143 144 def __new__(Class):145 return super().__new__(Class, "\N{black chess pawn}")146class WhiteChessPawn(Piece):147 __slots__ = ()148 149 def __new__(Class):150 return super().__new__(Class, "\N{white chess pawn}")151if __name__ == "__main__":...

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 Robotframework-anywherelibrary 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