code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
if not index: # first item.
return slice(0, self.SIGNATURE[0])
if index >= len(self.SIGNATURE):
raise IndexError('index out of self.SIGNATURE range')
pad_start = sum(self.SIGNATURE[:index])
pad_stop = pad_start + self.SIGNATURE[index]
return slic... | def _get_slicers(self, index) | Return a slice object to slice a list/bytearray by.
Positional arguments:
index -- index of self.SIGNATURE to target self.bytearray by.
Returns:
slice() object. E.g. `x = _get_slicers(0); ba_instance[x]` | 4.352868 | 3.631338 | 1.198695 |
self.bytearray[self._get_slicers(0)] = bytearray(c_int32(value or 0)) | def pid(self, value) | Process ID setter. | 17.175123 | 16.042147 | 1.070625 |
self.bytearray[self._get_slicers(1)] = bytearray(c_int32(value or 0)) | def uid(self, value) | User ID setter. | 17.330048 | 16.150957 | 1.073004 |
self.bytearray[self._get_slicers(2)] = bytearray(c_int32(value or 0)) | def gid(self, value) | Group ID setter. | 17.126005 | 15.448569 | 1.108582 |
family = c
if not hasattr(family, 'gf_ops'):
setattr(family, 'gf_ops', nl_list_head(container_of=family))
if not hasattr(family, 'gf_mc_grps'):
setattr(family, 'gf_mc_grps', nl_list_head(container_of=family))
nl_init_list_head(family.gf_ops)
nl_init_list_head(family.gf_mc_grps) | def family_constructor(c) | https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/family.c#L37.
Positional arguments:
c -- nl_object-derived class instance. | 4.127102 | 4.208232 | 0.980721 |
family = c
if not hasattr(family, 'gf_ops'):
setattr(family, 'gf_ops', nl_list_head(container_of=family))
if not hasattr(family, 'gf_mc_grps'):
setattr(family, 'gf_mc_grps', nl_list_head(container_of=family))
ops = tmp = genl_family_op()
grp = t_grp = genl_family_grp()
if fa... | def family_free_data(c) | https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/family.c#L45.
Positional arguments:
c -- nl_object-derived class instance. | 5.243997 | 4.977923 | 1.053451 |
grp = genl_family_grp(id_=id_, name=name)
nl_list_add_tail(grp.list_, family.gf_mc_grps)
return 0 | def genl_family_add_grp(family, id_, name) | https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/family.c#L366.
Positional arguments:
family -- Generic Netlink family object (genl_family class instance).
id_ -- new numeric identifier (integer).
name -- new human readable name (string).
Returns:
0 | 12.482557 | 18.499191 | 0.674762 |
# Regular expression for comments
comment_re = re.compile(
'(^)?[^\S\n]*/(?:\*(.*?)\*/[^\S\n]*|/[^\n]*)($)?',
re.DOTALL | re.MULTILINE
)
with open(filename) as f:
content = ''.join(f.readlines())
## Looking for comments
match = comment_re.search(content)
... | def parse_json(filename) | Parse a JSON file
First remove comments and then use the json module package
Comments look like :
// ...
or
/*
...
*/ | 2.71016 | 2.656798 | 1.020085 |
parent_data = get_default_metadata_data()
child_data = get_child_metadata_data()
data = parent_data['metadataObjects'] + child_data
for item in data:
if 'directoryName' in item and item['directoryName'].lower() == dir_name.lower():
return item
elif 'tagName' in item and item[... | def get_meta_type_by_dir(dir_name) | > quick and dirty fix for users experiencing issues with "newer" metadata types not properly tested by mm
> if the project has a cached .describe, let's use that to detect metadata types | 3.880419 | 2.398757 | 1.617679 |
data = get_default_metadata_data()
child_data = get_child_metadata_data()
for item in data["metadataObjects"]:
if 'xmlName' in item and item['xmlName'] == name:
return item
for item in child_data:
if 'xmlName' in item and item['xmlName'] == name:
return item
'... | def get_meta_type_by_name(name) | > quick and dirty fix for users experiencing issues with "newer" metadata types not properly tested by mm
> if the project has a cached .describe, let's use that to detect metadata types | 4.581647 | 2.628307 | 1.743193 |
api_name = params["api_name"]
file_name = github_template["file_name"]
template_source = config.connection.get_plugin_client_setting('mm_template_source', 'joeferraro/MavensMate-Templates/master')
template_location = config.connection.get_plugin_client_setting('mm_template_location', 'remote')
... | def put_skeleton_files_on_disk(metadata_type, where, github_template=None, params={}) | Generates file based on jinja2 templates | 2.904758 | 2.850448 | 1.019053 |
"grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
args = [iter(iterable)] * n
return itertools.izip_longest(fillvalue=fillvalue, *args) | def grouper(n, iterable, fillvalue=None) | grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx | 2.056745 | 2.429844 | 0.846451 |
return int(genl_send_simple(nl_sock_h, GENL_ID_CTRL, CTRL_CMD_GETFAMILY, CTRL_VERSION, NLM_F_DUMP)) | def ctrl_request_update(_, nl_sock_h) | https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/ctrl.c#L37.
Positional arguments:
nl_sock_h -- nl_sock class instance.
Returns:
Integer, genl_send_simple() output. | 16.123203 | 9.742147 | 1.654995 |
remaining = c_int()
if not grp_attr:
raise BUG
for nla in nla_for_each_nested(grp_attr, remaining):
tb = dict()
err = nla_parse_nested(tb, CTRL_ATTR_MCAST_GRP_MAX, nla, family_grp_policy)
if err < 0:
return err
if not tb[CTRL_ATTR_MCAST_GRP_ID] or no... | def parse_mcast_grps(family, grp_attr) | https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/ctrl.c#L64.
Positional arguments:
family -- genl_family class instance.
grp_attr -- nlattr class instance.
Returns:
0 on success or a negative error code. | 5.008693 | 4.7809 | 1.047646 |
tb = dict((i, None) for i in range(CTRL_ATTR_MAX + 1))
nlh = nlmsg_hdr(msg)
ret = arg
if genlmsg_parse(nlh, 0, tb, CTRL_ATTR_MAX, ctrl_policy):
return NL_SKIP
if tb[CTRL_ATTR_FAMILY_ID]:
genl_family_set_id(ret, nla_get_u16(tb[CTRL_ATTR_FAMILY_ID]))
if tb[CTRL_ATTR_MCAST_GROU... | def probe_response(msg, arg) | Process responses from from the query sent by genl_ctrl_probe_by_name().
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/ctrl.c#L203
Process returned messages, filling out the missing information in the genl_family structure.
Positional arguments:
msg -- returned message (nl_msg class inst... | 7.852133 | 5.66258 | 1.386671 |
ret = genl_family_alloc()
if not ret:
return None
genl_family_set_name(ret, name)
msg = nlmsg_alloc()
orig = nl_socket_get_cb(sk)
cb = nl_cb_clone(orig)
genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, GENL_ID_CTRL, 0, 0, CTRL_CMD_GETFAMILY, 1)
nla_put_string(msg, CTRL_ATTR_FAMI... | def genl_ctrl_probe_by_name(sk, name) | Look up generic Netlink family by family name querying the kernel directly.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/ctrl.c#L237
Directly query's the kernel for a given family name.
Note: This API call differs from genl_ctrl_search_by_name in that it queries the kernel directly, allowin... | 7.314245 | 7.060548 | 1.035932 |
family = genl_ctrl_probe_by_name(sk, name)
if family is None:
return -NLE_OBJ_NOTFOUND
return int(genl_family_get_id(family)) | def genl_ctrl_resolve(sk, name) | Resolve Generic Netlink family name to numeric identifier.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/ctrl.c#L429
Resolves the Generic Netlink family name to the corresponding numeric family identifier. This function queries the
kernel directly, use genl_ctrl_search_by_name() if you need t... | 8.30888 | 8.888376 | 0.934803 |
for grp in nl_list_for_each_entry(genl_family_grp(), family.gf_mc_grps, 'list_'):
if grp.name == grp_name:
return grp.id_
return -NLE_OBJ_NOTFOUND | def genl_ctrl_grp_by_name(family, grp_name) | https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/ctrl.c#L446.
Positional arguments:
family -- genl_family class instance.
grp_name -- bytes.
Returns:
group ID or negative error code. | 17.493402 | 15.748707 | 1.110783 |
family = genl_ctrl_probe_by_name(sk, family_name)
if family is None:
return -NLE_OBJ_NOTFOUND
return genl_ctrl_grp_by_name(family, grp_name) | def genl_ctrl_resolve_grp(sk, family_name, grp_name) | Resolve Generic Netlink family group name.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/ctrl.c#L471
Looks up the family object and resolves the group name to the numeric group identifier.
Positional arguments:
sk -- Generic Netlink socket (nl_sock class instance).
family_name -- nam... | 5.150867 | 5.960323 | 0.864193 |
answer = list()
for i in range(len(data)):
r = data[i] & 0x7f
if r == BSS_MEMBERSHIP_SELECTOR_VHT_PHY and data[i] & 0x80:
value = 'VHT'
elif r == BSS_MEMBERSHIP_SELECTOR_HT_PHY and data[i] & 0x80:
value = 'HT'
else:
value = '{0}.{1}'.forma... | def get_supprates(_, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n227.
Positional arguments:
data -- bytearray data to read. | 3.875108 | 3.893833 | 0.995191 |
answers = {'Environment': country_env_str(chr(data[2]))}
data = data[3:]
while len(data) >= 3:
triplet = ieee80211_country_ie_triplet(data)
if triplet.ext.reg_extension_id >= IEEE80211_COUNTRY_EXTENSION_ID:
answers['Extension ID'] = triplet.ext.reg_extension_id
... | def get_country(_, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n267.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict. | 4.504823 | 4.415343 | 1.020266 |
legend = {0: 'Use group cipher suite', 1: 'WEP-40', 2: 'TKIP', 4: 'CCMP', 5: 'WEP-104', }
key = data[3]
if ieee80211_oui == bytes(data[:3]):
legend.update({6: 'AES-128-CMAC', 8: 'GCMP', })
elif ms_oui != bytes(data[:3]):
key = None
return legend.get(key, '{0:02x}-{1:02x}-{2:02x}... | def get_cipher(data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n336.
Positional arguments:
data -- bytearray data to read.
Returns:
WiFi stream cipher used by the access point (string). | 4.786221 | 4.932985 | 0.970248 |
answers = {
'Capabilities': get_ht_capability(data[0] | (data[1] << 8)),
'Minimum RX AMPDU time spacing': ampdu_space.get((data[2] >> 2) & 7, 'BUG (spacing more than 3 bits!)'),
'Maximum RX AMPDU length': {0: 8191, 1: 16383, 2: 32767, 3: 65535}.get(data[2] & 3, 0),
}
answers.upd... | def get_ht_capa(_, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n602.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict. | 5.885804 | 6.003047 | 0.980469 |
answers = dict()
idx = 0
while idx < len(data) - 1:
qri = data[idx]
proto_id = data[idx + 1]
answers['Query Response Info'] = qri
answers['Query Response Length Limit'] = qri & 0x7f
if qri & (1 << 7):
answers['PAME-BI'] = True
answers['proto_i... | def get_11u_advert(_, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n676.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict. | 8.988265 | 9.112883 | 0.986325 |
protection = ('no', 'nonmember', 20, 'non-HT mixed')
sta_chan_width = (20, 'any')
answers = {
'primary channel': data[0],
'secondary channel offset': ht_secondary_offset[data[1] & 0x3],
'STA channel width': sta_chan_width[(data[1] & 0x4) >> 2],
'RIFS': (data[1] & 0x8) >>... | def get_ht_op(_, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n766.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict. | 4.626245 | 4.694616 | 0.985436 |
answers = list()
for i in range(len(data)):
base = i * 8
for bit in range(8):
if not data[i] & (1 << bit):
continue
answers.append(CAPA.get(bit + base, bit))
return answers | def get_capabilities(_, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n796.
Positional arguments:
data -- bytearray data to read.
Returns:
List. | 5.597538 | 5.163164 | 1.084129 |
answers = {
'DTIM Count': data[0],
'DTIM Period': data[1],
'Bitmap Control': data[2],
'Bitmap[0]': data[3],
}
if len(data) - 4:
answers['+ octets'] = len(data) - 4
return answers | def get_tim(_, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n874.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict. | 9.284175 | 7.980855 | 1.163306 |
answers = {
'passive dwell': (data[1] << 8) | data[0],
'active dwell': (data[3] << 8) | data[2],
'channel width trigger scan interval': (data[5] << 8) | data[4],
'scan passive total per channel': (data[7] << 8) | data[6],
'scan active total per channel': (data[9] << 8) |... | def get_obss_scan_params(_, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n914.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict. | 3.960689 | 3.906977 | 1.013748 |
if data[0] < len(ht_secondary_offset):
return "{0} ({1})".format(ht_secondary_offset[data[0]], data[0])
return "{0}".format(data[0]) | def get_secchan_offs(type_, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n927.
Positional arguments:
type_ -- corresponding `ieprinters` dictionary key for the instance.
data -- bytearray data to read. | 4.912845 | 6.048783 | 0.812204 |
answers = {
'station count': (data[1] << 8) | data[0],
'channel utilisation': data[2] / 255.0,
'available admission capacity': (data[4] << 8) | data[3],
}
return answers | def get_bss_load(_, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n935.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict. | 6.231921 | 6.396461 | 0.974276 |
if not instance.print_:
return dict()
if len(data) < instance.minlen or len(data) > instance.maxlen:
if data:
return {'<invalid: {0} byte(s)>'.format(len(data)): ' '.join(format(x, '02x') for x in data)}
return {'<invalid: no data>': data}
return {instance.name: inst... | def get_ie(instance, key, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n981.
Positional arguments:
instance -- `ie_print` class instance.
key -- corresponding `ieprinters` dictionary key for the instance.
data -- bytearray data to read.
Returns:
Dictionary of parsed data with string key... | 4.808785 | 4.426026 | 1.086479 |
answers = dict()
aci_tbl = ('BE', 'BK', 'VI', 'VO')
if data[0] & 0x80:
answers['u-APSD'] = True
data = data[2:]
for i in range(4):
key = aci_tbl[(data[0] >> 5) & 3]
value = dict()
if data[0] & 0x10:
value['acm'] = True
value['CW'] = ((1 << (d... | def get_wifi_wmm_param(data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n1046.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict. | 5.019715 | 4.952142 | 1.013645 |
answers = dict()
if data[0] == 0x01:
if len(data) < 20:
key = 'invalid'
elif data[1] != 1:
key = 'Parameter: not version 1'
else:
answers.update(get_wifi_wmm_param(data[2:]))
return answers
elif data[0] == 0x00:
key = 'info... | def get_wifi_wmm(_, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n1088.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict. | 3.709609 | 3.661706 | 1.013082 |
answers = dict()
while len(data) >= 4:
subtype = (data[0] << 8) + data[1]
sublen = (data[2] << 8) + data[3]
if sublen > len(data):
break
elif subtype == 0x104a:
answers['Version'] = data[4] >> 4, data[4] & 0xF
elif subtype == 0x1011:
... | def get_wifi_wps(_, data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n1130.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict. | 2.895732 | 2.871449 | 1.008457 |
if len(data) < 3:
return dict(('Vendor specific: <too short> data', ' '.join(format(x, '02x'))) for x in data)
key = data[3]
if bytes(data[:3]) == ms_oui:
if key in wifiprinters and wifiprinters[key].flags & 1:
return get_ie(wifiprinters[key], key, data[4:])
return ... | def get_vendor(data) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n1401.
Positional arguments:
data -- bytearray data to read.
Returns:
Dictionary of parsed data with string keys. | 3.119733 | 3.15257 | 0.989584 |
answers = dict()
while len(ie) >= 2 and len(ie) >= ie[1]:
key = ie[0] # Should be key in `ieprinters` dict.
len_ = ie[1] # Length of this information element.
data = ie[2:len_ + 2] # Data for this information element.
if key in ieprinters and ieprinters[key].flags & 1:
... | def get_ies(ie) | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n1456.
Positional arguments:
ie -- bytearray data to read.
Returns:
Dictionary of all parsed data. In the iw tool it prints everything to terminal. This function returns a dictionary
with string keys (being the "titles" ... | 4.324599 | 4.30378 | 1.004837 |
if not os.path.exists(os.path.join(HERE, path)):
return ''
file_handle = codecs.open(os.path.join(HERE, path), encoding='utf-8')
contents = file_handle.read(length)
file_handle.close()
return contents | def _safe_read(path, length) | Read file contents. | 2.338305 | 2.149974 | 1.087597 |
ret = func(*args, **kwargs)
if no_exit or ret >= 0:
return ret
reason = errmsg[abs(ret)]
error('{0}() returned {1} ({2})'.format(func.__name__, ret, reason)) | def ok(no_exit, func, *args, **kwargs) | Exit if `ret` is not OK (a negative number). | 4.844467 | 4.196396 | 1.154435 |
arg.value = err.error
return libnl.handlers.NL_STOP | def error_handler(_, err, arg) | Update the mutable integer `arg` with the error code. | 127.13726 | 69.567909 | 1.827527 |
gnlh = genlmsghdr(nlmsg_data(nlmsg_hdr(msg)))
if gnlh.cmd == nl80211.NL80211_CMD_SCAN_ABORTED:
arg.value = 1 # The scan was aborted for some reason.
elif gnlh.cmd == nl80211.NL80211_CMD_NEW_SCAN_RESULTS:
arg.value = 0 # The scan completed successfully. `callback_dump` will collect the... | def callback_trigger(msg, arg) | Called when the kernel is done scanning. Only signals if it was successful or if it failed. No other data.
Positional arguments:
msg -- nl_msg class instance containing the data sent by the kernel.
arg -- mutable integer (ctypes.c_int()) to update with results.
Returns:
An integer, value of NL_SKI... | 7.030865 | 5.754286 | 1.221848 |
bss = dict() # To be filled by nla_parse_nested().
# First we must parse incoming data into manageable chunks and check for errors.
gnlh = genlmsghdr(nlmsg_data(nlmsg_hdr(msg)))
tb = dict((i, None) for i in range(nl80211.NL80211_ATTR_MAX + 1))
nla_parse(tb, nl80211.NL80211_ATTR_MAX, genlmsg_a... | def callback_dump(msg, results) | Here is where SSIDs and their data is decoded from the binary data sent by the kernel.
This function is called once per SSID. Everything in `msg` pertains to just one SSID.
Positional arguments:
msg -- nl_msg class instance containing the data sent by the kernel.
results -- dictionary to populate with... | 4.243729 | 4.19299 | 1.012101 |
msg = nlmsg_alloc()
genlmsg_put(msg, 0, 0, driver_id, 0, NLM_F_DUMP, nl80211.NL80211_CMD_GET_SCAN, 0)
nla_put_u32(msg, nl80211.NL80211_ATTR_IFINDEX, if_index)
cb = libnl.handlers.nl_cb_alloc(libnl.handlers.NL_CB_DEFAULT)
libnl.handlers.nl_cb_set(cb, libnl.handlers.NL_CB_VALID, libnl.handlers.NL... | def do_scan_results(sk, if_index, driver_id, results) | Retrieve the results of a successful scan (SSIDs and data about them).
This function does not require root privileges. It eventually calls a callback that actually decodes data about
SSIDs but this function kicks that off.
May exit the program (sys.exit()) if a fatal error occurs.
Positional argument... | 4.162894 | 4.091183 | 1.017528 |
final_days, final_hours, final_minutes, final_seconds = 0, 0, 0, seconds
if final_seconds >= 86400:
final_days = int(final_seconds / 86400.0)
final_seconds -= final_days * 86400
if final_seconds >= 3600:
final_hours = int(final_seconds / 3600.0)
final_seconds -= final_ho... | def eta_letters(seconds) | Convert seconds remaining into human readable strings.
From https://github.com/Robpol86/etaprogress/blob/ad934d4/etaprogress/components/eta_conversions.py.
Positional arguments:
seconds -- integer/float indicating seconds remaining. | 1.419793 | 1.447734 | 0.9807 |
table = AsciiTable([COLUMNS])
table.justify_columns[2] = 'right'
table.justify_columns[3] = 'right'
table.justify_columns[4] = 'right'
table_data = list()
for row_in in data:
row_out = [
str(row_in.get('ssid', '')).replace('\0', ''),
str(row_in.get('security'... | def print_table(data) | Print the table of detected SSIDs and their data to screen.
Positional arguments:
data -- list of dictionaries. | 2.220657 | 2.41464 | 0.919664 |
# First get the wireless interface index.
pack = struct.pack('16sI', OPTIONS['<interface>'].encode('ascii'), 0)
sk = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
info = struct.unpack('16sI', fcntl.ioctl(sk.fileno(), 0x8933, pack))
except OSError:
return error('Wireless ... | def main() | Main function called upon script execution. | 4.467604 | 4.44628 | 1.004796 |
fmt = 'DBG<0>%(pathname)s:%(lineno)d %(funcName)s: %(message)s'
handler_stderr = logging.StreamHandler(sys.stderr)
handler_stderr.setFormatter(logging.Formatter(fmt))
if OPTIONS['--verbose'] == 1:
handler_stderr.addFilter(logging.Filter(__name__))
root_logger = logging.getLogger()
... | def setup_logging() | Called when __name__ == '__main__' below. Sets up logging library.
All logging messages go to stderr, from DEBUG to CRITICAL. This script uses print() for regular messages. | 3.412932 | 3.217122 | 1.060865 |
'''
Generate a SOAP header as defined in:
http://www.salesforce.com/us/developer/docs/api/Content/soap_headers.htm
'''
try:
return self._sforce.factory.create(sObjectType)
except:
print 'There is not a SOAP header of type %s' % sObjectType | def generateHeader(self, sObjectType) | Generate a SOAP header as defined in:
http://www.salesforce.com/us/developer/docs/api/Content/soap_headers.htm | 5.96327 | 3.034219 | 1.96534 |
'''
Generate a Salesforce object, such as a Lead or Contact
'''
obj = self._sforce.factory.create('ens:sObject')
obj.type = sObjectType
return obj | def generateObject(self, sObjectType) | Generate a Salesforce object, such as a Lead or Contact | 11.202767 | 7.312516 | 1.531999 |
'''
If any of the following calls return a single result, and self._strictResultTyping is true,
return the single result, rather than [(SaveResult) {...}]:
convertLead()
create()
delete()
emptyRecycleBin()
invalidateSessions()
merge()
process()
retrieve()
... | def _handleResultTyping(self, result) | If any of the following calls return a single result, and self._strictResultTyping is true,
return the single result, rather than [(SaveResult) {...}]:
convertLead()
create()
delete()
emptyRecycleBin()
invalidateSessions()
merge()
process()
retrieve()
undelete(... | 12.21499 | 1.587543 | 7.694275 |
'''
Marshall generic sObjects into a list of SAX elements
This code is going away ASAP
tag param is for nested objects (e.g. MergeRequest) where
key: object must be in <key/>, not <sObjects/>
'''
if not isinstance(sObjects, (tuple, list)):
sObjects = (sObjects, )
if sObjects[0].t... | def _marshallSObjects(self, sObjects, tag = 'sObjects') | Marshall generic sObjects into a list of SAX elements
This code is going away ASAP
tag param is for nested objects (e.g. MergeRequest) where
key: object must be in <key/>, not <sObjects/> | 6.30794 | 3.86786 | 1.63086 |
'''
Set the endpoint after when Salesforce returns the URL after successful login()
'''
# suds 0.3.7+ supports multiple wsdl services, but breaks setlocation :(
# see https://fedorahosted.org/suds/ticket/261
try:
self._sforce.set_options(location = location)
except:
self._sforce.... | def _setEndpoint(self, location) | Set the endpoint after when Salesforce returns the URL after successful login() | 10.474283 | 6.383938 | 1.640724 |
'''
Attach particular SOAP headers to the request depending on the method call made
'''
# All calls, including utility calls, set the session header
headers = {'SessionHeader': self._sessionHeader}
if 'debug_categories' in kwargs:
#ERROR, WARN, INFO, DEBUG, FINE, FINER, FINEST
#Db, ... | def _setHeaders(self, call = None, **kwargs) | Attach particular SOAP headers to the request depending on the method call made | 3.018817 | 2.842525 | 1.062019 |
'''
Retrieves the list of individual objects that have been updated (added or
changed) within the given timespan for the specified object.
'''
self._setHeaders('getUpdated')
return self._sforce.service.getUpdated(sObjectType, startDate, endDate) | def getUpdated(self, sObjectType, startDate, endDate) | Retrieves the list of individual objects that have been updated (added or
changed) within the given timespan for the specified object. | 7.479643 | 3.565424 | 2.097827 |
'''
Invalidate a Salesforce session
This should be used with extreme caution, for the following (undocumented) reason:
All API connections for a given user share a single session ID
This will call logout() WHICH LOGS OUT THAT USER FROM EVERY CONCURRENT SESSION
return invalidateSessionsResult
... | def invalidateSessions(self, sessionIds) | Invalidate a Salesforce session
This should be used with extreme caution, for the following (undocumented) reason:
All API connections for a given user share a single session ID
This will call logout() WHICH LOGS OUT THAT USER FROM EVERY CONCURRENT SESSION
return invalidateSessionsResult | 18.373953 | 2.919153 | 6.294275 |
'''
Login to Salesforce.com and starts a client session.
Unlike other toolkits, token is a separate parameter, because
Salesforce doesn't explicitly tell you to append it when it gives
you a login error. Folks that are new to the API may not know this.
'username' : Username
'password' : P... | def login(self, username, password, token) | Login to Salesforce.com and starts a client session.
Unlike other toolkits, token is a separate parameter, because
Salesforce doesn't explicitly tell you to append it when it gives
you a login error. Folks that are new to the API may not know this.
'username' : Username
'password' : Password
... | 7.354467 | 3.803467 | 1.933622 |
'''
Executes a query against the specified object and returns data that matches
the specified criteria.
'''
self._setHeaders('query')
return self._sforce.service.query(queryString) | def query(self, queryString) | Executes a query against the specified object and returns data that matches
the specified criteria. | 12.011888 | 6.053341 | 1.98434 |
'''
Retrieves data from specified objects, whether or not they have been deleted.
'''
self._setHeaders('queryAll')
return self._sforce.service.queryAll(queryString) | def queryAll(self, queryString) | Retrieves data from specified objects, whether or not they have been deleted. | 15.663976 | 6.336481 | 2.472031 |
'''
Retrieves the next batch of objects from a query.
'''
self._setHeaders('queryMore')
return self._sforce.service.queryMore(queryLocator) | def queryMore(self, queryLocator) | Retrieves the next batch of objects from a query. | 10.677819 | 7.748481 | 1.378053 |
'''
Describes metadata (field list and object properties) for the specified
object.
'''
self._setHeaders('describeSObject')
return self._sforce.service.describeSObject(sObjectsType) | def describeSObject(self, sObjectsType) | Describes metadata (field list and object properties) for the specified
object. | 11.46594 | 5.982961 | 1.916432 |
'''
An array-based version of describeSObject; describes metadata (field list
and object properties) for the specified object or array of objects.
'''
self._setHeaders('describeSObjects')
return self._handleResultTyping(self._sforce.service.describeSObjects(sObjectTypes)) | def describeSObjects(self, sObjectTypes) | An array-based version of describeSObject; describes metadata (field list
and object properties) for the specified object or array of objects. | 14.193497 | 4.985129 | 2.847167 |
'''
Changes a user's password to a system-generated value.
'''
self._setHeaders('resetPassword')
return self._sforce.service.resetPassword(userId) | def resetPassword(self, userId) | Changes a user's password to a system-generated value. | 10.511868 | 7.563509 | 1.389814 |
'''
Sets the specified user's password to the specified value.
'''
self._setHeaders('setPassword')
return self._sforce.service.setPassword(userId, password) | def setPassword(self, userId, password) | Sets the specified user's password to the specified value. | 8.475348 | 7.101423 | 1.193472 |
ops = cache_ops
while ops: # Loop until `ops` is None.
if ops.co_name == name:
return ops
ops = ops.co_next
return None | def _nl_cache_ops_lookup(name) | https://github.com/thom311/libnl/blob/libnl3_2_25/lib/cache_mngt.c#L41.
Positional arguments:
name -- string.
Returns:
nl_cache_ops instance or None. | 6.298138 | 6.520225 | 0.965939 |
ops = cache_ops
while ops: # Loop until `ops` is None.
if ops.co_protocol == protocol:
for co_msgtype in ops.co_msgtypes:
if co_msgtype.mt_id == msgtype:
return ops
ops = ops.co_next
return None | def _cache_ops_associate(protocol, msgtype) | https://github.com/thom311/libnl/blob/libnl3_2_25/lib/cache_mngt.c#L111.
Positional arguments:
protocol -- Netlink protocol (integer).
msgtype -- Netlink message type (integer).
Returns:
nl_cache_ops instance with matching protocol containing matching msgtype or None. | 6.004598 | 4.711106 | 1.274562 |
for i in ops.co_msgtypes:
if i.mt_id == msgtype:
return i
return None | def nl_msgtype_lookup(ops, msgtype) | Lookup message type cache association.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/cache_mngt.c#L189
Searches for a matching message type association ing the specified cache operations.
Positional arguments:
ops -- cache operations (nl_cache_ops class instance).
msgtype -- Netlink messa... | 8.337267 | 9.309483 | 0.895567 |
global cache_ops
if not ops.co_name or not ops.co_obj_ops:
return -NLE_INVAL
with cache_ops_lock:
if _nl_cache_ops_lookup(ops.co_name):
return -NLE_EXIST
ops.co_refcnt = 0
ops.co_next = cache_ops
cache_ops = ops
_LOGGER.debug('Registered cache ... | def nl_cache_mngt_register(ops) | Register a set of cache operations.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/cache_mngt.c#L252
Called by users of caches to announce the availability of a certain cache type.
Positional arguments:
ops -- cache operations (nl_cache_ops class instance).
Returns:
0 on success or a ... | 5.83191 | 5.720232 | 1.019523 |
if 'type' not in self.params:
raise MMException("Please include the type of log, 'user' or 'apex'")
if 'debug_categories' not in self.params:
raise MMException("Please include debug categories in dictionary format: e.g.: {'ApexCode':'DEBUG', 'Visualforce':'INFO'}")
... | def execute(self) | params = {
"ApexCode" : "None",
"ApexProfiling" : "01pd0000001yXtYAAU",
"Callout" : True,
"Database" : 1,
"ExpirationDate" : 3,
"ScopeId" : "",
"System" ... | 3.339176 | 2.983206 | 1.119325 |
config.logger.debug('logging self')
config.logger.debug(self.params )
if 'project_name' in self.params:
self.params.pop('project_name', None)
if 'settings' in self.params:
self.params.pop('settings', None)
create_result = config.sfdc_client.creat... | def execute(self) | self.params = {
"ActionScriptType" : "None",
"ExecutableEntityId" : "01pd0000001yXtYAAU",
"IsDumpingHeap" : True,
"Iteration" : 1,
"Line" : 3,
"ScopeId" : "005d00000... | 4.537216 | 4.23245 | 1.072007 |
'''
POST /project/creds
{
"project_name" : "my project name"
"username" : "mm@force.com",
"password" : "force",
"org_type" : "developer",
}
NOTE: project name should not be updated, as it is used to find the project in q... | def update_credentials_request(request_handler) | POST /project/creds
{
"project_name" : "my project name"
"username" : "mm@force.com",
"password" : "force",
"org_type" : "developer",
}
NOTE: project name should not be updated, as it is used to find the project in question
... | 7.93355 | 2.262751 | 3.506152 |
flags = getattr(socket, 'SOCK_CLOEXEC', 0)
if sk.s_fd != -1:
return -NLE_BAD_SOCK
try:
sk.socket_instance = socket.socket(getattr(socket, 'AF_NETLINK', -1), socket.SOCK_RAW | flags, protocol)
except OSError as exc:
return -nl_syserr2nlerr(exc.errno)
if not sk.s_flags & ... | def nl_connect(sk, protocol) | Create file descriptor and bind socket.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L96
Creates a new Netlink socket using `socket.socket()` and binds the socket to the protocol and local port specified
in the `sk` socket object (if any). Fails if the socket is already connected.
Posit... | 3.215939 | 3.151936 | 1.020306 |
if sk.s_fd < 0:
return -NLE_BAD_SOCK
nlmsg_set_src(msg, sk.s_local)
cb = sk.s_cb
if cb.cb_set[NL_CB_MSG_OUT]:
ret = nl_cb_call(cb, NL_CB_MSG_OUT, msg)
if ret != NL_OK:
return ret
if hdr.msg_name is None:
address = None
else:
address = tup... | def nl_sendmsg(sk, msg, hdr) | Transmit Netlink message using socket.sendmsg|sendto|send().
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L299
Transmits the message specified in `hdr` over the Netlink socket using Python's socket.sendmsg().
ATTENTION: The `msg` argument will *not* be used to derive the message payload tha... | 4.150512 | 3.945662 | 1.051918 |
hdr = msghdr(msg_name=sk.s_peer, msg_iov=iov)
# Overwrite destination if specified in the message itself, defaults to the peer address of the socket.
dst = nlmsg_get_dst(msg)
if dst.nl_family == socket.AF_NETLINK:
hdr.msg_name = dst
# Add credentials if present.
creds = nlmsg_get_... | def nl_send_iovec(sk, msg, iov, _) | Transmit Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L342
This function is identical to nl_send().
This function triggers the `NL_CB_MSG_OUT` callback.
Positional arguments:
sk -- Netlink socket (nl_sock class instance).
msg -- Netlink message (nl_msg class in... | 7.786558 | 8.677757 | 0.897301 |
cb = sk.s_cb
if cb.cb_send_ow:
return cb.cb_send_ow(sk, msg)
hdr = nlmsg_hdr(msg)
iov = hdr.bytearray[:hdr.nlmsg_len]
return nl_send_iovec(sk, msg, iov, 1) | def nl_send(sk, msg) | Transmit Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L416
Transmits the Netlink message `msg` over the Netlink socket using the `socket.sendmsg()`. This function is based on
`nl_send_iovec()`.
The message is addressed to the peer as specified in the socket by either th... | 7.71165 | 7.788496 | 0.990133 |
nlh = msg.nm_nlh
if nlh.nlmsg_pid == NL_AUTO_PORT:
nlh.nlmsg_pid = nl_socket_get_local_port(sk)
if nlh.nlmsg_seq == NL_AUTO_SEQ:
nlh.nlmsg_seq = sk.s_seq_next
sk.s_seq_next += 1
if msg.nm_protocol == -1:
msg.nm_protocol = sk.s_proto
nlh.nlmsg_flags |= NLM_F_REQUE... | def nl_complete_msg(sk, msg) | Finalize Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L450
This function finalizes a Netlink message by completing the message with desirable flags and values depending on the
socket configuration.
- If not yet filled out, the source address of the message (`nlmsg_pid`)... | 4.284247 | 2.743443 | 1.561632 |
msg = nlmsg_alloc_simple(type_, flags)
if buf is not None and size:
err = nlmsg_append(msg, buf, size, NLMSG_ALIGNTO)
if err < 0:
return err
return nl_send_auto(sk, msg) | def nl_send_simple(sk, type_, flags, buf=None, size=0) | Construct and transmit a Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L549
Allocates a new Netlink message based on `type_` and `flags`. If `buf` points to payload of length `size` that
payload will be appended to the message.
Sends out the message using `nl_send_auto()... | 5.17458 | 5.160563 | 1.002716 |
flags = 0
page_size = resource.getpagesize() * 4
if sk.s_flags & NL_MSG_PEEK:
flags |= socket.MSG_PEEK | socket.MSG_TRUNC
iov_len = sk.s_bufsize or page_size
if creds and sk.s_flags & NL_SOCK_PASSCRED:
raise NotImplementedError # TODO https://github.com/Robpol86/libnl/issues/2... | def nl_recv(sk, nla, buf, creds=None) | Receive data from Netlink socket.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L625
Receives data from a connected netlink socket using recvmsg() and returns the number of bytes read. The read data is
stored in a newly allocated buffer that is assigned to `buf`. The peer's netlink address wi... | 4.389983 | 4.262521 | 1.029903 |
if cb.cb_recvmsgs_ow:
return int(cb.cb_recvmsgs_ow(sk, cb))
return int(recvmsgs(sk, cb)) | def nl_recvmsgs_report(sk, cb) | Receive a set of messages from a Netlink socket and report parsed messages.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L998
This function is identical to nl_recvmsgs() to the point that it will return the number of parsed messages instead
of 0 on success.
See nl_recvmsgs().
Posit... | 7.063042 | 7.501873 | 0.941504 |
err = nl_recvmsgs_report(sk, cb)
if err > 0:
return 0
return int(err) | def nl_recvmsgs(sk, cb) | Receive a set of messages from a Netlink socket.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L1023
Repeatedly calls nl_recv() or the respective replacement if provided by the application (see nl_cb_overwrite_recv())
and parses the received data as Netlink messages. Stops reading if one of t... | 5.934436 | 5.194095 | 1.142535 |
cb = nl_cb_clone(sk.s_cb)
nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, lambda *_: NL_STOP, None)
return int(nl_recvmsgs(sk, cb)) | def nl_wait_for_ack(sk) | Wait for ACK.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L1058
Waits until an ACK is received for the latest not yet acknowledged Netlink message.
Positional arguments:
sk -- Netlink socket (nl_sock class instance).
Returns:
Number of received messages or a negative error cod... | 10.370526 | 11.890164 | 0.872194 |
prev.next_ = obj
obj.prev = prev
next_.prev = obj
obj.next_ = next_ | def _nl_list_add(obj, prev, next_) | https://github.com/thom311/libnl/blob/libnl3_2_25/include/netlink/list.h#L27.
Positional arguments:
obj -- nl_list_head class instance.
prev -- nl_list_head class instance.
next_ -- nl_list_head class instance. | 3.280281 | 3.371413 | 0.972969 |
obj.next.prev = obj.prev
obj.prev.next_ = obj.next_ | def nl_list_del(obj) | https://github.com/thom311/libnl/blob/libnl3_2_25/include/netlink/list.h#L49.
Positional arguments:
obj -- nl_list_head class instance. | 6.052652 | 8.32207 | 0.727301 |
if ptr.container_of:
return ptr.container_of
null_data = type_()
setattr(null_data, member, ptr)
return null_data | def nl_list_entry(ptr, type_, member) | https://github.com/thom311/libnl/blob/libnl3_2_25/include/netlink/list.h#L64. | 7.71312 | 7.259934 | 1.062423 |
pos = nl_list_entry(head.next_, type(pos), member)
while True:
yield pos
if getattr(pos, member) != head:
pos = nl_list_entry(getattr(pos, member).next_, type(pos), member)
continue
break | def nl_list_for_each_entry(pos, head, member) | https://github.com/thom311/libnl/blob/libnl3_2_25/include/netlink/list.h#L79.
Positional arguments:
pos -- class instance holding an nl_list_head instance.
head -- nl_list_head class instance.
member -- attribute (string).
Returns:
Generator yielding a class instances. | 5.020141 | 4.544948 | 1.104554 |
pos = nl_list_entry(head.next_, type(pos), member)
n = nl_list_entry(pos.member.next_, type(pos), member)
while True:
yield pos
if getattr(pos, member) != head:
pos = n
n = nl_list_entry(n.member.next_, type(n), member)
continue
break | def nl_list_for_each_entry_safe(pos, n, head, member) | https://github.com/thom311/libnl/blob/libnl3_2_25/include/netlink/list.h#L84.
Positional arguments:
pos -- class instance holding an nl_list_head instance.
n -- class instance holding an nl_list_head instance.
head -- nl_list_head class instance.
member -- attribute (string).
Returns:
Gene... | 4.465793 | 3.937398 | 1.134199 |
del buf[:]
if type_ in tbl:
buf.extend(tbl[type_].encode('ascii'))
else:
buf.extend('0x{0:x}'.format(type_).encode('ascii'))
return buf | def __type2str(type_, buf, _, tbl) | https://github.com/thom311/libnl/blob/libnl3_2_25/lib/utils.c#L968.
Positional arguments:
type_ -- integer, key to lookup in `tbl`.
buf -- bytearray().
_ -- unused.
tbl -- dict.
Returns:
Reference to `buf`. | 3.395269 | 3.38554 | 1.002874 |
# First convert `msg` into something more manageable.
nlh = nlmsg_hdr(msg)
iface = ifinfomsg(nlmsg_data(nlh))
hdr = IFLA_RTA(iface)
remaining = ctypes.c_int(nlh.nlmsg_len - NLMSG_LENGTH(iface.SIZEOF))
# Now iterate through each rtattr stored in `iface`.
while RTA_OK(hdr, remaining):
... | def callback(msg, _) | Callback function called by libnl upon receiving messages from the kernel.
Positional arguments:
msg -- nl_msg class instance containing the data sent by the kernel.
Returns:
An integer, value of NL_OK. It tells libnl to proceed with processing the next kernel message. | 13.639462 | 11.447458 | 1.191484 |
# First open a socket to the kernel. Same one used for sending and receiving.
sk = nl_socket_alloc() # Creates an `nl_sock` instance.
ret = nl_connect(sk, NETLINK_ROUTE) # Create file descriptor and bind socket.
if ret < 0:
reason = errmsg[abs(ret)]
return error('nl_connect() retu... | def main() | Main function called upon script execution. | 5.266066 | 5.232707 | 1.006375 |
settings = {}
user_path = self.get_plugin_settings_path("User")
def_path = self.get_plugin_settings_path("MavensMate")
'''
if the default path for settings is none, we're either dealing with a bad client setup or
a new client like Atom.io. Let's load the settings... | def get_plugin_client_settings(self) | if the default path for settings is none, we're either dealing with a bad client setup or
a new client like Atom.io. Let's load the settings from the default cache and optionally allow
them to pipe settings in via STDIN | 4.402683 | 3.00141 | 1.466872 |
return nla_for_each_attr(nlmsg_attrdata(nlh, hdrlen), nlmsg_attrlen(nlh, hdrlen), rem) | def nlmsg_for_each_attr(nlh, hdrlen, rem) | Iterate over a stream of attributes in a message.
https://github.com/thom311/libnl/blob/libnl3_2_25/include/netlink/msg.h#L123
Positional arguments:
nlh -- Netlink message header (nlmsghdr class instance).
hdrlen -- length of family header (integer).
rem -- initialized to len, holds bytes currentl... | 4.969702 | 5.385902 | 0.922724 |
data = nlmsg_data(nlh)
return libnl.linux_private.netlink.nlattr(bytearray_ptr(data, libnl.linux_private.netlink.NLMSG_ALIGN(hdrlen))) | def nlmsg_attrdata(nlh, hdrlen) | Head of attributes data.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L143
Positional arguments:
nlh -- Netlink message header (nlmsghdr class instance).
hdrlen -- length of family specific header (integer).
Returns:
First attribute (nlattr class instance with others in its pay... | 12.316462 | 12.094351 | 1.018365 |
return max(nlmsg_len(nlh) - libnl.linux_private.netlink.NLMSG_ALIGN(hdrlen), 0) | def nlmsg_attrlen(nlh, hdrlen) | Length of attributes data.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L154
nlh -- Netlink message header (nlmsghdr class instance).
hdrlen -- length of family specific header (integer).
Returns:
Integer. | 13.422027 | 15.695863 | 0.855131 |
sizeof = libnl.linux_private.netlink.nlmsghdr.SIZEOF
return remaining.value >= sizeof and sizeof <= nlh.nlmsg_len <= remaining.value | def nlmsg_ok(nlh, remaining) | Check if the Netlink message fits into the remaining bytes.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L179
Positional arguments:
nlh -- Netlink message header (nlmsghdr class instance).
remaining -- number of bytes remaining in message stream (c_int).
Returns:
Boolean. | 18.701445 | 16.459316 | 1.136222 |
totlen = libnl.linux_private.netlink.NLMSG_ALIGN(nlh.nlmsg_len)
remaining.value -= totlen
return libnl.linux_private.netlink.nlmsghdr(bytearray_ptr(nlh.bytearray, totlen)) | def nlmsg_next(nlh, remaining) | Next Netlink message in message stream.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L194
Positional arguments:
nlh -- Netlink message header (nlmsghdr class instance).
remaining -- number of bytes remaining in message stream (c_int).
Returns:
The next Netlink message in the me... | 9.61972 | 10.387244 | 0.926109 |
if not nlmsg_valid_hdr(nlh, hdrlen):
return -NLE_MSG_TOOSHORT
return nla_parse(tb, maxtype, nlmsg_attrdata(nlh, hdrlen), nlmsg_attrlen(nlh, hdrlen), policy) | def nlmsg_parse(nlh, hdrlen, tb, maxtype, policy) | Parse attributes of a Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L213
Positional arguments:
nlh -- Netlink message header (nlmsghdr class instance).
hdrlen -- length of family specific header (integer).
tb -- dictionary of nlattr instances (length of maxtype+1).
... | 5.679036 | 6.398483 | 0.88756 |
return nla_find(nlmsg_attrdata(nlh, hdrlen), nlmsg_attrlen(nlh, hdrlen), attrtype) | def nlmsg_find_attr(nlh, hdrlen, attrtype) | Find a specific attribute in a Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L231
Positional arguments:
nlh -- Netlink message header (nlmsghdr class instance).
hdrlen -- length of family specific header (integer).
attrtype -- type of attribute to look for (integer).... | 5.279591 | 6.361572 | 0.829919 |
len_ = max(libnl.linux_private.netlink.nlmsghdr.SIZEOF, len_)
nm = nl_msg()
nm.nm_refcnt = 1
nm.nm_nlh = libnl.linux_private.netlink.nlmsghdr(bytearray(b'\0') * len_)
nm.nm_protocol = -1
nm.nm_size = len_
nm.nm_nlh.nlmsg_len = nlmsg_total_size(0)
_LOGGER.debug('msg 0x%x: Allocated n... | def nlmsg_alloc(len_=default_msg_size) | Allocate a new Netlink message with maximum payload size specified.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L299
Allocates a new Netlink message without any further payload. The maximum payload size defaults to
resource.getpagesize() or as otherwise specified with nlmsg_set_default_siz... | 6.817915 | 6.640829 | 1.026666 |
nm = nlmsg_alloc()
if hdr:
new = nm.nm_nlh
new.nlmsg_type = hdr.nlmsg_type
new.nlmsg_flags = hdr.nlmsg_flags
new.nlmsg_seq = hdr.nlmsg_seq
new.nlmsg_pid = hdr.nlmsg_pid
return nm | def nlmsg_inherit(hdr=None) | Allocate a new Netlink message and inherit Netlink message header.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L322
Allocates a new Netlink message and inherits the original message header. If `hdr` is not None it will be used as a
template for the Netlink message header, otherwise the hea... | 3.399071 | 3.673533 | 0.925287 |
nlh = libnl.linux_private.netlink.nlmsghdr(nlmsg_type=nlmsgtype, nlmsg_flags=flags)
msg = nlmsg_inherit(nlh)
_LOGGER.debug('msg 0x%x: Allocated new simple message', id(msg))
return msg | def nlmsg_alloc_simple(nlmsgtype, flags) | Allocate a new Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L346
Positional arguments:
nlmsgtype -- Netlink message type (integer).
flags -- message flags (integer).
Returns:
Newly allocated Netlink message (nl_msg class instance) or None. | 8.658746 | 10.648278 | 0.813159 |
nm = nlmsg_alloc(hdr.nlmsg_len)
if not nm:
return None
nm.nm_nlh.bytearray = hdr.bytearray.copy()[:hdr.nlmsg_len]
return nm | def nlmsg_convert(hdr) | Convert a Netlink message received from a Netlink socket to an nl_msg.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L382
Allocates a new Netlink message and copies all of the data in `hdr` into the new message object.
Positional arguments:
hdr -- Netlink message received from netlink s... | 7.443821 | 7.779141 | 0.956895 |
nlmsg_len_ = n.nm_nlh.nlmsg_len
tlen = len_ if not pad else ((len_ + (pad - 1)) & ~(pad - 1))
if tlen + nlmsg_len_ > n.nm_size:
return None
buf = bytearray_ptr(n.nm_nlh.bytearray, nlmsg_len_)
n.nm_nlh.nlmsg_len += tlen
if tlen > len_:
bytearray_ptr(buf, len_, tlen)[:] = by... | def nlmsg_reserve(n, len_, pad) | Reserve room for additional data in a Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L407
Reserves room for additional data at the tail of the an existing netlink message. Eventual padding required will be
zeroed out.
bytearray_ptr() at the start of additional data or No... | 4.367834 | 4.145899 | 1.053531 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.