Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
copy2_fixed | (src, dest) | Wrap shutil.copy2() but map errors copying socket files to
SpecialFileError as expected.
See also https://bugs.python.org/issue37700.
| Wrap shutil.copy2() but map errors copying socket files to
SpecialFileError as expected. | def copy2_fixed(src, dest):
# type: (str, str) -> None
"""Wrap shutil.copy2() but map errors copying socket files to
SpecialFileError as expected.
See also https://bugs.python.org/issue37700.
"""
try:
shutil.copy2(src, dest)
except (OSError, IOError):
for f in [src, dest]:
... | [
"def",
"copy2_fixed",
"(",
"src",
",",
"dest",
")",
":",
"# type: (str, str) -> None",
"try",
":",
"shutil",
".",
"copy2",
"(",
"src",
",",
"dest",
")",
"except",
"(",
"OSError",
",",
"IOError",
")",
":",
"for",
"f",
"in",
"[",
"src",
",",
"dest",
"]... | [
58,
0
] | [
80,
13
] | python | en | ['en', 'en', 'en'] | True |
adjacent_tmp_file | (path, **kwargs) | Return a file-like object pointing to a tmp file next to path.
The file is created securely and is ensured to be written to disk
after the context reaches its end.
kwargs will be passed to tempfile.NamedTemporaryFile to control
the way the temporary file will be opened.
| Return a file-like object pointing to a tmp file next to path. | def adjacent_tmp_file(path, **kwargs):
# type: (str, **Any) -> Iterator[NamedTemporaryFileResult]
"""Return a file-like object pointing to a tmp file next to path.
The file is created securely and is ensured to be written to disk
after the context reaches its end.
kwargs will be passed to tempfile... | [
"def",
"adjacent_tmp_file",
"(",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (str, **Any) -> Iterator[NamedTemporaryFileResult]",
"with",
"NamedTemporaryFile",
"(",
"delete",
"=",
"False",
",",
"dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
... | [
89,
0
] | [
111,
42
] | python | en | ['en', 'en', 'en'] | True |
test_writable_dir | (path) | Check if a directory is writable.
Uses os.access() on POSIX, tries creating files on Windows.
| Check if a directory is writable. | def test_writable_dir(path):
# type: (str) -> bool
"""Check if a directory is writable.
Uses os.access() on POSIX, tries creating files on Windows.
"""
# If the directory doesn't exist, find the closest parent that does.
while not os.path.isdir(path):
parent = os.path.dirname(path)
... | [
"def",
"test_writable_dir",
"(",
"path",
")",
":",
"# type: (str) -> bool",
"# If the directory doesn't exist, find the closest parent that does.",
"while",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"parent",
"=",
"os",
".",
"path",
".",
"dirnam... | [
132,
0
] | [
148,
39
] | python | en | ['en', 'en', 'en'] | True |
find_files | (path, pattern) | Returns a list of absolute paths of files beneath path, recursively,
with filenames which match the UNIX-style shell glob pattern. | Returns a list of absolute paths of files beneath path, recursively,
with filenames which match the UNIX-style shell glob pattern. | def find_files(path, pattern):
# type: (str, str) -> List[str]
"""Returns a list of absolute paths of files beneath path, recursively,
with filenames which match the UNIX-style shell glob pattern."""
result = [] # type: List[str]
for root, _, files in os.walk(path):
matches = fnmatch.filter... | [
"def",
"find_files",
"(",
"path",
",",
"pattern",
")",
":",
"# type: (str, str) -> List[str]",
"result",
"=",
"[",
"]",
"# type: List[str]",
"for",
"root",
",",
"_",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"matches",
"=",
"fnmatch",
... | [
187,
0
] | [
195,
17
] | python | en | ['en', 'en', 'en'] | True |
install | (cls) |
Class decorator for installation on sys.meta_path.
Adds the backport DistributionFinder to sys.meta_path and
attempts to disable the finder functionality of the stdlib
DistributionFinder.
|
Class decorator for installation on sys.meta_path. | def install(cls):
"""
Class decorator for installation on sys.meta_path.
Adds the backport DistributionFinder to sys.meta_path and
attempts to disable the finder functionality of the stdlib
DistributionFinder.
"""
sys.meta_path.append(cls())
disable_stdlib_finder()
return cls | [
"def",
"install",
"(",
"cls",
")",
":",
"sys",
".",
"meta_path",
".",
"append",
"(",
"cls",
"(",
")",
")",
"disable_stdlib_finder",
"(",
")",
"return",
"cls"
] | [
58,
0
] | [
68,
14
] | python | en | ['en', 'error', 'th'] | False |
disable_stdlib_finder | () |
Give the backport primacy for discovering path-based distributions
by monkey-patching the stdlib O_O.
See #91 for more background for rationale on this sketchy
behavior.
|
Give the backport primacy for discovering path-based distributions
by monkey-patching the stdlib O_O. | def disable_stdlib_finder():
"""
Give the backport primacy for discovering path-based distributions
by monkey-patching the stdlib O_O.
See #91 for more background for rationale on this sketchy
behavior.
"""
def matches(finder):
return (
getattr(finder, '__module__', None... | [
"def",
"disable_stdlib_finder",
"(",
")",
":",
"def",
"matches",
"(",
"finder",
")",
":",
"return",
"(",
"getattr",
"(",
"finder",
",",
"'__module__'",
",",
"None",
")",
"==",
"'_frozen_importlib_external'",
"and",
"hasattr",
"(",
"finder",
",",
"'find_distrib... | [
71,
0
] | [
85,
37
] | python | en | ['en', 'error', 'th'] | False |
unique_everseen | (iterable) | List unique elements, preserving order. Remember all elements ever seen. | List unique elements, preserving order. Remember all elements ever seen. | def unique_everseen(iterable): # pragma: nocover
"List unique elements, preserving order. Remember all elements ever seen."
seen = set()
seen_add = seen.add
for element in filterfalse(seen.__contains__, iterable):
seen_add(element)
yield element | [
"def",
"unique_everseen",
"(",
"iterable",
")",
":",
"# pragma: nocover",
"seen",
"=",
"set",
"(",
")",
"seen_add",
"=",
"seen",
".",
"add",
"for",
"element",
"in",
"filterfalse",
"(",
"seen",
".",
"__contains__",
",",
"iterable",
")",
":",
"seen_add",
"("... | [
140,
0
] | [
147,
21
] | python | ca | ['ca', 'ca', 'en'] | True |
LidarrHookTests.test_lidarr_test | (self) |
Tests if lidarr test payload is handled correctly
|
Tests if lidarr test payload is handled correctly
| def test_lidarr_test(self) -> None:
"""
Tests if lidarr test payload is handled correctly
"""
expected_topic = "Lidarr - Test"
expected_message = "Lidarr webhook has been successfully configured."
self.check_webhook("lidarr_test", expected_topic, expected_message) | [
"def",
"test_lidarr_test",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Lidarr - Test\"",
"expected_message",
"=",
"\"Lidarr webhook has been successfully configured.\"",
"self",
".",
"check_webhook",
"(",
"\"lidarr_test\"",
",",
"expected_topic",
",",
"... | [
8,
4
] | [
14,
75
] | python | en | ['en', 'error', 'th'] | False |
LidarrHookTests.test_lidarr_tracks_renamed | (self) |
Tests if lidarr tracks renamed payload is handled correctly
|
Tests if lidarr tracks renamed payload is handled correctly
| def test_lidarr_tracks_renamed(self) -> None:
"""
Tests if lidarr tracks renamed payload is handled correctly
"""
expected_topic = "Little Mix"
expected_message = "The artist Little Mix has had its tracks renamed."
self.check_webhook("lidarr_tracks_renamed", expected_topi... | [
"def",
"test_lidarr_tracks_renamed",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Little Mix\"",
"expected_message",
"=",
"\"The artist Little Mix has had its tracks renamed.\"",
"self",
".",
"check_webhook",
"(",
"\"lidarr_tracks_renamed\"",
",",
"expected_... | [
16,
4
] | [
22,
85
] | python | en | ['en', 'error', 'th'] | False |
LidarrHookTests.test_lidarr_tracks_retagged | (self) |
Tests if lidarr tracks retagged payload is handled correctly
|
Tests if lidarr tracks retagged payload is handled correctly
| def test_lidarr_tracks_retagged(self) -> None:
"""
Tests if lidarr tracks retagged payload is handled correctly
"""
expected_topic = "Little Mix"
expected_message = "The artist Little Mix has had its tracks retagged."
self.check_webhook("lidarr_tracks_retagged", expected_... | [
"def",
"test_lidarr_tracks_retagged",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Little Mix\"",
"expected_message",
"=",
"\"The artist Little Mix has had its tracks retagged.\"",
"self",
".",
"check_webhook",
"(",
"\"lidarr_tracks_retagged\"",
",",
"expect... | [
24,
4
] | [
30,
86
] | python | en | ['en', 'error', 'th'] | False |
LidarrHookTests.test_lidarr_tracks_imported | (self) |
Tests if lidarr tracks imported payload is handled correctly
|
Tests if lidarr tracks imported payload is handled correctly
| def test_lidarr_tracks_imported(self) -> None:
"""
Tests if lidarr tracks imported payload is handled correctly
"""
expected_topic = "UB40"
expected_message = """
The following tracks by UB40 have been imported:
* Cherry Oh Baby
* Keep On Moving
* Please Don't Make Me Cry
* Sweet... | [
"def",
"test_lidarr_tracks_imported",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"UB40\"",
"expected_message",
"=",
"\"\"\"\nThe following tracks by UB40 have been imported:\n* Cherry Oh Baby\n* Keep On Moving\n* Please Don't Make Me Cry\n* Sweet Sensation\n* Johnny Too ... | [
32,
4
] | [
50,
86
] | python | en | ['en', 'error', 'th'] | False |
LidarrHookTests.test_lidarr_tracks_imported_upgrade | (self) |
Tests if lidarr tracks imported upgrade payload is handled correctly
|
Tests if lidarr tracks imported upgrade payload is handled correctly
| def test_lidarr_tracks_imported_upgrade(self) -> None:
"""
Tests if lidarr tracks imported upgrade payload is handled correctly
"""
expected_topic = "Little Mix"
expected_message = """
The following tracks by Little Mix have been imported due to upgrade:
* The National Manthem
* ... | [
"def",
"test_lidarr_tracks_imported_upgrade",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Little Mix\"",
"expected_message",
"=",
"\"\"\"\nThe following tracks by Little Mix have been imported due to upgrade:\n* The National Manthem\n* Woman Like Me\n* Think About Us\n* ... | [
52,
4
] | [
78,
94
] | python | en | ['en', 'error', 'th'] | False |
LidarrHookTests.test_lidarr_album_grabbed | (self) |
Tests if lidarr album grabbed payload is handled correctly
|
Tests if lidarr album grabbed payload is handled correctly
| def test_lidarr_album_grabbed(self) -> None:
"""
Tests if lidarr album grabbed payload is handled correctly
"""
expected_topic = "UB40"
expected_message = "The album Labour of Love by UB40 has been grabbed."
self.check_webhook("lidarr_album_grabbed", expected_topic, expec... | [
"def",
"test_lidarr_album_grabbed",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"UB40\"",
"expected_message",
"=",
"\"The album Labour of Love by UB40 has been grabbed.\"",
"self",
".",
"check_webhook",
"(",
"\"lidarr_album_grabbed\"",
",",
"expected_topic",... | [
80,
4
] | [
86,
84
] | python | en | ['en', 'error', 'th'] | False |
LidarrHookTests.test_lidarr_tracks_imported_over_limit | (self) |
Tests if lidarr tracks imported over limit payload is handled correctly
|
Tests if lidarr tracks imported over limit payload is handled correctly
| def test_lidarr_tracks_imported_over_limit(self) -> None:
"""
Tests if lidarr tracks imported over limit payload is handled correctly
"""
expected_topic = "Michael Jackson"
expected_message = """
The following tracks by Michael Jackson have been imported:
* Scream
* Billie Jean
*... | [
"def",
"test_lidarr_tracks_imported_over_limit",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Michael Jackson\"",
"expected_message",
"=",
"\"\"\"\nThe following tracks by Michael Jackson have been imported:\n* Scream\n* Billie Jean\n* The Way You Make Me Feel\n* They Don... | [
88,
4
] | [
117,
97
] | python | en | ['en', 'error', 'th'] | False |
LidarrHookTests.test_lidarr_tracks_imported_upgrade_over_limit | (self) |
Tests if lidarr tracks imported upgrade over limit payload is handled correctly
|
Tests if lidarr tracks imported upgrade over limit payload is handled correctly
| def test_lidarr_tracks_imported_upgrade_over_limit(self) -> None:
"""
Tests if lidarr tracks imported upgrade over limit payload is handled correctly
"""
expected_topic = "Michael Jackson"
expected_message = """
The following tracks by Michael Jackson have been imported due to up... | [
"def",
"test_lidarr_tracks_imported_upgrade_over_limit",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Michael Jackson\"",
"expected_message",
"=",
"\"\"\"\nThe following tracks by Michael Jackson have been imported due to upgrade:\n* Scream\n* Billie Jean\n* The Way You M... | [
119,
4
] | [
150,
9
] | python | en | ['en', 'error', 'th'] | False |
UptimeRobotHookTests.test_uptimerobot_monitor_down | (self) |
Tests if uptimerobot monitor down is handled correctly
|
Tests if uptimerobot monitor down is handled correctly
| def test_uptimerobot_monitor_down(self) -> None:
"""
Tests if uptimerobot monitor down is handled correctly
"""
expected_topic = "Web Server"
expected_message = "Web Server (server1.example.com) is DOWN (Host Is Unreachable)."
self.check_webhook("uptimerobot_monitor_down"... | [
"def",
"test_uptimerobot_monitor_down",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Web Server\"",
"expected_message",
"=",
"\"Web Server (server1.example.com) is DOWN (Host Is Unreachable).\"",
"self",
".",
"check_webhook",
"(",
"\"uptimerobot_monitor_down\"",... | [
11,
4
] | [
17,
88
] | python | en | ['en', 'error', 'th'] | False |
UptimeRobotHookTests.test_uptimerobot_monitor_up | (self) |
Tests if uptimerobot monitor up is handled correctly
|
Tests if uptimerobot monitor up is handled correctly
| def test_uptimerobot_monitor_up(self) -> None:
"""
Tests if uptimerobot monitor up is handled correctly
"""
expected_topic = "Mail Server"
expected_message = """
Mail Server (server2.example.com) is back UP (Host Is Reachable).
It was down for 44 minutes and 37 seconds.
""".strip... | [
"def",
"test_uptimerobot_monitor_up",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Mail Server\"",
"expected_message",
"=",
"\"\"\"\nMail Server (server2.example.com) is back UP (Host Is Reachable).\nIt was down for 44 minutes and 37 seconds.\n\"\"\"",
".",
"strip",
... | [
19,
4
] | [
28,
86
] | python | en | ['en', 'error', 'th'] | False |
UptimeRobotHookTests.test_uptimerobot_invalid_payload_with_missing_data | (self) |
Tests if invalid uptime robot payloads are handled correctly
|
Tests if invalid uptime robot payloads are handled correctly
| def test_uptimerobot_invalid_payload_with_missing_data(self) -> None:
"""
Tests if invalid uptime robot payloads are handled correctly
"""
self.url = self.build_webhook_url()
payload = self.get_body("uptimerobot_invalid_payload_with_missing_data")
result = self.client_pos... | [
"def",
"test_uptimerobot_invalid_payload_with_missing_data",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"url",
"=",
"self",
".",
"build_webhook_url",
"(",
")",
"payload",
"=",
"self",
".",
"get_body",
"(",
"\"uptimerobot_invalid_payload_with_missing_data\"",
")... | [
30,
4
] | [
46,
64
] | python | en | ['en', 'error', 'th'] | False |
get_topological_weights | (graph, expected_node_count) | Assign weights to each node based on how "deep" they are.
This implementation may change at any point in the future without prior
notice.
We take the length for the longest path to any node from root, ignoring any
paths that contain a single node twice (i.e. cycles). This is done through
a depth-f... | Assign weights to each node based on how "deep" they are. | def get_topological_weights(graph, expected_node_count):
# type: (Graph, int) -> Dict[Optional[str], int]
"""Assign weights to each node based on how "deep" they are.
This implementation may change at any point in the future without prior
notice.
We take the length for the longest path to any node... | [
"def",
"get_topological_weights",
"(",
"graph",
",",
"expected_node_count",
")",
":",
"# type: (Graph, int) -> Dict[Optional[str], int]",
"path",
"=",
"set",
"(",
")",
"# type: Set[Optional[str]]",
"weights",
"=",
"{",
"}",
"# type: Dict[Optional[str], int]",
"def",
"visit"... | [
237,
0
] | [
280,
18
] | python | en | ['en', 'en', 'en'] | True |
_req_set_item_sorter | (
item, # type: Tuple[str, InstallRequirement]
weights, # type: Dict[Optional[str], int]
) | Key function used to sort install requirements for installation.
Based on the "weight" mapping calculated in ``get_installation_order()``.
The canonical package name is returned as the second member as a tie-
breaker to ensure the result is predictable, which is useful in tests.
| Key function used to sort install requirements for installation. | def _req_set_item_sorter(
item, # type: Tuple[str, InstallRequirement]
weights, # type: Dict[Optional[str], int]
):
# type: (...) -> Tuple[int, str]
"""Key function used to sort install requirements for installation.
Based on the "weight" mapping calculated in ``get_installation_order()``.
... | [
"def",
"_req_set_item_sorter",
"(",
"item",
",",
"# type: Tuple[str, InstallRequirement]",
"weights",
",",
"# type: Dict[Optional[str], int]",
")",
":",
"# type: (...) -> Tuple[int, str]",
"name",
"=",
"canonicalize_name",
"(",
"item",
"[",
"0",
"]",
")",
"return",
"weigh... | [
283,
0
] | [
295,
30
] | python | en | ['en', 'en', 'en'] | True |
Resolver.get_installation_order | (self, req_set) | Get order for installation of requirements in RequirementSet.
The returned list contains a requirement before another that depends on
it. This helps ensure that the environment is kept consistent as they
get installed one-by-one.
The current implementation creates a topological orderin... | Get order for installation of requirements in RequirementSet. | def get_installation_order(self, req_set):
# type: (RequirementSet) -> List[InstallRequirement]
"""Get order for installation of requirements in RequirementSet.
The returned list contains a requirement before another that depends on
it. This helps ensure that the environment is kept con... | [
"def",
"get_installation_order",
"(",
"self",
",",
"req_set",
")",
":",
"# type: (RequirementSet) -> List[InstallRequirement]",
"assert",
"self",
".",
"_result",
"is",
"not",
"None",
",",
"\"must call resolve() first\"",
"graph",
"=",
"self",
".",
"_result",
".",
"gra... | [
208,
4
] | [
234,
49
] | python | en | ['en', 'en', 'en'] | True |
F10Entity.ContainmentTree | (self) |
Adding Fan and PowerSupply to Scalable CompTree
:return: JSON
|
Adding Fan and PowerSupply to Scalable CompTree
:return: JSON
| def ContainmentTree(self):
"""
Adding Fan and PowerSupply to Scalable CompTree
:return: JSON
"""
device_json = self.get_json_device()
ctree = self._build_ctree(self.protofactory.ctree, device_json)
mf10model = self.entityjson.get('System',[None])[0].get('Mo... | [
"def",
"ContainmentTree",
"(",
"self",
")",
":",
"device_json",
"=",
"self",
".",
"get_json_device",
"(",
")",
"ctree",
"=",
"self",
".",
"_build_ctree",
"(",
"self",
".",
"protofactory",
".",
"ctree",
",",
"device_json",
")",
"mf10model",
"=",
"self",
"."... | [
825,
4
] | [
841,
20
] | python | en | ['en', 'ja', 'th'] | False |
generate_subthresholds | (min_value, max_value, num_thresholds) |
Generate a series of ``num_thresholds`` logarithmically spaced values
in the range (min_value, max_value) (both exclusive).
|
Generate a series of ``num_thresholds`` logarithmically spaced values
in the range (min_value, max_value) (both exclusive).
| def generate_subthresholds(min_value, max_value, num_thresholds):
"""
Generate a series of ``num_thresholds`` logarithmically spaced values
in the range (min_value, max_value) (both exclusive).
"""
# First, we calculate a logarithmically spaced sequence between exp(0.0)
# and (max - min + 1). Th... | [
"def",
"generate_subthresholds",
"(",
"min_value",
",",
"max_value",
",",
"num_thresholds",
")",
":",
"# First, we calculate a logarithmically spaced sequence between exp(0.0)",
"# and (max - min + 1). That is, the total range is between 1 and one",
"# greater than the difference between max... | [
10,
0
] | [
28,
22
] | python | en | ['en', 'error', 'th'] | False |
get_error_radius | (wcs, x_value, x_error, y_value, y_error) |
Estimate an absolute angular error on the position (x_value, y_value)
with the given errors.
This is a pessimistic estimate, because we take sum of the error
along the X and Y axes. Better might be to project them both back on
to the major/minor axes of the elliptical fit, but this should do for
... |
Estimate an absolute angular error on the position (x_value, y_value)
with the given errors. | def get_error_radius(wcs, x_value, x_error, y_value, y_error):
"""
Estimate an absolute angular error on the position (x_value, y_value)
with the given errors.
This is a pessimistic estimate, because we take sum of the error
along the X and Y axes. Better might be to project them both back on
t... | [
"def",
"get_error_radius",
"(",
"wcs",
",",
"x_value",
",",
"x_error",
",",
"y_value",
",",
"y_error",
")",
":",
"error_radius",
"=",
"0",
"try",
":",
"centre_ra",
",",
"centre_dec",
"=",
"wcs",
".",
"p2s",
"(",
"[",
"x_value",
",",
"y_value",
"]",
")"... | [
31,
0
] | [
62,
23
] | python | en | ['en', 'error', 'th'] | False |
circular_mask | (xdim, ydim, radius) |
Returns a numpy array of shape (xdim, ydim). All points with radius of
the centre are set to 0; outside that region, they are set to 1.
|
Returns a numpy array of shape (xdim, ydim). All points with radius of
the centre are set to 0; outside that region, they are set to 1.
| def circular_mask(xdim, ydim, radius):
"""
Returns a numpy array of shape (xdim, ydim). All points with radius of
the centre are set to 0; outside that region, they are set to 1.
"""
centre_x, centre_y = (xdim-1)/2.0, (ydim-1)/2.0
x, y = numpy.ogrid[-centre_x:xdim-centre_x, -centre_y:ydim-centre... | [
"def",
"circular_mask",
"(",
"xdim",
",",
"ydim",
",",
"radius",
")",
":",
"centre_x",
",",
"centre_y",
"=",
"(",
"xdim",
"-",
"1",
")",
"/",
"2.0",
",",
"(",
"ydim",
"-",
"1",
")",
"/",
"2.0",
"x",
",",
"y",
"=",
"numpy",
".",
"ogrid",
"[",
... | [
65,
0
] | [
72,
37
] | python | en | ['en', 'error', 'th'] | False |
generate_result_maps | (data, sourcelist) | Return a source and residual image
Given a data array (image) and list of sources, return two images, one
showing the sources themselves and the other the residual after the
sources have been removed from the input data.
| Return a source and residual image | def generate_result_maps(data, sourcelist):
"""Return a source and residual image
Given a data array (image) and list of sources, return two images, one
showing the sources themselves and the other the residual after the
sources have been removed from the input data.
"""
residual_map = numpy.ar... | [
"def",
"generate_result_maps",
"(",
"data",
",",
"sourcelist",
")",
":",
"residual_map",
"=",
"numpy",
".",
"array",
"(",
"data",
")",
"# array constructor copies by default",
"gaussian_map",
"=",
"numpy",
".",
"zeros",
"(",
"residual_map",
".",
"shape",
")",
"f... | [
75,
0
] | [
109,
37
] | python | en | ['en', 'en', 'en'] | True |
calculate_correlation_lengths | (semimajor, semiminor) | Calculate the Condon correlation length
In order to derive the error bars from Gauss fitting from the
Condon (1997, PASP 109, 116C) formulae, one needs the so called
correlation length. The Condon formulae assumes a circular area
with diameter theta_N (in pixels) for the correlation. This was
later... | Calculate the Condon correlation length | def calculate_correlation_lengths(semimajor, semiminor):
"""Calculate the Condon correlation length
In order to derive the error bars from Gauss fitting from the
Condon (1997, PASP 109, 116C) formulae, one needs the so called
correlation length. The Condon formulae assumes a circular area
with diam... | [
"def",
"calculate_correlation_lengths",
"(",
"semimajor",
",",
"semiminor",
")",
":",
"return",
"(",
"2.0",
"*",
"semimajor",
",",
"2.0",
"*",
"semiminor",
")"
] | [
112,
0
] | [
131,
45
] | python | en | ['en', 'gl', 'en'] | True |
calculate_beamsize | (semimajor, semiminor) | Calculate the beamsize based on the semi major and minor axes | Calculate the beamsize based on the semi major and minor axes | def calculate_beamsize(semimajor, semiminor):
"""Calculate the beamsize based on the semi major and minor axes"""
return numpy.pi * semimajor * semiminor | [
"def",
"calculate_beamsize",
"(",
"semimajor",
",",
"semiminor",
")",
":",
"return",
"numpy",
".",
"pi",
"*",
"semimajor",
"*",
"semiminor"
] | [
134,
0
] | [
137,
43
] | python | en | ['en', 'en', 'en'] | True |
fudge_max_pix | (semimajor, semiminor, theta) | Estimate peak flux correction at pixel of maximum flux
Previously, we adopted Rengelink's correction for the
underestimate of the peak of the Gaussian by the maximum pixel
method: fudge_max_pix = 1.06. See the WENSS paper
(1997A&AS..124..259R) or his thesis. (The peak of the Gaussian
is, of course... | Estimate peak flux correction at pixel of maximum flux | def fudge_max_pix(semimajor, semiminor, theta):
"""Estimate peak flux correction at pixel of maximum flux
Previously, we adopted Rengelink's correction for the
underestimate of the peak of the Gaussian by the maximum pixel
method: fudge_max_pix = 1.06. See the WENSS paper
(1997A&AS..124..259R) or h... | [
"def",
"fudge_max_pix",
"(",
"semimajor",
",",
"semiminor",
",",
"theta",
")",
":",
"# scipy.integrate.dblquad: Computes a double integral",
"# from the scipy docs:",
"# Return the double (definite) integral of f1(y,x) from x=a..b",
"# and y=f2(x)..f3(x).",
"log20",
"=",
"numpy",... | [
140,
0
] | [
174,
21
] | python | en | ['en', 'la', 'en'] | True |
maximum_pixel_method_variance | (semimajor, semiminor, theta) | Estimate variance for peak flux at pixel position of maximum
When we use the maximum pixel method, with a correction
fudge_max_pix, there should be no bias, unless the peaks of the
Gaussians are not randomly distributed, but relatively close to
the centres of the pixels due to selection effects from de... | Estimate variance for peak flux at pixel position of maximum | def maximum_pixel_method_variance(semimajor, semiminor, theta):
"""Estimate variance for peak flux at pixel position of maximum
When we use the maximum pixel method, with a correction
fudge_max_pix, there should be no bias, unless the peaks of the
Gaussians are not randomly distributed, but relatively ... | [
"def",
"maximum_pixel_method_variance",
"(",
"semimajor",
",",
"semiminor",
",",
"theta",
")",
":",
"# scipy.integrate.dblquad: Computes a double integral",
"# from the scipy docs:",
"# Return the double (definite) integral of f1(y,x) from x=a..b",
"# and y=f2(x)..f3(x).",
"log20",
... | [
177,
0
] | [
213,
19
] | python | en | ['en', 'la', 'en'] | True |
flatten | (nested_list) | Flatten a nested list
Nested lists are made in the deblending algorithm. They're
awful. This is a piece of code I grabbed from
http://www.daniweb.com/code/snippet216879.html.
The output from this method is a generator, so make sure to turn
it into a list, like this::
flattened = list(flat... | Flatten a nested list | def flatten(nested_list):
"""Flatten a nested list
Nested lists are made in the deblending algorithm. They're
awful. This is a piece of code I grabbed from
http://www.daniweb.com/code/snippet216879.html.
The output from this method is a generator, so make sure to turn
it into a list, like this... | [
"def",
"flatten",
"(",
"nested_list",
")",
":",
"for",
"elem",
"in",
"nested_list",
":",
"if",
"isinstance",
"(",
"elem",
",",
"(",
"tuple",
",",
"list",
",",
"numpy",
".",
"ndarray",
")",
")",
":",
"for",
"i",
"in",
"flatten",
"(",
"elem",
")",
":... | [
216,
0
] | [
233,
22
] | python | da | ['da', 'lb', 'pt'] | False |
Worker.url | (self) | Return URL. | Return URL. | def url(self) -> str:
"""Return URL."""
return self._url | [
"def",
"url",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_url"
] | [
78,
4
] | [
80,
24
] | python | en | ['en', 'cy', 'en'] | False |
Worker.executionContext | (self) | Return ExecutionContext. | Return ExecutionContext. | async def executionContext(self) -> ExecutionContext:
"""Return ExecutionContext."""
return await self._executionContextPromise | [
"async",
"def",
"executionContext",
"(",
"self",
")",
"->",
"ExecutionContext",
":",
"return",
"await",
"self",
".",
"_executionContextPromise"
] | [
82,
4
] | [
84,
50
] | python | en | ['en', 'pt', 'en'] | False |
Worker.evaluate | (self, pageFunction: str, *args: Any) | Evaluate ``pageFunction`` with ``args``.
Shortcut for ``(await worker.executionContext).evaluate(pageFunction, *args)``.
| Evaluate ``pageFunction`` with ``args``. | async def evaluate(self, pageFunction: str, *args: Any) -> Any:
"""Evaluate ``pageFunction`` with ``args``.
Shortcut for ``(await worker.executionContext).evaluate(pageFunction, *args)``.
""" # noqa: E501
return await (await self._executionContextPromise).evaluate(
pageFunc... | [
"async",
"def",
"evaluate",
"(",
"self",
",",
"pageFunction",
":",
"str",
",",
"*",
"args",
":",
"Any",
")",
"->",
"Any",
":",
"# noqa: E501",
"return",
"await",
"(",
"await",
"self",
".",
"_executionContextPromise",
")",
".",
"evaluate",
"(",
"pageFunctio... | [
86,
4
] | [
92,
32
] | python | en | ['en', 'en', 'en'] | True |
Worker.evaluateHandle | (self, pageFunction: str, *args: Any) | Evaluate ``pageFunction`` with ``args`` and return :class:`~pyppeteer.execution_context.JSHandle`.
Shortcut for ``(await worker.executionContext).evaluateHandle(pageFunction, *args)``.
| Evaluate ``pageFunction`` with ``args`` and return :class:`~pyppeteer.execution_context.JSHandle`. | async def evaluateHandle(self, pageFunction: str, *args: Any) -> JSHandle:
"""Evaluate ``pageFunction`` with ``args`` and return :class:`~pyppeteer.execution_context.JSHandle`.
Shortcut for ``(await worker.executionContext).evaluateHandle(pageFunction, *args)``.
""" # noqa: E501
return... | [
"async",
"def",
"evaluateHandle",
"(",
"self",
",",
"pageFunction",
":",
"str",
",",
"*",
"args",
":",
"Any",
")",
"->",
"JSHandle",
":",
"# noqa: E501",
"return",
"await",
"(",
"await",
"self",
".",
"_executionContextPromise",
")",
".",
"evaluateHandle",
"(... | [
94,
4
] | [
100,
32
] | python | en | ['en', 'en', 'en'] | True |
_add_doc | (func, doc) | Add documentation to a function. | Add documentation to a function. | def _add_doc(func, doc):
"""Add documentation to a function."""
func.__doc__ = doc | [
"def",
"_add_doc",
"(",
"func",
",",
"doc",
")",
":",
"func",
".",
"__doc__",
"=",
"doc"
] | [
74,
0
] | [
76,
22
] | python | en | ['en', 'en', 'en'] | True |
_import_module | (name) | Import module, returning the module after the last dot. | Import module, returning the module after the last dot. | def _import_module(name):
"""Import module, returning the module after the last dot."""
__import__(name)
return sys.modules[name] | [
"def",
"_import_module",
"(",
"name",
")",
":",
"__import__",
"(",
"name",
")",
"return",
"sys",
".",
"modules",
"[",
"name",
"]"
] | [
79,
0
] | [
82,
28
] | python | en | ['en', 'en', 'en'] | True |
add_move | (move) | Add an item to six.moves. | Add an item to six.moves. | def add_move(move):
"""Add an item to six.moves."""
setattr(_MovedItems, move.name, move) | [
"def",
"add_move",
"(",
"move",
")",
":",
"setattr",
"(",
"_MovedItems",
",",
"move",
".",
"name",
",",
"move",
")"
] | [
515,
0
] | [
517,
41
] | python | en | ['en', 'en', 'en'] | True |
remove_move | (name) | Remove item from six.moves. | Remove item from six.moves. | def remove_move(name):
"""Remove item from six.moves."""
try:
delattr(_MovedItems, name)
except AttributeError:
try:
del moves.__dict__[name]
except KeyError:
raise AttributeError("no such move, %r" % (name,)) | [
"def",
"remove_move",
"(",
"name",
")",
":",
"try",
":",
"delattr",
"(",
"_MovedItems",
",",
"name",
")",
"except",
"AttributeError",
":",
"try",
":",
"del",
"moves",
".",
"__dict__",
"[",
"name",
"]",
"except",
"KeyError",
":",
"raise",
"AttributeError",
... | [
520,
0
] | [
528,
62
] | python | en | ['en', 'en', 'en'] | True |
with_metaclass | (meta, *bases) | Create a base class with a metaclass. | Create a base class with a metaclass. | def with_metaclass(meta, *bases):
"""Create a base class with a metaclass."""
# This requires a bit of explanation: the basic idea is to make a dummy
# metaclass for one level of class instantiation that replaces itself with
# the actual metaclass.
class metaclass(type):
def __new__(cls, nam... | [
"def",
"with_metaclass",
"(",
"meta",
",",
"*",
"bases",
")",
":",
"# This requires a bit of explanation: the basic idea is to make a dummy",
"# metaclass for one level of class instantiation that replaces itself with",
"# the actual metaclass.",
"class",
"metaclass",
"(",
"type",
")... | [
883,
0
] | [
896,
61
] | python | en | ['en', 'en', 'en'] | True |
add_metaclass | (metaclass) | Class decorator for creating a class with a metaclass. | Class decorator for creating a class with a metaclass. | def add_metaclass(metaclass):
"""Class decorator for creating a class with a metaclass."""
def wrapper(cls):
orig_vars = cls.__dict__.copy()
slots = orig_vars.get("__slots__")
if slots is not None:
if isinstance(slots, str):
slots = [slots]
for sl... | [
"def",
"add_metaclass",
"(",
"metaclass",
")",
":",
"def",
"wrapper",
"(",
"cls",
")",
":",
"orig_vars",
"=",
"cls",
".",
"__dict__",
".",
"copy",
"(",
")",
"slots",
"=",
"orig_vars",
".",
"get",
"(",
"\"__slots__\"",
")",
"if",
"slots",
"is",
"not",
... | [
899,
0
] | [
916,
18
] | python | en | ['en', 'en', 'en'] | True |
ensure_binary | (s, encoding="utf-8", errors="strict") | Coerce **s** to six.binary_type.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> encoded to `bytes`
- `bytes` -> `bytes`
| Coerce **s** to six.binary_type. | def ensure_binary(s, encoding="utf-8", errors="strict"):
"""Coerce **s** to six.binary_type.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> encoded to `bytes`
- `bytes` -> `bytes`
"""
if isinstance(s, text_type):
return s.enc... | [
"def",
"ensure_binary",
"(",
"s",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"errors",
"=",
"\"strict\"",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"text_type",
")",
":",
"return",
"s",
".",
"encode",
"(",
"encoding",
",",
"errors",
")",
"elif",
"isins... | [
919,
0
] | [
935,
60
] | python | en | ['en', 'sn', 'en'] | True |
ensure_str | (s, encoding="utf-8", errors="strict") | Coerce *s* to `str`.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
| Coerce *s* to `str`. | def ensure_str(s, encoding="utf-8", errors="strict"):
"""Coerce *s* to `str`.
For Python 2:
- `unicode` -> encoded to `str`
- `str` -> `str`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
"""
if not isinstance(s, (text_type, binary_type)):
raise TypeEr... | [
"def",
"ensure_str",
"(",
"s",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"errors",
"=",
"\"strict\"",
")",
":",
"if",
"not",
"isinstance",
"(",
"s",
",",
"(",
"text_type",
",",
"binary_type",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"not expecting type '%... | [
938,
0
] | [
955,
12
] | python | en | ['en', 'sl', 'en'] | True |
ensure_text | (s, encoding="utf-8", errors="strict") | Coerce *s* to six.text_type.
For Python 2:
- `unicode` -> `unicode`
- `str` -> `unicode`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
| Coerce *s* to six.text_type. | def ensure_text(s, encoding="utf-8", errors="strict"):
"""Coerce *s* to six.text_type.
For Python 2:
- `unicode` -> `unicode`
- `str` -> `unicode`
For Python 3:
- `str` -> `str`
- `bytes` -> decoded to `str`
"""
if isinstance(s, binary_type):
return s.decode(encodin... | [
"def",
"ensure_text",
"(",
"s",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"errors",
"=",
"\"strict\"",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"binary_type",
")",
":",
"return",
"s",
".",
"decode",
"(",
"encoding",
",",
"errors",
")",
"elif",
"isins... | [
958,
0
] | [
974,
60
] | python | en | ['en', 'sr', 'en'] | True |
python_2_unicode_compatible | (klass) |
A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
|
A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing. | def python_2_unicode_compatible(klass):
"""
A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
"""
if PY2:
... | [
"def",
"python_2_unicode_compatible",
"(",
"klass",
")",
":",
"if",
"PY2",
":",
"if",
"\"__str__\"",
"not",
"in",
"klass",
".",
"__dict__",
":",
"raise",
"ValueError",
"(",
"\"@python_2_unicode_compatible cannot be applied \"",
"\"to %s because it doesn't define __str__().\... | [
977,
0
] | [
993,
16
] | python | en | ['en', 'error', 'th'] | False |
_SixMetaPathImporter.is_package | (self, fullname) |
Return true, if the named module is a package.
We need this method to get correct spec objects with
Python 3.4 (see PEP451)
|
Return true, if the named module is a package. | def is_package(self, fullname):
"""
Return true, if the named module is a package.
We need this method to get correct spec objects with
Python 3.4 (see PEP451)
"""
return hasattr(self.__get_module(fullname), "__path__") | [
"def",
"is_package",
"(",
"self",
",",
"fullname",
")",
":",
"return",
"hasattr",
"(",
"self",
".",
"__get_module",
"(",
"fullname",
")",
",",
"\"__path__\"",
")"
] | [
204,
4
] | [
211,
63
] | python | en | ['en', 'error', 'th'] | False |
_SixMetaPathImporter.get_code | (self, fullname) | Return None
Required, if is_package is implemented | Return None | def get_code(self, fullname):
"""Return None
Required, if is_package is implemented"""
self.__get_module(fullname) # eventually raises ImportError
return None | [
"def",
"get_code",
"(",
"self",
",",
"fullname",
")",
":",
"self",
".",
"__get_module",
"(",
"fullname",
")",
"# eventually raises ImportError",
"return",
"None"
] | [
213,
4
] | [
218,
19
] | python | en | ['en', 'co', 'en'] | False |
Bazaar.export | (self, location, url) |
Export the Bazaar repository at the url to the destination location
|
Export the Bazaar repository at the url to the destination location
| def export(self, location, url):
# type: (str, HiddenText) -> None
"""
Export the Bazaar repository at the url to the destination location
"""
# Remove the location to make sure Bazaar can export it correctly
if os.path.exists(location):
rmtree(location)
... | [
"def",
"export",
"(",
"self",
",",
"location",
",",
"url",
")",
":",
"# type: (str, HiddenText) -> None",
"# Remove the location to make sure Bazaar can export it correctly",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"location",
")",
":",
"rmtree",
"(",
"location",... | [
46,
4
] | [
58,
9
] | python | en | ['en', 'error', 'th'] | False |
Bazaar.is_commit_id_equal | (cls, dest, name) | Always assume the versions don't match | Always assume the versions don't match | def is_commit_id_equal(cls, dest, name):
"""Always assume the versions don't match"""
return False | [
"def",
"is_commit_id_equal",
"(",
"cls",
",",
"dest",
",",
"name",
")",
":",
"return",
"False"
] | [
114,
4
] | [
116,
20
] | python | en | ['en', 'en', 'en'] | True |
AbstractConnectionPool.__init__ | (self, minconn, maxconn, *args, **kwargs) | Initialize the connection pool.
New 'minconn' connections are created immediately calling 'connfunc'
with given parameters. The connection pool will support a maximum of
about 'maxconn' connections.
| Initialize the connection pool. | def __init__(self, minconn, maxconn, *args, **kwargs):
"""Initialize the connection pool.
New 'minconn' connections are created immediately calling 'connfunc'
with given parameters. The connection pool will support a maximum of
about 'maxconn' connections.
"""
self.minco... | [
"def",
"__init__",
"(",
"self",
",",
"minconn",
",",
"maxconn",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"minconn",
"=",
"int",
"(",
"minconn",
")",
"self",
".",
"maxconn",
"=",
"int",
"(",
"maxconn",
")",
"self",
".",
"c... | [
37,
4
] | [
57,
27
] | python | en | ['en', 'en', 'en'] | True |
AbstractConnectionPool._connect | (self, key=None) | Create a new connection and assign it to 'key' if not None. | Create a new connection and assign it to 'key' if not None. | def _connect(self, key=None):
"""Create a new connection and assign it to 'key' if not None."""
conn = psycopg2.connect(*self._args, **self._kwargs)
if key is not None:
self._used[key] = conn
self._rused[id(conn)] = key
else:
self._pool.append(conn)
... | [
"def",
"_connect",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"conn",
"=",
"psycopg2",
".",
"connect",
"(",
"*",
"self",
".",
"_args",
",",
"*",
"*",
"self",
".",
"_kwargs",
")",
"if",
"key",
"is",
"not",
"None",
":",
"self",
".",
"_used",
... | [
59,
4
] | [
67,
19
] | python | en | ['en', 'en', 'en'] | True |
AbstractConnectionPool._getkey | (self) | Return a new unique key. | Return a new unique key. | def _getkey(self):
"""Return a new unique key."""
self._keys += 1
return self._keys | [
"def",
"_getkey",
"(",
"self",
")",
":",
"self",
".",
"_keys",
"+=",
"1",
"return",
"self",
".",
"_keys"
] | [
69,
4
] | [
72,
25
] | python | ca | ['fr', 'ca', 'en'] | False |
AbstractConnectionPool._getconn | (self, key=None) | Get a free connection and assign it to 'key' if not None. | Get a free connection and assign it to 'key' if not None. | def _getconn(self, key=None):
"""Get a free connection and assign it to 'key' if not None."""
if self.closed:
raise PoolError("connection pool is closed")
if key is None:
key = self._getkey()
if key in self._used:
return self._used[key]
if se... | [
"def",
"_getconn",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"PoolError",
"(",
"\"connection pool is closed\"",
")",
"if",
"key",
"is",
"None",
":",
"key",
"=",
"self",
".",
"_getkey",
"(",
")",
"if",
... | [
74,
4
] | [
91,
37
] | python | en | ['en', 'en', 'en'] | True |
AbstractConnectionPool._putconn | (self, conn, key=None, close=False) | Put away a connection. | Put away a connection. | def _putconn(self, conn, key=None, close=False):
"""Put away a connection."""
if self.closed:
raise PoolError("connection pool is closed")
if key is None:
key = self._rused.get(id(conn))
if not key:
raise PoolError("trying to put unkeyed connection")
... | [
"def",
"_putconn",
"(",
"self",
",",
"conn",
",",
"key",
"=",
"None",
",",
"close",
"=",
"False",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"PoolError",
"(",
"\"connection pool is closed\"",
")",
"if",
"key",
"is",
"None",
":",
"key",
"=",
... | [
93,
4
] | [
126,
37
] | python | en | ['en', 'en', 'en'] | True |
AbstractConnectionPool._closeall | (self) | Close all connections.
Note that this can lead to some code fail badly when trying to use
an already closed connection. If you call .closeall() make sure
your code can deal with it.
| Close all connections. | def _closeall(self):
"""Close all connections.
Note that this can lead to some code fail badly when trying to use
an already closed connection. If you call .closeall() make sure
your code can deal with it.
"""
if self.closed:
raise PoolError("connection pool ... | [
"def",
"_closeall",
"(",
"self",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"PoolError",
"(",
"\"connection pool is closed\"",
")",
"for",
"conn",
"in",
"self",
".",
"_pool",
"+",
"list",
"(",
"self",
".",
"_used",
".",
"values",
"(",
")",
")... | [
128,
4
] | [
142,
26
] | python | en | ['en', 'en', 'en'] | True |
ThreadedConnectionPool.__init__ | (self, minconn, maxconn, *args, **kwargs) | Initialize the threading lock. | Initialize the threading lock. | def __init__(self, minconn, maxconn, *args, **kwargs):
"""Initialize the threading lock."""
import threading
AbstractConnectionPool.__init__(
self, minconn, maxconn, *args, **kwargs)
self._lock = threading.Lock() | [
"def",
"__init__",
"(",
"self",
",",
"minconn",
",",
"maxconn",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"threading",
"AbstractConnectionPool",
".",
"__init__",
"(",
"self",
",",
"minconn",
",",
"maxconn",
",",
"*",
"args",
",",
"... | [
156,
4
] | [
161,
37
] | python | en | ['en', 'en', 'en'] | True |
ThreadedConnectionPool.getconn | (self, key=None) | Get a free connection and assign it to 'key' if not None. | Get a free connection and assign it to 'key' if not None. | def getconn(self, key=None):
"""Get a free connection and assign it to 'key' if not None."""
self._lock.acquire()
try:
return self._getconn(key)
finally:
self._lock.release() | [
"def",
"getconn",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"self",
".",
"_lock",
".",
"acquire",
"(",
")",
"try",
":",
"return",
"self",
".",
"_getconn",
"(",
"key",
")",
"finally",
":",
"self",
".",
"_lock",
".",
"release",
"(",
")"
] | [
163,
4
] | [
169,
32
] | python | en | ['en', 'en', 'en'] | True |
ThreadedConnectionPool.putconn | (self, conn=None, key=None, close=False) | Put away an unused connection. | Put away an unused connection. | def putconn(self, conn=None, key=None, close=False):
"""Put away an unused connection."""
self._lock.acquire()
try:
self._putconn(conn, key, close)
finally:
self._lock.release() | [
"def",
"putconn",
"(",
"self",
",",
"conn",
"=",
"None",
",",
"key",
"=",
"None",
",",
"close",
"=",
"False",
")",
":",
"self",
".",
"_lock",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"_putconn",
"(",
"conn",
",",
"key",
",",
"close",
... | [
171,
4
] | [
177,
32
] | python | en | ['en', 'en', 'en'] | True |
ThreadedConnectionPool.closeall | (self) | Close all connections (even the one currently in use.) | Close all connections (even the one currently in use.) | def closeall(self):
"""Close all connections (even the one currently in use.)"""
self._lock.acquire()
try:
self._closeall()
finally:
self._lock.release() | [
"def",
"closeall",
"(",
"self",
")",
":",
"self",
".",
"_lock",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"_closeall",
"(",
")",
"finally",
":",
"self",
".",
"_lock",
".",
"release",
"(",
")"
] | [
179,
4
] | [
185,
32
] | python | en | ['en', 'en', 'en'] | True |
PersistentConnectionPool.__init__ | (self, minconn, maxconn, *args, **kwargs) | Initialize the threading lock. | Initialize the threading lock. | def __init__(self, minconn, maxconn, *args, **kwargs):
"""Initialize the threading lock."""
import warnings
warnings.warn("deprecated: use ZPsycopgDA.pool implementation",
DeprecationWarning)
import threading
AbstractConnectionPool.__init__(
self, minconn... | [
"def",
"__init__",
"(",
"self",
",",
"minconn",
",",
"maxconn",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"warnings",
"warnings",
".",
"warn",
"(",
"\"deprecated: use ZPsycopgDA.pool implementation\"",
",",
"DeprecationWarning",
")",
"import... | [
198,
4
] | [
212,
31
] | python | en | ['en', 'en', 'en'] | True |
PersistentConnectionPool.getconn | (self) | Generate thread id and return a connection. | Generate thread id and return a connection. | def getconn(self):
"""Generate thread id and return a connection."""
key = self.__thread.get_ident()
self._lock.acquire()
try:
return self._getconn(key)
finally:
self._lock.release() | [
"def",
"getconn",
"(",
"self",
")",
":",
"key",
"=",
"self",
".",
"__thread",
".",
"get_ident",
"(",
")",
"self",
".",
"_lock",
".",
"acquire",
"(",
")",
"try",
":",
"return",
"self",
".",
"_getconn",
"(",
"key",
")",
"finally",
":",
"self",
".",
... | [
214,
4
] | [
221,
32
] | python | en | ['en', 'en', 'en'] | True |
PersistentConnectionPool.putconn | (self, conn=None, close=False) | Put away an unused connection. | Put away an unused connection. | def putconn(self, conn=None, close=False):
"""Put away an unused connection."""
key = self.__thread.get_ident()
self._lock.acquire()
try:
if not conn:
conn = self._used[key]
self._putconn(conn, key, close)
finally:
self._lock.re... | [
"def",
"putconn",
"(",
"self",
",",
"conn",
"=",
"None",
",",
"close",
"=",
"False",
")",
":",
"key",
"=",
"self",
".",
"__thread",
".",
"get_ident",
"(",
")",
"self",
".",
"_lock",
".",
"acquire",
"(",
")",
"try",
":",
"if",
"not",
"conn",
":",
... | [
223,
4
] | [
232,
32
] | python | en | ['en', 'en', 'en'] | True |
PersistentConnectionPool.closeall | (self) | Close all connections (even the one currently in use.) | Close all connections (even the one currently in use.) | def closeall(self):
"""Close all connections (even the one currently in use.)"""
self._lock.acquire()
try:
self._closeall()
finally:
self._lock.release() | [
"def",
"closeall",
"(",
"self",
")",
":",
"self",
".",
"_lock",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"_closeall",
"(",
")",
"finally",
":",
"self",
".",
"_lock",
".",
"release",
"(",
")"
] | [
234,
4
] | [
240,
32
] | python | en | ['en', 'en', 'en'] | True |
profiled | (func: FuncT) |
This decorator should obviously be used only in a dev environment.
It works best when surrounding a function that you expect to be
called once. One strategy is to write a backend test and wrap the
test case with the profiled decorator.
You can run a single test case like this:
# edit zer... |
This decorator should obviously be used only in a dev environment.
It works best when surrounding a function that you expect to be
called once. One strategy is to write a backend test and wrap the
test case with the profiled decorator. | def profiled(func: FuncT) -> FuncT:
"""
This decorator should obviously be used only in a dev environment.
It works best when surrounding a function that you expect to be
called once. One strategy is to write a backend test and wrap the
test case with the profiled decorator.
You can run a sing... | [
"def",
"profiled",
"(",
"func",
":",
"FuncT",
")",
"->",
"FuncT",
":",
"func_",
":",
"Callable",
"[",
"...",
",",
"object",
"]",
"=",
"func",
"# work around https://github.com/python/mypy/issues/9075",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped_func",
"("... | [
7,
0
] | [
34,
36
] | python | en | ['en', 'error', 'th'] | False |
sensitive_variables | (*variables) |
Indicates which variables used in the decorated function are sensitive, so
that those variables can later be treated in a special way, for example
by hiding them when logging unhandled exceptions.
Two forms are accepted:
* with specified variable names:
@sensitive_variables('user', 'pass... |
Indicates which variables used in the decorated function are sensitive, so
that those variables can later be treated in a special way, for example
by hiding them when logging unhandled exceptions. | def sensitive_variables(*variables):
"""
Indicates which variables used in the decorated function are sensitive, so
that those variables can later be treated in a special way, for example
by hiding them when logging unhandled exceptions.
Two forms are accepted:
* with specified variable names:... | [
"def",
"sensitive_variables",
"(",
"*",
"variables",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"sensitive_variables_wrapper",
"(",
"*",
"func_args",
",",
"*",
"*",
"func_kwargs",
")",
":",... | [
5,
0
] | [
37,
20
] | python | en | ['en', 'error', 'th'] | False |
sensitive_post_parameters | (*parameters) |
Indicates which POST parameters used in the decorated view are sensitive,
so that those parameters can later be treated in a special way, for example
by hiding them when logging unhandled exceptions.
Two forms are accepted:
* with specified parameters:
@sensitive_post_parameters('passwor... |
Indicates which POST parameters used in the decorated view are sensitive,
so that those parameters can later be treated in a special way, for example
by hiding them when logging unhandled exceptions. | def sensitive_post_parameters(*parameters):
"""
Indicates which POST parameters used in the decorated view are sensitive,
so that those parameters can later be treated in a special way, for example
by hiding them when logging unhandled exceptions.
Two forms are accepted:
* with specified param... | [
"def",
"sensitive_post_parameters",
"(",
"*",
"parameters",
")",
":",
"def",
"decorator",
"(",
"view",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"view",
")",
"def",
"sensitive_post_parameters_wrapper",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
... | [
40,
0
] | [
77,
20
] | python | en | ['en', 'error', 'th'] | False |
get_snippet_model_from_url_params | (app_name, model_name) |
Retrieve a model from an app_label / model_name combo.
Raise Http404 if the model is not a valid snippet type.
|
Retrieve a model from an app_label / model_name combo.
Raise Http404 if the model is not a valid snippet type.
| def get_snippet_model_from_url_params(app_name, model_name):
"""
Retrieve a model from an app_label / model_name combo.
Raise Http404 if the model is not a valid snippet type.
"""
try:
model = apps.get_model(app_name, model_name)
except LookupError:
raise Http404
if model not... | [
"def",
"get_snippet_model_from_url_params",
"(",
"app_name",
",",
"model_name",
")",
":",
"try",
":",
"model",
"=",
"apps",
".",
"get_model",
"(",
"app_name",
",",
"model_name",
")",
"except",
"LookupError",
":",
"raise",
"Http404",
"if",
"model",
"not",
"in",... | [
29,
0
] | [
42,
16
] | python | en | ['en', 'error', 'th'] | False |
EmoticonTranslationsHelpExtension.extendMarkdown | (self, md: Markdown) | Add SettingHelpExtension to the Markdown instance. | Add SettingHelpExtension to the Markdown instance. | def extendMarkdown(self, md: Markdown) -> None:
"""Add SettingHelpExtension to the Markdown instance."""
md.registerExtension(self)
md.preprocessors.register(EmoticonTranslation(), "emoticon_translations", -505) | [
"def",
"extendMarkdown",
"(",
"self",
",",
"md",
":",
"Markdown",
")",
"->",
"None",
":",
"md",
".",
"registerExtension",
"(",
"self",
")",
"md",
".",
"preprocessors",
".",
"register",
"(",
"EmoticonTranslation",
"(",
")",
",",
"\"emoticon_translations\"",
"... | [
39,
4
] | [
42,
87
] | python | en | ['en', 'en', 'en'] | True |
autocomplete | () | Entry Point for completion of main and subcommand options.
| Entry Point for completion of main and subcommand options.
| def autocomplete():
# type: () -> None
"""Entry Point for completion of main and subcommand options.
"""
# Don't complete if user hasn't sourced bash_completion file.
if 'PIP_AUTO_COMPLETE' not in os.environ:
return
cwords = os.environ['COMP_WORDS'].split()[1:]
cword = int(os.environ... | [
"def",
"autocomplete",
"(",
")",
":",
"# type: () -> None",
"# Don't complete if user hasn't sourced bash_completion file.",
"if",
"'PIP_AUTO_COMPLETE'",
"not",
"in",
"os",
".",
"environ",
":",
"return",
"cwords",
"=",
"os",
".",
"environ",
"[",
"'COMP_WORDS'",
"]",
"... | [
17,
0
] | [
109,
15
] | python | en | ['en', 'en', 'en'] | True |
get_path_completion_type | (cwords, cword, opts) | Get the type of path completion (``file``, ``dir``, ``path`` or None)
:param cwords: same as the environmental variable ``COMP_WORDS``
:param cword: same as the environmental variable ``COMP_CWORD``
:param opts: The available options to check
:return: path completion type (``file``, ``dir``, ``path`` o... | Get the type of path completion (``file``, ``dir``, ``path`` or None) | def get_path_completion_type(cwords, cword, opts):
# type: (List[str], int, Iterable[Any]) -> Optional[str]
"""Get the type of path completion (``file``, ``dir``, ``path`` or None)
:param cwords: same as the environmental variable ``COMP_WORDS``
:param cword: same as the environmental variable ``COMP_C... | [
"def",
"get_path_completion_type",
"(",
"cwords",
",",
"cword",
",",
"opts",
")",
":",
"# type: (List[str], int, Iterable[Any]) -> Optional[str]",
"if",
"cword",
"<",
"2",
"or",
"not",
"cwords",
"[",
"cword",
"-",
"2",
"]",
".",
"startswith",
"(",
"'-'",
")",
... | [
112,
0
] | [
132,
15
] | python | en | ['en', 'en', 'en'] | True |
auto_complete_paths | (current, completion_type) | If ``completion_type`` is ``file`` or ``path``, list all regular files
and directories starting with ``current``; otherwise only list directories
starting with ``current``.
:param current: The word to be completed
:param completion_type: path completion type(`file`, `path` or `dir`)i
:return: A gen... | If ``completion_type`` is ``file`` or ``path``, list all regular files
and directories starting with ``current``; otherwise only list directories
starting with ``current``. | def auto_complete_paths(current, completion_type):
# type: (str, str) -> Iterable[str]
"""If ``completion_type`` is ``file`` or ``path``, list all regular files
and directories starting with ``current``; otherwise only list directories
starting with ``current``.
:param current: The word to be compl... | [
"def",
"auto_complete_paths",
"(",
"current",
",",
"completion_type",
")",
":",
"# type: (str, str) -> Iterable[str]",
"directory",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"current",
")",
"current_path",
"=",
"os",
".",
"path",
".",
"abspath"... | [
135,
0
] | [
163,
45
] | python | en | ['en', 'en', 'en'] | True |
config | (env=DEFAULT_ENV, default=None, engine=None, conn_max_age=0, ssl_require=False) | Returns configured DATABASE dictionary from DATABASE_URL. | Returns configured DATABASE dictionary from DATABASE_URL. | def config(env=DEFAULT_ENV, default=None, engine=None, conn_max_age=0, ssl_require=False):
"""Returns configured DATABASE dictionary from DATABASE_URL."""
config = {}
s = os.environ.get(env, default)
if s:
config = parse(s, engine, conn_max_age, ssl_require)
return config | [
"def",
"config",
"(",
"env",
"=",
"DEFAULT_ENV",
",",
"default",
"=",
"None",
",",
"engine",
"=",
"None",
",",
"conn_max_age",
"=",
"0",
",",
"ssl_require",
"=",
"False",
")",
":",
"config",
"=",
"{",
"}",
"s",
"=",
"os",
".",
"environ",
".",
"get"... | [
46,
0
] | [
56,
17
] | python | en | ['en', 'en', 'en'] | True |
parse | (url, engine=None, conn_max_age=0, ssl_require=False) | Parses a database URL. | Parses a database URL. | def parse(url, engine=None, conn_max_age=0, ssl_require=False):
"""Parses a database URL."""
if url == 'sqlite://:memory:':
# this is a special case, because if we pass this URL into
# urlparse, urlparse will choke trying to interpret "memory"
# as a port number
return {
... | [
"def",
"parse",
"(",
"url",
",",
"engine",
"=",
"None",
",",
"conn_max_age",
"=",
"0",
",",
"ssl_require",
"=",
"False",
")",
":",
"if",
"url",
"==",
"'sqlite://:memory:'",
":",
"# this is a special case, because if we pass this URL into",
"# urlparse, urlparse will c... | [
59,
0
] | [
143,
17
] | python | en | ['en', 'en', 'en'] | True |
remove_admin_access_permissions | (apps, schema_editor) | Reverse the above additions of permissions. | Reverse the above additions of permissions. | def remove_admin_access_permissions(apps, schema_editor):
"""Reverse the above additions of permissions."""
ContentType = apps.get_model('contenttypes.ContentType')
Permission = apps.get_model('auth.Permission')
wagtailadmin_content_type = ContentType.objects.get(
app_label='wagtailadmin',
... | [
"def",
"remove_admin_access_permissions",
"(",
"apps",
",",
"schema_editor",
")",
":",
"ContentType",
"=",
"apps",
".",
"get_model",
"(",
"'contenttypes.ContentType'",
")",
"Permission",
"=",
"apps",
".",
"get_model",
"(",
"'auth.Permission'",
")",
"wagtailadmin_conte... | [
27,
0
] | [
39,
14
] | python | en | ['en', 'en', 'en'] | True |
_NormalizedSource | (source) | Normalize the path.
But not if that gets rid of a variable, as this may expand to something
larger than one directory.
Arguments:
source: The path to be normalize.d
Returns:
The normalized path.
| Normalize the path. | def _NormalizedSource(source):
"""Normalize the path.
But not if that gets rid of a variable, as this may expand to something
larger than one directory.
Arguments:
source: The path to be normalize.d
Returns:
The normalized path.
"""
normalized = os.path.normpath(source)
if source.co... | [
"def",
"_NormalizedSource",
"(",
"source",
")",
":",
"normalized",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"source",
")",
"if",
"source",
".",
"count",
"(",
"\"$\"",
")",
"==",
"normalized",
".",
"count",
"(",
"\"$\"",
")",
":",
"source",
"=",
... | [
141,
0
] | [
156,
17
] | python | en | ['en', 'en', 'en'] | True |
_FixPath | (path) | Convert paths to a form that will make sense in a vcproj file.
Arguments:
path: The path to convert, may contain / etc.
Returns:
The path with all slashes made into backslashes.
| Convert paths to a form that will make sense in a vcproj file. | def _FixPath(path):
"""Convert paths to a form that will make sense in a vcproj file.
Arguments:
path: The path to convert, may contain / etc.
Returns:
The path with all slashes made into backslashes.
"""
if (
fixpath_prefix
and path
and not os.path.isabs(path)
and... | [
"def",
"_FixPath",
"(",
"path",
")",
":",
"if",
"(",
"fixpath_prefix",
"and",
"path",
"and",
"not",
"os",
".",
"path",
".",
"isabs",
"(",
"path",
")",
"and",
"not",
"path",
"[",
"0",
"]",
"==",
"\"$\"",
"and",
"not",
"_IsWindowsAbsPath",
"(",
"path",... | [
159,
0
] | [
179,
15
] | python | en | ['en', 'en', 'en'] | True |
_IsWindowsAbsPath | (path) |
On Cygwin systems Python needs a little help determining if a path
is an absolute Windows path or not, so that
it does not treat those as relative, which results in bad paths like:
'..\\C:\\<some path>\\some_source_code_file.cc'
|
On Cygwin systems Python needs a little help determining if a path
is an absolute Windows path or not, so that
it does not treat those as relative, which results in bad paths like:
'..\\C:\\<some path>\\some_source_code_file.cc'
| def _IsWindowsAbsPath(path):
"""
On Cygwin systems Python needs a little help determining if a path
is an absolute Windows path or not, so that
it does not treat those as relative, which results in bad paths like:
'..\\C:\\<some path>\\some_source_code_file.cc'
"""
return path.startswith("c:") or path... | [
"def",
"_IsWindowsAbsPath",
"(",
"path",
")",
":",
"return",
"path",
".",
"startswith",
"(",
"\"c:\"",
")",
"or",
"path",
".",
"startswith",
"(",
"\"C:\"",
")"
] | [
182,
0
] | [
189,
57
] | python | en | ['en', 'error', 'th'] | False |
_FixPaths | (paths) | Fix each of the paths of the list. | Fix each of the paths of the list. | def _FixPaths(paths):
"""Fix each of the paths of the list."""
return [_FixPath(i) for i in paths] | [
"def",
"_FixPaths",
"(",
"paths",
")",
":",
"return",
"[",
"_FixPath",
"(",
"i",
")",
"for",
"i",
"in",
"paths",
"]"
] | [
192,
0
] | [
194,
39
] | python | en | ['en', 'en', 'en'] | True |
_ConvertSourcesToFilterHierarchy | (
sources, prefix=None, excluded=None, list_excluded=True, msvs_version=None
) | Converts a list split source file paths into a vcproj folder hierarchy.
Arguments:
sources: A list of source file paths split.
prefix: A list of source file path layers meant to apply to each of sources.
excluded: A set of excluded files.
msvs_version: A MSVSVersion object.
Returns:
A hierarch... | Converts a list split source file paths into a vcproj folder hierarchy. | def _ConvertSourcesToFilterHierarchy(
sources, prefix=None, excluded=None, list_excluded=True, msvs_version=None
):
"""Converts a list split source file paths into a vcproj folder hierarchy.
Arguments:
sources: A list of source file paths split.
prefix: A list of source file path layers meant to appl... | [
"def",
"_ConvertSourcesToFilterHierarchy",
"(",
"sources",
",",
"prefix",
"=",
"None",
",",
"excluded",
"=",
"None",
",",
"list_excluded",
"=",
"True",
",",
"msvs_version",
"=",
"None",
")",
":",
"if",
"not",
"prefix",
":",
"prefix",
"=",
"[",
"]",
"result... | [
197,
0
] | [
268,
17
] | python | en | ['en', 'fr', 'en'] | True |
_AddActionStep | (actions_dict, inputs, outputs, description, command) | Merge action into an existing list of actions.
Care must be taken so that actions which have overlapping inputs either don't
get assigned to the same input, or get collapsed into one.
Arguments:
actions_dict: dictionary keyed on input name, which maps to a list of
dicts describing the actions attached... | Merge action into an existing list of actions. | def _AddActionStep(actions_dict, inputs, outputs, description, command):
"""Merge action into an existing list of actions.
Care must be taken so that actions which have overlapping inputs either don't
get assigned to the same input, or get collapsed into one.
Arguments:
actions_dict: dictionary keyed on... | [
"def",
"_AddActionStep",
"(",
"actions_dict",
",",
"inputs",
",",
"outputs",
",",
"description",
",",
"command",
")",
":",
"# Require there to be at least one input (call sites will ensure this).",
"assert",
"inputs",
"action",
"=",
"{",
"\"inputs\"",
":",
"inputs",
","... | [
458,
0
] | [
490,
45
] | python | en | ['en', 'en', 'en'] | True |
_AddCustomBuildToolForMSVS | (
p, spec, primary_input, inputs, outputs, description, cmd
) | Add a custom build tool to execute something.
Arguments:
p: the target project
spec: the target project dict
primary_input: input file to attach the build tool to
inputs: list of inputs
outputs: list of outputs
description: description of the action
cmd: command line to execute
| Add a custom build tool to execute something. | def _AddCustomBuildToolForMSVS(
p, spec, primary_input, inputs, outputs, description, cmd
):
"""Add a custom build tool to execute something.
Arguments:
p: the target project
spec: the target project dict
primary_input: input file to attach the build tool to
inputs: list of inputs
outputs... | [
"def",
"_AddCustomBuildToolForMSVS",
"(",
"p",
",",
"spec",
",",
"primary_input",
",",
"inputs",
",",
"outputs",
",",
"description",
",",
"cmd",
")",
":",
"inputs",
"=",
"_FixPaths",
"(",
"inputs",
")",
"outputs",
"=",
"_FixPaths",
"(",
"outputs",
")",
"to... | [
493,
0
] | [
522,
9
] | python | en | ['en', 'en', 'en'] | True |
_AddAccumulatedActionsToMSVS | (p, spec, actions_dict) | Add actions accumulated into an actions_dict, merging as needed.
Arguments:
p: the target project
spec: the target project dict
actions_dict: dictionary keyed on input name, which maps to a list of
dicts describing the actions attached to that input file.
| Add actions accumulated into an actions_dict, merging as needed. | def _AddAccumulatedActionsToMSVS(p, spec, actions_dict):
"""Add actions accumulated into an actions_dict, merging as needed.
Arguments:
p: the target project
spec: the target project dict
actions_dict: dictionary keyed on input name, which maps to a list of
dicts describing the actions attach... | [
"def",
"_AddAccumulatedActionsToMSVS",
"(",
"p",
",",
"spec",
",",
"actions_dict",
")",
":",
"for",
"primary_input",
"in",
"actions_dict",
":",
"inputs",
"=",
"OrderedSet",
"(",
")",
"outputs",
"=",
"OrderedSet",
"(",
")",
"descriptions",
"=",
"[",
"]",
"com... | [
525,
0
] | [
555,
9
] | python | en | ['en', 'en', 'en'] | True |
_RuleExpandPath | (path, input_file) | Given the input file to which a rule applied, string substitute a path.
Arguments:
path: a path to string expand
input_file: the file to which the rule applied.
Returns:
The string substituted path.
| Given the input file to which a rule applied, string substitute a path. | def _RuleExpandPath(path, input_file):
"""Given the input file to which a rule applied, string substitute a path.
Arguments:
path: a path to string expand
input_file: the file to which the rule applied.
Returns:
The string substituted path.
"""
path = path.replace(
"$(InputName)", os.... | [
"def",
"_RuleExpandPath",
"(",
"path",
",",
"input_file",
")",
":",
"path",
"=",
"path",
".",
"replace",
"(",
"\"$(InputName)\"",
",",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"split",
"(",
"input_file",
")",
"[",
"1",
"]",
")... | [
558,
0
] | [
576,
15
] | python | en | ['en', 'en', 'en'] | True |
_FindRuleTriggerFiles | (rule, sources) | Find the list of files which a particular rule applies to.
Arguments:
rule: the rule in question
sources: the set of all known source files for this project
Returns:
The list of sources that trigger a particular rule.
| Find the list of files which a particular rule applies to. | def _FindRuleTriggerFiles(rule, sources):
"""Find the list of files which a particular rule applies to.
Arguments:
rule: the rule in question
sources: the set of all known source files for this project
Returns:
The list of sources that trigger a particular rule.
"""
return rule.get("rule_sour... | [
"def",
"_FindRuleTriggerFiles",
"(",
"rule",
",",
"sources",
")",
":",
"return",
"rule",
".",
"get",
"(",
"\"rule_sources\"",
",",
"[",
"]",
")"
] | [
579,
0
] | [
588,
39
] | python | en | ['en', 'en', 'en'] | True |
_RuleInputsAndOutputs | (rule, trigger_file) | Find the inputs and outputs generated by a rule.
Arguments:
rule: the rule in question.
trigger_file: the main trigger for this rule.
Returns:
The pair of (inputs, outputs) involved in this rule.
| Find the inputs and outputs generated by a rule. | def _RuleInputsAndOutputs(rule, trigger_file):
"""Find the inputs and outputs generated by a rule.
Arguments:
rule: the rule in question.
trigger_file: the main trigger for this rule.
Returns:
The pair of (inputs, outputs) involved in this rule.
"""
raw_inputs = _FixPaths(rule.get("inputs", [... | [
"def",
"_RuleInputsAndOutputs",
"(",
"rule",
",",
"trigger_file",
")",
":",
"raw_inputs",
"=",
"_FixPaths",
"(",
"rule",
".",
"get",
"(",
"\"inputs\"",
",",
"[",
"]",
")",
")",
"raw_outputs",
"=",
"_FixPaths",
"(",
"rule",
".",
"get",
"(",
"\"outputs\"",
... | [
591,
0
] | [
609,
28
] | python | en | ['en', 'en', 'en'] | True |
_GenerateNativeRulesForMSVS | (p, rules, output_dir, spec, options) | Generate a native rules file.
Arguments:
p: the target project
rules: the set of rules to include
output_dir: the directory in which the project/gyp resides
spec: the project dict
options: global generator options
| Generate a native rules file. | def _GenerateNativeRulesForMSVS(p, rules, output_dir, spec, options):
"""Generate a native rules file.
Arguments:
p: the target project
rules: the set of rules to include
output_dir: the directory in which the project/gyp resides
spec: the project dict
options: global generator options
"""
... | [
"def",
"_GenerateNativeRulesForMSVS",
"(",
"p",
",",
"rules",
",",
"output_dir",
",",
"spec",
",",
"options",
")",
":",
"rules_filename",
"=",
"\"%s%s.rules\"",
"%",
"(",
"spec",
"[",
"\"target_name\"",
"]",
",",
"options",
".",
"suffix",
")",
"rules_file",
... | [
612,
0
] | [
648,
33
] | python | en | ['en', 'co', 'en'] | True |
_GenerateExternalRules | (rules, output_dir, spec, sources, options, actions_to_add) | Generate an external makefile to do a set of rules.
Arguments:
rules: the list of rules to include
output_dir: path containing project and gyp files
spec: project specification data
sources: set of sources known
options: global generator options
actions_to_add: The list of actions we will add... | Generate an external makefile to do a set of rules. | def _GenerateExternalRules(rules, output_dir, spec, sources, options, actions_to_add):
"""Generate an external makefile to do a set of rules.
Arguments:
rules: the list of rules to include
output_dir: path containing project and gyp files
spec: project specification data
sources: set of sources k... | [
"def",
"_GenerateExternalRules",
"(",
"rules",
",",
"output_dir",
",",
"spec",
",",
"sources",
",",
"options",
",",
"actions_to_add",
")",
":",
"filename",
"=",
"\"%s_rules%s.mk\"",
"%",
"(",
"spec",
"[",
"\"target_name\"",
"]",
",",
"options",
".",
"suffix",
... | [
657,
0
] | [
739,
5
] | python | en | ['en', 'en', 'en'] | True |
_EscapeEnvironmentVariableExpansion | (s) | Escapes % characters.
Escapes any % characters so that Windows-style environment variable
expansions will leave them alone.
See http://connect.microsoft.com/VisualStudio/feedback/details/106127/cl-d-name-text-containing-percentage-characters-doesnt-compile
to understand why we have to do this.
Args:
s... | Escapes % characters. | def _EscapeEnvironmentVariableExpansion(s):
"""Escapes % characters.
Escapes any % characters so that Windows-style environment variable
expansions will leave them alone.
See http://connect.microsoft.com/VisualStudio/feedback/details/106127/cl-d-name-text-containing-percentage-characters-doesnt-compile
to ... | [
"def",
"_EscapeEnvironmentVariableExpansion",
"(",
"s",
")",
":",
"# noqa: E731,E123,E501",
"s",
"=",
"s",
".",
"replace",
"(",
"\"%\"",
",",
"\"%%\"",
")",
"return",
"s"
] | [
742,
0
] | [
757,
12
] | python | en | ['es', 'en', 'en'] | True |
_EscapeCommandLineArgumentForMSVS | (s) | Escapes a Windows command-line argument.
So that the Win32 CommandLineToArgv function will turn the escaped result back
into the original string.
See http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
("Parsing C++ Command-Line Arguments") to understand why we have to do
this.
Args:
s: the string... | Escapes a Windows command-line argument. | def _EscapeCommandLineArgumentForMSVS(s):
"""Escapes a Windows command-line argument.
So that the Win32 CommandLineToArgv function will turn the escaped result back
into the original string.
See http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
("Parsing C++ Command-Line Arguments") to understand why w... | [
"def",
"_EscapeCommandLineArgumentForMSVS",
"(",
"s",
")",
":",
"def",
"_Replace",
"(",
"match",
")",
":",
"# For a literal quote, CommandLineToArgv requires an odd number of",
"# backslashes preceding it, and it produces half as many literal backslashes",
"# (rounded down). So we need t... | [
763,
0
] | [
788,
12
] | python | en | ['en', 'fr', 'en'] | True |
_EscapeVCProjCommandLineArgListItem | (s) | Escapes command line arguments for MSVS.
The VCProj format stores string lists in a single string using commas and
semi-colons as separators, which must be quoted if they are to be
interpreted literally. However, command-line arguments may already have
quotes, and the VCProj parser is ignorant of the backslash... | Escapes command line arguments for MSVS. | def _EscapeVCProjCommandLineArgListItem(s):
"""Escapes command line arguments for MSVS.
The VCProj format stores string lists in a single string using commas and
semi-colons as separators, which must be quoted if they are to be
interpreted literally. However, command-line arguments may already have
quotes,... | [
"def",
"_EscapeVCProjCommandLineArgListItem",
"(",
"s",
")",
":",
"def",
"_Replace",
"(",
"match",
")",
":",
"# For a non-literal quote, CommandLineToArgv requires an even number of",
"# backslashes preceding it, and it produces half as many literal",
"# backslashes. So we need to produc... | [
794,
0
] | [
840,
12
] | python | en | ['en', 'fr', 'en'] | True |
_EscapeCppDefineForMSVS | (s) | Escapes a CPP define so that it will reach the compiler unaltered. | Escapes a CPP define so that it will reach the compiler unaltered. | def _EscapeCppDefineForMSVS(s):
"""Escapes a CPP define so that it will reach the compiler unaltered."""
s = _EscapeEnvironmentVariableExpansion(s)
s = _EscapeCommandLineArgumentForMSVS(s)
s = _EscapeVCProjCommandLineArgListItem(s)
# cl.exe replaces literal # characters with = in preprocessor defini... | [
"def",
"_EscapeCppDefineForMSVS",
"(",
"s",
")",
":",
"s",
"=",
"_EscapeEnvironmentVariableExpansion",
"(",
"s",
")",
"s",
"=",
"_EscapeCommandLineArgumentForMSVS",
"(",
"s",
")",
"s",
"=",
"_EscapeVCProjCommandLineArgListItem",
"(",
"s",
")",
"# cl.exe replaces liter... | [
843,
0
] | [
851,
12
] | python | en | ['en', 'en', 'en'] | True |
_EscapeCommandLineArgumentForMSBuild | (s) | Escapes a Windows command-line argument for use by MSBuild. | Escapes a Windows command-line argument for use by MSBuild. | def _EscapeCommandLineArgumentForMSBuild(s):
"""Escapes a Windows command-line argument for use by MSBuild."""
def _Replace(match):
return (len(match.group(1)) / 2 * 4) * "\\" + '\\"'
# Escape all quotes so that they are interpreted literally.
s = quote_replacer_regex2.sub(_Replace, s)
ret... | [
"def",
"_EscapeCommandLineArgumentForMSBuild",
"(",
"s",
")",
":",
"def",
"_Replace",
"(",
"match",
")",
":",
"return",
"(",
"len",
"(",
"match",
".",
"group",
"(",
"1",
")",
")",
"/",
"2",
"*",
"4",
")",
"*",
"\"\\\\\"",
"+",
"'\\\\\"'",
"# Escape all... | [
857,
0
] | [
865,
12
] | python | en | ['en', 'en', 'en'] | True |
_EscapeCppDefineForMSBuild | (s) | Escapes a CPP define so that it will reach the compiler unaltered. | Escapes a CPP define so that it will reach the compiler unaltered. | def _EscapeCppDefineForMSBuild(s):
"""Escapes a CPP define so that it will reach the compiler unaltered."""
s = _EscapeEnvironmentVariableExpansion(s)
s = _EscapeCommandLineArgumentForMSBuild(s)
s = _EscapeMSBuildSpecialCharacters(s)
# cl.exe replaces literal # characters with = in preprocessor defi... | [
"def",
"_EscapeCppDefineForMSBuild",
"(",
"s",
")",
":",
"s",
"=",
"_EscapeEnvironmentVariableExpansion",
"(",
"s",
")",
"s",
"=",
"_EscapeCommandLineArgumentForMSBuild",
"(",
"s",
")",
"s",
"=",
"_EscapeMSBuildSpecialCharacters",
"(",
"s",
")",
"# cl.exe replaces lit... | [
882,
0
] | [
890,
12
] | python | en | ['en', 'en', 'en'] | True |
_GenerateRulesForMSVS | (
p, output_dir, options, spec, sources, excluded_sources, actions_to_add
) | Generate all the rules for a particular project.
Arguments:
p: the project
output_dir: directory to emit rules to
options: global options passed to the generator
spec: the specification for this project
sources: the set of all known source files in this project
excluded_sources: the set of so... | Generate all the rules for a particular project. | def _GenerateRulesForMSVS(
p, output_dir, options, spec, sources, excluded_sources, actions_to_add
):
"""Generate all the rules for a particular project.
Arguments:
p: the project
output_dir: directory to emit rules to
options: global options passed to the generator
spec: the specification fo... | [
"def",
"_GenerateRulesForMSVS",
"(",
"p",
",",
"output_dir",
",",
"options",
",",
"spec",
",",
"sources",
",",
"excluded_sources",
",",
"actions_to_add",
")",
":",
"rules",
"=",
"spec",
".",
"get",
"(",
"\"rules\"",
",",
"[",
"]",
")",
"rules_native",
"=",... | [
893,
0
] | [
920,
67
] | python | en | ['en', 'en', 'en'] | True |
_FilterActionsFromExcluded | (excluded_sources, actions_to_add) | Take inputs with actions attached out of the list of exclusions.
Arguments:
excluded_sources: list of source files not to be built.
actions_to_add: dict of actions keyed on source file they're attached to.
Returns:
excluded_sources with files that have actions attached removed.
| Take inputs with actions attached out of the list of exclusions. | def _FilterActionsFromExcluded(excluded_sources, actions_to_add):
"""Take inputs with actions attached out of the list of exclusions.
Arguments:
excluded_sources: list of source files not to be built.
actions_to_add: dict of actions keyed on source file they're attached to.
Returns:
excluded_source... | [
"def",
"_FilterActionsFromExcluded",
"(",
"excluded_sources",
",",
"actions_to_add",
")",
":",
"must_keep",
"=",
"OrderedSet",
"(",
"_FixPaths",
"(",
"actions_to_add",
".",
"keys",
"(",
")",
")",
")",
"return",
"[",
"s",
"for",
"s",
"in",
"excluded_sources",
"... | [
945,
0
] | [
955,
62
] | python | en | ['en', 'en', 'en'] | True |
_GetGuidOfProject | (proj_path, spec) | Get the guid for the project.
Arguments:
proj_path: Path of the vcproj or vcxproj file to generate.
spec: The target dictionary containing the properties of the target.
Returns:
the guid.
Raises:
ValueError: if the specified GUID is invalid.
| Get the guid for the project. | def _GetGuidOfProject(proj_path, spec):
"""Get the guid for the project.
Arguments:
proj_path: Path of the vcproj or vcxproj file to generate.
spec: The target dictionary containing the properties of the target.
Returns:
the guid.
Raises:
ValueError: if the specified GUID is invalid.
"""
... | [
"def",
"_GetGuidOfProject",
"(",
"proj_path",
",",
"spec",
")",
":",
"# Pluck out the default configuration.",
"default_config",
"=",
"_GetDefaultConfiguration",
"(",
"spec",
")",
"# Decide the guid of the project.",
"guid",
"=",
"default_config",
".",
"get",
"(",
"\"msvs... | [
962,
0
] | [
985,
15
] | python | en | ['en', 'en', 'en'] | True |
_GetMsbuildToolsetOfProject | (proj_path, spec, version) | Get the platform toolset for the project.
Arguments:
proj_path: Path of the vcproj or vcxproj file to generate.
spec: The target dictionary containing the properties of the target.
version: The MSVSVersion object.
Returns:
the platform toolset string or None.
| Get the platform toolset for the project. | def _GetMsbuildToolsetOfProject(proj_path, spec, version):
"""Get the platform toolset for the project.
Arguments:
proj_path: Path of the vcproj or vcxproj file to generate.
spec: The target dictionary containing the properties of the target.
version: The MSVSVersion object.
Returns:
the platfo... | [
"def",
"_GetMsbuildToolsetOfProject",
"(",
"proj_path",
",",
"spec",
",",
"version",
")",
":",
"# Pluck out the default configuration.",
"default_config",
"=",
"_GetDefaultConfiguration",
"(",
"spec",
")",
"toolset",
"=",
"default_config",
".",
"get",
"(",
"\"msbuild_to... | [
988,
0
] | [
1005,
18
] | python | en | ['en', 'en', 'en'] | True |
_GenerateProject | (project, options, version, generator_flags, spec) | Generates a vcproj file.
Arguments:
project: the MSVSProject object.
options: global generator options.
version: the MSVSVersion object.
generator_flags: dict of generator-specific flags.
Returns:
A list of source files that cannot be found on disk.
| Generates a vcproj file. | def _GenerateProject(project, options, version, generator_flags, spec):
"""Generates a vcproj file.
Arguments:
project: the MSVSProject object.
options: global generator options.
version: the MSVSVersion object.
generator_flags: dict of generator-specific flags.
Returns:
A list of source fi... | [
"def",
"_GenerateProject",
"(",
"project",
",",
"options",
",",
"version",
",",
"generator_flags",
",",
"spec",
")",
":",
"default_config",
"=",
"_GetDefaultConfiguration",
"(",
"project",
".",
"spec",
")",
"# Skip emitting anything if told to with msvs_existing_vcproj op... | [
1008,
0
] | [
1028,
79
] | python | en | ['en', 'it', 'pt'] | False |
_GenerateMSVSProject | (project, options, version, generator_flags) | Generates a .vcproj file. It may create .rules and .user files too.
Arguments:
project: The project object we will generate the file for.
options: Global options passed to the generator.
version: The VisualStudioVersion object.
generator_flags: dict of generator-specific flags.
| Generates a .vcproj file. It may create .rules and .user files too. | def _GenerateMSVSProject(project, options, version, generator_flags):
"""Generates a .vcproj file. It may create .rules and .user files too.
Arguments:
project: The project object we will generate the file for.
options: Global options passed to the generator.
version: The VisualStudioVersion object.... | [
"def",
"_GenerateMSVSProject",
"(",
"project",
",",
"options",
",",
"version",
",",
"generator_flags",
")",
":",
"spec",
"=",
"project",
".",
"spec",
"gyp",
".",
"common",
".",
"EnsureDirExists",
"(",
"project",
".",
"path",
")",
"platforms",
"=",
"_GetUniqu... | [
1031,
0
] | [
1090,
26
] | python | en | ['en', 'en', 'en'] | True |
_GetUniquePlatforms | (spec) | Returns the list of unique platforms for this spec, e.g ['win32', ...].
Arguments:
spec: The target dictionary containing the properties of the target.
Returns:
The MSVSUserFile object created.
| Returns the list of unique platforms for this spec, e.g ['win32', ...]. | def _GetUniquePlatforms(spec):
"""Returns the list of unique platforms for this spec, e.g ['win32', ...].
Arguments:
spec: The target dictionary containing the properties of the target.
Returns:
The MSVSUserFile object created.
"""
# Gather list of unique platforms.
platforms = OrderedSet()
... | [
"def",
"_GetUniquePlatforms",
"(",
"spec",
")",
":",
"# Gather list of unique platforms.",
"platforms",
"=",
"OrderedSet",
"(",
")",
"for",
"configuration",
"in",
"spec",
"[",
"\"configurations\"",
"]",
":",
"platforms",
".",
"add",
"(",
"_ConfigPlatform",
"(",
"s... | [
1093,
0
] | [
1106,
20
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.