python类__getitem__()的实例源码

function_LOCAL_1076.py 文件源码 项目:idascripts 作者: ctfhacker 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def decompile(cls, ea):
        '''(UNSTABLE) Returns the decompiled code of the basic-block at the address ``ea``.'''
        source = idaapi.decompile(ea)

        res = map(functools.partial(operator.__getitem__, source.eamap), cls.iterate(ea))
        res = itertools.chain(*res)
        formatted = reduce(lambda t,c: t if t[-1].ea == c.ea else t+[c], res, [next(res)])

        res = []
        # FIXME: pretty damn unstable
        try:
            for fmt in formatted:
                res.append( fmt.print1(source.__deref__()) )
        except TypeError: pass
        return '\n'.join(map(idaapi.tag_remove,res))

# function frame attributes
# FIXME: put these in their own object and replace them with aliases
function_REMOTE_1076.py 文件源码 项目:idascripts 作者: ctfhacker 项目源码 文件源码 阅读 47 收藏 0 点赞 0 评论 0
def decompile(cls, ea):
        '''(UNSTABLE) Returns the decompiled code of the basic-block at the address ``ea``.'''
        source = idaapi.decompile(ea)

        res = map(functools.partial(operator.__getitem__, source.eamap), cls.iterate(ea))
        res = itertools.chain(*res)
        formatted = reduce(lambda t,c: t if t[-1].ea == c.ea else t+[c], res, [next(res)])

        res = []
        # FIXME: This is pretty damn unstable in my tests.
        try:
            for fmt in formatted:
                res.append( fmt.print1(source.__deref__()) )
        except TypeError: pass
        return '\n'.join(map(idaapi.tag_remove,res))

# function frame attributes
# FIXME: put these in their own object and replace them with aliases
function_LOCAL_3024.py 文件源码 项目:idascripts 作者: ctfhacker 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def decompile(cls, ea):
        '''(UNSTABLE) Returns the decompiled code of the basic-block at the address ``ea``.'''
        source = idaapi.decompile(ea)

        res = map(functools.partial(operator.__getitem__, source.eamap), cls.iterate(ea))
        res = itertools.chain(*res)
        formatted = reduce(lambda t,c: t if t[-1].ea == c.ea else t+[c], res, [next(res)])

        res = []
        # FIXME: pretty damn unstable
        try:
            for fmt in formatted:
                res.append( fmt.print1(source.__deref__()) )
        except TypeError: pass
        return '\n'.join(map(idaapi.tag_remove,res))

# function frame attributes
# FIXME: put these in their own object and replace them with aliases
function_BASE_3024.py 文件源码 项目:idascripts 作者: ctfhacker 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def decompile(cls, ea):
        '''(UNSTABLE) Returns the decompiled code of the basic-block at the address ``ea``.'''
        source = idaapi.decompile(ea)

        res = map(functools.partial(operator.__getitem__, source.eamap), cls.iterate(ea))
        res = itertools.chain(*res)
        formatted = reduce(lambda t,c: t if t[-1].ea == c.ea else t+[c], res, [next(res)])

        res = []
        # FIXME: pretty damn unstable
        try:
            for fmt in formatted:
                res.append( fmt.print1(source.__deref__()) )
        except TypeError: pass
        return '\n'.join(map(idaapi.tag_remove,res))

# function frame attributes
# FIXME: put these in their own object and replace them with aliases
function_REMOTE_3024.py 文件源码 项目:idascripts 作者: ctfhacker 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def decompile(cls, ea):
        '''(UNSTABLE) Returns the decompiled code of the basic-block at the address ``ea``.'''
        source = idaapi.decompile(ea)

        res = map(functools.partial(operator.__getitem__, source.eamap), cls.iterate(ea))
        res = itertools.chain(*res)
        formatted = reduce(lambda t,c: t if t[-1].ea == c.ea else t+[c], res, [next(res)])

        res = []
        # FIXME: This is pretty damn unstable in my tests.
        try:
            for fmt in formatted:
                res.append( fmt.print1(source.__deref__()) )
        except TypeError: pass
        return '\n'.join(map(idaapi.tag_remove,res))

# function frame attributes
# FIXME: put these in their own object and replace them with aliases
function_BASE_1076.py 文件源码 项目:idascripts 作者: ctfhacker 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def decompile(cls, ea):
        '''(UNSTABLE) Returns the decompiled code of the basic-block at the address ``ea``.'''
        source = idaapi.decompile(ea)

        res = map(functools.partial(operator.__getitem__, source.eamap), cls.iterate(ea))
        res = itertools.chain(*res)
        formatted = reduce(lambda t,c: t if t[-1].ea == c.ea else t+[c], res, [next(res)])

        res = []
        # FIXME: pretty damn unstable
        try:
            for fmt in formatted:
                res.append( fmt.print1(source.__deref__()) )
        except TypeError: pass
        return '\n'.join(map(idaapi.tag_remove,res))

