Exemplo n.º 1
0
def __iterate__(**type):
    '''Iterate through each segment defined in the database that match the keywords specified by `type`.'''
    def newsegment(index):
        seg = idaapi.getnseg(index)
        seg.index, _ = index, ui.navigation.set(interface.range.start(seg))
        return seg

    iterable = itertools.imap(newsegment,
                              six.moves.range(idaapi.get_segm_qty()))
    for key, value in six.iteritems(
            type or builtins.dict(predicate=utils.fconstant(True))):
        iterable = builtins.list(__matcher__.match(key, value, iterable))
    for item in iterable:
        yield item
Exemplo n.º 2
0
    'fpassthru', 'fdefault', 'fpass', 'fidentity', 'fid', 'first', 'second',
    'third', 'last', 'fcompose', 'fdiscard', 'fcondition', 'fmap', 'flazy',
    'fmemo', 'fpartial', 'fapply', 'fcurry', 'frpartial', 'freverse',
    'freversed', 'fexc', 'fexception', 'fcatch', 'fcomplement', 'fnot',
    'ilist', 'liter', 'ituple', 'titer', 'itake', 'iget', 'imap', 'ifilter',
    'ichain', 'izip', 'count'
]

### functional programming primitives (FIXME: probably better to document these with examples)

# box any specified arguments
fbox = fboxed = lambda *a: a
# return a closure that executes `f` with the arguments unboxed.
funbox = lambda f, *a, **k: lambda *ap, **kp: f(
    *(a + builtins.reduce(operator.add, builtins.map(builtins.tuple, ap),
                          ())), **builtins.dict(k.items() + kp.items()))
# return a closure that will check that `object` is an instance of `type`.
finstance = lambda *type: frpartial(builtins.isinstance, type)
# return a closure that will check if its argument has an item `key`.
fhasitem = fitemQ = lambda key: fcompose(
    fcatch(frpartial(operator.getitem, key)), iter, next,
    fpartial(operator.eq, None))
# return a closure that will get a particular element from an object
fgetitem = fitem = lambda item, *default: lambda object: default[
    0] if default and item not in object else object[item]
# return a closure that will check if its argument has an `attribute`.
fhasattr = fattributeQ = lambda attribute: frpartial(hasattr, attribute)
# return a closure that will get a particular attribute from an object
fgetattr = fattribute = lambda attribute, *default: lambda object: getattr(
    object, attribute, *default)
# return a closure that always returns `object`.
Exemplo n.º 3
0
 def lazy(*ap, **kp):
     A, K = a + ap, sortedtuple(k.items() + kp.items())
     return state[(A, K)] if (A, K) in state else state.setdefault(
         (A, K), f(*A, **builtins.dict(k.items() + kp.items())))
from six.moves import builtins

c1 = complex()
d1 = dict()
f1 = float()
i1 = int()
l1 = list()
s1 = str()
t1 = tuple()

c2 = builtins.complex()
d2 = builtins.dict()
f2 = builtins.float()
i2 = builtins.int()
l2 = builtins.list()
s2 = builtins.str()
t2 = builtins.tuple()