repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Robpol86/libnl | libnl/genl/ctrl.py | genl_ctrl_resolve_grp | 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 Ne... | python | 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 Ne... | [
"def",
"genl_ctrl_resolve_grp",
"(",
"sk",
",",
"family_name",
",",
"grp_name",
")",
":",
"family",
"=",
"genl_ctrl_probe_by_name",
"(",
"sk",
",",
"family_name",
")",
"if",
"family",
"is",
"None",
":",
"return",
"-",
"NLE_OBJ_NOTFOUND",
"return",
"genl_ctrl_grp... | 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... | [
"Resolve",
"Generic",
"Netlink",
"family",
"group",
"name",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/genl/ctrl.py#L227-L245 | train | 59,700 |
Robpol86/libnl | setup.py | _safe_read | def _safe_read(path, length):
"""Read file contents."""
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 | python | def _safe_read(path, length):
"""Read file contents."""
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",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"HERE",
",",
"path",
")",
")",
":",
"return",
"''",
"file_handle",
"=",
"codecs",
".",
"open",
"("... | Read file contents. | [
"Read",
"file",
"contents",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/setup.py#L39-L46 | train | 59,701 |
Robpol86/libnl | example_scan_access_points.py | error_handler | def error_handler(_, err, arg):
"""Update the mutable integer `arg` with the error code."""
arg.value = err.error
return libnl.handlers.NL_STOP | python | def error_handler(_, err, arg):
"""Update the mutable integer `arg` with the error code."""
arg.value = err.error
return libnl.handlers.NL_STOP | [
"def",
"error_handler",
"(",
"_",
",",
"err",
",",
"arg",
")",
":",
"arg",
".",
"value",
"=",
"err",
".",
"error",
"return",
"libnl",
".",
"handlers",
".",
"NL_STOP"
] | Update the mutable integer `arg` with the error code. | [
"Update",
"the",
"mutable",
"integer",
"arg",
"with",
"the",
"error",
"code",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/example_scan_access_points.py#L90-L93 | train | 59,702 |
Robpol86/libnl | example_scan_access_points.py | callback_trigger | 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.
R... | python | 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.
R... | [
"def",
"callback_trigger",
"(",
"msg",
",",
"arg",
")",
":",
"gnlh",
"=",
"genlmsghdr",
"(",
"nlmsg_data",
"(",
"nlmsg_hdr",
"(",
"msg",
")",
")",
")",
"if",
"gnlh",
".",
"cmd",
"==",
"nl80211",
".",
"NL80211_CMD_SCAN_ABORTED",
":",
"arg",
".",
"value",
... | 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... | [
"Called",
"when",
"the",
"kernel",
"is",
"done",
"scanning",
".",
"Only",
"signals",
"if",
"it",
"was",
"successful",
"or",
"if",
"it",
"failed",
".",
"No",
"other",
"data",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/example_scan_access_points.py#L102-L118 | train | 59,703 |
Robpol86/libnl | example_scan_access_points.py | callback_dump | 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.
... | python | 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.
... | [
"def",
"callback_dump",
"(",
"msg",
",",
"results",
")",
":",
"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... | 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... | [
"Here",
"is",
"where",
"SSIDs",
"and",
"their",
"data",
"is",
"decoded",
"from",
"the",
"binary",
"data",
"sent",
"by",
"the",
"kernel",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/example_scan_access_points.py#L121-L152 | train | 59,704 |
Robpol86/libnl | example_scan_access_points.py | do_scan_trigger | def do_scan_trigger(sk, if_index, driver_id, mcid):
"""Issue a scan request to the kernel and wait for it to reply with a signal.
This function issues NL80211_CMD_TRIGGER_SCAN which requires root privileges.
The way NL80211 works is first you issue NL80211_CMD_TRIGGER_SCAN and wait for the kernel to signa... | python | def do_scan_trigger(sk, if_index, driver_id, mcid):
"""Issue a scan request to the kernel and wait for it to reply with a signal.
This function issues NL80211_CMD_TRIGGER_SCAN which requires root privileges.
The way NL80211 works is first you issue NL80211_CMD_TRIGGER_SCAN and wait for the kernel to signa... | [
"def",
"do_scan_trigger",
"(",
"sk",
",",
"if_index",
",",
"driver_id",
",",
"mcid",
")",
":",
"# First get the \"scan\" membership group ID and join the socket to the group.",
"_LOGGER",
".",
"debug",
"(",
"'Joining group %d.'",
",",
"mcid",
")",
"ret",
"=",
"nl_socket... | Issue a scan request to the kernel and wait for it to reply with a signal.
This function issues NL80211_CMD_TRIGGER_SCAN which requires root privileges.
The way NL80211 works is first you issue NL80211_CMD_TRIGGER_SCAN and wait for the kernel to signal that the scan is
done. When that signal occurs, data ... | [
"Issue",
"a",
"scan",
"request",
"to",
"the",
"kernel",
"and",
"wait",
"for",
"it",
"to",
"reply",
"with",
"a",
"signal",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/example_scan_access_points.py#L155-L224 | train | 59,705 |
Robpol86/libnl | example_scan_access_points.py | eta_letters | 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.
"""
final_days, final_hours, fin... | python | 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.
"""
final_days, final_hours, fin... | [
"def",
"eta_letters",
"(",
"seconds",
")",
":",
"final_days",
",",
"final_hours",
",",
"final_minutes",
",",
"final_seconds",
"=",
"0",
",",
"0",
",",
"0",
",",
"seconds",
"if",
"final_seconds",
">=",
"86400",
":",
"final_days",
"=",
"int",
"(",
"final_sec... | 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. | [
"Convert",
"seconds",
"remaining",
"into",
"human",
"readable",
"strings",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/example_scan_access_points.py#L257-L286 | train | 59,706 |
Robpol86/libnl | example_scan_access_points.py | print_table | def print_table(data):
"""Print the table of detected SSIDs and their data to screen.
Positional arguments:
data -- list of dictionaries.
"""
table = AsciiTable([COLUMNS])
table.justify_columns[2] = 'right'
table.justify_columns[3] = 'right'
table.justify_columns[4] = 'right'
table_... | python | def print_table(data):
"""Print the table of detected SSIDs and their data to screen.
Positional arguments:
data -- list of dictionaries.
"""
table = AsciiTable([COLUMNS])
table.justify_columns[2] = 'right'
table.justify_columns[3] = 'right'
table.justify_columns[4] = 'right'
table_... | [
"def",
"print_table",
"(",
"data",
")",
":",
"table",
"=",
"AsciiTable",
"(",
"[",
"COLUMNS",
"]",
")",
"table",
".",
"justify_columns",
"[",
"2",
"]",
"=",
"'right'",
"table",
".",
"justify_columns",
"[",
"3",
"]",
"=",
"'right'",
"table",
".",
"justi... | Print the table of detected SSIDs and their data to screen.
Positional arguments:
data -- list of dictionaries. | [
"Print",
"the",
"table",
"of",
"detected",
"SSIDs",
"and",
"their",
"data",
"to",
"screen",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/example_scan_access_points.py#L289-L319 | train | 59,707 |
joeferraro/mm | mm/sforce/base.py | SforceBaseClient.generateObject | def generateObject(self, sObjectType):
'''
Generate a Salesforce object, such as a Lead or Contact
'''
obj = self._sforce.factory.create('ens:sObject')
obj.type = sObjectType
return obj | python | def generateObject(self, sObjectType):
'''
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",
")",
":",
"obj",
"=",
"self",
".",
"_sforce",
".",
"factory",
".",
"create",
"(",
"'ens:sObject'",
")",
"obj",
".",
"type",
"=",
"sObjectType",
"return",
"obj"
] | Generate a Salesforce object, such as a Lead or Contact | [
"Generate",
"a",
"Salesforce",
"object",
"such",
"as",
"a",
"Lead",
"or",
"Contact"
] | 43dce48a2249faab4d872c228ada9fbdbeec147b | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/base.py#L179-L185 | train | 59,708 |
joeferraro/mm | mm/sforce/base.py | SforceBaseClient._marshallSObjects | 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/>
'''
if not isinstance(sObjects, (tuple, l... | python | 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/>
'''
if not isinstance(sObjects, (tuple, l... | [
"def",
"_marshallSObjects",
"(",
"self",
",",
"sObjects",
",",
"tag",
"=",
"'sObjects'",
")",
":",
"if",
"not",
"isinstance",
"(",
"sObjects",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"sObjects",
"=",
"(",
"sObjects",
",",
")",
"if",
"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/> | [
"Marshall",
"generic",
"sObjects",
"into",
"a",
"list",
"of",
"SAX",
"elements"
] | 43dce48a2249faab4d872c228ada9fbdbeec147b | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/base.py#L211-L251 | train | 59,709 |
joeferraro/mm | mm/sforce/base.py | SforceBaseClient._setHeaders | def _setHeaders(self, call = None, **kwargs):
'''
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... | python | def _setHeaders(self, call = None, **kwargs):
'''
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... | [
"def",
"_setHeaders",
"(",
"self",
",",
"call",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# All calls, including utility calls, set the session header",
"headers",
"=",
"{",
"'SessionHeader'",
":",
"self",
".",
"_sessionHeader",
"}",
"if",
"'debug_categories'... | Attach particular SOAP headers to the request depending on the method call made | [
"Attach",
"particular",
"SOAP",
"headers",
"to",
"the",
"request",
"depending",
"on",
"the",
"method",
"call",
"made"
] | 43dce48a2249faab4d872c228ada9fbdbeec147b | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/base.py#L266-L395 | train | 59,710 |
joeferraro/mm | mm/sforce/base.py | SforceBaseClient.invalidateSessions | 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 SESS... | python | 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 SESS... | [
"def",
"invalidateSessions",
"(",
"self",
",",
"sessionIds",
")",
":",
"self",
".",
"_setHeaders",
"(",
"'invalidateSessions'",
")",
"return",
"self",
".",
"_handleResultTyping",
"(",
"self",
".",
"_sforce",
".",
"service",
".",
"invalidateSessions",
"(",
"sessi... | 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 | [
"Invalidate",
"a",
"Salesforce",
"session"
] | 43dce48a2249faab4d872c228ada9fbdbeec147b | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/base.py#L462-L473 | train | 59,711 |
joeferraro/mm | mm/sforce/base.py | SforceBaseClient.query | def query(self, queryString):
'''
Executes a query against the specified object and returns data that matches
the specified criteria.
'''
self._setHeaders('query')
return self._sforce.service.query(queryString) | python | def query(self, queryString):
'''
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",
")",
":",
"self",
".",
"_setHeaders",
"(",
"'query'",
")",
"return",
"self",
".",
"_sforce",
".",
"service",
".",
"query",
"(",
"queryString",
")"
] | Executes a query against the specified object and returns data that matches
the specified criteria. | [
"Executes",
"a",
"query",
"against",
"the",
"specified",
"object",
"and",
"returns",
"data",
"that",
"matches",
"the",
"specified",
"criteria",
"."
] | 43dce48a2249faab4d872c228ada9fbdbeec147b | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/base.py#L523-L529 | train | 59,712 |
joeferraro/mm | mm/sforce/base.py | SforceBaseClient.queryAll | def queryAll(self, queryString):
'''
Retrieves data from specified objects, whether or not they have been deleted.
'''
self._setHeaders('queryAll')
return self._sforce.service.queryAll(queryString) | python | def queryAll(self, queryString):
'''
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",
")",
":",
"self",
".",
"_setHeaders",
"(",
"'queryAll'",
")",
"return",
"self",
".",
"_sforce",
".",
"service",
".",
"queryAll",
"(",
"queryString",
")"
] | Retrieves data from specified objects, whether or not they have been deleted. | [
"Retrieves",
"data",
"from",
"specified",
"objects",
"whether",
"or",
"not",
"they",
"have",
"been",
"deleted",
"."
] | 43dce48a2249faab4d872c228ada9fbdbeec147b | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/base.py#L531-L536 | train | 59,713 |
joeferraro/mm | mm/sforce/base.py | SforceBaseClient.queryMore | def queryMore(self, queryLocator):
'''
Retrieves the next batch of objects from a query.
'''
self._setHeaders('queryMore')
return self._sforce.service.queryMore(queryLocator) | python | def queryMore(self, queryLocator):
'''
Retrieves the next batch of objects from a query.
'''
self._setHeaders('queryMore')
return self._sforce.service.queryMore(queryLocator) | [
"def",
"queryMore",
"(",
"self",
",",
"queryLocator",
")",
":",
"self",
".",
"_setHeaders",
"(",
"'queryMore'",
")",
"return",
"self",
".",
"_sforce",
".",
"service",
".",
"queryMore",
"(",
"queryLocator",
")"
] | Retrieves the next batch of objects from a query. | [
"Retrieves",
"the",
"next",
"batch",
"of",
"objects",
"from",
"a",
"query",
"."
] | 43dce48a2249faab4d872c228ada9fbdbeec147b | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/base.py#L538-L543 | train | 59,714 |
joeferraro/mm | mm/sforce/base.py | SforceBaseClient.resetPassword | def resetPassword(self, userId):
'''
Changes a user's password to a system-generated value.
'''
self._setHeaders('resetPassword')
return self._sforce.service.resetPassword(userId) | python | def resetPassword(self, userId):
'''
Changes a user's password to a system-generated value.
'''
self._setHeaders('resetPassword')
return self._sforce.service.resetPassword(userId) | [
"def",
"resetPassword",
"(",
"self",
",",
"userId",
")",
":",
"self",
".",
"_setHeaders",
"(",
"'resetPassword'",
")",
"return",
"self",
".",
"_sforce",
".",
"service",
".",
"resetPassword",
"(",
"userId",
")"
] | Changes a user's password to a system-generated value. | [
"Changes",
"a",
"user",
"s",
"password",
"to",
"a",
"system",
"-",
"generated",
"value",
"."
] | 43dce48a2249faab4d872c228ada9fbdbeec147b | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/base.py#L592-L597 | train | 59,715 |
joeferraro/mm | mm/sforce/base.py | SforceBaseClient.setPassword | def setPassword(self, userId, password):
'''
Sets the specified user's password to the specified value.
'''
self._setHeaders('setPassword')
return self._sforce.service.setPassword(userId, password) | python | def setPassword(self, userId, password):
'''
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",
")",
":",
"self",
".",
"_setHeaders",
"(",
"'setPassword'",
")",
"return",
"self",
".",
"_sforce",
".",
"service",
".",
"setPassword",
"(",
"userId",
",",
"password",
")"
] | Sets the specified user's password to the specified value. | [
"Sets",
"the",
"specified",
"user",
"s",
"password",
"to",
"the",
"specified",
"value",
"."
] | 43dce48a2249faab4d872c228ada9fbdbeec147b | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/sforce/base.py#L603-L608 | train | 59,716 |
Robpol86/libnl | libnl/cache_mngt.py | nl_msgtype_lookup | 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 c... | python | 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 c... | [
"def",
"nl_msgtype_lookup",
"(",
"ops",
",",
"msgtype",
")",
":",
"for",
"i",
"in",
"ops",
".",
"co_msgtypes",
":",
"if",
"i",
".",
"mt_id",
"==",
"msgtype",
":",
"return",
"i",
"return",
"None"
] | 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... | [
"Lookup",
"message",
"type",
"cache",
"association",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/cache_mngt.py#L77-L94 | train | 59,717 |
Robpol86/libnl | libnl/cache_mngt.py | nl_cache_mngt_register | 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 instanc... | python | 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 instanc... | [
"def",
"nl_cache_mngt_register",
"(",
"ops",
")",
":",
"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",
... | 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 ... | [
"Register",
"a",
"set",
"of",
"cache",
"operations",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/cache_mngt.py#L97-L123 | train | 59,718 |
Robpol86/libnl | libnl/nl.py | nl_connect | 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 so... | python | 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 so... | [
"def",
"nl_connect",
"(",
"sk",
",",
"protocol",
")",
":",
"flags",
"=",
"getattr",
"(",
"socket",
",",
"'SOCK_CLOEXEC'",
",",
"0",
")",
"if",
"sk",
".",
"s_fd",
"!=",
"-",
"1",
":",
"return",
"-",
"NLE_BAD_SOCK",
"try",
":",
"sk",
".",
"socket_insta... | 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... | [
"Create",
"file",
"descriptor",
"and",
"bind",
"socket",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/nl.py#L42-L83 | train | 59,719 |
Robpol86/libnl | libnl/nl.py | nl_complete_msg | 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... | python | 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... | [
"def",
"nl_complete_msg",
"(",
"sk",
",",
"msg",
")",
":",
"nlh",
"=",
"msg",
".",
"nm_nlh",
"if",
"nlh",
".",
"nlmsg_pid",
"==",
"NL_AUTO_PORT",
":",
"nlh",
".",
"nlmsg_pid",
"=",
"nl_socket_get_local_port",
"(",
"sk",
")",
"if",
"nlh",
".",
"nlmsg_seq"... | 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`)... | [
"Finalize",
"Netlink",
"message",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/nl.py#L213-L242 | train | 59,720 |
Robpol86/libnl | libnl/nl.py | nl_send_simple | 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 t... | python | 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 t... | [
"def",
"nl_send_simple",
"(",
"sk",
",",
"type_",
",",
"flags",
",",
"buf",
"=",
"None",
",",
"size",
"=",
"0",
")",
":",
"msg",
"=",
"nlmsg_alloc_simple",
"(",
"type_",
",",
"flags",
")",
"if",
"buf",
"is",
"not",
"None",
"and",
"size",
":",
"err"... | 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()... | [
"Construct",
"and",
"transmit",
"a",
"Netlink",
"message",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/nl.py#L265-L292 | train | 59,721 |
Robpol86/libnl | libnl/nl.py | nl_recv | 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 as... | python | 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 as... | [
"def",
"nl_recv",
"(",
"sk",
",",
"nla",
",",
"buf",
",",
"creds",
"=",
"None",
")",
":",
"flags",
"=",
"0",
"page_size",
"=",
"resource",
".",
"getpagesize",
"(",
")",
"*",
"4",
"if",
"sk",
".",
"s_flags",
"&",
"NL_MSG_PEEK",
":",
"flags",
"|=",
... | 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... | [
"Receive",
"data",
"from",
"Netlink",
"socket",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/nl.py#L295-L376 | train | 59,722 |
Robpol86/libnl | libnl/nl.py | nl_recvmsgs_report | 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 succ... | python | 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 succ... | [
"def",
"nl_recvmsgs_report",
"(",
"sk",
",",
"cb",
")",
":",
"if",
"cb",
".",
"cb_recvmsgs_ow",
":",
"return",
"int",
"(",
"cb",
".",
"cb_recvmsgs_ow",
"(",
"sk",
",",
"cb",
")",
")",
"return",
"int",
"(",
"recvmsgs",
"(",
"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... | [
"Receive",
"a",
"set",
"of",
"messages",
"from",
"a",
"Netlink",
"socket",
"and",
"report",
"parsed",
"messages",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/nl.py#L624-L643 | train | 59,723 |
Robpol86/libnl | libnl/nl.py | nl_recvmsgs | 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 mes... | python | 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 mes... | [
"def",
"nl_recvmsgs",
"(",
"sk",
",",
"cb",
")",
":",
"err",
"=",
"nl_recvmsgs_report",
"(",
"sk",
",",
"cb",
")",
"if",
"err",
">",
"0",
":",
"return",
"0",
"return",
"int",
"(",
"err",
")"
] | 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... | [
"Receive",
"a",
"set",
"of",
"messages",
"from",
"a",
"Netlink",
"socket",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/nl.py#L646-L669 | train | 59,724 |
Robpol86/libnl | libnl/nl.py | nl_wait_for_ack | 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 ... | python | 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 ... | [
"def",
"nl_wait_for_ack",
"(",
"sk",
")",
":",
"cb",
"=",
"nl_cb_clone",
"(",
"sk",
".",
"s_cb",
")",
"nl_cb_set",
"(",
"cb",
",",
"NL_CB_ACK",
",",
"NL_CB_CUSTOM",
",",
"lambda",
"*",
"_",
":",
"NL_STOP",
",",
"None",
")",
"return",
"int",
"(",
"nl_... | 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... | [
"Wait",
"for",
"ACK",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/nl.py#L704-L719 | train | 59,725 |
joeferraro/mm | mm/connection.py | PluginConnection.get_plugin_client_settings | def get_plugin_client_settings(self):
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... | python | def get_plugin_client_settings(self):
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... | [
"def",
"get_plugin_client_settings",
"(",
"self",
")",
":",
"settings",
"=",
"{",
"}",
"user_path",
"=",
"self",
".",
"get_plugin_settings_path",
"(",
"\"User\"",
")",
"def_path",
"=",
"self",
".",
"get_plugin_settings_path",
"(",
"\"MavensMate\"",
")",
"if",
"d... | 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 | [
"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",
... | 43dce48a2249faab4d872c228ada9fbdbeec147b | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/connection.py#L176-L216 | train | 59,726 |
Robpol86/libnl | libnl/msg.py | nlmsg_for_each_attr | 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).
... | python | 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).
... | [
"def",
"nlmsg_for_each_attr",
"(",
"nlh",
",",
"hdrlen",
",",
"rem",
")",
":",
"return",
"nla_for_each_attr",
"(",
"nlmsg_attrdata",
"(",
"nlh",
",",
"hdrlen",
")",
",",
"nlmsg_attrlen",
"(",
"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... | [
"Iterate",
"over",
"a",
"stream",
"of",
"attributes",
"in",
"a",
"message",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L70-L83 | train | 59,727 |
Robpol86/libnl | libnl/msg.py | nlmsg_attrdata | 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 (nlat... | python | 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 (nlat... | [
"def",
"nlmsg_attrdata",
"(",
"nlh",
",",
"hdrlen",
")",
":",
"data",
"=",
"nlmsg_data",
"(",
"nlh",
")",
"return",
"libnl",
".",
"linux_private",
".",
"netlink",
".",
"nlattr",
"(",
"bytearray_ptr",
"(",
"data",
",",
"libnl",
".",
"linux_private",
".",
... | 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... | [
"Head",
"of",
"attributes",
"data",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L86-L99 | train | 59,728 |
Robpol86/libnl | libnl/msg.py | nlmsg_attrlen | 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.
"""
return max(nlmsg_len(nlh)... | python | 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.
"""
return max(nlmsg_len(nlh)... | [
"def",
"nlmsg_attrlen",
"(",
"nlh",
",",
"hdrlen",
")",
":",
"return",
"max",
"(",
"nlmsg_len",
"(",
"nlh",
")",
"-",
"libnl",
".",
"linux_private",
".",
"netlink",
".",
"NLMSG_ALIGN",
"(",
"hdrlen",
")",
",",
"0",
")"
] | 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. | [
"Length",
"of",
"attributes",
"data",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L102-L113 | train | 59,729 |
Robpol86/libnl | libnl/msg.py | nlmsg_ok | 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_i... | python | 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_i... | [
"def",
"nlmsg_ok",
"(",
"nlh",
",",
"remaining",
")",
":",
"sizeof",
"=",
"libnl",
".",
"linux_private",
".",
"netlink",
".",
"nlmsghdr",
".",
"SIZEOF",
"return",
"remaining",
".",
"value",
">=",
"sizeof",
"and",
"sizeof",
"<=",
"nlh",
".",
"nlmsg_len",
... | 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. | [
"Check",
"if",
"the",
"Netlink",
"message",
"fits",
"into",
"the",
"remaining",
"bytes",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L128-L141 | train | 59,730 |
Robpol86/libnl | libnl/msg.py | nlmsg_next | 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:... | python | 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:... | [
"def",
"nlmsg_next",
"(",
"nlh",
",",
"remaining",
")",
":",
"totlen",
"=",
"libnl",
".",
"linux_private",
".",
"netlink",
".",
"NLMSG_ALIGN",
"(",
"nlh",
".",
"nlmsg_len",
")",
"remaining",
".",
"value",
"-=",
"totlen",
"return",
"libnl",
".",
"linux_priv... | 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... | [
"Next",
"Netlink",
"message",
"in",
"message",
"stream",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L144-L158 | train | 59,731 |
Robpol86/libnl | libnl/msg.py | nlmsg_parse | 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 ... | python | 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 ... | [
"def",
"nlmsg_parse",
"(",
"nlh",
",",
"hdrlen",
",",
"tb",
",",
"maxtype",
",",
"policy",
")",
":",
"if",
"not",
"nlmsg_valid_hdr",
"(",
"nlh",
",",
"hdrlen",
")",
":",
"return",
"-",
"NLE_MSG_TOOSHORT",
"return",
"nla_parse",
"(",
"tb",
",",
"maxtype",... | 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).
... | [
"Parse",
"attributes",
"of",
"a",
"Netlink",
"message",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L161-L178 | train | 59,732 |
Robpol86/libnl | libnl/msg.py | nlmsg_find_attr | 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).
a... | python | 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).
a... | [
"def",
"nlmsg_find_attr",
"(",
"nlh",
",",
"hdrlen",
",",
"attrtype",
")",
":",
"return",
"nla_find",
"(",
"nlmsg_attrdata",
"(",
"nlh",
",",
"hdrlen",
")",
",",
"nlmsg_attrlen",
"(",
"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).... | [
"Find",
"a",
"specific",
"attribute",
"in",
"a",
"Netlink",
"message",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L181-L194 | train | 59,733 |
Robpol86/libnl | libnl/msg.py | nlmsg_alloc | 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... | python | 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... | [
"def",
"nlmsg_alloc",
"(",
"len_",
"=",
"default_msg_size",
")",
":",
"len_",
"=",
"max",
"(",
"libnl",
".",
"linux_private",
".",
"netlink",
".",
"nlmsghdr",
".",
"SIZEOF",
",",
"len_",
")",
"nm",
"=",
"nl_msg",
"(",
")",
"nm",
".",
"nm_refcnt",
"=",
... | 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... | [
"Allocate",
"a",
"new",
"Netlink",
"message",
"with",
"maximum",
"payload",
"size",
"specified",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L197-L216 | train | 59,734 |
Robpol86/libnl | libnl/msg.py | nlmsg_inherit | 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 Netli... | python | 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 Netli... | [
"def",
"nlmsg_inherit",
"(",
"hdr",
"=",
"None",
")",
":",
"nm",
"=",
"nlmsg_alloc",
"(",
")",
"if",
"hdr",
":",
"new",
"=",
"nm",
".",
"nm_nlh",
"new",
".",
"nlmsg_type",
"=",
"hdr",
".",
"nlmsg_type",
"new",
".",
"nlmsg_flags",
"=",
"hdr",
".",
"... | 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... | [
"Allocate",
"a",
"new",
"Netlink",
"message",
"and",
"inherit",
"Netlink",
"message",
"header",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L222-L243 | train | 59,735 |
Robpol86/libnl | libnl/msg.py | nlmsg_alloc_simple | 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_m... | python | 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_m... | [
"def",
"nlmsg_alloc_simple",
"(",
"nlmsgtype",
",",
"flags",
")",
":",
"nlh",
"=",
"libnl",
".",
"linux_private",
".",
"netlink",
".",
"nlmsghdr",
"(",
"nlmsg_type",
"=",
"nlmsgtype",
",",
"nlmsg_flags",
"=",
"flags",
")",
"msg",
"=",
"nlmsg_inherit",
"(",
... | 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. | [
"Allocate",
"a",
"new",
"Netlink",
"message",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L246-L261 | train | 59,736 |
Robpol86/libnl | libnl/msg.py | nlmsg_convert | 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 ... | python | 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 ... | [
"def",
"nlmsg_convert",
"(",
"hdr",
")",
":",
"nm",
"=",
"nlmsg_alloc",
"(",
"hdr",
".",
"nlmsg_len",
")",
"if",
"not",
"nm",
":",
"return",
"None",
"nm",
".",
"nm_nlh",
".",
"bytearray",
"=",
"hdr",
".",
"bytearray",
".",
"copy",
"(",
")",
"[",
":... | 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... | [
"Convert",
"a",
"Netlink",
"message",
"received",
"from",
"a",
"Netlink",
"socket",
"to",
"an",
"nl_msg",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L276-L293 | train | 59,737 |
Robpol86/libnl | libnl/msg.py | nlmsg_reserve | 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... | python | 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... | [
"def",
"nlmsg_reserve",
"(",
"n",
",",
"len_",
",",
"pad",
")",
":",
"nlmsg_len_",
"=",
"n",
".",
"nm_nlh",
".",
"nlmsg_len",
"tlen",
"=",
"len_",
"if",
"not",
"pad",
"else",
"(",
"(",
"len_",
"+",
"(",
"pad",
"-",
"1",
")",
")",
"&",
"~",
"(",... | 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... | [
"Reserve",
"room",
"for",
"additional",
"data",
"in",
"a",
"Netlink",
"message",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L296-L318 | train | 59,738 |
Robpol86/libnl | libnl/msg.py | nlmsg_append | def nlmsg_append(n, data, len_, pad):
"""Append data to tail of a Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L442
Extends the Netlink message as needed and appends the data of given length to the message.
Positional arguments:
n -- Netlink message (nl_msg class i... | python | def nlmsg_append(n, data, len_, pad):
"""Append data to tail of a Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L442
Extends the Netlink message as needed and appends the data of given length to the message.
Positional arguments:
n -- Netlink message (nl_msg class i... | [
"def",
"nlmsg_append",
"(",
"n",
",",
"data",
",",
"len_",
",",
"pad",
")",
":",
"tmp",
"=",
"nlmsg_reserve",
"(",
"n",
",",
"len_",
",",
"pad",
")",
"if",
"tmp",
"is",
"None",
":",
"return",
"-",
"NLE_NOMEM",
"tmp",
"[",
":",
"len_",
"]",
"=",
... | Append data to tail of a Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L442
Extends the Netlink message as needed and appends the data of given length to the message.
Positional arguments:
n -- Netlink message (nl_msg class instance).
data -- data to add.
len_ -... | [
"Append",
"data",
"to",
"tail",
"of",
"a",
"Netlink",
"message",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L321-L342 | train | 59,739 |
Robpol86/libnl | libnl/msg.py | nlmsg_put | def nlmsg_put(n, pid, seq, type_, payload, flags):
"""Add a Netlink message header to a Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L503
Adds or overwrites the Netlink message header in an existing message object.
Positional arguments:
n -- Netlink message (nl_msg... | python | def nlmsg_put(n, pid, seq, type_, payload, flags):
"""Add a Netlink message header to a Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L503
Adds or overwrites the Netlink message header in an existing message object.
Positional arguments:
n -- Netlink message (nl_msg... | [
"def",
"nlmsg_put",
"(",
"n",
",",
"pid",
",",
"seq",
",",
"type_",
",",
"payload",
",",
"flags",
")",
":",
"if",
"n",
".",
"nm_nlh",
".",
"nlmsg_len",
"<",
"libnl",
".",
"linux_private",
".",
"netlink",
".",
"NLMSG_HDRLEN",
":",
"raise",
"BUG",
"nlh... | Add a Netlink message header to a Netlink message.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L503
Adds or overwrites the Netlink message header in an existing message object.
Positional arguments:
n -- Netlink message (nl_msg class instance).
pid -- Netlink process id or NL_AUTO... | [
"Add",
"a",
"Netlink",
"message",
"header",
"to",
"a",
"Netlink",
"message",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L345-L377 | train | 59,740 |
Robpol86/libnl | libnl/msg.py | nl_nlmsg_flags2str | def nl_nlmsg_flags2str(flags, buf, _=None):
"""Netlink Message Flags Translations.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L664
Positional arguments:
flags -- integer.
buf -- bytearray().
Keyword arguments:
_ -- unused.
Returns:
Reference to `buf`.
"""
... | python | def nl_nlmsg_flags2str(flags, buf, _=None):
"""Netlink Message Flags Translations.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L664
Positional arguments:
flags -- integer.
buf -- bytearray().
Keyword arguments:
_ -- unused.
Returns:
Reference to `buf`.
"""
... | [
"def",
"nl_nlmsg_flags2str",
"(",
"flags",
",",
"buf",
",",
"_",
"=",
"None",
")",
":",
"del",
"buf",
"[",
":",
"]",
"all_flags",
"=",
"(",
"(",
"'REQUEST'",
",",
"libnl",
".",
"linux_private",
".",
"netlink",
".",
"NLM_F_REQUEST",
")",
",",
"(",
"'M... | Netlink Message Flags Translations.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L664
Positional arguments:
flags -- integer.
buf -- bytearray().
Keyword arguments:
_ -- unused.
Returns:
Reference to `buf`. | [
"Netlink",
"Message",
"Flags",
"Translations",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L445-L483 | train | 59,741 |
Robpol86/libnl | libnl/msg.py | dump_hex | def dump_hex(ofd, start, len_, prefix=0):
"""Convert `start` to hex and logs it, 16 bytes per log statement.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L760
Positional arguments:
ofd -- function to call with arguments similar to `logging.debug`.
start -- bytearray() or bytearray_p... | python | def dump_hex(ofd, start, len_, prefix=0):
"""Convert `start` to hex and logs it, 16 bytes per log statement.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L760
Positional arguments:
ofd -- function to call with arguments similar to `logging.debug`.
start -- bytearray() or bytearray_p... | [
"def",
"dump_hex",
"(",
"ofd",
",",
"start",
",",
"len_",
",",
"prefix",
"=",
"0",
")",
":",
"prefix_whitespaces",
"=",
"' '",
"*",
"prefix",
"limit",
"=",
"16",
"-",
"(",
"prefix",
"*",
"2",
")",
"start_",
"=",
"start",
"[",
":",
"len_",
"]",
"... | Convert `start` to hex and logs it, 16 bytes per log statement.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L760
Positional arguments:
ofd -- function to call with arguments similar to `logging.debug`.
start -- bytearray() or bytearray_ptr() instance.
len_ -- size of `start` (integ... | [
"Convert",
"start",
"to",
"hex",
"and",
"logs",
"it",
"16",
"bytes",
"per",
"log",
"statement",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L486-L510 | train | 59,742 |
Robpol86/libnl | libnl/msg.py | nl_msg_dump | def nl_msg_dump(msg, ofd=_LOGGER.debug):
"""Dump message in human readable format to callable.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L970
Positional arguments:
msg -- message to print (nl_msg class instance).
Keyword arguments:
ofd -- function to call with arguments simi... | python | def nl_msg_dump(msg, ofd=_LOGGER.debug):
"""Dump message in human readable format to callable.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L970
Positional arguments:
msg -- message to print (nl_msg class instance).
Keyword arguments:
ofd -- function to call with arguments simi... | [
"def",
"nl_msg_dump",
"(",
"msg",
",",
"ofd",
"=",
"_LOGGER",
".",
"debug",
")",
":",
"hdr",
"=",
"nlmsg_hdr",
"(",
"msg",
")",
"ofd",
"(",
"'-------------------------- BEGIN NETLINK MESSAGE ---------------------------'",
")",
"ofd",
"(",
"' [NETLINK HEADER] %d oct... | Dump message in human readable format to callable.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L970
Positional arguments:
msg -- message to print (nl_msg class instance).
Keyword arguments:
ofd -- function to call with arguments similar to `logging.debug`. | [
"Dump",
"message",
"in",
"human",
"readable",
"format",
"to",
"callable",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/msg.py#L683-L706 | train | 59,743 |
Robpol86/libnl | libnl/object.py | nl_object_alloc | def nl_object_alloc(ops):
"""Allocate a new object of kind specified by the operations handle.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/object.c#L54
Positional arguments:
ops -- cache operations handle (nl_object_ops class instance).
Returns:
New nl_object class instance or None.... | python | def nl_object_alloc(ops):
"""Allocate a new object of kind specified by the operations handle.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/object.c#L54
Positional arguments:
ops -- cache operations handle (nl_object_ops class instance).
Returns:
New nl_object class instance or None.... | [
"def",
"nl_object_alloc",
"(",
"ops",
")",
":",
"new",
"=",
"nl_object",
"(",
")",
"nl_init_list_head",
"(",
"new",
".",
"ce_list",
")",
"new",
".",
"ce_ops",
"=",
"ops",
"if",
"ops",
".",
"oo_constructor",
":",
"ops",
".",
"oo_constructor",
"(",
"new",
... | Allocate a new object of kind specified by the operations handle.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/object.c#L54
Positional arguments:
ops -- cache operations handle (nl_object_ops class instance).
Returns:
New nl_object class instance or None. | [
"Allocate",
"a",
"new",
"object",
"of",
"kind",
"specified",
"by",
"the",
"operations",
"handle",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/object.py#L19-L36 | train | 59,744 |
Robpol86/libnl | libnl/genl/mngt.py | genl_register_family | def genl_register_family(ops):
"""Register Generic Netlink family and associated commands.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/mngt.c#L164
Registers the specified Generic Netlink family definition together with all associated commands. After registration,
received Generic Netlin... | python | def genl_register_family(ops):
"""Register Generic Netlink family and associated commands.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/mngt.c#L164
Registers the specified Generic Netlink family definition together with all associated commands. After registration,
received Generic Netlin... | [
"def",
"genl_register_family",
"(",
"ops",
")",
":",
"if",
"not",
"ops",
".",
"o_name",
"or",
"(",
"ops",
".",
"o_cmds",
"and",
"ops",
".",
"o_ncmds",
"<=",
"0",
")",
":",
"return",
"-",
"NLE_INVAL",
"if",
"ops",
".",
"o_id",
"and",
"lookup_family",
... | Register Generic Netlink family and associated commands.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/mngt.c#L164
Registers the specified Generic Netlink family definition together with all associated commands. After registration,
received Generic Netlink messages can be passed to genl_handl... | [
"Register",
"Generic",
"Netlink",
"family",
"and",
"associated",
"commands",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/genl/mngt.py#L206-L232 | train | 59,745 |
Robpol86/libnl | libnl/genl/mngt.py | genl_register | def genl_register(ops):
"""Register Generic Netlink family backed cache.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/mngt.c#L241
Same as genl_register_family() but additionally registers the specified cache operations using
nl_cache_mngt_register() and associates it with the Generic Net... | python | def genl_register(ops):
"""Register Generic Netlink family backed cache.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/mngt.c#L241
Same as genl_register_family() but additionally registers the specified cache operations using
nl_cache_mngt_register() and associates it with the Generic Net... | [
"def",
"genl_register",
"(",
"ops",
")",
":",
"if",
"ops",
".",
"co_protocol",
"!=",
"NETLINK_GENERIC",
":",
"return",
"-",
"NLE_PROTO_MISMATCH",
"if",
"ops",
".",
"co_hdrsize",
"<",
"GENL_HDRSIZE",
"(",
"0",
")",
":",
"return",
"-",
"NLE_INVAL",
"if",
"op... | Register Generic Netlink family backed cache.
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/genl/mngt.c#L241
Same as genl_register_family() but additionally registers the specified cache operations using
nl_cache_mngt_register() and associates it with the Generic Netlink family.
Positional ar... | [
"Register",
"Generic",
"Netlink",
"family",
"backed",
"cache",
"."
] | 274e9fdaa39822d06ef70b799ed4a95937a4d923 | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/genl/mngt.py#L235-L265 | train | 59,746 |
joeferraro/mm | mm/request.py | MavensMateRequestHandler.__setup_connection | def __setup_connection(self):
"""
each operation requested represents a session
the session holds information about the plugin running it
and establishes a project object
"""
if self.payload != None and type(self.payload) is dict and 'settings' in ... | python | def __setup_connection(self):
"""
each operation requested represents a session
the session holds information about the plugin running it
and establishes a project object
"""
if self.payload != None and type(self.payload) is dict and 'settings' in ... | [
"def",
"__setup_connection",
"(",
"self",
")",
":",
"if",
"self",
".",
"payload",
"!=",
"None",
"and",
"type",
"(",
"self",
".",
"payload",
")",
"is",
"dict",
"and",
"'settings'",
"in",
"self",
".",
"payload",
":",
"config",
".",
"plugin_client_settings",
... | each operation requested represents a session
the session holds information about the plugin running it
and establishes a project object | [
"each",
"operation",
"requested",
"represents",
"a",
"session",
"the",
"session",
"holds",
"information",
"about",
"the",
"plugin",
"running",
"it",
"and",
"establishes",
"a",
"project",
"object"
] | 43dce48a2249faab4d872c228ada9fbdbeec147b | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/request.py#L45-L62 | train | 59,747 |
joeferraro/mm | mm/request.py | MavensMateRequestHandler.execute | def execute(self):
"""
Executes requested command
"""
try:
self.__setup_connection()
#if the arg switch argument is included, the request is to launch the out of box
#MavensMate UI, so we generate the HTML for the UI and launch the process
... | python | def execute(self):
"""
Executes requested command
"""
try:
self.__setup_connection()
#if the arg switch argument is included, the request is to launch the out of box
#MavensMate UI, so we generate the HTML for the UI and launch the process
... | [
"def",
"execute",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"__setup_connection",
"(",
")",
"#if the arg switch argument is included, the request is to launch the out of box",
"#MavensMate UI, so we generate the HTML for the UI and launch the process",
"#example: mm -o new_projec... | Executes requested command | [
"Executes",
"requested",
"command"
] | 43dce48a2249faab4d872c228ada9fbdbeec147b | https://github.com/joeferraro/mm/blob/43dce48a2249faab4d872c228ada9fbdbeec147b/mm/request.py#L64-L95 | train | 59,748 |
dvdme/forecastiopy | forecastiopy/FIOAlerts.py | FIOAlerts.get_alert | def get_alert(self, alert):
"""
Recieves a day as an argument and returns the prediction for that alert
if is available. If not, function will return None.
"""
if alert > self.alerts_count() or self.alerts_count() is None:
return None
else:
return ... | python | def get_alert(self, alert):
"""
Recieves a day as an argument and returns the prediction for that alert
if is available. If not, function will return None.
"""
if alert > self.alerts_count() or self.alerts_count() is None:
return None
else:
return ... | [
"def",
"get_alert",
"(",
"self",
",",
"alert",
")",
":",
"if",
"alert",
">",
"self",
".",
"alerts_count",
"(",
")",
"or",
"self",
".",
"alerts_count",
"(",
")",
"is",
"None",
":",
"return",
"None",
"else",
":",
"return",
"self",
".",
"get",
"(",
")... | Recieves a day as an argument and returns the prediction for that alert
if is available. If not, function will return None. | [
"Recieves",
"a",
"day",
"as",
"an",
"argument",
"and",
"returns",
"the",
"prediction",
"for",
"that",
"alert",
"if",
"is",
"available",
".",
"If",
"not",
"function",
"will",
"return",
"None",
"."
] | 3cc81a078da655369b8ba3ac416f8b58f7293b4e | https://github.com/dvdme/forecastiopy/blob/3cc81a078da655369b8ba3ac416f8b58f7293b4e/forecastiopy/FIOAlerts.py#L36-L44 | train | 59,749 |
dvdme/forecastiopy | forecastiopy/ForecastIO.py | ForecastIO.get_forecast | def get_forecast(self, latitude, longitude):
"""
Gets the weather data from darksky api and stores it in
the respective dictionaries if available.
This function should be used to fetch weather information.
"""
reply = self.http_get(self.url_builder(latitude, longitude))
... | python | def get_forecast(self, latitude, longitude):
"""
Gets the weather data from darksky api and stores it in
the respective dictionaries if available.
This function should be used to fetch weather information.
"""
reply = self.http_get(self.url_builder(latitude, longitude))
... | [
"def",
"get_forecast",
"(",
"self",
",",
"latitude",
",",
"longitude",
")",
":",
"reply",
"=",
"self",
".",
"http_get",
"(",
"self",
".",
"url_builder",
"(",
"latitude",
",",
"longitude",
")",
")",
"self",
".",
"forecast",
"=",
"json",
".",
"loads",
"(... | Gets the weather data from darksky api and stores it in
the respective dictionaries if available.
This function should be used to fetch weather information. | [
"Gets",
"the",
"weather",
"data",
"from",
"darksky",
"api",
"and",
"stores",
"it",
"in",
"the",
"respective",
"dictionaries",
"if",
"available",
".",
"This",
"function",
"should",
"be",
"used",
"to",
"fetch",
"weather",
"information",
"."
] | 3cc81a078da655369b8ba3ac416f8b58f7293b4e | https://github.com/dvdme/forecastiopy/blob/3cc81a078da655369b8ba3ac416f8b58f7293b4e/forecastiopy/ForecastIO.py#L88-L98 | train | 59,750 |
dvdme/forecastiopy | forecastiopy/ForecastIO.py | ForecastIO.get_forecast_fromstr | def get_forecast_fromstr(self, reply):
"""
Gets the weather data from a darksky api response string
and stores it in the respective dictionaries if available.
This function should be used to fetch weather information.
"""
self.forecast = json.loads(reply)
for ite... | python | def get_forecast_fromstr(self, reply):
"""
Gets the weather data from a darksky api response string
and stores it in the respective dictionaries if available.
This function should be used to fetch weather information.
"""
self.forecast = json.loads(reply)
for ite... | [
"def",
"get_forecast_fromstr",
"(",
"self",
",",
"reply",
")",
":",
"self",
".",
"forecast",
"=",
"json",
".",
"loads",
"(",
"reply",
")",
"for",
"item",
"in",
"self",
".",
"forecast",
".",
"keys",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"item",
... | Gets the weather data from a darksky api response string
and stores it in the respective dictionaries if available.
This function should be used to fetch weather information. | [
"Gets",
"the",
"weather",
"data",
"from",
"a",
"darksky",
"api",
"response",
"string",
"and",
"stores",
"it",
"in",
"the",
"respective",
"dictionaries",
"if",
"available",
".",
"This",
"function",
"should",
"be",
"used",
"to",
"fetch",
"weather",
"information"... | 3cc81a078da655369b8ba3ac416f8b58f7293b4e | https://github.com/dvdme/forecastiopy/blob/3cc81a078da655369b8ba3ac416f8b58f7293b4e/forecastiopy/ForecastIO.py#L100-L109 | train | 59,751 |
dvdme/forecastiopy | forecastiopy/ForecastIO.py | ForecastIO.url_builder | def url_builder(self, latitude, longitude):
"""
This function is used to build the correct url to make the request
to the forecast.io api.
Recieves the latitude and the longitude.
Return a string with the url.
"""
try:
float(latitude)
float... | python | def url_builder(self, latitude, longitude):
"""
This function is used to build the correct url to make the request
to the forecast.io api.
Recieves the latitude and the longitude.
Return a string with the url.
"""
try:
float(latitude)
float... | [
"def",
"url_builder",
"(",
"self",
",",
"latitude",
",",
"longitude",
")",
":",
"try",
":",
"float",
"(",
"latitude",
")",
"float",
"(",
"longitude",
")",
"except",
"TypeError",
":",
"raise",
"TypeError",
"(",
"'Latitude (%s) and Longitude (%s) must be a float num... | This function is used to build the correct url to make the request
to the forecast.io api.
Recieves the latitude and the longitude.
Return a string with the url. | [
"This",
"function",
"is",
"used",
"to",
"build",
"the",
"correct",
"url",
"to",
"make",
"the",
"request",
"to",
"the",
"forecast",
".",
"io",
"api",
".",
"Recieves",
"the",
"latitude",
"and",
"the",
"longitude",
".",
"Return",
"a",
"string",
"with",
"the... | 3cc81a078da655369b8ba3ac416f8b58f7293b4e | https://github.com/dvdme/forecastiopy/blob/3cc81a078da655369b8ba3ac416f8b58f7293b4e/forecastiopy/ForecastIO.py#L111-L149 | train | 59,752 |
dvdme/forecastiopy | forecastiopy/ForecastIO.py | ForecastIO.http_get | def http_get(self, request_url):
"""
This function recieves the request url and it is used internally to get
the information via http.
Returns the response content.
Raises Timeout, TooManyRedirects, RequestException.
Raises KeyError if headers are not present.
Rai... | python | def http_get(self, request_url):
"""
This function recieves the request url and it is used internally to get
the information via http.
Returns the response content.
Raises Timeout, TooManyRedirects, RequestException.
Raises KeyError if headers are not present.
Rai... | [
"def",
"http_get",
"(",
"self",
",",
"request_url",
")",
":",
"try",
":",
"headers",
"=",
"{",
"'Accept-Encoding'",
":",
"'gzip, deflate'",
"}",
"response",
"=",
"requests",
".",
"get",
"(",
"request_url",
",",
"headers",
"=",
"headers",
")",
"except",
"re... | This function recieves the request url and it is used internally to get
the information via http.
Returns the response content.
Raises Timeout, TooManyRedirects, RequestException.
Raises KeyError if headers are not present.
Raises HTTPError if responde code is not 200. | [
"This",
"function",
"recieves",
"the",
"request",
"url",
"and",
"it",
"is",
"used",
"internally",
"to",
"get",
"the",
"information",
"via",
"http",
".",
"Returns",
"the",
"response",
"content",
".",
"Raises",
"Timeout",
"TooManyRedirects",
"RequestException",
".... | 3cc81a078da655369b8ba3ac416f8b58f7293b4e | https://github.com/dvdme/forecastiopy/blob/3cc81a078da655369b8ba3ac416f8b58f7293b4e/forecastiopy/ForecastIO.py#L160-L205 | train | 59,753 |
zeehio/parmap | parmap/parmap.py | _map_or_starmap | def _map_or_starmap(function, iterable, args, kwargs, map_or_starmap):
"""
Shared function between parmap.map and parmap.starmap.
Refer to those functions for details.
"""
arg_newarg = (("parallel", "pm_parallel"), ("chunksize", "pm_chunksize"),
("pool", "pm_pool"), ("processes", "... | python | def _map_or_starmap(function, iterable, args, kwargs, map_or_starmap):
"""
Shared function between parmap.map and parmap.starmap.
Refer to those functions for details.
"""
arg_newarg = (("parallel", "pm_parallel"), ("chunksize", "pm_chunksize"),
("pool", "pm_pool"), ("processes", "... | [
"def",
"_map_or_starmap",
"(",
"function",
",",
"iterable",
",",
"args",
",",
"kwargs",
",",
"map_or_starmap",
")",
":",
"arg_newarg",
"=",
"(",
"(",
"\"parallel\"",
",",
"\"pm_parallel\"",
")",
",",
"(",
"\"chunksize\"",
",",
"\"pm_chunksize\"",
")",
",",
"... | Shared function between parmap.map and parmap.starmap.
Refer to those functions for details. | [
"Shared",
"function",
"between",
"parmap",
".",
"map",
"and",
"parmap",
".",
"starmap",
".",
"Refer",
"to",
"those",
"functions",
"for",
"details",
"."
] | 368b77e1a49ff30aef9de2274ad430ad43a3f617 | https://github.com/zeehio/parmap/blob/368b77e1a49ff30aef9de2274ad430ad43a3f617/parmap/parmap.py#L220-L273 | train | 59,754 |
zeehio/parmap | parmap/parmap.py | _map_or_starmap_async | def _map_or_starmap_async(function, iterable, args, kwargs, map_or_starmap):
"""
Shared function between parmap.map_async and parmap.starmap_async.
Refer to those functions for details.
"""
arg_newarg = (("parallel", "pm_parallel"), ("chunksize", "pm_chunksize"),
("pool", "pm_pool"... | python | def _map_or_starmap_async(function, iterable, args, kwargs, map_or_starmap):
"""
Shared function between parmap.map_async and parmap.starmap_async.
Refer to those functions for details.
"""
arg_newarg = (("parallel", "pm_parallel"), ("chunksize", "pm_chunksize"),
("pool", "pm_pool"... | [
"def",
"_map_or_starmap_async",
"(",
"function",
",",
"iterable",
",",
"args",
",",
"kwargs",
",",
"map_or_starmap",
")",
":",
"arg_newarg",
"=",
"(",
"(",
"\"parallel\"",
",",
"\"pm_parallel\"",
")",
",",
"(",
"\"chunksize\"",
",",
"\"pm_chunksize\"",
")",
",... | Shared function between parmap.map_async and parmap.starmap_async.
Refer to those functions for details. | [
"Shared",
"function",
"between",
"parmap",
".",
"map_async",
"and",
"parmap",
".",
"starmap_async",
".",
"Refer",
"to",
"those",
"functions",
"for",
"details",
"."
] | 368b77e1a49ff30aef9de2274ad430ad43a3f617 | https://github.com/zeehio/parmap/blob/368b77e1a49ff30aef9de2274ad430ad43a3f617/parmap/parmap.py#L386-L428 | train | 59,755 |
zeehio/parmap | parmap/parmap.py | map_async | def map_async(function, iterable, *args, **kwargs):
"""This function is the multiprocessing.Pool.map_async version that
supports multiple arguments.
>>> [function(x, args[0], args[1],...) for x in iterable]
:param pm_parallel: Force parallelization on/off. If False, the
... | python | def map_async(function, iterable, *args, **kwargs):
"""This function is the multiprocessing.Pool.map_async version that
supports multiple arguments.
>>> [function(x, args[0], args[1],...) for x in iterable]
:param pm_parallel: Force parallelization on/off. If False, the
... | [
"def",
"map_async",
"(",
"function",
",",
"iterable",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_map_or_starmap_async",
"(",
"function",
",",
"iterable",
",",
"args",
",",
"kwargs",
",",
"\"map\"",
")"
] | This function is the multiprocessing.Pool.map_async version that
supports multiple arguments.
>>> [function(x, args[0], args[1],...) for x in iterable]
:param pm_parallel: Force parallelization on/off. If False, the
function won't be asynchronous.
:type pm_paral... | [
"This",
"function",
"is",
"the",
"multiprocessing",
".",
"Pool",
".",
"map_async",
"version",
"that",
"supports",
"multiple",
"arguments",
"."
] | 368b77e1a49ff30aef9de2274ad430ad43a3f617 | https://github.com/zeehio/parmap/blob/368b77e1a49ff30aef9de2274ad430ad43a3f617/parmap/parmap.py#L431-L453 | train | 59,756 |
zeehio/parmap | parmap/parmap.py | starmap_async | def starmap_async(function, iterables, *args, **kwargs):
"""This function is the multiprocessing.Pool.starmap_async version that
supports multiple arguments.
>>> return ([function(x1,x2,x3,..., args[0], args[1],...) for
>>> (x1,x2,x3...) in iterable])
:param pm_parall... | python | def starmap_async(function, iterables, *args, **kwargs):
"""This function is the multiprocessing.Pool.starmap_async version that
supports multiple arguments.
>>> return ([function(x1,x2,x3,..., args[0], args[1],...) for
>>> (x1,x2,x3...) in iterable])
:param pm_parall... | [
"def",
"starmap_async",
"(",
"function",
",",
"iterables",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_map_or_starmap_async",
"(",
"function",
",",
"iterables",
",",
"args",
",",
"kwargs",
",",
"\"starmap\"",
")"
] | This function is the multiprocessing.Pool.starmap_async version that
supports multiple arguments.
>>> return ([function(x1,x2,x3,..., args[0], args[1],...) for
>>> (x1,x2,x3...) in iterable])
:param pm_parallel: Force parallelization on/off. If False, the
... | [
"This",
"function",
"is",
"the",
"multiprocessing",
".",
"Pool",
".",
"starmap_async",
"version",
"that",
"supports",
"multiple",
"arguments",
"."
] | 368b77e1a49ff30aef9de2274ad430ad43a3f617 | https://github.com/zeehio/parmap/blob/368b77e1a49ff30aef9de2274ad430ad43a3f617/parmap/parmap.py#L456-L478 | train | 59,757 |
iclab/centinel | centinel/primitives/dnslib.py | lookup_domain | def lookup_domain(domain, nameservers=[], rtype="A",
exclude_nameservers=[], timeout=2):
"""Wrapper for DNSQuery method"""
dns_exp = DNSQuery(domains=[domain], nameservers=nameservers, rtype=rtype,
exclude_nameservers=exclude_nameservers, timeout=timeout)
return dns_... | python | def lookup_domain(domain, nameservers=[], rtype="A",
exclude_nameservers=[], timeout=2):
"""Wrapper for DNSQuery method"""
dns_exp = DNSQuery(domains=[domain], nameservers=nameservers, rtype=rtype,
exclude_nameservers=exclude_nameservers, timeout=timeout)
return dns_... | [
"def",
"lookup_domain",
"(",
"domain",
",",
"nameservers",
"=",
"[",
"]",
",",
"rtype",
"=",
"\"A\"",
",",
"exclude_nameservers",
"=",
"[",
"]",
",",
"timeout",
"=",
"2",
")",
":",
"dns_exp",
"=",
"DNSQuery",
"(",
"domains",
"=",
"[",
"domain",
"]",
... | Wrapper for DNSQuery method | [
"Wrapper",
"for",
"DNSQuery",
"method"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/primitives/dnslib.py#L21-L26 | train | 59,758 |
iclab/centinel | centinel/primitives/dnslib.py | parse_out_ips | def parse_out_ips(message):
"""Given a message, parse out the ips in the answer"""
ips = []
for entry in message.answer:
for rdata in entry.items:
ips.append(rdata.to_text())
return ips | python | def parse_out_ips(message):
"""Given a message, parse out the ips in the answer"""
ips = []
for entry in message.answer:
for rdata in entry.items:
ips.append(rdata.to_text())
return ips | [
"def",
"parse_out_ips",
"(",
"message",
")",
":",
"ips",
"=",
"[",
"]",
"for",
"entry",
"in",
"message",
".",
"answer",
":",
"for",
"rdata",
"in",
"entry",
".",
"items",
":",
"ips",
".",
"append",
"(",
"rdata",
".",
"to_text",
"(",
")",
")",
"retur... | Given a message, parse out the ips in the answer | [
"Given",
"a",
"message",
"parse",
"out",
"the",
"ips",
"in",
"the",
"answer"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/primitives/dnslib.py#L264-L271 | train | 59,759 |
iclab/centinel | centinel/primitives/dnslib.py | DNSQuery.send_chaos_queries | def send_chaos_queries(self):
"""Send chaos queries to identify the DNS server and its manufacturer
Note: we send 2 queries for BIND stuff per RFC 4892 and 1
query per RFC 6304
Note: we are not waiting on a second response because we
shouldn't be getting injected packets here
... | python | def send_chaos_queries(self):
"""Send chaos queries to identify the DNS server and its manufacturer
Note: we send 2 queries for BIND stuff per RFC 4892 and 1
query per RFC 6304
Note: we are not waiting on a second response because we
shouldn't be getting injected packets here
... | [
"def",
"send_chaos_queries",
"(",
"self",
")",
":",
"names",
"=",
"[",
"\"HOSTNAME.BIND\"",
",",
"\"VERSION.BIND\"",
",",
"\"ID.SERVER\"",
"]",
"self",
".",
"results",
"=",
"{",
"'exp-name'",
":",
"\"chaos-queries\"",
"}",
"for",
"name",
"in",
"names",
":",
... | Send chaos queries to identify the DNS server and its manufacturer
Note: we send 2 queries for BIND stuff per RFC 4892 and 1
query per RFC 6304
Note: we are not waiting on a second response because we
shouldn't be getting injected packets here | [
"Send",
"chaos",
"queries",
"to",
"identify",
"the",
"DNS",
"server",
"and",
"its",
"manufacturer"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/primitives/dnslib.py#L77-L105 | train | 59,760 |
iclab/centinel | centinel/primitives/dnslib.py | DNSQuery.lookup_domains | def lookup_domains(self):
"""More complex DNS primitive that looks up domains concurrently
Note: if you want to lookup multiple domains, you should use
this function
"""
thread_error = False
thread_wait_timeout = 200
ind = 1
total_item_count = len(self.do... | python | def lookup_domains(self):
"""More complex DNS primitive that looks up domains concurrently
Note: if you want to lookup multiple domains, you should use
this function
"""
thread_error = False
thread_wait_timeout = 200
ind = 1
total_item_count = len(self.do... | [
"def",
"lookup_domains",
"(",
"self",
")",
":",
"thread_error",
"=",
"False",
"thread_wait_timeout",
"=",
"200",
"ind",
"=",
"1",
"total_item_count",
"=",
"len",
"(",
"self",
".",
"domains",
")",
"for",
"domain",
"in",
"self",
".",
"domains",
":",
"for",
... | More complex DNS primitive that looks up domains concurrently
Note: if you want to lookup multiple domains, you should use
this function | [
"More",
"complex",
"DNS",
"primitive",
"that",
"looks",
"up",
"domains",
"concurrently"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/primitives/dnslib.py#L107-L157 | train | 59,761 |
iclab/centinel | centinel/command.py | Command.start | def start(self, timeout=None):
"""Start running the command"""
self.thread.start()
start_time = time.time()
if not timeout:
timeout = self.timeout
# every second, check the condition of the thread and return
# control to the user if appropriate
while ... | python | def start(self, timeout=None):
"""Start running the command"""
self.thread.start()
start_time = time.time()
if not timeout:
timeout = self.timeout
# every second, check the condition of the thread and return
# control to the user if appropriate
while ... | [
"def",
"start",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"thread",
".",
"start",
"(",
")",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"if",
"not",
"timeout",
":",
"timeout",
"=",
"self",
".",
"timeout",
"# every second,... | Start running the command | [
"Start",
"running",
"the",
"command"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/command.py#L49-L64 | train | 59,762 |
iclab/centinel | centinel/command.py | Command.stop | def stop(self, timeout=None):
"""Stop the given command"""
if not timeout:
timeout = self.timeout
self.kill_switch()
# Send the signal to all the process groups
self.process.kill()
self.thread.join(timeout)
try:
os.killpg(os.getpgid(self.p... | python | def stop(self, timeout=None):
"""Stop the given command"""
if not timeout:
timeout = self.timeout
self.kill_switch()
# Send the signal to all the process groups
self.process.kill()
self.thread.join(timeout)
try:
os.killpg(os.getpgid(self.p... | [
"def",
"stop",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"not",
"timeout",
":",
"timeout",
"=",
"self",
".",
"timeout",
"self",
".",
"kill_switch",
"(",
")",
"# Send the signal to all the process groups",
"self",
".",
"process",
".",
"kill",
... | Stop the given command | [
"Stop",
"the",
"given",
"command"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/command.py#L66-L82 | train | 59,763 |
iclab/centinel | centinel/primitives/traceroute.py | traceroute_batch | def traceroute_batch(input_list, results={}, method="udp", cmd_arguments=None,
delay_time=0.1, max_threads=100):
"""
This is a parallel version of the traceroute primitive.
:param input_list: the input is a list of domain names
:param method: the packet type used for traceroute, UD... | python | def traceroute_batch(input_list, results={}, method="udp", cmd_arguments=None,
delay_time=0.1, max_threads=100):
"""
This is a parallel version of the traceroute primitive.
:param input_list: the input is a list of domain names
:param method: the packet type used for traceroute, UD... | [
"def",
"traceroute_batch",
"(",
"input_list",
",",
"results",
"=",
"{",
"}",
",",
"method",
"=",
"\"udp\"",
",",
"cmd_arguments",
"=",
"None",
",",
"delay_time",
"=",
"0.1",
",",
"max_threads",
"=",
"100",
")",
":",
"threads",
"=",
"[",
"]",
"thread_erro... | This is a parallel version of the traceroute primitive.
:param input_list: the input is a list of domain names
:param method: the packet type used for traceroute, UDP by default
:param cmd_arguments: the list of arguments that need to be passed
to traceroute.
:param delay_time: ... | [
"This",
"is",
"a",
"parallel",
"version",
"of",
"the",
"traceroute",
"primitive",
"."
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/primitives/traceroute.py#L148-L207 | train | 59,764 |
iclab/centinel | centinel/primitives/traceroute.py | _traceroute_callback | def _traceroute_callback(self, line, kill_switch):
"""
Callback function to handle traceroute.
:param self:
:param line:
:param kill_switch:
:return:
"""
line = line.lower()
if "traceroute to" in line:
self.started = True
# need to run as root but not running as root.
... | python | def _traceroute_callback(self, line, kill_switch):
"""
Callback function to handle traceroute.
:param self:
:param line:
:param kill_switch:
:return:
"""
line = line.lower()
if "traceroute to" in line:
self.started = True
# need to run as root but not running as root.
... | [
"def",
"_traceroute_callback",
"(",
"self",
",",
"line",
",",
"kill_switch",
")",
":",
"line",
"=",
"line",
".",
"lower",
"(",
")",
"if",
"\"traceroute to\"",
"in",
"line",
":",
"self",
".",
"started",
"=",
"True",
"# need to run as root but not running as root.... | Callback function to handle traceroute.
:param self:
:param line:
:param kill_switch:
:return: | [
"Callback",
"function",
"to",
"handle",
"traceroute",
"."
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/primitives/traceroute.py#L210-L233 | train | 59,765 |
iclab/centinel | centinel/vpn/openvpn.py | OpenVPN.output_callback | def output_callback(self, line, kill_switch):
"""Set status of openvpn according to what we process"""
self.notifications += line + "\n"
if "Initialization Sequence Completed" in line:
self.started = True
if "ERROR:" in line or "Cannot resolve host address:" in line:
... | python | def output_callback(self, line, kill_switch):
"""Set status of openvpn according to what we process"""
self.notifications += line + "\n"
if "Initialization Sequence Completed" in line:
self.started = True
if "ERROR:" in line or "Cannot resolve host address:" in line:
... | [
"def",
"output_callback",
"(",
"self",
",",
"line",
",",
"kill_switch",
")",
":",
"self",
".",
"notifications",
"+=",
"line",
"+",
"\"\\n\"",
"if",
"\"Initialization Sequence Completed\"",
"in",
"line",
":",
"self",
".",
"started",
"=",
"True",
"if",
"\"ERROR:... | Set status of openvpn according to what we process | [
"Set",
"status",
"of",
"openvpn",
"according",
"to",
"what",
"we",
"process"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/vpn/openvpn.py#L57-L66 | train | 59,766 |
iclab/centinel | centinel/client.py | Client.load_experiments | def load_experiments(self):
"""This function will return the list of experiments.
"""
logging.debug("Loading experiments.")
# look for experiments in experiments directory
exp_dir = self.config['dirs']['experiments_dir']
for path in glob.glob(os.path.join(exp_dir, '[!_]*.... | python | def load_experiments(self):
"""This function will return the list of experiments.
"""
logging.debug("Loading experiments.")
# look for experiments in experiments directory
exp_dir = self.config['dirs']['experiments_dir']
for path in glob.glob(os.path.join(exp_dir, '[!_]*.... | [
"def",
"load_experiments",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"\"Loading experiments.\"",
")",
"# look for experiments in experiments directory",
"exp_dir",
"=",
"self",
".",
"config",
"[",
"'dirs'",
"]",
"[",
"'experiments_dir'",
"]",
"for",
"path... | This function will return the list of experiments. | [
"This",
"function",
"will",
"return",
"the",
"list",
"of",
"experiments",
"."
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/client.py#L83-L106 | train | 59,767 |
iclab/centinel | centinel/primitives/tcpdump.py | _tcpdump_callback | def _tcpdump_callback(self, line, kill_switch):
"""Callback function to handle tcpdump"""
line = line.lower()
if ("listening" in line) or ("reading" in line):
self.started = True
if ("no suitable device" in line):
self.error = True
self.kill_switch()
if "by kernel" in line:
... | python | def _tcpdump_callback(self, line, kill_switch):
"""Callback function to handle tcpdump"""
line = line.lower()
if ("listening" in line) or ("reading" in line):
self.started = True
if ("no suitable device" in line):
self.error = True
self.kill_switch()
if "by kernel" in line:
... | [
"def",
"_tcpdump_callback",
"(",
"self",
",",
"line",
",",
"kill_switch",
")",
":",
"line",
"=",
"line",
".",
"lower",
"(",
")",
"if",
"(",
"\"listening\"",
"in",
"line",
")",
"or",
"(",
"\"reading\"",
"in",
"line",
")",
":",
"self",
".",
"started",
... | Callback function to handle tcpdump | [
"Callback",
"function",
"to",
"handle",
"tcpdump"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/primitives/tcpdump.py#L78-L88 | train | 59,768 |
iclab/centinel | centinel/cli.py | _run | def _run():
"""Entry point for package and cli uses"""
args = parse_args()
# parse custom parameters
custom_meta = None
if args.custom_meta:
print "Adding custom parameters:"
custom_meta = {}
try:
for item in args.custom_meta.split(','):
key, val... | python | def _run():
"""Entry point for package and cli uses"""
args = parse_args()
# parse custom parameters
custom_meta = None
if args.custom_meta:
print "Adding custom parameters:"
custom_meta = {}
try:
for item in args.custom_meta.split(','):
key, val... | [
"def",
"_run",
"(",
")",
":",
"args",
"=",
"parse_args",
"(",
")",
"# parse custom parameters",
"custom_meta",
"=",
"None",
"if",
"args",
".",
"custom_meta",
":",
"print",
"\"Adding custom parameters:\"",
"custom_meta",
"=",
"{",
"}",
"try",
":",
"for",
"item"... | Entry point for package and cli uses | [
"Entry",
"point",
"for",
"package",
"and",
"cli",
"uses"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/cli.py#L114-L201 | train | 59,769 |
iclab/centinel | centinel/primitives/tls.py | get_fingerprint_batch | def get_fingerprint_batch(input_list, results={}, default_port=443,
delay_time=0.5, max_threads=100):
"""
This is a parallel version of the TLS fingerprint primitive.
:param input_list: the input is a list of host:ports.
:param default_port: default port to use when no port sp... | python | def get_fingerprint_batch(input_list, results={}, default_port=443,
delay_time=0.5, max_threads=100):
"""
This is a parallel version of the TLS fingerprint primitive.
:param input_list: the input is a list of host:ports.
:param default_port: default port to use when no port sp... | [
"def",
"get_fingerprint_batch",
"(",
"input_list",
",",
"results",
"=",
"{",
"}",
",",
"default_port",
"=",
"443",
",",
"delay_time",
"=",
"0.5",
",",
"max_threads",
"=",
"100",
")",
":",
"threads",
"=",
"[",
"]",
"thread_error",
"=",
"False",
"thread_wait... | This is a parallel version of the TLS fingerprint primitive.
:param input_list: the input is a list of host:ports.
:param default_port: default port to use when no port specified
:param delay_time: delay before starting each thread
:param max_threads: maximum number of concurrent threads
:return: | [
"This",
"is",
"a",
"parallel",
"version",
"of",
"the",
"TLS",
"fingerprint",
"primitive",
"."
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/primitives/tls.py#L90-L157 | train | 59,770 |
iclab/centinel | centinel/primitives/http.py | meta_redirect | def meta_redirect(content):
"""
Returns redirecting URL if there is a HTML refresh meta tag,
returns None otherwise
:param content: HTML content
"""
decoded = content.decode("utf-8", errors="replace")
try:
soup = BeautifulSoup.BeautifulSoup(decoded)
except Exception as e:
... | python | def meta_redirect(content):
"""
Returns redirecting URL if there is a HTML refresh meta tag,
returns None otherwise
:param content: HTML content
"""
decoded = content.decode("utf-8", errors="replace")
try:
soup = BeautifulSoup.BeautifulSoup(decoded)
except Exception as e:
... | [
"def",
"meta_redirect",
"(",
"content",
")",
":",
"decoded",
"=",
"content",
".",
"decode",
"(",
"\"utf-8\"",
",",
"errors",
"=",
"\"replace\"",
")",
"try",
":",
"soup",
"=",
"BeautifulSoup",
".",
"BeautifulSoup",
"(",
"decoded",
")",
"except",
"Exception",
... | Returns redirecting URL if there is a HTML refresh meta tag,
returns None otherwise
:param content: HTML content | [
"Returns",
"redirecting",
"URL",
"if",
"there",
"is",
"a",
"HTML",
"refresh",
"meta",
"tag",
"returns",
"None",
"otherwise"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/primitives/http.py#L17-L43 | train | 59,771 |
iclab/centinel | centinel/primitives/http.py | _get_http_request | def _get_http_request(netloc, path="/", headers=None, ssl=False):
"""
Actually gets the http. Moved this to it's own private method since
it is called several times for following redirects
:param host:
:param path:
:param headers:
:param ssl:
:return:
"""
if ssl:
port = ... | python | def _get_http_request(netloc, path="/", headers=None, ssl=False):
"""
Actually gets the http. Moved this to it's own private method since
it is called several times for following redirects
:param host:
:param path:
:param headers:
:param ssl:
:return:
"""
if ssl:
port = ... | [
"def",
"_get_http_request",
"(",
"netloc",
",",
"path",
"=",
"\"/\"",
",",
"headers",
"=",
"None",
",",
"ssl",
"=",
"False",
")",
":",
"if",
"ssl",
":",
"port",
"=",
"443",
"else",
":",
"port",
"=",
"80",
"host",
"=",
"netloc",
"if",
"len",
"(",
... | Actually gets the http. Moved this to it's own private method since
it is called several times for following redirects
:param host:
:param path:
:param headers:
:param ssl:
:return: | [
"Actually",
"gets",
"the",
"http",
".",
"Moved",
"this",
"to",
"it",
"s",
"own",
"private",
"method",
"since",
"it",
"is",
"called",
"several",
"times",
"for",
"following",
"redirects"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/primitives/http.py#L46-L98 | train | 59,772 |
iclab/centinel | centinel/primitives/http.py | get_requests_batch | def get_requests_batch(input_list, results={}, delay_time=0.5, max_threads=100):
"""
This is a parallel version of the HTTP GET primitive.
:param input_list: the input is a list of either dictionaries containing
query information, or just domain names (and NOT URLs).
:param delay... | python | def get_requests_batch(input_list, results={}, delay_time=0.5, max_threads=100):
"""
This is a parallel version of the HTTP GET primitive.
:param input_list: the input is a list of either dictionaries containing
query information, or just domain names (and NOT URLs).
:param delay... | [
"def",
"get_requests_batch",
"(",
"input_list",
",",
"results",
"=",
"{",
"}",
",",
"delay_time",
"=",
"0.5",
",",
"max_threads",
"=",
"100",
")",
":",
"threads",
"=",
"[",
"]",
"thread_error",
"=",
"False",
"thread_wait_timeout",
"=",
"200",
"ind",
"=",
... | This is a parallel version of the HTTP GET primitive.
:param input_list: the input is a list of either dictionaries containing
query information, or just domain names (and NOT URLs).
:param delay_time: delay before starting each thread
:param max_threads: maximum number of concurrent... | [
"This",
"is",
"a",
"parallel",
"version",
"of",
"the",
"HTTP",
"GET",
"primitive",
"."
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/primitives/http.py#L244-L344 | train | 59,773 |
iclab/centinel | centinel/daemonize.py | create_script_for_location | def create_script_for_location(content, destination):
"""Create a script with the given content, mv it to the
destination, and make it executable
Parameters:
content- the content to put in the script
destination- the directory to copy to
Note: due to constraints on os.rename, destination must ... | python | def create_script_for_location(content, destination):
"""Create a script with the given content, mv it to the
destination, and make it executable
Parameters:
content- the content to put in the script
destination- the directory to copy to
Note: due to constraints on os.rename, destination must ... | [
"def",
"create_script_for_location",
"(",
"content",
",",
"destination",
")",
":",
"temp",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"mode",
"=",
"'w'",
",",
"delete",
"=",
"False",
")",
"temp",
".",
"write",
"(",
"content",
")",
"temp",
".",
"close... | Create a script with the given content, mv it to the
destination, and make it executable
Parameters:
content- the content to put in the script
destination- the directory to copy to
Note: due to constraints on os.rename, destination must be an
absolute path to a file, not just a directory | [
"Create",
"a",
"script",
"with",
"the",
"given",
"content",
"mv",
"it",
"to",
"the",
"destination",
"and",
"make",
"it",
"executable"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/daemonize.py#L11-L29 | train | 59,774 |
iclab/centinel | centinel/daemonize.py | daemonize | def daemonize(package, bin_loc, user):
"""Create crontab entries to run centinel every hour and
autoupdate every day
Parameters:
package- name of the currently installed package (will be used for
autoupdate). If this parameter is None, the autoupdater will
not be used
bin_loc- loc... | python | def daemonize(package, bin_loc, user):
"""Create crontab entries to run centinel every hour and
autoupdate every day
Parameters:
package- name of the currently installed package (will be used for
autoupdate). If this parameter is None, the autoupdater will
not be used
bin_loc- loc... | [
"def",
"daemonize",
"(",
"package",
",",
"bin_loc",
",",
"user",
")",
":",
"path",
"=",
"\"/etc/cron.hourly/centinel-\"",
"+",
"user",
"if",
"user",
"!=",
"\"root\"",
":",
"# create a script to run centinel every hour as the current user",
"hourly",
"=",
"\"\"",
".",
... | Create crontab entries to run centinel every hour and
autoupdate every day
Parameters:
package- name of the currently installed package (will be used for
autoupdate). If this parameter is None, the autoupdater will
not be used
bin_loc- location of the centinel binary/script.
Note... | [
"Create",
"crontab",
"entries",
"to",
"run",
"centinel",
"every",
"hour",
"and",
"autoupdate",
"every",
"day"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/daemonize.py#L32-L79 | train | 59,775 |
iclab/centinel | centinel/vpn/hma.py | create_config_files | def create_config_files(directory):
"""Create all available VPN configuration files in the given directory
Note: I am basically just following along with what their script
client does
"""
# get the config file template
template_url = ("https://securenetconnection.com/vpnconfig/"
... | python | def create_config_files(directory):
"""Create all available VPN configuration files in the given directory
Note: I am basically just following along with what their script
client does
"""
# get the config file template
template_url = ("https://securenetconnection.com/vpnconfig/"
... | [
"def",
"create_config_files",
"(",
"directory",
")",
":",
"# get the config file template",
"template_url",
"=",
"(",
"\"https://securenetconnection.com/vpnconfig/\"",
"\"openvpn-template.ovpn\"",
")",
"resp",
"=",
"requests",
".",
"get",
"(",
"template_url",
")",
"resp",
... | Create all available VPN configuration files in the given directory
Note: I am basically just following along with what their script
client does | [
"Create",
"all",
"available",
"VPN",
"configuration",
"files",
"in",
"the",
"given",
"directory"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/vpn/hma.py#L10-L56 | train | 59,776 |
iclab/centinel | centinel/backend.py | User.sync_scheduler | def sync_scheduler(self):
"""Download the scheduler.info file and perform a smart comparison
with what we currently have so that we don't overwrite the
last_run timestamp
To do a smart comparison, we go over each entry in the
server's scheduler file. If a scheduler entry is not ... | python | def sync_scheduler(self):
"""Download the scheduler.info file and perform a smart comparison
with what we currently have so that we don't overwrite the
last_run timestamp
To do a smart comparison, we go over each entry in the
server's scheduler file. If a scheduler entry is not ... | [
"def",
"sync_scheduler",
"(",
"self",
")",
":",
"# get the server scheduler.info file",
"url",
"=",
"\"%s/%s/%s\"",
"%",
"(",
"self",
".",
"config",
"[",
"'server'",
"]",
"[",
"'server_url'",
"]",
",",
"\"experiments\"",
",",
"\"scheduler.info\"",
")",
"try",
":... | Download the scheduler.info file and perform a smart comparison
with what we currently have so that we don't overwrite the
last_run timestamp
To do a smart comparison, we go over each entry in the
server's scheduler file. If a scheduler entry is not present
in the server copy, w... | [
"Download",
"the",
"scheduler",
".",
"info",
"file",
"and",
"perform",
"a",
"smart",
"comparison",
"with",
"what",
"we",
"currently",
"have",
"so",
"that",
"we",
"don",
"t",
"overwrite",
"the",
"last_run",
"timestamp"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/backend.py#L105-L170 | train | 59,777 |
iclab/centinel | centinel/backend.py | User.informed_consent | def informed_consent(self):
"""Create a URL for the user to give their consent through"""
if self.typeable_handle is None:
consent_url = [self.config['server']['server_url'],
"/get_initial_consent?username="]
consent_url.append(urlsafe_b64encode(self.us... | python | def informed_consent(self):
"""Create a URL for the user to give their consent through"""
if self.typeable_handle is None:
consent_url = [self.config['server']['server_url'],
"/get_initial_consent?username="]
consent_url.append(urlsafe_b64encode(self.us... | [
"def",
"informed_consent",
"(",
"self",
")",
":",
"if",
"self",
".",
"typeable_handle",
"is",
"None",
":",
"consent_url",
"=",
"[",
"self",
".",
"config",
"[",
"'server'",
"]",
"[",
"'server_url'",
"]",
",",
"\"/get_initial_consent?username=\"",
"]",
"consent_... | Create a URL for the user to give their consent through | [
"Create",
"a",
"URL",
"for",
"the",
"user",
"to",
"give",
"their",
"consent",
"through"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/backend.py#L277-L292 | train | 59,778 |
iclab/centinel | centinel/vpn/cli.py | return_abs_path | def return_abs_path(directory, path):
"""
Unfortunately, Python is not smart enough to return an absolute
path with tilde expansion, so I writing functionality to do this
:param directory:
:param path:
:return:
"""
if directory is None or path is None:
return
directory = os.... | python | def return_abs_path(directory, path):
"""
Unfortunately, Python is not smart enough to return an absolute
path with tilde expansion, so I writing functionality to do this
:param directory:
:param path:
:return:
"""
if directory is None or path is None:
return
directory = os.... | [
"def",
"return_abs_path",
"(",
"directory",
",",
"path",
")",
":",
"if",
"directory",
"is",
"None",
"or",
"path",
"is",
"None",
":",
"return",
"directory",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"directory",
")",
"return",
"os",
".",
"path",
"... | Unfortunately, Python is not smart enough to return an absolute
path with tilde expansion, so I writing functionality to do this
:param directory:
:param path:
:return: | [
"Unfortunately",
"Python",
"is",
"not",
"smart",
"enough",
"to",
"return",
"an",
"absolute",
"path",
"with",
"tilde",
"expansion",
"so",
"I",
"writing",
"functionality",
"to",
"do",
"this"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/vpn/cli.py#L369-L381 | train | 59,779 |
iclab/centinel | centinel/vpn/cli.py | _run | def _run():
"""Entry point for all uses of centinel"""
args = parse_args()
# register signal handler
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler)
# set up logging
log_formatter = logging.Formatter("%(asctime)s %(filename)s(line %(lineno)d) "
... | python | def _run():
"""Entry point for all uses of centinel"""
args = parse_args()
# register signal handler
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler)
# set up logging
log_formatter = logging.Formatter("%(asctime)s %(filename)s(line %(lineno)d) "
... | [
"def",
"_run",
"(",
")",
":",
"args",
"=",
"parse_args",
"(",
")",
"# register signal handler",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGTERM",
",",
"signal_handler",
")",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
"signal_handler",
... | Entry point for all uses of centinel | [
"Entry",
"point",
"for",
"all",
"uses",
"of",
"centinel"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/vpn/cli.py#L508-L566 | train | 59,780 |
iclab/centinel | centinel/config.py | Configuration.parse_config | def parse_config(self, config_file):
"""
Given a configuration file, read in and interpret the results
:param config_file:
:return:
"""
with open(config_file, 'r') as f:
config = json.load(f)
self.params = config
if self.params['proxy']['prox... | python | def parse_config(self, config_file):
"""
Given a configuration file, read in and interpret the results
:param config_file:
:return:
"""
with open(config_file, 'r') as f:
config = json.load(f)
self.params = config
if self.params['proxy']['prox... | [
"def",
"parse_config",
"(",
"self",
",",
"config_file",
")",
":",
"with",
"open",
"(",
"config_file",
",",
"'r'",
")",
"as",
"f",
":",
"config",
"=",
"json",
".",
"load",
"(",
"f",
")",
"self",
".",
"params",
"=",
"config",
"if",
"self",
".",
"para... | Given a configuration file, read in and interpret the results
:param config_file:
:return: | [
"Given",
"a",
"configuration",
"file",
"read",
"in",
"and",
"interpret",
"the",
"results"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/config.py#L82-L95 | train | 59,781 |
iclab/centinel | centinel/config.py | Configuration.update | def update(self, old, backup_path=None):
"""
Update the old configuration file with new values.
:param old: old configuration to update.
:param backup_path: path to write a backup of the old config file.
:return:
"""
for category in old.params.keys():
... | python | def update(self, old, backup_path=None):
"""
Update the old configuration file with new values.
:param old: old configuration to update.
:param backup_path: path to write a backup of the old config file.
:return:
"""
for category in old.params.keys():
... | [
"def",
"update",
"(",
"self",
",",
"old",
",",
"backup_path",
"=",
"None",
")",
":",
"for",
"category",
"in",
"old",
".",
"params",
".",
"keys",
"(",
")",
":",
"for",
"parameter",
"in",
"old",
".",
"params",
"[",
"category",
"]",
".",
"keys",
"(",
... | Update the old configuration file with new values.
:param old: old configuration to update.
:param backup_path: path to write a backup of the old config file.
:return: | [
"Update",
"the",
"old",
"configuration",
"file",
"with",
"new",
"values",
"."
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/config.py#L97-L132 | train | 59,782 |
iclab/centinel | centinel/config.py | Configuration.write_out_config | def write_out_config(self, config_file):
"""
Write out the configuration file
:param config_file:
:return:
Note: this will erase all comments from the config file
"""
with open(config_file, 'w') as f:
json.dump(self.params, f, indent=2,
... | python | def write_out_config(self, config_file):
"""
Write out the configuration file
:param config_file:
:return:
Note: this will erase all comments from the config file
"""
with open(config_file, 'w') as f:
json.dump(self.params, f, indent=2,
... | [
"def",
"write_out_config",
"(",
"self",
",",
"config_file",
")",
":",
"with",
"open",
"(",
"config_file",
",",
"'w'",
")",
"as",
"f",
":",
"json",
".",
"dump",
"(",
"self",
".",
"params",
",",
"f",
",",
"indent",
"=",
"2",
",",
"separators",
"=",
"... | Write out the configuration file
:param config_file:
:return:
Note: this will erase all comments from the config file | [
"Write",
"out",
"the",
"configuration",
"file"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/config.py#L134-L146 | train | 59,783 |
iclab/centinel | centinel/primitives/headless_browser.py | HeadlessBrowser.divide_url | def divide_url(self, url):
"""
divide url into host and path two parts
"""
if 'https://' in url:
host = url[8:].split('/')[0]
path = url[8 + len(host):]
elif 'http://' in url:
host = url[7:].split('/')[0]
path = url[7 + len(host):]
... | python | def divide_url(self, url):
"""
divide url into host and path two parts
"""
if 'https://' in url:
host = url[8:].split('/')[0]
path = url[8 + len(host):]
elif 'http://' in url:
host = url[7:].split('/')[0]
path = url[7 + len(host):]
... | [
"def",
"divide_url",
"(",
"self",
",",
"url",
")",
":",
"if",
"'https://'",
"in",
"url",
":",
"host",
"=",
"url",
"[",
"8",
":",
"]",
".",
"split",
"(",
"'/'",
")",
"[",
"0",
"]",
"path",
"=",
"url",
"[",
"8",
"+",
"len",
"(",
"host",
")",
... | divide url into host and path two parts | [
"divide",
"url",
"into",
"host",
"and",
"path",
"two",
"parts"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/primitives/headless_browser.py#L145-L158 | train | 59,784 |
iclab/centinel | centinel/utils.py | hash_folder | def hash_folder(folder, regex='[!_]*'):
"""
Get the md5 sum of each file in the folder and return to the user
:param folder: the folder to compute the sums over
:param regex: an expression to limit the files we match
:return:
Note: by default we will hash every file in the folder
Note: we... | python | def hash_folder(folder, regex='[!_]*'):
"""
Get the md5 sum of each file in the folder and return to the user
:param folder: the folder to compute the sums over
:param regex: an expression to limit the files we match
:return:
Note: by default we will hash every file in the folder
Note: we... | [
"def",
"hash_folder",
"(",
"folder",
",",
"regex",
"=",
"'[!_]*'",
")",
":",
"file_hashes",
"=",
"{",
"}",
"for",
"path",
"in",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"folder",
",",
"regex",
")",
")",
":",
"# exclude folders",... | Get the md5 sum of each file in the folder and return to the user
:param folder: the folder to compute the sums over
:param regex: an expression to limit the files we match
:return:
Note: by default we will hash every file in the folder
Note: we will not match anything that starts with an undersc... | [
"Get",
"the",
"md5",
"sum",
"of",
"each",
"file",
"in",
"the",
"folder",
"and",
"return",
"to",
"the",
"user"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/utils.py#L31-L55 | train | 59,785 |
iclab/centinel | centinel/utils.py | compute_files_to_download | def compute_files_to_download(client_hashes, server_hashes):
"""
Given a dictionary of file hashes from the client and the
server, specify which files should be downloaded from the server
:param client_hashes: a dictionary where the filenames are keys and the
values are md5 ha... | python | def compute_files_to_download(client_hashes, server_hashes):
"""
Given a dictionary of file hashes from the client and the
server, specify which files should be downloaded from the server
:param client_hashes: a dictionary where the filenames are keys and the
values are md5 ha... | [
"def",
"compute_files_to_download",
"(",
"client_hashes",
",",
"server_hashes",
")",
":",
"to_dload",
",",
"to_delete",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"filename",
"in",
"server_hashes",
":",
"if",
"filename",
"not",
"in",
"client_hashes",
":",
"to_dload"... | Given a dictionary of file hashes from the client and the
server, specify which files should be downloaded from the server
:param client_hashes: a dictionary where the filenames are keys and the
values are md5 hashes as strings
:param server_hashes: a dictionary where the filename... | [
"Given",
"a",
"dictionary",
"of",
"file",
"hashes",
"from",
"the",
"client",
"and",
"the",
"server",
"specify",
"which",
"files",
"should",
"be",
"downloaded",
"from",
"the",
"server"
] | 9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4 | https://github.com/iclab/centinel/blob/9a25dcf30c6a1db3c046f7ccb8ab8873e455c1a4/centinel/utils.py#L58-L90 | train | 59,786 |
click-contrib/click-spinner | click_spinner/__init__.py | spinner | def spinner(beep=False, disable=False, force=False):
"""This function creates a context manager that is used to display a
spinner on stdout as long as the context has not exited.
The spinner is created only if stdout is not redirected, or if the spinner
is forced using the `force` parameter.
Param... | python | def spinner(beep=False, disable=False, force=False):
"""This function creates a context manager that is used to display a
spinner on stdout as long as the context has not exited.
The spinner is created only if stdout is not redirected, or if the spinner
is forced using the `force` parameter.
Param... | [
"def",
"spinner",
"(",
"beep",
"=",
"False",
",",
"disable",
"=",
"False",
",",
"force",
"=",
"False",
")",
":",
"return",
"Spinner",
"(",
"beep",
",",
"disable",
",",
"force",
")"
] | This function creates a context manager that is used to display a
spinner on stdout as long as the context has not exited.
The spinner is created only if stdout is not redirected, or if the spinner
is forced using the `force` parameter.
Parameters
----------
beep : bool
Beep when spinn... | [
"This",
"function",
"creates",
"a",
"context",
"manager",
"that",
"is",
"used",
"to",
"display",
"a",
"spinner",
"on",
"stdout",
"as",
"long",
"as",
"the",
"context",
"has",
"not",
"exited",
"."
] | 5cd08058f87a6cceef0ec6de60a73a400d35ef55 | https://github.com/click-contrib/click-spinner/blob/5cd08058f87a6cceef0ec6de60a73a400d35ef55/click_spinner/__init__.py#L52-L76 | train | 59,787 |
xray7224/PyPump | docs/examples/pypump-post-note.py | App.verifier | def verifier(self, url):
""" Will ask user to click link to accept app and write code """
webbrowser.open(url)
print('A browser should have opened up with a link to allow us to access')
print('your account, follow the instructions on the link and paste the verifier')
print('Code ... | python | def verifier(self, url):
""" Will ask user to click link to accept app and write code """
webbrowser.open(url)
print('A browser should have opened up with a link to allow us to access')
print('your account, follow the instructions on the link and paste the verifier')
print('Code ... | [
"def",
"verifier",
"(",
"self",
",",
"url",
")",
":",
"webbrowser",
".",
"open",
"(",
"url",
")",
"print",
"(",
"'A browser should have opened up with a link to allow us to access'",
")",
"print",
"(",
"'your account, follow the instructions on the link and paste the verifier... | Will ask user to click link to accept app and write code | [
"Will",
"ask",
"user",
"to",
"click",
"link",
"to",
"accept",
"app",
"and",
"write",
"code"
] | f921f691c39fe021f4fd124b6bc91718c9e49b4a | https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/docs/examples/pypump-post-note.py#L74-L82 | train | 59,788 |
xray7224/PyPump | docs/examples/pypump-post-note.py | App.write_config | def write_config(self):
""" Write config to file """
if not os.path.exists(os.path.dirname(self.config_file)):
os.makedirs(os.path.dirname(self.config_file))
with open(self.config_file, 'w') as f:
f.write(json.dumps(self.config))
f.close() | python | def write_config(self):
""" Write config to file """
if not os.path.exists(os.path.dirname(self.config_file)):
os.makedirs(os.path.dirname(self.config_file))
with open(self.config_file, 'w') as f:
f.write(json.dumps(self.config))
f.close() | [
"def",
"write_config",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"config_file",
")",
")",
":",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"dirname",
"(... | Write config to file | [
"Write",
"config",
"to",
"file"
] | f921f691c39fe021f4fd124b6bc91718c9e49b4a | https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/docs/examples/pypump-post-note.py#L84-L90 | train | 59,789 |
xray7224/PyPump | docs/examples/pypump-post-note.py | App.read_config | def read_config(self):
""" Read config from file """
try:
with open(self.config_file, 'r') as f:
self.config = json.loads(f.read())
f.close()
except IOError:
return False
return True | python | def read_config(self):
""" Read config from file """
try:
with open(self.config_file, 'r') as f:
self.config = json.loads(f.read())
f.close()
except IOError:
return False
return True | [
"def",
"read_config",
"(",
"self",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"config_file",
",",
"'r'",
")",
"as",
"f",
":",
"self",
".",
"config",
"=",
"json",
".",
"loads",
"(",
"f",
".",
"read",
"(",
")",
")",
"f",
".",
"close"... | Read config from file | [
"Read",
"config",
"from",
"file"
] | f921f691c39fe021f4fd124b6bc91718c9e49b4a | https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/docs/examples/pypump-post-note.py#L92-L100 | train | 59,790 |
xray7224/PyPump | docs/examples/pypump-post-note.py | App.post_note | def post_note(self):
""" Post note and return the URL of the posted note """
if self.args.note_title:
note_title = self.args.note_title
else:
note_title = None
note_content = self.args.note_content
mynote = self.pump.Note(display_name=note_title, content=... | python | def post_note(self):
""" Post note and return the URL of the posted note """
if self.args.note_title:
note_title = self.args.note_title
else:
note_title = None
note_content = self.args.note_content
mynote = self.pump.Note(display_name=note_title, content=... | [
"def",
"post_note",
"(",
"self",
")",
":",
"if",
"self",
".",
"args",
".",
"note_title",
":",
"note_title",
"=",
"self",
".",
"args",
".",
"note_title",
"else",
":",
"note_title",
"=",
"None",
"note_content",
"=",
"self",
".",
"args",
".",
"note_content"... | Post note and return the URL of the posted note | [
"Post",
"note",
"and",
"return",
"the",
"URL",
"of",
"the",
"posted",
"note"
] | f921f691c39fe021f4fd124b6bc91718c9e49b4a | https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/docs/examples/pypump-post-note.py#L102-L115 | train | 59,791 |
xray7224/PyPump | pypump/models/feed.py | ItemList.get_obj_id | def get_obj_id(self, item):
""" Get the id of a PumpObject.
:param item: id string or PumpObject
"""
if item is not None:
if isinstance(item, six.string_types):
return item
elif hasattr(item, 'id'):
return item.id | python | def get_obj_id(self, item):
""" Get the id of a PumpObject.
:param item: id string or PumpObject
"""
if item is not None:
if isinstance(item, six.string_types):
return item
elif hasattr(item, 'id'):
return item.id | [
"def",
"get_obj_id",
"(",
"self",
",",
"item",
")",
":",
"if",
"item",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"item",
",",
"six",
".",
"string_types",
")",
":",
"return",
"item",
"elif",
"hasattr",
"(",
"item",
",",
"'id'",
")",
":",
"r... | Get the id of a PumpObject.
:param item: id string or PumpObject | [
"Get",
"the",
"id",
"of",
"a",
"PumpObject",
"."
] | f921f691c39fe021f4fd124b6bc91718c9e49b4a | https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/pypump/models/feed.py#L80-L89 | train | 59,792 |
xray7224/PyPump | pypump/models/feed.py | ItemList.get_page | def get_page(self, url):
""" Get a page of items from API """
if url:
data = self.feed._request(url, offset=self._offset, since=self._since, before=self._before)
# set values to False to avoid using them for next request
self._before = False if self._before is not No... | python | def get_page(self, url):
""" Get a page of items from API """
if url:
data = self.feed._request(url, offset=self._offset, since=self._since, before=self._before)
# set values to False to avoid using them for next request
self._before = False if self._before is not No... | [
"def",
"get_page",
"(",
"self",
",",
"url",
")",
":",
"if",
"url",
":",
"data",
"=",
"self",
".",
"feed",
".",
"_request",
"(",
"url",
",",
"offset",
"=",
"self",
".",
"_offset",
",",
"since",
"=",
"self",
".",
"_since",
",",
"before",
"=",
"self... | Get a page of items from API | [
"Get",
"a",
"page",
"of",
"items",
"from",
"API"
] | f921f691c39fe021f4fd124b6bc91718c9e49b4a | https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/pypump/models/feed.py#L91-L107 | train | 59,793 |
xray7224/PyPump | pypump/models/feed.py | ItemList.done | def done(self):
""" Check if we should stop returning objects """
if self._done:
return self._done
if self._limit is None:
self._done = False
elif self.itemcount >= self._limit:
self._done = True
return self._done | python | def done(self):
""" Check if we should stop returning objects """
if self._done:
return self._done
if self._limit is None:
self._done = False
elif self.itemcount >= self._limit:
self._done = True
return self._done | [
"def",
"done",
"(",
"self",
")",
":",
"if",
"self",
".",
"_done",
":",
"return",
"self",
".",
"_done",
"if",
"self",
".",
"_limit",
"is",
"None",
":",
"self",
".",
"_done",
"=",
"False",
"elif",
"self",
".",
"itemcount",
">=",
"self",
".",
"_limit"... | Check if we should stop returning objects | [
"Check",
"if",
"we",
"should",
"stop",
"returning",
"objects"
] | f921f691c39fe021f4fd124b6bc91718c9e49b4a | https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/pypump/models/feed.py#L164-L174 | train | 59,794 |
xray7224/PyPump | pypump/models/feed.py | ItemList._build_cache | def _build_cache(self):
""" Build a list of objects from feed's cached items or API page"""
self.cache = []
if self.done:
return
for i in (self.get_cached() if self._cached else self.get_page(self.url)):
if not self._cached:
# some objects don't h... | python | def _build_cache(self):
""" Build a list of objects from feed's cached items or API page"""
self.cache = []
if self.done:
return
for i in (self.get_cached() if self._cached else self.get_page(self.url)):
if not self._cached:
# some objects don't h... | [
"def",
"_build_cache",
"(",
"self",
")",
":",
"self",
".",
"cache",
"=",
"[",
"]",
"if",
"self",
".",
"done",
":",
"return",
"for",
"i",
"in",
"(",
"self",
".",
"get_cached",
"(",
")",
"if",
"self",
".",
"_cached",
"else",
"self",
".",
"get_page",
... | Build a list of objects from feed's cached items or API page | [
"Build",
"a",
"list",
"of",
"objects",
"from",
"feed",
"s",
"cached",
"items",
"or",
"API",
"page"
] | f921f691c39fe021f4fd124b6bc91718c9e49b4a | https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/pypump/models/feed.py#L176-L212 | train | 59,795 |
xray7224/PyPump | pypump/models/feed.py | Feed.items | def items(self, offset=None, limit=20, since=None, before=None, *args, **kwargs):
""" Get a feed's items.
:param offset: Amount of items to skip before returning data
:param since: Return items added after this id (ordered old -> new)
:param before: Return items added before this id (o... | python | def items(self, offset=None, limit=20, since=None, before=None, *args, **kwargs):
""" Get a feed's items.
:param offset: Amount of items to skip before returning data
:param since: Return items added after this id (ordered old -> new)
:param before: Return items added before this id (o... | [
"def",
"items",
"(",
"self",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"20",
",",
"since",
"=",
"None",
",",
"before",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"ItemList",
"(",
"self",
",",
"offset",
"=",
... | Get a feed's items.
:param offset: Amount of items to skip before returning data
:param since: Return items added after this id (ordered old -> new)
:param before: Return items added before this id (ordered new -> old)
:param limit: Amount of items to return | [
"Get",
"a",
"feed",
"s",
"items",
"."
] | f921f691c39fe021f4fd124b6bc91718c9e49b4a | https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/pypump/models/feed.py#L335-L343 | train | 59,796 |
xray7224/PyPump | pypump/models/feed.py | Inbox.direct | def direct(self):
""" Direct inbox feed,
contains activities addressed directly to the owner of the inbox.
"""
url = self._subfeed("direct")
if "direct" in self.url or "major" in self.url or "minor" in self.url:
return self
if self._direct is None:
... | python | def direct(self):
""" Direct inbox feed,
contains activities addressed directly to the owner of the inbox.
"""
url = self._subfeed("direct")
if "direct" in self.url or "major" in self.url or "minor" in self.url:
return self
if self._direct is None:
... | [
"def",
"direct",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_subfeed",
"(",
"\"direct\"",
")",
"if",
"\"direct\"",
"in",
"self",
".",
"url",
"or",
"\"major\"",
"in",
"self",
".",
"url",
"or",
"\"minor\"",
"in",
"self",
".",
"url",
":",
"return"... | Direct inbox feed,
contains activities addressed directly to the owner of the inbox. | [
"Direct",
"inbox",
"feed",
"contains",
"activities",
"addressed",
"directly",
"to",
"the",
"owner",
"of",
"the",
"inbox",
"."
] | f921f691c39fe021f4fd124b6bc91718c9e49b4a | https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/pypump/models/feed.py#L444-L453 | train | 59,797 |
xray7224/PyPump | pypump/models/feed.py | Inbox.major | def major(self):
""" Major inbox feed, contains major activities such as notes and images. """
url = self._subfeed("major")
if "major" in self.url or "minor" in self.url:
return self
if self._major is None:
self._major = self.__class__(url, pypump=self._pump)
... | python | def major(self):
""" Major inbox feed, contains major activities such as notes and images. """
url = self._subfeed("major")
if "major" in self.url or "minor" in self.url:
return self
if self._major is None:
self._major = self.__class__(url, pypump=self._pump)
... | [
"def",
"major",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_subfeed",
"(",
"\"major\"",
")",
"if",
"\"major\"",
"in",
"self",
".",
"url",
"or",
"\"minor\"",
"in",
"self",
".",
"url",
":",
"return",
"self",
"if",
"self",
".",
"_major",
"is",
"... | Major inbox feed, contains major activities such as notes and images. | [
"Major",
"inbox",
"feed",
"contains",
"major",
"activities",
"such",
"as",
"notes",
"and",
"images",
"."
] | f921f691c39fe021f4fd124b6bc91718c9e49b4a | https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/pypump/models/feed.py#L456-L463 | train | 59,798 |
xray7224/PyPump | pypump/models/feed.py | Inbox.minor | def minor(self):
""" Minor inbox feed, contains minor activities such as likes, shares and follows. """
url = self._subfeed("minor")
if "minor" in self.url or "major" in self.url:
return self
if self._minor is None:
self._minor = self.__class__(url, pypump=self._p... | python | def minor(self):
""" Minor inbox feed, contains minor activities such as likes, shares and follows. """
url = self._subfeed("minor")
if "minor" in self.url or "major" in self.url:
return self
if self._minor is None:
self._minor = self.__class__(url, pypump=self._p... | [
"def",
"minor",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_subfeed",
"(",
"\"minor\"",
")",
"if",
"\"minor\"",
"in",
"self",
".",
"url",
"or",
"\"major\"",
"in",
"self",
".",
"url",
":",
"return",
"self",
"if",
"self",
".",
"_minor",
"is",
"... | Minor inbox feed, contains minor activities such as likes, shares and follows. | [
"Minor",
"inbox",
"feed",
"contains",
"minor",
"activities",
"such",
"as",
"likes",
"shares",
"and",
"follows",
"."
] | f921f691c39fe021f4fd124b6bc91718c9e49b4a | https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/pypump/models/feed.py#L466-L473 | train | 59,799 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.