id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
55,100 | PythonRails/rails | rails/request.py | Request.get_url_param | def get_url_param(self, index, default=None):
"""
Return url parameter with given index.
Args:
- index: starts from zero, and come after controller and
action names in url.
"""
params = self.get_url_params()
return params[index] if index < len(params) e... | python | def get_url_param(self, index, default=None):
"""
Return url parameter with given index.
Args:
- index: starts from zero, and come after controller and
action names in url.
"""
params = self.get_url_params()
return params[index] if index < len(params) e... | [
"def",
"get_url_param",
"(",
"self",
",",
"index",
",",
"default",
"=",
"None",
")",
":",
"params",
"=",
"self",
".",
"get_url_params",
"(",
")",
"return",
"params",
"[",
"index",
"]",
"if",
"index",
"<",
"len",
"(",
"params",
")",
"else",
"default"
] | Return url parameter with given index.
Args:
- index: starts from zero, and come after controller and
action names in url. | [
"Return",
"url",
"parameter",
"with",
"given",
"index",
"."
] | 1e199b9da4da5b24fef39fc6212d71fc9fbb18a5 | https://github.com/PythonRails/rails/blob/1e199b9da4da5b24fef39fc6212d71fc9fbb18a5/rails/request.py#L32-L41 |
55,101 | edoburu/django-any-urlfield | any_urlfield/registry.py | UrlType.get_widget | def get_widget(self):
"""
Create the widget for the URL type.
"""
form_field = self.get_form_field()
widget = form_field.widget
if isinstance(widget, type):
widget = widget()
# Widget instantiation needs to happen manually.
# Auto skip if choi... | python | def get_widget(self):
"""
Create the widget for the URL type.
"""
form_field = self.get_form_field()
widget = form_field.widget
if isinstance(widget, type):
widget = widget()
# Widget instantiation needs to happen manually.
# Auto skip if choi... | [
"def",
"get_widget",
"(",
"self",
")",
":",
"form_field",
"=",
"self",
".",
"get_form_field",
"(",
")",
"widget",
"=",
"form_field",
".",
"widget",
"if",
"isinstance",
"(",
"widget",
",",
"type",
")",
":",
"widget",
"=",
"widget",
"(",
")",
"# Widget ins... | Create the widget for the URL type. | [
"Create",
"the",
"widget",
"for",
"the",
"URL",
"type",
"."
] | 8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab | https://github.com/edoburu/django-any-urlfield/blob/8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab/any_urlfield/registry.py#L57-L72 |
55,102 | edoburu/django-any-urlfield | any_urlfield/registry.py | UrlTypeRegistry.register | def register(self, ModelClass, form_field=None, widget=None, title=None, prefix=None, has_id_value=True):
"""
Register a custom model with the ``AnyUrlField``.
"""
if any(urltype.model == ModelClass for urltype in self._url_types):
raise ValueError("Model is already registere... | python | def register(self, ModelClass, form_field=None, widget=None, title=None, prefix=None, has_id_value=True):
"""
Register a custom model with the ``AnyUrlField``.
"""
if any(urltype.model == ModelClass for urltype in self._url_types):
raise ValueError("Model is already registere... | [
"def",
"register",
"(",
"self",
",",
"ModelClass",
",",
"form_field",
"=",
"None",
",",
"widget",
"=",
"None",
",",
"title",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"has_id_value",
"=",
"True",
")",
":",
"if",
"any",
"(",
"urltype",
".",
"model... | Register a custom model with the ``AnyUrlField``. | [
"Register",
"a",
"custom",
"model",
"with",
"the",
"AnyUrlField",
"."
] | 8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab | https://github.com/edoburu/django-any-urlfield/blob/8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab/any_urlfield/registry.py#L90-L116 |
55,103 | edoburu/django-any-urlfield | any_urlfield/registry.py | UrlTypeRegistry.get_for_model | def get_for_model(self, ModelClass):
"""
Return the URL type for a given model class
"""
for urltype in self._url_types:
if urltype.model is ModelClass:
return urltype
return None | python | def get_for_model(self, ModelClass):
"""
Return the URL type for a given model class
"""
for urltype in self._url_types:
if urltype.model is ModelClass:
return urltype
return None | [
"def",
"get_for_model",
"(",
"self",
",",
"ModelClass",
")",
":",
"for",
"urltype",
"in",
"self",
".",
"_url_types",
":",
"if",
"urltype",
".",
"model",
"is",
"ModelClass",
":",
"return",
"urltype",
"return",
"None"
] | Return the URL type for a given model class | [
"Return",
"the",
"URL",
"type",
"for",
"a",
"given",
"model",
"class"
] | 8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab | https://github.com/edoburu/django-any-urlfield/blob/8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab/any_urlfield/registry.py#L136-L143 |
55,104 | edoburu/django-any-urlfield | any_urlfield/registry.py | UrlTypeRegistry.index | def index(self, prefix):
"""
Return the model index for a prefix.
"""
# Any web domain will be handled by the standard URLField.
if self.is_external_url_prefix(prefix):
prefix = 'http'
for i, urltype in enumerate(self._url_types):
if urltype.prefi... | python | def index(self, prefix):
"""
Return the model index for a prefix.
"""
# Any web domain will be handled by the standard URLField.
if self.is_external_url_prefix(prefix):
prefix = 'http'
for i, urltype in enumerate(self._url_types):
if urltype.prefi... | [
"def",
"index",
"(",
"self",
",",
"prefix",
")",
":",
"# Any web domain will be handled by the standard URLField.",
"if",
"self",
".",
"is_external_url_prefix",
"(",
"prefix",
")",
":",
"prefix",
"=",
"'http'",
"for",
"i",
",",
"urltype",
"in",
"enumerate",
"(",
... | Return the model index for a prefix. | [
"Return",
"the",
"model",
"index",
"for",
"a",
"prefix",
"."
] | 8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab | https://github.com/edoburu/django-any-urlfield/blob/8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab/any_urlfield/registry.py#L155-L166 |
55,105 | caktus/rapidsms-tropo | rtropo/views.py | message_received | def message_received(request, backend_name):
"""Handle HTTP requests from Tropo.
"""
logger.debug("@@ request from Tropo - raw data: %s" % request.body)
try:
post = json.loads(request.body)
except ValueError:
logger.exception("EXCEPTION decoding post data in incoming request")
... | python | def message_received(request, backend_name):
"""Handle HTTP requests from Tropo.
"""
logger.debug("@@ request from Tropo - raw data: %s" % request.body)
try:
post = json.loads(request.body)
except ValueError:
logger.exception("EXCEPTION decoding post data in incoming request")
... | [
"def",
"message_received",
"(",
"request",
",",
"backend_name",
")",
":",
"logger",
".",
"debug",
"(",
"\"@@ request from Tropo - raw data: %s\"",
"%",
"request",
".",
"body",
")",
"try",
":",
"post",
"=",
"json",
".",
"loads",
"(",
"request",
".",
"body",
"... | Handle HTTP requests from Tropo. | [
"Handle",
"HTTP",
"requests",
"from",
"Tropo",
"."
] | 7680f351053837f210bf90576fa8f947c8f1c5c6 | https://github.com/caktus/rapidsms-tropo/blob/7680f351053837f210bf90576fa8f947c8f1c5c6/rtropo/views.py#L21-L81 |
55,106 | project-ncl/pnc-cli | pnc_cli/runningbuilds.py | list_running_builds | def list_running_builds(page_size=200, page_index=0, sort=""):
"""
List all RunningBuilds
"""
content = list_running_builds_raw(page_size, page_index, sort)
if content:
return utils.format_json_list(content) | python | def list_running_builds(page_size=200, page_index=0, sort=""):
"""
List all RunningBuilds
"""
content = list_running_builds_raw(page_size, page_index, sort)
if content:
return utils.format_json_list(content) | [
"def",
"list_running_builds",
"(",
"page_size",
"=",
"200",
",",
"page_index",
"=",
"0",
",",
"sort",
"=",
"\"\"",
")",
":",
"content",
"=",
"list_running_builds_raw",
"(",
"page_size",
",",
"page_index",
",",
"sort",
")",
"if",
"content",
":",
"return",
"... | List all RunningBuilds | [
"List",
"all",
"RunningBuilds"
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/runningbuilds.py#L13-L19 |
55,107 | SmartTeleMax/iktomi | iktomi/forms/convs.py | between | def between(min_value, max_value):
'Numerical values limit'
message = N_('value should be between %(min)d and %(max)d') % \
dict(min=min_value, max=max_value)
@validator(message)
def wrapper(conv, value):
if value is None:
# it meens that this value is not requir... | python | def between(min_value, max_value):
'Numerical values limit'
message = N_('value should be between %(min)d and %(max)d') % \
dict(min=min_value, max=max_value)
@validator(message)
def wrapper(conv, value):
if value is None:
# it meens that this value is not requir... | [
"def",
"between",
"(",
"min_value",
",",
"max_value",
")",
":",
"message",
"=",
"N_",
"(",
"'value should be between %(min)d and %(max)d'",
")",
"%",
"dict",
"(",
"min",
"=",
"min_value",
",",
"max",
"=",
"max_value",
")",
"@",
"validator",
"(",
"message",
"... | Numerical values limit | [
"Numerical",
"values",
"limit"
] | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/forms/convs.py#L250-L265 |
55,108 | mithro/python-datetime-tz | datetime_tz/__init__.py | _tzinfome | def _tzinfome(tzinfo):
"""Gets a tzinfo object from a string.
Args:
tzinfo: A string (or string like) object, or a datetime.tzinfo object.
Returns:
An datetime.tzinfo object.
Raises:
UnknownTimeZoneError: If the timezone given can't be decoded.
"""
if not isinstance(tzinfo, datetime.tzinfo):
... | python | def _tzinfome(tzinfo):
"""Gets a tzinfo object from a string.
Args:
tzinfo: A string (or string like) object, or a datetime.tzinfo object.
Returns:
An datetime.tzinfo object.
Raises:
UnknownTimeZoneError: If the timezone given can't be decoded.
"""
if not isinstance(tzinfo, datetime.tzinfo):
... | [
"def",
"_tzinfome",
"(",
"tzinfo",
")",
":",
"if",
"not",
"isinstance",
"(",
"tzinfo",
",",
"datetime",
".",
"tzinfo",
")",
":",
"try",
":",
"tzinfo",
"=",
"pytz",
".",
"timezone",
"(",
"tzinfo",
")",
"assert",
"tzinfo",
".",
"zone",
"in",
"pytz",
".... | Gets a tzinfo object from a string.
Args:
tzinfo: A string (or string like) object, or a datetime.tzinfo object.
Returns:
An datetime.tzinfo object.
Raises:
UnknownTimeZoneError: If the timezone given can't be decoded. | [
"Gets",
"a",
"tzinfo",
"object",
"from",
"a",
"string",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L85-L103 |
55,109 | mithro/python-datetime-tz | datetime_tz/__init__.py | localize | def localize(dt, force_to_local=True):
"""Localize a datetime to the local timezone.
If dt is naive, returns the same datetime with the local timezone, otherwise
uses astimezone to convert.
Args:
dt: datetime object.
force_to_local: Force all results to be in local time.
Returns:
A datetime_tz ... | python | def localize(dt, force_to_local=True):
"""Localize a datetime to the local timezone.
If dt is naive, returns the same datetime with the local timezone, otherwise
uses astimezone to convert.
Args:
dt: datetime object.
force_to_local: Force all results to be in local time.
Returns:
A datetime_tz ... | [
"def",
"localize",
"(",
"dt",
",",
"force_to_local",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"dt",
",",
"datetime_tz",
")",
":",
"if",
"not",
"dt",
".",
"tzinfo",
":",
"return",
"datetime_tz",
"(",
"dt",
",",
"tzinfo",
"=",
"localtz",
... | Localize a datetime to the local timezone.
If dt is naive, returns the same datetime with the local timezone, otherwise
uses astimezone to convert.
Args:
dt: datetime object.
force_to_local: Force all results to be in local time.
Returns:
A datetime_tz object. | [
"Localize",
"a",
"datetime",
"to",
"the",
"local",
"timezone",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L110-L129 |
55,110 | mithro/python-datetime-tz | datetime_tz/__init__.py | get_naive | def get_naive(dt):
"""Gets a naive datetime from a datetime.
datetime_tz objects can't just have tzinfo replaced with None, you need to
call asdatetime.
Args:
dt: datetime object.
Returns:
datetime object without any timezone information.
"""
if not dt.tzinfo:
return dt
if hasattr(dt, "as... | python | def get_naive(dt):
"""Gets a naive datetime from a datetime.
datetime_tz objects can't just have tzinfo replaced with None, you need to
call asdatetime.
Args:
dt: datetime object.
Returns:
datetime object without any timezone information.
"""
if not dt.tzinfo:
return dt
if hasattr(dt, "as... | [
"def",
"get_naive",
"(",
"dt",
")",
":",
"if",
"not",
"dt",
".",
"tzinfo",
":",
"return",
"dt",
"if",
"hasattr",
"(",
"dt",
",",
"\"asdatetime\"",
")",
":",
"return",
"dt",
".",
"asdatetime",
"(",
")",
"return",
"dt",
".",
"replace",
"(",
"tzinfo",
... | Gets a naive datetime from a datetime.
datetime_tz objects can't just have tzinfo replaced with None, you need to
call asdatetime.
Args:
dt: datetime object.
Returns:
datetime object without any timezone information. | [
"Gets",
"a",
"naive",
"datetime",
"from",
"a",
"datetime",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L132-L148 |
55,111 | mithro/python-datetime-tz | datetime_tz/__init__.py | detect_timezone | def detect_timezone():
"""Try and detect the timezone that Python is currently running in.
We have a bunch of different methods for trying to figure this out (listed in
order they are attempted).
* In windows, use win32timezone.TimeZoneInfo.local()
* Try TZ environment variable.
* Try and find /etc/t... | python | def detect_timezone():
"""Try and detect the timezone that Python is currently running in.
We have a bunch of different methods for trying to figure this out (listed in
order they are attempted).
* In windows, use win32timezone.TimeZoneInfo.local()
* Try TZ environment variable.
* Try and find /etc/t... | [
"def",
"detect_timezone",
"(",
")",
":",
"if",
"sys",
".",
"platform",
"==",
"\"win32\"",
":",
"tz",
"=",
"_detect_timezone_windows",
"(",
")",
"if",
"tz",
"is",
"not",
"None",
":",
"return",
"tz",
"# First we try the TZ variable",
"tz",
"=",
"_detect_timezone... | Try and detect the timezone that Python is currently running in.
We have a bunch of different methods for trying to figure this out (listed in
order they are attempted).
* In windows, use win32timezone.TimeZoneInfo.local()
* Try TZ environment variable.
* Try and find /etc/timezone file (with timezone ... | [
"Try",
"and",
"detect",
"the",
"timezone",
"that",
"Python",
"is",
"currently",
"running",
"in",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L183-L230 |
55,112 | mithro/python-datetime-tz | datetime_tz/__init__.py | _load_local_tzinfo | def _load_local_tzinfo():
"""Load zoneinfo from local disk."""
tzdir = os.environ.get("TZDIR", "/usr/share/zoneinfo/posix")
localtzdata = {}
for dirpath, _, filenames in os.walk(tzdir):
for filename in filenames:
filepath = os.path.join(dirpath, filename)
name = os.path.relpath(filepath, tzdir)... | python | def _load_local_tzinfo():
"""Load zoneinfo from local disk."""
tzdir = os.environ.get("TZDIR", "/usr/share/zoneinfo/posix")
localtzdata = {}
for dirpath, _, filenames in os.walk(tzdir):
for filename in filenames:
filepath = os.path.join(dirpath, filename)
name = os.path.relpath(filepath, tzdir)... | [
"def",
"_load_local_tzinfo",
"(",
")",
":",
"tzdir",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"TZDIR\"",
",",
"\"/usr/share/zoneinfo/posix\"",
")",
"localtzdata",
"=",
"{",
"}",
"for",
"dirpath",
",",
"_",
",",
"filenames",
"in",
"os",
".",
"walk",
... | Load zoneinfo from local disk. | [
"Load",
"zoneinfo",
"from",
"local",
"disk",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L257-L272 |
55,113 | mithro/python-datetime-tz | datetime_tz/__init__.py | _wrap_method | def _wrap_method(name):
"""Wrap a method.
Patch a method which might return a datetime.datetime to return a
datetime_tz.datetime_tz instead.
Args:
name: The name of the method to patch
"""
method = getattr(datetime.datetime, name)
# Have to give the second argument as method has no __module__ optio... | python | def _wrap_method(name):
"""Wrap a method.
Patch a method which might return a datetime.datetime to return a
datetime_tz.datetime_tz instead.
Args:
name: The name of the method to patch
"""
method = getattr(datetime.datetime, name)
# Have to give the second argument as method has no __module__ optio... | [
"def",
"_wrap_method",
"(",
"name",
")",
":",
"method",
"=",
"getattr",
"(",
"datetime",
".",
"datetime",
",",
"name",
")",
"# Have to give the second argument as method has no __module__ option.",
"@",
"functools",
".",
"wraps",
"(",
"method",
",",
"(",
"\"__name__... | Wrap a method.
Patch a method which might return a datetime.datetime to return a
datetime_tz.datetime_tz instead.
Args:
name: The name of the method to patch | [
"Wrap",
"a",
"method",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L855-L875 |
55,114 | mithro/python-datetime-tz | datetime_tz/__init__.py | datetime_tz.asdatetime | def asdatetime(self, naive=True):
"""Return this datetime_tz as a datetime object.
Args:
naive: Return *without* any tz info.
Returns:
This datetime_tz as a datetime object.
"""
args = list(self.timetuple()[0:6])+[self.microsecond]
if not naive:
args.append(self.tzinfo)
r... | python | def asdatetime(self, naive=True):
"""Return this datetime_tz as a datetime object.
Args:
naive: Return *without* any tz info.
Returns:
This datetime_tz as a datetime object.
"""
args = list(self.timetuple()[0:6])+[self.microsecond]
if not naive:
args.append(self.tzinfo)
r... | [
"def",
"asdatetime",
"(",
"self",
",",
"naive",
"=",
"True",
")",
":",
"args",
"=",
"list",
"(",
"self",
".",
"timetuple",
"(",
")",
"[",
"0",
":",
"6",
"]",
")",
"+",
"[",
"self",
".",
"microsecond",
"]",
"if",
"not",
"naive",
":",
"args",
"."... | Return this datetime_tz as a datetime object.
Args:
naive: Return *without* any tz info.
Returns:
This datetime_tz as a datetime object. | [
"Return",
"this",
"datetime_tz",
"as",
"a",
"datetime",
"object",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L476-L488 |
55,115 | mithro/python-datetime-tz | datetime_tz/__init__.py | datetime_tz.asdate | def asdate(self):
"""Return this datetime_tz as a date object.
Returns:
This datetime_tz as a date object.
"""
return datetime.date(self.year, self.month, self.day) | python | def asdate(self):
"""Return this datetime_tz as a date object.
Returns:
This datetime_tz as a date object.
"""
return datetime.date(self.year, self.month, self.day) | [
"def",
"asdate",
"(",
"self",
")",
":",
"return",
"datetime",
".",
"date",
"(",
"self",
".",
"year",
",",
"self",
".",
"month",
",",
"self",
".",
"day",
")"
] | Return this datetime_tz as a date object.
Returns:
This datetime_tz as a date object. | [
"Return",
"this",
"datetime_tz",
"as",
"a",
"date",
"object",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L490-L496 |
55,116 | mithro/python-datetime-tz | datetime_tz/__init__.py | datetime_tz.astimezone | def astimezone(self, tzinfo):
"""Returns a version of this timestamp converted to the given timezone.
Args:
tzinfo: Either a datetime.tzinfo object or a string (which will be looked
up in pytz.
Returns:
A datetime_tz object in the given timezone.
"""
# Assert we are not a... | python | def astimezone(self, tzinfo):
"""Returns a version of this timestamp converted to the given timezone.
Args:
tzinfo: Either a datetime.tzinfo object or a string (which will be looked
up in pytz.
Returns:
A datetime_tz object in the given timezone.
"""
# Assert we are not a... | [
"def",
"astimezone",
"(",
"self",
",",
"tzinfo",
")",
":",
"# Assert we are not a naive datetime object",
"assert",
"self",
".",
"tzinfo",
"is",
"not",
"None",
"tzinfo",
"=",
"_tzinfome",
"(",
"tzinfo",
")",
"d",
"=",
"self",
".",
"asdatetime",
"(",
"naive",
... | Returns a version of this timestamp converted to the given timezone.
Args:
tzinfo: Either a datetime.tzinfo object or a string (which will be looked
up in pytz.
Returns:
A datetime_tz object in the given timezone. | [
"Returns",
"a",
"version",
"of",
"this",
"timestamp",
"converted",
"to",
"the",
"given",
"timezone",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L508-L524 |
55,117 | mithro/python-datetime-tz | datetime_tz/__init__.py | datetime_tz.replace | def replace(self, **kw):
"""Return datetime with new specified fields given as arguments.
For example, dt.replace(days=4) would return a new datetime_tz object with
exactly the same as dt but with the days attribute equal to 4.
Any attribute can be replaced, but tzinfo can not be set to None.
Arg... | python | def replace(self, **kw):
"""Return datetime with new specified fields given as arguments.
For example, dt.replace(days=4) would return a new datetime_tz object with
exactly the same as dt but with the days attribute equal to 4.
Any attribute can be replaced, but tzinfo can not be set to None.
Arg... | [
"def",
"replace",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"if",
"\"tzinfo\"",
"in",
"kw",
":",
"if",
"kw",
"[",
"\"tzinfo\"",
"]",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"\"Can not remove the timezone use asdatetime()\"",
")",
"else",
":",
"tzin... | Return datetime with new specified fields given as arguments.
For example, dt.replace(days=4) would return a new datetime_tz object with
exactly the same as dt but with the days attribute equal to 4.
Any attribute can be replaced, but tzinfo can not be set to None.
Args:
Any datetime_tz attribu... | [
"Return",
"datetime",
"with",
"new",
"specified",
"fields",
"given",
"as",
"arguments",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L527-L564 |
55,118 | mithro/python-datetime-tz | datetime_tz/__init__.py | datetime_tz.utcnow | def utcnow(cls):
"""Return a new datetime representing UTC day and time."""
obj = datetime.datetime.utcnow()
obj = cls(obj, tzinfo=pytz.utc)
return obj | python | def utcnow(cls):
"""Return a new datetime representing UTC day and time."""
obj = datetime.datetime.utcnow()
obj = cls(obj, tzinfo=pytz.utc)
return obj | [
"def",
"utcnow",
"(",
"cls",
")",
":",
"obj",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"obj",
"=",
"cls",
"(",
"obj",
",",
"tzinfo",
"=",
"pytz",
".",
"utc",
")",
"return",
"obj"
] | Return a new datetime representing UTC day and time. | [
"Return",
"a",
"new",
"datetime",
"representing",
"UTC",
"day",
"and",
"time",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L714-L718 |
55,119 | mithro/python-datetime-tz | datetime_tz/__init__.py | iterate.between | def between(start, delta, end=None):
"""Return an iterator between this date till given end point.
Example usage:
>>> d = datetime_tz.smartparse("5 days ago")
2008/05/12 11:45
>>> for i in d.between(timedelta(days=1), datetime_tz.now()):
>>> print i
2008/05/12 11:45
2008/... | python | def between(start, delta, end=None):
"""Return an iterator between this date till given end point.
Example usage:
>>> d = datetime_tz.smartparse("5 days ago")
2008/05/12 11:45
>>> for i in d.between(timedelta(days=1), datetime_tz.now()):
>>> print i
2008/05/12 11:45
2008/... | [
"def",
"between",
"(",
"start",
",",
"delta",
",",
"end",
"=",
"None",
")",
":",
"toyield",
"=",
"start",
"while",
"end",
"is",
"None",
"or",
"toyield",
"<",
"end",
":",
"yield",
"toyield",
"toyield",
"+=",
"delta"
] | Return an iterator between this date till given end point.
Example usage:
>>> d = datetime_tz.smartparse("5 days ago")
2008/05/12 11:45
>>> for i in d.between(timedelta(days=1), datetime_tz.now()):
>>> print i
2008/05/12 11:45
2008/05/13 11:45
2008/05/14 11:45
200... | [
"Return",
"an",
"iterator",
"between",
"this",
"date",
"till",
"given",
"end",
"point",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L756-L782 |
55,120 | mithro/python-datetime-tz | datetime_tz/__init__.py | iterate.days | def days(start, end=None):
"""Iterate over the days between the given datetime_tzs.
Args:
start: datetime_tz to start from.
end: (Optional) Date to end at, if not given the iterator will never
terminate.
Returns:
An iterator which generates datetime_tz objects a day apart.
... | python | def days(start, end=None):
"""Iterate over the days between the given datetime_tzs.
Args:
start: datetime_tz to start from.
end: (Optional) Date to end at, if not given the iterator will never
terminate.
Returns:
An iterator which generates datetime_tz objects a day apart.
... | [
"def",
"days",
"(",
"start",
",",
"end",
"=",
"None",
")",
":",
"return",
"iterate",
".",
"between",
"(",
"start",
",",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"1",
")",
",",
"end",
")"
] | Iterate over the days between the given datetime_tzs.
Args:
start: datetime_tz to start from.
end: (Optional) Date to end at, if not given the iterator will never
terminate.
Returns:
An iterator which generates datetime_tz objects a day apart. | [
"Iterate",
"over",
"the",
"days",
"between",
"the",
"given",
"datetime_tzs",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L799-L810 |
55,121 | mithro/python-datetime-tz | datetime_tz/__init__.py | iterate.hours | def hours(start, end=None):
"""Iterate over the hours between the given datetime_tzs.
Args:
start: datetime_tz to start from.
end: (Optional) Date to end at, if not given the iterator will never
terminate.
Returns:
An iterator which generates datetime_tz objects a hour apart.
... | python | def hours(start, end=None):
"""Iterate over the hours between the given datetime_tzs.
Args:
start: datetime_tz to start from.
end: (Optional) Date to end at, if not given the iterator will never
terminate.
Returns:
An iterator which generates datetime_tz objects a hour apart.
... | [
"def",
"hours",
"(",
"start",
",",
"end",
"=",
"None",
")",
":",
"return",
"iterate",
".",
"between",
"(",
"start",
",",
"datetime",
".",
"timedelta",
"(",
"hours",
"=",
"1",
")",
",",
"end",
")"
] | Iterate over the hours between the given datetime_tzs.
Args:
start: datetime_tz to start from.
end: (Optional) Date to end at, if not given the iterator will never
terminate.
Returns:
An iterator which generates datetime_tz objects a hour apart. | [
"Iterate",
"over",
"the",
"hours",
"between",
"the",
"given",
"datetime_tzs",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L813-L824 |
55,122 | mithro/python-datetime-tz | datetime_tz/__init__.py | iterate.minutes | def minutes(start, end=None):
"""Iterate over the minutes between the given datetime_tzs.
Args:
start: datetime_tz to start from.
end: (Optional) Date to end at, if not given the iterator will never
terminate.
Returns:
An iterator which generates datetime_tz objects a minute a... | python | def minutes(start, end=None):
"""Iterate over the minutes between the given datetime_tzs.
Args:
start: datetime_tz to start from.
end: (Optional) Date to end at, if not given the iterator will never
terminate.
Returns:
An iterator which generates datetime_tz objects a minute a... | [
"def",
"minutes",
"(",
"start",
",",
"end",
"=",
"None",
")",
":",
"return",
"iterate",
".",
"between",
"(",
"start",
",",
"datetime",
".",
"timedelta",
"(",
"minutes",
"=",
"1",
")",
",",
"end",
")"
] | Iterate over the minutes between the given datetime_tzs.
Args:
start: datetime_tz to start from.
end: (Optional) Date to end at, if not given the iterator will never
terminate.
Returns:
An iterator which generates datetime_tz objects a minute apart. | [
"Iterate",
"over",
"the",
"minutes",
"between",
"the",
"given",
"datetime_tzs",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L827-L838 |
55,123 | jedie/django-cms-tools | django_cms_tools/fixture_helper/pages.py | publish_page | def publish_page(page, languages):
"""
Publish a CMS page in all given languages.
"""
for language_code, lang_name in iter_languages(languages):
url = page.get_absolute_url()
if page.publisher_is_draft:
page.publish(language_code)
log.info('page "%s" published in... | python | def publish_page(page, languages):
"""
Publish a CMS page in all given languages.
"""
for language_code, lang_name in iter_languages(languages):
url = page.get_absolute_url()
if page.publisher_is_draft:
page.publish(language_code)
log.info('page "%s" published in... | [
"def",
"publish_page",
"(",
"page",
",",
"languages",
")",
":",
"for",
"language_code",
",",
"lang_name",
"in",
"iter_languages",
"(",
"languages",
")",
":",
"url",
"=",
"page",
".",
"get_absolute_url",
"(",
")",
"if",
"page",
".",
"publisher_is_draft",
":",... | Publish a CMS page in all given languages. | [
"Publish",
"a",
"CMS",
"page",
"in",
"all",
"given",
"languages",
"."
] | 0a70dbbb6f770f5a73c8ecd174d5559a37262792 | https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L47-L60 |
55,124 | jedie/django-cms-tools | django_cms_tools/fixture_helper/pages.py | create_cms_plugin_page | def create_cms_plugin_page(apphook, apphook_namespace, placeholder_slot=None):
"""
Create cms plugin page in all existing languages.
Add a link to the index page.
:param apphook: e.g...........: 'FooBarApp'
:param apphook_namespace: e.g.: 'foobar'
:return:
"""
creator = CmsPluginPageCre... | python | def create_cms_plugin_page(apphook, apphook_namespace, placeholder_slot=None):
"""
Create cms plugin page in all existing languages.
Add a link to the index page.
:param apphook: e.g...........: 'FooBarApp'
:param apphook_namespace: e.g.: 'foobar'
:return:
"""
creator = CmsPluginPageCre... | [
"def",
"create_cms_plugin_page",
"(",
"apphook",
",",
"apphook_namespace",
",",
"placeholder_slot",
"=",
"None",
")",
":",
"creator",
"=",
"CmsPluginPageCreator",
"(",
"apphook",
"=",
"apphook",
",",
"apphook_namespace",
"=",
"apphook_namespace",
",",
")",
"creator"... | Create cms plugin page in all existing languages.
Add a link to the index page.
:param apphook: e.g...........: 'FooBarApp'
:param apphook_namespace: e.g.: 'foobar'
:return: | [
"Create",
"cms",
"plugin",
"page",
"in",
"all",
"existing",
"languages",
".",
"Add",
"a",
"link",
"to",
"the",
"index",
"page",
"."
] | 0a70dbbb6f770f5a73c8ecd174d5559a37262792 | https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L458-L473 |
55,125 | jedie/django-cms-tools | django_cms_tools/fixture_helper/pages.py | CmsPageCreator.publish | def publish(self, page):
"""
Publish the page in all languages.
"""
assert page.publisher_is_draft == True, "Page '%s' must be a draft!" % page
publish_page(page, languages=self.languages) | python | def publish(self, page):
"""
Publish the page in all languages.
"""
assert page.publisher_is_draft == True, "Page '%s' must be a draft!" % page
publish_page(page, languages=self.languages) | [
"def",
"publish",
"(",
"self",
",",
"page",
")",
":",
"assert",
"page",
".",
"publisher_is_draft",
"==",
"True",
",",
"\"Page '%s' must be a draft!\"",
"%",
"page",
"publish_page",
"(",
"page",
",",
"languages",
"=",
"self",
".",
"languages",
")"
] | Publish the page in all languages. | [
"Publish",
"the",
"page",
"in",
"all",
"languages",
"."
] | 0a70dbbb6f770f5a73c8ecd174d5559a37262792 | https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L148-L153 |
55,126 | jedie/django-cms-tools | django_cms_tools/fixture_helper/pages.py | CmsPageCreator.add_plugins | def add_plugins(self, page, placeholder):
"""
Add a "TextPlugin" in all languages.
"""
for language_code, lang_name in iter_languages(self.languages):
for no in range(1, self.dummy_text_count + 1):
add_plugin_kwargs = self.get_add_plugin_kwargs(
... | python | def add_plugins(self, page, placeholder):
"""
Add a "TextPlugin" in all languages.
"""
for language_code, lang_name in iter_languages(self.languages):
for no in range(1, self.dummy_text_count + 1):
add_plugin_kwargs = self.get_add_plugin_kwargs(
... | [
"def",
"add_plugins",
"(",
"self",
",",
"page",
",",
"placeholder",
")",
":",
"for",
"language_code",
",",
"lang_name",
"in",
"iter_languages",
"(",
"self",
".",
"languages",
")",
":",
"for",
"no",
"in",
"range",
"(",
"1",
",",
"self",
".",
"dummy_text_c... | Add a "TextPlugin" in all languages. | [
"Add",
"a",
"TextPlugin",
"in",
"all",
"languages",
"."
] | 0a70dbbb6f770f5a73c8ecd174d5559a37262792 | https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L303-L320 |
55,127 | jedie/django-cms-tools | django_cms_tools/fixture_helper/pages.py | CmsPageCreator.get_or_create_placeholder | def get_or_create_placeholder(self, page, placeholder_slot):
"""
Add a placeholder if not exists.
"""
placeholder, created = get_or_create_placeholder(
page, placeholder_slot, delete_existing=self.delete_first)
return placeholder, created | python | def get_or_create_placeholder(self, page, placeholder_slot):
"""
Add a placeholder if not exists.
"""
placeholder, created = get_or_create_placeholder(
page, placeholder_slot, delete_existing=self.delete_first)
return placeholder, created | [
"def",
"get_or_create_placeholder",
"(",
"self",
",",
"page",
",",
"placeholder_slot",
")",
":",
"placeholder",
",",
"created",
"=",
"get_or_create_placeholder",
"(",
"page",
",",
"placeholder_slot",
",",
"delete_existing",
"=",
"self",
".",
"delete_first",
")",
"... | Add a placeholder if not exists. | [
"Add",
"a",
"placeholder",
"if",
"not",
"exists",
"."
] | 0a70dbbb6f770f5a73c8ecd174d5559a37262792 | https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L322-L328 |
55,128 | jedie/django-cms-tools | django_cms_tools/fixture_helper/pages.py | CmsPageCreator.fill_content | def fill_content(self, page, placeholder_slot):
"""
Add a placeholder to the page.
Here we add a "TextPlugin" in all languages.
"""
if len(placeholder_slot) == 1:
raise RuntimeError(placeholder_slot)
placeholder, created = self.get_or_create_placeholder(
... | python | def fill_content(self, page, placeholder_slot):
"""
Add a placeholder to the page.
Here we add a "TextPlugin" in all languages.
"""
if len(placeholder_slot) == 1:
raise RuntimeError(placeholder_slot)
placeholder, created = self.get_or_create_placeholder(
... | [
"def",
"fill_content",
"(",
"self",
",",
"page",
",",
"placeholder_slot",
")",
":",
"if",
"len",
"(",
"placeholder_slot",
")",
"==",
"1",
":",
"raise",
"RuntimeError",
"(",
"placeholder_slot",
")",
"placeholder",
",",
"created",
"=",
"self",
".",
"get_or_cre... | Add a placeholder to the page.
Here we add a "TextPlugin" in all languages. | [
"Add",
"a",
"placeholder",
"to",
"the",
"page",
".",
"Here",
"we",
"add",
"a",
"TextPlugin",
"in",
"all",
"languages",
"."
] | 0a70dbbb6f770f5a73c8ecd174d5559a37262792 | https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L330-L339 |
55,129 | jedie/django-cms-tools | django_cms_tools/fixture_helper/pages.py | CmsPluginPageCreator.create | def create(self):
"""
Create the plugin page in all languages and fill dummy content.
"""
plugin = CMSPlugin.objects.filter(plugin_type=self.apphook)
if plugin.exists():
log.debug('Plugin page for "%s" plugin already exist, ok.',
self.apphook)
... | python | def create(self):
"""
Create the plugin page in all languages and fill dummy content.
"""
plugin = CMSPlugin.objects.filter(plugin_type=self.apphook)
if plugin.exists():
log.debug('Plugin page for "%s" plugin already exist, ok.',
self.apphook)
... | [
"def",
"create",
"(",
"self",
")",
":",
"plugin",
"=",
"CMSPlugin",
".",
"objects",
".",
"filter",
"(",
"plugin_type",
"=",
"self",
".",
"apphook",
")",
"if",
"plugin",
".",
"exists",
"(",
")",
":",
"log",
".",
"debug",
"(",
"'Plugin page for \"%s\" plug... | Create the plugin page in all languages and fill dummy content. | [
"Create",
"the",
"plugin",
"page",
"in",
"all",
"languages",
"and",
"fill",
"dummy",
"content",
"."
] | 0a70dbbb6f770f5a73c8ecd174d5559a37262792 | https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L437-L455 |
55,130 | CivicSpleen/ambry | ambry/orm/source_table.py | SourceTable.column | def column(self, source_header_or_pos):
"""
Return a column by name or position
:param source_header_or_pos: If a string, a source header name. If an integer, column position
:return:
"""
for c in self.columns:
if c.source_header == source_header_or_pos:
... | python | def column(self, source_header_or_pos):
"""
Return a column by name or position
:param source_header_or_pos: If a string, a source header name. If an integer, column position
:return:
"""
for c in self.columns:
if c.source_header == source_header_or_pos:
... | [
"def",
"column",
"(",
"self",
",",
"source_header_or_pos",
")",
":",
"for",
"c",
"in",
"self",
".",
"columns",
":",
"if",
"c",
".",
"source_header",
"==",
"source_header_or_pos",
":",
"assert",
"c",
".",
"st_vid",
"==",
"self",
".",
"vid",
"return",
"c",... | Return a column by name or position
:param source_header_or_pos: If a string, a source header name. If an integer, column position
:return: | [
"Return",
"a",
"column",
"by",
"name",
"or",
"position"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/source_table.py#L186-L202 |
55,131 | CivicSpleen/ambry | ambry/orm/__init__.py | table_convert_geometry | def table_convert_geometry(metadata, table_name):
"""Get table metadata from the database."""
from sqlalchemy import Table
from ..orm import Geometry
table = Table(table_name, metadata, autoload=True)
for c in table.columns:
# HACK! Sqlalchemy sees spatialte GEOMETRY types
# as NU... | python | def table_convert_geometry(metadata, table_name):
"""Get table metadata from the database."""
from sqlalchemy import Table
from ..orm import Geometry
table = Table(table_name, metadata, autoload=True)
for c in table.columns:
# HACK! Sqlalchemy sees spatialte GEOMETRY types
# as NU... | [
"def",
"table_convert_geometry",
"(",
"metadata",
",",
"table_name",
")",
":",
"from",
"sqlalchemy",
"import",
"Table",
"from",
".",
".",
"orm",
"import",
"Geometry",
"table",
"=",
"Table",
"(",
"table_name",
",",
"metadata",
",",
"autoload",
"=",
"True",
")... | Get table metadata from the database. | [
"Get",
"table",
"metadata",
"from",
"the",
"database",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/__init__.py#L74-L89 |
55,132 | CivicSpleen/ambry | ambry/orm/__init__.py | incver | def incver(o, prop_names):
"""Increment the version numbers of a set of properties and return a new object"""
from ambry.identity import ObjectNumber
d = {}
for p in o.__mapper__.attrs:
v = getattr(o, p.key)
if v is None:
d[p.key] = None
elif p.key in prop_names:
... | python | def incver(o, prop_names):
"""Increment the version numbers of a set of properties and return a new object"""
from ambry.identity import ObjectNumber
d = {}
for p in o.__mapper__.attrs:
v = getattr(o, p.key)
if v is None:
d[p.key] = None
elif p.key in prop_names:
... | [
"def",
"incver",
"(",
"o",
",",
"prop_names",
")",
":",
"from",
"ambry",
".",
"identity",
"import",
"ObjectNumber",
"d",
"=",
"{",
"}",
"for",
"p",
"in",
"o",
".",
"__mapper__",
".",
"attrs",
":",
"v",
"=",
"getattr",
"(",
"o",
",",
"p",
".",
"ke... | Increment the version numbers of a set of properties and return a new object | [
"Increment",
"the",
"version",
"numbers",
"of",
"a",
"set",
"of",
"properties",
"and",
"return",
"a",
"new",
"object"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/__init__.py#L408-L424 |
55,133 | CivicSpleen/ambry | ambry/orm/__init__.py | MutationList.coerce | def coerce(cls, key, value):
"""Convert plain list to MutationList."""
if isinstance(value, string_types):
value = value.strip()
if value[0] == '[': # It's json encoded, probably
try:
value = json.loads(value)
except ValueErro... | python | def coerce(cls, key, value):
"""Convert plain list to MutationList."""
if isinstance(value, string_types):
value = value.strip()
if value[0] == '[': # It's json encoded, probably
try:
value = json.loads(value)
except ValueErro... | [
"def",
"coerce",
"(",
"cls",
",",
"key",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"string_types",
")",
":",
"value",
"=",
"value",
".",
"strip",
"(",
")",
"if",
"value",
"[",
"0",
"]",
"==",
"'['",
":",
"# It's json encoded, pro... | Convert plain list to MutationList. | [
"Convert",
"plain",
"list",
"to",
"MutationList",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/__init__.py#L214-L232 |
55,134 | CivicSpleen/ambry | ambry/bundle/asql_parser.py | parse_view | def parse_view(query):
""" Parses asql query to view object.
Args:
query (str): asql query
Returns:
View instance: parsed view.
"""
try:
idx = query.lower().index('where')
query = query[:idx]
except ValueError:
pass
if not query.endswith(';'):
... | python | def parse_view(query):
""" Parses asql query to view object.
Args:
query (str): asql query
Returns:
View instance: parsed view.
"""
try:
idx = query.lower().index('where')
query = query[:idx]
except ValueError:
pass
if not query.endswith(';'):
... | [
"def",
"parse_view",
"(",
"query",
")",
":",
"try",
":",
"idx",
"=",
"query",
".",
"lower",
"(",
")",
".",
"index",
"(",
"'where'",
")",
"query",
"=",
"query",
"[",
":",
"idx",
"]",
"except",
"ValueError",
":",
"pass",
"if",
"not",
"query",
".",
... | Parses asql query to view object.
Args:
query (str): asql query
Returns:
View instance: parsed view. | [
"Parses",
"asql",
"query",
"to",
"view",
"object",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/asql_parser.py#L36-L58 |
55,135 | CivicSpleen/ambry | ambry/bundle/asql_parser.py | _build_join | def _build_join(t):
""" Populates join token fields. """
t.source.name = t.source.parsed_name
t.source.alias = t.source.parsed_alias[0] if t.source.parsed_alias else ''
return t | python | def _build_join(t):
""" Populates join token fields. """
t.source.name = t.source.parsed_name
t.source.alias = t.source.parsed_alias[0] if t.source.parsed_alias else ''
return t | [
"def",
"_build_join",
"(",
"t",
")",
":",
"t",
".",
"source",
".",
"name",
"=",
"t",
".",
"source",
".",
"parsed_name",
"t",
".",
"source",
".",
"alias",
"=",
"t",
".",
"source",
".",
"parsed_alias",
"[",
"0",
"]",
"if",
"t",
".",
"source",
".",
... | Populates join token fields. | [
"Populates",
"join",
"token",
"fields",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/asql_parser.py#L177-L182 |
55,136 | CivicSpleen/ambry | ambry/bundle/asql_parser.py | substitute_vids | def substitute_vids(library, statement):
""" Replace all of the references to tables and partitions with their vids.
This is a bit of a hack -- it ought to work with the parser, but instead it just looks for
common SQL tokens that indicate an identifier.
:param statement: an sqlstatement. String.
... | python | def substitute_vids(library, statement):
""" Replace all of the references to tables and partitions with their vids.
This is a bit of a hack -- it ought to work with the parser, but instead it just looks for
common SQL tokens that indicate an identifier.
:param statement: an sqlstatement. String.
... | [
"def",
"substitute_vids",
"(",
"library",
",",
"statement",
")",
":",
"from",
"ambry",
".",
"identity",
"import",
"ObjectNumber",
",",
"TableNumber",
",",
"NotObjectNumberError",
"from",
"ambry",
".",
"orm",
".",
"exc",
"import",
"NotFoundError",
"try",
":",
"... | Replace all of the references to tables and partitions with their vids.
This is a bit of a hack -- it ought to work with the parser, but instead it just looks for
common SQL tokens that indicate an identifier.
:param statement: an sqlstatement. String.
:return: tuple: new_statement, set of table vids,... | [
"Replace",
"all",
"of",
"the",
"references",
"to",
"tables",
"and",
"partitions",
"with",
"their",
"vids",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/asql_parser.py#L361-L413 |
55,137 | CivicSpleen/ambry | ambry/bundle/asql_parser.py | find_indexable_materializable | def find_indexable_materializable(sql, library):
"""
Parse a statement, then call functions to install, materialize or create indexes for partitions
referenced in the statement.
:param sql:
:param materialize_f:
:param install_f:
:param index_f:
:return:
"""
derefed, tables, pa... | python | def find_indexable_materializable(sql, library):
"""
Parse a statement, then call functions to install, materialize or create indexes for partitions
referenced in the statement.
:param sql:
:param materialize_f:
:param install_f:
:param index_f:
:return:
"""
derefed, tables, pa... | [
"def",
"find_indexable_materializable",
"(",
"sql",
",",
"library",
")",
":",
"derefed",
",",
"tables",
",",
"partitions",
"=",
"substitute_vids",
"(",
"library",
",",
"sql",
")",
"if",
"derefed",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'create inde... | Parse a statement, then call functions to install, materialize or create indexes for partitions
referenced in the statement.
:param sql:
:param materialize_f:
:param install_f:
:param index_f:
:return: | [
"Parse",
"a",
"statement",
"then",
"call",
"functions",
"to",
"install",
"materialize",
"or",
"create",
"indexes",
"for",
"partitions",
"referenced",
"in",
"the",
"statement",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/asql_parser.py#L491-L574 |
55,138 | CivicSpleen/ambry | ambry/bundle/asql_parser.py | FIMRecord.update | def update(self, rec=None, drop=None, tables=None, install=None, materialize=None,
indexes=None, joins=0, views=0):
""" Updates current record.
Args:
rec (FIMRecord):
"""
if not drop:
drop = []
if not tables:
tables = set()
... | python | def update(self, rec=None, drop=None, tables=None, install=None, materialize=None,
indexes=None, joins=0, views=0):
""" Updates current record.
Args:
rec (FIMRecord):
"""
if not drop:
drop = []
if not tables:
tables = set()
... | [
"def",
"update",
"(",
"self",
",",
"rec",
"=",
"None",
",",
"drop",
"=",
"None",
",",
"tables",
"=",
"None",
",",
"install",
"=",
"None",
",",
"materialize",
"=",
"None",
",",
"indexes",
"=",
"None",
",",
"joins",
"=",
"0",
",",
"views",
"=",
"0"... | Updates current record.
Args:
rec (FIMRecord): | [
"Updates",
"current",
"record",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/asql_parser.py#L448-L488 |
55,139 | project-ncl/pnc-cli | pnc_cli/swagger_client/models/product_release_rest.py | ProductReleaseRest.support_level | def support_level(self, support_level):
"""
Sets the support_level of this ProductReleaseRest.
:param support_level: The support_level of this ProductReleaseRest.
:type: str
"""
allowed_values = ["UNRELEASED", "EARLYACCESS", "SUPPORTED", "EXTENDED_SUPPORT", "EOL"]
... | python | def support_level(self, support_level):
"""
Sets the support_level of this ProductReleaseRest.
:param support_level: The support_level of this ProductReleaseRest.
:type: str
"""
allowed_values = ["UNRELEASED", "EARLYACCESS", "SUPPORTED", "EXTENDED_SUPPORT", "EOL"]
... | [
"def",
"support_level",
"(",
"self",
",",
"support_level",
")",
":",
"allowed_values",
"=",
"[",
"\"UNRELEASED\"",
",",
"\"EARLYACCESS\"",
",",
"\"SUPPORTED\"",
",",
"\"EXTENDED_SUPPORT\"",
",",
"\"EOL\"",
"]",
"if",
"support_level",
"not",
"in",
"allowed_values",
... | Sets the support_level of this ProductReleaseRest.
:param support_level: The support_level of this ProductReleaseRest.
:type: str | [
"Sets",
"the",
"support_level",
"of",
"this",
"ProductReleaseRest",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/models/product_release_rest.py#L244-L258 |
55,140 | twisted/epsilon | epsilon/hotfixes/internet_task_clock.py | callLater | def callLater(self, when, what, *a, **kw):
"""
Copied from twisted.internet.task.Clock, r20480. Fixes the bug
where the wrong DelayedCall would sometimes be returned.
"""
dc = base.DelayedCall(self.seconds() + when,
what, a, kw,
self.calls.remo... | python | def callLater(self, when, what, *a, **kw):
"""
Copied from twisted.internet.task.Clock, r20480. Fixes the bug
where the wrong DelayedCall would sometimes be returned.
"""
dc = base.DelayedCall(self.seconds() + when,
what, a, kw,
self.calls.remo... | [
"def",
"callLater",
"(",
"self",
",",
"when",
",",
"what",
",",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"dc",
"=",
"base",
".",
"DelayedCall",
"(",
"self",
".",
"seconds",
"(",
")",
"+",
"when",
",",
"what",
",",
"a",
",",
"kw",
",",
"self",... | Copied from twisted.internet.task.Clock, r20480. Fixes the bug
where the wrong DelayedCall would sometimes be returned. | [
"Copied",
"from",
"twisted",
".",
"internet",
".",
"task",
".",
"Clock",
"r20480",
".",
"Fixes",
"the",
"bug",
"where",
"the",
"wrong",
"DelayedCall",
"would",
"sometimes",
"be",
"returned",
"."
] | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/internet_task_clock.py#L7-L19 |
55,141 | twisted/epsilon | epsilon/hotfixes/internet_task_clock.py | clockIsBroken | def clockIsBroken():
"""
Returns whether twisted.internet.task.Clock has the bug that
returns the wrong DelayedCall or not.
"""
clock = Clock()
dc1 = clock.callLater(10, lambda: None)
dc2 = clock.callLater(1, lambda: None)
if dc1 is dc2:
return True
else:
return False | python | def clockIsBroken():
"""
Returns whether twisted.internet.task.Clock has the bug that
returns the wrong DelayedCall or not.
"""
clock = Clock()
dc1 = clock.callLater(10, lambda: None)
dc2 = clock.callLater(1, lambda: None)
if dc1 is dc2:
return True
else:
return False | [
"def",
"clockIsBroken",
"(",
")",
":",
"clock",
"=",
"Clock",
"(",
")",
"dc1",
"=",
"clock",
".",
"callLater",
"(",
"10",
",",
"lambda",
":",
"None",
")",
"dc2",
"=",
"clock",
".",
"callLater",
"(",
"1",
",",
"lambda",
":",
"None",
")",
"if",
"dc... | Returns whether twisted.internet.task.Clock has the bug that
returns the wrong DelayedCall or not. | [
"Returns",
"whether",
"twisted",
".",
"internet",
".",
"task",
".",
"Clock",
"has",
"the",
"bug",
"that",
"returns",
"the",
"wrong",
"DelayedCall",
"or",
"not",
"."
] | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/internet_task_clock.py#L21-L32 |
55,142 | project-ncl/pnc-cli | pnc_cli/tools/scm_utils.py | shrink_patch | def shrink_patch(patch_path, target_file):
"""
Shrinks a patch on patch_path to contain only changes for target_file.
:param patch_path: path to the shrinked patch file
:param target_file: filename of a file of which changes should be kept
:return: True if the is a section containing changes for ta... | python | def shrink_patch(patch_path, target_file):
"""
Shrinks a patch on patch_path to contain only changes for target_file.
:param patch_path: path to the shrinked patch file
:param target_file: filename of a file of which changes should be kept
:return: True if the is a section containing changes for ta... | [
"def",
"shrink_patch",
"(",
"patch_path",
",",
"target_file",
")",
":",
"logging",
".",
"debug",
"(",
"\"Shrinking patch file %s to keep only %s changes.\"",
",",
"patch_path",
",",
"target_file",
")",
"shrinked_lines",
"=",
"[",
"]",
"patch_file",
"=",
"None",
"try... | Shrinks a patch on patch_path to contain only changes for target_file.
:param patch_path: path to the shrinked patch file
:param target_file: filename of a file of which changes should be kept
:return: True if the is a section containing changes for target_file, Flase otherwise | [
"Shrinks",
"a",
"patch",
"on",
"patch_path",
"to",
"contain",
"only",
"changes",
"for",
"target_file",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/scm_utils.py#L274-L313 |
55,143 | project-ncl/pnc-cli | pnc_cli/swagger_client/models/build_set_status_changed_event.py | BuildSetStatusChangedEvent.new_status | def new_status(self, new_status):
"""
Sets the new_status of this BuildSetStatusChangedEvent.
:param new_status: The new_status of this BuildSetStatusChangedEvent.
:type: str
"""
allowed_values = ["NEW", "DONE", "REJECTED"]
if new_status not in allowed_values:
... | python | def new_status(self, new_status):
"""
Sets the new_status of this BuildSetStatusChangedEvent.
:param new_status: The new_status of this BuildSetStatusChangedEvent.
:type: str
"""
allowed_values = ["NEW", "DONE", "REJECTED"]
if new_status not in allowed_values:
... | [
"def",
"new_status",
"(",
"self",
",",
"new_status",
")",
":",
"allowed_values",
"=",
"[",
"\"NEW\"",
",",
"\"DONE\"",
",",
"\"REJECTED\"",
"]",
"if",
"new_status",
"not",
"in",
"allowed_values",
":",
"raise",
"ValueError",
"(",
"\"Invalid value for `new_status` (... | Sets the new_status of this BuildSetStatusChangedEvent.
:param new_status: The new_status of this BuildSetStatusChangedEvent.
:type: str | [
"Sets",
"the",
"new_status",
"of",
"this",
"BuildSetStatusChangedEvent",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/models/build_set_status_changed_event.py#L139-L153 |
55,144 | project-ncl/pnc-cli | pnc_cli/swagger_client/models/build_set_status_changed_event.py | BuildSetStatusChangedEvent.old_status | def old_status(self, old_status):
"""
Sets the old_status of this BuildSetStatusChangedEvent.
:param old_status: The old_status of this BuildSetStatusChangedEvent.
:type: str
"""
allowed_values = ["NEW", "DONE", "REJECTED"]
if old_status not in allowed_values:
... | python | def old_status(self, old_status):
"""
Sets the old_status of this BuildSetStatusChangedEvent.
:param old_status: The old_status of this BuildSetStatusChangedEvent.
:type: str
"""
allowed_values = ["NEW", "DONE", "REJECTED"]
if old_status not in allowed_values:
... | [
"def",
"old_status",
"(",
"self",
",",
"old_status",
")",
":",
"allowed_values",
"=",
"[",
"\"NEW\"",
",",
"\"DONE\"",
",",
"\"REJECTED\"",
"]",
"if",
"old_status",
"not",
"in",
"allowed_values",
":",
"raise",
"ValueError",
"(",
"\"Invalid value for `old_status` (... | Sets the old_status of this BuildSetStatusChangedEvent.
:param old_status: The old_status of this BuildSetStatusChangedEvent.
:type: str | [
"Sets",
"the",
"old_status",
"of",
"this",
"BuildSetStatusChangedEvent",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/models/build_set_status_changed_event.py#L250-L264 |
55,145 | cosven/feeluown-core | fuocore/utils.py | find_previous | def find_previous(element, l):
"""
find previous element in a sorted list
>>> find_previous(0, [0])
0
>>> find_previous(2, [1, 1, 3])
1
>>> find_previous(0, [1, 2])
>>> find_previous(1.5, [1, 2])
1
>>> find_previous(3, [1, 2])
2
"""
length = len(l)
for index, cur... | python | def find_previous(element, l):
"""
find previous element in a sorted list
>>> find_previous(0, [0])
0
>>> find_previous(2, [1, 1, 3])
1
>>> find_previous(0, [1, 2])
>>> find_previous(1.5, [1, 2])
1
>>> find_previous(3, [1, 2])
2
"""
length = len(l)
for index, cur... | [
"def",
"find_previous",
"(",
"element",
",",
"l",
")",
":",
"length",
"=",
"len",
"(",
"l",
")",
"for",
"index",
",",
"current",
"in",
"enumerate",
"(",
"l",
")",
":",
"# current is the last element",
"if",
"length",
"-",
"1",
"==",
"index",
":",
"retu... | find previous element in a sorted list
>>> find_previous(0, [0])
0
>>> find_previous(2, [1, 1, 3])
1
>>> find_previous(0, [1, 2])
>>> find_previous(1.5, [1, 2])
1
>>> find_previous(3, [1, 2])
2 | [
"find",
"previous",
"element",
"in",
"a",
"sorted",
"list"
] | 62dc64638f62971b16be0a75c0b8c7ae2999869e | https://github.com/cosven/feeluown-core/blob/62dc64638f62971b16be0a75c0b8c7ae2999869e/fuocore/utils.py#L43-L69 |
55,146 | CivicSpleen/ambry | ambry/orm/remote.py | Remote.update | def update(self):
"""Cache the list into the data section of the record"""
from ambry.orm.exc import NotFoundError
from requests.exceptions import ConnectionError, HTTPError
from boto.exception import S3ResponseError
d = {}
try:
for k, v in self.list(full=T... | python | def update(self):
"""Cache the list into the data section of the record"""
from ambry.orm.exc import NotFoundError
from requests.exceptions import ConnectionError, HTTPError
from boto.exception import S3ResponseError
d = {}
try:
for k, v in self.list(full=T... | [
"def",
"update",
"(",
"self",
")",
":",
"from",
"ambry",
".",
"orm",
".",
"exc",
"import",
"NotFoundError",
"from",
"requests",
".",
"exceptions",
"import",
"ConnectionError",
",",
"HTTPError",
"from",
"boto",
".",
"exception",
"import",
"S3ResponseError",
"d"... | Cache the list into the data section of the record | [
"Cache",
"the",
"list",
"into",
"the",
"data",
"section",
"of",
"the",
"record"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L177-L200 |
55,147 | CivicSpleen/ambry | ambry/orm/remote.py | Remote.list | def list(self, full=False):
"""List all of the bundles in the remote"""
if self.is_api:
return self._list_api(full=full)
else:
return self._list_fs(full=full) | python | def list(self, full=False):
"""List all of the bundles in the remote"""
if self.is_api:
return self._list_api(full=full)
else:
return self._list_fs(full=full) | [
"def",
"list",
"(",
"self",
",",
"full",
"=",
"False",
")",
":",
"if",
"self",
".",
"is_api",
":",
"return",
"self",
".",
"_list_api",
"(",
"full",
"=",
"full",
")",
"else",
":",
"return",
"self",
".",
"_list_fs",
"(",
"full",
"=",
"full",
")"
] | List all of the bundles in the remote | [
"List",
"all",
"of",
"the",
"bundles",
"in",
"the",
"remote"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L202-L208 |
55,148 | CivicSpleen/ambry | ambry/orm/remote.py | Remote._update_fs_list | def _update_fs_list(self):
"""Cache the full list for http access. This creates a meta file that can be read all at once,
rather than requiring a list operation like S3 access does"""
from json import dumps
full_list = [ e[1] for e in self._list_fs(full=True) ]
remote = self._f... | python | def _update_fs_list(self):
"""Cache the full list for http access. This creates a meta file that can be read all at once,
rather than requiring a list operation like S3 access does"""
from json import dumps
full_list = [ e[1] for e in self._list_fs(full=True) ]
remote = self._f... | [
"def",
"_update_fs_list",
"(",
"self",
")",
":",
"from",
"json",
"import",
"dumps",
"full_list",
"=",
"[",
"e",
"[",
"1",
"]",
"for",
"e",
"in",
"self",
".",
"_list_fs",
"(",
"full",
"=",
"True",
")",
"]",
"remote",
"=",
"self",
".",
"_fs_remote",
... | Cache the full list for http access. This creates a meta file that can be read all at once,
rather than requiring a list operation like S3 access does | [
"Cache",
"the",
"full",
"list",
"for",
"http",
"access",
".",
"This",
"creates",
"a",
"meta",
"file",
"that",
"can",
"be",
"read",
"all",
"at",
"once",
"rather",
"than",
"requiring",
"a",
"list",
"operation",
"like",
"S3",
"access",
"does"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L253-L262 |
55,149 | CivicSpleen/ambry | ambry/orm/remote.py | Remote.checkin | def checkin(self, package, no_partitions=False, force=False, cb=None):
"""
Check in a bundle package to the remote.
:param package: A Database, referencing a sqlite database holding the bundle
:param cb: a two argument progress callback: cb(message, num_records)
:return:
... | python | def checkin(self, package, no_partitions=False, force=False, cb=None):
"""
Check in a bundle package to the remote.
:param package: A Database, referencing a sqlite database holding the bundle
:param cb: a two argument progress callback: cb(message, num_records)
:return:
... | [
"def",
"checkin",
"(",
"self",
",",
"package",
",",
"no_partitions",
"=",
"False",
",",
"force",
"=",
"False",
",",
"cb",
"=",
"None",
")",
":",
"from",
"ambry",
".",
"orm",
".",
"exc",
"import",
"NotFoundError",
"if",
"not",
"os",
".",
"path",
".",
... | Check in a bundle package to the remote.
:param package: A Database, referencing a sqlite database holding the bundle
:param cb: a two argument progress callback: cb(message, num_records)
:return: | [
"Check",
"in",
"a",
"bundle",
"package",
"to",
"the",
"remote",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L307-L323 |
55,150 | CivicSpleen/ambry | ambry/orm/remote.py | Remote._put_metadata | def _put_metadata(self, fs_remote, ds):
"""Store metadata on a pyfs remote"""
from six import text_type
from fs.errors import ResourceNotFoundError
identity = ds.identity
d = identity.dict
d['summary'] = ds.config.metadata.about.summary
d['title'] = ds.config.... | python | def _put_metadata(self, fs_remote, ds):
"""Store metadata on a pyfs remote"""
from six import text_type
from fs.errors import ResourceNotFoundError
identity = ds.identity
d = identity.dict
d['summary'] = ds.config.metadata.about.summary
d['title'] = ds.config.... | [
"def",
"_put_metadata",
"(",
"self",
",",
"fs_remote",
",",
"ds",
")",
":",
"from",
"six",
"import",
"text_type",
"from",
"fs",
".",
"errors",
"import",
"ResourceNotFoundError",
"identity",
"=",
"ds",
".",
"identity",
"d",
"=",
"identity",
".",
"dict",
"d"... | Store metadata on a pyfs remote | [
"Store",
"metadata",
"on",
"a",
"pyfs",
"remote"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L398-L428 |
55,151 | CivicSpleen/ambry | ambry/orm/remote.py | Remote.checkout | def checkout(self, ref, cb=None):
"""Checkout a bundle from the remote. Returns a file-like object"""
if self.is_api:
return self._checkout_api(ref, cb=cb)
else:
return self._checkout_fs(ref, cb=cb) | python | def checkout(self, ref, cb=None):
"""Checkout a bundle from the remote. Returns a file-like object"""
if self.is_api:
return self._checkout_api(ref, cb=cb)
else:
return self._checkout_fs(ref, cb=cb) | [
"def",
"checkout",
"(",
"self",
",",
"ref",
",",
"cb",
"=",
"None",
")",
":",
"if",
"self",
".",
"is_api",
":",
"return",
"self",
".",
"_checkout_api",
"(",
"ref",
",",
"cb",
"=",
"cb",
")",
"else",
":",
"return",
"self",
".",
"_checkout_fs",
"(",
... | Checkout a bundle from the remote. Returns a file-like object | [
"Checkout",
"a",
"bundle",
"from",
"the",
"remote",
".",
"Returns",
"a",
"file",
"-",
"like",
"object"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L463-L468 |
55,152 | CivicSpleen/ambry | ambry/orm/remote.py | Remote.remove | def remove(self, ref, cb=None):
"""Check in a bundle to the remote"""
if self.is_api:
return self._remove_api(ref, cb)
else:
return self._remove_fs(ref, cb) | python | def remove(self, ref, cb=None):
"""Check in a bundle to the remote"""
if self.is_api:
return self._remove_api(ref, cb)
else:
return self._remove_fs(ref, cb) | [
"def",
"remove",
"(",
"self",
",",
"ref",
",",
"cb",
"=",
"None",
")",
":",
"if",
"self",
".",
"is_api",
":",
"return",
"self",
".",
"_remove_api",
"(",
"ref",
",",
"cb",
")",
"else",
":",
"return",
"self",
".",
"_remove_fs",
"(",
"ref",
",",
"cb... | Check in a bundle to the remote | [
"Check",
"in",
"a",
"bundle",
"to",
"the",
"remote"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L484-L490 |
55,153 | CivicSpleen/ambry | ambry/orm/remote.py | Remote.s3 | def s3(self, url, account_acessor=None, access=None, secret=None):
"""Setup an S3 pyfs, with account credentials, fixing an ssl matching problem"""
from ambry.util.ambrys3 import AmbryS3FS
from ambry.util import parse_url_to_dict
import ssl
pd = parse_url_to_dict(url)
i... | python | def s3(self, url, account_acessor=None, access=None, secret=None):
"""Setup an S3 pyfs, with account credentials, fixing an ssl matching problem"""
from ambry.util.ambrys3 import AmbryS3FS
from ambry.util import parse_url_to_dict
import ssl
pd = parse_url_to_dict(url)
i... | [
"def",
"s3",
"(",
"self",
",",
"url",
",",
"account_acessor",
"=",
"None",
",",
"access",
"=",
"None",
",",
"secret",
"=",
"None",
")",
":",
"from",
"ambry",
".",
"util",
".",
"ambrys3",
"import",
"AmbryS3FS",
"from",
"ambry",
".",
"util",
"import",
... | Setup an S3 pyfs, with account credentials, fixing an ssl matching problem | [
"Setup",
"an",
"S3",
"pyfs",
"with",
"account",
"credentials",
"fixing",
"an",
"ssl",
"matching",
"problem"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L555-L584 |
55,154 | edoburu/django-any-urlfield | any_urlfield/templatetags/any_urlfield_tags.py | withdict | def withdict(parser, token):
"""
Take a complete context dict as extra layer.
"""
bits = token.split_contents()
if len(bits) != 2:
raise TemplateSyntaxError("{% withdict %} expects one argument")
nodelist = parser.parse(('endwithdict',))
parser.delete_first_token()
return WithD... | python | def withdict(parser, token):
"""
Take a complete context dict as extra layer.
"""
bits = token.split_contents()
if len(bits) != 2:
raise TemplateSyntaxError("{% withdict %} expects one argument")
nodelist = parser.parse(('endwithdict',))
parser.delete_first_token()
return WithD... | [
"def",
"withdict",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
"!=",
"2",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"{% withdict %} expects one argument\"",
")",
"nodelist",
"... | Take a complete context dict as extra layer. | [
"Take",
"a",
"complete",
"context",
"dict",
"as",
"extra",
"layer",
"."
] | 8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab | https://github.com/edoburu/django-any-urlfield/blob/8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab/any_urlfield/templatetags/any_urlfield_tags.py#L31-L45 |
55,155 | edoburu/django-any-urlfield | any_urlfield/templatetags/any_urlfield_tags.py | WithDictNode.render | def render(self, context):
"""
Render the tag, with extra context layer.
"""
extra_context = self.context_expr.resolve(context)
if not isinstance(extra_context, dict):
raise TemplateSyntaxError("{% withdict %} expects the argument to be a dictionary.")
with c... | python | def render(self, context):
"""
Render the tag, with extra context layer.
"""
extra_context = self.context_expr.resolve(context)
if not isinstance(extra_context, dict):
raise TemplateSyntaxError("{% withdict %} expects the argument to be a dictionary.")
with c... | [
"def",
"render",
"(",
"self",
",",
"context",
")",
":",
"extra_context",
"=",
"self",
".",
"context_expr",
".",
"resolve",
"(",
"context",
")",
"if",
"not",
"isinstance",
"(",
"extra_context",
",",
"dict",
")",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"... | Render the tag, with extra context layer. | [
"Render",
"the",
"tag",
"with",
"extra",
"context",
"layer",
"."
] | 8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab | https://github.com/edoburu/django-any-urlfield/blob/8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab/any_urlfield/templatetags/any_urlfield_tags.py#L18-L27 |
55,156 | sailthru/relay | relay/plugins/__init__.py | oscillating_setpoint | def oscillating_setpoint(_square_wave=False, shift=0):
"""A basic example of a target that you may want to approximate.
If you have a thermostat, this is a temperature setting.
This target can't change too often
"""
import math
c = 0
while 1:
if _square_wave:
yield ((c %... | python | def oscillating_setpoint(_square_wave=False, shift=0):
"""A basic example of a target that you may want to approximate.
If you have a thermostat, this is a temperature setting.
This target can't change too often
"""
import math
c = 0
while 1:
if _square_wave:
yield ((c %... | [
"def",
"oscillating_setpoint",
"(",
"_square_wave",
"=",
"False",
",",
"shift",
"=",
"0",
")",
":",
"import",
"math",
"c",
"=",
"0",
"while",
"1",
":",
"if",
"_square_wave",
":",
"yield",
"(",
"(",
"c",
"%",
"300",
")",
"<",
"150",
")",
"*",
"30",
... | A basic example of a target that you may want to approximate.
If you have a thermostat, this is a temperature setting.
This target can't change too often | [
"A",
"basic",
"example",
"of",
"a",
"target",
"that",
"you",
"may",
"want",
"to",
"approximate",
"."
] | 995209346c6663675d96d0cbff3bb67b9758c8e2 | https://github.com/sailthru/relay/blob/995209346c6663675d96d0cbff3bb67b9758c8e2/relay/plugins/__init__.py#L71-L86 |
55,157 | sailthru/relay | relay/plugins/__init__.py | bash_echo_metric | def bash_echo_metric():
"""A very basic example that monitors
a number of currently running processes"""
import subprocess
# import random
# more predictable version of the metric
cmd = (
'set -o pipefail '
' ; pgrep -f "^bash.*sleep .*from bash: started relay launcher"'
... | python | def bash_echo_metric():
"""A very basic example that monitors
a number of currently running processes"""
import subprocess
# import random
# more predictable version of the metric
cmd = (
'set -o pipefail '
' ; pgrep -f "^bash.*sleep .*from bash: started relay launcher"'
... | [
"def",
"bash_echo_metric",
"(",
")",
":",
"import",
"subprocess",
"# import random",
"# more predictable version of the metric",
"cmd",
"=",
"(",
"'set -o pipefail '",
"' ; pgrep -f \"^bash.*sleep .*from bash: started relay launcher\"'",
"' | wc -l '",
")",
"# less predictable versio... | A very basic example that monitors
a number of currently running processes | [
"A",
"very",
"basic",
"example",
"that",
"monitors",
"a",
"number",
"of",
"currently",
"running",
"processes"
] | 995209346c6663675d96d0cbff3bb67b9758c8e2 | https://github.com/sailthru/relay/blob/995209346c6663675d96d0cbff3bb67b9758c8e2/relay/plugins/__init__.py#L101-L121 |
55,158 | sailthru/relay | relay/plugins/__init__.py | bash_echo_warmer | def bash_echo_warmer(n):
"""A very basic example of how to create n additional tasks.
This is a warmer function with randomly delayed effects on the
bash_echo_metric and random task lengths to make the metric less
predictable
"""
import subprocess
import random
cmd = (
'set -o pi... | python | def bash_echo_warmer(n):
"""A very basic example of how to create n additional tasks.
This is a warmer function with randomly delayed effects on the
bash_echo_metric and random task lengths to make the metric less
predictable
"""
import subprocess
import random
cmd = (
'set -o pi... | [
"def",
"bash_echo_warmer",
"(",
"n",
")",
":",
"import",
"subprocess",
"import",
"random",
"cmd",
"=",
"(",
"'set -o pipefail '",
"\" ; sleep %s \"",
"\" ; sh -c 'echo from bash: started relay launcher task && sleep %s'\"",
")",
"for",
"i",
"in",
"range",
"(",
"n",
")",... | A very basic example of how to create n additional tasks.
This is a warmer function with randomly delayed effects on the
bash_echo_metric and random task lengths to make the metric less
predictable | [
"A",
"very",
"basic",
"example",
"of",
"how",
"to",
"create",
"n",
"additional",
"tasks",
".",
"This",
"is",
"a",
"warmer",
"function",
"with",
"randomly",
"delayed",
"effects",
"on",
"the",
"bash_echo_metric",
"and",
"random",
"task",
"lengths",
"to",
"make... | 995209346c6663675d96d0cbff3bb67b9758c8e2 | https://github.com/sailthru/relay/blob/995209346c6663675d96d0cbff3bb67b9758c8e2/relay/plugins/__init__.py#L124-L140 |
55,159 | sailthru/relay | relay/plugins/__init__.py | bash_echo_cooler | def bash_echo_cooler(n):
"""A very basic example of how to destroy n running tasks
This is a cooler function
"""
import subprocess
cmd = (
'set -o pipefile '
' ; kill `pgrep -f "from bash: started relay launcher task"'
' | tail -n %s` 2>/dev/null' % n)
subprocess.Popen(cm... | python | def bash_echo_cooler(n):
"""A very basic example of how to destroy n running tasks
This is a cooler function
"""
import subprocess
cmd = (
'set -o pipefile '
' ; kill `pgrep -f "from bash: started relay launcher task"'
' | tail -n %s` 2>/dev/null' % n)
subprocess.Popen(cm... | [
"def",
"bash_echo_cooler",
"(",
"n",
")",
":",
"import",
"subprocess",
"cmd",
"=",
"(",
"'set -o pipefile '",
"' ; kill `pgrep -f \"from bash: started relay launcher task\"'",
"' | tail -n %s` 2>/dev/null'",
"%",
"n",
")",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"s... | A very basic example of how to destroy n running tasks
This is a cooler function | [
"A",
"very",
"basic",
"example",
"of",
"how",
"to",
"destroy",
"n",
"running",
"tasks",
"This",
"is",
"a",
"cooler",
"function"
] | 995209346c6663675d96d0cbff3bb67b9758c8e2 | https://github.com/sailthru/relay/blob/995209346c6663675d96d0cbff3bb67b9758c8e2/relay/plugins/__init__.py#L143-L152 |
55,160 | sailthru/relay | relay/plugins/__init__.py | stop_if_mostly_diverging | def stop_if_mostly_diverging(errdata):
"""This is an example stop condition that asks Relay to quit if
the error difference between consecutive samples is increasing more than
half of the time.
It's quite sensitive and designed for the demo, so you probably shouldn't
use this is a production settin... | python | def stop_if_mostly_diverging(errdata):
"""This is an example stop condition that asks Relay to quit if
the error difference between consecutive samples is increasing more than
half of the time.
It's quite sensitive and designed for the demo, so you probably shouldn't
use this is a production settin... | [
"def",
"stop_if_mostly_diverging",
"(",
"errdata",
")",
":",
"n_increases",
"=",
"sum",
"(",
"[",
"abs",
"(",
"y",
")",
"-",
"abs",
"(",
"x",
")",
">",
"0",
"for",
"x",
",",
"y",
"in",
"zip",
"(",
"errdata",
",",
"errdata",
"[",
"1",
":",
"]",
... | This is an example stop condition that asks Relay to quit if
the error difference between consecutive samples is increasing more than
half of the time.
It's quite sensitive and designed for the demo, so you probably shouldn't
use this is a production setting | [
"This",
"is",
"an",
"example",
"stop",
"condition",
"that",
"asks",
"Relay",
"to",
"quit",
"if",
"the",
"error",
"difference",
"between",
"consecutive",
"samples",
"is",
"increasing",
"more",
"than",
"half",
"of",
"the",
"time",
"."
] | 995209346c6663675d96d0cbff3bb67b9758c8e2 | https://github.com/sailthru/relay/blob/995209346c6663675d96d0cbff3bb67b9758c8e2/relay/plugins/__init__.py#L155-L172 |
55,161 | project-ncl/pnc-cli | pnc_cli/tools/tasks.py | Task.has_resolved_dependencies | def has_resolved_dependencies(self):
"""Return True if all dependencies are in State.DONE"""
for dependency in self.dependencies:
if dependency.state != Task.State.DONE:
return False
return True | python | def has_resolved_dependencies(self):
"""Return True if all dependencies are in State.DONE"""
for dependency in self.dependencies:
if dependency.state != Task.State.DONE:
return False
return True | [
"def",
"has_resolved_dependencies",
"(",
"self",
")",
":",
"for",
"dependency",
"in",
"self",
".",
"dependencies",
":",
"if",
"dependency",
".",
"state",
"!=",
"Task",
".",
"State",
".",
"DONE",
":",
"return",
"False",
"return",
"True"
] | Return True if all dependencies are in State.DONE | [
"Return",
"True",
"if",
"all",
"dependencies",
"are",
"in",
"State",
".",
"DONE"
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L46-L52 |
55,162 | project-ncl/pnc-cli | pnc_cli/tools/tasks.py | Task.dependencies_as_list | def dependencies_as_list(self):
"""Returns a list of dependency names."""
dependencies = []
for dependency in self.dependencies:
dependencies.append(dependency.name)
return dependencies | python | def dependencies_as_list(self):
"""Returns a list of dependency names."""
dependencies = []
for dependency in self.dependencies:
dependencies.append(dependency.name)
return dependencies | [
"def",
"dependencies_as_list",
"(",
"self",
")",
":",
"dependencies",
"=",
"[",
"]",
"for",
"dependency",
"in",
"self",
".",
"dependencies",
":",
"dependencies",
".",
"append",
"(",
"dependency",
".",
"name",
")",
"return",
"dependencies"
] | Returns a list of dependency names. | [
"Returns",
"a",
"list",
"of",
"dependency",
"names",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L57-L62 |
55,163 | project-ncl/pnc-cli | pnc_cli/tools/tasks.py | Tasks.get_task | def get_task(self, name):
"""Get task by name or create it if it does not exists."""
if name in self.tasks.keys():
task = self.tasks[name]
else:
task = Task(name)
self.tasks[name] = task
return task | python | def get_task(self, name):
"""Get task by name or create it if it does not exists."""
if name in self.tasks.keys():
task = self.tasks[name]
else:
task = Task(name)
self.tasks[name] = task
return task | [
"def",
"get_task",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"tasks",
".",
"keys",
"(",
")",
":",
"task",
"=",
"self",
".",
"tasks",
"[",
"name",
"]",
"else",
":",
"task",
"=",
"Task",
"(",
"name",
")",
"self",
".",
... | Get task by name or create it if it does not exists. | [
"Get",
"task",
"by",
"name",
"or",
"create",
"it",
"if",
"it",
"does",
"not",
"exists",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L97-L104 |
55,164 | project-ncl/pnc-cli | pnc_cli/tools/tasks.py | Tasks.get_next | def get_next(self):
"""Return next task from the stack that has all dependencies resolved.
Return None if there are no tasks with resolved dependencies or is there are no more tasks on stack.
Use `count` to check is there are still some task left on the stack.
raise ValueError if total ... | python | def get_next(self):
"""Return next task from the stack that has all dependencies resolved.
Return None if there are no tasks with resolved dependencies or is there are no more tasks on stack.
Use `count` to check is there are still some task left on the stack.
raise ValueError if total ... | [
"def",
"get_next",
"(",
"self",
")",
":",
"self",
".",
"update_tasks_status",
"(",
")",
"if",
"self",
".",
"dirty",
":",
"self",
".",
"tsort",
"(",
")",
"self",
".",
"dirty",
"=",
"False",
"for",
"key",
",",
"task",
"in",
"self",
".",
"tasks",
".",... | Return next task from the stack that has all dependencies resolved.
Return None if there are no tasks with resolved dependencies or is there are no more tasks on stack.
Use `count` to check is there are still some task left on the stack.
raise ValueError if total ordering is not possible. | [
"Return",
"next",
"task",
"from",
"the",
"stack",
"that",
"has",
"all",
"dependencies",
"resolved",
".",
"Return",
"None",
"if",
"there",
"are",
"no",
"tasks",
"with",
"resolved",
"dependencies",
"or",
"is",
"there",
"are",
"no",
"more",
"tasks",
"on",
"st... | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L114-L131 |
55,165 | project-ncl/pnc-cli | pnc_cli/tools/tasks.py | Tasks.count_buildable_tasks | def count_buildable_tasks(self):
"""Count tasks that are new and have dependencies in non FAILED state."""
self.update_tasks_status()
buildable_tasks_count = 0
for key, task in self.tasks.iteritems():
if task.state is Task.State.NEW:
if self.are_dependencies_b... | python | def count_buildable_tasks(self):
"""Count tasks that are new and have dependencies in non FAILED state."""
self.update_tasks_status()
buildable_tasks_count = 0
for key, task in self.tasks.iteritems():
if task.state is Task.State.NEW:
if self.are_dependencies_b... | [
"def",
"count_buildable_tasks",
"(",
"self",
")",
":",
"self",
".",
"update_tasks_status",
"(",
")",
"buildable_tasks_count",
"=",
"0",
"for",
"key",
",",
"task",
"in",
"self",
".",
"tasks",
".",
"iteritems",
"(",
")",
":",
"if",
"task",
".",
"state",
"i... | Count tasks that are new and have dependencies in non FAILED state. | [
"Count",
"tasks",
"that",
"are",
"new",
"and",
"have",
"dependencies",
"in",
"non",
"FAILED",
"state",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L165-L177 |
55,166 | project-ncl/pnc-cli | pnc_cli/tools/tasks.py | Tasks.tsort | def tsort(self):
"""Given a partial ordering, return a totally ordered list.
part is a dict of partial orderings. Each value is a set,
which the key depends on.
The return value is a list of sets, each of which has only
dependencies on items in previous entries in the list.
... | python | def tsort(self):
"""Given a partial ordering, return a totally ordered list.
part is a dict of partial orderings. Each value is a set,
which the key depends on.
The return value is a list of sets, each of which has only
dependencies on items in previous entries in the list.
... | [
"def",
"tsort",
"(",
"self",
")",
":",
"task_dict",
"=",
"{",
"}",
"for",
"key",
",",
"task",
"in",
"self",
".",
"tasks",
".",
"iteritems",
"(",
")",
":",
"task_dict",
"[",
"task",
"]",
"=",
"task",
".",
"dependencies",
"# parts = parts.copy()",
"parts... | Given a partial ordering, return a totally ordered list.
part is a dict of partial orderings. Each value is a set,
which the key depends on.
The return value is a list of sets, each of which has only
dependencies on items in previous entries in the list.
raise ValueError if o... | [
"Given",
"a",
"partial",
"ordering",
"return",
"a",
"totally",
"ordered",
"list",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L197-L223 |
55,167 | PythonRails/rails | rails/config.py | Config._load_config | def _load_config(self):
"""
Load project's config and return dict.
TODO: Convert the original dotted representation to hierarchical.
"""
config = import_module('config')
variables = [var for var in dir(config) if not var.startswith('_')]
return {var: getattr(conf... | python | def _load_config(self):
"""
Load project's config and return dict.
TODO: Convert the original dotted representation to hierarchical.
"""
config = import_module('config')
variables = [var for var in dir(config) if not var.startswith('_')]
return {var: getattr(conf... | [
"def",
"_load_config",
"(",
"self",
")",
":",
"config",
"=",
"import_module",
"(",
"'config'",
")",
"variables",
"=",
"[",
"var",
"for",
"var",
"in",
"dir",
"(",
"config",
")",
"if",
"not",
"var",
".",
"startswith",
"(",
"'_'",
")",
"]",
"return",
"{... | Load project's config and return dict.
TODO: Convert the original dotted representation to hierarchical. | [
"Load",
"project",
"s",
"config",
"and",
"return",
"dict",
"."
] | 1e199b9da4da5b24fef39fc6212d71fc9fbb18a5 | https://github.com/PythonRails/rails/blob/1e199b9da4da5b24fef39fc6212d71fc9fbb18a5/rails/config.py#L18-L26 |
55,168 | PythonRails/rails | rails/config.py | Config.get | def get(name, default=None):
"""
Return variable by name from the project's config.
Name can be a dotted path, like: 'rails.db.type'.
"""
if '.' not in name:
raise Exception("Config path should be divided by at least one dot")
section_name, var_path = name.sp... | python | def get(name, default=None):
"""
Return variable by name from the project's config.
Name can be a dotted path, like: 'rails.db.type'.
"""
if '.' not in name:
raise Exception("Config path should be divided by at least one dot")
section_name, var_path = name.sp... | [
"def",
"get",
"(",
"name",
",",
"default",
"=",
"None",
")",
":",
"if",
"'.'",
"not",
"in",
"name",
":",
"raise",
"Exception",
"(",
"\"Config path should be divided by at least one dot\"",
")",
"section_name",
",",
"var_path",
"=",
"name",
".",
"split",
"(",
... | Return variable by name from the project's config.
Name can be a dotted path, like: 'rails.db.type'. | [
"Return",
"variable",
"by",
"name",
"from",
"the",
"project",
"s",
"config",
"."
] | 1e199b9da4da5b24fef39fc6212d71fc9fbb18a5 | https://github.com/PythonRails/rails/blob/1e199b9da4da5b24fef39fc6212d71fc9fbb18a5/rails/config.py#L29-L39 |
55,169 | CivicSpleen/ambry | ambry/util/sortedcollection.py | SortedCollection.find_lt | def find_lt(self, k):
"""Return last item with a key < k.
Raise ValueError if not found.
"""
i = bisect_left(self._keys, k)
if i:
return self._items[i - 1]
raise ValueError('No item found with key below: %r' % (k,)) | python | def find_lt(self, k):
"""Return last item with a key < k.
Raise ValueError if not found.
"""
i = bisect_left(self._keys, k)
if i:
return self._items[i - 1]
raise ValueError('No item found with key below: %r' % (k,)) | [
"def",
"find_lt",
"(",
"self",
",",
"k",
")",
":",
"i",
"=",
"bisect_left",
"(",
"self",
".",
"_keys",
",",
"k",
")",
"if",
"i",
":",
"return",
"self",
".",
"_items",
"[",
"i",
"-",
"1",
"]",
"raise",
"ValueError",
"(",
"'No item found with key below... | Return last item with a key < k.
Raise ValueError if not found. | [
"Return",
"last",
"item",
"with",
"a",
"key",
"<",
"k",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/util/sortedcollection.py#L200-L209 |
55,170 | CivicSpleen/ambry | ambry/util/sortedcollection.py | SortedCollection.find_ge_index | def find_ge_index(self, k):
'Return first item with a key >= equal to k. Raise ValueError if not found'
i = bisect_left(self._keys, k)
if i != len(self):
return i
raise ValueError('No item found with key at or above: %r' % (k,)) | python | def find_ge_index(self, k):
'Return first item with a key >= equal to k. Raise ValueError if not found'
i = bisect_left(self._keys, k)
if i != len(self):
return i
raise ValueError('No item found with key at or above: %r' % (k,)) | [
"def",
"find_ge_index",
"(",
"self",
",",
"k",
")",
":",
"i",
"=",
"bisect_left",
"(",
"self",
".",
"_keys",
",",
"k",
")",
"if",
"i",
"!=",
"len",
"(",
"self",
")",
":",
"return",
"i",
"raise",
"ValueError",
"(",
"'No item found with key at or above: %r... | Return first item with a key >= equal to k. Raise ValueError if not found | [
"Return",
"first",
"item",
"with",
"a",
"key",
">",
"=",
"equal",
"to",
"k",
".",
"Raise",
"ValueError",
"if",
"not",
"found"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/util/sortedcollection.py#L218-L223 |
55,171 | and800/aioreloader | aioreloader/_contents.py | start | def start(
loop: abstract_loop = None,
interval: float = 0.5,
hook: hook_type = None) -> asyncio.Task:
"""
Start the reloader.
Create the task which is watching loaded modules
and manually added files via ``watch()``
and reloading the process in case of modification.
Att... | python | def start(
loop: abstract_loop = None,
interval: float = 0.5,
hook: hook_type = None) -> asyncio.Task:
"""
Start the reloader.
Create the task which is watching loaded modules
and manually added files via ``watch()``
and reloading the process in case of modification.
Att... | [
"def",
"start",
"(",
"loop",
":",
"abstract_loop",
"=",
"None",
",",
"interval",
":",
"float",
"=",
"0.5",
",",
"hook",
":",
"hook_type",
"=",
"None",
")",
"->",
"asyncio",
".",
"Task",
":",
"if",
"loop",
"is",
"None",
":",
"loop",
"=",
"asyncio",
... | Start the reloader.
Create the task which is watching loaded modules
and manually added files via ``watch()``
and reloading the process in case of modification.
Attach this task to the loop.
If ``hook`` is provided, it will be called right before
the application goes to the reload stage. | [
"Start",
"the",
"reloader",
"."
] | 9f44b537b69185be4f19d31d9427afdc195a8abd | https://github.com/and800/aioreloader/blob/9f44b537b69185be4f19d31d9427afdc195a8abd/aioreloader/_contents.py#L29-L62 |
55,172 | SmartTeleMax/iktomi | iktomi/utils/dt.py | strftime | def strftime(dt, fmt):
'''
`strftime` implementation working before 1900
'''
if _illegal_s.search(fmt):
raise TypeError("This strftime implementation does not handle %s")
if dt.year > 1900:
return dt.strftime(fmt)
fmt = fmt.replace('%c', '%a %b %d %H:%M:%S %Y')\
.re... | python | def strftime(dt, fmt):
'''
`strftime` implementation working before 1900
'''
if _illegal_s.search(fmt):
raise TypeError("This strftime implementation does not handle %s")
if dt.year > 1900:
return dt.strftime(fmt)
fmt = fmt.replace('%c', '%a %b %d %H:%M:%S %Y')\
.re... | [
"def",
"strftime",
"(",
"dt",
",",
"fmt",
")",
":",
"if",
"_illegal_s",
".",
"search",
"(",
"fmt",
")",
":",
"raise",
"TypeError",
"(",
"\"This strftime implementation does not handle %s\"",
")",
"if",
"dt",
".",
"year",
">",
"1900",
":",
"return",
"dt",
"... | `strftime` implementation working before 1900 | [
"strftime",
"implementation",
"working",
"before",
"1900"
] | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/utils/dt.py#L19-L42 |
55,173 | mithro/python-datetime-tz | datetime_tz/detect_windows.py | _detect_timezone_windows | def _detect_timezone_windows():
"""Detect timezone on the windows platform."""
# pylint: disable=global-statement
global win32timezone_to_en
# Try and fetch the key_name for the timezone using
# Get(Dynamic)TimeZoneInformation
tzi = DTZI_c()
kernel32 = ctypes.windll.kernel32
getter = kernel32.GetTimeZo... | python | def _detect_timezone_windows():
"""Detect timezone on the windows platform."""
# pylint: disable=global-statement
global win32timezone_to_en
# Try and fetch the key_name for the timezone using
# Get(Dynamic)TimeZoneInformation
tzi = DTZI_c()
kernel32 = ctypes.windll.kernel32
getter = kernel32.GetTimeZo... | [
"def",
"_detect_timezone_windows",
"(",
")",
":",
"# pylint: disable=global-statement",
"global",
"win32timezone_to_en",
"# Try and fetch the key_name for the timezone using",
"# Get(Dynamic)TimeZoneInformation",
"tzi",
"=",
"DTZI_c",
"(",
")",
"kernel32",
"=",
"ctypes",
".",
"... | Detect timezone on the windows platform. | [
"Detect",
"timezone",
"on",
"the",
"windows",
"platform",
"."
] | 3c682d003f8b28e39f0c096773e471aeb68e6bbb | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/detect_windows.py#L89-L126 |
55,174 | SmartTeleMax/iktomi | iktomi/auth.py | CookieAuth.login | def login(self, template='login'):
'''
This property will return component which will handle login requests.
auth.login(template='login.html')
'''
def _login(env, data):
form = self._login_form(env)
next = env.request.GET.get('next', '/')
... | python | def login(self, template='login'):
'''
This property will return component which will handle login requests.
auth.login(template='login.html')
'''
def _login(env, data):
form = self._login_form(env)
next = env.request.GET.get('next', '/')
... | [
"def",
"login",
"(",
"self",
",",
"template",
"=",
"'login'",
")",
":",
"def",
"_login",
"(",
"env",
",",
"data",
")",
":",
"form",
"=",
"self",
".",
"_login_form",
"(",
"env",
")",
"next",
"=",
"env",
".",
"request",
".",
"GET",
".",
"get",
"(",... | This property will return component which will handle login requests.
auth.login(template='login.html') | [
"This",
"property",
"will",
"return",
"component",
"which",
"will",
"handle",
"login",
"requests",
"."
] | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/auth.py#L104-L126 |
55,175 | SmartTeleMax/iktomi | iktomi/auth.py | CookieAuth.logout | def logout(self, redirect_to='/'):
'''
This property will return component which will handle logout requests.
It only handles POST requests and do not display any rendered content.
This handler deletes session id from `storage`. If there is no
session id provided or id is incorre... | python | def logout(self, redirect_to='/'):
'''
This property will return component which will handle logout requests.
It only handles POST requests and do not display any rendered content.
This handler deletes session id from `storage`. If there is no
session id provided or id is incorre... | [
"def",
"logout",
"(",
"self",
",",
"redirect_to",
"=",
"'/'",
")",
":",
"def",
"_logout",
"(",
"env",
",",
"data",
")",
":",
"location",
"=",
"redirect_to",
"if",
"location",
"is",
"None",
"and",
"env",
".",
"request",
".",
"referer",
":",
"location",
... | This property will return component which will handle logout requests.
It only handles POST requests and do not display any rendered content.
This handler deletes session id from `storage`. If there is no
session id provided or id is incorrect handler silently redirects to
login url and ... | [
"This",
"property",
"will",
"return",
"component",
"which",
"will",
"handle",
"logout",
"requests",
".",
"It",
"only",
"handles",
"POST",
"requests",
"and",
"do",
"not",
"display",
"any",
"rendered",
"content",
".",
"This",
"handler",
"deletes",
"session",
"id... | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/auth.py#L128-L145 |
55,176 | project-ncl/pnc-cli | pnc_cli/swagger_client/models/support_level_page.py | SupportLevelPage.content | def content(self, content):
"""
Sets the content of this SupportLevelPage.
:param content: The content of this SupportLevelPage.
:type: list[str]
"""
allowed_values = ["UNRELEASED", "EARLYACCESS", "SUPPORTED", "EXTENDED_SUPPORT", "EOL"]
if not set(content).issubs... | python | def content(self, content):
"""
Sets the content of this SupportLevelPage.
:param content: The content of this SupportLevelPage.
:type: list[str]
"""
allowed_values = ["UNRELEASED", "EARLYACCESS", "SUPPORTED", "EXTENDED_SUPPORT", "EOL"]
if not set(content).issubs... | [
"def",
"content",
"(",
"self",
",",
"content",
")",
":",
"allowed_values",
"=",
"[",
"\"UNRELEASED\"",
",",
"\"EARLYACCESS\"",
",",
"\"SUPPORTED\"",
",",
"\"EXTENDED_SUPPORT\"",
",",
"\"EOL\"",
"]",
"if",
"not",
"set",
"(",
"content",
")",
".",
"issubset",
"... | Sets the content of this SupportLevelPage.
:param content: The content of this SupportLevelPage.
:type: list[str] | [
"Sets",
"the",
"content",
"of",
"this",
"SupportLevelPage",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/models/support_level_page.py#L140-L155 |
55,177 | CivicSpleen/ambry | ambry/util/flo.py | copy_file_or_flo | def copy_file_or_flo(input_, output, buffer_size=64 * 1024, cb=None):
""" Copy a file name or file-like-object to another
file name or file-like object"""
assert bool(input_)
assert bool(output)
input_opened = False
output_opened = False
try:
if isinstance(input_, string_types):
... | python | def copy_file_or_flo(input_, output, buffer_size=64 * 1024, cb=None):
""" Copy a file name or file-like-object to another
file name or file-like object"""
assert bool(input_)
assert bool(output)
input_opened = False
output_opened = False
try:
if isinstance(input_, string_types):
... | [
"def",
"copy_file_or_flo",
"(",
"input_",
",",
"output",
",",
"buffer_size",
"=",
"64",
"*",
"1024",
",",
"cb",
"=",
"None",
")",
":",
"assert",
"bool",
"(",
"input_",
")",
"assert",
"bool",
"(",
"output",
")",
"input_opened",
"=",
"False",
"output_opene... | Copy a file name or file-like-object to another
file name or file-like object | [
"Copy",
"a",
"file",
"name",
"or",
"file",
"-",
"like",
"-",
"object",
"to",
"another",
"file",
"name",
"or",
"file",
"-",
"like",
"object"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/util/flo.py#L38-L85 |
55,178 | caktus/rapidsms-tropo | rtropo/outgoing.py | TropoBackend.execute_tropo_program | def execute_tropo_program(self, program):
"""
Ask Tropo to execute a program for us.
We can't do this directly;
we have to ask Tropo to call us back and then give Tropo the
program in the response body to that request from Tropo.
But we can pass data to Tropo and ask Tr... | python | def execute_tropo_program(self, program):
"""
Ask Tropo to execute a program for us.
We can't do this directly;
we have to ask Tropo to call us back and then give Tropo the
program in the response body to that request from Tropo.
But we can pass data to Tropo and ask Tr... | [
"def",
"execute_tropo_program",
"(",
"self",
",",
"program",
")",
":",
"# The signer will also \"pickle\" the data structure for us",
"signed_program",
"=",
"signing",
".",
"dumps",
"(",
"program",
")",
"params",
"=",
"{",
"'action'",
":",
"'create'",
",",
"# Required... | Ask Tropo to execute a program for us.
We can't do this directly;
we have to ask Tropo to call us back and then give Tropo the
program in the response body to that request from Tropo.
But we can pass data to Tropo and ask Tropo to pass it back
to us when Tropo calls us back. So... | [
"Ask",
"Tropo",
"to",
"execute",
"a",
"program",
"for",
"us",
"."
] | 7680f351053837f210bf90576fa8f947c8f1c5c6 | https://github.com/caktus/rapidsms-tropo/blob/7680f351053837f210bf90576fa8f947c8f1c5c6/rtropo/outgoing.py#L40-L96 |
55,179 | caktus/rapidsms-tropo | rtropo/outgoing.py | TropoBackend.send | def send(self, id_, text, identities, context=None):
"""
Send messages when using RapidSMS 0.14.0 or later.
We can send multiple messages in one Tropo program, so we do
that.
:param id_: Unused, included for compatibility with RapidSMS.
:param string text: The message t... | python | def send(self, id_, text, identities, context=None):
"""
Send messages when using RapidSMS 0.14.0 or later.
We can send multiple messages in one Tropo program, so we do
that.
:param id_: Unused, included for compatibility with RapidSMS.
:param string text: The message t... | [
"def",
"send",
"(",
"self",
",",
"id_",
",",
"text",
",",
"identities",
",",
"context",
"=",
"None",
")",
":",
"# Build our program",
"from_",
"=",
"self",
".",
"config",
"[",
"'number'",
"]",
".",
"replace",
"(",
"'-'",
",",
"''",
")",
"commands",
"... | Send messages when using RapidSMS 0.14.0 or later.
We can send multiple messages in one Tropo program, so we do
that.
:param id_: Unused, included for compatibility with RapidSMS.
:param string text: The message text to send.
:param identities: A list of identities to send the ... | [
"Send",
"messages",
"when",
"using",
"RapidSMS",
"0",
".",
"14",
".",
"0",
"or",
"later",
"."
] | 7680f351053837f210bf90576fa8f947c8f1c5c6 | https://github.com/caktus/rapidsms-tropo/blob/7680f351053837f210bf90576fa8f947c8f1c5c6/rtropo/outgoing.py#L98-L135 |
55,180 | CivicSpleen/ambry | ambry/valuetype/geo.py | CensusTractGeoid.dotted | def dotted(self):
"""Return just the tract number, excluding the state and county, in the dotted format"""
v = str(self.geoid.tract).zfill(6)
return v[0:4] + '.' + v[4:] | python | def dotted(self):
"""Return just the tract number, excluding the state and county, in the dotted format"""
v = str(self.geoid.tract).zfill(6)
return v[0:4] + '.' + v[4:] | [
"def",
"dotted",
"(",
"self",
")",
":",
"v",
"=",
"str",
"(",
"self",
".",
"geoid",
".",
"tract",
")",
".",
"zfill",
"(",
"6",
")",
"return",
"v",
"[",
"0",
":",
"4",
"]",
"+",
"'.'",
"+",
"v",
"[",
"4",
":",
"]"
] | Return just the tract number, excluding the state and county, in the dotted format | [
"Return",
"just",
"the",
"tract",
"number",
"excluding",
"the",
"state",
"and",
"county",
"in",
"the",
"dotted",
"format"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/geo.py#L115-L118 |
55,181 | CivicSpleen/ambry | ambry/valuetype/geo.py | GeoCensusVT.subclass | def subclass(cls, vt_code, vt_args):
"""Return a dynamic subclass that has the extra parameters built in"""
from geoid import get_class
import geoid.census
parser = get_class(geoid.census, vt_args.strip('/')).parse
cls = type(vt_code.replace('/', '_'), (cls,), {'vt_code': vt_co... | python | def subclass(cls, vt_code, vt_args):
"""Return a dynamic subclass that has the extra parameters built in"""
from geoid import get_class
import geoid.census
parser = get_class(geoid.census, vt_args.strip('/')).parse
cls = type(vt_code.replace('/', '_'), (cls,), {'vt_code': vt_co... | [
"def",
"subclass",
"(",
"cls",
",",
"vt_code",
",",
"vt_args",
")",
":",
"from",
"geoid",
"import",
"get_class",
"import",
"geoid",
".",
"census",
"parser",
"=",
"get_class",
"(",
"geoid",
".",
"census",
",",
"vt_args",
".",
"strip",
"(",
"'/'",
")",
"... | Return a dynamic subclass that has the extra parameters built in | [
"Return",
"a",
"dynamic",
"subclass",
"that",
"has",
"the",
"extra",
"parameters",
"built",
"in"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/geo.py#L139-L150 |
55,182 | derpston/python-multitail2 | src/multitail2.py | TailedFile._open | def _open(self, path, skip_to_end = True, offset = None):
"""Open `path`, optionally seeking to the end if `skip_to_end` is True."""
fh = os.fdopen(os.open(path, os.O_RDONLY | os.O_NONBLOCK))
# If the file is being opened for the first time, jump to the end.
# Otherwise, it is being reopened af... | python | def _open(self, path, skip_to_end = True, offset = None):
"""Open `path`, optionally seeking to the end if `skip_to_end` is True."""
fh = os.fdopen(os.open(path, os.O_RDONLY | os.O_NONBLOCK))
# If the file is being opened for the first time, jump to the end.
# Otherwise, it is being reopened af... | [
"def",
"_open",
"(",
"self",
",",
"path",
",",
"skip_to_end",
"=",
"True",
",",
"offset",
"=",
"None",
")",
":",
"fh",
"=",
"os",
".",
"fdopen",
"(",
"os",
".",
"open",
"(",
"path",
",",
"os",
".",
"O_RDONLY",
"|",
"os",
".",
"O_NONBLOCK",
")",
... | Open `path`, optionally seeking to the end if `skip_to_end` is True. | [
"Open",
"path",
"optionally",
"seeking",
"to",
"the",
"end",
"if",
"skip_to_end",
"is",
"True",
"."
] | 4f05311da3b18f7a8cfe2877e68e35e88c07298d | https://github.com/derpston/python-multitail2/blob/4f05311da3b18f7a8cfe2877e68e35e88c07298d/src/multitail2.py#L27-L47 |
55,183 | derpston/python-multitail2 | src/multitail2.py | TailedFile._read | def _read(self, limit = None):
"""Checks the file for new data and refills the buffer if it finds any."""
# The code that used to be here was self._fh.read(limit)
# However, this broke on OSX. os.read, however, works fine, but doesn't
# take the None argument or have any way to specify "read to ... | python | def _read(self, limit = None):
"""Checks the file for new data and refills the buffer if it finds any."""
# The code that used to be here was self._fh.read(limit)
# However, this broke on OSX. os.read, however, works fine, but doesn't
# take the None argument or have any way to specify "read to ... | [
"def",
"_read",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"# The code that used to be here was self._fh.read(limit)",
"# However, this broke on OSX. os.read, however, works fine, but doesn't",
"# take the None argument or have any way to specify \"read to the end\".",
"# This emula... | Checks the file for new data and refills the buffer if it finds any. | [
"Checks",
"the",
"file",
"for",
"new",
"data",
"and",
"refills",
"the",
"buffer",
"if",
"it",
"finds",
"any",
"."
] | 4f05311da3b18f7a8cfe2877e68e35e88c07298d | https://github.com/derpston/python-multitail2/blob/4f05311da3b18f7a8cfe2877e68e35e88c07298d/src/multitail2.py#L49-L65 |
55,184 | derpston/python-multitail2 | src/multitail2.py | TailedFile.hasBeenRotated | def hasBeenRotated(self):
"""Returns a boolean indicating whether the file has been removed and recreated during the time it has been open."""
try:
# If the inodes don't match, it means the file has been replaced.
# The inode number cannot be recycled as long as we hold the
# file... | python | def hasBeenRotated(self):
"""Returns a boolean indicating whether the file has been removed and recreated during the time it has been open."""
try:
# If the inodes don't match, it means the file has been replaced.
# The inode number cannot be recycled as long as we hold the
# file... | [
"def",
"hasBeenRotated",
"(",
"self",
")",
":",
"try",
":",
"# If the inodes don't match, it means the file has been replaced.",
"# The inode number cannot be recycled as long as we hold the",
"# filehandle open, so this test can be trusted.",
"return",
"os",
".",
"stat",
"(",
"self"... | Returns a boolean indicating whether the file has been removed and recreated during the time it has been open. | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"file",
"has",
"been",
"removed",
"and",
"recreated",
"during",
"the",
"time",
"it",
"has",
"been",
"open",
"."
] | 4f05311da3b18f7a8cfe2877e68e35e88c07298d | https://github.com/derpston/python-multitail2/blob/4f05311da3b18f7a8cfe2877e68e35e88c07298d/src/multitail2.py#L68-L77 |
55,185 | derpston/python-multitail2 | src/multitail2.py | TailedFile.reopen | def reopen(self):
"""Reopens the file. Usually used after it has been rotated."""
# Read any remaining content in the file and store it in a buffer.
self._read()
# Close it to ensure we don't leak file descriptors
self._close()
# Reopen the file.
try:
self._open... | python | def reopen(self):
"""Reopens the file. Usually used after it has been rotated."""
# Read any remaining content in the file and store it in a buffer.
self._read()
# Close it to ensure we don't leak file descriptors
self._close()
# Reopen the file.
try:
self._open... | [
"def",
"reopen",
"(",
"self",
")",
":",
"# Read any remaining content in the file and store it in a buffer.",
"self",
".",
"_read",
"(",
")",
"# Close it to ensure we don't leak file descriptors",
"self",
".",
"_close",
"(",
")",
"# Reopen the file.",
"try",
":",
"self",
... | Reopens the file. Usually used after it has been rotated. | [
"Reopens",
"the",
"file",
".",
"Usually",
"used",
"after",
"it",
"has",
"been",
"rotated",
"."
] | 4f05311da3b18f7a8cfe2877e68e35e88c07298d | https://github.com/derpston/python-multitail2/blob/4f05311da3b18f7a8cfe2877e68e35e88c07298d/src/multitail2.py#L79-L92 |
55,186 | derpston/python-multitail2 | src/multitail2.py | TailedFile.readlines | def readlines(self):
"""A generator producing lines from the file."""
# If the file is not open, there's nothing to return
if not self._fh:
raise StopIteration
at_eof = False
while True:
# Clean the buffer sometimes.
if self._bufoffset > (self._maxreadsize / 2)... | python | def readlines(self):
"""A generator producing lines from the file."""
# If the file is not open, there's nothing to return
if not self._fh:
raise StopIteration
at_eof = False
while True:
# Clean the buffer sometimes.
if self._bufoffset > (self._maxreadsize / 2)... | [
"def",
"readlines",
"(",
"self",
")",
":",
"# If the file is not open, there's nothing to return",
"if",
"not",
"self",
".",
"_fh",
":",
"raise",
"StopIteration",
"at_eof",
"=",
"False",
"while",
"True",
":",
"# Clean the buffer sometimes.",
"if",
"self",
".",
"_buf... | A generator producing lines from the file. | [
"A",
"generator",
"producing",
"lines",
"from",
"the",
"file",
"."
] | 4f05311da3b18f7a8cfe2877e68e35e88c07298d | https://github.com/derpston/python-multitail2/blob/4f05311da3b18f7a8cfe2877e68e35e88c07298d/src/multitail2.py#L94-L135 |
55,187 | derpston/python-multitail2 | src/multitail2.py | MultiTail._rescan | def _rescan(self, skip_to_end = True):
"""Check for new files, deleted files, and rotated files."""
# Get listing of matching files.
paths = []
for single_glob in self._globspec:
paths.extend(glob.glob(single_glob))
# Remove files that don't appear in the new list.
for pat... | python | def _rescan(self, skip_to_end = True):
"""Check for new files, deleted files, and rotated files."""
# Get listing of matching files.
paths = []
for single_glob in self._globspec:
paths.extend(glob.glob(single_glob))
# Remove files that don't appear in the new list.
for pat... | [
"def",
"_rescan",
"(",
"self",
",",
"skip_to_end",
"=",
"True",
")",
":",
"# Get listing of matching files.",
"paths",
"=",
"[",
"]",
"for",
"single_glob",
"in",
"self",
".",
"_globspec",
":",
"paths",
".",
"extend",
"(",
"glob",
".",
"glob",
"(",
"single_... | Check for new files, deleted files, and rotated files. | [
"Check",
"for",
"new",
"files",
"deleted",
"files",
"and",
"rotated",
"files",
"."
] | 4f05311da3b18f7a8cfe2877e68e35e88c07298d | https://github.com/derpston/python-multitail2/blob/4f05311da3b18f7a8cfe2877e68e35e88c07298d/src/multitail2.py#L153-L176 |
55,188 | twisted/epsilon | epsilon/amprouter.py | Route.connectTo | def connectTo(self, remoteRouteName):
"""
Set the name of the route which will be added to outgoing boxes.
"""
self.remoteRouteName = remoteRouteName
# This route must not be started before its router is started. If
# sender is None, then the router is not started. When... | python | def connectTo(self, remoteRouteName):
"""
Set the name of the route which will be added to outgoing boxes.
"""
self.remoteRouteName = remoteRouteName
# This route must not be started before its router is started. If
# sender is None, then the router is not started. When... | [
"def",
"connectTo",
"(",
"self",
",",
"remoteRouteName",
")",
":",
"self",
".",
"remoteRouteName",
"=",
"remoteRouteName",
"# This route must not be started before its router is started. If",
"# sender is None, then the router is not started. When the router is",
"# started, it will ... | Set the name of the route which will be added to outgoing boxes. | [
"Set",
"the",
"name",
"of",
"the",
"route",
"which",
"will",
"be",
"added",
"to",
"outgoing",
"boxes",
"."
] | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/amprouter.py#L54-L63 |
55,189 | twisted/epsilon | epsilon/amprouter.py | Route.sendBox | def sendBox(self, box):
"""
Add the route and send the box.
"""
if self.remoteRouteName is _unspecified:
raise RouteNotConnected()
if self.remoteRouteName is not None:
box[_ROUTE] = self.remoteRouteName.encode('ascii')
self.router._sender.sendBox(b... | python | def sendBox(self, box):
"""
Add the route and send the box.
"""
if self.remoteRouteName is _unspecified:
raise RouteNotConnected()
if self.remoteRouteName is not None:
box[_ROUTE] = self.remoteRouteName.encode('ascii')
self.router._sender.sendBox(b... | [
"def",
"sendBox",
"(",
"self",
",",
"box",
")",
":",
"if",
"self",
".",
"remoteRouteName",
"is",
"_unspecified",
":",
"raise",
"RouteNotConnected",
"(",
")",
"if",
"self",
".",
"remoteRouteName",
"is",
"not",
"None",
":",
"box",
"[",
"_ROUTE",
"]",
"=",
... | Add the route and send the box. | [
"Add",
"the",
"route",
"and",
"send",
"the",
"box",
"."
] | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/amprouter.py#L87-L95 |
55,190 | twisted/epsilon | epsilon/amprouter.py | Router.bindRoute | def bindRoute(self, receiver, routeName=_unspecified):
"""
Create a new route to associate the given route name with the given
receiver.
@type routeName: C{unicode} or L{NoneType}
@param routeName: The identifier for the newly created route. If
C{None}, boxes with n... | python | def bindRoute(self, receiver, routeName=_unspecified):
"""
Create a new route to associate the given route name with the given
receiver.
@type routeName: C{unicode} or L{NoneType}
@param routeName: The identifier for the newly created route. If
C{None}, boxes with n... | [
"def",
"bindRoute",
"(",
"self",
",",
"receiver",
",",
"routeName",
"=",
"_unspecified",
")",
":",
"if",
"routeName",
"is",
"_unspecified",
":",
"routeName",
"=",
"self",
".",
"createRouteIdentifier",
"(",
")",
"# self._sender may yet be None; if so, this route goes i... | Create a new route to associate the given route name with the given
receiver.
@type routeName: C{unicode} or L{NoneType}
@param routeName: The identifier for the newly created route. If
C{None}, boxes with no route in them will be delivered to this
receiver.
@r... | [
"Create",
"a",
"new",
"route",
"to",
"associate",
"the",
"given",
"route",
"name",
"with",
"the",
"given",
"receiver",
"."
] | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/amprouter.py#L147-L168 |
55,191 | twisted/epsilon | epsilon/amprouter.py | Router.startReceivingBoxes | def startReceivingBoxes(self, sender):
"""
Initialize route tracking objects.
"""
self._sender = sender
for routeName, route in self._unstarted.iteritems():
# Any route which has been bound but which does not yet have a
# remote route name should not yet b... | python | def startReceivingBoxes(self, sender):
"""
Initialize route tracking objects.
"""
self._sender = sender
for routeName, route in self._unstarted.iteritems():
# Any route which has been bound but which does not yet have a
# remote route name should not yet b... | [
"def",
"startReceivingBoxes",
"(",
"self",
",",
"sender",
")",
":",
"self",
".",
"_sender",
"=",
"sender",
"for",
"routeName",
",",
"route",
"in",
"self",
".",
"_unstarted",
".",
"iteritems",
"(",
")",
":",
"# Any route which has been bound but which does not yet ... | Initialize route tracking objects. | [
"Initialize",
"route",
"tracking",
"objects",
"."
] | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/amprouter.py#L171-L183 |
55,192 | project-ncl/pnc-cli | pnc_cli/brewpush.py | push_build | def push_build(id, tag_prefix):
"""
Push build to Brew
"""
req = swagger_client.BuildRecordPushRequestRest()
req.tag_prefix = tag_prefix
req.build_record_id = id
response = utils.checked_api_call(pnc_api.build_push, 'push', body=req)
if response:
return utils.format_json_list(res... | python | def push_build(id, tag_prefix):
"""
Push build to Brew
"""
req = swagger_client.BuildRecordPushRequestRest()
req.tag_prefix = tag_prefix
req.build_record_id = id
response = utils.checked_api_call(pnc_api.build_push, 'push', body=req)
if response:
return utils.format_json_list(res... | [
"def",
"push_build",
"(",
"id",
",",
"tag_prefix",
")",
":",
"req",
"=",
"swagger_client",
".",
"BuildRecordPushRequestRest",
"(",
")",
"req",
".",
"tag_prefix",
"=",
"tag_prefix",
"req",
".",
"build_record_id",
"=",
"id",
"response",
"=",
"utils",
".",
"che... | Push build to Brew | [
"Push",
"build",
"to",
"Brew"
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/brewpush.py#L16-L25 |
55,193 | project-ncl/pnc-cli | pnc_cli/brewpush.py | push_build_set | def push_build_set(id, tag_prefix):
"""
Push build set to Brew
"""
req = swagger_client.BuildConfigSetRecordPushRequestRest()
req.tag_prefix = tag_prefix
req.build_config_set_record_id = id
response = utils.checked_api_call(pnc_api.build_push, 'push_record_set', body=req)
if response:
... | python | def push_build_set(id, tag_prefix):
"""
Push build set to Brew
"""
req = swagger_client.BuildConfigSetRecordPushRequestRest()
req.tag_prefix = tag_prefix
req.build_config_set_record_id = id
response = utils.checked_api_call(pnc_api.build_push, 'push_record_set', body=req)
if response:
... | [
"def",
"push_build_set",
"(",
"id",
",",
"tag_prefix",
")",
":",
"req",
"=",
"swagger_client",
".",
"BuildConfigSetRecordPushRequestRest",
"(",
")",
"req",
".",
"tag_prefix",
"=",
"tag_prefix",
"req",
".",
"build_config_set_record_id",
"=",
"id",
"response",
"=",
... | Push build set to Brew | [
"Push",
"build",
"set",
"to",
"Brew"
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/brewpush.py#L31-L40 |
55,194 | project-ncl/pnc-cli | pnc_cli/brewpush.py | push_build_status | def push_build_status(id):
"""
Get status of Brew push.
"""
response = utils.checked_api_call(pnc_api.build_push, 'status', build_record_id=id)
if response:
return utils.format_json(response) | python | def push_build_status(id):
"""
Get status of Brew push.
"""
response = utils.checked_api_call(pnc_api.build_push, 'status', build_record_id=id)
if response:
return utils.format_json(response) | [
"def",
"push_build_status",
"(",
"id",
")",
":",
"response",
"=",
"utils",
".",
"checked_api_call",
"(",
"pnc_api",
".",
"build_push",
",",
"'status'",
",",
"build_record_id",
"=",
"id",
")",
"if",
"response",
":",
"return",
"utils",
".",
"format_json",
"(",... | Get status of Brew push. | [
"Get",
"status",
"of",
"Brew",
"push",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/brewpush.py#L45-L51 |
55,195 | SmartTeleMax/iktomi | iktomi/db/files.py | FileManager.create_transient | def create_transient(self, input_stream, original_name, length=None):
'''Create TransientFile and file on FS from given input stream and
original file name.'''
ext = os.path.splitext(original_name)[1]
transient = self.new_transient(ext)
if not os.path.isdir(self.transient_root):... | python | def create_transient(self, input_stream, original_name, length=None):
'''Create TransientFile and file on FS from given input stream and
original file name.'''
ext = os.path.splitext(original_name)[1]
transient = self.new_transient(ext)
if not os.path.isdir(self.transient_root):... | [
"def",
"create_transient",
"(",
"self",
",",
"input_stream",
",",
"original_name",
",",
"length",
"=",
"None",
")",
":",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"original_name",
")",
"[",
"1",
"]",
"transient",
"=",
"self",
".",
"new_transie... | Create TransientFile and file on FS from given input stream and
original file name. | [
"Create",
"TransientFile",
"and",
"file",
"on",
"FS",
"from",
"given",
"input",
"stream",
"and",
"original",
"file",
"name",
"."
] | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/db/files.py#L149-L158 |
55,196 | SmartTeleMax/iktomi | iktomi/db/files.py | FileManager.new_transient | def new_transient(self, ext=''):
'''Creates empty TransientFile with random name and given extension.
File on FS is not created'''
name = random_name(self.transient_length) + ext
return TransientFile(self.transient_root, name, self) | python | def new_transient(self, ext=''):
'''Creates empty TransientFile with random name and given extension.
File on FS is not created'''
name = random_name(self.transient_length) + ext
return TransientFile(self.transient_root, name, self) | [
"def",
"new_transient",
"(",
"self",
",",
"ext",
"=",
"''",
")",
":",
"name",
"=",
"random_name",
"(",
"self",
".",
"transient_length",
")",
"+",
"ext",
"return",
"TransientFile",
"(",
"self",
".",
"transient_root",
",",
"name",
",",
"self",
")"
] | Creates empty TransientFile with random name and given extension.
File on FS is not created | [
"Creates",
"empty",
"TransientFile",
"with",
"random",
"name",
"and",
"given",
"extension",
".",
"File",
"on",
"FS",
"is",
"not",
"created"
] | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/db/files.py#L160-L164 |
55,197 | SmartTeleMax/iktomi | iktomi/db/files.py | FileManager.get_transient | def get_transient(self, name):
'''Restores TransientFile object with given name.
Should be used when form is submitted with file name and no file'''
# security checks: basically no folders are allowed
assert not ('/' in name or '\\' in name or name[0] in '.~')
transient = Transie... | python | def get_transient(self, name):
'''Restores TransientFile object with given name.
Should be used when form is submitted with file name and no file'''
# security checks: basically no folders are allowed
assert not ('/' in name or '\\' in name or name[0] in '.~')
transient = Transie... | [
"def",
"get_transient",
"(",
"self",
",",
"name",
")",
":",
"# security checks: basically no folders are allowed",
"assert",
"not",
"(",
"'/'",
"in",
"name",
"or",
"'\\\\'",
"in",
"name",
"or",
"name",
"[",
"0",
"]",
"in",
"'.~'",
")",
"transient",
"=",
"Tra... | Restores TransientFile object with given name.
Should be used when form is submitted with file name and no file | [
"Restores",
"TransientFile",
"object",
"with",
"given",
"name",
".",
"Should",
"be",
"used",
"when",
"form",
"is",
"submitted",
"with",
"file",
"name",
"and",
"no",
"file"
] | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/db/files.py#L166-L175 |
55,198 | SmartTeleMax/iktomi | iktomi/db/files.py | FileManager.store | def store(self, transient_file, persistent_file):
'''Makes PersistentFile from TransientFile'''
#for i in range(5):
# persistent_file = PersistentFile(self.persistent_root,
# persistent_name, self)
# if not os.path.exists(persistent_file.... | python | def store(self, transient_file, persistent_file):
'''Makes PersistentFile from TransientFile'''
#for i in range(5):
# persistent_file = PersistentFile(self.persistent_root,
# persistent_name, self)
# if not os.path.exists(persistent_file.... | [
"def",
"store",
"(",
"self",
",",
"transient_file",
",",
"persistent_file",
")",
":",
"#for i in range(5):",
"# persistent_file = PersistentFile(self.persistent_root,",
"# persistent_name, self)",
"# if not os.path.exists(persistent_file.path):",
... | Makes PersistentFile from TransientFile | [
"Makes",
"PersistentFile",
"from",
"TransientFile"
] | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/db/files.py#L177-L190 |
55,199 | CivicSpleen/ambry | ambry/util/debug.py | trace | def trace(fn): # pragma: no cover
""" Prints parameteters and return values of the each call of the wrapped function.
Usage:
decorate appropriate function or method:
@trace
def myf():
...
"""
def wrapped(*args, **kwargs):
msg = []
msg.appe... | python | def trace(fn): # pragma: no cover
""" Prints parameteters and return values of the each call of the wrapped function.
Usage:
decorate appropriate function or method:
@trace
def myf():
...
"""
def wrapped(*args, **kwargs):
msg = []
msg.appe... | [
"def",
"trace",
"(",
"fn",
")",
":",
"# pragma: no cover",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"msg",
"=",
"[",
"]",
"msg",
".",
"append",
"(",
"'Enter {}('",
".",
"format",
"(",
"fn",
".",
"__name__",
")",
")",
... | Prints parameteters and return values of the each call of the wrapped function.
Usage:
decorate appropriate function or method:
@trace
def myf():
... | [
"Prints",
"parameteters",
"and",
"return",
"values",
"of",
"the",
"each",
"call",
"of",
"the",
"wrapped",
"function",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/util/debug.py#L37-L63 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.