本文整理汇总了Python中past.builtins.map方法的典型用法代码示例。如果您正苦于以下问题:Python builtins.map方法的具体用法?Python builtins.map怎么用?Python builtins.map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类past.builtins
的用法示例。
在下文中一共展示了builtins.map方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_vertical_guides
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def find_vertical_guides(self, item_vedges, pdx, height, excluded_items):
# The root state cannot be aligned
if not self.item.parent:
return 0, ()
states_v = self._get_siblings_and_parent()
try:
guides = list(map(Guide, states_v))
except TypeError:
guides = []
vedges = set()
for g in guides:
for x in g.vertical():
vedges.add(self.view.get_matrix_i2v(g.item).transform_point(x, 0)[0])
dx, edges_x = self.find_closest(item_vedges, vedges)
return dx, edges_x
示例2: find_horizontal_guides
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def find_horizontal_guides(self, item_hedges, pdy, width, excluded_items):
# The root state cannot be aligned
if not self.item.parent:
return 0, ()
states_v = self._get_siblings_and_parent()
try:
guides = list(map(Guide, states_v))
except TypeError:
guides = []
hedges = set()
for g in guides:
for y in g.horizontal():
hedges.add(self.view.get_matrix_i2v(g.item).transform_point(0, y)[1])
dy, edges_y = self.find_closest(item_hedges, hedges)
return dy, edges_y
示例3: start_notify
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def start_notify(self, on_change):
"""Enable notification of changes for this characteristic on the
specified on_change callback. on_change should be a function that takes
one parameter which is the value (as a string of bytes) of the changed
characteristic value.
"""
# Setup a closure to be the first step in handling the on change callback.
# This closure will verify the characteristic is changed and pull out the
# new value to pass to the user's on change callback.
def characteristic_changed(iface, changed_props, invalidated_props):
# Check that this change is for a GATT characteristic and it has a
# new value.
if iface != _CHARACTERISTIC_INTERFACE:
return
if 'Value' not in changed_props:
return
# Send the new value to the on_change callback.
on_change(''.join(map(chr, changed_props['Value'])))
# Hook up the property changed signal to call the closure above.
self._props.connect_to_signal('PropertiesChanged', characteristic_changed)
# Enable notifications for changes on the characteristic.
self._characteristic.StartNotify()
示例4: print_dot_chart
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def print_dot_chart(self):
"""Print a dot output graph representing the workflow."""
print("digraph toil_graph {")
print("# This graph was created from job-store: %s" % self.jobStoreName)
# Make job IDs to node names map
jobsToNodeNames = dict(enumerate(map(lambda job: job.jobStoreID, self.jobsToReport)))
# Print the nodes
for job in set(self.jobsToReport):
print('%s [label="%s %s"];' % (
jobsToNodeNames[job.jobStoreID], job.jobName, job.jobStoreID))
# Print the edges
for job in set(self.jobsToReport):
for level, jobList in enumerate(job.stack):
for childJob in jobList:
# Check, b/c successor may be finished / not in the set of jobs
if childJob.jobStoreID in jobsToNodeNames:
print('%s -> %s [label="%i"];' % (
jobsToNodeNames[job.jobStoreID],
jobsToNodeNames[childJob.jobStoreID], level))
print("}")
示例5: s_update
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def s_update(name, value):
"""
Update the value of the named primitive in the currently open request.
:type name: str
:param name: Name of object whose value we wish to update
:type value: Mixed
:param value: Updated value
"""
if name not in map(lambda o: o.name, blocks.CURRENT.walk()):
raise exception.SullyRuntimeError("NO OBJECT WITH NAME '%s' FOUND IN CURRENT REQUEST" % name)
blocks.CURRENT.names[name].value = value
# PRIMITIVES
示例6: uuid_str_to_bin
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def uuid_str_to_bin(uuid):
"""
Converts a UUID string to binary form.
Expected string input format is same as uuid_bin_to_str()'s output format.
Ripped from Core Impacket.
:param uuid: UUID string to convert to bytes.
:type uuid: str
:return: UUID as bytes.
:rtype: bytes
"""
uuid_re = r"([\dA-Fa-f]{8})-([\dA-Fa-f]{4})-([\dA-Fa-f]{4})-([\dA-Fa-f]{4})-([\dA-Fa-f]{4})([\dA-Fa-f]{8})"
matches = re.match(uuid_re, uuid)
# pytype: disable=attribute-error
(uuid1, uuid2, uuid3, uuid4, uuid5, uuid6) = map(lambda x: int(x, 16), matches.groups())
# pytype: enable=attribute-error
uuid = struct.pack("<LHH", uuid1, uuid2, uuid3)
uuid += struct.pack(">HHL", uuid4, uuid5, uuid6)
return uuid
示例7: ipv4_checksum
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def ipv4_checksum(msg):
"""
Return IPv4 checksum of msg.
:param msg: Message to compute checksum over.
:type msg: bytes
:return: IPv4 checksum of msg.
:rtype: int
"""
# Pad with 0 byte if needed
if len(msg) % 2 == 1:
msg += b"\x00"
msg_words = map(_collate_bytes, msg[0::2], msg[1::2])
total = reduce(_ones_complement_sum_carry_16, msg_words, 0)
return ~total & 0xFFFF
示例8: failure_summary
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def failure_summary(self):
"""Return test summary string based on fuzz logger results.
:return: Test summary string, may be multi-line.
"""
summary = "Test Summary: {0} tests ran.\n".format(len(self.all_test_cases))
summary += "PASSED: {0} test cases.\n".format(len(self.passed_test_cases))
if len(self.failed_test_cases) > 0:
summary += "FAILED: {0} test cases:\n".format(len(self.failed_test_cases))
summary += "{0}\n".format("\n".join(map(str, self.failed_test_cases)))
if len(self.error_test_cases) > 0:
summary += "Errors on {0} test cases:\n".format(len(self.error_test_cases))
summary += "{0}".format("\n".join(map(str, self.error_test_cases)))
return summary
示例9: test_noniterators_produce_lists
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def test_noniterators_produce_lists(self):
l = range(10)
self.assertTrue(isinstance(l, list))
l2 = zip(l, list('ABCDE')*2)
self.assertTrue(isinstance(l2, list))
double = lambda x: x*2
l3 = map(double, l)
self.assertTrue(isinstance(l3, list))
is_odd = lambda x: x % 2 == 1
l4 = filter(is_odd, range(10))
self.assertEqual(l4, [1, 3, 5, 7, 9])
self.assertTrue(isinstance(l4, list))
示例10: load_bedgraph_matrix
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def load_bedgraph_matrix(self, filename, pChromosomes=None):
# load spectrum matrix:
matrix = []
chrom_list = []
start_list = []
end_list = []
with open(filename, 'r') as fh:
for line in fh:
# if type(line)
if line.startswith("#"):
# recover the parameters used to generate the spectrum_matrix
parameters = json.loads(line[1:].strip())
continue
fields = line.strip().split('\t')
chrom, start, end = fields[0:3]
if pChromosomes is not None:
if chrom in pChromosomes:
chrom_list.append(chrom)
start_list.append(int(float(start)))
end_list.append(int(float(end)))
matrix.append(map(float, fields[3:]))
else:
chrom_list.append(chrom)
start_list.append(int(float(start)))
end_list.append(int(float(end)))
matrix.append(map(float, fields[3:]))
self.min_depth = parameters['minDepth']
self.max_depth = parameters['maxDepth']
self.step = parameters['step']
self.binsize = parameters['binsize']
matrix = np.vstack(matrix)
self.bedgraph_matrix = {'chrom': np.array(chrom_list),
'chr_start': np.array(start_list).astype(int),
'chr_end': np.array(end_list).astype(int),
'matrix': matrix}
示例11: list_characteristics
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def list_characteristics(self):
"""Return list of GATT characteristics that have been discovered for this
service.
"""
paths = self._props.Get(_SERVICE_INTERFACE, 'Characteristics')
return map(BluezGattCharacteristic,
get_provider()._get_objects_by_path(paths))
示例12: list_descriptors
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def list_descriptors(self):
"""Return list of GATT descriptors that have been discovered for this
characteristic.
"""
paths = self._props.Get(_CHARACTERISTIC_INTERFACE, 'Descriptors')
return map(BluezGattDescriptor,
get_provider()._get_objects_by_path(paths))
示例13: list_services
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def list_services(self):
"""Return a list of GattService objects that have been discovered for
this device.
"""
return map(BluezGattService,
get_provider()._get_objects(_SERVICE_INTERFACE,
self._device.object_path))
示例14: discover
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def discover(self, service_uuids, char_uuids, timeout_sec=TIMEOUT_SEC):
"""Wait up to timeout_sec for the specified services and characteristics
to be discovered on the device. If the timeout is exceeded without
discovering the services and characteristics then an exception is thrown.
"""
# Turn expected values into a counter of each UUID for fast comparison.
expected_services = set(service_uuids)
expected_chars = set(char_uuids)
# Loop trying to find the expected services for the device.
start = time.time()
while True:
# Find actual services discovered for the device.
actual_services = set(self.advertised)
# Find actual characteristics discovered for the device.
chars = map(BluezGattCharacteristic,
get_provider()._get_objects(_CHARACTERISTIC_INTERFACE,
self._device.object_path))
actual_chars = set(map(lambda x: x.uuid, chars))
# Compare actual discovered UUIDs with expected and return true if at
# least the expected UUIDs are available.
if actual_services >= expected_services and actual_chars >= expected_chars:
# Found at least the expected services!
return True
# Couldn't find the devices so check if timeout has expired and try again.
if time.time()-start >= timeout_sec:
return False
time.sleep(1)
示例15: list_adapters
# 需要导入模块: from past import builtins [as 别名]
# 或者: from past.builtins import map [as 别名]
def list_adapters(self):
"""Return a list of BLE adapter objects connected to the system."""
return map(BluezAdapter, self._get_objects('org.bluez.Adapter1'))