partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | INNOMetric.parse_innotop_mode_b | Generic parsing method for all other modes | src/naarad/metrics/innotop_metric.py | def parse_innotop_mode_b(self):
""" Generic parsing method for all other modes """
with open(self.infile, 'r') as infh:
# Pre processing to figure out different headers
max_row_quot = 0
valrow = -1
thisrowcolumns = {}
data = {}
while True:
line1 = infh.readline()
... | def parse_innotop_mode_b(self):
""" Generic parsing method for all other modes """
with open(self.infile, 'r') as infh:
# Pre processing to figure out different headers
max_row_quot = 0
valrow = -1
thisrowcolumns = {}
data = {}
while True:
line1 = infh.readline()
... | [
"Generic",
"parsing",
"method",
"for",
"all",
"other",
"modes"
] | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/innotop_metric.py#L91-L182 | [
"def",
"parse_innotop_mode_b",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"infile",
",",
"'r'",
")",
"as",
"infh",
":",
"# Pre processing to figure out different headers",
"max_row_quot",
"=",
"0",
"valrow",
"=",
"-",
"1",
"thisrowcolumns",
"=",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | INNOMetric.parse_innotop_mode_m | Special parsing method for Innotop "Replication Status" results (innotop --mode M) | src/naarad/metrics/innotop_metric.py | def parse_innotop_mode_m(self):
""" Special parsing method for Innotop "Replication Status" results (innotop --mode M)"""
with open(self.infile, 'r') as infh:
# Pre processing to figure out different headers
max_row_quot = 0
valrow = -1
thisrowcolumns = {}
data = {}
last_ts =... | def parse_innotop_mode_m(self):
""" Special parsing method for Innotop "Replication Status" results (innotop --mode M)"""
with open(self.infile, 'r') as infh:
# Pre processing to figure out different headers
max_row_quot = 0
valrow = -1
thisrowcolumns = {}
data = {}
last_ts =... | [
"Special",
"parsing",
"method",
"for",
"Innotop",
"Replication",
"Status",
"results",
"(",
"innotop",
"--",
"mode",
"M",
")"
] | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/innotop_metric.py#L184-L263 | [
"def",
"parse_innotop_mode_m",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"infile",
",",
"'r'",
")",
"as",
"infh",
":",
"# Pre processing to figure out different headers",
"max_row_quot",
"=",
"0",
"valrow",
"=",
"-",
"1",
"thisrowcolumns",
"=",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | highlight_region | Highlight a region on the chart between the specified start and end x-co-ordinates.
param pyplot plt: matplotlibk pyplot which contains the charts to be highlighted
param string start_x : epoch time millis
param string end_x : epoch time millis | src/naarad/graphing/matplotlib_naarad.py | def highlight_region(plt, start_x, end_x):
"""
Highlight a region on the chart between the specified start and end x-co-ordinates.
param pyplot plt: matplotlibk pyplot which contains the charts to be highlighted
param string start_x : epoch time millis
param string end_x : epoch time millis
"""
start_x = ... | def highlight_region(plt, start_x, end_x):
"""
Highlight a region on the chart between the specified start and end x-co-ordinates.
param pyplot plt: matplotlibk pyplot which contains the charts to be highlighted
param string start_x : epoch time millis
param string end_x : epoch time millis
"""
start_x = ... | [
"Highlight",
"a",
"region",
"on",
"the",
"chart",
"between",
"the",
"specified",
"start",
"and",
"end",
"x",
"-",
"co",
"-",
"ordinates",
".",
"param",
"pyplot",
"plt",
":",
"matplotlibk",
"pyplot",
"which",
"contains",
"the",
"charts",
"to",
"be",
"highli... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/graphing/matplotlib_naarad.py#L74-L83 | [
"def",
"highlight_region",
"(",
"plt",
",",
"start_x",
",",
"end_x",
")",
":",
"start_x",
"=",
"convert_to_mdate",
"(",
"start_x",
")",
"end_x",
"=",
"convert_to_mdate",
"(",
"end_x",
")",
"plt",
".",
"axvspan",
"(",
"start_x",
",",
"end_x",
",",
"color",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | graph_data_on_the_same_graph | graph_data_on_the_same_graph: put a list of plots on the same graph: currently it supports CDF | src/naarad/graphing/matplotlib_naarad.py | def graph_data_on_the_same_graph(list_of_plots, output_directory, resource_path, output_filename):
"""
graph_data_on_the_same_graph: put a list of plots on the same graph: currently it supports CDF
"""
maximum_yvalue = -float('inf')
minimum_yvalue = float('inf')
plots = curate_plot_list(list_of_plots)
plo... | def graph_data_on_the_same_graph(list_of_plots, output_directory, resource_path, output_filename):
"""
graph_data_on_the_same_graph: put a list of plots on the same graph: currently it supports CDF
"""
maximum_yvalue = -float('inf')
minimum_yvalue = float('inf')
plots = curate_plot_list(list_of_plots)
plo... | [
"graph_data_on_the_same_graph",
":",
"put",
"a",
"list",
"of",
"plots",
"on",
"the",
"same",
"graph",
":",
"currently",
"it",
"supports",
"CDF"
] | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/graphing/matplotlib_naarad.py#L154-L198 | [
"def",
"graph_data_on_the_same_graph",
"(",
"list_of_plots",
",",
"output_directory",
",",
"resource_path",
",",
"output_filename",
")",
":",
"maximum_yvalue",
"=",
"-",
"float",
"(",
"'inf'",
")",
"minimum_yvalue",
"=",
"float",
"(",
"'inf'",
")",
"plots",
"=",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | DerivativeDetector._set_scores | Compute anomaly scores for the time series. | lib/luminol/src/luminol/algorithms/anomaly_detector_algorithms/derivative_detector.py | def _set_scores(self):
"""
Compute anomaly scores for the time series.
"""
anom_scores = {}
self._compute_derivatives()
derivatives_ema = utils.compute_ema(self.smoothing_factor, self.derivatives)
for i, (timestamp, value) in enumerate(self.time_series_items):
anom_scores[timestamp] = ... | def _set_scores(self):
"""
Compute anomaly scores for the time series.
"""
anom_scores = {}
self._compute_derivatives()
derivatives_ema = utils.compute_ema(self.smoothing_factor, self.derivatives)
for i, (timestamp, value) in enumerate(self.time_series_items):
anom_scores[timestamp] = ... | [
"Compute",
"anomaly",
"scores",
"for",
"the",
"time",
"series",
"."
] | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/lib/luminol/src/luminol/algorithms/anomaly_detector_algorithms/derivative_detector.py#L57-L70 | [
"def",
"_set_scores",
"(",
"self",
")",
":",
"anom_scores",
"=",
"{",
"}",
"self",
".",
"_compute_derivatives",
"(",
")",
"derivatives_ema",
"=",
"utils",
".",
"compute_ema",
"(",
"self",
".",
"smoothing_factor",
",",
"self",
".",
"derivatives",
")",
"for",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | SARMetric.extract_metric_name | Method to extract SAR metric names from the section given in the config. The SARMetric class assumes that
the section name will contain the SAR types listed in self.supported_sar_types tuple
:param str metric_name: Section name from the config
:return: str which identifies what kind of SAR metric the secti... | src/naarad/metrics/sar_metric.py | def extract_metric_name(self, metric_name):
"""
Method to extract SAR metric names from the section given in the config. The SARMetric class assumes that
the section name will contain the SAR types listed in self.supported_sar_types tuple
:param str metric_name: Section name from the config
:return... | def extract_metric_name(self, metric_name):
"""
Method to extract SAR metric names from the section given in the config. The SARMetric class assumes that
the section name will contain the SAR types listed in self.supported_sar_types tuple
:param str metric_name: Section name from the config
:return... | [
"Method",
"to",
"extract",
"SAR",
"metric",
"names",
"from",
"the",
"section",
"given",
"in",
"the",
"config",
".",
"The",
"SARMetric",
"class",
"assumes",
"that",
"the",
"section",
"name",
"will",
"contain",
"the",
"SAR",
"types",
"listed",
"in",
"self",
... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/sar_metric.py#L47-L60 | [
"def",
"extract_metric_name",
"(",
"self",
",",
"metric_name",
")",
":",
"for",
"metric_type",
"in",
"self",
".",
"supported_sar_types",
":",
"if",
"metric_type",
"in",
"metric_name",
":",
"return",
"metric_type",
"logger",
".",
"error",
"(",
"'Section [%s] does n... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | CrossCorrelator._find_allowed_shift | Find the maximum allowed shift steps based on max_shift_milliseconds.
param list timestamps: timestamps of a time series. | lib/luminol/src/luminol/algorithms/correlator_algorithms/cross_correlator.py | def _find_allowed_shift(self, timestamps):
"""
Find the maximum allowed shift steps based on max_shift_milliseconds.
param list timestamps: timestamps of a time series.
"""
init_ts = timestamps[0]
residual_timestamps = map(lambda ts: ts - init_ts, timestamps)
n = len(residual_timestamps)
... | def _find_allowed_shift(self, timestamps):
"""
Find the maximum allowed shift steps based on max_shift_milliseconds.
param list timestamps: timestamps of a time series.
"""
init_ts = timestamps[0]
residual_timestamps = map(lambda ts: ts - init_ts, timestamps)
n = len(residual_timestamps)
... | [
"Find",
"the",
"maximum",
"allowed",
"shift",
"steps",
"based",
"on",
"max_shift_milliseconds",
".",
"param",
"list",
"timestamps",
":",
"timestamps",
"of",
"a",
"time",
"series",
"."
] | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/lib/luminol/src/luminol/algorithms/correlator_algorithms/cross_correlator.py#L84-L92 | [
"def",
"_find_allowed_shift",
"(",
"self",
",",
"timestamps",
")",
":",
"init_ts",
"=",
"timestamps",
"[",
"0",
"]",
"residual_timestamps",
"=",
"map",
"(",
"lambda",
"ts",
":",
"ts",
"-",
"init_ts",
",",
"timestamps",
")",
"n",
"=",
"len",
"(",
"residua... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | CrossCorrelator._find_first_bigger | Find the first element in timestamps whose value is bigger than target.
param list values: list of timestamps(epoch number).
param target: target value.
param lower_bound: lower bound for binary search.
param upper_bound: upper bound for binary search. | lib/luminol/src/luminol/algorithms/correlator_algorithms/cross_correlator.py | def _find_first_bigger(self, timestamps, target, lower_bound, upper_bound):
"""
Find the first element in timestamps whose value is bigger than target.
param list values: list of timestamps(epoch number).
param target: target value.
param lower_bound: lower bound for binary search.
param upper_b... | def _find_first_bigger(self, timestamps, target, lower_bound, upper_bound):
"""
Find the first element in timestamps whose value is bigger than target.
param list values: list of timestamps(epoch number).
param target: target value.
param lower_bound: lower bound for binary search.
param upper_b... | [
"Find",
"the",
"first",
"element",
"in",
"timestamps",
"whose",
"value",
"is",
"bigger",
"than",
"target",
".",
"param",
"list",
"values",
":",
"list",
"of",
"timestamps",
"(",
"epoch",
"number",
")",
".",
"param",
"target",
":",
"target",
"value",
".",
... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/lib/luminol/src/luminol/algorithms/correlator_algorithms/cross_correlator.py#L94-L108 | [
"def",
"_find_first_bigger",
"(",
"self",
",",
"timestamps",
",",
"target",
",",
"lower_bound",
",",
"upper_bound",
")",
":",
"while",
"lower_bound",
"<",
"upper_bound",
":",
"pos",
"=",
"lower_bound",
"+",
"(",
"upper_bound",
"-",
"lower_bound",
")",
"/",
"... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad.create_analysis | Create Analysis and save in Naarad from config
:param config:
:return: | src/naarad/__init__.py | def create_analysis(self, config):
"""
Create Analysis and save in Naarad from config
:param config:
:return:
"""
self._default_test_id += 1
self._analyses[self._default_test_id] = _Analysis(ts_start=None, config=config, test_id=self._default_test_id) | def create_analysis(self, config):
"""
Create Analysis and save in Naarad from config
:param config:
:return:
"""
self._default_test_id += 1
self._analyses[self._default_test_id] = _Analysis(ts_start=None, config=config, test_id=self._default_test_id) | [
"Create",
"Analysis",
"and",
"save",
"in",
"Naarad",
"from",
"config",
":",
"param",
"config",
":",
":",
"return",
":"
] | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L74-L81 | [
"def",
"create_analysis",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"_default_test_id",
"+=",
"1",
"self",
".",
"_analyses",
"[",
"self",
".",
"_default_test_id",
"]",
"=",
"_Analysis",
"(",
"ts_start",
"=",
"None",
",",
"config",
"=",
"config",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad.signal_start | Initialize an analysis object and set ts_start for the analysis represented by test_id
:param test_id: integer that represents the analysis
:param config: config can be a ConfigParser.ConfigParser object or a string specifying local or http(s) location
for config
:return: test_id | src/naarad/__init__.py | def signal_start(self, config, test_id=None, **kwargs):
"""
Initialize an analysis object and set ts_start for the analysis represented by test_id
:param test_id: integer that represents the analysis
:param config: config can be a ConfigParser.ConfigParser object or a string specifying local or http(s) ... | def signal_start(self, config, test_id=None, **kwargs):
"""
Initialize an analysis object and set ts_start for the analysis represented by test_id
:param test_id: integer that represents the analysis
:param config: config can be a ConfigParser.ConfigParser object or a string specifying local or http(s) ... | [
"Initialize",
"an",
"analysis",
"object",
"and",
"set",
"ts_start",
"for",
"the",
"analysis",
"represented",
"by",
"test_id",
":",
"param",
"test_id",
":",
"integer",
"that",
"represents",
"the",
"analysis",
":",
"param",
"config",
":",
"config",
"can",
"be",
... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L83-L103 | [
"def",
"signal_start",
"(",
"self",
",",
"config",
",",
"test_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"test_id",
":",
"self",
".",
"_default_test_id",
"+=",
"1",
"test_id",
"=",
"self",
".",
"_default_test_id",
"self",
".",
"_... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad.signal_stop | Set ts_end for the analysis represented by test_id
:param test_id: integer that represents the analysis
:return: test_id | src/naarad/__init__.py | def signal_stop(self, test_id=None):
"""
Set ts_end for the analysis represented by test_id
:param test_id: integer that represents the analysis
:return: test_id
"""
if test_id is None:
test_id = self._default_test_id
if self._analyses[test_id].ts_end:
return CONSTANTS.OK
sel... | def signal_stop(self, test_id=None):
"""
Set ts_end for the analysis represented by test_id
:param test_id: integer that represents the analysis
:return: test_id
"""
if test_id is None:
test_id = self._default_test_id
if self._analyses[test_id].ts_end:
return CONSTANTS.OK
sel... | [
"Set",
"ts_end",
"for",
"the",
"analysis",
"represented",
"by",
"test_id",
":",
"param",
"test_id",
":",
"integer",
"that",
"represents",
"the",
"analysis",
":",
"return",
":",
"test_id"
] | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L105-L116 | [
"def",
"signal_stop",
"(",
"self",
",",
"test_id",
"=",
"None",
")",
":",
"if",
"test_id",
"is",
"None",
":",
"test_id",
"=",
"self",
".",
"_default_test_id",
"if",
"self",
".",
"_analyses",
"[",
"test_id",
"]",
".",
"ts_end",
":",
"return",
"CONSTANTS",... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad.get_failed_analyses | Returns a list of test_id for which naarad analysis failed
:return: list of test_ids | src/naarad/__init__.py | def get_failed_analyses(self):
"""
Returns a list of test_id for which naarad analysis failed
:return: list of test_ids
"""
failed_analyses = []
for test_id in self._analyses.keys():
if self._analyses[test_id].status != CONSTANTS.OK:
failed_analyses.append(test_id)
return faile... | def get_failed_analyses(self):
"""
Returns a list of test_id for which naarad analysis failed
:return: list of test_ids
"""
failed_analyses = []
for test_id in self._analyses.keys():
if self._analyses[test_id].status != CONSTANTS.OK:
failed_analyses.append(test_id)
return faile... | [
"Returns",
"a",
"list",
"of",
"test_id",
"for",
"which",
"naarad",
"analysis",
"failed",
":",
"return",
":",
"list",
"of",
"test_ids"
] | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L118-L127 | [
"def",
"get_failed_analyses",
"(",
"self",
")",
":",
"failed_analyses",
"=",
"[",
"]",
"for",
"test_id",
"in",
"self",
".",
"_analyses",
".",
"keys",
"(",
")",
":",
"if",
"self",
".",
"_analyses",
"[",
"test_id",
"]",
".",
"status",
"!=",
"CONSTANTS",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad._set_sla_data | Get sla data from each metric and set it in the _Analysis object specified by test_id to make it available
for retrieval
:return: currently always returns CONSTANTS.OK. Maybe enhanced in future to return additional status | src/naarad/__init__.py | def _set_sla_data(self, test_id, metrics):
"""
Get sla data from each metric and set it in the _Analysis object specified by test_id to make it available
for retrieval
:return: currently always returns CONSTANTS.OK. Maybe enhanced in future to return additional status
"""
for metric in metrics:
... | def _set_sla_data(self, test_id, metrics):
"""
Get sla data from each metric and set it in the _Analysis object specified by test_id to make it available
for retrieval
:return: currently always returns CONSTANTS.OK. Maybe enhanced in future to return additional status
"""
for metric in metrics:
... | [
"Get",
"sla",
"data",
"from",
"each",
"metric",
"and",
"set",
"it",
"in",
"the",
"_Analysis",
"object",
"specified",
"by",
"test_id",
"to",
"make",
"it",
"available",
"for",
"retrieval",
":",
"return",
":",
"currently",
"always",
"returns",
"CONSTANTS",
".",... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L136-L144 | [
"def",
"_set_sla_data",
"(",
"self",
",",
"test_id",
",",
"metrics",
")",
":",
"for",
"metric",
"in",
"metrics",
":",
"self",
".",
"_analyses",
"[",
"test_id",
"]",
".",
"sla_data",
"[",
"metric",
".",
"label",
"]",
"=",
"metric",
".",
"sla_map",
"retu... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad._set_stats_data | Get summary stats data from each metric and set it in the _Analysis object specified by test_id to make it available
for retrieval
:return: currently always returns CONSTANTS.OK. Maybe enhanced in future to return additional status | src/naarad/__init__.py | def _set_stats_data(self, test_id, metrics):
"""
Get summary stats data from each metric and set it in the _Analysis object specified by test_id to make it available
for retrieval
:return: currently always returns CONSTANTS.OK. Maybe enhanced in future to return additional status
"""
for metric ... | def _set_stats_data(self, test_id, metrics):
"""
Get summary stats data from each metric and set it in the _Analysis object specified by test_id to make it available
for retrieval
:return: currently always returns CONSTANTS.OK. Maybe enhanced in future to return additional status
"""
for metric ... | [
"Get",
"summary",
"stats",
"data",
"from",
"each",
"metric",
"and",
"set",
"it",
"in",
"the",
"_Analysis",
"object",
"specified",
"by",
"test_id",
"to",
"make",
"it",
"available",
"for",
"retrieval",
":",
"return",
":",
"currently",
"always",
"returns",
"CON... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L153-L161 | [
"def",
"_set_stats_data",
"(",
"self",
",",
"test_id",
",",
"metrics",
")",
":",
"for",
"metric",
"in",
"metrics",
":",
"self",
".",
"_analyses",
"[",
"test_id",
"]",
".",
"stats_data",
"[",
"metric",
".",
"label",
"]",
"=",
"metric",
".",
"summary_stats... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad._create_output_directories | Create the necessary output and resource directories for the specified analysis
:param: analysis: analysis associated with a given test_id | src/naarad/__init__.py | def _create_output_directories(self, analysis):
"""
Create the necessary output and resource directories for the specified analysis
:param: analysis: analysis associated with a given test_id
"""
try:
os.makedirs(analysis.output_directory)
except OSError as exception:
if exception.err... | def _create_output_directories(self, analysis):
"""
Create the necessary output and resource directories for the specified analysis
:param: analysis: analysis associated with a given test_id
"""
try:
os.makedirs(analysis.output_directory)
except OSError as exception:
if exception.err... | [
"Create",
"the",
"necessary",
"output",
"and",
"resource",
"directories",
"for",
"the",
"specified",
"analysis",
":",
"param",
":",
"analysis",
":",
"analysis",
"associated",
"with",
"a",
"given",
"test_id"
] | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L163-L178 | [
"def",
"_create_output_directories",
"(",
"self",
",",
"analysis",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"analysis",
".",
"output_directory",
")",
"except",
"OSError",
"as",
"exception",
":",
"if",
"exception",
".",
"errno",
"!=",
"errno",
".",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad._run_pre | If Naarad is run in CLI mode, execute any pre run steps specified in the config. ts_start/ts_end are set based on
workload run steps if any.
:param: analysis: The analysis object being processed
:param: run_steps: list of post run steps | src/naarad/__init__.py | def _run_pre(self, analysis, run_steps):
"""
If Naarad is run in CLI mode, execute any pre run steps specified in the config. ts_start/ts_end are set based on
workload run steps if any.
:param: analysis: The analysis object being processed
:param: run_steps: list of post run steps
"""
worklo... | def _run_pre(self, analysis, run_steps):
"""
If Naarad is run in CLI mode, execute any pre run steps specified in the config. ts_start/ts_end are set based on
workload run steps if any.
:param: analysis: The analysis object being processed
:param: run_steps: list of post run steps
"""
worklo... | [
"If",
"Naarad",
"is",
"run",
"in",
"CLI",
"mode",
"execute",
"any",
"pre",
"run",
"steps",
"specified",
"in",
"the",
"config",
".",
"ts_start",
"/",
"ts_end",
"are",
"set",
"based",
"on",
"workload",
"run",
"steps",
"if",
"any",
".",
":",
"param",
":",... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L180-L195 | [
"def",
"_run_pre",
"(",
"self",
",",
"analysis",
",",
"run_steps",
")",
":",
"workload_run_steps",
"=",
"[",
"]",
"for",
"run_step",
"in",
"sorted",
"(",
"run_steps",
",",
"key",
"=",
"lambda",
"step",
":",
"step",
".",
"run_rank",
")",
":",
"run_step",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad._run_post | If Naarad is run in CLI mode, execute any post run steps specified in the config
:param: run_steps: list of post run steps | src/naarad/__init__.py | def _run_post(self, run_steps):
"""
If Naarad is run in CLI mode, execute any post run steps specified in the config
:param: run_steps: list of post run steps
"""
for run_step in sorted(run_steps, key=lambda step: step.run_rank):
run_step.run()
return CONSTANTS.OK | def _run_post(self, run_steps):
"""
If Naarad is run in CLI mode, execute any post run steps specified in the config
:param: run_steps: list of post run steps
"""
for run_step in sorted(run_steps, key=lambda step: step.run_rank):
run_step.run()
return CONSTANTS.OK | [
"If",
"Naarad",
"is",
"run",
"in",
"CLI",
"mode",
"execute",
"any",
"post",
"run",
"steps",
"specified",
"in",
"the",
"config",
":",
"param",
":",
"run_steps",
":",
"list",
"of",
"post",
"run",
"steps"
] | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L197-L204 | [
"def",
"_run_post",
"(",
"self",
",",
"run_steps",
")",
":",
"for",
"run_step",
"in",
"sorted",
"(",
"run_steps",
",",
"key",
"=",
"lambda",
"step",
":",
"step",
".",
"run_rank",
")",
":",
"run_step",
".",
"run",
"(",
")",
"return",
"CONSTANTS",
".",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad._process_args | When Naarad is run in CLI mode, get the CL arguments and update the analysis
:param: analysis: The analysis being processed
:param: args: Command Line Arguments received by naarad | src/naarad/__init__.py | def _process_args(self, analysis, args):
"""
When Naarad is run in CLI mode, get the CL arguments and update the analysis
:param: analysis: The analysis being processed
:param: args: Command Line Arguments received by naarad
"""
if args.exit_code:
self.return_exit_code = args.exit_code
... | def _process_args(self, analysis, args):
"""
When Naarad is run in CLI mode, get the CL arguments and update the analysis
:param: analysis: The analysis being processed
:param: args: Command Line Arguments received by naarad
"""
if args.exit_code:
self.return_exit_code = args.exit_code
... | [
"When",
"Naarad",
"is",
"run",
"in",
"CLI",
"mode",
"get",
"the",
"CL",
"arguments",
"and",
"update",
"the",
"analysis",
":",
"param",
":",
"analysis",
":",
"The",
"analysis",
"being",
"processed",
":",
"param",
":",
"args",
":",
"Command",
"Line",
"Argu... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L206-L222 | [
"def",
"_process_args",
"(",
"self",
",",
"analysis",
",",
"args",
")",
":",
"if",
"args",
".",
"exit_code",
":",
"self",
".",
"return_exit_code",
"=",
"args",
".",
"exit_code",
"if",
"args",
".",
"no_plots",
":",
"self",
".",
"skip_plots",
"=",
"args",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad.analyze | Run all the analysis saved in self._analyses, sorted by test_id.
This is useful when Naarad() is used by other programs and multiple analyses are run
In naarad CLI mode, len(_analyses) == 1
:param: input_directory: location of log files
:param: output_directory: root directory for analysis output
:p... | src/naarad/__init__.py | def analyze(self, input_directory, output_directory, **kwargs):
"""
Run all the analysis saved in self._analyses, sorted by test_id.
This is useful when Naarad() is used by other programs and multiple analyses are run
In naarad CLI mode, len(_analyses) == 1
:param: input_directory: location of log f... | def analyze(self, input_directory, output_directory, **kwargs):
"""
Run all the analysis saved in self._analyses, sorted by test_id.
This is useful when Naarad() is used by other programs and multiple analyses are run
In naarad CLI mode, len(_analyses) == 1
:param: input_directory: location of log f... | [
"Run",
"all",
"the",
"analysis",
"saved",
"in",
"self",
".",
"_analyses",
"sorted",
"by",
"test_id",
".",
"This",
"is",
"useful",
"when",
"Naarad",
"()",
"is",
"used",
"by",
"other",
"programs",
"and",
"multiple",
"analyses",
"are",
"run",
"In",
"naarad",
... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L224-L266 | [
"def",
"analyze",
"(",
"self",
",",
"input_directory",
",",
"output_directory",
",",
"*",
"*",
"kwargs",
")",
":",
"is_api_call",
"=",
"True",
"if",
"len",
"(",
"self",
".",
"_analyses",
")",
"==",
"0",
":",
"if",
"'config'",
"not",
"in",
"kwargs",
"."... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad.run | :param analysis: Run naarad analysis for the specified analysis object
:param **kwargs: Additional keyword args can be passed in here for future enhancements
:return: | src/naarad/__init__.py | def run(self, analysis, is_api_call, **kwargs):
"""
:param analysis: Run naarad analysis for the specified analysis object
:param **kwargs: Additional keyword args can be passed in here for future enhancements
:return:
"""
threads = []
crossplots = []
report_args = {}
metrics = defau... | def run(self, analysis, is_api_call, **kwargs):
"""
:param analysis: Run naarad analysis for the specified analysis object
:param **kwargs: Additional keyword args can be passed in here for future enhancements
:return:
"""
threads = []
crossplots = []
report_args = {}
metrics = defau... | [
":",
"param",
"analysis",
":",
"Run",
"naarad",
"analysis",
"for",
"the",
"specified",
"analysis",
"object",
":",
"param",
"**",
"kwargs",
":",
"Additional",
"keyword",
"args",
"can",
"be",
"passed",
"in",
"here",
"for",
"future",
"enhancements",
":",
"retur... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L268-L351 | [
"def",
"run",
"(",
"self",
",",
"analysis",
",",
"is_api_call",
",",
"*",
"*",
"kwargs",
")",
":",
"threads",
"=",
"[",
"]",
"crossplots",
"=",
"[",
"]",
"report_args",
"=",
"{",
"}",
"metrics",
"=",
"defaultdict",
"(",
")",
"run_steps",
"=",
"defaul... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad.diff | Create a diff report using test_id_1 as a baseline
:param: test_id_1: test id to be used as baseline
:param: test_id_2: test id to compare against baseline
:param: config file for diff (optional)
:param: **kwargs: keyword arguments | src/naarad/__init__.py | def diff(self, test_id_1, test_id_2, config=None, **kwargs):
"""
Create a diff report using test_id_1 as a baseline
:param: test_id_1: test id to be used as baseline
:param: test_id_2: test id to compare against baseline
:param: config file for diff (optional)
:param: **kwargs: keyword arguments... | def diff(self, test_id_1, test_id_2, config=None, **kwargs):
"""
Create a diff report using test_id_1 as a baseline
:param: test_id_1: test id to be used as baseline
:param: test_id_2: test id to compare against baseline
:param: config file for diff (optional)
:param: **kwargs: keyword arguments... | [
"Create",
"a",
"diff",
"report",
"using",
"test_id_1",
"as",
"a",
"baseline",
":",
"param",
":",
"test_id_1",
":",
"test",
"id",
"to",
"be",
"used",
"as",
"baseline",
":",
"param",
":",
"test_id_2",
":",
"test",
"id",
"to",
"compare",
"against",
"baselin... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L353-L376 | [
"def",
"diff",
"(",
"self",
",",
"test_id_1",
",",
"test_id_2",
",",
"config",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"output_directory",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_output_directory",
",",
"'diff_'",
"+",
"str",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad.diff_reports_by_location | Create a diff report using report1 as a baseline
:param: report1_location: report to be used as baseline
:param: report2_location: report to compare against baseline
:param: config file for diff (optional)
:param: **kwargs: keyword arguments | src/naarad/__init__.py | def diff_reports_by_location(self, report1_location, report2_location, output_directory, config=None, **kwargs):
"""
Create a diff report using report1 as a baseline
:param: report1_location: report to be used as baseline
:param: report2_location: report to compare against baseline
:param: config fi... | def diff_reports_by_location(self, report1_location, report2_location, output_directory, config=None, **kwargs):
"""
Create a diff report using report1 as a baseline
:param: report1_location: report to be used as baseline
:param: report2_location: report to compare against baseline
:param: config fi... | [
"Create",
"a",
"diff",
"report",
"using",
"report1",
"as",
"a",
"baseline",
":",
"param",
":",
"report1_location",
":",
"report",
"to",
"be",
"used",
"as",
"baseline",
":",
"param",
":",
"report2_location",
":",
"report",
"to",
"compare",
"against",
"baselin... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L378-L399 | [
"def",
"diff_reports_by_location",
"(",
"self",
",",
"report1_location",
",",
"report2_location",
",",
"output_directory",
",",
"config",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
":",
"if",
"'output_directory'",
"in",
"kwargs",
".",
"key... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | Naarad._process_naarad_config | Process the config file associated with a particular analysis and return metrics, run_steps and crossplots.
Also sets output directory and resource_path for an anlaysis | src/naarad/__init__.py | def _process_naarad_config(self, config, analysis):
"""
Process the config file associated with a particular analysis and return metrics, run_steps and crossplots.
Also sets output directory and resource_path for an anlaysis
"""
graph_timezone = None
output_directory = analysis.output_directory
... | def _process_naarad_config(self, config, analysis):
"""
Process the config file associated with a particular analysis and return metrics, run_steps and crossplots.
Also sets output directory and resource_path for an anlaysis
"""
graph_timezone = None
output_directory = analysis.output_directory
... | [
"Process",
"the",
"config",
"file",
"associated",
"with",
"a",
"particular",
"analysis",
"and",
"return",
"metrics",
"run_steps",
"and",
"crossplots",
".",
"Also",
"sets",
"output",
"directory",
"and",
"resource_path",
"for",
"an",
"anlaysis"
] | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L401-L475 | [
"def",
"_process_naarad_config",
"(",
"self",
",",
"config",
",",
"analysis",
")",
":",
"graph_timezone",
"=",
"None",
"output_directory",
"=",
"analysis",
".",
"output_directory",
"resource_path",
"=",
"analysis",
".",
"resource_path",
"run_steps",
"=",
"defaultdic... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | ProcZoneinfoMetric.parse | Parse the vmstat file
:return: status of the metric parse | src/naarad/metrics/proczoneinfo_metric.py | def parse(self):
"""
Parse the vmstat file
:return: status of the metric parse
"""
file_status = True
for input_file in self.infile_list:
file_status = file_status and naarad.utils.is_valid_file(input_file)
if not file_status:
return False
status = True
cur_zone = No... | def parse(self):
"""
Parse the vmstat file
:return: status of the metric parse
"""
file_status = True
for input_file in self.infile_list:
file_status = file_status and naarad.utils.is_valid_file(input_file)
if not file_status:
return False
status = True
cur_zone = No... | [
"Parse",
"the",
"vmstat",
"file",
":",
"return",
":",
"status",
"of",
"the",
"metric",
"parse"
] | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/proczoneinfo_metric.py#L63-L129 | [
"def",
"parse",
"(",
"self",
")",
":",
"file_status",
"=",
"True",
"for",
"input_file",
"in",
"self",
".",
"infile_list",
":",
"file_status",
"=",
"file_status",
"and",
"naarad",
".",
"utils",
".",
"is_valid_file",
"(",
"input_file",
")",
"if",
"not",
"fil... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | ClusterMetric.collect | Take a list of metrics, filter all metrics based on hostname, and metric_type
For each metric, merge the corresponding csv files into one,update corresponding properties such as csv_column_map.
Users can specify functions: raw, count (qps), sum (aggregated value), avg (averaged value)
The timestamp granular... | src/naarad/metrics/cluster_metric.py | def collect(self):
"""
Take a list of metrics, filter all metrics based on hostname, and metric_type
For each metric, merge the corresponding csv files into one,update corresponding properties such as csv_column_map.
Users can specify functions: raw, count (qps), sum (aggregated value), avg (averaged va... | def collect(self):
"""
Take a list of metrics, filter all metrics based on hostname, and metric_type
For each metric, merge the corresponding csv files into one,update corresponding properties such as csv_column_map.
Users can specify functions: raw, count (qps), sum (aggregated value), avg (averaged va... | [
"Take",
"a",
"list",
"of",
"metrics",
"filter",
"all",
"metrics",
"based",
"on",
"hostname",
"and",
"metric_type",
"For",
"each",
"metric",
"merge",
"the",
"corresponding",
"csv",
"files",
"into",
"one",
"update",
"corresponding",
"properties",
"such",
"as",
"... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/cluster_metric.py#L54-L130 | [
"def",
"collect",
"(",
"self",
")",
":",
"for",
"aggr_metric",
"in",
"self",
".",
"aggr_metrics",
":",
"# e.g., SAR-device.sda.await:count,sum,avg",
"functions_aggr",
"=",
"[",
"]",
"fields",
"=",
"aggr_metric",
".",
"split",
"(",
"\":\"",
")",
"cur_metric_type",
... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | LinkedInAndroidRumMetric.get_times | get start time stamp, launch time duration, and nus update time duration from JSON object native
:param JSON OBJECT native
:return: LONG event time stamp, LONG launch time, and LONG nus update time | src/naarad/metrics/linkedin_android_rum_metric.py | def get_times(self, native):
"""
get start time stamp, launch time duration, and nus update time duration from JSON object native
:param JSON OBJECT native
:return: LONG event time stamp, LONG launch time, and LONG nus update time
"""
start_time = 0
end_time = 0
launch_time = 0
nus_u... | def get_times(self, native):
"""
get start time stamp, launch time duration, and nus update time duration from JSON object native
:param JSON OBJECT native
:return: LONG event time stamp, LONG launch time, and LONG nus update time
"""
start_time = 0
end_time = 0
launch_time = 0
nus_u... | [
"get",
"start",
"time",
"stamp",
"launch",
"time",
"duration",
"and",
"nus",
"update",
"time",
"duration",
"from",
"JSON",
"object",
"native",
":",
"param",
"JSON",
"OBJECT",
"native",
":",
"return",
":",
"LONG",
"event",
"time",
"stamp",
"LONG",
"launch",
... | linkedin/naarad | python | https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/linkedin_android_rum_metric.py#L55-L81 | [
"def",
"get_times",
"(",
"self",
",",
"native",
")",
":",
"start_time",
"=",
"0",
"end_time",
"=",
"0",
"launch_time",
"=",
"0",
"nus_update_time",
"=",
"0",
"for",
"item",
"in",
"native",
":",
"if",
"item",
"[",
"CONSTANTS",
".",
"LIA_TIMING_NAME",
"]",... | 261e2c0760fd6a6b0ee59064180bd8e3674311fe |
valid | SpeedCheck.run | Perform the Oct2Py speed analysis.
Uses timeit to test the raw execution of an Octave command,
Then tests progressively larger array passing. | oct2py/speed_check.py | def run(self):
"""Perform the Oct2Py speed analysis.
Uses timeit to test the raw execution of an Octave command,
Then tests progressively larger array passing.
"""
print('Oct2Py speed test')
print('*' * 20)
time.sleep(1)
print('Raw speed: ')
... | def run(self):
"""Perform the Oct2Py speed analysis.
Uses timeit to test the raw execution of an Octave command,
Then tests progressively larger array passing.
"""
print('Oct2Py speed test')
print('*' * 20)
time.sleep(1)
print('Raw speed: ')
... | [
"Perform",
"the",
"Oct2Py",
"speed",
"analysis",
".",
"Uses",
"timeit",
"to",
"test",
"the",
"raw",
"execution",
"of",
"an",
"Octave",
"command",
"Then",
"tests",
"progressively",
"larger",
"array",
"passing",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/speed_check.py#L40-L68 | [
"def",
"run",
"(",
"self",
")",
":",
"print",
"(",
"'Oct2Py speed test'",
")",
"print",
"(",
"'*'",
"*",
"20",
")",
"time",
".",
"sleep",
"(",
"1",
")",
"print",
"(",
"'Raw speed: '",
")",
"avg",
"=",
"timeit",
".",
"timeit",
"(",
"self",
".",
"raw... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py.exit | Quits this octave session and cleans up. | oct2py/core.py | def exit(self):
"""Quits this octave session and cleans up.
"""
if self._engine:
self._engine.repl.terminate()
self._engine = None | def exit(self):
"""Quits this octave session and cleans up.
"""
if self._engine:
self._engine.repl.terminate()
self._engine = None | [
"Quits",
"this",
"octave",
"session",
"and",
"cleans",
"up",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L106-L111 | [
"def",
"exit",
"(",
"self",
")",
":",
"if",
"self",
".",
"_engine",
":",
"self",
".",
"_engine",
".",
"repl",
".",
"terminate",
"(",
")",
"self",
".",
"_engine",
"=",
"None"
] | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py.push | Put a variable or variables into the Octave session.
Parameters
----------
name : str or list
Name of the variable(s).
var : object or list
The value(s) to pass.
timeout : float
Time to wait for response from Octave (per line).
... | oct2py/core.py | def push(self, name, var, timeout=None, verbose=True):
"""
Put a variable or variables into the Octave session.
Parameters
----------
name : str or list
Name of the variable(s).
var : object or list
The value(s) to pass.
timeout ... | def push(self, name, var, timeout=None, verbose=True):
"""
Put a variable or variables into the Octave session.
Parameters
----------
name : str or list
Name of the variable(s).
var : object or list
The value(s) to pass.
timeout ... | [
"Put",
"a",
"variable",
"or",
"variables",
"into",
"the",
"Octave",
"session",
".",
"Parameters",
"----------",
"name",
":",
"str",
"or",
"list",
"Name",
"of",
"the",
"variable",
"(",
"s",
")",
".",
"var",
":",
"object",
"or",
"list",
"The",
"value",
"... | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L113-L150 | [
"def",
"push",
"(",
"self",
",",
"name",
",",
"var",
",",
"timeout",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"name",
"=",
"[",
"name",
"]",
"var",
"=",... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py.pull | Retrieve a value or values from the Octave session.
Parameters
----------
var : str or list
Name of the variable(s) to retrieve.
timeout : float, optional.
Time to wait for response from Octave (per line).
**kwargs: Deprecated kwargs, ignored.
... | oct2py/core.py | def pull(self, var, timeout=None, verbose=True):
"""
Retrieve a value or values from the Octave session.
Parameters
----------
var : str or list
Name of the variable(s) to retrieve.
timeout : float, optional.
Time to wait for response fro... | def pull(self, var, timeout=None, verbose=True):
"""
Retrieve a value or values from the Octave session.
Parameters
----------
var : str or list
Name of the variable(s) to retrieve.
timeout : float, optional.
Time to wait for response fro... | [
"Retrieve",
"a",
"value",
"or",
"values",
"from",
"the",
"Octave",
"session",
".",
"Parameters",
"----------",
"var",
":",
"str",
"or",
"list",
"Name",
"of",
"the",
"variable",
"(",
"s",
")",
"to",
"retrieve",
".",
"timeout",
":",
"float",
"optional",
".... | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L152-L199 | [
"def",
"pull",
"(",
"self",
",",
"var",
",",
"timeout",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"var",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"var",
"=",
"[",
"var",
"]",
"outputs",
"=",
"[",
"]",
... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py.get_pointer | Get a pointer to a named object in the Octave workspace.
Parameters
----------
name: str
The name of the object in the Octave workspace.
timemout: float, optional.
Time to wait for response from Octave (per line).
Examples
--------
... | oct2py/core.py | def get_pointer(self, name, timeout=None):
"""Get a pointer to a named object in the Octave workspace.
Parameters
----------
name: str
The name of the object in the Octave workspace.
timemout: float, optional.
Time to wait for response from Octave... | def get_pointer(self, name, timeout=None):
"""Get a pointer to a named object in the Octave workspace.
Parameters
----------
name: str
The name of the object in the Octave workspace.
timemout: float, optional.
Time to wait for response from Octave... | [
"Get",
"a",
"pointer",
"to",
"a",
"named",
"object",
"in",
"the",
"Octave",
"workspace",
".",
"Parameters",
"----------",
"name",
":",
"str",
"The",
"name",
"of",
"the",
"object",
"in",
"the",
"Octave",
"workspace",
".",
"timemout",
":",
"float",
"optional... | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L201-L261 | [
"def",
"get_pointer",
"(",
"self",
",",
"name",
",",
"timeout",
"=",
"None",
")",
":",
"exist",
"=",
"self",
".",
"_exist",
"(",
"name",
")",
"isobject",
"=",
"self",
".",
"_isobject",
"(",
"name",
",",
"exist",
")",
"if",
"exist",
"==",
"0",
":",
... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py.extract_figures | Extract the figures in the directory to IPython display objects.
Parameters
----------
plot_dir: str
The plot dir where the figures were created.
remove: bool, optional.
Whether to remove the plot directory after saving. | oct2py/core.py | def extract_figures(self, plot_dir, remove=False):
"""Extract the figures in the directory to IPython display objects.
Parameters
----------
plot_dir: str
The plot dir where the figures were created.
remove: bool, optional.
Whether to remove the p... | def extract_figures(self, plot_dir, remove=False):
"""Extract the figures in the directory to IPython display objects.
Parameters
----------
plot_dir: str
The plot dir where the figures were created.
remove: bool, optional.
Whether to remove the p... | [
"Extract",
"the",
"figures",
"in",
"the",
"directory",
"to",
"IPython",
"display",
"objects",
".",
"Parameters",
"----------",
"plot_dir",
":",
"str",
"The",
"plot",
"dir",
"where",
"the",
"figures",
"were",
"created",
".",
"remove",
":",
"bool",
"optional",
... | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L263-L274 | [
"def",
"extract_figures",
"(",
"self",
",",
"plot_dir",
",",
"remove",
"=",
"False",
")",
":",
"figures",
"=",
"self",
".",
"_engine",
".",
"extract_figures",
"(",
"plot_dir",
",",
"remove",
")",
"return",
"figures"
] | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py.feval | Run a function in Octave and return the result.
Parameters
----------
func_path: str
Name of function to run or a path to an m-file.
func_args: object, optional
Args to send to the function.
nout: int, optional
Desired number of retur... | oct2py/core.py | def feval(self, func_path, *func_args, **kwargs):
"""Run a function in Octave and return the result.
Parameters
----------
func_path: str
Name of function to run or a path to an m-file.
func_args: object, optional
Args to send to the function.
... | def feval(self, func_path, *func_args, **kwargs):
"""Run a function in Octave and return the result.
Parameters
----------
func_path: str
Name of function to run or a path to an m-file.
func_args: object, optional
Args to send to the function.
... | [
"Run",
"a",
"function",
"in",
"Octave",
"and",
"return",
"the",
"result",
".",
"Parameters",
"----------",
"func_path",
":",
"str",
"Name",
"of",
"function",
"to",
"run",
"or",
"a",
"path",
"to",
"an",
"m",
"-",
"file",
".",
"func_args",
":",
"object",
... | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L276-L379 | [
"def",
"feval",
"(",
"self",
",",
"func_path",
",",
"*",
"func_args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"_engine",
":",
"raise",
"Oct2PyError",
"(",
"'Session is not open'",
")",
"nout",
"=",
"kwargs",
".",
"get",
"(",
"'nout... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py.eval | Evaluate an Octave command or commands.
Parameters
----------
cmds : str or list
Commands(s) to pass to Octave.
verbose : bool, optional
Log Octave output at INFO level. If False, log at DEBUG level.
stream_handler: callable, optional
... | oct2py/core.py | def eval(self, cmds, verbose=True, timeout=None, stream_handler=None,
temp_dir=None, plot_dir=None, plot_name='plot', plot_format='svg',
plot_width=None, plot_height=None, plot_res=None,
nout=0, **kwargs):
"""
Evaluate an Octave command or commands.
... | def eval(self, cmds, verbose=True, timeout=None, stream_handler=None,
temp_dir=None, plot_dir=None, plot_name='plot', plot_format='svg',
plot_width=None, plot_height=None, plot_res=None,
nout=0, **kwargs):
"""
Evaluate an Octave command or commands.
... | [
"Evaluate",
"an",
"Octave",
"command",
"or",
"commands",
".",
"Parameters",
"----------",
"cmds",
":",
"str",
"or",
"list",
"Commands",
"(",
"s",
")",
"to",
"pass",
"to",
"Octave",
".",
"verbose",
":",
"bool",
"optional",
"Log",
"Octave",
"output",
"at",
... | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L381-L503 | [
"def",
"eval",
"(",
"self",
",",
"cmds",
",",
"verbose",
"=",
"True",
",",
"timeout",
"=",
"None",
",",
"stream_handler",
"=",
"None",
",",
"temp_dir",
"=",
"None",
",",
"plot_dir",
"=",
"None",
",",
"plot_name",
"=",
"'plot'",
",",
"plot_format",
"=",... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py.restart | Restart an Octave session in a clean state | oct2py/core.py | def restart(self):
"""Restart an Octave session in a clean state
"""
if self._engine:
self._engine.repl.terminate()
executable = self._executable
if executable:
os.environ['OCTAVE_EXECUTABLE'] = executable
if 'OCTAVE_EXECUTABLE' not in os... | def restart(self):
"""Restart an Octave session in a clean state
"""
if self._engine:
self._engine.repl.terminate()
executable = self._executable
if executable:
os.environ['OCTAVE_EXECUTABLE'] = executable
if 'OCTAVE_EXECUTABLE' not in os... | [
"Restart",
"an",
"Octave",
"session",
"in",
"a",
"clean",
"state"
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L505-L521 | [
"def",
"restart",
"(",
"self",
")",
":",
"if",
"self",
".",
"_engine",
":",
"self",
".",
"_engine",
".",
"repl",
".",
"terminate",
"(",
")",
"executable",
"=",
"self",
".",
"_executable",
"if",
"executable",
":",
"os",
".",
"environ",
"[",
"'OCTAVE_EXE... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py._feval | Run the given function with the given args. | oct2py/core.py | def _feval(self, func_name, func_args=(), dname='', nout=0,
timeout=None, stream_handler=None, store_as='', plot_dir=None):
"""Run the given function with the given args.
"""
engine = self._engine
if engine is None:
raise Oct2PyError('Session is closed')
... | def _feval(self, func_name, func_args=(), dname='', nout=0,
timeout=None, stream_handler=None, store_as='', plot_dir=None):
"""Run the given function with the given args.
"""
engine = self._engine
if engine is None:
raise Oct2PyError('Session is closed')
... | [
"Run",
"the",
"given",
"function",
"with",
"the",
"given",
"args",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L523-L593 | [
"def",
"_feval",
"(",
"self",
",",
"func_name",
",",
"func_args",
"=",
"(",
")",
",",
"dname",
"=",
"''",
",",
"nout",
"=",
"0",
",",
"timeout",
"=",
"None",
",",
"stream_handler",
"=",
"None",
",",
"store_as",
"=",
"''",
",",
"plot_dir",
"=",
"Non... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py._parse_error | Create a traceback for an Octave evaluation error. | oct2py/core.py | def _parse_error(self, err):
"""Create a traceback for an Octave evaluation error.
"""
self.logger.debug(err)
stack = err.get('stack', [])
if not err['message'].startswith('parse error:'):
err['message'] = 'error: ' + err['message']
errmsg = 'Octave eva... | def _parse_error(self, err):
"""Create a traceback for an Octave evaluation error.
"""
self.logger.debug(err)
stack = err.get('stack', [])
if not err['message'].startswith('parse error:'):
err['message'] = 'error: ' + err['message']
errmsg = 'Octave eva... | [
"Create",
"a",
"traceback",
"for",
"an",
"Octave",
"evaluation",
"error",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L595-L614 | [
"def",
"_parse_error",
"(",
"self",
",",
"err",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"err",
")",
"stack",
"=",
"err",
".",
"get",
"(",
"'stack'",
",",
"[",
"]",
")",
"if",
"not",
"err",
"[",
"'message'",
"]",
".",
"startswith",
"("... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py._get_doc | Get the documentation of an Octave procedure or object.
Parameters
----------
name : str
Function name to search for.
Returns
-------
out : str
Documentation string.
Raises
------
Oct2PyError
If th... | oct2py/core.py | def _get_doc(self, name):
"""
Get the documentation of an Octave procedure or object.
Parameters
----------
name : str
Function name to search for.
Returns
-------
out : str
Documentation string.
Raises
... | def _get_doc(self, name):
"""
Get the documentation of an Octave procedure or object.
Parameters
----------
name : str
Function name to search for.
Returns
-------
out : str
Documentation string.
Raises
... | [
"Get",
"the",
"documentation",
"of",
"an",
"Octave",
"procedure",
"or",
"object",
".",
"Parameters",
"----------",
"name",
":",
"str",
"Function",
"name",
"to",
"search",
"for",
".",
"Returns",
"-------",
"out",
":",
"str",
"Documentation",
"string",
".",
"R... | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L620-L666 | [
"def",
"_get_doc",
"(",
"self",
",",
"name",
")",
":",
"doc",
"=",
"'No documentation for %s'",
"%",
"name",
"engine",
"=",
"self",
".",
"_engine",
"doc",
"=",
"engine",
".",
"eval",
"(",
"'help(\"%s\")'",
"%",
"name",
",",
"silent",
"=",
"True",
")",
... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py._exist | Test whether a name exists and return the name code.
Raises an error when the name does not exist. | oct2py/core.py | def _exist(self, name):
"""Test whether a name exists and return the name code.
Raises an error when the name does not exist.
"""
cmd = 'exist("%s")' % name
resp = self._engine.eval(cmd, silent=True).strip()
exist = int(resp.split()[-1])
if exist == 0:
... | def _exist(self, name):
"""Test whether a name exists and return the name code.
Raises an error when the name does not exist.
"""
cmd = 'exist("%s")' % name
resp = self._engine.eval(cmd, silent=True).strip()
exist = int(resp.split()[-1])
if exist == 0:
... | [
"Test",
"whether",
"a",
"name",
"exists",
"and",
"return",
"the",
"name",
"code",
".",
"Raises",
"an",
"error",
"when",
"the",
"name",
"does",
"not",
"exist",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L668-L679 | [
"def",
"_exist",
"(",
"self",
",",
"name",
")",
":",
"cmd",
"=",
"'exist(\"%s\")'",
"%",
"name",
"resp",
"=",
"self",
".",
"_engine",
".",
"eval",
"(",
"cmd",
",",
"silent",
"=",
"True",
")",
".",
"strip",
"(",
")",
"exist",
"=",
"int",
"(",
"res... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py._isobject | Test whether the name is an object. | oct2py/core.py | def _isobject(self, name, exist):
"""Test whether the name is an object."""
if exist in [2, 5]:
return False
cmd = 'isobject(%s)' % name
resp = self._engine.eval(cmd, silent=True).strip()
return resp == 'ans = 1' | def _isobject(self, name, exist):
"""Test whether the name is an object."""
if exist in [2, 5]:
return False
cmd = 'isobject(%s)' % name
resp = self._engine.eval(cmd, silent=True).strip()
return resp == 'ans = 1' | [
"Test",
"whether",
"the",
"name",
"is",
"an",
"object",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L681-L687 | [
"def",
"_isobject",
"(",
"self",
",",
"name",
",",
"exist",
")",
":",
"if",
"exist",
"in",
"[",
"2",
",",
"5",
"]",
":",
"return",
"False",
"cmd",
"=",
"'isobject(%s)'",
"%",
"name",
"resp",
"=",
"self",
".",
"_engine",
".",
"eval",
"(",
"cmd",
"... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py._get_function_ptr | Get or create a function pointer of the given name. | oct2py/core.py | def _get_function_ptr(self, name):
"""Get or create a function pointer of the given name."""
func = _make_function_ptr_instance
self._function_ptrs.setdefault(name, func(self, name))
return self._function_ptrs[name] | def _get_function_ptr(self, name):
"""Get or create a function pointer of the given name."""
func = _make_function_ptr_instance
self._function_ptrs.setdefault(name, func(self, name))
return self._function_ptrs[name] | [
"Get",
"or",
"create",
"a",
"function",
"pointer",
"of",
"the",
"given",
"name",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L689-L693 | [
"def",
"_get_function_ptr",
"(",
"self",
",",
"name",
")",
":",
"func",
"=",
"_make_function_ptr_instance",
"self",
".",
"_function_ptrs",
".",
"setdefault",
"(",
"name",
",",
"func",
"(",
"self",
",",
"name",
")",
")",
"return",
"self",
".",
"_function_ptrs... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py._get_user_class | Get or create a user class of the given type. | oct2py/core.py | def _get_user_class(self, name):
"""Get or create a user class of the given type."""
self._user_classes.setdefault(name, _make_user_class(self, name))
return self._user_classes[name] | def _get_user_class(self, name):
"""Get or create a user class of the given type."""
self._user_classes.setdefault(name, _make_user_class(self, name))
return self._user_classes[name] | [
"Get",
"or",
"create",
"a",
"user",
"class",
"of",
"the",
"given",
"type",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L695-L698 | [
"def",
"_get_user_class",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_user_classes",
".",
"setdefault",
"(",
"name",
",",
"_make_user_class",
"(",
"self",
",",
"name",
")",
")",
"return",
"self",
".",
"_user_classes",
"[",
"name",
"]"
] | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | Oct2Py._cleanup | Clean up resources used by the session. | oct2py/core.py | def _cleanup(self):
"""Clean up resources used by the session.
"""
self.exit()
workspace = osp.join(os.getcwd(), 'octave-workspace')
if osp.exists(workspace):
os.remove(workspace) | def _cleanup(self):
"""Clean up resources used by the session.
"""
self.exit()
workspace = osp.join(os.getcwd(), 'octave-workspace')
if osp.exists(workspace):
os.remove(workspace) | [
"Clean",
"up",
"resources",
"used",
"by",
"the",
"session",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L700-L706 | [
"def",
"_cleanup",
"(",
"self",
")",
":",
"self",
".",
"exit",
"(",
")",
"workspace",
"=",
"osp",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"'octave-workspace'",
")",
"if",
"osp",
".",
"exists",
"(",
"workspace",
")",
":",
"os",
".",
... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | demo | Play a demo script showing most of the oct2py api features.
Parameters
==========
delay : float
Time between each command in seconds. | oct2py/demo.py | def demo(delay=1, interactive=True):
"""
Play a demo script showing most of the oct2py api features.
Parameters
==========
delay : float
Time between each command in seconds.
"""
script = """
#########################
# Oct2Py demo
#########################... | def demo(delay=1, interactive=True):
"""
Play a demo script showing most of the oct2py api features.
Parameters
==========
delay : float
Time between each command in seconds.
"""
script = """
#########################
# Oct2Py demo
#########################... | [
"Play",
"a",
"demo",
"script",
"showing",
"most",
"of",
"the",
"oct2py",
"api",
"features",
".",
"Parameters",
"==========",
"delay",
":",
"float",
"Time",
"between",
"each",
"command",
"in",
"seconds",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/demo.py#L10-L74 | [
"def",
"demo",
"(",
"delay",
"=",
"1",
",",
"interactive",
"=",
"True",
")",
":",
"script",
"=",
"\"\"\"\r\n #########################\r\n # Oct2Py demo\r\n #########################\r\n import numpy as np\r\n from oct2py import Oct2Py\r\n oc = Oct2Py()\r\n # basic c... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | kill_octave | Kill all octave instances (cross-platform).
This will restart the "octave" instance. If you have instantiated
Any other Oct2Py objects, you must restart them. | oct2py/__init__.py | def kill_octave():
"""Kill all octave instances (cross-platform).
This will restart the "octave" instance. If you have instantiated
Any other Oct2Py objects, you must restart them.
"""
import os
if os.name == 'nt':
os.system('taskkill /im octave /f')
else:
os.syst... | def kill_octave():
"""Kill all octave instances (cross-platform).
This will restart the "octave" instance. If you have instantiated
Any other Oct2Py objects, you must restart them.
"""
import os
if os.name == 'nt':
os.system('taskkill /im octave /f')
else:
os.syst... | [
"Kill",
"all",
"octave",
"instances",
"(",
"cross",
"-",
"platform",
")",
".",
"This",
"will",
"restart",
"the",
"octave",
"instance",
".",
"If",
"you",
"have",
"instantiated",
"Any",
"other",
"Oct2Py",
"objects",
"you",
"must",
"restart",
"them",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/__init__.py#L43-L55 | [
"def",
"kill_octave",
"(",
")",
":",
"import",
"os",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"os",
".",
"system",
"(",
"'taskkill /im octave /f'",
")",
"else",
":",
"os",
".",
"system",
"(",
"'killall -9 octave'",
")",
"os",
".",
"system",
"(",
"'k... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | thread_check | Start a number of threads and verify each has a unique Octave session.
Parameters
==========
nthreads : int
Number of threads to use.
Raises
======
Oct2PyError
If the thread does not sucessfully demonstrate independence. | oct2py/thread_check.py | def thread_check(nthreads=3):
"""
Start a number of threads and verify each has a unique Octave session.
Parameters
==========
nthreads : int
Number of threads to use.
Raises
======
Oct2PyError
If the thread does not sucessfully demonstrate independence.
... | def thread_check(nthreads=3):
"""
Start a number of threads and verify each has a unique Octave session.
Parameters
==========
nthreads : int
Number of threads to use.
Raises
======
Oct2PyError
If the thread does not sucessfully demonstrate independence.
... | [
"Start",
"a",
"number",
"of",
"threads",
"and",
"verify",
"each",
"has",
"a",
"unique",
"Octave",
"session",
".",
"Parameters",
"==========",
"nthreads",
":",
"int",
"Number",
"of",
"threads",
"to",
"use",
".",
"Raises",
"======",
"Oct2PyError",
"If",
"the",... | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/thread_check.py#L39-L64 | [
"def",
"thread_check",
"(",
"nthreads",
"=",
"3",
")",
":",
"print",
"(",
"\"Starting {0} threads at {1}\"",
".",
"format",
"(",
"nthreads",
",",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
")",
")",
"threads",
"=",
"[",
"]",
"for",
"i",
"in",
"... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | ThreadClass.run | Create a unique instance of Octave and verify namespace uniqueness.
Raises
======
Oct2PyError
If the thread does not sucessfully demonstrate independence | oct2py/thread_check.py | def run(self):
"""
Create a unique instance of Octave and verify namespace uniqueness.
Raises
======
Oct2PyError
If the thread does not sucessfully demonstrate independence
"""
octave = Oct2Py()
# write the same variable name in ea... | def run(self):
"""
Create a unique instance of Octave and verify namespace uniqueness.
Raises
======
Oct2PyError
If the thread does not sucessfully demonstrate independence
"""
octave = Oct2Py()
# write the same variable name in ea... | [
"Create",
"a",
"unique",
"instance",
"of",
"Octave",
"and",
"verify",
"namespace",
"uniqueness",
".",
"Raises",
"======",
"Oct2PyError",
"If",
"the",
"thread",
"does",
"not",
"sucessfully",
"demonstrate",
"independence"
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/thread_check.py#L15-L36 | [
"def",
"run",
"(",
"self",
")",
":",
"octave",
"=",
"Oct2Py",
"(",
")",
"# write the same variable name in each thread and read it back\r",
"octave",
".",
"push",
"(",
"'name'",
",",
"self",
".",
"getName",
"(",
")",
")",
"name",
"=",
"octave",
".",
"pull",
... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | read_file | Read the data from the given file path. | oct2py/io.py | def read_file(path, session=None):
"""Read the data from the given file path.
"""
try:
data = loadmat(path, struct_as_record=True)
except UnicodeDecodeError as e:
raise Oct2PyError(str(e))
out = dict()
for (key, value) in data.items():
out[key] = _extract(value, ... | def read_file(path, session=None):
"""Read the data from the given file path.
"""
try:
data = loadmat(path, struct_as_record=True)
except UnicodeDecodeError as e:
raise Oct2PyError(str(e))
out = dict()
for (key, value) in data.items():
out[key] = _extract(value, ... | [
"Read",
"the",
"data",
"from",
"the",
"given",
"file",
"path",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/io.py#L32-L42 | [
"def",
"read_file",
"(",
"path",
",",
"session",
"=",
"None",
")",
":",
"try",
":",
"data",
"=",
"loadmat",
"(",
"path",
",",
"struct_as_record",
"=",
"True",
")",
"except",
"UnicodeDecodeError",
"as",
"e",
":",
"raise",
"Oct2PyError",
"(",
"str",
"(",
... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | write_file | Save a Python object to an Octave file on the given path. | oct2py/io.py | def write_file(obj, path, oned_as='row', convert_to_float=True):
"""Save a Python object to an Octave file on the given path.
"""
data = _encode(obj, convert_to_float)
try:
# scipy.io.savemat is not thread-save.
# See https://github.com/scipy/scipy/issues/7260
with _WRITE_... | def write_file(obj, path, oned_as='row', convert_to_float=True):
"""Save a Python object to an Octave file on the given path.
"""
data = _encode(obj, convert_to_float)
try:
# scipy.io.savemat is not thread-save.
# See https://github.com/scipy/scipy/issues/7260
with _WRITE_... | [
"Save",
"a",
"Python",
"object",
"to",
"an",
"Octave",
"file",
"on",
"the",
"given",
"path",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/io.py#L45-L56 | [
"def",
"write_file",
"(",
"obj",
",",
"path",
",",
"oned_as",
"=",
"'row'",
",",
"convert_to_float",
"=",
"True",
")",
":",
"data",
"=",
"_encode",
"(",
"obj",
",",
"convert_to_float",
")",
"try",
":",
"# scipy.io.savemat is not thread-save.\r",
"# See https://g... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | _extract | Convert the Octave values to values suitable for Python. | oct2py/io.py | def _extract(data, session=None):
"""Convert the Octave values to values suitable for Python.
"""
# Extract each item of a list.
if isinstance(data, list):
return [_extract(d, session) for d in data]
# Ignore leaf objects.
if not isinstance(data, np.ndarray):
return dat... | def _extract(data, session=None):
"""Convert the Octave values to values suitable for Python.
"""
# Extract each item of a list.
if isinstance(data, list):
return [_extract(d, session) for d in data]
# Ignore leaf objects.
if not isinstance(data, np.ndarray):
return dat... | [
"Convert",
"the",
"Octave",
"values",
"to",
"values",
"suitable",
"for",
"Python",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/io.py#L242-L281 | [
"def",
"_extract",
"(",
"data",
",",
"session",
"=",
"None",
")",
":",
"# Extract each item of a list.\r",
"if",
"isinstance",
"(",
"data",
",",
"list",
")",
":",
"return",
"[",
"_extract",
"(",
"d",
",",
"session",
")",
"for",
"d",
"in",
"data",
"]",
... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | _create_struct | Create a struct from session data. | oct2py/io.py | def _create_struct(data, session):
"""Create a struct from session data.
"""
out = Struct()
for name in data.dtype.names:
item = data[name]
# Extract values that are cells (they are doubly wrapped).
if isinstance(item, np.ndarray) and item.dtype.kind == 'O':
i... | def _create_struct(data, session):
"""Create a struct from session data.
"""
out = Struct()
for name in data.dtype.names:
item = data[name]
# Extract values that are cells (they are doubly wrapped).
if isinstance(item, np.ndarray) and item.dtype.kind == 'O':
i... | [
"Create",
"a",
"struct",
"from",
"session",
"data",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/io.py#L284-L294 | [
"def",
"_create_struct",
"(",
"data",
",",
"session",
")",
":",
"out",
"=",
"Struct",
"(",
")",
"for",
"name",
"in",
"data",
".",
"dtype",
".",
"names",
":",
"item",
"=",
"data",
"[",
"name",
"]",
"# Extract values that are cells (they are doubly wrapped).\r",... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | _encode | Convert the Python values to values suitable to send to Octave. | oct2py/io.py | def _encode(data, convert_to_float):
"""Convert the Python values to values suitable to send to Octave.
"""
ctf = convert_to_float
# Handle variable pointer.
if isinstance(data, (OctaveVariablePtr)):
return _encode(data.value, ctf)
# Handle a user defined object.
if isins... | def _encode(data, convert_to_float):
"""Convert the Python values to values suitable to send to Octave.
"""
ctf = convert_to_float
# Handle variable pointer.
if isinstance(data, (OctaveVariablePtr)):
return _encode(data.value, ctf)
# Handle a user defined object.
if isins... | [
"Convert",
"the",
"Python",
"values",
"to",
"values",
"suitable",
"to",
"send",
"to",
"Octave",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/io.py#L297-L382 | [
"def",
"_encode",
"(",
"data",
",",
"convert_to_float",
")",
":",
"ctf",
"=",
"convert_to_float",
"# Handle variable pointer.\r",
"if",
"isinstance",
"(",
"data",
",",
"(",
"OctaveVariablePtr",
")",
")",
":",
"return",
"_encode",
"(",
"data",
".",
"value",
","... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | _is_simple_numeric | Test if a list contains simple numeric data. | oct2py/io.py | def _is_simple_numeric(data):
"""Test if a list contains simple numeric data."""
for item in data:
if isinstance(item, set):
item = list(item)
if isinstance(item, list):
if not _is_simple_numeric(item):
return False
elif not isinstance(item... | def _is_simple_numeric(data):
"""Test if a list contains simple numeric data."""
for item in data:
if isinstance(item, set):
item = list(item)
if isinstance(item, list):
if not _is_simple_numeric(item):
return False
elif not isinstance(item... | [
"Test",
"if",
"a",
"list",
"contains",
"simple",
"numeric",
"data",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/io.py#L385-L395 | [
"def",
"_is_simple_numeric",
"(",
"data",
")",
":",
"for",
"item",
"in",
"data",
":",
"if",
"isinstance",
"(",
"item",
",",
"set",
")",
":",
"item",
"=",
"list",
"(",
"item",
")",
"if",
"isinstance",
"(",
"item",
",",
"list",
")",
":",
"if",
"not",... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | get_log | Return a console logger.
Output may be sent to the logger using the `debug`, `info`, `warning`,
`error` and `critical` methods.
Parameters
----------
name : str
Name of the log.
References
----------
.. [1] Logging facility for Python,
http://docs.pytho... | oct2py/utils.py | def get_log(name=None):
"""Return a console logger.
Output may be sent to the logger using the `debug`, `info`, `warning`,
`error` and `critical` methods.
Parameters
----------
name : str
Name of the log.
References
----------
.. [1] Logging facility for Pytho... | def get_log(name=None):
"""Return a console logger.
Output may be sent to the logger using the `debug`, `info`, `warning`,
`error` and `critical` methods.
Parameters
----------
name : str
Name of the log.
References
----------
.. [1] Logging facility for Pytho... | [
"Return",
"a",
"console",
"logger",
".",
"Output",
"may",
"be",
"sent",
"to",
"the",
"logger",
"using",
"the",
"debug",
"info",
"warning",
"error",
"and",
"critical",
"methods",
".",
"Parameters",
"----------",
"name",
":",
"str",
"Name",
"of",
"the",
"log... | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/utils.py#L22-L46 | [
"def",
"get_log",
"(",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"'oct2py'",
"else",
":",
"name",
"=",
"'oct2py.'",
"+",
"name",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"log",
".",
"setLevel",
"... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | _setup_log | Configure root logger. | oct2py/utils.py | def _setup_log():
"""Configure root logger.
"""
try:
handler = logging.StreamHandler(stream=sys.stdout)
except TypeError: # pragma: no cover
handler = logging.StreamHandler(strm=sys.stdout)
log = get_log()
log.addHandler(handler)
log.setLevel(logging.INFO)
lo... | def _setup_log():
"""Configure root logger.
"""
try:
handler = logging.StreamHandler(stream=sys.stdout)
except TypeError: # pragma: no cover
handler = logging.StreamHandler(strm=sys.stdout)
log = get_log()
log.addHandler(handler)
log.setLevel(logging.INFO)
lo... | [
"Configure",
"root",
"logger",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/utils.py#L49-L60 | [
"def",
"_setup_log",
"(",
")",
":",
"try",
":",
"handler",
"=",
"logging",
".",
"StreamHandler",
"(",
"stream",
"=",
"sys",
".",
"stdout",
")",
"except",
"TypeError",
":",
"# pragma: no cover\r",
"handler",
"=",
"logging",
".",
"StreamHandler",
"(",
"strm",
... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | _make_user_class | Make an Octave class for a given class name | oct2py/dynamic.py | def _make_user_class(session, name):
"""Make an Octave class for a given class name"""
attrs = session.eval('fieldnames(%s);' % name, nout=1).ravel().tolist()
methods = session.eval('methods(%s);' % name, nout=1).ravel().tolist()
ref = weakref.ref(session)
doc = _DocDescriptor(ref, name)
values... | def _make_user_class(session, name):
"""Make an Octave class for a given class name"""
attrs = session.eval('fieldnames(%s);' % name, nout=1).ravel().tolist()
methods = session.eval('methods(%s);' % name, nout=1).ravel().tolist()
ref = weakref.ref(session)
doc = _DocDescriptor(ref, name)
values... | [
"Make",
"an",
"Octave",
"class",
"for",
"a",
"given",
"class",
"name"
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/dynamic.py#L209-L230 | [
"def",
"_make_user_class",
"(",
"session",
",",
"name",
")",
":",
"attrs",
"=",
"session",
".",
"eval",
"(",
"'fieldnames(%s);'",
"%",
"name",
",",
"nout",
"=",
"1",
")",
".",
"ravel",
"(",
")",
".",
"tolist",
"(",
")",
"methods",
"=",
"session",
"."... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | OctaveUserClass.from_value | This is how an instance is created when we read a
MatlabObject from a MAT file. | oct2py/dynamic.py | def from_value(cls, value):
"""This is how an instance is created when we read a
MatlabObject from a MAT file.
"""
instance = OctaveUserClass.__new__(cls)
instance._address = '%s_%s' % (instance._name, id(instance))
instance._ref().push(instance._address, value)
... | def from_value(cls, value):
"""This is how an instance is created when we read a
MatlabObject from a MAT file.
"""
instance = OctaveUserClass.__new__(cls)
instance._address = '%s_%s' % (instance._name, id(instance))
instance._ref().push(instance._address, value)
... | [
"This",
"is",
"how",
"an",
"instance",
"is",
"created",
"when",
"we",
"read",
"a",
"MatlabObject",
"from",
"a",
"MAT",
"file",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/dynamic.py#L177-L184 | [
"def",
"from_value",
"(",
"cls",
",",
"value",
")",
":",
"instance",
"=",
"OctaveUserClass",
".",
"__new__",
"(",
"cls",
")",
"instance",
".",
"_address",
"=",
"'%s_%s'",
"%",
"(",
"instance",
".",
"_name",
",",
"id",
"(",
"instance",
")",
")",
"instan... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | OctaveUserClass.to_value | Convert to a value to send to Octave. | oct2py/dynamic.py | def to_value(cls, instance):
"""Convert to a value to send to Octave."""
if not isinstance(instance, OctaveUserClass) or not instance._attrs:
return dict()
# Bootstrap a MatlabObject from scipy.io
# From https://github.com/scipy/scipy/blob/93a0ea9e5d4aba1f661b6bb0e18f9c2d1fce... | def to_value(cls, instance):
"""Convert to a value to send to Octave."""
if not isinstance(instance, OctaveUserClass) or not instance._attrs:
return dict()
# Bootstrap a MatlabObject from scipy.io
# From https://github.com/scipy/scipy/blob/93a0ea9e5d4aba1f661b6bb0e18f9c2d1fce... | [
"Convert",
"to",
"a",
"value",
"to",
"send",
"to",
"Octave",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/dynamic.py#L187-L200 | [
"def",
"to_value",
"(",
"cls",
",",
"instance",
")",
":",
"if",
"not",
"isinstance",
"(",
"instance",
",",
"OctaveUserClass",
")",
"or",
"not",
"instance",
".",
"_attrs",
":",
"return",
"dict",
"(",
")",
"# Bootstrap a MatlabObject from scipy.io",
"# From https:... | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | OctaveUserClass.to_pointer | Get a pointer to the private object. | oct2py/dynamic.py | def to_pointer(cls, instance):
"""Get a pointer to the private object.
"""
return OctavePtr(instance._ref, instance._name, instance._address) | def to_pointer(cls, instance):
"""Get a pointer to the private object.
"""
return OctavePtr(instance._ref, instance._name, instance._address) | [
"Get",
"a",
"pointer",
"to",
"the",
"private",
"object",
"."
] | blink1073/oct2py | python | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/dynamic.py#L203-L206 | [
"def",
"to_pointer",
"(",
"cls",
",",
"instance",
")",
":",
"return",
"OctavePtr",
"(",
"instance",
".",
"_ref",
",",
"instance",
".",
"_name",
",",
"instance",
".",
"_address",
")"
] | bfc69d2168ae3d98258f95bbc55a858c21836b58 |
valid | document_func_view | Decorator to make functional view documentable via drf-autodocs | drf_autodocs/decorators.py | def document_func_view(serializer_class=None,
response_serializer_class=None,
filter_backends=None,
permission_classes=None,
authentication_classes=None,
doc_format_args=list(),
doc_... | def document_func_view(serializer_class=None,
response_serializer_class=None,
filter_backends=None,
permission_classes=None,
authentication_classes=None,
doc_format_args=list(),
doc_... | [
"Decorator",
"to",
"make",
"functional",
"view",
"documentable",
"via",
"drf",
"-",
"autodocs"
] | iMakedonsky/drf-autodocs | python | https://github.com/iMakedonsky/drf-autodocs/blob/06c2d1d5a9cd23e698310dbce6100463bd8c3f46/drf_autodocs/decorators.py#L4-L29 | [
"def",
"document_func_view",
"(",
"serializer_class",
"=",
"None",
",",
"response_serializer_class",
"=",
"None",
",",
"filter_backends",
"=",
"None",
",",
"permission_classes",
"=",
"None",
",",
"authentication_classes",
"=",
"None",
",",
"doc_format_args",
"=",
"l... | 06c2d1d5a9cd23e698310dbce6100463bd8c3f46 |
valid | format_docstring | Decorator for clean docstring formatting | drf_autodocs/decorators.py | def format_docstring(*args, **kwargs):
"""
Decorator for clean docstring formatting
"""
def decorator(func):
func.__doc__ = getdoc(func).format(*args, **kwargs)
return func
return decorator | def format_docstring(*args, **kwargs):
"""
Decorator for clean docstring formatting
"""
def decorator(func):
func.__doc__ = getdoc(func).format(*args, **kwargs)
return func
return decorator | [
"Decorator",
"for",
"clean",
"docstring",
"formatting"
] | iMakedonsky/drf-autodocs | python | https://github.com/iMakedonsky/drf-autodocs/blob/06c2d1d5a9cd23e698310dbce6100463bd8c3f46/drf_autodocs/decorators.py#L32-L39 | [
"def",
"format_docstring",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"func",
".",
"__doc__",
"=",
"getdoc",
"(",
"func",
")",
".",
"format",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"re... | 06c2d1d5a9cd23e698310dbce6100463bd8c3f46 |
valid | is_rarfile | Return true if file is a valid RAR file. | unrar/rarfile.py | def is_rarfile(filename):
"""Return true if file is a valid RAR file."""
mode = constants.RAR_OM_LIST_INCSPLIT
archive = unrarlib.RAROpenArchiveDataEx(filename, mode=mode)
try:
handle = unrarlib.RAROpenArchiveEx(ctypes.byref(archive))
except unrarlib.UnrarException:
return False
... | def is_rarfile(filename):
"""Return true if file is a valid RAR file."""
mode = constants.RAR_OM_LIST_INCSPLIT
archive = unrarlib.RAROpenArchiveDataEx(filename, mode=mode)
try:
handle = unrarlib.RAROpenArchiveEx(ctypes.byref(archive))
except unrarlib.UnrarException:
return False
... | [
"Return",
"true",
"if",
"file",
"is",
"a",
"valid",
"RAR",
"file",
"."
] | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L46-L55 | [
"def",
"is_rarfile",
"(",
"filename",
")",
":",
"mode",
"=",
"constants",
".",
"RAR_OM_LIST_INCSPLIT",
"archive",
"=",
"unrarlib",
".",
"RAROpenArchiveDataEx",
"(",
"filename",
",",
"mode",
"=",
"mode",
")",
"try",
":",
"handle",
"=",
"unrarlib",
".",
"RAROp... | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | RarFile._read_header | Read current member header into a RarInfo object. | unrar/rarfile.py | def _read_header(self, handle):
"""Read current member header into a RarInfo object."""
header_data = unrarlib.RARHeaderDataEx()
try:
res = unrarlib.RARReadHeaderEx(handle, ctypes.byref(header_data))
rarinfo = RarInfo(header=header_data)
except unrarlib.ArchiveEnd... | def _read_header(self, handle):
"""Read current member header into a RarInfo object."""
header_data = unrarlib.RARHeaderDataEx()
try:
res = unrarlib.RARReadHeaderEx(handle, ctypes.byref(header_data))
rarinfo = RarInfo(header=header_data)
except unrarlib.ArchiveEnd... | [
"Read",
"current",
"member",
"header",
"into",
"a",
"RarInfo",
"object",
"."
] | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L143-L158 | [
"def",
"_read_header",
"(",
"self",
",",
"handle",
")",
":",
"header_data",
"=",
"unrarlib",
".",
"RARHeaderDataEx",
"(",
")",
"try",
":",
"res",
"=",
"unrarlib",
".",
"RARReadHeaderEx",
"(",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"header_data",
")",
... | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | RarFile._process_current | Process current member with 'op' operation. | unrar/rarfile.py | def _process_current(self, handle, op, dest_path=None, dest_name=None):
"""Process current member with 'op' operation."""
unrarlib.RARProcessFileW(handle, op, dest_path, dest_name) | def _process_current(self, handle, op, dest_path=None, dest_name=None):
"""Process current member with 'op' operation."""
unrarlib.RARProcessFileW(handle, op, dest_path, dest_name) | [
"Process",
"current",
"member",
"with",
"op",
"operation",
"."
] | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L160-L162 | [
"def",
"_process_current",
"(",
"self",
",",
"handle",
",",
"op",
",",
"dest_path",
"=",
"None",
",",
"dest_name",
"=",
"None",
")",
":",
"unrarlib",
".",
"RARProcessFileW",
"(",
"handle",
",",
"op",
",",
"dest_path",
",",
"dest_name",
")"
] | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | RarFile._load_metadata | Load archive members metadata. | unrar/rarfile.py | def _load_metadata(self, handle):
"""Load archive members metadata."""
rarinfo = self._read_header(handle)
while rarinfo:
self.filelist.append(rarinfo)
self.NameToInfo[rarinfo.filename] = rarinfo
self._process_current(handle, constants.RAR_SKIP)
ra... | def _load_metadata(self, handle):
"""Load archive members metadata."""
rarinfo = self._read_header(handle)
while rarinfo:
self.filelist.append(rarinfo)
self.NameToInfo[rarinfo.filename] = rarinfo
self._process_current(handle, constants.RAR_SKIP)
ra... | [
"Load",
"archive",
"members",
"metadata",
"."
] | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L164-L171 | [
"def",
"_load_metadata",
"(",
"self",
",",
"handle",
")",
":",
"rarinfo",
"=",
"self",
".",
"_read_header",
"(",
"handle",
")",
"while",
"rarinfo",
":",
"self",
".",
"filelist",
".",
"append",
"(",
"rarinfo",
")",
"self",
".",
"NameToInfo",
"[",
"rarinfo... | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | RarFile._open | Open RAR archive file. | unrar/rarfile.py | def _open(self, archive):
"""Open RAR archive file."""
try:
handle = unrarlib.RAROpenArchiveEx(ctypes.byref(archive))
except unrarlib.UnrarException:
raise BadRarFile("Invalid RAR file.")
return handle | def _open(self, archive):
"""Open RAR archive file."""
try:
handle = unrarlib.RAROpenArchiveEx(ctypes.byref(archive))
except unrarlib.UnrarException:
raise BadRarFile("Invalid RAR file.")
return handle | [
"Open",
"RAR",
"archive",
"file",
"."
] | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L173-L179 | [
"def",
"_open",
"(",
"self",
",",
"archive",
")",
":",
"try",
":",
"handle",
"=",
"unrarlib",
".",
"RAROpenArchiveEx",
"(",
"ctypes",
".",
"byref",
"(",
"archive",
")",
")",
"except",
"unrarlib",
".",
"UnrarException",
":",
"raise",
"BadRarFile",
"(",
"\... | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | RarFile.open | Return file-like object for 'member'.
'member' may be a filename or a RarInfo object. | unrar/rarfile.py | def open(self, member, pwd=None):
"""Return file-like object for 'member'.
'member' may be a filename or a RarInfo object.
"""
if isinstance(member, RarInfo):
member = member.filename
archive = unrarlib.RAROpenArchiveDataEx(
self.filename, mode=consta... | def open(self, member, pwd=None):
"""Return file-like object for 'member'.
'member' may be a filename or a RarInfo object.
"""
if isinstance(member, RarInfo):
member = member.filename
archive = unrarlib.RAROpenArchiveDataEx(
self.filename, mode=consta... | [
"Return",
"file",
"-",
"like",
"object",
"for",
"member",
"."
] | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L188-L241 | [
"def",
"open",
"(",
"self",
",",
"member",
",",
"pwd",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"member",
",",
"RarInfo",
")",
":",
"member",
"=",
"member",
".",
"filename",
"archive",
"=",
"unrarlib",
".",
"RAROpenArchiveDataEx",
"(",
"self",
"... | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | RarFile.namelist | Return a list of file names in the archive. | unrar/rarfile.py | def namelist(self):
"""Return a list of file names in the archive."""
names = []
for member in self.filelist:
names.append(member.filename)
return names | def namelist(self):
"""Return a list of file names in the archive."""
names = []
for member in self.filelist:
names.append(member.filename)
return names | [
"Return",
"a",
"list",
"of",
"file",
"names",
"in",
"the",
"archive",
"."
] | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L247-L252 | [
"def",
"namelist",
"(",
"self",
")",
":",
"names",
"=",
"[",
"]",
"for",
"member",
"in",
"self",
".",
"filelist",
":",
"names",
".",
"append",
"(",
"member",
".",
"filename",
")",
"return",
"names"
] | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | RarFile.getinfo | Return the instance of RarInfo given 'name'. | unrar/rarfile.py | def getinfo(self, name):
"""Return the instance of RarInfo given 'name'."""
rarinfo = self.NameToInfo.get(name)
if rarinfo is None:
raise KeyError('There is no item named %r in the archive' % name)
return rarinfo | def getinfo(self, name):
"""Return the instance of RarInfo given 'name'."""
rarinfo = self.NameToInfo.get(name)
if rarinfo is None:
raise KeyError('There is no item named %r in the archive' % name)
return rarinfo | [
"Return",
"the",
"instance",
"of",
"RarInfo",
"given",
"name",
"."
] | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L258-L263 | [
"def",
"getinfo",
"(",
"self",
",",
"name",
")",
":",
"rarinfo",
"=",
"self",
".",
"NameToInfo",
".",
"get",
"(",
"name",
")",
"if",
"rarinfo",
"is",
"None",
":",
"raise",
"KeyError",
"(",
"'There is no item named %r in the archive'",
"%",
"name",
")",
"re... | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | RarFile.printdir | Print a table of contents for the RAR file. | unrar/rarfile.py | def printdir(self):
"""Print a table of contents for the RAR file."""
print("%-46s %19s %12s" % ("File Name", "Modified ", "Size"))
for rarinfo in self.filelist:
date = "%d-%02d-%02d %02d:%02d:%02d" % rarinfo.date_time[:6]
print("%-46s %s %12d" % (
rari... | def printdir(self):
"""Print a table of contents for the RAR file."""
print("%-46s %19s %12s" % ("File Name", "Modified ", "Size"))
for rarinfo in self.filelist:
date = "%d-%02d-%02d %02d:%02d:%02d" % rarinfo.date_time[:6]
print("%-46s %s %12d" % (
rari... | [
"Print",
"a",
"table",
"of",
"contents",
"for",
"the",
"RAR",
"file",
"."
] | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L270-L276 | [
"def",
"printdir",
"(",
"self",
")",
":",
"print",
"(",
"\"%-46s %19s %12s\"",
"%",
"(",
"\"File Name\"",
",",
"\"Modified \"",
",",
"\"Size\"",
")",
")",
"for",
"rarinfo",
"in",
"self",
".",
"filelist",
":",
"date",
"=",
"\"%d-%02d-%02d %02d:%02d:%02d\"",
... | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | RarFile.extract | Extract a member from the archive to the current working directory,
using its full name. Its file information is extracted as accurately
as possible. `member' may be a filename or a RarInfo object. You can
specify a different directory using `path'. | unrar/rarfile.py | def extract(self, member, path=None, pwd=None):
"""Extract a member from the archive to the current working directory,
using its full name. Its file information is extracted as accurately
as possible. `member' may be a filename or a RarInfo object. You can
specify a different di... | def extract(self, member, path=None, pwd=None):
"""Extract a member from the archive to the current working directory,
using its full name. Its file information is extracted as accurately
as possible. `member' may be a filename or a RarInfo object. You can
specify a different di... | [
"Extract",
"a",
"member",
"from",
"the",
"archive",
"to",
"the",
"current",
"working",
"directory",
"using",
"its",
"full",
"name",
".",
"Its",
"file",
"information",
"is",
"extracted",
"as",
"accurately",
"as",
"possible",
".",
"member",
"may",
"be",
"a",
... | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L300-L313 | [
"def",
"extract",
"(",
"self",
",",
"member",
",",
"path",
"=",
"None",
",",
"pwd",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"member",
",",
"RarInfo",
")",
":",
"member",
"=",
"member",
".",
"filename",
"if",
"path",
"is",
"None",
":",
"path... | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | RarFile.extractall | Extract all members from the archive to the current working
directory. `path' specifies a different directory to extract to.
`members' is optional and must be a subset of the list returned
by namelist(). | unrar/rarfile.py | def extractall(self, path=None, members=None, pwd=None):
"""Extract all members from the archive to the current working
directory. `path' specifies a different directory to extract to.
`members' is optional and must be a subset of the list returned
by namelist().
"""
... | def extractall(self, path=None, members=None, pwd=None):
"""Extract all members from the archive to the current working
directory. `path' specifies a different directory to extract to.
`members' is optional and must be a subset of the list returned
by namelist().
"""
... | [
"Extract",
"all",
"members",
"from",
"the",
"archive",
"to",
"the",
"current",
"working",
"directory",
".",
"path",
"specifies",
"a",
"different",
"directory",
"to",
"extract",
"to",
".",
"members",
"is",
"optional",
"and",
"must",
"be",
"a",
"subset",
"of",... | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L315-L323 | [
"def",
"extractall",
"(",
"self",
",",
"path",
"=",
"None",
",",
"members",
"=",
"None",
",",
"pwd",
"=",
"None",
")",
":",
"if",
"members",
"is",
"None",
":",
"members",
"=",
"self",
".",
"namelist",
"(",
")",
"self",
".",
"_extract_members",
"(",
... | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | RarFile._extract_members | Extract the RarInfo objects 'members' to a physical
file on the path targetpath. | unrar/rarfile.py | def _extract_members(self, members, targetpath, pwd):
"""Extract the RarInfo objects 'members' to a physical
file on the path targetpath.
"""
archive = unrarlib.RAROpenArchiveDataEx(
self.filename, mode=constants.RAR_OM_EXTRACT)
handle = self._open(archive)
... | def _extract_members(self, members, targetpath, pwd):
"""Extract the RarInfo objects 'members' to a physical
file on the path targetpath.
"""
archive = unrarlib.RAROpenArchiveDataEx(
self.filename, mode=constants.RAR_OM_EXTRACT)
handle = self._open(archive)
... | [
"Extract",
"the",
"RarInfo",
"objects",
"members",
"to",
"a",
"physical",
"file",
"on",
"the",
"path",
"targetpath",
"."
] | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L325-L355 | [
"def",
"_extract_members",
"(",
"self",
",",
"members",
",",
"targetpath",
",",
"pwd",
")",
":",
"archive",
"=",
"unrarlib",
".",
"RAROpenArchiveDataEx",
"(",
"self",
".",
"filename",
",",
"mode",
"=",
"constants",
".",
"RAR_OM_EXTRACT",
")",
"handle",
"=",
... | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | dostime_to_timetuple | Convert a RAR archive member DOS time to a Python time tuple. | unrar/unrarlib.py | def dostime_to_timetuple(dostime):
"""Convert a RAR archive member DOS time to a Python time tuple."""
dostime = dostime >> 16
dostime = dostime & 0xffff
day = dostime & 0x1f
month = (dostime >> 5) & 0xf
year = 1980 + (dostime >> 9)
second = 2 * (dostime & 0x1f)
minute = (dostime >> 5) &... | def dostime_to_timetuple(dostime):
"""Convert a RAR archive member DOS time to a Python time tuple."""
dostime = dostime >> 16
dostime = dostime & 0xffff
day = dostime & 0x1f
month = (dostime >> 5) & 0xf
year = 1980 + (dostime >> 9)
second = 2 * (dostime & 0x1f)
minute = (dostime >> 5) &... | [
"Convert",
"a",
"RAR",
"archive",
"member",
"DOS",
"time",
"to",
"a",
"Python",
"time",
"tuple",
"."
] | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/unrarlib.py#L60-L70 | [
"def",
"dostime_to_timetuple",
"(",
"dostime",
")",
":",
"dostime",
"=",
"dostime",
">>",
"16",
"dostime",
"=",
"dostime",
"&",
"0xffff",
"day",
"=",
"dostime",
"&",
"0x1f",
"month",
"=",
"(",
"dostime",
">>",
"5",
")",
"&",
"0xf",
"year",
"=",
"1980",... | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | _c_func | Wrap c function setting prototype. | unrar/unrarlib.py | def _c_func(func, restype, argtypes, errcheck=None):
"""Wrap c function setting prototype."""
func.restype = restype
func.argtypes = argtypes
if errcheck is not None:
func.errcheck = errcheck
return func | def _c_func(func, restype, argtypes, errcheck=None):
"""Wrap c function setting prototype."""
func.restype = restype
func.argtypes = argtypes
if errcheck is not None:
func.errcheck = errcheck
return func | [
"Wrap",
"c",
"function",
"setting",
"prototype",
"."
] | matiasb/python-unrar | python | https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/unrarlib.py#L199-L205 | [
"def",
"_c_func",
"(",
"func",
",",
"restype",
",",
"argtypes",
",",
"errcheck",
"=",
"None",
")",
":",
"func",
".",
"restype",
"=",
"restype",
"func",
".",
"argtypes",
"=",
"argtypes",
"if",
"errcheck",
"is",
"not",
"None",
":",
"func",
".",
"errcheck... | b1ac46cbcf42f3d3c5c69ab971fe97369a4da617 |
valid | _load_savefile_header | Load and validate the header of a pcap file. | pcapfile/savefile.py | def _load_savefile_header(file_h):
"""
Load and validate the header of a pcap file.
"""
try:
raw_savefile_header = file_h.read(24)
except UnicodeDecodeError:
print("\nMake sure the input file is opened in read binary, 'rb'\n")
raise InvalidEncoding("Could not read file; it mi... | def _load_savefile_header(file_h):
"""
Load and validate the header of a pcap file.
"""
try:
raw_savefile_header = file_h.read(24)
except UnicodeDecodeError:
print("\nMake sure the input file is opened in read binary, 'rb'\n")
raise InvalidEncoding("Could not read file; it mi... | [
"Load",
"and",
"validate",
"the",
"header",
"of",
"a",
"pcap",
"file",
"."
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/savefile.py#L90-L120 | [
"def",
"_load_savefile_header",
"(",
"file_h",
")",
":",
"try",
":",
"raw_savefile_header",
"=",
"file_h",
".",
"read",
"(",
"24",
")",
"except",
"UnicodeDecodeError",
":",
"print",
"(",
"\"\\nMake sure the input file is opened in read binary, 'rb'\\n\"",
")",
"raise",
... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | load_savefile | Parse a savefile as a pcap_savefile instance. Returns the savefile
on success and None on failure. Verbose mode prints additional information
about the file's processing. layers defines how many layers to descend and
decode the packet. input_file should be a Python file object. | pcapfile/savefile.py | def load_savefile(input_file, layers=0, verbose=False, lazy=False):
"""
Parse a savefile as a pcap_savefile instance. Returns the savefile
on success and None on failure. Verbose mode prints additional information
about the file's processing. layers defines how many layers to descend and
decode the ... | def load_savefile(input_file, layers=0, verbose=False, lazy=False):
"""
Parse a savefile as a pcap_savefile instance. Returns the savefile
on success and None on failure. Verbose mode prints additional information
about the file's processing. layers defines how many layers to descend and
decode the ... | [
"Parse",
"a",
"savefile",
"as",
"a",
"pcap_savefile",
"instance",
".",
"Returns",
"the",
"savefile",
"on",
"success",
"and",
"None",
"on",
"failure",
".",
"Verbose",
"mode",
"prints",
"additional",
"information",
"about",
"the",
"file",
"s",
"processing",
".",... | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/savefile.py#L123-L152 | [
"def",
"load_savefile",
"(",
"input_file",
",",
"layers",
"=",
"0",
",",
"verbose",
"=",
"False",
",",
"lazy",
"=",
"False",
")",
":",
"global",
"VERBOSE",
"old_verbose",
"=",
"VERBOSE",
"VERBOSE",
"=",
"verbose",
"__TRACE__",
"(",
"'[+] attempting to load {:s... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | _load_packets | Read packets from the capture file. Expects the file handle to point to
the location immediately after the header (24 bytes). | pcapfile/savefile.py | def _load_packets(file_h, header, layers=0):
"""
Read packets from the capture file. Expects the file handle to point to
the location immediately after the header (24 bytes).
"""
pkts = []
hdrp = ctypes.pointer(header)
while True:
pkt = _read_a_packet(file_h, hdrp, layers)
i... | def _load_packets(file_h, header, layers=0):
"""
Read packets from the capture file. Expects the file handle to point to
the location immediately after the header (24 bytes).
"""
pkts = []
hdrp = ctypes.pointer(header)
while True:
pkt = _read_a_packet(file_h, hdrp, layers)
i... | [
"Read",
"packets",
"from",
"the",
"capture",
"file",
".",
"Expects",
"the",
"file",
"handle",
"to",
"point",
"to",
"the",
"location",
"immediately",
"after",
"the",
"header",
"(",
"24",
"bytes",
")",
"."
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/savefile.py#L175-L190 | [
"def",
"_load_packets",
"(",
"file_h",
",",
"header",
",",
"layers",
"=",
"0",
")",
":",
"pkts",
"=",
"[",
"]",
"hdrp",
"=",
"ctypes",
".",
"pointer",
"(",
"header",
")",
"while",
"True",
":",
"pkt",
"=",
"_read_a_packet",
"(",
"file_h",
",",
"hdrp",... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | _generate_packets | Read packets one by one from the capture file. Expects the file
handle to point to the location immediately after the header (24
bytes). | pcapfile/savefile.py | def _generate_packets(file_h, header, layers=0):
"""
Read packets one by one from the capture file. Expects the file
handle to point to the location immediately after the header (24
bytes).
"""
hdrp = ctypes.pointer(header)
while True:
pkt = _read_a_packet(file_h, hdrp, layers)
... | def _generate_packets(file_h, header, layers=0):
"""
Read packets one by one from the capture file. Expects the file
handle to point to the location immediately after the header (24
bytes).
"""
hdrp = ctypes.pointer(header)
while True:
pkt = _read_a_packet(file_h, hdrp, layers)
... | [
"Read",
"packets",
"one",
"by",
"one",
"from",
"the",
"capture",
"file",
".",
"Expects",
"the",
"file",
"handle",
"to",
"point",
"to",
"the",
"location",
"immediately",
"after",
"the",
"header",
"(",
"24",
"bytes",
")",
"."
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/savefile.py#L193-L205 | [
"def",
"_generate_packets",
"(",
"file_h",
",",
"header",
",",
"layers",
"=",
"0",
")",
":",
"hdrp",
"=",
"ctypes",
".",
"pointer",
"(",
"header",
")",
"while",
"True",
":",
"pkt",
"=",
"_read_a_packet",
"(",
"file_h",
",",
"hdrp",
",",
"layers",
")",
... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | _read_a_packet | Reads the next individual packet from the capture file. Expects
the file handle to be somewhere after the header, on the next
per-packet header. | pcapfile/savefile.py | def _read_a_packet(file_h, hdrp, layers=0):
"""
Reads the next individual packet from the capture file. Expects
the file handle to be somewhere after the header, on the next
per-packet header.
"""
raw_packet_header = file_h.read(16)
if not raw_packet_header or len(raw_packet_header) != 16:
... | def _read_a_packet(file_h, hdrp, layers=0):
"""
Reads the next individual packet from the capture file. Expects
the file handle to be somewhere after the header, on the next
per-packet header.
"""
raw_packet_header = file_h.read(16)
if not raw_packet_header or len(raw_packet_header) != 16:
... | [
"Reads",
"the",
"next",
"individual",
"packet",
"from",
"the",
"capture",
"file",
".",
"Expects",
"the",
"file",
"handle",
"to",
"be",
"somewhere",
"after",
"the",
"header",
"on",
"the",
"next",
"per",
"-",
"packet",
"header",
"."
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/savefile.py#L208-L239 | [
"def",
"_read_a_packet",
"(",
"file_h",
",",
"hdrp",
",",
"layers",
"=",
"0",
")",
":",
"raw_packet_header",
"=",
"file_h",
".",
"read",
"(",
"16",
")",
"if",
"not",
"raw_packet_header",
"or",
"len",
"(",
"raw_packet_header",
")",
"!=",
"16",
":",
"retur... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | parse_ipv4 | Given a raw IPv4 address (i.e. as an unsigned integer), return it in
dotted quad notation. | pcapfile/protocols/network/ip.py | def parse_ipv4(address):
"""
Given a raw IPv4 address (i.e. as an unsigned integer), return it in
dotted quad notation.
"""
raw = struct.pack('I', address)
octets = struct.unpack('BBBB', raw)[::-1]
ipv4 = b'.'.join([('%d' % o).encode('ascii') for o in bytearray(octets)])
return ipv4 | def parse_ipv4(address):
"""
Given a raw IPv4 address (i.e. as an unsigned integer), return it in
dotted quad notation.
"""
raw = struct.pack('I', address)
octets = struct.unpack('BBBB', raw)[::-1]
ipv4 = b'.'.join([('%d' % o).encode('ascii') for o in bytearray(octets)])
return ipv4 | [
"Given",
"a",
"raw",
"IPv4",
"address",
"(",
"i",
".",
"e",
".",
"as",
"an",
"unsigned",
"integer",
")",
"return",
"it",
"in",
"dotted",
"quad",
"notation",
"."
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/network/ip.py#L80-L88 | [
"def",
"parse_ipv4",
"(",
"address",
")",
":",
"raw",
"=",
"struct",
".",
"pack",
"(",
"'I'",
",",
"address",
")",
"octets",
"=",
"struct",
".",
"unpack",
"(",
"'BBBB'",
",",
"raw",
")",
"[",
":",
":",
"-",
"1",
"]",
"ipv4",
"=",
"b'.'",
".",
"... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | strip_ip | Remove the IP packet layer, yielding the transport layer. | pcapfile/protocols/network/ip.py | def strip_ip(packet):
"""
Remove the IP packet layer, yielding the transport layer.
"""
if not isinstance(packet, IP):
packet = IP(packet)
payload = packet.payload
return payload | def strip_ip(packet):
"""
Remove the IP packet layer, yielding the transport layer.
"""
if not isinstance(packet, IP):
packet = IP(packet)
payload = packet.payload
return payload | [
"Remove",
"the",
"IP",
"packet",
"layer",
"yielding",
"the",
"transport",
"layer",
"."
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/network/ip.py#L91-L99 | [
"def",
"strip_ip",
"(",
"packet",
")",
":",
"if",
"not",
"isinstance",
"(",
"packet",
",",
"IP",
")",
":",
"packet",
"=",
"IP",
"(",
"packet",
")",
"payload",
"=",
"packet",
".",
"payload",
"return",
"payload"
] | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | strip_ethernet | Strip the Ethernet frame from a packet. | pcapfile/protocols/linklayer/ethernet.py | def strip_ethernet(packet):
"""
Strip the Ethernet frame from a packet.
"""
if not isinstance(packet, Ethernet):
packet = Ethernet(packet)
payload = packet.payload
return payload | def strip_ethernet(packet):
"""
Strip the Ethernet frame from a packet.
"""
if not isinstance(packet, Ethernet):
packet = Ethernet(packet)
payload = packet.payload
return payload | [
"Strip",
"the",
"Ethernet",
"frame",
"from",
"a",
"packet",
"."
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/ethernet.py#L57-L65 | [
"def",
"strip_ethernet",
"(",
"packet",
")",
":",
"if",
"not",
"isinstance",
"(",
"packet",
",",
"Ethernet",
")",
":",
"packet",
"=",
"Ethernet",
"(",
"packet",
")",
"payload",
"=",
"packet",
".",
"payload",
"return",
"payload"
] | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Ethernet.load_network | Given an Ethernet frame, determine the appropriate sub-protocol;
If layers is greater than zerol determine the type of the payload
and load the appropriate type of network packet. It is expected
that the payload be a hexified string. The layers argument determines
how many layers to desc... | pcapfile/protocols/linklayer/ethernet.py | def load_network(self, layers=1):
"""
Given an Ethernet frame, determine the appropriate sub-protocol;
If layers is greater than zerol determine the type of the payload
and load the appropriate type of network packet. It is expected
that the payload be a hexified string. The laye... | def load_network(self, layers=1):
"""
Given an Ethernet frame, determine the appropriate sub-protocol;
If layers is greater than zerol determine the type of the payload
and load the appropriate type of network packet. It is expected
that the payload be a hexified string. The laye... | [
"Given",
"an",
"Ethernet",
"frame",
"determine",
"the",
"appropriate",
"sub",
"-",
"protocol",
";",
"If",
"layers",
"is",
"greater",
"than",
"zerol",
"determine",
"the",
"type",
"of",
"the",
"payload",
"and",
"load",
"the",
"appropriate",
"type",
"of",
"netw... | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/ethernet.py#L31-L47 | [
"def",
"load_network",
"(",
"self",
",",
"layers",
"=",
"1",
")",
":",
"if",
"layers",
":",
"ctor",
"=",
"payload_type",
"(",
"self",
".",
"type",
")",
"[",
"0",
"]",
"if",
"ctor",
":",
"ctor",
"=",
"ctor",
"payload",
"=",
"self",
".",
"payload",
... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | WIFI | calls wifi packet discriminator and constructor.
:frame: ctypes.Structure
:no_rtap: Bool
:return: packet object in success
:return: int
-1 on known error
:return: int
-2 on unknown error | pcapfile/protocols/linklayer/wifi.py | def WIFI(frame, no_rtap=False):
"""calls wifi packet discriminator and constructor.
:frame: ctypes.Structure
:no_rtap: Bool
:return: packet object in success
:return: int
-1 on known error
:return: int
-2 on unknown error
"""
pack = None
try:
pack = WiHelper.g... | def WIFI(frame, no_rtap=False):
"""calls wifi packet discriminator and constructor.
:frame: ctypes.Structure
:no_rtap: Bool
:return: packet object in success
:return: int
-1 on known error
:return: int
-2 on unknown error
"""
pack = None
try:
pack = WiHelper.g... | [
"calls",
"wifi",
"packet",
"discriminator",
"and",
"constructor",
".",
":",
"frame",
":",
"ctypes",
".",
"Structure",
":",
"no_rtap",
":",
"Bool",
":",
"return",
":",
"packet",
"object",
"in",
"success",
":",
"return",
":",
"int",
"-",
"1",
"on",
"known"... | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L253-L268 | [
"def",
"WIFI",
"(",
"frame",
",",
"no_rtap",
"=",
"False",
")",
":",
"pack",
"=",
"None",
"try",
":",
"pack",
"=",
"WiHelper",
".",
"get_wifi_packet",
"(",
"frame",
",",
"no_rtap",
")",
"except",
"Exception",
"as",
"e",
":",
"logging",
".",
"exception"... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | WiHelper.get_wifi_packet | Discriminates Wi-Fi packet and creates
packet object.
:frame: ctypes.Structure
:no_rtap: Bool
:return: obj
Wi-Fi packet | pcapfile/protocols/linklayer/wifi.py | def get_wifi_packet(frame, no_rtap=False):
"""Discriminates Wi-Fi packet and creates
packet object.
:frame: ctypes.Structure
:no_rtap: Bool
:return: obj
Wi-Fi packet
"""
_, packet = WiHelper._strip_rtap(frame)
frame_control = struct.unpack('BB'... | def get_wifi_packet(frame, no_rtap=False):
"""Discriminates Wi-Fi packet and creates
packet object.
:frame: ctypes.Structure
:no_rtap: Bool
:return: obj
Wi-Fi packet
"""
_, packet = WiHelper._strip_rtap(frame)
frame_control = struct.unpack('BB'... | [
"Discriminates",
"Wi",
"-",
"Fi",
"packet",
"and",
"creates",
"packet",
"object",
".",
":",
"frame",
":",
"ctypes",
".",
"Structure",
":",
"no_rtap",
":",
"Bool",
":",
"return",
":",
"obj",
"Wi",
"-",
"Fi",
"packet"
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L279-L322 | [
"def",
"get_wifi_packet",
"(",
"frame",
",",
"no_rtap",
"=",
"False",
")",
":",
"_",
",",
"packet",
"=",
"WiHelper",
".",
"_strip_rtap",
"(",
"frame",
")",
"frame_control",
"=",
"struct",
".",
"unpack",
"(",
"'BB'",
",",
"packet",
"[",
":",
"2",
"]",
... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | WiHelper._strip_rtap | strip injected radiotap header.
:return: ctypes.Structure
radiotap header
:return: ctypes.Structure
actual layer 2 Wi-Fi payload | pcapfile/protocols/linklayer/wifi.py | def _strip_rtap(frame):
"""strip injected radiotap header.
:return: ctypes.Structure
radiotap header
:return: ctypes.Structure
actual layer 2 Wi-Fi payload
"""
rtap_len = WiHelper.__get_rtap_len(frame)
rtap = frame[:rtap_len]
packet = frame... | def _strip_rtap(frame):
"""strip injected radiotap header.
:return: ctypes.Structure
radiotap header
:return: ctypes.Structure
actual layer 2 Wi-Fi payload
"""
rtap_len = WiHelper.__get_rtap_len(frame)
rtap = frame[:rtap_len]
packet = frame... | [
"strip",
"injected",
"radiotap",
"header",
".",
":",
"return",
":",
"ctypes",
".",
"Structure",
"radiotap",
"header",
":",
"return",
":",
"ctypes",
".",
"Structure",
"actual",
"layer",
"2",
"Wi",
"-",
"Fi",
"payload"
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L325-L335 | [
"def",
"_strip_rtap",
"(",
"frame",
")",
":",
"rtap_len",
"=",
"WiHelper",
".",
"__get_rtap_len",
"(",
"frame",
")",
"rtap",
"=",
"frame",
"[",
":",
"rtap_len",
"]",
"packet",
"=",
"frame",
"[",
"rtap_len",
":",
"]",
"return",
"rtap",
",",
"packet"
] | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_present | strip(4 byte) radiotap.present. Those are flags that
identify existence of incoming radiotap meta-data.
:idx: int
:return: str
:return: namedtuple | pcapfile/protocols/linklayer/wifi.py | def strip_present(payload):
"""strip(4 byte) radiotap.present. Those are flags that
identify existence of incoming radiotap meta-data.
:idx: int
:return: str
:return: namedtuple
"""
present = collections.namedtuple(
'present', ['tsft', 'flags', 'rate',... | def strip_present(payload):
"""strip(4 byte) radiotap.present. Those are flags that
identify existence of incoming radiotap meta-data.
:idx: int
:return: str
:return: namedtuple
"""
present = collections.namedtuple(
'present', ['tsft', 'flags', 'rate',... | [
"strip",
"(",
"4",
"byte",
")",
"radiotap",
".",
"present",
".",
"Those",
"are",
"flags",
"that",
"identify",
"existence",
"of",
"incoming",
"radiotap",
"meta",
"-",
"data",
".",
":",
"idx",
":",
"int",
":",
"return",
":",
"str",
":",
"return",
":",
... | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L734-L777 | [
"def",
"strip_present",
"(",
"payload",
")",
":",
"present",
"=",
"collections",
".",
"namedtuple",
"(",
"'present'",
",",
"[",
"'tsft'",
",",
"'flags'",
",",
"'rate'",
",",
"'channel'",
",",
"'fhss'",
",",
"'dbm_antsignal'",
",",
"'dbm_antnoise'",
",",
"'lo... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_tsft | strip(8 byte) radiotap.mactime
:idx: int
:return: int
idx
:return: int
mactime | pcapfile/protocols/linklayer/wifi.py | def strip_tsft(self, idx):
"""strip(8 byte) radiotap.mactime
:idx: int
:return: int
idx
:return: int
mactime
"""
idx = Radiotap.align(idx, 8)
mactime, = struct.unpack_from('<Q', self._rtap, idx)
return idx + 8, mactime | def strip_tsft(self, idx):
"""strip(8 byte) radiotap.mactime
:idx: int
:return: int
idx
:return: int
mactime
"""
idx = Radiotap.align(idx, 8)
mactime, = struct.unpack_from('<Q', self._rtap, idx)
return idx + 8, mactime | [
"strip",
"(",
"8",
"byte",
")",
"radiotap",
".",
"mactime",
":",
"idx",
":",
"int",
":",
"return",
":",
"int",
"idx",
":",
"return",
":",
"int",
"mactime"
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L779-L789 | [
"def",
"strip_tsft",
"(",
"self",
",",
"idx",
")",
":",
"idx",
"=",
"Radiotap",
".",
"align",
"(",
"idx",
",",
"8",
")",
"mactime",
",",
"=",
"struct",
".",
"unpack_from",
"(",
"'<Q'",
",",
"self",
".",
"_rtap",
",",
"idx",
")",
"return",
"idx",
... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_flags | strip(1 byte) radiotap.flags
:idx: int
:return: int
idx
:return: collections.namedtuple | pcapfile/protocols/linklayer/wifi.py | def strip_flags(self, idx):
"""strip(1 byte) radiotap.flags
:idx: int
:return: int
idx
:return: collections.namedtuple
"""
flags = collections.namedtuple(
'flags', ['cfp', 'preamble', 'wep', 'fragmentation', 'fcs',
'datapad', ... | def strip_flags(self, idx):
"""strip(1 byte) radiotap.flags
:idx: int
:return: int
idx
:return: collections.namedtuple
"""
flags = collections.namedtuple(
'flags', ['cfp', 'preamble', 'wep', 'fragmentation', 'fcs',
'datapad', ... | [
"strip",
"(",
"1",
"byte",
")",
"radiotap",
".",
"flags",
":",
"idx",
":",
"int",
":",
"return",
":",
"int",
"idx",
":",
"return",
":",
"collections",
".",
"namedtuple"
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L791-L811 | [
"def",
"strip_flags",
"(",
"self",
",",
"idx",
")",
":",
"flags",
"=",
"collections",
".",
"namedtuple",
"(",
"'flags'",
",",
"[",
"'cfp'",
",",
"'preamble'",
",",
"'wep'",
",",
"'fragmentation'",
",",
"'fcs'",
",",
"'datapad'",
",",
"'badfcs'",
",",
"'s... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_rate | strip(1 byte) radiotap.datarate
note that, unit of this field is originally 0.5 Mbps
:idx: int
:return: int
idx
:return: double
rate in terms of Mbps | pcapfile/protocols/linklayer/wifi.py | def strip_rate(self, idx):
"""strip(1 byte) radiotap.datarate
note that, unit of this field is originally 0.5 Mbps
:idx: int
:return: int
idx
:return: double
rate in terms of Mbps
"""
val, = struct.unpack_from('<B', self._rtap, idx)
... | def strip_rate(self, idx):
"""strip(1 byte) radiotap.datarate
note that, unit of this field is originally 0.5 Mbps
:idx: int
:return: int
idx
:return: double
rate in terms of Mbps
"""
val, = struct.unpack_from('<B', self._rtap, idx)
... | [
"strip",
"(",
"1",
"byte",
")",
"radiotap",
".",
"datarate",
"note",
"that",
"unit",
"of",
"this",
"field",
"is",
"originally",
"0",
".",
"5",
"Mbps",
":",
"idx",
":",
"int",
":",
"return",
":",
"int",
"idx",
":",
"return",
":",
"double",
"rate",
"... | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L813-L824 | [
"def",
"strip_rate",
"(",
"self",
",",
"idx",
")",
":",
"val",
",",
"=",
"struct",
".",
"unpack_from",
"(",
"'<B'",
",",
"self",
".",
"_rtap",
",",
"idx",
")",
"rate_unit",
"=",
"float",
"(",
"1",
")",
"/",
"2",
"# Mbps",
"return",
"idx",
"+",
"1... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_chan | strip(2 byte) radiotap.channel.flags
:idx: int
:return: int
idx
:return: collections.namedtuple | pcapfile/protocols/linklayer/wifi.py | def strip_chan(self, idx):
"""strip(2 byte) radiotap.channel.flags
:idx: int
:return: int
idx
:return: collections.namedtuple
"""
chan = collections.namedtuple(
'chan', ['freq', 'turbo', 'cck', 'ofdm', 'two_g', 'five_g',
'passi... | def strip_chan(self, idx):
"""strip(2 byte) radiotap.channel.flags
:idx: int
:return: int
idx
:return: collections.namedtuple
"""
chan = collections.namedtuple(
'chan', ['freq', 'turbo', 'cck', 'ofdm', 'two_g', 'five_g',
'passi... | [
"strip",
"(",
"2",
"byte",
")",
"radiotap",
".",
"channel",
".",
"flags",
":",
"idx",
":",
"int",
":",
"return",
":",
"int",
"idx",
":",
"return",
":",
"collections",
".",
"namedtuple"
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L826-L855 | [
"def",
"strip_chan",
"(",
"self",
",",
"idx",
")",
":",
"chan",
"=",
"collections",
".",
"namedtuple",
"(",
"'chan'",
",",
"[",
"'freq'",
",",
"'turbo'",
",",
"'cck'",
",",
"'ofdm'",
",",
"'two_g'",
",",
"'five_g'",
",",
"'passive'",
",",
"'dynamic'",
... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_fhss | strip (2 byte) radiotap.fhss.hopset(1 byte) and
radiotap.fhss.pattern(1 byte)
:idx: int
:return: int
idx
:return: collections.namedtuple | pcapfile/protocols/linklayer/wifi.py | def strip_fhss(self, idx):
"""strip (2 byte) radiotap.fhss.hopset(1 byte) and
radiotap.fhss.pattern(1 byte)
:idx: int
:return: int
idx
:return: collections.namedtuple
"""
fhss = collections.namedtuple('fhss', ['hopset', 'pattern'])
fhss.hopset,... | def strip_fhss(self, idx):
"""strip (2 byte) radiotap.fhss.hopset(1 byte) and
radiotap.fhss.pattern(1 byte)
:idx: int
:return: int
idx
:return: collections.namedtuple
"""
fhss = collections.namedtuple('fhss', ['hopset', 'pattern'])
fhss.hopset,... | [
"strip",
"(",
"2",
"byte",
")",
"radiotap",
".",
"fhss",
".",
"hopset",
"(",
"1",
"byte",
")",
"and",
"radiotap",
".",
"fhss",
".",
"pattern",
"(",
"1",
"byte",
")",
":",
"idx",
":",
"int",
":",
"return",
":",
"int",
"idx",
":",
"return",
":",
... | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L857-L867 | [
"def",
"strip_fhss",
"(",
"self",
",",
"idx",
")",
":",
"fhss",
"=",
"collections",
".",
"namedtuple",
"(",
"'fhss'",
",",
"[",
"'hopset'",
",",
"'pattern'",
"]",
")",
"fhss",
".",
"hopset",
",",
"fhss",
".",
"pattern",
",",
"=",
"struct",
".",
"unpa... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_dbm_antsignal | strip(1 byte) radiotap.dbm.ant_signal
:idx: int
:return: int
idx
:return: int | pcapfile/protocols/linklayer/wifi.py | def strip_dbm_antsignal(self, idx):
"""strip(1 byte) radiotap.dbm.ant_signal
:idx: int
:return: int
idx
:return: int
"""
dbm_antsignal, = struct.unpack_from('<b', self._rtap, idx)
return idx + 1, dbm_antsignal | def strip_dbm_antsignal(self, idx):
"""strip(1 byte) radiotap.dbm.ant_signal
:idx: int
:return: int
idx
:return: int
"""
dbm_antsignal, = struct.unpack_from('<b', self._rtap, idx)
return idx + 1, dbm_antsignal | [
"strip",
"(",
"1",
"byte",
")",
"radiotap",
".",
"dbm",
".",
"ant_signal",
":",
"idx",
":",
"int",
":",
"return",
":",
"int",
"idx",
":",
"return",
":",
"int"
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L869-L877 | [
"def",
"strip_dbm_antsignal",
"(",
"self",
",",
"idx",
")",
":",
"dbm_antsignal",
",",
"=",
"struct",
".",
"unpack_from",
"(",
"'<b'",
",",
"self",
".",
"_rtap",
",",
"idx",
")",
"return",
"idx",
"+",
"1",
",",
"dbm_antsignal"
] | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_dbm_antnoise | strip(1 byte) radiotap.dbm_antnoise
:idx: int
:return: int
idx
:return: int | pcapfile/protocols/linklayer/wifi.py | def strip_dbm_antnoise(self, idx):
"""strip(1 byte) radiotap.dbm_antnoise
:idx: int
:return: int
idx
:return: int
"""
dbm_antnoise, = struct.unpack_from('<b', self._rtap, idx)
return idx + 1, dbm_antnoise | def strip_dbm_antnoise(self, idx):
"""strip(1 byte) radiotap.dbm_antnoise
:idx: int
:return: int
idx
:return: int
"""
dbm_antnoise, = struct.unpack_from('<b', self._rtap, idx)
return idx + 1, dbm_antnoise | [
"strip",
"(",
"1",
"byte",
")",
"radiotap",
".",
"dbm_antnoise",
":",
"idx",
":",
"int",
":",
"return",
":",
"int",
"idx",
":",
"return",
":",
"int"
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L879-L887 | [
"def",
"strip_dbm_antnoise",
"(",
"self",
",",
"idx",
")",
":",
"dbm_antnoise",
",",
"=",
"struct",
".",
"unpack_from",
"(",
"'<b'",
",",
"self",
".",
"_rtap",
",",
"idx",
")",
"return",
"idx",
"+",
"1",
",",
"dbm_antnoise"
] | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_lock_quality | strip(2 byte) lock quality
:idx: int
:return: int
idx
:return: int | pcapfile/protocols/linklayer/wifi.py | def strip_lock_quality(self, idx):
"""strip(2 byte) lock quality
:idx: int
:return: int
idx
:return: int
"""
idx = Radiotap.align(idx, 2)
lock_quality, = struct.unpack_from('<H', self._rtap, idx)
return idx + 2, lock_quality | def strip_lock_quality(self, idx):
"""strip(2 byte) lock quality
:idx: int
:return: int
idx
:return: int
"""
idx = Radiotap.align(idx, 2)
lock_quality, = struct.unpack_from('<H', self._rtap, idx)
return idx + 2, lock_quality | [
"strip",
"(",
"2",
"byte",
")",
"lock",
"quality",
":",
"idx",
":",
"int",
":",
"return",
":",
"int",
"idx",
":",
"return",
":",
"int"
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L889-L898 | [
"def",
"strip_lock_quality",
"(",
"self",
",",
"idx",
")",
":",
"idx",
"=",
"Radiotap",
".",
"align",
"(",
"idx",
",",
"2",
")",
"lock_quality",
",",
"=",
"struct",
".",
"unpack_from",
"(",
"'<H'",
",",
"self",
".",
"_rtap",
",",
"idx",
")",
"return"... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_tx_attenuation | strip(1 byte) tx_attenuation
:idx: int
:return: int
idx
:return: int | pcapfile/protocols/linklayer/wifi.py | def strip_tx_attenuation(self, idx):
"""strip(1 byte) tx_attenuation
:idx: int
:return: int
idx
:return: int
"""
idx = Radiotap.align(idx, 2)
tx_attenuation, = struct.unpack_from('<H', self._rtap, idx)
return idx + 2, tx_attenuation | def strip_tx_attenuation(self, idx):
"""strip(1 byte) tx_attenuation
:idx: int
:return: int
idx
:return: int
"""
idx = Radiotap.align(idx, 2)
tx_attenuation, = struct.unpack_from('<H', self._rtap, idx)
return idx + 2, tx_attenuation | [
"strip",
"(",
"1",
"byte",
")",
"tx_attenuation",
":",
"idx",
":",
"int",
":",
"return",
":",
"int",
"idx",
":",
"return",
":",
"int"
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L900-L909 | [
"def",
"strip_tx_attenuation",
"(",
"self",
",",
"idx",
")",
":",
"idx",
"=",
"Radiotap",
".",
"align",
"(",
"idx",
",",
"2",
")",
"tx_attenuation",
",",
"=",
"struct",
".",
"unpack_from",
"(",
"'<H'",
",",
"self",
".",
"_rtap",
",",
"idx",
")",
"ret... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_db_tx_attenuation | strip(1 byte) db_tx_attenuation
:return: int
idx
:return: int | pcapfile/protocols/linklayer/wifi.py | def strip_db_tx_attenuation(self, idx):
"""strip(1 byte) db_tx_attenuation
:return: int
idx
:return: int
"""
idx = Radiotap.align(idx, 2)
db_tx_attenuation, = struct.unpack_from('<H', self._rtap, idx)
return idx + 2, db_tx_attenuation | def strip_db_tx_attenuation(self, idx):
"""strip(1 byte) db_tx_attenuation
:return: int
idx
:return: int
"""
idx = Radiotap.align(idx, 2)
db_tx_attenuation, = struct.unpack_from('<H', self._rtap, idx)
return idx + 2, db_tx_attenuation | [
"strip",
"(",
"1",
"byte",
")",
"db_tx_attenuation",
":",
"return",
":",
"int",
"idx",
":",
"return",
":",
"int"
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L911-L919 | [
"def",
"strip_db_tx_attenuation",
"(",
"self",
",",
"idx",
")",
":",
"idx",
"=",
"Radiotap",
".",
"align",
"(",
"idx",
",",
"2",
")",
"db_tx_attenuation",
",",
"=",
"struct",
".",
"unpack_from",
"(",
"'<H'",
",",
"self",
".",
"_rtap",
",",
"idx",
")",
... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_dbm_tx_power | strip(1 byte) dbm_tx_power
:return: int
idx
:return: int | pcapfile/protocols/linklayer/wifi.py | def strip_dbm_tx_power(self, idx):
"""strip(1 byte) dbm_tx_power
:return: int
idx
:return: int
"""
idx = Radiotap.align(idx, 1)
dbm_tx_power, = struct.unpack_from('<b', self._rtap, idx)
return idx + 1, dbm_tx_power | def strip_dbm_tx_power(self, idx):
"""strip(1 byte) dbm_tx_power
:return: int
idx
:return: int
"""
idx = Radiotap.align(idx, 1)
dbm_tx_power, = struct.unpack_from('<b', self._rtap, idx)
return idx + 1, dbm_tx_power | [
"strip",
"(",
"1",
"byte",
")",
"dbm_tx_power",
":",
"return",
":",
"int",
"idx",
":",
"return",
":",
"int"
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L921-L929 | [
"def",
"strip_dbm_tx_power",
"(",
"self",
",",
"idx",
")",
":",
"idx",
"=",
"Radiotap",
".",
"align",
"(",
"idx",
",",
"1",
")",
"dbm_tx_power",
",",
"=",
"struct",
".",
"unpack_from",
"(",
"'<b'",
",",
"self",
".",
"_rtap",
",",
"idx",
")",
"return"... | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
valid | Radiotap.strip_antenna | strip(1 byte) radiotap.antenna
:return: int
idx
:return: int | pcapfile/protocols/linklayer/wifi.py | def strip_antenna(self, idx):
"""strip(1 byte) radiotap.antenna
:return: int
idx
:return: int
"""
antenna, = struct.unpack_from('<B', self._rtap, idx)
return idx + 1, antenna | def strip_antenna(self, idx):
"""strip(1 byte) radiotap.antenna
:return: int
idx
:return: int
"""
antenna, = struct.unpack_from('<B', self._rtap, idx)
return idx + 1, antenna | [
"strip",
"(",
"1",
"byte",
")",
"radiotap",
".",
"antenna",
":",
"return",
":",
"int",
"idx",
":",
"return",
":",
"int"
] | kisom/pypcapfile | python | https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L931-L938 | [
"def",
"strip_antenna",
"(",
"self",
",",
"idx",
")",
":",
"antenna",
",",
"=",
"struct",
".",
"unpack_from",
"(",
"'<B'",
",",
"self",
".",
"_rtap",
",",
"idx",
")",
"return",
"idx",
"+",
"1",
",",
"antenna"
] | 67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.