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
7616cdb4e52669a1660aff8714077789b9f04ed8
sunlongbo/chromium
tools/metrics/histograms/expand_owners.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
ExpandHistogramsOWNERS
null
def ExpandHistogramsOWNERS(histograms): """Updates the given DOM Element's descendants, if necessary. When a histogram has an owner node whose text is an OWNERS file path rather than an email address, e.g. <owner>src/base/android/OWNERS</owner> instead of <owner>joy@chromium.org</owner>, then (A) the histogram...
Updates the given DOM Element's descendants, if necessary. When a histogram has an owner node whose text is an OWNERS file path rather than an email address, e.g. <owner>src/base/android/OWNERS</owner> instead of <owner>joy@chromium.org</owner>, then (A) the histogram's owners need to be updated and (B) a comp...
Updates the given DOM Element's descendants, if necessary. When a histogram has an owner node whose text is an OWNERS file path rather than an email address, e.g. src/base/android/OWNERS instead of joy@chromium.org, then (A) the histogram's owners need to be updated and (B) a component may be added. If the text of an ...
[ "Updates", "the", "given", "DOM", "Element", "'", "s", "descendants", "if", "necessary", ".", "When", "a", "histogram", "has", "an", "owner", "node", "whose", "text", "is", "an", "OWNERS", "file", "path", "rather", "than", "an", "email", "address", "e", ...
def ExpandHistogramsOWNERS(histograms): email_pattern = re.compile(_EMAIL_PATTERN) iter_matches = extract_histograms.IterElementsWithTag for histogram in iter_matches(histograms, 'histogram'): owners = [owner for owner in iter_matches(histogram, 'owner', 1)] emails_with_dom_elements = set([ owner....
[ "def", "ExpandHistogramsOWNERS", "(", "histograms", ")", ":", "email_pattern", "=", "re", ".", "compile", "(", "_EMAIL_PATTERN", ")", "iter_matches", "=", "extract_histograms", ".", "IterElementsWithTag", "for", "histogram", "in", "iter_matches", "(", "histograms", ...
Updates the given DOM Element's descendants, if necessary.
[ "Updates", "the", "given", "DOM", "Element", "'", "s", "descendants", "if", "necessary", "." ]
[ "\"\"\"Updates the given DOM Element's descendants, if necessary.\n\n When a histogram has an owner node whose text is an OWNERS file path rather\n than an email address, e.g. <owner>src/base/android/OWNERS</owner> instead of\n <owner>joy@chromium.org</owner>, then (A) the histogram's owners need to be\n update...
[ { "param": "histograms", "type": null } ]
{ "returns": [], "raises": [ { "docstring": "Raised if the OWNERS file with the given path does not exist.", "docstring_tokens": [ "Raised", "if", "the", "OWNERS", "file", "with", "the", "given", "path", "does", ...
761a57be094c496c9b321687634b3f8257a56db7
sunlongbo/chromium
ui/file_manager/base/gn/js_test_gen_html.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_process_js_module
null
def _process_js_module(input_file, output_filename): """Generates the HTML for a unittest based on JS Modules. Args: input_file: The path for the unittest JS module. output_filename: The path/filename for HTML to be generated. """ # Map //ui/file_manager files to test URL: js_module_url = input_file...
Generates the HTML for a unittest based on JS Modules. Args: input_file: The path for the unittest JS module. output_filename: The path/filename for HTML to be generated.
Generates the HTML for a unittest based on JS Modules.
[ "Generates", "the", "HTML", "for", "a", "unittest", "based", "on", "JS", "Modules", "." ]
def _process_js_module(input_file, output_filename): js_module_url = input_file.replace( 'ui/file_manager/', 'chrome://file_manager_test/ui/file_manager/', 1) with open(output_filename, 'w') as out: out.write(_HTML_FILE_START + '\n') line = _JS_MODULE % (js_module_url) out.write(line + '\n') l...
[ "def", "_process_js_module", "(", "input_file", ",", "output_filename", ")", ":", "js_module_url", "=", "input_file", ".", "replace", "(", "'ui/file_manager/'", ",", "'chrome://file_manager_test/ui/file_manager/'", ",", "1", ")", "with", "open", "(", "output_filename", ...
Generates the HTML for a unittest based on JS Modules.
[ "Generates", "the", "HTML", "for", "a", "unittest", "based", "on", "JS", "Modules", "." ]
[ "\"\"\"Generates the HTML for a unittest based on JS Modules.\n\n Args:\n input_file: The path for the unittest JS module.\n output_filename: The path/filename for HTML to be generated.\n \"\"\"", "# Map //ui/file_manager files to test URL:" ]
[ { "param": "input_file", "type": null }, { "param": "output_filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "input_file", "type": null, "docstring": "The path for the unittest JS module.", "docstring_tokens": [ "The", "path", "for", "the", "unittest", "JS", "module", "."...
1aee769d2cb55ed0ad2468687af4b64610f29b63
sunlongbo/chromium
third_party/blink/tools/blinkpy/common/pretty_diff.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
parse
<not_specific>
def parse(lines): """Parses diff lines, and creates a DiffFile instance. Finds a file diff header, creates a single DiffFile instance, and returns a tuple of the DiffFile instance and unconsumed lines. If a file diff isn't found, (None, lines) is returned. """ diff_comma...
Parses diff lines, and creates a DiffFile instance. Finds a file diff header, creates a single DiffFile instance, and returns a tuple of the DiffFile instance and unconsumed lines. If a file diff isn't found, (None, lines) is returned.
Parses diff lines, and creates a DiffFile instance. Finds a file diff header, creates a single DiffFile instance, and returns a tuple of the DiffFile instance and unconsumed lines. If a file diff isn't found, (None, lines) is returned.
[ "Parses", "diff", "lines", "and", "creates", "a", "DiffFile", "instance", ".", "Finds", "a", "file", "diff", "header", "creates", "a", "single", "DiffFile", "instance", "and", "returns", "a", "tuple", "of", "the", "DiffFile", "instance", "and", "unconsumed", ...
def parse(lines): diff_command_re = r'diff (?:-[^ ]+ )*a/([^ ]+) b/([^ ]+)' old_name = None new_name = None info_lines = None found_diff_command_line = False for i, line in enumerate(lines): if not found_diff_command_line: match = re.match(diff...
[ "def", "parse", "(", "lines", ")", ":", "diff_command_re", "=", "r'diff (?:-[^ ]+ )*a/([^ ]+) b/([^ ]+)'", "old_name", "=", "None", "new_name", "=", "None", "info_lines", "=", "None", "found_diff_command_line", "=", "False", "for", "i", ",", "line", "in", "enumera...
Parses diff lines, and creates a DiffFile instance.
[ "Parses", "diff", "lines", "and", "creates", "a", "DiffFile", "instance", "." ]
[ "\"\"\"Parses diff lines, and creates a DiffFile instance.\n\n Finds a file diff header, creates a single DiffFile instance, and\n returns a tuple of the DiffFile instance and unconsumed lines. If a file\n diff isn't found, (None, lines) is returned.\n \"\"\"", "# Adjusts old_name and ...
[ { "param": "lines", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "lines", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1aee769d2cb55ed0ad2468687af4b64610f29b63
sunlongbo/chromium
third_party/blink/tools/blinkpy/common/pretty_diff.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
parse
<not_specific>
def parse(lines): """Parses diff lines, and creates a sequence of DiffHunk instances. Finds a hunk header, creates a sequence of DiffHunk instances, and returns a tuple of the DiffHunk list and unconsumed lines. If a hunk header isn't found, ValueError is raised. """ old...
Parses diff lines, and creates a sequence of DiffHunk instances. Finds a hunk header, creates a sequence of DiffHunk instances, and returns a tuple of the DiffHunk list and unconsumed lines. If a hunk header isn't found, ValueError is raised.
Parses diff lines, and creates a sequence of DiffHunk instances. Finds a hunk header, creates a sequence of DiffHunk instances, and returns a tuple of the DiffHunk list and unconsumed lines. If a hunk header isn't found, ValueError is raised.
[ "Parses", "diff", "lines", "and", "creates", "a", "sequence", "of", "DiffHunk", "instances", ".", "Finds", "a", "hunk", "header", "creates", "a", "sequence", "of", "DiffHunk", "instances", "and", "returns", "a", "tuple", "of", "the", "DiffHunk", "list", "and...
def parse(lines): old_start = None new_start = None context = None hunk_lines = None hunks = [] hunk_header_re = r'^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)?' found_hunk_header = False for i, line in enumerate(lines): if not found_hunk_header...
[ "def", "parse", "(", "lines", ")", ":", "old_start", "=", "None", "new_start", "=", "None", "context", "=", "None", "hunk_lines", "=", "None", "hunks", "=", "[", "]", "hunk_header_re", "=", "r'^@@ -(\\d+)(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@(.*)?'", "found_hunk_header",...
Parses diff lines, and creates a sequence of DiffHunk instances.
[ "Parses", "diff", "lines", "and", "creates", "a", "sequence", "of", "DiffHunk", "instances", "." ]
[ "\"\"\"Parses diff lines, and creates a sequence of DiffHunk instances.\n\n Finds a hunk header, creates a sequence of DiffHunk instances, and\n returns a tuple of the DiffHunk list and unconsumed lines. If a hunk\n header isn't found, ValueError is raised.\n \"\"\"" ]
[ { "param": "lines", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "lines", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1aee769d2cb55ed0ad2468687af4b64610f29b63
sunlongbo/chromium
third_party/blink/tools/blinkpy/common/pretty_diff.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
parse
<not_specific>
def parse(lines): """Creates a BinaryHunk instance starting with lines[0]. Returns a tuple of the BinaryHunk instance and unconsumed lines. """ match = re.match(r'(literal|delta) (\d+)', lines[0]) if not match: raise ValueError('No "literal <size>" or "delta <size>"....
Creates a BinaryHunk instance starting with lines[0]. Returns a tuple of the BinaryHunk instance and unconsumed lines.
Creates a BinaryHunk instance starting with lines[0]. Returns a tuple of the BinaryHunk instance and unconsumed lines.
[ "Creates", "a", "BinaryHunk", "instance", "starting", "with", "lines", "[", "0", "]", ".", "Returns", "a", "tuple", "of", "the", "BinaryHunk", "instance", "and", "unconsumed", "lines", "." ]
def parse(lines): match = re.match(r'(literal|delta) (\d+)', lines[0]) if not match: raise ValueError('No "literal <size>" or "delta <size>".') bin_type = match.group(1) size = int(match.group(2)) bin_data = b'' lines = lines[1:] for i, line in enumera...
[ "def", "parse", "(", "lines", ")", ":", "match", "=", "re", ".", "match", "(", "r'(literal|delta) (\\d+)'", ",", "lines", "[", "0", "]", ")", "if", "not", "match", ":", "raise", "ValueError", "(", "'No \"literal <size>\" or \"delta <size>\".'", ")", "bin_type"...
Creates a BinaryHunk instance starting with lines[0].
[ "Creates", "a", "BinaryHunk", "instance", "starting", "with", "lines", "[", "0", "]", "." ]
[ "\"\"\"Creates a BinaryHunk instance starting with lines[0].\n\n Returns a tuple of the BinaryHunk instance and unconsumed lines.\n \"\"\"", "# Map a letter to a number.", "# A-Z -> 1-26", "# a-z -> 27-52" ]
[ { "param": "lines", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "lines", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1af4525e293c664256cf8df14a1de9b37576ef10
sunlongbo/chromium
tools/json_schema_compiler/cpp_util.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
Classname
<not_specific>
def Classname(s): """Translates a namespace name or function name into something more suited to C++. eg experimental.downloads -> Experimental_Downloads updateAll -> UpdateAll update_all -> UpdateAll """ if s == '': return 'EMPTY_STRING' if IsUnixName(s): result = CamelCase(s) else: resu...
Translates a namespace name or function name into something more suited to C++. eg experimental.downloads -> Experimental_Downloads updateAll -> UpdateAll update_all -> UpdateAll
Translates a namespace name or function name into something more suited to C++.
[ "Translates", "a", "namespace", "name", "or", "function", "name", "into", "something", "more", "suited", "to", "C", "++", "." ]
def Classname(s): if s == '': return 'EMPTY_STRING' if IsUnixName(s): result = CamelCase(s) else: result = '_'.join([x[0].upper() + x[1:] for x in re.split(r'\W', s)]) assert result if result[0].isdigit(): result = '_' + result return result
[ "def", "Classname", "(", "s", ")", ":", "if", "s", "==", "''", ":", "return", "'EMPTY_STRING'", "if", "IsUnixName", "(", "s", ")", ":", "result", "=", "CamelCase", "(", "s", ")", "else", ":", "result", "=", "'_'", ".", "join", "(", "[", "x", "[",...
Translates a namespace name or function name into something more suited to C++.
[ "Translates", "a", "namespace", "name", "or", "function", "name", "into", "something", "more", "suited", "to", "C", "++", "." ]
[ "\"\"\"Translates a namespace name or function name into something more\n suited to C++.\n\n eg experimental.downloads -> Experimental_Downloads\n updateAll -> UpdateAll\n update_all -> UpdateAll\n \"\"\"", "# Ensure the class name follows c++ identifier rules by prepending an", "# underscore if needed." ]
[ { "param": "s", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1af4525e293c664256cf8df14a1de9b37576ef10
sunlongbo/chromium
tools/json_schema_compiler/cpp_util.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
GetAsFundamentalValue
<not_specific>
def GetAsFundamentalValue(type_, src): """Returns the C++ code for retrieving a fundamental type from a Value into a variable. src: Value """ if type_.property_type == PropertyType.BOOLEAN: s = '%s.GetIfBool()' elif type_.property_type == PropertyType.DOUBLE: s = '%s.GetIfDouble()' elif type_.pro...
Returns the C++ code for retrieving a fundamental type from a Value into a variable. src: Value
Returns the C++ code for retrieving a fundamental type from a Value into a variable. Value
[ "Returns", "the", "C", "++", "code", "for", "retrieving", "a", "fundamental", "type", "from", "a", "Value", "into", "a", "variable", ".", "Value" ]
def GetAsFundamentalValue(type_, src): if type_.property_type == PropertyType.BOOLEAN: s = '%s.GetIfBool()' elif type_.property_type == PropertyType.DOUBLE: s = '%s.GetIfDouble()' elif type_.property_type == PropertyType.INTEGER: s = '%s.GetIfInt()' elif (type_.property_type == PropertyType.STRING o...
[ "def", "GetAsFundamentalValue", "(", "type_", ",", "src", ")", ":", "if", "type_", ".", "property_type", "==", "PropertyType", ".", "BOOLEAN", ":", "s", "=", "'%s.GetIfBool()'", "elif", "type_", ".", "property_type", "==", "PropertyType", ".", "DOUBLE", ":", ...
Returns the C++ code for retrieving a fundamental type from a Value into a variable.
[ "Returns", "the", "C", "++", "code", "for", "retrieving", "a", "fundamental", "type", "from", "a", "Value", "into", "a", "variable", "." ]
[ "\"\"\"Returns the C++ code for retrieving a fundamental type from a\n Value into a variable.\n\n src: Value\n \"\"\"" ]
[ { "param": "type_", "type": null }, { "param": "src", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type_", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "src", "type": null, "docstring": null, "docstring_tokens": [...
1af4525e293c664256cf8df14a1de9b37576ef10
sunlongbo/chromium
tools/json_schema_compiler/cpp_util.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
GetValueType
<not_specific>
def GetValueType(type_): """Returns the Value::Type corresponding to the model.Type. """ if type_.property_type == PropertyType.ARRAY: return 'base::Value::Type::LIST' if type_.property_type == PropertyType.BINARY: return 'base::Value::Type::BINARY' if type_.property_type == PropertyType.BOOLEAN: ...
Returns the Value::Type corresponding to the model.Type.
Returns the Value::Type corresponding to the model.Type.
[ "Returns", "the", "Value", "::", "Type", "corresponding", "to", "the", "model", ".", "Type", "." ]
def GetValueType(type_): if type_.property_type == PropertyType.ARRAY: return 'base::Value::Type::LIST' if type_.property_type == PropertyType.BINARY: return 'base::Value::Type::BINARY' if type_.property_type == PropertyType.BOOLEAN: return 'base::Value::Type::BOOLEAN' if type_.property_type == Prop...
[ "def", "GetValueType", "(", "type_", ")", ":", "if", "type_", ".", "property_type", "==", "PropertyType", ".", "ARRAY", ":", "return", "'base::Value::Type::LIST'", "if", "type_", ".", "property_type", "==", "PropertyType", ".", "BINARY", ":", "return", "'base::V...
Returns the Value::Type corresponding to the model.Type.
[ "Returns", "the", "Value", "::", "Type", "corresponding", "to", "the", "model", ".", "Type", "." ]
[ "\"\"\"Returns the Value::Type corresponding to the model.Type.\n \"\"\"" ]
[ { "param": "type_", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type_", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1af4525e293c664256cf8df14a1de9b37576ef10
sunlongbo/chromium
tools/json_schema_compiler/cpp_util.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
FeatureNameToConstantName
<not_specific>
def FeatureNameToConstantName(feature_name): # type: (str) -> str """Returns a kName for a feature's name. """ return ('k' + ''.join(word[0].upper() + word[1:] for word in feature_name.replace('.', ' ').split()))
Returns a kName for a feature's name.
Returns a kName for a feature's name.
[ "Returns", "a", "kName", "for", "a", "feature", "'", "s", "name", "." ]
def FeatureNameToConstantName(feature_name): return ('k' + ''.join(word[0].upper() + word[1:] for word in feature_name.replace('.', ' ').split()))
[ "def", "FeatureNameToConstantName", "(", "feature_name", ")", ":", "return", "(", "'k'", "+", "''", ".", "join", "(", "word", "[", "0", "]", ".", "upper", "(", ")", "+", "word", "[", "1", ":", "]", "for", "word", "in", "feature_name", ".", "replace",...
Returns a kName for a feature's name.
[ "Returns", "a", "kName", "for", "a", "feature", "'", "s", "name", "." ]
[ "# type: (str) -> str", "\"\"\"Returns a kName for a feature's name.\n \"\"\"" ]
[ { "param": "feature_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "feature_name", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1af4525e293c664256cf8df14a1de9b37576ef10
sunlongbo/chromium
tools/json_schema_compiler/cpp_util.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
IsUnixName
<not_specific>
def IsUnixName(s): # type (str) -> bool """Returns true if |s| is of the type unix_name i.e. only has lower cased characters and underscores with at least one underscore. """ return all(x.islower() or x == '_' for x in s) and '_' in s
Returns true if |s| is of the type unix_name i.e. only has lower cased characters and underscores with at least one underscore.
Returns true if |s| is of the type unix_name i.e. only has lower cased characters and underscores with at least one underscore.
[ "Returns", "true", "if", "|s|", "is", "of", "the", "type", "unix_name", "i", ".", "e", ".", "only", "has", "lower", "cased", "characters", "and", "underscores", "with", "at", "least", "one", "underscore", "." ]
def IsUnixName(s): return all(x.islower() or x == '_' for x in s) and '_' in s
[ "def", "IsUnixName", "(", "s", ")", ":", "return", "all", "(", "x", ".", "islower", "(", ")", "or", "x", "==", "'_'", "for", "x", "in", "s", ")", "and", "'_'", "in", "s" ]
Returns true if |s| is of the type unix_name i.e.
[ "Returns", "true", "if", "|s|", "is", "of", "the", "type", "unix_name", "i", ".", "e", "." ]
[ "# type (str) -> bool", "\"\"\"Returns true if |s| is of the type unix_name i.e. only has lower cased\n characters and underscores with at least one underscore.\n \"\"\"" ]
[ { "param": "s", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1af4525e293c664256cf8df14a1de9b37576ef10
sunlongbo/chromium
tools/json_schema_compiler/cpp_util.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
ToPosixPath
<not_specific>
def ToPosixPath(path): """Returns |path| with separator converted to POSIX style. This is needed to generate C++ #include paths. """ return path.replace(os.path.sep, posixpath.sep)
Returns |path| with separator converted to POSIX style. This is needed to generate C++ #include paths.
Returns |path| with separator converted to POSIX style. This is needed to generate C++ #include paths.
[ "Returns", "|path|", "with", "separator", "converted", "to", "POSIX", "style", ".", "This", "is", "needed", "to", "generate", "C", "++", "#include", "paths", "." ]
def ToPosixPath(path): return path.replace(os.path.sep, posixpath.sep)
[ "def", "ToPosixPath", "(", "path", ")", ":", "return", "path", ".", "replace", "(", "os", ".", "path", ".", "sep", ",", "posixpath", ".", "sep", ")" ]
Returns |path| with separator converted to POSIX style.
[ "Returns", "|path|", "with", "separator", "converted", "to", "POSIX", "style", "." ]
[ "\"\"\"Returns |path| with separator converted to POSIX style.\n\n This is needed to generate C++ #include paths.\n \"\"\"" ]
[ { "param": "path", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
290fb94084a99381e9699646efb2b5af2e238cb5
sunlongbo/chromium
tools/android/bitmap_to_reached.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_DumpToOffsets
<not_specific>
def _DumpToOffsets(filename): """From a dump, returns a list of offsets in it. Args: filename: (str) Dump filename. Returns: ([int]) offsets in the dump, that is relative to .text start. """ bitfield = None offsets = [] with open(filename, 'r') as f: bitfield = f.read() assert len(bitfield...
From a dump, returns a list of offsets in it. Args: filename: (str) Dump filename. Returns: ([int]) offsets in the dump, that is relative to .text start.
From a dump, returns a list of offsets in it.
[ "From", "a", "dump", "returns", "a", "list", "of", "offsets", "in", "it", "." ]
def _DumpToOffsets(filename): bitfield = None offsets = [] with open(filename, 'r') as f: bitfield = f.read() assert len(bitfield) % SIZEOF_INT == 0 count = len(bitfield) / SIZEOF_INT for i in xrange(count): entry = struct.unpack_from('<I', bitfield, offset=i * SIZEOF_INT)[0] for bit in range(BI...
[ "def", "_DumpToOffsets", "(", "filename", ")", ":", "bitfield", "=", "None", "offsets", "=", "[", "]", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "bitfield", "=", "f", ".", "read", "(", ")", "assert", "len", "(", "bitfield", ...
From a dump, returns a list of offsets in it.
[ "From", "a", "dump", "returns", "a", "list", "of", "offsets", "in", "it", "." ]
[ "\"\"\"From a dump, returns a list of offsets in it.\n\n Args:\n filename: (str) Dump filename.\n\n Returns:\n ([int]) offsets in the dump, that is relative to .text start.\n \"\"\"" ]
[ { "param": "filename", "type": null } ]
{ "returns": [ { "docstring": "([int]) offsets in the dump, that is relative to .text start.", "docstring_tokens": [ "(", "[", "int", "]", ")", "offsets", "in", "the", "dump", "that", "is", "relative", ...
290fb94084a99381e9699646efb2b5af2e238cb5
sunlongbo/chromium
tools/android/bitmap_to_reached.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_ReachedSymbols
<not_specific>
def _ReachedSymbols(offsets, offset_to_symbol): """Returns a list of reached symbols from offsets in .text. Args: offsets: ([int]) List of reached offsets. offset_to_symbol: [symbol_extractor.SymbolInfo or None] as returned by |SymbolOffsetProcessor.GetDumpOffsetToSymbolInfo()| Returns: ([symb...
Returns a list of reached symbols from offsets in .text. Args: offsets: ([int]) List of reached offsets. offset_to_symbol: [symbol_extractor.SymbolInfo or None] as returned by |SymbolOffsetProcessor.GetDumpOffsetToSymbolInfo()| Returns: ([symbol_extractor.SymbolInfo])
Returns a list of reached symbols from offsets in .text.
[ "Returns", "a", "list", "of", "reached", "symbols", "from", "offsets", "in", ".", "text", "." ]
def _ReachedSymbols(offsets, offset_to_symbol): symbol_infos = set() missing = 0 for offset in offsets: index = offset / BYTES_GRANULARITY if index > len(offset_to_symbol): missing += 1 continue symbol_infos.add(offset_to_symbol[index]) if missing: logging.warning('Couldn\'t match %d...
[ "def", "_ReachedSymbols", "(", "offsets", ",", "offset_to_symbol", ")", ":", "symbol_infos", "=", "set", "(", ")", "missing", "=", "0", "for", "offset", "in", "offsets", ":", "index", "=", "offset", "/", "BYTES_GRANULARITY", "if", "index", ">", "len", "(",...
Returns a list of reached symbols from offsets in .text.
[ "Returns", "a", "list", "of", "reached", "symbols", "from", "offsets", "in", ".", "text", "." ]
[ "\"\"\"Returns a list of reached symbols from offsets in .text.\n\n Args:\n offsets: ([int]) List of reached offsets.\n offset_to_symbol: [symbol_extractor.SymbolInfo or None] as returned by\n |SymbolOffsetProcessor.GetDumpOffsetToSymbolInfo()|\n\n Returns:\n ([symbol_extractor.SymbolInfo])\n \"\"\...
[ { "param": "offsets", "type": null }, { "param": "offset_to_symbol", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "offsets", "type": null, "docstring": "([int]) List of reached offsets.", "docstring_tokens": [ "(", ...
5370ea857de77634b21a52db61991c5c5491ac69
sunlongbo/chromium
tools/android/pagecontroller/search_strings.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
find_term_in_grd
<not_specific>
def find_term_in_grd(self, term, is_regex): """ Returns matches for term in the form (string id, text, desc) """ results = [] for name,value in self.message_lookup.iteritems(): if ((not is_regex and value['text'] == term) or (is_regex and re.match(term, value['text']))): results.appe...
Returns matches for term in the form (string id, text, desc)
Returns matches for term in the form (string id, text, desc)
[ "Returns", "matches", "for", "term", "in", "the", "form", "(", "string", "id", "text", "desc", ")" ]
def find_term_in_grd(self, term, is_regex): results = [] for name,value in self.message_lookup.iteritems(): if ((not is_regex and value['text'] == term) or (is_regex and re.match(term, value['text']))): results.append((name[4:].lower(), value['text'], value['desc'])) return results
[ "def", "find_term_in_grd", "(", "self", ",", "term", ",", "is_regex", ")", ":", "results", "=", "[", "]", "for", "name", ",", "value", "in", "self", ".", "message_lookup", ".", "iteritems", "(", ")", ":", "if", "(", "(", "not", "is_regex", "and", "va...
Returns matches for term in the form (string id, text, desc)
[ "Returns", "matches", "for", "term", "in", "the", "form", "(", "string", "id", "text", "desc", ")" ]
[ "\"\"\" Returns matches for term in the form (string id, text, desc) \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "term", "type": null }, { "param": "is_regex", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "term", "type": null, "docstring": null, "docstring_tokens": [...
5375da0fe65f5042fc4ceaa3dc6cef8c01437b02
sunlongbo/chromium
tools/translation/helper/translation_helper.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_parse_grd_file
<not_specific>
def _parse_grd_file(grd_path): """Reads a grd(p) file and any subfiles included via <part file="..." />. Args: grd_path: The path of the .grd or .grdp file. Returns: A tuple (grd_dom, grdp_paths). dom is an ElementTree DOM for the grd file, with the <part> elements inlined. grdp_paths is the list of ...
Reads a grd(p) file and any subfiles included via <part file="..." />. Args: grd_path: The path of the .grd or .grdp file. Returns: A tuple (grd_dom, grdp_paths). dom is an ElementTree DOM for the grd file, with the <part> elements inlined. grdp_paths is the list of grdp files that were included vi...
Reads a grd(p) file and any subfiles included via .
[ "Reads", "a", "grd", "(", "p", ")", "file", "and", "any", "subfiles", "included", "via", "." ]
def _parse_grd_file(grd_path): grdp_paths = [] grd_dom = ElementTree.parse(grd_path) part_nodes = list(grd_dom.findall('.//part')) for part_node in part_nodes: grdp_rel_path = part_node.get('file') grdp_path = os.path.join(os.path.dirname(grd_path), grdp_rel_path) grdp_paths.append(grdp_path) gr...
[ "def", "_parse_grd_file", "(", "grd_path", ")", ":", "grdp_paths", "=", "[", "]", "grd_dom", "=", "ElementTree", ".", "parse", "(", "grd_path", ")", "part_nodes", "=", "list", "(", "grd_dom", ".", "findall", "(", "'.//part'", ")", ")", "for", "part_node", ...
Reads a grd(p) file and any subfiles included via <part file="..." />.
[ "Reads", "a", "grd", "(", "p", ")", "file", "and", "any", "subfiles", "included", "via", "<part", "file", "=", "\"", "...", "\"", "/", ">", "." ]
[ "\"\"\"Reads a grd(p) file and any subfiles included via <part file=\"...\" />.\n\n Args:\n grd_path: The path of the .grd or .grdp file.\n Returns:\n A tuple (grd_dom, grdp_paths). dom is an ElementTree DOM for the grd file,\n with the <part> elements inlined. grdp_paths is the list of grdp files that\n...
[ { "param": "grd_path", "type": null } ]
{ "returns": [ { "docstring": "A tuple (grd_dom, grdp_paths). dom is an ElementTree DOM for the grd file,\nwith the elements inlined. grdp_paths is the list of grdp files that\nwere included via elements.", "docstring_tokens": [ "A", "tuple", "(", "grd_dom", "...
5375da0fe65f5042fc4ceaa3dc6cef8c01437b02
sunlongbo/chromium
tools/translation/helper/translation_helper.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_parse_translation_expectations
<not_specific>
def _parse_translation_expectations(path): """Parses a translations expectations file. Example translations expectations file: { "desktop_grds": { "languages": ["es", "fr"], "files": [ "ash/ash_strings.grd", "ui/strings/ui_strings.grd", ], }, "android_grds": { ...
Parses a translations expectations file. Example translations expectations file: { "desktop_grds": { "languages": ["es", "fr"], "files": [ "ash/ash_strings.grd", "ui/strings/ui_strings.grd", ], }, "android_grds": { "languages": ["de", "pt-BR"], "files": [ ...
Parses a translations expectations file.
[ "Parses", "a", "translations", "expectations", "file", "." ]
def _parse_translation_expectations(path): with open(path) as f: file_contents = f.read() def assert_list_of_strings(l, name): assert isinstance(l, list) and all(isinstance(s, basestring) for s in l), ( '%s must be a list of strings' % name) try: translations_expectations = ast.literal_eval(fi...
[ "def", "_parse_translation_expectations", "(", "path", ")", ":", "with", "open", "(", "path", ")", "as", "f", ":", "file_contents", "=", "f", ".", "read", "(", ")", "def", "assert_list_of_strings", "(", "l", ",", "name", ")", ":", "assert", "isinstance", ...
Parses a translations expectations file.
[ "Parses", "a", "translations", "expectations", "file", "." ]
[ "\"\"\"Parses a translations expectations file.\n\n Example translations expectations file:\n {\n \"desktop_grds\": {\n \"languages\": [\"es\", \"fr\"],\n \"files\": [\n \"ash/ash_strings.grd\",\n \"ui/strings/ui_strings.grd\",\n ],\n },\n \"android_grds\": {\n \"languag...
[ { "param": "path", "type": null } ]
{ "returns": [ { "docstring": "A tuple (grd_to_langs, untranslated_grds, internal_grds).\ngrd_to_langs maps each grd path to the list of languages into which\nthat grd should be translated. untranslated_grds is a list of grds\nthat \"appear translatable\" but should not be translated.\ninternal_grds is a li...
992f46b9460996b1037e8f694dfa6dbae1e321eb
sunlongbo/chromium
tools/cygprofile/symbol_extractor.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_FromObjdumpLine
<not_specific>
def _FromObjdumpLine(line): """Create a SymbolInfo by parsing a properly formatted objdump output line. Args: line: line from objdump Returns: An instance of SymbolInfo if the line represents a symbol, None otherwise. """ m = _OBJDUMP_LINE_RE.match(line) if not m: return None # A symbol can...
Create a SymbolInfo by parsing a properly formatted objdump output line. Args: line: line from objdump Returns: An instance of SymbolInfo if the line represents a symbol, None otherwise.
Create a SymbolInfo by parsing a properly formatted objdump output line.
[ "Create", "a", "SymbolInfo", "by", "parsing", "a", "properly", "formatted", "objdump", "output", "line", "." ]
def _FromObjdumpLine(line): m = _OBJDUMP_LINE_RE.match(line) if not m: return None assert m.group('assert_scope') in set(['g', 'l', ' ']), line assert m.group('assert_weak_or_strong') in set(['w', ' ']), line assert m.group('assert_tab') == '\t', line assert m.group('assert_4spaces') == ' ' * 4, line ...
[ "def", "_FromObjdumpLine", "(", "line", ")", ":", "m", "=", "_OBJDUMP_LINE_RE", ".", "match", "(", "line", ")", "if", "not", "m", ":", "return", "None", "assert", "m", ".", "group", "(", "'assert_scope'", ")", "in", "set", "(", "[", "'g'", ",", "'l'"...
Create a SymbolInfo by parsing a properly formatted objdump output line.
[ "Create", "a", "SymbolInfo", "by", "parsing", "a", "properly", "formatted", "objdump", "output", "line", "." ]
[ "\"\"\"Create a SymbolInfo by parsing a properly formatted objdump output line.\n\n Args:\n line: line from objdump\n\n Returns:\n An instance of SymbolInfo if the line represents a symbol, None otherwise.\n \"\"\"", "# A symbol can be (g)lobal, (l)ocal, or neither (a space). Per objdump's", "# manpage...
[ { "param": "line", "type": null } ]
{ "returns": [ { "docstring": "An instance of SymbolInfo if the line represents a symbol, None otherwise.", "docstring_tokens": [ "An", "instance", "of", "SymbolInfo", "if", "the", "line", "represents", "a", "symbol", ...
992f46b9460996b1037e8f694dfa6dbae1e321eb
sunlongbo/chromium
tools/cygprofile/symbol_extractor.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_SymbolInfosFromStream
<not_specific>
def _SymbolInfosFromStream(objdump_lines): """Parses the output of objdump, and get all the symbols from a binary. Args: objdump_lines: An iterable of lines Returns: A list of SymbolInfo. """ name_to_offsets = collections.defaultdict(list) symbol_infos = [] for line in objdump_lines: symbol_...
Parses the output of objdump, and get all the symbols from a binary. Args: objdump_lines: An iterable of lines Returns: A list of SymbolInfo.
Parses the output of objdump, and get all the symbols from a binary.
[ "Parses", "the", "output", "of", "objdump", "and", "get", "all", "the", "symbols", "from", "a", "binary", "." ]
def _SymbolInfosFromStream(objdump_lines): name_to_offsets = collections.defaultdict(list) symbol_infos = [] for line in objdump_lines: symbol_info = _FromObjdumpLine(line.decode('utf-8').rstrip('\n')) if symbol_info is not None: if not symbol_info.name.startswith('__ThumbV7PILongThunk_'): n...
[ "def", "_SymbolInfosFromStream", "(", "objdump_lines", ")", ":", "name_to_offsets", "=", "collections", ".", "defaultdict", "(", "list", ")", "symbol_infos", "=", "[", "]", "for", "line", "in", "objdump_lines", ":", "symbol_info", "=", "_FromObjdumpLine", "(", "...
Parses the output of objdump, and get all the symbols from a binary.
[ "Parses", "the", "output", "of", "objdump", "and", "get", "all", "the", "symbols", "from", "a", "binary", "." ]
[ "\"\"\"Parses the output of objdump, and get all the symbols from a binary.\n\n Args:\n objdump_lines: An iterable of lines\n\n Returns:\n A list of SymbolInfo.\n \"\"\"", "# On ARM the LLD linker inserts pseudo-functions (thunks) that allow", "# jumping distances farther than 16 MiB. Such thunks are k...
[ { "param": "objdump_lines", "type": null } ]
{ "returns": [ { "docstring": "A list of SymbolInfo.", "docstring_tokens": [ "A", "list", "of", "SymbolInfo", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "objdump_lines", "type": null, "docstring...
992f46b9460996b1037e8f694dfa6dbae1e321eb
sunlongbo/chromium
tools/cygprofile/symbol_extractor.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
SymbolInfosFromBinary
<not_specific>
def SymbolInfosFromBinary(binary_filename): """Runs objdump to get all the symbols from a binary. Args: binary_filename: path to the binary. Returns: A list of SymbolInfo from the binary. """ command = [_TOOL_PREFIX + 'objdump', '-t', '-w', binary_filename] try: p = subprocess.Popen(command, s...
Runs objdump to get all the symbols from a binary. Args: binary_filename: path to the binary. Returns: A list of SymbolInfo from the binary.
Runs objdump to get all the symbols from a binary.
[ "Runs", "objdump", "to", "get", "all", "the", "symbols", "from", "a", "binary", "." ]
def SymbolInfosFromBinary(binary_filename): command = [_TOOL_PREFIX + 'objdump', '-t', '-w', binary_filename] try: p = subprocess.Popen(command, stdout=subprocess.PIPE) except OSError as error: logging.error("Failed to execute the command: path=%s, binary_filename=%s", command[0], binary...
[ "def", "SymbolInfosFromBinary", "(", "binary_filename", ")", ":", "command", "=", "[", "_TOOL_PREFIX", "+", "'objdump'", ",", "'-t'", ",", "'-w'", ",", "binary_filename", "]", "try", ":", "p", "=", "subprocess", ".", "Popen", "(", "command", ",", "stdout", ...
Runs objdump to get all the symbols from a binary.
[ "Runs", "objdump", "to", "get", "all", "the", "symbols", "from", "a", "binary", "." ]
[ "\"\"\"Runs objdump to get all the symbols from a binary.\n\n Args:\n binary_filename: path to the binary.\n\n Returns:\n A list of SymbolInfo from the binary.\n \"\"\"" ]
[ { "param": "binary_filename", "type": null } ]
{ "returns": [ { "docstring": "A list of SymbolInfo from the binary.", "docstring_tokens": [ "A", "list", "of", "SymbolInfo", "from", "the", "binary", "." ], "type": null } ], "raises": [], "params": [ { "i...
992f46b9460996b1037e8f694dfa6dbae1e321eb
sunlongbo/chromium
tools/cygprofile/symbol_extractor.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_SymbolInfosFromLlvmNm
<not_specific>
def _SymbolInfosFromLlvmNm(lines): """Extracts all defined symbols names from llvm-nm output. Only defined (weak and regular) symbols are extracted. Args: lines: Iterable of lines. Returns: [str] A list of symbol names, can be empty. """ symbol_names = [] for line in lines: line = line.deco...
Extracts all defined symbols names from llvm-nm output. Only defined (weak and regular) symbols are extracted. Args: lines: Iterable of lines. Returns: [str] A list of symbol names, can be empty.
Extracts all defined symbols names from llvm-nm output. Only defined (weak and regular) symbols are extracted.
[ "Extracts", "all", "defined", "symbols", "names", "from", "llvm", "-", "nm", "output", ".", "Only", "defined", "(", "weak", "and", "regular", ")", "symbols", "are", "extracted", "." ]
def _SymbolInfosFromLlvmNm(lines): symbol_names = [] for line in lines: line = line.decode('utf-8') m = _LLVM_NM_LINE_RE.match(line) assert m is not None, line if m.group('symbol_type') not in ['t', 'T', 'w', 'W']: continue symbol_names.append(m.group('name')) return symbol_names
[ "def", "_SymbolInfosFromLlvmNm", "(", "lines", ")", ":", "symbol_names", "=", "[", "]", "for", "line", "in", "lines", ":", "line", "=", "line", ".", "decode", "(", "'utf-8'", ")", "m", "=", "_LLVM_NM_LINE_RE", ".", "match", "(", "line", ")", "assert", ...
Extracts all defined symbols names from llvm-nm output.
[ "Extracts", "all", "defined", "symbols", "names", "from", "llvm", "-", "nm", "output", "." ]
[ "\"\"\"Extracts all defined symbols names from llvm-nm output.\n\n Only defined (weak and regular) symbols are extracted.\n\n Args:\n lines: Iterable of lines.\n\n Returns:\n [str] A list of symbol names, can be empty.\n \"\"\"" ]
[ { "param": "lines", "type": null } ]
{ "returns": [ { "docstring": "[str] A list of symbol names, can be empty.", "docstring_tokens": [ "[", "str", "]", "A", "list", "of", "symbol", "names", "can", "be", "empty", "." ], "type": nul...
992f46b9460996b1037e8f694dfa6dbae1e321eb
sunlongbo/chromium
tools/cygprofile/symbol_extractor.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
SymbolNamesFromLlvmBitcodeFile
<not_specific>
def SymbolNamesFromLlvmBitcodeFile(filename): """Extracts all defined symbols names from an LLVM bitcode file. Args: filename: (str) File to parse. Returns: [str] A list of symbol names, can be empty. """ command = (_NM_PATH, '--defined-only', filename) p = subprocess.Popen(command, shell=False, s...
Extracts all defined symbols names from an LLVM bitcode file. Args: filename: (str) File to parse. Returns: [str] A list of symbol names, can be empty.
Extracts all defined symbols names from an LLVM bitcode file.
[ "Extracts", "all", "defined", "symbols", "names", "from", "an", "LLVM", "bitcode", "file", "." ]
def SymbolNamesFromLlvmBitcodeFile(filename): command = (_NM_PATH, '--defined-only', filename) p = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) try: result = _SymbolInfosFromLlvmNm(p.stdout) if not result: file_size = os.stat(filename)...
[ "def", "SymbolNamesFromLlvmBitcodeFile", "(", "filename", ")", ":", "command", "=", "(", "_NM_PATH", ",", "'--defined-only'", ",", "filename", ")", "p", "=", "subprocess", ".", "Popen", "(", "command", ",", "shell", "=", "False", ",", "stdout", "=", "subproc...
Extracts all defined symbols names from an LLVM bitcode file.
[ "Extracts", "all", "defined", "symbols", "names", "from", "an", "LLVM", "bitcode", "file", "." ]
[ "\"\"\"Extracts all defined symbols names from an LLVM bitcode file.\n\n Args:\n filename: (str) File to parse.\n\n Returns:\n [str] A list of symbol names, can be empty.\n \"\"\"" ]
[ { "param": "filename", "type": null } ]
{ "returns": [ { "docstring": "[str] A list of symbol names, can be empty.", "docstring_tokens": [ "[", "str", "]", "A", "list", "of", "symbol", "names", "can", "be", "empty", "." ], "type": nul...
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
to_dafsa
<not_specific>
def to_dafsa(words): """Generates a DAFSA from a word list and returns the source node. Each word is split into characters so that each character is represented by a unique node. It is assumed the word list is not empty. """ if not words: raise InputError('The origin list must not be empty') def ToNode...
Generates a DAFSA from a word list and returns the source node. Each word is split into characters so that each character is represented by a unique node. It is assumed the word list is not empty.
Generates a DAFSA from a word list and returns the source node. Each word is split into characters so that each character is represented by a unique node. It is assumed the word list is not empty.
[ "Generates", "a", "DAFSA", "from", "a", "word", "list", "and", "returns", "the", "source", "node", ".", "Each", "word", "is", "split", "into", "characters", "so", "that", "each", "character", "is", "represented", "by", "a", "unique", "node", ".", "It", "...
def to_dafsa(words): if not words: raise InputError('The origin list must not be empty') def ToNodes(word): if not 0x1F < ord(word[0]) < 0x80: raise InputError('Origins must be printable 7-bit ASCII') if len(word) == 1: return chr(ord(word[0]) & 0x0F), [None] return word[0], [ToNodes(wor...
[ "def", "to_dafsa", "(", "words", ")", ":", "if", "not", "words", ":", "raise", "InputError", "(", "'The origin list must not be empty'", ")", "def", "ToNodes", "(", "word", ")", ":", "\"\"\"Split words into characters\"\"\"", "if", "not", "0x1F", "<", "ord", "("...
Generates a DAFSA from a word list and returns the source node.
[ "Generates", "a", "DAFSA", "from", "a", "word", "list", "and", "returns", "the", "source", "node", "." ]
[ "\"\"\"Generates a DAFSA from a word list and returns the source node.\n\n Each word is split into characters so that each character is represented by\n a unique node. It is assumed the word list is not empty.\n \"\"\"", "\"\"\"Split words into characters\"\"\"" ]
[ { "param": "words", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "words", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
to_words
<not_specific>
def to_words(node): """Generates a word list from all paths starting from an internal node.""" if not node: return [''] return [(node[0] + word) for child in node[1] for word in to_words(child)]
Generates a word list from all paths starting from an internal node.
Generates a word list from all paths starting from an internal node.
[ "Generates", "a", "word", "list", "from", "all", "paths", "starting", "from", "an", "internal", "node", "." ]
def to_words(node): if not node: return [''] return [(node[0] + word) for child in node[1] for word in to_words(child)]
[ "def", "to_words", "(", "node", ")", ":", "if", "not", "node", ":", "return", "[", "''", "]", "return", "[", "(", "node", "[", "0", "]", "+", "word", ")", "for", "child", "in", "node", "[", "1", "]", "for", "word", "in", "to_words", "(", "child...
Generates a word list from all paths starting from an internal node.
[ "Generates", "a", "word", "list", "from", "all", "paths", "starting", "from", "an", "internal", "node", "." ]
[ "\"\"\"Generates a word list from all paths starting from an internal node.\"\"\"" ]
[ { "param": "node", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "node", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
reverse
<not_specific>
def reverse(dafsa): """Generates a new DAFSA that is reversed, so that the old sink node becomes the new source node. """ sink = [] nodemap = {} def dfs(node, parent): """Creates reverse nodes. A new reverse node will be created for each old node. The new node will get a reversed label and the...
Generates a new DAFSA that is reversed, so that the old sink node becomes the new source node.
Generates a new DAFSA that is reversed, so that the old sink node becomes the new source node.
[ "Generates", "a", "new", "DAFSA", "that", "is", "reversed", "so", "that", "the", "old", "sink", "node", "becomes", "the", "new", "source", "node", "." ]
def reverse(dafsa): sink = [] nodemap = {} def dfs(node, parent): if not node: sink.append(parent) elif id(node) not in nodemap: nodemap[id(node)] = (node[0][::-1], [parent]) for child in node[1]: dfs(child, nodemap[id(node)]) else: nodemap[id(node)][1].append(parent) ...
[ "def", "reverse", "(", "dafsa", ")", ":", "sink", "=", "[", "]", "nodemap", "=", "{", "}", "def", "dfs", "(", "node", ",", "parent", ")", ":", "\"\"\"Creates reverse nodes.\n\n A new reverse node will be created for each old node. The new node will\n get a reversed ...
Generates a new DAFSA that is reversed, so that the old sink node becomes the new source node.
[ "Generates", "a", "new", "DAFSA", "that", "is", "reversed", "so", "that", "the", "old", "sink", "node", "becomes", "the", "new", "source", "node", "." ]
[ "\"\"\"Generates a new DAFSA that is reversed, so that the old sink node becomes\n the new source node.\n \"\"\"", "\"\"\"Creates reverse nodes.\n\n A new reverse node will be created for each old node. The new node will\n get a reversed label and the parents of the old node as children.\n \"\"\"" ]
[ { "param": "dafsa", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dafsa", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
dfs
null
def dfs(node, parent): """Creates reverse nodes. A new reverse node will be created for each old node. The new node will get a reversed label and the parents of the old node as children. """ if not node: sink.append(parent) elif id(node) not in nodemap: nodemap[id(node)] = (node[0][...
Creates reverse nodes. A new reverse node will be created for each old node. The new node will get a reversed label and the parents of the old node as children.
Creates reverse nodes. A new reverse node will be created for each old node. The new node will get a reversed label and the parents of the old node as children.
[ "Creates", "reverse", "nodes", ".", "A", "new", "reverse", "node", "will", "be", "created", "for", "each", "old", "node", ".", "The", "new", "node", "will", "get", "a", "reversed", "label", "and", "the", "parents", "of", "the", "old", "node", "as", "ch...
def dfs(node, parent): if not node: sink.append(parent) elif id(node) not in nodemap: nodemap[id(node)] = (node[0][::-1], [parent]) for child in node[1]: dfs(child, nodemap[id(node)]) else: nodemap[id(node)][1].append(parent)
[ "def", "dfs", "(", "node", ",", "parent", ")", ":", "if", "not", "node", ":", "sink", ".", "append", "(", "parent", ")", "elif", "id", "(", "node", ")", "not", "in", "nodemap", ":", "nodemap", "[", "id", "(", "node", ")", "]", "=", "(", "node",...
Creates reverse nodes.
[ "Creates", "reverse", "nodes", "." ]
[ "\"\"\"Creates reverse nodes.\n\n A new reverse node will be created for each old node. The new node will\n get a reversed label and the parents of the old node as children.\n \"\"\"" ]
[ { "param": "node", "type": null }, { "param": "parent", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "node", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "parent", "type": null, "docstring": null, "docstring_tokens":...
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
join_labels
<not_specific>
def join_labels(dafsa): """Generates a new DAFSA where internal nodes are merged if there is a one to one connection. """ parentcount = { id(None): 2 } nodemap = { id(None): None } def count_parents(node): """Count incoming references""" if id(node) in parentcount: parentcount[id(node)] += 1 ...
Generates a new DAFSA where internal nodes are merged if there is a one to one connection.
Generates a new DAFSA where internal nodes are merged if there is a one to one connection.
[ "Generates", "a", "new", "DAFSA", "where", "internal", "nodes", "are", "merged", "if", "there", "is", "a", "one", "to", "one", "connection", "." ]
def join_labels(dafsa): parentcount = { id(None): 2 } nodemap = { id(None): None } def count_parents(node): if id(node) in parentcount: parentcount[id(node)] += 1 else: parentcount[id(node)] = 1 for child in node[1]: count_parents(child) def join(node): if id(node) not in n...
[ "def", "join_labels", "(", "dafsa", ")", ":", "parentcount", "=", "{", "id", "(", "None", ")", ":", "2", "}", "nodemap", "=", "{", "id", "(", "None", ")", ":", "None", "}", "def", "count_parents", "(", "node", ")", ":", "\"\"\"Count incoming references...
Generates a new DAFSA where internal nodes are merged if there is a one to one connection.
[ "Generates", "a", "new", "DAFSA", "where", "internal", "nodes", "are", "merged", "if", "there", "is", "a", "one", "to", "one", "connection", "." ]
[ "\"\"\"Generates a new DAFSA where internal nodes are merged if there is a one to\n one connection.\n \"\"\"", "\"\"\"Count incoming references\"\"\"", "\"\"\"Create new nodes\"\"\"" ]
[ { "param": "dafsa", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dafsa", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
join_suffixes
<not_specific>
def join_suffixes(dafsa): """Generates a new DAFSA where nodes that represent the same word lists towards the sink are merged. """ nodemap = { frozenset(('',)): None } def join(node): """Returns a macthing node. A new node is created if no matching node exists. The graph is accessed in dfs order. ...
Generates a new DAFSA where nodes that represent the same word lists towards the sink are merged.
Generates a new DAFSA where nodes that represent the same word lists towards the sink are merged.
[ "Generates", "a", "new", "DAFSA", "where", "nodes", "that", "represent", "the", "same", "word", "lists", "towards", "the", "sink", "are", "merged", "." ]
def join_suffixes(dafsa): nodemap = { frozenset(('',)): None } def join(node): suffixes = frozenset(to_words(node)) if suffixes not in nodemap: nodemap[suffixes] = (node[0], [join(child) for child in node[1]]) return nodemap[suffixes] return [join(node) for node in dafsa]
[ "def", "join_suffixes", "(", "dafsa", ")", ":", "nodemap", "=", "{", "frozenset", "(", "(", "''", ",", ")", ")", ":", "None", "}", "def", "join", "(", "node", ")", ":", "\"\"\"Returns a macthing node. A new node is created if no matching node\n exists. The graph ...
Generates a new DAFSA where nodes that represent the same word lists towards the sink are merged.
[ "Generates", "a", "new", "DAFSA", "where", "nodes", "that", "represent", "the", "same", "word", "lists", "towards", "the", "sink", "are", "merged", "." ]
[ "\"\"\"Generates a new DAFSA where nodes that represent the same word lists\n towards the sink are merged.\n \"\"\"", "\"\"\"Returns a macthing node. A new node is created if no matching node\n exists. The graph is accessed in dfs order.\n \"\"\"" ]
[ { "param": "dafsa", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dafsa", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
top_sort
<not_specific>
def top_sort(dafsa): """Generates list of nodes in topological sort order.""" incoming = {} def count_incoming(node): """Counts incoming references.""" if node: if id(node) not in incoming: incoming[id(node)] = 1 for child in node[1]: count_incoming(child) else: ...
Generates list of nodes in topological sort order.
Generates list of nodes in topological sort order.
[ "Generates", "list", "of", "nodes", "in", "topological", "sort", "order", "." ]
def top_sort(dafsa): incoming = {} def count_incoming(node): if node: if id(node) not in incoming: incoming[id(node)] = 1 for child in node[1]: count_incoming(child) else: incoming[id(node)] += 1 for node in dafsa: count_incoming(node) for node in dafsa: ...
[ "def", "top_sort", "(", "dafsa", ")", ":", "incoming", "=", "{", "}", "def", "count_incoming", "(", "node", ")", ":", "\"\"\"Counts incoming references.\"\"\"", "if", "node", ":", "if", "id", "(", "node", ")", "not", "in", "incoming", ":", "incoming", "[",...
Generates list of nodes in topological sort order.
[ "Generates", "list", "of", "nodes", "in", "topological", "sort", "order", "." ]
[ "\"\"\"Generates list of nodes in topological sort order.\"\"\"", "\"\"\"Counts incoming references.\"\"\"" ]
[ { "param": "dafsa", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dafsa", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
encode_links
<not_specific>
def encode_links(children, offsets, current): """Encodes a list of children as one, two or three byte offsets.""" if not children[0]: # This is an <end_label> node and no links follow such nodes assert len(children) == 1 return [] guess = 3 * len(children) assert children children = sorted(childre...
Encodes a list of children as one, two or three byte offsets.
Encodes a list of children as one, two or three byte offsets.
[ "Encodes", "a", "list", "of", "children", "as", "one", "two", "or", "three", "byte", "offsets", "." ]
def encode_links(children, offsets, current): if not children[0]: assert len(children) == 1 return [] guess = 3 * len(children) assert children children = sorted(children, key = lambda x: -offsets[id(x)]) while True: offset = current + guess buf = [] for child in children: last = len...
[ "def", "encode_links", "(", "children", ",", "offsets", ",", "current", ")", ":", "if", "not", "children", "[", "0", "]", ":", "assert", "len", "(", "children", ")", "==", "1", "return", "[", "]", "guess", "=", "3", "*", "len", "(", "children", ")"...
Encodes a list of children as one, two or three byte offsets.
[ "Encodes", "a", "list", "of", "children", "as", "one", "two", "or", "three", "byte", "offsets", "." ]
[ "\"\"\"Encodes a list of children as one, two or three byte offsets.\"\"\"", "# This is an <end_label> node and no links follow such nodes", "# A 6-bit offset: \"s0xxxxxx\"", "# A 13-bit offset: \"s10xxxxxxxxxxxxx\"", "# A 21-bit offset: \"s11xxxxxxxxxxxxxxxxxxxxx\"", "# Distance in first link is relative...
[ { "param": "children", "type": null }, { "param": "offsets", "type": null }, { "param": "current", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "children", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offsets", "type": null, "docstring": null, "docstring_tok...
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
encode_prefix
<not_specific>
def encode_prefix(label): """Encodes a node label as a list of bytes without a trailing high byte. This method encodes a node if there is exactly one child and the child follows immidiately after so that no jump is needed. This label will then be a prefix to the label in the child node. """ assert label ...
Encodes a node label as a list of bytes without a trailing high byte. This method encodes a node if there is exactly one child and the child follows immidiately after so that no jump is needed. This label will then be a prefix to the label in the child node.
Encodes a node label as a list of bytes without a trailing high byte. This method encodes a node if there is exactly one child and the child follows immidiately after so that no jump is needed. This label will then be a prefix to the label in the child node.
[ "Encodes", "a", "node", "label", "as", "a", "list", "of", "bytes", "without", "a", "trailing", "high", "byte", ".", "This", "method", "encodes", "a", "node", "if", "there", "is", "exactly", "one", "child", "and", "the", "child", "follows", "immidiately", ...
def encode_prefix(label): assert label return [ord(c) for c in reversed(label)]
[ "def", "encode_prefix", "(", "label", ")", ":", "assert", "label", "return", "[", "ord", "(", "c", ")", "for", "c", "in", "reversed", "(", "label", ")", "]" ]
Encodes a node label as a list of bytes without a trailing high byte.
[ "Encodes", "a", "node", "label", "as", "a", "list", "of", "bytes", "without", "a", "trailing", "high", "byte", "." ]
[ "\"\"\"Encodes a node label as a list of bytes without a trailing high byte.\n\n This method encodes a node if there is exactly one child and the\n child follows immidiately after so that no jump is needed. This label\n will then be a prefix to the label in the child node.\n \"\"\"" ]
[ { "param": "label", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "label", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
encode_label
<not_specific>
def encode_label(label): """Encodes a node label as a list of bytes with a trailing high byte >0x80. """ buf = encode_prefix(label) # Set most significant bit to mark end of label in this node. buf[0] |= (1 << 7) return buf
Encodes a node label as a list of bytes with a trailing high byte >0x80.
Encodes a node label as a list of bytes with a trailing high byte >0x80.
[ "Encodes", "a", "node", "label", "as", "a", "list", "of", "bytes", "with", "a", "trailing", "high", "byte", ">", "0x80", "." ]
def encode_label(label): buf = encode_prefix(label) buf[0] |= (1 << 7) return buf
[ "def", "encode_label", "(", "label", ")", ":", "buf", "=", "encode_prefix", "(", "label", ")", "buf", "[", "0", "]", "|=", "(", "1", "<<", "7", ")", "return", "buf" ]
Encodes a node label as a list of bytes with a trailing high byte >0x80.
[ "Encodes", "a", "node", "label", "as", "a", "list", "of", "bytes", "with", "a", "trailing", "high", "byte", ">", "0x80", "." ]
[ "\"\"\"Encodes a node label as a list of bytes with a trailing high byte >0x80.\n \"\"\"", "# Set most significant bit to mark end of label in this node." ]
[ { "param": "label", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "label", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
encode
<not_specific>
def encode(dafsa): """Encodes a DAFSA to a list of bytes""" output = [] offsets = {} for node in reversed(top_sort(dafsa)): if (len(node[1]) == 1 and node[1][0] and (offsets[id(node[1][0])] == len(output))): output.extend(encode_prefix(node[0])) else: output.extend(encode_links(node...
Encodes a DAFSA to a list of bytes
Encodes a DAFSA to a list of bytes
[ "Encodes", "a", "DAFSA", "to", "a", "list", "of", "bytes" ]
def encode(dafsa): output = [] offsets = {} for node in reversed(top_sort(dafsa)): if (len(node[1]) == 1 and node[1][0] and (offsets[id(node[1][0])] == len(output))): output.extend(encode_prefix(node[0])) else: output.extend(encode_links(node[1], offsets, len(output))) output.ext...
[ "def", "encode", "(", "dafsa", ")", ":", "output", "=", "[", "]", "offsets", "=", "{", "}", "for", "node", "in", "reversed", "(", "top_sort", "(", "dafsa", ")", ")", ":", "if", "(", "len", "(", "node", "[", "1", "]", ")", "==", "1", "and", "n...
Encodes a DAFSA to a list of bytes
[ "Encodes", "a", "DAFSA", "to", "a", "list", "of", "bytes" ]
[ "\"\"\"Encodes a DAFSA to a list of bytes\"\"\"" ]
[ { "param": "dafsa", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dafsa", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
to_proto
<not_specific>
def to_proto(data): """Generates protobuf from a list of encoded bytes.""" message = media_engagement_preload_pb2.PreloadedData() message.dafsa = array.array('B', data).tobytes() return message.SerializeToString()
Generates protobuf from a list of encoded bytes.
Generates protobuf from a list of encoded bytes.
[ "Generates", "protobuf", "from", "a", "list", "of", "encoded", "bytes", "." ]
def to_proto(data): message = media_engagement_preload_pb2.PreloadedData() message.dafsa = array.array('B', data).tobytes() return message.SerializeToString()
[ "def", "to_proto", "(", "data", ")", ":", "message", "=", "media_engagement_preload_pb2", ".", "PreloadedData", "(", ")", "message", ".", "dafsa", "=", "array", ".", "array", "(", "'B'", ",", "data", ")", ".", "tobytes", "(", ")", "return", "message", "....
Generates protobuf from a list of encoded bytes.
[ "Generates", "protobuf", "from", "a", "list", "of", "encoded", "bytes", "." ]
[ "\"\"\"Generates protobuf from a list of encoded bytes.\"\"\"" ]
[ { "param": "data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "data", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
words_to_proto
<not_specific>
def words_to_proto(words): """Generates protobuf from a word list""" dafsa = to_dafsa(words) for fun in (reverse, join_suffixes, reverse, join_suffixes, join_labels): dafsa = fun(dafsa) return to_proto(encode(dafsa))
Generates protobuf from a word list
Generates protobuf from a word list
[ "Generates", "protobuf", "from", "a", "word", "list" ]
def words_to_proto(words): dafsa = to_dafsa(words) for fun in (reverse, join_suffixes, reverse, join_suffixes, join_labels): dafsa = fun(dafsa) return to_proto(encode(dafsa))
[ "def", "words_to_proto", "(", "words", ")", ":", "dafsa", "=", "to_dafsa", "(", "words", ")", "for", "fun", "in", "(", "reverse", ",", "join_suffixes", ",", "reverse", ",", "join_suffixes", ",", "join_labels", ")", ":", "dafsa", "=", "fun", "(", "dafsa",...
Generates protobuf from a word list
[ "Generates", "protobuf", "from", "a", "word", "list" ]
[ "\"\"\"Generates protobuf from a word list\"\"\"" ]
[ { "param": "words", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "words", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db78c6720f48f3195756e510289576691c2e3f66
sunlongbo/chromium
tools/media_engagement_preload/make_dafsa.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
parse_json
<not_specific>
def parse_json(infile): """Parses the JSON input file and appends a 0 or 1 based on protocol.""" try: netlocs = {} for entry in json.loads(infile): # Parse the origin and reject any with an invalid protocol. parsed = urllib.parse.urlparse(entry) if parsed.scheme != 'http' and parsed.scheme...
Parses the JSON input file and appends a 0 or 1 based on protocol.
Parses the JSON input file and appends a 0 or 1 based on protocol.
[ "Parses", "the", "JSON", "input", "file", "and", "appends", "a", "0", "or", "1", "based", "on", "protocol", "." ]
def parse_json(infile): try: netlocs = {} for entry in json.loads(infile): parsed = urllib.parse.urlparse(entry) if parsed.scheme != 'http' and parsed.scheme != 'https': raise InputError('Invalid protocol: %s' % entry) netlocs[parsed.netloc] = max( netlocs.get(parsed.netloc...
[ "def", "parse_json", "(", "infile", ")", ":", "try", ":", "netlocs", "=", "{", "}", "for", "entry", "in", "json", ".", "loads", "(", "infile", ")", ":", "parsed", "=", "urllib", ".", "parse", ".", "urlparse", "(", "entry", ")", "if", "parsed", ".",...
Parses the JSON input file and appends a 0 or 1 based on protocol.
[ "Parses", "the", "JSON", "input", "file", "and", "appends", "a", "0", "or", "1", "based", "on", "protocol", "." ]
[ "\"\"\"Parses the JSON input file and appends a 0 or 1 based on protocol.\"\"\"", "# Parse the origin and reject any with an invalid protocol.", "# Store the netloc in netlocs with a flag for either HTTP+HTTPS or HTTPS", "# only. The HTTP+HTTPS value is numerically higher than HTTPS only so it", "# will tak...
[ { "param": "infile", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "infile", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db8096c4a89df06c318f51eb15b2fed0670ad786
sunlongbo/chromium
third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
tokenize_name
<not_specific>
def tokenize_name(name): """Tokenize the specified name. A token consists of A-Z, a-z, and 0-9 characters. Other characters work as token delimiters, and the resultant list won't contain such characters. Capital letters also work as delimiters. E.g. 'FooBar-baz' is tokenized to ['Foo', 'Bar', 'baz...
Tokenize the specified name. A token consists of A-Z, a-z, and 0-9 characters. Other characters work as token delimiters, and the resultant list won't contain such characters. Capital letters also work as delimiters. E.g. 'FooBar-baz' is tokenized to ['Foo', 'Bar', 'baz']. See _TOKEN_PATTERNS for more...
Tokenize the specified name. A token consists of A-Z, a-z, and 0-9 characters. Other characters work as token delimiters, and the resultant list won't contain such characters. Capital letters also work as delimiters. This function detects special cases that are not easily discernible without additional knowledge, such...
[ "Tokenize", "the", "specified", "name", ".", "A", "token", "consists", "of", "A", "-", "Z", "a", "-", "z", "and", "0", "-", "9", "characters", ".", "Other", "characters", "work", "as", "token", "delimiters", "and", "the", "resultant", "list", "won", "'...
def tokenize_name(name): tokens = [] match = re.search(r'^(' + '|'.join(_SPECIAL_TOKENS_WITH_NUMBERS) + r')', name, re.IGNORECASE) if match: tokens.append(match.group(0)) name = name[match.end(0):] return tokens + _TOKEN_RE.findall(name)
[ "def", "tokenize_name", "(", "name", ")", ":", "tokens", "=", "[", "]", "match", "=", "re", ".", "search", "(", "r'^('", "+", "'|'", ".", "join", "(", "_SPECIAL_TOKENS_WITH_NUMBERS", ")", "+", "r')'", ",", "name", ",", "re", ".", "IGNORECASE", ")", "...
Tokenize the specified name.
[ "Tokenize", "the", "specified", "name", "." ]
[ "\"\"\"Tokenize the specified name.\n\n A token consists of A-Z, a-z, and 0-9 characters. Other characters work as\n token delimiters, and the resultant list won't contain such characters.\n Capital letters also work as delimiters. E.g. 'FooBar-baz' is tokenized to\n ['Foo', 'Bar', 'baz']. See _TOKEN_P...
[ { "param": "name", "type": null } ]
{ "returns": [ { "docstring": "A list of token strings.", "docstring_tokens": [ "A", "list", "of", "token", "strings", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "name", "type": null, "d...
db8096c4a89df06c318f51eb15b2fed0670ad786
sunlongbo/chromium
third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
to_lower_camel_case
<not_specific>
def to_lower_camel_case(self): """Lower camel case is the name style for attribute names and operation names in web platform APIs. e.g. 'addEventListener', 'documentURI', 'fftSize' https://en.wikipedia.org/wiki/Camel_case. """ if not self.tokens: retu...
Lower camel case is the name style for attribute names and operation names in web platform APIs. e.g. 'addEventListener', 'documentURI', 'fftSize' https://en.wikipedia.org/wiki/Camel_case.
Lower camel case is the name style for attribute names and operation names in web platform APIs.
[ "Lower", "camel", "case", "is", "the", "name", "style", "for", "attribute", "names", "and", "operation", "names", "in", "web", "platform", "APIs", "." ]
def to_lower_camel_case(self): if not self.tokens: return '' return self.tokens[0].lower() + ''.join( [token[0].upper() + token[1:] for token in self.tokens[1:]])
[ "def", "to_lower_camel_case", "(", "self", ")", ":", "if", "not", "self", ".", "tokens", ":", "return", "''", "return", "self", ".", "tokens", "[", "0", "]", ".", "lower", "(", ")", "+", "''", ".", "join", "(", "[", "token", "[", "0", "]", ".", ...
Lower camel case is the name style for attribute names and operation names in web platform APIs.
[ "Lower", "camel", "case", "is", "the", "name", "style", "for", "attribute", "names", "and", "operation", "names", "in", "web", "platform", "APIs", "." ]
[ "\"\"\"Lower camel case is the name style for attribute names and operation\n names in web platform APIs.\n e.g. 'addEventListener', 'documentURI', 'fftSize'\n https://en.wikipedia.org/wiki/Camel_case.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db8096c4a89df06c318f51eb15b2fed0670ad786
sunlongbo/chromium
third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
to_class_name
<not_specific>
def to_class_name(self, prefix=None, suffix=None): """Represents this name as a class name in Chromium C++ style. i.e. UpperCamelCase. """ camel_prefix = prefix[0].upper() + prefix[1:].lower() if prefix else '' camel_suffix = suffix[0].upper() + suffix[1:].lower() if suffix else...
Represents this name as a class name in Chromium C++ style. i.e. UpperCamelCase.
Represents this name as a class name in Chromium C++ style.
[ "Represents", "this", "name", "as", "a", "class", "name", "in", "Chromium", "C", "++", "style", "." ]
def to_class_name(self, prefix=None, suffix=None): camel_prefix = prefix[0].upper() + prefix[1:].lower() if prefix else '' camel_suffix = suffix[0].upper() + suffix[1:].lower() if suffix else '' return camel_prefix + self.to_upper_camel_case() + camel_suffix
[ "def", "to_class_name", "(", "self", ",", "prefix", "=", "None", ",", "suffix", "=", "None", ")", ":", "camel_prefix", "=", "prefix", "[", "0", "]", ".", "upper", "(", ")", "+", "prefix", "[", "1", ":", "]", ".", "lower", "(", ")", "if", "prefix"...
Represents this name as a class name in Chromium C++ style.
[ "Represents", "this", "name", "as", "a", "class", "name", "in", "Chromium", "C", "++", "style", "." ]
[ "\"\"\"Represents this name as a class name in Chromium C++ style.\n\n i.e. UpperCamelCase.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "prefix", "type": null }, { "param": "suffix", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "prefix", "type": null, "docstring": null, "docstring_tokens":...
db8096c4a89df06c318f51eb15b2fed0670ad786
sunlongbo/chromium
third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
to_class_data_member
<not_specific>
def to_class_data_member(self, prefix=None, suffix=None): """Represents this name as a data member name in Chromium C++ style. i.e. snake_case_with_trailing_underscore_. """ lower_prefix = prefix.lower() + '_' if prefix else '' lower_suffix = suffix.lower() + '_' if suffix else ...
Represents this name as a data member name in Chromium C++ style. i.e. snake_case_with_trailing_underscore_.
Represents this name as a data member name in Chromium C++ style.
[ "Represents", "this", "name", "as", "a", "data", "member", "name", "in", "Chromium", "C", "++", "style", "." ]
def to_class_data_member(self, prefix=None, suffix=None): lower_prefix = prefix.lower() + '_' if prefix else '' lower_suffix = suffix.lower() + '_' if suffix else '' return lower_prefix + self.to_snake_case() + '_' + lower_suffix
[ "def", "to_class_data_member", "(", "self", ",", "prefix", "=", "None", ",", "suffix", "=", "None", ")", ":", "lower_prefix", "=", "prefix", ".", "lower", "(", ")", "+", "'_'", "if", "prefix", "else", "''", "lower_suffix", "=", "suffix", ".", "lower", ...
Represents this name as a data member name in Chromium C++ style.
[ "Represents", "this", "name", "as", "a", "data", "member", "name", "in", "Chromium", "C", "++", "style", "." ]
[ "\"\"\"Represents this name as a data member name in Chromium C++ style.\n\n i.e. snake_case_with_trailing_underscore_.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "prefix", "type": null }, { "param": "suffix", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "prefix", "type": null, "docstring": null, "docstring_tokens":...
db8096c4a89df06c318f51eb15b2fed0670ad786
sunlongbo/chromium
third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
to_function_name
<not_specific>
def to_function_name(self, prefix=None, suffix=None): """Represents this name as a function name in Blink C++ style. i.e. UpperCamelCase Note that this function should not be used for IDL operation names and C++ functions implementing IDL operations and attributes. """ c...
Represents this name as a function name in Blink C++ style. i.e. UpperCamelCase Note that this function should not be used for IDL operation names and C++ functions implementing IDL operations and attributes.
Represents this name as a function name in Blink C++ style.
[ "Represents", "this", "name", "as", "a", "function", "name", "in", "Blink", "C", "++", "style", "." ]
def to_function_name(self, prefix=None, suffix=None): camel_prefix = prefix[0].upper() + prefix[1:].lower() if prefix else '' camel_suffix = '' if type(suffix) is list: for item in suffix: camel_suffix += item[0].upper() + item[1:].lower() elif suffix: ...
[ "def", "to_function_name", "(", "self", ",", "prefix", "=", "None", ",", "suffix", "=", "None", ")", ":", "camel_prefix", "=", "prefix", "[", "0", "]", ".", "upper", "(", ")", "+", "prefix", "[", "1", ":", "]", ".", "lower", "(", ")", "if", "pref...
Represents this name as a function name in Blink C++ style.
[ "Represents", "this", "name", "as", "a", "function", "name", "in", "Blink", "C", "++", "style", "." ]
[ "\"\"\"Represents this name as a function name in Blink C++ style.\n\n i.e. UpperCamelCase\n Note that this function should not be used for IDL operation names and\n C++ functions implementing IDL operations and attributes.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "prefix", "type": null }, { "param": "suffix", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "prefix", "type": null, "docstring": null, "docstring_tokens":...
db8096c4a89df06c318f51eb15b2fed0670ad786
sunlongbo/chromium
third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
to_enum_value
<not_specific>
def to_enum_value(self): """Represents this name as an enum value in Blink C++ style. i.e. kUpperCamelCase """ return 'k' + self.to_upper_camel_case()
Represents this name as an enum value in Blink C++ style. i.e. kUpperCamelCase
Represents this name as an enum value in Blink C++ style.
[ "Represents", "this", "name", "as", "an", "enum", "value", "in", "Blink", "C", "++", "style", "." ]
def to_enum_value(self): return 'k' + self.to_upper_camel_case()
[ "def", "to_enum_value", "(", "self", ")", ":", "return", "'k'", "+", "self", ".", "to_upper_camel_case", "(", ")" ]
Represents this name as an enum value in Blink C++ style.
[ "Represents", "this", "name", "as", "an", "enum", "value", "in", "Blink", "C", "++", "style", "." ]
[ "\"\"\"Represents this name as an enum value in Blink C++ style.\n\n i.e. kUpperCamelCase\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
db8096c4a89df06c318f51eb15b2fed0670ad786
sunlongbo/chromium
third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
to_header_guard
<not_specific>
def to_header_guard(self): """Represents this name as a header guard style in Chromium C++ style. i.e. THIRD_PARTY_BLINK_RENDERER_MODULES_MODULES_EXPORT_H_ """ return re.sub(r'[-/.]', '_', self.to_macro_case()) + '_'
Represents this name as a header guard style in Chromium C++ style. i.e. THIRD_PARTY_BLINK_RENDERER_MODULES_MODULES_EXPORT_H_
Represents this name as a header guard style in Chromium C++ style.
[ "Represents", "this", "name", "as", "a", "header", "guard", "style", "in", "Chromium", "C", "++", "style", "." ]
def to_header_guard(self): return re.sub(r'[-/.]', '_', self.to_macro_case()) + '_'
[ "def", "to_header_guard", "(", "self", ")", ":", "return", "re", ".", "sub", "(", "r'[-/.]'", ",", "'_'", ",", "self", ".", "to_macro_case", "(", ")", ")", "+", "'_'" ]
Represents this name as a header guard style in Chromium C++ style.
[ "Represents", "this", "name", "as", "a", "header", "guard", "style", "in", "Chromium", "C", "++", "style", "." ]
[ "\"\"\"Represents this name as a header guard style in Chromium C++ style.\n\n i.e. THIRD_PARTY_BLINK_RENDERER_MODULES_MODULES_EXPORT_H_\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
13a49912a4cba5f3ddc6e7dee8b2b97713d8604f
sunlongbo/chromium
third_party/blink/renderer/bindings/scripts/validator/framework/rule_base.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
validate
null
def validate(self, assert_, target): """ Validates that `target` satisfies the rule. Args: assert_: A function which takes a condition and a string error message. target: An object included in web_idl.Database. """ raise NotImplemented...
Validates that `target` satisfies the rule. Args: assert_: A function which takes a condition and a string error message. target: An object included in web_idl.Database.
Validates that `target` satisfies the rule.
[ "Validates", "that", "`", "target", "`", "satisfies", "the", "rule", "." ]
def validate(self, assert_, target): raise NotImplementedError()
[ "def", "validate", "(", "self", ",", "assert_", ",", "target", ")", ":", "raise", "NotImplementedError", "(", ")" ]
Validates that `target` satisfies the rule.
[ "Validates", "that", "`", "target", "`", "satisfies", "the", "rule", "." ]
[ "\"\"\"\n Validates that `target` satisfies the rule.\n\n Args:\n assert_:\n A function which takes a condition and a string error message.\n target:\n An object included in web_idl.Database.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "assert_", "type": null }, { "param": "target", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "assert_", "type": null, "docstring": "A function which takes a cond...
6b7c329148732fc573fa36c8c32b8fff5616a768
sunlongbo/chromium
content/test/gpu/fuchsia_util.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
RunTestOnFuchsiaDevice
<not_specific>
def RunTestOnFuchsiaDevice(script_cmd): """Preps Fuchsia device with pave and package update, then runs script.""" parser = argparse.ArgumentParser() AddCommonArgs(parser) AddTargetSpecificArgs(parser) runner_script_args, test_args = parser.parse_known_args() ConfigureLogging(runner_script_args) # If ou...
Preps Fuchsia device with pave and package update, then runs script.
Preps Fuchsia device with pave and package update, then runs script.
[ "Preps", "Fuchsia", "device", "with", "pave", "and", "package", "update", "then", "runs", "script", "." ]
def RunTestOnFuchsiaDevice(script_cmd): parser = argparse.ArgumentParser() AddCommonArgs(parser) AddTargetSpecificArgs(parser) runner_script_args, test_args = parser.parse_known_args() ConfigureLogging(runner_script_args) if not runner_script_args.out_dir: runner_script_args.out_dir = os.getcwd() clea...
[ "def", "RunTestOnFuchsiaDevice", "(", "script_cmd", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "AddCommonArgs", "(", "parser", ")", "AddTargetSpecificArgs", "(", "parser", ")", "runner_script_args", ",", "test_args", "=", "parser", ".", ...
Preps Fuchsia device with pave and package update, then runs script.
[ "Preps", "Fuchsia", "device", "with", "pave", "and", "package", "update", "then", "runs", "script", "." ]
[ "\"\"\"Preps Fuchsia device with pave and package update, then runs script.\"\"\"", "# If out_dir is not set, assume the script is being launched", "# from the output directory.", "# Create a temporary log file that Telemetry will look to use to build", "# an artifact when tests fail.", "# Pass all other ...
[ { "param": "script_cmd", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "script_cmd", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b950aecc6cc812b3a3ab15d15d20e095ad2c194
sunlongbo/chromium
third_party/blink/tools/blinkpy/web_tests/port/linux.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_setup_dummy_home_dir
null
def _setup_dummy_home_dir(self): """Creates a dummy home directory for running the test. This is a workaround for crbug.com/595504; see crbug.com/612730. If crbug.com/612730 is resolved in another way, then this may be unnecessary. """ self._original_home = self.host.env...
Creates a dummy home directory for running the test. This is a workaround for crbug.com/595504; see crbug.com/612730. If crbug.com/612730 is resolved in another way, then this may be unnecessary.
Creates a dummy home directory for running the test.
[ "Creates", "a", "dummy", "home", "directory", "for", "running", "the", "test", "." ]
def _setup_dummy_home_dir(self): self._original_home = self.host.environ.get('HOME') self._original_cipd_cache_dir = self.host.environ.get('CIPD_CACHE_DIR') dummy_home = str(self._filesystem.mkdtemp()) self.host.environ['HOME'] = dummy_home self.host.environ['CIPD_CACHE_DIR'] = o...
[ "def", "_setup_dummy_home_dir", "(", "self", ")", ":", "self", ".", "_original_home", "=", "self", ".", "host", ".", "environ", ".", "get", "(", "'HOME'", ")", "self", ".", "_original_cipd_cache_dir", "=", "self", ".", "host", ".", "environ", ".", "get", ...
Creates a dummy home directory for running the test.
[ "Creates", "a", "dummy", "home", "directory", "for", "running", "the", "test", "." ]
[ "\"\"\"Creates a dummy home directory for running the test.\n\n This is a workaround for crbug.com/595504; see crbug.com/612730.\n If crbug.com/612730 is resolved in another way, then this may be\n unnecessary.\n \"\"\"", "# When using a dummy home directory, CIPD cache directory needs...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b950aecc6cc812b3a3ab15d15d20e095ad2c194
sunlongbo/chromium
third_party/blink/tools/blinkpy/web_tests/port/linux.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_clean_up_dummy_home_dir
null
def _clean_up_dummy_home_dir(self): """Cleans up the dummy dir and resets the HOME environment variable.""" dummy_home = self.host.environ['HOME'] assert dummy_home != self._original_home self._filesystem.rmtree(dummy_home) self.host.environ['HOME'] = self._original_home ...
Cleans up the dummy dir and resets the HOME environment variable.
Cleans up the dummy dir and resets the HOME environment variable.
[ "Cleans", "up", "the", "dummy", "dir", "and", "resets", "the", "HOME", "environment", "variable", "." ]
def _clean_up_dummy_home_dir(self): dummy_home = self.host.environ['HOME'] assert dummy_home != self._original_home self._filesystem.rmtree(dummy_home) self.host.environ['HOME'] = self._original_home if self._original_cipd_cache_dir: self.host.environ['CIPD_CACHE_DIR'...
[ "def", "_clean_up_dummy_home_dir", "(", "self", ")", ":", "dummy_home", "=", "self", ".", "host", ".", "environ", "[", "'HOME'", "]", "assert", "dummy_home", "!=", "self", ".", "_original_home", "self", ".", "_filesystem", ".", "rmtree", "(", "dummy_home", "...
Cleans up the dummy dir and resets the HOME environment variable.
[ "Cleans", "up", "the", "dummy", "dir", "and", "resets", "the", "HOME", "environment", "variable", "." ]
[ "\"\"\"Cleans up the dummy dir and resets the HOME environment variable.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b950aecc6cc812b3a3ab15d15d20e095ad2c194
sunlongbo/chromium
third_party/blink/tools/blinkpy/web_tests/port/linux.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_find_display
<not_specific>
def _find_display(self): """Tries to find a free X display, looping if necessary.""" # The "xvfb-run" command uses :99 by default. for display_number in range(99, 120): if self.host.filesystem.exists('/tmp/.X%d-lock' % display_number): continue display = '...
Tries to find a free X display, looping if necessary.
Tries to find a free X display, looping if necessary.
[ "Tries", "to", "find", "a", "free", "X", "display", "looping", "if", "necessary", "." ]
def _find_display(self): for display_number in range(99, 120): if self.host.filesystem.exists('/tmp/.X%d-lock' % display_number): continue display = ':%d' % display_number exit_code = self.host.executive.run_command( ['xdpyinfo', '-display', di...
[ "def", "_find_display", "(", "self", ")", ":", "for", "display_number", "in", "range", "(", "99", ",", "120", ")", ":", "if", "self", ".", "host", ".", "filesystem", ".", "exists", "(", "'/tmp/.X%d-lock'", "%", "display_number", ")", ":", "continue", "di...
Tries to find a free X display, looping if necessary.
[ "Tries", "to", "find", "a", "free", "X", "display", "looping", "if", "necessary", "." ]
[ "\"\"\"Tries to find a free X display, looping if necessary.\"\"\"", "# The \"xvfb-run\" command uses :99 by default." ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6b9deb25bbc68d7013ff0fb2a8604e663545f00d
sunlongbo/chromium
tools/symsrc/img_fingerprint.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
GetImgFingerprint
<not_specific>
def GetImgFingerprint(filename): """Returns the fingerprint for an image file""" pe = pefile.PE(filename) return "%08X%x" % ( pe.FILE_HEADER.TimeDateStamp, pe.OPTIONAL_HEADER.SizeOfImage)
Returns the fingerprint for an image file
Returns the fingerprint for an image file
[ "Returns", "the", "fingerprint", "for", "an", "image", "file" ]
def GetImgFingerprint(filename): pe = pefile.PE(filename) return "%08X%x" % ( pe.FILE_HEADER.TimeDateStamp, pe.OPTIONAL_HEADER.SizeOfImage)
[ "def", "GetImgFingerprint", "(", "filename", ")", ":", "pe", "=", "pefile", ".", "PE", "(", "filename", ")", "return", "\"%08X%x\"", "%", "(", "pe", ".", "FILE_HEADER", ".", "TimeDateStamp", ",", "pe", ".", "OPTIONAL_HEADER", ".", "SizeOfImage", ")" ]
Returns the fingerprint for an image file
[ "Returns", "the", "fingerprint", "for", "an", "image", "file" ]
[ "\"\"\"Returns the fingerprint for an image file\"\"\"" ]
[ { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d85e330ebdb01d0061cc24e4010090c779507999
sunlongbo/chromium
tools/metrics/actions/action_utils.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
CreateActionsFromSuffixes
null
def CreateActionsFromSuffixes(actions_dict, action_suffix_nodes): """Creates new actions from suffixes and adds them to actions_dict. Args: actions_dict: dict of existing action name to Action object. action_suffix_nodes: a list of action-suffix nodes Returns: A dictionary of action name to list of ...
Creates new actions from suffixes and adds them to actions_dict. Args: actions_dict: dict of existing action name to Action object. action_suffix_nodes: a list of action-suffix nodes Returns: A dictionary of action name to list of Suffix objects for that action. Raises: UndefinedActionItemError...
Creates new actions from suffixes and adds them to actions_dict.
[ "Creates", "new", "actions", "from", "suffixes", "and", "adds", "them", "to", "actions_dict", "." ]
def CreateActionsFromSuffixes(actions_dict, action_suffix_nodes): action_to_suffixes_dict = _CreateActionToSuffixesDict(action_suffix_nodes) while _CreateActionsFromSuffixes(actions_dict, action_to_suffixes_dict): pass if action_to_suffixes_dict: raise UndefinedActionItemError('Following actions are missi...
[ "def", "CreateActionsFromSuffixes", "(", "actions_dict", ",", "action_suffix_nodes", ")", ":", "action_to_suffixes_dict", "=", "_CreateActionToSuffixesDict", "(", "action_suffix_nodes", ")", "while", "_CreateActionsFromSuffixes", "(", "actions_dict", ",", "action_to_suffixes_di...
Creates new actions from suffixes and adds them to actions_dict.
[ "Creates", "new", "actions", "from", "suffixes", "and", "adds", "them", "to", "actions_dict", "." ]
[ "\"\"\"Creates new actions from suffixes and adds them to actions_dict.\n\n Args:\n actions_dict: dict of existing action name to Action object.\n action_suffix_nodes: a list of action-suffix nodes\n\n Returns:\n A dictionary of action name to list of Suffix objects for that action.\n\n Raises:\n Und...
[ { "param": "actions_dict", "type": null }, { "param": "action_suffix_nodes", "type": null } ]
{ "returns": [ { "docstring": "A dictionary of action name to list of Suffix objects for that action.", "docstring_tokens": [ "A", "dictionary", "of", "action", "name", "to", "list", "of", "Suffix", "objects", "for...
d85e330ebdb01d0061cc24e4010090c779507999
sunlongbo/chromium
tools/metrics/actions/action_utils.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_CreateActionToSuffixesDict
<not_specific>
def _CreateActionToSuffixesDict(action_suffix_nodes): """Creates a dict of action name to list of Suffix objects for that action. Args: action_suffix_nodes: a list of action-suffix nodes Returns: A dictionary of action name to list of Suffix objects for that action. """ action_to_suffixes_dict = {} ...
Creates a dict of action name to list of Suffix objects for that action. Args: action_suffix_nodes: a list of action-suffix nodes Returns: A dictionary of action name to list of Suffix objects for that action.
Creates a dict of action name to list of Suffix objects for that action.
[ "Creates", "a", "dict", "of", "action", "name", "to", "list", "of", "Suffix", "objects", "for", "that", "action", "." ]
def _CreateActionToSuffixesDict(action_suffix_nodes): action_to_suffixes_dict = {} for action_suffix_node in action_suffix_nodes: separator = _GetAttribute(action_suffix_node, 'separator', '_') ordering = _GetAttribute(action_suffix_node, 'ordering', 'suffix') suffixes = [Suffix(suffix_node.getAttribute...
[ "def", "_CreateActionToSuffixesDict", "(", "action_suffix_nodes", ")", ":", "action_to_suffixes_dict", "=", "{", "}", "for", "action_suffix_node", "in", "action_suffix_nodes", ":", "separator", "=", "_GetAttribute", "(", "action_suffix_node", ",", "'separator'", ",", "'...
Creates a dict of action name to list of Suffix objects for that action.
[ "Creates", "a", "dict", "of", "action", "name", "to", "list", "of", "Suffix", "objects", "for", "that", "action", "." ]
[ "\"\"\"Creates a dict of action name to list of Suffix objects for that action.\n\n Args:\n action_suffix_nodes: a list of action-suffix nodes\n\n Returns:\n A dictionary of action name to list of Suffix objects for that action.\n \"\"\"", "# If <affected-action> has <with-suffix> child nodes, only those...
[ { "param": "action_suffix_nodes", "type": null } ]
{ "returns": [ { "docstring": "A dictionary of action name to list of Suffix objects for that action.", "docstring_tokens": [ "A", "dictionary", "of", "action", "name", "to", "list", "of", "Suffix", "objects", "for...
d85e330ebdb01d0061cc24e4010090c779507999
sunlongbo/chromium
tools/metrics/actions/action_utils.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_GetAttribute
<not_specific>
def _GetAttribute(node, attribute_name, default_value): """Returns the attribute's value or default_value if attribute doesn't exist. Args: node: an XML dom element. attribute_name: name of the attribute. default_value: default value to return if attribute doesn't exist. Returns: The value of th...
Returns the attribute's value or default_value if attribute doesn't exist. Args: node: an XML dom element. attribute_name: name of the attribute. default_value: default value to return if attribute doesn't exist. Returns: The value of the attribute or default_value if attribute doesn't exist.
Returns the attribute's value or default_value if attribute doesn't exist.
[ "Returns", "the", "attribute", "'", "s", "value", "or", "default_value", "if", "attribute", "doesn", "'", "t", "exist", "." ]
def _GetAttribute(node, attribute_name, default_value): if node.hasAttribute(attribute_name): return node.getAttribute(attribute_name) else: return default_value
[ "def", "_GetAttribute", "(", "node", ",", "attribute_name", ",", "default_value", ")", ":", "if", "node", ".", "hasAttribute", "(", "attribute_name", ")", ":", "return", "node", ".", "getAttribute", "(", "attribute_name", ")", "else", ":", "return", "default_v...
Returns the attribute's value or default_value if attribute doesn't exist.
[ "Returns", "the", "attribute", "'", "s", "value", "or", "default_value", "if", "attribute", "doesn", "'", "t", "exist", "." ]
[ "\"\"\"Returns the attribute's value or default_value if attribute doesn't exist.\n\n Args:\n node: an XML dom element.\n attribute_name: name of the attribute.\n default_value: default value to return if attribute doesn't exist.\n\n Returns:\n The value of the attribute or default_value if attribute ...
[ { "param": "node", "type": null }, { "param": "attribute_name", "type": null }, { "param": "default_value", "type": null } ]
{ "returns": [ { "docstring": "The value of the attribute or default_value if attribute doesn't exist.", "docstring_tokens": [ "The", "value", "of", "the", "attribute", "or", "default_value", "if", "attribute", "doesn", ...
d85e330ebdb01d0061cc24e4010090c779507999
sunlongbo/chromium
tools/metrics/actions/action_utils.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_CreateActionsFromSuffixes
<not_specific>
def _CreateActionsFromSuffixes(actions_dict, action_to_suffixes_dict): """Creates new actions with action-suffix pairs and adds them to actions_dict. For every key (action name) in action_to_suffixes_dict, This function looks to see whether it exists in actions_dict. If so it combines the Action object from ac...
Creates new actions with action-suffix pairs and adds them to actions_dict. For every key (action name) in action_to_suffixes_dict, This function looks to see whether it exists in actions_dict. If so it combines the Action object from actions_dict with all the Suffix objects from action_to_suffixes_dict to cre...
Creates new actions with action-suffix pairs and adds them to actions_dict. For every key (action name) in action_to_suffixes_dict, This function looks to see whether it exists in actions_dict. If so it combines the Action object from actions_dict with all the Suffix objects from action_to_suffixes_dict to create new A...
[ "Creates", "new", "actions", "with", "action", "-", "suffix", "pairs", "and", "adds", "them", "to", "actions_dict", ".", "For", "every", "key", "(", "action", "name", ")", "in", "action_to_suffixes_dict", "This", "function", "looks", "to", "see", "whether", ...
def _CreateActionsFromSuffixes(actions_dict, action_to_suffixes_dict): expanded_actions = set() for action_name, suffixes in action_to_suffixes_dict.items(): if action_name in actions_dict: existing_action = actions_dict[action_name] for suffix in suffixes: _CreateActionFromSuffix(actions_di...
[ "def", "_CreateActionsFromSuffixes", "(", "actions_dict", ",", "action_to_suffixes_dict", ")", ":", "expanded_actions", "=", "set", "(", ")", "for", "action_name", ",", "suffixes", "in", "action_to_suffixes_dict", ".", "items", "(", ")", ":", "if", "action_name", ...
Creates new actions with action-suffix pairs and adds them to actions_dict.
[ "Creates", "new", "actions", "with", "action", "-", "suffix", "pairs", "and", "adds", "them", "to", "actions_dict", "." ]
[ "\"\"\"Creates new actions with action-suffix pairs and adds them to actions_dict.\n\n For every key (action name) in action_to_suffixes_dict, This function looks\n to see whether it exists in actions_dict. If so it combines the Action object\n from actions_dict with all the Suffix objects from action_to_suffixe...
[ { "param": "actions_dict", "type": null }, { "param": "action_to_suffixes_dict", "type": null } ]
{ "returns": [ { "docstring": "True if any new action was added, False otherwise.", "docstring_tokens": [ "True", "if", "any", "new", "action", "was", "added", "False", "otherwise", "." ], "type": null } ...
d85e330ebdb01d0061cc24e4010090c779507999
sunlongbo/chromium
tools/metrics/actions/action_utils.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_CreateActionFromSuffix
null
def _CreateActionFromSuffix(actions_dict, action, suffix): """Creates a new action with action and suffix and adds it to actions_dict. Args: actions_dict: dict of existing action name to Action object. action: an Action object to combine with suffix. suffix: a suffix object to combine with action. R...
Creates a new action with action and suffix and adds it to actions_dict. Args: actions_dict: dict of existing action name to Action object. action: an Action object to combine with suffix. suffix: a suffix object to combine with action. Returns: None. Raises: InvalidAffecteddActionNameError...
Creates a new action with action and suffix and adds it to actions_dict.
[ "Creates", "a", "new", "action", "with", "action", "and", "suffix", "and", "adds", "it", "to", "actions_dict", "." ]
def _CreateActionFromSuffix(actions_dict, action, suffix): if suffix.ordering == 'suffix': new_action_name = action.name + suffix.separator + suffix.name else: (before, dot, after) = action.name.partition('.') if not after: raise InvalidAffecteddActionNameError( "Action name '%s' must co...
[ "def", "_CreateActionFromSuffix", "(", "actions_dict", ",", "action", ",", "suffix", ")", ":", "if", "suffix", ".", "ordering", "==", "'suffix'", ":", "new_action_name", "=", "action", ".", "name", "+", "suffix", ".", "separator", "+", "suffix", ".", "name",...
Creates a new action with action and suffix and adds it to actions_dict.
[ "Creates", "a", "new", "action", "with", "action", "and", "suffix", "and", "adds", "it", "to", "actions_dict", "." ]
[ "\"\"\"Creates a new action with action and suffix and adds it to actions_dict.\n\n Args:\n actions_dict: dict of existing action name to Action object.\n action: an Action object to combine with suffix.\n suffix: a suffix object to combine with action.\n\n Returns:\n None.\n\n Raises:\n InvalidAf...
[ { "param": "actions_dict", "type": null }, { "param": "action", "type": null }, { "param": "suffix", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [ { "docstring": "if the action name does not contain a dot", "docstring_tokens": [ "if", "the", "action", "name", "does",...
d86c6d4cbaeb59df0fff6468794ca6dfcf599aaa
sunlongbo/chromium
third_party/blink/tools/gdb/blink.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
guess_string_length
<not_specific>
def guess_string_length(ptr): """Guess length of string pointed by ptr. Returns a tuple of (length, an error message). """ # Try to guess at the length. for i in range(0, 2048): try: if int((ptr + i).dereference()) == 0: return i, '' except RuntimeError: ...
Guess length of string pointed by ptr. Returns a tuple of (length, an error message).
Guess length of string pointed by ptr. Returns a tuple of (length, an error message).
[ "Guess", "length", "of", "string", "pointed", "by", "ptr", ".", "Returns", "a", "tuple", "of", "(", "length", "an", "error", "message", ")", "." ]
def guess_string_length(ptr): for i in range(0, 2048): try: if int((ptr + i).dereference()) == 0: return i, '' except RuntimeError: return i, ' (gdb hit inaccessible memory)' return 256, ' (gdb found no trailing NUL)'
[ "def", "guess_string_length", "(", "ptr", ")", ":", "for", "i", "in", "range", "(", "0", ",", "2048", ")", ":", "try", ":", "if", "int", "(", "(", "ptr", "+", "i", ")", ".", "dereference", "(", ")", ")", "==", "0", ":", "return", "i", ",", "'...
Guess length of string pointed by ptr.
[ "Guess", "length", "of", "string", "pointed", "by", "ptr", "." ]
[ "\"\"\"Guess length of string pointed by ptr.\n\n Returns a tuple of (length, an error message).\n \"\"\"", "# Try to guess at the length.", "# We indexed into inaccessible memory; give up." ]
[ { "param": "ptr", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d86c6d4cbaeb59df0fff6468794ca6dfcf599aaa
sunlongbo/chromium
third_party/blink/tools/gdb/blink.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
ustring_to_string
<not_specific>
def ustring_to_string(ptr, length=None): """Convert a pointer to UTF-16 data into a Python string encoded with utf-8. ptr and length are both gdb.Value objects. If length is unspecified, will guess at the length.""" error_message = '' if length is None: length, error_message = guess_string_...
Convert a pointer to UTF-16 data into a Python string encoded with utf-8. ptr and length are both gdb.Value objects. If length is unspecified, will guess at the length.
Convert a pointer to UTF-16 data into a Python string encoded with utf-8. ptr and length are both gdb.Value objects. If length is unspecified, will guess at the length.
[ "Convert", "a", "pointer", "to", "UTF", "-", "16", "data", "into", "a", "Python", "string", "encoded", "with", "utf", "-", "8", ".", "ptr", "and", "length", "are", "both", "gdb", ".", "Value", "objects", ".", "If", "length", "is", "unspecified", "will"...
def ustring_to_string(ptr, length=None): error_message = '' if length is None: length, error_message = guess_string_length(ptr) else: length = int(length) char_vals = [int((ptr + i).dereference()) for i in range(length)] string = struct.pack('H' * length, *char_vals).decode( ...
[ "def", "ustring_to_string", "(", "ptr", ",", "length", "=", "None", ")", ":", "error_message", "=", "''", "if", "length", "is", "None", ":", "length", ",", "error_message", "=", "guess_string_length", "(", "ptr", ")", "else", ":", "length", "=", "int", "...
Convert a pointer to UTF-16 data into a Python string encoded with utf-8.
[ "Convert", "a", "pointer", "to", "UTF", "-", "16", "data", "into", "a", "Python", "string", "encoded", "with", "utf", "-", "8", "." ]
[ "\"\"\"Convert a pointer to UTF-16 data into a Python string encoded with utf-8.\n\n ptr and length are both gdb.Value objects.\n If length is unspecified, will guess at the length.\"\"\"" ]
[ { "param": "ptr", "type": null }, { "param": "length", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "length", "type": null, "docstring": null, "docstring_tokens": ...
d86c6d4cbaeb59df0fff6468794ca6dfcf599aaa
sunlongbo/chromium
third_party/blink/tools/gdb/blink.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
lstring_to_string
<not_specific>
def lstring_to_string(ptr, length=None): """Convert a pointer to LChar* data into a Python (non-Unicode) string. ptr and length are both gdb.Value objects. If length is unspecified, will guess at the length.""" error_message = '' if length is None: length, error_message = guess_string_lengt...
Convert a pointer to LChar* data into a Python (non-Unicode) string. ptr and length are both gdb.Value objects. If length is unspecified, will guess at the length.
Convert a pointer to LChar* data into a Python (non-Unicode) string. ptr and length are both gdb.Value objects. If length is unspecified, will guess at the length.
[ "Convert", "a", "pointer", "to", "LChar", "*", "data", "into", "a", "Python", "(", "non", "-", "Unicode", ")", "string", ".", "ptr", "and", "length", "are", "both", "gdb", ".", "Value", "objects", ".", "If", "length", "is", "unspecified", "will", "gues...
def lstring_to_string(ptr, length=None): error_message = '' if length is None: length, error_message = guess_string_length(ptr) else: length = int(length) string = ''.join([chr((ptr + i).dereference()) for i in range(length)]) return string + error_message
[ "def", "lstring_to_string", "(", "ptr", ",", "length", "=", "None", ")", ":", "error_message", "=", "''", "if", "length", "is", "None", ":", "length", ",", "error_message", "=", "guess_string_length", "(", "ptr", ")", "else", ":", "length", "=", "int", "...
Convert a pointer to LChar* data into a Python (non-Unicode) string.
[ "Convert", "a", "pointer", "to", "LChar", "*", "data", "into", "a", "Python", "(", "non", "-", "Unicode", ")", "string", "." ]
[ "\"\"\"Convert a pointer to LChar* data into a Python (non-Unicode) string.\n\n ptr and length are both gdb.Value objects.\n If length is unspecified, will guess at the length.\"\"\"" ]
[ { "param": "ptr", "type": null }, { "param": "length", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "length", "type": null, "docstring": null, "docstring_tokens": ...
d86c6d4cbaeb59df0fff6468794ca6dfcf599aaa
sunlongbo/chromium
third_party/blink/tools/gdb/blink.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
typed_ptr
<not_specific>
def typed_ptr(ptr): """Prints a pointer along with its exact type. By default, gdb would print just the address, which takes more steps to interpret. """ # Returning this as a cast expression surrounded by parentheses # makes it easier to cut+paste inside of gdb. return '((%s)%s)' % (ptr.dy...
Prints a pointer along with its exact type. By default, gdb would print just the address, which takes more steps to interpret.
Prints a pointer along with its exact type. By default, gdb would print just the address, which takes more steps to interpret.
[ "Prints", "a", "pointer", "along", "with", "its", "exact", "type", ".", "By", "default", "gdb", "would", "print", "just", "the", "address", "which", "takes", "more", "steps", "to", "interpret", "." ]
def typed_ptr(ptr): return '((%s)%s)' % (ptr.dynamic_type, ptr)
[ "def", "typed_ptr", "(", "ptr", ")", ":", "return", "'((%s)%s)'", "%", "(", "ptr", ".", "dynamic_type", ",", "ptr", ")" ]
Prints a pointer along with its exact type.
[ "Prints", "a", "pointer", "along", "with", "its", "exact", "type", "." ]
[ "\"\"\"Prints a pointer along with its exact type.\n\n By default, gdb would print just the address, which takes more\n steps to interpret.\n \"\"\"", "# Returning this as a cast expression surrounded by parentheses", "# makes it easier to cut+paste inside of gdb." ]
[ { "param": "ptr", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d86c6d4cbaeb59df0fff6468794ca6dfcf599aaa
sunlongbo/chromium
third_party/blink/tools/gdb/blink.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
lookup_function
<not_specific>
def lookup_function(val): """Function used to load pretty printers; will be passed to GDB.""" type = val.type if type.code == gdb.TYPE_CODE_REF: type = type.target() type = type.unqualified().strip_typedefs() tag = type.tag if tag: for function, pr...
Function used to load pretty printers; will be passed to GDB.
Function used to load pretty printers; will be passed to GDB.
[ "Function", "used", "to", "load", "pretty", "printers", ";", "will", "be", "passed", "to", "GDB", "." ]
def lookup_function(val): type = val.type if type.code == gdb.TYPE_CODE_REF: type = type.target() type = type.unqualified().strip_typedefs() tag = type.tag if tag: for function, pretty_printer in pretty_printers: if function.search(tag): ...
[ "def", "lookup_function", "(", "val", ")", ":", "type", "=", "val", ".", "type", "if", "type", ".", "code", "==", "gdb", ".", "TYPE_CODE_REF", ":", "type", "=", "type", ".", "target", "(", ")", "type", "=", "type", ".", "unqualified", "(", ")", "."...
Function used to load pretty printers; will be passed to GDB.
[ "Function", "used", "to", "load", "pretty", "printers", ";", "will", "be", "passed", "to", "GDB", "." ]
[ "\"\"\"Function used to load pretty printers; will be passed to GDB.\"\"\"" ]
[ { "param": "val", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "val", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
28a44ad2878c2e564807e34fb9ce91d06d484377
sunlongbo/chromium
tools/perf/core/services/isolate_service.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
Request
<not_specific>
def Request(endpoint, **kwargs): """Send a request to some isolate service endpoint.""" kwargs.setdefault('use_auth', True) kwargs.setdefault('accept', 'json') return request.Request(SERVICE_URL + endpoint, **kwargs)
Send a request to some isolate service endpoint.
Send a request to some isolate service endpoint.
[ "Send", "a", "request", "to", "some", "isolate", "service", "endpoint", "." ]
def Request(endpoint, **kwargs): kwargs.setdefault('use_auth', True) kwargs.setdefault('accept', 'json') return request.Request(SERVICE_URL + endpoint, **kwargs)
[ "def", "Request", "(", "endpoint", ",", "**", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'use_auth'", ",", "True", ")", "kwargs", ".", "setdefault", "(", "'accept'", ",", "'json'", ")", "return", "request", ".", "Request", "(", "SERVICE_URL", ...
Send a request to some isolate service endpoint.
[ "Send", "a", "request", "to", "some", "isolate", "service", "endpoint", "." ]
[ "\"\"\"Send a request to some isolate service endpoint.\"\"\"" ]
[ { "param": "endpoint", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "endpoint", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
28a44ad2878c2e564807e34fb9ce91d06d484377
sunlongbo/chromium
tools/perf/core/services/isolate_service.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
RetrieveCompressed
<not_specific>
def RetrieveCompressed(digest): """Retrieve the compressed content stored at some isolate digest. Responses are cached locally to speed up retrieving content multiple times for the same digest. """ cache_file = os.path.join(CACHE_DIR, digest) if os.path.exists(cache_file): with open(cache_file, 'rb') a...
Retrieve the compressed content stored at some isolate digest. Responses are cached locally to speed up retrieving content multiple times for the same digest.
Retrieve the compressed content stored at some isolate digest. Responses are cached locally to speed up retrieving content multiple times for the same digest.
[ "Retrieve", "the", "compressed", "content", "stored", "at", "some", "isolate", "digest", ".", "Responses", "are", "cached", "locally", "to", "speed", "up", "retrieving", "content", "multiple", "times", "for", "the", "same", "digest", "." ]
def RetrieveCompressed(digest): cache_file = os.path.join(CACHE_DIR, digest) if os.path.exists(cache_file): with open(cache_file, 'rb') as f: return f.read() else: if not os.path.isdir(CACHE_DIR): os.makedirs(CACHE_DIR) content = _RetrieveCompressed(digest) with open(cache_file, 'wb') ...
[ "def", "RetrieveCompressed", "(", "digest", ")", ":", "cache_file", "=", "os", ".", "path", ".", "join", "(", "CACHE_DIR", ",", "digest", ")", "if", "os", ".", "path", ".", "exists", "(", "cache_file", ")", ":", "with", "open", "(", "cache_file", ",", ...
Retrieve the compressed content stored at some isolate digest.
[ "Retrieve", "the", "compressed", "content", "stored", "at", "some", "isolate", "digest", "." ]
[ "\"\"\"Retrieve the compressed content stored at some isolate digest.\n\n Responses are cached locally to speed up retrieving content multiple times\n for the same digest.\n \"\"\"" ]
[ { "param": "digest", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "digest", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
28a44ad2878c2e564807e34fb9ce91d06d484377
sunlongbo/chromium
tools/perf/core/services/isolate_service.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_RetrieveCompressed
<not_specific>
def _RetrieveCompressed(digest): """Retrieve the compressed content stored at some isolate digest.""" data = Request( '/retrieve', method='POST', content_type='json', data={'namespace': {'namespace': 'default-gzip'}, 'digest': digest}) if 'url' in data: return request.Request(data['url']) if 'c...
Retrieve the compressed content stored at some isolate digest.
Retrieve the compressed content stored at some isolate digest.
[ "Retrieve", "the", "compressed", "content", "stored", "at", "some", "isolate", "digest", "." ]
def _RetrieveCompressed(digest): data = Request( '/retrieve', method='POST', content_type='json', data={'namespace': {'namespace': 'default-gzip'}, 'digest': digest}) if 'url' in data: return request.Request(data['url']) if 'content' in data: return base64.b64decode(data['content']) else: ...
[ "def", "_RetrieveCompressed", "(", "digest", ")", ":", "data", "=", "Request", "(", "'/retrieve'", ",", "method", "=", "'POST'", ",", "content_type", "=", "'json'", ",", "data", "=", "{", "'namespace'", ":", "{", "'namespace'", ":", "'default-gzip'", "}", ...
Retrieve the compressed content stored at some isolate digest.
[ "Retrieve", "the", "compressed", "content", "stored", "at", "some", "isolate", "digest", "." ]
[ "\"\"\"Retrieve the compressed content stored at some isolate digest.\"\"\"" ]
[ { "param": "digest", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "digest", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3860efa970d9507217cc81a70cea19c34ec1c6f6
sunlongbo/chromium
third_party/blink/tools/blinkpy/common/system/log_utils_unittest.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
tearDown
null
def tearDown(self): """Reset logging to its original state. This method ensures that the logging configuration set up for a unit test does not affect logging in other unit tests. """ logger = self._log for handler in self._handlers: logger.removeHandler(handl...
Reset logging to its original state. This method ensures that the logging configuration set up for a unit test does not affect logging in other unit tests.
Reset logging to its original state. This method ensures that the logging configuration set up for a unit test does not affect logging in other unit tests.
[ "Reset", "logging", "to", "its", "original", "state", ".", "This", "method", "ensures", "that", "the", "logging", "configuration", "set", "up", "for", "a", "unit", "test", "does", "not", "affect", "logging", "in", "other", "unit", "tests", "." ]
def tearDown(self): logger = self._log for handler in self._handlers: logger.removeHandler(handler)
[ "def", "tearDown", "(", "self", ")", ":", "logger", "=", "self", ".", "_log", "for", "handler", "in", "self", ".", "_handlers", ":", "logger", ".", "removeHandler", "(", "handler", ")" ]
Reset logging to its original state.
[ "Reset", "logging", "to", "its", "original", "state", "." ]
[ "\"\"\"Reset logging to its original state.\n\n This method ensures that the logging configuration set up\n for a unit test does not affect logging in other unit tests.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dbe60ad7b522eccd5613fe9a13197935a9ad814e
sunlongbo/chromium
components/vector_icons/aggregate_vector_icons.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
ExtractIconReps
<not_specific>
def ExtractIconReps(icon_file_name): """Reads the contents of the given icon file and returns a dictionary of icon sizes to vector commands for different icon representations stored in that file. Args: icon_file_name: The file path of the icon file to read. """ with open(icon_file_name, "r") as...
Reads the contents of the given icon file and returns a dictionary of icon sizes to vector commands for different icon representations stored in that file. Args: icon_file_name: The file path of the icon file to read.
Reads the contents of the given icon file and returns a dictionary of icon sizes to vector commands for different icon representations stored in that file.
[ "Reads", "the", "contents", "of", "the", "given", "icon", "file", "and", "returns", "a", "dictionary", "of", "icon", "sizes", "to", "vector", "commands", "for", "different", "icon", "representations", "stored", "in", "that", "file", "." ]
def ExtractIconReps(icon_file_name): with open(icon_file_name, "r") as icon_file: icon_file_contents = icon_file.readlines() current_icon_size = REFERENCE_SIZE_DIP icon_sizes = [] current_icon_representation = [] icon_representations = {} for line in icon_file_contents: line = line.partition(CPP_COM...
[ "def", "ExtractIconReps", "(", "icon_file_name", ")", ":", "with", "open", "(", "icon_file_name", ",", "\"r\"", ")", "as", "icon_file", ":", "icon_file_contents", "=", "icon_file", ".", "readlines", "(", ")", "current_icon_size", "=", "REFERENCE_SIZE_DIP", "icon_s...
Reads the contents of the given icon file and returns a dictionary of icon sizes to vector commands for different icon representations stored in that file.
[ "Reads", "the", "contents", "of", "the", "given", "icon", "file", "and", "returns", "a", "dictionary", "of", "icon", "sizes", "to", "vector", "commands", "for", "different", "icon", "representations", "stored", "in", "that", "file", "." ]
[ "\"\"\"Reads the contents of the given icon file and returns a dictionary of icon\n sizes to vector commands for different icon representations stored in that\n file.\n\n Args:\n icon_file_name: The file path of the icon file to read.\n \"\"\"", "# Strip comments and empty lines.", "# Retrieve si...
[ { "param": "icon_file_name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "icon_file_name", "type": null, "docstring": "The file path of the icon file to read.", "docstring_tokens": [ "The", "file", "path", "of", "the", "icon", "file", "...
dbe60ad7b522eccd5613fe9a13197935a9ad814e
sunlongbo/chromium
components/vector_icons/aggregate_vector_icons.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
AggregateVectorIcons
null
def AggregateVectorIcons(working_directory, file_list, output_cc, output_h): """Compiles all .icon files in a directory into two C++ files. Args: working_directory: The path to the directory that holds the .icon files and C++ templates. file_list: A file containing the list of vector icon fil...
Compiles all .icon files in a directory into two C++ files. Args: working_directory: The path to the directory that holds the .icon files and C++ templates. file_list: A file containing the list of vector icon files to process. output_cc: The path that should be used to write the .cc file...
Compiles all .icon files in a directory into two C++ files.
[ "Compiles", "all", ".", "icon", "files", "in", "a", "directory", "into", "two", "C", "++", "files", "." ]
def AggregateVectorIcons(working_directory, file_list, output_cc, output_h): icon_list = [] with open(file_list, "r") as f: file_list_contents = f.read() icon_list = shlex.split(file_list_contents) path_map = {} for icon_path in icon_list: (icon_name, extension) = os.path.splitext(os.path.basename(ico...
[ "def", "AggregateVectorIcons", "(", "working_directory", ",", "file_list", ",", "output_cc", ",", "output_h", ")", ":", "icon_list", "=", "[", "]", "with", "open", "(", "file_list", ",", "\"r\"", ")", "as", "f", ":", "file_list_contents", "=", "f", ".", "r...
Compiles all .icon files in a directory into two C++ files.
[ "Compiles", "all", ".", "icon", "files", "in", "a", "directory", "into", "two", "C", "++", "files", "." ]
[ "\"\"\"Compiles all .icon files in a directory into two C++ files.\n\n Args:\n working_directory: The path to the directory that holds the .icon files\n and C++ templates.\n file_list: A file containing the list of vector icon files to process.\n output_cc: The path that should be used to w...
[ { "param": "working_directory", "type": null }, { "param": "file_list", "type": null }, { "param": "output_cc", "type": null }, { "param": "output_h", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "working_directory", "type": null, "docstring": "The path to the directory that holds the .icon files\nand C++ templates.", "docstring_tokens": [ "The", "path", "to", "the", "directory", ...
20ef0128671efe6afdb89cedd8f51efd20a1de35
sunlongbo/chromium
third_party/blink/tools/blinkpy/style/filereader.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_read_lines
<not_specific>
def _read_lines(self, file_path): """Read the file at a path, and return its lines. Raises: IOError: If the file does not exist or cannot be read. """ # Support the UNIX convention of using "-" for stdin. if file_path == '-': file = codecs.StreamReaderWrite...
Read the file at a path, and return its lines. Raises: IOError: If the file does not exist or cannot be read.
Read the file at a path, and return its lines.
[ "Read", "the", "file", "at", "a", "path", "and", "return", "its", "lines", "." ]
def _read_lines(self, file_path): if file_path == '-': file = codecs.StreamReaderWriter(sys.stdin, codecs.getreader('utf8'), codecs.getwriter('utf8'), 'replace') ...
[ "def", "_read_lines", "(", "self", ",", "file_path", ")", ":", "if", "file_path", "==", "'-'", ":", "file", "=", "codecs", ".", "StreamReaderWriter", "(", "sys", ".", "stdin", ",", "codecs", ".", "getreader", "(", "'utf8'", ")", ",", "codecs", ".", "ge...
Read the file at a path, and return its lines.
[ "Read", "the", "file", "at", "a", "path", "and", "return", "its", "lines", "." ]
[ "\"\"\"Read the file at a path, and return its lines.\n\n Raises:\n IOError: If the file does not exist or cannot be read.\n \"\"\"", "# Support the UNIX convention of using \"-\" for stdin.", "# We do not open the file with universal newline support", "# (codecs does not support it any...
[ { "param": "self", "type": null }, { "param": "file_path", "type": null } ]
{ "returns": [], "raises": [ { "docstring": "If the file does not exist or cannot be read.", "docstring_tokens": [ "If", "the", "file", "does", "not", "exist", "or", "cannot", "be", "read", "." ], "ty...
20ef0128671efe6afdb89cedd8f51efd20a1de35
sunlongbo/chromium
third_party/blink/tools/blinkpy/style/filereader.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
process_file
<not_specific>
def process_file(self, file_path, **kwargs): """Process the given file by calling the processor's process() method. Args: file_path: The path of the file to process. **kwargs: Any additional keyword parameters that should be passed to the processor's process() me...
Process the given file by calling the processor's process() method. Args: file_path: The path of the file to process. **kwargs: Any additional keyword parameters that should be passed to the processor's process() method. The process() method should s...
Process the given file by calling the processor's process() method.
[ "Process", "the", "given", "file", "by", "calling", "the", "processor", "'", "s", "process", "()", "method", "." ]
def process_file(self, file_path, **kwargs): self.file_count += 1 if not self.filesystem.exists(file_path) and file_path != '-': _log.error("File does not exist: '%s'", file_path) sys.exit(1) if not self._processor.should_process(file_path): _log.debug("Skippi...
[ "def", "process_file", "(", "self", ",", "file_path", ",", "**", "kwargs", ")", ":", "self", ".", "file_count", "+=", "1", "if", "not", "self", ".", "filesystem", ".", "exists", "(", "file_path", ")", "and", "file_path", "!=", "'-'", ":", "_log", ".", ...
Process the given file by calling the processor's process() method.
[ "Process", "the", "given", "file", "by", "calling", "the", "processor", "'", "s", "process", "()", "method", "." ]
[ "\"\"\"Process the given file by calling the processor's process() method.\n\n Args:\n file_path: The path of the file to process.\n **kwargs: Any additional keyword parameters that should be passed\n to the processor's process() method. The process()\n ...
[ { "param": "self", "type": null }, { "param": "file_path", "type": null } ]
{ "returns": [], "raises": [ { "docstring": "If no file at file_path exists.", "docstring_tokens": [ "If", "no", "file", "at", "file_path", "exists", "." ], "type": "SystemExit" } ], "params": [ { "identifier": "se...
20ef0128671efe6afdb89cedd8f51efd20a1de35
sunlongbo/chromium
third_party/blink/tools/blinkpy/style/filereader.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_process_directory
null
def _process_directory(self, directory): """Process all files in the given directory, recursively.""" # FIXME: We should consider moving to self.filesystem.files_under() (or adding walk() to FileSystem) for dir_path, _, file_names in os.walk(directory): for file_name in file_names: ...
Process all files in the given directory, recursively.
Process all files in the given directory, recursively.
[ "Process", "all", "files", "in", "the", "given", "directory", "recursively", "." ]
def _process_directory(self, directory): for dir_path, _, file_names in os.walk(directory): for file_name in file_names: file_path = self.filesystem.join(dir_path, file_name) self.process_file(file_path)
[ "def", "_process_directory", "(", "self", ",", "directory", ")", ":", "for", "dir_path", ",", "_", ",", "file_names", "in", "os", ".", "walk", "(", "directory", ")", ":", "for", "file_name", "in", "file_names", ":", "file_path", "=", "self", ".", "filesy...
Process all files in the given directory, recursively.
[ "Process", "all", "files", "in", "the", "given", "directory", "recursively", "." ]
[ "\"\"\"Process all files in the given directory, recursively.\"\"\"", "# FIXME: We should consider moving to self.filesystem.files_under() (or adding walk() to FileSystem)" ]
[ { "param": "self", "type": null }, { "param": "directory", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "directory", "type": null, "docstring": null, "docstring_token...
20ef0128671efe6afdb89cedd8f51efd20a1de35
sunlongbo/chromium
third_party/blink/tools/blinkpy/style/filereader.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
count_delete_only_file
null
def count_delete_only_file(self): """Count up files that contains only deleted lines. Files which has no modified or newly-added lines don't need to check style, but should be treated as checked. For that purpose, we just count up the number of such files. """ self.delet...
Count up files that contains only deleted lines. Files which has no modified or newly-added lines don't need to check style, but should be treated as checked. For that purpose, we just count up the number of such files.
Count up files that contains only deleted lines. Files which has no modified or newly-added lines don't need to check style, but should be treated as checked. For that purpose, we just count up the number of such files.
[ "Count", "up", "files", "that", "contains", "only", "deleted", "lines", ".", "Files", "which", "has", "no", "modified", "or", "newly", "-", "added", "lines", "don", "'", "t", "need", "to", "check", "style", "but", "should", "be", "treated", "as", "checke...
def count_delete_only_file(self): self.delete_only_file_count += 1
[ "def", "count_delete_only_file", "(", "self", ")", ":", "self", ".", "delete_only_file_count", "+=", "1" ]
Count up files that contains only deleted lines.
[ "Count", "up", "files", "that", "contains", "only", "deleted", "lines", "." ]
[ "\"\"\"Count up files that contains only deleted lines.\n\n Files which has no modified or newly-added lines don't need\n to check style, but should be treated as checked. For that\n purpose, we just count up the number of such files.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
20f06646f663b7c0f0997dcee182ec0ec5bd9e29
sunlongbo/chromium
third_party/blink/renderer/build/scripts/cluster.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
l2_pairwise_distance
<not_specific>
def l2_pairwise_distance(v1, v2): """Euclidean distance from each point in v1 to each point in v2 Args: v1: list of point 1 v2: list of point 2 Returns: distance matrix between each point in v1 and v2 """ nrow = len(v1) ncol = len(v2) dist_mat = [[0 for _ in range(n...
Euclidean distance from each point in v1 to each point in v2 Args: v1: list of point 1 v2: list of point 2 Returns: distance matrix between each point in v1 and v2
Euclidean distance from each point in v1 to each point in v2
[ "Euclidean", "distance", "from", "each", "point", "in", "v1", "to", "each", "point", "in", "v2" ]
def l2_pairwise_distance(v1, v2): nrow = len(v1) ncol = len(v2) dist_mat = [[0 for _ in range(ncol)] for _ in range(nrow)] for i in range(nrow): for j in range(ncol): dist_mat[i][j] = math.sqrt((v1[i] - v2[j])**2) return dist_mat
[ "def", "l2_pairwise_distance", "(", "v1", ",", "v2", ")", ":", "nrow", "=", "len", "(", "v1", ")", "ncol", "=", "len", "(", "v2", ")", "dist_mat", "=", "[", "[", "0", "for", "_", "in", "range", "(", "ncol", ")", "]", "for", "_", "in", "range", ...
Euclidean distance from each point in v1 to each point in v2
[ "Euclidean", "distance", "from", "each", "point", "in", "v1", "to", "each", "point", "in", "v2" ]
[ "\"\"\"Euclidean distance from each point in v1 to each point in v2\n\n Args:\n v1: list of point 1\n v2: list of point 2\n\n Returns:\n distance matrix between each point in v1 and v2\n \"\"\"" ]
[ { "param": "v1", "type": null }, { "param": "v2", "type": null } ]
{ "returns": [ { "docstring": "distance matrix between each point in v1 and v2", "docstring_tokens": [ "distance", "matrix", "between", "each", "point", "in", "v1", "and", "v2" ], "type": null } ], "raises": []...
20f06646f663b7c0f0997dcee182ec0ec5bd9e29
sunlongbo/chromium
third_party/blink/renderer/build/scripts/cluster.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
calculate_error
<not_specific>
def calculate_error(k_means_matrix): """Calculate the sum of distance from each point to its nearest cluster center Args: k_means_matrix: distance matrix of point to cluster center Returns: Sum of distance from each point to its nearest cluster center """ return sum([min(dist) for ...
Calculate the sum of distance from each point to its nearest cluster center Args: k_means_matrix: distance matrix of point to cluster center Returns: Sum of distance from each point to its nearest cluster center
Calculate the sum of distance from each point to its nearest cluster center
[ "Calculate", "the", "sum", "of", "distance", "from", "each", "point", "to", "its", "nearest", "cluster", "center" ]
def calculate_error(k_means_matrix): return sum([min(dist) for dist in k_means_matrix])
[ "def", "calculate_error", "(", "k_means_matrix", ")", ":", "return", "sum", "(", "[", "min", "(", "dist", ")", "for", "dist", "in", "k_means_matrix", "]", ")" ]
Calculate the sum of distance from each point to its nearest cluster center
[ "Calculate", "the", "sum", "of", "distance", "from", "each", "point", "to", "its", "nearest", "cluster", "center" ]
[ "\"\"\"Calculate the sum of distance from each point to its nearest cluster center\n\n Args:\n k_means_matrix: distance matrix of point to cluster center\n\n Returns:\n Sum of distance from each point to its nearest cluster center\n \"\"\"" ]
[ { "param": "k_means_matrix", "type": null } ]
{ "returns": [ { "docstring": "Sum of distance from each point to its nearest cluster center", "docstring_tokens": [ "Sum", "of", "distance", "from", "each", "point", "to", "its", "nearest", "cluster", "center" ...
20f06646f663b7c0f0997dcee182ec0ec5bd9e29
sunlongbo/chromium
third_party/blink/renderer/build/scripts/cluster.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
k_means
<not_specific>
def k_means(x_input, n_cluster=3, n_iter=100, n_tries=10): """Perform 1-D k-means clustering on a list of numbers x_input Args: x_input: list of numbers n_cluster: number of clusters n_iter: number of iterations Returns: centers: list of n_cluster elements containing the cl...
Perform 1-D k-means clustering on a list of numbers x_input Args: x_input: list of numbers n_cluster: number of clusters n_iter: number of iterations Returns: centers: list of n_cluster elements containing the cluster centers min_dist_idx: list of len(x_input) elements ...
Perform 1-D k-means clustering on a list of numbers x_input
[ "Perform", "1", "-", "D", "k", "-", "means", "clustering", "on", "a", "list", "of", "numbers", "x_input" ]
def k_means(x_input, n_cluster=3, n_iter=100, n_tries=10): results = [] for _ in range(n_tries): error_value = 0 rand.seed(None) centers = sorted([rand.uniform(0.0, 100.0) for i in range(n_cluster)]) min_dist_idx = [0] * len(x_input) i = 0 while i < n_iter: ...
[ "def", "k_means", "(", "x_input", ",", "n_cluster", "=", "3", ",", "n_iter", "=", "100", ",", "n_tries", "=", "10", ")", ":", "results", "=", "[", "]", "for", "_", "in", "range", "(", "n_tries", ")", ":", "error_value", "=", "0", "rand", ".", "se...
Perform 1-D k-means clustering on a list of numbers x_input
[ "Perform", "1", "-", "D", "k", "-", "means", "clustering", "on", "a", "list", "of", "numbers", "x_input" ]
[ "\"\"\"Perform 1-D k-means clustering on a list of numbers x_input\n\n Args:\n x_input: list of numbers\n n_cluster: number of clusters\n n_iter: number of iterations\n\n Returns:\n centers: list of n_cluster elements containing the cluster centers\n min_dist_idx: list of le...
[ { "param": "x_input", "type": null }, { "param": "n_cluster", "type": null }, { "param": "n_iter", "type": null }, { "param": "n_tries", "type": null } ]
{ "returns": [ { "docstring": "list of n_cluster elements containing the cluster centers\nmin_dist_idx: list of len(x_input) elements containing the nearest cluster center's id\nerror_value: sum of all distance from each point to its nearest cluster center", "docstring_tokens": [ "list", ...
7426363294e9ce33324f44d7885995831c064600
sunlongbo/chromium
third_party/android_crazy_linker/src/tests/pylib/source_utils.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
CSourceForArrayData
<not_specific>
def CSourceForArrayData(values, formatter, margin=4, width=80): """Turn an array of values into a C source array data definition. Args: values: Array of input values. formatter: Formatting function, applied to each input value to get a C-source description of the value. margin: Left-side margin /...
Turn an array of values into a C source array data definition. Args: values: Array of input values. formatter: Formatting function, applied to each input value to get a C-source description of the value. margin: Left-side margin / indentation level. width: Maximum line width. Returns: A s...
Turn an array of values into a C source array data definition.
[ "Turn", "an", "array", "of", "values", "into", "a", "C", "source", "array", "data", "definition", "." ]
def CSourceForArrayData(values, formatter, margin=4, width=80): read_pos = 0 read_len = len(values) write_pos = margin line_start = ' ' * margin max_width = width - margin - 1 out = '' while read_pos < read_len: out += line_start write_pos = 0 comma = '' while read_pos < read_len: it...
[ "def", "CSourceForArrayData", "(", "values", ",", "formatter", ",", "margin", "=", "4", ",", "width", "=", "80", ")", ":", "read_pos", "=", "0", "read_len", "=", "len", "(", "values", ")", "write_pos", "=", "margin", "line_start", "=", "' '", "*", "mar...
Turn an array of values into a C source array data definition.
[ "Turn", "an", "array", "of", "values", "into", "a", "C", "source", "array", "data", "definition", "." ]
[ "\"\"\"Turn an array of values into a C source array data definition.\n\n Args:\n values: Array of input values.\n formatter: Formatting function, applied to each input value to get a\n C-source description of the value.\n margin: Left-side margin / indentation level.\n width: Maximum line width.\...
[ { "param": "values", "type": null }, { "param": "formatter", "type": null }, { "param": "margin", "type": null }, { "param": "width", "type": null } ]
{ "returns": [ { "docstring": "A string containing the data definition as a C source fragment.", "docstring_tokens": [ "A", "string", "containing", "the", "data", "definition", "as", "a", "C", "source", "fragment",...
7426363294e9ce33324f44d7885995831c064600
sunlongbo/chromium
third_party/android_crazy_linker/src/tests/pylib/source_utils.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
CSourceForIntegerHexArray
<not_specific>
def CSourceForIntegerHexArray(values, num_bits, margin=4, width=80): """Turn an array of integers into a C source array data definition. Args: values: An array of integers. num_bits: The number of bits of said integers (i.e. 8, 16, 32 or 64). margin: Left-side margin / indentation level (must be > 0). ...
Turn an array of integers into a C source array data definition. Args: values: An array of integers. num_bits: The number of bits of said integers (i.e. 8, 16, 32 or 64). margin: Left-side margin / indentation level (must be > 0). width: Maximum line width. Returns: A string containing the data...
Turn an array of integers into a C source array data definition.
[ "Turn", "an", "array", "of", "integers", "into", "a", "C", "source", "array", "data", "definition", "." ]
def CSourceForIntegerHexArray(values, num_bits, margin=4, width=80): chars_per_word = num_bits / 4 format_str = ' 0x%%0%dx' % chars_per_word out = CSourceForArrayData(values, lambda x: format_str % x, margin - 1, width) out += ',\n' return out
[ "def", "CSourceForIntegerHexArray", "(", "values", ",", "num_bits", ",", "margin", "=", "4", ",", "width", "=", "80", ")", ":", "chars_per_word", "=", "num_bits", "/", "4", "format_str", "=", "' 0x%%0%dx'", "%", "chars_per_word", "out", "=", "CSourceForArrayDa...
Turn an array of integers into a C source array data definition.
[ "Turn", "an", "array", "of", "integers", "into", "a", "C", "source", "array", "data", "definition", "." ]
[ "\"\"\"Turn an array of integers into a C source array data definition.\n\n Args:\n values: An array of integers.\n num_bits: The number of bits of said integers (i.e. 8, 16, 32 or 64).\n margin: Left-side margin / indentation level (must be > 0).\n width: Maximum line width.\n Returns:\n A string ...
[ { "param": "values", "type": null }, { "param": "num_bits", "type": null }, { "param": "margin", "type": null }, { "param": "width", "type": null } ]
{ "returns": [ { "docstring": "A string containing the data definition as a C source fragment.", "docstring_tokens": [ "A", "string", "containing", "the", "data", "definition", "as", "a", "C", "source", "fragment",...
7426363294e9ce33324f44d7885995831c064600
sunlongbo/chromium
third_party/android_crazy_linker/src/tests/pylib/source_utils.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_FormatChar
<not_specific>
def _FormatChar(ch): """Convert a character into its C source description.""" code = ord(ch) if code < 32 or code > 127: return "'\\%d'" % code else: return "'%s'" % ch
Convert a character into its C source description.
Convert a character into its C source description.
[ "Convert", "a", "character", "into", "its", "C", "source", "description", "." ]
def _FormatChar(ch): code = ord(ch) if code < 32 or code > 127: return "'\\%d'" % code else: return "'%s'" % ch
[ "def", "_FormatChar", "(", "ch", ")", ":", "code", "=", "ord", "(", "ch", ")", "if", "code", "<", "32", "or", "code", ">", "127", ":", "return", "\"'\\\\%d'\"", "%", "code", "else", ":", "return", "\"'%s'\"", "%", "ch" ]
Convert a character into its C source description.
[ "Convert", "a", "character", "into", "its", "C", "source", "description", "." ]
[ "\"\"\"Convert a character into its C source description.\"\"\"" ]
[ { "param": "ch", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ch", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7426363294e9ce33324f44d7885995831c064600
sunlongbo/chromium
third_party/android_crazy_linker/src/tests/pylib/source_utils.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
CSourceForConstCharArray
<not_specific>
def CSourceForConstCharArray(chars, variable_name, margin=4, width=80): """Return C source fragment for static const char C array. Args: chars: An array or string containing all the characters for array. variable_name: Name of the array variable. Returns: A new string holding a C source fragment for ...
Return C source fragment for static const char C array. Args: chars: An array or string containing all the characters for array. variable_name: Name of the array variable. Returns: A new string holding a C source fragment for the array definition.
Return C source fragment for static const char C array.
[ "Return", "C", "source", "fragment", "for", "static", "const", "char", "C", "array", "." ]
def CSourceForConstCharArray(chars, variable_name, margin=4, width=80): out = 'static const char %s[%d] = {\n' % (variable_name, len(chars)) out += CSourceForArrayData(chars, _FormatChar, margin, width) out += '};\n' return out
[ "def", "CSourceForConstCharArray", "(", "chars", ",", "variable_name", ",", "margin", "=", "4", ",", "width", "=", "80", ")", ":", "out", "=", "'static const char %s[%d] = {\\n'", "%", "(", "variable_name", ",", "len", "(", "chars", ")", ")", "out", "+=", ...
Return C source fragment for static const char C array.
[ "Return", "C", "source", "fragment", "for", "static", "const", "char", "C", "array", "." ]
[ "\"\"\"Return C source fragment for static const char C array.\n\n Args:\n chars: An array or string containing all the characters for array.\n variable_name: Name of the array variable.\n Returns:\n A new string holding a C source fragment for the array definition.\n \"\"\"" ]
[ { "param": "chars", "type": null }, { "param": "variable_name", "type": null }, { "param": "margin", "type": null }, { "param": "width", "type": null } ]
{ "returns": [ { "docstring": "A new string holding a C source fragment for the array definition.", "docstring_tokens": [ "A", "new", "string", "holding", "a", "C", "source", "fragment", "for", "the", "array", ...
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
StartPinpointJobs
<not_specific>
def StartPinpointJobs(state, date): """Start new pinpoint jobs for the last commit on the given date.""" revision, timestamp = GetLastCommitOfDate(date) if any(item['revision'] == revision for item in state): logging.info('No new jobs to start.') return # Add a new item to the state with info about job...
Start new pinpoint jobs for the last commit on the given date.
Start new pinpoint jobs for the last commit on the given date.
[ "Start", "new", "pinpoint", "jobs", "for", "the", "last", "commit", "on", "the", "given", "date", "." ]
def StartPinpointJobs(state, date): revision, timestamp = GetLastCommitOfDate(date) if any(item['revision'] == revision for item in state): logging.info('No new jobs to start.') return logging.info('Starting jobs for %s (%s):', timestamp[:10], revision) item = {'revision': revision, 'timestamp': timesta...
[ "def", "StartPinpointJobs", "(", "state", ",", "date", ")", ":", "revision", ",", "timestamp", "=", "GetLastCommitOfDate", "(", "date", ")", "if", "any", "(", "item", "[", "'revision'", "]", "==", "revision", "for", "item", "in", "state", ")", ":", "logg...
Start new pinpoint jobs for the last commit on the given date.
[ "Start", "new", "pinpoint", "jobs", "for", "the", "last", "commit", "on", "the", "given", "date", "." ]
[ "\"\"\"Start new pinpoint jobs for the last commit on the given date.\"\"\"", "# Add a new item to the state with info about jobs for this revision.", "# Keep items sorted by date." ]
[ { "param": "state", "type": null }, { "param": "date", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "state", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "date", "type": null, "docstring": null, "docstring_tokens": ...
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
CollectPinpointResults
null
def CollectPinpointResults(state): """Check the status of pinpoint jobs and collect their results.""" # First iterate over all running jobs, and update their status. for item in state: active = [job['id'] for job in item['jobs'] if not IsJobFinished(job)] if not active: continue cmd = ['vpython'...
Check the status of pinpoint jobs and collect their results.
Check the status of pinpoint jobs and collect their results.
[ "Check", "the", "status", "of", "pinpoint", "jobs", "and", "collect", "their", "results", "." ]
def CollectPinpointResults(state): for item in state: active = [job['id'] for job in item['jobs'] if not IsJobFinished(job)] if not active: continue cmd = ['vpython', PINPOINT_CLI, 'status'] cmd.extend(active) output = subprocess.check_output(cmd, universal_newlines=True) updates = dict(...
[ "def", "CollectPinpointResults", "(", "state", ")", ":", "for", "item", "in", "state", ":", "active", "=", "[", "job", "[", "'id'", "]", "for", "job", "in", "item", "[", "'jobs'", "]", "if", "not", "IsJobFinished", "(", "job", ")", "]", "if", "not", ...
Check the status of pinpoint jobs and collect their results.
[ "Check", "the", "status", "of", "pinpoint", "jobs", "and", "collect", "their", "results", "." ]
[ "\"\"\"Check the status of pinpoint jobs and collect their results.\"\"\"", "# First iterate over all running jobs, and update their status.", "# Now iterate over all completed jobs, and download their results if needed.", "# Skip if not ready or all failed." ]
[ { "param": "state", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "state", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
LoadJobsState
<not_specific>
def LoadJobsState(): """Load the latest recorded state of pinpoint jobs.""" local_path = CachedFilePath(JOBS_STATE_FILE) if os.path.exists(local_path) or DownloadFromCloudStorage(local_path): return LoadJsonFile(local_path) else: logging.info('No jobs state found. Creating empty state.') return []
Load the latest recorded state of pinpoint jobs.
Load the latest recorded state of pinpoint jobs.
[ "Load", "the", "latest", "recorded", "state", "of", "pinpoint", "jobs", "." ]
def LoadJobsState(): local_path = CachedFilePath(JOBS_STATE_FILE) if os.path.exists(local_path) or DownloadFromCloudStorage(local_path): return LoadJsonFile(local_path) else: logging.info('No jobs state found. Creating empty state.') return []
[ "def", "LoadJobsState", "(", ")", ":", "local_path", "=", "CachedFilePath", "(", "JOBS_STATE_FILE", ")", "if", "os", ".", "path", ".", "exists", "(", "local_path", ")", "or", "DownloadFromCloudStorage", "(", "local_path", ")", ":", "return", "LoadJsonFile", "(...
Load the latest recorded state of pinpoint jobs.
[ "Load", "the", "latest", "recorded", "state", "of", "pinpoint", "jobs", "." ]
[ "\"\"\"Load the latest recorded state of pinpoint jobs.\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
UpdateJobsState
null
def UpdateJobsState(state): """Write back the updated state of pinpoint jobs. If there were any changes to the state, i.e. new jobs were created or existing ones completed, both the local cached copy and the backup in cloud storage are updated. """ local_path = CachedFilePath(JOBS_STATE_FILE) with tempfi...
Write back the updated state of pinpoint jobs. If there were any changes to the state, i.e. new jobs were created or existing ones completed, both the local cached copy and the backup in cloud storage are updated.
Write back the updated state of pinpoint jobs. If there were any changes to the state, i.e. new jobs were created or existing ones completed, both the local cached copy and the backup in cloud storage are updated.
[ "Write", "back", "the", "updated", "state", "of", "pinpoint", "jobs", ".", "If", "there", "were", "any", "changes", "to", "the", "state", "i", ".", "e", ".", "new", "jobs", "were", "created", "or", "existing", "ones", "completed", "both", "the", "local",...
def UpdateJobsState(state): local_path = CachedFilePath(JOBS_STATE_FILE) with tempfile_ext.NamedTemporaryFile(mode='w') as tmp: json.dump(state, tmp, sort_keys=True, indent=2, separators=(',', ': ')) tmp.close() if not os.path.exists(local_path) or not filecmp.cmp(tmp.name, local_path): shutil.cop...
[ "def", "UpdateJobsState", "(", "state", ")", ":", "local_path", "=", "CachedFilePath", "(", "JOBS_STATE_FILE", ")", "with", "tempfile_ext", ".", "NamedTemporaryFile", "(", "mode", "=", "'w'", ")", "as", "tmp", ":", "json", ".", "dump", "(", "state", ",", "...
Write back the updated state of pinpoint jobs.
[ "Write", "back", "the", "updated", "state", "of", "pinpoint", "jobs", "." ]
[ "\"\"\"Write back the updated state of pinpoint jobs.\n\n If there were any changes to the state, i.e. new jobs were created or\n existing ones completed, both the local cached copy and the backup in cloud\n storage are updated.\n \"\"\"" ]
[ { "param": "state", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "state", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
GetCachedDataset
<not_specific>
def GetCachedDataset(): """Load the latest dataset with cached data.""" local_path = CachedFilePath(DATASET_PKL_FILE) if os.path.exists(local_path) or DownloadFromCloudStorage(local_path): return pd.read_pickle(local_path) else: return None
Load the latest dataset with cached data.
Load the latest dataset with cached data.
[ "Load", "the", "latest", "dataset", "with", "cached", "data", "." ]
def GetCachedDataset(): local_path = CachedFilePath(DATASET_PKL_FILE) if os.path.exists(local_path) or DownloadFromCloudStorage(local_path): return pd.read_pickle(local_path) else: return None
[ "def", "GetCachedDataset", "(", ")", ":", "local_path", "=", "CachedFilePath", "(", "DATASET_PKL_FILE", ")", "if", "os", ".", "path", ".", "exists", "(", "local_path", ")", "or", "DownloadFromCloudStorage", "(", "local_path", ")", ":", "return", "pd", ".", "...
Load the latest dataset with cached data.
[ "Load", "the", "latest", "dataset", "with", "cached", "data", "." ]
[ "\"\"\"Load the latest dataset with cached data.\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
UpdateCachedDataset
null
def UpdateCachedDataset(df): """Write back the dataset with cached data.""" local_path = CachedFilePath(DATASET_PKL_FILE) df.to_pickle(local_path) UploadToCloudStorage(local_path)
Write back the dataset with cached data.
Write back the dataset with cached data.
[ "Write", "back", "the", "dataset", "with", "cached", "data", "." ]
def UpdateCachedDataset(df): local_path = CachedFilePath(DATASET_PKL_FILE) df.to_pickle(local_path) UploadToCloudStorage(local_path)
[ "def", "UpdateCachedDataset", "(", "df", ")", ":", "local_path", "=", "CachedFilePath", "(", "DATASET_PKL_FILE", ")", "df", ".", "to_pickle", "(", "local_path", ")", "UploadToCloudStorage", "(", "local_path", ")" ]
Write back the dataset with cached data.
[ "Write", "back", "the", "dataset", "with", "cached", "data", "." ]
[ "\"\"\"Write back the dataset with cached data.\"\"\"" ]
[ { "param": "df", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "df", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
GetItemsToUpdate
<not_specific>
def GetItemsToUpdate(state): """Select jobs with new data to download and cached data for existing jobs. This also filters out old revisions to keep only recent (6 months) data. Returns: new_items: A list of job items from which to get data. cached_df: A DataFrame with existing cached data, may be None....
Select jobs with new data to download and cached data for existing jobs. This also filters out old revisions to keep only recent (6 months) data. Returns: new_items: A list of job items from which to get data. cached_df: A DataFrame with existing cached data, may be None.
Select jobs with new data to download and cached data for existing jobs. This also filters out old revisions to keep only recent (6 months) data.
[ "Select", "jobs", "with", "new", "data", "to", "download", "and", "cached", "data", "for", "existing", "jobs", ".", "This", "also", "filters", "out", "old", "revisions", "to", "keep", "only", "recent", "(", "6", "months", ")", "data", "." ]
def GetItemsToUpdate(state): from_date = str(TimeAgo(months=6).date()) new_items = [item for item in state if item['timestamp'] > from_date] df = GetCachedDataset() if df is not None: recent_revisions = set(item['revision'] for item in new_items) df = df[df['revision'].isin(recent_revisions)] known_...
[ "def", "GetItemsToUpdate", "(", "state", ")", ":", "from_date", "=", "str", "(", "TimeAgo", "(", "months", "=", "6", ")", ".", "date", "(", ")", ")", "new_items", "=", "[", "item", "for", "item", "in", "state", "if", "item", "[", "'timestamp'", "]", ...
Select jobs with new data to download and cached data for existing jobs.
[ "Select", "jobs", "with", "new", "data", "to", "download", "and", "cached", "data", "for", "existing", "jobs", "." ]
[ "\"\"\"Select jobs with new data to download and cached data for existing jobs.\n\n This also filters out old revisions to keep only recent (6 months) data.\n\n Returns:\n new_items: A list of job items from which to get data.\n cached_df: A DataFrame with existing cached data, may be None.\n \"\"\"" ]
[ { "param": "state", "type": null } ]
{ "returns": [ { "docstring": "A list of job items from which to get data.\ncached_df: A DataFrame with existing cached data, may be None.", "docstring_tokens": [ "A", "list", "of", "job", "items", "from", "which", "to", "get", ...
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
AggregateAndUploadResults
<not_specific>
def AggregateAndUploadResults(new_items, cached_df=None): """Aggregate results collected and upload them to cloud storage.""" dfs = [] if cached_df is not None: dfs.append(cached_df) found_new = False for item in new_items: if _SkipProcessing(item): # Jobs are not ready, or all have failed. co...
Aggregate results collected and upload them to cloud storage.
Aggregate results collected and upload them to cloud storage.
[ "Aggregate", "results", "collected", "and", "upload", "them", "to", "cloud", "storage", "." ]
def AggregateAndUploadResults(new_items, cached_df=None): dfs = [] if cached_df is not None: dfs.append(cached_df) found_new = False for item in new_items: if _SkipProcessing(item): continue if not found_new: logging.info('Processing data from new results:') found_new = True ...
[ "def", "AggregateAndUploadResults", "(", "new_items", ",", "cached_df", "=", "None", ")", ":", "dfs", "=", "[", "]", "if", "cached_df", "is", "not", "None", ":", "dfs", ".", "append", "(", "cached_df", ")", "found_new", "=", "False", "for", "item", "in",...
Aggregate results collected and upload them to cloud storage.
[ "Aggregate", "results", "collected", "and", "upload", "them", "to", "cloud", "storage", "." ]
[ "\"\"\"Aggregate results collected and upload them to cloud storage.\"\"\"", "# Jobs are not ready, or all have failed.", "# Otherwise update our cache and upload.", "# Drop revisions with no results and mark the last result for each metric,", "# both with/without patch, as a 'reference'. This allows making...
[ { "param": "new_items", "type": null }, { "param": "cached_df", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "new_items", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cached_df", "type": null, "docstring": null, "docstring_...
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
GetRevisionResults
<not_specific>
def GetRevisionResults(item): """Aggregate the results from jobs that ran on a particular revision.""" # First load pinpoint csv results into a DataFrame. The dtype arg is needed # to ensure that job_id's are always read a strings (even if some of them # look like large numbers). df = pd.read_csv(RevisionResu...
Aggregate the results from jobs that ran on a particular revision.
Aggregate the results from jobs that ran on a particular revision.
[ "Aggregate", "the", "results", "from", "jobs", "that", "ran", "on", "a", "particular", "revision", "." ]
def GetRevisionResults(item): df = pd.read_csv(RevisionResultsFile(item), dtype={'job_id': str}) assert df['change'].str.contains(item['revision']).all(), ( 'Not all results match the expected git revision') df = df[df['name'].isin(MEASUREMENTS)] df = df[df['story'].isin(ACTIVE_STORIES)] if not df.empty...
[ "def", "GetRevisionResults", "(", "item", ")", ":", "df", "=", "pd", ".", "read_csv", "(", "RevisionResultsFile", "(", "item", ")", ",", "dtype", "=", "{", "'job_id'", ":", "str", "}", ")", "assert", "df", "[", "'change'", "]", ".", "str", ".", "cont...
Aggregate the results from jobs that ran on a particular revision.
[ "Aggregate", "the", "results", "from", "jobs", "that", "ran", "on", "a", "particular", "revision", "." ]
[ "\"\"\"Aggregate the results from jobs that ran on a particular revision.\"\"\"", "# First load pinpoint csv results into a DataFrame. The dtype arg is needed", "# to ensure that job_id's are always read a strings (even if some of them", "# look like large numbers).", "# Filter out and keep only the measure...
[ { "param": "item", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "item", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
GetLastCommitOfDate
<not_specific>
def GetLastCommitOfDate(date): """"Find the the lastest commit that landed on a given date.""" # Make sure our local git repo has up to date info on origin/master. logging.info('Fetching latest origin/master data.') subprocess.check_output( ['git', 'fetch', 'origin', 'master'], cwd=TOOLS_PERF_DIR, s...
Find the the lastest commit that landed on a given date.
Find the the lastest commit that landed on a given date.
[ "Find", "the", "the", "lastest", "commit", "that", "landed", "on", "a", "given", "date", "." ]
def GetLastCommitOfDate(date): logging.info('Fetching latest origin/master data.') subprocess.check_output( ['git', 'fetch', 'origin', 'master'], cwd=TOOLS_PERF_DIR, stderr=subprocess.STDOUT) cutoff_date = date.replace(hour=12).ceil('D') logging.info('Finding latest commit before %s.', cutoff_date) ...
[ "def", "GetLastCommitOfDate", "(", "date", ")", ":", "logging", ".", "info", "(", "'Fetching latest origin/master data.'", ")", "subprocess", ".", "check_output", "(", "[", "'git'", ",", "'fetch'", ",", "'origin'", ",", "'master'", "]", ",", "cwd", "=", "TOOLS...
Find the the lastest commit that landed on a given date.
[ "Find", "the", "the", "lastest", "commit", "that", "landed", "on", "a", "given", "date", "." ]
[ "\"\"\"\"Find the the lastest commit that landed on a given date.\"\"\"", "# Make sure our local git repo has up to date info on origin/master.", "# Snap the date to the end of the day.", "# We expect there to be some commits after the 'cutoff_date', otherwise", "# there isn't yet a *last* commit before tha...
[ { "param": "date", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "date", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
FindCommit
<not_specific>
def FindCommit(before_date=None, after_date=None): """Find latest commit with optional before/after date constraints.""" cmd = ['git', 'log', '--max-count', '1', '--format=format:%H:%ct'] if before_date is not None: cmd.extend(['--before', before_date.isoformat()]) if after_date is not None: cmd.extend(...
Find latest commit with optional before/after date constraints.
Find latest commit with optional before/after date constraints.
[ "Find", "latest", "commit", "with", "optional", "before", "/", "after", "date", "constraints", "." ]
def FindCommit(before_date=None, after_date=None): cmd = ['git', 'log', '--max-count', '1', '--format=format:%H:%ct'] if before_date is not None: cmd.extend(['--before', before_date.isoformat()]) if after_date is not None: cmd.extend(['--after', after_date.isoformat()]) cmd.append('origin/master') lin...
[ "def", "FindCommit", "(", "before_date", "=", "None", ",", "after_date", "=", "None", ")", ":", "cmd", "=", "[", "'git'", ",", "'log'", ",", "'--max-count'", ",", "'1'", ",", "'--format=format:%H:%ct'", "]", "if", "before_date", "is", "not", "None", ":", ...
Find latest commit with optional before/after date constraints.
[ "Find", "latest", "commit", "with", "optional", "before", "/", "after", "date", "constraints", "." ]
[ "\"\"\"Find latest commit with optional before/after date constraints.\"\"\"" ]
[ { "param": "before_date", "type": null }, { "param": "after_date", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "before_date", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "after_date", "type": null, "docstring": null, "docstri...
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
DownloadFromCloudStorage
<not_specific>
def DownloadFromCloudStorage(filepath): """Get the given file from cloud storage.""" try: gsutil.Copy( posixpath.join(CLOUD_STORAGE_DIR, os.path.basename(filepath)), filepath) logging.info('Downloaded copy of %s from cloud storage.', filepath) return True except subprocess.CalledProcessError: ...
Get the given file from cloud storage.
Get the given file from cloud storage.
[ "Get", "the", "given", "file", "from", "cloud", "storage", "." ]
def DownloadFromCloudStorage(filepath): try: gsutil.Copy( posixpath.join(CLOUD_STORAGE_DIR, os.path.basename(filepath)), filepath) logging.info('Downloaded copy of %s from cloud storage.', filepath) return True except subprocess.CalledProcessError: logging.info('Failed to download copy of %s...
[ "def", "DownloadFromCloudStorage", "(", "filepath", ")", ":", "try", ":", "gsutil", ".", "Copy", "(", "posixpath", ".", "join", "(", "CLOUD_STORAGE_DIR", ",", "os", ".", "path", ".", "basename", "(", "filepath", ")", ")", ",", "filepath", ")", "logging", ...
Get the given file from cloud storage.
[ "Get", "the", "given", "file", "from", "cloud", "storage", "." ]
[ "\"\"\"Get the given file from cloud storage.\"\"\"" ]
[ { "param": "filepath", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filepath", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f61294bbca498db4ab2494dbcc5b399baea3479c
sunlongbo/chromium
tools/perf/cli_tools/pinboard/pinboard.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
SetUpLogging
null
def SetUpLogging(level): """Set up logging to log both to stderr and a file.""" logger = logging.getLogger() logger.setLevel(level) formatter = logging.Formatter( '(%(levelname)s) %(asctime)s [%(module)s] %(message)s') h1 = logging.StreamHandler() h1.setFormatter(formatter) logger.addHandler(h1) ...
Set up logging to log both to stderr and a file.
Set up logging to log both to stderr and a file.
[ "Set", "up", "logging", "to", "log", "both", "to", "stderr", "and", "a", "file", "." ]
def SetUpLogging(level): logger = logging.getLogger() logger.setLevel(level) formatter = logging.Formatter( '(%(levelname)s) %(asctime)s [%(module)s] %(message)s') h1 = logging.StreamHandler() h1.setFormatter(formatter) logger.addHandler(h1) h2 = handlers.TimedRotatingFileHandler( filename=Cach...
[ "def", "SetUpLogging", "(", "level", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", ")", "logger", ".", "setLevel", "(", "level", ")", "formatter", "=", "logging", ".", "Formatter", "(", "'(%(levelname)s) %(asctime)s [%(module)s] %(message)s'", ")", ...
Set up logging to log both to stderr and a file.
[ "Set", "up", "logging", "to", "log", "both", "to", "stderr", "and", "a", "file", "." ]
[ "\"\"\"Set up logging to log both to stderr and a file.\"\"\"" ]
[ { "param": "level", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "level", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9b6ccceb254ac469507ff24498bdcf9c954452cc
sunlongbo/chromium
third_party/blink/renderer/modules/bluetooth/testing/clusterfuzz/fuzzer_helpers.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
FillInParameter
<not_specific>
def FillInParameter(parameter, func, template): """Replaces occurrences of a parameter by calling a provided generator. Args: parameter: A string representing the parameter that should be replaced. func: A function that returns a string representing the value used to replace an instance o...
Replaces occurrences of a parameter by calling a provided generator. Args: parameter: A string representing the parameter that should be replaced. func: A function that returns a string representing the value used to replace an instance of the parameter. template: A string that contains...
Replaces occurrences of a parameter by calling a provided generator.
[ "Replaces", "occurrences", "of", "a", "parameter", "by", "calling", "a", "provided", "generator", "." ]
def FillInParameter(parameter, func, template): result = template while parameter in result: result = result.replace(parameter, func(), 1) return result
[ "def", "FillInParameter", "(", "parameter", ",", "func", ",", "template", ")", ":", "result", "=", "template", "while", "parameter", "in", "result", ":", "result", "=", "result", ".", "replace", "(", "parameter", ",", "func", "(", ")", ",", "1", ")", "...
Replaces occurrences of a parameter by calling a provided generator.
[ "Replaces", "occurrences", "of", "a", "parameter", "by", "calling", "a", "provided", "generator", "." ]
[ "\"\"\"Replaces occurrences of a parameter by calling a provided generator.\n\n Args:\n parameter: A string representing the parameter that should be replaced.\n func: A function that returns a string representing the value used to\n replace an instance of the parameter.\n template: A str...
[ { "param": "parameter", "type": null }, { "param": "func", "type": null }, { "param": "template", "type": null } ]
{ "returns": [ { "docstring": "A string containing the value of |template| in which instances of\n|pameter| have been replaced by results of calling |func|.", "docstring_tokens": [ "A", "string", "containing", "the", "value", "of", "|template|", ...
e9424b76b18f0694906b990dc7b6da70c3a4c72b
sunlongbo/chromium
tools/variations/bisect_variations.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_GetSupportedBrowserTypes
<not_specific>
def _GetSupportedBrowserTypes(): """Returns the supported browser types on this platform.""" if sys.platform.startswith('win'): return _CHROME_PATH_WIN.keys() if sys.platform == 'darwin': return _CHROME_PATH_MAC.keys(); if sys.platform.startswith('linux'): return _CHROME_PATH_LINUX.keys(); raise N...
Returns the supported browser types on this platform.
Returns the supported browser types on this platform.
[ "Returns", "the", "supported", "browser", "types", "on", "this", "platform", "." ]
def _GetSupportedBrowserTypes(): if sys.platform.startswith('win'): return _CHROME_PATH_WIN.keys() if sys.platform == 'darwin': return _CHROME_PATH_MAC.keys(); if sys.platform.startswith('linux'): return _CHROME_PATH_LINUX.keys(); raise NotImplementedError('Unsupported platform')
[ "def", "_GetSupportedBrowserTypes", "(", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "'win'", ")", ":", "return", "_CHROME_PATH_WIN", ".", "keys", "(", ")", "if", "sys", ".", "platform", "==", "'darwin'", ":", "return", "_CHROME_PATH_MAC"...
Returns the supported browser types on this platform.
[ "Returns", "the", "supported", "browser", "types", "on", "this", "platform", "." ]
[ "\"\"\"Returns the supported browser types on this platform.\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
e9424b76b18f0694906b990dc7b6da70c3a4c72b
sunlongbo/chromium
tools/variations/bisect_variations.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_LocateBrowser_Win
<not_specific>
def _LocateBrowser_Win(browser_type): """Locates browser executable path based on input browser type. Args: browser_type: 'stable', 'beta', 'dev', 'canary', or 'chromium'. Returns: Browser executable path. """ if browser_type in ['stable', 'beta', 'dev']: return os.path.join(os.getenv('Progr...
Locates browser executable path based on input browser type. Args: browser_type: 'stable', 'beta', 'dev', 'canary', or 'chromium'. Returns: Browser executable path.
Locates browser executable path based on input browser type.
[ "Locates", "browser", "executable", "path", "based", "on", "input", "browser", "type", "." ]
def _LocateBrowser_Win(browser_type): if browser_type in ['stable', 'beta', 'dev']: return os.path.join(os.getenv('ProgramFiles(x86)'), _CHROME_PATH_WIN[browser_type]) else: assert browser_type in ['canary', 'chromium'] return os.path.join(os.getenv('LOCALAPPDATA'), ...
[ "def", "_LocateBrowser_Win", "(", "browser_type", ")", ":", "if", "browser_type", "in", "[", "'stable'", ",", "'beta'", ",", "'dev'", "]", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "getenv", "(", "'ProgramFiles(x86)'", ")", ",", "_CH...
Locates browser executable path based on input browser type.
[ "Locates", "browser", "executable", "path", "based", "on", "input", "browser", "type", "." ]
[ "\"\"\"Locates browser executable path based on input browser type.\n\n Args:\n browser_type: 'stable', 'beta', 'dev', 'canary', or 'chromium'.\n\n Returns:\n Browser executable path.\n \"\"\"" ]
[ { "param": "browser_type", "type": null } ]
{ "returns": [ { "docstring": "Browser executable path.", "docstring_tokens": [ "Browser", "executable", "path", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "browser_type", "type": null, "docstring": "'s...
e9424b76b18f0694906b990dc7b6da70c3a4c72b
sunlongbo/chromium
tools/variations/bisect_variations.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_LocateBrowser_Mac
<not_specific>
def _LocateBrowser_Mac(browser_type): """Locates browser executable path based on input browser type. Args: browser_type: A supported browser type on Mac. Returns: Browser executable path. """ return _CHROME_PATH_MAC[browser_type]
Locates browser executable path based on input browser type. Args: browser_type: A supported browser type on Mac. Returns: Browser executable path.
Locates browser executable path based on input browser type.
[ "Locates", "browser", "executable", "path", "based", "on", "input", "browser", "type", "." ]
def _LocateBrowser_Mac(browser_type): return _CHROME_PATH_MAC[browser_type]
[ "def", "_LocateBrowser_Mac", "(", "browser_type", ")", ":", "return", "_CHROME_PATH_MAC", "[", "browser_type", "]" ]
Locates browser executable path based on input browser type.
[ "Locates", "browser", "executable", "path", "based", "on", "input", "browser", "type", "." ]
[ "\"\"\"Locates browser executable path based on input browser type.\n\n Args:\n browser_type: A supported browser type on Mac.\n\n Returns:\n Browser executable path.\n \"\"\"" ]
[ { "param": "browser_type", "type": null } ]
{ "returns": [ { "docstring": "Browser executable path.", "docstring_tokens": [ "Browser", "executable", "path", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "browser_type", "type": null, "docstring": "A ...
e9424b76b18f0694906b990dc7b6da70c3a4c72b
sunlongbo/chromium
tools/variations/bisect_variations.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_LocateBrowser_Linux
<not_specific>
def _LocateBrowser_Linux(browser_type): """Locates browser executable path based on input browser type. Args: browser_type: A supported browser type on Linux. Returns: Browser executable path. """ return _CHROME_PATH_LINUX[browser_type]
Locates browser executable path based on input browser type. Args: browser_type: A supported browser type on Linux. Returns: Browser executable path.
Locates browser executable path based on input browser type.
[ "Locates", "browser", "executable", "path", "based", "on", "input", "browser", "type", "." ]
def _LocateBrowser_Linux(browser_type): return _CHROME_PATH_LINUX[browser_type]
[ "def", "_LocateBrowser_Linux", "(", "browser_type", ")", ":", "return", "_CHROME_PATH_LINUX", "[", "browser_type", "]" ]
Locates browser executable path based on input browser type.
[ "Locates", "browser", "executable", "path", "based", "on", "input", "browser", "type", "." ]
[ "\"\"\"Locates browser executable path based on input browser type.\n\n Args:\n browser_type: A supported browser type on Linux.\n\n Returns:\n Browser executable path.\n \"\"\"" ]
[ { "param": "browser_type", "type": null } ]
{ "returns": [ { "docstring": "Browser executable path.", "docstring_tokens": [ "Browser", "executable", "path", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "browser_type", "type": null, "docstring": "A ...
e9424b76b18f0694906b990dc7b6da70c3a4c72b
sunlongbo/chromium
tools/variations/bisect_variations.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_LocateBrowser
<not_specific>
def _LocateBrowser(browser_type): """Locates browser executable path based on input browser type. Args: browser_type: A supported browser types on this platform. Returns: Browser executable path. """ supported_browser_types = _GetSupportedBrowserTypes() if browser_type not in supported_browser...
Locates browser executable path based on input browser type. Args: browser_type: A supported browser types on this platform. Returns: Browser executable path.
Locates browser executable path based on input browser type.
[ "Locates", "browser", "executable", "path", "based", "on", "input", "browser", "type", "." ]
def _LocateBrowser(browser_type): supported_browser_types = _GetSupportedBrowserTypes() if browser_type not in supported_browser_types: raise ValueError('Invalid browser type. Supported values are: %s.' % ', '.join(supported_browser_types)) if sys.platform.startswith('win'): retur...
[ "def", "_LocateBrowser", "(", "browser_type", ")", ":", "supported_browser_types", "=", "_GetSupportedBrowserTypes", "(", ")", "if", "browser_type", "not", "in", "supported_browser_types", ":", "raise", "ValueError", "(", "'Invalid browser type. Supported values are: %s.'", ...
Locates browser executable path based on input browser type.
[ "Locates", "browser", "executable", "path", "based", "on", "input", "browser", "type", "." ]
[ "\"\"\"Locates browser executable path based on input browser type.\n\n Args:\n browser_type: A supported browser types on this platform.\n\n Returns:\n Browser executable path.\n \"\"\"" ]
[ { "param": "browser_type", "type": null } ]
{ "returns": [ { "docstring": "Browser executable path.", "docstring_tokens": [ "Browser", "executable", "path", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "browser_type", "type": null, "docstring": "A ...
e9424b76b18f0694906b990dc7b6da70c3a4c72b
sunlongbo/chromium
tools/variations/bisect_variations.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_LoadVariations
<not_specific>
def _LoadVariations(filename): """Reads variations commandline switches from a file. Args: filename: A file that contains variations commandline switches. Returns: A list of commandline switches. """ with open(filename, 'r') as f: data = f.read().replace('\n', ' ') switches = split_variati...
Reads variations commandline switches from a file. Args: filename: A file that contains variations commandline switches. Returns: A list of commandline switches.
Reads variations commandline switches from a file.
[ "Reads", "variations", "commandline", "switches", "from", "a", "file", "." ]
def _LoadVariations(filename): with open(filename, 'r') as f: data = f.read().replace('\n', ' ') switches = split_variations_cmd.ParseCommandLineSwitchesString(data) return ['--%s=%s' % (switch_name, switch_value) for switch_name, switch_value in switches.items()]
[ "def", "_LoadVariations", "(", "filename", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "data", "=", "f", ".", "read", "(", ")", ".", "replace", "(", "'\\n'", ",", "' '", ")", "switches", "=", "split_variations_cmd", "....
Reads variations commandline switches from a file.
[ "Reads", "variations", "commandline", "switches", "from", "a", "file", "." ]
[ "\"\"\"Reads variations commandline switches from a file.\n\n Args:\n filename: A file that contains variations commandline switches.\n\n Returns:\n A list of commandline switches.\n \"\"\"" ]
[ { "param": "filename", "type": null } ]
{ "returns": [ { "docstring": "A list of commandline switches.", "docstring_tokens": [ "A", "list", "of", "commandline", "switches", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "filename", "typ...
e9424b76b18f0694906b990dc7b6da70c3a4c72b
sunlongbo/chromium
tools/variations/bisect_variations.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_BuildBrowserArgs
<not_specific>
def _BuildBrowserArgs(user_data_dir, extra_browser_args, variations_args): """Builds commandline switches browser runs with. Args: user_data_dir: A path that is used as user data dir. extra_browser_args: A list of extra commandline switches browser runs with. variations_args: A list of ...
Builds commandline switches browser runs with. Args: user_data_dir: A path that is used as user data dir. extra_browser_args: A list of extra commandline switches browser runs with. variations_args: A list of commandline switches that defines the variations cmd browser runs with...
Builds commandline switches browser runs with.
[ "Builds", "commandline", "switches", "browser", "runs", "with", "." ]
def _BuildBrowserArgs(user_data_dir, extra_browser_args, variations_args): browser_args = [ '--no-first-run', '--no-default-browser-check', '--user-data-dir=%s' % user_data_dir, ] browser_args.extend(extra_browser_args) browser_args.extend(variations_args) return browser_args
[ "def", "_BuildBrowserArgs", "(", "user_data_dir", ",", "extra_browser_args", ",", "variations_args", ")", ":", "browser_args", "=", "[", "'--no-first-run'", ",", "'--no-default-browser-check'", ",", "'--user-data-dir=%s'", "%", "user_data_dir", ",", "]", "browser_args", ...
Builds commandline switches browser runs with.
[ "Builds", "commandline", "switches", "browser", "runs", "with", "." ]
[ "\"\"\"Builds commandline switches browser runs with.\n\n Args:\n user_data_dir: A path that is used as user data dir.\n extra_browser_args: A list of extra commandline switches browser runs\n with.\n variations_args: A list of commandline switches that defines the\n variations cmd...
[ { "param": "user_data_dir", "type": null }, { "param": "extra_browser_args", "type": null }, { "param": "variations_args", "type": null } ]
{ "returns": [ { "docstring": "A list of commandline switches.", "docstring_tokens": [ "A", "list", "of", "commandline", "switches", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "user_data_dir", ...
e9424b76b18f0694906b990dc7b6da70c3a4c72b
sunlongbo/chromium
tools/variations/bisect_variations.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_RunVariations
<not_specific>
def _RunVariations(browser_path, url, extra_browser_args, variations_args): """Launches browser with given variations. Args: browser_path: Browser executable file. url: The webpage URL browser goes to after it launches. extra_browser_args: A list of extra commandline switches browser runs ...
Launches browser with given variations. Args: browser_path: Browser executable file. url: The webpage URL browser goes to after it launches. extra_browser_args: A list of extra commandline switches browser runs with. variations_args: A list of commandline switches that defines the ...
Launches browser with given variations.
[ "Launches", "browser", "with", "given", "variations", "." ]
def _RunVariations(browser_path, url, extra_browser_args, variations_args): command = [os.path.abspath(browser_path)] if url: command.append(url) tempdir = tempfile.mkdtemp(prefix='bisect_variations_tmp') command.extend(_BuildBrowserArgs(user_data_dir=tempdir, extra_browse...
[ "def", "_RunVariations", "(", "browser_path", ",", "url", ",", "extra_browser_args", ",", "variations_args", ")", ":", "command", "=", "[", "os", ".", "path", ".", "abspath", "(", "browser_path", ")", "]", "if", "url", ":", "command", ".", "append", "(", ...
Launches browser with given variations.
[ "Launches", "browser", "with", "given", "variations", "." ]
[ "\"\"\"Launches browser with given variations.\n\n Args:\n browser_path: Browser executable file.\n url: The webpage URL browser goes to after it launches.\n extra_browser_args: A list of extra commandline switches browser runs\n with.\n variations_args: A list of commandline switches ...
[ { "param": "browser_path", "type": null }, { "param": "url", "type": null }, { "param": "extra_browser_args", "type": null }, { "param": "variations_args", "type": null } ]
{ "returns": [ { "docstring": "A set of (returncode, stdout, stderr) from browser subprocess.", "docstring_tokens": [ "A", "set", "of", "(", "returncode", "stdout", "stderr", ")", "from", "browser", "subprocess", ...
e9424b76b18f0694906b990dc7b6da70c3a4c72b
sunlongbo/chromium
tools/variations/bisect_variations.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
_AskCanReproduce
<not_specific>
def _AskCanReproduce(exit_status, stdout, stderr): """Asks whether running Chrome with given variations reproduces the issue. Args: exit_status: Chrome subprocess return code. stdout: Chrome subprocess stdout. stderr: Chrome subprocess stderr. Returns: One of ['y', 'n', 'r']: 'y'...
Asks whether running Chrome with given variations reproduces the issue. Args: exit_status: Chrome subprocess return code. stdout: Chrome subprocess stdout. stderr: Chrome subprocess stderr. Returns: One of ['y', 'n', 'r']: 'y': yes 'n': no 'r': retry
Asks whether running Chrome with given variations reproduces the issue.
[ "Asks", "whether", "running", "Chrome", "with", "given", "variations", "reproduces", "the", "issue", "." ]
def _AskCanReproduce(exit_status, stdout, stderr): while True: response = raw_input('Can we reproduce with given variations file ' '[(y)es/(n)o/(r)etry/(s)tdout/(q)uit]: ').lower() if response in ('y', 'n', 'r'): return response if response == 'q': sys.exit() if re...
[ "def", "_AskCanReproduce", "(", "exit_status", ",", "stdout", ",", "stderr", ")", ":", "while", "True", ":", "response", "=", "raw_input", "(", "'Can we reproduce with given variations file '", "'[(y)es/(n)o/(r)etry/(s)tdout/(q)uit]: '", ")", ".", "lower", "(", ")", "...
Asks whether running Chrome with given variations reproduces the issue.
[ "Asks", "whether", "running", "Chrome", "with", "given", "variations", "reproduces", "the", "issue", "." ]
[ "\"\"\"Asks whether running Chrome with given variations reproduces the issue.\n\n Args:\n exit_status: Chrome subprocess return code.\n stdout: Chrome subprocess stdout.\n stderr: Chrome subprocess stderr.\n\n Returns:\n One of ['y', 'n', 'r']:\n 'y': yes\n 'n': no\n 'r':...
[ { "param": "exit_status", "type": null }, { "param": "stdout", "type": null }, { "param": "stderr", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "One of ['y', 'n', 'r']" } ], "raises": [], "params": [ { "identifier": "exit_status", "type": null, "docstring": "Chrome subprocess return code.", "docstring_tokens": ...
f89c5293a3e16ade7a1cb2425d4b816bf8c7717c
sunlongbo/chromium
chrome/chrome_cleaner/tools/import_util.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
AddProtosToPath
null
def AddProtosToPath(root_path): """Adds generated protobuf modules to the Python import path. Args: root_path: root directory where the pyproto subdir is located. """ assert root_path is not None # Add the root pyproto dir so Python packages under that dir (such as # google.protobuf, which is built by ...
Adds generated protobuf modules to the Python import path. Args: root_path: root directory where the pyproto subdir is located.
Adds generated protobuf modules to the Python import path.
[ "Adds", "generated", "protobuf", "modules", "to", "the", "Python", "import", "path", "." ]
def AddProtosToPath(root_path): assert root_path is not None pyproto_dir = os.path.join(root_path, 'pyproto') AddImportPath(pyproto_dir) AddImportPath(os.path.join(pyproto_dir, 'chrome', 'chrome_cleaner', 'proto')) AddImportPath(os.path.join(pyproto_dir, 'chrome', 'chrome_cleaner', 'logging', ...
[ "def", "AddProtosToPath", "(", "root_path", ")", ":", "assert", "root_path", "is", "not", "None", "pyproto_dir", "=", "os", ".", "path", ".", "join", "(", "root_path", ",", "'pyproto'", ")", "AddImportPath", "(", "pyproto_dir", ")", "AddImportPath", "(", "os...
Adds generated protobuf modules to the Python import path.
[ "Adds", "generated", "protobuf", "modules", "to", "the", "Python", "import", "path", "." ]
[ "\"\"\"Adds generated protobuf modules to the Python import path.\n\n Args:\n root_path: root directory where the pyproto subdir is located.\n \"\"\"", "# Add the root pyproto dir so Python packages under that dir (such as", "# google.protobuf, which is built by //third_party/protobuf:py_proto) can be", ...
[ { "param": "root_path", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root_path", "type": null, "docstring": "root directory where the pyproto subdir is located.", "docstring_tokens": [ "root", "directory", "where", "the", "pyproto", "subdir", ...
5e8de89409976528f8d97d4962f9f111c6d158a1
sunlongbo/chromium
third_party/blink/renderer/bindings/scripts/web_idl/composition_parts.py
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
Python
location
<not_specific>
def location(self): """ Returns the primary location, i.e. location of the main definition. """ return self._locations[0] if self._locations else Location()
Returns the primary location, i.e. location of the main definition.
Returns the primary location, i.e. location of the main definition.
[ "Returns", "the", "primary", "location", "i", ".", "e", ".", "location", "of", "the", "main", "definition", "." ]
def location(self): return self._locations[0] if self._locations else Location()
[ "def", "location", "(", "self", ")", ":", "return", "self", ".", "_locations", "[", "0", "]", "if", "self", ".", "_locations", "else", "Location", "(", ")" ]
Returns the primary location, i.e.
[ "Returns", "the", "primary", "location", "i", ".", "e", "." ]
[ "\"\"\"\n Returns the primary location, i.e. location of the main definition.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }