示例#1
0
 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
示例#2
0
    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)
示例#3
0
文件: windows.py 项目: alanhdu/conda
 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)
示例#4
0
文件: _dbm.py 项目: timm/timmnix
 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))
示例#5
0
文件: pmda.py 项目: tongfw/pcp
 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
示例#6
0
 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
示例#7
0
文件: mmv.py 项目: taintedkernel/pcp
 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
示例#8
0
文件: mmv.py 项目: wuliming/pcp
 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
示例#9
0
 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
示例#10
0
 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)
示例#11
0
 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:])
示例#12
0
 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))
示例#13
0
    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)
示例#14
0
    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)
示例#15
0
    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)
示例#16
0
 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, 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))
示例#18
0
    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)
示例#19
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
示例#20
0
    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)
示例#21
0
    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)
示例#23
0
    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)
示例#24
0
    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)
示例#25
0
 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
示例#26
0
    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)
示例#27
0
    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
示例#28
0
    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, *args):
        self.Name = cast((c_char * 8)(), c_char_p)
#        self.Name = cast((c_wchar * 8)(), c_wchar_p)
        Structure.__init__(self, *args)
示例#30
0
 def __init__(self):
     Structure.__init__(self)
     r_core_new = r2lib().r_core_new
     r_core_new.restype = c_void_p
     self._o = r_core_new()
示例#31
0
    def __init__(self):
        Structure.__init__(self)

        self.cb = sizeof(self)
示例#32
0
文件: dbm.py 项目: 1018365842/FreeIMU
 def __init__(self, text):
     if not isinstance(text, str):
         raise TypeError("datum: expected string, not %s" % type(text))
     Structure.__init__(self, text, len(text))
示例#33
0
	def __init__(self, *args):
		Structure.__init__(self, *args)
		self.m_Version = 1
示例#34
0
 def __init__(self, t: datetime) -> None:
     timestamp = (t - datetime(1970, 1, 1)).total_seconds()
     timestamp = (int(timestamp) + 11644473600) * 10000000
     Structure.__init__(self, timestamp)
示例#35
0
文件: pmda.py 项目: aeppert/pcp
 def __init__(self, instid, name):
     Structure.__init__(self)
     self.i_inst = instid
     self.i_name = name.encode('utf-8')
示例#36
0
 def __init__(self, **kwargs):
     """ Initialize the Fixture Def """
     if "filter" not in kwargs:
         kwargs["filter"] = Filter()
     
     Structure.__init__(self, **kwargs)
示例#37
0
 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
示例#38
0
 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)
示例#39
0
 def __init__(self, text):
     if not isinstance(text, str):
         raise TypeError("datum: expected string, not %s" % type(text))
     Structure.__init__(self, text, len(text))
示例#40
0
 def __init__(self):
     Structure.__init__(self, 512+9*4)
示例#41
0
 def __init__(self):
     Structure.__init__(self)
     self.__field_names = [f for (f, t) in self._fields_]
     self.update(self._defaults_)
示例#42
0
 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
示例#43
0
文件: pmda.py 项目: tongfw/pcp
 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)
示例#44
0
 def __init__(self) -> None:
     Structure.__init__(self)
     self.file_attributes = FileAttribute(0)
示例#45
0
 def __init__(self, inst, name):
     Structure.__init__(self)
     if type(name) != type(b''):
         name = name.encode('utf-8')
     self.external = name
     self.internal = inst
示例#46
0
 def __init__(self, inst, name):
     Structure.__init__(self)
     if not isinstance(name, bytes):
         name = name.encode('utf-8')
     self.external = name
     self.internal = inst
示例#47
0
文件: pam.py 项目: 1mentat/salt
 def __init__(self):
     Structure.__init__(self)
     self.handle = 0
示例#48
0
文件: pmda.py 项目: tongfw/pcp
 def __init__(self, instid, name):
     Structure.__init__(self)
     self.i_inst = instid
     self.i_name = name
示例#49
0
 def __init__(self, instid, name):
     Structure.__init__(self)
     self.i_inst = instid
     self.i_name = name.encode('utf-8')
示例#50
0
 def __init__(self):
     Structure.__init__(self)
     self.handle = 0
示例#51
0
 def __init__(self):
     Structure.__init__(self)
     self.__field_names = [ f for (f, t) in self._fields_]
     self.update(self._defaults_)
示例#52
0
 def __init__(self, token=maxtoken):
     buf = ctypes.create_string_buffer(token) 
     Structure.__init__(self,sizeof(buf),2,cast(pointer(buf),PVOID))
示例#53
0
 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
示例#54
0
 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)
示例#55
0
 def __init__(self): # populate deeply (empty memory fields) rather than shallow null pointers.
     Structure.__init__(self, pointer(ULONG()), pointer(ULONG()))
示例#56
0
 def __init__(self):
     Structure.__init__(self)
     
     self.cb = sizeof(self)
示例#57
0
 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)
示例#58
0
文件: mmv.py 项目: taintedkernel/pcp
 def __init__(self, inst, name):
     Structure.__init__(self)
     if type(name) != type(b''):
         name = name.encode('utf-8')
     self.external = name
     self.internal = inst
示例#59
0
 def __init__(self, *args):
     Structure.__init__(self,0,1,pointer(SecBuffer(*args)))