repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
ministryofjustice/money-to-prisoners-common | mtp_common/build_tasks/executor.py | Context.management_command | def management_command(self, command, *args, **kwargs):
"""
Runs a Django management command
"""
self.setup_django()
if 'verbosity' not in kwargs:
kwargs['verbosity'] = self.verbosity
if not self.use_colour:
kwargs['no_color'] = False
self.... | python | def management_command(self, command, *args, **kwargs):
"""
Runs a Django management command
"""
self.setup_django()
if 'verbosity' not in kwargs:
kwargs['verbosity'] = self.verbosity
if not self.use_colour:
kwargs['no_color'] = False
self.... | [
"def",
"management_command",
"(",
"self",
",",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"setup_django",
"(",
")",
"if",
"'verbosity'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'verbosity'",
"]",
"=",
"self",
".",
... | Runs a Django management command | [
"Runs",
"a",
"Django",
"management",
"command"
] | train | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/build_tasks/executor.py#L451-L461 |
ministryofjustice/money-to-prisoners-common | mtp_common/build_tasks/executor.py | Executor.help | def help(self, context):
"""
Prints this help (use --verbosity 2 for more details)
"""
context.info('%s\n%s [global options] [task] [task options]...\n' % (self.name, sys.argv[0]))
def print_parameter(prn, p):
if p.description:
suffix = ' - {0.desc... | python | def help(self, context):
"""
Prints this help (use --verbosity 2 for more details)
"""
context.info('%s\n%s [global options] [task] [task options]...\n' % (self.name, sys.argv[0]))
def print_parameter(prn, p):
if p.description:
suffix = ' - {0.desc... | [
"def",
"help",
"(",
"self",
",",
"context",
")",
":",
"context",
".",
"info",
"(",
"'%s\\n%s [global options] [task] [task options]...\\n'",
"%",
"(",
"self",
".",
"name",
",",
"sys",
".",
"argv",
"[",
"0",
"]",
")",
")",
"def",
"print_parameter",
"(",
"pr... | Prints this help (use --verbosity 2 for more details) | [
"Prints",
"this",
"help",
"(",
"use",
"--",
"verbosity",
"2",
"for",
"more",
"details",
")"
] | train | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/build_tasks/executor.py#L527-L557 |
ministryofjustice/money-to-prisoners-common | mtp_common/auth/__init__.py | login | def login(request, user):
"""
Persist a user id and a backend in the request. This way a user doesn't
have to reauthenticate on every request. Note that data set during
the anonymous session is retained when the user logs in.
"""
session_auth_hash = ''
if user is None:
user = request... | python | def login(request, user):
"""
Persist a user id and a backend in the request. This way a user doesn't
have to reauthenticate on every request. Note that data set during
the anonymous session is retained when the user logs in.
"""
session_auth_hash = ''
if user is None:
user = request... | [
"def",
"login",
"(",
"request",
",",
"user",
")",
":",
"session_auth_hash",
"=",
"''",
"if",
"user",
"is",
"None",
":",
"user",
"=",
"request",
".",
"user",
"if",
"hasattr",
"(",
"user",
",",
"'get_session_auth_hash'",
")",
":",
"session_auth_hash",
"=",
... | Persist a user id and a backend in the request. This way a user doesn't
have to reauthenticate on every request. Note that data set during
the anonymous session is retained when the user logs in. | [
"Persist",
"a",
"user",
"id",
"and",
"a",
"backend",
"in",
"the",
"request",
".",
"This",
"way",
"a",
"user",
"doesn",
"t",
"have",
"to",
"reauthenticate",
"on",
"every",
"request",
".",
"Note",
"that",
"data",
"set",
"during",
"the",
"anonymous",
"sessi... | train | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/auth/__init__.py#L22-L55 |
ministryofjustice/money-to-prisoners-common | mtp_common/auth/__init__.py | get_user | def get_user(request):
"""
Returns the user model instance associated with the given request session.
If no user is retrieved an instance of `MojAnonymousUser` is returned.
"""
user = None
try:
user_id = request.session[SESSION_KEY]
token = request.session[AUTH_TOKEN_SESSION_KEY]... | python | def get_user(request):
"""
Returns the user model instance associated with the given request session.
If no user is retrieved an instance of `MojAnonymousUser` is returned.
"""
user = None
try:
user_id = request.session[SESSION_KEY]
token = request.session[AUTH_TOKEN_SESSION_KEY]... | [
"def",
"get_user",
"(",
"request",
")",
":",
"user",
"=",
"None",
"try",
":",
"user_id",
"=",
"request",
".",
"session",
"[",
"SESSION_KEY",
"]",
"token",
"=",
"request",
".",
"session",
"[",
"AUTH_TOKEN_SESSION_KEY",
"]",
"user_data",
"=",
"request",
".",... | Returns the user model instance associated with the given request session.
If no user is retrieved an instance of `MojAnonymousUser` is returned. | [
"Returns",
"the",
"user",
"model",
"instance",
"associated",
"with",
"the",
"given",
"request",
"session",
".",
"If",
"no",
"user",
"is",
"retrieved",
"an",
"instance",
"of",
"MojAnonymousUser",
"is",
"returned",
"."
] | train | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/auth/__init__.py#L58-L86 |
ministryofjustice/money-to-prisoners-common | mtp_common/auth/__init__.py | logout | def logout(request):
"""
Removes the authenticated user's ID from the request and flushes their
session data.
"""
# Dispatch the signal before the user is logged out so the receivers have a
# chance to find out *who* logged out.
user = getattr(request, 'user', None)
if hasattr(user, 'is_... | python | def logout(request):
"""
Removes the authenticated user's ID from the request and flushes their
session data.
"""
# Dispatch the signal before the user is logged out so the receivers have a
# chance to find out *who* logged out.
user = getattr(request, 'user', None)
if hasattr(user, 'is_... | [
"def",
"logout",
"(",
"request",
")",
":",
"# Dispatch the signal before the user is logged out so the receivers have a",
"# chance to find out *who* logged out.",
"user",
"=",
"getattr",
"(",
"request",
",",
"'user'",
",",
"None",
")",
"if",
"hasattr",
"(",
"user",
",",
... | Removes the authenticated user's ID from the request and flushes their
session data. | [
"Removes",
"the",
"authenticated",
"user",
"s",
"ID",
"from",
"the",
"request",
"and",
"flushes",
"their",
"session",
"data",
"."
] | train | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/auth/__init__.py#L96-L117 |
koreyou/word_embedding_loader | word_embedding_loader/saver/word2vec_text.py | save | def save(f, arr, vocab):
"""
Save word embedding file.
Check :func:`word_embedding_loader.saver.glove.save` for the API.
"""
f.write(('%d %d' % (arr.shape[0], arr.shape[1])).encode('utf-8'))
for word, idx in vocab:
_write_line(f, arr[idx], word) | python | def save(f, arr, vocab):
"""
Save word embedding file.
Check :func:`word_embedding_loader.saver.glove.save` for the API.
"""
f.write(('%d %d' % (arr.shape[0], arr.shape[1])).encode('utf-8'))
for word, idx in vocab:
_write_line(f, arr[idx], word) | [
"def",
"save",
"(",
"f",
",",
"arr",
",",
"vocab",
")",
":",
"f",
".",
"write",
"(",
"(",
"'%d %d'",
"%",
"(",
"arr",
".",
"shape",
"[",
"0",
"]",
",",
"arr",
".",
"shape",
"[",
"1",
"]",
")",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")",
... | Save word embedding file.
Check :func:`word_embedding_loader.saver.glove.save` for the API. | [
"Save",
"word",
"embedding",
"file",
".",
"Check",
":",
"func",
":",
"word_embedding_loader",
".",
"saver",
".",
"glove",
".",
"save",
"for",
"the",
"API",
"."
] | train | https://github.com/koreyou/word_embedding_loader/blob/1bc123f1a8bea12646576dcd768dae3ecea39c06/word_embedding_loader/saver/word2vec_text.py#L20-L27 |
ministryofjustice/money-to-prisoners-common | mtp_common/spooling.py | spoolable | def spoolable(*, pre_condition=True, body_params=()):
"""
Decorates a function to make it spoolable using uWSGI, but if no spooling mechanism is available,
the function is called synchronously. All decorated function arguments must be picklable and
the first annotated with `Context` will receive an obje... | python | def spoolable(*, pre_condition=True, body_params=()):
"""
Decorates a function to make it spoolable using uWSGI, but if no spooling mechanism is available,
the function is called synchronously. All decorated function arguments must be picklable and
the first annotated with `Context` will receive an obje... | [
"def",
"spoolable",
"(",
"*",
",",
"pre_condition",
"=",
"True",
",",
"body_params",
"=",
"(",
")",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"context_name",
"=",
"None",
"keyword_kinds",
"=",
"{",
"inspect",
".",
"Parameter",
".",
"POSITIONAL... | Decorates a function to make it spoolable using uWSGI, but if no spooling mechanism is available,
the function is called synchronously. All decorated function arguments must be picklable and
the first annotated with `Context` will receive an object that defines the current execution state.
Return values are... | [
"Decorates",
"a",
"function",
"to",
"make",
"it",
"spoolable",
"using",
"uWSGI",
"but",
"if",
"no",
"spooling",
"mechanism",
"is",
"available",
"the",
"function",
"is",
"called",
"synchronously",
".",
"All",
"decorated",
"function",
"arguments",
"must",
"be",
... | train | https://github.com/ministryofjustice/money-to-prisoners-common/blob/33c43a2912cb990d9148da7c8718f480f07d90a1/mtp_common/spooling.py#L144-L172 |
Jaymon/prom | prom/model.py | Orm.fields | def fields(self):
"""
return all the fields and their raw values for this Orm instance. This
property returns a dict with the field names and their current values
if you want to control the values for outputting to an api, use .jsonable()
"""
return {k:getattr(self, k, N... | python | def fields(self):
"""
return all the fields and their raw values for this Orm instance. This
property returns a dict with the field names and their current values
if you want to control the values for outputting to an api, use .jsonable()
"""
return {k:getattr(self, k, N... | [
"def",
"fields",
"(",
"self",
")",
":",
"return",
"{",
"k",
":",
"getattr",
"(",
"self",
",",
"k",
",",
"None",
")",
"for",
"k",
"in",
"self",
".",
"schema",
".",
"fields",
"}"
] | return all the fields and their raw values for this Orm instance. This
property returns a dict with the field names and their current values
if you want to control the values for outputting to an api, use .jsonable() | [
"return",
"all",
"the",
"fields",
"and",
"their",
"raw",
"values",
"for",
"this",
"Orm",
"instance",
".",
"This",
"property",
"returns",
"a",
"dict",
"with",
"the",
"field",
"names",
"and",
"their",
"current",
"values"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/model.py#L144-L151 |
Jaymon/prom | prom/model.py | Orm.create | def create(cls, fields=None, **fields_kwargs):
"""
create an instance of cls with the passed in fields and set it into the db
fields -- dict -- field_name keys, with their respective values
**fields_kwargs -- dict -- if you would rather pass in fields as name=val, that works also
... | python | def create(cls, fields=None, **fields_kwargs):
"""
create an instance of cls with the passed in fields and set it into the db
fields -- dict -- field_name keys, with their respective values
**fields_kwargs -- dict -- if you would rather pass in fields as name=val, that works also
... | [
"def",
"create",
"(",
"cls",
",",
"fields",
"=",
"None",
",",
"*",
"*",
"fields_kwargs",
")",
":",
"# NOTE -- you cannot use hydrate/populate here because populate alters modified fields",
"instance",
"=",
"cls",
"(",
"fields",
",",
"*",
"*",
"fields_kwargs",
")",
"... | create an instance of cls with the passed in fields and set it into the db
fields -- dict -- field_name keys, with their respective values
**fields_kwargs -- dict -- if you would rather pass in fields as name=val, that works also | [
"create",
"an",
"instance",
"of",
"cls",
"with",
"the",
"passed",
"in",
"fields",
"and",
"set",
"it",
"into",
"the",
"db"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/model.py#L182-L192 |
Jaymon/prom | prom/model.py | Orm.populate | def populate(self, fields=None, **fields_kwargs):
"""take the passed in fields, combine them with missing fields that should
be there and then run all those through appropriate methods to hydrate this
orm.
The method replaces cls.hydrate() since it was becoming hard to understand
... | python | def populate(self, fields=None, **fields_kwargs):
"""take the passed in fields, combine them with missing fields that should
be there and then run all those through appropriate methods to hydrate this
orm.
The method replaces cls.hydrate() since it was becoming hard to understand
... | [
"def",
"populate",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"*",
"*",
"fields_kwargs",
")",
":",
"# this will run all the fields of the Orm, not just the fields in fields",
"# dict, another name would be hydrate",
"pop_fields",
"=",
"{",
"}",
"fields",
"=",
"self",
... | take the passed in fields, combine them with missing fields that should
be there and then run all those through appropriate methods to hydrate this
orm.
The method replaces cls.hydrate() since it was becoming hard to understand
what was going on with all these methods that did things ju... | [
"take",
"the",
"passed",
"in",
"fields",
"combine",
"them",
"with",
"missing",
"fields",
"that",
"should",
"be",
"there",
"and",
"then",
"run",
"all",
"those",
"through",
"appropriate",
"methods",
"to",
"hydrate",
"this",
"orm",
"."
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/model.py#L225-L249 |
Jaymon/prom | prom/model.py | Orm._populate | def _populate(self, fields):
"""this runs all the fields through their iget methods to mimic them
freshly coming out of the db, then resets modified
:param fields: dict, the fields that were passed in
"""
schema = self.schema
for k, v in fields.items():
field... | python | def _populate(self, fields):
"""this runs all the fields through their iget methods to mimic them
freshly coming out of the db, then resets modified
:param fields: dict, the fields that were passed in
"""
schema = self.schema
for k, v in fields.items():
field... | [
"def",
"_populate",
"(",
"self",
",",
"fields",
")",
":",
"schema",
"=",
"self",
".",
"schema",
"for",
"k",
",",
"v",
"in",
"fields",
".",
"items",
"(",
")",
":",
"fields",
"[",
"k",
"]",
"=",
"schema",
".",
"fields",
"[",
"k",
"]",
".",
"iget"... | this runs all the fields through their iget methods to mimic them
freshly coming out of the db, then resets modified
:param fields: dict, the fields that were passed in | [
"this",
"runs",
"all",
"the",
"fields",
"through",
"their",
"iget",
"methods",
"to",
"mimic",
"them",
"freshly",
"coming",
"out",
"of",
"the",
"db",
"then",
"resets",
"modified"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/model.py#L251-L262 |
Jaymon/prom | prom/model.py | Orm.depopulate | def depopulate(self, is_update):
"""Get all the fields that need to be saved
:param is_udpate: bool, True if update query, False if insert
:returns: dict, key is field_name and val is the field value to be saved
"""
fields = {}
schema = self.schema
for k, field i... | python | def depopulate(self, is_update):
"""Get all the fields that need to be saved
:param is_udpate: bool, True if update query, False if insert
:returns: dict, key is field_name and val is the field value to be saved
"""
fields = {}
schema = self.schema
for k, field i... | [
"def",
"depopulate",
"(",
"self",
",",
"is_update",
")",
":",
"fields",
"=",
"{",
"}",
"schema",
"=",
"self",
".",
"schema",
"for",
"k",
",",
"field",
"in",
"schema",
".",
"fields",
".",
"items",
"(",
")",
":",
"is_modified",
"=",
"k",
"in",
"self"... | Get all the fields that need to be saved
:param is_udpate: bool, True if update query, False if insert
:returns: dict, key is field_name and val is the field value to be saved | [
"Get",
"all",
"the",
"fields",
"that",
"need",
"to",
"be",
"saved"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/model.py#L264-L294 |
Jaymon/prom | prom/model.py | Orm.insert | def insert(self):
"""persist the field values of this orm"""
ret = True
schema = self.schema
fields = self.depopulate(False)
q = self.query
q.set_fields(fields)
pk = q.insert()
if pk:
fields = q.fields
fields[schema.pk.name] = pk
... | python | def insert(self):
"""persist the field values of this orm"""
ret = True
schema = self.schema
fields = self.depopulate(False)
q = self.query
q.set_fields(fields)
pk = q.insert()
if pk:
fields = q.fields
fields[schema.pk.name] = pk
... | [
"def",
"insert",
"(",
"self",
")",
":",
"ret",
"=",
"True",
"schema",
"=",
"self",
".",
"schema",
"fields",
"=",
"self",
".",
"depopulate",
"(",
"False",
")",
"q",
"=",
"self",
".",
"query",
"q",
".",
"set_fields",
"(",
"fields",
")",
"pk",
"=",
... | persist the field values of this orm | [
"persist",
"the",
"field",
"values",
"of",
"this",
"orm"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/model.py#L296-L314 |
Jaymon/prom | prom/model.py | Orm.update | def update(self):
"""re-persist the updated field values of this orm that has a primary key"""
ret = True
fields = self.depopulate(True)
q = self.query
q.set_fields(fields)
pk = self.pk
if pk:
q.is_field(self.schema.pk.name, pk)
else:
... | python | def update(self):
"""re-persist the updated field values of this orm that has a primary key"""
ret = True
fields = self.depopulate(True)
q = self.query
q.set_fields(fields)
pk = self.pk
if pk:
q.is_field(self.schema.pk.name, pk)
else:
... | [
"def",
"update",
"(",
"self",
")",
":",
"ret",
"=",
"True",
"fields",
"=",
"self",
".",
"depopulate",
"(",
"True",
")",
"q",
"=",
"self",
".",
"query",
"q",
".",
"set_fields",
"(",
"fields",
")",
"pk",
"=",
"self",
".",
"pk",
"if",
"pk",
":",
"... | re-persist the updated field values of this orm that has a primary key | [
"re",
"-",
"persist",
"the",
"updated",
"field",
"values",
"of",
"this",
"orm",
"that",
"has",
"a",
"primary",
"key"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/model.py#L316-L337 |
Jaymon/prom | prom/model.py | Orm.save | def save(self):
"""
persist the fields in this object into the db, this will update if _id is set, otherwise
it will insert
see also -- .insert(), .update()
"""
ret = False
# we will only use the primary key if it hasn't been modified
pk = None
i... | python | def save(self):
"""
persist the fields in this object into the db, this will update if _id is set, otherwise
it will insert
see also -- .insert(), .update()
"""
ret = False
# we will only use the primary key if it hasn't been modified
pk = None
i... | [
"def",
"save",
"(",
"self",
")",
":",
"ret",
"=",
"False",
"# we will only use the primary key if it hasn't been modified",
"pk",
"=",
"None",
"if",
"self",
".",
"schema",
".",
"pk",
".",
"name",
"not",
"in",
"self",
".",
"modified_fields",
":",
"pk",
"=",
"... | persist the fields in this object into the db, this will update if _id is set, otherwise
it will insert
see also -- .insert(), .update() | [
"persist",
"the",
"fields",
"in",
"this",
"object",
"into",
"the",
"db",
"this",
"will",
"update",
"if",
"_id",
"is",
"set",
"otherwise",
"it",
"will",
"insert"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/model.py#L340-L359 |
Jaymon/prom | prom/model.py | Orm.delete | def delete(self):
"""delete the object from the db if pk is set"""
ret = False
q = self.query
pk = self.pk
if pk:
pk_name = self.schema.pk.name
self.query.is_field(pk_name, pk).delete()
setattr(self, pk_name, None)
# mark all the f... | python | def delete(self):
"""delete the object from the db if pk is set"""
ret = False
q = self.query
pk = self.pk
if pk:
pk_name = self.schema.pk.name
self.query.is_field(pk_name, pk).delete()
setattr(self, pk_name, None)
# mark all the f... | [
"def",
"delete",
"(",
"self",
")",
":",
"ret",
"=",
"False",
"q",
"=",
"self",
".",
"query",
"pk",
"=",
"self",
".",
"pk",
"if",
"pk",
":",
"pk_name",
"=",
"self",
".",
"schema",
".",
"pk",
".",
"name",
"self",
".",
"query",
".",
"is_field",
"(... | delete the object from the db if pk is set | [
"delete",
"the",
"object",
"from",
"the",
"db",
"if",
"pk",
"is",
"set"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/model.py#L361-L379 |
Jaymon/prom | prom/model.py | Orm.reset_modified | def reset_modified(self):
"""
reset field modification tracking
this is handy for when you are loading a new Orm with the results from a query and
you don't want set() to do anything, you can Orm(**fields) and then orm.reset_modified() to
clear all the passed in fields from the ... | python | def reset_modified(self):
"""
reset field modification tracking
this is handy for when you are loading a new Orm with the results from a query and
you don't want set() to do anything, you can Orm(**fields) and then orm.reset_modified() to
clear all the passed in fields from the ... | [
"def",
"reset_modified",
"(",
"self",
")",
":",
"self",
".",
"modified_fields",
"=",
"set",
"(",
")",
"# compensate for us not having knowledge of certain fields changing",
"for",
"field_name",
",",
"field",
"in",
"self",
".",
"schema",
".",
"normal_fields",
".",
"i... | reset field modification tracking
this is handy for when you are loading a new Orm with the results from a query and
you don't want set() to do anything, you can Orm(**fields) and then orm.reset_modified() to
clear all the passed in fields from the modified list | [
"reset",
"field",
"modification",
"tracking"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/model.py#L385-L398 |
Jaymon/prom | prom/model.py | Orm.modify | def modify(self, fields=None, **fields_kwargs):
"""update the fields of this instance with the values in dict fields
this should rarely be messed with, if you would like to manipulate the
fields you should override _modify()
:param fields: dict, the fields in a dict
:param **fi... | python | def modify(self, fields=None, **fields_kwargs):
"""update the fields of this instance with the values in dict fields
this should rarely be messed with, if you would like to manipulate the
fields you should override _modify()
:param fields: dict, the fields in a dict
:param **fi... | [
"def",
"modify",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"*",
"*",
"fields_kwargs",
")",
":",
"modified_fields",
"=",
"set",
"(",
")",
"fields",
"=",
"self",
".",
"make_dict",
"(",
"fields",
",",
"fields_kwargs",
")",
"fields",
"=",
"self",
".",
... | update the fields of this instance with the values in dict fields
this should rarely be messed with, if you would like to manipulate the
fields you should override _modify()
:param fields: dict, the fields in a dict
:param **fields_kwargs: dict, if you would like to pass the fields as ... | [
"update",
"the",
"fields",
"of",
"this",
"instance",
"with",
"the",
"values",
"in",
"dict",
"fields"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/model.py#L400-L420 |
Jaymon/prom | prom/model.py | Orm.jsonable | def jsonable(self, *args, **options):
"""
return a public version of this instance that can be jsonified
Note that this does not return _id, _created, _updated, the reason why is
because lots of times you have a different name for _id (like if it is a
user object, then you migh... | python | def jsonable(self, *args, **options):
"""
return a public version of this instance that can be jsonified
Note that this does not return _id, _created, _updated, the reason why is
because lots of times you have a different name for _id (like if it is a
user object, then you migh... | [
"def",
"jsonable",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"d",
"=",
"{",
"}",
"for",
"field_name",
",",
"field",
"in",
"self",
".",
"schema",
".",
"normal_fields",
".",
"items",
"(",
")",
":",
"field_val",
"=",
"getattr"... | return a public version of this instance that can be jsonified
Note that this does not return _id, _created, _updated, the reason why is
because lots of times you have a different name for _id (like if it is a
user object, then you might want to call it user_id instead of _id) and I
di... | [
"return",
"a",
"public",
"version",
"of",
"this",
"instance",
"that",
"can",
"be",
"jsonified"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/model.py#L466-L486 |
guaix-ucm/pyemir | emirdrp/tools/merge2images.py | merge2images | def merge2images(hdu1, hdu2, debugplot):
"""Merge 2 EMIR images, averaging the common region.
Parameters
----------
hdu1 : HDUList object
Input image #1.
hdu2 : HDUList object
Input image #2.
debugplot : int
Determines whether intermediate computations and/or plots
... | python | def merge2images(hdu1, hdu2, debugplot):
"""Merge 2 EMIR images, averaging the common region.
Parameters
----------
hdu1 : HDUList object
Input image #1.
hdu2 : HDUList object
Input image #2.
debugplot : int
Determines whether intermediate computations and/or plots
... | [
"def",
"merge2images",
"(",
"hdu1",
",",
"hdu2",
",",
"debugplot",
")",
":",
"# check image dimensions",
"image_header",
"=",
"hdu1",
"[",
"0",
"]",
".",
"header",
"image_header_",
"=",
"hdu2",
"[",
"0",
"]",
".",
"header",
"#",
"naxis",
"=",
"image_header... | Merge 2 EMIR images, averaging the common region.
Parameters
----------
hdu1 : HDUList object
Input image #1.
hdu2 : HDUList object
Input image #2.
debugplot : int
Determines whether intermediate computations and/or plots
are displayed. The valid codes are defined in... | [
"Merge",
"2",
"EMIR",
"images",
"averaging",
"the",
"common",
"region",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/merge2images.py#L34-L106 |
Jaymon/prom | prom/interface/__init__.py | configure_environ | def configure_environ(dsn_env_name='PROM_DSN', connection_class=DsnConnection):
"""
configure interfaces based on environment variables
by default, when prom is imported, it will look for PROM_DSN, and PROM_DSN_N (where
N is 1 through infinity) in the environment, if it finds them, it will assume they
... | python | def configure_environ(dsn_env_name='PROM_DSN', connection_class=DsnConnection):
"""
configure interfaces based on environment variables
by default, when prom is imported, it will look for PROM_DSN, and PROM_DSN_N (where
N is 1 through infinity) in the environment, if it finds them, it will assume they
... | [
"def",
"configure_environ",
"(",
"dsn_env_name",
"=",
"'PROM_DSN'",
",",
"connection_class",
"=",
"DsnConnection",
")",
":",
"inters",
"=",
"[",
"]",
"cs",
"=",
"dsnparse",
".",
"parse_environs",
"(",
"dsn_env_name",
",",
"parse_class",
"=",
"connection_class",
... | configure interfaces based on environment variables
by default, when prom is imported, it will look for PROM_DSN, and PROM_DSN_N (where
N is 1 through infinity) in the environment, if it finds them, it will assume they
are dsn urls that prom understands and will configure db connections with them. If you
... | [
"configure",
"interfaces",
"based",
"on",
"environment",
"variables"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/__init__.py#L13-L42 |
Jaymon/prom | prom/interface/__init__.py | configure | def configure(dsn, connection_class=DsnConnection):
"""
configure an interface to be used to query a backend
you use this function to configure an Interface using a dsn, then you can get
that interface using the get_interface() method
dsn -- string -- a properly formatted prom dsn, see DsnConnecti... | python | def configure(dsn, connection_class=DsnConnection):
"""
configure an interface to be used to query a backend
you use this function to configure an Interface using a dsn, then you can get
that interface using the get_interface() method
dsn -- string -- a properly formatted prom dsn, see DsnConnecti... | [
"def",
"configure",
"(",
"dsn",
",",
"connection_class",
"=",
"DsnConnection",
")",
":",
"c",
"=",
"dsnparse",
".",
"parse",
"(",
"dsn",
",",
"parse_class",
"=",
"connection_class",
")",
"inter",
"=",
"c",
".",
"interface",
"set_interface",
"(",
"inter",
"... | configure an interface to be used to query a backend
you use this function to configure an Interface using a dsn, then you can get
that interface using the get_interface() method
dsn -- string -- a properly formatted prom dsn, see DsnConnection for how to format the dsn | [
"configure",
"an",
"interface",
"to",
"be",
"used",
"to",
"query",
"a",
"backend"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/__init__.py#L45-L57 |
Jaymon/prom | prom/interface/__init__.py | set_interface | def set_interface(interface, name=''):
"""
don't want to bother with a dsn? Use this method to make an interface available
"""
global interfaces
if not interface: raise ValueError('interface is empty')
# close down the interface before we discard it
if name in interfaces:
interface... | python | def set_interface(interface, name=''):
"""
don't want to bother with a dsn? Use this method to make an interface available
"""
global interfaces
if not interface: raise ValueError('interface is empty')
# close down the interface before we discard it
if name in interfaces:
interface... | [
"def",
"set_interface",
"(",
"interface",
",",
"name",
"=",
"''",
")",
":",
"global",
"interfaces",
"if",
"not",
"interface",
":",
"raise",
"ValueError",
"(",
"'interface is empty'",
")",
"# close down the interface before we discard it",
"if",
"name",
"in",
"interf... | don't want to bother with a dsn? Use this method to make an interface available | [
"don",
"t",
"want",
"to",
"bother",
"with",
"a",
"dsn?",
"Use",
"this",
"method",
"to",
"make",
"an",
"interface",
"available"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/__init__.py#L69-L81 |
Fuyukai/asyncwebsockets | asyncwebsockets/server.py | open_websocket_server | async def open_websocket_server(sock, filter=None): # pylint: disable=W0622
"""
A context manager which serves this websocket.
:param filter: an async callback which accepts the connection request
and returns a bool, or an explicit Accept/Reject message.
"""
ws = await create_websocket_server(... | python | async def open_websocket_server(sock, filter=None): # pylint: disable=W0622
"""
A context manager which serves this websocket.
:param filter: an async callback which accepts the connection request
and returns a bool, or an explicit Accept/Reject message.
"""
ws = await create_websocket_server(... | [
"async",
"def",
"open_websocket_server",
"(",
"sock",
",",
"filter",
"=",
"None",
")",
":",
"# pylint: disable=W0622",
"ws",
"=",
"await",
"create_websocket_server",
"(",
"sock",
",",
"filter",
"=",
"filter",
")",
"try",
":",
"yield",
"ws",
"finally",
":",
"... | A context manager which serves this websocket.
:param filter: an async callback which accepts the connection request
and returns a bool, or an explicit Accept/Reject message. | [
"A",
"context",
"manager",
"which",
"serves",
"this",
"websocket",
"."
] | train | https://github.com/Fuyukai/asyncwebsockets/blob/e33e75fd51ce5ae0feac244e8407d2672c5b4745/asyncwebsockets/server.py#L14-L25 |
Fuyukai/asyncwebsockets | asyncwebsockets/server.py | create_websocket_server | async def create_websocket_server(sock, filter=None): # pylint: disable=W0622
"""
A more low-level form of open_websocket_server.
You are responsible for closing this websocket.
"""
ws = Websocket()
await ws.start_server(sock, filter=filter)
return ws | python | async def create_websocket_server(sock, filter=None): # pylint: disable=W0622
"""
A more low-level form of open_websocket_server.
You are responsible for closing this websocket.
"""
ws = Websocket()
await ws.start_server(sock, filter=filter)
return ws | [
"async",
"def",
"create_websocket_server",
"(",
"sock",
",",
"filter",
"=",
"None",
")",
":",
"# pylint: disable=W0622",
"ws",
"=",
"Websocket",
"(",
")",
"await",
"ws",
".",
"start_server",
"(",
"sock",
",",
"filter",
"=",
"filter",
")",
"return",
"ws"
] | A more low-level form of open_websocket_server.
You are responsible for closing this websocket. | [
"A",
"more",
"low",
"-",
"level",
"form",
"of",
"open_websocket_server",
".",
"You",
"are",
"responsible",
"for",
"closing",
"this",
"websocket",
"."
] | train | https://github.com/Fuyukai/asyncwebsockets/blob/e33e75fd51ce5ae0feac244e8407d2672c5b4745/asyncwebsockets/server.py#L28-L35 |
Jaymon/prom | prom/config.py | Schema.normal_fields | def normal_fields(self):
"""fields that aren't magic (eg, aren't _id, _created, _updated)"""
return {f:v for f, v in self.fields.items() if not f.startswith('_')} | python | def normal_fields(self):
"""fields that aren't magic (eg, aren't _id, _created, _updated)"""
return {f:v for f, v in self.fields.items() if not f.startswith('_')} | [
"def",
"normal_fields",
"(",
"self",
")",
":",
"return",
"{",
"f",
":",
"v",
"for",
"f",
",",
"v",
"in",
"self",
".",
"fields",
".",
"items",
"(",
")",
"if",
"not",
"f",
".",
"startswith",
"(",
"'_'",
")",
"}"
] | fields that aren't magic (eg, aren't _id, _created, _updated) | [
"fields",
"that",
"aren",
"t",
"magic",
"(",
"eg",
"aren",
"t",
"_id",
"_created",
"_updated",
")"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/config.py#L170-L172 |
Jaymon/prom | prom/config.py | Schema.required_fields | def required_fields(self):
"""The normal required fields (eg, no magic fields like _id are included)"""
return {f:v for f, v in self.normal_fields.items() if v.required} | python | def required_fields(self):
"""The normal required fields (eg, no magic fields like _id are included)"""
return {f:v for f, v in self.normal_fields.items() if v.required} | [
"def",
"required_fields",
"(",
"self",
")",
":",
"return",
"{",
"f",
":",
"v",
"for",
"f",
",",
"v",
"in",
"self",
".",
"normal_fields",
".",
"items",
"(",
")",
"if",
"v",
".",
"required",
"}"
] | The normal required fields (eg, no magic fields like _id are included) | [
"The",
"normal",
"required",
"fields",
"(",
"eg",
"no",
"magic",
"fields",
"like",
"_id",
"are",
"included",
")"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/config.py#L175-L177 |
Jaymon/prom | prom/config.py | Schema.magic_fields | def magic_fields(self):
"""the magic fields for the schema"""
return {f:v for f, v in self.fields.items() if f.startswith('_')} | python | def magic_fields(self):
"""the magic fields for the schema"""
return {f:v for f, v in self.fields.items() if f.startswith('_')} | [
"def",
"magic_fields",
"(",
"self",
")",
":",
"return",
"{",
"f",
":",
"v",
"for",
"f",
",",
"v",
"in",
"self",
".",
"fields",
".",
"items",
"(",
")",
"if",
"f",
".",
"startswith",
"(",
"'_'",
")",
"}"
] | the magic fields for the schema | [
"the",
"magic",
"fields",
"for",
"the",
"schema"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/config.py#L180-L182 |
Jaymon/prom | prom/config.py | Schema.set_index | def set_index(self, index_name, index):
"""
add an index to the schema
for the most part, you will use the __getattr__ method of adding indexes for a more fluid interface,
but you can use this if you want to get closer to the bare metal
index_name -- string -- the name of the i... | python | def set_index(self, index_name, index):
"""
add an index to the schema
for the most part, you will use the __getattr__ method of adding indexes for a more fluid interface,
but you can use this if you want to get closer to the bare metal
index_name -- string -- the name of the i... | [
"def",
"set_index",
"(",
"self",
",",
"index_name",
",",
"index",
")",
":",
"if",
"not",
"index_name",
":",
"raise",
"ValueError",
"(",
"\"index_name must have a value\"",
")",
"if",
"index_name",
"in",
"self",
".",
"indexes",
":",
"raise",
"ValueError",
"(",
... | add an index to the schema
for the most part, you will use the __getattr__ method of adding indexes for a more fluid interface,
but you can use this if you want to get closer to the bare metal
index_name -- string -- the name of the index
index -- Index() -- an Index instance | [
"add",
"an",
"index",
"to",
"the",
"schema"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/config.py#L281-L301 |
Jaymon/prom | prom/config.py | Field.schema | def schema(self):
"""return the schema instance if this is reference to another table"""
if not hasattr(self, "_schema"):
ret = None
o = self._type
if isinstance(o, type):
ret = getattr(o, "schema", None)
elif isinstance(o, Schema):
... | python | def schema(self):
"""return the schema instance if this is reference to another table"""
if not hasattr(self, "_schema"):
ret = None
o = self._type
if isinstance(o, type):
ret = getattr(o, "schema", None)
elif isinstance(o, Schema):
... | [
"def",
"schema",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_schema\"",
")",
":",
"ret",
"=",
"None",
"o",
"=",
"self",
".",
"_type",
"if",
"isinstance",
"(",
"o",
",",
"type",
")",
":",
"ret",
"=",
"getattr",
"(",
"o",
... | return the schema instance if this is reference to another table | [
"return",
"the",
"schema",
"instance",
"if",
"this",
"is",
"reference",
"to",
"another",
"table"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/config.py#L390-L407 |
Jaymon/prom | prom/config.py | Field.fval | def fval(self, instance):
"""return the raw value that this property is holding internally for instance"""
try:
val = instance.__dict__[self.instance_field_name]
except KeyError as e:
#raise AttributeError(str(e))
val = None
return val | python | def fval(self, instance):
"""return the raw value that this property is holding internally for instance"""
try:
val = instance.__dict__[self.instance_field_name]
except KeyError as e:
#raise AttributeError(str(e))
val = None
return val | [
"def",
"fval",
"(",
"self",
",",
"instance",
")",
":",
"try",
":",
"val",
"=",
"instance",
".",
"__dict__",
"[",
"self",
".",
"instance_field_name",
"]",
"except",
"KeyError",
"as",
"e",
":",
"#raise AttributeError(str(e))",
"val",
"=",
"None",
"return",
"... | return the raw value that this property is holding internally for instance | [
"return",
"the",
"raw",
"value",
"that",
"this",
"property",
"is",
"holding",
"internally",
"for",
"instance"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/config.py#L561-L569 |
openmicroanalysis/pyxray | pyxray/base.py | _Database.set_default_reference | def set_default_reference(self, method, reference):
"""
Set the default reference for a method.
:arg method: name of a method
:type method: :class:`str`
{reference}
"""
if method not in self._available_methods:
raise ValueError('Unknown method: {0}'.... | python | def set_default_reference(self, method, reference):
"""
Set the default reference for a method.
:arg method: name of a method
:type method: :class:`str`
{reference}
"""
if method not in self._available_methods:
raise ValueError('Unknown method: {0}'.... | [
"def",
"set_default_reference",
"(",
"self",
",",
"method",
",",
"reference",
")",
":",
"if",
"method",
"not",
"in",
"self",
".",
"_available_methods",
":",
"raise",
"ValueError",
"(",
"'Unknown method: {0}'",
".",
"format",
"(",
"method",
")",
")",
"self",
... | Set the default reference for a method.
:arg method: name of a method
:type method: :class:`str`
{reference} | [
"Set",
"the",
"default",
"reference",
"for",
"a",
"method",
"."
] | train | https://github.com/openmicroanalysis/pyxray/blob/cae89677f00ebcc0952f94d1ab70e6b35e1a51e9/pyxray/base.py#L74-L85 |
openmicroanalysis/pyxray | pyxray/base.py | _Database.get_default_reference | def get_default_reference(self, method):
"""
Returns the default reference for a method.
:arg method: name of a method
:type method: :class:`str`
:return: reference
:rtype: :class:`Reference <pyxray.descriptor.Reference>` or :class:`str`
"""
if method no... | python | def get_default_reference(self, method):
"""
Returns the default reference for a method.
:arg method: name of a method
:type method: :class:`str`
:return: reference
:rtype: :class:`Reference <pyxray.descriptor.Reference>` or :class:`str`
"""
if method no... | [
"def",
"get_default_reference",
"(",
"self",
",",
"method",
")",
":",
"if",
"method",
"not",
"in",
"self",
".",
"_available_methods",
":",
"raise",
"ValueError",
"(",
"'Unknown method: {0}'",
".",
"format",
"(",
"method",
")",
")",
"return",
"self",
".",
"_d... | Returns the default reference for a method.
:arg method: name of a method
:type method: :class:`str`
:return: reference
:rtype: :class:`Reference <pyxray.descriptor.Reference>` or :class:`str` | [
"Returns",
"the",
"default",
"reference",
"for",
"a",
"method",
"."
] | train | https://github.com/openmicroanalysis/pyxray/blob/cae89677f00ebcc0952f94d1ab70e6b35e1a51e9/pyxray/base.py#L87-L99 |
openmicroanalysis/pyxray | pyxray/base.py | _Database.print_element_xray_transitions | def print_element_xray_transitions(self, element, file=sys.stdout, tabulate_kwargs=None):
"""
Prints all x-ray transitions for an element, with their different
notations and energy.
{element}
:arg file: file for output, default to standard out
"""
header = ['IUP... | python | def print_element_xray_transitions(self, element, file=sys.stdout, tabulate_kwargs=None):
"""
Prints all x-ray transitions for an element, with their different
notations and energy.
{element}
:arg file: file for output, default to standard out
"""
header = ['IUP... | [
"def",
"print_element_xray_transitions",
"(",
"self",
",",
"element",
",",
"file",
"=",
"sys",
".",
"stdout",
",",
"tabulate_kwargs",
"=",
"None",
")",
":",
"header",
"=",
"[",
"'IUPAC'",
",",
"'Siegbahn'",
",",
"'Energy (eV)'",
",",
"'Probability'",
"]",
"r... | Prints all x-ray transitions for an element, with their different
notations and energy.
{element}
:arg file: file for output, default to standard out | [
"Prints",
"all",
"x",
"-",
"ray",
"transitions",
"for",
"an",
"element",
"with",
"their",
"different",
"notations",
"and",
"energy",
"."
] | train | https://github.com/openmicroanalysis/pyxray/blob/cae89677f00ebcc0952f94d1ab70e6b35e1a51e9/pyxray/base.py#L243-L282 |
Jaymon/prom | prom/cli/dump.py | get_modules | def get_modules(modulepath):
"""return all found modules at modulepath (eg, foo.bar) including modulepath module"""
m = importlib.import_module(modulepath)
mpath = m.__file__
ret = set([m])
if "__init__." in mpath.lower():
mpath = os.path.dirname(mpath)
# https://docs.python.org/2/... | python | def get_modules(modulepath):
"""return all found modules at modulepath (eg, foo.bar) including modulepath module"""
m = importlib.import_module(modulepath)
mpath = m.__file__
ret = set([m])
if "__init__." in mpath.lower():
mpath = os.path.dirname(mpath)
# https://docs.python.org/2/... | [
"def",
"get_modules",
"(",
"modulepath",
")",
":",
"m",
"=",
"importlib",
".",
"import_module",
"(",
"modulepath",
")",
"mpath",
"=",
"m",
".",
"__file__",
"ret",
"=",
"set",
"(",
"[",
"m",
"]",
")",
"if",
"\"__init__.\"",
"in",
"mpath",
".",
"lower",
... | return all found modules at modulepath (eg, foo.bar) including modulepath module | [
"return",
"all",
"found",
"modules",
"at",
"modulepath",
"(",
"eg",
"foo",
".",
"bar",
")",
"including",
"modulepath",
"module"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/cli/dump.py#L22-L41 |
Jaymon/prom | prom/cli/dump.py | get_subclasses | def get_subclasses(modulepath, parent_class):
"""given a module return all the parent_class subclasses that are found in
that module and any submodules.
:param modulepath: string, a path like foo.bar.che
:param parent_class: object, the class whose children you are looking for
:returns: set, all th... | python | def get_subclasses(modulepath, parent_class):
"""given a module return all the parent_class subclasses that are found in
that module and any submodules.
:param modulepath: string, a path like foo.bar.che
:param parent_class: object, the class whose children you are looking for
:returns: set, all th... | [
"def",
"get_subclasses",
"(",
"modulepath",
",",
"parent_class",
")",
":",
"if",
"isinstance",
"(",
"modulepath",
",",
"ModuleType",
")",
":",
"modules",
"=",
"get_modules",
"(",
"modulepath",
".",
"__name__",
")",
"else",
":",
"modules",
"=",
"get_modules",
... | given a module return all the parent_class subclasses that are found in
that module and any submodules.
:param modulepath: string, a path like foo.bar.che
:param parent_class: object, the class whose children you are looking for
:returns: set, all the found child classes in modulepath of parent_class | [
"given",
"a",
"module",
"return",
"all",
"the",
"parent_class",
"subclasses",
"that",
"are",
"found",
"in",
"that",
"module",
"and",
"any",
"submodules",
"."
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/cli/dump.py#L44-L63 |
Jaymon/prom | prom/cli/dump.py | build_dump_order | def build_dump_order(orm_class, orm_classes):
"""pass in an array, when you encounter a ref, call this method again with the array
when something has no more refs, then it gets appended to the array and returns, each
time something gets through the list they are added, but before they are added to the
l... | python | def build_dump_order(orm_class, orm_classes):
"""pass in an array, when you encounter a ref, call this method again with the array
when something has no more refs, then it gets appended to the array and returns, each
time something gets through the list they are added, but before they are added to the
l... | [
"def",
"build_dump_order",
"(",
"orm_class",
",",
"orm_classes",
")",
":",
"if",
"orm_class",
"in",
"orm_classes",
":",
"return",
"for",
"field_name",
",",
"field_val",
"in",
"orm_class",
".",
"schema",
".",
"fields",
".",
"items",
"(",
")",
":",
"if",
"fi... | pass in an array, when you encounter a ref, call this method again with the array
when something has no more refs, then it gets appended to the array and returns, each
time something gets through the list they are added, but before they are added to the
list it is checked to see if it is already in the list... | [
"pass",
"in",
"an",
"array",
"when",
"you",
"encounter",
"a",
"ref",
"call",
"this",
"method",
"again",
"with",
"the",
"array",
"when",
"something",
"has",
"no",
"more",
"refs",
"then",
"it",
"gets",
"appended",
"to",
"the",
"array",
"and",
"returns",
"e... | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/cli/dump.py#L66-L78 |
Jaymon/prom | prom/cli/dump.py | get_orm_classes | def get_orm_classes(path):
"""this will return prom.Orm classes found in the given path (classpath or modulepath)"""
ret = set()
try:
m = importlib.import_module(path)
except ImportError:
# we have a classpath
m, klass = get_objects(path)
if issubclass(klass, Orm):
... | python | def get_orm_classes(path):
"""this will return prom.Orm classes found in the given path (classpath or modulepath)"""
ret = set()
try:
m = importlib.import_module(path)
except ImportError:
# we have a classpath
m, klass = get_objects(path)
if issubclass(klass, Orm):
... | [
"def",
"get_orm_classes",
"(",
"path",
")",
":",
"ret",
"=",
"set",
"(",
")",
"try",
":",
"m",
"=",
"importlib",
".",
"import_module",
"(",
"path",
")",
"except",
"ImportError",
":",
"# we have a classpath",
"m",
",",
"klass",
"=",
"get_objects",
"(",
"p... | this will return prom.Orm classes found in the given path (classpath or modulepath) | [
"this",
"will",
"return",
"prom",
".",
"Orm",
"classes",
"found",
"in",
"the",
"given",
"path",
"(",
"classpath",
"or",
"modulepath",
")"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/cli/dump.py#L81-L96 |
Jaymon/prom | prom/cli/dump.py | main_dump | def main_dump(paths, directory, dry_run):
"""dump all or part of the prom data, currently only works on Postgres databases
basically just a wrapper around `dump backup` https://github.com/Jaymon/dump
"""
table_map = get_table_map(paths)
for conn_name, conn_info in table_map.items():
inter ... | python | def main_dump(paths, directory, dry_run):
"""dump all or part of the prom data, currently only works on Postgres databases
basically just a wrapper around `dump backup` https://github.com/Jaymon/dump
"""
table_map = get_table_map(paths)
for conn_name, conn_info in table_map.items():
inter ... | [
"def",
"main_dump",
"(",
"paths",
",",
"directory",
",",
"dry_run",
")",
":",
"table_map",
"=",
"get_table_map",
"(",
"paths",
")",
"for",
"conn_name",
",",
"conn_info",
"in",
"table_map",
".",
"items",
"(",
")",
":",
"inter",
"=",
"conn_info",
"[",
"\"i... | dump all or part of the prom data, currently only works on Postgres databases
basically just a wrapper around `dump backup` https://github.com/Jaymon/dump | [
"dump",
"all",
"or",
"part",
"of",
"the",
"prom",
"data",
"currently",
"only",
"works",
"on",
"Postgres",
"databases"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/cli/dump.py#L182-L201 |
Jaymon/prom | prom/cli/dump.py | main_restore | def main_restore(directory, conn_name):
"""Restore your database dumped with the dump command
just a wrapper around `dump restore` https://github.com/Jaymon/dump
"""
inter = get_interface(conn_name)
conn = inter.connection_config
cmd = get_base_cmd("restore", inter, directory)
run_cmd(cmd) | python | def main_restore(directory, conn_name):
"""Restore your database dumped with the dump command
just a wrapper around `dump restore` https://github.com/Jaymon/dump
"""
inter = get_interface(conn_name)
conn = inter.connection_config
cmd = get_base_cmd("restore", inter, directory)
run_cmd(cmd) | [
"def",
"main_restore",
"(",
"directory",
",",
"conn_name",
")",
":",
"inter",
"=",
"get_interface",
"(",
"conn_name",
")",
"conn",
"=",
"inter",
".",
"connection_config",
"cmd",
"=",
"get_base_cmd",
"(",
"\"restore\"",
",",
"inter",
",",
"directory",
")",
"r... | Restore your database dumped with the dump command
just a wrapper around `dump restore` https://github.com/Jaymon/dump | [
"Restore",
"your",
"database",
"dumped",
"with",
"the",
"dump",
"command"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/cli/dump.py#L211-L219 |
Jaymon/prom | prom/interface/postgres.py | PostgreSQL._get_fields | def _get_fields(self, table_name, **kwargs):
"""return all the fields for the given schema"""
ret = {}
query_str = []
query_args = ['f', table_name]
# I had to brush up on my join knowledge while writing this query
# https://en.wikipedia.org/wiki/Join_(SQL)
#
... | python | def _get_fields(self, table_name, **kwargs):
"""return all the fields for the given schema"""
ret = {}
query_str = []
query_args = ['f', table_name]
# I had to brush up on my join knowledge while writing this query
# https://en.wikipedia.org/wiki/Join_(SQL)
#
... | [
"def",
"_get_fields",
"(",
"self",
",",
"table_name",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"}",
"query_str",
"=",
"[",
"]",
"query_args",
"=",
"[",
"'f'",
",",
"table_name",
"]",
"# I had to brush up on my join knowledge while writing this query",... | return all the fields for the given schema | [
"return",
"all",
"the",
"fields",
"for",
"the",
"given",
"schema"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/postgres.py#L184-L262 |
Jaymon/prom | prom/interface/postgres.py | PostgreSQL._get_indexes | def _get_indexes(self, schema, **kwargs):
"""return all the indexes for the given schema"""
ret = {}
query_str = []
query_str.append('SELECT')
query_str.append(' tbl.relname AS table_name, i.relname AS index_name, a.attname AS field_name,')
query_str.append(' ix.indkey ... | python | def _get_indexes(self, schema, **kwargs):
"""return all the indexes for the given schema"""
ret = {}
query_str = []
query_str.append('SELECT')
query_str.append(' tbl.relname AS table_name, i.relname AS index_name, a.attname AS field_name,')
query_str.append(' ix.indkey ... | [
"def",
"_get_indexes",
"(",
"self",
",",
"schema",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"}",
"query_str",
"=",
"[",
"]",
"query_str",
".",
"append",
"(",
"'SELECT'",
")",
"query_str",
".",
"append",
"(",
"' tbl.relname AS table_name, i.reln... | return all the indexes for the given schema | [
"return",
"all",
"the",
"indexes",
"for",
"the",
"given",
"schema"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/postgres.py#L264-L290 |
Jaymon/prom | prom/interface/postgres.py | PostgreSQL._set_index | def _set_index(self, schema, name, fields, **index_options):
"""
NOTE -- we set the index name using <table_name>_<name> format since indexes have to have
a globally unique name in postgres
http://www.postgresql.org/docs/9.1/static/sql-createindex.html
"""
index_fields =... | python | def _set_index(self, schema, name, fields, **index_options):
"""
NOTE -- we set the index name using <table_name>_<name> format since indexes have to have
a globally unique name in postgres
http://www.postgresql.org/docs/9.1/static/sql-createindex.html
"""
index_fields =... | [
"def",
"_set_index",
"(",
"self",
",",
"schema",
",",
"name",
",",
"fields",
",",
"*",
"*",
"index_options",
")",
":",
"index_fields",
"=",
"[",
"]",
"for",
"field_name",
"in",
"fields",
":",
"field",
"=",
"schema",
".",
"fields",
"[",
"field_name",
"]... | NOTE -- we set the index name using <table_name>_<name> format since indexes have to have
a globally unique name in postgres
http://www.postgresql.org/docs/9.1/static/sql-createindex.html | [
"NOTE",
"--",
"we",
"set",
"the",
"index",
"name",
"using",
"<table_name",
">",
"_<name",
">",
"format",
"since",
"indexes",
"have",
"to",
"have",
"a",
"globally",
"unique",
"name",
"in",
"postgres"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/postgres.py#L292-L314 |
IdentityPython/oidcendpoint | src/oidcendpoint/oidc/token.py | AccessToken.client_authentication | def client_authentication(self, request, auth=None, **kwargs):
"""
Deal with client authentication
:param request: The refresh access token request
:param auth: Client authentication information
:param kwargs: Extra keyword arguments
:return: dictionary containing client... | python | def client_authentication(self, request, auth=None, **kwargs):
"""
Deal with client authentication
:param request: The refresh access token request
:param auth: Client authentication information
:param kwargs: Extra keyword arguments
:return: dictionary containing client... | [
"def",
"client_authentication",
"(",
"self",
",",
"request",
",",
"auth",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"auth_info",
"=",
"verify_client",
"(",
"self",
".",
"endpoint_context",
",",
"request",
",",
"auth",
")",
"except",
"Ex... | Deal with client authentication
:param request: The refresh access token request
:param auth: Client authentication information
:param kwargs: Extra keyword arguments
:return: dictionary containing client id, client authentication method
and possibly access token. | [
"Deal",
"with",
"client",
"authentication"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/oidc/token.py#L111-L135 |
IdentityPython/oidcendpoint | src/oidcendpoint/oidc/token.py | AccessToken._post_parse_request | def _post_parse_request(self, request, client_id='', **kwargs):
"""
This is where clients come to get their access tokens
:param request: The request
:param authn: Authentication info, comes from HTTP header
:returns:
"""
if 'state' in request:
try:
... | python | def _post_parse_request(self, request, client_id='', **kwargs):
"""
This is where clients come to get their access tokens
:param request: The request
:param authn: Authentication info, comes from HTTP header
:returns:
"""
if 'state' in request:
try:
... | [
"def",
"_post_parse_request",
"(",
"self",
",",
"request",
",",
"client_id",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'state'",
"in",
"request",
":",
"try",
":",
"sinfo",
"=",
"self",
".",
"endpoint_context",
".",
"sdb",
"[",
"request",
"["... | This is where clients come to get their access tokens
:param request: The request
:param authn: Authentication info, comes from HTTP header
:returns: | [
"This",
"is",
"where",
"clients",
"come",
"to",
"get",
"their",
"access",
"tokens"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/oidc/token.py#L137-L164 |
BreakingBytes/simkit | simkit/core/outputs.py | OutputRegistry.register | def register(self, new_outputs, *args, **kwargs):
"""
Register outputs and metadata.
* ``initial_value`` - used in dynamic calculations
* ``size`` - number of elements per timestep
* ``uncertainty`` - in percent of nominal value
* ``variance`` - dictionary of covariances... | python | def register(self, new_outputs, *args, **kwargs):
"""
Register outputs and metadata.
* ``initial_value`` - used in dynamic calculations
* ``size`` - number of elements per timestep
* ``uncertainty`` - in percent of nominal value
* ``variance`` - dictionary of covariances... | [
"def",
"register",
"(",
"self",
",",
"new_outputs",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"zip",
"(",
"self",
".",
"meta_names",
",",
"args",
")",
")",
"# call super method",
"super",
"(",
"OutputRegistry",
... | Register outputs and metadata.
* ``initial_value`` - used in dynamic calculations
* ``size`` - number of elements per timestep
* ``uncertainty`` - in percent of nominal value
* ``variance`` - dictionary of covariances, diagonal is square of
uncertianties, no units
* ``... | [
"Register",
"outputs",
"and",
"metadata",
"."
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/outputs.py#L31-L52 |
guaix-ucm/pyemir | emirdrp/recipes/image/dither.py | FullDitheredImagesRecipe.initial_classification | def initial_classification(self, obresult, target_is_sky=False):
"""Classify input frames, """
# lists of targets and sky frames
with obresult.frames[0].open() as baseimg:
# Initial checks
has_bpm_ext = 'BPM' in baseimg
self.logger.debug('images have BPM exte... | python | def initial_classification(self, obresult, target_is_sky=False):
"""Classify input frames, """
# lists of targets and sky frames
with obresult.frames[0].open() as baseimg:
# Initial checks
has_bpm_ext = 'BPM' in baseimg
self.logger.debug('images have BPM exte... | [
"def",
"initial_classification",
"(",
"self",
",",
"obresult",
",",
"target_is_sky",
"=",
"False",
")",
":",
"# lists of targets and sky frames",
"with",
"obresult",
".",
"frames",
"[",
"0",
"]",
".",
"open",
"(",
")",
"as",
"baseimg",
":",
"# Initial checks",
... | Classify input frames, | [
"Classify",
"input",
"frames"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/recipes/image/dither.py#L427-L473 |
guaix-ucm/pyemir | emirdrp/instrument/csuconf.py | read_csu_2 | def read_csu_2(barmodel, hdr):
"""Read CSU information and slits from header"""
conf = CSUConf(barmodel)
conf.conf_f = hdr.get('CSUCONFF', 'UNKNOWN')
# Read CSUPOS and set position in model
# The bars
for idx in conf.bars:
key = "CSUP{}".format(idx)
# UNIT of CSUPOS?
# w... | python | def read_csu_2(barmodel, hdr):
"""Read CSU information and slits from header"""
conf = CSUConf(barmodel)
conf.conf_f = hdr.get('CSUCONFF', 'UNKNOWN')
# Read CSUPOS and set position in model
# The bars
for idx in conf.bars:
key = "CSUP{}".format(idx)
# UNIT of CSUPOS?
# w... | [
"def",
"read_csu_2",
"(",
"barmodel",
",",
"hdr",
")",
":",
"conf",
"=",
"CSUConf",
"(",
"barmodel",
")",
"conf",
".",
"conf_f",
"=",
"hdr",
".",
"get",
"(",
"'CSUCONFF'",
",",
"'UNKNOWN'",
")",
"# Read CSUPOS and set position in model",
"# The bars",
"for",
... | Read CSU information and slits from header | [
"Read",
"CSU",
"information",
"and",
"slits",
"from",
"header"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/csuconf.py#L262-L306 |
guaix-ucm/pyemir | emirdrp/instrument/csuconf.py | read_csu_3 | def read_csu_3(barmodel, hdr):
"""Read CSU information and slits from header"""
conf = CSUConf(barmodel)
conf.set_state(hdr)
return conf | python | def read_csu_3(barmodel, hdr):
"""Read CSU information and slits from header"""
conf = CSUConf(barmodel)
conf.set_state(hdr)
return conf | [
"def",
"read_csu_3",
"(",
"barmodel",
",",
"hdr",
")",
":",
"conf",
"=",
"CSUConf",
"(",
"barmodel",
")",
"conf",
".",
"set_state",
"(",
"hdr",
")",
"return",
"conf"
] | Read CSU information and slits from header | [
"Read",
"CSU",
"information",
"and",
"slits",
"from",
"header"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/csuconf.py#L309-L313 |
guaix-ucm/pyemir | emirdrp/instrument/csuconf.py | CSUConf.set_state | def set_state(self, hdr):
"""Read CSU information and slits from header"""
self.conf_f = hdr.get('CSUCONFF', 'UNKNOWN')
# Read CSUPOS and set position in model
# The bars
for idx in self.bars:
key = "CSUP{}".format(idx)
# UNIT is mm
# set CSU... | python | def set_state(self, hdr):
"""Read CSU information and slits from header"""
self.conf_f = hdr.get('CSUCONFF', 'UNKNOWN')
# Read CSUPOS and set position in model
# The bars
for idx in self.bars:
key = "CSUP{}".format(idx)
# UNIT is mm
# set CSU... | [
"def",
"set_state",
"(",
"self",
",",
"hdr",
")",
":",
"self",
".",
"conf_f",
"=",
"hdr",
".",
"get",
"(",
"'CSUCONFF'",
",",
"'UNKNOWN'",
")",
"# Read CSUPOS and set position in model",
"# The bars",
"for",
"idx",
"in",
"self",
".",
"bars",
":",
"key",
"=... | Read CSU information and slits from header | [
"Read",
"CSU",
"information",
"and",
"slits",
"from",
"header"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/csuconf.py#L46-L60 |
guaix-ucm/pyemir | emirdrp/instrument/csuconf.py | CSUConf._update_slits | def _update_slits(self, hdr):
"""Recreate slits"""
# Slits.
# For the moment we will fuse only reference slits
# clean existing slits
self.slits = {}
mm = []
for idx in self.LBARS:
# References from header
try:
slit_t = h... | python | def _update_slits(self, hdr):
"""Recreate slits"""
# Slits.
# For the moment we will fuse only reference slits
# clean existing slits
self.slits = {}
mm = []
for idx in self.LBARS:
# References from header
try:
slit_t = h... | [
"def",
"_update_slits",
"(",
"self",
",",
"hdr",
")",
":",
"# Slits.",
"# For the moment we will fuse only reference slits",
"# clean existing slits",
"self",
".",
"slits",
"=",
"{",
"}",
"mm",
"=",
"[",
"]",
"for",
"idx",
"in",
"self",
".",
"LBARS",
":",
"# R... | Recreate slits | [
"Recreate",
"slits"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/csuconf.py#L62-L104 |
thorgate/tg-utils | tg_utils/managers.py | NotifyPostChangeQuerySet.update_or_create | def update_or_create(self, *args, **kwargs):
""" Only sent when not created, since default implementation will
call `self.create` when creating which triggers our signal
already.
"""
obj, created = super().update_or_create(*args, **kwargs)
if not created:
... | python | def update_or_create(self, *args, **kwargs):
""" Only sent when not created, since default implementation will
call `self.create` when creating which triggers our signal
already.
"""
obj, created = super().update_or_create(*args, **kwargs)
if not created:
... | [
"def",
"update_or_create",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
",",
"created",
"=",
"super",
"(",
")",
".",
"update_or_create",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"created",
":",
"retur... | Only sent when not created, since default implementation will
call `self.create` when creating which triggers our signal
already. | [
"Only",
"sent",
"when",
"not",
"created",
"since",
"default",
"implementation",
"will",
"call",
"self",
".",
"create",
"when",
"creating",
"which",
"triggers",
"our",
"signal",
"already",
"."
] | train | https://github.com/thorgate/tg-utils/blob/81e404e837334b241686d9159cc3eb44de509a88/tg_utils/managers.py#L41-L51 |
Yelp/uwsgi_metrics | uwsgi_metrics/timer.py | Timer.update | def update(self, duration):
"""Add a recorded duration."""
if duration >= 0:
self.histogram.update(duration)
self.meter.mark() | python | def update(self, duration):
"""Add a recorded duration."""
if duration >= 0:
self.histogram.update(duration)
self.meter.mark() | [
"def",
"update",
"(",
"self",
",",
"duration",
")",
":",
"if",
"duration",
">=",
"0",
":",
"self",
".",
"histogram",
".",
"update",
"(",
"duration",
")",
"self",
".",
"meter",
".",
"mark",
"(",
")"
] | Add a recorded duration. | [
"Add",
"a",
"recorded",
"duration",
"."
] | train | https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/timer.py#L44-L48 |
BeyondTheClouds/enoslib | enoslib/infra/enos_vmong5k/provider.py | _build_g5k_conf | def _build_g5k_conf(vmong5k_conf):
"""Build the conf of the g5k provider from the vmong5k conf."""
clusters = [m.cluster for m in vmong5k_conf.machines]
sites = g5k_api_utils.get_clusters_sites(clusters)
site_names = set(sites.values())
if len(site_names) > 1:
raise Exception("Multisite depl... | python | def _build_g5k_conf(vmong5k_conf):
"""Build the conf of the g5k provider from the vmong5k conf."""
clusters = [m.cluster for m in vmong5k_conf.machines]
sites = g5k_api_utils.get_clusters_sites(clusters)
site_names = set(sites.values())
if len(site_names) > 1:
raise Exception("Multisite depl... | [
"def",
"_build_g5k_conf",
"(",
"vmong5k_conf",
")",
":",
"clusters",
"=",
"[",
"m",
".",
"cluster",
"for",
"m",
"in",
"vmong5k_conf",
".",
"machines",
"]",
"sites",
"=",
"g5k_api_utils",
".",
"get_clusters_sites",
"(",
"clusters",
")",
"site_names",
"=",
"se... | Build the conf of the g5k provider from the vmong5k conf. | [
"Build",
"the",
"conf",
"of",
"the",
"g5k",
"provider",
"from",
"the",
"vmong5k",
"conf",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_vmong5k/provider.py#L79-L87 |
BreakingBytes/simkit | simkit/contrib/readers.py | copy_model_instance | def copy_model_instance(obj):
"""
Copy Django model instance as a dictionary excluding automatically created
fields like an auto-generated sequence as a primary key or an auto-created
many-to-one reverse relation.
:param obj: Django model object
:return: copy of model instance as dictionary
... | python | def copy_model_instance(obj):
"""
Copy Django model instance as a dictionary excluding automatically created
fields like an auto-generated sequence as a primary key or an auto-created
many-to-one reverse relation.
:param obj: Django model object
:return: copy of model instance as dictionary
... | [
"def",
"copy_model_instance",
"(",
"obj",
")",
":",
"meta",
"=",
"getattr",
"(",
"obj",
",",
"'_meta'",
")",
"# make pycharm happy",
"# dictionary of model values excluding auto created and related fields",
"return",
"{",
"f",
".",
"name",
":",
"getattr",
"(",
"obj",
... | Copy Django model instance as a dictionary excluding automatically created
fields like an auto-generated sequence as a primary key or an auto-created
many-to-one reverse relation.
:param obj: Django model object
:return: copy of model instance as dictionary | [
"Copy",
"Django",
"model",
"instance",
"as",
"a",
"dictionary",
"excluding",
"automatically",
"created",
"fields",
"like",
"an",
"auto",
"-",
"generated",
"sequence",
"as",
"a",
"primary",
"key",
"or",
"an",
"auto",
"-",
"created",
"many",
"-",
"to",
"-",
... | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/contrib/readers.py#L18-L31 |
BreakingBytes/simkit | simkit/contrib/readers.py | ArgumentReader.load_data | def load_data(self, *args, **kwargs):
"""
Collects positional and keyword arguments into `data` and applies units.
:return: data
"""
# get positional argument names from parameters and apply them to args
# update data with additional kwargs
argpos = {
... | python | def load_data(self, *args, **kwargs):
"""
Collects positional and keyword arguments into `data` and applies units.
:return: data
"""
# get positional argument names from parameters and apply them to args
# update data with additional kwargs
argpos = {
... | [
"def",
"load_data",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# get positional argument names from parameters and apply them to args",
"# update data with additional kwargs",
"argpos",
"=",
"{",
"v",
"[",
"'extras'",
"]",
"[",
"'argpos'",
"]",... | Collects positional and keyword arguments into `data` and applies units.
:return: data | [
"Collects",
"positional",
"and",
"keyword",
"arguments",
"into",
"data",
"and",
"applies",
"units",
"."
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/contrib/readers.py#L60-L75 |
BreakingBytes/simkit | simkit/contrib/readers.py | ArgumentReader.apply_units_to_cache | def apply_units_to_cache(self, data):
"""
Applies units to data when a proxy reader is used. For example if the
data is cached as JSON and retrieved using the
:class:`~simkit.core.data_readers.JSONReader`, then units can be
applied from the original parameter schema.
:pa... | python | def apply_units_to_cache(self, data):
"""
Applies units to data when a proxy reader is used. For example if the
data is cached as JSON and retrieved using the
:class:`~simkit.core.data_readers.JSONReader`, then units can be
applied from the original parameter schema.
:pa... | [
"def",
"apply_units_to_cache",
"(",
"self",
",",
"data",
")",
":",
"# if units key exists then apply",
"for",
"k",
",",
"v",
"in",
"self",
".",
"parameters",
".",
"iteritems",
"(",
")",
":",
"if",
"v",
"and",
"v",
".",
"get",
"(",
"'units'",
")",
":",
... | Applies units to data when a proxy reader is used. For example if the
data is cached as JSON and retrieved using the
:class:`~simkit.core.data_readers.JSONReader`, then units can be
applied from the original parameter schema.
:param data: Data read by proxy reader.
:return: data... | [
"Applies",
"units",
"to",
"data",
"when",
"a",
"proxy",
"reader",
"is",
"used",
".",
"For",
"example",
"if",
"the",
"data",
"is",
"cached",
"as",
"JSON",
"and",
"retrieved",
"using",
"the",
":",
"class",
":",
"~simkit",
".",
"core",
".",
"data_readers",
... | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/contrib/readers.py#L77-L91 |
BreakingBytes/simkit | simkit/contrib/readers.py | DjangoModelReader.load_data | def load_data(self, model_instance, *args, **kwargs):
"""
Apply units to model.
:return: data
"""
model_dict = copy_model_instance(model_instance)
return super(DjangoModelReader, self).load_data(**model_dict) | python | def load_data(self, model_instance, *args, **kwargs):
"""
Apply units to model.
:return: data
"""
model_dict = copy_model_instance(model_instance)
return super(DjangoModelReader, self).load_data(**model_dict) | [
"def",
"load_data",
"(",
"self",
",",
"model_instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"model_dict",
"=",
"copy_model_instance",
"(",
"model_instance",
")",
"return",
"super",
"(",
"DjangoModelReader",
",",
"self",
")",
".",
"load_data"... | Apply units to model.
:return: data | [
"Apply",
"units",
"to",
"model",
".",
":",
"return",
":",
"data"
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/contrib/readers.py#L129-L135 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | cached | def cached(f):
"""Decorator for caching/retrieving api calls request.
Many calls to the API are getter on static parts (e.g site of a given
cluster name won't change). By caching some responses we can avoid
hammering the API server.
"""
@functools.wraps(f)
def wrapped(*args, **kwargs):
... | python | def cached(f):
"""Decorator for caching/retrieving api calls request.
Many calls to the API are getter on static parts (e.g site of a given
cluster name won't change). By caching some responses we can avoid
hammering the API server.
"""
@functools.wraps(f)
def wrapped(*args, **kwargs):
... | [
"def",
"cached",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"_cache_lock",
":",
"identifier",
"=",
"(",
"f",
".",
"__name__",
",",
"args",
",",... | Decorator for caching/retrieving api calls request.
Many calls to the API are getter on static parts (e.g site of a given
cluster name won't change). By caching some responses we can avoid
hammering the API server. | [
"Decorator",
"for",
"caching",
"/",
"retrieving",
"api",
"calls",
"request",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L35-L55 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | get_api_client | def get_api_client():
"""Gets the reference to the API cient (singleton)."""
with _api_lock:
global _api_client
if not _api_client:
conf_file = os.path.join(os.environ.get("HOME"),
".python-grid5000.yaml")
_api_client = Client.from_yam... | python | def get_api_client():
"""Gets the reference to the API cient (singleton)."""
with _api_lock:
global _api_client
if not _api_client:
conf_file = os.path.join(os.environ.get("HOME"),
".python-grid5000.yaml")
_api_client = Client.from_yam... | [
"def",
"get_api_client",
"(",
")",
":",
"with",
"_api_lock",
":",
"global",
"_api_client",
"if",
"not",
"_api_client",
":",
"conf_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"\"HOME\"",
")",
",",
"\".python-gri... | Gets the reference to the API cient (singleton). | [
"Gets",
"the",
"reference",
"to",
"the",
"API",
"cient",
"(",
"singleton",
")",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L78-L87 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | grid_reload_from_name | def grid_reload_from_name(job_name):
"""Reload all running or pending jobs of Grid'5000 with a given name.
By default all the sites will be searched for jobs with the name
``job_name``. Using EnOSlib there can be only one job per site with name
``job_name``.
Note that it honors the ``exluded_sites... | python | def grid_reload_from_name(job_name):
"""Reload all running or pending jobs of Grid'5000 with a given name.
By default all the sites will be searched for jobs with the name
``job_name``. Using EnOSlib there can be only one job per site with name
``job_name``.
Note that it honors the ``exluded_sites... | [
"def",
"grid_reload_from_name",
"(",
"job_name",
")",
":",
"gk",
"=",
"get_api_client",
"(",
")",
"sites",
"=",
"get_all_sites_obj",
"(",
")",
"jobs",
"=",
"[",
"]",
"for",
"site",
"in",
"[",
"s",
"for",
"s",
"in",
"sites",
"if",
"s",
".",
"uid",
"no... | Reload all running or pending jobs of Grid'5000 with a given name.
By default all the sites will be searched for jobs with the name
``job_name``. Using EnOSlib there can be only one job per site with name
``job_name``.
Note that it honors the ``exluded_sites`` attribute of the client so the
scan c... | [
"Reload",
"all",
"running",
"or",
"pending",
"jobs",
"of",
"Grid",
"5000",
"with",
"a",
"given",
"name",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L96-L129 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | grid_reload_from_ids | def grid_reload_from_ids(oargrid_jobids):
"""Reload all running or pending jobs of Grid'5000 from their ids
Args:
oargrid_jobids (list): list of ``(site, oar_jobid)`` identifying the
jobs on each site
Returns:
The list of python-grid5000 jobs retrieved
"""
gk = get_api_... | python | def grid_reload_from_ids(oargrid_jobids):
"""Reload all running or pending jobs of Grid'5000 from their ids
Args:
oargrid_jobids (list): list of ``(site, oar_jobid)`` identifying the
jobs on each site
Returns:
The list of python-grid5000 jobs retrieved
"""
gk = get_api_... | [
"def",
"grid_reload_from_ids",
"(",
"oargrid_jobids",
")",
":",
"gk",
"=",
"get_api_client",
"(",
")",
"jobs",
"=",
"[",
"]",
"for",
"site",
",",
"job_id",
"in",
"oargrid_jobids",
":",
"jobs",
".",
"append",
"(",
"gk",
".",
"sites",
"[",
"site",
"]",
"... | Reload all running or pending jobs of Grid'5000 from their ids
Args:
oargrid_jobids (list): list of ``(site, oar_jobid)`` identifying the
jobs on each site
Returns:
The list of python-grid5000 jobs retrieved | [
"Reload",
"all",
"running",
"or",
"pending",
"jobs",
"of",
"Grid",
"5000",
"from",
"their",
"ids"
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L132-L146 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | grid_destroy_from_name | def grid_destroy_from_name(job_name):
"""Destroy all the jobs with a given name.
Args:
job_name (str): the job name
"""
jobs = grid_reload_from_name(job_name)
for job in jobs:
job.delete()
logger.info("Killing the job (%s, %s)" % (job.site, job.uid)) | python | def grid_destroy_from_name(job_name):
"""Destroy all the jobs with a given name.
Args:
job_name (str): the job name
"""
jobs = grid_reload_from_name(job_name)
for job in jobs:
job.delete()
logger.info("Killing the job (%s, %s)" % (job.site, job.uid)) | [
"def",
"grid_destroy_from_name",
"(",
"job_name",
")",
":",
"jobs",
"=",
"grid_reload_from_name",
"(",
"job_name",
")",
"for",
"job",
"in",
"jobs",
":",
"job",
".",
"delete",
"(",
")",
"logger",
".",
"info",
"(",
"\"Killing the job (%s, %s)\"",
"%",
"(",
"jo... | Destroy all the jobs with a given name.
Args:
job_name (str): the job name | [
"Destroy",
"all",
"the",
"jobs",
"with",
"a",
"given",
"name",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L149-L158 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | grid_destroy_from_ids | def grid_destroy_from_ids(oargrid_jobids):
"""Destroy all the jobs with corresponding ids
Args:
oargrid_jobids (list): the ``(site, oar_job_id)`` list of tuple
identifying the jobs for each site. """
jobs = grid_reload_from_ids(oargrid_jobids)
for job in jobs:
job.delete()
... | python | def grid_destroy_from_ids(oargrid_jobids):
"""Destroy all the jobs with corresponding ids
Args:
oargrid_jobids (list): the ``(site, oar_job_id)`` list of tuple
identifying the jobs for each site. """
jobs = grid_reload_from_ids(oargrid_jobids)
for job in jobs:
job.delete()
... | [
"def",
"grid_destroy_from_ids",
"(",
"oargrid_jobids",
")",
":",
"jobs",
"=",
"grid_reload_from_ids",
"(",
"oargrid_jobids",
")",
"for",
"job",
"in",
"jobs",
":",
"job",
".",
"delete",
"(",
")",
"logger",
".",
"info",
"(",
"\"Killing the jobs %s\"",
"%",
"oarg... | Destroy all the jobs with corresponding ids
Args:
oargrid_jobids (list): the ``(site, oar_job_id)`` list of tuple
identifying the jobs for each site. | [
"Destroy",
"all",
"the",
"jobs",
"with",
"corresponding",
"ids"
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L161-L170 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | submit_jobs | def submit_jobs(job_specs):
"""Submit a job
Args:
job_spec (dict): The job specifiation (see Grid'5000 API reference)
"""
gk = get_api_client()
jobs = []
try:
for site, job_spec in job_specs:
logger.info("Submitting %s on %s" % (job_spec, site))
jobs.appe... | python | def submit_jobs(job_specs):
"""Submit a job
Args:
job_spec (dict): The job specifiation (see Grid'5000 API reference)
"""
gk = get_api_client()
jobs = []
try:
for site, job_spec in job_specs:
logger.info("Submitting %s on %s" % (job_spec, site))
jobs.appe... | [
"def",
"submit_jobs",
"(",
"job_specs",
")",
":",
"gk",
"=",
"get_api_client",
"(",
")",
"jobs",
"=",
"[",
"]",
"try",
":",
"for",
"site",
",",
"job_spec",
"in",
"job_specs",
":",
"logger",
".",
"info",
"(",
"\"Submitting %s on %s\"",
"%",
"(",
"job_spec... | Submit a job
Args:
job_spec (dict): The job specifiation (see Grid'5000 API reference) | [
"Submit",
"a",
"job"
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L173-L192 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | wait_for_jobs | def wait_for_jobs(jobs):
"""Waits for all the jobs to be runnning.
Args:
jobs(list): list of the python-grid5000 jobs to wait for
Raises:
Exception: if one of the job gets in error state.
"""
all_running = False
while not all_running:
all_running = True
time.s... | python | def wait_for_jobs(jobs):
"""Waits for all the jobs to be runnning.
Args:
jobs(list): list of the python-grid5000 jobs to wait for
Raises:
Exception: if one of the job gets in error state.
"""
all_running = False
while not all_running:
all_running = True
time.s... | [
"def",
"wait_for_jobs",
"(",
"jobs",
")",
":",
"all_running",
"=",
"False",
"while",
"not",
"all_running",
":",
"all_running",
"=",
"True",
"time",
".",
"sleep",
"(",
"5",
")",
"for",
"job",
"in",
"jobs",
":",
"job",
".",
"refresh",
"(",
")",
"schedule... | Waits for all the jobs to be runnning.
Args:
jobs(list): list of the python-grid5000 jobs to wait for
Raises:
Exception: if one of the job gets in error state. | [
"Waits",
"for",
"all",
"the",
"jobs",
"to",
"be",
"runnning",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L195-L220 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | grid_deploy | def grid_deploy(site, nodes, options):
"""Deploy and wait for the deployment to be finished.
Args:
site(str): the site
nodes(list): list of nodes (str) to depoy
options(dict): option of the deployment (refer to the Grid'5000 API
Specifications)
Returns:
tuple of... | python | def grid_deploy(site, nodes, options):
"""Deploy and wait for the deployment to be finished.
Args:
site(str): the site
nodes(list): list of nodes (str) to depoy
options(dict): option of the deployment (refer to the Grid'5000 API
Specifications)
Returns:
tuple of... | [
"def",
"grid_deploy",
"(",
"site",
",",
"nodes",
",",
"options",
")",
":",
"gk",
"=",
"get_api_client",
"(",
")",
"environment",
"=",
"options",
".",
"pop",
"(",
"\"env_name\"",
")",
"options",
".",
"update",
"(",
"environment",
"=",
"environment",
")",
... | Deploy and wait for the deployment to be finished.
Args:
site(str): the site
nodes(list): list of nodes (str) to depoy
options(dict): option of the deployment (refer to the Grid'5000 API
Specifications)
Returns:
tuple of deployed(list), undeployed(list) nodes. | [
"Deploy",
"and",
"wait",
"for",
"the",
"deployment",
"to",
"be",
"finished",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L223-L257 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | set_nodes_vlan | def set_nodes_vlan(site, nodes, interface, vlan_id):
"""Set the interface of the nodes in a specific vlan.
It is assumed that the same interface name is available on the node.
Args:
site(str): site to consider
nodes(list): nodes to consider
interface(str): the network interface to ... | python | def set_nodes_vlan(site, nodes, interface, vlan_id):
"""Set the interface of the nodes in a specific vlan.
It is assumed that the same interface name is available on the node.
Args:
site(str): site to consider
nodes(list): nodes to consider
interface(str): the network interface to ... | [
"def",
"set_nodes_vlan",
"(",
"site",
",",
"nodes",
",",
"interface",
",",
"vlan_id",
")",
":",
"def",
"_to_network_address",
"(",
"host",
")",
":",
"\"\"\"Translate a host to a network address\n e.g:\n paranoia-20.rennes.grid5000.fr -> paranoia-20-eth2.rennes.grid5... | Set the interface of the nodes in a specific vlan.
It is assumed that the same interface name is available on the node.
Args:
site(str): site to consider
nodes(list): nodes to consider
interface(str): the network interface to put in the vlan
vlan_id(str): the id of the vlan | [
"Set",
"the",
"interface",
"of",
"the",
"nodes",
"in",
"a",
"specific",
"vlan",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L260-L282 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | clusters_sites_obj | def clusters_sites_obj(clusters):
"""Get all the corresponding sites of the passed clusters.
Args:
clusters(list): list of string uid of sites (e.g 'rennes')
Return:
dict corresponding to the mapping cluster uid to python-grid5000 site
"""
result = {}
all_clusters = get_all_clu... | python | def clusters_sites_obj(clusters):
"""Get all the corresponding sites of the passed clusters.
Args:
clusters(list): list of string uid of sites (e.g 'rennes')
Return:
dict corresponding to the mapping cluster uid to python-grid5000 site
"""
result = {}
all_clusters = get_all_clu... | [
"def",
"clusters_sites_obj",
"(",
"clusters",
")",
":",
"result",
"=",
"{",
"}",
"all_clusters",
"=",
"get_all_clusters_sites",
"(",
")",
"clusters_sites",
"=",
"{",
"c",
":",
"s",
"for",
"(",
"c",
",",
"s",
")",
"in",
"all_clusters",
".",
"items",
"(",
... | Get all the corresponding sites of the passed clusters.
Args:
clusters(list): list of string uid of sites (e.g 'rennes')
Return:
dict corresponding to the mapping cluster uid to python-grid5000 site | [
"Get",
"all",
"the",
"corresponding",
"sites",
"of",
"the",
"passed",
"clusters",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L309-L326 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | get_all_clusters_sites | def get_all_clusters_sites():
"""Get all the cluster of all the sites.
Returns:
dict corresponding to the mapping cluster uid to python-grid5000 site
"""
result = {}
gk = get_api_client()
sites = gk.sites.list()
for site in sites:
clusters = site.clusters.list()
resu... | python | def get_all_clusters_sites():
"""Get all the cluster of all the sites.
Returns:
dict corresponding to the mapping cluster uid to python-grid5000 site
"""
result = {}
gk = get_api_client()
sites = gk.sites.list()
for site in sites:
clusters = site.clusters.list()
resu... | [
"def",
"get_all_clusters_sites",
"(",
")",
":",
"result",
"=",
"{",
"}",
"gk",
"=",
"get_api_client",
"(",
")",
"sites",
"=",
"gk",
".",
"sites",
".",
"list",
"(",
")",
"for",
"site",
"in",
"sites",
":",
"clusters",
"=",
"site",
".",
"clusters",
".",... | Get all the cluster of all the sites.
Returns:
dict corresponding to the mapping cluster uid to python-grid5000 site | [
"Get",
"all",
"the",
"cluster",
"of",
"all",
"the",
"sites",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L330-L342 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | get_nodes | def get_nodes(cluster):
"""Get all the nodes of a given cluster.
Args:
cluster(string): uid of the cluster (e.g 'rennes')
"""
gk = get_api_client()
site = get_cluster_site(cluster)
return gk.sites[site].clusters[cluster].nodes.list() | python | def get_nodes(cluster):
"""Get all the nodes of a given cluster.
Args:
cluster(string): uid of the cluster (e.g 'rennes')
"""
gk = get_api_client()
site = get_cluster_site(cluster)
return gk.sites[site].clusters[cluster].nodes.list() | [
"def",
"get_nodes",
"(",
"cluster",
")",
":",
"gk",
"=",
"get_api_client",
"(",
")",
"site",
"=",
"get_cluster_site",
"(",
"cluster",
")",
"return",
"gk",
".",
"sites",
"[",
"site",
"]",
".",
"clusters",
"[",
"cluster",
"]",
".",
"nodes",
".",
"list",
... | Get all the nodes of a given cluster.
Args:
cluster(string): uid of the cluster (e.g 'rennes') | [
"Get",
"all",
"the",
"nodes",
"of",
"a",
"given",
"cluster",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L372-L380 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | get_cluster_interfaces | def get_cluster_interfaces(cluster, extra_cond=lambda nic: True):
"""Get the network interfaces names corresponding to a criteria.
Note that the cluster is passed (not the individual node names), thus it is
assumed that all nodes in a cluster have the same interface names same
configuration. In additio... | python | def get_cluster_interfaces(cluster, extra_cond=lambda nic: True):
"""Get the network interfaces names corresponding to a criteria.
Note that the cluster is passed (not the individual node names), thus it is
assumed that all nodes in a cluster have the same interface names same
configuration. In additio... | [
"def",
"get_cluster_interfaces",
"(",
"cluster",
",",
"extra_cond",
"=",
"lambda",
"nic",
":",
"True",
")",
":",
"nics",
"=",
"get_nics",
"(",
"cluster",
")",
"# NOTE(msimonin): Since 05/18 nics on g5k nodes have predictable names but",
"# the api description keep the legacy ... | Get the network interfaces names corresponding to a criteria.
Note that the cluster is passed (not the individual node names), thus it is
assumed that all nodes in a cluster have the same interface names same
configuration. In addition to ``extra_cond``, only the mountable and
Ehernet interfaces are re... | [
"Get",
"the",
"network",
"interfaces",
"names",
"corresponding",
"to",
"a",
"criteria",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L397-L423 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | get_clusters_interfaces | def get_clusters_interfaces(clusters, extra_cond=lambda nic: True):
""" Returns for each cluster the available cluster interfaces
Args:
clusters (str): list of the clusters
extra_cond (lambda): extra predicate to filter network card retrieved
from the API. E.g lambda nic: not nic['mounted']... | python | def get_clusters_interfaces(clusters, extra_cond=lambda nic: True):
""" Returns for each cluster the available cluster interfaces
Args:
clusters (str): list of the clusters
extra_cond (lambda): extra predicate to filter network card retrieved
from the API. E.g lambda nic: not nic['mounted']... | [
"def",
"get_clusters_interfaces",
"(",
"clusters",
",",
"extra_cond",
"=",
"lambda",
"nic",
":",
"True",
")",
":",
"interfaces",
"=",
"{",
"}",
"for",
"cluster",
"in",
"clusters",
":",
"nics",
"=",
"get_cluster_interfaces",
"(",
"cluster",
",",
"extra_cond",
... | Returns for each cluster the available cluster interfaces
Args:
clusters (str): list of the clusters
extra_cond (lambda): extra predicate to filter network card retrieved
from the API. E.g lambda nic: not nic['mounted'] will retrieve all the
usable network cards that are not mounted by defa... | [
"Returns",
"for",
"each",
"cluster",
"the",
"available",
"cluster",
"interfaces"
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L426-L452 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | can_start_on_cluster | def can_start_on_cluster(nodes_status,
nodes,
start,
walltime):
"""Check if #nodes can be started on a given cluster.
This is intended to give a good enough approximation.
This can be use to prefiltered possible reservation dates be... | python | def can_start_on_cluster(nodes_status,
nodes,
start,
walltime):
"""Check if #nodes can be started on a given cluster.
This is intended to give a good enough approximation.
This can be use to prefiltered possible reservation dates be... | [
"def",
"can_start_on_cluster",
"(",
"nodes_status",
",",
"nodes",
",",
"start",
",",
"walltime",
")",
":",
"candidates",
"=",
"[",
"]",
"for",
"node",
",",
"status",
"in",
"nodes_status",
".",
"items",
"(",
")",
":",
"reservations",
"=",
"status",
".",
"... | Check if #nodes can be started on a given cluster.
This is intended to give a good enough approximation.
This can be use to prefiltered possible reservation dates before submitting
them on oar. | [
"Check",
"if",
"#nodes",
"can",
"be",
"started",
"on",
"a",
"given",
"cluster",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L455-L490 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/g5k_api_utils.py | _do_synchronise_jobs | def _do_synchronise_jobs(walltime, machines):
""" This returns a common reservation date for all the jobs.
This reservation date is really only a hint and will be supplied to each
oar server. Without this *common* reservation_date, one oar server can
decide to postpone the start of the job while the ot... | python | def _do_synchronise_jobs(walltime, machines):
""" This returns a common reservation date for all the jobs.
This reservation date is really only a hint and will be supplied to each
oar server. Without this *common* reservation_date, one oar server can
decide to postpone the start of the job while the ot... | [
"def",
"_do_synchronise_jobs",
"(",
"walltime",
",",
"machines",
")",
":",
"offset",
"=",
"SYNCHRONISATION_OFFSET",
"start",
"=",
"time",
".",
"time",
"(",
")",
"+",
"offset",
"_t",
"=",
"time",
".",
"strptime",
"(",
"walltime",
",",
"\"%H:%M:%S\"",
")",
"... | This returns a common reservation date for all the jobs.
This reservation date is really only a hint and will be supplied to each
oar server. Without this *common* reservation_date, one oar server can
decide to postpone the start of the job while the other are already
running. But this doens't prevent ... | [
"This",
"returns",
"a",
"common",
"reservation",
"date",
"for",
"all",
"the",
"jobs",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/g5k_api_utils.py#L493-L543 |
openmicroanalysis/pyxray | pyxray/sql/command.py | chunked | def chunked(iterable, n):
"""Break an iterable into lists of a given length::
>>> list(chunked([1, 2, 3, 4, 5, 6, 7], 3))
[[1, 2, 3], [4, 5, 6], [7]]
If the length of ``iterable`` is not evenly divisible by ``n``, the last
returned list will be shorter.
This is useful for splitting up... | python | def chunked(iterable, n):
"""Break an iterable into lists of a given length::
>>> list(chunked([1, 2, 3, 4, 5, 6, 7], 3))
[[1, 2, 3], [4, 5, 6], [7]]
If the length of ``iterable`` is not evenly divisible by ``n``, the last
returned list will be shorter.
This is useful for splitting up... | [
"def",
"chunked",
"(",
"iterable",
",",
"n",
")",
":",
"return",
"iter",
"(",
"functools",
".",
"partial",
"(",
"take",
",",
"n",
",",
"iter",
"(",
"iterable",
")",
")",
",",
"[",
"]",
")"
] | Break an iterable into lists of a given length::
>>> list(chunked([1, 2, 3, 4, 5, 6, 7], 3))
[[1, 2, 3], [4, 5, 6], [7]]
If the length of ``iterable`` is not evenly divisible by ``n``, the last
returned list will be shorter.
This is useful for splitting up a computation on a large number ... | [
"Break",
"an",
"iterable",
"into",
"lists",
"of",
"a",
"given",
"length",
"::"
] | train | https://github.com/openmicroanalysis/pyxray/blob/cae89677f00ebcc0952f94d1ab70e6b35e1a51e9/pyxray/sql/command.py#L31-L49 |
volafiled/python-volapi | volapi/handler.py | Handler.add_data | def add_data(self, rawdata):
"""Add data to given room's state"""
for data in rawdata:
try:
item = data[0]
if item[0] == 2:
# Flush messages but we got nothing to flush
continue
if item[0] != 0:
... | python | def add_data(self, rawdata):
"""Add data to given room's state"""
for data in rawdata:
try:
item = data[0]
if item[0] == 2:
# Flush messages but we got nothing to flush
continue
if item[0] != 0:
... | [
"def",
"add_data",
"(",
"self",
",",
"rawdata",
")",
":",
"for",
"data",
"in",
"rawdata",
":",
"try",
":",
"item",
"=",
"data",
"[",
"0",
"]",
"if",
"item",
"[",
"0",
"]",
"==",
"2",
":",
"# Flush messages but we got nothing to flush",
"continue",
"if",
... | Add data to given room's state | [
"Add",
"data",
"to",
"given",
"room",
"s",
"state"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L34-L61 |
volafiled/python-volapi | volapi/handler.py | Handler.register_callback | def register_callback(self):
"""Register callback that we will have to wait for"""
cid = str(self.__cid)
self.__cid += 1
event = queue.Queue()
self.__callbacks[cid] = event
return cid, event | python | def register_callback(self):
"""Register callback that we will have to wait for"""
cid = str(self.__cid)
self.__cid += 1
event = queue.Queue()
self.__callbacks[cid] = event
return cid, event | [
"def",
"register_callback",
"(",
"self",
")",
":",
"cid",
"=",
"str",
"(",
"self",
".",
"__cid",
")",
"self",
".",
"__cid",
"+=",
"1",
"event",
"=",
"queue",
".",
"Queue",
"(",
")",
"self",
".",
"__callbacks",
"[",
"cid",
"]",
"=",
"event",
"return... | Register callback that we will have to wait for | [
"Register",
"callback",
"that",
"we",
"will",
"have",
"to",
"wait",
"for"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L63-L70 |
volafiled/python-volapi | volapi/handler.py | Handler._handle_401 | def _handle_401(self, data):
"""Handle Lain being helpful"""
ex = ConnectionError(
"Can't login to a protected room without a proper password", data
)
self.conn.reraise(ex) | python | def _handle_401(self, data):
"""Handle Lain being helpful"""
ex = ConnectionError(
"Can't login to a protected room without a proper password", data
)
self.conn.reraise(ex) | [
"def",
"_handle_401",
"(",
"self",
",",
"data",
")",
":",
"ex",
"=",
"ConnectionError",
"(",
"\"Can't login to a protected room without a proper password\"",
",",
"data",
")",
"self",
".",
"conn",
".",
"reraise",
"(",
"ex",
")"
] | Handle Lain being helpful | [
"Handle",
"Lain",
"being",
"helpful"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L83-L89 |
volafiled/python-volapi | volapi/handler.py | Handler._handle_429 | def _handle_429(self, data):
"""Handle Lain being helpful"""
ex = IOError("Too fast", data)
self.conn.reraise(ex) | python | def _handle_429(self, data):
"""Handle Lain being helpful"""
ex = IOError("Too fast", data)
self.conn.reraise(ex) | [
"def",
"_handle_429",
"(",
"self",
",",
"data",
")",
":",
"ex",
"=",
"IOError",
"(",
"\"Too fast\"",
",",
"data",
")",
"self",
".",
"conn",
".",
"reraise",
"(",
"ex",
")"
] | Handle Lain being helpful | [
"Handle",
"Lain",
"being",
"helpful"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L91-L95 |
volafiled/python-volapi | volapi/handler.py | Handler._handle_callback | def _handle_callback(self, data):
"""Handle lain's callback. Only used with getFileinfo so far"""
cb_id = data.get("id")
args = data.get("args")
event = self.__callbacks.pop(cb_id, None)
if not event:
return
if not args:
event.put(args)
... | python | def _handle_callback(self, data):
"""Handle lain's callback. Only used with getFileinfo so far"""
cb_id = data.get("id")
args = data.get("args")
event = self.__callbacks.pop(cb_id, None)
if not event:
return
if not args:
event.put(args)
... | [
"def",
"_handle_callback",
"(",
"self",
",",
"data",
")",
":",
"cb_id",
"=",
"data",
".",
"get",
"(",
"\"id\"",
")",
"args",
"=",
"data",
".",
"get",
"(",
"\"args\"",
")",
"event",
"=",
"self",
".",
"__callbacks",
".",
"pop",
"(",
"cb_id",
",",
"No... | Handle lain's callback. Only used with getFileinfo so far | [
"Handle",
"lain",
"s",
"callback",
".",
"Only",
"used",
"with",
"getFileinfo",
"so",
"far"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L97-L113 |
volafiled/python-volapi | volapi/handler.py | Handler._handle_userCount | def _handle_userCount(self, data):
"""Handle user count changes"""
self.room.user_count = data
self.conn.enqueue_data("user_count", self.room.user_count) | python | def _handle_userCount(self, data):
"""Handle user count changes"""
self.room.user_count = data
self.conn.enqueue_data("user_count", self.room.user_count) | [
"def",
"_handle_userCount",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"room",
".",
"user_count",
"=",
"data",
"self",
".",
"conn",
".",
"enqueue_data",
"(",
"\"user_count\"",
",",
"self",
".",
"room",
".",
"user_count",
")"
] | Handle user count changes | [
"Handle",
"user",
"count",
"changes"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L115-L119 |
volafiled/python-volapi | volapi/handler.py | Handler._handle_userInfo | def _handle_userInfo(self, data):
"""Handle user information"""
for k, v in data.items():
if k == "nick":
if v == "None":
v = "Volaphile"
setattr(self.room.user, k, v)
self.conn.enqueue_data(k, self.room.user.nick)
... | python | def _handle_userInfo(self, data):
"""Handle user information"""
for k, v in data.items():
if k == "nick":
if v == "None":
v = "Volaphile"
setattr(self.room.user, k, v)
self.conn.enqueue_data(k, self.room.user.nick)
... | [
"def",
"_handle_userInfo",
"(",
"self",
",",
"data",
")",
":",
"for",
"k",
",",
"v",
"in",
"data",
".",
"items",
"(",
")",
":",
"if",
"k",
"==",
"\"nick\"",
":",
"if",
"v",
"==",
"\"None\"",
":",
"v",
"=",
"\"Volaphile\"",
"setattr",
"(",
"self",
... | Handle user information | [
"Handle",
"user",
"information"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L121-L137 |
volafiled/python-volapi | volapi/handler.py | Handler._handle_key | def _handle_key(self, data):
"""Handle keys"""
self.room.key = data
self.conn.enqueue_data("key", self.room.key) | python | def _handle_key(self, data):
"""Handle keys"""
self.room.key = data
self.conn.enqueue_data("key", self.room.key) | [
"def",
"_handle_key",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"room",
".",
"key",
"=",
"data",
"self",
".",
"conn",
".",
"enqueue_data",
"(",
"\"key\"",
",",
"self",
".",
"room",
".",
"key",
")"
] | Handle keys | [
"Handle",
"keys"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L139-L143 |
volafiled/python-volapi | volapi/handler.py | Handler._handle_config | def _handle_config(self, data):
"""Handle initial config push and config changes"""
self.room.config.update(data)
self.conn.enqueue_data("config", data) | python | def _handle_config(self, data):
"""Handle initial config push and config changes"""
self.room.config.update(data)
self.conn.enqueue_data("config", data) | [
"def",
"_handle_config",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"room",
".",
"config",
".",
"update",
"(",
"data",
")",
"self",
".",
"conn",
".",
"enqueue_data",
"(",
"\"config\"",
",",
"data",
")"
] | Handle initial config push and config changes | [
"Handle",
"initial",
"config",
"push",
"and",
"config",
"changes"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L145-L149 |
volafiled/python-volapi | volapi/handler.py | Handler._handle_files | def _handle_files(self, data):
"""Handle new files being uploaded"""
initial = data.get("set", False)
files = data["files"]
for f in files:
try:
fobj = File(
self.room,
self.conn,
f[0],
... | python | def _handle_files(self, data):
"""Handle new files being uploaded"""
initial = data.get("set", False)
files = data["files"]
for f in files:
try:
fobj = File(
self.room,
self.conn,
f[0],
... | [
"def",
"_handle_files",
"(",
"self",
",",
"data",
")",
":",
"initial",
"=",
"data",
".",
"get",
"(",
"\"set\"",
",",
"False",
")",
"files",
"=",
"data",
"[",
"\"files\"",
"]",
"for",
"f",
"in",
"files",
":",
"try",
":",
"fobj",
"=",
"File",
"(",
... | Handle new files being uploaded | [
"Handle",
"new",
"files",
"being",
"uploaded"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L151-L177 |
volafiled/python-volapi | volapi/handler.py | Handler._handle_delete_file | def _handle_delete_file(self, data):
"""Handle files being removed"""
file = self.room.filedict.get(data)
if file:
self.room.filedict = data, None
self.conn.enqueue_data("delete_file", file) | python | def _handle_delete_file(self, data):
"""Handle files being removed"""
file = self.room.filedict.get(data)
if file:
self.room.filedict = data, None
self.conn.enqueue_data("delete_file", file) | [
"def",
"_handle_delete_file",
"(",
"self",
",",
"data",
")",
":",
"file",
"=",
"self",
".",
"room",
".",
"filedict",
".",
"get",
"(",
"data",
")",
"if",
"file",
":",
"self",
".",
"room",
".",
"filedict",
"=",
"data",
",",
"None",
"self",
".",
"conn... | Handle files being removed | [
"Handle",
"files",
"being",
"removed"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L179-L185 |
volafiled/python-volapi | volapi/handler.py | Handler._handle_chat | def _handle_chat(self, data):
"""Handle chat messages"""
self.conn.enqueue_data(
"chat", ChatMessage.from_data(self.room, self.conn, data)
) | python | def _handle_chat(self, data):
"""Handle chat messages"""
self.conn.enqueue_data(
"chat", ChatMessage.from_data(self.room, self.conn, data)
) | [
"def",
"_handle_chat",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"conn",
".",
"enqueue_data",
"(",
"\"chat\"",
",",
"ChatMessage",
".",
"from_data",
"(",
"self",
".",
"room",
",",
"self",
".",
"conn",
",",
"data",
")",
")"
] | Handle chat messages | [
"Handle",
"chat",
"messages"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L187-L192 |
volafiled/python-volapi | volapi/handler.py | Handler._handle_changed_config | def _handle_changed_config(self, change):
"""Handle configuration changes"""
key, value = change.get("key"), change.get("value")
self.room.config.update({key: value})
self.conn.enqueue_data("config", self.room.config) | python | def _handle_changed_config(self, change):
"""Handle configuration changes"""
key, value = change.get("key"), change.get("value")
self.room.config.update({key: value})
self.conn.enqueue_data("config", self.room.config) | [
"def",
"_handle_changed_config",
"(",
"self",
",",
"change",
")",
":",
"key",
",",
"value",
"=",
"change",
".",
"get",
"(",
"\"key\"",
")",
",",
"change",
".",
"get",
"(",
"\"value\"",
")",
"self",
".",
"room",
".",
"config",
".",
"update",
"(",
"{",... | Handle configuration changes | [
"Handle",
"configuration",
"changes"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L194-L199 |
volafiled/python-volapi | volapi/handler.py | Handler._handle_chat_name | def _handle_chat_name(self, data):
"""Handle user name changes"""
self.room.user.nick = data
self.conn.enqueue_data("user", self.room.user) | python | def _handle_chat_name(self, data):
"""Handle user name changes"""
self.room.user.nick = data
self.conn.enqueue_data("user", self.room.user) | [
"def",
"_handle_chat_name",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"room",
".",
"user",
".",
"nick",
"=",
"data",
"self",
".",
"conn",
".",
"enqueue_data",
"(",
"\"user\"",
",",
"self",
".",
"room",
".",
"user",
")"
] | Handle user name changes | [
"Handle",
"user",
"name",
"changes"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L201-L205 |
guaix-ucm/pyemir | emirdrp/processing/wavecal/islitlet_progress.py | islitlet_progress | def islitlet_progress(islitlet, islitlet_max):
"""Auxiliary function to print out progress in loop of slitlets.
Parameters
----------
islitlet : int
Current slitlet number.
islitlet_max : int
Maximum slitlet number.
"""
if islitlet % 10 == 0:
cout = str(islitlet // ... | python | def islitlet_progress(islitlet, islitlet_max):
"""Auxiliary function to print out progress in loop of slitlets.
Parameters
----------
islitlet : int
Current slitlet number.
islitlet_max : int
Maximum slitlet number.
"""
if islitlet % 10 == 0:
cout = str(islitlet // ... | [
"def",
"islitlet_progress",
"(",
"islitlet",
",",
"islitlet_max",
")",
":",
"if",
"islitlet",
"%",
"10",
"==",
"0",
":",
"cout",
"=",
"str",
"(",
"islitlet",
"//",
"10",
")",
"else",
":",
"cout",
"=",
"'.'",
"sys",
".",
"stdout",
".",
"write",
"(",
... | Auxiliary function to print out progress in loop of slitlets.
Parameters
----------
islitlet : int
Current slitlet number.
islitlet_max : int
Maximum slitlet number. | [
"Auxiliary",
"function",
"to",
"print",
"out",
"progress",
"in",
"loop",
"of",
"slitlets",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/wavecal/islitlet_progress.py#L27-L45 |
guaix-ucm/pyemir | emirdrp/core/correctors.py | get_corrector_f | def get_corrector_f(rinput, meta, ins, datamodel):
"""Corrector for intensity flat"""
from emirdrp.processing.flatfield import FlatFieldCorrector
flat_info = meta['master_flat']
with rinput.master_flat.open() as hdul:
_logger.info('loading intensity flat')
_logger.debug('flat info: %s', ... | python | def get_corrector_f(rinput, meta, ins, datamodel):
"""Corrector for intensity flat"""
from emirdrp.processing.flatfield import FlatFieldCorrector
flat_info = meta['master_flat']
with rinput.master_flat.open() as hdul:
_logger.info('loading intensity flat')
_logger.debug('flat info: %s', ... | [
"def",
"get_corrector_f",
"(",
"rinput",
",",
"meta",
",",
"ins",
",",
"datamodel",
")",
":",
"from",
"emirdrp",
".",
"processing",
".",
"flatfield",
"import",
"FlatFieldCorrector",
"flat_info",
"=",
"meta",
"[",
"'master_flat'",
"]",
"with",
"rinput",
".",
... | Corrector for intensity flat | [
"Corrector",
"for",
"intensity",
"flat"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/core/correctors.py#L94-L113 |
guaix-ucm/pyemir | emirdrp/decorators.py | loginfo | def loginfo(method):
"""Log the contents of Recipe Input"""
def loginfo_method(self, rinput):
klass = rinput.__class__
for key in klass.stored():
val = getattr(rinput, key)
if isinstance(val, DataFrame):
self.logger.debug("DataFrame %s", info.gather_in... | python | def loginfo(method):
"""Log the contents of Recipe Input"""
def loginfo_method(self, rinput):
klass = rinput.__class__
for key in klass.stored():
val = getattr(rinput, key)
if isinstance(val, DataFrame):
self.logger.debug("DataFrame %s", info.gather_in... | [
"def",
"loginfo",
"(",
"method",
")",
":",
"def",
"loginfo_method",
"(",
"self",
",",
"rinput",
")",
":",
"klass",
"=",
"rinput",
".",
"__class__",
"for",
"key",
"in",
"klass",
".",
"stored",
"(",
")",
":",
"val",
"=",
"getattr",
"(",
"rinput",
",",
... | Log the contents of Recipe Input | [
"Log",
"the",
"contents",
"of",
"Recipe",
"Input"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/decorators.py#L28-L50 |
BeyondTheClouds/enoslib | enoslib/host.py | Host.to_host | def to_host(self):
"""Copy or coerce to a Host."""
return Host(self.address,
alias=self.alias,
user=self.user,
keyfile=self.keyfile,
port=self.port,
extra=self.extra) | python | def to_host(self):
"""Copy or coerce to a Host."""
return Host(self.address,
alias=self.alias,
user=self.user,
keyfile=self.keyfile,
port=self.port,
extra=self.extra) | [
"def",
"to_host",
"(",
"self",
")",
":",
"return",
"Host",
"(",
"self",
".",
"address",
",",
"alias",
"=",
"self",
".",
"alias",
",",
"user",
"=",
"self",
".",
"user",
",",
"keyfile",
"=",
"self",
".",
"keyfile",
",",
"port",
"=",
"self",
".",
"p... | Copy or coerce to a Host. | [
"Copy",
"or",
"coerce",
"to",
"a",
"Host",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/host.py#L27-L34 |
Jaymon/prom | prom/cli/generate.py | get_table_info | def get_table_info(*table_names):
"""Returns a dict with table_name keys mapped to the Interface that table exists in
:param *table_names: the tables you are searching for
"""
ret = {}
if table_names:
for table_name in table_names:
for name, inter in get_interfaces().items():
... | python | def get_table_info(*table_names):
"""Returns a dict with table_name keys mapped to the Interface that table exists in
:param *table_names: the tables you are searching for
"""
ret = {}
if table_names:
for table_name in table_names:
for name, inter in get_interfaces().items():
... | [
"def",
"get_table_info",
"(",
"*",
"table_names",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"table_names",
":",
"for",
"table_name",
"in",
"table_names",
":",
"for",
"name",
",",
"inter",
"in",
"get_interfaces",
"(",
")",
".",
"items",
"(",
")",
":",
"if",... | Returns a dict with table_name keys mapped to the Interface that table exists in
:param *table_names: the tables you are searching for | [
"Returns",
"a",
"dict",
"with",
"table_name",
"keys",
"mapped",
"to",
"the",
"Interface",
"that",
"table",
"exists",
"in"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/cli/generate.py#L12-L28 |
Jaymon/prom | prom/cli/generate.py | main_generate | def main_generate(table_names, stream):
"""This will print out valid prom python code for given tables that already exist
in a database.
This is really handy when you want to bootstrap an existing database to work
with prom and don't want to manually create Orm objects for the tables you want
to us... | python | def main_generate(table_names, stream):
"""This will print out valid prom python code for given tables that already exist
in a database.
This is really handy when you want to bootstrap an existing database to work
with prom and don't want to manually create Orm objects for the tables you want
to us... | [
"def",
"main_generate",
"(",
"table_names",
",",
"stream",
")",
":",
"with",
"stream",
".",
"open",
"(",
")",
"as",
"fp",
":",
"fp",
".",
"write_line",
"(",
"\"from datetime import datetime, date\"",
")",
"fp",
".",
"write_line",
"(",
"\"from decimal import Deci... | This will print out valid prom python code for given tables that already exist
in a database.
This is really handy when you want to bootstrap an existing database to work
with prom and don't want to manually create Orm objects for the tables you want
to use, let `generate` do it for you | [
"This",
"will",
"print",
"out",
"valid",
"prom",
"python",
"code",
"for",
"given",
"tables",
"that",
"already",
"exist",
"in",
"a",
"database",
"."
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/cli/generate.py#L50-L84 |
guaix-ucm/pyemir | emirdrp/instrument/distortions.py | exvp | def exvp(pos_x, pos_y):
"""Convert virtual pixel to real pixel"""
pos_x = numpy.asarray(pos_x)
pos_y = numpy.asarray(pos_y)
# convert virtual pixel to real pixel
# convert world coordinate to pixel
center = [1024.5, 1024.5]
cf = EMIR_PLATESCALE_RADS
pos_base_x = pos_x - center[0]
po... | python | def exvp(pos_x, pos_y):
"""Convert virtual pixel to real pixel"""
pos_x = numpy.asarray(pos_x)
pos_y = numpy.asarray(pos_y)
# convert virtual pixel to real pixel
# convert world coordinate to pixel
center = [1024.5, 1024.5]
cf = EMIR_PLATESCALE_RADS
pos_base_x = pos_x - center[0]
po... | [
"def",
"exvp",
"(",
"pos_x",
",",
"pos_y",
")",
":",
"pos_x",
"=",
"numpy",
".",
"asarray",
"(",
"pos_x",
")",
"pos_y",
"=",
"numpy",
".",
"asarray",
"(",
"pos_y",
")",
"# convert virtual pixel to real pixel",
"# convert world coordinate to pixel",
"center",
"="... | Convert virtual pixel to real pixel | [
"Convert",
"virtual",
"pixel",
"to",
"real",
"pixel"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/distortions.py#L26-L45 |
IdentityPython/oidcendpoint | src/oidcendpoint/oidc/registration.py | match_sp_sep | def match_sp_sep(first, second):
"""
Verify that all the values in 'first' appear in 'second'.
The values can either be in the form of lists or as space separated
items.
:param first:
:param second:
:return: True/False
"""
if isinstance(first, list):
one = [set(v.split(" "))... | python | def match_sp_sep(first, second):
"""
Verify that all the values in 'first' appear in 'second'.
The values can either be in the form of lists or as space separated
items.
:param first:
:param second:
:return: True/False
"""
if isinstance(first, list):
one = [set(v.split(" "))... | [
"def",
"match_sp_sep",
"(",
"first",
",",
"second",
")",
":",
"if",
"isinstance",
"(",
"first",
",",
"list",
")",
":",
"one",
"=",
"[",
"set",
"(",
"v",
".",
"split",
"(",
"\" \"",
")",
")",
"for",
"v",
"in",
"first",
"]",
"else",
":",
"one",
"... | Verify that all the values in 'first' appear in 'second'.
The values can either be in the form of lists or as space separated
items.
:param first:
:param second:
:return: True/False | [
"Verify",
"that",
"all",
"the",
"values",
"in",
"first",
"appear",
"in",
"second",
".",
"The",
"values",
"can",
"either",
"be",
"in",
"the",
"form",
"of",
"lists",
"or",
"as",
"space",
"separated",
"items",
"."
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/oidc/registration.py#L57-L80 |
IdentityPython/oidcendpoint | src/oidcendpoint/oidc/registration.py | Registration._verify_sector_identifier | def _verify_sector_identifier(self, request):
"""
Verify `sector_identifier_uri` is reachable and that it contains
`redirect_uri`s.
:param request: Provider registration request
:return: si_redirects, sector_id
:raises: InvalidSectorIdentifier
"""
si_url... | python | def _verify_sector_identifier(self, request):
"""
Verify `sector_identifier_uri` is reachable and that it contains
`redirect_uri`s.
:param request: Provider registration request
:return: si_redirects, sector_id
:raises: InvalidSectorIdentifier
"""
si_url... | [
"def",
"_verify_sector_identifier",
"(",
"self",
",",
"request",
")",
":",
"si_url",
"=",
"request",
"[",
"\"sector_identifier_uri\"",
"]",
"try",
":",
"res",
"=",
"self",
".",
"endpoint_context",
".",
"httpc",
".",
"get",
"(",
"si_url",
")",
"except",
"Exce... | Verify `sector_identifier_uri` is reachable and that it contains
`redirect_uri`s.
:param request: Provider registration request
:return: si_redirects, sector_id
:raises: InvalidSectorIdentifier | [
"Verify",
"sector_identifier_uri",
"is",
"reachable",
"and",
"that",
"it",
"contains",
"redirect_uri",
"s",
"."
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/oidc/registration.py#L288-L322 |
guaix-ucm/pyemir | emirdrp/util/sexcatalog.py | SExtractorfile.readline | def readline(self):
"""
Read and analyse the next line of the SExtractor catalog
and return a dictionary {'param1': value, 'param2': value, ...}.
"""
if not(self._firstline):
self._line = self._file.readline()
self._firstline = False
if not(self._lin... | python | def readline(self):
"""
Read and analyse the next line of the SExtractor catalog
and return a dictionary {'param1': value, 'param2': value, ...}.
"""
if not(self._firstline):
self._line = self._file.readline()
self._firstline = False
if not(self._lin... | [
"def",
"readline",
"(",
"self",
")",
":",
"if",
"not",
"(",
"self",
".",
"_firstline",
")",
":",
"self",
".",
"_line",
"=",
"self",
".",
"_file",
".",
"readline",
"(",
")",
"self",
".",
"_firstline",
"=",
"False",
"if",
"not",
"(",
"self",
".",
"... | Read and analyse the next line of the SExtractor catalog
and return a dictionary {'param1': value, 'param2': value, ...}. | [
"Read",
"and",
"analyse",
"the",
"next",
"line",
"of",
"the",
"SExtractor",
"catalog",
"and",
"return",
"a",
"dictionary",
"{",
"param1",
":",
"value",
"param2",
":",
"value",
"...",
"}",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/util/sexcatalog.py#L740-L759 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.