repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Linaro/squad | squad/core/management/commands/users.py | Command.handle_update | def handle_update(self, options): # pylint: disable=no-self-use
""" Update existing user"""
username = options["username"]
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
raise CommandError("User %s does not exist" % username)
if... | python | def handle_update(self, options): # pylint: disable=no-self-use
""" Update existing user"""
username = options["username"]
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
raise CommandError("User %s does not exist" % username)
if... | [
"def",
"handle_update",
"(",
"self",
",",
"options",
")",
":",
"# pylint: disable=no-self-use",
"username",
"=",
"options",
"[",
"\"username\"",
"]",
"try",
":",
"user",
"=",
"User",
".",
"objects",
".",
"get",
"(",
"username",
"=",
"username",
")",
"except"... | Update existing user | [
"Update",
"existing",
"user"
] | 27da5375e119312a86f231df95f99c979b9f48f0 | https://github.com/Linaro/squad/blob/27da5375e119312a86f231df95f99c979b9f48f0/squad/core/management/commands/users.py#L176-L192 | train | 30,200 |
Linaro/squad | squad/core/management/commands/users.py | Command.handle_details | def handle_details(self, username):
""" Print user details """
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
raise CommandError("Unable to find user '%s'" % username)
self.stdout.write("username : %s" % username)
self.stdout... | python | def handle_details(self, username):
""" Print user details """
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
raise CommandError("Unable to find user '%s'" % username)
self.stdout.write("username : %s" % username)
self.stdout... | [
"def",
"handle_details",
"(",
"self",
",",
"username",
")",
":",
"try",
":",
"user",
"=",
"User",
".",
"objects",
".",
"get",
"(",
"username",
"=",
"username",
")",
"except",
"User",
".",
"DoesNotExist",
":",
"raise",
"CommandError",
"(",
"\"Unable to find... | Print user details | [
"Print",
"user",
"details"
] | 27da5375e119312a86f231df95f99c979b9f48f0 | https://github.com/Linaro/squad/blob/27da5375e119312a86f231df95f99c979b9f48f0/squad/core/management/commands/users.py#L194-L206 | train | 30,201 |
Linaro/squad | squad/core/plugins.py | apply_plugins | def apply_plugins(plugin_names):
"""
This function should be used by code in the SQUAD core to trigger
functionality from plugins.
The ``plugin_names`` argument is list of plugins names to be used. Most
probably, you will want to pass the list of plugins enabled for a given
project, e.g. ``pro... | python | def apply_plugins(plugin_names):
"""
This function should be used by code in the SQUAD core to trigger
functionality from plugins.
The ``plugin_names`` argument is list of plugins names to be used. Most
probably, you will want to pass the list of plugins enabled for a given
project, e.g. ``pro... | [
"def",
"apply_plugins",
"(",
"plugin_names",
")",
":",
"if",
"plugin_names",
"is",
"None",
":",
"return",
"for",
"p",
"in",
"plugin_names",
":",
"try",
":",
"plugin",
"=",
"get_plugin_instance",
"(",
"p",
")",
"yield",
"(",
"plugin",
")",
"except",
"Plugin... | This function should be used by code in the SQUAD core to trigger
functionality from plugins.
The ``plugin_names`` argument is list of plugins names to be used. Most
probably, you will want to pass the list of plugins enabled for a given
project, e.g. ``project.enabled_plugins``.
Example::
... | [
"This",
"function",
"should",
"be",
"used",
"by",
"code",
"in",
"the",
"SQUAD",
"core",
"to",
"trigger",
"functionality",
"from",
"plugins",
"."
] | 27da5375e119312a86f231df95f99c979b9f48f0 | https://github.com/Linaro/squad/blob/27da5375e119312a86f231df95f99c979b9f48f0/squad/core/plugins.py#L61-L88 | train | 30,202 |
Linaro/squad | squad/core/models.py | Build.metadata | def metadata(self):
"""
The build metadata is the union of the metadata in its test runs.
Common keys with different values are transformed into a list with each
of the different values.
"""
if self.__metadata__ is None:
metadata = {}
for test_run ... | python | def metadata(self):
"""
The build metadata is the union of the metadata in its test runs.
Common keys with different values are transformed into a list with each
of the different values.
"""
if self.__metadata__ is None:
metadata = {}
for test_run ... | [
"def",
"metadata",
"(",
"self",
")",
":",
"if",
"self",
".",
"__metadata__",
"is",
"None",
":",
"metadata",
"=",
"{",
"}",
"for",
"test_run",
"in",
"self",
".",
"test_runs",
".",
"defer",
"(",
"None",
")",
".",
"all",
"(",
")",
":",
"for",
"key",
... | The build metadata is the union of the metadata in its test runs.
Common keys with different values are transformed into a list with each
of the different values. | [
"The",
"build",
"metadata",
"is",
"the",
"union",
"of",
"the",
"metadata",
"in",
"its",
"test",
"runs",
".",
"Common",
"keys",
"with",
"different",
"values",
"are",
"transformed",
"into",
"a",
"list",
"with",
"each",
"of",
"the",
"different",
"values",
"."... | 27da5375e119312a86f231df95f99c979b9f48f0 | https://github.com/Linaro/squad/blob/27da5375e119312a86f231df95f99c979b9f48f0/squad/core/models.py#L352-L371 | train | 30,203 |
Linaro/squad | squad/api/rest.py | ProjectViewSet.builds | def builds(self, request, pk=None):
"""
List of builds for the current project.
"""
builds = self.get_object().builds.prefetch_related('test_runs').order_by('-datetime')
page = self.paginate_queryset(builds)
serializer = BuildSerializer(page, many=True, context={'request'... | python | def builds(self, request, pk=None):
"""
List of builds for the current project.
"""
builds = self.get_object().builds.prefetch_related('test_runs').order_by('-datetime')
page = self.paginate_queryset(builds)
serializer = BuildSerializer(page, many=True, context={'request'... | [
"def",
"builds",
"(",
"self",
",",
"request",
",",
"pk",
"=",
"None",
")",
":",
"builds",
"=",
"self",
".",
"get_object",
"(",
")",
".",
"builds",
".",
"prefetch_related",
"(",
"'test_runs'",
")",
".",
"order_by",
"(",
"'-datetime'",
")",
"page",
"=",
... | List of builds for the current project. | [
"List",
"of",
"builds",
"for",
"the",
"current",
"project",
"."
] | 27da5375e119312a86f231df95f99c979b9f48f0 | https://github.com/Linaro/squad/blob/27da5375e119312a86f231df95f99c979b9f48f0/squad/api/rest.py#L356-L363 | train | 30,204 |
Linaro/squad | squad/api/rest.py | ProjectViewSet.suites | def suites(self, request, pk=None):
"""
List of test suite names available in this project
"""
suites_names = self.get_object().suites.values_list('slug')
suites_metadata = SuiteMetadata.objects.filter(kind='suite', suite__in=suites_names)
page = self.paginate_queryset(su... | python | def suites(self, request, pk=None):
"""
List of test suite names available in this project
"""
suites_names = self.get_object().suites.values_list('slug')
suites_metadata = SuiteMetadata.objects.filter(kind='suite', suite__in=suites_names)
page = self.paginate_queryset(su... | [
"def",
"suites",
"(",
"self",
",",
"request",
",",
"pk",
"=",
"None",
")",
":",
"suites_names",
"=",
"self",
".",
"get_object",
"(",
")",
".",
"suites",
".",
"values_list",
"(",
"'slug'",
")",
"suites_metadata",
"=",
"SuiteMetadata",
".",
"objects",
".",... | List of test suite names available in this project | [
"List",
"of",
"test",
"suite",
"names",
"available",
"in",
"this",
"project"
] | 27da5375e119312a86f231df95f99c979b9f48f0 | https://github.com/Linaro/squad/blob/27da5375e119312a86f231df95f99c979b9f48f0/squad/api/rest.py#L366-L374 | train | 30,205 |
NoRedInk/make-lambda-package | make_lambda_package/cli.py | main | def main(
source,
repo_source_files,
requirements_file,
local_source_file,
work_dir):
"""
Bundle up a deployment package for AWS Lambda.
From your local filesystem:
\b
$ make-lambda-package .
...
dist/lambda-package.zip
Or from a rem... | python | def main(
source,
repo_source_files,
requirements_file,
local_source_file,
work_dir):
"""
Bundle up a deployment package for AWS Lambda.
From your local filesystem:
\b
$ make-lambda-package .
...
dist/lambda-package.zip
Or from a rem... | [
"def",
"main",
"(",
"source",
",",
"repo_source_files",
",",
"requirements_file",
",",
"local_source_file",
",",
"work_dir",
")",
":",
"scm_source",
"=",
"fsutil",
".",
"parse_path_or_url",
"(",
"source",
")",
"paths",
"=",
"fsutil",
".",
"decide_paths",
"(",
... | Bundle up a deployment package for AWS Lambda.
From your local filesystem:
\b
$ make-lambda-package .
...
dist/lambda-package.zip
Or from a remote git repository:
\b
$ make-lambda-package https://github.com/NoRedInk/make-lambda-package.git
...
vendor/d... | [
"Bundle",
"up",
"a",
"deployment",
"package",
"for",
"AWS",
"Lambda",
"."
] | eb9326352e41f7df3a630b06ad0a7554138c174a | https://github.com/NoRedInk/make-lambda-package/blob/eb9326352e41f7df3a630b06ad0a7554138c174a/make_lambda_package/cli.py#L29-L105 | train | 30,206 |
dwavesystems/dwave-neal | neal/sampler.py | _default_ising_beta_range | def _default_ising_beta_range(h, J):
"""Determine the starting and ending beta from h J
Args:
h (dict)
J (dict)
Assume each variable in J is also in h.
We use the minimum bias to give a lower bound on the minimum energy gap, such at the
final sweeps we are highly likely to settle... | python | def _default_ising_beta_range(h, J):
"""Determine the starting and ending beta from h J
Args:
h (dict)
J (dict)
Assume each variable in J is also in h.
We use the minimum bias to give a lower bound on the minimum energy gap, such at the
final sweeps we are highly likely to settle... | [
"def",
"_default_ising_beta_range",
"(",
"h",
",",
"J",
")",
":",
"# Get nonzero, absolute biases",
"abs_h",
"=",
"[",
"abs",
"(",
"hh",
")",
"for",
"hh",
"in",
"h",
".",
"values",
"(",
")",
"if",
"hh",
"!=",
"0",
"]",
"abs_J",
"=",
"[",
"abs",
"(",
... | Determine the starting and ending beta from h J
Args:
h (dict)
J (dict)
Assume each variable in J is also in h.
We use the minimum bias to give a lower bound on the minimum energy gap, such at the
final sweeps we are highly likely to settle into the current valley. | [
"Determine",
"the",
"starting",
"and",
"ending",
"beta",
"from",
"h",
"J"
] | c9ce6251b9486e3c5e736e2171c07a4d643a31a5 | https://github.com/dwavesystems/dwave-neal/blob/c9ce6251b9486e3c5e736e2171c07a4d643a31a5/neal/sampler.py#L295-L342 | train | 30,207 |
EpistasisLab/scikit-rebate | skrebate/relieff.py | ReliefF._getMultiClassMap | def _getMultiClassMap(self):
""" Relief algorithms handle the scoring updates a little differently for data with multiclass outcomes. In ReBATE we implement multiclass scoring in line with
the strategy described by Kononenko 1994 within the RELIEF-F variant which was suggested to outperform the RELIEF-E... | python | def _getMultiClassMap(self):
""" Relief algorithms handle the scoring updates a little differently for data with multiclass outcomes. In ReBATE we implement multiclass scoring in line with
the strategy described by Kononenko 1994 within the RELIEF-F variant which was suggested to outperform the RELIEF-E... | [
"def",
"_getMultiClassMap",
"(",
"self",
")",
":",
"mcmap",
"=",
"dict",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_datalen",
")",
":",
"if",
"(",
"self",
".",
"_y",
"[",
"i",
"]",
"not",
"in",
"mcmap",
")",
":",
"mcmap",
"[",
"se... | Relief algorithms handle the scoring updates a little differently for data with multiclass outcomes. In ReBATE we implement multiclass scoring in line with
the strategy described by Kononenko 1994 within the RELIEF-F variant which was suggested to outperform the RELIEF-E multiclass variant. This strategy weight... | [
"Relief",
"algorithms",
"handle",
"the",
"scoring",
"updates",
"a",
"little",
"differently",
"for",
"data",
"with",
"multiclass",
"outcomes",
".",
"In",
"ReBATE",
"we",
"implement",
"multiclass",
"scoring",
"in",
"line",
"with",
"the",
"strategy",
"described",
"... | 67dab51a7525fa5d076b059f1e6f8cff7481c1ef | https://github.com/EpistasisLab/scikit-rebate/blob/67dab51a7525fa5d076b059f1e6f8cff7481c1ef/skrebate/relieff.py#L258-L275 | train | 30,208 |
EpistasisLab/scikit-rebate | skrebate/relieff.py | ReliefF._distarray_missing | def _distarray_missing(self, xc, xd, cdiffs):
"""Distance array calculation for data with missing values"""
cindices = []
dindices = []
# Get Boolean mask locating missing values for continuous and discrete features separately. These correspond to xc and xd respectively.
for i in... | python | def _distarray_missing(self, xc, xd, cdiffs):
"""Distance array calculation for data with missing values"""
cindices = []
dindices = []
# Get Boolean mask locating missing values for continuous and discrete features separately. These correspond to xc and xd respectively.
for i in... | [
"def",
"_distarray_missing",
"(",
"self",
",",
"xc",
",",
"xd",
",",
"cdiffs",
")",
":",
"cindices",
"=",
"[",
"]",
"dindices",
"=",
"[",
"]",
"# Get Boolean mask locating missing values for continuous and discrete features separately. These correspond to xc and xd respective... | Distance array calculation for data with missing values | [
"Distance",
"array",
"calculation",
"for",
"data",
"with",
"missing",
"values"
] | 67dab51a7525fa5d076b059f1e6f8cff7481c1ef | https://github.com/EpistasisLab/scikit-rebate/blob/67dab51a7525fa5d076b059f1e6f8cff7481c1ef/skrebate/relieff.py#L357-L374 | train | 30,209 |
EpistasisLab/scikit-rebate | skrebate/surfstar.py | SURFstar._find_neighbors | def _find_neighbors(self, inst, avg_dist):
""" Identify nearest as well as farthest hits and misses within radius defined by average distance over whole distance array.
This works the same regardless of endpoint type. """
NN_near = []
NN_far = []
min_indices = []
max_indi... | python | def _find_neighbors(self, inst, avg_dist):
""" Identify nearest as well as farthest hits and misses within radius defined by average distance over whole distance array.
This works the same regardless of endpoint type. """
NN_near = []
NN_far = []
min_indices = []
max_indi... | [
"def",
"_find_neighbors",
"(",
"self",
",",
"inst",
",",
"avg_dist",
")",
":",
"NN_near",
"=",
"[",
"]",
"NN_far",
"=",
"[",
"]",
"min_indices",
"=",
"[",
"]",
"max_indices",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_datalen",
"... | Identify nearest as well as farthest hits and misses within radius defined by average distance over whole distance array.
This works the same regardless of endpoint type. | [
"Identify",
"nearest",
"as",
"well",
"as",
"farthest",
"hits",
"and",
"misses",
"within",
"radius",
"defined",
"by",
"average",
"distance",
"over",
"whole",
"distance",
"array",
".",
"This",
"works",
"the",
"same",
"regardless",
"of",
"endpoint",
"type",
"."
] | 67dab51a7525fa5d076b059f1e6f8cff7481c1ef | https://github.com/EpistasisLab/scikit-rebate/blob/67dab51a7525fa5d076b059f1e6f8cff7481c1ef/skrebate/surfstar.py#L46-L70 | train | 30,210 |
EpistasisLab/scikit-rebate | skrebate/scoring_utils.py | get_row_missing | def get_row_missing(xc, xd, cdiffs, index, cindices, dindices):
""" Calculate distance between index instance and all other instances. """
row = np.empty(0, dtype=np.double) # initialize empty row
cinst1 = xc[index] # continuous-valued features for index instance
dinst1 = xd[index] # discrete-val... | python | def get_row_missing(xc, xd, cdiffs, index, cindices, dindices):
""" Calculate distance between index instance and all other instances. """
row = np.empty(0, dtype=np.double) # initialize empty row
cinst1 = xc[index] # continuous-valued features for index instance
dinst1 = xd[index] # discrete-val... | [
"def",
"get_row_missing",
"(",
"xc",
",",
"xd",
",",
"cdiffs",
",",
"index",
",",
"cindices",
",",
"dindices",
")",
":",
"row",
"=",
"np",
".",
"empty",
"(",
"0",
",",
"dtype",
"=",
"np",
".",
"double",
")",
"# initialize empty row\r",
"cinst1",
"=",
... | Calculate distance between index instance and all other instances. | [
"Calculate",
"distance",
"between",
"index",
"instance",
"and",
"all",
"other",
"instances",
"."
] | 67dab51a7525fa5d076b059f1e6f8cff7481c1ef | https://github.com/EpistasisLab/scikit-rebate/blob/67dab51a7525fa5d076b059f1e6f8cff7481c1ef/skrebate/scoring_utils.py#L31-L83 | train | 30,211 |
EpistasisLab/scikit-rebate | skrebate/scoring_utils.py | ramp_function | def ramp_function(data_type, attr, fname, xinstfeature, xNNifeature):
""" Our own user simplified variation of the ramp function suggested by Hong 1994, 1997. Hong's method requires the user to specifiy two thresholds
that indicate the max difference before a score of 1 is given, as well a min difference befo... | python | def ramp_function(data_type, attr, fname, xinstfeature, xNNifeature):
""" Our own user simplified variation of the ramp function suggested by Hong 1994, 1997. Hong's method requires the user to specifiy two thresholds
that indicate the max difference before a score of 1 is given, as well a min difference befo... | [
"def",
"ramp_function",
"(",
"data_type",
",",
"attr",
",",
"fname",
",",
"xinstfeature",
",",
"xNNifeature",
")",
":",
"diff",
"=",
"0",
"mmdiff",
"=",
"attr",
"[",
"fname",
"]",
"[",
"3",
"]",
"# Max/Min range of values for target feature\r",
"rawfd",
"=",
... | Our own user simplified variation of the ramp function suggested by Hong 1994, 1997. Hong's method requires the user to specifiy two thresholds
that indicate the max difference before a score of 1 is given, as well a min difference before a score of 0 is given, and any in the middle get a
score that is the no... | [
"Our",
"own",
"user",
"simplified",
"variation",
"of",
"the",
"ramp",
"function",
"suggested",
"by",
"Hong",
"1994",
"1997",
".",
"Hong",
"s",
"method",
"requires",
"the",
"user",
"to",
"specifiy",
"two",
"thresholds",
"that",
"indicate",
"the",
"max",
"diff... | 67dab51a7525fa5d076b059f1e6f8cff7481c1ef | https://github.com/EpistasisLab/scikit-rebate/blob/67dab51a7525fa5d076b059f1e6f8cff7481c1ef/skrebate/scoring_utils.py#L86-L108 | train | 30,212 |
EpistasisLab/scikit-rebate | skrebate/scoring_utils.py | ReliefF_compute_scores | def ReliefF_compute_scores(inst, attr, nan_entries, num_attributes, mcmap, NN, headers, class_type, X, y, labels_std, data_type):
""" Unique scoring procedure for ReliefF algorithm. Scoring based on k nearest hits and misses of current target instance. """
scores = np.zeros(num_attributes)
for feature_nu... | python | def ReliefF_compute_scores(inst, attr, nan_entries, num_attributes, mcmap, NN, headers, class_type, X, y, labels_std, data_type):
""" Unique scoring procedure for ReliefF algorithm. Scoring based on k nearest hits and misses of current target instance. """
scores = np.zeros(num_attributes)
for feature_nu... | [
"def",
"ReliefF_compute_scores",
"(",
"inst",
",",
"attr",
",",
"nan_entries",
",",
"num_attributes",
",",
"mcmap",
",",
"NN",
",",
"headers",
",",
"class_type",
",",
"X",
",",
"y",
",",
"labels_std",
",",
"data_type",
")",
":",
"scores",
"=",
"np",
".",... | Unique scoring procedure for ReliefF algorithm. Scoring based on k nearest hits and misses of current target instance. | [
"Unique",
"scoring",
"procedure",
"for",
"ReliefF",
"algorithm",
".",
"Scoring",
"based",
"on",
"k",
"nearest",
"hits",
"and",
"misses",
"of",
"current",
"target",
"instance",
"."
] | 67dab51a7525fa5d076b059f1e6f8cff7481c1ef | https://github.com/EpistasisLab/scikit-rebate/blob/67dab51a7525fa5d076b059f1e6f8cff7481c1ef/skrebate/scoring_utils.py#L352-L358 | train | 30,213 |
EpistasisLab/scikit-rebate | skrebate/scoring_utils.py | SURFstar_compute_scores | def SURFstar_compute_scores(inst, attr, nan_entries, num_attributes, mcmap, NN_near, NN_far, headers, class_type, X, y, labels_std, data_type):
""" Unique scoring procedure for SURFstar algorithm. Scoring based on nearest neighbors within defined radius, as well as
'anti-scoring' of far instances outside of r... | python | def SURFstar_compute_scores(inst, attr, nan_entries, num_attributes, mcmap, NN_near, NN_far, headers, class_type, X, y, labels_std, data_type):
""" Unique scoring procedure for SURFstar algorithm. Scoring based on nearest neighbors within defined radius, as well as
'anti-scoring' of far instances outside of r... | [
"def",
"SURFstar_compute_scores",
"(",
"inst",
",",
"attr",
",",
"nan_entries",
",",
"num_attributes",
",",
"mcmap",
",",
"NN_near",
",",
"NN_far",
",",
"headers",
",",
"class_type",
",",
"X",
",",
"y",
",",
"labels_std",
",",
"data_type",
")",
":",
"score... | Unique scoring procedure for SURFstar algorithm. Scoring based on nearest neighbors within defined radius, as well as
'anti-scoring' of far instances outside of radius of current target instance | [
"Unique",
"scoring",
"procedure",
"for",
"SURFstar",
"algorithm",
".",
"Scoring",
"based",
"on",
"nearest",
"neighbors",
"within",
"defined",
"radius",
"as",
"well",
"as",
"anti",
"-",
"scoring",
"of",
"far",
"instances",
"outside",
"of",
"radius",
"of",
"curr... | 67dab51a7525fa5d076b059f1e6f8cff7481c1ef | https://github.com/EpistasisLab/scikit-rebate/blob/67dab51a7525fa5d076b059f1e6f8cff7481c1ef/skrebate/scoring_utils.py#L372-L384 | train | 30,214 |
EpistasisLab/scikit-rebate | skrebate/multisurfstar.py | MultiSURFstar._find_neighbors | def _find_neighbors(self, inst):
""" Identify nearest as well as farthest hits and misses within radius defined by average distance and standard deviation of distances from target instanace.
This works the same regardless of endpoint type. """
dist_vect = []
for j in range(self._datalen)... | python | def _find_neighbors(self, inst):
""" Identify nearest as well as farthest hits and misses within radius defined by average distance and standard deviation of distances from target instanace.
This works the same regardless of endpoint type. """
dist_vect = []
for j in range(self._datalen)... | [
"def",
"_find_neighbors",
"(",
"self",
",",
"inst",
")",
":",
"dist_vect",
"=",
"[",
"]",
"for",
"j",
"in",
"range",
"(",
"self",
".",
"_datalen",
")",
":",
"if",
"inst",
"!=",
"j",
":",
"locator",
"=",
"[",
"inst",
",",
"j",
"]",
"if",
"inst",
... | Identify nearest as well as farthest hits and misses within radius defined by average distance and standard deviation of distances from target instanace.
This works the same regardless of endpoint type. | [
"Identify",
"nearest",
"as",
"well",
"as",
"farthest",
"hits",
"and",
"misses",
"within",
"radius",
"defined",
"by",
"average",
"distance",
"and",
"standard",
"deviation",
"of",
"distances",
"from",
"target",
"instanace",
".",
"This",
"works",
"the",
"same",
"... | 67dab51a7525fa5d076b059f1e6f8cff7481c1ef | https://github.com/EpistasisLab/scikit-rebate/blob/67dab51a7525fa5d076b059f1e6f8cff7481c1ef/skrebate/multisurfstar.py#L46-L75 | train | 30,215 |
EpistasisLab/scikit-rebate | skrebate/surf.py | SURF._find_neighbors | def _find_neighbors(self, inst, avg_dist):
""" Identify nearest hits and misses within radius defined by average distance over whole distance array.
This works the same regardless of endpoint type. """
NN = []
min_indicies = []
for i in range(self._datalen):
if inst ... | python | def _find_neighbors(self, inst, avg_dist):
""" Identify nearest hits and misses within radius defined by average distance over whole distance array.
This works the same regardless of endpoint type. """
NN = []
min_indicies = []
for i in range(self._datalen):
if inst ... | [
"def",
"_find_neighbors",
"(",
"self",
",",
"inst",
",",
"avg_dist",
")",
":",
"NN",
"=",
"[",
"]",
"min_indicies",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_datalen",
")",
":",
"if",
"inst",
"!=",
"i",
":",
"locator",
"=",
"[... | Identify nearest hits and misses within radius defined by average distance over whole distance array.
This works the same regardless of endpoint type. | [
"Identify",
"nearest",
"hits",
"and",
"misses",
"within",
"radius",
"defined",
"by",
"average",
"distance",
"over",
"whole",
"distance",
"array",
".",
"This",
"works",
"the",
"same",
"regardless",
"of",
"endpoint",
"type",
"."
] | 67dab51a7525fa5d076b059f1e6f8cff7481c1ef | https://github.com/EpistasisLab/scikit-rebate/blob/67dab51a7525fa5d076b059f1e6f8cff7481c1ef/skrebate/surf.py#L71-L87 | train | 30,216 |
edaniszewski/pylint-quotes | pylint_quotes/checker.py | StringQuoteChecker.leave_module | def leave_module(self, node):
"""Leave module and check remaining triple quotes.
Args:
node: the module node we are leaving.
"""
for triple_quote in self._tokenized_triple_quotes.values():
self._check_triple_quotes(triple_quote)
# after we are done check... | python | def leave_module(self, node):
"""Leave module and check remaining triple quotes.
Args:
node: the module node we are leaving.
"""
for triple_quote in self._tokenized_triple_quotes.values():
self._check_triple_quotes(triple_quote)
# after we are done check... | [
"def",
"leave_module",
"(",
"self",
",",
"node",
")",
":",
"for",
"triple_quote",
"in",
"self",
".",
"_tokenized_triple_quotes",
".",
"values",
"(",
")",
":",
"self",
".",
"_check_triple_quotes",
"(",
"triple_quote",
")",
"# after we are done checking these, clear o... | Leave module and check remaining triple quotes.
Args:
node: the module node we are leaving. | [
"Leave",
"module",
"and",
"check",
"remaining",
"triple",
"quotes",
"."
] | f13529541d6d787b5b37611a080937f5adba6357 | https://github.com/edaniszewski/pylint-quotes/blob/f13529541d6d787b5b37611a080937f5adba6357/pylint_quotes/checker.py#L110-L121 | train | 30,217 |
edaniszewski/pylint-quotes | pylint_quotes/checker.py | StringQuoteChecker._process_for_docstring | def _process_for_docstring(self, node, node_type):
"""Check for docstring quote consistency.
Args:
node: the AST node being visited.
node_type: the type of node being operated on.
"""
# if there is no docstring, don't need to do anything.
if node.doc is n... | python | def _process_for_docstring(self, node, node_type):
"""Check for docstring quote consistency.
Args:
node: the AST node being visited.
node_type: the type of node being operated on.
"""
# if there is no docstring, don't need to do anything.
if node.doc is n... | [
"def",
"_process_for_docstring",
"(",
"self",
",",
"node",
",",
"node_type",
")",
":",
"# if there is no docstring, don't need to do anything.",
"if",
"node",
".",
"doc",
"is",
"not",
"None",
":",
"# the module is everything, so to find the docstring, we",
"# iterate line by ... | Check for docstring quote consistency.
Args:
node: the AST node being visited.
node_type: the type of node being operated on. | [
"Check",
"for",
"docstring",
"quote",
"consistency",
"."
] | f13529541d6d787b5b37611a080937f5adba6357 | https://github.com/edaniszewski/pylint-quotes/blob/f13529541d6d787b5b37611a080937f5adba6357/pylint_quotes/checker.py#L147-L206 | train | 30,218 |
edaniszewski/pylint-quotes | pylint_quotes/checker.py | StringQuoteChecker._find_docstring_line_for_no_body | def _find_docstring_line_for_no_body(self, start):
"""Find the docstring associated with a definition with no body
in the node.
In these cases, the provided start and end line number for that
element are the same, so we must get the docstring based on the
sequential position of ... | python | def _find_docstring_line_for_no_body(self, start):
"""Find the docstring associated with a definition with no body
in the node.
In these cases, the provided start and end line number for that
element are the same, so we must get the docstring based on the
sequential position of ... | [
"def",
"_find_docstring_line_for_no_body",
"(",
"self",
",",
"start",
")",
":",
"tracked",
"=",
"sorted",
"(",
"list",
"(",
"self",
".",
"_tokenized_triple_quotes",
".",
"keys",
"(",
")",
")",
")",
"for",
"i",
"in",
"tracked",
":",
"if",
"min",
"(",
"sta... | Find the docstring associated with a definition with no body
in the node.
In these cases, the provided start and end line number for that
element are the same, so we must get the docstring based on the
sequential position of known docstrings.
Args:
start: the row wh... | [
"Find",
"the",
"docstring",
"associated",
"with",
"a",
"definition",
"with",
"no",
"body",
"in",
"the",
"node",
"."
] | f13529541d6d787b5b37611a080937f5adba6357 | https://github.com/edaniszewski/pylint-quotes/blob/f13529541d6d787b5b37611a080937f5adba6357/pylint_quotes/checker.py#L208-L227 | train | 30,219 |
edaniszewski/pylint-quotes | pylint_quotes/checker.py | StringQuoteChecker._find_docstring_line | def _find_docstring_line(self, start, end):
"""Find the row where a docstring starts in a function or class.
This will search for the first match of a triple quote token in
row sequence from the start of the class or function.
Args:
start: the row where the class / function... | python | def _find_docstring_line(self, start, end):
"""Find the row where a docstring starts in a function or class.
This will search for the first match of a triple quote token in
row sequence from the start of the class or function.
Args:
start: the row where the class / function... | [
"def",
"_find_docstring_line",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"for",
"i",
"in",
"range",
"(",
"start",
",",
"end",
"+",
"1",
")",
":",
"if",
"i",
"in",
"self",
".",
"_tokenized_triple_quotes",
":",
"return",
"i",
"return",
"None"
] | Find the row where a docstring starts in a function or class.
This will search for the first match of a triple quote token in
row sequence from the start of the class or function.
Args:
start: the row where the class / function starts.
end: the row where the class / fun... | [
"Find",
"the",
"row",
"where",
"a",
"docstring",
"starts",
"in",
"a",
"function",
"or",
"class",
"."
] | f13529541d6d787b5b37611a080937f5adba6357 | https://github.com/edaniszewski/pylint-quotes/blob/f13529541d6d787b5b37611a080937f5adba6357/pylint_quotes/checker.py#L229-L245 | train | 30,220 |
edaniszewski/pylint-quotes | pylint_quotes/checker.py | StringQuoteChecker.process_tokens | def process_tokens(self, tokens):
"""Process the token stream.
This is required to override the parent class' implementation.
Args:
tokens: the tokens from the token stream to process.
"""
for tok_type, token, (start_row, start_col), _, _ in tokens:
if t... | python | def process_tokens(self, tokens):
"""Process the token stream.
This is required to override the parent class' implementation.
Args:
tokens: the tokens from the token stream to process.
"""
for tok_type, token, (start_row, start_col), _, _ in tokens:
if t... | [
"def",
"process_tokens",
"(",
"self",
",",
"tokens",
")",
":",
"for",
"tok_type",
",",
"token",
",",
"(",
"start_row",
",",
"start_col",
")",
",",
"_",
",",
"_",
"in",
"tokens",
":",
"if",
"tok_type",
"==",
"tokenize",
".",
"STRING",
":",
"# 'token' is... | Process the token stream.
This is required to override the parent class' implementation.
Args:
tokens: the tokens from the token stream to process. | [
"Process",
"the",
"token",
"stream",
"."
] | f13529541d6d787b5b37611a080937f5adba6357 | https://github.com/edaniszewski/pylint-quotes/blob/f13529541d6d787b5b37611a080937f5adba6357/pylint_quotes/checker.py#L247-L259 | train | 30,221 |
edaniszewski/pylint-quotes | pylint_quotes/checker.py | StringQuoteChecker._process_string_token | def _process_string_token(self, token, start_row, start_col):
"""Internal method for identifying and checking string tokens
from the token stream.
Args:
token: the token to check.
start_row: the line on which the token was found.
start_col: the column on whic... | python | def _process_string_token(self, token, start_row, start_col):
"""Internal method for identifying and checking string tokens
from the token stream.
Args:
token: the token to check.
start_row: the line on which the token was found.
start_col: the column on whic... | [
"def",
"_process_string_token",
"(",
"self",
",",
"token",
",",
"start_row",
",",
"start_col",
")",
":",
"for",
"i",
",",
"char",
"in",
"enumerate",
"(",
"token",
")",
":",
"if",
"char",
"in",
"QUOTES",
":",
"break",
"# pylint: disable=undefined-loop-variable"... | Internal method for identifying and checking string tokens
from the token stream.
Args:
token: the token to check.
start_row: the line on which the token was found.
start_col: the column on which the token was found. | [
"Internal",
"method",
"for",
"identifying",
"and",
"checking",
"string",
"tokens",
"from",
"the",
"token",
"stream",
"."
] | f13529541d6d787b5b37611a080937f5adba6357 | https://github.com/edaniszewski/pylint-quotes/blob/f13529541d6d787b5b37611a080937f5adba6357/pylint_quotes/checker.py#L261-L300 | train | 30,222 |
edaniszewski/pylint-quotes | pylint_quotes/checker.py | StringQuoteChecker._check_triple_quotes | def _check_triple_quotes(self, quote_record):
"""Check if the triple quote from tokenization is valid.
Args:
quote_record: a tuple containing the info about the string
from tokenization, giving the (token, quote, row number, column).
"""
_, triple, row, col =... | python | def _check_triple_quotes(self, quote_record):
"""Check if the triple quote from tokenization is valid.
Args:
quote_record: a tuple containing the info about the string
from tokenization, giving the (token, quote, row number, column).
"""
_, triple, row, col =... | [
"def",
"_check_triple_quotes",
"(",
"self",
",",
"quote_record",
")",
":",
"_",
",",
"triple",
",",
"row",
",",
"col",
"=",
"quote_record",
"if",
"triple",
"!=",
"TRIPLE_QUOTE_OPTS",
".",
"get",
"(",
"self",
".",
"config",
".",
"triple_quote",
")",
":",
... | Check if the triple quote from tokenization is valid.
Args:
quote_record: a tuple containing the info about the string
from tokenization, giving the (token, quote, row number, column). | [
"Check",
"if",
"the",
"triple",
"quote",
"from",
"tokenization",
"is",
"valid",
"."
] | f13529541d6d787b5b37611a080937f5adba6357 | https://github.com/edaniszewski/pylint-quotes/blob/f13529541d6d787b5b37611a080937f5adba6357/pylint_quotes/checker.py#L302-L311 | train | 30,223 |
edaniszewski/pylint-quotes | pylint_quotes/checker.py | StringQuoteChecker._check_docstring_quotes | def _check_docstring_quotes(self, quote_record):
"""Check if the docstring quote from tokenization is valid.
Args:
quote_record: a tuple containing the info about the string
from tokenization, giving the (token, quote, row number).
"""
_, triple, row, col = q... | python | def _check_docstring_quotes(self, quote_record):
"""Check if the docstring quote from tokenization is valid.
Args:
quote_record: a tuple containing the info about the string
from tokenization, giving the (token, quote, row number).
"""
_, triple, row, col = q... | [
"def",
"_check_docstring_quotes",
"(",
"self",
",",
"quote_record",
")",
":",
"_",
",",
"triple",
",",
"row",
",",
"col",
"=",
"quote_record",
"if",
"triple",
"!=",
"TRIPLE_QUOTE_OPTS",
".",
"get",
"(",
"self",
".",
"config",
".",
"docstring_quote",
")",
"... | Check if the docstring quote from tokenization is valid.
Args:
quote_record: a tuple containing the info about the string
from tokenization, giving the (token, quote, row number). | [
"Check",
"if",
"the",
"docstring",
"quote",
"from",
"tokenization",
"is",
"valid",
"."
] | f13529541d6d787b5b37611a080937f5adba6357 | https://github.com/edaniszewski/pylint-quotes/blob/f13529541d6d787b5b37611a080937f5adba6357/pylint_quotes/checker.py#L313-L322 | train | 30,224 |
edaniszewski/pylint-quotes | pylint_quotes/checker.py | StringQuoteChecker._invalid_string_quote | def _invalid_string_quote(self, quote, row, correct_quote=None, col=None):
"""Add a message for an invalid string literal quote.
Args:
quote: The quote characters that were found.
row: The row number the quote character was found on.
correct_quote: The quote characte... | python | def _invalid_string_quote(self, quote, row, correct_quote=None, col=None):
"""Add a message for an invalid string literal quote.
Args:
quote: The quote characters that were found.
row: The row number the quote character was found on.
correct_quote: The quote characte... | [
"def",
"_invalid_string_quote",
"(",
"self",
",",
"quote",
",",
"row",
",",
"correct_quote",
"=",
"None",
",",
"col",
"=",
"None",
")",
":",
"if",
"not",
"correct_quote",
":",
"correct_quote",
"=",
"SMART_QUOTE_OPTS",
".",
"get",
"(",
"self",
".",
"config"... | Add a message for an invalid string literal quote.
Args:
quote: The quote characters that were found.
row: The row number the quote character was found on.
correct_quote: The quote characters that is required. If None
(default), will use the one from the conf... | [
"Add",
"a",
"message",
"for",
"an",
"invalid",
"string",
"literal",
"quote",
"."
] | f13529541d6d787b5b37611a080937f5adba6357 | https://github.com/edaniszewski/pylint-quotes/blob/f13529541d6d787b5b37611a080937f5adba6357/pylint_quotes/checker.py#L324-L342 | train | 30,225 |
edaniszewski/pylint-quotes | pylint_quotes/checker.py | StringQuoteChecker._invalid_triple_quote | def _invalid_triple_quote(self, quote, row, col=None):
"""Add a message for an invalid triple quote.
Args:
quote: The quote characters that were found.
row: The row number the quote characters were found on.
col: The column the quote characters were found on.
... | python | def _invalid_triple_quote(self, quote, row, col=None):
"""Add a message for an invalid triple quote.
Args:
quote: The quote characters that were found.
row: The row number the quote characters were found on.
col: The column the quote characters were found on.
... | [
"def",
"_invalid_triple_quote",
"(",
"self",
",",
"quote",
",",
"row",
",",
"col",
"=",
"None",
")",
":",
"self",
".",
"add_message",
"(",
"'invalid-triple-quote'",
",",
"line",
"=",
"row",
",",
"args",
"=",
"(",
"quote",
",",
"TRIPLE_QUOTE_OPTS",
".",
"... | Add a message for an invalid triple quote.
Args:
quote: The quote characters that were found.
row: The row number the quote characters were found on.
col: The column the quote characters were found on. | [
"Add",
"a",
"message",
"for",
"an",
"invalid",
"triple",
"quote",
"."
] | f13529541d6d787b5b37611a080937f5adba6357 | https://github.com/edaniszewski/pylint-quotes/blob/f13529541d6d787b5b37611a080937f5adba6357/pylint_quotes/checker.py#L364-L377 | train | 30,226 |
edaniszewski/pylint-quotes | pylint_quotes/checker.py | StringQuoteChecker._invalid_docstring_quote | def _invalid_docstring_quote(self, quote, row, col=None):
"""Add a message for an invalid docstring quote.
Args:
quote: The quote characters that were found.
row: The row number the quote characters were found on.
col: The column the quote characters were found on.
... | python | def _invalid_docstring_quote(self, quote, row, col=None):
"""Add a message for an invalid docstring quote.
Args:
quote: The quote characters that were found.
row: The row number the quote characters were found on.
col: The column the quote characters were found on.
... | [
"def",
"_invalid_docstring_quote",
"(",
"self",
",",
"quote",
",",
"row",
",",
"col",
"=",
"None",
")",
":",
"self",
".",
"add_message",
"(",
"'invalid-docstring-quote'",
",",
"line",
"=",
"row",
",",
"args",
"=",
"(",
"quote",
",",
"TRIPLE_QUOTE_OPTS",
".... | Add a message for an invalid docstring quote.
Args:
quote: The quote characters that were found.
row: The row number the quote characters were found on.
col: The column the quote characters were found on. | [
"Add",
"a",
"message",
"for",
"an",
"invalid",
"docstring",
"quote",
"."
] | f13529541d6d787b5b37611a080937f5adba6357 | https://github.com/edaniszewski/pylint-quotes/blob/f13529541d6d787b5b37611a080937f5adba6357/pylint_quotes/checker.py#L379-L392 | train | 30,227 |
ethereum/py-geth | geth/chain.py | get_live_data_dir | def get_live_data_dir():
"""
pygeth needs a base directory to store it's chain data. By default this is
the directory that `geth` uses as it's `datadir`.
"""
if sys.platform == 'darwin':
data_dir = os.path.expanduser(os.path.join(
"~",
"Library",
"Ethereu... | python | def get_live_data_dir():
"""
pygeth needs a base directory to store it's chain data. By default this is
the directory that `geth` uses as it's `datadir`.
"""
if sys.platform == 'darwin':
data_dir = os.path.expanduser(os.path.join(
"~",
"Library",
"Ethereu... | [
"def",
"get_live_data_dir",
"(",
")",
":",
"if",
"sys",
".",
"platform",
"==",
"'darwin'",
":",
"data_dir",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"os",
".",
"path",
".",
"join",
"(",
"\"~\"",
",",
"\"Library\"",
",",
"\"Ethereum\"",
",",
")",... | pygeth needs a base directory to store it's chain data. By default this is
the directory that `geth` uses as it's `datadir`. | [
"pygeth",
"needs",
"a",
"base",
"directory",
"to",
"store",
"it",
"s",
"chain",
"data",
".",
"By",
"default",
"this",
"is",
"the",
"directory",
"that",
"geth",
"uses",
"as",
"it",
"s",
"datadir",
"."
] | ad462e7c841ebd9363b318889252e1f7d7c09c56 | https://github.com/ethereum/py-geth/blob/ad462e7c841ebd9363b318889252e1f7d7c09c56/geth/chain.py#L16-L46 | train | 30,228 |
ethereum/py-geth | geth/accounts.py | get_accounts | def get_accounts(data_dir, **geth_kwargs):
"""
Returns all geth accounts as tuple of hex encoded strings
>>> geth_accounts()
... ('0x...', '0x...')
"""
command, proc = spawn_geth(dict(
data_dir=data_dir,
suffix_args=['account', 'list'],
**geth_kwargs
))
stdoutdat... | python | def get_accounts(data_dir, **geth_kwargs):
"""
Returns all geth accounts as tuple of hex encoded strings
>>> geth_accounts()
... ('0x...', '0x...')
"""
command, proc = spawn_geth(dict(
data_dir=data_dir,
suffix_args=['account', 'list'],
**geth_kwargs
))
stdoutdat... | [
"def",
"get_accounts",
"(",
"data_dir",
",",
"*",
"*",
"geth_kwargs",
")",
":",
"command",
",",
"proc",
"=",
"spawn_geth",
"(",
"dict",
"(",
"data_dir",
"=",
"data_dir",
",",
"suffix_args",
"=",
"[",
"'account'",
",",
"'list'",
"]",
",",
"*",
"*",
"get... | Returns all geth accounts as tuple of hex encoded strings
>>> geth_accounts()
... ('0x...', '0x...') | [
"Returns",
"all",
"geth",
"accounts",
"as",
"tuple",
"of",
"hex",
"encoded",
"strings"
] | ad462e7c841ebd9363b318889252e1f7d7c09c56 | https://github.com/ethereum/py-geth/blob/ad462e7c841ebd9363b318889252e1f7d7c09c56/geth/accounts.py#L8-L34 | train | 30,229 |
ethereum/py-geth | geth/accounts.py | create_new_account | def create_new_account(data_dir, password, **geth_kwargs):
"""Creates a new Ethereum account on geth.
This is useful for testing when you want to stress
interaction (transfers) between Ethereum accounts.
This command communicates with ``geth`` command over
terminal interaction. It creates keystore... | python | def create_new_account(data_dir, password, **geth_kwargs):
"""Creates a new Ethereum account on geth.
This is useful for testing when you want to stress
interaction (transfers) between Ethereum accounts.
This command communicates with ``geth`` command over
terminal interaction. It creates keystore... | [
"def",
"create_new_account",
"(",
"data_dir",
",",
"password",
",",
"*",
"*",
"geth_kwargs",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"password",
")",
":",
"geth_kwargs",
"[",
"'password'",
"]",
"=",
"password",
"command",
",",
"proc",
"=",... | Creates a new Ethereum account on geth.
This is useful for testing when you want to stress
interaction (transfers) between Ethereum accounts.
This command communicates with ``geth`` command over
terminal interaction. It creates keystore folder and new
account there.
This function only works a... | [
"Creates",
"a",
"new",
"Ethereum",
"account",
"on",
"geth",
"."
] | ad462e7c841ebd9363b318889252e1f7d7c09c56 | https://github.com/ethereum/py-geth/blob/ad462e7c841ebd9363b318889252e1f7d7c09c56/geth/accounts.py#L40-L129 | train | 30,230 |
obriencj/python-javatools | javatools/ziputils.py | compare | def compare(left, right):
"""
yields EVENT,ENTRY pairs describing the differences between left
and right, which are filenames for a pair of zip files
"""
with open_zip(left) as l:
with open_zip(right) as r:
return compare_zips(l, r) | python | def compare(left, right):
"""
yields EVENT,ENTRY pairs describing the differences between left
and right, which are filenames for a pair of zip files
"""
with open_zip(left) as l:
with open_zip(right) as r:
return compare_zips(l, r) | [
"def",
"compare",
"(",
"left",
",",
"right",
")",
":",
"with",
"open_zip",
"(",
"left",
")",
"as",
"l",
":",
"with",
"open_zip",
"(",
"right",
")",
"as",
"r",
":",
"return",
"compare_zips",
"(",
"l",
",",
"r",
")"
] | yields EVENT,ENTRY pairs describing the differences between left
and right, which are filenames for a pair of zip files | [
"yields",
"EVENT",
"ENTRY",
"pairs",
"describing",
"the",
"differences",
"between",
"left",
"and",
"right",
"which",
"are",
"filenames",
"for",
"a",
"pair",
"of",
"zip",
"files"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/ziputils.py#L44-L52 | train | 30,231 |
obriencj/python-javatools | javatools/ziputils.py | compare_zips | def compare_zips(left, right):
"""
yields EVENT,ENTRY pairs describing the differences between left
and right ZipFile instances
"""
ll = set(left.namelist())
rl = set(right.namelist())
for f in ll:
if f in rl:
rl.remove(f)
if f[-1] == '/':
#... | python | def compare_zips(left, right):
"""
yields EVENT,ENTRY pairs describing the differences between left
and right ZipFile instances
"""
ll = set(left.namelist())
rl = set(right.namelist())
for f in ll:
if f in rl:
rl.remove(f)
if f[-1] == '/':
#... | [
"def",
"compare_zips",
"(",
"left",
",",
"right",
")",
":",
"ll",
"=",
"set",
"(",
"left",
".",
"namelist",
"(",
")",
")",
"rl",
"=",
"set",
"(",
"right",
".",
"namelist",
"(",
")",
")",
"for",
"f",
"in",
"ll",
":",
"if",
"f",
"in",
"rl",
":"... | yields EVENT,ENTRY pairs describing the differences between left
and right ZipFile instances | [
"yields",
"EVENT",
"ENTRY",
"pairs",
"describing",
"the",
"differences",
"between",
"left",
"and",
"right",
"ZipFile",
"instances"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/ziputils.py#L55-L82 | train | 30,232 |
obriencj/python-javatools | javatools/ziputils.py | _different | def _different(left, right, f):
"""
true if entry f is different between left and right ZipFile
instances
"""
l = left.getinfo(f)
r = right.getinfo(f)
if (l.file_size == r.file_size) and (l.CRC == r.CRC):
# ok, they seem passibly similar, let's deep check them.
return _deep... | python | def _different(left, right, f):
"""
true if entry f is different between left and right ZipFile
instances
"""
l = left.getinfo(f)
r = right.getinfo(f)
if (l.file_size == r.file_size) and (l.CRC == r.CRC):
# ok, they seem passibly similar, let's deep check them.
return _deep... | [
"def",
"_different",
"(",
"left",
",",
"right",
",",
"f",
")",
":",
"l",
"=",
"left",
".",
"getinfo",
"(",
"f",
")",
"r",
"=",
"right",
".",
"getinfo",
"(",
"f",
")",
"if",
"(",
"l",
".",
"file_size",
"==",
"r",
".",
"file_size",
")",
"and",
... | true if entry f is different between left and right ZipFile
instances | [
"true",
"if",
"entry",
"f",
"is",
"different",
"between",
"left",
"and",
"right",
"ZipFile",
"instances"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/ziputils.py#L85-L100 | train | 30,233 |
obriencj/python-javatools | javatools/ziputils.py | _deep_different | def _deep_different(left, right, entry):
"""
checks that entry is identical between ZipFile instances left and
right
"""
left = chunk_zip_entry(left, entry)
right = chunk_zip_entry(right, entry)
for ldata, rdata in zip_longest(left, right):
if ldata != rdata:
return Tru... | python | def _deep_different(left, right, entry):
"""
checks that entry is identical between ZipFile instances left and
right
"""
left = chunk_zip_entry(left, entry)
right = chunk_zip_entry(right, entry)
for ldata, rdata in zip_longest(left, right):
if ldata != rdata:
return Tru... | [
"def",
"_deep_different",
"(",
"left",
",",
"right",
",",
"entry",
")",
":",
"left",
"=",
"chunk_zip_entry",
"(",
"left",
",",
"entry",
")",
"right",
"=",
"chunk_zip_entry",
"(",
"right",
",",
"entry",
")",
"for",
"ldata",
",",
"rdata",
"in",
"zip_longes... | checks that entry is identical between ZipFile instances left and
right | [
"checks",
"that",
"entry",
"is",
"identical",
"between",
"ZipFile",
"instances",
"left",
"and",
"right"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/ziputils.py#L103-L115 | train | 30,234 |
obriencj/python-javatools | javatools/ziputils.py | collect_compare_into | def collect_compare_into(left, right, added, removed, altered, same):
"""
collects the differences between left and right, which are
filenames for valid zip files, into the lists added, removed,
altered, and same. Returns a tuple of added, removed, altered,
same
"""
with open_zip(left) as ... | python | def collect_compare_into(left, right, added, removed, altered, same):
"""
collects the differences between left and right, which are
filenames for valid zip files, into the lists added, removed,
altered, and same. Returns a tuple of added, removed, altered,
same
"""
with open_zip(left) as ... | [
"def",
"collect_compare_into",
"(",
"left",
",",
"right",
",",
"added",
",",
"removed",
",",
"altered",
",",
"same",
")",
":",
"with",
"open_zip",
"(",
"left",
")",
"as",
"l",
":",
"with",
"open_zip",
"(",
"right",
")",
"as",
"r",
":",
"return",
"col... | collects the differences between left and right, which are
filenames for valid zip files, into the lists added, removed,
altered, and same. Returns a tuple of added, removed, altered,
same | [
"collects",
"the",
"differences",
"between",
"left",
"and",
"right",
"which",
"are",
"filenames",
"for",
"valid",
"zip",
"files",
"into",
"the",
"lists",
"added",
"removed",
"altered",
"and",
"same",
".",
"Returns",
"a",
"tuple",
"of",
"added",
"removed",
"a... | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/ziputils.py#L128-L140 | train | 30,235 |
obriencj/python-javatools | javatools/ziputils.py | collect_compare_zips_into | def collect_compare_zips_into(left, right, added, removed, altered, same):
"""
collects the differences between left and right ZipFile instances
into the lists added, removed, altered, and same. Returns a tuple
of added, removed, altered, same
"""
for event, filename in compare_zips(left, righ... | python | def collect_compare_zips_into(left, right, added, removed, altered, same):
"""
collects the differences between left and right ZipFile instances
into the lists added, removed, altered, and same. Returns a tuple
of added, removed, altered, same
"""
for event, filename in compare_zips(left, righ... | [
"def",
"collect_compare_zips_into",
"(",
"left",
",",
"right",
",",
"added",
",",
"removed",
",",
"altered",
",",
"same",
")",
":",
"for",
"event",
",",
"filename",
"in",
"compare_zips",
"(",
"left",
",",
"right",
")",
":",
"if",
"event",
"==",
"LEFT",
... | collects the differences between left and right ZipFile instances
into the lists added, removed, altered, and same. Returns a tuple
of added, removed, altered, same | [
"collects",
"the",
"differences",
"between",
"left",
"and",
"right",
"ZipFile",
"instances",
"into",
"the",
"lists",
"added",
"removed",
"altered",
"and",
"same",
".",
"Returns",
"a",
"tuple",
"of",
"added",
"removed",
"altered",
"same"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/ziputils.py#L152-L174 | train | 30,236 |
obriencj/python-javatools | javatools/ziputils.py | is_zipstream | def is_zipstream(data):
"""
just like zipfile.is_zipfile, but works upon buffers and streams
rather than filenames.
If data supports the read method, it will be treated as a stream
and read from to test whether it is a valid ZipFile.
If data also supports the tell and seek methods, it will be
... | python | def is_zipstream(data):
"""
just like zipfile.is_zipfile, but works upon buffers and streams
rather than filenames.
If data supports the read method, it will be treated as a stream
and read from to test whether it is a valid ZipFile.
If data also supports the tell and seek methods, it will be
... | [
"def",
"is_zipstream",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"(",
"str",
",",
"buffer",
")",
")",
":",
"data",
"=",
"BytesIO",
"(",
"data",
")",
"if",
"hasattr",
"(",
"data",
",",
"\"read\"",
")",
":",
"tell",
"=",
"0",
"if... | just like zipfile.is_zipfile, but works upon buffers and streams
rather than filenames.
If data supports the read method, it will be treated as a stream
and read from to test whether it is a valid ZipFile.
If data also supports the tell and seek methods, it will be
rewound after being tested. | [
"just",
"like",
"zipfile",
".",
"is_zipfile",
"but",
"works",
"upon",
"buffers",
"and",
"streams",
"rather",
"than",
"filenames",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/ziputils.py#L177-L208 | train | 30,237 |
obriencj/python-javatools | javatools/ziputils.py | file_crc32 | def file_crc32(filename, chunksize=_CHUNKSIZE):
"""
calculate the CRC32 of the contents of filename
"""
check = 0
with open(filename, 'rb') as fd:
for data in iter(lambda: fd.read(chunksize), ""):
check = crc32(data, check)
return check | python | def file_crc32(filename, chunksize=_CHUNKSIZE):
"""
calculate the CRC32 of the contents of filename
"""
check = 0
with open(filename, 'rb') as fd:
for data in iter(lambda: fd.read(chunksize), ""):
check = crc32(data, check)
return check | [
"def",
"file_crc32",
"(",
"filename",
",",
"chunksize",
"=",
"_CHUNKSIZE",
")",
":",
"check",
"=",
"0",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fd",
":",
"for",
"data",
"in",
"iter",
"(",
"lambda",
":",
"fd",
".",
"read",
"(",
"ch... | calculate the CRC32 of the contents of filename | [
"calculate",
"the",
"CRC32",
"of",
"the",
"contents",
"of",
"filename"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/ziputils.py#L211-L220 | train | 30,238 |
obriencj/python-javatools | javatools/ziputils.py | _collect_infos | def _collect_infos(dirname):
""" Utility function used by ExplodedZipFile to generate ZipInfo
entries for all of the files and directories under dirname """
for r, _ds, fs in walk(dirname):
if not islink(r) and r != dirname:
i = ZipInfo()
i.filename = join(relpath(r, dirnam... | python | def _collect_infos(dirname):
""" Utility function used by ExplodedZipFile to generate ZipInfo
entries for all of the files and directories under dirname """
for r, _ds, fs in walk(dirname):
if not islink(r) and r != dirname:
i = ZipInfo()
i.filename = join(relpath(r, dirnam... | [
"def",
"_collect_infos",
"(",
"dirname",
")",
":",
"for",
"r",
",",
"_ds",
",",
"fs",
"in",
"walk",
"(",
"dirname",
")",
":",
"if",
"not",
"islink",
"(",
"r",
")",
"and",
"r",
"!=",
"dirname",
":",
"i",
"=",
"ZipInfo",
"(",
")",
"i",
".",
"file... | Utility function used by ExplodedZipFile to generate ZipInfo
entries for all of the files and directories under dirname | [
"Utility",
"function",
"used",
"by",
"ExplodedZipFile",
"to",
"generate",
"ZipInfo",
"entries",
"for",
"all",
"of",
"the",
"files",
"and",
"directories",
"under",
"dirname"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/ziputils.py#L223-L254 | train | 30,239 |
obriencj/python-javatools | javatools/ziputils.py | zip_file | def zip_file(fn, mode="r"):
"""
returns either a zipfile.ZipFile instance or an ExplodedZipFile
instance, depending on whether fn is the name of a valid zip file,
or a directory.
"""
if isdir(fn):
return ExplodedZipFile(fn)
elif is_zipfile(fn):
return ZipFile(fn, mode)
e... | python | def zip_file(fn, mode="r"):
"""
returns either a zipfile.ZipFile instance or an ExplodedZipFile
instance, depending on whether fn is the name of a valid zip file,
or a directory.
"""
if isdir(fn):
return ExplodedZipFile(fn)
elif is_zipfile(fn):
return ZipFile(fn, mode)
e... | [
"def",
"zip_file",
"(",
"fn",
",",
"mode",
"=",
"\"r\"",
")",
":",
"if",
"isdir",
"(",
"fn",
")",
":",
"return",
"ExplodedZipFile",
"(",
"fn",
")",
"elif",
"is_zipfile",
"(",
"fn",
")",
":",
"return",
"ZipFile",
"(",
"fn",
",",
"mode",
")",
"else",... | returns either a zipfile.ZipFile instance or an ExplodedZipFile
instance, depending on whether fn is the name of a valid zip file,
or a directory. | [
"returns",
"either",
"a",
"zipfile",
".",
"ZipFile",
"instance",
"or",
"an",
"ExplodedZipFile",
"instance",
"depending",
"on",
"whether",
"fn",
"is",
"the",
"name",
"of",
"a",
"valid",
"zip",
"file",
"or",
"a",
"directory",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/ziputils.py#L300-L312 | train | 30,240 |
obriencj/python-javatools | javatools/ziputils.py | chunk_zip_entry | def chunk_zip_entry(zipfile, name, chunksize=_CHUNKSIZE):
"""
opens an entry from an openex zip file archive and yields
sequential chunks of data from the resulting stream.
"""
with open_zip_entry(zipfile, name, mode='r') as stream:
data = stream.read(chunksize)
while data:
... | python | def chunk_zip_entry(zipfile, name, chunksize=_CHUNKSIZE):
"""
opens an entry from an openex zip file archive and yields
sequential chunks of data from the resulting stream.
"""
with open_zip_entry(zipfile, name, mode='r') as stream:
data = stream.read(chunksize)
while data:
... | [
"def",
"chunk_zip_entry",
"(",
"zipfile",
",",
"name",
",",
"chunksize",
"=",
"_CHUNKSIZE",
")",
":",
"with",
"open_zip_entry",
"(",
"zipfile",
",",
"name",
",",
"mode",
"=",
"'r'",
")",
"as",
"stream",
":",
"data",
"=",
"stream",
".",
"read",
"(",
"ch... | opens an entry from an openex zip file archive and yields
sequential chunks of data from the resulting stream. | [
"opens",
"an",
"entry",
"from",
"an",
"openex",
"zip",
"file",
"archive",
"and",
"yields",
"sequential",
"chunks",
"of",
"data",
"from",
"the",
"resulting",
"stream",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/ziputils.py#L344-L354 | train | 30,241 |
obriencj/python-javatools | javatools/change.py | collect_by_typename | def collect_by_typename(obj_sequence, cache=None):
"""
collects objects from obj_sequence and stores them into buckets by
type name. cache is an optional dict into which we collect the
results.
"""
if cache is None:
cache = {}
for val in obj_sequence:
key = type(val).__name... | python | def collect_by_typename(obj_sequence, cache=None):
"""
collects objects from obj_sequence and stores them into buckets by
type name. cache is an optional dict into which we collect the
results.
"""
if cache is None:
cache = {}
for val in obj_sequence:
key = type(val).__name... | [
"def",
"collect_by_typename",
"(",
"obj_sequence",
",",
"cache",
"=",
"None",
")",
":",
"if",
"cache",
"is",
"None",
":",
"cache",
"=",
"{",
"}",
"for",
"val",
"in",
"obj_sequence",
":",
"key",
"=",
"type",
"(",
"val",
")",
".",
"__name__",
"bucket",
... | collects objects from obj_sequence and stores them into buckets by
type name. cache is an optional dict into which we collect the
results. | [
"collects",
"objects",
"from",
"obj_sequence",
"and",
"stores",
"them",
"into",
"buckets",
"by",
"type",
"name",
".",
"cache",
"is",
"an",
"optional",
"dict",
"into",
"which",
"we",
"collect",
"the",
"results",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/change.py#L37-L56 | train | 30,242 |
obriencj/python-javatools | javatools/change.py | collect_by_type | def collect_by_type(obj_sequence, cache=None):
"""
collects objects from obj_sequence and stores them into buckets by
type. cache is an optional dict into which we collect the results.
"""
if cache is None:
cache = {}
for val in obj_sequence:
key = type(val)
bucket = c... | python | def collect_by_type(obj_sequence, cache=None):
"""
collects objects from obj_sequence and stores them into buckets by
type. cache is an optional dict into which we collect the results.
"""
if cache is None:
cache = {}
for val in obj_sequence:
key = type(val)
bucket = c... | [
"def",
"collect_by_type",
"(",
"obj_sequence",
",",
"cache",
"=",
"None",
")",
":",
"if",
"cache",
"is",
"None",
":",
"cache",
"=",
"{",
"}",
"for",
"val",
"in",
"obj_sequence",
":",
"key",
"=",
"type",
"(",
"val",
")",
"bucket",
"=",
"cache",
".",
... | collects objects from obj_sequence and stores them into buckets by
type. cache is an optional dict into which we collect the results. | [
"collects",
"objects",
"from",
"obj_sequence",
"and",
"stores",
"them",
"into",
"buckets",
"by",
"type",
".",
"cache",
"is",
"an",
"optional",
"dict",
"into",
"which",
"we",
"collect",
"the",
"results",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/change.py#L59-L77 | train | 30,243 |
obriencj/python-javatools | javatools/change.py | yield_sorted_by_type | def yield_sorted_by_type(*typelist):
"""
a useful decorator for the collect_impl method of SuperChange
subclasses. Caches the yielded changes, and re-emits them
collected by their type. The order of the types can be specified
by listing the types as arguments to this decorator. Unlisted
types wi... | python | def yield_sorted_by_type(*typelist):
"""
a useful decorator for the collect_impl method of SuperChange
subclasses. Caches the yielded changes, and re-emits them
collected by their type. The order of the types can be specified
by listing the types as arguments to this decorator. Unlisted
types wi... | [
"def",
"yield_sorted_by_type",
"(",
"*",
"typelist",
")",
":",
"def",
"decorate",
"(",
"fun",
")",
":",
"@",
"wraps",
"(",
"fun",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"return",
"iterate_by_type",
"(",
"fun",
"("... | a useful decorator for the collect_impl method of SuperChange
subclasses. Caches the yielded changes, and re-emits them
collected by their type. The order of the types can be specified
by listing the types as arguments to this decorator. Unlisted
types will be yielded last in no guaranteed order.
G... | [
"a",
"useful",
"decorator",
"for",
"the",
"collect_impl",
"method",
"of",
"SuperChange",
"subclasses",
".",
"Caches",
"the",
"yielded",
"changes",
"and",
"re",
"-",
"emits",
"them",
"collected",
"by",
"their",
"type",
".",
"The",
"order",
"of",
"the",
"types... | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/change.py#L100-L118 | train | 30,244 |
obriencj/python-javatools | javatools/change.py | Change.simplify | def simplify(self, options=None):
"""
returns a dict describing a simple snapshot of this change, and
its children if any.
"""
simple = {
"class": type(self).__name__,
"is_change": self.is_change(),
"description": self.get_description(),
... | python | def simplify(self, options=None):
"""
returns a dict describing a simple snapshot of this change, and
its children if any.
"""
simple = {
"class": type(self).__name__,
"is_change": self.is_change(),
"description": self.get_description(),
... | [
"def",
"simplify",
"(",
"self",
",",
"options",
"=",
"None",
")",
":",
"simple",
"=",
"{",
"\"class\"",
":",
"type",
"(",
"self",
")",
".",
"__name__",
",",
"\"is_change\"",
":",
"self",
".",
"is_change",
"(",
")",
",",
"\"description\"",
":",
"self",
... | returns a dict describing a simple snapshot of this change, and
its children if any. | [
"returns",
"a",
"dict",
"describing",
"a",
"simple",
"snapshot",
"of",
"this",
"change",
"and",
"its",
"children",
"if",
"any",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/change.py#L183-L208 | train | 30,245 |
obriencj/python-javatools | javatools/change.py | GenericChange.simplify | def simplify(self, options=None):
"""
provide a simple representation of this change as a dictionary
"""
# TODO: we might want to get rid of this method and just move
# it into the JSONEncoder in report.py
simple = super(GenericChange, self).simplify(options)
l... | python | def simplify(self, options=None):
"""
provide a simple representation of this change as a dictionary
"""
# TODO: we might want to get rid of this method and just move
# it into the JSONEncoder in report.py
simple = super(GenericChange, self).simplify(options)
l... | [
"def",
"simplify",
"(",
"self",
",",
"options",
"=",
"None",
")",
":",
"# TODO: we might want to get rid of this method and just move",
"# it into the JSONEncoder in report.py",
"simple",
"=",
"super",
"(",
"GenericChange",
",",
"self",
")",
".",
"simplify",
"(",
"optio... | provide a simple representation of this change as a dictionary | [
"provide",
"a",
"simple",
"representation",
"of",
"this",
"change",
"as",
"a",
"dictionary"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/change.py#L364-L382 | train | 30,246 |
obriencj/python-javatools | javatools/change.py | SuperChange.clear | def clear(self):
"""
clears all child changes and drops the reference to them
"""
super(SuperChange, self).clear()
for c in self.changes:
c.clear()
self.changes = tuple() | python | def clear(self):
"""
clears all child changes and drops the reference to them
"""
super(SuperChange, self).clear()
for c in self.changes:
c.clear()
self.changes = tuple() | [
"def",
"clear",
"(",
"self",
")",
":",
"super",
"(",
"SuperChange",
",",
"self",
")",
".",
"clear",
"(",
")",
"for",
"c",
"in",
"self",
".",
"changes",
":",
"c",
".",
"clear",
"(",
")",
"self",
".",
"changes",
"=",
"tuple",
"(",
")"
] | clears all child changes and drops the reference to them | [
"clears",
"all",
"child",
"changes",
"and",
"drops",
"the",
"reference",
"to",
"them"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/change.py#L419-L428 | train | 30,247 |
obriencj/python-javatools | javatools/change.py | SuperChange.collect_impl | def collect_impl(self):
"""
instantiates each of the entries in in the overriden change_types
field with the left and right data
"""
ldata = self.get_ldata()
rdata = self.get_rdata()
for change_type in self.change_types:
yield change_type(ldata, rdat... | python | def collect_impl(self):
"""
instantiates each of the entries in in the overriden change_types
field with the left and right data
"""
ldata = self.get_ldata()
rdata = self.get_rdata()
for change_type in self.change_types:
yield change_type(ldata, rdat... | [
"def",
"collect_impl",
"(",
"self",
")",
":",
"ldata",
"=",
"self",
".",
"get_ldata",
"(",
")",
"rdata",
"=",
"self",
".",
"get_rdata",
"(",
")",
"for",
"change_type",
"in",
"self",
".",
"change_types",
":",
"yield",
"change_type",
"(",
"ldata",
",",
"... | instantiates each of the entries in in the overriden change_types
field with the left and right data | [
"instantiates",
"each",
"of",
"the",
"entries",
"in",
"in",
"the",
"overriden",
"change_types",
"field",
"with",
"the",
"left",
"and",
"right",
"data"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/change.py#L431-L441 | train | 30,248 |
obriencj/python-javatools | javatools/change.py | SuperChange.collect | def collect(self, force=False):
"""
calls collect_impl and stores the results as the child changes of
this super-change. Returns a tuple of the data generated from
collect_impl. Caches the result rather than re-computing each
time, unless force is True
"""
if for... | python | def collect(self, force=False):
"""
calls collect_impl and stores the results as the child changes of
this super-change. Returns a tuple of the data generated from
collect_impl. Caches the result rather than re-computing each
time, unless force is True
"""
if for... | [
"def",
"collect",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"if",
"force",
"or",
"not",
"self",
".",
"changes",
":",
"self",
".",
"changes",
"=",
"tuple",
"(",
"self",
".",
"collect_impl",
"(",
")",
")",
"return",
"self",
".",
"changes"
] | calls collect_impl and stores the results as the child changes of
this super-change. Returns a tuple of the data generated from
collect_impl. Caches the result rather than re-computing each
time, unless force is True | [
"calls",
"collect_impl",
"and",
"stores",
"the",
"results",
"as",
"the",
"child",
"changes",
"of",
"this",
"super",
"-",
"change",
".",
"Returns",
"a",
"tuple",
"of",
"the",
"data",
"generated",
"from",
"collect_impl",
".",
"Caches",
"the",
"result",
"rather... | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/change.py#L444-L454 | train | 30,249 |
obriencj/python-javatools | javatools/change.py | SuperChange.check_impl | def check_impl(self):
"""
sets self.changes to the result of self.changes_impl, then if any
member of those checks shows as a change, will return
True,None
"""
c = False
for change in self.collect():
change.check()
c = c or change.is_chang... | python | def check_impl(self):
"""
sets self.changes to the result of self.changes_impl, then if any
member of those checks shows as a change, will return
True,None
"""
c = False
for change in self.collect():
change.check()
c = c or change.is_chang... | [
"def",
"check_impl",
"(",
"self",
")",
":",
"c",
"=",
"False",
"for",
"change",
"in",
"self",
".",
"collect",
"(",
")",
":",
"change",
".",
"check",
"(",
")",
"c",
"=",
"c",
"or",
"change",
".",
"is_change",
"(",
")",
"return",
"c",
",",
"None"
] | sets self.changes to the result of self.changes_impl, then if any
member of those checks shows as a change, will return
True,None | [
"sets",
"self",
".",
"changes",
"to",
"the",
"result",
"of",
"self",
".",
"changes_impl",
"then",
"if",
"any",
"member",
"of",
"those",
"checks",
"shows",
"as",
"a",
"change",
"will",
"return",
"True",
"None"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/change.py#L457-L468 | train | 30,250 |
obriencj/python-javatools | javatools/change.py | SuperChange.is_ignored | def is_ignored(self, options):
"""
If we have changed children and all the children which are changes
are ignored, then we are ignored. Otherwise, we are not
ignored
"""
if not self.is_change():
return False
changes = self.collect()
if not ch... | python | def is_ignored(self, options):
"""
If we have changed children and all the children which are changes
are ignored, then we are ignored. Otherwise, we are not
ignored
"""
if not self.is_change():
return False
changes = self.collect()
if not ch... | [
"def",
"is_ignored",
"(",
"self",
",",
"options",
")",
":",
"if",
"not",
"self",
".",
"is_change",
"(",
")",
":",
"return",
"False",
"changes",
"=",
"self",
".",
"collect",
"(",
")",
"if",
"not",
"changes",
":",
"return",
"False",
"for",
"change",
"i... | If we have changed children and all the children which are changes
are ignored, then we are ignored. Otherwise, we are not
ignored | [
"If",
"we",
"have",
"changed",
"children",
"and",
"all",
"the",
"children",
"which",
"are",
"changes",
"are",
"ignored",
"then",
"we",
"are",
"ignored",
".",
"Otherwise",
"we",
"are",
"not",
"ignored"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/change.py#L471-L488 | train | 30,251 |
obriencj/python-javatools | javatools/change.py | SuperChange.squash_children | def squash_children(self, options):
"""
reduces the memory footprint of this super-change by converting
all child changes into squashed changes
"""
oldsubs = self.collect()
self.changes = tuple(squash(c, options=options) for c in oldsubs)
for change in oldsubs:
... | python | def squash_children(self, options):
"""
reduces the memory footprint of this super-change by converting
all child changes into squashed changes
"""
oldsubs = self.collect()
self.changes = tuple(squash(c, options=options) for c in oldsubs)
for change in oldsubs:
... | [
"def",
"squash_children",
"(",
"self",
",",
"options",
")",
":",
"oldsubs",
"=",
"self",
".",
"collect",
"(",
")",
"self",
".",
"changes",
"=",
"tuple",
"(",
"squash",
"(",
"c",
",",
"options",
"=",
"options",
")",
"for",
"c",
"in",
"oldsubs",
")",
... | reduces the memory footprint of this super-change by converting
all child changes into squashed changes | [
"reduces",
"the",
"memory",
"footprint",
"of",
"this",
"super",
"-",
"change",
"by",
"converting",
"all",
"child",
"changes",
"into",
"squashed",
"changes"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/change.py#L522-L532 | train | 30,252 |
obriencj/python-javatools | javatools/jardiff.py | add_jardiff_optgroup | def add_jardiff_optgroup(parser):
"""
option group specific to the tests in jardiff
"""
og = parser.add_argument_group("JAR Checking Options")
og.add_argument("--ignore-jar-entry", action="append", default=[])
og.add_argument("--ignore-jar-signature",
action="store_true", ... | python | def add_jardiff_optgroup(parser):
"""
option group specific to the tests in jardiff
"""
og = parser.add_argument_group("JAR Checking Options")
og.add_argument("--ignore-jar-entry", action="append", default=[])
og.add_argument("--ignore-jar-signature",
action="store_true", ... | [
"def",
"add_jardiff_optgroup",
"(",
"parser",
")",
":",
"og",
"=",
"parser",
".",
"add_argument_group",
"(",
"\"JAR Checking Options\"",
")",
"og",
".",
"add_argument",
"(",
"\"--ignore-jar-entry\"",
",",
"action",
"=",
"\"append\"",
",",
"default",
"=",
"[",
"]... | option group specific to the tests in jardiff | [
"option",
"group",
"specific",
"to",
"the",
"tests",
"in",
"jardiff"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/jardiff.py#L554-L577 | train | 30,253 |
obriencj/python-javatools | javatools/jardiff.py | default_jardiff_options | def default_jardiff_options(updates=None):
"""
generate an options object with the appropriate default values in
place for API usage of jardiff features. overrides is an optional
dictionary which will be used to update fields on the options
object.
"""
parser = create_optparser()
option... | python | def default_jardiff_options(updates=None):
"""
generate an options object with the appropriate default values in
place for API usage of jardiff features. overrides is an optional
dictionary which will be used to update fields on the options
object.
"""
parser = create_optparser()
option... | [
"def",
"default_jardiff_options",
"(",
"updates",
"=",
"None",
")",
":",
"parser",
"=",
"create_optparser",
"(",
")",
"options",
",",
"_args",
"=",
"parser",
".",
"parse_args",
"(",
"list",
"(",
")",
")",
"if",
"updates",
":",
"# pylint: disable=W0212",
"opt... | generate an options object with the appropriate default values in
place for API usage of jardiff features. overrides is an optional
dictionary which will be used to update fields on the options
object. | [
"generate",
"an",
"options",
"object",
"with",
"the",
"appropriate",
"default",
"values",
"in",
"place",
"for",
"API",
"usage",
"of",
"jardiff",
"features",
".",
"overrides",
"is",
"an",
"optional",
"dictionary",
"which",
"will",
"be",
"used",
"to",
"update",
... | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/jardiff.py#L604-L619 | train | 30,254 |
obriencj/python-javatools | javatools/jardiff.py | main | def main(args=sys.argv):
"""
main entry point for the jardiff CLI
"""
parser = create_optparser(args[0])
return cli(parser.parse_args(args[1:])) | python | def main(args=sys.argv):
"""
main entry point for the jardiff CLI
"""
parser = create_optparser(args[0])
return cli(parser.parse_args(args[1:])) | [
"def",
"main",
"(",
"args",
"=",
"sys",
".",
"argv",
")",
":",
"parser",
"=",
"create_optparser",
"(",
"args",
"[",
"0",
"]",
")",
"return",
"cli",
"(",
"parser",
".",
"parse_args",
"(",
"args",
"[",
"1",
":",
"]",
")",
")"
] | main entry point for the jardiff CLI | [
"main",
"entry",
"point",
"for",
"the",
"jardiff",
"CLI"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/jardiff.py#L622-L628 | train | 30,255 |
obriencj/python-javatools | javatools/report.py | add_general_report_optgroup | def add_general_report_optgroup(parser):
"""
General Reporting Options
"""
g = parser.add_argument_group("Reporting Options")
g.add_argument("--report-dir", action="store", default=None)
g.add_argument("--report", action=_opt_cb_report,
help="comma-separated list of report ... | python | def add_general_report_optgroup(parser):
"""
General Reporting Options
"""
g = parser.add_argument_group("Reporting Options")
g.add_argument("--report-dir", action="store", default=None)
g.add_argument("--report", action=_opt_cb_report,
help="comma-separated list of report ... | [
"def",
"add_general_report_optgroup",
"(",
"parser",
")",
":",
"g",
"=",
"parser",
".",
"add_argument_group",
"(",
"\"Reporting Options\"",
")",
"g",
".",
"add_argument",
"(",
"\"--report-dir\"",
",",
"action",
"=",
"\"store\"",
",",
"default",
"=",
"None",
")",... | General Reporting Options | [
"General",
"Reporting",
"Options"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L262-L272 | train | 30,256 |
obriencj/python-javatools | javatools/report.py | add_json_report_optgroup | def add_json_report_optgroup(parser):
"""
Option group for the JSON report format
"""
g = parser.add_argument_group("JSON Report Options")
g.add_argument("--json-indent", action="store", default=2, type=int) | python | def add_json_report_optgroup(parser):
"""
Option group for the JSON report format
"""
g = parser.add_argument_group("JSON Report Options")
g.add_argument("--json-indent", action="store", default=2, type=int) | [
"def",
"add_json_report_optgroup",
"(",
"parser",
")",
":",
"g",
"=",
"parser",
".",
"add_argument_group",
"(",
"\"JSON Report Options\"",
")",
"g",
".",
"add_argument",
"(",
"\"--json-indent\"",
",",
"action",
"=",
"\"store\"",
",",
"default",
"=",
"2",
",",
... | Option group for the JSON report format | [
"Option",
"group",
"for",
"the",
"JSON",
"report",
"format"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L305-L312 | train | 30,257 |
obriencj/python-javatools | javatools/report.py | _indent_change | def _indent_change(change, out, options, indent):
"""
recursive function to print indented change descriptions
"""
show_unchanged = getattr(options, "show_unchanged", False)
show_ignored = getattr(options, "show_ignored", False)
show = False
desc = change.get_description()
if change.i... | python | def _indent_change(change, out, options, indent):
"""
recursive function to print indented change descriptions
"""
show_unchanged = getattr(options, "show_unchanged", False)
show_ignored = getattr(options, "show_ignored", False)
show = False
desc = change.get_description()
if change.i... | [
"def",
"_indent_change",
"(",
"change",
",",
"out",
",",
"options",
",",
"indent",
")",
":",
"show_unchanged",
"=",
"getattr",
"(",
"options",
",",
"\"show_unchanged\"",
",",
"False",
")",
"show_ignored",
"=",
"getattr",
"(",
"options",
",",
"\"show_ignored\""... | recursive function to print indented change descriptions | [
"recursive",
"function",
"to",
"print",
"indented",
"change",
"descriptions"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L359-L385 | train | 30,258 |
obriencj/python-javatools | javatools/report.py | _indent | def _indent(stream, indent, *msgs):
""" write a message to a text stream, with indentation. Also ensures that
the output encoding of the messages is safe for writing. """
for x in range(0, indent):
stream.write(" ")
for x in msgs:
# Any nicer way? In Py2 x can be 'str' or 'unicode'.
... | python | def _indent(stream, indent, *msgs):
""" write a message to a text stream, with indentation. Also ensures that
the output encoding of the messages is safe for writing. """
for x in range(0, indent):
stream.write(" ")
for x in msgs:
# Any nicer way? In Py2 x can be 'str' or 'unicode'.
... | [
"def",
"_indent",
"(",
"stream",
",",
"indent",
",",
"*",
"msgs",
")",
":",
"for",
"x",
"in",
"range",
"(",
"0",
",",
"indent",
")",
":",
"stream",
".",
"write",
"(",
"\" \"",
")",
"for",
"x",
"in",
"msgs",
":",
"# Any nicer way? In Py2 x can be 'str'... | write a message to a text stream, with indentation. Also ensures that
the output encoding of the messages is safe for writing. | [
"write",
"a",
"message",
"to",
"a",
"text",
"stream",
"with",
"indentation",
".",
"Also",
"ensures",
"that",
"the",
"output",
"encoding",
"of",
"the",
"messages",
"is",
"safe",
"for",
"writing",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L388-L398 | train | 30,259 |
obriencj/python-javatools | javatools/report.py | _compose_cheetah_template_map | def _compose_cheetah_template_map(cache):
"""
does the work of composing the cheetah template map into the given
cache
"""
from .cheetah import get_templates
# pylint: disable=W0406
# needed for introspection
import javatools
for template_type in get_templates():
if "_" no... | python | def _compose_cheetah_template_map(cache):
"""
does the work of composing the cheetah template map into the given
cache
"""
from .cheetah import get_templates
# pylint: disable=W0406
# needed for introspection
import javatools
for template_type in get_templates():
if "_" no... | [
"def",
"_compose_cheetah_template_map",
"(",
"cache",
")",
":",
"from",
".",
"cheetah",
"import",
"get_templates",
"# pylint: disable=W0406",
"# needed for introspection",
"import",
"javatools",
"for",
"template_type",
"in",
"get_templates",
"(",
")",
":",
"if",
"\"_\""... | does the work of composing the cheetah template map into the given
cache | [
"does",
"the",
"work",
"of",
"composing",
"the",
"cheetah",
"template",
"map",
"into",
"the",
"given",
"cache"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L531-L569 | train | 30,260 |
obriencj/python-javatools | javatools/report.py | resolve_cheetah_template | def resolve_cheetah_template(change_type):
"""
return the appropriate cheetah template class for the given change
type, using the method-resolution-order of the change type.
"""
tm = cheetah_template_map()
# follow the built-in MRO for a type to find the matching
# cheetah template
for... | python | def resolve_cheetah_template(change_type):
"""
return the appropriate cheetah template class for the given change
type, using the method-resolution-order of the change type.
"""
tm = cheetah_template_map()
# follow the built-in MRO for a type to find the matching
# cheetah template
for... | [
"def",
"resolve_cheetah_template",
"(",
"change_type",
")",
":",
"tm",
"=",
"cheetah_template_map",
"(",
")",
"# follow the built-in MRO for a type to find the matching",
"# cheetah template",
"for",
"t",
"in",
"change_type",
".",
"mro",
"(",
")",
":",
"tmpl",
"=",
"t... | return the appropriate cheetah template class for the given change
type, using the method-resolution-order of the change type. | [
"return",
"the",
"appropriate",
"cheetah",
"template",
"class",
"for",
"the",
"given",
"change",
"type",
"using",
"the",
"method",
"-",
"resolution",
"-",
"order",
"of",
"the",
"change",
"type",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L588-L606 | train | 30,261 |
obriencj/python-javatools | javatools/report.py | add_html_report_optgroup | def add_html_report_optgroup(parser):
"""
Option group for the HTML report format
"""
g = parser.add_argument_group("HTML Report Options")
g.add_argument("--html-stylesheet", action="append",
dest="html_stylesheets", default=list())
g.add_argument("--html-javascript", actio... | python | def add_html_report_optgroup(parser):
"""
Option group for the HTML report format
"""
g = parser.add_argument_group("HTML Report Options")
g.add_argument("--html-stylesheet", action="append",
dest="html_stylesheets", default=list())
g.add_argument("--html-javascript", actio... | [
"def",
"add_html_report_optgroup",
"(",
"parser",
")",
":",
"g",
"=",
"parser",
".",
"add_argument_group",
"(",
"\"HTML Report Options\"",
")",
"g",
".",
"add_argument",
"(",
"\"--html-stylesheet\"",
",",
"action",
"=",
"\"append\"",
",",
"dest",
"=",
"\"html_styl... | Option group for the HTML report format | [
"Option",
"group",
"for",
"the",
"HTML",
"report",
"format"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L609-L624 | train | 30,262 |
obriencj/python-javatools | javatools/report.py | quick_report | def quick_report(report_type, change, options):
"""
writes a change report via report_type to options.output or
sys.stdout
"""
report = report_type(None, options)
if options.output:
with open(options.output, "w") as out:
report.run(change, None, out)
else:
repor... | python | def quick_report(report_type, change, options):
"""
writes a change report via report_type to options.output or
sys.stdout
"""
report = report_type(None, options)
if options.output:
with open(options.output, "w") as out:
report.run(change, None, out)
else:
repor... | [
"def",
"quick_report",
"(",
"report_type",
",",
"change",
",",
"options",
")",
":",
"report",
"=",
"report_type",
"(",
"None",
",",
"options",
")",
"if",
"options",
".",
"output",
":",
"with",
"open",
"(",
"options",
".",
"output",
",",
"\"w\"",
")",
"... | writes a change report via report_type to options.output or
sys.stdout | [
"writes",
"a",
"change",
"report",
"via",
"report_type",
"to",
"options",
".",
"output",
"or",
"sys",
".",
"stdout"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L627-L639 | train | 30,263 |
obriencj/python-javatools | javatools/report.py | Reporter.get_relative_breadcrumbs | def get_relative_breadcrumbs(self):
"""
get the breadcrumbs as relative to the basedir
"""
basedir = self.basedir
crumbs = self.breadcrumbs
return [(relpath(b, basedir), e) for b, e in crumbs] | python | def get_relative_breadcrumbs(self):
"""
get the breadcrumbs as relative to the basedir
"""
basedir = self.basedir
crumbs = self.breadcrumbs
return [(relpath(b, basedir), e) for b, e in crumbs] | [
"def",
"get_relative_breadcrumbs",
"(",
"self",
")",
":",
"basedir",
"=",
"self",
".",
"basedir",
"crumbs",
"=",
"self",
".",
"breadcrumbs",
"return",
"[",
"(",
"relpath",
"(",
"b",
",",
"basedir",
")",
",",
"e",
")",
"for",
"b",
",",
"e",
"in",
"cru... | get the breadcrumbs as relative to the basedir | [
"get",
"the",
"breadcrumbs",
"as",
"relative",
"to",
"the",
"basedir"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L70-L78 | train | 30,264 |
obriencj/python-javatools | javatools/report.py | Reporter.add_formats_by_name | def add_formats_by_name(self, rfmt_list):
"""
adds formats by short label descriptors, such as 'txt', 'json', or
'html'
"""
for fmt in rfmt_list:
if fmt == "json":
self.add_report_format(JSONReportFormat)
elif fmt in ("txt", "text"):
... | python | def add_formats_by_name(self, rfmt_list):
"""
adds formats by short label descriptors, such as 'txt', 'json', or
'html'
"""
for fmt in rfmt_list:
if fmt == "json":
self.add_report_format(JSONReportFormat)
elif fmt in ("txt", "text"):
... | [
"def",
"add_formats_by_name",
"(",
"self",
",",
"rfmt_list",
")",
":",
"for",
"fmt",
"in",
"rfmt_list",
":",
"if",
"fmt",
"==",
"\"json\"",
":",
"self",
".",
"add_report_format",
"(",
"JSONReportFormat",
")",
"elif",
"fmt",
"in",
"(",
"\"txt\"",
",",
"\"te... | adds formats by short label descriptors, such as 'txt', 'json', or
'html' | [
"adds",
"formats",
"by",
"short",
"label",
"descriptors",
"such",
"as",
"txt",
"json",
"or",
"html"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L81-L93 | train | 30,265 |
obriencj/python-javatools | javatools/report.py | Reporter.subreporter | def subreporter(self, subpath, entry):
"""
create a reporter for a sub-report, with updated breadcrumbs and
the same output formats
"""
newbase = join(self.basedir, subpath)
r = Reporter(newbase, entry, self.options)
crumbs = list(self.breadcrumbs)
crumb... | python | def subreporter(self, subpath, entry):
"""
create a reporter for a sub-report, with updated breadcrumbs and
the same output formats
"""
newbase = join(self.basedir, subpath)
r = Reporter(newbase, entry, self.options)
crumbs = list(self.breadcrumbs)
crumb... | [
"def",
"subreporter",
"(",
"self",
",",
"subpath",
",",
"entry",
")",
":",
"newbase",
"=",
"join",
"(",
"self",
".",
"basedir",
",",
"subpath",
")",
"r",
"=",
"Reporter",
"(",
"newbase",
",",
"entry",
",",
"self",
".",
"options",
")",
"crumbs",
"=",
... | create a reporter for a sub-report, with updated breadcrumbs and
the same output formats | [
"create",
"a",
"reporter",
"for",
"a",
"sub",
"-",
"report",
"with",
"updated",
"breadcrumbs",
"and",
"the",
"same",
"output",
"formats"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L106-L120 | train | 30,266 |
obriencj/python-javatools | javatools/report.py | Reporter.setup | def setup(self):
"""
instantiates all report formats that have been added to this
reporter, and calls their setup methods.
"""
if self._formats:
# setup has been run already.
return
basedir = self.basedir
options = self.options
cr... | python | def setup(self):
"""
instantiates all report formats that have been added to this
reporter, and calls their setup methods.
"""
if self._formats:
# setup has been run already.
return
basedir = self.basedir
options = self.options
cr... | [
"def",
"setup",
"(",
"self",
")",
":",
"if",
"self",
".",
"_formats",
":",
"# setup has been run already.",
"return",
"basedir",
"=",
"self",
".",
"basedir",
"options",
"=",
"self",
".",
"options",
"crumbs",
"=",
"self",
".",
"get_relative_breadcrumbs",
"(",
... | instantiates all report formats that have been added to this
reporter, and calls their setup methods. | [
"instantiates",
"all",
"report",
"formats",
"that",
"have",
"been",
"added",
"to",
"this",
"reporter",
"and",
"calls",
"their",
"setup",
"methods",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L123-L143 | train | 30,267 |
obriencj/python-javatools | javatools/report.py | Reporter.run | def run(self, change):
"""
runs the report format instances in this reporter. Will call setup
if it hasn't been called already
"""
if self._formats is None:
self.setup()
entry = self.entry
for fmt in self._formats:
fmt.run(change, entry)... | python | def run(self, change):
"""
runs the report format instances in this reporter. Will call setup
if it hasn't been called already
"""
if self._formats is None:
self.setup()
entry = self.entry
for fmt in self._formats:
fmt.run(change, entry)... | [
"def",
"run",
"(",
"self",
",",
"change",
")",
":",
"if",
"self",
".",
"_formats",
"is",
"None",
":",
"self",
".",
"setup",
"(",
")",
"entry",
"=",
"self",
".",
"entry",
"for",
"fmt",
"in",
"self",
".",
"_formats",
":",
"fmt",
".",
"run",
"(",
... | runs the report format instances in this reporter. Will call setup
if it hasn't been called already | [
"runs",
"the",
"report",
"format",
"instances",
"in",
"this",
"reporter",
".",
"Will",
"call",
"setup",
"if",
"it",
"hasn",
"t",
"been",
"called",
"already"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L146-L160 | train | 30,268 |
obriencj/python-javatools | javatools/report.py | Reporter.clear | def clear(self):
"""
calls clear on any report format instances created during setup
and drops the cache
"""
if self._formats:
for fmt in self._formats:
fmt.clear()
self._formats = None | python | def clear(self):
"""
calls clear on any report format instances created during setup
and drops the cache
"""
if self._formats:
for fmt in self._formats:
fmt.clear()
self._formats = None | [
"def",
"clear",
"(",
"self",
")",
":",
"if",
"self",
".",
"_formats",
":",
"for",
"fmt",
"in",
"self",
".",
"_formats",
":",
"fmt",
".",
"clear",
"(",
")",
"self",
".",
"_formats",
"=",
"None"
] | calls clear on any report format instances created during setup
and drops the cache | [
"calls",
"clear",
"on",
"any",
"report",
"format",
"instances",
"created",
"during",
"setup",
"and",
"drops",
"the",
"cache"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L163-L172 | train | 30,269 |
obriencj/python-javatools | javatools/report.py | CheetahReportFormat._relative | def _relative(self, uri):
"""
if uri is relative, re-relate it to our basedir
"""
if uri.startswith("http:") or \
uri.startswith("https:") or \
uri.startswith("file:") or \
uri.startswith("/"):
return uri
elif exists(uri):
... | python | def _relative(self, uri):
"""
if uri is relative, re-relate it to our basedir
"""
if uri.startswith("http:") or \
uri.startswith("https:") or \
uri.startswith("file:") or \
uri.startswith("/"):
return uri
elif exists(uri):
... | [
"def",
"_relative",
"(",
"self",
",",
"uri",
")",
":",
"if",
"uri",
".",
"startswith",
"(",
"\"http:\"",
")",
"or",
"uri",
".",
"startswith",
"(",
"\"https:\"",
")",
"or",
"uri",
".",
"startswith",
"(",
"\"file:\"",
")",
"or",
"uri",
".",
"startswith",... | if uri is relative, re-relate it to our basedir | [
"if",
"uri",
"is",
"relative",
"re",
"-",
"relate",
"it",
"to",
"our",
"basedir"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L409-L424 | train | 30,270 |
obriencj/python-javatools | javatools/report.py | CheetahReportFormat._relative_uris | def _relative_uris(self, uri_list):
"""
if uris in list are relative, re-relate them to our basedir
"""
return [u for u in (self._relative(uri) for uri in uri_list) if u] | python | def _relative_uris(self, uri_list):
"""
if uris in list are relative, re-relate them to our basedir
"""
return [u for u in (self._relative(uri) for uri in uri_list) if u] | [
"def",
"_relative_uris",
"(",
"self",
",",
"uri_list",
")",
":",
"return",
"[",
"u",
"for",
"u",
"in",
"(",
"self",
".",
"_relative",
"(",
"uri",
")",
"for",
"uri",
"in",
"uri_list",
")",
"if",
"u",
"]"
] | if uris in list are relative, re-relate them to our basedir | [
"if",
"uris",
"in",
"list",
"are",
"relative",
"re",
"-",
"relate",
"them",
"to",
"our",
"basedir"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L427-L432 | train | 30,271 |
obriencj/python-javatools | javatools/report.py | CheetahReportFormat.setup | def setup(self):
"""
copies default stylesheets and javascript files if necessary, and
appends them to the options
"""
from javatools import cheetah
options = self.options
datadir = getattr(options, "html_copy_data", None)
if getattr(options, "html_data... | python | def setup(self):
"""
copies default stylesheets and javascript files if necessary, and
appends them to the options
"""
from javatools import cheetah
options = self.options
datadir = getattr(options, "html_copy_data", None)
if getattr(options, "html_data... | [
"def",
"setup",
"(",
"self",
")",
":",
"from",
"javatools",
"import",
"cheetah",
"options",
"=",
"self",
".",
"options",
"datadir",
"=",
"getattr",
"(",
"options",
",",
"\"html_copy_data\"",
",",
"None",
")",
"if",
"getattr",
"(",
"options",
",",
"\"html_d... | copies default stylesheets and javascript files if necessary, and
appends them to the options | [
"copies",
"default",
"stylesheets",
"and",
"javascript",
"files",
"if",
"necessary",
"and",
"appends",
"them",
"to",
"the",
"options"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L435-L472 | train | 30,272 |
obriencj/python-javatools | javatools/report.py | CheetahReportFormat.run_impl | def run_impl(self, change, entry, out):
"""
sets up the report directory for an HTML report. Obtains the
top-level Cheetah template that is appropriate for the change
instance, and runs it.
The cheetah templates are supplied the following values:
* change - the Change i... | python | def run_impl(self, change, entry, out):
"""
sets up the report directory for an HTML report. Obtains the
top-level Cheetah template that is appropriate for the change
instance, and runs it.
The cheetah templates are supplied the following values:
* change - the Change i... | [
"def",
"run_impl",
"(",
"self",
",",
"change",
",",
"entry",
",",
"out",
")",
":",
"options",
"=",
"self",
".",
"options",
"# translate relative paths if necessary",
"javascripts",
"=",
"self",
".",
"_relative_uris",
"(",
"options",
".",
"html_javascripts",
")",... | sets up the report directory for an HTML report. Obtains the
top-level Cheetah template that is appropriate for the change
instance, and runs it.
The cheetah templates are supplied the following values:
* change - the Change instance to report on
* entry - the string name of t... | [
"sets",
"up",
"the",
"report",
"directory",
"for",
"an",
"HTML",
"report",
".",
"Obtains",
"the",
"top",
"-",
"level",
"Cheetah",
"template",
"that",
"is",
"appropriate",
"for",
"the",
"change",
"instance",
"and",
"runs",
"it",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/report.py#L475-L528 | train | 30,273 |
obriencj/python-javatools | javatools/distinfo.py | DistInfo.get_requires | def get_requires(self, ignored=tuple()):
""" a map of requirements to what requires it. ignored is an
optional list of globbed patterns indicating packages,
classes, etc that shouldn't be included in the provides map"""
if self._requires is None:
self._collect_requires_provi... | python | def get_requires(self, ignored=tuple()):
""" a map of requirements to what requires it. ignored is an
optional list of globbed patterns indicating packages,
classes, etc that shouldn't be included in the provides map"""
if self._requires is None:
self._collect_requires_provi... | [
"def",
"get_requires",
"(",
"self",
",",
"ignored",
"=",
"tuple",
"(",
")",
")",
":",
"if",
"self",
".",
"_requires",
"is",
"None",
":",
"self",
".",
"_collect_requires_provides",
"(",
")",
"d",
"=",
"self",
".",
"_requires",
"if",
"ignored",
":",
"d",... | a map of requirements to what requires it. ignored is an
optional list of globbed patterns indicating packages,
classes, etc that shouldn't be included in the provides map | [
"a",
"map",
"of",
"requirements",
"to",
"what",
"requires",
"it",
".",
"ignored",
"is",
"an",
"optional",
"list",
"of",
"globbed",
"patterns",
"indicating",
"packages",
"classes",
"etc",
"that",
"shouldn",
"t",
"be",
"included",
"in",
"the",
"provides",
"map... | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/distinfo.py#L116-L128 | train | 30,274 |
obriencj/python-javatools | javatools/distinfo.py | DistInfo.get_provides | def get_provides(self, ignored=tuple()):
""" a map of provided classes and class members, and what
provides them. ignored is an optional list of globbed patterns
indicating packages, classes, etc that shouldn't be included
in the provides map"""
if self._provides is None:
... | python | def get_provides(self, ignored=tuple()):
""" a map of provided classes and class members, and what
provides them. ignored is an optional list of globbed patterns
indicating packages, classes, etc that shouldn't be included
in the provides map"""
if self._provides is None:
... | [
"def",
"get_provides",
"(",
"self",
",",
"ignored",
"=",
"tuple",
"(",
")",
")",
":",
"if",
"self",
".",
"_provides",
"is",
"None",
":",
"self",
".",
"_collect_requires_provides",
"(",
")",
"d",
"=",
"self",
".",
"_provides",
"if",
"ignored",
":",
"d",... | a map of provided classes and class members, and what
provides them. ignored is an optional list of globbed patterns
indicating packages, classes, etc that shouldn't be included
in the provides map | [
"a",
"map",
"of",
"provided",
"classes",
"and",
"class",
"members",
"and",
"what",
"provides",
"them",
".",
"ignored",
"is",
"an",
"optional",
"list",
"of",
"globbed",
"patterns",
"indicating",
"packages",
"classes",
"etc",
"that",
"shouldn",
"t",
"be",
"inc... | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/distinfo.py#L131-L144 | train | 30,275 |
obriencj/python-javatools | javatools/distinfo.py | DistInfo.close | def close(self):
""" if this was a zip'd distribution, any introspection
may have resulted in opening or creating temporary files.
Call close in order to clean up. """
if self.tmpdir:
rmtree(self.tmpdir)
self.tmpdir = None
self._contents = None | python | def close(self):
""" if this was a zip'd distribution, any introspection
may have resulted in opening or creating temporary files.
Call close in order to clean up. """
if self.tmpdir:
rmtree(self.tmpdir)
self.tmpdir = None
self._contents = None | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"tmpdir",
":",
"rmtree",
"(",
"self",
".",
"tmpdir",
")",
"self",
".",
"tmpdir",
"=",
"None",
"self",
".",
"_contents",
"=",
"None"
] | if this was a zip'd distribution, any introspection
may have resulted in opening or creating temporary files.
Call close in order to clean up. | [
"if",
"this",
"was",
"a",
"zip",
"d",
"distribution",
"any",
"introspection",
"may",
"have",
"resulted",
"in",
"opening",
"or",
"creating",
"temporary",
"files",
".",
"Call",
"close",
"in",
"order",
"to",
"clean",
"up",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/distinfo.py#L179-L188 | train | 30,276 |
obriencj/python-javatools | javatools/opcodes.py | _unpack | def _unpack(struct, bc, offset=0):
"""
returns the unpacked data tuple, and the next offset past the
unpacked data
"""
return struct.unpack_from(bc, offset), offset + struct.size | python | def _unpack(struct, bc, offset=0):
"""
returns the unpacked data tuple, and the next offset past the
unpacked data
"""
return struct.unpack_from(bc, offset), offset + struct.size | [
"def",
"_unpack",
"(",
"struct",
",",
"bc",
",",
"offset",
"=",
"0",
")",
":",
"return",
"struct",
".",
"unpack_from",
"(",
"bc",
",",
"offset",
")",
",",
"offset",
"+",
"struct",
".",
"size"
] | returns the unpacked data tuple, and the next offset past the
unpacked data | [
"returns",
"the",
"unpacked",
"data",
"tuple",
"and",
"the",
"next",
"offset",
"past",
"the",
"unpacked",
"data"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/opcodes.py#L162-L168 | train | 30,277 |
obriencj/python-javatools | javatools/opcodes.py | _unpack_lookupswitch | def _unpack_lookupswitch(bc, offset):
"""
function for unpacking the lookupswitch op arguments
"""
jump = (offset % 4)
if jump:
offset += (4 - jump)
(default, npairs), offset = _unpack(_struct_ii, bc, offset)
switches = list()
for _index in range(npairs):
pair, offset ... | python | def _unpack_lookupswitch(bc, offset):
"""
function for unpacking the lookupswitch op arguments
"""
jump = (offset % 4)
if jump:
offset += (4 - jump)
(default, npairs), offset = _unpack(_struct_ii, bc, offset)
switches = list()
for _index in range(npairs):
pair, offset ... | [
"def",
"_unpack_lookupswitch",
"(",
"bc",
",",
"offset",
")",
":",
"jump",
"=",
"(",
"offset",
"%",
"4",
")",
"if",
"jump",
":",
"offset",
"+=",
"(",
"4",
"-",
"jump",
")",
"(",
"default",
",",
"npairs",
")",
",",
"offset",
"=",
"_unpack",
"(",
"... | function for unpacking the lookupswitch op arguments | [
"function",
"for",
"unpacking",
"the",
"lookupswitch",
"op",
"arguments"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/opcodes.py#L171-L187 | train | 30,278 |
obriencj/python-javatools | javatools/opcodes.py | _unpack_tableswitch | def _unpack_tableswitch(bc, offset):
"""
function for unpacking the tableswitch op arguments
"""
jump = (offset % 4)
if jump:
offset += (4 - jump)
(default, low, high), offset = _unpack(_struct_iii, bc, offset)
joffs = list()
for _index in range((high - low) + 1):
j, o... | python | def _unpack_tableswitch(bc, offset):
"""
function for unpacking the tableswitch op arguments
"""
jump = (offset % 4)
if jump:
offset += (4 - jump)
(default, low, high), offset = _unpack(_struct_iii, bc, offset)
joffs = list()
for _index in range((high - low) + 1):
j, o... | [
"def",
"_unpack_tableswitch",
"(",
"bc",
",",
"offset",
")",
":",
"jump",
"=",
"(",
"offset",
"%",
"4",
")",
"if",
"jump",
":",
"offset",
"+=",
"(",
"4",
"-",
"jump",
")",
"(",
"default",
",",
"low",
",",
"high",
")",
",",
"offset",
"=",
"_unpack... | function for unpacking the tableswitch op arguments | [
"function",
"for",
"unpacking",
"the",
"tableswitch",
"op",
"arguments"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/opcodes.py#L190-L206 | train | 30,279 |
obriencj/python-javatools | javatools/opcodes.py | _unpack_wide | def _unpack_wide(bc, offset):
"""
unpacker for wide ops
"""
code = ord(bc[offset])
if code == OP_iinc:
return _unpack(_struct_BHh, bc, offset)
elif code in (OP_iload, OP_fload, OP_aload, OP_lload, OP_dload,
OP_istore, OP_fstore, OP_astore, OP_lstore,
... | python | def _unpack_wide(bc, offset):
"""
unpacker for wide ops
"""
code = ord(bc[offset])
if code == OP_iinc:
return _unpack(_struct_BHh, bc, offset)
elif code in (OP_iload, OP_fload, OP_aload, OP_lload, OP_dload,
OP_istore, OP_fstore, OP_astore, OP_lstore,
... | [
"def",
"_unpack_wide",
"(",
"bc",
",",
"offset",
")",
":",
"code",
"=",
"ord",
"(",
"bc",
"[",
"offset",
"]",
")",
"if",
"code",
"==",
"OP_iinc",
":",
"return",
"_unpack",
"(",
"_struct_BHh",
",",
"bc",
",",
"offset",
")",
"elif",
"code",
"in",
"("... | unpacker for wide ops | [
"unpacker",
"for",
"wide",
"ops"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/opcodes.py#L209-L228 | train | 30,280 |
obriencj/python-javatools | javatools/distdiff.py | _mp_run_check | def _mp_run_check(tasks, results, options):
"""
a helper function for multiprocessing with DistReport.
"""
try:
for index, change in iter(tasks.get, None):
# this is the part that takes up all of our time and
# produces side-effects like writing out files for all of
... | python | def _mp_run_check(tasks, results, options):
"""
a helper function for multiprocessing with DistReport.
"""
try:
for index, change in iter(tasks.get, None):
# this is the part that takes up all of our time and
# produces side-effects like writing out files for all of
... | [
"def",
"_mp_run_check",
"(",
"tasks",
",",
"results",
",",
"options",
")",
":",
"try",
":",
"for",
"index",
",",
"change",
"in",
"iter",
"(",
"tasks",
".",
"get",
",",
"None",
")",
":",
"# this is the part that takes up all of our time and",
"# produces side-eff... | a helper function for multiprocessing with DistReport. | [
"a",
"helper",
"function",
"for",
"multiprocessing",
"with",
"DistReport",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/distdiff.py#L525-L549 | train | 30,281 |
obriencj/python-javatools | javatools/distdiff.py | add_distdiff_optgroup | def add_distdiff_optgroup(parser):
"""
Option group relating to the use of a DistChange or DistReport
"""
# for the --processes default
cpus = cpu_count()
og = parser.add_argument_group("Distribution Checking Options")
og.add_argument("--processes", type=int, default=cpus,
... | python | def add_distdiff_optgroup(parser):
"""
Option group relating to the use of a DistChange or DistReport
"""
# for the --processes default
cpus = cpu_count()
og = parser.add_argument_group("Distribution Checking Options")
og.add_argument("--processes", type=int, default=cpus,
... | [
"def",
"add_distdiff_optgroup",
"(",
"parser",
")",
":",
"# for the --processes default",
"cpus",
"=",
"cpu_count",
"(",
")",
"og",
"=",
"parser",
".",
"add_argument_group",
"(",
"\"Distribution Checking Options\"",
")",
"og",
".",
"add_argument",
"(",
"\"--processes\... | Option group relating to the use of a DistChange or DistReport | [
"Option",
"group",
"relating",
"to",
"the",
"use",
"of",
"a",
"DistChange",
"or",
"DistReport"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/distdiff.py#L591-L617 | train | 30,282 |
obriencj/python-javatools | javatools/distdiff.py | create_optparser | def create_optparser(progname=None):
"""
an OptionParser instance filled with options and groups
appropriate for use with the distdiff command
"""
from . import report
parser = ArgumentParser(prog=progname)
parser.add_argument("dist", nargs=2,
help="distributions to ... | python | def create_optparser(progname=None):
"""
an OptionParser instance filled with options and groups
appropriate for use with the distdiff command
"""
from . import report
parser = ArgumentParser(prog=progname)
parser.add_argument("dist", nargs=2,
help="distributions to ... | [
"def",
"create_optparser",
"(",
"progname",
"=",
"None",
")",
":",
"from",
".",
"import",
"report",
"parser",
"=",
"ArgumentParser",
"(",
"prog",
"=",
"progname",
")",
"parser",
".",
"add_argument",
"(",
"\"dist\"",
",",
"nargs",
"=",
"2",
",",
"help",
"... | an OptionParser instance filled with options and groups
appropriate for use with the distdiff command | [
"an",
"OptionParser",
"instance",
"filled",
"with",
"options",
"and",
"groups",
"appropriate",
"for",
"use",
"with",
"the",
"distdiff",
"command"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/distdiff.py#L620-L640 | train | 30,283 |
obriencj/python-javatools | javatools/distdiff.py | default_distdiff_options | def default_distdiff_options(updates=None):
"""
generate an options object with the appropriate default values in
place for API usage of distdiff features. overrides is an optional
dictionary which will be used to update fields on the options
object.
"""
parser = create_optparser()
opti... | python | def default_distdiff_options(updates=None):
"""
generate an options object with the appropriate default values in
place for API usage of distdiff features. overrides is an optional
dictionary which will be used to update fields on the options
object.
"""
parser = create_optparser()
opti... | [
"def",
"default_distdiff_options",
"(",
"updates",
"=",
"None",
")",
":",
"parser",
"=",
"create_optparser",
"(",
")",
"options",
"=",
"parser",
".",
"parse_args",
"(",
"list",
"(",
")",
")",
"if",
"updates",
":",
"# pylint: disable=W0212",
"options",
".",
"... | generate an options object with the appropriate default values in
place for API usage of distdiff features. overrides is an optional
dictionary which will be used to update fields on the options
object. | [
"generate",
"an",
"options",
"object",
"with",
"the",
"appropriate",
"default",
"values",
"in",
"place",
"for",
"API",
"usage",
"of",
"distdiff",
"features",
".",
"overrides",
"is",
"an",
"optional",
"dictionary",
"which",
"will",
"be",
"used",
"to",
"update",... | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/distdiff.py#L643-L658 | train | 30,284 |
obriencj/python-javatools | javatools/distdiff.py | DistChange.collect_impl | def collect_impl(self):
"""
emits change instances based on the delta of the two distribution
directories
"""
ld = self.ldata
rd = self.rdata
deep = not self.shallow
for event, entry in compare(ld, rd):
if deep and fnmatches(entry, *JAR_PATTE... | python | def collect_impl(self):
"""
emits change instances based on the delta of the two distribution
directories
"""
ld = self.ldata
rd = self.rdata
deep = not self.shallow
for event, entry in compare(ld, rd):
if deep and fnmatches(entry, *JAR_PATTE... | [
"def",
"collect_impl",
"(",
"self",
")",
":",
"ld",
"=",
"self",
".",
"ldata",
"rd",
"=",
"self",
".",
"rdata",
"deep",
"=",
"not",
"self",
".",
"shallow",
"for",
"event",
",",
"entry",
"in",
"compare",
"(",
"ld",
",",
"rd",
")",
":",
"if",
"deep... | emits change instances based on the delta of the two distribution
directories | [
"emits",
"change",
"instances",
"based",
"on",
"the",
"delta",
"of",
"the",
"two",
"distribution",
"directories"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/distdiff.py#L304-L363 | train | 30,285 |
obriencj/python-javatools | javatools/distdiff.py | DistReport.collect_impl | def collect_impl(self):
"""
overrides DistJarChange and DistClassChange from the underlying
DistChange with DistJarReport and DistClassReport instances
"""
for c in DistChange.collect_impl(self):
if isinstance(c, DistJarChange):
if c.is_change():
... | python | def collect_impl(self):
"""
overrides DistJarChange and DistClassChange from the underlying
DistChange with DistJarReport and DistClassReport instances
"""
for c in DistChange.collect_impl(self):
if isinstance(c, DistJarChange):
if c.is_change():
... | [
"def",
"collect_impl",
"(",
"self",
")",
":",
"for",
"c",
"in",
"DistChange",
".",
"collect_impl",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"c",
",",
"DistJarChange",
")",
":",
"if",
"c",
".",
"is_change",
"(",
")",
":",
"ln",
"=",
"DistJarRep... | overrides DistJarChange and DistClassChange from the underlying
DistChange with DistJarReport and DistClassReport instances | [
"overrides",
"DistJarChange",
"and",
"DistClassChange",
"from",
"the",
"underlying",
"DistChange",
"with",
"DistJarReport",
"and",
"DistClassReport",
"instances"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/distdiff.py#L383-L400 | train | 30,286 |
obriencj/python-javatools | javatools/distdiff.py | DistReport.mp_check_impl | def mp_check_impl(self, process_count):
"""
a multiprocessing-enabled check implementation. Will create up to
process_count helper processes and use them to perform the
DistJarReport and DistClassReport actions.
"""
from multiprocessing import Process, Queue
opt... | python | def mp_check_impl(self, process_count):
"""
a multiprocessing-enabled check implementation. Will create up to
process_count helper processes and use them to perform the
DistJarReport and DistClassReport actions.
"""
from multiprocessing import Process, Queue
opt... | [
"def",
"mp_check_impl",
"(",
"self",
",",
"process_count",
")",
":",
"from",
"multiprocessing",
"import",
"Process",
",",
"Queue",
"options",
"=",
"self",
".",
"reporter",
".",
"options",
"# this is the function that will be run in a separate process,",
"# which will hand... | a multiprocessing-enabled check implementation. Will create up to
process_count helper processes and use them to perform the
DistJarReport and DistClassReport actions. | [
"a",
"multiprocessing",
"-",
"enabled",
"check",
"implementation",
".",
"Will",
"create",
"up",
"to",
"process_count",
"helper",
"processes",
"and",
"use",
"them",
"to",
"perform",
"the",
"DistJarReport",
"and",
"DistClassReport",
"actions",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/distdiff.py#L403-L486 | train | 30,287 |
obriencj/python-javatools | javatools/pack.py | compile_struct | def compile_struct(fmt, cache=None):
"""
returns a struct.Struct instance compiled from fmt. If fmt has
already been compiled, it will return the previously compiled
Struct instance from the cache.
"""
if cache is None:
cache = _struct_cache
sfmt = cache.get(fmt, None)
if not s... | python | def compile_struct(fmt, cache=None):
"""
returns a struct.Struct instance compiled from fmt. If fmt has
already been compiled, it will return the previously compiled
Struct instance from the cache.
"""
if cache is None:
cache = _struct_cache
sfmt = cache.get(fmt, None)
if not s... | [
"def",
"compile_struct",
"(",
"fmt",
",",
"cache",
"=",
"None",
")",
":",
"if",
"cache",
"is",
"None",
":",
"cache",
"=",
"_struct_cache",
"sfmt",
"=",
"cache",
".",
"get",
"(",
"fmt",
",",
"None",
")",
"if",
"not",
"sfmt",
":",
"sfmt",
"=",
"Struc... | returns a struct.Struct instance compiled from fmt. If fmt has
already been compiled, it will return the previously compiled
Struct instance from the cache. | [
"returns",
"a",
"struct",
".",
"Struct",
"instance",
"compiled",
"from",
"fmt",
".",
"If",
"fmt",
"has",
"already",
"been",
"compiled",
"it",
"will",
"return",
"the",
"previously",
"compiled",
"Struct",
"instance",
"from",
"the",
"cache",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/pack.py#L55-L69 | train | 30,288 |
obriencj/python-javatools | javatools/pack.py | BufferUnpacker.unpack | def unpack(self, fmt):
"""
unpacks the given fmt from the underlying buffer and returns the
results. Will raise an UnpackException if there is not enough
data to satisfy the fmt
"""
sfmt = compile_struct(fmt)
size = sfmt.size
offset = self.offset
... | python | def unpack(self, fmt):
"""
unpacks the given fmt from the underlying buffer and returns the
results. Will raise an UnpackException if there is not enough
data to satisfy the fmt
"""
sfmt = compile_struct(fmt)
size = sfmt.size
offset = self.offset
... | [
"def",
"unpack",
"(",
"self",
",",
"fmt",
")",
":",
"sfmt",
"=",
"compile_struct",
"(",
"fmt",
")",
"size",
"=",
"sfmt",
".",
"size",
"offset",
"=",
"self",
".",
"offset",
"if",
"self",
".",
"data",
":",
"avail",
"=",
"len",
"(",
"self",
".",
"da... | unpacks the given fmt from the underlying buffer and returns the
results. Will raise an UnpackException if there is not enough
data to satisfy the fmt | [
"unpacks",
"the",
"given",
"fmt",
"from",
"the",
"underlying",
"buffer",
"and",
"returns",
"the",
"results",
".",
"Will",
"raise",
"an",
"UnpackException",
"if",
"there",
"is",
"not",
"enough",
"data",
"to",
"satisfy",
"the",
"fmt"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/pack.py#L183-L203 | train | 30,289 |
obriencj/python-javatools | javatools/pack.py | BufferUnpacker.unpack_struct | def unpack_struct(self, struct):
"""
unpacks the given struct from the underlying buffer and returns
the results. Will raise an UnpackException if there is not
enough data to satisfy the format of the structure
"""
size = struct.size
offset = self.offset
... | python | def unpack_struct(self, struct):
"""
unpacks the given struct from the underlying buffer and returns
the results. Will raise an UnpackException if there is not
enough data to satisfy the format of the structure
"""
size = struct.size
offset = self.offset
... | [
"def",
"unpack_struct",
"(",
"self",
",",
"struct",
")",
":",
"size",
"=",
"struct",
".",
"size",
"offset",
"=",
"self",
".",
"offset",
"if",
"self",
".",
"data",
":",
"avail",
"=",
"len",
"(",
"self",
".",
"data",
")",
"-",
"offset",
"else",
":",
... | unpacks the given struct from the underlying buffer and returns
the results. Will raise an UnpackException if there is not
enough data to satisfy the format of the structure | [
"unpacks",
"the",
"given",
"struct",
"from",
"the",
"underlying",
"buffer",
"and",
"returns",
"the",
"results",
".",
"Will",
"raise",
"an",
"UnpackException",
"if",
"there",
"is",
"not",
"enough",
"data",
"to",
"satisfy",
"the",
"format",
"of",
"the",
"struc... | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/pack.py#L206-L225 | train | 30,290 |
obriencj/python-javatools | javatools/pack.py | BufferUnpacker.read | def read(self, count):
"""
read count bytes from the underlying buffer and return them as a
str. Raises an UnpackException if there is not enough data in
the underlying buffer.
"""
offset = self.offset
if self.data:
avail = len(self.data) - offset
... | python | def read(self, count):
"""
read count bytes from the underlying buffer and return them as a
str. Raises an UnpackException if there is not enough data in
the underlying buffer.
"""
offset = self.offset
if self.data:
avail = len(self.data) - offset
... | [
"def",
"read",
"(",
"self",
",",
"count",
")",
":",
"offset",
"=",
"self",
".",
"offset",
"if",
"self",
".",
"data",
":",
"avail",
"=",
"len",
"(",
"self",
".",
"data",
")",
"-",
"offset",
"else",
":",
"avail",
"=",
"0",
"if",
"avail",
"<",
"co... | read count bytes from the underlying buffer and return them as a
str. Raises an UnpackException if there is not enough data in
the underlying buffer. | [
"read",
"count",
"bytes",
"from",
"the",
"underlying",
"buffer",
"and",
"return",
"them",
"as",
"a",
"str",
".",
"Raises",
"an",
"UnpackException",
"if",
"there",
"is",
"not",
"enough",
"data",
"in",
"the",
"underlying",
"buffer",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/pack.py#L228-L245 | train | 30,291 |
obriencj/python-javatools | javatools/pack.py | StreamUnpacker.unpack | def unpack(self, fmt):
"""
unpacks the given fmt from the underlying stream and returns the
results. Will raise an UnpackException if there is not enough
data to satisfy the fmt
"""
sfmt = compile_struct(fmt)
size = sfmt.size
if not self.data:
... | python | def unpack(self, fmt):
"""
unpacks the given fmt from the underlying stream and returns the
results. Will raise an UnpackException if there is not enough
data to satisfy the fmt
"""
sfmt = compile_struct(fmt)
size = sfmt.size
if not self.data:
... | [
"def",
"unpack",
"(",
"self",
",",
"fmt",
")",
":",
"sfmt",
"=",
"compile_struct",
"(",
"fmt",
")",
"size",
"=",
"sfmt",
".",
"size",
"if",
"not",
"self",
".",
"data",
":",
"raise",
"UnpackException",
"(",
"fmt",
",",
"size",
",",
"0",
")",
"buff",... | unpacks the given fmt from the underlying stream and returns the
results. Will raise an UnpackException if there is not enough
data to satisfy the fmt | [
"unpacks",
"the",
"given",
"fmt",
"from",
"the",
"underlying",
"stream",
"and",
"returns",
"the",
"results",
".",
"Will",
"raise",
"an",
"UnpackException",
"if",
"there",
"is",
"not",
"enough",
"data",
"to",
"satisfy",
"the",
"fmt"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/pack.py#L271-L288 | train | 30,292 |
obriencj/python-javatools | javatools/pack.py | StreamUnpacker.unpack_struct | def unpack_struct(self, struct):
"""
unpacks the given struct from the underlying stream and returns
the results. Will raise an UnpackException if there is not
enough data to satisfy the format of the structure
"""
size = struct.size
if not self.data:
... | python | def unpack_struct(self, struct):
"""
unpacks the given struct from the underlying stream and returns
the results. Will raise an UnpackException if there is not
enough data to satisfy the format of the structure
"""
size = struct.size
if not self.data:
... | [
"def",
"unpack_struct",
"(",
"self",
",",
"struct",
")",
":",
"size",
"=",
"struct",
".",
"size",
"if",
"not",
"self",
".",
"data",
":",
"raise",
"UnpackException",
"(",
"struct",
".",
"format",
",",
"size",
",",
"0",
")",
"buff",
"=",
"self",
".",
... | unpacks the given struct from the underlying stream and returns
the results. Will raise an UnpackException if there is not
enough data to satisfy the format of the structure | [
"unpacks",
"the",
"given",
"struct",
"from",
"the",
"underlying",
"stream",
"and",
"returns",
"the",
"results",
".",
"Will",
"raise",
"an",
"UnpackException",
"if",
"there",
"is",
"not",
"enough",
"data",
"to",
"satisfy",
"the",
"format",
"of",
"the",
"struc... | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/pack.py#L291-L307 | train | 30,293 |
obriencj/python-javatools | javatools/pack.py | StreamUnpacker.read | def read(self, count):
"""
read count bytes from the unpacker and return it. Raises an
UnpackException if there is not enough data in the underlying
stream.
"""
if not self.data:
raise UnpackException(None, count, 0)
buff = self.data.read(count)
... | python | def read(self, count):
"""
read count bytes from the unpacker and return it. Raises an
UnpackException if there is not enough data in the underlying
stream.
"""
if not self.data:
raise UnpackException(None, count, 0)
buff = self.data.read(count)
... | [
"def",
"read",
"(",
"self",
",",
"count",
")",
":",
"if",
"not",
"self",
".",
"data",
":",
"raise",
"UnpackException",
"(",
"None",
",",
"count",
",",
"0",
")",
"buff",
"=",
"self",
".",
"data",
".",
"read",
"(",
"count",
")",
"if",
"len",
"(",
... | read count bytes from the unpacker and return it. Raises an
UnpackException if there is not enough data in the underlying
stream. | [
"read",
"count",
"bytes",
"from",
"the",
"unpacker",
"and",
"return",
"it",
".",
"Raises",
"an",
"UnpackException",
"if",
"there",
"is",
"not",
"enough",
"data",
"in",
"the",
"underlying",
"stream",
"."
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/pack.py#L310-L324 | train | 30,294 |
obriencj/python-javatools | javatools/pack.py | StreamUnpacker.close | def close(self):
"""
close this unpacker, and the underlying stream if it supports such
"""
data = self.data
self.data = None
if hasattr(data, "close"):
data.close() | python | def close(self):
"""
close this unpacker, and the underlying stream if it supports such
"""
data = self.data
self.data = None
if hasattr(data, "close"):
data.close() | [
"def",
"close",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"data",
"self",
".",
"data",
"=",
"None",
"if",
"hasattr",
"(",
"data",
",",
"\"close\"",
")",
":",
"data",
".",
"close",
"(",
")"
] | close this unpacker, and the underlying stream if it supports such | [
"close",
"this",
"unpacker",
"and",
"the",
"underlying",
"stream",
"if",
"it",
"supports",
"such"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/pack.py#L327-L336 | train | 30,295 |
obriencj/python-javatools | javatools/cheetah/setuptools.py | cheetah_build_py_cmd.build_template | def build_template(self, template, template_file, package):
"""
Compile the cheetah template in src into a python file in build
"""
try:
from Cheetah.Compiler import Compiler
except ImportError:
self.announce("unable to import Cheetah.Compiler, build fail... | python | def build_template(self, template, template_file, package):
"""
Compile the cheetah template in src into a python file in build
"""
try:
from Cheetah.Compiler import Compiler
except ImportError:
self.announce("unable to import Cheetah.Compiler, build fail... | [
"def",
"build_template",
"(",
"self",
",",
"template",
",",
"template_file",
",",
"package",
")",
":",
"try",
":",
"from",
"Cheetah",
".",
"Compiler",
"import",
"Compiler",
"except",
"ImportError",
":",
"self",
".",
"announce",
"(",
"\"unable to import Cheetah.C... | Compile the cheetah template in src into a python file in build | [
"Compile",
"the",
"cheetah",
"template",
"in",
"src",
"into",
"a",
"python",
"file",
"in",
"build"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/cheetah/setuptools.py#L88-L120 | train | 30,296 |
obriencj/python-javatools | javatools/classdiff.py | add_classdiff_optgroup | def add_classdiff_optgroup(parser):
"""
option group specific to class checking
"""
g = parser.add_argument_group("Class Checking Options")
g.add_argument("--ignore-version-up", action="store_true",
default=False)
g.add_argument("--ignore-version-down", action="store_true", ... | python | def add_classdiff_optgroup(parser):
"""
option group specific to class checking
"""
g = parser.add_argument_group("Class Checking Options")
g.add_argument("--ignore-version-up", action="store_true",
default=False)
g.add_argument("--ignore-version-down", action="store_true", ... | [
"def",
"add_classdiff_optgroup",
"(",
"parser",
")",
":",
"g",
"=",
"parser",
".",
"add_argument_group",
"(",
"\"Class Checking Options\"",
")",
"g",
".",
"add_argument",
"(",
"\"--ignore-version-up\"",
",",
"action",
"=",
"\"store_true\"",
",",
"default",
"=",
"F... | option group specific to class checking | [
"option",
"group",
"specific",
"to",
"class",
"checking"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/classdiff.py#L981-L1012 | train | 30,297 |
obriencj/python-javatools | javatools/classdiff.py | add_general_optgroup | def add_general_optgroup(parser):
"""
option group for general-use features of all javatool CLIs
"""
g = parser.add_argument_group("General Options")
g.add_argument("-q", "--quiet", dest="silent",
action="store_true", default=False)
g.add_argument("-v", "--verbose", nargs=0... | python | def add_general_optgroup(parser):
"""
option group for general-use features of all javatool CLIs
"""
g = parser.add_argument_group("General Options")
g.add_argument("-q", "--quiet", dest="silent",
action="store_true", default=False)
g.add_argument("-v", "--verbose", nargs=0... | [
"def",
"add_general_optgroup",
"(",
"parser",
")",
":",
"g",
"=",
"parser",
".",
"add_argument_group",
"(",
"\"General Options\"",
")",
"g",
".",
"add_argument",
"(",
"\"-q\"",
",",
"\"--quiet\"",
",",
"dest",
"=",
"\"silent\"",
",",
"action",
"=",
"\"store_tr... | option group for general-use features of all javatool CLIs | [
"option",
"group",
"for",
"general",
"-",
"use",
"features",
"of",
"all",
"javatool",
"CLIs"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/classdiff.py#L1083-L1104 | train | 30,298 |
obriencj/python-javatools | javatools/cheetah/__init__.py | _iter_templates | def _iter_templates():
"""
uses reflection to yield the Cheetah templates under this module
"""
# pylint: disable=W0406
# needed for introspection
import javatools.cheetah
from Cheetah.Template import Template
for _, name, _ in iter_modules(__path__):
__import__("javatools.chee... | python | def _iter_templates():
"""
uses reflection to yield the Cheetah templates under this module
"""
# pylint: disable=W0406
# needed for introspection
import javatools.cheetah
from Cheetah.Template import Template
for _, name, _ in iter_modules(__path__):
__import__("javatools.chee... | [
"def",
"_iter_templates",
"(",
")",
":",
"# pylint: disable=W0406",
"# needed for introspection",
"import",
"javatools",
".",
"cheetah",
"from",
"Cheetah",
".",
"Template",
"import",
"Template",
"for",
"_",
",",
"name",
",",
"_",
"in",
"iter_modules",
"(",
"__path... | uses reflection to yield the Cheetah templates under this module | [
"uses",
"reflection",
"to",
"yield",
"the",
"Cheetah",
"templates",
"under",
"this",
"module"
] | 9e2332b452ddc508bed0615937dddcb2cf051557 | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/cheetah/__init__.py#L28-L42 | train | 30,299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.