repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
openvax/varlens | varlens/read_evidence/pileup_collection.py | PileupCollection.filter | def filter(self,
drop_duplicates=False,
drop_improper_mate_pairs=False,
min_mapping_quality=None,
min_base_quality=None,
filters=None):
'''
Return a new PileupCollection that includes only pileup elements
satisfying the specified criter... | python | def filter(self,
drop_duplicates=False,
drop_improper_mate_pairs=False,
min_mapping_quality=None,
min_base_quality=None,
filters=None):
'''
Return a new PileupCollection that includes only pileup elements
satisfying the specified criter... | [
"def",
"filter",
"(",
"self",
",",
"drop_duplicates",
"=",
"False",
",",
"drop_improper_mate_pairs",
"=",
"False",
",",
"min_mapping_quality",
"=",
"None",
",",
"min_base_quality",
"=",
"None",
",",
"filters",
"=",
"None",
")",
":",
"if",
"filters",
"is",
"N... | Return a new PileupCollection that includes only pileup elements
satisfying the specified criteria.
Parameters
----------
drop_duplicates (optional, default False) : boolean
Remove alignments with the is_duplicate flag.
drop_improper_mate_pairs (optional, default Fa... | [
"Return",
"a",
"new",
"PileupCollection",
"that",
"includes",
"only",
"pileup",
"elements",
"satisfying",
"the",
"specified",
"criteria",
"."
] | 715d3ede5893757b2fcba4117515621bca7b1e5d | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/read_evidence/pileup_collection.py#L445-L501 | train |
openvax/varlens | varlens/read_evidence/pileup_collection.py | PileupCollection.merge | def merge(self, *others):
'''
Return a new PileupCollection that is the union of self and the other
specified collections.
'''
new_pileups = {}
for collection in (self,) + others:
for (locus, pileup) in collection.pileups.items():
if locus in n... | python | def merge(self, *others):
'''
Return a new PileupCollection that is the union of self and the other
specified collections.
'''
new_pileups = {}
for collection in (self,) + others:
for (locus, pileup) in collection.pileups.items():
if locus in n... | [
"def",
"merge",
"(",
"self",
",",
"*",
"others",
")",
":",
"new_pileups",
"=",
"{",
"}",
"for",
"collection",
"in",
"(",
"self",
",",
")",
"+",
"others",
":",
"for",
"(",
"locus",
",",
"pileup",
")",
"in",
"collection",
".",
"pileups",
".",
"items"... | Return a new PileupCollection that is the union of self and the other
specified collections. | [
"Return",
"a",
"new",
"PileupCollection",
"that",
"is",
"the",
"union",
"of",
"self",
"and",
"the",
"other",
"specified",
"collections",
"."
] | 715d3ede5893757b2fcba4117515621bca7b1e5d | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/read_evidence/pileup_collection.py#L503-L515 | train |
openvax/varlens | varlens/read_evidence/pileup_collection.py | PileupCollection.from_bam | def from_bam(pysam_samfile, loci, normalized_contig_names=True):
'''
Create a PileupCollection for a set of loci from a BAM file.
Parameters
----------
pysam_samfile : `pysam.Samfile` instance, or filename string
to a BAM file. The BAM file must be indexed.
... | python | def from_bam(pysam_samfile, loci, normalized_contig_names=True):
'''
Create a PileupCollection for a set of loci from a BAM file.
Parameters
----------
pysam_samfile : `pysam.Samfile` instance, or filename string
to a BAM file. The BAM file must be indexed.
... | [
"def",
"from_bam",
"(",
"pysam_samfile",
",",
"loci",
",",
"normalized_contig_names",
"=",
"True",
")",
":",
"loci",
"=",
"[",
"to_locus",
"(",
"obj",
")",
"for",
"obj",
"in",
"loci",
"]",
"close_on_completion",
"=",
"False",
"if",
"typechecks",
".",
"is_s... | Create a PileupCollection for a set of loci from a BAM file.
Parameters
----------
pysam_samfile : `pysam.Samfile` instance, or filename string
to a BAM file. The BAM file must be indexed.
loci : list of Locus instances
Loci to collect pileups for.
norm... | [
"Create",
"a",
"PileupCollection",
"for",
"a",
"set",
"of",
"loci",
"from",
"a",
"BAM",
"file",
"."
] | 715d3ede5893757b2fcba4117515621bca7b1e5d | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/read_evidence/pileup_collection.py#L518-L603 | train |
inveniosoftware/invenio-query-parser | invenio_query_parser/contrib/elasticsearch/__init__.py | invenio_query_factory | def invenio_query_factory(parser=None, walkers=None):
"""Create a parser returning Elastic Search DSL query instance."""
parser = parser or Main
walkers = walkers or [PypegConverter()]
walkers.append(ElasticSearchDSL())
def invenio_query(pattern):
query = pypeg2.parse(pattern, parser, white... | python | def invenio_query_factory(parser=None, walkers=None):
"""Create a parser returning Elastic Search DSL query instance."""
parser = parser or Main
walkers = walkers or [PypegConverter()]
walkers.append(ElasticSearchDSL())
def invenio_query(pattern):
query = pypeg2.parse(pattern, parser, white... | [
"def",
"invenio_query_factory",
"(",
"parser",
"=",
"None",
",",
"walkers",
"=",
"None",
")",
":",
"parser",
"=",
"parser",
"or",
"Main",
"walkers",
"=",
"walkers",
"or",
"[",
"PypegConverter",
"(",
")",
"]",
"walkers",
".",
"append",
"(",
"ElasticSearchDS... | Create a parser returning Elastic Search DSL query instance. | [
"Create",
"a",
"parser",
"returning",
"Elastic",
"Search",
"DSL",
"query",
"instance",
"."
] | 21a2c36318003ff52d2e18e7196bb420db8ecb4b | https://github.com/inveniosoftware/invenio-query-parser/blob/21a2c36318003ff52d2e18e7196bb420db8ecb4b/invenio_query_parser/contrib/elasticsearch/__init__.py#L34-L45 | train |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_timeseries_profile.py | NCEITimeSeriesProfileOrthogonalBase.check_dimensions | def check_dimensions(self, dataset):
'''
Checks that the feature types of this dataset are consistent with a timeseries-profile-orthogonal dataset.
:param netCDF4.Dataset dataset: An open netCDF dataset
'''
results = []
required_ctx = TestCtx(BaseCheck.HIGH, 'All geophys... | python | def check_dimensions(self, dataset):
'''
Checks that the feature types of this dataset are consistent with a timeseries-profile-orthogonal dataset.
:param netCDF4.Dataset dataset: An open netCDF dataset
'''
results = []
required_ctx = TestCtx(BaseCheck.HIGH, 'All geophys... | [
"def",
"check_dimensions",
"(",
"self",
",",
"dataset",
")",
":",
"results",
"=",
"[",
"]",
"required_ctx",
"=",
"TestCtx",
"(",
"BaseCheck",
".",
"HIGH",
",",
"'All geophysical variables are timeseries-profile-orthogonal feature types'",
")",
"message",
"=",
"'{} mus... | Checks that the feature types of this dataset are consistent with a timeseries-profile-orthogonal dataset.
:param netCDF4.Dataset dataset: An open netCDF dataset | [
"Checks",
"that",
"the",
"feature",
"types",
"of",
"this",
"dataset",
"are",
"consistent",
"with",
"a",
"timeseries",
"-",
"profile",
"-",
"orthogonal",
"dataset",
"."
] | 963fefd7fa43afd32657ac4c36aad4ddb4c25acf | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_timeseries_profile.py#L21-L43 | train |
cloudmesh-cmd3/cmd3 | fabfile/doc.py | theme | def theme(name='readthedocs'):
"""set name to 'bootstrap' in case you want to use bootstrap.
This also requires the template sto be in the main dir"""
os.environ['SPHINX_THEME'] = name
if os.environ['SPHINX_THEME'] == 'bootstrap':
local('cp docs/source/_templates/layout_bootstrap.html docs/... | python | def theme(name='readthedocs'):
"""set name to 'bootstrap' in case you want to use bootstrap.
This also requires the template sto be in the main dir"""
os.environ['SPHINX_THEME'] = name
if os.environ['SPHINX_THEME'] == 'bootstrap':
local('cp docs/source/_templates/layout_bootstrap.html docs/... | [
"def",
"theme",
"(",
"name",
"=",
"'readthedocs'",
")",
":",
"os",
".",
"environ",
"[",
"'SPHINX_THEME'",
"]",
"=",
"name",
"if",
"os",
".",
"environ",
"[",
"'SPHINX_THEME'",
"]",
"==",
"'bootstrap'",
":",
"local",
"(",
"'cp docs/source/_templates/layout_boots... | set name to 'bootstrap' in case you want to use bootstrap.
This also requires the template sto be in the main dir | [
"set",
"name",
"to",
"bootstrap",
"in",
"case",
"you",
"want",
"to",
"use",
"bootstrap",
".",
"This",
"also",
"requires",
"the",
"template",
"sto",
"be",
"in",
"the",
"main",
"dir"
] | 92e33c96032fd3921f159198a0e57917c4dc34ed | https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/fabfile/doc.py#L57-L67 | train |
cloudmesh-cmd3/cmd3 | fabfile/doc.py | html | def html(theme_name='readthedocs'):
# disable Flask RSTPAGES due to sphinx incompatibility
os.environ['RSTPAGES'] = 'FALSE'
theme(theme_name)
api()
man()
"""build the doc locally and view"""
clean()
local("cd docs; make html")
local("fab security.check")
local("touch docs/build/h... | python | def html(theme_name='readthedocs'):
# disable Flask RSTPAGES due to sphinx incompatibility
os.environ['RSTPAGES'] = 'FALSE'
theme(theme_name)
api()
man()
"""build the doc locally and view"""
clean()
local("cd docs; make html")
local("fab security.check")
local("touch docs/build/h... | [
"def",
"html",
"(",
"theme_name",
"=",
"'readthedocs'",
")",
":",
"os",
".",
"environ",
"[",
"'RSTPAGES'",
"]",
"=",
"'FALSE'",
"theme",
"(",
"theme_name",
")",
"api",
"(",
")",
"man",
"(",
")",
"clean",
"(",
")",
"local",
"(",
"\"cd docs; make html\"",
... | build the doc locally and view | [
"build",
"the",
"doc",
"locally",
"and",
"view"
] | 92e33c96032fd3921f159198a0e57917c4dc34ed | https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/fabfile/doc.py#L70-L80 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | sign_message | def sign_message(body: ByteString, secret: Text) -> Text:
"""
Compute a message's signature.
"""
return 'sha1={}'.format(
hmac.new(secret.encode(), body, sha1).hexdigest()
) | python | def sign_message(body: ByteString, secret: Text) -> Text:
"""
Compute a message's signature.
"""
return 'sha1={}'.format(
hmac.new(secret.encode(), body, sha1).hexdigest()
) | [
"def",
"sign_message",
"(",
"body",
":",
"ByteString",
",",
"secret",
":",
"Text",
")",
"->",
"Text",
":",
"return",
"'sha1={}'",
".",
"format",
"(",
"hmac",
".",
"new",
"(",
"secret",
".",
"encode",
"(",
")",
",",
"body",
",",
"sha1",
")",
".",
"h... | Compute a message's signature. | [
"Compute",
"a",
"message",
"s",
"signature",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L112-L119 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | FacebookUser._get_user | async def _get_user(self):
"""
Get the user dict from cache or query it from the platform if missing.
"""
if self._cache is None:
try:
self._cache = \
await self.facebook.get_user(self.fbid, self.page_id)
except PlatformOperati... | python | async def _get_user(self):
"""
Get the user dict from cache or query it from the platform if missing.
"""
if self._cache is None:
try:
self._cache = \
await self.facebook.get_user(self.fbid, self.page_id)
except PlatformOperati... | [
"async",
"def",
"_get_user",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cache",
"is",
"None",
":",
"try",
":",
"self",
".",
"_cache",
"=",
"await",
"self",
".",
"facebook",
".",
"get_user",
"(",
"self",
".",
"fbid",
",",
"self",
".",
"page_id",
")... | Get the user dict from cache or query it from the platform if missing. | [
"Get",
"the",
"user",
"dict",
"from",
"cache",
"or",
"query",
"it",
"from",
"the",
"platform",
"if",
"missing",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L146-L157 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | FacebookUser.get_friendly_name | async def get_friendly_name(self) -> Text:
"""
The friendly name is mapped to Facebook's first name. If the first
name is missing, use the last name.
"""
u = await self._get_user()
f = u.get('first_name', '').strip()
l = u.get('last_name', '').strip()
ret... | python | async def get_friendly_name(self) -> Text:
"""
The friendly name is mapped to Facebook's first name. If the first
name is missing, use the last name.
"""
u = await self._get_user()
f = u.get('first_name', '').strip()
l = u.get('last_name', '').strip()
ret... | [
"async",
"def",
"get_friendly_name",
"(",
"self",
")",
"->",
"Text",
":",
"u",
"=",
"await",
"self",
".",
"_get_user",
"(",
")",
"f",
"=",
"u",
".",
"get",
"(",
"'first_name'",
",",
"''",
")",
".",
"strip",
"(",
")",
"l",
"=",
"u",
".",
"get",
... | The friendly name is mapped to Facebook's first name. If the first
name is missing, use the last name. | [
"The",
"friendly",
"name",
"is",
"mapped",
"to",
"Facebook",
"s",
"first",
"name",
".",
"If",
"the",
"first",
"name",
"is",
"missing",
"use",
"the",
"last",
"name",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L171-L180 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | FacebookUser.get_gender | async def get_gender(self) -> User.Gender:
"""
Get the gender from Facebook.
"""
u = await self._get_user()
try:
return User.Gender(u.get('gender'))
except ValueError:
return User.Gender.unknown | python | async def get_gender(self) -> User.Gender:
"""
Get the gender from Facebook.
"""
u = await self._get_user()
try:
return User.Gender(u.get('gender'))
except ValueError:
return User.Gender.unknown | [
"async",
"def",
"get_gender",
"(",
"self",
")",
"->",
"User",
".",
"Gender",
":",
"u",
"=",
"await",
"self",
".",
"_get_user",
"(",
")",
"try",
":",
"return",
"User",
".",
"Gender",
"(",
"u",
".",
"get",
"(",
"'gender'",
")",
")",
"except",
"ValueE... | Get the gender from Facebook. | [
"Get",
"the",
"gender",
"from",
"Facebook",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L182-L191 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | FacebookMessage.get_user | def get_user(self) -> FacebookUser:
"""
Generate a Facebook user instance
"""
return FacebookUser(
self._event['sender']['id'],
self.get_page_id(),
self._facebook,
self,
) | python | def get_user(self) -> FacebookUser:
"""
Generate a Facebook user instance
"""
return FacebookUser(
self._event['sender']['id'],
self.get_page_id(),
self._facebook,
self,
) | [
"def",
"get_user",
"(",
"self",
")",
"->",
"FacebookUser",
":",
"return",
"FacebookUser",
"(",
"self",
".",
"_event",
"[",
"'sender'",
"]",
"[",
"'id'",
"]",
",",
"self",
".",
"get_page_id",
"(",
")",
",",
"self",
".",
"_facebook",
",",
"self",
",",
... | Generate a Facebook user instance | [
"Generate",
"a",
"Facebook",
"user",
"instance"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L244-L253 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | FacebookMessage.get_layers | def get_layers(self) -> List[BaseLayer]:
"""
Return all layers that can be found in the message.
"""
out = []
msg = self._event.get('message', {})
if 'text' in msg:
out.append(lyr.RawText(msg['text']))
for attachment in msg.get('attachments') or []:
... | python | def get_layers(self) -> List[BaseLayer]:
"""
Return all layers that can be found in the message.
"""
out = []
msg = self._event.get('message', {})
if 'text' in msg:
out.append(lyr.RawText(msg['text']))
for attachment in msg.get('attachments') or []:
... | [
"def",
"get_layers",
"(",
"self",
")",
"->",
"List",
"[",
"BaseLayer",
"]",
":",
"out",
"=",
"[",
"]",
"msg",
"=",
"self",
".",
"_event",
".",
"get",
"(",
"'message'",
",",
"{",
"}",
")",
"if",
"'text'",
"in",
"msg",
":",
"out",
".",
"append",
... | Return all layers that can be found in the message. | [
"Return",
"all",
"layers",
"that",
"can",
"be",
"found",
"in",
"the",
"message",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L261-L297 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook.verify_token | def verify_token(self):
"""
Automatically generated secure verify token
"""
h = sha256()
h.update(self.app_access_token.encode())
return h.hexdigest() | python | def verify_token(self):
"""
Automatically generated secure verify token
"""
h = sha256()
h.update(self.app_access_token.encode())
return h.hexdigest() | [
"def",
"verify_token",
"(",
"self",
")",
":",
"h",
"=",
"sha256",
"(",
")",
"h",
".",
"update",
"(",
"self",
".",
"app_access_token",
".",
"encode",
"(",
")",
")",
"return",
"h",
".",
"hexdigest",
"(",
")"
] | Automatically generated secure verify token | [
"Automatically",
"generated",
"secure",
"verify",
"token"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L385-L392 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook.hook_up | def hook_up(self, router: UrlDispatcher):
"""
Dynamically hooks the right webhook paths
"""
router.add_get(self.webhook_path, self.check_hook)
router.add_post(self.webhook_path, self.receive_events) | python | def hook_up(self, router: UrlDispatcher):
"""
Dynamically hooks the right webhook paths
"""
router.add_get(self.webhook_path, self.check_hook)
router.add_post(self.webhook_path, self.receive_events) | [
"def",
"hook_up",
"(",
"self",
",",
"router",
":",
"UrlDispatcher",
")",
":",
"router",
".",
"add_get",
"(",
"self",
".",
"webhook_path",
",",
"self",
".",
"check_hook",
")",
"router",
".",
"add_post",
"(",
"self",
".",
"webhook_path",
",",
"self",
".",
... | Dynamically hooks the right webhook paths | [
"Dynamically",
"hooks",
"the",
"right",
"webhook",
"paths"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L410-L416 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook.check_hook | async def check_hook(self, request: HttpRequest):
"""
Called when Facebook checks the hook
"""
verify_token = request.query.get('hub.verify_token')
if not verify_token:
return json_response({
'error': 'No verification token was provided',
... | python | async def check_hook(self, request: HttpRequest):
"""
Called when Facebook checks the hook
"""
verify_token = request.query.get('hub.verify_token')
if not verify_token:
return json_response({
'error': 'No verification token was provided',
... | [
"async",
"def",
"check_hook",
"(",
"self",
",",
"request",
":",
"HttpRequest",
")",
":",
"verify_token",
"=",
"request",
".",
"query",
".",
"get",
"(",
"'hub.verify_token'",
")",
"if",
"not",
"verify_token",
":",
"return",
"json_response",
"(",
"{",
"'error'... | Called when Facebook checks the hook | [
"Called",
"when",
"Facebook",
"checks",
"the",
"hook"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L418-L435 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook.receive_events | async def receive_events(self, request: HttpRequest):
"""
Events received from Facebook
"""
body = await request.read()
s = self.settings()
try:
content = ujson.loads(body)
except ValueError:
return json_response({
'error'... | python | async def receive_events(self, request: HttpRequest):
"""
Events received from Facebook
"""
body = await request.read()
s = self.settings()
try:
content = ujson.loads(body)
except ValueError:
return json_response({
'error'... | [
"async",
"def",
"receive_events",
"(",
"self",
",",
"request",
":",
"HttpRequest",
")",
":",
"body",
"=",
"await",
"request",
".",
"read",
"(",
")",
"s",
"=",
"self",
".",
"settings",
"(",
")",
"try",
":",
"content",
"=",
"ujson",
".",
"loads",
"(",
... | Events received from Facebook | [
"Events",
"received",
"from",
"Facebook"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L437-L470 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._deferred_init | async def _deferred_init(self):
"""
Run those things in a sepearate tasks as they are not required for the
bot to work and they take a lot of time to run.
"""
await self._check_subscriptions()
await self._set_whitelist()
await self._set_get_started()
awai... | python | async def _deferred_init(self):
"""
Run those things in a sepearate tasks as they are not required for the
bot to work and they take a lot of time to run.
"""
await self._check_subscriptions()
await self._set_whitelist()
await self._set_get_started()
awai... | [
"async",
"def",
"_deferred_init",
"(",
"self",
")",
":",
"await",
"self",
".",
"_check_subscriptions",
"(",
")",
"await",
"self",
".",
"_set_whitelist",
"(",
")",
"await",
"self",
".",
"_set_get_started",
"(",
")",
"await",
"self",
".",
"_set_greeting_text",
... | Run those things in a sepearate tasks as they are not required for the
bot to work and they take a lot of time to run. | [
"Run",
"those",
"things",
"in",
"a",
"sepearate",
"tasks",
"as",
"they",
"are",
"not",
"required",
"for",
"the",
"bot",
"to",
"work",
"and",
"they",
"take",
"a",
"lot",
"of",
"time",
"to",
"run",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L472-L482 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._send_to_messenger_profile | async def _send_to_messenger_profile(self, page, content):
"""
The messenger profile API handles all meta-information about the bot,
like the menu. This allows to submit data to this API endpoint.
:param page: page dict from the configuration
:param content: content to be sent t... | python | async def _send_to_messenger_profile(self, page, content):
"""
The messenger profile API handles all meta-information about the bot,
like the menu. This allows to submit data to this API endpoint.
:param page: page dict from the configuration
:param content: content to be sent t... | [
"async",
"def",
"_send_to_messenger_profile",
"(",
"self",
",",
"page",
",",
"content",
")",
":",
"log_name",
"=",
"', '",
".",
"join",
"(",
"repr",
"(",
"x",
")",
"for",
"x",
"in",
"content",
".",
"keys",
"(",
")",
")",
"page_id",
"=",
"page",
"[",
... | The messenger profile API handles all meta-information about the bot,
like the menu. This allows to submit data to this API endpoint.
:param page: page dict from the configuration
:param content: content to be sent to Facebook (as dict) | [
"The",
"messenger",
"profile",
"API",
"handles",
"all",
"meta",
"-",
"information",
"about",
"the",
"bot",
"like",
"the",
"menu",
".",
"This",
"allows",
"to",
"submit",
"data",
"to",
"this",
"API",
"endpoint",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L507-L548 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._set_get_started | async def _set_get_started(self):
"""
Set the "get started" action for all configured pages.
"""
page = self.settings()
if 'get_started' in page:
payload = page['get_started']
else:
payload = {'action': 'get_started'}
await self._send_to... | python | async def _set_get_started(self):
"""
Set the "get started" action for all configured pages.
"""
page = self.settings()
if 'get_started' in page:
payload = page['get_started']
else:
payload = {'action': 'get_started'}
await self._send_to... | [
"async",
"def",
"_set_get_started",
"(",
"self",
")",
":",
"page",
"=",
"self",
".",
"settings",
"(",
")",
"if",
"'get_started'",
"in",
"page",
":",
"payload",
"=",
"page",
"[",
"'get_started'",
"]",
"else",
":",
"payload",
"=",
"{",
"'action'",
":",
"... | Set the "get started" action for all configured pages. | [
"Set",
"the",
"get",
"started",
"action",
"for",
"all",
"configured",
"pages",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L550-L568 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._set_greeting_text | async def _set_greeting_text(self):
"""
Set the greeting text of the page
"""
page = self.settings()
if 'greeting' in page:
await self._send_to_messenger_profile(page, {
'greeting': page['greeting'],
})
logger.info('Greeting ... | python | async def _set_greeting_text(self):
"""
Set the greeting text of the page
"""
page = self.settings()
if 'greeting' in page:
await self._send_to_messenger_profile(page, {
'greeting': page['greeting'],
})
logger.info('Greeting ... | [
"async",
"def",
"_set_greeting_text",
"(",
"self",
")",
":",
"page",
"=",
"self",
".",
"settings",
"(",
")",
"if",
"'greeting'",
"in",
"page",
":",
"await",
"self",
".",
"_send_to_messenger_profile",
"(",
"page",
",",
"{",
"'greeting'",
":",
"page",
"[",
... | Set the greeting text of the page | [
"Set",
"the",
"greeting",
"text",
"of",
"the",
"page"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L570-L582 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._set_persistent_menu | async def _set_persistent_menu(self):
"""
Define the persistent menu for all pages
"""
page = self.settings()
if 'menu' in page:
await self._send_to_messenger_profile(page, {
'persistent_menu': page['menu'],
})
logger.info('S... | python | async def _set_persistent_menu(self):
"""
Define the persistent menu for all pages
"""
page = self.settings()
if 'menu' in page:
await self._send_to_messenger_profile(page, {
'persistent_menu': page['menu'],
})
logger.info('S... | [
"async",
"def",
"_set_persistent_menu",
"(",
"self",
")",
":",
"page",
"=",
"self",
".",
"settings",
"(",
")",
"if",
"'menu'",
"in",
"page",
":",
"await",
"self",
".",
"_send_to_messenger_profile",
"(",
"page",
",",
"{",
"'persistent_menu'",
":",
"page",
"... | Define the persistent menu for all pages | [
"Define",
"the",
"persistent",
"menu",
"for",
"all",
"pages"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L584-L596 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._set_whitelist | async def _set_whitelist(self):
"""
Whitelist domains for the messenger extensions
"""
page = self.settings()
if 'whitelist' in page:
await self._send_to_messenger_profile(page, {
'whitelisted_domains': page['whitelist'],
})
... | python | async def _set_whitelist(self):
"""
Whitelist domains for the messenger extensions
"""
page = self.settings()
if 'whitelist' in page:
await self._send_to_messenger_profile(page, {
'whitelisted_domains': page['whitelist'],
})
... | [
"async",
"def",
"_set_whitelist",
"(",
"self",
")",
":",
"page",
"=",
"self",
".",
"settings",
"(",
")",
"if",
"'whitelist'",
"in",
"page",
":",
"await",
"self",
".",
"_send_to_messenger_profile",
"(",
"page",
",",
"{",
"'whitelisted_domains'",
":",
"page",
... | Whitelist domains for the messenger extensions | [
"Whitelist",
"domains",
"for",
"the",
"messenger",
"extensions"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L598-L612 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._get_subscriptions_endpoint | def _get_subscriptions_endpoint(self):
"""
Generates the URL and tokens for the subscriptions endpoint
"""
s = self.settings()
params = {
'access_token': self.app_access_token,
}
return (
GRAPH_ENDPOINT.format(f'{s["app_id"]}/subscriptio... | python | def _get_subscriptions_endpoint(self):
"""
Generates the URL and tokens for the subscriptions endpoint
"""
s = self.settings()
params = {
'access_token': self.app_access_token,
}
return (
GRAPH_ENDPOINT.format(f'{s["app_id"]}/subscriptio... | [
"def",
"_get_subscriptions_endpoint",
"(",
"self",
")",
":",
"s",
"=",
"self",
".",
"settings",
"(",
")",
"params",
"=",
"{",
"'access_token'",
":",
"self",
".",
"app_access_token",
",",
"}",
"return",
"(",
"GRAPH_ENDPOINT",
".",
"format",
"(",
"f'{s[\"app_i... | Generates the URL and tokens for the subscriptions endpoint | [
"Generates",
"the",
"URL",
"and",
"tokens",
"for",
"the",
"subscriptions",
"endpoint"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L614-L628 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._get_subscriptions | async def _get_subscriptions(self) -> Tuple[Set[Text], Text]:
"""
List the subscriptions currently active
"""
url, params = self._get_subscriptions_endpoint()
get = self.session.get(url, params=params)
async with get as r:
await self._handle_fb_response(r)
... | python | async def _get_subscriptions(self) -> Tuple[Set[Text], Text]:
"""
List the subscriptions currently active
"""
url, params = self._get_subscriptions_endpoint()
get = self.session.get(url, params=params)
async with get as r:
await self._handle_fb_response(r)
... | [
"async",
"def",
"_get_subscriptions",
"(",
"self",
")",
"->",
"Tuple",
"[",
"Set",
"[",
"Text",
"]",
",",
"Text",
"]",
":",
"url",
",",
"params",
"=",
"self",
".",
"_get_subscriptions_endpoint",
"(",
")",
"get",
"=",
"self",
".",
"session",
".",
"get",... | List the subscriptions currently active | [
"List",
"the",
"subscriptions",
"currently",
"active"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L630-L650 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._set_subscriptions | async def _set_subscriptions(self, subscriptions):
"""
Set the subscriptions to a specific list of values
"""
url, params = self._get_subscriptions_endpoint()
data = {
'object': 'page',
'callback_url': self.webhook_url,
'fields': ', '.join(su... | python | async def _set_subscriptions(self, subscriptions):
"""
Set the subscriptions to a specific list of values
"""
url, params = self._get_subscriptions_endpoint()
data = {
'object': 'page',
'callback_url': self.webhook_url,
'fields': ', '.join(su... | [
"async",
"def",
"_set_subscriptions",
"(",
"self",
",",
"subscriptions",
")",
":",
"url",
",",
"params",
"=",
"self",
".",
"_get_subscriptions_endpoint",
"(",
")",
"data",
"=",
"{",
"'object'",
":",
"'page'",
",",
"'callback_url'",
":",
"self",
".",
"webhook... | Set the subscriptions to a specific list of values | [
"Set",
"the",
"subscriptions",
"to",
"a",
"specific",
"list",
"of",
"values"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L652-L679 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._check_subscriptions | async def _check_subscriptions(self):
"""
Checks that all subscriptions are subscribed
"""
subscribed, url = await self._get_subscriptions()
expect = set(settings.FACEBOOK_SUBSCRIPTIONS)
if (expect - subscribed) or url != self.webhook_url:
await self._set_su... | python | async def _check_subscriptions(self):
"""
Checks that all subscriptions are subscribed
"""
subscribed, url = await self._get_subscriptions()
expect = set(settings.FACEBOOK_SUBSCRIPTIONS)
if (expect - subscribed) or url != self.webhook_url:
await self._set_su... | [
"async",
"def",
"_check_subscriptions",
"(",
"self",
")",
":",
"subscribed",
",",
"url",
"=",
"await",
"self",
".",
"_get_subscriptions",
"(",
")",
"expect",
"=",
"set",
"(",
"settings",
".",
"FACEBOOK_SUBSCRIPTIONS",
")",
"if",
"(",
"expect",
"-",
"subscrib... | Checks that all subscriptions are subscribed | [
"Checks",
"that",
"all",
"subscriptions",
"are",
"subscribed"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L681-L693 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook.handle_event | async def handle_event(self, event: FacebookMessage):
"""
Handle an incoming message from Facebook.
"""
responder = FacebookResponder(self)
await self._notify(event, responder) | python | async def handle_event(self, event: FacebookMessage):
"""
Handle an incoming message from Facebook.
"""
responder = FacebookResponder(self)
await self._notify(event, responder) | [
"async",
"def",
"handle_event",
"(",
"self",
",",
"event",
":",
"FacebookMessage",
")",
":",
"responder",
"=",
"FacebookResponder",
"(",
"self",
")",
"await",
"self",
".",
"_notify",
"(",
"event",
",",
"responder",
")"
] | Handle an incoming message from Facebook. | [
"Handle",
"an",
"incoming",
"message",
"from",
"Facebook",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L695-L700 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._access_token | def _access_token(self, request: Request=None, page_id: Text=''):
"""
Guess the access token for that specific request.
"""
if not page_id:
msg = request.message # type: FacebookMessage
page_id = msg.get_page_id()
page = self.settings()
if page... | python | def _access_token(self, request: Request=None, page_id: Text=''):
"""
Guess the access token for that specific request.
"""
if not page_id:
msg = request.message # type: FacebookMessage
page_id = msg.get_page_id()
page = self.settings()
if page... | [
"def",
"_access_token",
"(",
"self",
",",
"request",
":",
"Request",
"=",
"None",
",",
"page_id",
":",
"Text",
"=",
"''",
")",
":",
"if",
"not",
"page_id",
":",
"msg",
"=",
"request",
".",
"message",
"page_id",
"=",
"msg",
".",
"get_page_id",
"(",
")... | Guess the access token for that specific request. | [
"Guess",
"the",
"access",
"token",
"for",
"that",
"specific",
"request",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L702-L718 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._make_qr | async def _make_qr(self,
qr: QuickRepliesList.BaseOption,
request: Request):
"""
Generate a single quick reply's content.
"""
if isinstance(qr, QuickRepliesList.TextOption):
return {
'content_type': 'text',
... | python | async def _make_qr(self,
qr: QuickRepliesList.BaseOption,
request: Request):
"""
Generate a single quick reply's content.
"""
if isinstance(qr, QuickRepliesList.TextOption):
return {
'content_type': 'text',
... | [
"async",
"def",
"_make_qr",
"(",
"self",
",",
"qr",
":",
"QuickRepliesList",
".",
"BaseOption",
",",
"request",
":",
"Request",
")",
":",
"if",
"isinstance",
"(",
"qr",
",",
"QuickRepliesList",
".",
"TextOption",
")",
":",
"return",
"{",
"'content_type'",
... | Generate a single quick reply's content. | [
"Generate",
"a",
"single",
"quick",
"reply",
"s",
"content",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L720-L736 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._send_text | async def _send_text(self, request: Request, stack: Stack):
"""
Send text layers to the user. Each layer will go in its own bubble.
Also, Facebook limits messages to 320 chars, so if any message is
longer than that it will be split into as many messages as needed to
be accepted ... | python | async def _send_text(self, request: Request, stack: Stack):
"""
Send text layers to the user. Each layer will go in its own bubble.
Also, Facebook limits messages to 320 chars, so if any message is
longer than that it will be split into as many messages as needed to
be accepted ... | [
"async",
"def",
"_send_text",
"(",
"self",
",",
"request",
":",
"Request",
",",
"stack",
":",
"Stack",
")",
":",
"parts",
"=",
"[",
"]",
"for",
"layer",
"in",
"stack",
".",
"layers",
":",
"if",
"isinstance",
"(",
"layer",
",",
"lyr",
".",
"MultiText"... | Send text layers to the user. Each layer will go in its own bubble.
Also, Facebook limits messages to 320 chars, so if any message is
longer than that it will be split into as many messages as needed to
be accepted by Facebook. | [
"Send",
"text",
"layers",
"to",
"the",
"user",
".",
"Each",
"layer",
"will",
"go",
"in",
"its",
"own",
"bubble",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L749-L783 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._send_generic_template | async def _send_generic_template(self, request: Request, stack: Stack):
"""
Generates and send a generic template.
"""
gt = stack.get_layer(GenericTemplate)
payload = await gt.serialize(request)
msg = {
'attachment': {
'type': 'template',
... | python | async def _send_generic_template(self, request: Request, stack: Stack):
"""
Generates and send a generic template.
"""
gt = stack.get_layer(GenericTemplate)
payload = await gt.serialize(request)
msg = {
'attachment': {
'type': 'template',
... | [
"async",
"def",
"_send_generic_template",
"(",
"self",
",",
"request",
":",
"Request",
",",
"stack",
":",
"Stack",
")",
":",
"gt",
"=",
"stack",
".",
"get_layer",
"(",
"GenericTemplate",
")",
"payload",
"=",
"await",
"gt",
".",
"serialize",
"(",
"request",... | Generates and send a generic template. | [
"Generates",
"and",
"send",
"a",
"generic",
"template",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L785-L801 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._send_button_template | async def _send_button_template(self, request: Request, stack: Stack):
"""
Generates and send a button template.
"""
gt = stack.get_layer(ButtonTemplate)
payload = {
'template_type': 'button',
'text': await render(gt.text, request),
'buttons'... | python | async def _send_button_template(self, request: Request, stack: Stack):
"""
Generates and send a button template.
"""
gt = stack.get_layer(ButtonTemplate)
payload = {
'template_type': 'button',
'text': await render(gt.text, request),
'buttons'... | [
"async",
"def",
"_send_button_template",
"(",
"self",
",",
"request",
":",
"Request",
",",
"stack",
":",
"Stack",
")",
":",
"gt",
"=",
"stack",
".",
"get_layer",
"(",
"ButtonTemplate",
")",
"payload",
"=",
"{",
"'template_type'",
":",
"'button'",
",",
"'te... | Generates and send a button template. | [
"Generates",
"and",
"send",
"a",
"button",
"template",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L803-L824 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._send_typing | async def _send_typing(self, request: Request, stack: Stack):
"""
Send to Facebook typing indications
"""
active = stack.get_layer(lyr.Typing).active
msg = ujson.dumps({
'recipient': {
'id': request.conversation.fbid,
},
'send... | python | async def _send_typing(self, request: Request, stack: Stack):
"""
Send to Facebook typing indications
"""
active = stack.get_layer(lyr.Typing).active
msg = ujson.dumps({
'recipient': {
'id': request.conversation.fbid,
},
'send... | [
"async",
"def",
"_send_typing",
"(",
"self",
",",
"request",
":",
"Request",
",",
"stack",
":",
"Stack",
")",
":",
"active",
"=",
"stack",
".",
"get_layer",
"(",
"lyr",
".",
"Typing",
")",
".",
"active",
"msg",
"=",
"ujson",
".",
"dumps",
"(",
"{",
... | Send to Facebook typing indications | [
"Send",
"to",
"Facebook",
"typing",
"indications"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L858-L890 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._handle_fb_response | async def _handle_fb_response(self, response: aiohttp.ClientResponse):
"""
Check that Facebook was OK with the API call we just made and raise
an exception if it failed.
"""
ok = response.status == 200
if not ok:
# noinspection PyBroadException
t... | python | async def _handle_fb_response(self, response: aiohttp.ClientResponse):
"""
Check that Facebook was OK with the API call we just made and raise
an exception if it failed.
"""
ok = response.status == 200
if not ok:
# noinspection PyBroadException
t... | [
"async",
"def",
"_handle_fb_response",
"(",
"self",
",",
"response",
":",
"aiohttp",
".",
"ClientResponse",
")",
":",
"ok",
"=",
"response",
".",
"status",
"==",
"200",
"if",
"not",
"ok",
":",
"try",
":",
"error",
"=",
"(",
"await",
"response",
".",
"j... | Check that Facebook was OK with the API call we just made and raise
an exception if it failed. | [
"Check",
"that",
"Facebook",
"was",
"OK",
"with",
"the",
"API",
"call",
"we",
"just",
"made",
"and",
"raise",
"an",
"exception",
"if",
"it",
"failed",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L892-L908 | train |
BernardFW/bernard | src/bernard/platforms/facebook/platform.py | Facebook._send | async def _send(self,
request: Request,
content: Dict[Text, Any],
stack: Stack):
"""
Actually proceed to sending the message to the Facebook API.
"""
msg = {
'recipient': {
'id': request.conversation... | python | async def _send(self,
request: Request,
content: Dict[Text, Any],
stack: Stack):
"""
Actually proceed to sending the message to the Facebook API.
"""
msg = {
'recipient': {
'id': request.conversation... | [
"async",
"def",
"_send",
"(",
"self",
",",
"request",
":",
"Request",
",",
"content",
":",
"Dict",
"[",
"Text",
",",
"Any",
"]",
",",
"stack",
":",
"Stack",
")",
":",
"msg",
"=",
"{",
"'recipient'",
":",
"{",
"'id'",
":",
"request",
".",
"conversat... | Actually proceed to sending the message to the Facebook API. | [
"Actually",
"proceed",
"to",
"sending",
"the",
"message",
"to",
"the",
"Facebook",
"API",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/platform.py#L910-L951 | train |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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",
")",
"self",
".",
"_index",
"=",
"self",
".",
"_make_index",
"(",
")",
"self",
".",
"_transformed",
"=",
... | 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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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'",
")",
"platform_name",
"=",
"getattr",
"(",
"dataset",
",",
"'platform'",
",",
"''"... | 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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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",
")",
"if",... | 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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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",
"if",
"not",
"uuid_or_name",
":",
"raise",
"ValueError",
"(",
"'No Workflow was specified.'",
")",
"try",
":",
"uuid_o... | 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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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",
"}",
"params",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
".",
"__request",
"(",
"self",
".",
"url",
... | 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 |
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 |
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 |
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 |
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",
")",
":",
"start",
"=",
"int",
"(",
"inclusive_start",
")",
"-",
"1",
"end",
"=",
"int",
"(",
"inclusive_end",
"... | 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 |
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 |
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 |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.