def __init__(self, text): if isinstance(text, str): text = text.encode(sys.getdefaultencoding()) elif not isinstance(text, bytes): msg = "dbm mapping keys must be a string or bytes object, not {!r}" raise TypeError(msg.format(type(text).__name__)) Structure.__init__(self, text, len(text))
def __init__(self, uuidstr): uuid = UUID(uuidstr) Structure.__init__(self) self.Data1, self.Data2, self.Data3, \ self.Data4[0], self.Data4[1], rest = uuid.fields for i in range(2, 8): self.Data4[i] = rest >> (8 - i - 1) * 8 & 0xff
def __init__(self, *args, **kwargs): self.__enums = dict((f, t) for f, t in self._fields_ if issubclass_(t, Enum)) for field, val in iteritems(self._defaults_): setattr(self, field, val) Structure.__init__(self, *args, **kwargs)
def __init__(self, pixel, line, x, y, z=0.0): Structure.__init__(self) self.pixel = pixel self.line = line self.x = x self.y = y self.z = 0.0
def __init__(self, **kwargs): Structure.__init__(self) self.cbSize = sizeof(self) for field_name, field_value in kwargs.items(): if isinstance(field_value, string_types): field_value = ensure_binary(field_value) setattr(self, field_name, field_value)
def __init__(self, *args, **kwargs): self.__enums = dict((f, t) for f, t in self._fields_ if issubclass(t, Enum)) for field, val in self._defaults_.iteritems(): setattr(self, field, val) Structure.__init__(self, *args, **kwargs)
def __init__ (self, pixel, line, x, y, z = 0.0): Structure.__init__(self) self.pixel = pixel self.line = line self.x = x self.y = y self.z = 0.0
def __init__(self, indom, insts): Structure.__init__(self) self.it_numinst = 0 self.it_set = None self.it_indom = indom self.load_indom(indom, insts) self.set_instances(indom, insts)
def __init__(self, pmid, typeof, indom, sem, units): Structure.__init__(self) self.m_user = None self.m_desc.pmid = pmid self.m_desc.type = typeof self.m_desc.indom = indom self.m_desc.sem = sem self.m_desc.units = units
def __init__(self): Structure.__init__(self) r2 = r2lib() if r2 is None: return r_core_new = r2.r_core_new r_core_new.restype = c_void_p self._o = r_core_new()
def __init__(self, *_args): Structure.__init__(self) # # Need to bind the following to the instance so it is available in # `__del__()` when the interpreter shuts down. # self._free_chip_name = _free_chip_name self.byref = byref
def __init__(self, serial, shorttext = '', helptext = ''): Structure.__init__(self) if type(helptext) != type(b''): helptext = helptext.encode('utf-8') if type(shorttext) != type(b''): shorttext = shorttext.encode('utf-8') self.shorttext = shorttext self.helptext = shorttext self.serial = serial
def __getattribute__(self, name): _map = Structure.__getattribute__(self, '_map') value = Structure.__getattribute__(self, name) if name in _map: enum_class = _map[name] if isinstance(value, Array): return [enum_class(x) for x in value] return enum_class(value) return value
def __init__(self, serial, shorttext='', helptext=''): Structure.__init__(self) if helptext is not None and not isinstance(helptext, bytes): helptext = helptext.encode('utf-8') if shorttext is not None and not isinstance(shorttext, bytes): shorttext = shorttext.encode('utf-8') self.shorttext = shorttext self.helptext = shorttext self.serial = serial
def __init__(self, guid=None): Structure.__init__(self) if guid: x = uuid.UUID(guid) f = x.fields self.data1 = DWORD(f[0]) self.data2 = WORD(f[1]) self.data3 = WORD(f[2]) data4_cast = c_byte * 8 self.data4 = data4_cast(*x.bytes[8:])
def __init__(self): self.c_iflag = 0 self.c_oflag = 0 self.c_cflag = 0 self.c_lflag = 0 self.c_line = 0 self.c_ispeed = 0 self.c_ospeed = 0 #self.c_cc = c_ubyte * 19 Structure.__init__(self)
def __init__(self, value=None, max_length=0): strbuf = None length = 0 if value is not None or max_length > 0: length = len(value) if value is not None else 0 max_length = max(length, max_length) if value: strbuf = create_unicode_buffer(value, max_length) else: strbuf = create_unicode_buffer(max_length) Structure.__init__(self, length * 2, max_length * 2, cast(strbuf, LPWSTR))
def __init__(self, virtual_keycode, down): scancode = windll.user32.MapVirtualKeyA(virtual_keycode, 0) flags = 0 if not down: flags |= win32con.KEYEVENTF_KEYUP if virtual_keycode in self.extended_keys: flags |= win32con.KEYEVENTF_EXTENDEDKEY extra = pointer(c_ulong(0)) Structure.__init__(self, virtual_keycode, scancode, flags, 0, extra)
def __init__(self, value=None, max_length=0): strbuf = None length = 0 if value is not None or max_length > 0: length = len(value) max_length = max(length, max_length) if value: strbuf = create_unicode_buffer(value, max_length) else: strbuf = create_unicode_buffer(max_length) Structure.__init__(self, length * 2, max_length * 2, cast(strbuf, LPWSTR))
def __init__(self, name, parent=None): """Initialize ObjectAttributes. :param name: full path to the file if parent is None else filename inside parent directory :type name: UnicodeString :param parent: handle of the parent directory :type parent: HANDLE | None """ Structure.__init__(self, sizeof(ObjectAttributes), parent, pointer(name), self.OBJ_CASE_INSENSITIVE, None, None)
def __init__(self, hWave, block_len): Structure.__init__(self) self.handle = hWave self.membuf = create_string_buffer(block_len) self.lpData = cast(self.membuf, c_void_p) self.BufferLength = block_len self.Flags = 0 self.BytesRecorded = 0 self.User = 0 self.Loops = 0 self.lpNext = 0 self.reserved = 0
def __init__(self, name, item, typeof, semantics, dimension, indom = 0, shorttext = '', helptext = ''): Structure.__init__(self) if type(name) != type(b''): name = name.encode('utf-8') if type(helptext) != type(b''): helptext = helptext.encode('utf-8') if type(shorttext) != type(b''): shorttext = shorttext.encode('utf-8') self.shorttext = shorttext self.helptext = shorttext self.typeof = typeof self.indom = indom self.item = item
def __init__(self, element): if isinstance(element, KeyboardInput): element_type = win32con.INPUT_KEYBOARD union = _InputUnion(ki=element) elif isinstance(element, MouseInput): element_type = win32con.INPUT_MOUSE union = _InputUnion(mi=element) elif isinstance(element, HardwareInput): element_type = win32con.INPUT_HARDWARE union = _InputUnion(hi=element) else: raise TypeError("Unknown input type: %r" % element) Structure.__init__(self, type=element_type, ii=union)
def __init__(self, value: Optional[str] = None, max_length: int = 0): strbuf = None length = 0 if value is not None or max_length > 0: length = len(value) if value is not None else 0 max_length = max(length, max_length) if value: strbuf = create_unicode_buffer(value, max_length) else: strbuf = create_unicode_buffer(max_length) ctypes_strbuf = ctypes_cast(strbuf, LPWSTR) # type: ignore Structure.__init__(self, length * 2, max_length * 2, ctypes_strbuf)
def __init__(self, name, parent=None): """Initialize ObjectAttributes. :param name: full path to the file if parent is None else filename inside parent directory :type name: UnicodeString :param parent: handle of the parent directory :type parent: HANDLE """ Structure.__init__(self, sizeof(ObjectAttributes), parent, pointer(name), self.OBJ_CASE_INSENSITIVE, None, None)
def __init__(self, virtual_keycode, down, scancode=-1): """Initialize structure based on key type.""" if scancode == -1: scancode = windll.user32.MapVirtualKeyW(virtual_keycode, 0) flags = 0 if virtual_keycode is 0: flags |= 4 # KEYEVENTF_UNICODE elif virtual_keycode not in self.soft_keys: flags |= 8 # KEYEVENTF_SCANCODE if not down: flags |= win32con.KEYEVENTF_KEYUP if virtual_keycode in self.extended_keys: flags |= win32con.KEYEVENTF_EXTENDEDKEY extra = pointer(c_ulong(0)) Structure.__init__(self, virtual_keycode, scancode, flags, 0, extra)
def __init__(self, virtual_keycode, down, scancode=None, layout=None): """Initialize structure based on key type.""" flags = 0 if virtual_keycode == 0: flags |= 4 # KEYEVENTF_UNICODE else: # Translate *virtual_keycode* into a scan code, if necessary. # Assume that *layout* is a keyboard layout (HKL). if scancode is None: user32 = windll.user32 if sys.getwindowsversion().major < 6: map_type = 0 # MAPVK_VK_TO_VSC else: map_type = 4 # MAPVK_VK_TO_VSC_EX if layout is None: scancode = user32.MapVirtualKeyW(virtual_keycode, map_type) else: scancode = user32.MapVirtualKeyExW(virtual_keycode, map_type, layout) # Add the KEYEVENTF_SCANCODE flag if the Win32 MapVirtualKey(Ex) # function returned a translation. If not, then fallback on # the specified keycode. This is also done for "soft" keys. if scancode and virtual_keycode not in self.soft_keys: flags |= 8 # KEYEVENTF_SCANCODE # Add the KEYEVENTF_EXTENDEDKEY flag, if necessary. # Starting with Windows Vista, extended scan codes are # specified with the high byte containing either 0xe0 or # 0xe1. if scancode >> 8 in (0xe0, 0xe1): flags |= win32con.KEYEVENTF_EXTENDEDKEY # Always add the KEYEVENTF_EXTENDEDKEY flag for certain # virtual-keys (see above). if virtual_keycode in self.extended_keys: flags |= win32con.KEYEVENTF_EXTENDEDKEY if not down: flags |= win32con.KEYEVENTF_KEYUP extra = pointer(c_ulong(0)) Structure.__init__(self, virtual_keycode, scancode, flags, 0, extra)
def __init__(self, name, item, typeof, semantics, dimension, indom=0, shorttext='', helptext=''): # pylint: disable=R0913 Structure.__init__(self) if not isinstance(name, bytes): name = name.encode('utf-8') if helptext is not None and not isinstance(helptext, bytes): helptext = helptext.encode('utf-8') if shorttext is not None and not isinstance(shorttext, bytes): shorttext = shorttext.encode('utf-8') self.shorttext = shorttext self.helptext = shorttext self.typeof = typeof self.indom = indom self.item = item self.name = name
def load_from_offset(data: bytes, offset: int, structure: ctypes.Structure) -> ctypes.Structure: """ Loads information from the given sequence of bytes and offset into a specified structure type. :param data: input data :param offset: offset to start reading :param structure: the type of structure to create and fill :return: a structure that is to be filled from the bytes at the given offset """ return structure.from_buffer_copy(data[offset:offset + ctypes.sizeof(structure)])
def __init__(self, virtual_keycode, down, scancode=-1, layout=None): """Initialize structure based on key type.""" if scancode == -1: if not layout: scancode = windll.user32.MapVirtualKeyW(virtual_keycode, 0) else: # Assume that 'layout' is a keyboard layout (HKL). scancode = windll.user32.MapVirtualKeyExW( virtual_keycode, 0, layout) flags = 0 if virtual_keycode == 0: flags |= 4 # KEYEVENTF_UNICODE else: if virtual_keycode not in self.soft_keys: flags |= 8 # KEYEVENTF_SCANCODE if virtual_keycode in self.extended_keys: flags |= win32con.KEYEVENTF_EXTENDEDKEY if not down: flags |= win32con.KEYEVENTF_KEYUP extra = pointer(c_ulong(0)) # print(virtual_keycode, scancode, flags, 0, extra) Structure.__init__(self, virtual_keycode, scancode, flags, 0, extra)
def __init__(self, **kwargs): """ Ctypes.Structure with integrated default values. https://stackoverflow.com/questions/7946519/default-values-in-a-ctypes-structure/25892189#25892189 :param kwargs: values different to defaults :type kwargs: dict """ # sanity checks defaults = type(self)._defaults_ assert type(defaults) is types.DictionaryType # use defaults, but override with keyword arguments, if any values = defaults.copy() for (key, val) in kwargs.items(): values[key] = val # appropriately initialize ctypes.Structure #super().__init__(**values) # Python 3 syntax return Structure.__init__(self, **values) # Python 2 syntax
def __init__(self, uuidstr=None): uuid = UUID(uuidstr) Structure.__init__(self) self.Data1, self.Data2, self.Data3, self.Data4[0], self.Data4[1], rest = uuid.fields for i in range(2, 8): self.Data4[i] = rest >> (8 - i - 1) * 8 & 0xff
def __init__(self, uuid_): Structure.__init__(self) self.Data1, self.Data2, self.Data3, self.Data4[0], self.Data4[1], rest = uuid_.fields for i in range(2, 8): self.Data4[i] = rest>>(8 - i - 1)*8 & 0xff
def __init__(self, *args): Structure.__init__(self, *args) self.m_Version = 1
def __init__(self, **kwargs): """ Initialize the Fixture Def """ if "filter" not in kwargs: kwargs["filter"] = Filter() Structure.__init__(self, **kwargs)
def __init__(self, indom, insts): Structure.__init__(self) self.it_numinst = 0 self.it_set = None self.it_indom = indom self.set_instances(indom, insts)
def __init__(self, instid, name): Structure.__init__(self) self.i_inst = instid self.i_name = name
def __init__(self, inst, name): Structure.__init__(self) if type(name) != type(b''): name = name.encode('utf-8') self.external = name self.internal = inst
def __init__(self, **kw): self.r1 = Mat4.rowtype(*(kw.get('r1') or (1,0,0,0))) self.r2 = Mat4.rowtype(*(kw.get('r2') or (0,1,0,0))) self.r3 = Mat4.rowtype(*(kw.get('r3') or (0,0,1,0))) self.r4 = Mat4.rowtype(*(kw.get('r4') or (0,0,0,1))) Structure.__init__(self)
def __init__(self): Structure.__init__(self) self.handle = 0
def __init__(self): Structure.__init__(self) self.cb = sizeof(self)
def __init__(self, categoryBits=0x1, maskBits=0xFFFF, groupIndex=0): """ Initialize the filter with the proper defaults """ Structure.__init__(self, categoryBits=categoryBits, maskBits=maskBits, groupIndex=groupIndex)
def __init__(self, token=maxtoken): buf = ctypes.create_string_buffer(token) Structure.__init__(self,sizeof(buf),2,cast(pointer(buf),PVOID))
def __init__(self, *args): Structure.__init__(self,0,1,pointer(SecBuffer(*args)))
def __init__(self): Structure.__init__(self, 512+9*4)
def __init__(self, text): if not isinstance(text, str): raise TypeError("datum: expected string, not %s" % type(text)) Structure.__init__(self, text, len(text))
def __init__(self, instid, name): Structure.__init__(self) self.i_inst = instid self.i_name = name.encode('utf-8')
def __init__(self): Structure.__init__(self) self.__field_names = [ f for (f, t) in self._fields_] self.update(self._defaults_)
def __init__(self): # populate deeply (empty memory fields) rather than shallow null pointers. Structure.__init__(self, pointer(ULONG()), pointer(ULONG()))
def copy_struct(struct: ct.Structure) -> ct.Structure: copy = struct.__class__() ct.memmove(ct.addressof(copy), ct.addressof(struct), ct.sizeof(struct)) return copy