repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
pjmark/NIMPA | niftypet/nimpa/prc/regseg.py | dice_coeff_multiclass | def dice_coeff_multiclass(im1, im2, roi2ind):
''' Calculate Dice score for parcellation images <im1> and <im2> and ROI value <val>.
Input images can be given as:
1. paths to NIfTI image files or as
2. Numpy arrays.
The ROI value must be given as a dictionary of lists of index... | python | def dice_coeff_multiclass(im1, im2, roi2ind):
''' Calculate Dice score for parcellation images <im1> and <im2> and ROI value <val>.
Input images can be given as:
1. paths to NIfTI image files or as
2. Numpy arrays.
The ROI value must be given as a dictionary of lists of index... | [
"def",
"dice_coeff_multiclass",
"(",
"im1",
",",
"im2",
",",
"roi2ind",
")",
":",
"if",
"isinstance",
"(",
"im1",
",",
"basestring",
")",
"and",
"isinstance",
"(",
"im2",
",",
"basestring",
")",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"im1",
")",... | Calculate Dice score for parcellation images <im1> and <im2> and ROI value <val>.
Input images can be given as:
1. paths to NIfTI image files or as
2. Numpy arrays.
The ROI value must be given as a dictionary of lists of indexes for each ROI
Outputs a float number represe... | [
"Calculate",
"Dice",
"score",
"for",
"parcellation",
"images",
"<im1",
">",
"and",
"<im2",
">",
"and",
"ROI",
"value",
"<val",
">",
".",
"Input",
"images",
"can",
"be",
"given",
"as",
":",
"1",
".",
"paths",
"to",
"NIfTI",
"image",
"files",
"or",
"as",... | train | https://github.com/pjmark/NIMPA/blob/3f4231fed2934a1d92e4cd8e9e153b0118e29d86/niftypet/nimpa/prc/regseg.py#L1166-L1204 |
MisterWil/skybellpy | skybellpy/utils.py | gen_token | def gen_token():
"""Generate a new Skybellpy token."""
return ''.join(
random.choice(
string.ascii_uppercase + string.ascii_lowercase + string.digits)
for _ in range(32)) | python | def gen_token():
"""Generate a new Skybellpy token."""
return ''.join(
random.choice(
string.ascii_uppercase + string.ascii_lowercase + string.digits)
for _ in range(32)) | [
"def",
"gen_token",
"(",
")",
":",
"return",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"string",
".",
"ascii_uppercase",
"+",
"string",
".",
"ascii_lowercase",
"+",
"string",
".",
"digits",
")",
"for",
"_",
"in",
"range",
"(",
"32",
")",
... | Generate a new Skybellpy token. | [
"Generate",
"a",
"new",
"Skybellpy",
"token",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/utils.py#L25-L30 |
MisterWil/skybellpy | skybellpy/device.py | _validate_setting | def _validate_setting(setting, value):
"""Validate the setting and value."""
if setting not in CONST.ALL_SETTINGS:
raise SkybellException(ERROR.INVALID_SETTING, setting)
if setting == CONST.SETTINGS_DO_NOT_DISTURB:
if value not in CONST.SETTINGS_DO_NOT_DISTURB_VALUES:
raise Skyb... | python | def _validate_setting(setting, value):
"""Validate the setting and value."""
if setting not in CONST.ALL_SETTINGS:
raise SkybellException(ERROR.INVALID_SETTING, setting)
if setting == CONST.SETTINGS_DO_NOT_DISTURB:
if value not in CONST.SETTINGS_DO_NOT_DISTURB_VALUES:
raise Skyb... | [
"def",
"_validate_setting",
"(",
"setting",
",",
"value",
")",
":",
"if",
"setting",
"not",
"in",
"CONST",
".",
"ALL_SETTINGS",
":",
"raise",
"SkybellException",
"(",
"ERROR",
".",
"INVALID_SETTING",
",",
"setting",
")",
"if",
"setting",
"==",
"CONST",
".",
... | Validate the setting and value. | [
"Validate",
"the",
"setting",
"and",
"value",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L342-L385 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice.refresh | def refresh(self):
"""Refresh the devices json object data."""
# Update core device data
new_device_json = self._device_request()
_LOGGER.debug("Device Refresh Response: %s", new_device_json)
# Update avatar url
new_avatar_json = self._avatar_request()
_LOGGER.de... | python | def refresh(self):
"""Refresh the devices json object data."""
# Update core device data
new_device_json = self._device_request()
_LOGGER.debug("Device Refresh Response: %s", new_device_json)
# Update avatar url
new_avatar_json = self._avatar_request()
_LOGGER.de... | [
"def",
"refresh",
"(",
"self",
")",
":",
"# Update core device data",
"new_device_json",
"=",
"self",
".",
"_device_request",
"(",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Device Refresh Response: %s\"",
",",
"new_device_json",
")",
"# Update avatar url",
"new_avatar_json"... | Refresh the devices json object data. | [
"Refresh",
"the",
"devices",
"json",
"object",
"data",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L31-L55 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice.update | def update(self, device_json=None, info_json=None, settings_json=None,
avatar_json=None):
"""Update the internal device json data."""
if device_json:
UTILS.update(self._device_json, device_json)
if avatar_json:
UTILS.update(self._avatar_json, avatar_json)
... | python | def update(self, device_json=None, info_json=None, settings_json=None,
avatar_json=None):
"""Update the internal device json data."""
if device_json:
UTILS.update(self._device_json, device_json)
if avatar_json:
UTILS.update(self._avatar_json, avatar_json)
... | [
"def",
"update",
"(",
"self",
",",
"device_json",
"=",
"None",
",",
"info_json",
"=",
"None",
",",
"settings_json",
"=",
"None",
",",
"avatar_json",
"=",
"None",
")",
":",
"if",
"device_json",
":",
"UTILS",
".",
"update",
"(",
"self",
".",
"_device_json"... | Update the internal device json data. | [
"Update",
"the",
"internal",
"device",
"json",
"data",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L85-L98 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice._update_activities | def _update_activities(self):
"""Update stored activities and update caches as required."""
self._activities = self._activities_request()
_LOGGER.debug("Device Activities Response: %s", self._activities)
if not self._activities:
self._activities = []
elif not isinsta... | python | def _update_activities(self):
"""Update stored activities and update caches as required."""
self._activities = self._activities_request()
_LOGGER.debug("Device Activities Response: %s", self._activities)
if not self._activities:
self._activities = []
elif not isinsta... | [
"def",
"_update_activities",
"(",
"self",
")",
":",
"self",
".",
"_activities",
"=",
"self",
".",
"_activities_request",
"(",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Device Activities Response: %s\"",
",",
"self",
".",
"_activities",
")",
"if",
"not",
"self",
".... | Update stored activities and update caches as required. | [
"Update",
"stored",
"activities",
"and",
"update",
"caches",
"as",
"required",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L100-L110 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice._update_events | def _update_events(self):
"""Update our cached list of latest activity events."""
events = self._skybell.dev_cache(self, CONST.EVENT) or {}
for activity in self._activities:
event = activity.get(CONST.EVENT)
created_at = activity.get(CONST.CREATED_AT)
old_ev... | python | def _update_events(self):
"""Update our cached list of latest activity events."""
events = self._skybell.dev_cache(self, CONST.EVENT) or {}
for activity in self._activities:
event = activity.get(CONST.EVENT)
created_at = activity.get(CONST.CREATED_AT)
old_ev... | [
"def",
"_update_events",
"(",
"self",
")",
":",
"events",
"=",
"self",
".",
"_skybell",
".",
"dev_cache",
"(",
"self",
",",
"CONST",
".",
"EVENT",
")",
"or",
"{",
"}",
"for",
"activity",
"in",
"self",
".",
"_activities",
":",
"event",
"=",
"activity",
... | Update our cached list of latest activity events. | [
"Update",
"our",
"cached",
"list",
"of",
"latest",
"activity",
"events",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L112-L131 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice.activities | def activities(self, limit=1, event=None):
"""Return device activity information."""
activities = self._activities or []
# Filter our activity array if requested
if event:
activities = list(
filter(
lambda activity:
act... | python | def activities(self, limit=1, event=None):
"""Return device activity information."""
activities = self._activities or []
# Filter our activity array if requested
if event:
activities = list(
filter(
lambda activity:
act... | [
"def",
"activities",
"(",
"self",
",",
"limit",
"=",
"1",
",",
"event",
"=",
"None",
")",
":",
"activities",
"=",
"self",
".",
"_activities",
"or",
"[",
"]",
"# Filter our activity array if requested",
"if",
"event",
":",
"activities",
"=",
"list",
"(",
"f... | Return device activity information. | [
"Return",
"device",
"activity",
"information",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L133-L145 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice._set_setting | def _set_setting(self, settings):
"""Validate the settings and then send the PATCH request."""
for key, value in settings.items():
_validate_setting(key, value)
try:
self._settings_request(method="patch", json_data=settings)
self.update(settings_json=setting... | python | def _set_setting(self, settings):
"""Validate the settings and then send the PATCH request."""
for key, value in settings.items():
_validate_setting(key, value)
try:
self._settings_request(method="patch", json_data=settings)
self.update(settings_json=setting... | [
"def",
"_set_setting",
"(",
"self",
",",
"settings",
")",
":",
"for",
"key",
",",
"value",
"in",
"settings",
".",
"items",
"(",
")",
":",
"_validate_setting",
"(",
"key",
",",
"value",
")",
"try",
":",
"self",
".",
"_settings_request",
"(",
"method",
"... | Validate the settings and then send the PATCH request. | [
"Validate",
"the",
"settings",
"and",
"then",
"send",
"the",
"PATCH",
"request",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L162-L173 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice.location | def location(self):
"""Return lat and lng tuple."""
location = self._device_json.get(CONST.LOCATION, {})
return (location.get(CONST.LOCATION_LAT, 0),
location.get(CONST.LOCATION_LNG, 0)) | python | def location(self):
"""Return lat and lng tuple."""
location = self._device_json.get(CONST.LOCATION, {})
return (location.get(CONST.LOCATION_LAT, 0),
location.get(CONST.LOCATION_LNG, 0)) | [
"def",
"location",
"(",
"self",
")",
":",
"location",
"=",
"self",
".",
"_device_json",
".",
"get",
"(",
"CONST",
".",
"LOCATION",
",",
"{",
"}",
")",
"return",
"(",
"location",
".",
"get",
"(",
"CONST",
".",
"LOCATION_LAT",
",",
"0",
")",
",",
"lo... | Return lat and lng tuple. | [
"Return",
"lat",
"and",
"lng",
"tuple",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L201-L206 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice.wifi_status | def wifi_status(self):
"""Get the wifi status."""
return self._info_json.get(CONST.STATUS, {}).get(CONST.WIFI_LINK) | python | def wifi_status(self):
"""Get the wifi status."""
return self._info_json.get(CONST.STATUS, {}).get(CONST.WIFI_LINK) | [
"def",
"wifi_status",
"(",
"self",
")",
":",
"return",
"self",
".",
"_info_json",
".",
"get",
"(",
"CONST",
".",
"STATUS",
",",
"{",
"}",
")",
".",
"get",
"(",
"CONST",
".",
"WIFI_LINK",
")"
] | Get the wifi status. | [
"Get",
"the",
"wifi",
"status",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L219-L221 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice.do_not_disturb | def do_not_disturb(self):
"""Get if do not disturb is enabled."""
return bool(strtobool(str(self._settings_json.get(
CONST.SETTINGS_DO_NOT_DISTURB)))) | python | def do_not_disturb(self):
"""Get if do not disturb is enabled."""
return bool(strtobool(str(self._settings_json.get(
CONST.SETTINGS_DO_NOT_DISTURB)))) | [
"def",
"do_not_disturb",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"strtobool",
"(",
"str",
"(",
"self",
".",
"_settings_json",
".",
"get",
"(",
"CONST",
".",
"SETTINGS_DO_NOT_DISTURB",
")",
")",
")",
")"
] | Get if do not disturb is enabled. | [
"Get",
"if",
"do",
"not",
"disturb",
"is",
"enabled",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L234-L237 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice.do_not_disturb | def do_not_disturb(self, enabled):
"""Set do not disturb."""
self._set_setting(
{
CONST.SETTINGS_DO_NOT_DISTURB: str(enabled).lower()
}) | python | def do_not_disturb(self, enabled):
"""Set do not disturb."""
self._set_setting(
{
CONST.SETTINGS_DO_NOT_DISTURB: str(enabled).lower()
}) | [
"def",
"do_not_disturb",
"(",
"self",
",",
"enabled",
")",
":",
"self",
".",
"_set_setting",
"(",
"{",
"CONST",
".",
"SETTINGS_DO_NOT_DISTURB",
":",
"str",
"(",
"enabled",
")",
".",
"lower",
"(",
")",
"}",
")"
] | Set do not disturb. | [
"Set",
"do",
"not",
"disturb",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L240-L245 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice.motion_sensor | def motion_sensor(self, enabled):
"""Set the motion sensor state."""
if enabled is True:
value = CONST.SETTINGS_MOTION_POLICY_ON
elif enabled is False:
value = CONST.SETTINGS_MOTION_POLICY_OFF
else:
raise SkybellException(ERROR.INVALID_SETTING_VALUE,
... | python | def motion_sensor(self, enabled):
"""Set the motion sensor state."""
if enabled is True:
value = CONST.SETTINGS_MOTION_POLICY_ON
elif enabled is False:
value = CONST.SETTINGS_MOTION_POLICY_OFF
else:
raise SkybellException(ERROR.INVALID_SETTING_VALUE,
... | [
"def",
"motion_sensor",
"(",
"self",
",",
"enabled",
")",
":",
"if",
"enabled",
"is",
"True",
":",
"value",
"=",
"CONST",
".",
"SETTINGS_MOTION_POLICY_ON",
"elif",
"enabled",
"is",
"False",
":",
"value",
"=",
"CONST",
".",
"SETTINGS_MOTION_POLICY_OFF",
"else",... | Set the motion sensor state. | [
"Set",
"the",
"motion",
"sensor",
"state",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L270-L280 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice.led_rgb | def led_rgb(self):
"""Get devices LED color."""
return (int(self._settings_json.get(CONST.SETTINGS_LED_R)),
int(self._settings_json.get(CONST.SETTINGS_LED_G)),
int(self._settings_json.get(CONST.SETTINGS_LED_B))) | python | def led_rgb(self):
"""Get devices LED color."""
return (int(self._settings_json.get(CONST.SETTINGS_LED_R)),
int(self._settings_json.get(CONST.SETTINGS_LED_G)),
int(self._settings_json.get(CONST.SETTINGS_LED_B))) | [
"def",
"led_rgb",
"(",
"self",
")",
":",
"return",
"(",
"int",
"(",
"self",
".",
"_settings_json",
".",
"get",
"(",
"CONST",
".",
"SETTINGS_LED_R",
")",
")",
",",
"int",
"(",
"self",
".",
"_settings_json",
".",
"get",
"(",
"CONST",
".",
"SETTINGS_LED_G... | Get devices LED color. | [
"Get",
"devices",
"LED",
"color",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L303-L307 |
MisterWil/skybellpy | skybellpy/device.py | SkybellDevice.led_rgb | def led_rgb(self, color):
"""Set devices LED color."""
if (not isinstance(color, (list, tuple)) or
not all(isinstance(item, int) for item in color)):
raise SkybellException(ERROR.COLOR_VALUE_NOT_VALID, color)
self._set_setting(
{
CONST.SET... | python | def led_rgb(self, color):
"""Set devices LED color."""
if (not isinstance(color, (list, tuple)) or
not all(isinstance(item, int) for item in color)):
raise SkybellException(ERROR.COLOR_VALUE_NOT_VALID, color)
self._set_setting(
{
CONST.SET... | [
"def",
"led_rgb",
"(",
"self",
",",
"color",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"color",
",",
"(",
"list",
",",
"tuple",
")",
")",
"or",
"not",
"all",
"(",
"isinstance",
"(",
"item",
",",
"int",
")",
"for",
"item",
"in",
"color",
")",... | Set devices LED color. | [
"Set",
"devices",
"LED",
"color",
"."
] | train | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L310-L321 |
sdss/sdss_access | python/sdss_access/sync/http.py | HttpAccess.remote | def remote(self, remote_base=None, username=None, password=None):
"""
Configures remote access
Parameters
----------
remote_base : str
base URL path for remote repository
username : str
user name for remote repository
password : str
... | python | def remote(self, remote_base=None, username=None, password=None):
"""
Configures remote access
Parameters
----------
remote_base : str
base URL path for remote repository
username : str
user name for remote repository
password : str
... | [
"def",
"remote",
"(",
"self",
",",
"remote_base",
"=",
"None",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"if",
"remote_base",
"is",
"not",
"None",
":",
"self",
".",
"remote_base",
"=",
"remote_base",
"self",
".",
"_remote",
... | Configures remote access
Parameters
----------
remote_base : str
base URL path for remote repository
username : str
user name for remote repository
password : str
password for local repository | [
"Configures",
"remote",
"access"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/sync/http.py#L34-L56 |
sdss/sdss_access | python/sdss_access/sync/http.py | HttpAccess.get | def get(self, filetype, **kwargs):
"""Returns file name, downloading if remote access configured.
Parameters
----------
filetype : str
type of file
keyword arguments :
keywords to fully specify path
Notes
-----
Path templates are... | python | def get(self, filetype, **kwargs):
"""Returns file name, downloading if remote access configured.
Parameters
----------
filetype : str
type of file
keyword arguments :
keywords to fully specify path
Notes
-----
Path templates are... | [
"def",
"get",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"self",
".",
"full",
"(",
"filetype",
",",
"*",
"*",
"kwargs",
")",
"if",
"path",
":",
"if",
"self",
".",
"_remote",
":",
"self",
".",
"download_url_to_path... | Returns file name, downloading if remote access configured.
Parameters
----------
filetype : str
type of file
keyword arguments :
keywords to fully specify path
Notes
-----
Path templates are defined in $DIMAGE_DIR/data/dimage_paths.ini | [
"Returns",
"file",
"name",
"downloading",
"if",
"remote",
"access",
"configured",
"."
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/sync/http.py#L63-L85 |
sdss/sdss_access | python/sdss_access/sync/http.py | HttpAccess.download_url_to_path | def download_url_to_path(self, url, path, force=False):
"""
Download a file from url via http, and put it at path
Parameters
----------
url : str
URL of file to download
path : str
local path to put file in
"""
path_exists = isf... | python | def download_url_to_path(self, url, path, force=False):
"""
Download a file from url via http, and put it at path
Parameters
----------
url : str
URL of file to download
path : str
local path to put file in
"""
path_exists = isf... | [
"def",
"download_url_to_path",
"(",
"self",
",",
"url",
",",
"path",
",",
"force",
"=",
"False",
")",
":",
"path_exists",
"=",
"isfile",
"(",
"path",
")",
"if",
"not",
"path_exists",
"or",
"force",
":",
"dir",
"=",
"dirname",
"(",
"path",
")",
"if",
... | Download a file from url via http, and put it at path
Parameters
----------
url : str
URL of file to download
path : str
local path to put file in | [
"Download",
"a",
"file",
"from",
"url",
"via",
"http",
"and",
"put",
"it",
"at",
"path"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/sync/http.py#L87-L144 |
sdss/sdss_access | python/sdss_access/sync/rsync.py | RsyncAccess.remote | def remote(self, username=None, password=None, inquire=None):
""" Configures remote access """
self.set_netloc(sdss=True) # simplifies things to have a single sdss machine in .netrc
self.set_auth(username=username, password=password, inquire=inquire)
self.set_netloc(dtn=not self.public... | python | def remote(self, username=None, password=None, inquire=None):
""" Configures remote access """
self.set_netloc(sdss=True) # simplifies things to have a single sdss machine in .netrc
self.set_auth(username=username, password=password, inquire=inquire)
self.set_netloc(dtn=not self.public... | [
"def",
"remote",
"(",
"self",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"inquire",
"=",
"None",
")",
":",
"self",
".",
"set_netloc",
"(",
"sdss",
"=",
"True",
")",
"# simplifies things to have a single sdss machine in .netrc",
"self",
".... | Configures remote access | [
"Configures",
"remote",
"access"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/sync/rsync.py#L28-L34 |
sdss/sdss_access | python/sdss_access/sync/rsync.py | RsyncAccess.reset | def reset(self):
''' Reset all streams '''
# reset the main stream
if self.stream:
self.stream.reset()
# reset the initial stream (otherwise old 'adds' remain in the new stream)
if self.initial_stream:
self.initial_stream.reset() | python | def reset(self):
''' Reset all streams '''
# reset the main stream
if self.stream:
self.stream.reset()
# reset the initial stream (otherwise old 'adds' remain in the new stream)
if self.initial_stream:
self.initial_stream.reset() | [
"def",
"reset",
"(",
"self",
")",
":",
"# reset the main stream",
"if",
"self",
".",
"stream",
":",
"self",
".",
"stream",
".",
"reset",
"(",
")",
"# reset the initial stream (otherwise old 'adds' remain in the new stream)",
"if",
"self",
".",
"initial_stream",
":",
... | Reset all streams | [
"Reset",
"all",
"streams"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/sync/rsync.py#L47-L56 |
sdss/sdss_access | python/sdss_access/sync/rsync.py | RsyncAccess.add | def add(self, filetype, **kwargs):
""" Adds a filepath into the list of tasks to download"""
location = self.location(filetype, **kwargs)
source = self.url(filetype, sasdir='sas' if not self.public else '', **kwargs)
if 'full' not in kwargs:
destination = self.full(filetype,... | python | def add(self, filetype, **kwargs):
""" Adds a filepath into the list of tasks to download"""
location = self.location(filetype, **kwargs)
source = self.url(filetype, sasdir='sas' if not self.public else '', **kwargs)
if 'full' not in kwargs:
destination = self.full(filetype,... | [
"def",
"add",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"location",
"=",
"self",
".",
"location",
"(",
"filetype",
",",
"*",
"*",
"kwargs",
")",
"source",
"=",
"self",
".",
"url",
"(",
"filetype",
",",
"sasdir",
"=",
"'sas'",... | Adds a filepath into the list of tasks to download | [
"Adds",
"a",
"filepath",
"into",
"the",
"list",
"of",
"tasks",
"to",
"download"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/sync/rsync.py#L58-L71 |
sdss/sdss_access | python/sdss_access/sync/rsync.py | RsyncAccess.set_stream | def set_stream(self):
""" Sets the download streams """
if not self.auth:
raise AccessError("Please use the remote() method to set rsync authorization or use remote(public=True) for public data")
elif not self.initial_stream.task:
raise AccessError("No files to download.... | python | def set_stream(self):
""" Sets the download streams """
if not self.auth:
raise AccessError("Please use the remote() method to set rsync authorization or use remote(public=True) for public data")
elif not self.initial_stream.task:
raise AccessError("No files to download.... | [
"def",
"set_stream",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"auth",
":",
"raise",
"AccessError",
"(",
"\"Please use the remote() method to set rsync authorization or use remote(public=True) for public data\"",
")",
"elif",
"not",
"self",
".",
"initial_stream",
"... | Sets the download streams | [
"Sets",
"the",
"download",
"streams"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/sync/rsync.py#L73-L93 |
sdss/sdss_access | python/sdss_access/sync/rsync.py | RsyncAccess.commit | def commit(self, offset=None, limit=None, dryrun=False):
""" Start the rsync download """
self.stream.command = "rsync -avRK --files-from={path} {source} {destination}"
self.stream.append_tasks_to_streamlets(offset=offset, limit=limit)
self.stream.commit_streamlets()
self.stream... | python | def commit(self, offset=None, limit=None, dryrun=False):
""" Start the rsync download """
self.stream.command = "rsync -avRK --files-from={path} {source} {destination}"
self.stream.append_tasks_to_streamlets(offset=offset, limit=limit)
self.stream.commit_streamlets()
self.stream... | [
"def",
"commit",
"(",
"self",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"dryrun",
"=",
"False",
")",
":",
"self",
".",
"stream",
".",
"command",
"=",
"\"rsync -avRK --files-from={path} {source} {destination}\"",
"self",
".",
"stream",
".",
... | Start the rsync download | [
"Start",
"the",
"rsync",
"download"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/sync/rsync.py#L160-L167 |
kajala/django-jacc | jacc/models.py | AccountEntry.balance | def balance(self) -> Decimal:
"""
Returns account balance after this entry.
:return: Decimal
"""
return sum_queryset(AccountEntry.objects.filter(account=self.account, timestamp__lte=self.timestamp).exclude(timestamp=self.timestamp, id__gt=self.id)) | python | def balance(self) -> Decimal:
"""
Returns account balance after this entry.
:return: Decimal
"""
return sum_queryset(AccountEntry.objects.filter(account=self.account, timestamp__lte=self.timestamp).exclude(timestamp=self.timestamp, id__gt=self.id)) | [
"def",
"balance",
"(",
"self",
")",
"->",
"Decimal",
":",
"return",
"sum_queryset",
"(",
"AccountEntry",
".",
"objects",
".",
"filter",
"(",
"account",
"=",
"self",
".",
"account",
",",
"timestamp__lte",
"=",
"self",
".",
"timestamp",
")",
".",
"exclude",
... | Returns account balance after this entry.
:return: Decimal | [
"Returns",
"account",
"balance",
"after",
"this",
"entry",
".",
":",
"return",
":",
"Decimal"
] | train | https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/models.py#L134-L139 |
kajala/django-jacc | jacc/models.py | Account.get_balance | def get_balance(self, t: datetime):
"""
Returns account balance before specified datetime (excluding entries on the datetime).
:param t: datetime
:return: Decimal
"""
return sum_queryset(self.accountentry_set.all().filter(timestamp__lt=t)) | python | def get_balance(self, t: datetime):
"""
Returns account balance before specified datetime (excluding entries on the datetime).
:param t: datetime
:return: Decimal
"""
return sum_queryset(self.accountentry_set.all().filter(timestamp__lt=t)) | [
"def",
"get_balance",
"(",
"self",
",",
"t",
":",
"datetime",
")",
":",
"return",
"sum_queryset",
"(",
"self",
".",
"accountentry_set",
".",
"all",
"(",
")",
".",
"filter",
"(",
"timestamp__lt",
"=",
"t",
")",
")"
] | Returns account balance before specified datetime (excluding entries on the datetime).
:param t: datetime
:return: Decimal | [
"Returns",
"account",
"balance",
"before",
"specified",
"datetime",
"(",
"excluding",
"entries",
"on",
"the",
"datetime",
")",
".",
":",
"param",
"t",
":",
"datetime",
":",
"return",
":",
"Decimal"
] | train | https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/models.py#L195-L201 |
kajala/django-jacc | jacc/models.py | Account.needs_settling | def needs_settling(self, e: AccountEntry) -> bool:
"""
Returns True if all of following conditions are True:
a) entry type is settlement
b) entry has been recorded to this account
c) invoice to be settled has been set
d) entry has not been settled (=child set empty)
... | python | def needs_settling(self, e: AccountEntry) -> bool:
"""
Returns True if all of following conditions are True:
a) entry type is settlement
b) entry has been recorded to this account
c) invoice to be settled has been set
d) entry has not been settled (=child set empty)
... | [
"def",
"needs_settling",
"(",
"self",
",",
"e",
":",
"AccountEntry",
")",
"->",
"bool",
":",
"return",
"e",
".",
"type",
"and",
"e",
".",
"type",
".",
"is_settlement",
"and",
"e",
".",
"account",
".",
"id",
"==",
"self",
".",
"id",
"and",
"e",
".",... | Returns True if all of following conditions are True:
a) entry type is settlement
b) entry has been recorded to this account
c) invoice to be settled has been set
d) entry has not been settled (=child set empty)
:param e: AccountEntry (settlement)
:return: bool | [
"Returns",
"True",
"if",
"all",
"of",
"following",
"conditions",
"are",
"True",
":",
"a",
")",
"entry",
"type",
"is",
"settlement",
"b",
")",
"entry",
"has",
"been",
"recorded",
"to",
"this",
"account",
"c",
")",
"invoice",
"to",
"be",
"settled",
"has",
... | train | https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/models.py#L203-L213 |
kajala/django-jacc | jacc/models.py | Invoice.receivables_account | def receivables_account(self) -> Account:
"""
Returns receivables account. Receivables account is assumed to be the one were invoice rows were recorded.
:return: Account or None
"""
row = AccountEntry.objects.filter(source_invoice=self).order_by('id').first()
return row.a... | python | def receivables_account(self) -> Account:
"""
Returns receivables account. Receivables account is assumed to be the one were invoice rows were recorded.
:return: Account or None
"""
row = AccountEntry.objects.filter(source_invoice=self).order_by('id').first()
return row.a... | [
"def",
"receivables_account",
"(",
"self",
")",
"->",
"Account",
":",
"row",
"=",
"AccountEntry",
".",
"objects",
".",
"filter",
"(",
"source_invoice",
"=",
"self",
")",
".",
"order_by",
"(",
"'id'",
")",
".",
"first",
"(",
")",
"return",
"row",
".",
"... | Returns receivables account. Receivables account is assumed to be the one were invoice rows were recorded.
:return: Account or None | [
"Returns",
"receivables",
"account",
".",
"Receivables",
"account",
"is",
"assumed",
"to",
"be",
"the",
"one",
"were",
"invoice",
"rows",
"were",
"recorded",
".",
":",
"return",
":",
"Account",
"or",
"None"
] | train | https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/models.py#L272-L278 |
kajala/django-jacc | jacc/models.py | Invoice.get_entries | def get_entries(self, acc: Account, cls=AccountEntry) -> QuerySet:
"""
Returns entries related to this invoice on specified account.
:param acc: Account
:param cls: AccountEntry class
:return: QuerySet
"""
return cls.objects.filter(Q(account=acc) & (Q(source_invoi... | python | def get_entries(self, acc: Account, cls=AccountEntry) -> QuerySet:
"""
Returns entries related to this invoice on specified account.
:param acc: Account
:param cls: AccountEntry class
:return: QuerySet
"""
return cls.objects.filter(Q(account=acc) & (Q(source_invoi... | [
"def",
"get_entries",
"(",
"self",
",",
"acc",
":",
"Account",
",",
"cls",
"=",
"AccountEntry",
")",
"->",
"QuerySet",
":",
"return",
"cls",
".",
"objects",
".",
"filter",
"(",
"Q",
"(",
"account",
"=",
"acc",
")",
"&",
"(",
"Q",
"(",
"source_invoice... | Returns entries related to this invoice on specified account.
:param acc: Account
:param cls: AccountEntry class
:return: QuerySet | [
"Returns",
"entries",
"related",
"to",
"this",
"invoice",
"on",
"specified",
"account",
".",
":",
"param",
"acc",
":",
"Account",
":",
"param",
"cls",
":",
"AccountEntry",
"class",
":",
"return",
":",
"QuerySet"
] | train | https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/models.py#L285-L292 |
kajala/django-jacc | jacc/models.py | Invoice.get_item_balances | def get_item_balances(self, acc: Account) -> list:
"""
Returns balances of items of the invoice.
:param acc: Account
:return: list (AccountEntry, Decimal) in item id order
"""
items = []
entries = self.get_entries(acc)
for item in entries.filter(source_inv... | python | def get_item_balances(self, acc: Account) -> list:
"""
Returns balances of items of the invoice.
:param acc: Account
:return: list (AccountEntry, Decimal) in item id order
"""
items = []
entries = self.get_entries(acc)
for item in entries.filter(source_inv... | [
"def",
"get_item_balances",
"(",
"self",
",",
"acc",
":",
"Account",
")",
"->",
"list",
":",
"items",
"=",
"[",
"]",
"entries",
"=",
"self",
".",
"get_entries",
"(",
"acc",
")",
"for",
"item",
"in",
"entries",
".",
"filter",
"(",
"source_invoice",
"=",... | Returns balances of items of the invoice.
:param acc: Account
:return: list (AccountEntry, Decimal) in item id order | [
"Returns",
"balances",
"of",
"items",
"of",
"the",
"invoice",
".",
":",
"param",
"acc",
":",
"Account",
":",
"return",
":",
"list",
"(",
"AccountEntry",
"Decimal",
")",
"in",
"item",
"id",
"order"
] | train | https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/models.py#L302-L315 |
kajala/django-jacc | jacc/models.py | Invoice.get_unpaid_items | def get_unpaid_items(self, acc: Account) -> list:
"""
Returns unpaid items of the invoice in payback priority order.
:param acc: Account
:return: list (AccountEntry, Decimal) in payback priority order
"""
unpaid_items = []
for item, bal in self.get_item_balances(a... | python | def get_unpaid_items(self, acc: Account) -> list:
"""
Returns unpaid items of the invoice in payback priority order.
:param acc: Account
:return: list (AccountEntry, Decimal) in payback priority order
"""
unpaid_items = []
for item, bal in self.get_item_balances(a... | [
"def",
"get_unpaid_items",
"(",
"self",
",",
"acc",
":",
"Account",
")",
"->",
"list",
":",
"unpaid_items",
"=",
"[",
"]",
"for",
"item",
",",
"bal",
"in",
"self",
".",
"get_item_balances",
"(",
"acc",
")",
":",
"assert",
"isinstance",
"(",
"item",
","... | Returns unpaid items of the invoice in payback priority order.
:param acc: Account
:return: list (AccountEntry, Decimal) in payback priority order | [
"Returns",
"unpaid",
"items",
"of",
"the",
"invoice",
"in",
"payback",
"priority",
"order",
".",
":",
"param",
"acc",
":",
"Account",
":",
"return",
":",
"list",
"(",
"AccountEntry",
"Decimal",
")",
"in",
"payback",
"priority",
"order"
] | train | https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/models.py#L317-L334 |
kpdyer/regex2dfa | third_party/re2/re2/make_unicode_groups.py | MakeRanges | def MakeRanges(codes):
"""Turn a list like [1,2,3,7,8,9] into a range list [[1,3], [7,9]]"""
ranges = []
last = -100
for c in codes:
if c == last+1:
ranges[-1][1] = c
else:
ranges.append([c, c])
last = c
return ranges | python | def MakeRanges(codes):
"""Turn a list like [1,2,3,7,8,9] into a range list [[1,3], [7,9]]"""
ranges = []
last = -100
for c in codes:
if c == last+1:
ranges[-1][1] = c
else:
ranges.append([c, c])
last = c
return ranges | [
"def",
"MakeRanges",
"(",
"codes",
")",
":",
"ranges",
"=",
"[",
"]",
"last",
"=",
"-",
"100",
"for",
"c",
"in",
"codes",
":",
"if",
"c",
"==",
"last",
"+",
"1",
":",
"ranges",
"[",
"-",
"1",
"]",
"[",
"1",
"]",
"=",
"c",
"else",
":",
"rang... | Turn a list like [1,2,3,7,8,9] into a range list [[1,3], [7,9]] | [
"Turn",
"a",
"list",
"like",
"[",
"1",
"2",
"3",
"7",
"8",
"9",
"]",
"into",
"a",
"range",
"list",
"[[",
"1",
"3",
"]",
"[",
"7",
"9",
"]]"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/make_unicode_groups.py#L30-L40 |
kpdyer/regex2dfa | third_party/re2/re2/make_unicode_groups.py | PrintRanges | def PrintRanges(type, name, ranges):
"""Print the ranges as an array of type named name."""
print "static const %s %s[] = {" % (type, name,)
for lo, hi in ranges:
print "\t{ %d, %d }," % (lo, hi)
print "};" | python | def PrintRanges(type, name, ranges):
"""Print the ranges as an array of type named name."""
print "static const %s %s[] = {" % (type, name,)
for lo, hi in ranges:
print "\t{ %d, %d }," % (lo, hi)
print "};" | [
"def",
"PrintRanges",
"(",
"type",
",",
"name",
",",
"ranges",
")",
":",
"print",
"\"static const %s %s[] = {\"",
"%",
"(",
"type",
",",
"name",
",",
")",
"for",
"lo",
",",
"hi",
"in",
"ranges",
":",
"print",
"\"\\t{ %d, %d },\"",
"%",
"(",
"lo",
",",
... | Print the ranges as an array of type named name. | [
"Print",
"the",
"ranges",
"as",
"an",
"array",
"of",
"type",
"named",
"name",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/make_unicode_groups.py#L42-L47 |
kpdyer/regex2dfa | third_party/re2/re2/make_unicode_groups.py | PrintGroup | def PrintGroup(name, codes):
"""Print the data structures for the group of codes.
Return a UGroup literal for the group."""
# See unicode_groups.h for a description of the data structure.
# Split codes into 16-bit ranges and 32-bit ranges.
range16 = MakeRanges([c for c in codes if c < 65536])
range32 = Ma... | python | def PrintGroup(name, codes):
"""Print the data structures for the group of codes.
Return a UGroup literal for the group."""
# See unicode_groups.h for a description of the data structure.
# Split codes into 16-bit ranges and 32-bit ranges.
range16 = MakeRanges([c for c in codes if c < 65536])
range32 = Ma... | [
"def",
"PrintGroup",
"(",
"name",
",",
"codes",
")",
":",
"# See unicode_groups.h for a description of the data structure.",
"# Split codes into 16-bit ranges and 32-bit ranges.",
"range16",
"=",
"MakeRanges",
"(",
"[",
"c",
"for",
"c",
"in",
"codes",
"if",
"c",
"<",
"6... | Print the data structures for the group of codes.
Return a UGroup literal for the group. | [
"Print",
"the",
"data",
"structures",
"for",
"the",
"group",
"of",
"codes",
".",
"Return",
"a",
"UGroup",
"literal",
"for",
"the",
"group",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/make_unicode_groups.py#L56-L92 |
kajala/django-jacc | jacc/settle.py | settle_assigned_invoice | def settle_assigned_invoice(receivables_account: Account, settlement: AccountEntry, cls, **kwargs) -> list:
"""
Finds unpaid items in the invoice and generates entries to receivables account.
Settlement is matched to invoice items based on entry types payback order.
Generated payment entries have 'paren... | python | def settle_assigned_invoice(receivables_account: Account, settlement: AccountEntry, cls, **kwargs) -> list:
"""
Finds unpaid items in the invoice and generates entries to receivables account.
Settlement is matched to invoice items based on entry types payback order.
Generated payment entries have 'paren... | [
"def",
"settle_assigned_invoice",
"(",
"receivables_account",
":",
"Account",
",",
"settlement",
":",
"AccountEntry",
",",
"cls",
",",
"*",
"*",
"kwargs",
")",
"->",
"list",
":",
"invoice",
"=",
"settlement",
".",
"settled_invoice",
"if",
"settlement",
".",
"a... | Finds unpaid items in the invoice and generates entries to receivables account.
Settlement is matched to invoice items based on entry types payback order.
Generated payment entries have 'parent' field pointing to settlement, so that
if settlement is (ever) deleted the payment entries will get deleted as wel... | [
"Finds",
"unpaid",
"items",
"in",
"the",
"invoice",
"and",
"generates",
"entries",
"to",
"receivables",
"account",
".",
"Settlement",
"is",
"matched",
"to",
"invoice",
"items",
"based",
"on",
"entry",
"types",
"payback",
"order",
".",
"Generated",
"payment",
"... | train | https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/settle.py#L11-L66 |
kajala/django-jacc | jacc/settle.py | settle_credit_note | def settle_credit_note(credit_note: Invoice, debit_note: Invoice, cls, account: Account, **kwargs) -> list:
"""
Settles credit note. Records settling account entries for both original invoice and the credit note
(negative entries for the credit note).
Default timestamp for account entries is 'created' t... | python | def settle_credit_note(credit_note: Invoice, debit_note: Invoice, cls, account: Account, **kwargs) -> list:
"""
Settles credit note. Records settling account entries for both original invoice and the credit note
(negative entries for the credit note).
Default timestamp for account entries is 'created' t... | [
"def",
"settle_credit_note",
"(",
"credit_note",
":",
"Invoice",
",",
"debit_note",
":",
"Invoice",
",",
"cls",
",",
"account",
":",
"Account",
",",
"*",
"*",
"kwargs",
")",
"->",
"list",
":",
"assert",
"isinstance",
"(",
"credit_note",
",",
"Invoice",
")"... | Settles credit note. Records settling account entries for both original invoice and the credit note
(negative entries for the credit note).
Default timestamp for account entries is 'created' time of the credit note, can be overriden by kwargs.
:param credit_note: Credit note to settle
:param debit_note:... | [
"Settles",
"credit",
"note",
".",
"Records",
"settling",
"account",
"entries",
"for",
"both",
"original",
"invoice",
"and",
"the",
"credit",
"note",
"(",
"negative",
"entries",
"for",
"the",
"credit",
"note",
")",
".",
"Default",
"timestamp",
"for",
"account",... | train | https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/settle.py#L70-L114 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath._input_templates | def _input_templates(self):
"""Read the path template file.
"""
foo = self._config.read([self._pathfile])
if len(foo) == 1:
for k, v in self._config.items('paths'):
self.templates[k] = v
else:
raise ValueError("Could not read {0}!".format(s... | python | def _input_templates(self):
"""Read the path template file.
"""
foo = self._config.read([self._pathfile])
if len(foo) == 1:
for k, v in self._config.items('paths'):
self.templates[k] = v
else:
raise ValueError("Could not read {0}!".format(s... | [
"def",
"_input_templates",
"(",
"self",
")",
":",
"foo",
"=",
"self",
".",
"_config",
".",
"read",
"(",
"[",
"self",
".",
"_pathfile",
"]",
")",
"if",
"len",
"(",
"foo",
")",
"==",
"1",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_config",
"... | Read the path template file. | [
"Read",
"the",
"path",
"template",
"file",
"."
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L69-L78 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.lookup_keys | def lookup_keys(self, name):
''' Lookup the keyword arguments needed for a given path name
Parameters:
name (str):
The name of the path
Returns:
A list of keywords needed for filepath generation
'''
assert name, 'Must specify a path nam... | python | def lookup_keys(self, name):
''' Lookup the keyword arguments needed for a given path name
Parameters:
name (str):
The name of the path
Returns:
A list of keywords needed for filepath generation
'''
assert name, 'Must specify a path nam... | [
"def",
"lookup_keys",
"(",
"self",
",",
"name",
")",
":",
"assert",
"name",
",",
"'Must specify a path name'",
"assert",
"name",
"in",
"self",
".",
"templates",
".",
"keys",
"(",
")",
",",
"'{0} must be defined in the path templates'",
".",
"format",
"(",
"name"... | Lookup the keyword arguments needed for a given path name
Parameters:
name (str):
The name of the path
Returns:
A list of keywords needed for filepath generation | [
"Lookup",
"the",
"keyword",
"arguments",
"needed",
"for",
"a",
"given",
"path",
"name"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L80-L103 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath._check_special_kwargs | def _check_special_kwargs(self, name):
''' check special functions for kwargs
Checks the content of the special functions (%methodname) for
any keyword arguments referenced within
Parameters:
name (str):
A path key name
Returns:
... | python | def _check_special_kwargs(self, name):
''' check special functions for kwargs
Checks the content of the special functions (%methodname) for
any keyword arguments referenced within
Parameters:
name (str):
A path key name
Returns:
... | [
"def",
"_check_special_kwargs",
"(",
"self",
",",
"name",
")",
":",
"keys",
"=",
"[",
"]",
"# find any %method names in the template string",
"functions",
"=",
"re",
".",
"findall",
"(",
"r\"\\%\\w+\"",
",",
"self",
".",
"templates",
"[",
"name",
"]",
")",
"if... | check special functions for kwargs
Checks the content of the special functions (%methodname) for
any keyword arguments referenced within
Parameters:
name (str):
A path key name
Returns:
A list of keyword arguments found in any special fu... | [
"check",
"special",
"functions",
"for",
"kwargs",
"Checks",
"the",
"content",
"of",
"the",
"special",
"functions",
"(",
"%methodname",
")",
"for",
"any",
"keyword",
"arguments",
"referenced",
"within"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L105-L134 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath._find_source | def _find_source(method):
''' find source code of a given method
Find and extract the source code of a given method in a module.
Uses inspect.findsource to get all source code and performs some
selection magic to identify method source code. Doing it this way
because in... | python | def _find_source(method):
''' find source code of a given method
Find and extract the source code of a given method in a module.
Uses inspect.findsource to get all source code and performs some
selection magic to identify method source code. Doing it this way
because in... | [
"def",
"_find_source",
"(",
"method",
")",
":",
"# get source code lines of entire module method is in",
"source",
"=",
"inspect",
".",
"findsource",
"(",
"method",
")",
"is_method",
"=",
"inspect",
".",
"ismethod",
"(",
"method",
")",
"# create single source code strin... | find source code of a given method
Find and extract the source code of a given method in a module.
Uses inspect.findsource to get all source code and performs some
selection magic to identify method source code. Doing it this way
because inspect.getsource returns wrong method.
... | [
"find",
"source",
"code",
"of",
"a",
"given",
"method",
"Find",
"and",
"extract",
"the",
"source",
"code",
"of",
"a",
"given",
"method",
"in",
"a",
"module",
".",
"Uses",
"inspect",
".",
"findsource",
"to",
"get",
"all",
"source",
"code",
"and",
"perform... | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L137-L175 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.extract | def extract(self, name, example):
''' Extract keywords from an example path '''
# if pathlib not available do nothing
if not pathlib:
return None
# ensure example is a string
if isinstance(example, pathlib.Path):
example = str(example)
assert isi... | python | def extract(self, name, example):
''' Extract keywords from an example path '''
# if pathlib not available do nothing
if not pathlib:
return None
# ensure example is a string
if isinstance(example, pathlib.Path):
example = str(example)
assert isi... | [
"def",
"extract",
"(",
"self",
",",
"name",
",",
"example",
")",
":",
"# if pathlib not available do nothing",
"if",
"not",
"pathlib",
":",
"return",
"None",
"# ensure example is a string",
"if",
"isinstance",
"(",
"example",
",",
"pathlib",
".",
"Path",
")",
":... | Extract keywords from an example path | [
"Extract",
"keywords",
"from",
"an",
"example",
"path"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L189-L261 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.dir | def dir(self, filetype, **kwargs):
"""Return the directory containing a file of a given type.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
dir : str
Directory containing the file.
"""
full = k... | python | def dir(self, filetype, **kwargs):
"""Return the directory containing a file of a given type.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
dir : str
Directory containing the file.
"""
full = k... | [
"def",
"dir",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"full",
"=",
"kwargs",
".",
"get",
"(",
"'full'",
",",
"None",
")",
"if",
"not",
"full",
":",
"full",
"=",
"self",
".",
"full",
"(",
"filetype",
",",
"*",
"*",
"kwar... | Return the directory containing a file of a given type.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
dir : str
Directory containing the file. | [
"Return",
"the",
"directory",
"containing",
"a",
"file",
"of",
"a",
"given",
"type",
"."
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L263-L281 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.name | def name(self, filetype, **kwargs):
"""Return the directory containing a file of a given type.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
name : str
Name of a file with no directory information.
"""
... | python | def name(self, filetype, **kwargs):
"""Return the directory containing a file of a given type.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
name : str
Name of a file with no directory information.
"""
... | [
"def",
"name",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"full",
"=",
"kwargs",
".",
"get",
"(",
"'full'",
",",
"None",
")",
"if",
"not",
"full",
":",
"full",
"=",
"self",
".",
"full",
"(",
"filetype",
",",
"*",
"*",
"kwa... | Return the directory containing a file of a given type.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
name : str
Name of a file with no directory information. | [
"Return",
"the",
"directory",
"containing",
"a",
"file",
"of",
"a",
"given",
"type",
"."
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L283-L301 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.exists | def exists(self, filetype, remote=None, **kwargs):
'''Checks if the given type of file exists locally
Parameters
----------
filetype : str
File type parameter.
remote : bool
If True, checks for remote existence of the file
Returns
------... | python | def exists(self, filetype, remote=None, **kwargs):
'''Checks if the given type of file exists locally
Parameters
----------
filetype : str
File type parameter.
remote : bool
If True, checks for remote existence of the file
Returns
------... | [
"def",
"exists",
"(",
"self",
",",
"filetype",
",",
"remote",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"full",
"=",
"kwargs",
".",
"get",
"(",
"'full'",
",",
"None",
")",
"if",
"not",
"full",
":",
"full",
"=",
"self",
".",
"full",
"(",
"... | Checks if the given type of file exists locally
Parameters
----------
filetype : str
File type parameter.
remote : bool
If True, checks for remote existence of the file
Returns
-------
exists : bool
Boolean indicating if the ... | [
"Checks",
"if",
"the",
"given",
"type",
"of",
"file",
"exists",
"locally"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L303-L335 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.expand | def expand(self, filetype, **kwargs):
''' Expand a wildcard path locally
Parameters
----------
filetype : str
File type parameter.
as_url: bool
Boolean to return SAS urls
refine: str
Regular expression string to filter the list of fi... | python | def expand(self, filetype, **kwargs):
''' Expand a wildcard path locally
Parameters
----------
filetype : str
File type parameter.
as_url: bool
Boolean to return SAS urls
refine: str
Regular expression string to filter the list of fi... | [
"def",
"expand",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"full",
"=",
"kwargs",
".",
"get",
"(",
"'full'",
",",
"None",
")",
"if",
"not",
"full",
":",
"full",
"=",
"self",
".",
"full",
"(",
"filetype",
",",
"*",
"*",
"k... | Expand a wildcard path locally
Parameters
----------
filetype : str
File type parameter.
as_url: bool
Boolean to return SAS urls
refine: str
Regular expression string to filter the list of files by
before random selection
... | [
"Expand",
"a",
"wildcard",
"path",
"locally"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L337-L375 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.any | def any(self, filetype, **kwargs):
''' Checks if the local directory contains any of the type of file
Parameters
----------
filetype : str
File type parameter.
Returns
-------
any : bool
Boolean indicating if the any files exist in the ex... | python | def any(self, filetype, **kwargs):
''' Checks if the local directory contains any of the type of file
Parameters
----------
filetype : str
File type parameter.
Returns
-------
any : bool
Boolean indicating if the any files exist in the ex... | [
"def",
"any",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"expanded_files",
"=",
"self",
".",
"expand",
"(",
"filetype",
",",
"*",
"*",
"kwargs",
")",
"return",
"any",
"(",
"expanded_files",
")"
] | Checks if the local directory contains any of the type of file
Parameters
----------
filetype : str
File type parameter.
Returns
-------
any : bool
Boolean indicating if the any files exist in the expanded path on disk. | [
"Checks",
"if",
"the",
"local",
"directory",
"contains",
"any",
"of",
"the",
"type",
"of",
"file"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L377-L392 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.one | def one(self, filetype, **kwargs):
''' Returns random one of the given type of file
Parameters
----------
filetype : str
File type parameter.
as_url: bool
Boolean to return SAS urls
refine: str
Regular expression string to filter the... | python | def one(self, filetype, **kwargs):
''' Returns random one of the given type of file
Parameters
----------
filetype : str
File type parameter.
as_url: bool
Boolean to return SAS urls
refine: str
Regular expression string to filter the... | [
"def",
"one",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"expanded_files",
"=",
"self",
".",
"expand",
"(",
"filetype",
",",
"*",
"*",
"kwargs",
")",
"isany",
"=",
"self",
".",
"any",
"(",
"filetype",
",",
"*",
"*",
"kwargs",
... | Returns random one of the given type of file
Parameters
----------
filetype : str
File type parameter.
as_url: bool
Boolean to return SAS urls
refine: str
Regular expression string to filter the list of files by
before random sel... | [
"Returns",
"random",
"one",
"of",
"the",
"given",
"type",
"of",
"file"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L394-L417 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.random | def random(self, filetype, **kwargs):
''' Returns random number of the given type of file
Parameters
----------
filetype : str
File type parameter.
num : int
The number of files to return
as_url: bool
Boolean to return SAS urls
... | python | def random(self, filetype, **kwargs):
''' Returns random number of the given type of file
Parameters
----------
filetype : str
File type parameter.
num : int
The number of files to return
as_url: bool
Boolean to return SAS urls
... | [
"def",
"random",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"expanded_files",
"=",
"self",
".",
"expand",
"(",
"filetype",
",",
"*",
"*",
"kwargs",
")",
"isany",
"=",
"self",
".",
"any",
"(",
"filetype",
",",
"*",
"*",
"kwargs... | Returns random number of the given type of file
Parameters
----------
filetype : str
File type parameter.
num : int
The number of files to return
as_url: bool
Boolean to return SAS urls
refine: str
Regular expression str... | [
"Returns",
"random",
"number",
"of",
"the",
"given",
"type",
"of",
"file"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L419-L451 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.refine | def refine(self, filelist, regex, filterdir='out', **kwargs):
''' Returns a list of files filterd by a regular expression
Parameters
----------
filelist : list
A list of files to filter on.
regex : str
The regular expression string to filter your list
... | python | def refine(self, filelist, regex, filterdir='out', **kwargs):
''' Returns a list of files filterd by a regular expression
Parameters
----------
filelist : list
A list of files to filter on.
regex : str
The regular expression string to filter your list
... | [
"def",
"refine",
"(",
"self",
",",
"filelist",
",",
"regex",
",",
"filterdir",
"=",
"'out'",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"filelist",
",",
"'Must provide a list of filenames to refine on'",
"assert",
"regex",
",",
"'Must provide a regular expression ... | Returns a list of files filterd by a regular expression
Parameters
----------
filelist : list
A list of files to filter on.
regex : str
The regular expression string to filter your list
filterdir: {'in', 'out'}
Indicates the filter to be inc... | [
"Returns",
"a",
"list",
"of",
"files",
"filterd",
"by",
"a",
"regular",
"expression"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L453-L485 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.full | def full(self, filetype, **kwargs):
"""Return the full name of a given type of file.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
full : str
The full path to the file.
"""
# check if full alre... | python | def full(self, filetype, **kwargs):
"""Return the full name of a given type of file.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
full : str
The full path to the file.
"""
# check if full alre... | [
"def",
"full",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"# check if full already in kwargs",
"if",
"'full'",
"in",
"kwargs",
":",
"return",
"kwargs",
".",
"get",
"(",
"'full'",
")",
"# check for filetype in template",
"assert",
"filetype"... | Return the full name of a given type of file.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
full : str
The full path to the file. | [
"Return",
"the",
"full",
"name",
"of",
"a",
"given",
"type",
"of",
"file",
"."
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L487-L530 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath._call_special_functions | def _call_special_functions(self, filetype, template, **kwargs):
''' Call the special functions found in a template path
Calls special functions indicated by %methodname found in the
sdss_paths.ini template file, and replaces the %location in the path
with the returned content.
... | python | def _call_special_functions(self, filetype, template, **kwargs):
''' Call the special functions found in a template path
Calls special functions indicated by %methodname found in the
sdss_paths.ini template file, and replaces the %location in the path
with the returned content.
... | [
"def",
"_call_special_functions",
"(",
"self",
",",
"filetype",
",",
"template",
",",
"*",
"*",
"kwargs",
")",
":",
"# Now call special functions as appropriate",
"functions",
"=",
"re",
".",
"findall",
"(",
"r\"\\%\\w+\"",
",",
"template",
")",
"if",
"not",
"fu... | Call the special functions found in a template path
Calls special functions indicated by %methodname found in the
sdss_paths.ini template file, and replaces the %location in the path
with the returned content.
Parameters:
filetype (str):
template name of fil... | [
"Call",
"the",
"special",
"functions",
"found",
"in",
"a",
"template",
"path"
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L532-L563 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.location | def location(self, filetype, base_dir=None, **kwargs):
"""Return the location of the relative sas path of a given type of file.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
full : str
The relative sas path to ... | python | def location(self, filetype, base_dir=None, **kwargs):
"""Return the location of the relative sas path of a given type of file.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
full : str
The relative sas path to ... | [
"def",
"location",
"(",
"self",
",",
"filetype",
",",
"base_dir",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"full",
"=",
"kwargs",
".",
"get",
"(",
"'full'",
",",
"None",
")",
"if",
"not",
"full",
":",
"full",
"=",
"self",
".",
"full",
"(",... | Return the location of the relative sas path of a given type of file.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
full : str
The relative sas path to the file. | [
"Return",
"the",
"location",
"of",
"the",
"relative",
"sas",
"path",
"of",
"a",
"given",
"type",
"of",
"file",
"."
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L584-L608 |
sdss/sdss_access | python/sdss_access/path/path.py | BasePath.url | def url(self, filetype, base_dir=None, sasdir='sas', **kwargs):
"""Return the url of a given type of file.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
full : str
The sas url to the file.
"""
... | python | def url(self, filetype, base_dir=None, sasdir='sas', **kwargs):
"""Return the url of a given type of file.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
full : str
The sas url to the file.
"""
... | [
"def",
"url",
"(",
"self",
",",
"filetype",
",",
"base_dir",
"=",
"None",
",",
"sasdir",
"=",
"'sas'",
",",
"*",
"*",
"kwargs",
")",
":",
"location",
"=",
"self",
".",
"location",
"(",
"filetype",
",",
"*",
"*",
"kwargs",
")",
"return",
"join",
"("... | Return the url of a given type of file.
Parameters
----------
filetype : str
File type parameter.
Returns
-------
full : str
The sas url to the file. | [
"Return",
"the",
"url",
"of",
"a",
"given",
"type",
"of",
"file",
"."
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L610-L625 |
sdss/sdss_access | python/sdss_access/path/path.py | Path.plateid6 | def plateid6(self, filetype, **kwargs):
"""Print plate ID, accounting for 5-6 digit plate IDs.
Parameters
----------
filetype : str
File type parameter.
plateid : int or str
Plate ID number. Will be converted to int internally.
Returns
-... | python | def plateid6(self, filetype, **kwargs):
"""Print plate ID, accounting for 5-6 digit plate IDs.
Parameters
----------
filetype : str
File type parameter.
plateid : int or str
Plate ID number. Will be converted to int internally.
Returns
-... | [
"def",
"plateid6",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"plateid",
"=",
"int",
"(",
"kwargs",
"[",
"'plateid'",
"]",
")",
"if",
"plateid",
"<",
"10000",
":",
"return",
"\"{:0>6d}\"",
".",
"format",
"(",
"plateid",
")",
"el... | Print plate ID, accounting for 5-6 digit plate IDs.
Parameters
----------
filetype : str
File type parameter.
plateid : int or str
Plate ID number. Will be converted to int internally.
Returns
-------
plateid6 : str
Plate ID ... | [
"Print",
"plate",
"ID",
"accounting",
"for",
"5",
"-",
"6",
"digit",
"plate",
"IDs",
"."
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L640-L659 |
sdss/sdss_access | python/sdss_access/path/path.py | Path.platedir | def platedir(self, filetype, **kwargs):
"""Returns plate subdirectory in :envvar:`PLATELIST_DIR` of the form: ``NNNNXX/NNNNNN``.
Parameters
----------
filetype : str
File type parameter.
plateid : int or str
Plate ID number. Will be converted to int inte... | python | def platedir(self, filetype, **kwargs):
"""Returns plate subdirectory in :envvar:`PLATELIST_DIR` of the form: ``NNNNXX/NNNNNN``.
Parameters
----------
filetype : str
File type parameter.
plateid : int or str
Plate ID number. Will be converted to int inte... | [
"def",
"platedir",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"plateid",
"=",
"int",
"(",
"kwargs",
"[",
"'plateid'",
"]",
")",
"plateid100",
"=",
"plateid",
"//",
"100",
"subdir",
"=",
"\"{:0>4d}\"",
".",
"format",
"(",
"plateid1... | Returns plate subdirectory in :envvar:`PLATELIST_DIR` of the form: ``NNNNXX/NNNNNN``.
Parameters
----------
filetype : str
File type parameter.
plateid : int or str
Plate ID number. Will be converted to int internally.
Returns
-------
pl... | [
"Returns",
"plate",
"subdirectory",
"in",
":",
"envvar",
":",
"PLATELIST_DIR",
"of",
"the",
"form",
":",
"NNNNXX",
"/",
"NNNNNN",
"."
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L661-L679 |
sdss/sdss_access | python/sdss_access/path/path.py | Path.spectrodir | def spectrodir(self, filetype, **kwargs):
"""Returns :envvar:`SPECTRO_REDUX` or :envvar:`BOSS_SPECTRO_REDUX`
depending on the value of `run2d`.
Parameters
----------
filetype : str
File type parameter.
run2d : int or str
2D Reduction ID.
... | python | def spectrodir(self, filetype, **kwargs):
"""Returns :envvar:`SPECTRO_REDUX` or :envvar:`BOSS_SPECTRO_REDUX`
depending on the value of `run2d`.
Parameters
----------
filetype : str
File type parameter.
run2d : int or str
2D Reduction ID.
... | [
"def",
"spectrodir",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"str",
"(",
"kwargs",
"[",
"'run2d'",
"]",
")",
"in",
"(",
"'26'",
",",
"'103'",
",",
"'104'",
")",
":",
"return",
"os",
".",
"environ",
"[",
"'SPECTRO_REDU... | Returns :envvar:`SPECTRO_REDUX` or :envvar:`BOSS_SPECTRO_REDUX`
depending on the value of `run2d`.
Parameters
----------
filetype : str
File type parameter.
run2d : int or str
2D Reduction ID.
Returns
-------
spectrodir : str
... | [
"Returns",
":",
"envvar",
":",
"SPECTRO_REDUX",
"or",
":",
"envvar",
":",
"BOSS_SPECTRO_REDUX",
"depending",
"on",
"the",
"value",
"of",
"run2d",
"."
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L681-L700 |
sdss/sdss_access | python/sdss_access/path/path.py | Path.definitiondir | def definitiondir(self, filetype, **kwargs):
"""Returns definition subdirectory in :envvar:`PLATELIST_DIR` of the form: ``NNNNXX``.
Parameters
----------
filetype : str
File type parameter.
designid : int or str
Design ID number. Will be converted to int... | python | def definitiondir(self, filetype, **kwargs):
"""Returns definition subdirectory in :envvar:`PLATELIST_DIR` of the form: ``NNNNXX``.
Parameters
----------
filetype : str
File type parameter.
designid : int or str
Design ID number. Will be converted to int... | [
"def",
"definitiondir",
"(",
"self",
",",
"filetype",
",",
"*",
"*",
"kwargs",
")",
":",
"designid",
"=",
"int",
"(",
"kwargs",
"[",
"'designid'",
"]",
")",
"designid100",
"=",
"designid",
"//",
"100",
"subdir",
"=",
"\"{:0>4d}\"",
".",
"format",
"(",
... | Returns definition subdirectory in :envvar:`PLATELIST_DIR` of the form: ``NNNNXX``.
Parameters
----------
filetype : str
File type parameter.
designid : int or str
Design ID number. Will be converted to int internally.
Returns
-------
de... | [
"Returns",
"definition",
"subdirectory",
"in",
":",
"envvar",
":",
"PLATELIST_DIR",
"of",
"the",
"form",
":",
"NNNNXX",
"."
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L702-L721 |
sdss/sdss_access | python/sdss_access/sync/cli.py | Cli.foreground_run | def foreground_run(self, command, test=False, logger=None, logall=False, message=None, outname=None, errname=None):
"""A convenient wrapper to log and perform system calls.
Parameters
----------
command : str
The system command to run. It will be split internally by shlex.s... | python | def foreground_run(self, command, test=False, logger=None, logall=False, message=None, outname=None, errname=None):
"""A convenient wrapper to log and perform system calls.
Parameters
----------
command : str
The system command to run. It will be split internally by shlex.s... | [
"def",
"foreground_run",
"(",
"self",
",",
"command",
",",
"test",
"=",
"False",
",",
"logger",
"=",
"None",
",",
"logall",
"=",
"False",
",",
"message",
"=",
"None",
",",
"outname",
"=",
"None",
",",
"errname",
"=",
"None",
")",
":",
"if",
"logger",... | A convenient wrapper to log and perform system calls.
Parameters
----------
command : str
The system command to run. It will be split internally by shlex.split().
test : bool, optional
Set this to true to not actually run the commands.
logger : logging.l... | [
"A",
"convenient",
"wrapper",
"to",
"log",
"and",
"perform",
"system",
"calls",
"."
] | train | https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/sync/cli.py#L81-L163 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | change | def change(ui, repo, *pats, **opts):
"""create, edit or delete a change list
Create, edit or delete a change list.
A change list is a group of files to be reviewed and submitted together,
plus a textual description of the change.
Change lists are referred to by simple alphanumeric names.
Changes must be reviewe... | python | def change(ui, repo, *pats, **opts):
"""create, edit or delete a change list
Create, edit or delete a change list.
A change list is a group of files to be reviewed and submitted together,
plus a textual description of the change.
Change lists are referred to by simple alphanumeric names.
Changes must be reviewe... | [
"def",
"change",
"(",
"ui",
",",
"repo",
",",
"*",
"pats",
",",
"*",
"*",
"opts",
")",
":",
"if",
"codereview_disabled",
":",
"raise",
"hg_util",
".",
"Abort",
"(",
"codereview_disabled",
")",
"dirty",
"=",
"{",
"}",
"if",
"len",
"(",
"pats",
")",
... | create, edit or delete a change list
Create, edit or delete a change list.
A change list is a group of files to be reviewed and submitted together,
plus a textual description of the change.
Change lists are referred to by simple alphanumeric names.
Changes must be reviewed before they can be submitted.
In the ... | [
"create",
"edit",
"or",
"delete",
"a",
"change",
"list"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1277-L1385 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | undo | def undo(ui, repo, clname, **opts):
"""undo the effect of a CL
Creates a new CL that undoes an earlier CL.
After creating the CL, opens the CL text for editing so that
you can add the reason for the undo to the description.
"""
if repo[None].branch() != "default":
raise hg_util.Abort("cannot run hg undo outsi... | python | def undo(ui, repo, clname, **opts):
"""undo the effect of a CL
Creates a new CL that undoes an earlier CL.
After creating the CL, opens the CL text for editing so that
you can add the reason for the undo to the description.
"""
if repo[None].branch() != "default":
raise hg_util.Abort("cannot run hg undo outsi... | [
"def",
"undo",
"(",
"ui",
",",
"repo",
",",
"clname",
",",
"*",
"*",
"opts",
")",
":",
"if",
"repo",
"[",
"None",
"]",
".",
"branch",
"(",
")",
"!=",
"\"default\"",
":",
"raise",
"hg_util",
".",
"Abort",
"(",
"\"cannot run hg undo outside default branch\... | undo the effect of a CL
Creates a new CL that undoes an earlier CL.
After creating the CL, opens the CL text for editing so that
you can add the reason for the undo to the description. | [
"undo",
"the",
"effect",
"of",
"a",
"CL",
"Creates",
"a",
"new",
"CL",
"that",
"undoes",
"an",
"earlier",
"CL",
".",
"After",
"creating",
"the",
"CL",
"opens",
"the",
"CL",
"text",
"for",
"editing",
"so",
"that",
"you",
"can",
"add",
"the",
"reason",
... | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1424-L1435 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | release_apply | def release_apply(ui, repo, clname, **opts):
"""apply a CL to the release branch
Creates a new CL copying a previously committed change
from the main branch to the release branch.
The current client must either be clean or already be in
the release branch.
The release branch must be created by starting with a
... | python | def release_apply(ui, repo, clname, **opts):
"""apply a CL to the release branch
Creates a new CL copying a previously committed change
from the main branch to the release branch.
The current client must either be clean or already be in
the release branch.
The release branch must be created by starting with a
... | [
"def",
"release_apply",
"(",
"ui",
",",
"repo",
",",
"clname",
",",
"*",
"*",
"opts",
")",
":",
"c",
"=",
"repo",
"[",
"None",
"]",
"if",
"not",
"releaseBranch",
":",
"raise",
"hg_util",
".",
"Abort",
"(",
"\"no active release branches\"",
")",
"if",
"... | apply a CL to the release branch
Creates a new CL copying a previously committed change
from the main branch to the release branch.
The current client must either be clean or already be in
the release branch.
The release branch must be created by starting with a
clean client, disabling the code review plugin, ... | [
"apply",
"a",
"CL",
"to",
"the",
"release",
"branch"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1438-L1492 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | download | def download(ui, repo, clname, **opts):
"""download a change from the code review server
Download prints a description of the given change list
followed by its diff, downloaded from the code review server.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
cl, vers, patch, err = DownloadCL(u... | python | def download(ui, repo, clname, **opts):
"""download a change from the code review server
Download prints a description of the given change list
followed by its diff, downloaded from the code review server.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
cl, vers, patch, err = DownloadCL(u... | [
"def",
"download",
"(",
"ui",
",",
"repo",
",",
"clname",
",",
"*",
"*",
"opts",
")",
":",
"if",
"codereview_disabled",
":",
"raise",
"hg_util",
".",
"Abort",
"(",
"codereview_disabled",
")",
"cl",
",",
"vers",
",",
"patch",
",",
"err",
"=",
"DownloadC... | download a change from the code review server
Download prints a description of the given change list
followed by its diff, downloaded from the code review server. | [
"download",
"a",
"change",
"from",
"the",
"code",
"review",
"server"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1690-L1704 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | file | def file(ui, repo, clname, pat, *pats, **opts):
"""assign files to or remove files from a change list
Assign files to or (with -d) remove files from a change list.
The -d option only removes files from the change list.
It does not edit them or remove them from the repository.
"""
if codereview_disabled:
raise... | python | def file(ui, repo, clname, pat, *pats, **opts):
"""assign files to or remove files from a change list
Assign files to or (with -d) remove files from a change list.
The -d option only removes files from the change list.
It does not edit them or remove them from the repository.
"""
if codereview_disabled:
raise... | [
"def",
"file",
"(",
"ui",
",",
"repo",
",",
"clname",
",",
"pat",
",",
"*",
"pats",
",",
"*",
"*",
"opts",
")",
":",
"if",
"codereview_disabled",
":",
"raise",
"hg_util",
".",
"Abort",
"(",
"codereview_disabled",
")",
"pats",
"=",
"tuple",
"(",
"[",
... | assign files to or remove files from a change list
Assign files to or (with -d) remove files from a change list.
The -d option only removes files from the change list.
It does not edit them or remove them from the repository. | [
"assign",
"files",
"to",
"or",
"remove",
"files",
"from",
"a",
"change",
"list"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1710-L1770 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | gofmt | def gofmt(ui, repo, *pats, **opts):
"""apply gofmt to modified files
Applies gofmt to the modified files in the repository that match
the given patterns.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
files = ChangedExistingFiles(ui, repo, pats, opts)
files = gofmt_required(files)
if n... | python | def gofmt(ui, repo, *pats, **opts):
"""apply gofmt to modified files
Applies gofmt to the modified files in the repository that match
the given patterns.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
files = ChangedExistingFiles(ui, repo, pats, opts)
files = gofmt_required(files)
if n... | [
"def",
"gofmt",
"(",
"ui",
",",
"repo",
",",
"*",
"pats",
",",
"*",
"*",
"opts",
")",
":",
"if",
"codereview_disabled",
":",
"raise",
"hg_util",
".",
"Abort",
"(",
"codereview_disabled",
")",
"files",
"=",
"ChangedExistingFiles",
"(",
"ui",
",",
"repo",
... | apply gofmt to modified files
Applies gofmt to the modified files in the repository that match
the given patterns. | [
"apply",
"gofmt",
"to",
"modified",
"files"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1776-L1802 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | mail | def mail(ui, repo, *pats, **opts):
"""mail a change for review
Uploads a patch to the code review server and then sends mail
to the reviewer and CC list asking for a review.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
cl, err = CommandLineCL(ui, repo, pats, opts, op="mail", defaultcc=... | python | def mail(ui, repo, *pats, **opts):
"""mail a change for review
Uploads a patch to the code review server and then sends mail
to the reviewer and CC list asking for a review.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
cl, err = CommandLineCL(ui, repo, pats, opts, op="mail", defaultcc=... | [
"def",
"mail",
"(",
"ui",
",",
"repo",
",",
"*",
"pats",
",",
"*",
"*",
"opts",
")",
":",
"if",
"codereview_disabled",
":",
"raise",
"hg_util",
".",
"Abort",
"(",
"codereview_disabled",
")",
"cl",
",",
"err",
"=",
"CommandLineCL",
"(",
"ui",
",",
"re... | mail a change for review
Uploads a patch to the code review server and then sends mail
to the reviewer and CC list asking for a review. | [
"mail",
"a",
"change",
"for",
"review"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1811-L1838 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | ps | def ps(ui, repo, *pats, **opts):
"""alias for hg p --short
"""
opts['short'] = True
return pending(ui, repo, *pats, **opts) | python | def ps(ui, repo, *pats, **opts):
"""alias for hg p --short
"""
opts['short'] = True
return pending(ui, repo, *pats, **opts) | [
"def",
"ps",
"(",
"ui",
",",
"repo",
",",
"*",
"pats",
",",
"*",
"*",
"opts",
")",
":",
"opts",
"[",
"'short'",
"]",
"=",
"True",
"return",
"pending",
"(",
"ui",
",",
"repo",
",",
"*",
"pats",
",",
"*",
"*",
"opts",
")"
] | alias for hg p --short | [
"alias",
"for",
"hg",
"p",
"--",
"short"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1844-L1848 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | pq | def pq(ui, repo, *pats, **opts):
"""alias for hg p --quick
"""
opts['quick'] = True
return pending(ui, repo, *pats, **opts) | python | def pq(ui, repo, *pats, **opts):
"""alias for hg p --quick
"""
opts['quick'] = True
return pending(ui, repo, *pats, **opts) | [
"def",
"pq",
"(",
"ui",
",",
"repo",
",",
"*",
"pats",
",",
"*",
"*",
"opts",
")",
":",
"opts",
"[",
"'quick'",
"]",
"=",
"True",
"return",
"pending",
"(",
"ui",
",",
"repo",
",",
"*",
"pats",
",",
"*",
"*",
"opts",
")"
] | alias for hg p --quick | [
"alias",
"for",
"hg",
"p",
"--",
"quick"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1851-L1855 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | pending | def pending(ui, repo, *pats, **opts):
"""show pending changes
Lists pending changes followed by a list of unassigned but modified files.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
quick = opts.get('quick', False)
short = opts.get('short', False)
m = LoadAllCL(ui, repo, web=not quick... | python | def pending(ui, repo, *pats, **opts):
"""show pending changes
Lists pending changes followed by a list of unassigned but modified files.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
quick = opts.get('quick', False)
short = opts.get('short', False)
m = LoadAllCL(ui, repo, web=not quick... | [
"def",
"pending",
"(",
"ui",
",",
"repo",
",",
"*",
"pats",
",",
"*",
"*",
"opts",
")",
":",
"if",
"codereview_disabled",
":",
"raise",
"hg_util",
".",
"Abort",
"(",
"codereview_disabled",
")",
"quick",
"=",
"opts",
".",
"get",
"(",
"'quick'",
",",
"... | show pending changes
Lists pending changes followed by a list of unassigned but modified files. | [
"show",
"pending",
"changes"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1858-L1885 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | submit | def submit(ui, repo, *pats, **opts):
"""submit change to remote repository
Submits change to remote repository.
Bails out if the local repository is not in sync with the remote one.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
# We already called this on startup but sometimes Mercurial... | python | def submit(ui, repo, *pats, **opts):
"""submit change to remote repository
Submits change to remote repository.
Bails out if the local repository is not in sync with the remote one.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
# We already called this on startup but sometimes Mercurial... | [
"def",
"submit",
"(",
"ui",
",",
"repo",
",",
"*",
"pats",
",",
"*",
"*",
"opts",
")",
":",
"if",
"codereview_disabled",
":",
"raise",
"hg_util",
".",
"Abort",
"(",
"codereview_disabled",
")",
"# We already called this on startup but sometimes Mercurial forgets.",
... | submit change to remote repository
Submits change to remote repository.
Bails out if the local repository is not in sync with the remote one. | [
"submit",
"change",
"to",
"remote",
"repository"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1894-L2025 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | sync | def sync(ui, repo, **opts):
"""synchronize with remote repository
Incorporates recent changes from the remote repository
into the local repository.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
if not opts["local"]:
# If there are incoming CLs, pull -u will do the update.
# If there... | python | def sync(ui, repo, **opts):
"""synchronize with remote repository
Incorporates recent changes from the remote repository
into the local repository.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
if not opts["local"]:
# If there are incoming CLs, pull -u will do the update.
# If there... | [
"def",
"sync",
"(",
"ui",
",",
"repo",
",",
"*",
"*",
"opts",
")",
":",
"if",
"codereview_disabled",
":",
"raise",
"hg_util",
".",
"Abort",
"(",
"codereview_disabled",
")",
"if",
"not",
"opts",
"[",
"\"local\"",
"]",
":",
"# If there are incoming CLs, pull -... | synchronize with remote repository
Incorporates recent changes from the remote repository
into the local repository. | [
"synchronize",
"with",
"remote",
"repository"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L2031-L2056 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | upload | def upload(ui, repo, name, **opts):
"""upload diffs to the code review server
Uploads the current modifications for a given change to the server.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
repo.ui.quiet = True
cl, err = LoadCL(ui, repo, name, web=True)
if err != "":
raise hg_util.... | python | def upload(ui, repo, name, **opts):
"""upload diffs to the code review server
Uploads the current modifications for a given change to the server.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
repo.ui.quiet = True
cl, err = LoadCL(ui, repo, name, web=True)
if err != "":
raise hg_util.... | [
"def",
"upload",
"(",
"ui",
",",
"repo",
",",
"name",
",",
"*",
"*",
"opts",
")",
":",
"if",
"codereview_disabled",
":",
"raise",
"hg_util",
".",
"Abort",
"(",
"codereview_disabled",
")",
"repo",
".",
"ui",
".",
"quiet",
"=",
"True",
"cl",
",",
"err"... | upload diffs to the code review server
Uploads the current modifications for a given change to the server. | [
"upload",
"diffs",
"to",
"the",
"code",
"review",
"server"
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L2097-L2113 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | MySend | def MySend(request_path, payload=None,
content_type="application/octet-stream",
timeout=None, force_auth=True,
**kwargs):
"""Run MySend1 maybe twice, because Rietveld is unreliable."""
try:
return MySend1(request_path, payload, content_type, timeout, force_auth, **kwargs)
except Exception, e:
if type(e) !=... | python | def MySend(request_path, payload=None,
content_type="application/octet-stream",
timeout=None, force_auth=True,
**kwargs):
"""Run MySend1 maybe twice, because Rietveld is unreliable."""
try:
return MySend1(request_path, payload, content_type, timeout, force_auth, **kwargs)
except Exception, e:
if type(e) !=... | [
"def",
"MySend",
"(",
"request_path",
",",
"payload",
"=",
"None",
",",
"content_type",
"=",
"\"application/octet-stream\"",
",",
"timeout",
"=",
"None",
",",
"force_auth",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"MySend1",
"(... | Run MySend1 maybe twice, because Rietveld is unreliable. | [
"Run",
"MySend1",
"maybe",
"twice",
"because",
"Rietveld",
"is",
"unreliable",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L2444-L2456 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | MySend1 | def MySend1(request_path, payload=None,
content_type="application/octet-stream",
timeout=None, force_auth=True,
**kwargs):
"""Sends an RPC and returns the response.
Args:
request_path: The path to send the request to, eg /api/appversion/create.
payload: The body of the request, or None to send an emp... | python | def MySend1(request_path, payload=None,
content_type="application/octet-stream",
timeout=None, force_auth=True,
**kwargs):
"""Sends an RPC and returns the response.
Args:
request_path: The path to send the request to, eg /api/appversion/create.
payload: The body of the request, or None to send an emp... | [
"def",
"MySend1",
"(",
"request_path",
",",
"payload",
"=",
"None",
",",
"content_type",
"=",
"\"application/octet-stream\"",
",",
"timeout",
"=",
"None",
",",
"force_auth",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: Don't require authentication. Le... | Sends an RPC and returns the response.
Args:
request_path: The path to send the request to, eg /api/appversion/create.
payload: The body of the request, or None to send an empty request.
content_type: The Content-Type header to use.
timeout: timeout in seconds; default None i.e. no timeout.
(Note: for larg... | [
"Sends",
"an",
"RPC",
"and",
"returns",
"the",
"response",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L2461-L2527 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | GetEmail | def GetEmail(prompt):
"""Prompts the user for their email address and returns it.
The last used email address is saved to a file and offered up as a suggestion
to the user. If the user presses enter without typing in anything the last
used email address is used. If the user enters a new address, it is saved
for n... | python | def GetEmail(prompt):
"""Prompts the user for their email address and returns it.
The last used email address is saved to a file and offered up as a suggestion
to the user. If the user presses enter without typing in anything the last
used email address is used. If the user enters a new address, it is saved
for n... | [
"def",
"GetEmail",
"(",
"prompt",
")",
":",
"last_email_file_name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~/.last_codereview_email_address\"",
")",
"last_email",
"=",
"\"\"",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"last_email_file_name",
")",
... | Prompts the user for their email address and returns it.
The last used email address is saved to a file and offered up as a suggestion
to the user. If the user presses enter without typing in anything the last
used email address is used. If the user enters a new address, it is saved
for next time we prompt. | [
"Prompts",
"the",
"user",
"for",
"their",
"email",
"address",
"and",
"returns",
"it",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L2729-L2758 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | GetRpcServer | def GetRpcServer(options):
"""Returns an instance of an AbstractRpcServer.
Returns:
A new AbstractRpcServer, on which RPC calls can be made.
"""
rpc_server_class = HttpRpcServer
def GetUserCredentials():
"""Prompts the user for a username and password."""
# Disable status prints so they don't obscure the ... | python | def GetRpcServer(options):
"""Returns an instance of an AbstractRpcServer.
Returns:
A new AbstractRpcServer, on which RPC calls can be made.
"""
rpc_server_class = HttpRpcServer
def GetUserCredentials():
"""Prompts the user for a username and password."""
# Disable status prints so they don't obscure the ... | [
"def",
"GetRpcServer",
"(",
"options",
")",
":",
"rpc_server_class",
"=",
"HttpRpcServer",
"def",
"GetUserCredentials",
"(",
")",
":",
"\"\"\"Prompts the user for a username and password.\"\"\"",
"# Disable status prints so they don't obscure the password prompt.",
"global",
"globa... | Returns an instance of an AbstractRpcServer.
Returns:
A new AbstractRpcServer, on which RPC calls can be made. | [
"Returns",
"an",
"instance",
"of",
"an",
"AbstractRpcServer",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3048-L3091 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | EncodeMultipartFormData | def EncodeMultipartFormData(fields, files):
"""Encode form fields for multipart/form-data.
Args:
fields: A sequence of (name, value) elements for regular form fields.
files: A sequence of (name, filename, value) elements for data to be
uploaded as files.
Returns:
(content_type, body) ready for httplib.HT... | python | def EncodeMultipartFormData(fields, files):
"""Encode form fields for multipart/form-data.
Args:
fields: A sequence of (name, value) elements for regular form fields.
files: A sequence of (name, filename, value) elements for data to be
uploaded as files.
Returns:
(content_type, body) ready for httplib.HT... | [
"def",
"EncodeMultipartFormData",
"(",
"fields",
",",
"files",
")",
":",
"BOUNDARY",
"=",
"'-M-A-G-I-C---B-O-U-N-D-A-R-Y-'",
"CRLF",
"=",
"'\\r\\n'",
"lines",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"value",
")",
"in",
"fields",
":",
"typecheck",
"(",
"key",
... | Encode form fields for multipart/form-data.
Args:
fields: A sequence of (name, value) elements for regular form fields.
files: A sequence of (name, filename, value) elements for data to be
uploaded as files.
Returns:
(content_type, body) ready for httplib.HTTP instance.
Source:
http://aspn.activestate... | [
"Encode",
"form",
"fields",
"for",
"multipart",
"/",
"form",
"-",
"data",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3094-L3130 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | RunShellWithReturnCode | def RunShellWithReturnCode(command, print_output=False,
universal_newlines=True, env=os.environ):
"""Executes a command and returns the output from stdout and the return code.
Args:
command: Command to execute.
print_output: If True, the output is printed to stdout.
If False, both stdout and stderr are igno... | python | def RunShellWithReturnCode(command, print_output=False,
universal_newlines=True, env=os.environ):
"""Executes a command and returns the output from stdout and the return code.
Args:
command: Command to execute.
print_output: If True, the output is printed to stdout.
If False, both stdout and stderr are igno... | [
"def",
"RunShellWithReturnCode",
"(",
"command",
",",
"print_output",
"=",
"False",
",",
"universal_newlines",
"=",
"True",
",",
"env",
"=",
"os",
".",
"environ",
")",
":",
"logging",
".",
"info",
"(",
"\"Running %s\"",
",",
"command",
")",
"p",
"=",
"subp... | Executes a command and returns the output from stdout and the return code.
Args:
command: Command to execute.
print_output: If True, the output is printed to stdout.
If False, both stdout and stderr are ignored.
universal_newlines: Use universal_newlines flag (default: True).
Returns:
Tuple (output, retu... | [
"Executes",
"a",
"command",
"and",
"returns",
"the",
"output",
"from",
"stdout",
"and",
"the",
"return",
"code",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3141-L3174 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | SplitPatch | def SplitPatch(data):
"""Splits a patch into separate pieces for each file.
Args:
data: A string containing the output of svn diff.
Returns:
A list of 2-tuple (filename, text) where text is the svn diff output
pertaining to filename.
"""
patches = []
filename = None
diff = []
for line in data.splitline... | python | def SplitPatch(data):
"""Splits a patch into separate pieces for each file.
Args:
data: A string containing the output of svn diff.
Returns:
A list of 2-tuple (filename, text) where text is the svn diff output
pertaining to filename.
"""
patches = []
filename = None
diff = []
for line in data.splitline... | [
"def",
"SplitPatch",
"(",
"data",
")",
":",
"patches",
"=",
"[",
"]",
"filename",
"=",
"None",
"diff",
"=",
"[",
"]",
"for",
"line",
"in",
"data",
".",
"splitlines",
"(",
"True",
")",
":",
"new_filename",
"=",
"None",
"if",
"line",
".",
"startswith",... | Splits a patch into separate pieces for each file.
Args:
data: A string containing the output of svn diff.
Returns:
A list of 2-tuple (filename, text) where text is the svn diff output
pertaining to filename. | [
"Splits",
"a",
"patch",
"into",
"separate",
"pieces",
"for",
"each",
"file",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3525-L3562 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | UploadSeparatePatches | def UploadSeparatePatches(issue, rpc_server, patchset, data, options):
"""Uploads a separate patch for each file in the diff output.
Returns a list of [patch_key, filename] for each file.
"""
patches = SplitPatch(data)
rv = []
for patch in patches:
set_status("uploading patch for " + patch[0])
if len(patch[1... | python | def UploadSeparatePatches(issue, rpc_server, patchset, data, options):
"""Uploads a separate patch for each file in the diff output.
Returns a list of [patch_key, filename] for each file.
"""
patches = SplitPatch(data)
rv = []
for patch in patches:
set_status("uploading patch for " + patch[0])
if len(patch[1... | [
"def",
"UploadSeparatePatches",
"(",
"issue",
",",
"rpc_server",
",",
"patchset",
",",
"data",
",",
"options",
")",
":",
"patches",
"=",
"SplitPatch",
"(",
"data",
")",
"rv",
"=",
"[",
"]",
"for",
"patch",
"in",
"patches",
":",
"set_status",
"(",
"\"uplo... | Uploads a separate patch for each file in the diff output.
Returns a list of [patch_key, filename] for each file. | [
"Uploads",
"a",
"separate",
"patch",
"for",
"each",
"file",
"in",
"the",
"diff",
"output",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3565-L3591 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | AbstractRpcServer._CreateRequest | def _CreateRequest(self, url, data=None):
"""Creates a new urllib request."""
logging.debug("Creating request for: '%s' with payload:\n%s", url, data)
req = urllib2.Request(url, data=data)
if self.host_override:
req.add_header("Host", self.host_override)
for key, value in self.extra_headers.iteritems():
... | python | def _CreateRequest(self, url, data=None):
"""Creates a new urllib request."""
logging.debug("Creating request for: '%s' with payload:\n%s", url, data)
req = urllib2.Request(url, data=data)
if self.host_override:
req.add_header("Host", self.host_override)
for key, value in self.extra_headers.iteritems():
... | [
"def",
"_CreateRequest",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
")",
":",
"logging",
".",
"debug",
"(",
"\"Creating request for: '%s' with payload:\\n%s\"",
",",
"url",
",",
"data",
")",
"req",
"=",
"urllib2",
".",
"Request",
"(",
"url",
",",
"... | Creates a new urllib request. | [
"Creates",
"a",
"new",
"urllib",
"request",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L2827-L2835 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | AbstractRpcServer._GetAuthToken | def _GetAuthToken(self, email, password):
"""Uses ClientLogin to authenticate the user, returning an auth token.
Args:
email: The user's email address
password: The user's password
Raises:
ClientLoginError: If there was an error authenticating with ClientLogin.
HTTPError: If there was some other ... | python | def _GetAuthToken(self, email, password):
"""Uses ClientLogin to authenticate the user, returning an auth token.
Args:
email: The user's email address
password: The user's password
Raises:
ClientLoginError: If there was an error authenticating with ClientLogin.
HTTPError: If there was some other ... | [
"def",
"_GetAuthToken",
"(",
"self",
",",
"email",
",",
"password",
")",
":",
"account_type",
"=",
"\"GOOGLE\"",
"if",
"self",
".",
"host",
".",
"endswith",
"(",
"\".google.com\"",
")",
"and",
"not",
"force_google_account",
":",
"# Needed for use inside Google.",
... | Uses ClientLogin to authenticate the user, returning an auth token.
Args:
email: The user's email address
password: The user's password
Raises:
ClientLoginError: If there was an error authenticating with ClientLogin.
HTTPError: If there was some other form of HTTP error.
Returns:
The authenti... | [
"Uses",
"ClientLogin",
"to",
"authenticate",
"the",
"user",
"returning",
"an",
"auth",
"token",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L2837-L2876 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | AbstractRpcServer._GetAuthCookie | def _GetAuthCookie(self, auth_token):
"""Fetches authentication cookies for an authentication token.
Args:
auth_token: The authentication token returned by ClientLogin.
Raises:
HTTPError: If there was an error fetching the authentication cookies.
"""
# This is a dummy value to allow us to identify whe... | python | def _GetAuthCookie(self, auth_token):
"""Fetches authentication cookies for an authentication token.
Args:
auth_token: The authentication token returned by ClientLogin.
Raises:
HTTPError: If there was an error fetching the authentication cookies.
"""
# This is a dummy value to allow us to identify whe... | [
"def",
"_GetAuthCookie",
"(",
"self",
",",
"auth_token",
")",
":",
"# This is a dummy value to allow us to identify when we're successful.",
"continue_location",
"=",
"\"http://localhost/\"",
"args",
"=",
"{",
"\"continue\"",
":",
"continue_location",
",",
"\"auth\"",
":",
... | Fetches authentication cookies for an authentication token.
Args:
auth_token: The authentication token returned by ClientLogin.
Raises:
HTTPError: If there was an error fetching the authentication cookies. | [
"Fetches",
"authentication",
"cookies",
"for",
"an",
"authentication",
"token",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L2878-L2898 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | AbstractRpcServer._Authenticate | def _Authenticate(self):
"""Authenticates the user.
The authentication process works as follows:
1) We get a username and password from the user
2) We use ClientLogin to obtain an AUTH token for the user
(see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
3) We pass the auth token to /_... | python | def _Authenticate(self):
"""Authenticates the user.
The authentication process works as follows:
1) We get a username and password from the user
2) We use ClientLogin to obtain an AUTH token for the user
(see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
3) We pass the auth token to /_... | [
"def",
"_Authenticate",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"3",
")",
":",
"credentials",
"=",
"self",
".",
"auth_function",
"(",
")",
"try",
":",
"auth_token",
"=",
"self",
".",
"_GetAuthToken",
"(",
"credentials",
"[",
"0",
"]",
... | Authenticates the user.
The authentication process works as follows:
1) We get a username and password from the user
2) We use ClientLogin to obtain an AUTH token for the user
(see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
3) We pass the auth token to /_ah/login on the server to obta... | [
"Authenticates",
"the",
"user",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L2900-L2949 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | AbstractRpcServer.Send | def Send(self, request_path, payload=None,
content_type="application/octet-stream",
timeout=None,
**kwargs):
"""Sends an RPC and returns the response.
Args:
request_path: The path to send the request to, eg /api/appversion/create.
payload: The body of the request, or None to send an empty requ... | python | def Send(self, request_path, payload=None,
content_type="application/octet-stream",
timeout=None,
**kwargs):
"""Sends an RPC and returns the response.
Args:
request_path: The path to send the request to, eg /api/appversion/create.
payload: The body of the request, or None to send an empty requ... | [
"def",
"Send",
"(",
"self",
",",
"request_path",
",",
"payload",
"=",
"None",
",",
"content_type",
"=",
"\"application/octet-stream\"",
",",
"timeout",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: Don't require authentication. Let the server say",
"# wh... | Sends an RPC and returns the response.
Args:
request_path: The path to send the request to, eg /api/appversion/create.
payload: The body of the request, or None to send an empty request.
content_type: The Content-Type header to use.
timeout: timeout in seconds; default None i.e. no timeout.
(Note: fo... | [
"Sends",
"an",
"RPC",
"and",
"returns",
"the",
"response",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L2951-L2998 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | HttpRpcServer._Authenticate | def _Authenticate(self):
"""Save the cookie jar after authentication."""
super(HttpRpcServer, self)._Authenticate()
if self.save_cookies:
StatusUpdate("Saving authentication cookies to %s" % self.cookie_file)
self.cookie_jar.save() | python | def _Authenticate(self):
"""Save the cookie jar after authentication."""
super(HttpRpcServer, self)._Authenticate()
if self.save_cookies:
StatusUpdate("Saving authentication cookies to %s" % self.cookie_file)
self.cookie_jar.save() | [
"def",
"_Authenticate",
"(",
"self",
")",
":",
"super",
"(",
"HttpRpcServer",
",",
"self",
")",
".",
"_Authenticate",
"(",
")",
"if",
"self",
".",
"save_cookies",
":",
"StatusUpdate",
"(",
"\"Saving authentication cookies to %s\"",
"%",
"self",
".",
"cookie_file... | Save the cookie jar after authentication. | [
"Save",
"the",
"cookie",
"jar",
"after",
"authentication",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3004-L3009 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | HttpRpcServer._GetOpener | def _GetOpener(self):
"""Returns an OpenerDirector that supports cookies and ignores redirects.
Returns:
A urllib2.OpenerDirector object.
"""
opener = urllib2.OpenerDirector()
opener.add_handler(urllib2.ProxyHandler())
opener.add_handler(urllib2.UnknownHandler())
opener.add_handler(urllib2.HTTPHandler... | python | def _GetOpener(self):
"""Returns an OpenerDirector that supports cookies and ignores redirects.
Returns:
A urllib2.OpenerDirector object.
"""
opener = urllib2.OpenerDirector()
opener.add_handler(urllib2.ProxyHandler())
opener.add_handler(urllib2.UnknownHandler())
opener.add_handler(urllib2.HTTPHandler... | [
"def",
"_GetOpener",
"(",
"self",
")",
":",
"opener",
"=",
"urllib2",
".",
"OpenerDirector",
"(",
")",
"opener",
".",
"add_handler",
"(",
"urllib2",
".",
"ProxyHandler",
"(",
")",
")",
"opener",
".",
"add_handler",
"(",
"urllib2",
".",
"UnknownHandler",
"(... | Returns an OpenerDirector that supports cookies and ignores redirects.
Returns:
A urllib2.OpenerDirector object. | [
"Returns",
"an",
"OpenerDirector",
"that",
"supports",
"cookies",
"and",
"ignores",
"redirects",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3011-L3045 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | VersionControlSystem.CheckForUnknownFiles | def CheckForUnknownFiles(self):
"""Show an "are you sure?" prompt if there are unknown files."""
unknown_files = self.GetUnknownFiles()
if unknown_files:
print "The following files are not added to version control:"
for line in unknown_files:
print line
prompt = "Are you sure to continue?(y/N) "
a... | python | def CheckForUnknownFiles(self):
"""Show an "are you sure?" prompt if there are unknown files."""
unknown_files = self.GetUnknownFiles()
if unknown_files:
print "The following files are not added to version control:"
for line in unknown_files:
print line
prompt = "Are you sure to continue?(y/N) "
a... | [
"def",
"CheckForUnknownFiles",
"(",
"self",
")",
":",
"unknown_files",
"=",
"self",
".",
"GetUnknownFiles",
"(",
")",
"if",
"unknown_files",
":",
"print",
"\"The following files are not added to version control:\"",
"for",
"line",
"in",
"unknown_files",
":",
"print",
... | Show an "are you sure?" prompt if there are unknown files. | [
"Show",
"an",
"are",
"you",
"sure?",
"prompt",
"if",
"there",
"are",
"unknown",
"files",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3212-L3222 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | VersionControlSystem.GetBaseFiles | def GetBaseFiles(self, diff):
"""Helper that calls GetBase file for each file in the patch.
Returns:
A dictionary that maps from filename to GetBaseFile's tuple. Filenames
are retrieved based on lines that start with "Index:" or
"Property changes on:".
"""
files = {}
for line in diff.splitlines(Tru... | python | def GetBaseFiles(self, diff):
"""Helper that calls GetBase file for each file in the patch.
Returns:
A dictionary that maps from filename to GetBaseFile's tuple. Filenames
are retrieved based on lines that start with "Index:" or
"Property changes on:".
"""
files = {}
for line in diff.splitlines(Tru... | [
"def",
"GetBaseFiles",
"(",
"self",
",",
"diff",
")",
":",
"files",
"=",
"{",
"}",
"for",
"line",
"in",
"diff",
".",
"splitlines",
"(",
"True",
")",
":",
"if",
"line",
".",
"startswith",
"(",
"'Index:'",
")",
"or",
"line",
".",
"startswith",
"(",
"... | Helper that calls GetBase file for each file in the patch.
Returns:
A dictionary that maps from filename to GetBaseFile's tuple. Filenames
are retrieved based on lines that start with "Index:" or
"Property changes on:". | [
"Helper",
"that",
"calls",
"GetBase",
"file",
"for",
"each",
"file",
"in",
"the",
"patch",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3241-L3257 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | VersionControlSystem.UploadBaseFiles | def UploadBaseFiles(self, issue, rpc_server, patch_list, patchset, options,
files):
"""Uploads the base files (and if necessary, the current ones as well)."""
def UploadFile(filename, file_id, content, is_binary, status, is_base):
"""Uploads a file to the server."""
set_status("uploading " + filen... | python | def UploadBaseFiles(self, issue, rpc_server, patch_list, patchset, options,
files):
"""Uploads the base files (and if necessary, the current ones as well)."""
def UploadFile(filename, file_id, content, is_binary, status, is_base):
"""Uploads a file to the server."""
set_status("uploading " + filen... | [
"def",
"UploadBaseFiles",
"(",
"self",
",",
"issue",
",",
"rpc_server",
",",
"patch_list",
",",
"patchset",
",",
"options",
",",
"files",
")",
":",
"def",
"UploadFile",
"(",
"filename",
",",
"file_id",
",",
"content",
",",
"is_binary",
",",
"status",
",",
... | Uploads the base files (and if necessary, the current ones as well). | [
"Uploads",
"the",
"base",
"files",
"(",
"and",
"if",
"necessary",
"the",
"current",
"ones",
"as",
"well",
")",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3260-L3344 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | VersionControlSystem.IsImage | def IsImage(self, filename):
"""Returns true if the filename has an image extension."""
mimetype = mimetypes.guess_type(filename)[0]
if not mimetype:
return False
return mimetype.startswith("image/") | python | def IsImage(self, filename):
"""Returns true if the filename has an image extension."""
mimetype = mimetypes.guess_type(filename)[0]
if not mimetype:
return False
return mimetype.startswith("image/") | [
"def",
"IsImage",
"(",
"self",
",",
"filename",
")",
":",
"mimetype",
"=",
"mimetypes",
".",
"guess_type",
"(",
"filename",
")",
"[",
"0",
"]",
"if",
"not",
"mimetype",
":",
"return",
"False",
"return",
"mimetype",
".",
"startswith",
"(",
"\"image/\"",
"... | Returns true if the filename has an image extension. | [
"Returns",
"true",
"if",
"the",
"filename",
"has",
"an",
"image",
"extension",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3346-L3351 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | VersionControlSystem.IsBinary | def IsBinary(self, filename):
"""Returns true if the guessed mimetyped isnt't in text group."""
mimetype = mimetypes.guess_type(filename)[0]
if not mimetype:
return False # e.g. README, "real" binaries usually have an extension
# special case for text files which don't start with text/
if mimetype in TEXT... | python | def IsBinary(self, filename):
"""Returns true if the guessed mimetyped isnt't in text group."""
mimetype = mimetypes.guess_type(filename)[0]
if not mimetype:
return False # e.g. README, "real" binaries usually have an extension
# special case for text files which don't start with text/
if mimetype in TEXT... | [
"def",
"IsBinary",
"(",
"self",
",",
"filename",
")",
":",
"mimetype",
"=",
"mimetypes",
".",
"guess_type",
"(",
"filename",
")",
"[",
"0",
"]",
"if",
"not",
"mimetype",
":",
"return",
"False",
"# e.g. README, \"real\" binaries usually have an extension",
"# speci... | Returns true if the guessed mimetyped isnt't in text group. | [
"Returns",
"true",
"if",
"the",
"guessed",
"mimetyped",
"isnt",
"t",
"in",
"text",
"group",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3353-L3361 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | MercurialVCS._GetRelPath | def _GetRelPath(self, filename):
"""Get relative path of a file according to the current directory,
given its logical path in the repo."""
assert filename.startswith(self.subdir), (filename, self.subdir)
return filename[len(self.subdir):].lstrip(r"\/") | python | def _GetRelPath(self, filename):
"""Get relative path of a file according to the current directory,
given its logical path in the repo."""
assert filename.startswith(self.subdir), (filename, self.subdir)
return filename[len(self.subdir):].lstrip(r"\/") | [
"def",
"_GetRelPath",
"(",
"self",
",",
"filename",
")",
":",
"assert",
"filename",
".",
"startswith",
"(",
"self",
".",
"subdir",
")",
",",
"(",
"filename",
",",
"self",
".",
"subdir",
")",
"return",
"filename",
"[",
"len",
"(",
"self",
".",
"subdir",... | Get relative path of a file according to the current directory,
given its logical path in the repo. | [
"Get",
"relative",
"path",
"of",
"a",
"file",
"according",
"to",
"the",
"current",
"directory",
"given",
"its",
"logical",
"path",
"in",
"the",
"repo",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3417-L3421 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | MercurialVCS.GetUnknownFiles | def GetUnknownFiles(self):
"""Return a list of files unknown to the VCS."""
args = []
status = RunShell(["hg", "status", "--rev", self.base_rev, "-u", "."],
silent_ok=True)
unknown_files = []
for line in status.splitlines():
st, fn = line.split(" ", 1)
if st == "?":
unknown_files.append(fn)
re... | python | def GetUnknownFiles(self):
"""Return a list of files unknown to the VCS."""
args = []
status = RunShell(["hg", "status", "--rev", self.base_rev, "-u", "."],
silent_ok=True)
unknown_files = []
for line in status.splitlines():
st, fn = line.split(" ", 1)
if st == "?":
unknown_files.append(fn)
re... | [
"def",
"GetUnknownFiles",
"(",
"self",
")",
":",
"args",
"=",
"[",
"]",
"status",
"=",
"RunShell",
"(",
"[",
"\"hg\"",
",",
"\"status\"",
",",
"\"--rev\"",
",",
"self",
".",
"base_rev",
",",
"\"-u\"",
",",
"\".\"",
"]",
",",
"silent_ok",
"=",
"True",
... | Return a list of files unknown to the VCS. | [
"Return",
"a",
"list",
"of",
"files",
"unknown",
"to",
"the",
"VCS",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L3449-L3459 |
kpdyer/regex2dfa | third_party/re2/re2/unicode.py | _UInt | def _UInt(s):
"""Converts string to Unicode code point ('263A' => 0x263a).
Args:
s: string to convert
Returns:
Unicode code point
Raises:
InputError: the string is not a valid Unicode value.
"""
try:
v = int(s, 16)
except ValueError:
v = -1
if len(s) < 4 or len(s) > 6 or v < 0 or... | python | def _UInt(s):
"""Converts string to Unicode code point ('263A' => 0x263a).
Args:
s: string to convert
Returns:
Unicode code point
Raises:
InputError: the string is not a valid Unicode value.
"""
try:
v = int(s, 16)
except ValueError:
v = -1
if len(s) < 4 or len(s) > 6 or v < 0 or... | [
"def",
"_UInt",
"(",
"s",
")",
":",
"try",
":",
"v",
"=",
"int",
"(",
"s",
",",
"16",
")",
"except",
"ValueError",
":",
"v",
"=",
"-",
"1",
"if",
"len",
"(",
"s",
")",
"<",
"4",
"or",
"len",
"(",
"s",
")",
">",
"6",
"or",
"v",
"<",
"0",... | Converts string to Unicode code point ('263A' => 0x263a).
Args:
s: string to convert
Returns:
Unicode code point
Raises:
InputError: the string is not a valid Unicode value. | [
"Converts",
"string",
"to",
"Unicode",
"code",
"point",
"(",
"263A",
"=",
">",
"0x263a",
")",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/unicode.py#L26-L45 |
kpdyer/regex2dfa | third_party/re2/re2/unicode.py | _URange | def _URange(s):
"""Converts string to Unicode range.
'0001..0003' => [1, 2, 3].
'0001' => [1].
Args:
s: string to convert
Returns:
Unicode range
Raises:
InputError: the string is not a valid Unicode range.
"""
a = s.split("..")
if len(a) == 1:
return [_UInt(a[0])]
if len(a) =... | python | def _URange(s):
"""Converts string to Unicode range.
'0001..0003' => [1, 2, 3].
'0001' => [1].
Args:
s: string to convert
Returns:
Unicode range
Raises:
InputError: the string is not a valid Unicode range.
"""
a = s.split("..")
if len(a) == 1:
return [_UInt(a[0])]
if len(a) =... | [
"def",
"_URange",
"(",
"s",
")",
":",
"a",
"=",
"s",
".",
"split",
"(",
"\"..\"",
")",
"if",
"len",
"(",
"a",
")",
"==",
"1",
":",
"return",
"[",
"_UInt",
"(",
"a",
"[",
"0",
"]",
")",
"]",
"if",
"len",
"(",
"a",
")",
"==",
"2",
":",
"l... | Converts string to Unicode range.
'0001..0003' => [1, 2, 3].
'0001' => [1].
Args:
s: string to convert
Returns:
Unicode range
Raises:
InputError: the string is not a valid Unicode range. | [
"Converts",
"string",
"to",
"Unicode",
"range",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/unicode.py#L48-L71 |
kpdyer/regex2dfa | third_party/re2/re2/unicode.py | _ParseContinue | def _ParseContinue(s):
"""Parses a Unicode continuation field.
These are of the form '<Name, First>' or '<Name, Last>'.
Instead of giving an explicit range in a single table entry,
some Unicode tables use two entries, one for the first
code value in the range and one for the last.
The first entry's descrip... | python | def _ParseContinue(s):
"""Parses a Unicode continuation field.
These are of the form '<Name, First>' or '<Name, Last>'.
Instead of giving an explicit range in a single table entry,
some Unicode tables use two entries, one for the first
code value in the range and one for the last.
The first entry's descrip... | [
"def",
"_ParseContinue",
"(",
"s",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"\"<(.*), (First|Last)>\"",
",",
"s",
")",
"if",
"match",
"is",
"not",
"None",
":",
"return",
"match",
".",
"groups",
"(",
")",
"return",
"(",
"s",
",",
"None",
")"
] | Parses a Unicode continuation field.
These are of the form '<Name, First>' or '<Name, Last>'.
Instead of giving an explicit range in a single table entry,
some Unicode tables use two entries, one for the first
code value in the range and one for the last.
The first entry's description is '<Name, First>' inst... | [
"Parses",
"a",
"Unicode",
"continuation",
"field",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/unicode.py#L93-L117 |
kpdyer/regex2dfa | third_party/re2/re2/unicode.py | ReadUnicodeTable | def ReadUnicodeTable(filename, nfields, doline):
"""Generic Unicode table text file reader.
The reader takes care of stripping out comments and also
parsing the two different ways that the Unicode tables specify
code ranges (using the .. notation and splitting the range across
multiple lines).
Each non-co... | python | def ReadUnicodeTable(filename, nfields, doline):
"""Generic Unicode table text file reader.
The reader takes care of stripping out comments and also
parsing the two different ways that the Unicode tables specify
code ranges (using the .. notation and splitting the range across
multiple lines).
Each non-co... | [
"def",
"ReadUnicodeTable",
"(",
"filename",
",",
"nfields",
",",
"doline",
")",
":",
"if",
"nfields",
"<",
"2",
":",
"raise",
"InputError",
"(",
"\"invalid number of fields %d\"",
"%",
"(",
"nfields",
",",
")",
")",
"if",
"type",
"(",
"filename",
")",
"=="... | Generic Unicode table text file reader.
The reader takes care of stripping out comments and also
parsing the two different ways that the Unicode tables specify
code ranges (using the .. notation and splitting the range across
multiple lines).
Each non-comment line in the table is expected to have the given
... | [
"Generic",
"Unicode",
"table",
"text",
"file",
"reader",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/unicode.py#L120-L216 |
kpdyer/regex2dfa | third_party/re2/re2/unicode.py | CaseGroups | def CaseGroups(unicode_dir=_UNICODE_DIR):
"""Returns list of Unicode code groups equivalent under case folding.
Each group is a sorted list of code points,
and the list of groups is sorted by first code point
in the group.
Args:
unicode_dir: Unicode data directory
Returns:
list of Unicode code gr... | python | def CaseGroups(unicode_dir=_UNICODE_DIR):
"""Returns list of Unicode code groups equivalent under case folding.
Each group is a sorted list of code points,
and the list of groups is sorted by first code point
in the group.
Args:
unicode_dir: Unicode data directory
Returns:
list of Unicode code gr... | [
"def",
"CaseGroups",
"(",
"unicode_dir",
"=",
"_UNICODE_DIR",
")",
":",
"# Dict mapping lowercase code point to fold-equivalent group.",
"togroup",
"=",
"{",
"}",
"def",
"DoLine",
"(",
"codes",
",",
"fields",
")",
":",
"\"\"\"Process single CaseFolding.txt line, updating to... | Returns list of Unicode code groups equivalent under case folding.
Each group is a sorted list of code points,
and the list of groups is sorted by first code point
in the group.
Args:
unicode_dir: Unicode data directory
Returns:
list of Unicode code groups | [
"Returns",
"list",
"of",
"Unicode",
"code",
"groups",
"equivalent",
"under",
"case",
"folding",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/unicode.py#L219-L250 |
kpdyer/regex2dfa | third_party/re2/re2/unicode.py | Scripts | def Scripts(unicode_dir=_UNICODE_DIR):
"""Returns dict mapping script names to code lists.
Args:
unicode_dir: Unicode data directory
Returns:
dict mapping script names to code lists
"""
scripts = {}
def DoLine(codes, fields):
"""Process single Scripts.txt line, updating scripts."""
(_, n... | python | def Scripts(unicode_dir=_UNICODE_DIR):
"""Returns dict mapping script names to code lists.
Args:
unicode_dir: Unicode data directory
Returns:
dict mapping script names to code lists
"""
scripts = {}
def DoLine(codes, fields):
"""Process single Scripts.txt line, updating scripts."""
(_, n... | [
"def",
"Scripts",
"(",
"unicode_dir",
"=",
"_UNICODE_DIR",
")",
":",
"scripts",
"=",
"{",
"}",
"def",
"DoLine",
"(",
"codes",
",",
"fields",
")",
":",
"\"\"\"Process single Scripts.txt line, updating scripts.\"\"\"",
"(",
"_",
",",
"name",
")",
"=",
"fields",
... | Returns dict mapping script names to code lists.
Args:
unicode_dir: Unicode data directory
Returns:
dict mapping script names to code lists | [
"Returns",
"dict",
"mapping",
"script",
"names",
"to",
"code",
"lists",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/unicode.py#L253-L271 |
kpdyer/regex2dfa | third_party/re2/re2/unicode.py | Categories | def Categories(unicode_dir=_UNICODE_DIR):
"""Returns dict mapping category names to code lists.
Args:
unicode_dir: Unicode data directory
Returns:
dict mapping category names to code lists
"""
categories = {}
def DoLine(codes, fields):
"""Process single UnicodeData.txt line, updating categor... | python | def Categories(unicode_dir=_UNICODE_DIR):
"""Returns dict mapping category names to code lists.
Args:
unicode_dir: Unicode data directory
Returns:
dict mapping category names to code lists
"""
categories = {}
def DoLine(codes, fields):
"""Process single UnicodeData.txt line, updating categor... | [
"def",
"Categories",
"(",
"unicode_dir",
"=",
"_UNICODE_DIR",
")",
":",
"categories",
"=",
"{",
"}",
"def",
"DoLine",
"(",
"codes",
",",
"fields",
")",
":",
"\"\"\"Process single UnicodeData.txt line, updating categories.\"\"\"",
"category",
"=",
"fields",
"[",
"2",... | Returns dict mapping category names to code lists.
Args:
unicode_dir: Unicode data directory
Returns:
dict mapping category names to code lists | [
"Returns",
"dict",
"mapping",
"category",
"names",
"to",
"code",
"lists",
"."
] | train | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/unicode.py#L274-L296 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.