# function frame attributes
# FIXME: put these in their own object and replace them with aliases
basemapping.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def testIReadMapping(self, inst, state, absent):
    for key in state:
        self.assertEqual(inst[key], state[key])
        self.assertEqual(inst.get(key, None), state[key])
        self.failUnless(key in inst)

    for key in absent:
        self.assertEqual(inst.get(key, None), None)
        self.assertEqual(inst.get(key), None)
        self.assertEqual(inst.get(key, self), self)
        self.assertRaises(KeyError, __getitem__, inst, key)
basemapping.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def testIReadMapping(self, inst, state, absent):
    for key in state:
        self.assertEqual(inst[key], state[key])
        self.assertEqual(inst.get(key, None), state[key])
        self.failUnless(key in inst)

    for key in absent:
        self.assertEqual(inst.get(key, None), None)
        self.assertEqual(inst.get(key), None)
        self.assertEqual(inst.get(key, self), self)
        self.assertRaises(KeyError, __getitem__, inst, key)
basemapping.py 文件源码 项目:AskTanmay-NLQA-System- 作者: tanmayb123 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def testIReadMapping(self, inst, state, absent):
    for key in state:
        self.assertEqual(inst[key], state[key])
        self.assertEqual(inst.get(key, None), state[key])
        self.assertTrue(key in inst)

    for key in absent:
        self.assertEqual(inst.get(key, None), None)
        self.assertEqual(inst.get(key), None)
        self.assertEqual(inst.get(key, self), self)
        self.assertRaises(KeyError, __getitem__, inst, key)
macheap.py 文件源码 项目:MacHeap 作者: blankwall 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _calculate_(self, offset):
        res = self.new(self._object_).a
        res = reduce(operator.__getitem__, self._path_, res)
        return offset - res.getoffset()
macheap.py 文件源码 项目:MacHeap 作者: blankwall 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def next(self):
        '''Follow the next pointer to the next header entry.'''
        if self['next'].int():
            return reduce(operator.__getitem__, self._path_, self['next'].d.l)
        raise ValueError("{:s} : Unable to navigate to next pointer : 0x{:x}".format(self['next'].int()))
macheap.py 文件源码 项目:MacHeap 作者: blankwall 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def previous(self):
        '''Follow the previous pointer to the previous header entry.'''
        if self['previous'].int():
            return reduce(operator.__getitem__, self._path_, self['previous'].d.l)
        raise ValueError("{:s} : Unable to navigate to previous pointer : 0x{:x}".format(self['previous'].int()))
macheap.py 文件源码 项目:MacHeap 作者: blankwall 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _walk(self, direction):
        '''Yield all the elements in the specified direction.'''
        yield self
        res = direction(self)
        while res.int():
            res = res.d
            res = reduce(operator.__getitem__, self._path_, res.l)
            yield res
            res = direction(res)
        return

    # FIXME: make sure that these return each and every header
macheap.py 文件源码 项目:MacHeap 作者: blankwall 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def summary(self):
            mapper = ['.', 'X']
            return str().join(map(mapper.__getitem__, self.iterate()))
basemapping.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def testIReadMapping(self, inst, state, absent):
    for key in state:
        self.assertEqual(inst[key], state[key])
        self.assertEqual(inst.get(key, None), state[key])
        self.assertTrue(key in inst)

    for key in absent:
        self.assertEqual(inst.get(key, None), None)
        self.assertEqual(inst.get(key), None)
        self.assertEqual(inst.get(key, self), self)
        self.assertRaises(KeyError, __getitem__, inst, key)
pooldefs.py 文件源码 项目:sardana 作者: sardana-org 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def fromStr(cls, string):
        '''Convert string representation of SynchDomain enum e.g.
        'SynchDomain.Time' to SynchDomain objects. It also works with just
        domain strings like 'Time'. The following expressions are True:

        SynchDomain.fromStr(str(SynchDomain.Time)) == SynchDomain.Time
        SynchDomain.fromStr('Time') == SynchDomain.Time
        '''
        domain = string.split('.')
        if len(domain) == 1:
            return __getitem__(cls, domain[0])
        elif len(domain) == 2:
            return __getitem__(cls, domain[1])
        else:
            raise ValueError('Can not convert %s to SynchDomain' % string)


问题


面经


文章

微信
公众号

扫码关注公众号