hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c5a0104bc9ea53471b7c500c42bb9b83a2bc5a41 | sunlongbo/chromium | components/policy/tools/template_writers/writers/doc_writer.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _AddSupportedOnList | null | def _AddSupportedOnList(self, parent, supported_on_list):
'''Creates a HTML list containing the platforms, products and versions
that are specified in the list of supported_on.
Args:
parent: The DOM node for which the list will be added.
supported_on_list: The list of supported products, as a l... | Creates a HTML list containing the platforms, products and versions
that are specified in the list of supported_on.
Args:
parent: The DOM node for which the list will be added.
supported_on_list: The list of supported products, as a list of
dictionaries.
| Creates a HTML list containing the platforms, products and versions
that are specified in the list of supported_on. | [
"Creates",
"a",
"HTML",
"list",
"containing",
"the",
"platforms",
"products",
"and",
"versions",
"that",
"are",
"specified",
"in",
"the",
"list",
"of",
"supported_on",
"."
] | def _AddSupportedOnList(self, parent, supported_on_list):
ul = self._AddStyledElement(parent, 'ul', ['ul'])
for supported_on in supported_on_list:
text = []
product = supported_on['product']
platform = supported_on['platform']
text.append(self._PRODUCT_MAP[product])
text.append('(%... | [
"def",
"_AddSupportedOnList",
"(",
"self",
",",
"parent",
",",
"supported_on_list",
")",
":",
"ul",
"=",
"self",
".",
"_AddStyledElement",
"(",
"parent",
",",
"'ul'",
",",
"[",
"'ul'",
"]",
")",
"for",
"supported_on",
"in",
"supported_on_list",
":",
"text",
... | Creates a HTML list containing the platforms, products and versions
that are specified in the list of supported_on. | [
"Creates",
"a",
"HTML",
"list",
"containing",
"the",
"platforms",
"products",
"and",
"versions",
"that",
"are",
"specified",
"in",
"the",
"list",
"of",
"supported_on",
"."
] | [
"'''Creates a HTML list containing the platforms, products and versions\n that are specified in the list of supported_on.\n\n Args:\n parent: The DOM node for which the list will be added.\n supported_on_list: The list of supported products, as a list of\n dictionaries.\n '''",
"# Add th... | [
{
"param": "self",
"type": null
},
{
"param": "parent",
"type": null
},
{
"param": "supported_on_list",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "parent",
"type": null,
"docstring": "The DOM node for which the lis... |
c5a0104bc9ea53471b7c500c42bb9b83a2bc5a41 | sunlongbo/chromium | components/policy/tools/template_writers/writers/doc_writer.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _AddRangeRestrictionsList | null | def _AddRangeRestrictionsList(self, parent, schema):
'''Creates a HTML list containing range restrictions for an integer type
policy.
Args:
parent: The DOM node for which the list will be added.
schema: The schema of the policy.
'''
ul = self._AddStyledElement(parent, 'ul', ['ul'])
... | Creates a HTML list containing range restrictions for an integer type
policy.
Args:
parent: The DOM node for which the list will be added.
schema: The schema of the policy.
| Creates a HTML list containing range restrictions for an integer type
policy. | [
"Creates",
"a",
"HTML",
"list",
"containing",
"range",
"restrictions",
"for",
"an",
"integer",
"type",
"policy",
"."
] | def _AddRangeRestrictionsList(self, parent, schema):
ul = self._AddStyledElement(parent, 'ul', ['ul'])
if 'minimum' in schema:
text_min = self.GetLocalizedMessage('range_minimum')
self.AddElement(ul, 'li', {}, text_min + str(schema['minimum']))
if 'maximum' in schema:
text_max = self.GetLo... | [
"def",
"_AddRangeRestrictionsList",
"(",
"self",
",",
"parent",
",",
"schema",
")",
":",
"ul",
"=",
"self",
".",
"_AddStyledElement",
"(",
"parent",
",",
"'ul'",
",",
"[",
"'ul'",
"]",
")",
"if",
"'minimum'",
"in",
"schema",
":",
"text_min",
"=",
"self",... | Creates a HTML list containing range restrictions for an integer type
policy. | [
"Creates",
"a",
"HTML",
"list",
"containing",
"range",
"restrictions",
"for",
"an",
"integer",
"type",
"policy",
"."
] | [
"'''Creates a HTML list containing range restrictions for an integer type\n policy.\n\n Args:\n parent: The DOM node for which the list will be added.\n schema: The schema of the policy.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "parent",
"type": null
},
{
"param": "schema",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "parent",
"type": null,
"docstring": "The DOM node for which the lis... |
c5a0104bc9ea53471b7c500c42bb9b83a2bc5a41 | sunlongbo/chromium | components/policy/tools/template_writers/writers/doc_writer.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _AddPolicyDetails | null | def _AddPolicyDetails(self, parent, policy):
'''Adds the list of attributes of a policy to the HTML DOM node parent.
It will have the form:
<dl>
<dt>Attribute:</dt><dd>Description</dd>
...
</dl>
Args:
parent: A DOM element for which the list will be added.
policy: The data s... | Adds the list of attributes of a policy to the HTML DOM node parent.
It will have the form:
<dl>
<dt>Attribute:</dt><dd>Description</dd>
...
</dl>
Args:
parent: A DOM element for which the list will be added.
policy: The data structure of the policy.
| Adds the list of attributes of a policy to the HTML DOM node parent.
It will have the form:
Attribute:Description
| [
"Adds",
"the",
"list",
"of",
"attributes",
"of",
"a",
"policy",
"to",
"the",
"HTML",
"DOM",
"node",
"parent",
".",
"It",
"will",
"have",
"the",
"form",
":",
"Attribute",
":",
"Description"
] | def _AddPolicyDetails(self, parent, policy):
dl = self.AddElement(parent, 'dl')
data_type = [self._TYPE_MAP[policy['type']]]
qualified_types = []
is_complex_policy = False
if (self.IsPolicyOrItemSupportedOnPlatform(policy, 'android') and
self._RESTRICTION_TYPE_MAP.get(policy['type'], None)):... | [
"def",
"_AddPolicyDetails",
"(",
"self",
",",
"parent",
",",
"policy",
")",
":",
"dl",
"=",
"self",
".",
"AddElement",
"(",
"parent",
",",
"'dl'",
")",
"data_type",
"=",
"[",
"self",
".",
"_TYPE_MAP",
"[",
"policy",
"[",
"'type'",
"]",
"]",
"]",
"qua... | Adds the list of attributes of a policy to the HTML DOM node parent. | [
"Adds",
"the",
"list",
"of",
"attributes",
"of",
"a",
"policy",
"to",
"the",
"HTML",
"DOM",
"node",
"parent",
"."
] | [
"'''Adds the list of attributes of a policy to the HTML DOM node parent.\n It will have the form:\n <dl>\n <dt>Attribute:</dt><dd>Description</dd>\n ...\n </dl>\n\n Args:\n parent: A DOM element for which the list will be added.\n policy: The data structure of the policy.\n '''",
... | [
{
"param": "self",
"type": null
},
{
"param": "parent",
"type": null
},
{
"param": "policy",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "parent",
"type": null,
"docstring": "A DOM element for which the li... |
c5a0104bc9ea53471b7c500c42bb9b83a2bc5a41 | sunlongbo/chromium | components/policy/tools/template_writers/writers/doc_writer.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _AddPolicyRow | null | def _AddPolicyRow(self, parent, policy):
'''Adds a row for the policy in the summary table.
Args:
parent: The DOM node of the summary table.
policy: The data structure of the policy.
'''
tr = self._AddStyledElement(parent, 'tr', ['tr'])
indent = 'padding-left: %dpx;' % (7 + self._indent... | Adds a row for the policy in the summary table.
Args:
parent: The DOM node of the summary table.
policy: The data structure of the policy.
| Adds a row for the policy in the summary table. | [
"Adds",
"a",
"row",
"for",
"the",
"policy",
"in",
"the",
"summary",
"table",
"."
] | def _AddPolicyRow(self, parent, policy):
tr = self._AddStyledElement(parent, 'tr', ['tr'])
indent = 'padding-left: %dpx;' % (7 + self._indent_level * 14)
if policy['type'] != 'group':
name_td = self._AddStyledElement(tr, 'td', ['td', 'td.left'],
{'style': indent}... | [
"def",
"_AddPolicyRow",
"(",
"self",
",",
"parent",
",",
"policy",
")",
":",
"tr",
"=",
"self",
".",
"_AddStyledElement",
"(",
"parent",
",",
"'tr'",
",",
"[",
"'tr'",
"]",
")",
"indent",
"=",
"'padding-left: %dpx;'",
"%",
"(",
"7",
"+",
"self",
".",
... | Adds a row for the policy in the summary table. | [
"Adds",
"a",
"row",
"for",
"the",
"policy",
"in",
"the",
"summary",
"table",
"."
] | [
"'''Adds a row for the policy in the summary table.\n\n Args:\n parent: The DOM node of the summary table.\n policy: The data structure of the policy.\n '''",
"# Normal policies get two columns with name and caption.",
"# Groups get one column with caption."
] | [
{
"param": "self",
"type": null
},
{
"param": "parent",
"type": null
},
{
"param": "policy",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "parent",
"type": null,
"docstring": "The DOM node of the summary ta... |
c5a0104bc9ea53471b7c500c42bb9b83a2bc5a41 | sunlongbo/chromium | components/policy/tools/template_writers/writers/doc_writer.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _AddPolicySection | null | def _AddPolicySection(self, parent, policy):
'''Adds a section about the policy in the detailed policy listing.
Args:
parent: The DOM node of the <div> of the detailed policy list.
policy: The data structure of the policy.
'''
# Set style according to group nesting level.
indent = 'marg... | Adds a section about the policy in the detailed policy listing.
Args:
parent: The DOM node of the <div> of the detailed policy list.
policy: The data structure of the policy.
| Adds a section about the policy in the detailed policy listing. | [
"Adds",
"a",
"section",
"about",
"the",
"policy",
"in",
"the",
"detailed",
"policy",
"listing",
"."
] | def _AddPolicySection(self, parent, policy):
indent = 'margin-left: %dpx' % (self._indent_level * 28)
if policy['type'] == 'group':
heading = 'h2'
else:
heading = 'h3'
parent2 = self.AddElement(parent, 'div', {'style': indent})
h2 = self.AddElement(parent2, heading)
self.AddElement(h... | [
"def",
"_AddPolicySection",
"(",
"self",
",",
"parent",
",",
"policy",
")",
":",
"indent",
"=",
"'margin-left: %dpx'",
"%",
"(",
"self",
".",
"_indent_level",
"*",
"28",
")",
"if",
"policy",
"[",
"'type'",
"]",
"==",
"'group'",
":",
"heading",
"=",
"'h2'... | Adds a section about the policy in the detailed policy listing. | [
"Adds",
"a",
"section",
"about",
"the",
"policy",
"in",
"the",
"detailed",
"policy",
"listing",
"."
] | [
"'''Adds a section about the policy in the detailed policy listing.\n\n Args:\n parent: The DOM node of the <div> of the detailed policy list.\n policy: The data structure of the policy.\n '''",
"# Set style according to group nesting level.",
"# Normal policies get a full description.",
"# Gr... | [
{
"param": "self",
"type": null
},
{
"param": "parent",
"type": null
},
{
"param": "policy",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "parent",
"type": null,
"docstring": "The DOM node of the of the de... |
f199aab62a973abf222689bdbe0804a214654458 | sunlongbo/chromium | tools/flags/generate_expired_list.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | gen_file_header | <not_specific> | def gen_file_header(prog_name, meta_name):
"""Returns the header for the generated expiry list file.
The generated header contains at least:
* A copyright message on the first line
* A reference to this program (prog_name)
* A reference to the input metadata file
>>> 'The Chromium Authors' in gen_file_head... | Returns the header for the generated expiry list file.
The generated header contains at least:
* A copyright message on the first line
* A reference to this program (prog_name)
* A reference to the input metadata file
>>> 'The Chromium Authors' in gen_file_header('foo', 'bar')
True
>>> '/progname' in gen... | Returns the header for the generated expiry list file. | [
"Returns",
"the",
"header",
"for",
"the",
"generated",
"expiry",
"list",
"file",
"."
] | def gen_file_header(prog_name, meta_name):
return """// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This is a generated file. Do not edit it! It was generated by:
// {prog_name}
// and it was gen... | [
"def",
"gen_file_header",
"(",
"prog_name",
",",
"meta_name",
")",
":",
"return",
"\"\"\"// Copyright 2019 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n// This is a generated file. Do not edi... | Returns the header for the generated expiry list file. | [
"Returns",
"the",
"header",
"for",
"the",
"generated",
"expiry",
"list",
"file",
"."
] | [
"\"\"\"Returns the header for the generated expiry list file.\n\n The generated header contains at least:\n * A copyright message on the first line\n * A reference to this program (prog_name)\n * A reference to the input metadata file\n >>> 'The Chromium Authors' in gen_file_header('foo', 'bar')\n True\n >>>... | [
{
"param": "prog_name",
"type": null
},
{
"param": "meta_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "prog_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "meta_name",
"type": null,
"docstring": null,
"docstring_... |
f199aab62a973abf222689bdbe0804a214654458 | sunlongbo/chromium | tools/flags/generate_expired_list.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | gen_file_body | <not_specific> | def gen_file_body(flags, mstone):
"""Generates the body of the flag expiration list.
Flags appear in the list only if:
* Their expiration mstone is not -1
* Either the chrome version is unknown OR
* Their expiration mstone is <= the chrome version
>>> flags = [ { 'name': 'foo', 'expiry_milestone': 1 } ]
... | Generates the body of the flag expiration list.
Flags appear in the list only if:
* Their expiration mstone is not -1
* Either the chrome version is unknown OR
* Their expiration mstone is <= the chrome version
>>> flags = [ { 'name': 'foo', 'expiry_milestone': 1 } ]
>>> flags.append({ 'name': 'bar', 'exp... | Generates the body of the flag expiration list.
Flags appear in the list only if:
Their expiration mstone is not -1
Either the chrome version is unknown OR
Their expiration mstone is <= the chrome version
| [
"Generates",
"the",
"body",
"of",
"the",
"flag",
"expiration",
"list",
".",
"Flags",
"appear",
"in",
"the",
"list",
"only",
"if",
":",
"Their",
"expiration",
"mstone",
"is",
"not",
"-",
"1",
"Either",
"the",
"chrome",
"version",
"is",
"unknown",
"OR",
"T... | def gen_file_body(flags, mstone):
if mstone != None:
flags = list_flags.keep_expired_by(flags, mstone)
output = []
for f in flags:
if f['expiry_milestone'] != -1:
name, expiry = f['name'], f['expiry_milestone']
output.append(' {"' + name + '", ' + str(expiry) + '},')
return '\n'.join(output... | [
"def",
"gen_file_body",
"(",
"flags",
",",
"mstone",
")",
":",
"if",
"mstone",
"!=",
"None",
":",
"flags",
"=",
"list_flags",
".",
"keep_expired_by",
"(",
"flags",
",",
"mstone",
")",
"output",
"=",
"[",
"]",
"for",
"f",
"in",
"flags",
":",
"if",
"f"... | Generates the body of the flag expiration list. | [
"Generates",
"the",
"body",
"of",
"the",
"flag",
"expiration",
"list",
"."
] | [
"\"\"\"Generates the body of the flag expiration list.\n\n Flags appear in the list only if:\n * Their expiration mstone is not -1\n * Either the chrome version is unknown OR\n * Their expiration mstone is <= the chrome version\n\n >>> flags = [ { 'name': 'foo', 'expiry_milestone': 1 } ]\n >>> flags.append({ ... | [
{
"param": "flags",
"type": null
},
{
"param": "mstone",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "flags",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mstone",
"type": null,
"docstring": null,
"docstring_tokens"... |
5eff8533cc62ee6d20f5c0b807586e00edaebc9c | sunlongbo/chromium | tools/perf/page_sets/login_helpers/tumblr_login.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | LoginDesktopAccount | null | def LoginDesktopAccount(action_runner, credential,
credentials_path=login_utils.DEFAULT_CREDENTIAL_PATH):
"""Logs in into a Tumblr account."""
account_name, password = login_utils.GetAccountNameAndPassword(
credential, credentials_path=credentials_path)
action_runner.Navigate('https://www... | Logs in into a Tumblr account. | Logs in into a Tumblr account. | [
"Logs",
"in",
"into",
"a",
"Tumblr",
"account",
"."
] | def LoginDesktopAccount(action_runner, credential,
credentials_path=login_utils.DEFAULT_CREDENTIAL_PATH):
account_name, password = login_utils.GetAccountNameAndPassword(
credential, credentials_path=credentials_path)
action_runner.Navigate('https://www.tumblr.com/login')
login_utils.InputWi... | [
"def",
"LoginDesktopAccount",
"(",
"action_runner",
",",
"credential",
",",
"credentials_path",
"=",
"login_utils",
".",
"DEFAULT_CREDENTIAL_PATH",
")",
":",
"account_name",
",",
"password",
"=",
"login_utils",
".",
"GetAccountNameAndPassword",
"(",
"credential",
",",
... | Logs in into a Tumblr account. | [
"Logs",
"in",
"into",
"a",
"Tumblr",
"account",
"."
] | [
"\"\"\"Logs in into a Tumblr account.\"\"\""
] | [
{
"param": "action_runner",
"type": null
},
{
"param": "credential",
"type": null
},
{
"param": "credentials_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "action_runner",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "credential",
"type": null,
"docstring": null,
"docst... |
53bf5ef372eeda99d385fe77772718197a6fc106 | sunlongbo/chromium | tools/gdb/util/class_methods.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | member_function | <not_specific> | def member_function(return_type, name, arguments):
"""Decorate a member function.
See Class decorator for example usage within a class.
Args:
return_type: The return type of the function (e.g. 'int')
name: The function name (e.g. 'sum')
arguments: The argument types for this function (e.g. ['int', '... | Decorate a member function.
See Class decorator for example usage within a class.
Args:
return_type: The return type of the function (e.g. 'int')
name: The function name (e.g. 'sum')
arguments: The argument types for this function (e.g. ['int', 'int'])
Each type can be a string (e.g. 'int', 'std:... | Decorate a member function.
See Class decorator for example usage within a class.
The return type of the function
name: The function name
arguments: The argument types for this function
Each type can be a string or a
function which constructs the return type. See CreateTypeResolver
for details about type resolution. | [
"Decorate",
"a",
"member",
"function",
".",
"See",
"Class",
"decorator",
"for",
"example",
"usage",
"within",
"a",
"class",
".",
"The",
"return",
"type",
"of",
"the",
"function",
"name",
":",
"The",
"function",
"name",
"arguments",
":",
"The",
"argument",
... | def member_function(return_type, name, arguments):
def DefineMember(fn):
return MemberFunction(return_type, name, arguments, fn)
return DefineMember | [
"def",
"member_function",
"(",
"return_type",
",",
"name",
",",
"arguments",
")",
":",
"def",
"DefineMember",
"(",
"fn",
")",
":",
"return",
"MemberFunction",
"(",
"return_type",
",",
"name",
",",
"arguments",
",",
"fn",
")",
"return",
"DefineMember"
] | Decorate a member function. | [
"Decorate",
"a",
"member",
"function",
"."
] | [
"\"\"\"Decorate a member function.\n\n See Class decorator for example usage within a class.\n\n Args:\n return_type: The return type of the function (e.g. 'int')\n name: The function name (e.g. 'sum')\n arguments: The argument types for this function (e.g. ['int', 'int'])\n\n Each type can be a strin... | [
{
"param": "return_type",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "arguments",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "return_type",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tok... |
53bf5ef372eeda99d385fe77772718197a6fc106 | sunlongbo/chromium | tools/gdb/util/class_methods.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | Class | <not_specific> | def Class(class_name, template_types):
"""Decorate a python class with its corresponding C++ type.
Args:
class_name: The canonical string identifier for the class (e.g. base::Foo)
template_types: An array of names for each templated type (e.g. ['K',
'V'])
Example:
As an example, the following is ... | Decorate a python class with its corresponding C++ type.
Args:
class_name: The canonical string identifier for the class (e.g. base::Foo)
template_types: An array of names for each templated type (e.g. ['K',
'V'])
Example:
As an example, the following is an implementation of size() and operator[]
... | Decorate a python class with its corresponding C++ type.
Args:
class_name: The canonical string identifier for the class
template_types: An array of names for each templated type
As an example, the following is an implementation of size() and operator[]
on std::__1::vector, functions which are normally inlined and not... | [
"Decorate",
"a",
"python",
"class",
"with",
"its",
"corresponding",
"C",
"++",
"type",
".",
"Args",
":",
"class_name",
":",
"The",
"canonical",
"string",
"identifier",
"for",
"the",
"class",
"template_types",
":",
"An",
"array",
"of",
"names",
"for",
"each",... | def Class(class_name, template_types):
class MethodWorkerWrapper(gdb.xmethod.XMethod):
def __init__(self, name, worker_class):
super(MethodWorkerWrapper, self).__init__(name)
self.name = name
self.worker_class = worker_class
class ClassMatcher(gdb.xmethod.XMethodMatcher):
def __init__(self... | [
"def",
"Class",
"(",
"class_name",
",",
"template_types",
")",
":",
"class",
"MethodWorkerWrapper",
"(",
"gdb",
".",
"xmethod",
".",
"XMethod",
")",
":",
"\"\"\"Wrapper of an XMethodWorker class as an XMethod.\"\"\"",
"def",
"__init__",
"(",
"self",
",",
"name",
","... | Decorate a python class with its corresponding C++ type. | [
"Decorate",
"a",
"python",
"class",
"with",
"its",
"corresponding",
"C",
"++",
"type",
"."
] | [
"\"\"\"Decorate a python class with its corresponding C++ type.\n Args:\n class_name: The canonical string identifier for the class (e.g. base::Foo)\n template_types: An array of names for each templated type (e.g. ['K',\n 'V'])\n\n Example:\n As an example, the following is an implementation of size(... | [
{
"param": "class_name",
"type": null
},
{
"param": "template_types",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "class_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "template_types",
"type": null,
"docstring": null,
"docs... |
53bf5ef372eeda99d385fe77772718197a6fc106 | sunlongbo/chromium | tools/gdb/util/class_methods.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | CreateTypeResolver | <not_specific> | def CreateTypeResolver(type_desc):
"""Creates a callback which resolves to the appropriate type when
invoked.
This is a helper to allow specifying simple types as strings when
writing function descriptions. For complex cases, a callback can be
passed which will be invoked when template instantiatio... | Creates a callback which resolves to the appropriate type when
invoked.
This is a helper to allow specifying simple types as strings when
writing function descriptions. For complex cases, a callback can be
passed which will be invoked when template instantiation is known.
Args:
type_desc: A ... | Creates a callback which resolves to the appropriate type when
invoked.
This is a helper to allow specifying simple types as strings when
writing function descriptions. For complex cases, a callback can be
passed which will be invoked when template instantiation is known. | [
"Creates",
"a",
"callback",
"which",
"resolves",
"to",
"the",
"appropriate",
"type",
"when",
"invoked",
".",
"This",
"is",
"a",
"helper",
"to",
"allow",
"specifying",
"simple",
"types",
"as",
"strings",
"when",
"writing",
"function",
"descriptions",
".",
"For"... | def CreateTypeResolver(type_desc):
if callable(type_desc):
return type_desc
if type_desc == 'void':
return lambda T: None
if type_desc[-1] == '&':
inner_resolver = CreateTypeResolver(type_desc[:-1])
return lambda template_types: inner_resolver(template_types).reference()
if type_... | [
"def",
"CreateTypeResolver",
"(",
"type_desc",
")",
":",
"if",
"callable",
"(",
"type_desc",
")",
":",
"return",
"type_desc",
"if",
"type_desc",
"==",
"'void'",
":",
"return",
"lambda",
"T",
":",
"None",
"if",
"type_desc",
"[",
"-",
"1",
"]",
"==",
"'&'"... | Creates a callback which resolves to the appropriate type when
invoked. | [
"Creates",
"a",
"callback",
"which",
"resolves",
"to",
"the",
"appropriate",
"type",
"when",
"invoked",
"."
] | [
"\"\"\"Creates a callback which resolves to the appropriate type when\n invoked.\n\n This is a helper to allow specifying simple types as strings when\n writing function descriptions. For complex cases, a callback can be\n passed which will be invoked when template instantiation is known.\n\n Args:\n... | [
{
"param": "type_desc",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "type_desc",
"type": null,
"docstring": "A callback generating the type or a string description of\nthe type to lookup. Supported types are classes in the\ntemplate_classes array which will be looked up when those\ntemplated classes... |
53dee9e3554e9bb91923765ae4d868a810989751 | sunlongbo/chromium | tools/perf/core/bootstrap.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ListAllDepsPaths | <not_specific> | def ListAllDepsPaths(deps_file):
"""Recursively returns a list of all paths indicated in this deps file.
Note that this discards information about where path dependencies come from,
so this is only useful in the context of a Chromium source checkout that has
already fetched all dependencies.
Args:
deps_... | Recursively returns a list of all paths indicated in this deps file.
Note that this discards information about where path dependencies come from,
so this is only useful in the context of a Chromium source checkout that has
already fetched all dependencies.
Args:
deps_file: File containing deps information... | Recursively returns a list of all paths indicated in this deps file.
Note that this discards information about where path dependencies come from,
so this is only useful in the context of a Chromium source checkout that has
already fetched all dependencies. | [
"Recursively",
"returns",
"a",
"list",
"of",
"all",
"paths",
"indicated",
"in",
"this",
"deps",
"file",
".",
"Note",
"that",
"this",
"discards",
"information",
"about",
"where",
"path",
"dependencies",
"come",
"from",
"so",
"this",
"is",
"only",
"useful",
"i... | def ListAllDepsPaths(deps_file):
deps = {}
deps_includes = {}
chrome_root = os.path.dirname(__file__)
while os.path.basename(chrome_root) != 'src':
chrome_root = os.path.abspath(os.path.join(chrome_root, '..'))
exec (open(deps_file).read())
deps_paths = list(deps.keys())
for path in deps_includes.ke... | [
"def",
"ListAllDepsPaths",
"(",
"deps_file",
")",
":",
"deps",
"=",
"{",
"}",
"deps_includes",
"=",
"{",
"}",
"chrome_root",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"while",
"os",
".",
"path",
".",
"basename",
"(",
"chrome_root",
... | Recursively returns a list of all paths indicated in this deps file. | [
"Recursively",
"returns",
"a",
"list",
"of",
"all",
"paths",
"indicated",
"in",
"this",
"deps",
"file",
"."
] | [
"\"\"\"Recursively returns a list of all paths indicated in this deps file.\n\n Note that this discards information about where path dependencies come from,\n so this is only useful in the context of a Chromium source checkout that has\n already fetched all dependencies.\n\n Args:\n deps_file: File containin... | [
{
"param": "deps_file",
"type": null
}
] | {
"returns": [
{
"docstring": "A list of string paths starting under src that are required by the\ngiven deps file, and all of its sub-dependencies. This amounts to\nthe keys of the 'deps' dictionary.",
"docstring_tokens": [
"A",
"list",
"of",
"string",
"paths",... |
7ee91c802b7ab4aef3e992cd0afdc2854a7b3fbf | sunlongbo/chromium | tools/metrics/common/diff_util.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | PromptUserToAcceptDiff | <not_specific> | def PromptUserToAcceptDiff(old_text, new_text, prompt):
"""Displays a difference in two strings (old and new file contents) to the
user and asks whether the new version is acceptable.
Args:
old_text: A string containing old file contents.
new_text: A string containing new file contents.
prompt: Text ... | Displays a difference in two strings (old and new file contents) to the
user and asks whether the new version is acceptable.
Args:
old_text: A string containing old file contents.
new_text: A string containing new file contents.
prompt: Text that should be displayed to the user, asking whether the new
... | Displays a difference in two strings (old and new file contents) to the
user and asks whether the new version is acceptable. | [
"Displays",
"a",
"difference",
"in",
"two",
"strings",
"(",
"old",
"and",
"new",
"file",
"contents",
")",
"to",
"the",
"user",
"and",
"asks",
"whether",
"the",
"new",
"version",
"is",
"acceptable",
"."
] | def PromptUserToAcceptDiff(old_text, new_text, prompt):
logging.info('Computing diff...')
if old_text == new_text:
logging.info('No changes detected')
return True
html_diff = HtmlDiff(wrapcolumn=80).make_file(
old_text.splitlines(), new_text.splitlines(), fromdesc='Original',
todesc='Updated',... | [
"def",
"PromptUserToAcceptDiff",
"(",
"old_text",
",",
"new_text",
",",
"prompt",
")",
":",
"logging",
".",
"info",
"(",
"'Computing diff...'",
")",
"if",
"old_text",
"==",
"new_text",
":",
"logging",
".",
"info",
"(",
"'No changes detected'",
")",
"return",
"... | Displays a difference in two strings (old and new file contents) to the
user and asks whether the new version is acceptable. | [
"Displays",
"a",
"difference",
"in",
"two",
"strings",
"(",
"old",
"and",
"new",
"file",
"contents",
")",
"to",
"the",
"user",
"and",
"asks",
"whether",
"the",
"new",
"version",
"is",
"acceptable",
"."
] | [
"\"\"\"Displays a difference in two strings (old and new file contents) to the\n user and asks whether the new version is acceptable.\n\n Args:\n old_text: A string containing old file contents.\n new_text: A string containing new file contents.\n prompt: Text that should be displayed to the user, asking... | [
{
"param": "old_text",
"type": null
},
{
"param": "new_text",
"type": null
},
{
"param": "prompt",
"type": null
}
] | {
"returns": [
{
"docstring": "True is user accepted the changes or there were no changes, False otherwise.",
"docstring_tokens": [
"True",
"is",
"user",
"accepted",
"the",
"changes",
"or",
"there",
"were",
"no",
"... |
ee6add6bb3e16a8001d4c0c11e17c82876f8df8a | sunlongbo/chromium | chrome/chrome_cleaner/PRESUBMIT.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _CheckBuildFilesHaveExplicitVisibility | <not_specific> | def _CheckBuildFilesHaveExplicitVisibility(input_api, output_api):
"""Checks that all BUILD.gn files have a file-level 'visibility' directive.
We require all build files under //chrome/chrome_cleaner to have visibility
restrictions to enforce that changes under this directory cannot affect
Chrome. This lets us... | Checks that all BUILD.gn files have a file-level 'visibility' directive.
We require all build files under //chrome/chrome_cleaner to have visibility
restrictions to enforce that changes under this directory cannot affect
Chrome. This lets us safely cherry-pick changes that affect only this
directory to the sta... | Checks that all BUILD.gn files have a file-level 'visibility' directive.
We require all build files under //chrome/chrome_cleaner to have visibility
restrictions to enforce that changes under this directory cannot affect
Chrome. This lets us safely cherry-pick changes that affect only this
directory to the stable branc... | [
"Checks",
"that",
"all",
"BUILD",
".",
"gn",
"files",
"have",
"a",
"file",
"-",
"level",
"'",
"visibility",
"'",
"directive",
".",
"We",
"require",
"all",
"build",
"files",
"under",
"//",
"chrome",
"/",
"chrome_cleaner",
"to",
"have",
"visibility",
"restri... | def _CheckBuildFilesHaveExplicitVisibility(input_api, output_api):
results = []
files_without_visibility = []
def IsBuildFile(f):
local_path = input_api.os_path.normcase(f.LocalPath())
return local_path.endswith(input_api.os_path.normcase('BUILD.gn'))
for f in input_api.AffectedFiles(include_deletes=Fal... | [
"def",
"_CheckBuildFilesHaveExplicitVisibility",
"(",
"input_api",
",",
"output_api",
")",
":",
"results",
"=",
"[",
"]",
"files_without_visibility",
"=",
"[",
"]",
"def",
"IsBuildFile",
"(",
"f",
")",
":",
"local_path",
"=",
"input_api",
".",
"os_path",
".",
... | Checks that all BUILD.gn files have a file-level 'visibility' directive. | [
"Checks",
"that",
"all",
"BUILD",
".",
"gn",
"files",
"have",
"a",
"file",
"-",
"level",
"'",
"visibility",
"'",
"directive",
"."
] | [
"\"\"\"Checks that all BUILD.gn files have a file-level 'visibility' directive.\n\n We require all build files under //chrome/chrome_cleaner to have visibility\n restrictions to enforce that changes under this directory cannot affect\n Chrome. This lets us safely cherry-pick changes that affect only this\n dire... | [
{
"param": "input_api",
"type": null
},
{
"param": "output_api",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_api",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_api",
"type": null,
"docstring": null,
"docstring... |
ee6add6bb3e16a8001d4c0c11e17c82876f8df8a | sunlongbo/chromium | chrome/chrome_cleaner/PRESUBMIT.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _CommonChecks | <not_specific> | def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
results = []
results.extend(_CheckBuildFilesHaveExplicitVisibility(input_api, output_api))
return results | Checks common to both upload and commit. | Checks common to both upload and commit. | [
"Checks",
"common",
"to",
"both",
"upload",
"and",
"commit",
"."
] | def _CommonChecks(input_api, output_api):
results = []
results.extend(_CheckBuildFilesHaveExplicitVisibility(input_api, output_api))
return results | [
"def",
"_CommonChecks",
"(",
"input_api",
",",
"output_api",
")",
":",
"results",
"=",
"[",
"]",
"results",
".",
"extend",
"(",
"_CheckBuildFilesHaveExplicitVisibility",
"(",
"input_api",
",",
"output_api",
")",
")",
"return",
"results"
] | Checks common to both upload and commit. | [
"Checks",
"common",
"to",
"both",
"upload",
"and",
"commit",
"."
] | [
"\"\"\"Checks common to both upload and commit.\"\"\""
] | [
{
"param": "input_api",
"type": null
},
{
"param": "output_api",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_api",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_api",
"type": null,
"docstring": null,
"docstring... |
551251a1b18bbb40536dda7ee52df584a520b513 | sunlongbo/chromium | android_webview/javatests/PRESUBMIT.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _CheckAwJUnitTestRunner | <not_specific> | def _CheckAwJUnitTestRunner(input_api, output_api):
"""Checks that new tests use the AwJUnit4ClassRunner instead of some other
test runner. This is because WebView has special logic in the
AwJUnit4ClassRunner.
"""
run_with_pattern = input_api.re.compile(
r'^@RunWith\((.*)\)$')
correct_runner = 'AwJUn... | Checks that new tests use the AwJUnit4ClassRunner instead of some other
test runner. This is because WebView has special logic in the
AwJUnit4ClassRunner.
| Checks that new tests use the AwJUnit4ClassRunner instead of some other
test runner. This is because WebView has special logic in the
AwJUnit4ClassRunner. | [
"Checks",
"that",
"new",
"tests",
"use",
"the",
"AwJUnit4ClassRunner",
"instead",
"of",
"some",
"other",
"test",
"runner",
".",
"This",
"is",
"because",
"WebView",
"has",
"special",
"logic",
"in",
"the",
"AwJUnit4ClassRunner",
"."
] | def _CheckAwJUnitTestRunner(input_api, output_api):
run_with_pattern = input_api.re.compile(
r'^@RunWith\((.*)\)$')
correct_runner = 'AwJUnit4ClassRunner.class'
errors = []
def _FilterFile(affected_file):
return input_api.FilterSourceFile(
affected_file,
files_to_skip=input_api.DEFAULT... | [
"def",
"_CheckAwJUnitTestRunner",
"(",
"input_api",
",",
"output_api",
")",
":",
"run_with_pattern",
"=",
"input_api",
".",
"re",
".",
"compile",
"(",
"r'^@RunWith\\((.*)\\)$'",
")",
"correct_runner",
"=",
"'AwJUnit4ClassRunner.class'",
"errors",
"=",
"[",
"]",
"def... | Checks that new tests use the AwJUnit4ClassRunner instead of some other
test runner. | [
"Checks",
"that",
"new",
"tests",
"use",
"the",
"AwJUnit4ClassRunner",
"instead",
"of",
"some",
"other",
"test",
"runner",
"."
] | [
"\"\"\"Checks that new tests use the AwJUnit4ClassRunner instead of some other\n test runner. This is because WebView has special logic in the\n AwJUnit4ClassRunner.\n \"\"\""
] | [
{
"param": "input_api",
"type": null
},
{
"param": "output_api",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_api",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_api",
"type": null,
"docstring": null,
"docstring... |
551251a1b18bbb40536dda7ee52df584a520b513 | sunlongbo/chromium | android_webview/javatests/PRESUBMIT.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _CheckNoSkipCommandLineAnnotation | <not_specific> | def _CheckNoSkipCommandLineAnnotation(input_api, output_api):
"""Checks that tests do not add @SkipCommandLineParameterization annotation.
This was previously used to run the test in single-process-mode only (or,
multi-process-mode only if used with
@CommandLineFlags.Add(AwSwitches.WEBVIEW_SANDBOXED_RENDERER)).... | Checks that tests do not add @SkipCommandLineParameterization annotation.
This was previously used to run the test in single-process-mode only (or,
multi-process-mode only if used with
@CommandLineFlags.Add(AwSwitches.WEBVIEW_SANDBOXED_RENDERER)). This is
obsolete because we have dedicated annotations (@OnlyRun... | Checks that tests do not add @SkipCommandLineParameterization annotation.
This was previously used to run the test in single-process-mode only (or,
multi-process-mode only if used with
@CommandLineFlags.Add(AwSwitches.WEBVIEW_SANDBOXED_RENDERER)). This is
obsolete because we have dedicated annotations (@OnlyRunInSingle... | [
"Checks",
"that",
"tests",
"do",
"not",
"add",
"@SkipCommandLineParameterization",
"annotation",
".",
"This",
"was",
"previously",
"used",
"to",
"run",
"the",
"test",
"in",
"single",
"-",
"process",
"-",
"mode",
"only",
"(",
"or",
"multi",
"-",
"process",
"-... | def _CheckNoSkipCommandLineAnnotation(input_api, output_api):
skip_command_line_annotation = input_api.re.compile(
r'^\s*@SkipCommandLineParameterization.*$')
errors = []
def _FilterFile(affected_file):
return input_api.FilterSourceFile(
affected_file,
files_to_skip=input_api.DEFAULT_FIL... | [
"def",
"_CheckNoSkipCommandLineAnnotation",
"(",
"input_api",
",",
"output_api",
")",
":",
"skip_command_line_annotation",
"=",
"input_api",
".",
"re",
".",
"compile",
"(",
"r'^\\s*@SkipCommandLineParameterization.*$'",
")",
"errors",
"=",
"[",
"]",
"def",
"_FilterFile"... | Checks that tests do not add @SkipCommandLineParameterization annotation. | [
"Checks",
"that",
"tests",
"do",
"not",
"add",
"@SkipCommandLineParameterization",
"annotation",
"."
] | [
"\"\"\"Checks that tests do not add @SkipCommandLineParameterization annotation.\n This was previously used to run the test in single-process-mode only (or,\n multi-process-mode only if used with\n @CommandLineFlags.Add(AwSwitches.WEBVIEW_SANDBOXED_RENDERER)). This is\n obsolete because we have dedicated annota... | [
{
"param": "input_api",
"type": null
},
{
"param": "output_api",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_api",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_api",
"type": null,
"docstring": null,
"docstring... |
551251a1b18bbb40536dda7ee52df584a520b513 | sunlongbo/chromium | android_webview/javatests/PRESUBMIT.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _CheckNoSandboxedRendererSwitch | <not_specific> | def _CheckNoSandboxedRendererSwitch(input_api, output_api):
"""Checks that tests do not add the AwSwitches.WEBVIEW_SANDBOXED_RENDERER
command line flag. Tests should instead use @OnlyRunIn(MULTI_PROCESS).
"""
# This will not catch multi-line annotations (which are valid if adding
# multiple switches), but is... | Checks that tests do not add the AwSwitches.WEBVIEW_SANDBOXED_RENDERER
command line flag. Tests should instead use @OnlyRunIn(MULTI_PROCESS).
| Checks that tests do not add the AwSwitches.WEBVIEW_SANDBOXED_RENDERER
command line flag. | [
"Checks",
"that",
"tests",
"do",
"not",
"add",
"the",
"AwSwitches",
".",
"WEBVIEW_SANDBOXED_RENDERER",
"command",
"line",
"flag",
"."
] | def _CheckNoSandboxedRendererSwitch(input_api, output_api):
sandboxed_renderer_pattern = input_api.re.compile(
r'^\s*@CommandLineFlags\.Add\(.*'
r'\bAwSwitches\.WEBVIEW_SANDBOXED_RENDERER\b.*\)$')
errors = []
def _FilterFile(affected_file):
return input_api.FilterSourceFile(
affected_file,... | [
"def",
"_CheckNoSandboxedRendererSwitch",
"(",
"input_api",
",",
"output_api",
")",
":",
"sandboxed_renderer_pattern",
"=",
"input_api",
".",
"re",
".",
"compile",
"(",
"r'^\\s*@CommandLineFlags\\.Add\\(.*'",
"r'\\bAwSwitches\\.WEBVIEW_SANDBOXED_RENDERER\\b.*\\)$'",
")",
"error... | Checks that tests do not add the AwSwitches.WEBVIEW_SANDBOXED_RENDERER
command line flag. | [
"Checks",
"that",
"tests",
"do",
"not",
"add",
"the",
"AwSwitches",
".",
"WEBVIEW_SANDBOXED_RENDERER",
"command",
"line",
"flag",
"."
] | [
"\"\"\"Checks that tests do not add the AwSwitches.WEBVIEW_SANDBOXED_RENDERER\n command line flag. Tests should instead use @OnlyRunIn(MULTI_PROCESS).\n \"\"\"",
"# This will not catch multi-line annotations (which are valid if adding",
"# multiple switches), but is better than nothing (and avoids false posit... | [
{
"param": "input_api",
"type": null
},
{
"param": "output_api",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_api",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_api",
"type": null,
"docstring": null,
"docstring... |
5da6fca7f9a19be41b47e32af5189c75d9fb06c3 | sunlongbo/chromium | tools/binary_size/libsupersize/file_format.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | WriteNumberList | null | def WriteNumberList(self, gen):
"""Writes numbers from |gen| separated by space, in one line."""
sep = b''
for num in gen:
self.WriteBytes(sep)
self.WriteString(str(num))
sep = b' '
self.WriteBytes(b'\n') | Writes numbers from |gen| separated by space, in one line. | Writes numbers from |gen| separated by space, in one line. | [
"Writes",
"numbers",
"from",
"|gen|",
"separated",
"by",
"space",
"in",
"one",
"line",
"."
] | def WriteNumberList(self, gen):
sep = b''
for num in gen:
self.WriteBytes(sep)
self.WriteString(str(num))
sep = b' '
self.WriteBytes(b'\n') | [
"def",
"WriteNumberList",
"(",
"self",
",",
"gen",
")",
":",
"sep",
"=",
"b''",
"for",
"num",
"in",
"gen",
":",
"self",
".",
"WriteBytes",
"(",
"sep",
")",
"self",
".",
"WriteString",
"(",
"str",
"(",
"num",
")",
")",
"sep",
"=",
"b' '",
"self",
... | Writes numbers from |gen| separated by space, in one line. | [
"Writes",
"numbers",
"from",
"|gen|",
"separated",
"by",
"space",
"in",
"one",
"line",
"."
] | [
"\"\"\"Writes numbers from |gen| separated by space, in one line.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "gen",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gen",
"type": null,
"docstring": null,
"docstring_tokens": []... |
5da6fca7f9a19be41b47e32af5189c75d9fb06c3 | sunlongbo/chromium | tools/binary_size/libsupersize/file_format.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | SortSymbols | <not_specific> | def SortSymbols(raw_symbols, check_already_mostly_sorted=True):
"""Sorts the given symbols in the order that they should be archived in.
The sort order is chosen such that:
* Padding can be discarded.
* Ordering is deterministic (total ordering).
Also sorts |aliases| such that they match the order withi... | Sorts the given symbols in the order that they should be archived in.
The sort order is chosen such that:
* Padding can be discarded.
* Ordering is deterministic (total ordering).
Also sorts |aliases| such that they match the order within |raw_symbols|.
Args:
raw_symbols: List of symbols to sort.
... | Sorts the given symbols in the order that they should be archived in.
The sort order is chosen such that:
Padding can be discarded.
Ordering is deterministic (total ordering).
Also sorts |aliases| such that they match the order within |raw_symbols|. | [
"Sorts",
"the",
"given",
"symbols",
"in",
"the",
"order",
"that",
"they",
"should",
"be",
"archived",
"in",
".",
"The",
"sort",
"order",
"is",
"chosen",
"such",
"that",
":",
"Padding",
"can",
"be",
"discarded",
".",
"Ordering",
"is",
"deterministic",
"(",
... | def SortSymbols(raw_symbols, check_already_mostly_sorted=True):
def sort_key(s):
return (
_SECTION_SORT_ORDER[s.section_name],
s.IsOverhead(),
s.address,
s.address and s.size_without_padding > 0,
s.full_name.startswith('**'),
s.full_name,
s.object_path)
de... | [
"def",
"SortSymbols",
"(",
"raw_symbols",
",",
"check_already_mostly_sorted",
"=",
"True",
")",
":",
"def",
"sort_key",
"(",
"s",
")",
":",
"return",
"(",
"_SECTION_SORT_ORDER",
"[",
"s",
".",
"section_name",
"]",
",",
"s",
".",
"IsOverhead",
"(",
")",
","... | Sorts the given symbols in the order that they should be archived in. | [
"Sorts",
"the",
"given",
"symbols",
"in",
"the",
"order",
"that",
"they",
"should",
"be",
"archived",
"in",
"."
] | [
"\"\"\"Sorts the given symbols in the order that they should be archived in.\n\n The sort order is chosen such that:\n * Padding can be discarded.\n * Ordering is deterministic (total ordering).\n\n Also sorts |aliases| such that they match the order within |raw_symbols|.\n\n Args:\n raw_symbols: List o... | [
{
"param": "raw_symbols",
"type": null
},
{
"param": "check_already_mostly_sorted",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "raw_symbols",
"type": null,
"docstring": "List of symbols to sort.",
"docstring_tokens": [
"List",
"of",
"symbols",
"to",
"sort",
"."
],
"default": null,
"is_op... |
5da6fca7f9a19be41b47e32af5189c75d9fb06c3 | sunlongbo/chromium | tools/binary_size/libsupersize/file_format.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | CalculatePadding | null | def CalculatePadding(raw_symbols):
"""Populates the |padding| field based on symbol addresses. """
logging.info('Calculating padding')
seen_container_and_sections = set()
for i, symbol in enumerate(raw_symbols[1:]):
prev_symbol = raw_symbols[i]
if symbol.IsOverhead():
# Overhead symbols are not a... | Populates the |padding| field based on symbol addresses. | Populates the |padding| field based on symbol addresses. | [
"Populates",
"the",
"|padding|",
"field",
"based",
"on",
"symbol",
"addresses",
"."
] | def CalculatePadding(raw_symbols):
logging.info('Calculating padding')
seen_container_and_sections = set()
for i, symbol in enumerate(raw_symbols[1:]):
prev_symbol = raw_symbols[i]
if symbol.IsOverhead():
symbol.padding = symbol.size
if (prev_symbol.container.name != symbol.container.name
... | [
"def",
"CalculatePadding",
"(",
"raw_symbols",
")",
":",
"logging",
".",
"info",
"(",
"'Calculating padding'",
")",
"seen_container_and_sections",
"=",
"set",
"(",
")",
"for",
"i",
",",
"symbol",
"in",
"enumerate",
"(",
"raw_symbols",
"[",
"1",
":",
"]",
")"... | Populates the |padding| field based on symbol addresses. | [
"Populates",
"the",
"|padding|",
"field",
"based",
"on",
"symbol",
"addresses",
"."
] | [
"\"\"\"Populates the |padding| field based on symbol addresses. \"\"\"",
"# Overhead symbols are not actionable so should be padding-only.",
"# Padding-only symbols happen for ** symbol gaps."
] | [
{
"param": "raw_symbols",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "raw_symbols",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5da6fca7f9a19be41b47e32af5189c75d9fb06c3 | sunlongbo/chromium | tools/binary_size/libsupersize/file_format.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _ExpandSparseSymbols | <not_specific> | def _ExpandSparseSymbols(sparse_symbols):
"""Expands a symbol list with all aliases of all symbols in the list.
Args:
sparse_symbols: A list or SymbolGroup to expand.
"""
representative_symbols = set()
raw_symbols = []
logging.debug('Expanding sparse_symbols with aliases of included symbols')
for sym... | Expands a symbol list with all aliases of all symbols in the list.
Args:
sparse_symbols: A list or SymbolGroup to expand.
| Expands a symbol list with all aliases of all symbols in the list. | [
"Expands",
"a",
"symbol",
"list",
"with",
"all",
"aliases",
"of",
"all",
"symbols",
"in",
"the",
"list",
"."
] | def _ExpandSparseSymbols(sparse_symbols):
representative_symbols = set()
raw_symbols = []
logging.debug('Expanding sparse_symbols with aliases of included symbols')
for sym in sparse_symbols:
if sym.aliases:
num_syms = len(representative_symbols)
representative_symbols.add(sym.aliases[0])
... | [
"def",
"_ExpandSparseSymbols",
"(",
"sparse_symbols",
")",
":",
"representative_symbols",
"=",
"set",
"(",
")",
"raw_symbols",
"=",
"[",
"]",
"logging",
".",
"debug",
"(",
"'Expanding sparse_symbols with aliases of included symbols'",
")",
"for",
"sym",
"in",
"sparse_... | Expands a symbol list with all aliases of all symbols in the list. | [
"Expands",
"a",
"symbol",
"list",
"with",
"all",
"aliases",
"of",
"all",
"symbols",
"in",
"the",
"list",
"."
] | [
"\"\"\"Expands a symbol list with all aliases of all symbols in the list.\n\n Args:\n sparse_symbols: A list or SymbolGroup to expand.\n \"\"\""
] | [
{
"param": "sparse_symbols",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sparse_symbols",
"type": null,
"docstring": "A list or SymbolGroup to expand.",
"docstring_tokens": [
"A",
"list",
"or",
"SymbolGroup",
"to",
"expand",
"."
],
... |
5da6fca7f9a19be41b47e32af5189c75d9fb06c3 | sunlongbo/chromium | tools/binary_size/libsupersize/file_format.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _SaveSizeInfoToFile | null | def _SaveSizeInfoToFile(size_info,
file_obj,
include_padding=False,
sparse_symbols=None):
"""Saves size info to a .size file.
Args:
size_info: Data to write to the file
file_obj: File opened for writing.
include_padding: Whether to... | Saves size info to a .size file.
Args:
size_info: Data to write to the file
file_obj: File opened for writing.
include_padding: Whether to save padding data, useful if adding a subset of
symbols.
sparse_symbols: If present, only save these symbols to the file.
| Saves size info to a .size file. | [
"Saves",
"size",
"info",
"to",
"a",
".",
"size",
"file",
"."
] | def _SaveSizeInfoToFile(size_info,
file_obj,
include_padding=False,
sparse_symbols=None):
if sparse_symbols is not None:
raw_symbols = _ExpandSparseSymbols(sparse_symbols)
else:
raw_symbols = size_info.raw_symbols
num_containers = len... | [
"def",
"_SaveSizeInfoToFile",
"(",
"size_info",
",",
"file_obj",
",",
"include_padding",
"=",
"False",
",",
"sparse_symbols",
"=",
"None",
")",
":",
"if",
"sparse_symbols",
"is",
"not",
"None",
":",
"raw_symbols",
"=",
"_ExpandSparseSymbols",
"(",
"sparse_symbols"... | Saves size info to a .size file. | [
"Saves",
"size",
"info",
"to",
"a",
".",
"size",
"file",
"."
] | [
"\"\"\"Saves size info to a .size file.\n\n Args:\n size_info: Data to write to the file\n file_obj: File opened for writing.\n include_padding: Whether to save padding data, useful if adding a subset of\n symbols.\n sparse_symbols: If present, only save these symbols to the file.\n \"\"\"",
"#... | [
{
"param": "size_info",
"type": null
},
{
"param": "file_obj",
"type": null
},
{
"param": "include_padding",
"type": null
},
{
"param": "sparse_symbols",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "size_info",
"type": null,
"docstring": "Data to write to the file",
"docstring_tokens": [
"Data",
"to",
"write",
"to",
"the",
"file"
],
"default": null,
"is_opt... |
5da6fca7f9a19be41b47e32af5189c75d9fb06c3 | sunlongbo/chromium | tools/binary_size/libsupersize/file_format.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | gen_delta | null | def gen_delta(gen, prev_value=0):
"""Adapts a generator of numbers to deltas."""
for value in gen:
yield value - prev_value
prev_value = value | Adapts a generator of numbers to deltas. | Adapts a generator of numbers to deltas. | [
"Adapts",
"a",
"generator",
"of",
"numbers",
"to",
"deltas",
"."
] | def gen_delta(gen, prev_value=0):
for value in gen:
yield value - prev_value
prev_value = value | [
"def",
"gen_delta",
"(",
"gen",
",",
"prev_value",
"=",
"0",
")",
":",
"for",
"value",
"in",
"gen",
":",
"yield",
"value",
"-",
"prev_value",
"prev_value",
"=",
"value"
] | Adapts a generator of numbers to deltas. | [
"Adapts",
"a",
"generator",
"of",
"numbers",
"to",
"deltas",
"."
] | [
"\"\"\"Adapts a generator of numbers to deltas.\"\"\""
] | [
{
"param": "gen",
"type": null
},
{
"param": "prev_value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gen",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prev_value",
"type": null,
"docstring": null,
"docstring_token... |
5da6fca7f9a19be41b47e32af5189c75d9fb06c3 | sunlongbo/chromium | tools/binary_size/libsupersize/file_format.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | write_groups | null | def write_groups(func, delta=False):
"""Write func(symbol) for each symbol in each symbol group.
Each line written represents one symbol group in |symbol_group_by_segment|.
The values in each line are space separated and are the result of calling
|func| with the Nth symbol in the group.
If |delta|... | Write func(symbol) for each symbol in each symbol group.
Each line written represents one symbol group in |symbol_group_by_segment|.
The values in each line are space separated and are the result of calling
|func| with the Nth symbol in the group.
If |delta| is True, the differences in values are writ... | Write func(symbol) for each symbol in each symbol group.
Each line written represents one symbol group in |symbol_group_by_segment|.
The values in each line are space separated and are the result of calling
|func| with the Nth symbol in the group.
If |delta| is True, the differences in values are written instead. | [
"Write",
"func",
"(",
"symbol",
")",
"for",
"each",
"symbol",
"in",
"each",
"symbol",
"group",
".",
"Each",
"line",
"written",
"represents",
"one",
"symbol",
"group",
"in",
"|symbol_group_by_segment|",
".",
"The",
"values",
"in",
"each",
"line",
"are",
"spac... | def write_groups(func, delta=False):
for group in symbol_group_by_segment:
gen = map(func, group)
w.WriteNumberList(gen_delta(gen) if delta else gen) | [
"def",
"write_groups",
"(",
"func",
",",
"delta",
"=",
"False",
")",
":",
"for",
"group",
"in",
"symbol_group_by_segment",
":",
"gen",
"=",
"map",
"(",
"func",
",",
"group",
")",
"w",
".",
"WriteNumberList",
"(",
"gen_delta",
"(",
"gen",
")",
"if",
"de... | Write func(symbol) for each symbol in each symbol group. | [
"Write",
"func",
"(",
"symbol",
")",
"for",
"each",
"symbol",
"in",
"each",
"symbol",
"group",
"."
] | [
"\"\"\"Write func(symbol) for each symbol in each symbol group.\n\n Each line written represents one symbol group in |symbol_group_by_segment|.\n The values in each line are space separated and are the result of calling\n |func| with the Nth symbol in the group.\n\n If |delta| is True, the differences i... | [
{
"param": "func",
"type": null
},
{
"param": "delta",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "func",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "delta",
"type": null,
"docstring": null,
"docstring_tokens": ... |
5da6fca7f9a19be41b47e32af5189c75d9fb06c3 | sunlongbo/chromium | tools/binary_size/libsupersize/file_format.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _ReadLine | <not_specific> | def _ReadLine(file_iter):
"""Read a line from a file object iterator and remove the newline character.
Args:
file_iter: File object iterator
Returns:
String
"""
# str[:-1] removes the last character from a string, specifically the newline
return next(file_iter)[:-1] | Read a line from a file object iterator and remove the newline character.
Args:
file_iter: File object iterator
Returns:
String
| Read a line from a file object iterator and remove the newline character. | [
"Read",
"a",
"line",
"from",
"a",
"file",
"object",
"iterator",
"and",
"remove",
"the",
"newline",
"character",
"."
] | def _ReadLine(file_iter):
return next(file_iter)[:-1] | [
"def",
"_ReadLine",
"(",
"file_iter",
")",
":",
"return",
"next",
"(",
"file_iter",
")",
"[",
":",
"-",
"1",
"]"
] | Read a line from a file object iterator and remove the newline character. | [
"Read",
"a",
"line",
"from",
"a",
"file",
"object",
"iterator",
"and",
"remove",
"the",
"newline",
"character",
"."
] | [
"\"\"\"Read a line from a file object iterator and remove the newline character.\n\n Args:\n file_iter: File object iterator\n\n Returns:\n String\n \"\"\"",
"# str[:-1] removes the last character from a string, specifically the newline"
] | [
{
"param": "file_iter",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "file_iter",
"type": null,
"docstring": "File object iterator",
"docstring_tokens": [
"File",
"objec... |
5da6fca7f9a19be41b47e32af5189c75d9fb06c3 | sunlongbo/chromium | tools/binary_size/libsupersize/file_format.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _ReadValuesFromLine | <not_specific> | def _ReadValuesFromLine(file_iter, split):
"""Read a list of values from a line in a file object iterator.
Args:
file_iter: File object iterator
split: Splits the line with the given string
Returns:
List of string values
"""
return _ReadLine(file_iter).split(split) | Read a list of values from a line in a file object iterator.
Args:
file_iter: File object iterator
split: Splits the line with the given string
Returns:
List of string values
| Read a list of values from a line in a file object iterator. | [
"Read",
"a",
"list",
"of",
"values",
"from",
"a",
"line",
"in",
"a",
"file",
"object",
"iterator",
"."
] | def _ReadValuesFromLine(file_iter, split):
return _ReadLine(file_iter).split(split) | [
"def",
"_ReadValuesFromLine",
"(",
"file_iter",
",",
"split",
")",
":",
"return",
"_ReadLine",
"(",
"file_iter",
")",
".",
"split",
"(",
"split",
")"
] | Read a list of values from a line in a file object iterator. | [
"Read",
"a",
"list",
"of",
"values",
"from",
"a",
"line",
"in",
"a",
"file",
"object",
"iterator",
"."
] | [
"\"\"\"Read a list of values from a line in a file object iterator.\n\n Args:\n file_iter: File object iterator\n split: Splits the line with the given string\n\n Returns:\n List of string values\n \"\"\""
] | [
{
"param": "file_iter",
"type": null
},
{
"param": "split",
"type": null
}
] | {
"returns": [
{
"docstring": "List of string values",
"docstring_tokens": [
"List",
"of",
"string",
"values"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "file_iter",
"type": null,
"docstring": "File object ... |
5da6fca7f9a19be41b47e32af5189c75d9fb06c3 | sunlongbo/chromium | tools/binary_size/libsupersize/file_format.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _LoadSizeInfoFromFile | <not_specific> | def _LoadSizeInfoFromFile(file_obj, size_path):
"""Loads a size_info from the given file.
See _SaveSizeInfoToFile() for details on the .size file format.
Args:
file_obj: File to read, should be a GzipFile
"""
# Split lines on '\n', since '\r' can appear in some lines!
lines = io.TextIOWrapper(file_obj... | Loads a size_info from the given file.
See _SaveSizeInfoToFile() for details on the .size file format.
Args:
file_obj: File to read, should be a GzipFile
| Loads a size_info from the given file.
See _SaveSizeInfoToFile() for details on the .size file format. | [
"Loads",
"a",
"size_info",
"from",
"the",
"given",
"file",
".",
"See",
"_SaveSizeInfoToFile",
"()",
"for",
"details",
"on",
"the",
".",
"size",
"file",
"format",
"."
] | def _LoadSizeInfoFromFile(file_obj, size_path):
lines = io.TextIOWrapper(file_obj, newline='\n')
header_line = _ReadLine(lines).encode('ascii')
assert header_line == _COMMON_HEADER[:-1], 'was ' + str(header_line)
header_line = _ReadLine(lines).encode('ascii')
if header_line == _SIZE_HEADER_SINGLE_CONTAINER[:-... | [
"def",
"_LoadSizeInfoFromFile",
"(",
"file_obj",
",",
"size_path",
")",
":",
"lines",
"=",
"io",
".",
"TextIOWrapper",
"(",
"file_obj",
",",
"newline",
"=",
"'\\n'",
")",
"header_line",
"=",
"_ReadLine",
"(",
"lines",
")",
".",
"encode",
"(",
"'ascii'",
")... | Loads a size_info from the given file. | [
"Loads",
"a",
"size_info",
"from",
"the",
"given",
"file",
"."
] | [
"\"\"\"Loads a size_info from the given file.\n\n See _SaveSizeInfoToFile() for details on the .size file format.\n\n Args:\n file_obj: File to read, should be a GzipFile\n \"\"\"",
"# Split lines on '\\n', since '\\r' can appear in some lines!",
"# JSON header fields",
"# New format.",
"# Old format.... | [
{
"param": "file_obj",
"type": null
},
{
"param": "size_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file_obj",
"type": null,
"docstring": "File to read, should be a GzipFile",
"docstring_tokens": [
"File",
"to",
"read",
"should",
"be",
"a",
"GzipFile"
],
"de... |
5da6fca7f9a19be41b47e32af5189c75d9fb06c3 | sunlongbo/chromium | tools/binary_size/libsupersize/file_format.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | read_numeric | <not_specific> | def read_numeric(delta=False):
"""Read numeric values, where each line corresponds to a symbol group.
The values in each line are space separated.
If |delta| is True, the numbers are read as a value to add to the sum of the
prior values in the line, or as the amount to change by.
"""
ret = []
... | Read numeric values, where each line corresponds to a symbol group.
The values in each line are space separated.
If |delta| is True, the numbers are read as a value to add to the sum of the
prior values in the line, or as the amount to change by.
| Read numeric values, where each line corresponds to a symbol group.
The values in each line are space separated.
If |delta| is True, the numbers are read as a value to add to the sum of the
prior values in the line, or as the amount to change by. | [
"Read",
"numeric",
"values",
"where",
"each",
"line",
"corresponds",
"to",
"a",
"symbol",
"group",
".",
"The",
"values",
"in",
"each",
"line",
"are",
"space",
"separated",
".",
"If",
"|delta|",
"is",
"True",
"the",
"numbers",
"are",
"read",
"as",
"a",
"v... | def read_numeric(delta=False):
ret = []
delta_multiplier = int(delta)
for _ in symbol_counts:
value = 0
fields = []
for f in _ReadValuesFromLine(lines, split=' '):
value = value * delta_multiplier + int(f)
fields.append(value)
ret.append(fields)
return ret | [
"def",
"read_numeric",
"(",
"delta",
"=",
"False",
")",
":",
"ret",
"=",
"[",
"]",
"delta_multiplier",
"=",
"int",
"(",
"delta",
")",
"for",
"_",
"in",
"symbol_counts",
":",
"value",
"=",
"0",
"fields",
"=",
"[",
"]",
"for",
"f",
"in",
"_ReadValuesFr... | Read numeric values, where each line corresponds to a symbol group. | [
"Read",
"numeric",
"values",
"where",
"each",
"line",
"corresponds",
"to",
"a",
"symbol",
"group",
"."
] | [
"\"\"\"Read numeric values, where each line corresponds to a symbol group.\n\n The values in each line are space separated.\n If |delta| is True, the numbers are read as a value to add to the sum of the\n prior values in the line, or as the amount to change by.\n \"\"\""
] | [
{
"param": "delta",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "delta",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5da6fca7f9a19be41b47e32af5189c75d9fb06c3 | sunlongbo/chromium | tools/binary_size/libsupersize/file_format.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | LoadDeltaSizeInfo | <not_specific> | def LoadDeltaSizeInfo(path, file_obj=None):
"""Returns a tuple of size infos (before, after).
To reconstruct the DeltaSizeInfo, diff the two size infos.
"""
if not file_obj:
with open(path, 'rb') as f:
return LoadDeltaSizeInfo(path, f)
combined_header = _COMMON_HEADER + _SIZEDIFF_HEADER
actual_h... | Returns a tuple of size infos (before, after).
To reconstruct the DeltaSizeInfo, diff the two size infos.
| Returns a tuple of size infos (before, after).
To reconstruct the DeltaSizeInfo, diff the two size infos. | [
"Returns",
"a",
"tuple",
"of",
"size",
"infos",
"(",
"before",
"after",
")",
".",
"To",
"reconstruct",
"the",
"DeltaSizeInfo",
"diff",
"the",
"two",
"size",
"infos",
"."
] | def LoadDeltaSizeInfo(path, file_obj=None):
if not file_obj:
with open(path, 'rb') as f:
return LoadDeltaSizeInfo(path, f)
combined_header = _COMMON_HEADER + _SIZEDIFF_HEADER
actual_header = file_obj.read(len(combined_header))
if actual_header != combined_header:
raise Exception('Bad file header.'... | [
"def",
"LoadDeltaSizeInfo",
"(",
"path",
",",
"file_obj",
"=",
"None",
")",
":",
"if",
"not",
"file_obj",
":",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"f",
":",
"return",
"LoadDeltaSizeInfo",
"(",
"path",
",",
"f",
")",
"combined_header",
... | Returns a tuple of size infos (before, after). | [
"Returns",
"a",
"tuple",
"of",
"size",
"infos",
"(",
"before",
"after",
")",
"."
] | [
"\"\"\"Returns a tuple of size infos (before, after).\n\n To reconstruct the DeltaSizeInfo, diff the two size infos.\n \"\"\"",
"# + 1 for \\n"
] | [
{
"param": "path",
"type": null
},
{
"param": "file_obj",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file_obj",
"type": null,
"docstring": null,
"docstring_tokens... |
5daee773ba1479fdeca46d0022962e55db9c24c2 | sunlongbo/chromium | components/resources/protobufs/binary_proto_generator.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _fullname_to_filepath | <not_specific> | def _fullname_to_filepath(self, fullname):
"""Converts a full module name to a corresponding path to a .py file.
e.g. google.protobuf.text_format -> pyproto/google/protobuf/text_format.py
"""
for path in self._paths:
filepath = os.path.join(path, fullname.replace('.', os.sep) + '.py')
if os... | Converts a full module name to a corresponding path to a .py file.
e.g. google.protobuf.text_format -> pyproto/google/protobuf/text_format.py
| Converts a full module name to a corresponding path to a .py file. | [
"Converts",
"a",
"full",
"module",
"name",
"to",
"a",
"corresponding",
"path",
"to",
"a",
".",
"py",
"file",
"."
] | def _fullname_to_filepath(self, fullname):
for path in self._paths:
filepath = os.path.join(path, fullname.replace('.', os.sep) + '.py')
if os.path.isfile(filepath):
return filepath
return None | [
"def",
"_fullname_to_filepath",
"(",
"self",
",",
"fullname",
")",
":",
"for",
"path",
"in",
"self",
".",
"_paths",
":",
"filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"fullname",
".",
"replace",
"(",
"'.'",
",",
"os",
".",
"sep",... | Converts a full module name to a corresponding path to a .py file. | [
"Converts",
"a",
"full",
"module",
"name",
"to",
"a",
"corresponding",
"path",
"to",
"a",
".",
"py",
"file",
"."
] | [
"\"\"\"Converts a full module name to a corresponding path to a .py file.\n\n e.g. google.protobuf.text_format -> pyproto/google/protobuf/text_format.py\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "fullname",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fullname",
"type": null,
"docstring": null,
"docstring_tokens... |
5daee773ba1479fdeca46d0022962e55db9c24c2 | sunlongbo/chromium | components/resources/protobufs/binary_proto_generator.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | find_module | <not_specific> | def find_module(self, fullname, path=None):
"""Returns a loader module for the google.protobuf module in pyproto."""
if (fullname.startswith('google.protobuf.')
and self._module_exists(fullname)):
# Per PEP #302, this will result in self.load_module getting used
# to load |fullname|.
r... | Returns a loader module for the google.protobuf module in pyproto. | Returns a loader module for the google.protobuf module in pyproto. | [
"Returns",
"a",
"loader",
"module",
"for",
"the",
"google",
".",
"protobuf",
"module",
"in",
"pyproto",
"."
] | def find_module(self, fullname, path=None):
if (fullname.startswith('google.protobuf.')
and self._module_exists(fullname)):
return self
return None | [
"def",
"find_module",
"(",
"self",
",",
"fullname",
",",
"path",
"=",
"None",
")",
":",
"if",
"(",
"fullname",
".",
"startswith",
"(",
"'google.protobuf.'",
")",
"and",
"self",
".",
"_module_exists",
"(",
"fullname",
")",
")",
":",
"return",
"self",
"ret... | Returns a loader module for the google.protobuf module in pyproto. | [
"Returns",
"a",
"loader",
"module",
"for",
"the",
"google",
".",
"protobuf",
"module",
"in",
"pyproto",
"."
] | [
"\"\"\"Returns a loader module for the google.protobuf module in pyproto.\"\"\"",
"# Per PEP #302, this will result in self.load_module getting used",
"# to load |fullname|.",
"# Per PEP #302, if the module cannot be loaded, then return None."
] | [
{
"param": "self",
"type": null
},
{
"param": "fullname",
"type": null
},
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fullname",
"type": null,
"docstring": null,
"docstring_tokens... |
5daee773ba1479fdeca46d0022962e55db9c24c2 | sunlongbo/chromium | components/resources/protobufs/binary_proto_generator.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | load_module | <not_specific> | def load_module(self, fullname):
"""Loads the module specified by |fullname| and returns the module."""
if fullname in sys.modules:
# Per PEP #302, if |fullname| is in sys.modules, it must be returned.
return sys.modules[fullname]
if (not fullname.startswith('google.protobuf.') or
not s... | Loads the module specified by |fullname| and returns the module. | Loads the module specified by |fullname| and returns the module. | [
"Loads",
"the",
"module",
"specified",
"by",
"|fullname|",
"and",
"returns",
"the",
"module",
"."
] | def load_module(self, fullname):
if fullname in sys.modules:
return sys.modules[fullname]
if (not fullname.startswith('google.protobuf.') or
not self._module_exists(fullname)):
raise ImportError(fullname)
filepath = self._fullname_to_filepath(fullname)
return imp.load_source(fullname... | [
"def",
"load_module",
"(",
"self",
",",
"fullname",
")",
":",
"if",
"fullname",
"in",
"sys",
".",
"modules",
":",
"return",
"sys",
".",
"modules",
"[",
"fullname",
"]",
"if",
"(",
"not",
"fullname",
".",
"startswith",
"(",
"'google.protobuf.'",
")",
"or"... | Loads the module specified by |fullname| and returns the module. | [
"Loads",
"the",
"module",
"specified",
"by",
"|fullname|",
"and",
"returns",
"the",
"module",
"."
] | [
"\"\"\"Loads the module specified by |fullname| and returns the module.\"\"\"",
"# Per PEP #302, if |fullname| is in sys.modules, it must be returned.",
"# Per PEP #302, raise ImportError if the requested module/package",
"# cannot be loaded. This should never get reached for this simple loader,",
"# but is... | [
{
"param": "self",
"type": null
},
{
"param": "fullname",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fullname",
"type": null,
"docstring": null,
"docstring_tokens... |
5daee773ba1479fdeca46d0022962e55db9c24c2 | sunlongbo/chromium | components/resources/protobufs/binary_proto_generator.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _ImportProtoModules | null | def _ImportProtoModules(self, paths):
"""Import the protobuf modules we need. |paths| is list of import paths"""
for path in paths:
# Put the path to our proto libraries in front, so that we don't use
# system protobuf.
sys.path.insert(1, path)
if self._IsInVirtualEnv():
# Add a cus... | Import the protobuf modules we need. |paths| is list of import paths | Import the protobuf modules we need. |paths| is list of import paths | [
"Import",
"the",
"protobuf",
"modules",
"we",
"need",
".",
"|paths|",
"is",
"list",
"of",
"import",
"paths"
] | def _ImportProtoModules(self, paths):
for path in paths:
sys.path.insert(1, path)
if self._IsInVirtualEnv():
sys.meta_path.append(GoogleProtobufModuleImporter(paths))
import google.protobuf.text_format as text_format
globals()['text_format'] = text_format
self.ImportProtoModule() | [
"def",
"_ImportProtoModules",
"(",
"self",
",",
"paths",
")",
":",
"for",
"path",
"in",
"paths",
":",
"sys",
".",
"path",
".",
"insert",
"(",
"1",
",",
"path",
")",
"if",
"self",
".",
"_IsInVirtualEnv",
"(",
")",
":",
"sys",
".",
"meta_path",
".",
... | Import the protobuf modules we need. | [
"Import",
"the",
"protobuf",
"modules",
"we",
"need",
"."
] | [
"\"\"\"Import the protobuf modules we need. |paths| is list of import paths\"\"\"",
"# Put the path to our proto libraries in front, so that we don't use",
"# system protobuf.",
"# Add a custom module loader. When run in a virtualenv that has",
"# google.protobuf installed, the site-package was getting sear... | [
{
"param": "self",
"type": null
},
{
"param": "paths",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "paths",
"type": null,
"docstring": null,
"docstring_tokens": ... |
5daee773ba1479fdeca46d0022962e55db9c24c2 | sunlongbo/chromium | components/resources/protobufs/binary_proto_generator.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _GenerateBinaryProtos | null | def _GenerateBinaryProtos(self, opts):
""" Read the ASCII proto and generate one or more binary protos. """
# Read the ASCII
with open(opts.infile, 'r') as ifile:
ascii_pb_str = ifile.read()
# Parse it into a structured PB
full_pb = self.EmptyProtoInstance()
text_format.Merge(ascii_pb_str... | Read the ASCII proto and generate one or more binary protos. | Read the ASCII proto and generate one or more binary protos. | [
"Read",
"the",
"ASCII",
"proto",
"and",
"generate",
"one",
"or",
"more",
"binary",
"protos",
"."
] | def _GenerateBinaryProtos(self, opts):
with open(opts.infile, 'r') as ifile:
ascii_pb_str = ifile.read()
full_pb = self.EmptyProtoInstance()
text_format.Merge(ascii_pb_str, full_pb)
self.ValidatePb(opts, full_pb);
self.ProcessPb(opts, full_pb) | [
"def",
"_GenerateBinaryProtos",
"(",
"self",
",",
"opts",
")",
":",
"with",
"open",
"(",
"opts",
".",
"infile",
",",
"'r'",
")",
"as",
"ifile",
":",
"ascii_pb_str",
"=",
"ifile",
".",
"read",
"(",
")",
"full_pb",
"=",
"self",
".",
"EmptyProtoInstance",
... | Read the ASCII proto and generate one or more binary protos. | [
"Read",
"the",
"ASCII",
"proto",
"and",
"generate",
"one",
"or",
"more",
"binary",
"protos",
"."
] | [
"\"\"\" Read the ASCII proto and generate one or more binary protos. \"\"\"",
"# Read the ASCII",
"# Parse it into a structured PB"
] | [
{
"param": "self",
"type": null
},
{
"param": "opts",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "opts",
"type": null,
"docstring": null,
"docstring_tokens": [... |
5daee773ba1479fdeca46d0022962e55db9c24c2 | sunlongbo/chromium | components/resources/protobufs/binary_proto_generator.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ValidatePb | null | def ValidatePb(self, opts, pb):
""" Validate the basic values of the protobuf. The
file_type_policies_unittest.cc will also validate it by platform,
but this will catch errors earlier.
"""
pass | Validate the basic values of the protobuf. The
file_type_policies_unittest.cc will also validate it by platform,
but this will catch errors earlier.
| Validate the basic values of the protobuf. The
file_type_policies_unittest.cc will also validate it by platform,
but this will catch errors earlier. | [
"Validate",
"the",
"basic",
"values",
"of",
"the",
"protobuf",
".",
"The",
"file_type_policies_unittest",
".",
"cc",
"will",
"also",
"validate",
"it",
"by",
"platform",
"but",
"this",
"will",
"catch",
"errors",
"earlier",
"."
] | def ValidatePb(self, opts, pb):
pass | [
"def",
"ValidatePb",
"(",
"self",
",",
"opts",
",",
"pb",
")",
":",
"pass"
] | Validate the basic values of the protobuf. | [
"Validate",
"the",
"basic",
"values",
"of",
"the",
"protobuf",
"."
] | [
"\"\"\" Validate the basic values of the protobuf. The\n file_type_policies_unittest.cc will also validate it by platform,\n but this will catch errors earlier.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "opts",
"type": null
},
{
"param": "pb",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "opts",
"type": null,
"docstring": null,
"docstring_tokens": [... |
0c1feef8fc35a2804b081a0a5f8b62e1359dd6da | sunlongbo/chromium | third_party/blink/tools/blinkpy/w3c/local_wpt.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | run | <not_specific> | def run(self, command, **kwargs):
"""Runs a command in the local WPT directory."""
# TODO(robertma): Migrate to blinkpy.common.checkout.Git. (crbug.com/676399)
return self.host.executive.run_command(
command, cwd=self.path, **kwargs) | Runs a command in the local WPT directory. | Runs a command in the local WPT directory. | [
"Runs",
"a",
"command",
"in",
"the",
"local",
"WPT",
"directory",
"."
] | def run(self, command, **kwargs):
return self.host.executive.run_command(
command, cwd=self.path, **kwargs) | [
"def",
"run",
"(",
"self",
",",
"command",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"host",
".",
"executive",
".",
"run_command",
"(",
"command",
",",
"cwd",
"=",
"self",
".",
"path",
",",
"**",
"kwargs",
")"
] | Runs a command in the local WPT directory. | [
"Runs",
"a",
"command",
"in",
"the",
"local",
"WPT",
"directory",
"."
] | [
"\"\"\"Runs a command in the local WPT directory.\"\"\"",
"# TODO(robertma): Migrate to blinkpy.common.checkout.Git. (crbug.com/676399)"
] | [
{
"param": "self",
"type": null
},
{
"param": "command",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "command",
"type": null,
"docstring": null,
"docstring_tokens"... |
0c1feef8fc35a2804b081a0a5f8b62e1359dd6da | sunlongbo/chromium | third_party/blink/tools/blinkpy/w3c/local_wpt.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | clean | null | def clean(self):
"""Resets git to a clean state, on origin/master with no changed files."""
self.run(['git', 'reset', '--hard', 'HEAD'])
self.run(['git', 'clean', '-fdx'])
self.run(['git', 'checkout', 'origin/master']) | Resets git to a clean state, on origin/master with no changed files. | Resets git to a clean state, on origin/master with no changed files. | [
"Resets",
"git",
"to",
"a",
"clean",
"state",
"on",
"origin",
"/",
"master",
"with",
"no",
"changed",
"files",
"."
] | def clean(self):
self.run(['git', 'reset', '--hard', 'HEAD'])
self.run(['git', 'clean', '-fdx'])
self.run(['git', 'checkout', 'origin/master']) | [
"def",
"clean",
"(",
"self",
")",
":",
"self",
".",
"run",
"(",
"[",
"'git'",
",",
"'reset'",
",",
"'--hard'",
",",
"'HEAD'",
"]",
")",
"self",
".",
"run",
"(",
"[",
"'git'",
",",
"'clean'",
",",
"'-fdx'",
"]",
")",
"self",
".",
"run",
"(",
"["... | Resets git to a clean state, on origin/master with no changed files. | [
"Resets",
"git",
"to",
"a",
"clean",
"state",
"on",
"origin",
"/",
"master",
"with",
"no",
"changed",
"files",
"."
] | [
"\"\"\"Resets git to a clean state, on origin/master with no changed files.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0c1feef8fc35a2804b081a0a5f8b62e1359dd6da | sunlongbo/chromium | third_party/blink/tools/blinkpy/w3c/local_wpt.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | create_branch_with_patch | null | def create_branch_with_patch(self,
branch_name,
message,
patch,
author,
force_push=False):
"""Commits the given patch and pushes to the upstream re... | Commits the given patch and pushes to the upstream repo.
Args:
branch_name: The local and remote git branch name.
message: Commit message string.
patch: A patch that can be applied by git apply.
author: The git commit author.
force_push: Applies the -... | Commits the given patch and pushes to the upstream repo. | [
"Commits",
"the",
"given",
"patch",
"and",
"pushes",
"to",
"the",
"upstream",
"repo",
"."
] | def create_branch_with_patch(self,
branch_name,
message,
patch,
author,
force_push=False):
self.clean()
try:
_log.info('Deletin... | [
"def",
"create_branch_with_patch",
"(",
"self",
",",
"branch_name",
",",
"message",
",",
"patch",
",",
"author",
",",
"force_push",
"=",
"False",
")",
":",
"self",
".",
"clean",
"(",
")",
"try",
":",
"_log",
".",
"info",
"(",
"'Deleting old branch %s'",
",... | Commits the given patch and pushes to the upstream repo. | [
"Commits",
"the",
"given",
"patch",
"and",
"pushes",
"to",
"the",
"upstream",
"repo",
"."
] | [
"\"\"\"Commits the given patch and pushes to the upstream repo.\n\n Args:\n branch_name: The local and remote git branch name.\n message: Commit message string.\n patch: A patch that can be applied by git apply.\n author: The git commit author.\n force_p... | [
{
"param": "self",
"type": null
},
{
"param": "branch_name",
"type": null
},
{
"param": "message",
"type": null
},
{
"param": "patch",
"type": null
},
{
"param": "author",
"type": null
},
{
"param": "force_push",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "branch_name",
"type": null,
"docstring": "The local and remote git ... |
0c1feef8fc35a2804b081a0a5f8b62e1359dd6da | sunlongbo/chromium | third_party/blink/tools/blinkpy/w3c/local_wpt.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | apply_patch | <not_specific> | def apply_patch(self, patch):
"""Applies a Chromium patch to the local WPT repo and stages.
Returns:
A string containing error messages from git, empty if the patch applies cleanly.
"""
# Remove Chromium WPT directory prefix.
patch = patch.replace(CHROMIUM_WPT_DIR, '... | Applies a Chromium patch to the local WPT repo and stages.
Returns:
A string containing error messages from git, empty if the patch applies cleanly.
| Applies a Chromium patch to the local WPT repo and stages. | [
"Applies",
"a",
"Chromium",
"patch",
"to",
"the",
"local",
"WPT",
"repo",
"and",
"stages",
"."
] | def apply_patch(self, patch):
patch = patch.replace(CHROMIUM_WPT_DIR, '')
try:
self.run(['git', 'apply', '-'], input=patch)
self.run(['git', 'add', '.'])
except ScriptError as error:
return error.message
return '' | [
"def",
"apply_patch",
"(",
"self",
",",
"patch",
")",
":",
"patch",
"=",
"patch",
".",
"replace",
"(",
"CHROMIUM_WPT_DIR",
",",
"''",
")",
"try",
":",
"self",
".",
"run",
"(",
"[",
"'git'",
",",
"'apply'",
",",
"'-'",
"]",
",",
"input",
"=",
"patch... | Applies a Chromium patch to the local WPT repo and stages. | [
"Applies",
"a",
"Chromium",
"patch",
"to",
"the",
"local",
"WPT",
"repo",
"and",
"stages",
"."
] | [
"\"\"\"Applies a Chromium patch to the local WPT repo and stages.\n\n Returns:\n A string containing error messages from git, empty if the patch applies cleanly.\n \"\"\"",
"# Remove Chromium WPT directory prefix."
] | [
{
"param": "self",
"type": null
},
{
"param": "patch",
"type": null
}
] | {
"returns": [
{
"docstring": "A string containing error messages from git, empty if the patch applies cleanly.",
"docstring_tokens": [
"A",
"string",
"containing",
"error",
"messages",
"from",
"git",
"empty",
"if",
"the",... |
0c1feef8fc35a2804b081a0a5f8b62e1359dd6da | sunlongbo/chromium | third_party/blink/tools/blinkpy/w3c/local_wpt.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | commits_behind_master | <not_specific> | def commits_behind_master(self, commit):
"""Returns the number of commits after the given commit on origin/master.
This doesn't include the given commit, and this assumes that the given
commit is on the the master branch.
"""
return len(
self.run(['git', 'rev-list',
... | Returns the number of commits after the given commit on origin/master.
This doesn't include the given commit, and this assumes that the given
commit is on the the master branch.
| Returns the number of commits after the given commit on origin/master.
This doesn't include the given commit, and this assumes that the given
commit is on the the master branch. | [
"Returns",
"the",
"number",
"of",
"commits",
"after",
"the",
"given",
"commit",
"on",
"origin",
"/",
"master",
".",
"This",
"doesn",
"'",
"t",
"include",
"the",
"given",
"commit",
"and",
"this",
"assumes",
"that",
"the",
"given",
"commit",
"is",
"on",
"t... | def commits_behind_master(self, commit):
return len(
self.run(['git', 'rev-list',
'{}..origin/master'.format(commit)]).splitlines()) | [
"def",
"commits_behind_master",
"(",
"self",
",",
"commit",
")",
":",
"return",
"len",
"(",
"self",
".",
"run",
"(",
"[",
"'git'",
",",
"'rev-list'",
",",
"'{}..origin/master'",
".",
"format",
"(",
"commit",
")",
"]",
")",
".",
"splitlines",
"(",
")",
... | Returns the number of commits after the given commit on origin/master. | [
"Returns",
"the",
"number",
"of",
"commits",
"after",
"the",
"given",
"commit",
"on",
"origin",
"/",
"master",
"."
] | [
"\"\"\"Returns the number of commits after the given commit on origin/master.\n\n This doesn't include the given commit, and this assumes that the given\n commit is on the the master branch.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "commit",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "commit",
"type": null,
"docstring": null,
"docstring_tokens":... |
0c1feef8fc35a2804b081a0a5f8b62e1359dd6da | sunlongbo/chromium | third_party/blink/tools/blinkpy/w3c/local_wpt.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _most_recent_log_matching | <not_specific> | def _most_recent_log_matching(self, grep_str):
"""Finds the most recent commit whose message contains the given pattern.
Args:
grep_str: A regular expression. (git uses basic regexp by default!)
Returns:
A string containing the commit log of the first matched commit
... | Finds the most recent commit whose message contains the given pattern.
Args:
grep_str: A regular expression. (git uses basic regexp by default!)
Returns:
A string containing the commit log of the first matched commit
(empty if not found).
| Finds the most recent commit whose message contains the given pattern. | [
"Finds",
"the",
"most",
"recent",
"commit",
"whose",
"message",
"contains",
"the",
"given",
"pattern",
"."
] | def _most_recent_log_matching(self, grep_str):
return self.run(['git', 'log', '-1', '--grep', grep_str]) | [
"def",
"_most_recent_log_matching",
"(",
"self",
",",
"grep_str",
")",
":",
"return",
"self",
".",
"run",
"(",
"[",
"'git'",
",",
"'log'",
",",
"'-1'",
",",
"'--grep'",
",",
"grep_str",
"]",
")"
] | Finds the most recent commit whose message contains the given pattern. | [
"Finds",
"the",
"most",
"recent",
"commit",
"whose",
"message",
"contains",
"the",
"given",
"pattern",
"."
] | [
"\"\"\"Finds the most recent commit whose message contains the given pattern.\n\n Args:\n grep_str: A regular expression. (git uses basic regexp by default!)\n\n Returns:\n A string containing the commit log of the first matched commit\n (empty if not found).\n ... | [
{
"param": "self",
"type": null
},
{
"param": "grep_str",
"type": null
}
] | {
"returns": [
{
"docstring": "A string containing the commit log of the first matched commit\n(empty if not found).",
"docstring_tokens": [
"A",
"string",
"containing",
"the",
"commit",
"log",
"of",
"the",
"first",
"match... |
0c1feef8fc35a2804b081a0a5f8b62e1359dd6da | sunlongbo/chromium | third_party/blink/tools/blinkpy/w3c/local_wpt.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | commits_in_range | <not_specific> | def commits_in_range(self, revision_start, revision_end):
"""Finds all commits in the given range.
Args:
revision_start: The start of the revision range (exclusive).
revision_end: The end of the revision range (inclusive).
Return:
A list of (SHA, commit subj... | Finds all commits in the given range.
Args:
revision_start: The start of the revision range (exclusive).
revision_end: The end of the revision range (inclusive).
Return:
A list of (SHA, commit subject) pairs ordered reverse-chronologically.
| Finds all commits in the given range. | [
"Finds",
"all",
"commits",
"in",
"the",
"given",
"range",
"."
] | def commits_in_range(self, revision_start, revision_end):
revision_range = revision_start + '..' + revision_end
output = self.run(
['git', 'rev-list', '--pretty=oneline', revision_range])
commits = []
for line in output.splitlines():
commits.append(tuple(line.stri... | [
"def",
"commits_in_range",
"(",
"self",
",",
"revision_start",
",",
"revision_end",
")",
":",
"revision_range",
"=",
"revision_start",
"+",
"'..'",
"+",
"revision_end",
"output",
"=",
"self",
".",
"run",
"(",
"[",
"'git'",
",",
"'rev-list'",
",",
"'--pretty=on... | Finds all commits in the given range. | [
"Finds",
"all",
"commits",
"in",
"the",
"given",
"range",
"."
] | [
"\"\"\"Finds all commits in the given range.\n\n Args:\n revision_start: The start of the revision range (exclusive).\n revision_end: The end of the revision range (inclusive).\n\n Return:\n A list of (SHA, commit subject) pairs ordered reverse-chronologically.\n ... | [
{
"param": "self",
"type": null
},
{
"param": "revision_start",
"type": null
},
{
"param": "revision_end",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "revision_start",
"type": null,
"docstring": "The start of the revis... |
0c1feef8fc35a2804b081a0a5f8b62e1359dd6da | sunlongbo/chromium | third_party/blink/tools/blinkpy/w3c/local_wpt.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | is_commit_affecting_directory | <not_specific> | def is_commit_affecting_directory(self, commit, directory):
"""Checks if a commit affects a directory."""
exit_code = self.run([
'git', 'diff-tree', '--quiet', '--no-commit-id', '-r', commit,
'--', directory
],
return_exit_code=True)
r... | Checks if a commit affects a directory. | Checks if a commit affects a directory. | [
"Checks",
"if",
"a",
"commit",
"affects",
"a",
"directory",
"."
] | def is_commit_affecting_directory(self, commit, directory):
exit_code = self.run([
'git', 'diff-tree', '--quiet', '--no-commit-id', '-r', commit,
'--', directory
],
return_exit_code=True)
return exit_code == 1 | [
"def",
"is_commit_affecting_directory",
"(",
"self",
",",
"commit",
",",
"directory",
")",
":",
"exit_code",
"=",
"self",
".",
"run",
"(",
"[",
"'git'",
",",
"'diff-tree'",
",",
"'--quiet'",
",",
"'--no-commit-id'",
",",
"'-r'",
",",
"commit",
",",
"'--'",
... | Checks if a commit affects a directory. | [
"Checks",
"if",
"a",
"commit",
"affects",
"a",
"directory",
"."
] | [
"\"\"\"Checks if a commit affects a directory.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "commit",
"type": null
},
{
"param": "directory",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "commit",
"type": null,
"docstring": null,
"docstring_tokens":... |
0c1feef8fc35a2804b081a0a5f8b62e1359dd6da | sunlongbo/chromium | third_party/blink/tools/blinkpy/w3c/local_wpt.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | seek_change_id | <not_specific> | def seek_change_id(self, change_id):
"""Finds the most recent commit with the given Chromium change ID.
Returns:
A string of the matched commit log, empty if not found.
"""
return self._most_recent_log_matching('^Change-Id: %s' % change_id) | Finds the most recent commit with the given Chromium change ID.
Returns:
A string of the matched commit log, empty if not found.
| Finds the most recent commit with the given Chromium change ID. | [
"Finds",
"the",
"most",
"recent",
"commit",
"with",
"the",
"given",
"Chromium",
"change",
"ID",
"."
] | def seek_change_id(self, change_id):
return self._most_recent_log_matching('^Change-Id: %s' % change_id) | [
"def",
"seek_change_id",
"(",
"self",
",",
"change_id",
")",
":",
"return",
"self",
".",
"_most_recent_log_matching",
"(",
"'^Change-Id: %s'",
"%",
"change_id",
")"
] | Finds the most recent commit with the given Chromium change ID. | [
"Finds",
"the",
"most",
"recent",
"commit",
"with",
"the",
"given",
"Chromium",
"change",
"ID",
"."
] | [
"\"\"\"Finds the most recent commit with the given Chromium change ID.\n\n Returns:\n A string of the matched commit log, empty if not found.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "change_id",
"type": null
}
] | {
"returns": [
{
"docstring": "A string of the matched commit log, empty if not found.",
"docstring_tokens": [
"A",
"string",
"of",
"the",
"matched",
"commit",
"log",
"empty",
"if",
"not",
"found",
"."
... |
0c1feef8fc35a2804b081a0a5f8b62e1359dd6da | sunlongbo/chromium | third_party/blink/tools/blinkpy/w3c/local_wpt.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | seek_commit_position | <not_specific> | def seek_commit_position(self, commit_position):
"""Finds the most recent commit with the given Chromium commit position.
Returns:
A string of the matched commit log, empty if not found.
"""
return self._most_recent_log_matching(
'^Cr-Commit-Position: %s' % commi... | Finds the most recent commit with the given Chromium commit position.
Returns:
A string of the matched commit log, empty if not found.
| Finds the most recent commit with the given Chromium commit position. | [
"Finds",
"the",
"most",
"recent",
"commit",
"with",
"the",
"given",
"Chromium",
"commit",
"position",
"."
] | def seek_commit_position(self, commit_position):
return self._most_recent_log_matching(
'^Cr-Commit-Position: %s' % commit_position) | [
"def",
"seek_commit_position",
"(",
"self",
",",
"commit_position",
")",
":",
"return",
"self",
".",
"_most_recent_log_matching",
"(",
"'^Cr-Commit-Position: %s'",
"%",
"commit_position",
")"
] | Finds the most recent commit with the given Chromium commit position. | [
"Finds",
"the",
"most",
"recent",
"commit",
"with",
"the",
"given",
"Chromium",
"commit",
"position",
"."
] | [
"\"\"\"Finds the most recent commit with the given Chromium commit position.\n\n Returns:\n A string of the matched commit log, empty if not found.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "commit_position",
"type": null
}
] | {
"returns": [
{
"docstring": "A string of the matched commit log, empty if not found.",
"docstring_tokens": [
"A",
"string",
"of",
"the",
"matched",
"commit",
"log",
"empty",
"if",
"not",
"found",
"."
... |
7209d72a8ec015915edebe7acb76928fe17d9ec8 | sunlongbo/chromium | tools/perf/page_sets/press_story.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | AddMeasurement | null | def AddMeasurement(self, name, unit, samples, description=None):
"""Record an ad-hoc measurement.
Args:
name: A string with the name of the measurement (e.g. 'score', 'runtime',
etc).
unit: A string specifying the unit used for measurements (e.g. 'ms',
'count', etc).
samples: ... | Record an ad-hoc measurement.
Args:
name: A string with the name of the measurement (e.g. 'score', 'runtime',
etc).
unit: A string specifying the unit used for measurements (e.g. 'ms',
'count', etc).
samples: Either a single numeric value or a list of numeric values to
rec... | Record an ad-hoc measurement. | [
"Record",
"an",
"ad",
"-",
"hoc",
"measurement",
"."
] | def AddMeasurement(self, name, unit, samples, description=None):
self._measurements.append({'name': name, 'unit': unit, 'samples': samples,
'description': description}) | [
"def",
"AddMeasurement",
"(",
"self",
",",
"name",
",",
"unit",
",",
"samples",
",",
"description",
"=",
"None",
")",
":",
"self",
".",
"_measurements",
".",
"append",
"(",
"{",
"'name'",
":",
"name",
",",
"'unit'",
":",
"unit",
",",
"'samples'",
":",
... | Record an ad-hoc measurement. | [
"Record",
"an",
"ad",
"-",
"hoc",
"measurement",
"."
] | [
"\"\"\"Record an ad-hoc measurement.\n\n Args:\n name: A string with the name of the measurement (e.g. 'score', 'runtime',\n etc).\n unit: A string specifying the unit used for measurements (e.g. 'ms',\n 'count', etc).\n samples: Either a single numeric value or a list of numeric val... | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "unit",
"type": null
},
{
"param": "samples",
"type": null
},
{
"param": "description",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": "A string with the name of the me... |
7209d72a8ec015915edebe7acb76928fe17d9ec8 | sunlongbo/chromium | tools/perf/page_sets/press_story.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | AddJavaScriptMeasurement | null | def AddJavaScriptMeasurement(self, name, unit, code, **kwargs):
"""Run some JavaScript to obtain and record an ad-hoc measurements.
Args:
name: A string with the name of the measurement (e.g. 'score', 'runtime',
etc).
unit: A string specifying the unit used for measurements (e.g. 'ms',
... | Run some JavaScript to obtain and record an ad-hoc measurements.
Args:
name: A string with the name of the measurement (e.g. 'score', 'runtime',
etc).
unit: A string specifying the unit used for measurements (e.g. 'ms',
'count', etc).
code: A piece of JavaScript code to run on the... | Run some JavaScript to obtain and record an ad-hoc measurements.
Args:
name: A string with the name of the measurement .
unit: A string specifying the unit used for measurements .
code: A piece of JavaScript code to run on the current tab, it must
return either a single or a list of numeric values. These are the
values... | [
"Run",
"some",
"JavaScript",
"to",
"obtain",
"and",
"record",
"an",
"ad",
"-",
"hoc",
"measurements",
".",
"Args",
":",
"name",
":",
"A",
"string",
"with",
"the",
"name",
"of",
"the",
"measurement",
".",
"unit",
":",
"A",
"string",
"specifying",
"the",
... | def AddJavaScriptMeasurement(self, name, unit, code, **kwargs):
description = kwargs.pop('description', None)
samples = self._action_runner.EvaluateJavaScript(code, **kwargs)
self.AddMeasurement(name, unit, samples, description) | [
"def",
"AddJavaScriptMeasurement",
"(",
"self",
",",
"name",
",",
"unit",
",",
"code",
",",
"**",
"kwargs",
")",
":",
"description",
"=",
"kwargs",
".",
"pop",
"(",
"'description'",
",",
"None",
")",
"samples",
"=",
"self",
".",
"_action_runner",
".",
"E... | Run some JavaScript to obtain and record an ad-hoc measurements. | [
"Run",
"some",
"JavaScript",
"to",
"obtain",
"and",
"record",
"an",
"ad",
"-",
"hoc",
"measurements",
"."
] | [
"\"\"\"Run some JavaScript to obtain and record an ad-hoc measurements.\n\n Args:\n name: A string with the name of the measurement (e.g. 'score', 'runtime',\n etc).\n unit: A string specifying the unit used for measurements (e.g. 'ms',\n 'count', etc).\n code: A piece of JavaScript ... | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "unit",
"type": null
},
{
"param": "code",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
7211b983983253694a8c88a1660cb66513567589 | sunlongbo/chromium | tools/linux/procfs.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | vm_peak | <not_specific> | def vm_peak(self):
"""Returns a high-water (peak) virtual memory size in kilo-bytes."""
if self._vm_peak.endswith('kB'):
return int(self._vm_peak.split()[0])
raise ValueError('VmPeak is not in kB.') | Returns a high-water (peak) virtual memory size in kilo-bytes. | Returns a high-water (peak) virtual memory size in kilo-bytes. | [
"Returns",
"a",
"high",
"-",
"water",
"(",
"peak",
")",
"virtual",
"memory",
"size",
"in",
"kilo",
"-",
"bytes",
"."
] | def vm_peak(self):
if self._vm_peak.endswith('kB'):
return int(self._vm_peak.split()[0])
raise ValueError('VmPeak is not in kB.') | [
"def",
"vm_peak",
"(",
"self",
")",
":",
"if",
"self",
".",
"_vm_peak",
".",
"endswith",
"(",
"'kB'",
")",
":",
"return",
"int",
"(",
"self",
".",
"_vm_peak",
".",
"split",
"(",
")",
"[",
"0",
"]",
")",
"raise",
"ValueError",
"(",
"'VmPeak is not in ... | Returns a high-water (peak) virtual memory size in kilo-bytes. | [
"Returns",
"a",
"high",
"-",
"water",
"(",
"peak",
")",
"virtual",
"memory",
"size",
"in",
"kilo",
"-",
"bytes",
"."
] | [
"\"\"\"Returns a high-water (peak) virtual memory size in kilo-bytes.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7211b983983253694a8c88a1660cb66513567589 | sunlongbo/chromium | tools/linux/procfs.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | vm_size | <not_specific> | def vm_size(self):
"""Returns a virtual memory size in kilo-bytes."""
if self._vm_size.endswith('kB'):
return int(self._vm_size.split()[0])
raise ValueError('VmSize is not in kB.') | Returns a virtual memory size in kilo-bytes. | Returns a virtual memory size in kilo-bytes. | [
"Returns",
"a",
"virtual",
"memory",
"size",
"in",
"kilo",
"-",
"bytes",
"."
] | def vm_size(self):
if self._vm_size.endswith('kB'):
return int(self._vm_size.split()[0])
raise ValueError('VmSize is not in kB.') | [
"def",
"vm_size",
"(",
"self",
")",
":",
"if",
"self",
".",
"_vm_size",
".",
"endswith",
"(",
"'kB'",
")",
":",
"return",
"int",
"(",
"self",
".",
"_vm_size",
".",
"split",
"(",
")",
"[",
"0",
"]",
")",
"raise",
"ValueError",
"(",
"'VmSize is not in ... | Returns a virtual memory size in kilo-bytes. | [
"Returns",
"a",
"virtual",
"memory",
"size",
"in",
"kilo",
"-",
"bytes",
"."
] | [
"\"\"\"Returns a virtual memory size in kilo-bytes.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7211b983983253694a8c88a1660cb66513567589 | sunlongbo/chromium | tools/linux/procfs.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | vm_rss | <not_specific> | def vm_rss(self):
"""Returns a resident set size (RSS) in kilo-bytes."""
if self._vm_rss.endswith('kB'):
return int(self._vm_rss.split()[0])
raise ValueError('VmRSS is not in kB.') | Returns a resident set size (RSS) in kilo-bytes. | Returns a resident set size (RSS) in kilo-bytes. | [
"Returns",
"a",
"resident",
"set",
"size",
"(",
"RSS",
")",
"in",
"kilo",
"-",
"bytes",
"."
] | def vm_rss(self):
if self._vm_rss.endswith('kB'):
return int(self._vm_rss.split()[0])
raise ValueError('VmRSS is not in kB.') | [
"def",
"vm_rss",
"(",
"self",
")",
":",
"if",
"self",
".",
"_vm_rss",
".",
"endswith",
"(",
"'kB'",
")",
":",
"return",
"int",
"(",
"self",
".",
"_vm_rss",
".",
"split",
"(",
")",
"[",
"0",
"]",
")",
"raise",
"ValueError",
"(",
"'VmRSS is not in kB.'... | Returns a resident set size (RSS) in kilo-bytes. | [
"Returns",
"a",
"resident",
"set",
"size",
"(",
"RSS",
")",
"in",
"kilo",
"-",
"bytes",
"."
] | [
"\"\"\"Returns a resident set size (RSS) in kilo-bytes.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7211b983983253694a8c88a1660cb66513567589 | sunlongbo/chromium | tools/linux/procfs.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | main | <not_specific> | def main(argv):
"""The main function for manual testing."""
_LOGGER.setLevel(logging.WARNING)
handler = logging.StreamHandler()
handler.setLevel(logging.WARNING)
handler.setFormatter(logging.Formatter(
'%(asctime)s:%(name)s:%(levelname)s:%(message)s'))
_LOGGER.addHandler(handler)
pids = []
for ar... | The main function for manual testing. | The main function for manual testing. | [
"The",
"main",
"function",
"for",
"manual",
"testing",
"."
] | def main(argv):
_LOGGER.setLevel(logging.WARNING)
handler = logging.StreamHandler()
handler.setLevel(logging.WARNING)
handler.setFormatter(logging.Formatter(
'%(asctime)s:%(name)s:%(levelname)s:%(message)s'))
_LOGGER.addHandler(handler)
pids = []
for arg in argv[1:]:
try:
pid = int(arg)
... | [
"def",
"main",
"(",
"argv",
")",
":",
"_LOGGER",
".",
"setLevel",
"(",
"logging",
".",
"WARNING",
")",
"handler",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"handler",
".",
"setLevel",
"(",
"logging",
".",
"WARNING",
")",
"handler",
".",
"setFormatt... | The main function for manual testing. | [
"The",
"main",
"function",
"for",
"manual",
"testing",
"."
] | [
"\"\"\"The main function for manual testing.\"\"\""
] | [
{
"param": "argv",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "argv",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f7a93cd3118876628511270347dee9681e674123 | sunlongbo/chromium | testing/merge_scripts/noop_merge.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | noop_merge | <not_specific> | def noop_merge(output_json, jsons_to_merge):
"""Use the first supplied JSON as the output JSON.
Primarily intended for unsharded tasks.
Args:
output_json: A path to a JSON file to which the results should be written.
jsons_to_merge: A list of paths to JSON files.
"""
if len(jsons_to_merge) > 1:
... | Use the first supplied JSON as the output JSON.
Primarily intended for unsharded tasks.
Args:
output_json: A path to a JSON file to which the results should be written.
jsons_to_merge: A list of paths to JSON files.
| Use the first supplied JSON as the output JSON.
Primarily intended for unsharded tasks. | [
"Use",
"the",
"first",
"supplied",
"JSON",
"as",
"the",
"output",
"JSON",
".",
"Primarily",
"intended",
"for",
"unsharded",
"tasks",
"."
] | def noop_merge(output_json, jsons_to_merge):
if len(jsons_to_merge) > 1:
print >> sys.stderr, (
'Multiple JSONs provided: %s' % ','.join(jsons_to_merge))
return 1
if jsons_to_merge:
shutil.copyfile(jsons_to_merge[0], output_json)
else:
with open(output_json, 'w') as f:
json.dump({}, ... | [
"def",
"noop_merge",
"(",
"output_json",
",",
"jsons_to_merge",
")",
":",
"if",
"len",
"(",
"jsons_to_merge",
")",
">",
"1",
":",
"print",
">>",
"sys",
".",
"stderr",
",",
"(",
"'Multiple JSONs provided: %s'",
"%",
"','",
".",
"join",
"(",
"jsons_to_merge",
... | Use the first supplied JSON as the output JSON. | [
"Use",
"the",
"first",
"supplied",
"JSON",
"as",
"the",
"output",
"JSON",
"."
] | [
"\"\"\"Use the first supplied JSON as the output JSON.\n\n Primarily intended for unsharded tasks.\n\n Args:\n output_json: A path to a JSON file to which the results should be written.\n jsons_to_merge: A list of paths to JSON files.\n \"\"\""
] | [
{
"param": "output_json",
"type": null
},
{
"param": "jsons_to_merge",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "output_json",
"type": null,
"docstring": "A path to a JSON file to which the results should be written.",
"docstring_tokens": [
"A",
"path",
"to",
"a",
"JSON",
"file",
"t... |
685d941d54493eec8d9b290a649e2e23c24239c8 | sunlongbo/chromium | sandbox/policy/mac/generate_params.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _process_policy_files | null | def _process_policy_files(files):
"""Iterates the files in |files|, parsing out parameter definitions, and
yields the name-value pair.
"""
for sb_file in files:
with open(sb_file, 'r') as f:
for line in f:
comment_start = line.find(';')
if comment_star... | Iterates the files in |files|, parsing out parameter definitions, and
yields the name-value pair.
| Iterates the files in |files|, parsing out parameter definitions, and
yields the name-value pair. | [
"Iterates",
"the",
"files",
"in",
"|files|",
"parsing",
"out",
"parameter",
"definitions",
"and",
"yields",
"the",
"name",
"-",
"value",
"pair",
"."
] | def _process_policy_files(files):
for sb_file in files:
with open(sb_file, 'r') as f:
for line in f:
comment_start = line.find(';')
if comment_start != -1:
line = line[:comment_start]
match = DEFINE_RE.match(line)
... | [
"def",
"_process_policy_files",
"(",
"files",
")",
":",
"for",
"sb_file",
"in",
"files",
":",
"with",
"open",
"(",
"sb_file",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"comment_start",
"=",
"line",
".",
"find",
"(",
"';'",
")",
... | Iterates the files in |files|, parsing out parameter definitions, and
yields the name-value pair. | [
"Iterates",
"the",
"files",
"in",
"|files|",
"parsing",
"out",
"parameter",
"definitions",
"and",
"yields",
"the",
"name",
"-",
"value",
"pair",
"."
] | [
"\"\"\"Iterates the files in |files|, parsing out parameter definitions, and\n yields the name-value pair.\n \"\"\""
] | [
{
"param": "files",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "files",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _GetAnyElementIds | <not_specific> | def _GetAnyElementIds(payload):
"""Looks for any element, session, or window IDs, and returns them.
Payload should be passed as a dict or list.
Args:
payload: payload to check for IDs, as a python list or dict.
Returns:
list of ID strings, in order, in this payload
"""
element_tag="element-6066-11... | Looks for any element, session, or window IDs, and returns them.
Payload should be passed as a dict or list.
Args:
payload: payload to check for IDs, as a python list or dict.
Returns:
list of ID strings, in order, in this payload
| Looks for any element, session, or window IDs, and returns them.
Payload should be passed as a dict or list. | [
"Looks",
"for",
"any",
"element",
"session",
"or",
"window",
"IDs",
"and",
"returns",
"them",
".",
"Payload",
"should",
"be",
"passed",
"as",
"a",
"dict",
"or",
"list",
"."
] | def _GetAnyElementIds(payload):
element_tag="element-6066-11e4-a52e-4f735466cecf"
if isinstance(payload, dict):
if element_tag in payload:
return [payload[element_tag]]
elif isinstance(payload, list):
elements = [item[element_tag] for item in payload if element_tag in item]
windows = [item for i... | [
"def",
"_GetAnyElementIds",
"(",
"payload",
")",
":",
"element_tag",
"=",
"\"element-6066-11e4-a52e-4f735466cecf\"",
"if",
"isinstance",
"(",
"payload",
",",
"dict",
")",
":",
"if",
"element_tag",
"in",
"payload",
":",
"return",
"[",
"payload",
"[",
"element_tag",... | Looks for any element, session, or window IDs, and returns them. | [
"Looks",
"for",
"any",
"element",
"session",
"or",
"window",
"IDs",
"and",
"returns",
"them",
"."
] | [
"\"\"\"Looks for any element, session, or window IDs, and returns them.\n\n Payload should be passed as a dict or list.\n\n Args:\n payload: payload to check for IDs, as a python list or dict.\n Returns:\n list of ID strings, in order, in this payload\n \"\"\""
] | [
{
"param": "payload",
"type": null
}
] | {
"returns": [
{
"docstring": "list of ID strings, in order, in this payload",
"docstring_tokens": [
"list",
"of",
"ID",
"strings",
"in",
"order",
"in",
"this",
"payload"
],
"type": null
}
],
"raises": [],
"p... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _ReplaceUrl | null | def _ReplaceUrl(payload, base_url):
"""Swap out the base URL (starting with protocol) in this payload.
Useful when switching ports or URLs.
Args:
payload: payload in which to do the url replacement
base_url: url to replace any applicable urls in |payload| with.
"""
if base_url and "url" in payload:
... | Swap out the base URL (starting with protocol) in this payload.
Useful when switching ports or URLs.
Args:
payload: payload in which to do the url replacement
base_url: url to replace any applicable urls in |payload| with.
| Swap out the base URL (starting with protocol) in this payload.
Useful when switching ports or URLs. | [
"Swap",
"out",
"the",
"base",
"URL",
"(",
"starting",
"with",
"protocol",
")",
"in",
"this",
"payload",
".",
"Useful",
"when",
"switching",
"ports",
"or",
"URLs",
"."
] | def _ReplaceUrl(payload, base_url):
if base_url and "url" in payload:
payload["url"] = re.sub(r"^https?://((?!/).)*/",
base_url + "/", payload["url"]) | [
"def",
"_ReplaceUrl",
"(",
"payload",
",",
"base_url",
")",
":",
"if",
"base_url",
"and",
"\"url\"",
"in",
"payload",
":",
"payload",
"[",
"\"url\"",
"]",
"=",
"re",
".",
"sub",
"(",
"r\"^https?://((?!/).)*/\"",
",",
"base_url",
"+",
"\"/\"",
",",
"payload... | Swap out the base URL (starting with protocol) in this payload. | [
"Swap",
"out",
"the",
"base",
"URL",
"(",
"starting",
"with",
"protocol",
")",
"in",
"this",
"payload",
"."
] | [
"\"\"\"Swap out the base URL (starting with protocol) in this payload.\n\n Useful when switching ports or URLs.\n\n Args:\n payload: payload in which to do the url replacement\n base_url: url to replace any applicable urls in |payload| with.\n \"\"\""
] | [
{
"param": "payload",
"type": null
},
{
"param": "base_url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "payload",
"type": null,
"docstring": "payload in which to do the url replacement",
"docstring_tokens": [
"payload",
"in",
"which",
"to",
"do",
"the",
"url",
"repl... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _ReplaceBinary | null | def _ReplaceBinary(payload, binary):
"""Replace the binary path in |payload| with the one in |binary|.
If |binary| exists but there is no binary in |payload|, it is added at the
appropriate location. Operates in-place.
Args:
payload: InitSession payload as a dictionary to replace binary in
binary: new... | Replace the binary path in |payload| with the one in |binary|.
If |binary| exists but there is no binary in |payload|, it is added at the
appropriate location. Operates in-place.
Args:
payload: InitSession payload as a dictionary to replace binary in
binary: new binary to replace in payload. If binary i... | Replace the binary path in |payload| with the one in |binary|.
If |binary| exists but there is no binary in |payload|, it is added at the
appropriate location. Operates in-place.
InitSession payload as a dictionary to replace binary in
binary: new binary to replace in payload. If binary is not truthy, but
there is a b... | [
"Replace",
"the",
"binary",
"path",
"in",
"|payload|",
"with",
"the",
"one",
"in",
"|binary|",
".",
"If",
"|binary|",
"exists",
"but",
"there",
"is",
"no",
"binary",
"in",
"|payload|",
"it",
"is",
"added",
"at",
"the",
"appropriate",
"location",
".",
"Oper... | def _ReplaceBinary(payload, binary):
if ("desiredCapabilities" in payload
and "goog:chromeOptions" in payload["desiredCapabilities"]):
if binary:
(payload["desiredCapabilities"]["goog:chromeOptions"]
["binary"]) = binary
elif "binary" in payload["desiredCapabilities"]["goog:chromeOptions"]:... | [
"def",
"_ReplaceBinary",
"(",
"payload",
",",
"binary",
")",
":",
"if",
"(",
"\"desiredCapabilities\"",
"in",
"payload",
"and",
"\"goog:chromeOptions\"",
"in",
"payload",
"[",
"\"desiredCapabilities\"",
"]",
")",
":",
"if",
"binary",
":",
"(",
"payload",
"[",
... | Replace the binary path in |payload| with the one in |binary|. | [
"Replace",
"the",
"binary",
"path",
"in",
"|payload|",
"with",
"the",
"one",
"in",
"|binary|",
"."
] | [
"\"\"\"Replace the binary path in |payload| with the one in |binary|.\n\n If |binary| exists but there is no binary in |payload|, it is added at the\n appropriate location. Operates in-place.\n\n Args:\n payload: InitSession payload as a dictionary to replace binary in\n binary: new binary to replace in pa... | [
{
"param": "payload",
"type": null
},
{
"param": "binary",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "payload",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "binary",
"type": null,
"docstring": null,
"docstring_token... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _ReplaceSessionId | null | def _ReplaceSessionId(payload, id_map):
"""Update session IDs in this payload to match the current session.
Operates in-place.
Args:
payload: payload in which to replace session IDs.
id_map: mapping from logged IDs to IDs in the current session
"""
if "sessionId" in payload and payload["sessionId"] ... | Update session IDs in this payload to match the current session.
Operates in-place.
Args:
payload: payload in which to replace session IDs.
id_map: mapping from logged IDs to IDs in the current session
| Update session IDs in this payload to match the current session.
Operates in-place. | [
"Update",
"session",
"IDs",
"in",
"this",
"payload",
"to",
"match",
"the",
"current",
"session",
".",
"Operates",
"in",
"-",
"place",
"."
] | def _ReplaceSessionId(payload, id_map):
if "sessionId" in payload and payload["sessionId"] in id_map:
payload["sessionId"] = id_map[payload["sessionId"]] | [
"def",
"_ReplaceSessionId",
"(",
"payload",
",",
"id_map",
")",
":",
"if",
"\"sessionId\"",
"in",
"payload",
"and",
"payload",
"[",
"\"sessionId\"",
"]",
"in",
"id_map",
":",
"payload",
"[",
"\"sessionId\"",
"]",
"=",
"id_map",
"[",
"payload",
"[",
"\"sessio... | Update session IDs in this payload to match the current session. | [
"Update",
"session",
"IDs",
"in",
"this",
"payload",
"to",
"match",
"the",
"current",
"session",
"."
] | [
"\"\"\"Update session IDs in this payload to match the current session.\n\n Operates in-place.\n\n Args:\n payload: payload in which to replace session IDs.\n id_map: mapping from logged IDs to IDs in the current session\n \"\"\""
] | [
{
"param": "payload",
"type": null
},
{
"param": "id_map",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "payload",
"type": null,
"docstring": "payload in which to replace session IDs.",
"docstring_tokens": [
"payload",
"in",
"which",
"to",
"replace",
"session",
"IDs",
... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | AddSessionId | null | def AddSessionId(self, session_id):
"""Adds a session ID into this payload.
Args:
session_id: session ID to add.
"""
self.payload_raw["sessionId"] = session_id | Adds a session ID into this payload.
Args:
session_id: session ID to add.
| Adds a session ID into this payload. | [
"Adds",
"a",
"session",
"ID",
"into",
"this",
"payload",
"."
] | def AddSessionId(self, session_id):
self.payload_raw["sessionId"] = session_id | [
"def",
"AddSessionId",
"(",
"self",
",",
"session_id",
")",
":",
"self",
".",
"payload_raw",
"[",
"\"sessionId\"",
"]",
"=",
"session_id"
] | Adds a session ID into this payload. | [
"Adds",
"a",
"session",
"ID",
"into",
"this",
"payload",
"."
] | [
"\"\"\"Adds a session ID into this payload.\n\n Args:\n session_id: session ID to add.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "session_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "session_id",
"type": null,
"docstring": "session ID to add.",
... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | SubstituteIds | <not_specific> | def SubstituteIds(self, id_map, binary, base_url="", init_session=False):
"""Replace old IDs in the given payload with ones for the current session.
Args:
id_map: mapping from logged IDs to current-session ones
binary: binary to add into this command, if |init_session| is True
base_url: base ... | Replace old IDs in the given payload with ones for the current session.
Args:
id_map: mapping from logged IDs to current-session ones
binary: binary to add into this command, if |init_session| is True
base_url: base url to replace in the payload for navigation commands
init_session: whether... | Replace old IDs in the given payload with ones for the current session. | [
"Replace",
"old",
"IDs",
"in",
"the",
"given",
"payload",
"with",
"ones",
"for",
"the",
"current",
"session",
"."
] | def SubstituteIds(self, id_map, binary, base_url="", init_session=False):
if self.is_error or self.is_empty:
return
_ReplaceWindowAndElementIds(self.payload_raw, id_map)
_ReplaceSessionId(self.payload_raw, id_map)
if init_session:
_ReplaceBinary(self.payload_raw, binary)
_ReplaceUrl(self... | [
"def",
"SubstituteIds",
"(",
"self",
",",
"id_map",
",",
"binary",
",",
"base_url",
"=",
"\"\"",
",",
"init_session",
"=",
"False",
")",
":",
"if",
"self",
".",
"is_error",
"or",
"self",
".",
"is_empty",
":",
"return",
"_ReplaceWindowAndElementIds",
"(",
"... | Replace old IDs in the given payload with ones for the current session. | [
"Replace",
"old",
"IDs",
"in",
"the",
"given",
"payload",
"with",
"ones",
"for",
"the",
"current",
"session",
"."
] | [
"\"\"\"Replace old IDs in the given payload with ones for the current session.\n\n Args:\n id_map: mapping from logged IDs to current-session ones\n binary: binary to add into this command, if |init_session| is True\n base_url: base url to replace in the payload for navigation commands\n init... | [
{
"param": "self",
"type": null
},
{
"param": "id_map",
"type": null
},
{
"param": "binary",
"type": null
},
{
"param": "base_url",
"type": null
},
{
"param": "init_session",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id_map",
"type": null,
"docstring": "mapping from logged IDs to cur... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | UpdatePayloadForReplaySession | null | def UpdatePayloadForReplaySession(self,
id_map=None,
binary="",
base_url=None):
"""Processes IDs in the payload to match the current session.
This replaces old window, element, and session IDs in the pay... | Processes IDs in the payload to match the current session.
This replaces old window, element, and session IDs in the payload to match
the ones in the current session as defined in |id_map|. It also replaces
the binary and the url if appropriate.
Args:
id_map:
dict matching element, sessi... | Processes IDs in the payload to match the current session.
This replaces old window, element, and session IDs in the payload to match
the ones in the current session as defined in |id_map|. It also replaces
the binary and the url if appropriate. | [
"Processes",
"IDs",
"in",
"the",
"payload",
"to",
"match",
"the",
"current",
"session",
".",
"This",
"replaces",
"old",
"window",
"element",
"and",
"session",
"IDs",
"in",
"the",
"payload",
"to",
"match",
"the",
"ones",
"in",
"the",
"current",
"session",
"... | def UpdatePayloadForReplaySession(self,
id_map=None,
binary="",
base_url=None):
self.payload.AddSessionId(self.session_id)
self.payload.SubstituteIds(
id_map, binary, base_url, self.name == "InitS... | [
"def",
"UpdatePayloadForReplaySession",
"(",
"self",
",",
"id_map",
"=",
"None",
",",
"binary",
"=",
"\"\"",
",",
"base_url",
"=",
"None",
")",
":",
"self",
".",
"payload",
".",
"AddSessionId",
"(",
"self",
".",
"session_id",
")",
"self",
".",
"payload",
... | Processes IDs in the payload to match the current session. | [
"Processes",
"IDs",
"in",
"the",
"payload",
"to",
"match",
"the",
"current",
"session",
"."
] | [
"\"\"\"Processes IDs in the payload to match the current session.\n\n This replaces old window, element, and session IDs in the payload to match\n the ones in the current session as defined in |id_map|. It also replaces\n the binary and the url if appropriate.\n\n Args:\n id_map:\n dict matc... | [
{
"param": "self",
"type": null
},
{
"param": "id_map",
"type": null
},
{
"param": "binary",
"type": null
},
{
"param": "base_url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id_map",
"type": null,
"docstring": "dict matching element, session... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | GetNext | <not_specific> | def GetNext(self):
"""Get the next client command or response in the log.
Returns:
LogEntry object representing the next command or response in the log.
"""
if self._saved_log_entry is not None:
log_entry = self._saved_log_entry
self._saved_log_entry = None
return log_entry
... | Get the next client command or response in the log.
Returns:
LogEntry object representing the next command or response in the log.
| Get the next client command or response in the log. | [
"Get",
"the",
"next",
"client",
"command",
"or",
"response",
"in",
"the",
"log",
"."
] | def GetNext(self):
if self._saved_log_entry is not None:
log_entry = self._saved_log_entry
self._saved_log_entry = None
return log_entry
return self._parser.GetNext() | [
"def",
"GetNext",
"(",
"self",
")",
":",
"if",
"self",
".",
"_saved_log_entry",
"is",
"not",
"None",
":",
"log_entry",
"=",
"self",
".",
"_saved_log_entry",
"self",
".",
"_saved_log_entry",
"=",
"None",
"return",
"log_entry",
"return",
"self",
".",
"_parser"... | Get the next client command or response in the log. | [
"Get",
"the",
"next",
"client",
"command",
"or",
"response",
"in",
"the",
"log",
"."
] | [
"\"\"\"Get the next client command or response in the log.\n\n Returns:\n LogEntry object representing the next command or response in the log.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "LogEntry object representing the next command or response in the log.",
"docstring_tokens": [
"LogEntry",
"object",
"representing",
"the",
"next",
"command",
"or",
"response",
"in",
"the",
... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | UndoGetNext | null | def UndoGetNext(self, log_entry):
"""Undo the most recent GetNext call that returned |log_entry|.
Simulates going backwards in the log file by storing |log_entry| and
returning that on the next GetNext call.
Args:
entry: the returned entry from the GetNext that we wish to "undo"
Raises:
... | Undo the most recent GetNext call that returned |log_entry|.
Simulates going backwards in the log file by storing |log_entry| and
returning that on the next GetNext call.
Args:
entry: the returned entry from the GetNext that we wish to "undo"
Raises:
ReplayException: if this is called mult... | Undo the most recent GetNext call that returned |log_entry|.
Simulates going backwards in the log file by storing |log_entry| and
returning that on the next GetNext call. | [
"Undo",
"the",
"most",
"recent",
"GetNext",
"call",
"that",
"returned",
"|log_entry|",
".",
"Simulates",
"going",
"backwards",
"in",
"the",
"log",
"file",
"by",
"storing",
"|log_entry|",
"and",
"returning",
"that",
"on",
"the",
"next",
"GetNext",
"call",
"."
] | def UndoGetNext(self, log_entry):
if self._saved_log_entry is not None:
raise RuntimeError('Cannot undo multiple times in a row.')
self._saved_log_entry = log_entry | [
"def",
"UndoGetNext",
"(",
"self",
",",
"log_entry",
")",
":",
"if",
"self",
".",
"_saved_log_entry",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Cannot undo multiple times in a row.'",
")",
"self",
".",
"_saved_log_entry",
"=",
"log_entry"
] | Undo the most recent GetNext call that returned |log_entry|. | [
"Undo",
"the",
"most",
"recent",
"GetNext",
"call",
"that",
"returned",
"|log_entry|",
"."
] | [
"\"\"\"Undo the most recent GetNext call that returned |log_entry|.\n\n Simulates going backwards in the log file by storing |log_entry| and\n returning that on the next GetNext call.\n\n Args:\n entry: the returned entry from the GetNext that we wish to \"undo\"\n Raises:\n ReplayException: i... | [
{
"param": "self",
"type": null
},
{
"param": "log_entry",
"type": null
}
] | {
"returns": [],
"raises": [
{
"docstring": "if this is called multiple times in a row, which will\ncause the object to lose the previously undone entry.",
"docstring_tokens": [
"if",
"this",
"is",
"called",
"multiple",
"times",
"in",
"... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | GetNext | <not_specific> | def GetNext(self):
"""Get the next client command or response in the log.
Returns:
LogEntry object representing the next command or response in the log.
Returns None if at the end of the log
"""
header = self._GetNextClientHeaderLine()
if not header:
return None
payload_stri... | Get the next client command or response in the log.
Returns:
LogEntry object representing the next command or response in the log.
Returns None if at the end of the log
| Get the next client command or response in the log. | [
"Get",
"the",
"next",
"client",
"command",
"or",
"response",
"in",
"the",
"log",
"."
] | def GetNext(self):
header = self._GetNextClientHeaderLine()
if not header:
return None
payload_string = self._GetPayloadString(header)
return LogEntry(header, payload_string) | [
"def",
"GetNext",
"(",
"self",
")",
":",
"header",
"=",
"self",
".",
"_GetNextClientHeaderLine",
"(",
")",
"if",
"not",
"header",
":",
"return",
"None",
"payload_string",
"=",
"self",
".",
"_GetPayloadString",
"(",
"header",
")",
"return",
"LogEntry",
"(",
... | Get the next client command or response in the log. | [
"Get",
"the",
"next",
"client",
"command",
"or",
"response",
"in",
"the",
"log",
"."
] | [
"\"\"\"Get the next client command or response in the log.\n\n Returns:\n LogEntry object representing the next command or response in the log.\n Returns None if at the end of the log\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "LogEntry object representing the next command or response in the log.\nReturns None if at the end of the log",
"docstring_tokens": [
"LogEntry",
"object",
"representing",
"the",
"next",
"command",
"or",
"res... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _GetNextClientHeaderLine | <not_specific> | def _GetNextClientHeaderLine(self):
"""Get the next line that is a command or response for the client.
Returns:
String containing the header of the next client command/response, or
an empty string if we're at the end of the log file.
"""
while True:
next_line = self._log_file.readli... | Get the next line that is a command or response for the client.
Returns:
String containing the header of the next client command/response, or
an empty string if we're at the end of the log file.
| Get the next line that is a command or response for the client. | [
"Get",
"the",
"next",
"line",
"that",
"is",
"a",
"command",
"or",
"response",
"for",
"the",
"client",
"."
] | def _GetNextClientHeaderLine(self):
while True:
next_line = self._log_file.readline()
if not next_line:
return None
if re.match(self._CLIENT_PREAMBLE_REGEX, next_line):
return next_line
if re.match(self._CLIENT_PREAMBLE_REGEX_READABLE, next_line):
next_line = next_l... | [
"def",
"_GetNextClientHeaderLine",
"(",
"self",
")",
":",
"while",
"True",
":",
"next_line",
"=",
"self",
".",
"_log_file",
".",
"readline",
"(",
")",
"if",
"not",
"next_line",
":",
"return",
"None",
"if",
"re",
".",
"match",
"(",
"self",
".",
"_CLIENT_P... | Get the next line that is a command or response for the client. | [
"Get",
"the",
"next",
"line",
"that",
"is",
"a",
"command",
"or",
"response",
"for",
"the",
"client",
"."
] | [
"\"\"\"Get the next line that is a command or response for the client.\n\n Returns:\n String containing the header of the next client command/response, or\n an empty string if we're at the end of the log file.\n \"\"\"",
"# empty string indicates end of the log file.",
"#Readable timestamp con... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "String containing the header of the next client command/response, or\nan empty string if we're at the end of the log file.",
"docstring_tokens": [
"String",
"containing",
"the",
"header",
"of",
"the",
"next",
... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _GetPayloadString | <not_specific> | def _GetPayloadString(self, header_line):
"""Gets the payload for the current command in self._logfile.
Parses the given header line, along with any additional lines as
applicable, to get a complete JSON payload object from the current
command in the log file. Note that the payload can be JSON, and err... | Gets the payload for the current command in self._logfile.
Parses the given header line, along with any additional lines as
applicable, to get a complete JSON payload object from the current
command in the log file. Note that the payload can be JSON, and error
(just a string), or something else like an... | Gets the payload for the current command in self._logfile.
Parses the given header line, along with any additional lines as
applicable, to get a complete JSON payload object from the current
command in the log file. Note that the payload can be JSON, and error
(just a string), or something else like an int or a boolean... | [
"Gets",
"the",
"payload",
"for",
"the",
"current",
"command",
"in",
"self",
".",
"_logfile",
".",
"Parses",
"the",
"given",
"header",
"line",
"along",
"with",
"any",
"additional",
"lines",
"as",
"applicable",
"to",
"get",
"a",
"complete",
"JSON",
"payload",
... | def _GetPayloadString(self, header_line):
min_header = 5
header_segments = header_line.split()
if len(header_segments) < min_header:
return None
payload = " ".join(header_segments[min_header-1:])
opening_char = header_segments[min_header-1]
if opening_char == "{":
closing_char = "}"
... | [
"def",
"_GetPayloadString",
"(",
"self",
",",
"header_line",
")",
":",
"min_header",
"=",
"5",
"header_segments",
"=",
"header_line",
".",
"split",
"(",
")",
"if",
"len",
"(",
"header_segments",
")",
"<",
"min_header",
":",
"return",
"None",
"payload",
"=",
... | Gets the payload for the current command in self._logfile. | [
"Gets",
"the",
"payload",
"for",
"the",
"current",
"command",
"in",
"self",
".",
"_logfile",
"."
] | [
"\"\"\"Gets the payload for the current command in self._logfile.\n\n Parses the given header line, along with any additional lines as\n applicable, to get a complete JSON payload object from the current\n command in the log file. Note that the payload can be JSON, and error\n (just a string), or someth... | [
{
"param": "self",
"type": null
},
{
"param": "header_line",
"type": null
}
] | {
"returns": [
{
"docstring": "payload of the command as a string",
"docstring_tokens": [
"payload",
"of",
"the",
"command",
"as",
"a",
"string"
],
"type": null
}
],
"raises": [
{
"docstring": "if the JSON appears to... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | NextCommand | <not_specific> | def NextCommand(self, previous_response):
"""Get the next command in the log file.
Gets start of next command, returning the command and response,
ready to be executed directly in the new session.
Args:
previous_response: the response payload from running the previous command
outputted b... | Get the next command in the log file.
Gets start of next command, returning the command and response,
ready to be executed directly in the new session.
Args:
previous_response: the response payload from running the previous command
outputted by this function; None if this is the first comman... | Get the next command in the log file.
Gets start of next command, returning the command and response,
ready to be executed directly in the new session. | [
"Get",
"the",
"next",
"command",
"in",
"the",
"log",
"file",
".",
"Gets",
"start",
"of",
"next",
"command",
"returning",
"the",
"command",
"and",
"response",
"ready",
"to",
"be",
"executed",
"directly",
"in",
"the",
"new",
"session",
"."
] | def NextCommand(self, previous_response):
if previous_response:
self._IngestRealResponse(previous_response)
command = self._parser.GetNext()
if not command:
return None
if not command.IsCommand():
raise ReplayException("Command and Response unexpectedly out of order.")
if command... | [
"def",
"NextCommand",
"(",
"self",
",",
"previous_response",
")",
":",
"if",
"previous_response",
":",
"self",
".",
"_IngestRealResponse",
"(",
"previous_response",
")",
"command",
"=",
"self",
".",
"_parser",
".",
"GetNext",
"(",
")",
"if",
"not",
"command",
... | Get the next command in the log file. | [
"Get",
"the",
"next",
"command",
"in",
"the",
"log",
"file",
"."
] | [
"\"\"\"Get the next command in the log file.\n\n Gets start of next command, returning the command and response,\n ready to be executed directly in the new session.\n\n Args:\n previous_response: the response payload from running the previous command\n outputted by this function; None if this i... | [
{
"param": "self",
"type": null
},
{
"param": "previous_response",
"type": null
}
] | {
"returns": [
{
"docstring": "None if there are no remaining logs.\nOtherwise, |command|, a LogEntry object with the following fields:\nname: command name\ntype: either LogEntry.COMMAND or LogEntry.RESPONSE\npayload: parameters passed with the command\nsession_id: intended session ID for the command, or \"... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _IngestRealResponse | null | def _IngestRealResponse(self, response):
"""Process the actual response from the previously issued command.
Ingests the given response that came from calling the last command on
the running ChromeDriver replay instance. This is the step where the
session and element IDs are matched between |response| a... | Process the actual response from the previously issued command.
Ingests the given response that came from calling the last command on
the running ChromeDriver replay instance. This is the step where the
session and element IDs are matched between |response| and the logged
response.
Args:
res... | Process the actual response from the previously issued command.
Ingests the given response that came from calling the last command on
the running ChromeDriver replay instance. This is the step where the
session and element IDs are matched between |response| and the logged
response. | [
"Process",
"the",
"actual",
"response",
"from",
"the",
"previously",
"issued",
"command",
".",
"Ingests",
"the",
"given",
"response",
"that",
"came",
"from",
"calling",
"the",
"last",
"command",
"on",
"the",
"running",
"ChromeDriver",
"replay",
"instance",
".",
... | def _IngestRealResponse(self, response):
if "value" in response and self._staged_logged_ids:
real_ids = _GetAnyElementIds(response["value"])
if real_ids and self._staged_logged_ids:
for id_old, id_new in zip(self._staged_logged_ids, real_ids):
self._id_map[id_old] = id_new
self... | [
"def",
"_IngestRealResponse",
"(",
"self",
",",
"response",
")",
":",
"if",
"\"value\"",
"in",
"response",
"and",
"self",
".",
"_staged_logged_ids",
":",
"real_ids",
"=",
"_GetAnyElementIds",
"(",
"response",
"[",
"\"value\"",
"]",
")",
"if",
"real_ids",
"and"... | Process the actual response from the previously issued command. | [
"Process",
"the",
"actual",
"response",
"from",
"the",
"previously",
"issued",
"command",
"."
] | [
"\"\"\"Process the actual response from the previously issued command.\n\n Ingests the given response that came from calling the last command on\n the running ChromeDriver replay instance. This is the step where the\n session and element IDs are matched between |response| and the logged\n response.\n\n ... | [
{
"param": "self",
"type": null
},
{
"param": "response",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "response",
"type": null,
"docstring": "Python dict of the real resp... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _IngestLoggedResponse | null | def _IngestLoggedResponse(self, response):
"""Reads the response at the current position in the log file.
Also matches IDs between the logged and new sessions.
Args:
response: the response from the log (from _parser.GetNext)
"""
self._last_response = response # store for testing purposes
... | Reads the response at the current position in the log file.
Also matches IDs between the logged and new sessions.
Args:
response: the response from the log (from _parser.GetNext)
| Reads the response at the current position in the log file.
Also matches IDs between the logged and new sessions. | [
"Reads",
"the",
"response",
"at",
"the",
"current",
"position",
"in",
"the",
"log",
"file",
".",
"Also",
"matches",
"IDs",
"between",
"the",
"logged",
"and",
"new",
"sessions",
"."
] | def _IngestLoggedResponse(self, response):
self._last_response = response
self._staged_logged_ids = response.payload.GetAnyElementIds()
if response.name == "InitSession":
self._staged_logged_session_id = response.session_id | [
"def",
"_IngestLoggedResponse",
"(",
"self",
",",
"response",
")",
":",
"self",
".",
"_last_response",
"=",
"response",
"self",
".",
"_staged_logged_ids",
"=",
"response",
".",
"payload",
".",
"GetAnyElementIds",
"(",
")",
"if",
"response",
".",
"name",
"==",
... | Reads the response at the current position in the log file. | [
"Reads",
"the",
"response",
"at",
"the",
"current",
"position",
"in",
"the",
"log",
"file",
"."
] | [
"\"\"\"Reads the response at the current position in the log file.\n\n Also matches IDs between the logged and new sessions.\n\n Args:\n response: the response from the log (from _parser.GetNext)\n \"\"\"",
"# store for testing purposes"
] | [
{
"param": "self",
"type": null
},
{
"param": "response",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "response",
"type": null,
"docstring": "the response from the log (f... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _HandleGetSessions | <not_specific> | def _HandleGetSessions(self, first_command):
"""Special case handler for the GetSessions command.
Since it is dispatched to each session thread, GetSessions doesn't guarantee
command-response-command-response ordering in the log. This happens with
getSessions, which is broadcast to and logged by each o... | Special case handler for the GetSessions command.
Since it is dispatched to each session thread, GetSessions doesn't guarantee
command-response-command-response ordering in the log. This happens with
getSessions, which is broadcast to and logged by each of the active sessions
in the ChromeDriver instan... | Special case handler for the GetSessions command.
Since it is dispatched to each session thread, GetSessions doesn't guarantee
command-response-command-response ordering in the log. This happens with
getSessions, which is broadcast to and logged by each of the active sessions
in the ChromeDriver instance. This simply c... | [
"Special",
"case",
"handler",
"for",
"the",
"GetSessions",
"command",
".",
"Since",
"it",
"is",
"dispatched",
"to",
"each",
"session",
"thread",
"GetSessions",
"doesn",
"'",
"t",
"guarantee",
"command",
"-",
"response",
"-",
"command",
"-",
"response",
"orderi... | def _HandleGetSessions(self, first_command):
command_response_pairs = collections.defaultdict(dict)
command_response_pairs[first_command.session_id] = (
{"command": first_command})
while True:
next_entry = self._parser.GetNext()
if not next_entry:
self._parser.UndoGetNext(next_en... | [
"def",
"_HandleGetSessions",
"(",
"self",
",",
"first_command",
")",
":",
"command_response_pairs",
"=",
"collections",
".",
"defaultdict",
"(",
"dict",
")",
"command_response_pairs",
"[",
"first_command",
".",
"session_id",
"]",
"=",
"(",
"{",
"\"command\"",
":",... | Special case handler for the GetSessions command. | [
"Special",
"case",
"handler",
"for",
"the",
"GetSessions",
"command",
"."
] | [
"\"\"\"Special case handler for the GetSessions command.\n\n Since it is dispatched to each session thread, GetSessions doesn't guarantee\n command-response-command-response ordering in the log. This happens with\n getSessions, which is broadcast to and logged by each of the active sessions\n in the Chr... | [
{
"param": "self",
"type": null
},
{
"param": "first_command",
"type": null
}
] | {
"returns": [
{
"docstring": "the command that triggered all of the calls absorbed by\nthis function",
"docstring_tokens": [
"the",
"command",
"that",
"triggered",
"all",
"of",
"the",
"calls",
"absorbed",
"by",
"t... |
687742bdc6b514a510c19688aa0cd473c50a22ac | sunlongbo/chromium | chrome/test/chromedriver/log_replay/client_replay.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _GetCommandLineOptions | <not_specific> | def _GetCommandLineOptions():
"""Get, parse, and error check command line options for this file."""
usage = "usage: %prog <chromedriver binary> <input log path> [options]"
parser = optparse.OptionParser(usage=usage)
parser.add_option(
"", "--output-log-path",
help="Output verbose server logs to this... | Get, parse, and error check command line options for this file. | Get, parse, and error check command line options for this file. | [
"Get",
"parse",
"and",
"error",
"check",
"command",
"line",
"options",
"for",
"this",
"file",
"."
] | def _GetCommandLineOptions():
usage = "usage: %prog <chromedriver binary> <input log path> [options]"
parser = optparse.OptionParser(usage=usage)
parser.add_option(
"", "--output-log-path",
help="Output verbose server logs to this file")
parser.add_option(
"", "--chrome", help="Path to a build... | [
"def",
"_GetCommandLineOptions",
"(",
")",
":",
"usage",
"=",
"\"usage: %prog <chromedriver binary> <input log path> [options]\"",
"parser",
"=",
"optparse",
".",
"OptionParser",
"(",
"usage",
"=",
"usage",
")",
"parser",
".",
"add_option",
"(",
"\"\"",
",",
"\"--outp... | Get, parse, and error check command line options for this file. | [
"Get",
"parse",
"and",
"error",
"check",
"command",
"line",
"options",
"for",
"this",
"file",
"."
] | [
"\"\"\"Get, parse, and error check command line options for this file.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
37b515ba35394d98bea1a7599eb7c6af85d805bd | sunlongbo/chromium | components/safe_browsing/content/resources/gen_file_type_proto.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | FilterPbForPlatform | <not_specific> | def FilterPbForPlatform(full_pb, platform_type):
""" Return a filtered protobuf for this platform_type """
assert type(platform_type) is int, "Bad platform_type type"
new_pb = download_file_types_pb2.DownloadFileTypeConfig()
new_pb.CopyFrom(full_pb)
# Ensure there's only one platform_settings for ... | Return a filtered protobuf for this platform_type | Return a filtered protobuf for this platform_type | [
"Return",
"a",
"filtered",
"protobuf",
"for",
"this",
"platform_type"
] | def FilterPbForPlatform(full_pb, platform_type):
assert type(platform_type) is int, "Bad platform_type type"
new_pb = download_file_types_pb2.DownloadFileTypeConfig()
new_pb.CopyFrom(full_pb)
PrunePlatformSettings(new_pb.default_file_type, None, platform_type)
invalid_char_re = re.compile('[^a-z0-9_... | [
"def",
"FilterPbForPlatform",
"(",
"full_pb",
",",
"platform_type",
")",
":",
"assert",
"type",
"(",
"platform_type",
")",
"is",
"int",
",",
"\"Bad platform_type type\"",
"new_pb",
"=",
"download_file_types_pb2",
".",
"DownloadFileTypeConfig",
"(",
")",
"new_pb",
".... | Return a filtered protobuf for this platform_type | [
"Return",
"a",
"filtered",
"protobuf",
"for",
"this",
"platform_type"
] | [
"\"\"\" Return a filtered protobuf for this platform_type \"\"\"",
"# Ensure there's only one platform_settings for the default.",
"# This can be extended if we want to match weird extensions.",
"# Just no dots, non-UTF8, or uppercase chars.",
"# Filter platform_settings for each type.",
"# Modify file_ty... | [
{
"param": "full_pb",
"type": null
},
{
"param": "platform_type",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "full_pb",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "platform_type",
"type": null,
"docstring": null,
"docstrin... |
37b515ba35394d98bea1a7599eb7c6af85d805bd | sunlongbo/chromium | components/safe_browsing/content/resources/gen_file_type_proto.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | FilterForPlatformAndWrite | null | def FilterForPlatformAndWrite(full_pb, platform_type, outfile):
""" Filter and write out a file for this platform """
# Filter it
filtered_pb = FilterPbForPlatform(full_pb, platform_type)
# Serialize it
binary_pb_str = filtered_pb.SerializeToString()
# Write it to disk
open(outfile, 'wb').wr... | Filter and write out a file for this platform | Filter and write out a file for this platform | [
"Filter",
"and",
"write",
"out",
"a",
"file",
"for",
"this",
"platform"
] | def FilterForPlatformAndWrite(full_pb, platform_type, outfile):
filtered_pb = FilterPbForPlatform(full_pb, platform_type)
binary_pb_str = filtered_pb.SerializeToString()
open(outfile, 'wb').write(binary_pb_str) | [
"def",
"FilterForPlatformAndWrite",
"(",
"full_pb",
",",
"platform_type",
",",
"outfile",
")",
":",
"filtered_pb",
"=",
"FilterPbForPlatform",
"(",
"full_pb",
",",
"platform_type",
")",
"binary_pb_str",
"=",
"filtered_pb",
".",
"SerializeToString",
"(",
")",
"open",... | Filter and write out a file for this platform | [
"Filter",
"and",
"write",
"out",
"a",
"file",
"for",
"this",
"platform"
] | [
"\"\"\" Filter and write out a file for this platform \"\"\"",
"# Filter it",
"# Serialize it",
"# Write it to disk"
] | [
{
"param": "full_pb",
"type": null
},
{
"param": "platform_type",
"type": null
},
{
"param": "outfile",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "full_pb",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "platform_type",
"type": null,
"docstring": null,
"docstrin... |
37b515ba35394d98bea1a7599eb7c6af85d805bd | sunlongbo/chromium | components/safe_browsing/content/resources/gen_file_type_proto.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | MakeSubDirs | null | def MakeSubDirs(outfile):
""" Make the subdirectories needed to create file |outfile| """
dirname = os.path.dirname(outfile)
if not os.path.exists(dirname):
os.makedirs(dirname) | Make the subdirectories needed to create file |outfile| | Make the subdirectories needed to create file |outfile| | [
"Make",
"the",
"subdirectories",
"needed",
"to",
"create",
"file",
"|outfile|"
] | def MakeSubDirs(outfile):
dirname = os.path.dirname(outfile)
if not os.path.exists(dirname):
os.makedirs(dirname) | [
"def",
"MakeSubDirs",
"(",
"outfile",
")",
":",
"dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"outfile",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dirname",
")",
":",
"os",
".",
"makedirs",
"(",
"dirname",
")"
] | Make the subdirectories needed to create file |outfile| | [
"Make",
"the",
"subdirectories",
"needed",
"to",
"create",
"file",
"|outfile|"
] | [
"\"\"\" Make the subdirectories needed to create file |outfile| \"\"\""
] | [
{
"param": "outfile",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "outfile",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
37b515ba35394d98bea1a7599eb7c6af85d805bd | sunlongbo/chromium | components/safe_browsing/content/resources/gen_file_type_proto.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ValidatePb | null | def ValidatePb(self, opts, pb):
""" Validate the basic values of the protobuf. The
file_type_policies_unittest.cc will also validate it by platform,
but this will catch errors earlier.
"""
assert pb.version_id > 0
assert pb.sampled_ping_probability >= 0.0
assert pb.s... | Validate the basic values of the protobuf. The
file_type_policies_unittest.cc will also validate it by platform,
but this will catch errors earlier.
| Validate the basic values of the protobuf. The
file_type_policies_unittest.cc will also validate it by platform,
but this will catch errors earlier. | [
"Validate",
"the",
"basic",
"values",
"of",
"the",
"protobuf",
".",
"The",
"file_type_policies_unittest",
".",
"cc",
"will",
"also",
"validate",
"it",
"by",
"platform",
"but",
"this",
"will",
"catch",
"errors",
"earlier",
"."
] | def ValidatePb(self, opts, pb):
assert pb.version_id > 0
assert pb.sampled_ping_probability >= 0.0
assert pb.sampled_ping_probability <= 1.0
assert len(pb.default_file_type.platform_settings) >= 1
assert len(pb.file_types) > 1 | [
"def",
"ValidatePb",
"(",
"self",
",",
"opts",
",",
"pb",
")",
":",
"assert",
"pb",
".",
"version_id",
">",
"0",
"assert",
"pb",
".",
"sampled_ping_probability",
">=",
"0.0",
"assert",
"pb",
".",
"sampled_ping_probability",
"<=",
"1.0",
"assert",
"len",
"(... | Validate the basic values of the protobuf. | [
"Validate",
"the",
"basic",
"values",
"of",
"the",
"protobuf",
"."
] | [
"\"\"\" Validate the basic values of the protobuf. The\n file_type_policies_unittest.cc will also validate it by platform,\n but this will catch errors earlier.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "opts",
"type": null
},
{
"param": "pb",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "opts",
"type": null,
"docstring": null,
"docstring_tokens": [... |
37b515ba35394d98bea1a7599eb7c6af85d805bd | sunlongbo/chromium | components/safe_browsing/content/resources/gen_file_type_proto.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ProcessPb | null | def ProcessPb(self, opts, pb):
""" Generate one or more binary protos using the parsed proto. """
if opts.type is not None:
# Just one platform type
platform_enum = PlatformTypes()[opts.type]
outfile = os.path.join(opts.outdir, opts.outbasename)
FilterForP... | Generate one or more binary protos using the parsed proto. | Generate one or more binary protos using the parsed proto. | [
"Generate",
"one",
"or",
"more",
"binary",
"protos",
"using",
"the",
"parsed",
"proto",
"."
] | def ProcessPb(self, opts, pb):
if opts.type is not None:
platform_enum = PlatformTypes()[opts.type]
outfile = os.path.join(opts.outdir, opts.outbasename)
FilterForPlatformAndWrite(pb, platform_enum, outfile)
else:
for platform_type, platform_enum in Platfo... | [
"def",
"ProcessPb",
"(",
"self",
",",
"opts",
",",
"pb",
")",
":",
"if",
"opts",
".",
"type",
"is",
"not",
"None",
":",
"platform_enum",
"=",
"PlatformTypes",
"(",
")",
"[",
"opts",
".",
"type",
"]",
"outfile",
"=",
"os",
".",
"path",
".",
"join",
... | Generate one or more binary protos using the parsed proto. | [
"Generate",
"one",
"or",
"more",
"binary",
"protos",
"using",
"the",
"parsed",
"proto",
"."
] | [
"\"\"\" Generate one or more binary protos using the parsed proto. \"\"\"",
"# Just one platform type",
"# Make a separate file for each platform",
"# e.g. .../all/77/chromeos/download_file_types.pb"
] | [
{
"param": "self",
"type": null
},
{
"param": "opts",
"type": null
},
{
"param": "pb",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "opts",
"type": null,
"docstring": null,
"docstring_tokens": [... |
f28b6d2316bd2fa942ac2bdcc2bdb8e69f36bc47 | sunlongbo/chromium | testing/xvfb_unittest.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | launch_process | <not_specific> | def launch_process(args):
"""Launches a sub process to run through xvfb.py."""
return subprocess.Popen(
[XVFB, XVFB_TEST_SCRIPT] + args, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, env=os.environ.copy()) | Launches a sub process to run through xvfb.py. | Launches a sub process to run through xvfb.py. | [
"Launches",
"a",
"sub",
"process",
"to",
"run",
"through",
"xvfb",
".",
"py",
"."
] | def launch_process(args):
return subprocess.Popen(
[XVFB, XVFB_TEST_SCRIPT] + args, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, env=os.environ.copy()) | [
"def",
"launch_process",
"(",
"args",
")",
":",
"return",
"subprocess",
".",
"Popen",
"(",
"[",
"XVFB",
",",
"XVFB_TEST_SCRIPT",
"]",
"+",
"args",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
",",
"env",... | Launches a sub process to run through xvfb.py. | [
"Launches",
"a",
"sub",
"process",
"to",
"run",
"through",
"xvfb",
".",
"py",
"."
] | [
"\"\"\"Launches a sub process to run through xvfb.py.\"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f28b6d2316bd2fa942ac2bdcc2bdb8e69f36bc47 | sunlongbo/chromium | testing/xvfb_unittest.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | read_subprocess_message | <not_specific> | def read_subprocess_message(proc, starts_with):
"""Finds the value after first line prefix condition."""
for line in proc.stdout:
if line.startswith(starts_with):
return line.rstrip().replace(starts_with, '') | Finds the value after first line prefix condition. | Finds the value after first line prefix condition. | [
"Finds",
"the",
"value",
"after",
"first",
"line",
"prefix",
"condition",
"."
] | def read_subprocess_message(proc, starts_with):
for line in proc.stdout:
if line.startswith(starts_with):
return line.rstrip().replace(starts_with, '') | [
"def",
"read_subprocess_message",
"(",
"proc",
",",
"starts_with",
")",
":",
"for",
"line",
"in",
"proc",
".",
"stdout",
":",
"if",
"line",
".",
"startswith",
"(",
"starts_with",
")",
":",
"return",
"line",
".",
"rstrip",
"(",
")",
".",
"replace",
"(",
... | Finds the value after first line prefix condition. | [
"Finds",
"the",
"value",
"after",
"first",
"line",
"prefix",
"condition",
"."
] | [
"\"\"\"Finds the value after first line prefix condition.\"\"\""
] | [
{
"param": "proc",
"type": null
},
{
"param": "starts_with",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "proc",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "starts_with",
"type": null,
"docstring": null,
"docstring_tok... |
f28b6d2316bd2fa942ac2bdcc2bdb8e69f36bc47 | sunlongbo/chromium | testing/xvfb_unittest.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | send_signal | null | def send_signal(proc, sig, sleep_time=0.3):
"""Sends a signal to subprocess."""
time.sleep(sleep_time) # gives process time to launch.
os.kill(proc.pid, sig)
proc.wait() | Sends a signal to subprocess. | Sends a signal to subprocess. | [
"Sends",
"a",
"signal",
"to",
"subprocess",
"."
] | def send_signal(proc, sig, sleep_time=0.3):
time.sleep(sleep_time)
os.kill(proc.pid, sig)
proc.wait() | [
"def",
"send_signal",
"(",
"proc",
",",
"sig",
",",
"sleep_time",
"=",
"0.3",
")",
":",
"time",
".",
"sleep",
"(",
"sleep_time",
")",
"os",
".",
"kill",
"(",
"proc",
".",
"pid",
",",
"sig",
")",
"proc",
".",
"wait",
"(",
")"
] | Sends a signal to subprocess. | [
"Sends",
"a",
"signal",
"to",
"subprocess",
"."
] | [
"\"\"\"Sends a signal to subprocess.\"\"\"",
"# gives process time to launch."
] | [
{
"param": "proc",
"type": null
},
{
"param": "sig",
"type": null
},
{
"param": "sleep_time",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "proc",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sig",
"type": null,
"docstring": null,
"docstring_tokens": []... |
6aca09c53e87175b17f069b79b64ff688cb90299 | sunlongbo/chromium | tools/web_dev_style/html_checker.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | RunChecks | <not_specific> | def RunChecks(self):
"""Check for violations of the Chromium web development style guide. See
https://chromium.googlesource.com/chromium/src/+/main/styleguide/web/web.md
"""
results = []
affected_files = self.input_api.AffectedFiles(file_filter=self.file_filter,
... | Check for violations of the Chromium web development style guide. See
https://chromium.googlesource.com/chromium/src/+/main/styleguide/web/web.md
| Check for violations of the Chromium web development style guide. | [
"Check",
"for",
"violations",
"of",
"the",
"Chromium",
"web",
"development",
"style",
"guide",
"."
] | def RunChecks(self):
results = []
affected_files = self.input_api.AffectedFiles(file_filter=self.file_filter,
include_deletes=False)
for f in affected_files:
if not f.LocalPath().endswith('.html'):
continue
errors = []
for line_numb... | [
"def",
"RunChecks",
"(",
"self",
")",
":",
"results",
"=",
"[",
"]",
"affected_files",
"=",
"self",
".",
"input_api",
".",
"AffectedFiles",
"(",
"file_filter",
"=",
"self",
".",
"file_filter",
",",
"include_deletes",
"=",
"False",
")",
"for",
"f",
"in",
... | Check for violations of the Chromium web development style guide. | [
"Check",
"for",
"violations",
"of",
"the",
"Chromium",
"web",
"development",
"style",
"guide",
"."
] | [
"\"\"\"Check for violations of the Chromium web development style guide. See\n https://chromium.googlesource.com/chromium/src/+/main/styleguide/web/web.md\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6ae5f43d999176a223c12cad3cb161168e929dcf | sunlongbo/chromium | chrome/test/mini_installer/create_zip.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ArchiveDirectory | null | def ArchiveDirectory(path, zipf):
"""Archive an entire directory and subdirectories.
This will skip files that have an extension in BLOCKLIST.
Args:
path: The path to the current directory.
zipf: A handle to a ZipFile instance.
"""
logging.debug('Archiving %s', path)
for c_path... | Archive an entire directory and subdirectories.
This will skip files that have an extension in BLOCKLIST.
Args:
path: The path to the current directory.
zipf: A handle to a ZipFile instance.
| Archive an entire directory and subdirectories.
This will skip files that have an extension in BLOCKLIST. | [
"Archive",
"an",
"entire",
"directory",
"and",
"subdirectories",
".",
"This",
"will",
"skip",
"files",
"that",
"have",
"an",
"extension",
"in",
"BLOCKLIST",
"."
] | def ArchiveDirectory(path, zipf):
logging.debug('Archiving %s', path)
for c_path in [os.path.join(path, name) for name in os.listdir(path)]:
if os.path.isfile(c_path):
if os.path.splitext(c_path)[-1] in BLOCKLIST:
continue
logging.debug('Adding %s', os.path.relpat... | [
"def",
"ArchiveDirectory",
"(",
"path",
",",
"zipf",
")",
":",
"logging",
".",
"debug",
"(",
"'Archiving %s'",
",",
"path",
")",
"for",
"c_path",
"in",
"[",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"name",
")",
"for",
"name",
"in",
"os",
"... | Archive an entire directory and subdirectories. | [
"Archive",
"an",
"entire",
"directory",
"and",
"subdirectories",
"."
] | [
"\"\"\"Archive an entire directory and subdirectories.\n\n This will skip files that have an extension in BLOCKLIST.\n\n Args:\n path: The path to the current directory.\n zipf: A handle to a ZipFile instance.\n \"\"\""
] | [
{
"param": "path",
"type": null
},
{
"param": "zipf",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": "The path to the current directory.",
"docstring_tokens": [
"The",
"path",
"to",
"the",
"current",
"directory",
"."
],
"defa... |
07ccb5ce40ccffeda0a143aeb0cd087baca46814 | sunlongbo/chromium | tools/code_coverage/run_fuzz_target.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _PrepareCorpus | <not_specific> | def _PrepareCorpus(fuzzer_name, output_dir):
"""Prepares the corpus to run fuzzer target.
If a corpus for bots is available, use it directly, otherwise, creates a
dummy corpus.
Args:
fuzzer_name (str): Name of the fuzzer to create corpus for.
output_dir (str): An output directory to store artifacts.
... | Prepares the corpus to run fuzzer target.
If a corpus for bots is available, use it directly, otherwise, creates a
dummy corpus.
Args:
fuzzer_name (str): Name of the fuzzer to create corpus for.
output_dir (str): An output directory to store artifacts.
Returns:
A path to the directory of the prep... | Prepares the corpus to run fuzzer target.
If a corpus for bots is available, use it directly, otherwise, creates a
dummy corpus. | [
"Prepares",
"the",
"corpus",
"to",
"run",
"fuzzer",
"target",
".",
"If",
"a",
"corpus",
"for",
"bots",
"is",
"available",
"use",
"it",
"directly",
"otherwise",
"creates",
"a",
"dummy",
"corpus",
"."
] | def _PrepareCorpus(fuzzer_name, output_dir):
corpus_dir = os.path.join(output_dir, fuzzer_name + '_corpus')
_RecreateDir(corpus_dir)
corpus_for_bots = glob.glob(
os.path.join(os.path.abspath(_CORPUS_FOR_BOTS_DIR), fuzzer_name, '*.zip'))
if len(corpus_for_bots) >= 2:
raise RuntimeError(
'Expect... | [
"def",
"_PrepareCorpus",
"(",
"fuzzer_name",
",",
"output_dir",
")",
":",
"corpus_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"output_dir",
",",
"fuzzer_name",
"+",
"'_corpus'",
")",
"_RecreateDir",
"(",
"corpus_dir",
")",
"corpus_for_bots",
"=",
"glob",
... | Prepares the corpus to run fuzzer target. | [
"Prepares",
"the",
"corpus",
"to",
"run",
"fuzzer",
"target",
"."
] | [
"\"\"\"Prepares the corpus to run fuzzer target.\n\n If a corpus for bots is available, use it directly, otherwise, creates a\n dummy corpus.\n\n Args:\n fuzzer_name (str): Name of the fuzzer to create corpus for.\n output_dir (str): An output directory to store artifacts.\n\n Returns:\n A path to the ... | [
{
"param": "fuzzer_name",
"type": null
},
{
"param": "output_dir",
"type": null
}
] | {
"returns": [
{
"docstring": "A path to the directory of the prepared corpus.",
"docstring_tokens": [
"A",
"path",
"to",
"the",
"directory",
"of",
"the",
"prepared",
"corpus",
"."
],
"type": null
}
],
... |
07ccb5ce40ccffeda0a143aeb0cd087baca46814 | sunlongbo/chromium | tools/code_coverage/run_fuzz_target.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _ParseCommandArguments | <not_specific> | def _ParseCommandArguments():
"""Adds and parses relevant arguments for tool comands.
Returns:
A dictionary representing the arguments.
"""
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument(
'-f',
'--fuzzer',
type=str,
required=True,
help='Path to the fuzz targ... | Adds and parses relevant arguments for tool comands.
Returns:
A dictionary representing the arguments.
| Adds and parses relevant arguments for tool comands. | [
"Adds",
"and",
"parses",
"relevant",
"arguments",
"for",
"tool",
"comands",
"."
] | def _ParseCommandArguments():
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument(
'-f',
'--fuzzer',
type=str,
required=True,
help='Path to the fuzz target executable.')
arg_parser.add_argument(
'-o',
'--output-dir',
type=str,
required=True,
h... | [
"def",
"_ParseCommandArguments",
"(",
")",
":",
"arg_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"arg_parser",
".",
"add_argument",
"(",
"'-f'",
",",
"'--fuzzer'",
",",
"type",
"=",
"str",
",",
"required",
"=",
"True",
",",
"help",
"=",
"'Pa... | Adds and parses relevant arguments for tool comands. | [
"Adds",
"and",
"parses",
"relevant",
"arguments",
"for",
"tool",
"comands",
"."
] | [
"\"\"\"Adds and parses relevant arguments for tool comands.\n\n Returns:\n A dictionary representing the arguments.\n \"\"\"",
"# Ignored. Used to comply with isolated script contract, see chromium_tests",
"# and swarming recipe modules for more details.",
"# Ditto."
] | [] | {
"returns": [
{
"docstring": "A dictionary representing the arguments.",
"docstring_tokens": [
"A",
"dictionary",
"representing",
"the",
"arguments",
"."
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"o... |
07d8600187574f246cd7063a1ba8dd501314fea6 | sunlongbo/chromium | tools/json_schema_compiler/js_externs_generator_test.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _GetNamespace | <not_specific> | def _GetNamespace(self, fake_content, filename, is_idl):
"""Returns a namespace object for the given content"""
api_def = (idl_schema.Process(fake_content, filename) if is_idl
else json_parse.Parse(fake_content))
m = model.Model()
return m.AddNamespace(api_def[0], filename) | Returns a namespace object for the given content | Returns a namespace object for the given content | [
"Returns",
"a",
"namespace",
"object",
"for",
"the",
"given",
"content"
] | def _GetNamespace(self, fake_content, filename, is_idl):
api_def = (idl_schema.Process(fake_content, filename) if is_idl
else json_parse.Parse(fake_content))
m = model.Model()
return m.AddNamespace(api_def[0], filename) | [
"def",
"_GetNamespace",
"(",
"self",
",",
"fake_content",
",",
"filename",
",",
"is_idl",
")",
":",
"api_def",
"=",
"(",
"idl_schema",
".",
"Process",
"(",
"fake_content",
",",
"filename",
")",
"if",
"is_idl",
"else",
"json_parse",
".",
"Parse",
"(",
"fake... | Returns a namespace object for the given content | [
"Returns",
"a",
"namespace",
"object",
"for",
"the",
"given",
"content"
] | [
"\"\"\"Returns a namespace object for the given content\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "fake_content",
"type": null
},
{
"param": "filename",
"type": null
},
{
"param": "is_idl",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fake_content",
"type": null,
"docstring": null,
"docstring_to... |
8c527920d65fccee0499b30992bd31835475b87c | sunlongbo/chromium | native_client_sdk/src/build_tools/build_version.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ChromeVersion | <not_specific> | def ChromeVersion():
'''Extract chrome version from src/chrome/VERSION + svn.
Returns:
Chrome version string or trunk + svn rev.
'''
info = FetchCommitPosition()
_, ref, revision = ParseCommitPosition(info.revision)
if ref in ['refs/heads/master', 'refs/heads/main']:
return 'trunk.%s' % revision
... | Extract chrome version from src/chrome/VERSION + svn.
Returns:
Chrome version string or trunk + svn rev.
| Extract chrome version from src/chrome/VERSION + svn. | [
"Extract",
"chrome",
"version",
"from",
"src",
"/",
"chrome",
"/",
"VERSION",
"+",
"svn",
"."
] | def ChromeVersion():
info = FetchCommitPosition()
_, ref, revision = ParseCommitPosition(info.revision)
if ref in ['refs/heads/master', 'refs/heads/main']:
return 'trunk.%s' % revision
return ChromeVersionNoTrunk() | [
"def",
"ChromeVersion",
"(",
")",
":",
"info",
"=",
"FetchCommitPosition",
"(",
")",
"_",
",",
"ref",
",",
"revision",
"=",
"ParseCommitPosition",
"(",
"info",
".",
"revision",
")",
"if",
"ref",
"in",
"[",
"'refs/heads/master'",
",",
"'refs/heads/main'",
"]"... | Extract chrome version from src/chrome/VERSION + svn. | [
"Extract",
"chrome",
"version",
"from",
"src",
"/",
"chrome",
"/",
"VERSION",
"+",
"svn",
"."
] | [
"'''Extract chrome version from src/chrome/VERSION + svn.\n\n Returns:\n Chrome version string or trunk + svn rev.\n '''"
] | [] | {
"returns": [
{
"docstring": "Chrome version string or trunk + svn rev.",
"docstring_tokens": [
"Chrome",
"version",
"string",
"or",
"trunk",
"+",
"svn",
"rev",
"."
],
"type": null
}
],
"raises": [],
"params... |
8c527920d65fccee0499b30992bd31835475b87c | sunlongbo/chromium | native_client_sdk/src/build_tools/build_version.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ChromeRevision | <not_specific> | def ChromeRevision():
'''Extract chrome revision from svn.
Now that the Chrome source-of-truth is git, this will return the
Cr-Commit-Position instead. Fortunately, this value is equal to the SVN
revision if one exists.
Returns:
The Chrome revision as a string. e.g. "12345"
'''
version = Fe... | Extract chrome revision from svn.
Now that the Chrome source-of-truth is git, this will return the
Cr-Commit-Position instead. Fortunately, this value is equal to the SVN
revision if one exists.
Returns:
The Chrome revision as a string. e.g. "12345"
| Extract chrome revision from svn.
Now that the Chrome source-of-truth is git, this will return the
Cr-Commit-Position instead. Fortunately, this value is equal to the SVN
revision if one exists. | [
"Extract",
"chrome",
"revision",
"from",
"svn",
".",
"Now",
"that",
"the",
"Chrome",
"source",
"-",
"of",
"-",
"truth",
"is",
"git",
"this",
"will",
"return",
"the",
"Cr",
"-",
"Commit",
"-",
"Position",
"instead",
".",
"Fortunately",
"this",
"value",
"i... | def ChromeRevision():
version = FetchCommitPosition()
return ParseCommitPosition(version.revision)[2] | [
"def",
"ChromeRevision",
"(",
")",
":",
"version",
"=",
"FetchCommitPosition",
"(",
")",
"return",
"ParseCommitPosition",
"(",
"version",
".",
"revision",
")",
"[",
"2",
"]"
] | Extract chrome revision from svn. | [
"Extract",
"chrome",
"revision",
"from",
"svn",
"."
] | [
"'''Extract chrome revision from svn.\n\n Now that the Chrome source-of-truth is git, this will return the\n Cr-Commit-Position instead. Fortunately, this value is equal to the SVN\n revision if one exists.\n\n Returns:\n The Chrome revision as a string. e.g. \"12345\"\n '''"
] | [] | {
"returns": [
{
"docstring": "The Chrome revision as a string. e.g.",
"docstring_tokens": [
"The",
"Chrome",
"revision",
"as",
"a",
"string",
".",
"e",
".",
"g",
"."
],
"type": null
}
],
"raise... |
8c527920d65fccee0499b30992bd31835475b87c | sunlongbo/chromium | native_client_sdk/src/build_tools/build_version.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ChromeCommitPosition | <not_specific> | def ChromeCommitPosition():
'''Return the full git sha and commit position.
Returns:
A value like:
0178d4831bd36b5fb9ff477f03dc43b11626a6dc-refs/heads/main@{#292238}
'''
return FetchCommitPosition().revision | Return the full git sha and commit position.
Returns:
A value like:
0178d4831bd36b5fb9ff477f03dc43b11626a6dc-refs/heads/main@{#292238}
| Return the full git sha and commit position. | [
"Return",
"the",
"full",
"git",
"sha",
"and",
"commit",
"position",
"."
] | def ChromeCommitPosition():
return FetchCommitPosition().revision | [
"def",
"ChromeCommitPosition",
"(",
")",
":",
"return",
"FetchCommitPosition",
"(",
")",
".",
"revision"
] | Return the full git sha and commit position. | [
"Return",
"the",
"full",
"git",
"sha",
"and",
"commit",
"position",
"."
] | [
"'''Return the full git sha and commit position.\n\n Returns:\n A value like:\n 0178d4831bd36b5fb9ff477f03dc43b11626a6dc-refs/heads/main@{#292238}\n '''"
] | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8c527920d65fccee0499b30992bd31835475b87c | sunlongbo/chromium | native_client_sdk/src/build_tools/build_version.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | NaClRevision | <not_specific> | def NaClRevision():
'''Extract NaCl revision from svn.
Returns:
The NaCl revision as a string. e.g. "12345"
'''
nacl_dir = os.path.join(SRC_DIR, 'native_client')
return lastchange.FetchVersionInfo(nacl_dir).revision | Extract NaCl revision from svn.
Returns:
The NaCl revision as a string. e.g. "12345"
| Extract NaCl revision from svn. | [
"Extract",
"NaCl",
"revision",
"from",
"svn",
"."
] | def NaClRevision():
nacl_dir = os.path.join(SRC_DIR, 'native_client')
return lastchange.FetchVersionInfo(nacl_dir).revision | [
"def",
"NaClRevision",
"(",
")",
":",
"nacl_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"SRC_DIR",
",",
"'native_client'",
")",
"return",
"lastchange",
".",
"FetchVersionInfo",
"(",
"nacl_dir",
")",
".",
"revision"
] | Extract NaCl revision from svn. | [
"Extract",
"NaCl",
"revision",
"from",
"svn",
"."
] | [
"'''Extract NaCl revision from svn.\n\n Returns:\n The NaCl revision as a string. e.g. \"12345\"\n '''"
] | [] | {
"returns": [
{
"docstring": "The NaCl revision as a string. e.g.",
"docstring_tokens": [
"The",
"NaCl",
"revision",
"as",
"a",
"string",
".",
"e",
".",
"g",
"."
],
"type": null
}
],
"raises": ... |
8c527920d65fccee0499b30992bd31835475b87c | sunlongbo/chromium | native_client_sdk/src/build_tools/build_version.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | FetchCommitPosition | <not_specific> | def FetchCommitPosition(directory=None):
'''Return the "commit-position" of the Chromium git repo. This should be
equivalent to the SVN revision if one exists.
'''
SEARCH_LIMIT = 100
for i in xrange(SEARCH_LIMIT):
cmd = ['show', '-s', '--format=%H%n%B', 'HEAD~%d' % i]
proc = lastchange.RunGitCommand(d... | Return the "commit-position" of the Chromium git repo. This should be
equivalent to the SVN revision if one exists.
| Return the "commit-position" of the Chromium git repo. This should be
equivalent to the SVN revision if one exists. | [
"Return",
"the",
"\"",
"commit",
"-",
"position",
"\"",
"of",
"the",
"Chromium",
"git",
"repo",
".",
"This",
"should",
"be",
"equivalent",
"to",
"the",
"SVN",
"revision",
"if",
"one",
"exists",
"."
] | def FetchCommitPosition(directory=None):
SEARCH_LIMIT = 100
for i in xrange(SEARCH_LIMIT):
cmd = ['show', '-s', '--format=%H%n%B', 'HEAD~%d' % i]
proc = lastchange.RunGitCommand(directory, cmd)
if not proc:
break
output = proc.communicate()[0]
if not (proc.returncode == 0 and output):
... | [
"def",
"FetchCommitPosition",
"(",
"directory",
"=",
"None",
")",
":",
"SEARCH_LIMIT",
"=",
"100",
"for",
"i",
"in",
"xrange",
"(",
"SEARCH_LIMIT",
")",
":",
"cmd",
"=",
"[",
"'show'",
",",
"'-s'",
",",
"'--format=%H%n%B'",
",",
"'HEAD~%d'",
"%",
"i",
"]... | Return the "commit-position" of the Chromium git repo. | [
"Return",
"the",
"\"",
"commit",
"-",
"position",
"\"",
"of",
"the",
"Chromium",
"git",
"repo",
"."
] | [
"'''Return the \"commit-position\" of the Chromium git repo. This should be\n equivalent to the SVN revision if one exists.\n '''",
"# First line is the hash."
] | [
{
"param": "directory",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "directory",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8c527920d65fccee0499b30992bd31835475b87c | sunlongbo/chromium | native_client_sdk/src/build_tools/build_version.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ParseCommitPosition | <not_specific> | def ParseCommitPosition(commit_position):
'''Parse a Chrome commit position into its components.
Given a commit position like:
0178d4831bd36b5fb9ff477f03dc43b11626a6dc-refs/heads/main@{#292238}
Returns:
("0178d4831bd36b5fb9ff477f03dc43b11626a6dc", "refs/heads/main", "292238")
'''
m = re.match(r'([0-9... | Parse a Chrome commit position into its components.
Given a commit position like:
0178d4831bd36b5fb9ff477f03dc43b11626a6dc-refs/heads/main@{#292238}
Returns:
("0178d4831bd36b5fb9ff477f03dc43b11626a6dc", "refs/heads/main", "292238")
| Parse a Chrome commit position into its components. | [
"Parse",
"a",
"Chrome",
"commit",
"position",
"into",
"its",
"components",
"."
] | def ParseCommitPosition(commit_position):
m = re.match(r'([0-9a-fA-F]+)(?:-([^@]+)@{#(\d+)})?', commit_position)
if m:
return m.groups()
return None | [
"def",
"ParseCommitPosition",
"(",
"commit_position",
")",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r'([0-9a-fA-F]+)(?:-([^@]+)@{#(\\d+)})?'",
",",
"commit_position",
")",
"if",
"m",
":",
"return",
"m",
".",
"groups",
"(",
")",
"return",
"None"
] | Parse a Chrome commit position into its components. | [
"Parse",
"a",
"Chrome",
"commit",
"position",
"into",
"its",
"components",
"."
] | [
"'''Parse a Chrome commit position into its components.\n\n Given a commit position like:\n 0178d4831bd36b5fb9ff477f03dc43b11626a6dc-refs/heads/main@{#292238}\n Returns:\n (\"0178d4831bd36b5fb9ff477f03dc43b11626a6dc\", \"refs/heads/main\", \"292238\")\n '''"
] | [
{
"param": "commit_position",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "commit_position",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optiona... |
8c6359e9202b652e05880dd19316ca62117cdd32 | sunlongbo/chromium | third_party/blink/tools/blinkpy/web_tests/controllers/web_test_runner.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | start | null | def start(self):
"""This method is called when the object is starting to be used and it is safe
for the object to create state that does not need to be pickled (usually this means
it is called in a child process).
"""
self._host = self._caller.host
self._filesystem = self... | This method is called when the object is starting to be used and it is safe
for the object to create state that does not need to be pickled (usually this means
it is called in a child process).
| This method is called when the object is starting to be used and it is safe
for the object to create state that does not need to be pickled (usually this means
it is called in a child process). | [
"This",
"method",
"is",
"called",
"when",
"the",
"object",
"is",
"starting",
"to",
"be",
"used",
"and",
"it",
"is",
"safe",
"for",
"the",
"object",
"to",
"create",
"state",
"that",
"does",
"not",
"need",
"to",
"be",
"pickled",
"(",
"usually",
"this",
"... | def start(self):
self._host = self._caller.host
self._filesystem = self._host.filesystem
self._port = self._host.port_factory.get(self._options.platform,
self._options)
self._driver = self._port.create_driver(self._worker_number)
s... | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"_host",
"=",
"self",
".",
"_caller",
".",
"host",
"self",
".",
"_filesystem",
"=",
"self",
".",
"_host",
".",
"filesystem",
"self",
".",
"_port",
"=",
"self",
".",
"_host",
".",
"port_factory",
"."... | This method is called when the object is starting to be used and it is safe
for the object to create state that does not need to be pickled (usually this means
it is called in a child process). | [
"This",
"method",
"is",
"called",
"when",
"the",
"object",
"is",
"starting",
"to",
"be",
"used",
"and",
"it",
"is",
"safe",
"for",
"the",
"object",
"to",
"create",
"state",
"that",
"does",
"not",
"need",
"to",
"be",
"pickled",
"(",
"usually",
"this",
"... | [
"\"\"\"This method is called when the object is starting to be used and it is safe\n for the object to create state that does not need to be pickled (usually this means\n it is called in a child process).\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8c6359e9202b652e05880dd19316ca62117cdd32 | sunlongbo/chromium | third_party/blink/tools/blinkpy/web_tests/controllers/web_test_runner.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _shard_every_file | <not_specific> | def _shard_every_file(self, test_inputs, run_singly, virtual_is_unlocked):
"""Returns two lists of shards, each shard containing a single test file.
This mode gets maximal parallelism at the cost of much higher flakiness.
"""
locked_shards = []
unlocked_shards = []
virtu... | Returns two lists of shards, each shard containing a single test file.
This mode gets maximal parallelism at the cost of much higher flakiness.
| Returns two lists of shards, each shard containing a single test file.
This mode gets maximal parallelism at the cost of much higher flakiness. | [
"Returns",
"two",
"lists",
"of",
"shards",
"each",
"shard",
"containing",
"a",
"single",
"test",
"file",
".",
"This",
"mode",
"gets",
"maximal",
"parallelism",
"at",
"the",
"cost",
"of",
"much",
"higher",
"flakiness",
"."
] | def _shard_every_file(self, test_inputs, run_singly, virtual_is_unlocked):
locked_shards = []
unlocked_shards = []
virtual_inputs = []
for test_input in test_inputs:
if test_input.requires_lock:
locked_shards.append(TestShard('.', [test_input]))
el... | [
"def",
"_shard_every_file",
"(",
"self",
",",
"test_inputs",
",",
"run_singly",
",",
"virtual_is_unlocked",
")",
":",
"locked_shards",
"=",
"[",
"]",
"unlocked_shards",
"=",
"[",
"]",
"virtual_inputs",
"=",
"[",
"]",
"for",
"test_input",
"in",
"test_inputs",
"... | Returns two lists of shards, each shard containing a single test file. | [
"Returns",
"two",
"lists",
"of",
"shards",
"each",
"shard",
"containing",
"a",
"single",
"test",
"file",
"."
] | [
"\"\"\"Returns two lists of shards, each shard containing a single test file.\n\n This mode gets maximal parallelism at the cost of much higher flakiness.\n \"\"\"",
"# Note that we use a '.' for the shard name; the name doesn't really",
"# matter, and the only other meaningful value would be the ... | [
{
"param": "self",
"type": null
},
{
"param": "test_inputs",
"type": null
},
{
"param": "run_singly",
"type": null
},
{
"param": "virtual_is_unlocked",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "test_inputs",
"type": null,
"docstring": null,
"docstring_tok... |
8c6359e9202b652e05880dd19316ca62117cdd32 | sunlongbo/chromium | third_party/blink/tools/blinkpy/web_tests/controllers/web_test_runner.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _shard_by_directory | <not_specific> | def _shard_by_directory(self, test_inputs):
"""Returns two lists of shards, each shard containing all the files in a directory.
This is the default mode, and gets as much parallelism as we can while
minimizing flakiness caused by inter-test dependencies.
"""
locked_shards = []
... | Returns two lists of shards, each shard containing all the files in a directory.
This is the default mode, and gets as much parallelism as we can while
minimizing flakiness caused by inter-test dependencies.
| Returns two lists of shards, each shard containing all the files in a directory.
This is the default mode, and gets as much parallelism as we can while
minimizing flakiness caused by inter-test dependencies. | [
"Returns",
"two",
"lists",
"of",
"shards",
"each",
"shard",
"containing",
"all",
"the",
"files",
"in",
"a",
"directory",
".",
"This",
"is",
"the",
"default",
"mode",
"and",
"gets",
"as",
"much",
"parallelism",
"as",
"we",
"can",
"while",
"minimizing",
"fla... | def _shard_by_directory(self, test_inputs):
locked_shards = []
unlocked_shards = []
unlocked_slow_shards = []
tests_by_dir = {}
for test_input in test_inputs:
directory = self._split(test_input.test_name)[0]
tests_by_dir.setdefault(directory, [])
... | [
"def",
"_shard_by_directory",
"(",
"self",
",",
"test_inputs",
")",
":",
"locked_shards",
"=",
"[",
"]",
"unlocked_shards",
"=",
"[",
"]",
"unlocked_slow_shards",
"=",
"[",
"]",
"tests_by_dir",
"=",
"{",
"}",
"for",
"test_input",
"in",
"test_inputs",
":",
"d... | Returns two lists of shards, each shard containing all the files in a directory. | [
"Returns",
"two",
"lists",
"of",
"shards",
"each",
"shard",
"containing",
"all",
"the",
"files",
"in",
"a",
"directory",
"."
] | [
"\"\"\"Returns two lists of shards, each shard containing all the files in a directory.\n\n This is the default mode, and gets as much parallelism as we can while\n minimizing flakiness caused by inter-test dependencies.\n \"\"\"",
"# FIXME: Given that the tests are already sorted by director... | [
{
"param": "self",
"type": null
},
{
"param": "test_inputs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "test_inputs",
"type": null,
"docstring": null,
"docstring_tok... |
8c6359e9202b652e05880dd19316ca62117cdd32 | sunlongbo/chromium | third_party/blink/tools/blinkpy/web_tests/controllers/web_test_runner.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | _resize_shards | <not_specific> | def _resize_shards(self, old_shards, max_new_shards, shard_name_prefix):
"""Takes a list of shards and redistributes the tests into no more
than |max_new_shards| new shards.
"""
# This implementation assumes that each input shard only contains tests from a
# single directory, an... | Takes a list of shards and redistributes the tests into no more
than |max_new_shards| new shards.
| Takes a list of shards and redistributes the tests into no more
than |max_new_shards| new shards. | [
"Takes",
"a",
"list",
"of",
"shards",
"and",
"redistributes",
"the",
"tests",
"into",
"no",
"more",
"than",
"|max_new_shards|",
"new",
"shards",
"."
] | def _resize_shards(self, old_shards, max_new_shards, shard_name_prefix):
Each output shard contains the tests from one or more input shards and
hence may contain tests from multiple directories.
def divide_and_round_up(numerator, divisor):
return int(math.ceil(float(numerator) / di... | [
"def",
"_resize_shards",
"(",
"self",
",",
"old_shards",
",",
"max_new_shards",
",",
"shard_name_prefix",
")",
":",
"def",
"divide_and_round_up",
"(",
"numerator",
",",
"divisor",
")",
":",
"return",
"int",
"(",
"math",
".",
"ceil",
"(",
"float",
"(",
"numer... | Takes a list of shards and redistributes the tests into no more
than |max_new_shards| new shards. | [
"Takes",
"a",
"list",
"of",
"shards",
"and",
"redistributes",
"the",
"tests",
"into",
"no",
"more",
"than",
"|max_new_shards|",
"new",
"shards",
"."
] | [
"\"\"\"Takes a list of shards and redistributes the tests into no more\n than |max_new_shards| new shards.\n \"\"\"",
"# This implementation assumes that each input shard only contains tests from a",
"# single directory, and that tests in each shard must remain together; as a",
"# result, a give... | [
{
"param": "self",
"type": null
},
{
"param": "old_shards",
"type": null
},
{
"param": "max_new_shards",
"type": null
},
{
"param": "shard_name_prefix",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "old_shards",
"type": null,
"docstring": null,
"docstring_toke... |
8c66ecae065e81ba710338b398483268bcb37697 | sunlongbo/chromium | tools/perf/core/services/request.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | json | <not_specific> | def json(self):
"""Attempt to load the content as a json object."""
try:
return json.loads(self.content)
except Exception:
return None | Attempt to load the content as a json object. | Attempt to load the content as a json object. | [
"Attempt",
"to",
"load",
"the",
"content",
"as",
"a",
"json",
"object",
"."
] | def json(self):
try:
return json.loads(self.content)
except Exception:
return None | [
"def",
"json",
"(",
"self",
")",
":",
"try",
":",
"return",
"json",
".",
"loads",
"(",
"self",
".",
"content",
")",
"except",
"Exception",
":",
"return",
"None"
] | Attempt to load the content as a json object. | [
"Attempt",
"to",
"load",
"the",
"content",
"as",
"a",
"json",
"object",
"."
] | [
"\"\"\"Attempt to load the content as a json object.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8c66ecae065e81ba710338b398483268bcb37697 | sunlongbo/chromium | tools/perf/core/services/request.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | error_message | <not_specific> | def error_message(self):
"""Returns a unicode object with the error message found in the content."""
try:
# Try to find error message within json content.
return self.json['error']
except Exception:
# Otherwise fall back to entire content itself, converting str to unicode.
rv = self.... | Returns a unicode object with the error message found in the content. | Returns a unicode object with the error message found in the content. | [
"Returns",
"a",
"unicode",
"object",
"with",
"the",
"error",
"message",
"found",
"in",
"the",
"content",
"."
] | def error_message(self):
try:
return self.json['error']
except Exception:
rv = self.content
if not isinstance(rv, six.text_type):
rv = rv.decode('utf-8')
return rv | [
"def",
"error_message",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"json",
"[",
"'error'",
"]",
"except",
"Exception",
":",
"rv",
"=",
"self",
".",
"content",
"if",
"not",
"isinstance",
"(",
"rv",
",",
"six",
".",
"text_type",
")",
":"... | Returns a unicode object with the error message found in the content. | [
"Returns",
"a",
"unicode",
"object",
"with",
"the",
"error",
"message",
"found",
"in",
"the",
"content",
"."
] | [
"\"\"\"Returns a unicode object with the error message found in the content.\"\"\"",
"# Try to find error message within json content.",
"# Otherwise fall back to entire content itself, converting str to unicode."
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8c66ecae065e81ba710338b398483268bcb37697 | sunlongbo/chromium | tools/perf/core/services/request.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | BuildRequestError | <not_specific> | def BuildRequestError(request, response, content):
"""Build the correct RequestError depending on the response status."""
if response['status'].startswith('4'):
error = ClientError
elif response['status'].startswith('5'):
error = ServerError
else: # Fall back to the base class.
error = RequestError... | Build the correct RequestError depending on the response status. | Build the correct RequestError depending on the response status. | [
"Build",
"the",
"correct",
"RequestError",
"depending",
"on",
"the",
"response",
"status",
"."
] | def BuildRequestError(request, response, content):
if response['status'].startswith('4'):
error = ClientError
elif response['status'].startswith('5'):
error = ServerError
else:
error = RequestError
return error(request, response, content) | [
"def",
"BuildRequestError",
"(",
"request",
",",
"response",
",",
"content",
")",
":",
"if",
"response",
"[",
"'status'",
"]",
".",
"startswith",
"(",
"'4'",
")",
":",
"error",
"=",
"ClientError",
"elif",
"response",
"[",
"'status'",
"]",
".",
"startswith"... | Build the correct RequestError depending on the response status. | [
"Build",
"the",
"correct",
"RequestError",
"depending",
"on",
"the",
"response",
"status",
"."
] | [
"\"\"\"Build the correct RequestError depending on the response status.\"\"\"",
"# Fall back to the base class."
] | [
{
"param": "request",
"type": null
},
{
"param": "response",
"type": null
},
{
"param": "content",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "response",
"type": null,
"docstring": null,
"docstring_tok... |
8c66ecae065e81ba710338b398483268bcb37697 | sunlongbo/chromium | tools/perf/core/services/request.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | Request | <not_specific> | def Request(url, method='GET', params=None, data=None, accept=None,
content_type='urlencoded', use_auth=False, retries=None):
"""Perform an HTTP request of a given resource.
Args:
url: A string with the URL to request.
method: A string with the HTTP method to perform, e.g. 'GET' or 'POST'.
... | Perform an HTTP request of a given resource.
Args:
url: A string with the URL to request.
method: A string with the HTTP method to perform, e.g. 'GET' or 'POST'.
params: An optional dict or sequence of key, value pairs to be added as
a query to the url.
data: An optional dict or sequence of key... | Perform an HTTP request of a given resource.
Args:
url: A string with the URL to request.
method: A string with the HTTP method to perform, e.g. 'GET' or 'POST'.
params: An optional dict or sequence of key, value pairs to be added as
a query to the url.
data: An optional dict or sequence of key, value pairs to send as ... | [
"Perform",
"an",
"HTTP",
"request",
"of",
"a",
"given",
"resource",
".",
"Args",
":",
"url",
":",
"A",
"string",
"with",
"the",
"URL",
"to",
"request",
".",
"method",
":",
"A",
"string",
"with",
"the",
"HTTP",
"method",
"to",
"perform",
"e",
".",
"g"... | def Request(url, method='GET', params=None, data=None, accept=None,
content_type='urlencoded', use_auth=False, retries=None):
del retries
if params:
url = '%s?%s' % (url, six.moves.urllib.parse.urlencode(params))
body = None
headers = {}
if accept == 'json':
headers['Accept'] = 'applicat... | [
"def",
"Request",
"(",
"url",
",",
"method",
"=",
"'GET'",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"accept",
"=",
"None",
",",
"content_type",
"=",
"'urlencoded'",
",",
"use_auth",
"=",
"False",
",",
"retries",
"=",
"None",
")",
":... | Perform an HTTP request of a given resource. | [
"Perform",
"an",
"HTTP",
"request",
"of",
"a",
"given",
"resource",
"."
] | [
"\"\"\"Perform an HTTP request of a given resource.\n\n Args:\n url: A string with the URL to request.\n method: A string with the HTTP method to perform, e.g. 'GET' or 'POST'.\n params: An optional dict or sequence of key, value pairs to be added as\n a query to the url.\n data: An optional dict ... | [
{
"param": "url",
"type": null
},
{
"param": "method",
"type": null
},
{
"param": "params",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "accept",
"type": null
},
{
"param": "content_type",
"type": null
},
{
"param": "use_a... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "method",
"type": null,
"docstring": null,
"docstring_tokens": ... |
0fa95435ac3520bdc53468c1b493d31885d1c124 | sunlongbo/chromium | chrome/browser/share/core/resources/gen_share_targets_proto.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ParseInputPb | <not_specific> | def ParseInputPb(input_pb):
""" Return a protobuf based on input pb """
new_pb = share_target_pb2.MapLocaleTargets()
temp_pb = share_target_pb2.TargetLocalesForParsing()
temp_pb.CopyFrom(input_pb)
new_pb.version_id = temp_pb.version_id
all_targets_pb = share_target_pb2.TmpShareTargetMap()
... | Return a protobuf based on input pb | Return a protobuf based on input pb | [
"Return",
"a",
"protobuf",
"based",
"on",
"input",
"pb"
] | def ParseInputPb(input_pb):
new_pb = share_target_pb2.MapLocaleTargets()
temp_pb = share_target_pb2.TargetLocalesForParsing()
temp_pb.CopyFrom(input_pb)
new_pb.version_id = temp_pb.version_id
all_targets_pb = share_target_pb2.TmpShareTargetMap()
for s in temp_pb.targets:
all_targets_pb.a... | [
"def",
"ParseInputPb",
"(",
"input_pb",
")",
":",
"new_pb",
"=",
"share_target_pb2",
".",
"MapLocaleTargets",
"(",
")",
"temp_pb",
"=",
"share_target_pb2",
".",
"TargetLocalesForParsing",
"(",
")",
"temp_pb",
".",
"CopyFrom",
"(",
"input_pb",
")",
"new_pb",
".",... | Return a protobuf based on input pb | [
"Return",
"a",
"protobuf",
"based",
"on",
"input",
"pb"
] | [
"\"\"\" Return a protobuf based on input pb \"\"\""
] | [
{
"param": "input_pb",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_pb",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0fa95435ac3520bdc53468c1b493d31885d1c124 | sunlongbo/chromium | chrome/browser/share/core/resources/gen_share_targets_proto.py | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | Python | ValidatePb | null | def ValidatePb(self, opts, pb):
""" Validate the basic values of the protobuf."""
assert pb.version_id > 0
assert len(pb.locale_mapping) > 1
assert len(pb.targets) > 1 | Validate the basic values of the protobuf. | Validate the basic values of the protobuf. | [
"Validate",
"the",
"basic",
"values",
"of",
"the",
"protobuf",
"."
] | def ValidatePb(self, opts, pb):
assert pb.version_id > 0
assert len(pb.locale_mapping) > 1
assert len(pb.targets) > 1 | [
"def",
"ValidatePb",
"(",
"self",
",",
"opts",
",",
"pb",
")",
":",
"assert",
"pb",
".",
"version_id",
">",
"0",
"assert",
"len",
"(",
"pb",
".",
"locale_mapping",
")",
">",
"1",
"assert",
"len",
"(",
"pb",
".",
"targets",
")",
">",
"1"
] | Validate the basic values of the protobuf. | [
"Validate",
"the",
"basic",
"values",
"of",
"the",
"protobuf",
"."
] | [
"\"\"\" Validate the basic values of the protobuf.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "opts",
"type": null
},
{
"param": "pb",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "opts",
"type": null,
"docstring": null,
"docstring_tokens": [... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.