pile_js / ChromeDevTools__devtools-frontend.jsonl
Hamhams's picture
commit files to HF hub
c7f4bd0
{"nwo":"ChromeDevTools\/devtools-frontend","sha":"36834dd5de91aba0b15de21fc93958eee9e49108","path":"PRESUBMIT.py","language":"python","identifier":"_CheckForTooLargeFiles","parameters":"(input_api, output_api)","argument_list":"","return_statement":"","docstring":"Avoid large files, especially binary files, in the repository since\n git doesn't scale well for those. They will be in everyone's repo\n clones forever, forever making Chromium slower to clone and work\n with.","docstring_summary":"Avoid large files, especially binary files, in the repository since\n git doesn't scale well for those. They will be in everyone's repo\n clones forever, forever making Chromium slower to clone and work\n with.","docstring_tokens":["Avoid","large","files","especially","binary","files","in","the","repository","since","git","doesn","t","scale","well","for","those",".","They","will","be","in","everyone","s","repo","clones","forever","forever","making","Chromium","slower","to","clone","and","work","with","."],"function":"def _CheckForTooLargeFiles(input_api, output_api):\n \"\"\"Avoid large files, especially binary files, in the repository since\n git doesn't scale well for those. They will be in everyone's repo\n clones forever, forever making Chromium slower to clone and work\n with.\"\"\"\n # Uploading files to cloud storage is not trivial so we don't want\n # to set the limit too low, but the upper limit for \"normal\" large\n # files seems to be 1-2 MB, with a handful around 5-8 MB, so\n # anything over 20 MB is exceptional.\n TOO_LARGE_FILE_SIZE_LIMIT = 20 * 1024 * 1024 # 10 MB\n too_large_files = []\n for f in input_api.AffectedFiles():\n # Check both added and modified files (but not deleted files).\n if f.Action() in ('A', 'M'):\n size = input_api.os_path.getsize(f.AbsoluteLocalPath())\n if size > TOO_LARGE_FILE_SIZE_LIMIT:\n too_large_files.append(\"%s: %d bytes\" % (f.LocalPath(), size))\n if too_large_files:\n message = (\n 'Do not commit large files to git since git scales badly for those.\\n' +\n 'Instead put the large files in cloud storage and use DEPS to\\n' +\n 'fetch them.\\n' + '\\n'.join(too_large_files)\n )\n return [output_api.PresubmitError(\n 'Too large files found in commit', long_text=message + '\\n')]\n else:\n return []","function_tokens":["def","_CheckForTooLargeFiles","(","input_api",",","output_api",")",":","# Uploading files to cloud storage is not trivial so we don't want","# to set the limit too low, but the upper limit for \"normal\" large","# files seems to be 1-2 MB, with a handful around 5-8 MB, so","# anything over 20 MB is exceptional.","TOO_LARGE_FILE_SIZE_LIMIT","=","20","*","1024","*","1024","# 10 MB","too_large_files","=","[","]","for","f","in","input_api",".","AffectedFiles","(",")",":","# Check both added and modified files (but not deleted files).","if","f",".","Action","(",")","in","(","'A'",",","'M'",")",":","size","=","input_api",".","os_path",".","getsize","(","f",".","AbsoluteLocalPath","(",")",")","if","size",">","TOO_LARGE_FILE_SIZE_LIMIT",":","too_large_files",".","append","(","\"%s: %d bytes\"","%","(","f",".","LocalPath","(",")",",","size",")",")","if","too_large_files",":","message","=","(","'Do not commit large files to git since git scales badly for those.\\n'","+","'Instead put the large files in cloud storage and use DEPS to\\n'","+","'fetch them.\\n'","+","'\\n'",".","join","(","too_large_files",")",")","return","[","output_api",".","PresubmitError","(","'Too large files found in commit'",",","long_text","=","message","+","'\\n'",")","]","else",":","return","[","]"],"url":"https:\/\/github.com\/ChromeDevTools\/devtools-frontend\/blob\/36834dd5de91aba0b15de21fc93958eee9e49108\/PRESUBMIT.py#L472-L498"}
{"nwo":"ChromeDevTools\/devtools-frontend","sha":"36834dd5de91aba0b15de21fc93958eee9e49108","path":"PRESUBMIT.py","language":"python","identifier":"_CommonChecks","parameters":"(input_api, output_api)","argument_list":"","return_statement":"return results","docstring":"Checks common to both upload and commit.","docstring_summary":"Checks common to both upload and commit.","docstring_tokens":["Checks","common","to","both","upload","and","commit","."],"function":"def _CommonChecks(input_api, output_api):\n \"\"\"Checks common to both upload and commit.\"\"\"\n results = []\n results.extend(\n input_api.canned_checks.CheckAuthorizedAuthor(\n input_api, output_api, bot_allowlist=[AUTOROLL_ACCOUNT]))\n results.extend(_CheckExperimentTelemetry(input_api, output_api))\n results.extend(_CheckGeneratedFiles(input_api, output_api))\n results.extend(_CheckDevToolsStyleJS(input_api, output_api))\n results.extend(_CheckDevToolsStyleCSS(input_api, output_api))\n results.extend(_CheckDevToolsRunESLintTests(input_api, output_api))\n results.extend(_CheckDevToolsNonJSFileLicenseHeaders(\n input_api, output_api))\n\n results.extend(_CheckFormat(input_api, output_api))\n results.extend(_CheckChangesAreExclusiveToDirectory(input_api, output_api))\n # Run the canned checks from `depot_tools` after the custom DevTools checks.\n # The canned checks for example check that lines have line endings. The\n # DevTools presubmit checks automatically fix these issues. If we would run\n # the canned checks before the DevTools checks, they would erroneously conclude\n # that there are issues in the code. Since the canned checks are allowed to be\n # ignored, a confusing message is shown that asks if the failed presubmit can\n # be continued regardless. By fixing the issues before we reach the canned checks,\n # we don't show the message to suppress these errors, which would otherwise be\n # causing CQ to fail.\n results.extend(_RunCannedChecks(input_api, output_api))\n return results","function_tokens":["def","_CommonChecks","(","input_api",",","output_api",")",":","results","=","[","]","results",".","extend","(","input_api",".","canned_checks",".","CheckAuthorizedAuthor","(","input_api",",","output_api",",","bot_allowlist","=","[","AUTOROLL_ACCOUNT","]",")",")","results",".","extend","(","_CheckExperimentTelemetry","(","input_api",",","output_api",")",")","results",".","extend","(","_CheckGeneratedFiles","(","input_api",",","output_api",")",")","results",".","extend","(","_CheckDevToolsStyleJS","(","input_api",",","output_api",")",")","results",".","extend","(","_CheckDevToolsStyleCSS","(","input_api",",","output_api",")",")","results",".","extend","(","_CheckDevToolsRunESLintTests","(","input_api",",","output_api",")",")","results",".","extend","(","_CheckDevToolsNonJSFileLicenseHeaders","(","input_api",",","output_api",")",")","results",".","extend","(","_CheckFormat","(","input_api",",","output_api",")",")","results",".","extend","(","_CheckChangesAreExclusiveToDirectory","(","input_api",",","output_api",")",")","# Run the canned checks from `depot_tools` after the custom DevTools checks.","# The canned checks for example check that lines have line endings. The","# DevTools presubmit checks automatically fix these issues. If we would run","# the canned checks before the DevTools checks, they would erroneously conclude","# that there are issues in the code. Since the canned checks are allowed to be","# ignored, a confusing message is shown that asks if the failed presubmit can","# be continued regardless. By fixing the issues before we reach the canned checks,","# we don't show the message to suppress these errors, which would otherwise be","# causing CQ to fail.","results",".","extend","(","_RunCannedChecks","(","input_api",",","output_api",")",")","return","results"],"url":"https:\/\/github.com\/ChromeDevTools\/devtools-frontend\/blob\/36834dd5de91aba0b15de21fc93958eee9e49108\/PRESUBMIT.py#L520-L546"}
{"nwo":"ChromeDevTools\/devtools-frontend","sha":"36834dd5de91aba0b15de21fc93958eee9e49108","path":"PRESUBMIT.py","language":"python","identifier":"_SideEffectChecks","parameters":"(input_api, output_api)","argument_list":"","return_statement":"return results","docstring":"Check side effects caused by other checks","docstring_summary":"Check side effects caused by other checks","docstring_tokens":["Check","side","effects","caused","by","other","checks"],"function":"def _SideEffectChecks(input_api, output_api):\n \"\"\"Check side effects caused by other checks\"\"\"\n results = []\n results.extend(_CheckNoUncheckedFiles(input_api, output_api))\n results.extend(_CheckForTooLargeFiles(input_api, output_api))\n return results","function_tokens":["def","_SideEffectChecks","(","input_api",",","output_api",")",":","results","=","[","]","results",".","extend","(","_CheckNoUncheckedFiles","(","input_api",",","output_api",")",")","results",".","extend","(","_CheckForTooLargeFiles","(","input_api",",","output_api",")",")","return","results"],"url":"https:\/\/github.com\/ChromeDevTools\/devtools-frontend\/blob\/36834dd5de91aba0b15de21fc93958eee9e49108\/PRESUBMIT.py#L549-L554"}
{"nwo":"ChromeDevTools\/devtools-frontend","sha":"36834dd5de91aba0b15de21fc93958eee9e49108","path":"PRESUBMIT.py","language":"python","identifier":"_getAffectedFiles","parameters":"(input_api, parent_directories, excluded_actions, accepted_endings)","argument_list":"","return_statement":"return affected_files","docstring":"Return absolute file paths of affected files (not due to an excluded action)\n under a parent directory with an accepted file ending.","docstring_summary":"Return absolute file paths of affected files (not due to an excluded action)\n under a parent directory with an accepted file ending.","docstring_tokens":["Return","absolute","file","paths","of","affected","files","(","not","due","to","an","excluded","action",")","under","a","parent","directory","with","an","accepted","file","ending","."],"function":"def _getAffectedFiles(input_api, parent_directories, excluded_actions, accepted_endings): # pylint: disable=invalid-name\n \"\"\"Return absolute file paths of affected files (not due to an excluded action)\n under a parent directory with an accepted file ending.\n \"\"\"\n local_paths = [\n f.AbsoluteLocalPath() for f in input_api.AffectedFiles() if all(f.Action() != action for action in excluded_actions)\n ]\n affected_files = [\n file_name for file_name in local_paths\n if any(parent_directory in file_name\n for parent_directory in parent_directories) and (\n len(accepted_endings) == 0 or any(\n file_name.endswith(accepted_ending)\n for accepted_ending in accepted_endings))\n ]\n return affected_files","function_tokens":["def","_getAffectedFiles","(","input_api",",","parent_directories",",","excluded_actions",",","accepted_endings",")",":","# pylint: disable=invalid-name","local_paths","=","[","f",".","AbsoluteLocalPath","(",")","for","f","in","input_api",".","AffectedFiles","(",")","if","all","(","f",".","Action","(",")","!=","action","for","action","in","excluded_actions",")","]","affected_files","=","[","file_name","for","file_name","in","local_paths","if","any","(","parent_directory","in","file_name","for","parent_directory","in","parent_directories",")","and","(","len","(","accepted_endings",")","==","0","or","any","(","file_name",".","endswith","(","accepted_ending",")","for","accepted_ending","in","accepted_endings",")",")","]","return","affected_files"],"url":"https:\/\/github.com\/ChromeDevTools\/devtools-frontend\/blob\/36834dd5de91aba0b15de21fc93958eee9e49108\/PRESUBMIT.py#L578-L593"}
{"nwo":"ChromeDevTools\/devtools-frontend","sha":"36834dd5de91aba0b15de21fc93958eee9e49108","path":"third_party\/pyjson5\/src\/json5\/lib.py","language":"python","identifier":"load","parameters":"(fp, encoding=None, cls=None, object_hook=None, parse_float=None,\n parse_int=None, parse_constant=None, object_pairs_hook=None)","argument_list":"","return_statement":"return loads(s, encoding=encoding, cls=cls, object_hook=object_hook,\n parse_float=parse_float, parse_int=parse_int,\n parse_constant=parse_constant,\n object_pairs_hook=object_pairs_hook)","docstring":"Deserialize ``fp`` (a ``.read()``-supporting file-like object\n containing a JSON document) to a Python object.","docstring_summary":"Deserialize ``fp`` (a ``.read()``-supporting file-like object\n containing a JSON document) to a Python object.","docstring_tokens":["Deserialize","fp","(","a",".","read","()","-","supporting","file","-","like","object","containing","a","JSON","document",")","to","a","Python","object","."],"function":"def load(fp, encoding=None, cls=None, object_hook=None, parse_float=None,\n parse_int=None, parse_constant=None, object_pairs_hook=None):\n \"\"\"Deserialize ``fp`` (a ``.read()``-supporting file-like object\n containing a JSON document) to a Python object.\"\"\"\n\n s = fp.read()\n return loads(s, encoding=encoding, cls=cls, object_hook=object_hook,\n parse_float=parse_float, parse_int=parse_int,\n parse_constant=parse_constant,\n object_pairs_hook=object_pairs_hook)","function_tokens":["def","load","(","fp",",","encoding","=","None",",","cls","=","None",",","object_hook","=","None",",","parse_float","=","None",",","parse_int","=","None",",","parse_constant","=","None",",","object_pairs_hook","=","None",")",":","s","=","fp",".","read","(",")","return","loads","(","s",",","encoding","=","encoding",",","cls","=","cls",",","object_hook","=","object_hook",",","parse_float","=","parse_float",",","parse_int","=","parse_int",",","parse_constant","=","parse_constant",",","object_pairs_hook","=","object_pairs_hook",")"],"url":"https:\/\/github.com\/ChromeDevTools\/devtools-frontend\/blob\/36834dd5de91aba0b15de21fc93958eee9e49108\/third_party\/pyjson5\/src\/json5\/lib.py#L27-L36"}
{"nwo":"ChromeDevTools\/devtools-frontend","sha":"36834dd5de91aba0b15de21fc93958eee9e49108","path":"third_party\/pyjson5\/src\/json5\/lib.py","language":"python","identifier":"loads","parameters":"(s, encoding=None, cls=None, object_hook=None, parse_float=None,\n parse_int=None, parse_constant=None, object_pairs_hook=None)","argument_list":"","return_statement":"return _walk_ast(ast, dictify, parse_float, parse_int, parse_constant)","docstring":"Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a\n JSON5 document) to a Python object.","docstring_summary":"Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a\n JSON5 document) to a Python object.","docstring_tokens":["Deserialize","s","(","a","str","or","unicode","instance","containing","a","JSON5","document",")","to","a","Python","object","."],"function":"def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None,\n parse_int=None, parse_constant=None, object_pairs_hook=None):\n \"\"\"Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a\n JSON5 document) to a Python object.\"\"\"\n\n assert cls is None, 'Custom decoders are not supported'\n\n if sys.version_info[0] < 3:\n decodable_type = type('')\n else:\n decodable_type = type(b'')\n if isinstance(s, decodable_type):\n encoding = encoding or 'utf-8'\n s = s.decode(encoding)\n\n if not s:\n raise ValueError('Empty strings are not legal JSON5')\n parser = Parser(s, '<string>')\n ast, err, newpos = parser.parse()\n if err:\n raise ValueError(err)\n\n def _fp_constant_parser(s):\n return float(s.replace('Infinity', 'inf').replace('NaN', 'nan'))\n\n if object_pairs_hook:\n dictify = object_pairs_hook\n elif object_hook:\n dictify = lambda pairs: object_hook(dict(pairs))\n else:\n dictify = dict\n\n parse_float = parse_float or float\n parse_int = parse_int or int\n parse_constant = parse_constant or _fp_constant_parser\n\n return _walk_ast(ast, dictify, parse_float, parse_int, parse_constant)","function_tokens":["def","loads","(","s",",","encoding","=","None",",","cls","=","None",",","object_hook","=","None",",","parse_float","=","None",",","parse_int","=","None",",","parse_constant","=","None",",","object_pairs_hook","=","None",")",":","assert","cls","is","None",",","'Custom decoders are not supported'","if","sys",".","version_info","[","0","]","<","3",":","decodable_type","=","type","(","''",")","else",":","decodable_type","=","type","(","b''",")","if","isinstance","(","s",",","decodable_type",")",":","encoding","=","encoding","or","'utf-8'","s","=","s",".","decode","(","encoding",")","if","not","s",":","raise","ValueError","(","'Empty strings are not legal JSON5'",")","parser","=","Parser","(","s",",","'<string>'",")","ast",",","err",",","newpos","=","parser",".","parse","(",")","if","err",":","raise","ValueError","(","err",")","def","_fp_constant_parser","(","s",")",":","return","float","(","s",".","replace","(","'Infinity'",",","'inf'",")",".","replace","(","'NaN'",",","'nan'",")",")","if","object_pairs_hook",":","dictify","=","object_pairs_hook","elif","object_hook",":","dictify","=","lambda","pairs",":","object_hook","(","dict","(","pairs",")",")","else",":","dictify","=","dict","parse_float","=","parse_float","or","float","parse_int","=","parse_int","or","int","parse_constant","=","parse_constant","or","_fp_constant_parser","return","_walk_ast","(","ast",",","dictify",",","parse_float",",","parse_int",",","parse_constant",")"],"url":"https:\/\/github.com\/ChromeDevTools\/devtools-frontend\/blob\/36834dd5de91aba0b15de21fc93958eee9e49108\/third_party\/pyjson5\/src\/json5\/lib.py#L39-L75"}
{"nwo":"ChromeDevTools\/devtools-frontend","sha":"36834dd5de91aba0b15de21fc93958eee9e49108","path":"third_party\/pyjson5\/src\/json5\/lib.py","language":"python","identifier":"dumps","parameters":"(obj, compact=False, as_json=False, **kwargs)","argument_list":"","return_statement":"","docstring":"Serialize ``obj`` to a JSON5-formatted ``str``.","docstring_summary":"Serialize ``obj`` to a JSON5-formatted ``str``.","docstring_tokens":["Serialize","obj","to","a","JSON5","-","formatted","str","."],"function":"def dumps(obj, compact=False, as_json=False, **kwargs):\n \"\"\"Serialize ``obj`` to a JSON5-formatted ``str``.\"\"\"\n\n if as_json or not compact:\n return json.dumps(obj, **kwargs)\n\n t = type(obj)\n if obj == True:\n return u'true'\n elif obj == False:\n return u'false'\n elif obj == None:\n return u'null'\n elif t == type('') or t == type(u''):\n single = \"'\" in obj\n double = '\"' in obj\n if single and double:\n return json.dumps(obj)\n elif single:\n return '\"' + obj + '\"'\n else:\n return \"'\" + obj + \"'\"\n elif t is float or t is int:\n return str(obj)\n elif t is dict:\n return u'{' + u','.join([\n _dumpkey(k) + u':' + dumps(v) for k, v in obj.items()\n ]) + '}'\n elif t is list:\n return u'[' + ','.join([dumps(el) for el in obj]) + u']'\n else: # pragma: no cover\n return u''","function_tokens":["def","dumps","(","obj",",","compact","=","False",",","as_json","=","False",",","*","*","kwargs",")",":","if","as_json","or","not","compact",":","return","json",".","dumps","(","obj",",","*","*","kwargs",")","t","=","type","(","obj",")","if","obj","==","True",":","return","u'true'","elif","obj","==","False",":","return","u'false'","elif","obj","==","None",":","return","u'null'","elif","t","==","type","(","''",")","or","t","==","type","(","u''",")",":","single","=","\"'\"","in","obj","double","=","'\"'","in","obj","if","single","and","double",":","return","json",".","dumps","(","obj",")","elif","single",":","return","'\"'","+","obj","+","'\"'","else",":","return","\"'\"","+","obj","+","\"'\"","elif","t","is","float","or","t","is","int",":","return","str","(","obj",")","elif","t","is","dict",":","return","u'{'","+","u','",".","join","(","[","_dumpkey","(","k",")","+","u':'","+","dumps","(","v",")","for","k",",","v","in","obj",".","items","(",")","]",")","+","'}'","elif","t","is","list",":","return","u'['","+","','",".","join","(","[","dumps","(","el",")","for","el","in","obj","]",")","+","u']'","else",":","# pragma: no cover","return","u''"],"url":"https:\/\/github.com\/ChromeDevTools\/devtools-frontend\/blob\/36834dd5de91aba0b15de21fc93958eee9e49108\/third_party\/pyjson5\/src\/json5\/lib.py#L120-L151"}
{"nwo":"ChromeDevTools\/devtools-frontend","sha":"36834dd5de91aba0b15de21fc93958eee9e49108","path":"third_party\/pyjson5\/src\/json5\/lib.py","language":"python","identifier":"dump","parameters":"(obj, fp, **kwargs)","argument_list":"","return_statement":"","docstring":"Serialize ``obj`` to a JSON5-formatted stream to ``fp`` (a ``.write()``-\n supporting file-like object).","docstring_summary":"Serialize ``obj`` to a JSON5-formatted stream to ``fp`` (a ``.write()``-\n supporting file-like object).","docstring_tokens":["Serialize","obj","to","a","JSON5","-","formatted","stream","to","fp","(","a",".","write","()","-","supporting","file","-","like","object",")","."],"function":"def dump(obj, fp, **kwargs):\n \"\"\"Serialize ``obj`` to a JSON5-formatted stream to ``fp`` (a ``.write()``-\n supporting file-like object).\"\"\"\n\n s = dumps(obj, **kwargs)\n fp.write(str(s))","function_tokens":["def","dump","(","obj",",","fp",",","*","*","kwargs",")",":","s","=","dumps","(","obj",",","*","*","kwargs",")","fp",".","write","(","str","(","s",")",")"],"url":"https:\/\/github.com\/ChromeDevTools\/devtools-frontend\/blob\/36834dd5de91aba0b15de21fc93958eee9e49108\/third_party\/pyjson5\/src\/json5\/lib.py#L154-L159"}