repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook.get_user | async def get_user(self, user_id, page_id):
"""
Query a user from the API and return its JSON
"""
access_token = self._access_token(page_id=page_id)
params = {
'fields': 'first_name,last_name,profile_pic,locale,timezone'
',gender',
... | python | async def get_user(self, user_id, page_id):
"""
Query a user from the API and return its JSON
"""
access_token = self._access_token(page_id=page_id)
params = {
'fields': 'first_name,last_name,profile_pic,locale,timezone'
',gender',
... | [
"async",
"def",
"get_user",
"(",
"self",
",",
"user_id",
",",
"page_id",
")",
":",
"access_token",
"=",
"self",
".",
"_access_token",
"(",
"page_id",
"=",
"page_id",
")",
"params",
"=",
"{",
"'fields'",
":",
"'first_name,last_name,profile_pic,locale,timezone'",
... | Query a user from the API and return its JSON | [
"Query",
"a",
"user",
"from",
"the",
"API",
"and",
"return",
"its",
"JSON"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L953-L971 | train | Query a user from the API and return its JSON representation. |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook.ensure_usable_media | async def ensure_usable_media(self, media: BaseMedia) -> UrlMedia:
"""
So far, let's just accept URL media. We'll see in the future how it
goes.
"""
if not isinstance(media, UrlMedia):
raise ValueError('Facebook platform only accepts URL media')
return media | python | async def ensure_usable_media(self, media: BaseMedia) -> UrlMedia:
"""
So far, let's just accept URL media. We'll see in the future how it
goes.
"""
if not isinstance(media, UrlMedia):
raise ValueError('Facebook platform only accepts URL media')
return media | [
"async",
"def",
"ensure_usable_media",
"(",
"self",
",",
"media",
":",
"BaseMedia",
")",
"->",
"UrlMedia",
":",
"if",
"not",
"isinstance",
"(",
"media",
",",
"UrlMedia",
")",
":",
"raise",
"ValueError",
"(",
"'Facebook platform only accepts URL media'",
")",
"re... | So far, let's just accept URL media. We'll see in the future how it
goes. | [
"So",
"far",
"let",
"s",
"just",
"accept",
"URL",
"media",
".",
"We",
"ll",
"see",
"in",
"the",
"future",
"how",
"it",
"goes",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L973-L982 | train | Ensure that the given media is usable. |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._make_fake_message | def _make_fake_message(self, user_id, page_id, payload):
"""
Creates a fake message for the given user_id. It contains a postback
with the given payload.
"""
event = {
'sender': {
'id': user_id,
},
'recipient': {
... | python | def _make_fake_message(self, user_id, page_id, payload):
"""
Creates a fake message for the given user_id. It contains a postback
with the given payload.
"""
event = {
'sender': {
'id': user_id,
},
'recipient': {
... | [
"def",
"_make_fake_message",
"(",
"self",
",",
"user_id",
",",
"page_id",
",",
"payload",
")",
":",
"event",
"=",
"{",
"'sender'",
":",
"{",
"'id'",
":",
"user_id",
",",
"}",
",",
"'recipient'",
":",
"{",
"'id'",
":",
"page_id",
",",
"}",
",",
"'post... | Creates a fake message for the given user_id. It contains a postback
with the given payload. | [
"Creates",
"a",
"fake",
"message",
"for",
"the",
"given",
"user_id",
".",
"It",
"contains",
"a",
"postback",
"with",
"the",
"given",
"payload",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L984-L1002 | train | Creates a fake message for the given user_id page_id and payload. |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._message_from_sr | def _message_from_sr(self, token: Text, payload: Any) \
-> Optional[BaseMessage]:
"""
Tries to verify the signed request
"""
page = self.settings()
secret = page['app_secret']
try:
sr_data = SignedRequest.parse(token, secret)
except (Type... | python | def _message_from_sr(self, token: Text, payload: Any) \
-> Optional[BaseMessage]:
"""
Tries to verify the signed request
"""
page = self.settings()
secret = page['app_secret']
try:
sr_data = SignedRequest.parse(token, secret)
except (Type... | [
"def",
"_message_from_sr",
"(",
"self",
",",
"token",
":",
"Text",
",",
"payload",
":",
"Any",
")",
"->",
"Optional",
"[",
"BaseMessage",
"]",
":",
"page",
"=",
"self",
".",
"settings",
"(",
")",
"secret",
"=",
"page",
"[",
"'app_secret'",
"]",
"try",
... | Tries to verify the signed request | [
"Tries",
"to",
"verify",
"the",
"signed",
"request"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L1004-L1022 | train | Tries to verify the signed request and returns a fake message. |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._message_from_token | def _message_from_token(self, token: Text, payload: Any) \
-> Optional[BaseMessage]:
"""
Analyzes a signed token and generates the matching message
"""
try:
tk = jwt.decode(token, settings.WEBVIEW_SECRET_KEY)
except jwt.InvalidTokenError:
retu... | python | def _message_from_token(self, token: Text, payload: Any) \
-> Optional[BaseMessage]:
"""
Analyzes a signed token and generates the matching message
"""
try:
tk = jwt.decode(token, settings.WEBVIEW_SECRET_KEY)
except jwt.InvalidTokenError:
retu... | [
"def",
"_message_from_token",
"(",
"self",
",",
"token",
":",
"Text",
",",
"payload",
":",
"Any",
")",
"->",
"Optional",
"[",
"BaseMessage",
"]",
":",
"try",
":",
"tk",
"=",
"jwt",
".",
"decode",
"(",
"token",
",",
"settings",
".",
"WEBVIEW_SECRET_KEY",
... | Analyzes a signed token and generates the matching message | [
"Analyzes",
"a",
"signed",
"token",
"and",
"generates",
"the",
"matching",
"message"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L1024-L1044 | train | Generates a fake message from a signed token. |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook.message_from_token | async def message_from_token(self, token: Text, payload: Any) \
-> Optional[BaseMessage]:
"""
There is two ways of getting a FB user: either with a signed request or
either with a platform token. Both are tried out.
"""
methods = [
self._message_from_sr,
... | python | async def message_from_token(self, token: Text, payload: Any) \
-> Optional[BaseMessage]:
"""
There is two ways of getting a FB user: either with a signed request or
either with a platform token. Both are tried out.
"""
methods = [
self._message_from_sr,
... | [
"async",
"def",
"message_from_token",
"(",
"self",
",",
"token",
":",
"Text",
",",
"payload",
":",
"Any",
")",
"->",
"Optional",
"[",
"BaseMessage",
"]",
":",
"methods",
"=",
"[",
"self",
".",
"_message_from_sr",
",",
"self",
".",
"_message_from_token",
",... | There is two ways of getting a FB user: either with a signed request or
either with a platform token. Both are tried out. | [
"There",
"is",
"two",
"ways",
"of",
"getting",
"a",
"FB",
"user",
":",
"either",
"with",
"a",
"signed",
"request",
"or",
"either",
"with",
"a",
"platform",
"token",
".",
"Both",
"are",
"tried",
"out",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L1046-L1062 | train | Get a message from a token. |
BernardFW/bernard | src/bernard/engine/request.py | Request.get_trans_reg | def get_trans_reg(self, name: Text, default: Any=None) -> Any:
"""
Convenience function to access the transition register of a specific
kind.
:param name: Name of the register you want to see
:param default: What to return by default
"""
tr = self.register.get(R... | python | def get_trans_reg(self, name: Text, default: Any=None) -> Any:
"""
Convenience function to access the transition register of a specific
kind.
:param name: Name of the register you want to see
:param default: What to return by default
"""
tr = self.register.get(R... | [
"def",
"get_trans_reg",
"(",
"self",
",",
"name",
":",
"Text",
",",
"default",
":",
"Any",
"=",
"None",
")",
"->",
"Any",
":",
"tr",
"=",
"self",
".",
"register",
".",
"get",
"(",
"Register",
".",
"TRANSITION",
",",
"{",
"}",
")",
"return",
"tr",
... | Convenience function to access the transition register of a specific
kind.
:param name: Name of the register you want to see
:param default: What to return by default | [
"Convenience",
"function",
"to",
"access",
"the",
"transition",
"register",
"of",
"a",
"specific",
"kind",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/request.py#L189-L199 | train | Convenience function to access the transition register of a specific
kind. |
BernardFW/bernard | src/bernard/engine/request.py | Request.has_layer | def has_layer(self, class_: Type[L], became: bool=True) -> bool:
"""
Proxy to stack
"""
return self.stack.has_layer(class_, became) | python | def has_layer(self, class_: Type[L], became: bool=True) -> bool:
"""
Proxy to stack
"""
return self.stack.has_layer(class_, became) | [
"def",
"has_layer",
"(",
"self",
",",
"class_",
":",
"Type",
"[",
"L",
"]",
",",
"became",
":",
"bool",
"=",
"True",
")",
"->",
"bool",
":",
"return",
"self",
".",
"stack",
".",
"has_layer",
"(",
"class_",
",",
"became",
")"
] | Proxy to stack | [
"Proxy",
"to",
"stack"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/request.py#L201-L205 | train | Returns true if the stack has a layer with the given class. |
BernardFW/bernard | src/bernard/engine/request.py | Request.get_layer | def get_layer(self, class_: Type[L], became: bool=True) -> L:
"""
Proxy to stack
"""
return self.stack.get_layer(class_, became) | python | def get_layer(self, class_: Type[L], became: bool=True) -> L:
"""
Proxy to stack
"""
return self.stack.get_layer(class_, became) | [
"def",
"get_layer",
"(",
"self",
",",
"class_",
":",
"Type",
"[",
"L",
"]",
",",
"became",
":",
"bool",
"=",
"True",
")",
"->",
"L",
":",
"return",
"self",
".",
"stack",
".",
"get_layer",
"(",
"class_",
",",
"became",
")"
] | Proxy to stack | [
"Proxy",
"to",
"stack"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/request.py#L207-L211 | train | Get a specific layer from the stack. |
BernardFW/bernard | src/bernard/engine/request.py | Request.get_layers | def get_layers(self, class_: Type[L], became: bool=True) -> List[L]:
"""
Proxy to stack
"""
return self.stack.get_layers(class_, became) | python | def get_layers(self, class_: Type[L], became: bool=True) -> List[L]:
"""
Proxy to stack
"""
return self.stack.get_layers(class_, became) | [
"def",
"get_layers",
"(",
"self",
",",
"class_",
":",
"Type",
"[",
"L",
"]",
",",
"became",
":",
"bool",
"=",
"True",
")",
"->",
"List",
"[",
"L",
"]",
":",
"return",
"self",
".",
"stack",
".",
"get_layers",
"(",
"class_",
",",
"became",
")"
] | Proxy to stack | [
"Proxy",
"to",
"stack"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/request.py#L213-L217 | train | Get the layers of the given class. |
BernardFW/bernard | src/bernard/engine/request.py | Request.get_locale | async def get_locale(self) -> Text:
"""
Get the locale to use for this request. It's either the overridden
locale or the locale provided by the platform.
:return: Locale to use for this request
"""
if self._locale_override:
return self._locale_override
... | python | async def get_locale(self) -> Text:
"""
Get the locale to use for this request. It's either the overridden
locale or the locale provided by the platform.
:return: Locale to use for this request
"""
if self._locale_override:
return self._locale_override
... | [
"async",
"def",
"get_locale",
"(",
"self",
")",
"->",
"Text",
":",
"if",
"self",
".",
"_locale_override",
":",
"return",
"self",
".",
"_locale_override",
"else",
":",
"return",
"await",
"self",
".",
"user",
".",
"get_locale",
"(",
")"
] | Get the locale to use for this request. It's either the overridden
locale or the locale provided by the platform.
:return: Locale to use for this request | [
"Get",
"the",
"locale",
"to",
"use",
"for",
"this",
"request",
".",
"It",
"s",
"either",
"the",
"overridden",
"locale",
"or",
"the",
"locale",
"provided",
"by",
"the",
"platform",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/request.py#L229-L240 | train | Get the locale to use for this request. |
BernardFW/bernard | src/bernard/engine/request.py | Request.get_trans_flags | async def get_trans_flags(self) -> 'Flags':
"""
Gives a chance to middlewares to make the translation flags
"""
from bernard.middleware import MiddlewareManager
async def make_flags(request: Request) -> 'Flags':
return {}
mf = MiddlewareManager.instance().g... | python | async def get_trans_flags(self) -> 'Flags':
"""
Gives a chance to middlewares to make the translation flags
"""
from bernard.middleware import MiddlewareManager
async def make_flags(request: Request) -> 'Flags':
return {}
mf = MiddlewareManager.instance().g... | [
"async",
"def",
"get_trans_flags",
"(",
"self",
")",
"->",
"'Flags'",
":",
"from",
"bernard",
".",
"middleware",
"import",
"MiddlewareManager",
"async",
"def",
"make_flags",
"(",
"request",
":",
"Request",
")",
"->",
"'Flags'",
":",
"return",
"{",
"}",
"mf",... | Gives a chance to middlewares to make the translation flags | [
"Gives",
"a",
"chance",
"to",
"middlewares",
"to",
"make",
"the",
"translation",
"flags"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/request.py#L242-L253 | train | Returns the flags that should be applied to the translation of the current instance. |
BernardFW/bernard | src/bernard/engine/request.py | Request.sign_url | async def sign_url(self, url, method=HASH):
"""
Sign an URL with this request's auth token
"""
token = await self.get_token()
if method == self.QUERY:
return patch_qs(url, {
settings.WEBVIEW_TOKEN_KEY: token,
})
elif method == sel... | python | async def sign_url(self, url, method=HASH):
"""
Sign an URL with this request's auth token
"""
token = await self.get_token()
if method == self.QUERY:
return patch_qs(url, {
settings.WEBVIEW_TOKEN_KEY: token,
})
elif method == sel... | [
"async",
"def",
"sign_url",
"(",
"self",
",",
"url",
",",
"method",
"=",
"HASH",
")",
":",
"token",
"=",
"await",
"self",
".",
"get_token",
"(",
")",
"if",
"method",
"==",
"self",
".",
"QUERY",
":",
"return",
"patch_qs",
"(",
"url",
",",
"{",
"sett... | Sign an URL with this request's auth token | [
"Sign",
"an",
"URL",
"with",
"this",
"request",
"s",
"auth",
"token"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/request.py#L262-L279 | train | Sign an URL with this request s auth token |
BernardFW/bernard | src/bernard/layers/stack.py | Stack.layers | def layers(self, value: List['BaseLayer']):
"""
Perform a copy of the layers list in order to avoid the list changing
without updating the index.
Then update the index.
"""
self._layers = list(value) # type: List[BaseLayer]
self._index = self._make_index()
... | python | def layers(self, value: List['BaseLayer']):
"""
Perform a copy of the layers list in order to avoid the list changing
without updating the index.
Then update the index.
"""
self._layers = list(value) # type: List[BaseLayer]
self._index = self._make_index()
... | [
"def",
"layers",
"(",
"self",
",",
"value",
":",
"List",
"[",
"'BaseLayer'",
"]",
")",
":",
"self",
".",
"_layers",
"=",
"list",
"(",
"value",
")",
"# type: List[BaseLayer]",
"self",
".",
"_index",
"=",
"self",
".",
"_make_index",
"(",
")",
"self",
"."... | Perform a copy of the layers list in order to avoid the list changing
without updating the index.
Then update the index. | [
"Perform",
"a",
"copy",
"of",
"the",
"layers",
"list",
"in",
"order",
"to",
"avoid",
"the",
"list",
"changing",
"without",
"updating",
"the",
"index",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/layers/stack.py#L66-L75 | train | Set the list of layers for this entry. |
BernardFW/bernard | src/bernard/layers/stack.py | Stack._make_index | def _make_index(self):
"""
Perform the index computation. It groups layers by type into a
dictionary, to allow quick access.
"""
out = {}
for layer in self._layers:
cls = layer.__class__
out[cls] = out.get(cls, []) + [layer]
return out | python | def _make_index(self):
"""
Perform the index computation. It groups layers by type into a
dictionary, to allow quick access.
"""
out = {}
for layer in self._layers:
cls = layer.__class__
out[cls] = out.get(cls, []) + [layer]
return out | [
"def",
"_make_index",
"(",
"self",
")",
":",
"out",
"=",
"{",
"}",
"for",
"layer",
"in",
"self",
".",
"_layers",
":",
"cls",
"=",
"layer",
".",
"__class__",
"out",
"[",
"cls",
"]",
"=",
"out",
".",
"get",
"(",
"cls",
",",
"[",
"]",
")",
"+",
... | Perform the index computation. It groups layers by type into a
dictionary, to allow quick access. | [
"Perform",
"the",
"index",
"computation",
".",
"It",
"groups",
"layers",
"by",
"type",
"into",
"a",
"dictionary",
"to",
"allow",
"quick",
"access",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/layers/stack.py#L77-L89 | train | Perform the index computation. |
BernardFW/bernard | src/bernard/layers/stack.py | Stack.has_layer | def has_layer(self, class_: Type[L], became: bool=True) -> bool:
"""
Test the presence of a given layer type.
:param class_: Layer class you're interested in.
:param became: Allow transformed layers in results
"""
return (class_ in self._index or
(became... | python | def has_layer(self, class_: Type[L], became: bool=True) -> bool:
"""
Test the presence of a given layer type.
:param class_: Layer class you're interested in.
:param became: Allow transformed layers in results
"""
return (class_ in self._index or
(became... | [
"def",
"has_layer",
"(",
"self",
",",
"class_",
":",
"Type",
"[",
"L",
"]",
",",
"became",
":",
"bool",
"=",
"True",
")",
"->",
"bool",
":",
"return",
"(",
"class_",
"in",
"self",
".",
"_index",
"or",
"(",
"became",
"and",
"class_",
"in",
"self",
... | Test the presence of a given layer type.
:param class_: Layer class you're interested in.
:param became: Allow transformed layers in results | [
"Test",
"the",
"presence",
"of",
"a",
"given",
"layer",
"type",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/layers/stack.py#L101-L110 | train | Test if a given layer type is present in the results. |
BernardFW/bernard | src/bernard/layers/stack.py | Stack.get_layer | def get_layer(self, class_: Type[L], became: bool=True) -> L:
"""
Return the first layer of a given class. If that layer is not present,
then raise a KeyError.
:param class_: class of the expected layer
:param became: Allow transformed layers in results
"""
try:... | python | def get_layer(self, class_: Type[L], became: bool=True) -> L:
"""
Return the first layer of a given class. If that layer is not present,
then raise a KeyError.
:param class_: class of the expected layer
:param became: Allow transformed layers in results
"""
try:... | [
"def",
"get_layer",
"(",
"self",
",",
"class_",
":",
"Type",
"[",
"L",
"]",
",",
"became",
":",
"bool",
"=",
"True",
")",
"->",
"L",
":",
"try",
":",
"return",
"self",
".",
"_index",
"[",
"class_",
"]",
"[",
"0",
"]",
"except",
"KeyError",
":",
... | Return the first layer of a given class. If that layer is not present,
then raise a KeyError.
:param class_: class of the expected layer
:param became: Allow transformed layers in results | [
"Return",
"the",
"first",
"layer",
"of",
"a",
"given",
"class",
".",
"If",
"that",
"layer",
"is",
"not",
"present",
"then",
"raise",
"a",
"KeyError",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/layers/stack.py#L112-L127 | train | Returns the first layer of a given class. |
BernardFW/bernard | src/bernard/layers/stack.py | Stack.get_layers | def get_layers(self, class_: Type[L], became: bool=True) -> List[L]:
"""
Returns the list of layers of a given class. If no layers are present
then the list will be empty.
:param class_: class of the expected layers
:param became: Allow transformed layers in results
"""
... | python | def get_layers(self, class_: Type[L], became: bool=True) -> List[L]:
"""
Returns the list of layers of a given class. If no layers are present
then the list will be empty.
:param class_: class of the expected layers
:param became: Allow transformed layers in results
"""
... | [
"def",
"get_layers",
"(",
"self",
",",
"class_",
":",
"Type",
"[",
"L",
"]",
",",
"became",
":",
"bool",
"=",
"True",
")",
"->",
"List",
"[",
"L",
"]",
":",
"out",
"=",
"self",
".",
"_index",
".",
"get",
"(",
"class_",
",",
"[",
"]",
")",
"if... | Returns the list of layers of a given class. If no layers are present
then the list will be empty.
:param class_: class of the expected layers
:param became: Allow transformed layers in results | [
"Returns",
"the",
"list",
"of",
"layers",
"of",
"a",
"given",
"class",
".",
"If",
"no",
"layers",
"are",
"present",
"then",
"the",
"list",
"will",
"be",
"empty",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/layers/stack.py#L129-L143 | train | Returns the list of layers of a given class. |
jpscaletti/authcode | authcode/wsgi/bottle.py | get_site_name | def get_site_name(request):
"""Return the domain:port part of the URL without scheme.
Eg: facebook.com, 127.0.0.1:8080, etc.
"""
urlparts = request.urlparts
return ':'.join([urlparts.hostname, str(urlparts.port)]) | python | def get_site_name(request):
"""Return the domain:port part of the URL without scheme.
Eg: facebook.com, 127.0.0.1:8080, etc.
"""
urlparts = request.urlparts
return ':'.join([urlparts.hostname, str(urlparts.port)]) | [
"def",
"get_site_name",
"(",
"request",
")",
":",
"urlparts",
"=",
"request",
".",
"urlparts",
"return",
"':'",
".",
"join",
"(",
"[",
"urlparts",
".",
"hostname",
",",
"str",
"(",
"urlparts",
".",
"port",
")",
"]",
")"
] | Return the domain:port part of the URL without scheme.
Eg: facebook.com, 127.0.0.1:8080, etc. | [
"Return",
"the",
"domain",
":",
"port",
"part",
"of",
"the",
"URL",
"without",
"scheme",
".",
"Eg",
":",
"facebook",
".",
"com",
"127",
".",
"0",
".",
"0",
".",
"1",
":",
"8080",
"etc",
"."
] | 91529b6d0caec07d1452758d937e1e0745826139 | https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/wsgi/bottle.py#L10-L15 | train | Return the domain part of the URL without scheme. |
jpscaletti/authcode | authcode/wsgi/bottle.py | get_full_path | def get_full_path(request):
"""Return the current relative path including the query string.
Eg: “/foo/bar/?page=1”
"""
path = request.fullpath
query_string = request.environ.get('QUERY_STRING')
if query_string:
path += '?' + to_native(query_string)
return path | python | def get_full_path(request):
"""Return the current relative path including the query string.
Eg: “/foo/bar/?page=1”
"""
path = request.fullpath
query_string = request.environ.get('QUERY_STRING')
if query_string:
path += '?' + to_native(query_string)
return path | [
"def",
"get_full_path",
"(",
"request",
")",
":",
"path",
"=",
"request",
".",
"fullpath",
"query_string",
"=",
"request",
".",
"environ",
".",
"get",
"(",
"'QUERY_STRING'",
")",
"if",
"query_string",
":",
"path",
"+=",
"'?'",
"+",
"to_native",
"(",
"query... | Return the current relative path including the query string.
Eg: “/foo/bar/?page=1” | [
"Return",
"the",
"current",
"relative",
"path",
"including",
"the",
"query",
"string",
".",
"Eg",
":",
"“",
"/",
"foo",
"/",
"bar",
"/",
"?page",
"=",
"1”"
] | 91529b6d0caec07d1452758d937e1e0745826139 | https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/wsgi/bottle.py#L18-L26 | train | Return the current relative path including the query string. |
jpscaletti/authcode | authcode/wsgi/bottle.py | make_full_url | def make_full_url(request, url):
"""Get a relative URL and returns the absolute version.
Eg: “/foo/bar?q=is-open” ==> “http://example.com/foo/bar?q=is-open”
"""
urlparts = request.urlparts
return '{scheme}://{site}/{url}'.format(
scheme=urlparts.scheme,
site=get_site_name(request),
... | python | def make_full_url(request, url):
"""Get a relative URL and returns the absolute version.
Eg: “/foo/bar?q=is-open” ==> “http://example.com/foo/bar?q=is-open”
"""
urlparts = request.urlparts
return '{scheme}://{site}/{url}'.format(
scheme=urlparts.scheme,
site=get_site_name(request),
... | [
"def",
"make_full_url",
"(",
"request",
",",
"url",
")",
":",
"urlparts",
"=",
"request",
".",
"urlparts",
"return",
"'{scheme}://{site}/{url}'",
".",
"format",
"(",
"scheme",
"=",
"urlparts",
".",
"scheme",
",",
"site",
"=",
"get_site_name",
"(",
"request",
... | Get a relative URL and returns the absolute version.
Eg: “/foo/bar?q=is-open” ==> “http://example.com/foo/bar?q=is-open” | [
"Get",
"a",
"relative",
"URL",
"and",
"returns",
"the",
"absolute",
"version",
".",
"Eg",
":",
"“",
"/",
"foo",
"/",
"bar?q",
"=",
"is",
"-",
"open”",
"==",
">",
"“http",
":",
"//",
"example",
".",
"com",
"/",
"foo",
"/",
"bar?q",
"=",
"is",
"-",... | 91529b6d0caec07d1452758d937e1e0745826139 | https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/wsgi/bottle.py#L29-L38 | train | Get a relative URL and returns the absolute version. |
jpscaletti/authcode | authcode/wsgi/bottle.py | make_response | def make_response(body, mimetype='text/html'):
"""Build a framework specific HTPP response, containing ``body`` and
marked as the type ``mimetype``.
"""
from bottle import response
response.content_type = mimetype
return body or u'' | python | def make_response(body, mimetype='text/html'):
"""Build a framework specific HTPP response, containing ``body`` and
marked as the type ``mimetype``.
"""
from bottle import response
response.content_type = mimetype
return body or u'' | [
"def",
"make_response",
"(",
"body",
",",
"mimetype",
"=",
"'text/html'",
")",
":",
"from",
"bottle",
"import",
"response",
"response",
".",
"content_type",
"=",
"mimetype",
"return",
"body",
"or",
"u''"
] | Build a framework specific HTPP response, containing ``body`` and
marked as the type ``mimetype``. | [
"Build",
"a",
"framework",
"specific",
"HTPP",
"response",
"containing",
"body",
"and",
"marked",
"as",
"the",
"type",
"mimetype",
"."
] | 91529b6d0caec07d1452758d937e1e0745826139 | https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/wsgi/bottle.py#L87-L93 | train | Build an HTPP response containing the given body and mimetype. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_trajectory.py | NCEITrajectoryBase.check_trajectory_id | def check_trajectory_id(self, dataset):
'''
Checks that if a variable exists for the trajectory id it has the appropriate attributes
:param netCDF4.Dataset dataset: An open netCDF dataset
'''
results = []
exists_ctx = TestCtx(BaseCheck.MEDIUM, 'Variable defining "traject... | python | def check_trajectory_id(self, dataset):
'''
Checks that if a variable exists for the trajectory id it has the appropriate attributes
:param netCDF4.Dataset dataset: An open netCDF dataset
'''
results = []
exists_ctx = TestCtx(BaseCheck.MEDIUM, 'Variable defining "traject... | [
"def",
"check_trajectory_id",
"(",
"self",
",",
"dataset",
")",
":",
"results",
"=",
"[",
"]",
"exists_ctx",
"=",
"TestCtx",
"(",
"BaseCheck",
".",
"MEDIUM",
",",
"'Variable defining \"trajectory_id\" exists'",
")",
"trajectory_ids",
"=",
"dataset",
".",
"get_vari... | Checks that if a variable exists for the trajectory id it has the appropriate attributes
:param netCDF4.Dataset dataset: An open netCDF dataset | [
"Checks",
"that",
"if",
"a",
"variable",
"exists",
"for",
"the",
"trajectory",
"id",
"it",
"has",
"the",
"appropriate",
"attributes"
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_trajectory.py#L41-L61 | train | Checks that a variable exists for the trajectory id it has the appropriate attributes for the trajectory id. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_trajectory.py | NCEITrajectory1_1.check_required_attributes | def check_required_attributes(self, dataset):
'''
Feature type specific check of global required and highly recommended attributes.
:param netCDF4.Dataset dataset: An open netCDF dataset
'''
results = []
required_ctx = TestCtx(BaseCheck.HIGH, 'Required Global Attributes ... | python | def check_required_attributes(self, dataset):
'''
Feature type specific check of global required and highly recommended attributes.
:param netCDF4.Dataset dataset: An open netCDF dataset
'''
results = []
required_ctx = TestCtx(BaseCheck.HIGH, 'Required Global Attributes ... | [
"def",
"check_required_attributes",
"(",
"self",
",",
"dataset",
")",
":",
"results",
"=",
"[",
"]",
"required_ctx",
"=",
"TestCtx",
"(",
"BaseCheck",
".",
"HIGH",
",",
"'Required Global Attributes for Trajectory dataset'",
")",
"required_ctx",
".",
"assert_true",
"... | Feature type specific check of global required and highly recommended attributes.
:param netCDF4.Dataset dataset: An open netCDF dataset | [
"Feature",
"type",
"specific",
"check",
"of",
"global",
"required",
"and",
"highly",
"recommended",
"attributes",
"."
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_trajectory.py#L92-L113 | train | Feature type specific check of global required and highly recommended attributes. |
jpscaletti/authcode | authcode/auth_authentication_mixin.py | AuthenticationMixin.login | def login(self, user, remember=True, session=None):
"""Sets the current user UID in the session.
Instead of just storing the user's id, it generates a hash from the
password *salt*. That way, an admin or the user herself can invalidate
the login in other computers just by changing (or r... | python | def login(self, user, remember=True, session=None):
"""Sets the current user UID in the session.
Instead of just storing the user's id, it generates a hash from the
password *salt*. That way, an admin or the user herself can invalidate
the login in other computers just by changing (or r... | [
"def",
"login",
"(",
"self",
",",
"user",
",",
"remember",
"=",
"True",
",",
"session",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"u'User `{0}` logged in'",
".",
"format",
"(",
... | Sets the current user UID in the session.
Instead of just storing the user's id, it generates a hash from the
password *salt*. That way, an admin or the user herself can invalidate
the login in other computers just by changing (or re-saving)
her password. | [
"Sets",
"the",
"current",
"user",
"UID",
"in",
"the",
"session",
"."
] | 91529b6d0caec07d1452758d937e1e0745826139 | https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/auth_authentication_mixin.py#L130-L146 | train | Sets the current user UID in the session. |
jasonrbriggs/proton | python/proton/xmlutils.py | index | def index(elem):
'''
Return the index position of an element in the children of a parent.
'''
parent = elem.getparent()
for x in range(0, len(parent.getchildren())):
if parent.getchildren()[x] == elem:
return x
return -1 | python | def index(elem):
'''
Return the index position of an element in the children of a parent.
'''
parent = elem.getparent()
for x in range(0, len(parent.getchildren())):
if parent.getchildren()[x] == elem:
return x
return -1 | [
"def",
"index",
"(",
"elem",
")",
":",
"parent",
"=",
"elem",
".",
"getparent",
"(",
")",
"for",
"x",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"parent",
".",
"getchildren",
"(",
")",
")",
")",
":",
"if",
"parent",
".",
"getchildren",
"(",
")",
... | Return the index position of an element in the children of a parent. | [
"Return",
"the",
"index",
"position",
"of",
"an",
"element",
"in",
"the",
"children",
"of",
"a",
"parent",
"."
] | e734734750797ef0caaa1680379e07b86d7a53e3 | https://github.com/jasonrbriggs/proton/blob/e734734750797ef0caaa1680379e07b86d7a53e3/python/proton/xmlutils.py#L18-L26 | train | Return the index of an element in the children of a parent. |
jasonrbriggs/proton | python/proton/xmlutils.py | replaceelement | def replaceelement(oldelem, newelem):
'''
Given a parent element, replace oldelem with newelem.
'''
parent = oldelem.getparent()
if parent is not None:
size = len(parent.getchildren())
for x in range(0, size):
if parent.getchildren()[x] == oldelem:
parent.... | python | def replaceelement(oldelem, newelem):
'''
Given a parent element, replace oldelem with newelem.
'''
parent = oldelem.getparent()
if parent is not None:
size = len(parent.getchildren())
for x in range(0, size):
if parent.getchildren()[x] == oldelem:
parent.... | [
"def",
"replaceelement",
"(",
"oldelem",
",",
"newelem",
")",
":",
"parent",
"=",
"oldelem",
".",
"getparent",
"(",
")",
"if",
"parent",
"is",
"not",
"None",
":",
"size",
"=",
"len",
"(",
"parent",
".",
"getchildren",
"(",
")",
")",
"for",
"x",
"in",... | Given a parent element, replace oldelem with newelem. | [
"Given",
"a",
"parent",
"element",
"replace",
"oldelem",
"with",
"newelem",
"."
] | e734734750797ef0caaa1680379e07b86d7a53e3 | https://github.com/jasonrbriggs/proton/blob/e734734750797ef0caaa1680379e07b86d7a53e3/python/proton/xmlutils.py#L29-L39 | train | Given a parent element replace oldelem with newelem. |
jasonrbriggs/proton | python/proton/xmlutils.py | parseelement | def parseelement(elem):
'''
Convert the content of an element into more ElementTree structures.
We do this because sometimes we want to set xml as the content of an element.
'''
xml = '<%(tag)s>%(content)s</%(tag)s>' % {'tag' : elem.tag, 'content' : elem.text}
et = etree.fromstring(xml)
repl... | python | def parseelement(elem):
'''
Convert the content of an element into more ElementTree structures.
We do this because sometimes we want to set xml as the content of an element.
'''
xml = '<%(tag)s>%(content)s</%(tag)s>' % {'tag' : elem.tag, 'content' : elem.text}
et = etree.fromstring(xml)
repl... | [
"def",
"parseelement",
"(",
"elem",
")",
":",
"xml",
"=",
"'<%(tag)s>%(content)s</%(tag)s>'",
"%",
"{",
"'tag'",
":",
"elem",
".",
"tag",
",",
"'content'",
":",
"elem",
".",
"text",
"}",
"et",
"=",
"etree",
".",
"fromstring",
"(",
"xml",
")",
"replaceele... | Convert the content of an element into more ElementTree structures.
We do this because sometimes we want to set xml as the content of an element. | [
"Convert",
"the",
"content",
"of",
"an",
"element",
"into",
"more",
"ElementTree",
"structures",
".",
"We",
"do",
"this",
"because",
"sometimes",
"we",
"want",
"to",
"set",
"xml",
"as",
"the",
"content",
"of",
"an",
"element",
"."
] | e734734750797ef0caaa1680379e07b86d7a53e3 | https://github.com/jasonrbriggs/proton/blob/e734734750797ef0caaa1680379e07b86d7a53e3/python/proton/xmlutils.py#L42-L49 | train | Convert the content of an element into more ElementTree structures. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | BaseNCEICheck._check_min_max_range | def _check_min_max_range(self, var, test_ctx):
"""
Checks that either both valid_min and valid_max exist, or valid_range
exists.
"""
if 'valid_range' in var.ncattrs():
test_ctx.assert_true(var.valid_range.dtype == var.dtype and
len(var... | python | def _check_min_max_range(self, var, test_ctx):
"""
Checks that either both valid_min and valid_max exist, or valid_range
exists.
"""
if 'valid_range' in var.ncattrs():
test_ctx.assert_true(var.valid_range.dtype == var.dtype and
len(var... | [
"def",
"_check_min_max_range",
"(",
"self",
",",
"var",
",",
"test_ctx",
")",
":",
"if",
"'valid_range'",
"in",
"var",
".",
"ncattrs",
"(",
")",
":",
"test_ctx",
".",
"assert_true",
"(",
"var",
".",
"valid_range",
".",
"dtype",
"==",
"var",
".",
"dtype",... | Checks that either both valid_min and valid_max exist, or valid_range
exists. | [
"Checks",
"that",
"either",
"both",
"valid_min",
"and",
"valid_max",
"exist",
"or",
"valid_range",
"exists",
"."
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L92-L115 | train | Checks that both valid_min and valid_max exist and that both valid_min and valid_max exist. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | BaseNCEICheck.check_lat | def check_lat(self, dataset):
'''
float lat(time) ;//....................................... Depending on the precision used for the variable, the data type could be int or double instead of float.
lat:long_name = "" ; //...................................... RECOMMENDED - Provide a desc... | python | def check_lat(self, dataset):
'''
float lat(time) ;//....................................... Depending on the precision used for the variable, the data type could be int or double instead of float.
lat:long_name = "" ; //...................................... RECOMMENDED - Provide a desc... | [
"def",
"check_lat",
"(",
"self",
",",
"dataset",
")",
":",
"results",
"=",
"[",
"]",
"lat",
"=",
"util",
".",
"get_lat_variable",
"(",
"dataset",
")",
"if",
"not",
"lat",
":",
"return",
"Result",
"(",
"BaseCheck",
".",
"HIGH",
",",
"False",
",",
"'la... | float lat(time) ;//....................................... Depending on the precision used for the variable, the data type could be int or double instead of float.
lat:long_name = "" ; //...................................... RECOMMENDED - Provide a descriptive, long name for this variable.
... | [
"float",
"lat",
"(",
"time",
")",
";",
"//",
".......................................",
"Depending",
"on",
"the",
"precision",
"used",
"for",
"the",
"variable",
"the",
"data",
"type",
"could",
"be",
"int",
"or",
"double",
"instead",
"of",
"float",
".",
"lat",
... | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L117-L152 | train | Check the latitude variable for validity |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | BaseNCEICheck.check_lon | def check_lon(self, dataset):
'''
float lon(timeSeries) ; //........................................ Depending on the precision used for the variable, the data type could be int or double instead of float.
lon:long_name = "" ; //...................................... RECOMMENDED
... | python | def check_lon(self, dataset):
'''
float lon(timeSeries) ; //........................................ Depending on the precision used for the variable, the data type could be int or double instead of float.
lon:long_name = "" ; //...................................... RECOMMENDED
... | [
"def",
"check_lon",
"(",
"self",
",",
"dataset",
")",
":",
"results",
"=",
"[",
"]",
"lon",
"=",
"util",
".",
"get_lon_variable",
"(",
"dataset",
")",
"if",
"not",
"lon",
":",
"return",
"Result",
"(",
"BaseCheck",
".",
"HIGH",
",",
"False",
",",
"'lo... | float lon(timeSeries) ; //........................................ Depending on the precision used for the variable, the data type could be int or double instead of float.
lon:long_name = "" ; //...................................... RECOMMENDED
lon:standard_name = "longitude" ; //................. | [
"float",
"lon",
"(",
"timeSeries",
")",
";",
"//",
"........................................",
"Depending",
"on",
"the",
"precision",
"used",
"for",
"the",
"variable",
"the",
"data",
"type",
"could",
"be",
"int",
"or",
"double",
"instead",
"of",
"float",
".",
... | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L154-L188 | train | Check that the variable for longitude exists in the dataset. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | BaseNCEICheck.check_time | def check_time(self, dataset):
'''
double time(time) ;//........................................ Depending on the precision used for the variable, the data type could be int or double instead of float.
time:long_name = "" ; //..................................... RECOMMENDED - Provide a desc... | python | def check_time(self, dataset):
'''
double time(time) ;//........................................ Depending on the precision used for the variable, the data type could be int or double instead of float.
time:long_name = "" ; //..................................... RECOMMENDED - Provide a desc... | [
"def",
"check_time",
"(",
"self",
",",
"dataset",
")",
":",
"results",
"=",
"[",
"]",
"time_var",
"=",
"util",
".",
"get_time_variable",
"(",
"dataset",
")",
"if",
"not",
"time_var",
":",
"return",
"Result",
"(",
"BaseCheck",
".",
"HIGH",
",",
"False",
... | double time(time) ;//........................................ Depending on the precision used for the variable, the data type could be int or double instead of float.
time:long_name = "" ; //..................................... RECOMMENDED - Provide a descriptive, long name for this variable.
t... | [
"double",
"time",
"(",
"time",
")",
";",
"//",
"........................................",
"Depending",
"on",
"the",
"precision",
"used",
"for",
"the",
"variable",
"the",
"data",
"type",
"could",
"be",
"int",
"or",
"double",
"instead",
"of",
"float",
".",
"tim... | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L190-L234 | train | Checks the time variable for validity. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | BaseNCEICheck.check_height | def check_height(self, dataset):
'''
float z(time) ;//........................................ Depending on the precision used for the variable, the data type could be int or double instead of float. Also the variable "z" could be substituted with a more descriptive name like "depth", "altitude", "press... | python | def check_height(self, dataset):
'''
float z(time) ;//........................................ Depending on the precision used for the variable, the data type could be int or double instead of float. Also the variable "z" could be substituted with a more descriptive name like "depth", "altitude", "press... | [
"def",
"check_height",
"(",
"self",
",",
"dataset",
")",
":",
"results",
"=",
"[",
"]",
"exists_ctx",
"=",
"TestCtx",
"(",
"BaseCheck",
".",
"HIGH",
",",
"'Variable for height must exist'",
")",
"var",
"=",
"util",
".",
"get_z_variable",
"(",
"dataset",
")",... | float z(time) ;//........................................ Depending on the precision used for the variable, the data type could be int or double instead of float. Also the variable "z" could be substituted with a more descriptive name like "depth", "altitude", "pressure", etc.
z:long_name = "" ; //........ | [
"float",
"z",
"(",
"time",
")",
";",
"//",
"........................................",
"Depending",
"on",
"the",
"precision",
"used",
"for",
"the",
"variable",
"the",
"data",
"type",
"could",
"be",
"int",
"or",
"double",
"instead",
"of",
"float",
".",
"Also",
... | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L236-L298 | train | Check the variable for height exists and has the correct values. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | BaseNCEICheck.check_qaqc | def check_qaqc(self, dataset):
'''
byte boolean_flag_variable(timeSeries,time); //............................. A boolean flag variable, in which each bit of the flag can be a 1 or 0.
boolean_flag_variable:standard_name= "" ; //................. RECOMMENDED - This attribute should includ... | python | def check_qaqc(self, dataset):
'''
byte boolean_flag_variable(timeSeries,time); //............................. A boolean flag variable, in which each bit of the flag can be a 1 or 0.
boolean_flag_variable:standard_name= "" ; //................. RECOMMENDED - This attribute should includ... | [
"def",
"check_qaqc",
"(",
"self",
",",
"dataset",
")",
":",
"# Check the qaqc variables to ensure they are good",
"results",
"=",
"[",
"]",
"flag_variables",
"=",
"dataset",
".",
"get_variables_by_attributes",
"(",
"flag_meanings",
"=",
"lambda",
"x",
":",
"x",
"is"... | byte boolean_flag_variable(timeSeries,time); //............................. A boolean flag variable, in which each bit of the flag can be a 1 or 0.
boolean_flag_variable:standard_name= "" ; //................. RECOMMENDED - This attribute should include the standard name of the variable which this flag... | [
"byte",
"boolean_flag_variable",
"(",
"timeSeries",
"time",
")",
";",
"//",
".............................",
"A",
"boolean",
"flag",
"variable",
"in",
"which",
"each",
"bit",
"of",
"the",
"flag",
"can",
"be",
"a",
"1",
"or",
"0",
".",
"boolean_flag_variable",
... | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L300-L339 | train | Check the validity of a single flag in the specified dataset. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | BaseNCEICheck.check_instrument | def check_instrument(self, dataset):
'''
int instrument_parameter_variable(timeSeries); // ... RECOMMENDED - an instrument variable storing information about a parameter of the instrument used in the measurement, the dimensions don't have to be specified if the same instrument is used for all the measur... | python | def check_instrument(self, dataset):
'''
int instrument_parameter_variable(timeSeries); // ... RECOMMENDED - an instrument variable storing information about a parameter of the instrument used in the measurement, the dimensions don't have to be specified if the same instrument is used for all the measur... | [
"def",
"check_instrument",
"(",
"self",
",",
"dataset",
")",
":",
"# Check for the instrument variable",
"instruments",
"=",
"util",
".",
"get_instrument_variables",
"(",
"dataset",
")",
"if",
"not",
"instruments",
":",
"return",
"Result",
"(",
"BaseCheck",
".",
"... | int instrument_parameter_variable(timeSeries); // ... RECOMMENDED - an instrument variable storing information about a parameter of the instrument used in the measurement, the dimensions don't have to be specified if the same instrument is used for all the measurements.
instrument_parameter_variable:long_na... | [
"int",
"instrument_parameter_variable",
"(",
"timeSeries",
")",
";",
"//",
"...",
"RECOMMENDED",
"-",
"an",
"instrument",
"variable",
"storing",
"information",
"about",
"a",
"parameter",
"of",
"the",
"instrument",
"used",
"in",
"the",
"measurement",
"the",
"dimens... | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L341-L362 | train | Check that the variable for instrument exists. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | BaseNCEICheck.check_crs | def check_crs(self, dataset):
'''
int crs; //.......................................................... RECOMMENDED - A container variable storing information about the grid_mapping. All the attributes within a grid_mapping variable are described in http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.6/... | python | def check_crs(self, dataset):
'''
int crs; //.......................................................... RECOMMENDED - A container variable storing information about the grid_mapping. All the attributes within a grid_mapping variable are described in http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.6/... | [
"def",
"check_crs",
"(",
"self",
",",
"dataset",
")",
":",
"grid_mapping",
"=",
"util",
".",
"get_crs_variable",
"(",
"dataset",
")",
"if",
"grid_mapping",
"is",
"None",
":",
"return",
"Result",
"(",
"BaseCheck",
".",
"MEDIUM",
",",
"False",
",",
"'Recomme... | int crs; //.......................................................... RECOMMENDED - A container variable storing information about the grid_mapping. All the attributes within a grid_mapping variable are described in http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.6/cf-conventions.html#appendix-grid-mappings. For al... | [
"int",
"crs",
";",
"//",
"..........................................................",
"RECOMMENDED",
"-",
"A",
"container",
"variable",
"storing",
"information",
"about",
"the",
"grid_mapping",
".",
"All",
"the",
"attributes",
"within",
"a",
"grid_mapping",
"variable",
... | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L364-L394 | train | Check that the grid mapping variable exists and contains the required attributes. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | NCEI1_1Check.check_base_required_attributes | def check_base_required_attributes(self, dataset):
'''
Check the global required and highly recommended attributes for 1.1 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
:Conventions = "CF-1.6" ; ... | python | def check_base_required_attributes(self, dataset):
'''
Check the global required and highly recommended attributes for 1.1 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
:Conventions = "CF-1.6" ; ... | [
"def",
"check_base_required_attributes",
"(",
"self",
",",
"dataset",
")",
":",
"test_ctx",
"=",
"TestCtx",
"(",
"BaseCheck",
".",
"HIGH",
",",
"'Required global attributes'",
")",
"conventions",
"=",
"getattr",
"(",
"dataset",
",",
"'Conventions'",
",",
"''",
"... | Check the global required and highly recommended attributes for 1.1 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
:Conventions = "CF-1.6" ; //......................................... REQUIRED - Always try to... | [
"Check",
"the",
"global",
"required",
"and",
"highly",
"recommended",
"attributes",
"for",
"1",
".",
"1",
"templates",
".",
"These",
"go",
"an",
"extra",
"step",
"besides",
"just",
"checking",
"that",
"they",
"exist",
"."
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L419-L457 | train | Check the global required and highly recommended attributes for 1. 1 templates. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | NCEI1_1Check.check_recommended_global_attributes | def check_recommended_global_attributes(self, dataset):
'''
Check the global recommended attributes for 1.1 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
Basic "does it exist" checks are done in B... | python | def check_recommended_global_attributes(self, dataset):
'''
Check the global recommended attributes for 1.1 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
Basic "does it exist" checks are done in B... | [
"def",
"check_recommended_global_attributes",
"(",
"self",
",",
"dataset",
")",
":",
"recommended_ctx",
"=",
"TestCtx",
"(",
"BaseCheck",
".",
"MEDIUM",
",",
"'Recommended global attributes'",
")",
"# Do any of the variables define platform ?",
"variable_defined_platform",
"=... | Check the global recommended attributes for 1.1 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
Basic "does it exist" checks are done in BaseNCEICheck:check_recommended
:title = "" ; //........................ | [
"Check",
"the",
"global",
"recommended",
"attributes",
"for",
"1",
".",
"1",
"templates",
".",
"These",
"go",
"an",
"extra",
"step",
"besides",
"just",
"checking",
"that",
"they",
"exist",
"."
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L459-L567 | train | Check the global recommended attributes for 1. 1 templates. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | NCEI2_0Check.check_base_required_attributes | def check_base_required_attributes(self, dataset):
'''
Check the global required and highly recommended attributes for 2.0 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
:Conventions = "CF-1.6, ACD... | python | def check_base_required_attributes(self, dataset):
'''
Check the global required and highly recommended attributes for 2.0 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
:Conventions = "CF-1.6, ACD... | [
"def",
"check_base_required_attributes",
"(",
"self",
",",
"dataset",
")",
":",
"test_ctx",
"=",
"TestCtx",
"(",
"BaseCheck",
".",
"HIGH",
",",
"'Required global attributes'",
")",
"conventions",
"=",
"getattr",
"(",
"dataset",
",",
"'Conventions'",
",",
"''",
"... | Check the global required and highly recommended attributes for 2.0 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
:Conventions = "CF-1.6, ACDD-1.3" ; //............................... REQUIRED - Always try to use... | [
"Check",
"the",
"global",
"required",
"and",
"highly",
"recommended",
"attributes",
"for",
"2",
".",
"0",
"templates",
".",
"These",
"go",
"an",
"extra",
"step",
"besides",
"just",
"checking",
"that",
"they",
"exist",
"."
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L738-L773 | train | Check the global required and highly recommended attributes for 2. 0 templates. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | NCEI2_0Check.check_recommended_global_attributes | def check_recommended_global_attributes(self, dataset):
'''
Check the global recommended attributes for 2.0 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
:id = "" ; //................................ | python | def check_recommended_global_attributes(self, dataset):
'''
Check the global recommended attributes for 2.0 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
:id = "" ; //................................ | [
"def",
"check_recommended_global_attributes",
"(",
"self",
",",
"dataset",
")",
":",
"recommended_ctx",
"=",
"TestCtx",
"(",
"BaseCheck",
".",
"MEDIUM",
",",
"'Recommended global attributes'",
")",
"sea_names",
"=",
"[",
"sn",
".",
"lower",
"(",
")",
"for",
"sn"... | Check the global recommended attributes for 2.0 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
:id = "" ; //.................................................. RECOMMENDED - Should be a human readable unique identi... | [
"Check",
"the",
"global",
"recommended",
"attributes",
"for",
"2",
".",
"0",
"templates",
".",
"These",
"go",
"an",
"extra",
"step",
"besides",
"just",
"checking",
"that",
"they",
"exist",
"."
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L775-L853 | train | Check the global recommended attributes for 2. 0 templates. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | NCEI2_0Check.check_base_suggested_attributes | def check_base_suggested_attributes(self, dataset):
'''
Check the global suggested attributes for 2.0 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
:creator_type = "" ; //............................ | python | def check_base_suggested_attributes(self, dataset):
'''
Check the global suggested attributes for 2.0 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
:creator_type = "" ; //............................ | [
"def",
"check_base_suggested_attributes",
"(",
"self",
",",
"dataset",
")",
":",
"suggested_ctx",
"=",
"TestCtx",
"(",
"BaseCheck",
".",
"LOW",
",",
"'Suggested global attributes'",
")",
"# Do any of the variables define platform ?",
"platform_name",
"=",
"getattr",
"(",
... | Check the global suggested attributes for 2.0 templates. These go an extra step besides
just checking that they exist.
:param netCDF4.Dataset dataset: An open netCDF dataset
:creator_type = "" ; //........................................ SUGGESTED - Specifies type of creator with one of the fo... | [
"Check",
"the",
"global",
"suggested",
"attributes",
"for",
"2",
".",
"0",
"templates",
".",
"These",
"go",
"an",
"extra",
"step",
"besides",
"just",
"checking",
"that",
"they",
"exist",
"."
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L855-L919 | train | Check the global suggested attributes for 2. 0 templates. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | NCEI2_0Check.check_geophysical | def check_geophysical(self, dataset):
'''
Check the geophysical variable attributes for 2.0 templates.
Attributes missing_value and coverage_content_type have been added in NCEI 2.0
:param netCDF4.Dataset dataset: An open netCDF dataset
float geophysical_variable_1(time) ;//...... | python | def check_geophysical(self, dataset):
'''
Check the geophysical variable attributes for 2.0 templates.
Attributes missing_value and coverage_content_type have been added in NCEI 2.0
:param netCDF4.Dataset dataset: An open netCDF dataset
float geophysical_variable_1(time) ;//...... | [
"def",
"check_geophysical",
"(",
"self",
",",
"dataset",
")",
":",
"results",
"=",
"[",
"]",
"for",
"var",
"in",
"util",
".",
"get_geophysical_variables",
"(",
"dataset",
")",
":",
"ncvar",
"=",
"dataset",
".",
"variables",
"[",
"var",
"]",
"test_ctx",
"... | Check the geophysical variable attributes for 2.0 templates.
Attributes missing_value and coverage_content_type have been added in NCEI 2.0
:param netCDF4.Dataset dataset: An open netCDF dataset
float geophysical_variable_1(time) ;//................................ This is an example of how ea... | [
"Check",
"the",
"geophysical",
"variable",
"attributes",
"for",
"2",
".",
"0",
"templates",
".",
"Attributes",
"missing_value",
"and",
"coverage_content_type",
"have",
"been",
"added",
"in",
"NCEI",
"2",
".",
"0"
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L921-L999 | train | Check the attributes of the geophysical variable for 2. 0 templates. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_base.py | NCEI2_0Check.check_platform | def check_platform(self, dataset):
'''
int platform_variable; //............................................ RECOMMENDED - a container variable storing information about the platform. If more than one, can expand each attribute into a variable. For example, platform_call_sign and platform_nodc_code. See... | python | def check_platform(self, dataset):
'''
int platform_variable; //............................................ RECOMMENDED - a container variable storing information about the platform. If more than one, can expand each attribute into a variable. For example, platform_call_sign and platform_nodc_code. See... | [
"def",
"check_platform",
"(",
"self",
",",
"dataset",
")",
":",
"# Check for the platform variable",
"platforms",
"=",
"util",
".",
"get_platform_variables",
"(",
"dataset",
")",
"if",
"not",
"platforms",
":",
"return",
"Result",
"(",
"BaseCheck",
".",
"MEDIUM",
... | int platform_variable; //............................................ RECOMMENDED - a container variable storing information about the platform. If more than one, can expand each attribute into a variable. For example, platform_call_sign and platform_nodc_code. See instrument_parameter_variable for an example.
... | [
"int",
"platform_variable",
";",
"//",
"............................................",
"RECOMMENDED",
"-",
"a",
"container",
"variable",
"storing",
"information",
"about",
"the",
"platform",
".",
"If",
"more",
"than",
"one",
"can",
"expand",
"each",
"attribute",
"into... | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_base.py#L1001-L1043 | train | Checks the platform variable for existence. |
pyslackers/sir-bot-a-lot | sirbot/core/core.py | SirBot._configure | def _configure(self):
"""
Configure the core of sirbot
Merge the config with the default core config and configure logging.
The default logging level is `INFO`
"""
path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'config.yml'
)
... | python | def _configure(self):
"""
Configure the core of sirbot
Merge the config with the default core config and configure logging.
The default logging level is `INFO`
"""
path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'config.yml'
)
... | [
"def",
"_configure",
"(",
"self",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
",",
"'config.yml'",
")",
"with",
"open",
"(",
"pa... | Configure the core of sirbot
Merge the config with the default core config and configure logging.
The default logging level is `INFO` | [
"Configure",
"the",
"core",
"of",
"sirbot"
] | 22dfdd6a14d61dbe29423fd131b7a23e618b68d7 | https://github.com/pyslackers/sir-bot-a-lot/blob/22dfdd6a14d61dbe29423fd131b7a23e618b68d7/sirbot/core/core.py#L64-L83 | train | Configure the core of sirbot |
pyslackers/sir-bot-a-lot | sirbot/core/core.py | SirBot._start | async def _start(self, app: web.Application) -> None:
"""
Start sirbot
"""
logger.info('Starting Sir Bot-a-lot ...')
await self._start_plugins()
logger.info('Sir Bot-a-lot fully started') | python | async def _start(self, app: web.Application) -> None:
"""
Start sirbot
"""
logger.info('Starting Sir Bot-a-lot ...')
await self._start_plugins()
logger.info('Sir Bot-a-lot fully started') | [
"async",
"def",
"_start",
"(",
"self",
",",
"app",
":",
"web",
".",
"Application",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"'Starting Sir Bot-a-lot ...'",
")",
"await",
"self",
".",
"_start_plugins",
"(",
")",
"logger",
".",
"info",
"(",
"'Si... | Start sirbot | [
"Start",
"sirbot"
] | 22dfdd6a14d61dbe29423fd131b7a23e618b68d7 | https://github.com/pyslackers/sir-bot-a-lot/blob/22dfdd6a14d61dbe29423fd131b7a23e618b68d7/sirbot/core/core.py#L85-L92 | train | Start sirbot. |
pyslackers/sir-bot-a-lot | sirbot/core/core.py | SirBot._stop | async def _stop(self, app) -> None:
"""
Stop sirbot
"""
logger.info('Stopping Sir Bot-a-lot ...')
for task in self._tasks.values():
task.cancel()
await asyncio.gather(*self._tasks.values(), loop=self._loop)
await self._session.close()
logger.... | python | async def _stop(self, app) -> None:
"""
Stop sirbot
"""
logger.info('Stopping Sir Bot-a-lot ...')
for task in self._tasks.values():
task.cancel()
await asyncio.gather(*self._tasks.values(), loop=self._loop)
await self._session.close()
logger.... | [
"async",
"def",
"_stop",
"(",
"self",
",",
"app",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"'Stopping Sir Bot-a-lot ...'",
")",
"for",
"task",
"in",
"self",
".",
"_tasks",
".",
"values",
"(",
")",
":",
"task",
".",
"cancel",
"(",
")",
"awa... | Stop sirbot | [
"Stop",
"sirbot"
] | 22dfdd6a14d61dbe29423fd131b7a23e618b68d7 | https://github.com/pyslackers/sir-bot-a-lot/blob/22dfdd6a14d61dbe29423fd131b7a23e618b68d7/sirbot/core/core.py#L94-L105 | train | Stop the sirbot. |
pyslackers/sir-bot-a-lot | sirbot/core/core.py | SirBot._import_plugins | def _import_plugins(self) -> None:
"""
Import and register plugin in the plugin manager.
The pluggy library is used as plugin manager.
"""
logger.debug('Importing plugins')
self._pm = pluggy.PluginManager('sirbot')
self._pm.add_hookspecs(hookspecs)
for p... | python | def _import_plugins(self) -> None:
"""
Import and register plugin in the plugin manager.
The pluggy library is used as plugin manager.
"""
logger.debug('Importing plugins')
self._pm = pluggy.PluginManager('sirbot')
self._pm.add_hookspecs(hookspecs)
for p... | [
"def",
"_import_plugins",
"(",
"self",
")",
"->",
"None",
":",
"logger",
".",
"debug",
"(",
"'Importing plugins'",
")",
"self",
".",
"_pm",
"=",
"pluggy",
".",
"PluginManager",
"(",
"'sirbot'",
")",
"self",
".",
"_pm",
".",
"add_hookspecs",
"(",
"hookspecs... | Import and register plugin in the plugin manager.
The pluggy library is used as plugin manager. | [
"Import",
"and",
"register",
"plugin",
"in",
"the",
"plugin",
"manager",
"."
] | 22dfdd6a14d61dbe29423fd131b7a23e618b68d7 | https://github.com/pyslackers/sir-bot-a-lot/blob/22dfdd6a14d61dbe29423fd131b7a23e618b68d7/sirbot/core/core.py#L107-L126 | train | Import and register plugins in the plugin manager. |
pyslackers/sir-bot-a-lot | sirbot/core/core.py | SirBot._initialize_plugins | def _initialize_plugins(self):
"""
Initialize the plugins
Query the configuration and the plugins for info
(name, registry name, start priority, etc)
"""
logger.debug('Initializing plugins')
plugins = self._pm.hook.plugins(loop=self._loop)
if plugins:
... | python | def _initialize_plugins(self):
"""
Initialize the plugins
Query the configuration and the plugins for info
(name, registry name, start priority, etc)
"""
logger.debug('Initializing plugins')
plugins = self._pm.hook.plugins(loop=self._loop)
if plugins:
... | [
"def",
"_initialize_plugins",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Initializing plugins'",
")",
"plugins",
"=",
"self",
".",
"_pm",
".",
"hook",
".",
"plugins",
"(",
"loop",
"=",
"self",
".",
"_loop",
")",
"if",
"plugins",
":",
"for",
... | Initialize the plugins
Query the configuration and the plugins for info
(name, registry name, start priority, etc) | [
"Initialize",
"the",
"plugins"
] | 22dfdd6a14d61dbe29423fd131b7a23e618b68d7 | https://github.com/pyslackers/sir-bot-a-lot/blob/22dfdd6a14d61dbe29423fd131b7a23e618b68d7/sirbot/core/core.py#L128-L155 | train | Initialize the plugins and the start priority list |
pyslackers/sir-bot-a-lot | sirbot/core/core.py | SirBot._register_factory | def _register_factory(self):
"""
Index the available factories
Query the plugins for an usable factory and register it
"""
for name, info in self._plugins.items():
if info['priority']:
factory = getattr(info['plugin'], 'factory', None)
... | python | def _register_factory(self):
"""
Index the available factories
Query the plugins for an usable factory and register it
"""
for name, info in self._plugins.items():
if info['priority']:
factory = getattr(info['plugin'], 'factory', None)
... | [
"def",
"_register_factory",
"(",
"self",
")",
":",
"for",
"name",
",",
"info",
"in",
"self",
".",
"_plugins",
".",
"items",
"(",
")",
":",
"if",
"info",
"[",
"'priority'",
"]",
":",
"factory",
"=",
"getattr",
"(",
"info",
"[",
"'plugin'",
"]",
",",
... | Index the available factories
Query the plugins for an usable factory and register it | [
"Index",
"the",
"available",
"factories"
] | 22dfdd6a14d61dbe29423fd131b7a23e618b68d7 | https://github.com/pyslackers/sir-bot-a-lot/blob/22dfdd6a14d61dbe29423fd131b7a23e618b68d7/sirbot/core/core.py#L157-L168 | train | Register the available factories and their associated factory |
pyslackers/sir-bot-a-lot | sirbot/core/core.py | SirBot._configure_plugins | async def _configure_plugins(self) -> None:
"""
Configure the plugins
Asynchronously configure the plugins. Pass them their configuration,
the aiohttp session, the registry and the aiohttp router
"""
logger.debug('Configuring plugins')
funcs = [
info[... | python | async def _configure_plugins(self) -> None:
"""
Configure the plugins
Asynchronously configure the plugins. Pass them their configuration,
the aiohttp session, the registry and the aiohttp router
"""
logger.debug('Configuring plugins')
funcs = [
info[... | [
"async",
"def",
"_configure_plugins",
"(",
"self",
")",
"->",
"None",
":",
"logger",
".",
"debug",
"(",
"'Configuring plugins'",
")",
"funcs",
"=",
"[",
"info",
"[",
"'plugin'",
"]",
".",
"configure",
"(",
"config",
"=",
"info",
"[",
"'config'",
"]",
","... | Configure the plugins
Asynchronously configure the plugins. Pass them their configuration,
the aiohttp session, the registry and the aiohttp router | [
"Configure",
"the",
"plugins"
] | 22dfdd6a14d61dbe29423fd131b7a23e618b68d7 | https://github.com/pyslackers/sir-bot-a-lot/blob/22dfdd6a14d61dbe29423fd131b7a23e618b68d7/sirbot/core/core.py#L170-L189 | train | Configure the plugins. |
pyslackers/sir-bot-a-lot | sirbot/core/core.py | SirBot._start_plugins | async def _start_plugins(self) -> None:
"""
Start the plugins by priority
Start the plugins based on the priority and wait for them to be fully
started before starting the next one. This ensure plugins can use
a previously started one during startup.
"""
logger.d... | python | async def _start_plugins(self) -> None:
"""
Start the plugins by priority
Start the plugins based on the priority and wait for them to be fully
started before starting the next one. This ensure plugins can use
a previously started one during startup.
"""
logger.d... | [
"async",
"def",
"_start_plugins",
"(",
"self",
")",
"->",
"None",
":",
"logger",
".",
"debug",
"(",
"'Starting plugins'",
")",
"for",
"priority",
"in",
"sorted",
"(",
"self",
".",
"_start_priority",
",",
"reverse",
"=",
"True",
")",
":",
"logger",
".",
"... | Start the plugins by priority
Start the plugins based on the priority and wait for them to be fully
started before starting the next one. This ensure plugins can use
a previously started one during startup. | [
"Start",
"the",
"plugins",
"by",
"priority"
] | 22dfdd6a14d61dbe29423fd131b7a23e618b68d7 | https://github.com/pyslackers/sir-bot-a-lot/blob/22dfdd6a14d61dbe29423fd131b7a23e618b68d7/sirbot/core/core.py#L191-L222 | train | Start the plugins based on the priority and wait for them to be fully started. |
pyslackers/sir-bot-a-lot | sirbot/core/core.py | SirBot.update | async def update(self):
"""
Update sirbot
Trigger the update method of the plugins. This is needed if the plugins
need to perform update migration (i.e database)
"""
logger.info('Updating Sir Bot-a-lot')
for name, plugin in self._plugins.items():
plug... | python | async def update(self):
"""
Update sirbot
Trigger the update method of the plugins. This is needed if the plugins
need to perform update migration (i.e database)
"""
logger.info('Updating Sir Bot-a-lot')
for name, plugin in self._plugins.items():
plug... | [
"async",
"def",
"update",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Updating Sir Bot-a-lot'",
")",
"for",
"name",
",",
"plugin",
"in",
"self",
".",
"_plugins",
".",
"items",
"(",
")",
":",
"plugin_update",
"=",
"getattr",
"(",
"plugin",
"[",
... | Update sirbot
Trigger the update method of the plugins. This is needed if the plugins
need to perform update migration (i.e database) | [
"Update",
"sirbot"
] | 22dfdd6a14d61dbe29423fd131b7a23e618b68d7 | https://github.com/pyslackers/sir-bot-a-lot/blob/22dfdd6a14d61dbe29423fd131b7a23e618b68d7/sirbot/core/core.py#L224-L239 | train | Update the sirbot s internal cache with the current configuration. |
pyslackers/sir-bot-a-lot | sirbot/core/core.py | SirBot.run | def run(self, host: str = '0.0.0.0', port: int = 8080):
"""
Start sirbot
Configure sirbot and start the aiohttp.web.Application
Args:
host (str): host
port (int): port
"""
self._loop.run_until_complete(self._configure_plugins())
web.run_a... | python | def run(self, host: str = '0.0.0.0', port: int = 8080):
"""
Start sirbot
Configure sirbot and start the aiohttp.web.Application
Args:
host (str): host
port (int): port
"""
self._loop.run_until_complete(self._configure_plugins())
web.run_a... | [
"def",
"run",
"(",
"self",
",",
"host",
":",
"str",
"=",
"'0.0.0.0'",
",",
"port",
":",
"int",
"=",
"8080",
")",
":",
"self",
".",
"_loop",
".",
"run_until_complete",
"(",
"self",
".",
"_configure_plugins",
"(",
")",
")",
"web",
".",
"run_app",
"(",
... | Start sirbot
Configure sirbot and start the aiohttp.web.Application
Args:
host (str): host
port (int): port | [
"Start",
"sirbot"
] | 22dfdd6a14d61dbe29423fd131b7a23e618b68d7 | https://github.com/pyslackers/sir-bot-a-lot/blob/22dfdd6a14d61dbe29423fd131b7a23e618b68d7/sirbot/core/core.py#L250-L261 | train | Starts sirbot and starts the application |
samghelms/mathviz | mathviz_hopper/src/table.py | Table._create_settings | def _create_settings(self):
"""
Creates the settings object that will be sent
to the frontend vizualization
"""
self.settings = {
"columns": [{"Header": s, "accessor": s} for s in self.settings],
"port": self.port,
"docs": construct_trie(se... | python | def _create_settings(self):
"""
Creates the settings object that will be sent
to the frontend vizualization
"""
self.settings = {
"columns": [{"Header": s, "accessor": s} for s in self.settings],
"port": self.port,
"docs": construct_trie(se... | [
"def",
"_create_settings",
"(",
"self",
")",
":",
"self",
".",
"settings",
"=",
"{",
"\"columns\"",
":",
"[",
"{",
"\"Header\"",
":",
"s",
",",
"\"accessor\"",
":",
"s",
"}",
"for",
"s",
"in",
"self",
".",
"settings",
"]",
",",
"\"port\"",
":",
"self... | Creates the settings object that will be sent
to the frontend vizualization | [
"Creates",
"the",
"settings",
"object",
"that",
"will",
"be",
"sent",
"to",
"the",
"frontend",
"vizualization"
] | 30fe89537379faea4de8c8b568ac6e52e4d15353 | https://github.com/samghelms/mathviz/blob/30fe89537379faea4de8c8b568ac6e52e4d15353/mathviz_hopper/src/table.py#L75-L86 | train | Creates the settings object that will be sent
to the frontend vizualization
|
samghelms/mathviz | mathviz_hopper/src/table.py | Table.run_server | def run_server(self):
"""
Runs a server to handle queries to the index without creating the
javascript table.
"""
app = build_app()
run(app, host='localhost', port=self.port) | python | def run_server(self):
"""
Runs a server to handle queries to the index without creating the
javascript table.
"""
app = build_app()
run(app, host='localhost', port=self.port) | [
"def",
"run_server",
"(",
"self",
")",
":",
"app",
"=",
"build_app",
"(",
")",
"run",
"(",
"app",
",",
"host",
"=",
"'localhost'",
",",
"port",
"=",
"self",
".",
"port",
")"
] | Runs a server to handle queries to the index without creating the
javascript table. | [
"Runs",
"a",
"server",
"to",
"handle",
"queries",
"to",
"the",
"index",
"without",
"creating",
"the",
"javascript",
"table",
"."
] | 30fe89537379faea4de8c8b568ac6e52e4d15353 | https://github.com/samghelms/mathviz/blob/30fe89537379faea4de8c8b568ac6e52e4d15353/mathviz_hopper/src/table.py#L133-L140 | train | Runs a server to handle queries to the index without creating the
javascript table. |
samghelms/mathviz | mathviz_hopper/src/table.py | Table.print_ipython | def print_ipython(self):
"""
Renders the javascript table to a jupyter/ipython notebook cell
Usage example:
>>> t = Table(ind)
>>> t.print_ipython()
... renders the table to notebook cell
"""
from IPython.display import display, HTML
se... | python | def print_ipython(self):
"""
Renders the javascript table to a jupyter/ipython notebook cell
Usage example:
>>> t = Table(ind)
>>> t.print_ipython()
... renders the table to notebook cell
"""
from IPython.display import display, HTML
se... | [
"def",
"print_ipython",
"(",
"self",
")",
":",
"from",
"IPython",
".",
"display",
"import",
"display",
",",
"HTML",
"self",
".",
"_listen",
"(",
")",
"try",
":",
"shutil",
".",
"rmtree",
"(",
"'viz'",
")",
"except",
":",
"None",
"shutil",
".",
"copytre... | Renders the javascript table to a jupyter/ipython notebook cell
Usage example:
>>> t = Table(ind)
>>> t.print_ipython()
... renders the table to notebook cell | [
"Renders",
"the",
"javascript",
"table",
"to",
"a",
"jupyter",
"/",
"ipython",
"notebook",
"cell"
] | 30fe89537379faea4de8c8b568ac6e52e4d15353 | https://github.com/samghelms/mathviz/blob/30fe89537379faea4de8c8b568ac6e52e4d15353/mathviz_hopper/src/table.py#L142-L162 | train | Prints the javascript table to a jupyter notebook cell
|
polyaxon/hestia | hestia/string_utils.py | strip_spaces | def strip_spaces(value, sep=None, join=True):
"""Cleans trailing whitespaces and replaces also multiple whitespaces with a single space."""
value = value.strip()
value = [v.strip() for v in value.split(sep)]
join_sep = sep or ' '
return join_sep.join(value) if join else value | python | def strip_spaces(value, sep=None, join=True):
"""Cleans trailing whitespaces and replaces also multiple whitespaces with a single space."""
value = value.strip()
value = [v.strip() for v in value.split(sep)]
join_sep = sep or ' '
return join_sep.join(value) if join else value | [
"def",
"strip_spaces",
"(",
"value",
",",
"sep",
"=",
"None",
",",
"join",
"=",
"True",
")",
":",
"value",
"=",
"value",
".",
"strip",
"(",
")",
"value",
"=",
"[",
"v",
".",
"strip",
"(",
")",
"for",
"v",
"in",
"value",
".",
"split",
"(",
"sep"... | Cleans trailing whitespaces and replaces also multiple whitespaces with a single space. | [
"Cleans",
"trailing",
"whitespaces",
"and",
"replaces",
"also",
"multiple",
"whitespaces",
"with",
"a",
"single",
"space",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/string_utils.py#L5-L10 | train | Cleans trailing whitespaces and replaces also multiple whitespaces with a single space. |
BernardFW/bernard | src/bernard/engine/transition.py | Transition.rank | async def rank(self, request, origin: Optional[Text]) \
-> Tuple[
float,
Optional[BaseTrigger],
Optional[type],
Optional[bool],
]:
"""
Computes the rank of this transition for a given request.
It returns (in... | python | async def rank(self, request, origin: Optional[Text]) \
-> Tuple[
float,
Optional[BaseTrigger],
Optional[type],
Optional[bool],
]:
"""
Computes the rank of this transition for a given request.
It returns (in... | [
"async",
"def",
"rank",
"(",
"self",
",",
"request",
",",
"origin",
":",
"Optional",
"[",
"Text",
"]",
")",
"->",
"Tuple",
"[",
"float",
",",
"Optional",
"[",
"BaseTrigger",
"]",
",",
"Optional",
"[",
"type",
"]",
",",
"Optional",
"[",
"bool",
"]",
... | Computes the rank of this transition for a given request.
It returns (in order):
- The score (from 0 to 1)
- The trigger instance (if it matched)
- The class of the destination state (if matched) | [
"Computes",
"the",
"rank",
"of",
"this",
"transition",
"for",
"a",
"given",
"request",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/transition.py#L72-L100 | train | Returns the rank of this transition for a given request. |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_point.py | NCEIPointBase.check_dimensions | def check_dimensions(self, dataset):
'''
Checks that the feature types of this dataset are consitent with a point dataset
'''
required_ctx = TestCtx(BaseCheck.HIGH, 'All geophysical variables are point feature types')
t = util.get_time_variable(dataset)
# Exit prematurel... | python | def check_dimensions(self, dataset):
'''
Checks that the feature types of this dataset are consitent with a point dataset
'''
required_ctx = TestCtx(BaseCheck.HIGH, 'All geophysical variables are point feature types')
t = util.get_time_variable(dataset)
# Exit prematurel... | [
"def",
"check_dimensions",
"(",
"self",
",",
"dataset",
")",
":",
"required_ctx",
"=",
"TestCtx",
"(",
"BaseCheck",
".",
"HIGH",
",",
"'All geophysical variables are point feature types'",
")",
"t",
"=",
"util",
".",
"get_time_variable",
"(",
"dataset",
")",
"# Ex... | Checks that the feature types of this dataset are consitent with a point dataset | [
"Checks",
"that",
"the",
"feature",
"types",
"of",
"this",
"dataset",
"are",
"consitent",
"with",
"a",
"point",
"dataset"
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_point.py#L19-L40 | train | Checks that the feature types of this dataset are consitent with a point dataset |
BernardFW/bernard | src/bernard/engine/platform.py | Platform.settings | def settings(cls):
"""
Find the settings for the current class inside the platforms
configuration.
"""
from bernard.platforms.management import get_platform_settings
for platform in get_platform_settings():
candidate = import_class(platform['class'])
... | python | def settings(cls):
"""
Find the settings for the current class inside the platforms
configuration.
"""
from bernard.platforms.management import get_platform_settings
for platform in get_platform_settings():
candidate = import_class(platform['class'])
... | [
"def",
"settings",
"(",
"cls",
")",
":",
"from",
"bernard",
".",
"platforms",
".",
"management",
"import",
"get_platform_settings",
"for",
"platform",
"in",
"get_platform_settings",
"(",
")",
":",
"candidate",
"=",
"import_class",
"(",
"platform",
"[",
"'class'"... | Find the settings for the current class inside the platforms
configuration. | [
"Find",
"the",
"settings",
"for",
"the",
"current",
"class",
"inside",
"the",
"platforms",
"configuration",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/platform.py#L72-L83 | train | Find the settings for the current class inside the platforms
configuration. |
BernardFW/bernard | src/bernard/engine/platform.py | Platform._notify | async def _notify(self, message: BaseMessage, responder: Responder):
"""
Notify all callbacks that a message was received.
"""
for cb in self._listeners:
coro = cb(message, responder, self.fsm_creates_task)
if not self.fsm_creates_task:
self._regi... | python | async def _notify(self, message: BaseMessage, responder: Responder):
"""
Notify all callbacks that a message was received.
"""
for cb in self._listeners:
coro = cb(message, responder, self.fsm_creates_task)
if not self.fsm_creates_task:
self._regi... | [
"async",
"def",
"_notify",
"(",
"self",
",",
"message",
":",
"BaseMessage",
",",
"responder",
":",
"Responder",
")",
":",
"for",
"cb",
"in",
"self",
".",
"_listeners",
":",
"coro",
"=",
"cb",
"(",
"message",
",",
"responder",
",",
"self",
".",
"fsm_cre... | Notify all callbacks that a message was received. | [
"Notify",
"all",
"callbacks",
"that",
"a",
"message",
"was",
"received",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/platform.py#L104-L112 | train | Notify all listeners that a message was received. |
BernardFW/bernard | src/bernard/engine/platform.py | SimplePlatform.async_init | async def async_init(self):
"""
During async init we just need to create a HTTP session so we can keep
outgoing connexions to the platform alive.
"""
self.session = aiohttp.ClientSession()
asyncio.get_event_loop().create_task(self._deferred_init()) | python | async def async_init(self):
"""
During async init we just need to create a HTTP session so we can keep
outgoing connexions to the platform alive.
"""
self.session = aiohttp.ClientSession()
asyncio.get_event_loop().create_task(self._deferred_init()) | [
"async",
"def",
"async_init",
"(",
"self",
")",
":",
"self",
".",
"session",
"=",
"aiohttp",
".",
"ClientSession",
"(",
")",
"asyncio",
".",
"get_event_loop",
"(",
")",
".",
"create_task",
"(",
"self",
".",
"_deferred_init",
"(",
")",
")"
] | During async init we just need to create a HTTP session so we can keep
outgoing connexions to the platform alive. | [
"During",
"async",
"init",
"we",
"just",
"need",
"to",
"create",
"a",
"HTTP",
"session",
"so",
"we",
"can",
"keep",
"outgoing",
"connexions",
"to",
"the",
"platform",
"alive",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/platform.py#L177-L183 | train | Initialize the session. |
BernardFW/bernard | src/bernard/engine/platform.py | SimplePlatform.accept | def accept(self, stack: Stack):
"""
Checks that the stack can be accepted according to the `PATTERNS`.
If the pattern is found, then its name is stored in the `annotation`
attribute of the stack.
"""
for name, pattern in self.PATTERNS.items():
if stack.match... | python | def accept(self, stack: Stack):
"""
Checks that the stack can be accepted according to the `PATTERNS`.
If the pattern is found, then its name is stored in the `annotation`
attribute of the stack.
"""
for name, pattern in self.PATTERNS.items():
if stack.match... | [
"def",
"accept",
"(",
"self",
",",
"stack",
":",
"Stack",
")",
":",
"for",
"name",
",",
"pattern",
"in",
"self",
".",
"PATTERNS",
".",
"items",
"(",
")",
":",
"if",
"stack",
".",
"match_exp",
"(",
"pattern",
")",
":",
"stack",
".",
"annotation",
"=... | Checks that the stack can be accepted according to the `PATTERNS`.
If the pattern is found, then its name is stored in the `annotation`
attribute of the stack. | [
"Checks",
"that",
"the",
"stack",
"can",
"be",
"accepted",
"according",
"to",
"the",
"PATTERNS",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/platform.py#L192-L204 | train | Checks that the stack can be accepted according to the PATTERNS. |
BernardFW/bernard | src/bernard/engine/platform.py | SimplePlatform.send | def send(self, request: Request, stack: Stack) -> Coroutine:
"""
Send a stack to the platform.
Actually this will delegate to one of the `_send_*` functions depending
on what the stack looks like.
"""
if stack.annotation not in self.PATTERNS:
if not self.acc... | python | def send(self, request: Request, stack: Stack) -> Coroutine:
"""
Send a stack to the platform.
Actually this will delegate to one of the `_send_*` functions depending
on what the stack looks like.
"""
if stack.annotation not in self.PATTERNS:
if not self.acc... | [
"def",
"send",
"(",
"self",
",",
"request",
":",
"Request",
",",
"stack",
":",
"Stack",
")",
"->",
"Coroutine",
":",
"if",
"stack",
".",
"annotation",
"not",
"in",
"self",
".",
"PATTERNS",
":",
"if",
"not",
"self",
".",
"accept",
"(",
"stack",
")",
... | Send a stack to the platform.
Actually this will delegate to one of the `_send_*` functions depending
on what the stack looks like. | [
"Send",
"a",
"stack",
"to",
"the",
"platform",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/platform.py#L206-L219 | train | Send a stack to the platform. |
polyaxon/hestia | hestia/units.py | to_unit_memory | def to_unit_memory(number):
"""Creates a string representation of memory size given `number`."""
kb = 1024
number /= kb
if number < 100:
return '{} Kb'.format(round(number, 2))
number /= kb
if number < 300:
return '{} Mb'.format(round(number, 2))
number /= kb
return ... | python | def to_unit_memory(number):
"""Creates a string representation of memory size given `number`."""
kb = 1024
number /= kb
if number < 100:
return '{} Kb'.format(round(number, 2))
number /= kb
if number < 300:
return '{} Mb'.format(round(number, 2))
number /= kb
return ... | [
"def",
"to_unit_memory",
"(",
"number",
")",
":",
"kb",
"=",
"1024",
"number",
"/=",
"kb",
"if",
"number",
"<",
"100",
":",
"return",
"'{} Kb'",
".",
"format",
"(",
"round",
"(",
"number",
",",
"2",
")",
")",
"number",
"/=",
"kb",
"if",
"number",
"... | Creates a string representation of memory size given `number`. | [
"Creates",
"a",
"string",
"representation",
"of",
"memory",
"size",
"given",
"number",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/units.py#L5-L20 | train | Creates a string representation of memory size given number. |
polyaxon/hestia | hestia/units.py | to_percentage | def to_percentage(number, rounding=2):
"""Creates a percentage string representation from the given `number`. The
number is multiplied by 100 before adding a '%' character.
Raises `ValueError` if `number` cannot be converted to a number.
"""
number = float(number) * 100
number_as_int = int(numb... | python | def to_percentage(number, rounding=2):
"""Creates a percentage string representation from the given `number`. The
number is multiplied by 100 before adding a '%' character.
Raises `ValueError` if `number` cannot be converted to a number.
"""
number = float(number) * 100
number_as_int = int(numb... | [
"def",
"to_percentage",
"(",
"number",
",",
"rounding",
"=",
"2",
")",
":",
"number",
"=",
"float",
"(",
"number",
")",
"*",
"100",
"number_as_int",
"=",
"int",
"(",
"number",
")",
"rounded",
"=",
"round",
"(",
"number",
",",
"rounding",
")",
"return",... | Creates a percentage string representation from the given `number`. The
number is multiplied by 100 before adding a '%' character.
Raises `ValueError` if `number` cannot be converted to a number. | [
"Creates",
"a",
"percentage",
"string",
"representation",
"from",
"the",
"given",
"number",
".",
"The",
"number",
"is",
"multiplied",
"by",
"100",
"before",
"adding",
"a",
"%",
"character",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/units.py#L23-L33 | train | Converts a number to a percentage string. |
pyQode/pyqode.cobol | pyqode/cobol/widgets/pic_offsets.py | PicOffsetsTable.set_editor | def set_editor(self, editor):
"""
Sets the associated editor, when the editor's offset calculator mode
emit the signal pic_infos_available, the table is automatically
refreshed.
You can also refresh manually by calling :meth:`update_pic_infos`.
"""
if self._edito... | python | def set_editor(self, editor):
"""
Sets the associated editor, when the editor's offset calculator mode
emit the signal pic_infos_available, the table is automatically
refreshed.
You can also refresh manually by calling :meth:`update_pic_infos`.
"""
if self._edito... | [
"def",
"set_editor",
"(",
"self",
",",
"editor",
")",
":",
"if",
"self",
".",
"_editor",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"_editor",
".",
"offset_calculator",
".",
"pic_infos_available",
".",
"disconnect",
"(",
"self",
".",
"_update",
"... | Sets the associated editor, when the editor's offset calculator mode
emit the signal pic_infos_available, the table is automatically
refreshed.
You can also refresh manually by calling :meth:`update_pic_infos`. | [
"Sets",
"the",
"associated",
"editor",
"when",
"the",
"editor",
"s",
"offset",
"calculator",
"mode",
"emit",
"the",
"signal",
"pic_infos_available",
"the",
"table",
"is",
"automatically",
"refreshed",
"."
] | eedae4e320a4b2d0c44abb2c3061091321648fb7 | https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/widgets/pic_offsets.py#L25-L45 | train | Sets the associated editor for the current entry. |
BernardFW/bernard | src/bernard/conf/utils.py | patch_conf | def patch_conf(settings_patch=None, settings_file=None):
"""
Reload the configuration form scratch. Only the default config is loaded,
not the environment-specified config.
Then the specified patch is applied.
This is for unit tests only!
:param settings_patch: Custom configuration values to ... | python | def patch_conf(settings_patch=None, settings_file=None):
"""
Reload the configuration form scratch. Only the default config is loaded,
not the environment-specified config.
Then the specified patch is applied.
This is for unit tests only!
:param settings_patch: Custom configuration values to ... | [
"def",
"patch_conf",
"(",
"settings_patch",
"=",
"None",
",",
"settings_file",
"=",
"None",
")",
":",
"if",
"settings_patch",
"is",
"None",
":",
"settings_patch",
"=",
"{",
"}",
"reload_config",
"(",
")",
"os",
".",
"environ",
"[",
"ENVIRONMENT_VARIABLE",
"]... | Reload the configuration form scratch. Only the default config is loaded,
not the environment-specified config.
Then the specified patch is applied.
This is for unit tests only!
:param settings_patch: Custom configuration values to insert
:param settings_file: Custom settings file to read | [
"Reload",
"the",
"configuration",
"form",
"scratch",
".",
"Only",
"the",
"default",
"config",
"is",
"loaded",
"not",
"the",
"environment",
"-",
"specified",
"config",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/conf/utils.py#L30-L59 | train | Patch the configuration of a bernard. conf file. |
giancosta86/Iris | info/gianlucacosta/iris/ioc.py | Container.addRegistration | def addRegistration(self, key, registration):
"""
Binds an IoC registration to a given key. It should be used if you
introduce custom registrations; otherwise, registerTransient() and registerSingleton()
are usually shorter and simpler.
Registering a key twice raises a KeyError.
... | python | def addRegistration(self, key, registration):
"""
Binds an IoC registration to a given key. It should be used if you
introduce custom registrations; otherwise, registerTransient() and registerSingleton()
are usually shorter and simpler.
Registering a key twice raises a KeyError.
... | [
"def",
"addRegistration",
"(",
"self",
",",
"key",
",",
"registration",
")",
":",
"if",
"key",
"in",
"self",
".",
"_registrations",
":",
"raise",
"KeyError",
"(",
"\"Key already registered\"",
")",
"self",
".",
"_registrations",
"[",
"key",
"]",
"=",
"regist... | Binds an IoC registration to a given key. It should be used if you
introduce custom registrations; otherwise, registerTransient() and registerSingleton()
are usually shorter and simpler.
Registering a key twice raises a KeyError. | [
"Binds",
"an",
"IoC",
"registration",
"to",
"a",
"given",
"key",
".",
"It",
"should",
"be",
"used",
"if",
"you",
"introduce",
"custom",
"registrations",
";",
"otherwise",
"registerTransient",
"()",
"and",
"registerSingleton",
"()",
"are",
"usually",
"shorter",
... | b3d92cca5cce3653519bd032346b211c46a57d05 | https://github.com/giancosta86/Iris/blob/b3d92cca5cce3653519bd032346b211c46a57d05/info/gianlucacosta/iris/ioc.py#L102-L113 | train | Adds an IoC registration to a given key. |
giancosta86/Iris | info/gianlucacosta/iris/ioc.py | Container.registerSingleton | def registerSingleton(self, key, factoryMethod, disposeMethod=None):
"""
Binds a singleton instance to a key: whenever the requested key is resolved,
if the instance is still None, it is created by calling factoryMethod(container, key);
otherwise, it is just returned.
When the c... | python | def registerSingleton(self, key, factoryMethod, disposeMethod=None):
"""
Binds a singleton instance to a key: whenever the requested key is resolved,
if the instance is still None, it is created by calling factoryMethod(container, key);
otherwise, it is just returned.
When the c... | [
"def",
"registerSingleton",
"(",
"self",
",",
"key",
",",
"factoryMethod",
",",
"disposeMethod",
"=",
"None",
")",
":",
"return",
"self",
".",
"addRegistration",
"(",
"key",
",",
"SingletonRegistration",
"(",
"factoryMethod",
",",
"disposeMethod",
")",
")"
] | Binds a singleton instance to a key: whenever the requested key is resolved,
if the instance is still None, it is created by calling factoryMethod(container, key);
otherwise, it is just returned.
When the client calls dispose() on the container, disposeMethod(instance) is called
if the ... | [
"Binds",
"a",
"singleton",
"instance",
"to",
"a",
"key",
":",
"whenever",
"the",
"requested",
"key",
"is",
"resolved",
"if",
"the",
"instance",
"is",
"still",
"None",
"it",
"is",
"created",
"by",
"calling",
"factoryMethod",
"(",
"container",
"key",
")",
";... | b3d92cca5cce3653519bd032346b211c46a57d05 | https://github.com/giancosta86/Iris/blob/b3d92cca5cce3653519bd032346b211c46a57d05/info/gianlucacosta/iris/ioc.py#L127-L136 | train | Binds a singleton instance to a key. |
giancosta86/Iris | info/gianlucacosta/iris/ioc.py | Container.resolve | def resolve(self, key):
"""
Resolves the requested key to an object instance, raising a KeyError if the key is missing
"""
registration = self._registrations.get(key)
if registration is None:
raise KeyError("Unknown key: '{0}'".format(key))
return registrati... | python | def resolve(self, key):
"""
Resolves the requested key to an object instance, raising a KeyError if the key is missing
"""
registration = self._registrations.get(key)
if registration is None:
raise KeyError("Unknown key: '{0}'".format(key))
return registrati... | [
"def",
"resolve",
"(",
"self",
",",
"key",
")",
":",
"registration",
"=",
"self",
".",
"_registrations",
".",
"get",
"(",
"key",
")",
"if",
"registration",
"is",
"None",
":",
"raise",
"KeyError",
"(",
"\"Unknown key: '{0}'\"",
".",
"format",
"(",
"key",
... | Resolves the requested key to an object instance, raising a KeyError if the key is missing | [
"Resolves",
"the",
"requested",
"key",
"to",
"an",
"object",
"instance",
"raising",
"a",
"KeyError",
"if",
"the",
"key",
"is",
"missing"
] | b3d92cca5cce3653519bd032346b211c46a57d05 | https://github.com/giancosta86/Iris/blob/b3d92cca5cce3653519bd032346b211c46a57d05/info/gianlucacosta/iris/ioc.py#L139-L148 | train | Resolves the requested key to an object instance raising a KeyError if the key is missing
|
giancosta86/Iris | info/gianlucacosta/iris/ioc.py | Container.dispose | def dispose(self):
"""
Disposes every performed registration; the container can then be used again
"""
for registration in self._registrations.values():
registration.dispose()
self._registrations = {} | python | def dispose(self):
"""
Disposes every performed registration; the container can then be used again
"""
for registration in self._registrations.values():
registration.dispose()
self._registrations = {} | [
"def",
"dispose",
"(",
"self",
")",
":",
"for",
"registration",
"in",
"self",
".",
"_registrations",
".",
"values",
"(",
")",
":",
"registration",
".",
"dispose",
"(",
")",
"self",
".",
"_registrations",
"=",
"{",
"}"
] | Disposes every performed registration; the container can then be used again | [
"Disposes",
"every",
"performed",
"registration",
";",
"the",
"container",
"can",
"then",
"be",
"used",
"again"
] | b3d92cca5cce3653519bd032346b211c46a57d05 | https://github.com/giancosta86/Iris/blob/b3d92cca5cce3653519bd032346b211c46a57d05/info/gianlucacosta/iris/ioc.py#L151-L158 | train | Disposes all the registrations and the container. |
reanahub/reana-db | reana_db/utils.py | build_workspace_path | def build_workspace_path(user_id, workflow_id=None):
"""Build user's workspace relative path.
:param user_id: Owner of the workspace.
:param workflow_id: Optional parameter, if provided gives the path to the
workflow workspace instead of just the path to the user workspace.
:return: String that... | python | def build_workspace_path(user_id, workflow_id=None):
"""Build user's workspace relative path.
:param user_id: Owner of the workspace.
:param workflow_id: Optional parameter, if provided gives the path to the
workflow workspace instead of just the path to the user workspace.
:return: String that... | [
"def",
"build_workspace_path",
"(",
"user_id",
",",
"workflow_id",
"=",
"None",
")",
":",
"workspace_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'users'",
",",
"str",
"(",
"user_id",
")",
",",
"'workflows'",
")",
"if",
"workflow_id",
":",
"workspace_... | Build user's workspace relative path.
:param user_id: Owner of the workspace.
:param workflow_id: Optional parameter, if provided gives the path to the
workflow workspace instead of just the path to the user workspace.
:return: String that represents the workspace relative path.
i.e. users/... | [
"Build",
"user",
"s",
"workspace",
"relative",
"path",
"."
] | 4efcb46d23af035689964d8c25a804c5a8f1dfc3 | https://github.com/reanahub/reana-db/blob/4efcb46d23af035689964d8c25a804c5a8f1dfc3/reana_db/utils.py#L14-L27 | train | Build user s workspace relative path. |
reanahub/reana-db | reana_db/utils.py | _get_workflow_with_uuid_or_name | def _get_workflow_with_uuid_or_name(uuid_or_name, user_uuid):
"""Get Workflow from database with uuid or name.
:param uuid_or_name: String representing a valid UUIDv4 or valid
Workflow name. Valid name contains only ASCII alphanumerics.
Name might be in format 'reana.workflow.123' with arbitra... | python | def _get_workflow_with_uuid_or_name(uuid_or_name, user_uuid):
"""Get Workflow from database with uuid or name.
:param uuid_or_name: String representing a valid UUIDv4 or valid
Workflow name. Valid name contains only ASCII alphanumerics.
Name might be in format 'reana.workflow.123' with arbitra... | [
"def",
"_get_workflow_with_uuid_or_name",
"(",
"uuid_or_name",
",",
"user_uuid",
")",
":",
"from",
"reana_db",
".",
"models",
"import",
"Workflow",
"# Check existence",
"if",
"not",
"uuid_or_name",
":",
"raise",
"ValueError",
"(",
"'No Workflow was specified.'",
")",
... | Get Workflow from database with uuid or name.
:param uuid_or_name: String representing a valid UUIDv4 or valid
Workflow name. Valid name contains only ASCII alphanumerics.
Name might be in format 'reana.workflow.123' with arbitrary
number of dot-delimited substrings, where last substring s... | [
"Get",
"Workflow",
"from",
"database",
"with",
"uuid",
"or",
"name",
"."
] | 4efcb46d23af035689964d8c25a804c5a8f1dfc3 | https://github.com/reanahub/reana-db/blob/4efcb46d23af035689964d8c25a804c5a8f1dfc3/reana_db/utils.py#L30-L127 | train | Get a workflow from database with UUID or name. |
reanahub/reana-db | reana_db/utils.py | _get_workflow_by_name | def _get_workflow_by_name(workflow_name, user_uuid):
"""From Workflows named as `workflow_name` the latest run_number.
Only use when you are sure that workflow_name is not UUIDv4.
:rtype: reana-db.models.Workflow
"""
from reana_db.models import Workflow
workflow = Workflow.query.filter(
... | python | def _get_workflow_by_name(workflow_name, user_uuid):
"""From Workflows named as `workflow_name` the latest run_number.
Only use when you are sure that workflow_name is not UUIDv4.
:rtype: reana-db.models.Workflow
"""
from reana_db.models import Workflow
workflow = Workflow.query.filter(
... | [
"def",
"_get_workflow_by_name",
"(",
"workflow_name",
",",
"user_uuid",
")",
":",
"from",
"reana_db",
".",
"models",
"import",
"Workflow",
"workflow",
"=",
"Workflow",
".",
"query",
".",
"filter",
"(",
"Workflow",
".",
"name",
"==",
"workflow_name",
",",
"Work... | From Workflows named as `workflow_name` the latest run_number.
Only use when you are sure that workflow_name is not UUIDv4.
:rtype: reana-db.models.Workflow | [
"From",
"Workflows",
"named",
"as",
"workflow_name",
"the",
"latest",
"run_number",
"."
] | 4efcb46d23af035689964d8c25a804c5a8f1dfc3 | https://github.com/reanahub/reana-db/blob/4efcb46d23af035689964d8c25a804c5a8f1dfc3/reana_db/utils.py#L130-L149 | train | Get a workflow by name. |
reanahub/reana-db | reana_db/utils.py | _get_workflow_by_uuid | def _get_workflow_by_uuid(workflow_uuid):
"""Get Workflow with UUIDv4.
:param workflow_uuid: UUIDv4 of a Workflow.
:type workflow_uuid: String representing a valid UUIDv4.
:rtype: reana-db.models.Workflow
"""
from reana_db.models import Workflow
workflow = Workflow.query.filter(Workflow.id... | python | def _get_workflow_by_uuid(workflow_uuid):
"""Get Workflow with UUIDv4.
:param workflow_uuid: UUIDv4 of a Workflow.
:type workflow_uuid: String representing a valid UUIDv4.
:rtype: reana-db.models.Workflow
"""
from reana_db.models import Workflow
workflow = Workflow.query.filter(Workflow.id... | [
"def",
"_get_workflow_by_uuid",
"(",
"workflow_uuid",
")",
":",
"from",
"reana_db",
".",
"models",
"import",
"Workflow",
"workflow",
"=",
"Workflow",
".",
"query",
".",
"filter",
"(",
"Workflow",
".",
"id_",
"==",
"workflow_uuid",
")",
".",
"first",
"(",
")"... | Get Workflow with UUIDv4.
:param workflow_uuid: UUIDv4 of a Workflow.
:type workflow_uuid: String representing a valid UUIDv4.
:rtype: reana-db.models.Workflow | [
"Get",
"Workflow",
"with",
"UUIDv4",
"."
] | 4efcb46d23af035689964d8c25a804c5a8f1dfc3 | https://github.com/reanahub/reana-db/blob/4efcb46d23af035689964d8c25a804c5a8f1dfc3/reana_db/utils.py#L152-L170 | train | Get a workflow with the given UUID. |
BernardFW/bernard | src/bernard/i18n/loaders.py | extract_ranges | def extract_ranges(row, ranges: ColRanges) -> List[Text]:
"""
Extracts a list of ranges from a row:
- If the range is an int, just get the data at this index
- If the range is a tuple of two ints, use them as indices in a slice
- If the range is an int then a None, start the slice at the int and go... | python | def extract_ranges(row, ranges: ColRanges) -> List[Text]:
"""
Extracts a list of ranges from a row:
- If the range is an int, just get the data at this index
- If the range is a tuple of two ints, use them as indices in a slice
- If the range is an int then a None, start the slice at the int and go... | [
"def",
"extract_ranges",
"(",
"row",
",",
"ranges",
":",
"ColRanges",
")",
"->",
"List",
"[",
"Text",
"]",
":",
"out",
"=",
"[",
"]",
"for",
"r",
"in",
"ranges",
":",
"if",
"isinstance",
"(",
"r",
",",
"int",
")",
":",
"r",
"=",
"(",
"r",
",",
... | Extracts a list of ranges from a row:
- If the range is an int, just get the data at this index
- If the range is a tuple of two ints, use them as indices in a slice
- If the range is an int then a None, start the slice at the int and go
up to the end of the row. | [
"Extracts",
"a",
"list",
"of",
"ranges",
"from",
"a",
"row",
":"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/loaders.py#L233-L254 | train | Extracts a list of ranges from a row. |
BernardFW/bernard | src/bernard/i18n/loaders.py | LiveFileLoaderMixin._watch | async def _watch(self):
"""
Start the watching loop.
"""
file_name = os.path.basename(self._file_path)
logger.info(
'Watching %s "%s"',
self.THING,
self._file_path,
)
while self._running:
evt = await self._watcher.... | python | async def _watch(self):
"""
Start the watching loop.
"""
file_name = os.path.basename(self._file_path)
logger.info(
'Watching %s "%s"',
self.THING,
self._file_path,
)
while self._running:
evt = await self._watcher.... | [
"async",
"def",
"_watch",
"(",
"self",
")",
":",
"file_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"self",
".",
"_file_path",
")",
"logger",
".",
"info",
"(",
"'Watching %s \"%s\"'",
",",
"self",
".",
"THING",
",",
"self",
".",
"_file_path",
"... | Start the watching loop. | [
"Start",
"the",
"watching",
"loop",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/loaders.py#L54-L75 | train | Start the watching loop. |
BernardFW/bernard | src/bernard/i18n/loaders.py | LiveFileLoaderMixin.start | async def start(self, file_path, locale=None, kwargs=None):
"""
Setup the watching utilities, start the loop and load data a first
time.
"""
self._file_path = os.path.realpath(file_path)
self._locale = locale
if kwargs:
self._kwargs = kwargs
... | python | async def start(self, file_path, locale=None, kwargs=None):
"""
Setup the watching utilities, start the loop and load data a first
time.
"""
self._file_path = os.path.realpath(file_path)
self._locale = locale
if kwargs:
self._kwargs = kwargs
... | [
"async",
"def",
"start",
"(",
"self",
",",
"file_path",
",",
"locale",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"self",
".",
"_file_path",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"file_path",
")",
"self",
".",
"_locale",
"=",
"locale"... | Setup the watching utilities, start the loop and load data a first
time. | [
"Setup",
"the",
"watching",
"utilities",
"start",
"the",
"loop",
"and",
"load",
"data",
"a",
"first",
"time",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/loaders.py#L77-L103 | train | Start the event loop and load the data. |
BernardFW/bernard | src/bernard/i18n/loaders.py | BaseTranslationLoader._update | def _update(self, data: TransDict, *args, **kwargs):
"""
Propagate updates to listeners
:param data: Data to propagate
"""
for l in self.listeners:
l(data, *args, **kwargs) | python | def _update(self, data: TransDict, *args, **kwargs):
"""
Propagate updates to listeners
:param data: Data to propagate
"""
for l in self.listeners:
l(data, *args, **kwargs) | [
"def",
"_update",
"(",
"self",
",",
"data",
":",
"TransDict",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"l",
"in",
"self",
".",
"listeners",
":",
"l",
"(",
"data",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Propagate updates to listeners
:param data: Data to propagate | [
"Propagate",
"updates",
"to",
"listeners"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/loaders.py#L126-L134 | train | Update the internal state of the object. |
BernardFW/bernard | src/bernard/i18n/loaders.py | CsvTranslationLoader._load | async def _load(self):
"""
Load data from a Excel-formatted CSV file.
"""
flags = self._kwargs.get('flags')
if not flags:
flags = {1: {}}
cols = {k: [] for k in flags.keys()}
with open(self._file_path, newline='', encoding='utf-8') as f:
... | python | async def _load(self):
"""
Load data from a Excel-formatted CSV file.
"""
flags = self._kwargs.get('flags')
if not flags:
flags = {1: {}}
cols = {k: [] for k in flags.keys()}
with open(self._file_path, newline='', encoding='utf-8') as f:
... | [
"async",
"def",
"_load",
"(",
"self",
")",
":",
"flags",
"=",
"self",
".",
"_kwargs",
".",
"get",
"(",
"'flags'",
")",
"if",
"not",
"flags",
":",
"flags",
"=",
"{",
"1",
":",
"{",
"}",
"}",
"cols",
"=",
"{",
"k",
":",
"[",
"]",
"for",
"k",
... | Load data from a Excel-formatted CSV file. | [
"Load",
"data",
"from",
"a",
"Excel",
"-",
"formatted",
"CSV",
"file",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/loaders.py#L152-L178 | train | Load data from an Excel - formatted CSV file. |
BernardFW/bernard | src/bernard/i18n/loaders.py | CsvTranslationLoader.load | async def load(self, file_path, locale=None, flags=None):
"""
Start the loading/watching process
"""
await self.start(file_path, locale, {'flags': flags}) | python | async def load(self, file_path, locale=None, flags=None):
"""
Start the loading/watching process
"""
await self.start(file_path, locale, {'flags': flags}) | [
"async",
"def",
"load",
"(",
"self",
",",
"file_path",
",",
"locale",
"=",
"None",
",",
"flags",
"=",
"None",
")",
":",
"await",
"self",
".",
"start",
"(",
"file_path",
",",
"locale",
",",
"{",
"'flags'",
":",
"flags",
"}",
")"
] | Start the loading/watching process | [
"Start",
"the",
"loading",
"/",
"watching",
"process"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/loaders.py#L180-L185 | train | Load the data from a file. |
BernardFW/bernard | src/bernard/i18n/loaders.py | CsvIntentsLoader._load | async def _load(self):
"""
Load data from a Excel-formatted CSV file.
"""
key = self._kwargs['key']
pos = self._kwargs['pos']
neg = self._kwargs['neg']
with open(self._file_path, newline='', encoding='utf-8') as f:
reader = csv.reader(f)
... | python | async def _load(self):
"""
Load data from a Excel-formatted CSV file.
"""
key = self._kwargs['key']
pos = self._kwargs['pos']
neg = self._kwargs['neg']
with open(self._file_path, newline='', encoding='utf-8') as f:
reader = csv.reader(f)
... | [
"async",
"def",
"_load",
"(",
"self",
")",
":",
"key",
"=",
"self",
".",
"_kwargs",
"[",
"'key'",
"]",
"pos",
"=",
"self",
".",
"_kwargs",
"[",
"'pos'",
"]",
"neg",
"=",
"self",
".",
"_kwargs",
"[",
"'neg'",
"]",
"with",
"open",
"(",
"self",
".",... | Load data from a Excel-formatted CSV file. | [
"Load",
"data",
"from",
"a",
"Excel",
"-",
"formatted",
"CSV",
"file",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/loaders.py#L264-L285 | train | Load data from an Excel - formatted CSV file. |
BernardFW/bernard | src/bernard/i18n/loaders.py | CsvIntentsLoader.load | async def load(self,
file_path,
locale=None,
key: int = 0,
pos: int = 1,
neg: Optional[ColRanges] = None):
"""
Start the loading/watching process
"""
if neg is None:
neg: ColRanges... | python | async def load(self,
file_path,
locale=None,
key: int = 0,
pos: int = 1,
neg: Optional[ColRanges] = None):
"""
Start the loading/watching process
"""
if neg is None:
neg: ColRanges... | [
"async",
"def",
"load",
"(",
"self",
",",
"file_path",
",",
"locale",
"=",
"None",
",",
"key",
":",
"int",
"=",
"0",
",",
"pos",
":",
"int",
"=",
"1",
",",
"neg",
":",
"Optional",
"[",
"ColRanges",
"]",
"=",
"None",
")",
":",
"if",
"neg",
"is",... | Start the loading/watching process | [
"Start",
"the",
"loading",
"/",
"watching",
"process"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/loaders.py#L287-L304 | train | Load the content of a specific entry in the cache. |
cloudmesh-cmd3/cmd3 | cmd3/plugins/info.py | info.print_info | def print_info(self):
"""prints some info that the user may find useful"""
d = dir(self)
self.plugins = []
for key in d:
if key.startswith("info_"):
self.plugins.append(key)
for key in self.plugins:
if self.echo:
C... | python | def print_info(self):
"""prints some info that the user may find useful"""
d = dir(self)
self.plugins = []
for key in d:
if key.startswith("info_"):
self.plugins.append(key)
for key in self.plugins:
if self.echo:
C... | [
"def",
"print_info",
"(",
"self",
")",
":",
"d",
"=",
"dir",
"(",
"self",
")",
"self",
".",
"plugins",
"=",
"[",
"]",
"for",
"key",
"in",
"d",
":",
"if",
"key",
".",
"startswith",
"(",
"\"info_\"",
")",
":",
"self",
".",
"plugins",
".",
"append",... | prints some info that the user may find useful | [
"prints",
"some",
"info",
"that",
"the",
"user",
"may",
"find",
"useful"
] | 92e33c96032fd3921f159198a0e57917c4dc34ed | https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/info.py#L7-L19 | train | prints some info that the user may find useful |
cloudmesh-cmd3/cmd3 | cmd3/plugins/info.py | info.do_info | def do_info(self, arg, arguments):
"""
::
Usage:
info [--all]
Options:
--all -a more extensive information
Prints some internal information about the shell
"""
if arguments["--all"]:
Console.ok(... | python | def do_info(self, arg, arguments):
"""
::
Usage:
info [--all]
Options:
--all -a more extensive information
Prints some internal information about the shell
"""
if arguments["--all"]:
Console.ok(... | [
"def",
"do_info",
"(",
"self",
",",
"arg",
",",
"arguments",
")",
":",
"if",
"arguments",
"[",
"\"--all\"",
"]",
":",
"Console",
".",
"ok",
"(",
"70",
"*",
"\"-\"",
")",
"Console",
".",
"ok",
"(",
"'DIR'",
")",
"Console",
".",
"ok",
"(",
"70",
"*... | ::
Usage:
info [--all]
Options:
--all -a more extensive information
Prints some internal information about the shell | [
"::"
] | 92e33c96032fd3921f159198a0e57917c4dc34ed | https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/info.py#L22-L42 | train | Print some internal information about the current object |
openvax/varlens | varlens/variants_util.py | load_from_args_as_dataframe | def load_from_args_as_dataframe(args):
'''
Given parsed variant-loading arguments, return a pandas DataFrame.
If no variant loading arguments are specified, return None.
'''
if not args.variants and not args.single_variant:
return None
if args.variant_source_name:
variant_sourc... | python | def load_from_args_as_dataframe(args):
'''
Given parsed variant-loading arguments, return a pandas DataFrame.
If no variant loading arguments are specified, return None.
'''
if not args.variants and not args.single_variant:
return None
if args.variant_source_name:
variant_sourc... | [
"def",
"load_from_args_as_dataframe",
"(",
"args",
")",
":",
"if",
"not",
"args",
".",
"variants",
"and",
"not",
"args",
".",
"single_variant",
":",
"return",
"None",
"if",
"args",
".",
"variant_source_name",
":",
"variant_source_names",
"=",
"util",
".",
"exp... | Given parsed variant-loading arguments, return a pandas DataFrame.
If no variant loading arguments are specified, return None. | [
"Given",
"parsed",
"variant",
"-",
"loading",
"arguments",
"return",
"a",
"pandas",
"DataFrame",
"."
] | 715d3ede5893757b2fcba4117515621bca7b1e5d | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/variants_util.py#L72-L159 | train | Given parsed variant - loading arguments return a pandas DataFrame. |
rsgalloway/grit | grit/repo/proxy.py | Proxy.request | def request(self, cmd, *args, **kwargs):
"""
Request data fromo the server.
:param cmd: repo handler command.
:returns: Result.
"""
params = {'action': cmd}
#TODO: serialize the kwargs?
params.update(kwargs)
return self.__request(self.url, params... | python | def request(self, cmd, *args, **kwargs):
"""
Request data fromo the server.
:param cmd: repo handler command.
:returns: Result.
"""
params = {'action': cmd}
#TODO: serialize the kwargs?
params.update(kwargs)
return self.__request(self.url, params... | [
"def",
"request",
"(",
"self",
",",
"cmd",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"'action'",
":",
"cmd",
"}",
"#TODO: serialize the kwargs?",
"params",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
".",
"__requ... | Request data fromo the server.
:param cmd: repo handler command.
:returns: Result. | [
"Request",
"data",
"fromo",
"the",
"server",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/proxy.py#L77-L88 | train | Request data from the server. |
rsgalloway/grit | grit/repo/proxy.py | Proxy.__request | def __request(self, url, params):
"""
Make an HTTP POST request to the server and return JSON data.
:param url: HTTP URL to object.
:returns: Response as dict.
"""
log.debug('request: %s %s' %(url, str(params)))
try:
response = urlopen(url, urlenco... | python | def __request(self, url, params):
"""
Make an HTTP POST request to the server and return JSON data.
:param url: HTTP URL to object.
:returns: Response as dict.
"""
log.debug('request: %s %s' %(url, str(params)))
try:
response = urlopen(url, urlenco... | [
"def",
"__request",
"(",
"self",
",",
"url",
",",
"params",
")",
":",
"log",
".",
"debug",
"(",
"'request: %s %s'",
"%",
"(",
"url",
",",
"str",
"(",
"params",
")",
")",
")",
"try",
":",
"response",
"=",
"urlopen",
"(",
"url",
",",
"urlencode",
"("... | Make an HTTP POST request to the server and return JSON data.
:param url: HTTP URL to object.
:returns: Response as dict. | [
"Make",
"an",
"HTTP",
"POST",
"request",
"to",
"the",
"server",
"and",
"return",
"JSON",
"data",
"."
] | e6434ad8a1f4ac5d0903ebad630c81f8a5164d78 | https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/proxy.py#L90-L112 | train | Make an HTTP POST request to the server and return JSON data. |
openvax/varlens | varlens/locus.py | Locus.position | def position(self):
'''
If this locus spans a single base, this property gives that position.
Otherwise, raises a ValueError.
'''
if self.end != self.start + 1:
raise ValueError("Not a single base: %s" % str(self))
return self.start | python | def position(self):
'''
If this locus spans a single base, this property gives that position.
Otherwise, raises a ValueError.
'''
if self.end != self.start + 1:
raise ValueError("Not a single base: %s" % str(self))
return self.start | [
"def",
"position",
"(",
"self",
")",
":",
"if",
"self",
".",
"end",
"!=",
"self",
".",
"start",
"+",
"1",
":",
"raise",
"ValueError",
"(",
"\"Not a single base: %s\"",
"%",
"str",
"(",
"self",
")",
")",
"return",
"self",
".",
"start"
] | If this locus spans a single base, this property gives that position.
Otherwise, raises a ValueError. | [
"If",
"this",
"locus",
"spans",
"a",
"single",
"base",
"this",
"property",
"gives",
"that",
"position",
".",
"Otherwise",
"raises",
"a",
"ValueError",
"."
] | 715d3ede5893757b2fcba4117515621bca7b1e5d | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/locus.py#L45-L52 | train | Returns the position of the locus in the locus property. |
openvax/varlens | varlens/locus.py | Locus.from_interbase_coordinates | def from_interbase_coordinates(contig, start, end=None):
'''
Given coordinates in 0-based interbase coordinates, return a Locus
instance.
'''
typechecks.require_string(contig)
typechecks.require_integer(start)
if end is None:
end = start + 1
ty... | python | def from_interbase_coordinates(contig, start, end=None):
'''
Given coordinates in 0-based interbase coordinates, return a Locus
instance.
'''
typechecks.require_string(contig)
typechecks.require_integer(start)
if end is None:
end = start + 1
ty... | [
"def",
"from_interbase_coordinates",
"(",
"contig",
",",
"start",
",",
"end",
"=",
"None",
")",
":",
"typechecks",
".",
"require_string",
"(",
"contig",
")",
"typechecks",
".",
"require_integer",
"(",
"start",
")",
"if",
"end",
"is",
"None",
":",
"end",
"=... | Given coordinates in 0-based interbase coordinates, return a Locus
instance. | [
"Given",
"coordinates",
"in",
"0",
"-",
"based",
"interbase",
"coordinates",
"return",
"a",
"Locus",
"instance",
"."
] | 715d3ede5893757b2fcba4117515621bca7b1e5d | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/locus.py#L71-L82 | train | Given coordinates in 0 - based interbase coordinates return a Locus instance. |
openvax/varlens | varlens/sequence_context.py | variant_context | def variant_context(
reference_fasta,
contig,
inclusive_start,
inclusive_end,
alt,
context_length):
"""
Retrieve the surronding reference region from a variant.
SNVs are canonicalized so the reference base is a pyrmidine (C/T). For
indels the reverse co... | python | def variant_context(
reference_fasta,
contig,
inclusive_start,
inclusive_end,
alt,
context_length):
"""
Retrieve the surronding reference region from a variant.
SNVs are canonicalized so the reference base is a pyrmidine (C/T). For
indels the reverse co... | [
"def",
"variant_context",
"(",
"reference_fasta",
",",
"contig",
",",
"inclusive_start",
",",
"inclusive_end",
",",
"alt",
",",
"context_length",
")",
":",
"# Move from 1-base coorindates to 0-base coordinates",
"start",
"=",
"int",
"(",
"inclusive_start",
")",
"-",
"... | Retrieve the surronding reference region from a variant.
SNVs are canonicalized so the reference base is a pyrmidine (C/T). For
indels the reverse complement will still be taken if the first base of
the reference is not a pyrmidine, but since the reference will also be
reversed, that doesn't guarantee ... | [
"Retrieve",
"the",
"surronding",
"reference",
"region",
"from",
"a",
"variant",
"."
] | 715d3ede5893757b2fcba4117515621bca7b1e5d | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/sequence_context.py#L17-L85 | train | Retrieve the surronding reference region from a variant. |
BernardFW/bernard | src/bernard/trigram.py | normalize | def normalize(string: Text) -> Text:
"""
Normalizes a string to encompass various things humans tend to get wrong:
- Put everything lowercase
- Drop accents
- Transform all whitespaces sequences into a single space
- Remove spaces before and after punctuation
"""
string = string.lower(... | python | def normalize(string: Text) -> Text:
"""
Normalizes a string to encompass various things humans tend to get wrong:
- Put everything lowercase
- Drop accents
- Transform all whitespaces sequences into a single space
- Remove spaces before and after punctuation
"""
string = string.lower(... | [
"def",
"normalize",
"(",
"string",
":",
"Text",
")",
"->",
"Text",
":",
"string",
"=",
"string",
".",
"lower",
"(",
")",
"string",
"=",
"unidecode",
"(",
"string",
")",
"string",
"=",
"RE_WHITESPACES",
".",
"sub",
"(",
"' '",
",",
"string",
")",
".",... | Normalizes a string to encompass various things humans tend to get wrong:
- Put everything lowercase
- Drop accents
- Transform all whitespaces sequences into a single space
- Remove spaces before and after punctuation | [
"Normalizes",
"a",
"string",
"to",
"encompass",
"various",
"things",
"humans",
"tend",
"to",
"get",
"wrong",
":"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/trigram.py#L30-L44 | train | Normalizes a string to encompass various things humans tend to get wrong |
BernardFW/bernard | src/bernard/trigram.py | make_trigrams | def make_trigrams(i: Iterable[T]) \
-> Iterable[Tuple[Optional[T], Optional[T], Optional[T]]]:
"""
Compute all trigrams of an iterable and yield them. You probably want
to do something like:
>>> t = set(make_trigrams('hi there'))
"""
q = deque([None, None, None])
def nxt():
... | python | def make_trigrams(i: Iterable[T]) \
-> Iterable[Tuple[Optional[T], Optional[T], Optional[T]]]:
"""
Compute all trigrams of an iterable and yield them. You probably want
to do something like:
>>> t = set(make_trigrams('hi there'))
"""
q = deque([None, None, None])
def nxt():
... | [
"def",
"make_trigrams",
"(",
"i",
":",
"Iterable",
"[",
"T",
"]",
")",
"->",
"Iterable",
"[",
"Tuple",
"[",
"Optional",
"[",
"T",
"]",
",",
"Optional",
"[",
"T",
"]",
",",
"Optional",
"[",
"T",
"]",
"]",
"]",
":",
"q",
"=",
"deque",
"(",
"[",
... | Compute all trigrams of an iterable and yield them. You probably want
to do something like:
>>> t = set(make_trigrams('hi there')) | [
"Compute",
"all",
"trigrams",
"of",
"an",
"iterable",
"and",
"yield",
"them",
".",
"You",
"probably",
"want",
"to",
"do",
"something",
"like",
":"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/trigram.py#L51-L71 | train | Compute all trigrams of an iterable and yield them. |
BernardFW/bernard | src/bernard/trigram.py | Trigram.similarity | def similarity(self, other: 'Trigram') -> float:
"""
Compute the similarity with the provided other trigram.
"""
if not len(self._trigrams) or not len(other._trigrams):
return 0
count = float(len(self._trigrams & other._trigrams))
len1 = float(len(self._trigr... | python | def similarity(self, other: 'Trigram') -> float:
"""
Compute the similarity with the provided other trigram.
"""
if not len(self._trigrams) or not len(other._trigrams):
return 0
count = float(len(self._trigrams & other._trigrams))
len1 = float(len(self._trigr... | [
"def",
"similarity",
"(",
"self",
",",
"other",
":",
"'Trigram'",
")",
"->",
"float",
":",
"if",
"not",
"len",
"(",
"self",
".",
"_trigrams",
")",
"or",
"not",
"len",
"(",
"other",
".",
"_trigrams",
")",
":",
"return",
"0",
"count",
"=",
"float",
"... | Compute the similarity with the provided other trigram. | [
"Compute",
"the",
"similarity",
"with",
"the",
"provided",
"other",
"trigram",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/trigram.py#L89-L100 | train | Compute the similarity with the provided trigram. |
BernardFW/bernard | src/bernard/trigram.py | Matcher._match | def _match(self, local: Tuple[Trigram, ...], other: Trigram) -> float:
"""
Match a trigram with another one. If the negative matching wins,
returns an inverted matching.
"""
pos = local[0] % other
neg = max((x % other for x in local[1:]), default=0)
if neg > pos... | python | def _match(self, local: Tuple[Trigram, ...], other: Trigram) -> float:
"""
Match a trigram with another one. If the negative matching wins,
returns an inverted matching.
"""
pos = local[0] % other
neg = max((x % other for x in local[1:]), default=0)
if neg > pos... | [
"def",
"_match",
"(",
"self",
",",
"local",
":",
"Tuple",
"[",
"Trigram",
",",
"...",
"]",
",",
"other",
":",
"Trigram",
")",
"->",
"float",
":",
"pos",
"=",
"local",
"[",
"0",
"]",
"%",
"other",
"neg",
"=",
"max",
"(",
"(",
"x",
"%",
"other",
... | Match a trigram with another one. If the negative matching wins,
returns an inverted matching. | [
"Match",
"a",
"trigram",
"with",
"another",
"one",
".",
"If",
"the",
"negative",
"matching",
"wins",
"returns",
"an",
"inverted",
"matching",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/trigram.py#L120-L132 | train | Match a trigram with another trigram. |
BernardFW/bernard | src/bernard/trigram.py | Matcher.similarity | def similarity(self, other: Trigram) -> float:
"""
Find the best similarity within known trigrams.
"""
return max((self._match(x, other) for x in self.trigrams), default=0) | python | def similarity(self, other: Trigram) -> float:
"""
Find the best similarity within known trigrams.
"""
return max((self._match(x, other) for x in self.trigrams), default=0) | [
"def",
"similarity",
"(",
"self",
",",
"other",
":",
"Trigram",
")",
"->",
"float",
":",
"return",
"max",
"(",
"(",
"self",
".",
"_match",
"(",
"x",
",",
"other",
")",
"for",
"x",
"in",
"self",
".",
"trigrams",
")",
",",
"default",
"=",
"0",
")"
... | Find the best similarity within known trigrams. | [
"Find",
"the",
"best",
"similarity",
"within",
"known",
"trigrams",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/trigram.py#L134-L138 | train | Find the best similarity between this set and another set. |
BernardFW/bernard | src/bernard/trigram.py | LabelMatcher.similarity | def similarity(self, other: Trigram) -> Tuple[float, L]:
"""
Returns the best matching score and the associated label.
"""
return max(
((t % other, l) for t, l in self.trigrams),
key=lambda x: x[0],
) | python | def similarity(self, other: Trigram) -> Tuple[float, L]:
"""
Returns the best matching score and the associated label.
"""
return max(
((t % other, l) for t, l in self.trigrams),
key=lambda x: x[0],
) | [
"def",
"similarity",
"(",
"self",
",",
"other",
":",
"Trigram",
")",
"->",
"Tuple",
"[",
"float",
",",
"L",
"]",
":",
"return",
"max",
"(",
"(",
"(",
"t",
"%",
"other",
",",
"l",
")",
"for",
"t",
",",
"l",
"in",
"self",
".",
"trigrams",
")",
... | Returns the best matching score and the associated label. | [
"Returns",
"the",
"best",
"matching",
"score",
"and",
"the",
"associated",
"label",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/trigram.py#L159-L167 | train | Returns the best matching score and the associated label. |
transifex/transifex-python-library | txlib/http/base.py | BaseRequest._construct_full_hostname | def _construct_full_hostname(self, hostname):
"""Create a full (scheme included) hostname from the argument given.
Only HTTP and HTTP+SSL protocols are allowed.
Args:
hostname: The hostname to use.
Returns:
The full hostname.
Raises:
ValueErr... | python | def _construct_full_hostname(self, hostname):
"""Create a full (scheme included) hostname from the argument given.
Only HTTP and HTTP+SSL protocols are allowed.
Args:
hostname: The hostname to use.
Returns:
The full hostname.
Raises:
ValueErr... | [
"def",
"_construct_full_hostname",
"(",
"self",
",",
"hostname",
")",
":",
"if",
"hostname",
".",
"startswith",
"(",
"(",
"'http://'",
",",
"'https://'",
",",
")",
")",
":",
"return",
"hostname",
"if",
"'://'",
"in",
"hostname",
":",
"protocol",
",",
"host... | Create a full (scheme included) hostname from the argument given.
Only HTTP and HTTP+SSL protocols are allowed.
Args:
hostname: The hostname to use.
Returns:
The full hostname.
Raises:
ValueError: A not supported protocol is used. | [
"Create",
"a",
"full",
"(",
"scheme",
"included",
")",
"hostname",
"from",
"the",
"argument",
"given",
"."
] | 9fea86b718973de35ccca6d54bd1f445c9632406 | https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/http/base.py#L51-L68 | train | Create a full hostname from the argument given. |
transifex/transifex-python-library | txlib/http/base.py | BaseRequest._exception_for | def _exception_for(self, code):
"""Return the exception class suitable for the specified HTTP
status code.
Raises:
UnknownError: The HTTP status code is not one of the knowns.
"""
if code in self.errors:
return self.errors[code]
elif 500 <= code <... | python | def _exception_for(self, code):
"""Return the exception class suitable for the specified HTTP
status code.
Raises:
UnknownError: The HTTP status code is not one of the knowns.
"""
if code in self.errors:
return self.errors[code]
elif 500 <= code <... | [
"def",
"_exception_for",
"(",
"self",
",",
"code",
")",
":",
"if",
"code",
"in",
"self",
".",
"errors",
":",
"return",
"self",
".",
"errors",
"[",
"code",
"]",
"elif",
"500",
"<=",
"code",
"<",
"599",
":",
"return",
"exceptions",
".",
"RemoteServerErro... | Return the exception class suitable for the specified HTTP
status code.
Raises:
UnknownError: The HTTP status code is not one of the knowns. | [
"Return",
"the",
"exception",
"class",
"suitable",
"for",
"the",
"specified",
"HTTP",
"status",
"code",
"."
] | 9fea86b718973de35ccca6d54bd1f445c9632406 | https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/http/base.py#L86-L98 | train | Return the exception class suitable for the specified HTTP status code. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.