コード例 #1
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))
コード例 #2
0
 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
コード例 #3
0
ファイル: sdm_ctypes.py プロジェクト: dougalsutherland/sdm
    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)
コード例 #4
0
 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
 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
コード例 #6
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)
コード例 #7
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 self._defaults_.iteritems():
            setattr(self, field, val)

        Structure.__init__(self, *args, **kwargs)
コード例 #8
0
ファイル: gdalwarp.py プロジェクト: aaronr/labs-rectifier
 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
コード例 #9
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)
コード例 #10
0
 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
コード例 #11
0
 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()
コード例 #12
0
ファイル: __init__.py プロジェクト: tedder/pysensors3
 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
コード例 #13
0
ファイル: lm_sensors.py プロジェクト: 178518/netdata
 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
コード例 #14
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
コード例 #15
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
コード例 #16
0
ファイル: hdata.py プロジェクト: maajor/pyhapi
 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
コード例 #17
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
コード例 #18
0
ファイル: mmv.py プロジェクト: nkshirsagar/pcp_patch
 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
コード例 #19
0
ファイル: setupapi.py プロジェクト: rnestler/pyjoulescope
 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:])
コード例 #20
0
ファイル: serial.py プロジェクト: vathpela/terminal
 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)
コード例 #21
0
ファイル: native_api.py プロジェクト: enzbang/e3-core
 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))
コード例 #22
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)
コード例 #23
0
ファイル: sendinput.py プロジェクト: 523brain/dragonfly
    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)
コード例 #24
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))
コード例 #25
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)
コード例 #26
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
コード例 #27
0
ファイル: mmv.py プロジェクト: nkshirsagar/pcp_patch
 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
コード例 #28
0
ファイル: sendinput.py プロジェクト: 523brain/dragonfly
    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)
コード例 #29
0
ファイル: sendinput.py プロジェクト: daanzu/dragonfly-old
    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)
コード例 #30
0
ファイル: native_api.py プロジェクト: yakobowski/e3-core
    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)
コード例 #31
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
        """
        Structure.__init__(self,
                           sizeof(ObjectAttributes),
                           parent,
                           pointer(name),
                           self.OBJ_CASE_INSENSITIVE,
                           None,
                           None)
コード例 #32
0
ファイル: sendinput.py プロジェクト: daanzu/dragonfly-old
    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)
コード例 #33
0
ファイル: sendinput.py プロジェクト: Versatilus/dragonfly
    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)
コード例 #34
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
コード例 #35
0
ファイル: winceextractor.py プロジェクト: KodaSec/binwalk
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)])
コード例 #36
0
ファイル: sendinput.py プロジェクト: tripfish/dragonfly
    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)
コード例 #37
0
ファイル: backend_ctypes.py プロジェクト: hiveeyes/kotori
    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
コード例 #38
0
ファイル: backend_ctypes.py プロジェクト: thiasB/kotori
    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
コード例 #39
0
ファイル: utilwin32ctypes.py プロジェクト: drmrboy/gpodder
 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
コード例 #40
0
ファイル: win_api_defs.py プロジェクト: autosportlabs/plyer
 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
コード例 #41
0
	def __init__(self, *args):
		Structure.__init__(self, *args)
		self.m_Version = 1
コード例 #42
0
ファイル: fixture_def.py プロジェクト: cloew/NytramBox2D
 def __init__(self, **kwargs):
     """ Initialize the Fixture Def """
     if "filter" not in kwargs:
         kwargs["filter"] = Filter()
     
     Structure.__init__(self, **kwargs)
コード例 #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
ファイル: pmda.py プロジェクト: tongfw/pcp
 def __init__(self, instid, name):
     Structure.__init__(self)
     self.i_inst = instid
     self.i_name = name
コード例 #45
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
コード例 #46
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)
コード例 #47
0
ファイル: pam.py プロジェクト: 1mentat/salt
 def __init__(self):
     Structure.__init__(self)
     self.handle = 0
コード例 #48
0
ファイル: winprocess.py プロジェクト: pearu/iocbio
 def __init__(self):
     Structure.__init__(self)
     
     self.cb = sizeof(self)
コード例 #49
0
ファイル: filter.py プロジェクト: cloew/NytramBox2D
 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)
コード例 #50
0
ファイル: ctypes_sspi.py プロジェクト: benjimin/pywebcorp
 def __init__(self, token=maxtoken):
     buf = ctypes.create_string_buffer(token) 
     Structure.__init__(self,sizeof(buf),2,cast(pointer(buf),PVOID))
コード例 #51
0
ファイル: ctypes_sspi.py プロジェクト: benjimin/pywebcorp
 def __init__(self, *args):
     Structure.__init__(self,0,1,pointer(SecBuffer(*args)))
コード例 #52
0
ファイル: utils.py プロジェクト: wpjunior/telecentros
 def __init__(self):
     Structure.__init__(self, 512+9*4)
コード例 #53
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))
コード例 #54
0
 def __init__(self, instid, name):
     Structure.__init__(self)
     self.i_inst = instid
     self.i_name = name.encode('utf-8')
コード例 #55
0
ファイル: flann_ctypes.py プロジェクト: AdrianYu/flann
 def __init__(self):
     Structure.__init__(self)
     self.__field_names = [ f for (f, t) in self._fields_]
     self.update(self._defaults_)
コード例 #56
0
ファイル: pam.py プロジェクト: iitians/SambaManager
 def __init__(self):
     Structure.__init__(self)
     self.handle = 0
コード例 #57
0
ファイル: ctypes_sspi.py プロジェクト: benjimin/pywebcorp
 def __init__(self): # populate deeply (empty memory fields) rather than shallow null pointers.
     Structure.__init__(self, pointer(ULONG()), pointer(ULONG()))
コード例 #58
0
ファイル: pt.py プロジェクト: efeslab/hase
def copy_struct(struct: ct.Structure) -> ct.Structure:
    copy = struct.__class__()
    ct.memmove(ct.addressof(copy), ct.addressof(struct), ct.sizeof(struct))
    return copy
コード例 #59
0
ファイル: pmda.py プロジェクト: aeppert/pcp
 def __init__(self, instid, name):
     Structure.__init__(self)
     self.i_inst = instid
     self.i_name = name.encode('utf-8')