def list(**type):
"""List all the segments defined in the database.
Search type can be identified by providing a named argument.
like = glob match
regex = regular expression
selector = segment selector
index = particular index
name = specific segment name
predicate = function predicate
"""
res = __builtin__.list(iterate(**type))
maxindex = max(__builtin__.map(operator.attrgetter('index'), res) or [1])
maxaddr = max(__builtin__.map(operator.attrgetter('endEA'), res) or [1])
maxsize = max(__builtin__.map(operator.methodcaller('size'), res) or [1])
maxname = max(__builtin__.map(utils.compose(idaapi.get_true_segm_name,len), res) or [1])
cindex = math.ceil(math.log(maxindex)/math.log(10))
caddr = math.ceil(math.log(maxaddr)/math.log(16))
csize = math.ceil(math.log(maxsize)/math.log(16))
for seg in res:
comment = idaapi.get_segment_cmt(seg, 0) or idaapi.get_segment_cmt(seg, 1)
print("[{:{:d}d}] {:0{:d}x}:{:0{:d}x} {:>{:d}s} {:<+#{:d}x} sel:{:04x} flags:{:02x}{:s}".format(seg.index, int(cindex), seg.startEA, int(caddr), seg.endEA, int(caddr), idaapi.get_true_segm_name(seg), maxname, seg.size(), int(csize), seg.sel, seg.flags, "// {:s}".format(comment) if comment else ''))
return
## searching
python类map()的实例源码
def map(ea, size, newea, **kwds):
"""Map ``size`` bytes of data from ``ea`` into a new segment at ``newea``.
``name`` can be used to name the segment.
"""
fpos,data = idaapi.get_fileregion_offset(ea),database.read(ea, size)
if len(data) != size:
raise ValueError("{:s}.map({:x}, {:#x}, {:x}) : Unable to read {:#x} bytes from {:#x}".format(__name__, ea, size, newea, size, ea))
res = idaapi.mem2base(data, newea, fpos)
if not res:
raise ValueError("{:s}.map({:x}, {:#x}, {:x}) : Unable to remap {:#x}:{:+#x} to {:#x}".format(__name__, ea, size, newea, ea, size, newea))
return create(newea, size, kwds.get("name', 'map_{:x}".format(ea)))
#return create(newea, size, kwds.get("name', 'map_{:s}".format(newea>>4)))
# creation/destruction
def lmap(*args, **kwargs):
return list(map(*args, **kwargs))
def __repr__(self):
if not self:
return '%s()' % self.__class__.__name__
items = ', '.join(map('%r: %r'.__mod__, self.most_common()))
return '%s({%s})' % (self.__class__.__name__, items)
# Multiset-style mathematical operations discussed in:
# Knuth TAOCP Volume II section 4.6.3 exercise 19
# and at http://en.wikipedia.org/wiki/Multiset
#
# Outputs guaranteed to only include positive counts.
#
# To strip negative and zero counts, add-in an empty counter:
# c += Counter()
def flatmap(f, items):
return chain.from_iterable(map(f, items))
def lmap(*args, **kwargs):
return list(map(*args, **kwargs))
def flatmap(f, items):
return chain.from_iterable(map(f, items))
def lmap(*args, **kwargs):
return list(map(*args, **kwargs))
__init__.py 文件源码
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda
作者: SignalMedia
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def lmap(*args, **kwargs):
return list(map(*args, **kwargs))
def flatmap(f, items):
return chain.from_iterable(map(f, items))
def lmap(*args, **kwargs):
return list(map(*args, **kwargs))
def flatmap(f, items):
return chain.from_iterable(map(f, items))
def lmap(*args, **kwargs):
return list(map(*args, **kwargs))
def flatmap(f, items):
return chain.from_iterable(map(f, items))
def lmap(*args, **kwargs):
return list(map(*args, **kwargs))
def flatmap(f, items):
return chain.from_iterable(map(f, items))
def lmap(*args, **kwargs):
return list(map(*args, **kwargs))
def lmap(*args, **kwargs):
return list(map(*args, **kwargs))
def flatmap(f, items):
return chain.from_iterable(map(f, items))
def lmap(*args, **kwargs):
return list(map(*args, **kwargs))