id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
51,600
resync/resync
resync/client.py
Client.write_resource_list
def write_resource_list( self, paths=None, outfile=None, links=None, dump=None): """Write a Resource List or a Resource Dump for files on local disk. Set of resources included is based on paths setting or else the mappings. Optionally links can be added. Output will be to stdout unl...
python
def write_resource_list( self, paths=None, outfile=None, links=None, dump=None): """Write a Resource List or a Resource Dump for files on local disk. Set of resources included is based on paths setting or else the mappings. Optionally links can be added. Output will be to stdout unl...
[ "def", "write_resource_list", "(", "self", ",", "paths", "=", "None", ",", "outfile", "=", "None", ",", "links", "=", "None", ",", "dump", "=", "None", ")", ":", "rl", "=", "self", ".", "build_resource_list", "(", "paths", "=", "paths", ",", "set_path"...
Write a Resource List or a Resource Dump for files on local disk. Set of resources included is based on paths setting or else the mappings. Optionally links can be added. Output will be to stdout unless outfile is specified. If dump is true then a Resource Dump is written instead of a ...
[ "Write", "a", "Resource", "List", "or", "a", "Resource", "Dump", "for", "files", "on", "local", "disk", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L654-L683
51,601
resync/resync
resync/client.py
Client.write_change_list
def write_change_list(self, paths=None, outfile=None, ref_sitemap=None, newref_sitemap=None, empty=None, links=None, dump=None): """Write a change list. Unless the both ref_sitemap and newref_sitemap are specified then the Change List is calculated between the referenc...
python
def write_change_list(self, paths=None, outfile=None, ref_sitemap=None, newref_sitemap=None, empty=None, links=None, dump=None): """Write a change list. Unless the both ref_sitemap and newref_sitemap are specified then the Change List is calculated between the referenc...
[ "def", "write_change_list", "(", "self", ",", "paths", "=", "None", ",", "outfile", "=", "None", ",", "ref_sitemap", "=", "None", ",", "newref_sitemap", "=", "None", ",", "empty", "=", "None", ",", "links", "=", "None", ",", "dump", "=", "None", ")", ...
Write a change list. Unless the both ref_sitemap and newref_sitemap are specified then the Change List is calculated between the reference an the current state of files on disk. The files on disk are scanned based either on the paths setting or else on the mappings.
[ "Write", "a", "change", "list", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L685-L720
51,602
resync/resync
resync/client.py
Client.write_capability_list
def write_capability_list(self, capabilities=None, outfile=None, links=None): """Write a Capability List to outfile or STDOUT.""" capl = CapabilityList(ln=links) capl.pretty_xml = self.pretty_xml if (capabilities is not None): for name in capabil...
python
def write_capability_list(self, capabilities=None, outfile=None, links=None): """Write a Capability List to outfile or STDOUT.""" capl = CapabilityList(ln=links) capl.pretty_xml = self.pretty_xml if (capabilities is not None): for name in capabil...
[ "def", "write_capability_list", "(", "self", ",", "capabilities", "=", "None", ",", "outfile", "=", "None", ",", "links", "=", "None", ")", ":", "capl", "=", "CapabilityList", "(", "ln", "=", "links", ")", "capl", ".", "pretty_xml", "=", "self", ".", "...
Write a Capability List to outfile or STDOUT.
[ "Write", "a", "Capability", "List", "to", "outfile", "or", "STDOUT", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L722-L733
51,603
resync/resync
resync/client.py
Client.write_source_description
def write_source_description( self, capability_lists=None, outfile=None, links=None): """Write a ResourceSync Description document to outfile or STDOUT.""" rsd = SourceDescription(ln=links) rsd.pretty_xml = self.pretty_xml if (capability_lists is not None): for ur...
python
def write_source_description( self, capability_lists=None, outfile=None, links=None): """Write a ResourceSync Description document to outfile or STDOUT.""" rsd = SourceDescription(ln=links) rsd.pretty_xml = self.pretty_xml if (capability_lists is not None): for ur...
[ "def", "write_source_description", "(", "self", ",", "capability_lists", "=", "None", ",", "outfile", "=", "None", ",", "links", "=", "None", ")", ":", "rsd", "=", "SourceDescription", "(", "ln", "=", "links", ")", "rsd", ".", "pretty_xml", "=", "self", ...
Write a ResourceSync Description document to outfile or STDOUT.
[ "Write", "a", "ResourceSync", "Description", "document", "to", "outfile", "or", "STDOUT", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L735-L746
51,604
resync/resync
resync/client.py
Client.read_reference_resource_list
def read_reference_resource_list(self, ref_sitemap, name='reference'): """Read reference resource list and return the ResourceList object. The name parameter is used just in output messages to say what type of resource list is being read. """ rl = ResourceList() self.log...
python
def read_reference_resource_list(self, ref_sitemap, name='reference'): """Read reference resource list and return the ResourceList object. The name parameter is used just in output messages to say what type of resource list is being read. """ rl = ResourceList() self.log...
[ "def", "read_reference_resource_list", "(", "self", ",", "ref_sitemap", ",", "name", "=", "'reference'", ")", ":", "rl", "=", "ResourceList", "(", ")", "self", ".", "logger", ".", "info", "(", "\"Reading %s resource list from %s ...\"", "%", "(", "name", ",", ...
Read reference resource list and return the ResourceList object. The name parameter is used just in output messages to say what type of resource list is being read.
[ "Read", "reference", "resource", "list", "and", "return", "the", "ResourceList", "object", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L755-L787
51,605
resync/resync
resync/client.py
Client.prune_hashes
def prune_hashes(self, hashes, list_type): """Prune any hashes not in source resource or change list.""" discarded = [] for hash in hashes: if (hash in self.hashes): self.hashes.discard(hash) discarded.append(hash) self.logger.info("Not calcula...
python
def prune_hashes(self, hashes, list_type): """Prune any hashes not in source resource or change list.""" discarded = [] for hash in hashes: if (hash in self.hashes): self.hashes.discard(hash) discarded.append(hash) self.logger.info("Not calcula...
[ "def", "prune_hashes", "(", "self", ",", "hashes", ",", "list_type", ")", ":", "discarded", "=", "[", "]", "for", "hash", "in", "hashes", ":", "if", "(", "hash", "in", "self", ".", "hashes", ")", ":", "self", ".", "hashes", ".", "discard", "(", "ha...
Prune any hashes not in source resource or change list.
[ "Prune", "any", "hashes", "not", "in", "source", "resource", "or", "change", "list", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L789-L797
51,606
resync/resync
resync/client.py
Client.log_status
def log_status(self, in_sync=True, incremental=False, audit=False, same=None, created=0, updated=0, deleted=0, to_delete=0): """Write log message regarding status in standard form. Split this off so all messages from baseline/audit/incremental are written in a consistent form...
python
def log_status(self, in_sync=True, incremental=False, audit=False, same=None, created=0, updated=0, deleted=0, to_delete=0): """Write log message regarding status in standard form. Split this off so all messages from baseline/audit/incremental are written in a consistent form...
[ "def", "log_status", "(", "self", ",", "in_sync", "=", "True", ",", "incremental", "=", "False", ",", "audit", "=", "False", ",", "same", "=", "None", ",", "created", "=", "0", ",", "updated", "=", "0", ",", "deleted", "=", "0", ",", "to_delete", "...
Write log message regarding status in standard form. Split this off so all messages from baseline/audit/incremental are written in a consistent form.
[ "Write", "log", "message", "regarding", "status", "in", "standard", "form", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/client.py#L799-L830
51,607
pappasam/latexbuild
latexbuild/jinja2_extension.py
render_latex_template
def render_latex_template(path_templates, template_filename, template_vars=None): '''Render a latex template, filling in its template variables :param path_templates: the path to the template directory :param template_filename: the name, rooted at the path_template_directory, of the desired...
python
def render_latex_template(path_templates, template_filename, template_vars=None): '''Render a latex template, filling in its template variables :param path_templates: the path to the template directory :param template_filename: the name, rooted at the path_template_directory, of the desired...
[ "def", "render_latex_template", "(", "path_templates", ",", "template_filename", ",", "template_vars", "=", "None", ")", ":", "var_dict", "=", "template_vars", "if", "template_vars", "else", "{", "}", "var_dict_escape", "=", "recursive_apply", "(", "var_dict", ",", ...
Render a latex template, filling in its template variables :param path_templates: the path to the template directory :param template_filename: the name, rooted at the path_template_directory, of the desired template for rendering :param template_vars: dictionary of key:val for jinja2 variables ...
[ "Render", "a", "latex", "template", "filling", "in", "its", "template", "variables" ]
596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5
https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/jinja2_extension.py#L33-L49
51,608
neo4j-drivers/neotime
neotime/__init__.py
_normalize_day
def _normalize_day(year, month, day): """ Coerce the day of the month to an internal value that may or may not match the "public" value. With the exception of the last three days of every month, all days are stored as-is. The last three days are instead stored as -1 (the last), -2 (first from last)...
python
def _normalize_day(year, month, day): """ Coerce the day of the month to an internal value that may or may not match the "public" value. With the exception of the last three days of every month, all days are stored as-is. The last three days are instead stored as -1 (the last), -2 (first from last)...
[ "def", "_normalize_day", "(", "year", ",", "month", ",", "day", ")", ":", "if", "year", "<", "MIN_YEAR", "or", "year", ">", "MAX_YEAR", ":", "raise", "ValueError", "(", "\"Year out of range (%d..%d)\"", "%", "(", "MIN_YEAR", ",", "MAX_YEAR", ")", ")", "if"...
Coerce the day of the month to an internal value that may or may not match the "public" value. With the exception of the last three days of every month, all days are stored as-is. The last three days are instead stored as -1 (the last), -2 (first from last) and -3 (second from last). Therefore, fo...
[ "Coerce", "the", "day", "of", "the", "month", "to", "an", "internal", "value", "that", "may", "or", "may", "not", "match", "the", "public", "value", "." ]
9f6c1d782178fee5e27345dbf78ac161b3a95cc7
https://github.com/neo4j-drivers/neotime/blob/9f6c1d782178fee5e27345dbf78ac161b3a95cc7/neotime/__init__.py#L88-L138
51,609
neo4j-drivers/neotime
neotime/__init__.py
Date.from_clock_time
def from_clock_time(cls, clock_time, epoch): """ Convert from a ClockTime relative to a given epoch. """ try: clock_time = ClockTime(*clock_time) except (TypeError, ValueError): raise ValueError("Clock time must be a 2-tuple of (s, ns)") else: ...
python
def from_clock_time(cls, clock_time, epoch): """ Convert from a ClockTime relative to a given epoch. """ try: clock_time = ClockTime(*clock_time) except (TypeError, ValueError): raise ValueError("Clock time must be a 2-tuple of (s, ns)") else: ...
[ "def", "from_clock_time", "(", "cls", ",", "clock_time", ",", "epoch", ")", ":", "try", ":", "clock_time", "=", "ClockTime", "(", "*", "clock_time", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "raise", "ValueError", "(", "\"Clock time must ...
Convert from a ClockTime relative to a given epoch.
[ "Convert", "from", "a", "ClockTime", "relative", "to", "a", "given", "epoch", "." ]
9f6c1d782178fee5e27345dbf78ac161b3a95cc7
https://github.com/neo4j-drivers/neotime/blob/9f6c1d782178fee5e27345dbf78ac161b3a95cc7/neotime/__init__.py#L604-L613
51,610
neo4j-drivers/neotime
neotime/__init__.py
Time.from_native
def from_native(cls, t): """ Convert from a native Python `datetime.time` value. """ second = (1000000 * t.second + t.microsecond) / 1000000 return Time(t.hour, t.minute, second, t.tzinfo)
python
def from_native(cls, t): """ Convert from a native Python `datetime.time` value. """ second = (1000000 * t.second + t.microsecond) / 1000000 return Time(t.hour, t.minute, second, t.tzinfo)
[ "def", "from_native", "(", "cls", ",", "t", ")", ":", "second", "=", "(", "1000000", "*", "t", ".", "second", "+", "t", ".", "microsecond", ")", "/", "1000000", "return", "Time", "(", "t", ".", "hour", ",", "t", ".", "minute", ",", "second", ",",...
Convert from a native Python `datetime.time` value.
[ "Convert", "from", "a", "native", "Python", "datetime", ".", "time", "value", "." ]
9f6c1d782178fee5e27345dbf78ac161b3a95cc7
https://github.com/neo4j-drivers/neotime/blob/9f6c1d782178fee5e27345dbf78ac161b3a95cc7/neotime/__init__.py#L933-L937
51,611
neo4j-drivers/neotime
neotime/__init__.py
Time.from_clock_time
def from_clock_time(cls, clock_time, epoch): """ Convert from a `.ClockTime` relative to a given epoch. """ clock_time = ClockTime(*clock_time) ts = clock_time.seconds % 86400 nanoseconds = int(1000000000 * ts + clock_time.nanoseconds) return Time.from_ticks(epoch.time()....
python
def from_clock_time(cls, clock_time, epoch): """ Convert from a `.ClockTime` relative to a given epoch. """ clock_time = ClockTime(*clock_time) ts = clock_time.seconds % 86400 nanoseconds = int(1000000000 * ts + clock_time.nanoseconds) return Time.from_ticks(epoch.time()....
[ "def", "from_clock_time", "(", "cls", ",", "clock_time", ",", "epoch", ")", ":", "clock_time", "=", "ClockTime", "(", "*", "clock_time", ")", "ts", "=", "clock_time", ".", "seconds", "%", "86400", "nanoseconds", "=", "int", "(", "1000000000", "*", "ts", ...
Convert from a `.ClockTime` relative to a given epoch.
[ "Convert", "from", "a", ".", "ClockTime", "relative", "to", "a", "given", "epoch", "." ]
9f6c1d782178fee5e27345dbf78ac161b3a95cc7
https://github.com/neo4j-drivers/neotime/blob/9f6c1d782178fee5e27345dbf78ac161b3a95cc7/neotime/__init__.py#L940-L946
51,612
neo4j-drivers/neotime
neotime/__init__.py
Time.to_native
def to_native(self): """ Convert to a native Python `datetime.time` value. """ h, m, s = self.hour_minute_second s, ns = nano_divmod(s, 1) ms = int(nano_mul(ns, 1000000)) return time(h, m, s, ms)
python
def to_native(self): """ Convert to a native Python `datetime.time` value. """ h, m, s = self.hour_minute_second s, ns = nano_divmod(s, 1) ms = int(nano_mul(ns, 1000000)) return time(h, m, s, ms)
[ "def", "to_native", "(", "self", ")", ":", "h", ",", "m", ",", "s", "=", "self", ".", "hour_minute_second", "s", ",", "ns", "=", "nano_divmod", "(", "s", ",", "1", ")", "ms", "=", "int", "(", "nano_mul", "(", "ns", ",", "1000000", ")", ")", "re...
Convert to a native Python `datetime.time` value.
[ "Convert", "to", "a", "native", "Python", "datetime", ".", "time", "value", "." ]
9f6c1d782178fee5e27345dbf78ac161b3a95cc7
https://github.com/neo4j-drivers/neotime/blob/9f6c1d782178fee5e27345dbf78ac161b3a95cc7/neotime/__init__.py#L1121-L1127
51,613
inveniosoftware/invenio-oauth2server
invenio_oauth2server/cli.py
process_user
def process_user(ctx, param, value): """Return a user if exists.""" if value: if value.isdigit(): user = User.query.get(str(value)) else: user = User.query.filter(User.email == value).one_or_none() return user
python
def process_user(ctx, param, value): """Return a user if exists.""" if value: if value.isdigit(): user = User.query.get(str(value)) else: user = User.query.filter(User.email == value).one_or_none() return user
[ "def", "process_user", "(", "ctx", ",", "param", ",", "value", ")", ":", "if", "value", ":", "if", "value", ".", "isdigit", "(", ")", ":", "user", "=", "User", ".", "query", ".", "get", "(", "str", "(", "value", ")", ")", "else", ":", "user", "...
Return a user if exists.
[ "Return", "a", "user", "if", "exists", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/cli.py#L32-L39
51,614
inveniosoftware/invenio-oauth2server
invenio_oauth2server/cli.py
tokens_create
def tokens_create(name, user, scopes, internal): """Create a personal OAuth token.""" token = Token.create_personal( name, user.id, scopes=scopes, is_internal=internal) db.session.commit() click.secho(token.access_token, fg='blue')
python
def tokens_create(name, user, scopes, internal): """Create a personal OAuth token.""" token = Token.create_personal( name, user.id, scopes=scopes, is_internal=internal) db.session.commit() click.secho(token.access_token, fg='blue')
[ "def", "tokens_create", "(", "name", ",", "user", ",", "scopes", ",", "internal", ")", ":", "token", "=", "Token", ".", "create_personal", "(", "name", ",", "user", ".", "id", ",", "scopes", "=", "scopes", ",", "is_internal", "=", "internal", ")", "db"...
Create a personal OAuth token.
[ "Create", "a", "personal", "OAuth", "token", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/cli.py#L63-L68
51,615
inveniosoftware/invenio-oauth2server
invenio_oauth2server/cli.py
tokens_delete
def tokens_delete(name=None, user=None, read_access_token=None, force=False): """Delete a personal OAuth token.""" if not (name or user) and not read_access_token: click.get_current_context().fail( 'You have to pass either a "name" and "user" or the "token"') if name and user: cl...
python
def tokens_delete(name=None, user=None, read_access_token=None, force=False): """Delete a personal OAuth token.""" if not (name or user) and not read_access_token: click.get_current_context().fail( 'You have to pass either a "name" and "user" or the "token"') if name and user: cl...
[ "def", "tokens_delete", "(", "name", "=", "None", ",", "user", "=", "None", ",", "read_access_token", "=", "None", ",", "force", "=", "False", ")", ":", "if", "not", "(", "name", "or", "user", ")", "and", "not", "read_access_token", ":", "click", ".", ...
Delete a personal OAuth token.
[ "Delete", "a", "personal", "OAuth", "token", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/cli.py#L77-L100
51,616
davidrpugh/pyCollocation
pycollocation/solvers/solutions.py
Solution.normalize_residuals
def normalize_residuals(self, points): """Normalize residuals by the level of the variable.""" residuals = self.evaluate_residual(points) solutions = self.evaluate_solution(points) return [resid / soln for resid, soln in zip(residuals, solutions)]
python
def normalize_residuals(self, points): """Normalize residuals by the level of the variable.""" residuals = self.evaluate_residual(points) solutions = self.evaluate_solution(points) return [resid / soln for resid, soln in zip(residuals, solutions)]
[ "def", "normalize_residuals", "(", "self", ",", "points", ")", ":", "residuals", "=", "self", ".", "evaluate_residual", "(", "points", ")", "solutions", "=", "self", ".", "evaluate_solution", "(", "points", ")", "return", "[", "resid", "/", "soln", "for", ...
Normalize residuals by the level of the variable.
[ "Normalize", "residuals", "by", "the", "level", "of", "the", "variable", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/solvers/solutions.py#L66-L70
51,617
inveniosoftware/invenio-admin
invenio_admin/filters.py
UUIDEqualFilter.apply
def apply(self, query, value, alias): """Convert UUID. :param query: SQLAlchemy query object. :param value: UUID value. :param alias: Alias of the column. :returns: Filtered query matching the UUID value. """ try: value = uuid.UUID(value) ...
python
def apply(self, query, value, alias): """Convert UUID. :param query: SQLAlchemy query object. :param value: UUID value. :param alias: Alias of the column. :returns: Filtered query matching the UUID value. """ try: value = uuid.UUID(value) ...
[ "def", "apply", "(", "self", ",", "query", ",", "value", ",", "alias", ")", ":", "try", ":", "value", "=", "uuid", ".", "UUID", "(", "value", ")", "return", "query", ".", "filter", "(", "self", ".", "column", "==", "value", ")", "except", "ValueErr...
Convert UUID. :param query: SQLAlchemy query object. :param value: UUID value. :param alias: Alias of the column. :returns: Filtered query matching the UUID value.
[ "Convert", "UUID", "." ]
b5ff8f7de66d1d6b67efc9f81ff094eb2428f969
https://github.com/inveniosoftware/invenio-admin/blob/b5ff8f7de66d1d6b67efc9f81ff094eb2428f969/invenio_admin/filters.py#L22-L34
51,618
inveniosoftware/invenio-admin
invenio_admin/filters.py
FilterConverter.conv_uuid
def conv_uuid(self, column, name, **kwargs): """Convert UUID filter.""" return [f(column, name, **kwargs) for f in self.uuid_filters]
python
def conv_uuid(self, column, name, **kwargs): """Convert UUID filter.""" return [f(column, name, **kwargs) for f in self.uuid_filters]
[ "def", "conv_uuid", "(", "self", ",", "column", ",", "name", ",", "*", "*", "kwargs", ")", ":", "return", "[", "f", "(", "column", ",", "name", ",", "*", "*", "kwargs", ")", "for", "f", "in", "self", ".", "uuid_filters", "]" ]
Convert UUID filter.
[ "Convert", "UUID", "filter", "." ]
b5ff8f7de66d1d6b67efc9f81ff094eb2428f969
https://github.com/inveniosoftware/invenio-admin/blob/b5ff8f7de66d1d6b67efc9f81ff094eb2428f969/invenio_admin/filters.py#L43-L45
51,619
inveniosoftware/invenio-admin
invenio_admin/filters.py
FilterConverter.conv_variant
def conv_variant(self, column, name, **kwargs): """Convert variants.""" return self.convert(str(column.type), column, name, **kwargs)
python
def conv_variant(self, column, name, **kwargs): """Convert variants.""" return self.convert(str(column.type), column, name, **kwargs)
[ "def", "conv_variant", "(", "self", ",", "column", ",", "name", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "convert", "(", "str", "(", "column", ".", "type", ")", ",", "column", ",", "name", ",", "*", "*", "kwargs", ")" ]
Convert variants.
[ "Convert", "variants", "." ]
b5ff8f7de66d1d6b67efc9f81ff094eb2428f969
https://github.com/inveniosoftware/invenio-admin/blob/b5ff8f7de66d1d6b67efc9f81ff094eb2428f969/invenio_admin/filters.py#L48-L50
51,620
Kami/python-yubico-client
yubico_client/yubico.py
Yubico.verify
def verify(self, otp, timestamp=False, sl=None, timeout=None, return_response=False): """ Verify a provided OTP. :param otp: OTP to verify. :type otp: ``str`` :param timestamp: True to include request timestamp and session counter in the...
python
def verify(self, otp, timestamp=False, sl=None, timeout=None, return_response=False): """ Verify a provided OTP. :param otp: OTP to verify. :type otp: ``str`` :param timestamp: True to include request timestamp and session counter in the...
[ "def", "verify", "(", "self", ",", "otp", ",", "timestamp", "=", "False", ",", "sl", "=", "None", ",", "timeout", "=", "None", ",", "return_response", "=", "False", ")", ":", "ca_bundle_path", "=", "self", ".", "_get_ca_bundle_path", "(", ")", "otp", "...
Verify a provided OTP. :param otp: OTP to verify. :type otp: ``str`` :param timestamp: True to include request timestamp and session counter in the response. Defaults to False. :type timestamp: ``bool`` :param sl: A value indicating percentage of sync...
[ "Verify", "a", "provided", "OTP", "." ]
3334b2ee1b5b996af3ef6be57a4ea52b8e45e764
https://github.com/Kami/python-yubico-client/blob/3334b2ee1b5b996af3ef6be57a4ea52b8e45e764/yubico_client/yubico.py#L98-L161
51,621
Kami/python-yubico-client
yubico_client/yubico.py
Yubico.verify_multi
def verify_multi(self, otp_list, max_time_window=DEFAULT_MAX_TIME_WINDOW, sl=None, timeout=None): """ Verify a provided list of OTPs. :param max_time_window: Maximum number of seconds which can pass between the first and last OTP generation f...
python
def verify_multi(self, otp_list, max_time_window=DEFAULT_MAX_TIME_WINDOW, sl=None, timeout=None): """ Verify a provided list of OTPs. :param max_time_window: Maximum number of seconds which can pass between the first and last OTP generation f...
[ "def", "verify_multi", "(", "self", ",", "otp_list", ",", "max_time_window", "=", "DEFAULT_MAX_TIME_WINDOW", ",", "sl", "=", "None", ",", "timeout", "=", "None", ")", ":", "# Create the OTP objects", "otps", "=", "[", "]", "for", "otp", "in", "otp_list", ":"...
Verify a provided list of OTPs. :param max_time_window: Maximum number of seconds which can pass between the first and last OTP generation for the OTP to still be considered valid. :type max_time_window: ``int``
[ "Verify", "a", "provided", "list", "of", "OTPs", "." ]
3334b2ee1b5b996af3ef6be57a4ea52b8e45e764
https://github.com/Kami/python-yubico-client/blob/3334b2ee1b5b996af3ef6be57a4ea52b8e45e764/yubico_client/yubico.py#L163-L219
51,622
Kami/python-yubico-client
yubico_client/yubico.py
Yubico.generate_query_string
def generate_query_string(self, otp, nonce, timestamp=False, sl=None, timeout=None): """ Returns a query string which is sent to the validation servers. """ data = [('id', self.client_id), ('otp', otp), ('nonce', nonce)] ...
python
def generate_query_string(self, otp, nonce, timestamp=False, sl=None, timeout=None): """ Returns a query string which is sent to the validation servers. """ data = [('id', self.client_id), ('otp', otp), ('nonce', nonce)] ...
[ "def", "generate_query_string", "(", "self", ",", "otp", ",", "nonce", ",", "timestamp", "=", "False", ",", "sl", "=", "None", ",", "timeout", "=", "None", ")", ":", "data", "=", "[", "(", "'id'", ",", "self", ".", "client_id", ")", ",", "(", "'otp...
Returns a query string which is sent to the validation servers.
[ "Returns", "a", "query", "string", "which", "is", "sent", "to", "the", "validation", "servers", "." ]
3334b2ee1b5b996af3ef6be57a4ea52b8e45e764
https://github.com/Kami/python-yubico-client/blob/3334b2ee1b5b996af3ef6be57a4ea52b8e45e764/yubico_client/yubico.py#L280-L309
51,623
Kami/python-yubico-client
yubico_client/yubico.py
Yubico.parse_parameters_from_response
def parse_parameters_from_response(self, response): """ Returns a response signature and query string generated from the server response. 'h' aka signature argument is stripped from the returned query string. """ lines = response.splitlines() pairs = [line.strip()...
python
def parse_parameters_from_response(self, response): """ Returns a response signature and query string generated from the server response. 'h' aka signature argument is stripped from the returned query string. """ lines = response.splitlines() pairs = [line.strip()...
[ "def", "parse_parameters_from_response", "(", "self", ",", "response", ")", ":", "lines", "=", "response", ".", "splitlines", "(", ")", "pairs", "=", "[", "line", ".", "strip", "(", ")", ".", "split", "(", "'='", ",", "1", ")", "for", "line", "in", "...
Returns a response signature and query string generated from the server response. 'h' aka signature argument is stripped from the returned query string.
[ "Returns", "a", "response", "signature", "and", "query", "string", "generated", "from", "the", "server", "response", ".", "h", "aka", "signature", "argument", "is", "stripped", "from", "the", "returned", "query", "string", "." ]
3334b2ee1b5b996af3ef6be57a4ea52b8e45e764
https://github.com/Kami/python-yubico-client/blob/3334b2ee1b5b996af3ef6be57a4ea52b8e45e764/yubico_client/yubico.py#L327-L340
51,624
Kami/python-yubico-client
yubico_client/yubico.py
Yubico.get_parameters_as_dictionary
def get_parameters_as_dictionary(self, query_string): """ Returns query string parameters as a dictionary. """ pairs = (x.split('=', 1) for x in query_string.split('&')) return dict((k, unquote(v)) for k, v in pairs)
python
def get_parameters_as_dictionary(self, query_string): """ Returns query string parameters as a dictionary. """ pairs = (x.split('=', 1) for x in query_string.split('&')) return dict((k, unquote(v)) for k, v in pairs)
[ "def", "get_parameters_as_dictionary", "(", "self", ",", "query_string", ")", ":", "pairs", "=", "(", "x", ".", "split", "(", "'='", ",", "1", ")", "for", "x", "in", "query_string", ".", "split", "(", "'&'", ")", ")", "return", "dict", "(", "(", "k",...
Returns query string parameters as a dictionary.
[ "Returns", "query", "string", "parameters", "as", "a", "dictionary", "." ]
3334b2ee1b5b996af3ef6be57a4ea52b8e45e764
https://github.com/Kami/python-yubico-client/blob/3334b2ee1b5b996af3ef6be57a4ea52b8e45e764/yubico_client/yubico.py#L342-L345
51,625
Kami/python-yubico-client
yubico_client/yubico.py
Yubico._init_request_urls
def _init_request_urls(self, api_urls): """ Returns a list of the API URLs. """ if not isinstance(api_urls, (str, list, tuple)): raise TypeError('api_urls needs to be string or iterable!') if isinstance(api_urls, str): api_urls = (api_urls,) api_...
python
def _init_request_urls(self, api_urls): """ Returns a list of the API URLs. """ if not isinstance(api_urls, (str, list, tuple)): raise TypeError('api_urls needs to be string or iterable!') if isinstance(api_urls, str): api_urls = (api_urls,) api_...
[ "def", "_init_request_urls", "(", "self", ",", "api_urls", ")", ":", "if", "not", "isinstance", "(", "api_urls", ",", "(", "str", ",", "list", ",", "tuple", ")", ")", ":", "raise", "TypeError", "(", "'api_urls needs to be string or iterable!'", ")", "if", "i...
Returns a list of the API URLs.
[ "Returns", "a", "list", "of", "the", "API", "URLs", "." ]
3334b2ee1b5b996af3ef6be57a4ea52b8e45e764
https://github.com/Kami/python-yubico-client/blob/3334b2ee1b5b996af3ef6be57a4ea52b8e45e764/yubico_client/yubico.py#L347-L365
51,626
Kami/python-yubico-client
yubico_client/yubico.py
Yubico._get_ca_bundle_path
def _get_ca_bundle_path(self): """ Return a path to the CA bundle which is used for verifying the hosts SSL certificate. """ if self.ca_certs_bundle_path: # User provided a custom path return self.ca_certs_bundle_path # Return first bundle which i...
python
def _get_ca_bundle_path(self): """ Return a path to the CA bundle which is used for verifying the hosts SSL certificate. """ if self.ca_certs_bundle_path: # User provided a custom path return self.ca_certs_bundle_path # Return first bundle which i...
[ "def", "_get_ca_bundle_path", "(", "self", ")", ":", "if", "self", ".", "ca_certs_bundle_path", ":", "# User provided a custom path", "return", "self", ".", "ca_certs_bundle_path", "# Return first bundle which is available", "for", "file_path", "in", "COMMON_CA_LOCATIONS", ...
Return a path to the CA bundle which is used for verifying the hosts SSL certificate.
[ "Return", "a", "path", "to", "the", "CA", "bundle", "which", "is", "used", "for", "verifying", "the", "hosts", "SSL", "certificate", "." ]
3334b2ee1b5b996af3ef6be57a4ea52b8e45e764
https://github.com/Kami/python-yubico-client/blob/3334b2ee1b5b996af3ef6be57a4ea52b8e45e764/yubico_client/yubico.py#L367-L381
51,627
pappasam/latexbuild
latexbuild/utils.py
random_str_uuid
def random_str_uuid(string_length): """Returns a random string of length string_length""" if not isinstance(string_length, int) or not 1 <= string_length <= 32: msg = "string_length must be type int where 1 <= string_length <= 32" raise ValueError(msg) random = str(uuid.uuid4()).upper().repl...
python
def random_str_uuid(string_length): """Returns a random string of length string_length""" if not isinstance(string_length, int) or not 1 <= string_length <= 32: msg = "string_length must be type int where 1 <= string_length <= 32" raise ValueError(msg) random = str(uuid.uuid4()).upper().repl...
[ "def", "random_str_uuid", "(", "string_length", ")", ":", "if", "not", "isinstance", "(", "string_length", ",", "int", ")", "or", "not", "1", "<=", "string_length", "<=", "32", ":", "msg", "=", "\"string_length must be type int where 1 <= string_length <= 32\"", "ra...
Returns a random string of length string_length
[ "Returns", "a", "random", "string", "of", "length", "string_length" ]
596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5
https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/utils.py#L6-L12
51,628
pappasam/latexbuild
latexbuild/utils.py
random_name_filepath
def random_name_filepath(path_full, length_random=5): '''Take a filepath, add randome characters to its basename, and return the new filepath :param filename: either a filename or filepath :param length_random: length of random string to be generated ''' path_full_pre_extension, extension = os....
python
def random_name_filepath(path_full, length_random=5): '''Take a filepath, add randome characters to its basename, and return the new filepath :param filename: either a filename or filepath :param length_random: length of random string to be generated ''' path_full_pre_extension, extension = os....
[ "def", "random_name_filepath", "(", "path_full", ",", "length_random", "=", "5", ")", ":", "path_full_pre_extension", ",", "extension", "=", "os", ".", "path", ".", "splitext", "(", "path_full", ")", "random_str", "=", "random_str_uuid", "(", "length_random", ")...
Take a filepath, add randome characters to its basename, and return the new filepath :param filename: either a filename or filepath :param length_random: length of random string to be generated
[ "Take", "a", "filepath", "add", "randome", "characters", "to", "its", "basename", "and", "return", "the", "new", "filepath" ]
596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5
https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/utils.py#L14-L23
51,629
pappasam/latexbuild
latexbuild/utils.py
list_filepathes_with_predicate
def list_filepathes_with_predicate(path_dir, predicate): '''List all filepathes in a directory that begin with predicate :param path_dir: the directory whose top-level contents you wish to list :param predicate: the predicate you want to test the directory's found files against ''' if not o...
python
def list_filepathes_with_predicate(path_dir, predicate): '''List all filepathes in a directory that begin with predicate :param path_dir: the directory whose top-level contents you wish to list :param predicate: the predicate you want to test the directory's found files against ''' if not o...
[ "def", "list_filepathes_with_predicate", "(", "path_dir", ",", "predicate", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "path_dir", ")", ":", "raise", "ValueError", "(", "\"{} is not a directory\"", ".", "format", "(", "path_dir", ")", ")", ...
List all filepathes in a directory that begin with predicate :param path_dir: the directory whose top-level contents you wish to list :param predicate: the predicate you want to test the directory's found files against
[ "List", "all", "filepathes", "in", "a", "directory", "that", "begin", "with", "predicate" ]
596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5
https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/utils.py#L25-L36
51,630
pappasam/latexbuild
latexbuild/utils.py
recursive_apply
def recursive_apply(inval, func): '''Recursively apply a function to all levels of nested iterables :param inval: the object to run the function on :param func: the function that will be run on the inval ''' if isinstance(inval, dict): return {k: recursive_apply(v, func) for k, v in inval.i...
python
def recursive_apply(inval, func): '''Recursively apply a function to all levels of nested iterables :param inval: the object to run the function on :param func: the function that will be run on the inval ''' if isinstance(inval, dict): return {k: recursive_apply(v, func) for k, v in inval.i...
[ "def", "recursive_apply", "(", "inval", ",", "func", ")", ":", "if", "isinstance", "(", "inval", ",", "dict", ")", ":", "return", "{", "k", ":", "recursive_apply", "(", "v", ",", "func", ")", "for", "k", ",", "v", "in", "inval", ".", "items", "(", ...
Recursively apply a function to all levels of nested iterables :param inval: the object to run the function on :param func: the function that will be run on the inval
[ "Recursively", "apply", "a", "function", "to", "all", "levels", "of", "nested", "iterables" ]
596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5
https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/utils.py#L44-L55
51,631
resync/resync
resync/dump.py
Dump.write
def write(self, basename=None, write_separate_manifests=True): """Write one or more dump files to complete this dump. Returns the number of dump/archive files written. """ self.check_files() n = 0 for manifest in self.partition_dumps(): dumpbase = "%s%05d" % ...
python
def write(self, basename=None, write_separate_manifests=True): """Write one or more dump files to complete this dump. Returns the number of dump/archive files written. """ self.check_files() n = 0 for manifest in self.partition_dumps(): dumpbase = "%s%05d" % ...
[ "def", "write", "(", "self", ",", "basename", "=", "None", ",", "write_separate_manifests", "=", "True", ")", ":", "self", ".", "check_files", "(", ")", "n", "=", "0", "for", "manifest", "in", "self", ".", "partition_dumps", "(", ")", ":", "dumpbase", ...
Write one or more dump files to complete this dump. Returns the number of dump/archive files written.
[ "Write", "one", "or", "more", "dump", "files", "to", "complete", "this", "dump", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/dump.py#L35-L57
51,632
resync/resync
resync/dump.py
Dump.write_zip
def write_zip(self, resources=None, dumpfile=None): """Write a ZIP format dump file. Writes a ZIP file containing the resources in the iterable resources along with a manifest file manifest.xml (written first). No checks on the size of files or total size are performed, this is expected...
python
def write_zip(self, resources=None, dumpfile=None): """Write a ZIP format dump file. Writes a ZIP file containing the resources in the iterable resources along with a manifest file manifest.xml (written first). No checks on the size of files or total size are performed, this is expected...
[ "def", "write_zip", "(", "self", ",", "resources", "=", "None", ",", "dumpfile", "=", "None", ")", ":", "compression", "=", "(", "ZIP_DEFLATED", "if", "self", ".", "compress", "else", "ZIP_STORED", ")", "zf", "=", "ZipFile", "(", "dumpfile", ",", "mode",...
Write a ZIP format dump file. Writes a ZIP file containing the resources in the iterable resources along with a manifest file manifest.xml (written first). No checks on the size of files or total size are performed, this is expected to have been done beforehand.
[ "Write", "a", "ZIP", "format", "dump", "file", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/dump.py#L59-L87
51,633
resync/resync
resync/dump.py
Dump.write_warc
def write_warc(self, resources=None, dumpfile=None): """Write a WARC dump file. WARC support is not part of ResourceSync v1.0 (Z39.99 2014) but is left in this library for experimentation. """ # Load library late as we want to be able to run rest of code # without this i...
python
def write_warc(self, resources=None, dumpfile=None): """Write a WARC dump file. WARC support is not part of ResourceSync v1.0 (Z39.99 2014) but is left in this library for experimentation. """ # Load library late as we want to be able to run rest of code # without this i...
[ "def", "write_warc", "(", "self", ",", "resources", "=", "None", ",", "dumpfile", "=", "None", ")", ":", "# Load library late as we want to be able to run rest of code", "# without this installed", "try", ":", "from", "warc", "import", "WARCFile", ",", "WARCHeader", "...
Write a WARC dump file. WARC support is not part of ResourceSync v1.0 (Z39.99 2014) but is left in this library for experimentation.
[ "Write", "a", "WARC", "dump", "file", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/dump.py#L89-L117
51,634
resync/resync
resync/dump.py
Dump.check_files
def check_files(self, set_length=True, check_length=True): """Check all files in self.resources, find longest common prefix. Go though and check all files in self.resources, add up size, and find longest common path that can be used when writing the dump file. Saved in self.path_prefix....
python
def check_files(self, set_length=True, check_length=True): """Check all files in self.resources, find longest common prefix. Go though and check all files in self.resources, add up size, and find longest common path that can be used when writing the dump file. Saved in self.path_prefix....
[ "def", "check_files", "(", "self", ",", "set_length", "=", "True", ",", "check_length", "=", "True", ")", ":", "total_size", "=", "0", "# total size of all files in bytes", "path_prefix", "=", "None", "for", "resource", "in", "self", ".", "resources", ":", "if...
Check all files in self.resources, find longest common prefix. Go though and check all files in self.resources, add up size, and find longest common path that can be used when writing the dump file. Saved in self.path_prefix. Parameters set_length and check_length control control wheth...
[ "Check", "all", "files", "in", "self", ".", "resources", "find", "longest", "common", "prefix", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/dump.py#L119-L162
51,635
resync/resync
resync/dump.py
Dump.partition_dumps
def partition_dumps(self): """Yeild a set of manifest object that parition the dumps. Simply adds resources/files to a manifest until their are either the the correct number of files or the size limit is exceeded, then yields that manifest. """ manifest = self.manifest_c...
python
def partition_dumps(self): """Yeild a set of manifest object that parition the dumps. Simply adds resources/files to a manifest until their are either the the correct number of files or the size limit is exceeded, then yields that manifest. """ manifest = self.manifest_c...
[ "def", "partition_dumps", "(", "self", ")", ":", "manifest", "=", "self", ".", "manifest_class", "(", ")", "manifest_size", "=", "0", "manifest_files", "=", "0", "for", "resource", "in", "self", ".", "resources", ":", "manifest", ".", "add", "(", "resource...
Yeild a set of manifest object that parition the dumps. Simply adds resources/files to a manifest until their are either the the correct number of files or the size limit is exceeded, then yields that manifest.
[ "Yeild", "a", "set", "of", "manifest", "object", "that", "parition", "the", "dumps", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/dump.py#L164-L186
51,636
resync/resync
resync/dump.py
Dump.archive_path
def archive_path(self, real_path): """Return the archive path for file with real_path. Mapping is based on removal of self.path_prefix which is determined by self.check_files(). """ if (not self.path_prefix): return(real_path) else: return(os.path...
python
def archive_path(self, real_path): """Return the archive path for file with real_path. Mapping is based on removal of self.path_prefix which is determined by self.check_files(). """ if (not self.path_prefix): return(real_path) else: return(os.path...
[ "def", "archive_path", "(", "self", ",", "real_path", ")", ":", "if", "(", "not", "self", ".", "path_prefix", ")", ":", "return", "(", "real_path", ")", "else", ":", "return", "(", "os", ".", "path", ".", "relpath", "(", "real_path", ",", "self", "."...
Return the archive path for file with real_path. Mapping is based on removal of self.path_prefix which is determined by self.check_files().
[ "Return", "the", "archive", "path", "for", "file", "with", "real_path", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/dump.py#L188-L197
51,637
mryellow/maze_explorer
mazeexp/engine/mazeexp.py
MazeExplorer.reset
def reset(self): """ Attach a new engine to director """ self.scene = cocos.scene.Scene() self.z = 0 palette = config.settings['view']['palette'] #Player.palette = palette r, g, b = palette['bg'] self.scene.add(cocos.layer.ColorLayer(r, g, b, 255)...
python
def reset(self): """ Attach a new engine to director """ self.scene = cocos.scene.Scene() self.z = 0 palette = config.settings['view']['palette'] #Player.palette = palette r, g, b = palette['bg'] self.scene.add(cocos.layer.ColorLayer(r, g, b, 255)...
[ "def", "reset", "(", "self", ")", ":", "self", ".", "scene", "=", "cocos", ".", "scene", ".", "Scene", "(", ")", "self", ".", "z", "=", "0", "palette", "=", "config", ".", "settings", "[", "'view'", "]", "[", "'palette'", "]", "#Player.palette = pale...
Attach a new engine to director
[ "Attach", "a", "new", "engine", "to", "director" ]
ab8a25ccd05105d2fe57e0213d690cfc07e45827
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/mazeexp.py#L41-L66
51,638
mryellow/maze_explorer
mazeexp/engine/mazeexp.py
MazeExplorer.act
def act(self, action): """ Take one action for one step """ # FIXME: Hack to change in return type action = int(action) assert isinstance(action, int) assert action < self.actions_num, "%r (%s) invalid"%(action, type(action)) # Reset buttons for k...
python
def act(self, action): """ Take one action for one step """ # FIXME: Hack to change in return type action = int(action) assert isinstance(action, int) assert action < self.actions_num, "%r (%s) invalid"%(action, type(action)) # Reset buttons for k...
[ "def", "act", "(", "self", ",", "action", ")", ":", "# FIXME: Hack to change in return type", "action", "=", "int", "(", "action", ")", "assert", "isinstance", "(", "action", ",", "int", ")", "assert", "action", "<", "self", ".", "actions_num", ",", "\"%r (%...
Take one action for one step
[ "Take", "one", "action", "for", "one", "step" ]
ab8a25ccd05105d2fe57e0213d690cfc07e45827
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/mazeexp.py#L68-L94
51,639
mryellow/maze_explorer
mazeexp/engine/mazeexp.py
MazeExplorer.step
def step(self): """ Step the engine one tick """ self.director.window.switch_to() self.director.window.dispatch_events() self.director.window.dispatch_event('on_draw') self.director.window.flip() # Ticking before events caused glitches. pyglet.clo...
python
def step(self): """ Step the engine one tick """ self.director.window.switch_to() self.director.window.dispatch_events() self.director.window.dispatch_event('on_draw') self.director.window.flip() # Ticking before events caused glitches. pyglet.clo...
[ "def", "step", "(", "self", ")", ":", "self", ".", "director", ".", "window", ".", "switch_to", "(", ")", "self", ".", "director", ".", "window", ".", "dispatch_events", "(", ")", "self", ".", "director", ".", "window", ".", "dispatch_event", "(", "'on...
Step the engine one tick
[ "Step", "the", "engine", "one", "tick" ]
ab8a25ccd05105d2fe57e0213d690cfc07e45827
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/mazeexp.py#L96-L106
51,640
pappasam/latexbuild
latexbuild/build.py
LatexBuild.run_latex
def run_latex(self, cmd_wo_infile, path_outfile): '''Main runner for latex build Should compile the object's Latex template using a list of latex shell commands, along with an output file location. Runs the latex shell command until the process's .aux file remains unchanged. :r...
python
def run_latex(self, cmd_wo_infile, path_outfile): '''Main runner for latex build Should compile the object's Latex template using a list of latex shell commands, along with an output file location. Runs the latex shell command until the process's .aux file remains unchanged. :r...
[ "def", "run_latex", "(", "self", ",", "cmd_wo_infile", ",", "path_outfile", ")", ":", "# Generate path variables", "text_template", "=", "self", ".", "get_text_template", "(", ")", "path_template_random", "=", "random_name_filepath", "(", "self", ".", "path_template",...
Main runner for latex build Should compile the object's Latex template using a list of latex shell commands, along with an output file location. Runs the latex shell command until the process's .aux file remains unchanged. :return: STR template text that is ultimately rendered ...
[ "Main", "runner", "for", "latex", "build" ]
596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5
https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/build.py#L57-L120
51,641
mryellow/maze_explorer
mazeexp/engine/collidable.py
Collidable.update_center
def update_center(self, cshape_center): """cshape_center must be eu.Vector2""" assert isinstance(cshape_center, eu.Vector2) self.position = world_to_view(cshape_center) self.cshape.center = cshape_center
python
def update_center(self, cshape_center): """cshape_center must be eu.Vector2""" assert isinstance(cshape_center, eu.Vector2) self.position = world_to_view(cshape_center) self.cshape.center = cshape_center
[ "def", "update_center", "(", "self", ",", "cshape_center", ")", ":", "assert", "isinstance", "(", "cshape_center", ",", "eu", ".", "Vector2", ")", "self", ".", "position", "=", "world_to_view", "(", "cshape_center", ")", "self", ".", "cshape", ".", "center",...
cshape_center must be eu.Vector2
[ "cshape_center", "must", "be", "eu", ".", "Vector2" ]
ab8a25ccd05105d2fe57e0213d690cfc07e45827
https://github.com/mryellow/maze_explorer/blob/ab8a25ccd05105d2fe57e0213d690cfc07e45827/mazeexp/engine/collidable.py#L43-L48
51,642
tailhook/injections
injections/core.py
has
def has(cls): """Class decorator that declares dependencies""" deps = {} for i in dir(cls): if i.startswith('__') and i.endswith('__'): continue val = getattr(cls, i, None) if isinstance(val, Dependency): deps[i] = val if val.name is None: ...
python
def has(cls): """Class decorator that declares dependencies""" deps = {} for i in dir(cls): if i.startswith('__') and i.endswith('__'): continue val = getattr(cls, i, None) if isinstance(val, Dependency): deps[i] = val if val.name is None: ...
[ "def", "has", "(", "cls", ")", ":", "deps", "=", "{", "}", "for", "i", "in", "dir", "(", "cls", ")", ":", "if", "i", ".", "startswith", "(", "'__'", ")", "and", "i", ".", "endswith", "(", "'__'", ")", ":", "continue", "val", "=", "getattr", "...
Class decorator that declares dependencies
[ "Class", "decorator", "that", "declares", "dependencies" ]
564e077ad5445c12952a92fe1f685f8c6a8d2667
https://github.com/tailhook/injections/blob/564e077ad5445c12952a92fe1f685f8c6a8d2667/injections/core.py#L45-L57
51,643
tailhook/injections
injections/core.py
Container.inject
def inject(self, inst, **renames): """Injects dependencies and propagates dependency injector""" if renames: di = self.clone(**renames) else: di = self pro = di._provides inst.__injections_source__ = di deps = getattr(inst, '__injections__', None) ...
python
def inject(self, inst, **renames): """Injects dependencies and propagates dependency injector""" if renames: di = self.clone(**renames) else: di = self pro = di._provides inst.__injections_source__ = di deps = getattr(inst, '__injections__', None) ...
[ "def", "inject", "(", "self", ",", "inst", ",", "*", "*", "renames", ")", ":", "if", "renames", ":", "di", "=", "self", ".", "clone", "(", "*", "*", "renames", ")", "else", ":", "di", "=", "self", "pro", "=", "di", ".", "_provides", "inst", "."...
Injects dependencies and propagates dependency injector
[ "Injects", "dependencies", "and", "propagates", "dependency", "injector" ]
564e077ad5445c12952a92fe1f685f8c6a8d2667
https://github.com/tailhook/injections/blob/564e077ad5445c12952a92fe1f685f8c6a8d2667/injections/core.py#L103-L124
51,644
tailhook/injections
injections/core.py
Container.interconnect_all
def interconnect_all(self): """Propagate dependencies for provided instances""" for dep in topologically_sorted(self._provides): if hasattr(dep, '__injections__') and not hasattr(dep, '__injections_source__'): self.inject(dep)
python
def interconnect_all(self): """Propagate dependencies for provided instances""" for dep in topologically_sorted(self._provides): if hasattr(dep, '__injections__') and not hasattr(dep, '__injections_source__'): self.inject(dep)
[ "def", "interconnect_all", "(", "self", ")", ":", "for", "dep", "in", "topologically_sorted", "(", "self", ".", "_provides", ")", ":", "if", "hasattr", "(", "dep", ",", "'__injections__'", ")", "and", "not", "hasattr", "(", "dep", ",", "'__injections_source_...
Propagate dependencies for provided instances
[ "Propagate", "dependencies", "for", "provided", "instances" ]
564e077ad5445c12952a92fe1f685f8c6a8d2667
https://github.com/tailhook/injections/blob/564e077ad5445c12952a92fe1f685f8c6a8d2667/injections/core.py#L146-L150
51,645
davidrpugh/pyCollocation
pycollocation/basis_functions/polynomials.py
PolynomialBasis._basis_polynomial_factory
def _basis_polynomial_factory(cls, kind): """Return a polynomial given some coefficients.""" valid_kind = cls._validate(kind) basis_polynomial = getattr(np.polynomial, valid_kind) return basis_polynomial
python
def _basis_polynomial_factory(cls, kind): """Return a polynomial given some coefficients.""" valid_kind = cls._validate(kind) basis_polynomial = getattr(np.polynomial, valid_kind) return basis_polynomial
[ "def", "_basis_polynomial_factory", "(", "cls", ",", "kind", ")", ":", "valid_kind", "=", "cls", ".", "_validate", "(", "kind", ")", "basis_polynomial", "=", "getattr", "(", "np", ".", "polynomial", ",", "valid_kind", ")", "return", "basis_polynomial" ]
Return a polynomial given some coefficients.
[ "Return", "a", "polynomial", "given", "some", "coefficients", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/basis_functions/polynomials.py#L23-L27
51,646
davidrpugh/pyCollocation
pycollocation/basis_functions/polynomials.py
PolynomialBasis._validate
def _validate(cls, kind): """Validate the kind argument.""" if kind not in cls._valid_kinds: mesg = "'kind' must be one of {}, {}, {}, or {}." raise ValueError(mesg.format(*cls._valid_kinds)) else: return kind
python
def _validate(cls, kind): """Validate the kind argument.""" if kind not in cls._valid_kinds: mesg = "'kind' must be one of {}, {}, {}, or {}." raise ValueError(mesg.format(*cls._valid_kinds)) else: return kind
[ "def", "_validate", "(", "cls", ",", "kind", ")", ":", "if", "kind", "not", "in", "cls", ".", "_valid_kinds", ":", "mesg", "=", "\"'kind' must be one of {}, {}, {}, or {}.\"", "raise", "ValueError", "(", "mesg", ".", "format", "(", "*", "cls", ".", "_valid_k...
Validate the kind argument.
[ "Validate", "the", "kind", "argument", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/basis_functions/polynomials.py#L30-L36
51,647
davidrpugh/pyCollocation
pycollocation/basis_functions/polynomials.py
PolynomialBasis.derivatives_factory
def derivatives_factory(cls, coef, domain, kind, **kwargs): """ Given some coefficients, return a the derivative of a certain kind of orthogonal polynomial defined over a specific domain. """ basis_polynomial = cls._basis_polynomial_factory(kind) return basis_polynomial(...
python
def derivatives_factory(cls, coef, domain, kind, **kwargs): """ Given some coefficients, return a the derivative of a certain kind of orthogonal polynomial defined over a specific domain. """ basis_polynomial = cls._basis_polynomial_factory(kind) return basis_polynomial(...
[ "def", "derivatives_factory", "(", "cls", ",", "coef", ",", "domain", ",", "kind", ",", "*", "*", "kwargs", ")", ":", "basis_polynomial", "=", "cls", ".", "_basis_polynomial_factory", "(", "kind", ")", "return", "basis_polynomial", "(", "coef", ",", "domain"...
Given some coefficients, return a the derivative of a certain kind of orthogonal polynomial defined over a specific domain.
[ "Given", "some", "coefficients", "return", "a", "the", "derivative", "of", "a", "certain", "kind", "of", "orthogonal", "polynomial", "defined", "over", "a", "specific", "domain", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/basis_functions/polynomials.py#L39-L46
51,648
davidrpugh/pyCollocation
pycollocation/basis_functions/polynomials.py
PolynomialBasis.functions_factory
def functions_factory(cls, coef, domain, kind, **kwargs): """ Given some coefficients, return a certain kind of orthogonal polynomial defined over a specific domain. """ basis_polynomial = cls._basis_polynomial_factory(kind) return basis_polynomial(coef, domain)
python
def functions_factory(cls, coef, domain, kind, **kwargs): """ Given some coefficients, return a certain kind of orthogonal polynomial defined over a specific domain. """ basis_polynomial = cls._basis_polynomial_factory(kind) return basis_polynomial(coef, domain)
[ "def", "functions_factory", "(", "cls", ",", "coef", ",", "domain", ",", "kind", ",", "*", "*", "kwargs", ")", ":", "basis_polynomial", "=", "cls", ".", "_basis_polynomial_factory", "(", "kind", ")", "return", "basis_polynomial", "(", "coef", ",", "domain", ...
Given some coefficients, return a certain kind of orthogonal polynomial defined over a specific domain.
[ "Given", "some", "coefficients", "return", "a", "certain", "kind", "of", "orthogonal", "polynomial", "defined", "over", "a", "specific", "domain", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/basis_functions/polynomials.py#L54-L61
51,649
davidrpugh/pyCollocation
pycollocation/basis_functions/polynomials.py
PolynomialBasis.roots
def roots(cls, degree, domain, kind): """Return optimal collocation nodes for some orthogonal polynomial.""" basis_coefs = cls._basis_monomial_coefs(degree) basis_poly = cls.functions_factory(basis_coefs, domain, kind) return basis_poly.roots()
python
def roots(cls, degree, domain, kind): """Return optimal collocation nodes for some orthogonal polynomial.""" basis_coefs = cls._basis_monomial_coefs(degree) basis_poly = cls.functions_factory(basis_coefs, domain, kind) return basis_poly.roots()
[ "def", "roots", "(", "cls", ",", "degree", ",", "domain", ",", "kind", ")", ":", "basis_coefs", "=", "cls", ".", "_basis_monomial_coefs", "(", "degree", ")", "basis_poly", "=", "cls", ".", "functions_factory", "(", "basis_coefs", ",", "domain", ",", "kind"...
Return optimal collocation nodes for some orthogonal polynomial.
[ "Return", "optimal", "collocation", "nodes", "for", "some", "orthogonal", "polynomial", "." ]
9376f3488a992dc416cfd2a4dbb396d094927569
https://github.com/davidrpugh/pyCollocation/blob/9376f3488a992dc416cfd2a4dbb396d094927569/pycollocation/basis_functions/polynomials.py#L64-L68
51,650
resync/resync
resync/source_description.py
SourceDescription.add_capability_list
def add_capability_list(self, capability_list=None): """Add a capability list. Adds either a CapabiltyList object specified in capability_list or else creates a Resource with the URI given in capability_list and adds that to the Source Description """ if (hasattr(capabil...
python
def add_capability_list(self, capability_list=None): """Add a capability list. Adds either a CapabiltyList object specified in capability_list or else creates a Resource with the URI given in capability_list and adds that to the Source Description """ if (hasattr(capabil...
[ "def", "add_capability_list", "(", "self", ",", "capability_list", "=", "None", ")", ":", "if", "(", "hasattr", "(", "capability_list", ",", "'uri'", ")", ")", ":", "r", "=", "Resource", "(", "uri", "=", "capability_list", ".", "uri", ",", "capability", ...
Add a capability list. Adds either a CapabiltyList object specified in capability_list or else creates a Resource with the URI given in capability_list and adds that to the Source Description
[ "Add", "a", "capability", "list", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/source_description.py#L60-L75
51,651
inveniosoftware/invenio-oauth2server
invenio_oauth2server/ext.py
verify_oauth_token_and_set_current_user
def verify_oauth_token_and_set_current_user(): """Verify OAuth token and set current user on request stack. This function should be used **only** on REST application. .. code-block:: python app.before_request(verify_oauth_token_and_set_current_user) """ for func in oauth2._before_request_...
python
def verify_oauth_token_and_set_current_user(): """Verify OAuth token and set current user on request stack. This function should be used **only** on REST application. .. code-block:: python app.before_request(verify_oauth_token_and_set_current_user) """ for func in oauth2._before_request_...
[ "def", "verify_oauth_token_and_set_current_user", "(", ")", ":", "for", "func", "in", "oauth2", ".", "_before_request_funcs", ":", "func", "(", ")", "if", "not", "hasattr", "(", "request", ",", "'oauth'", ")", "or", "not", "request", ".", "oauth", ":", "scop...
Verify OAuth token and set current user on request stack. This function should be used **only** on REST application. .. code-block:: python app.before_request(verify_oauth_token_and_set_current_user)
[ "Verify", "OAuth", "token", "and", "set", "current", "user", "on", "request", "stack", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/ext.py#L165-L188
51,652
inveniosoftware/invenio-oauth2server
invenio_oauth2server/ext.py
_OAuth2ServerState.scope_choices
def scope_choices(self, exclude_internal=True): """Return list of scope choices. :param exclude_internal: Exclude internal scopes or not. (Default: ``True``) :returns: A list of tuples (id, scope). """ return [ (k, scope) for k, scope in sorted(self.scope...
python
def scope_choices(self, exclude_internal=True): """Return list of scope choices. :param exclude_internal: Exclude internal scopes or not. (Default: ``True``) :returns: A list of tuples (id, scope). """ return [ (k, scope) for k, scope in sorted(self.scope...
[ "def", "scope_choices", "(", "self", ",", "exclude_internal", "=", "True", ")", ":", "return", "[", "(", "k", ",", "scope", ")", "for", "k", ",", "scope", "in", "sorted", "(", "self", ".", "scopes", ".", "items", "(", ")", ")", "if", "not", "exclud...
Return list of scope choices. :param exclude_internal: Exclude internal scopes or not. (Default: ``True``) :returns: A list of tuples (id, scope).
[ "Return", "list", "of", "scope", "choices", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/ext.py#L61-L71
51,653
inveniosoftware/invenio-oauth2server
invenio_oauth2server/ext.py
_OAuth2ServerState.register_scope
def register_scope(self, scope): """Register a scope. :param scope: A :class:`invenio_oauth2server.models.Scope` instance. """ if not isinstance(scope, Scope): raise TypeError("Invalid scope type.") assert scope.id not in self.scopes self.scopes[scope.id] = s...
python
def register_scope(self, scope): """Register a scope. :param scope: A :class:`invenio_oauth2server.models.Scope` instance. """ if not isinstance(scope, Scope): raise TypeError("Invalid scope type.") assert scope.id not in self.scopes self.scopes[scope.id] = s...
[ "def", "register_scope", "(", "self", ",", "scope", ")", ":", "if", "not", "isinstance", "(", "scope", ",", "Scope", ")", ":", "raise", "TypeError", "(", "\"Invalid scope type.\"", ")", "assert", "scope", ".", "id", "not", "in", "self", ".", "scopes", "s...
Register a scope. :param scope: A :class:`invenio_oauth2server.models.Scope` instance.
[ "Register", "a", "scope", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/ext.py#L73-L81
51,654
inveniosoftware/invenio-oauth2server
invenio_oauth2server/ext.py
InvenioOAuth2ServerREST.monkeypatch_oauthlib_urlencode_chars
def monkeypatch_oauthlib_urlencode_chars(chars): """Monkeypatch OAuthlib set of "URL encoded"-safe characters. .. note:: OAuthlib keeps a set of characters that it considers as valid inside an URL-encoded query-string during parsing of requests. The issue is that th...
python
def monkeypatch_oauthlib_urlencode_chars(chars): """Monkeypatch OAuthlib set of "URL encoded"-safe characters. .. note:: OAuthlib keeps a set of characters that it considers as valid inside an URL-encoded query-string during parsing of requests. The issue is that th...
[ "def", "monkeypatch_oauthlib_urlencode_chars", "(", "chars", ")", ":", "modified_chars", "=", "set", "(", "chars", ")", "always_safe", "=", "set", "(", "oauthlib_commmon", ".", "always_safe", ")", "original_special_chars", "=", "oauthlib_commmon", ".", "urlencoded", ...
Monkeypatch OAuthlib set of "URL encoded"-safe characters. .. note:: OAuthlib keeps a set of characters that it considers as valid inside an URL-encoded query-string during parsing of requests. The issue is that this set of characters wasn't designed to be confi...
[ "Monkeypatch", "OAuthlib", "set", "of", "URL", "encoded", "-", "safe", "characters", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/ext.py#L223-L267
51,655
CameronLonsdale/lantern
lantern/fitness/ngram.py
NgramScorer
def NgramScorer(frequency_map): """Compute the score of a text by using the frequencies of ngrams. Example: >>> fitness = NgramScorer(english.unigrams) >>> fitness("ABC") -4.3622319742618245 Args: frequency_map (dict): ngram to frequency mapping """ # Calculate the ...
python
def NgramScorer(frequency_map): """Compute the score of a text by using the frequencies of ngrams. Example: >>> fitness = NgramScorer(english.unigrams) >>> fitness("ABC") -4.3622319742618245 Args: frequency_map (dict): ngram to frequency mapping """ # Calculate the ...
[ "def", "NgramScorer", "(", "frequency_map", ")", ":", "# Calculate the log probability", "length", "=", "len", "(", "next", "(", "iter", "(", "frequency_map", ")", ")", ")", "# TODO: 0.01 is a magic number. Needs to be better than that.", "floor", "=", "math", ".", "l...
Compute the score of a text by using the frequencies of ngrams. Example: >>> fitness = NgramScorer(english.unigrams) >>> fitness("ABC") -4.3622319742618245 Args: frequency_map (dict): ngram to frequency mapping
[ "Compute", "the", "score", "of", "a", "text", "by", "using", "the", "frequencies", "of", "ngrams", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/fitness/ngram.py#L11-L35
51,656
resync/resync
resync/capability_list.py
CapabilityList.add_capability
def add_capability(self, capability=None, uri=None, name=None): """Specific add function for capabilities. Takes either: - a capability object (derived from ListBase) as the first argument from which the capability name is extracted, and the URI if given - or a plain name stri...
python
def add_capability(self, capability=None, uri=None, name=None): """Specific add function for capabilities. Takes either: - a capability object (derived from ListBase) as the first argument from which the capability name is extracted, and the URI if given - or a plain name stri...
[ "def", "add_capability", "(", "self", ",", "capability", "=", "None", ",", "uri", "=", "None", ",", "name", "=", "None", ")", ":", "if", "(", "capability", "is", "not", "None", ")", ":", "name", "=", "capability", ".", "capability_name", "if", "(", "...
Specific add function for capabilities. Takes either: - a capability object (derived from ListBase) as the first argument from which the capability name is extracted, and the URI if given - or a plain name string and - the URI of the capability
[ "Specific", "add", "function", "for", "capabilities", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/capability_list.py#L97-L111
51,657
resync/resync
resync/capability_list.py
CapabilityList.capability_info
def capability_info(self, name=None): """Return information about the requested capability from this list. Will return None if there is no information about the requested capability. """ for r in self.resources: if (r.capability == name): return(r) re...
python
def capability_info(self, name=None): """Return information about the requested capability from this list. Will return None if there is no information about the requested capability. """ for r in self.resources: if (r.capability == name): return(r) re...
[ "def", "capability_info", "(", "self", ",", "name", "=", "None", ")", ":", "for", "r", "in", "self", ".", "resources", ":", "if", "(", "r", ".", "capability", "==", "name", ")", ":", "return", "(", "r", ")", "return", "(", "None", ")" ]
Return information about the requested capability from this list. Will return None if there is no information about the requested capability.
[ "Return", "information", "about", "the", "requested", "capability", "from", "this", "list", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/capability_list.py#L117-L125
51,658
robertpeteuil/multi-cloud-control
mcc/uimode.py
ui_main
def ui_main(fmt_table, node_dict): """Create the base UI in command mode.""" cmd_funct = {"quit": False, "run": node_cmd, "stop": node_cmd, "connect": node_cmd, "details": node_cmd, "update": True} ui_print("\033[?25l") # ...
python
def ui_main(fmt_table, node_dict): """Create the base UI in command mode.""" cmd_funct = {"quit": False, "run": node_cmd, "stop": node_cmd, "connect": node_cmd, "details": node_cmd, "update": True} ui_print("\033[?25l") # ...
[ "def", "ui_main", "(", "fmt_table", ",", "node_dict", ")", ":", "cmd_funct", "=", "{", "\"quit\"", ":", "False", ",", "\"run\"", ":", "node_cmd", ",", "\"stop\"", ":", "node_cmd", ",", "\"connect\"", ":", "node_cmd", ",", "\"details\"", ":", "node_cmd", ",...
Create the base UI in command mode.
[ "Create", "the", "base", "UI", "in", "command", "mode", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/uimode.py#L40-L62
51,659
robertpeteuil/multi-cloud-control
mcc/uimode.py
get_user_cmd
def get_user_cmd(node_dict): """Get main command selection.""" key_lu = {"q": ["quit", True], "r": ["run", True], "s": ["stop", True], "u": ["update", True], "c": ["connect", True], "d": ["details", True]} ui_cmd_bar() cmd_valid = False input_flush() with term.cbreak(...
python
def get_user_cmd(node_dict): """Get main command selection.""" key_lu = {"q": ["quit", True], "r": ["run", True], "s": ["stop", True], "u": ["update", True], "c": ["connect", True], "d": ["details", True]} ui_cmd_bar() cmd_valid = False input_flush() with term.cbreak(...
[ "def", "get_user_cmd", "(", "node_dict", ")", ":", "key_lu", "=", "{", "\"q\"", ":", "[", "\"quit\"", ",", "True", "]", ",", "\"r\"", ":", "[", "\"run\"", ",", "True", "]", ",", "\"s\"", ":", "[", "\"stop\"", ",", "True", "]", ",", "\"u\"", ":", ...
Get main command selection.
[ "Get", "main", "command", "selection", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/uimode.py#L65-L81
51,660
robertpeteuil/multi-cloud-control
mcc/uimode.py
node_cmd
def node_cmd(cmd_name, node_dict): """Process commands that target specific nodes.""" sc = {"run": cmd_startstop, "stop": cmd_startstop, "connect": cmd_connect, "details": cmd_details} node_num = node_selection(cmd_name, len(node_dict)) refresh_main = None if node_num != 0: (node_v...
python
def node_cmd(cmd_name, node_dict): """Process commands that target specific nodes.""" sc = {"run": cmd_startstop, "stop": cmd_startstop, "connect": cmd_connect, "details": cmd_details} node_num = node_selection(cmd_name, len(node_dict)) refresh_main = None if node_num != 0: (node_v...
[ "def", "node_cmd", "(", "cmd_name", ",", "node_dict", ")", ":", "sc", "=", "{", "\"run\"", ":", "cmd_startstop", ",", "\"stop\"", ":", "cmd_startstop", ",", "\"connect\"", ":", "cmd_connect", ",", "\"details\"", ":", "cmd_details", "}", "node_num", "=", "nod...
Process commands that target specific nodes.
[ "Process", "commands", "that", "target", "specific", "nodes", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/uimode.py#L84-L101
51,661
robertpeteuil/multi-cloud-control
mcc/uimode.py
node_selection
def node_selection(cmd_name, node_qty): """Determine Node via alternate input method.""" cmd_disp = cmd_name.upper() cmd_title = ("\r{1}{0} NODE{2} - Enter {3}#{2}" " ({4}0 = Exit Command{2}): ". format(cmd_disp, C_TI, C_NORM, C_WARN, C_HEAD2)) ui_cmd_title(cmd_title) ...
python
def node_selection(cmd_name, node_qty): """Determine Node via alternate input method.""" cmd_disp = cmd_name.upper() cmd_title = ("\r{1}{0} NODE{2} - Enter {3}#{2}" " ({4}0 = Exit Command{2}): ". format(cmd_disp, C_TI, C_NORM, C_WARN, C_HEAD2)) ui_cmd_title(cmd_title) ...
[ "def", "node_selection", "(", "cmd_name", ",", "node_qty", ")", ":", "cmd_disp", "=", "cmd_name", ".", "upper", "(", ")", "cmd_title", "=", "(", "\"\\r{1}{0} NODE{2} - Enter {3}#{2}\"", "\" ({4}0 = Exit Command{2}): \"", ".", "format", "(", "cmd_disp", ",", "C_TI", ...
Determine Node via alternate input method.
[ "Determine", "Node", "via", "alternate", "input", "method", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/uimode.py#L104-L126
51,662
robertpeteuil/multi-cloud-control
mcc/uimode.py
node_validate
def node_validate(node_dict, node_num, cmd_name): """Validate that command can be performed on target node.""" # cmd: [required-state, action-to-displayed, error-statement] req_lu = {"run": ["stopped", "Already Running"], "stop": ["running", "Already Stopped"], "connect": ["runni...
python
def node_validate(node_dict, node_num, cmd_name): """Validate that command can be performed on target node.""" # cmd: [required-state, action-to-displayed, error-statement] req_lu = {"run": ["stopped", "Already Running"], "stop": ["running", "Already Stopped"], "connect": ["runni...
[ "def", "node_validate", "(", "node_dict", ",", "node_num", ",", "cmd_name", ")", ":", "# cmd: [required-state, action-to-displayed, error-statement]", "req_lu", "=", "{", "\"run\"", ":", "[", "\"stopped\"", ",", "\"Already Running\"", "]", ",", "\"stop\"", ":", "[", ...
Validate that command can be performed on target node.
[ "Validate", "that", "command", "can", "be", "performed", "on", "target", "node", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/uimode.py#L129-L143
51,663
robertpeteuil/multi-cloud-control
mcc/uimode.py
cmd_startstop
def cmd_startstop(node, cmd_name, node_info): """Confirm command and execute it.""" cmd_lu = {"run": ["ex_start_node", "wait_until_running", "RUNNING"], "stop": ["ex_stop_node", "", "STOPPING"]} # specific delay & message {provider: {command: [delay, message]}} cld_lu = {"azure": {"stop": ...
python
def cmd_startstop(node, cmd_name, node_info): """Confirm command and execute it.""" cmd_lu = {"run": ["ex_start_node", "wait_until_running", "RUNNING"], "stop": ["ex_stop_node", "", "STOPPING"]} # specific delay & message {provider: {command: [delay, message]}} cld_lu = {"azure": {"stop": ...
[ "def", "cmd_startstop", "(", "node", ",", "cmd_name", ",", "node_info", ")", ":", "cmd_lu", "=", "{", "\"run\"", ":", "[", "\"ex_start_node\"", ",", "\"wait_until_running\"", ",", "\"RUNNING\"", "]", ",", "\"stop\"", ":", "[", "\"ex_stop_node\"", ",", "\"\"", ...
Confirm command and execute it.
[ "Confirm", "command", "and", "execute", "it", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/uimode.py#L146-L182
51,664
robertpeteuil/multi-cloud-control
mcc/uimode.py
cmd_connect
def cmd_connect(node, cmd_name, node_info): """Connect to node.""" # FUTURE: call function to check for custom connection-info conn_info = "Defaults" conf_mess = ("\r{0}{1} TO{2} {3} using {5}{4}{2} - Confirm [y/N]: ". format(C_STAT[cmd_name.upper()], cmd_name.upper(), C_NORM, ...
python
def cmd_connect(node, cmd_name, node_info): """Connect to node.""" # FUTURE: call function to check for custom connection-info conn_info = "Defaults" conf_mess = ("\r{0}{1} TO{2} {3} using {5}{4}{2} - Confirm [y/N]: ". format(C_STAT[cmd_name.upper()], cmd_name.upper(), C_NORM, ...
[ "def", "cmd_connect", "(", "node", ",", "cmd_name", ",", "node_info", ")", ":", "# FUTURE: call function to check for custom connection-info", "conn_info", "=", "\"Defaults\"", "conf_mess", "=", "(", "\"\\r{0}{1} TO{2} {3} using {5}{4}{2} - Confirm [y/N]: \"", ".", "format", ...
Connect to node.
[ "Connect", "to", "node", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/uimode.py#L185-L214
51,665
robertpeteuil/multi-cloud-control
mcc/uimode.py
ssh_get_info
def ssh_get_info(node): """Determine ssh-user and ssh-key for node.""" ssh_key = "" if node.cloud == "aws": raw_key = node.extra['key_name'] ssh_key = "-i {0}{1}.pem ".format(CONFIG_DIR, raw_key) ssh_user = ssh_calc_aws(node) elif node.cloud == "azure": ssh_user = node.ex...
python
def ssh_get_info(node): """Determine ssh-user and ssh-key for node.""" ssh_key = "" if node.cloud == "aws": raw_key = node.extra['key_name'] ssh_key = "-i {0}{1}.pem ".format(CONFIG_DIR, raw_key) ssh_user = ssh_calc_aws(node) elif node.cloud == "azure": ssh_user = node.ex...
[ "def", "ssh_get_info", "(", "node", ")", ":", "ssh_key", "=", "\"\"", "if", "node", ".", "cloud", "==", "\"aws\"", ":", "raw_key", "=", "node", ".", "extra", "[", "'key_name'", "]", "ssh_key", "=", "\"-i {0}{1}.pem \"", ".", "format", "(", "CONFIG_DIR", ...
Determine ssh-user and ssh-key for node.
[ "Determine", "ssh", "-", "user", "and", "ssh", "-", "key", "for", "node", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/uimode.py#L223-L239
51,666
robertpeteuil/multi-cloud-control
mcc/uimode.py
ssh_calc_aws
def ssh_calc_aws(node): """Calculate default ssh-user based on image-if of AWS instance.""" userlu = {"ubunt": "ubuntu", "debia": "admin", "fedor": "root", "cento": "centos", "openb": "root"} image_name = node.driver.get_image(node.extra['image_id']).name if not image_name: image_n...
python
def ssh_calc_aws(node): """Calculate default ssh-user based on image-if of AWS instance.""" userlu = {"ubunt": "ubuntu", "debia": "admin", "fedor": "root", "cento": "centos", "openb": "root"} image_name = node.driver.get_image(node.extra['image_id']).name if not image_name: image_n...
[ "def", "ssh_calc_aws", "(", "node", ")", ":", "userlu", "=", "{", "\"ubunt\"", ":", "\"ubuntu\"", ",", "\"debia\"", ":", "\"admin\"", ",", "\"fedor\"", ":", "\"root\"", ",", "\"cento\"", ":", "\"centos\"", ",", "\"openb\"", ":", "\"root\"", "}", "image_name"...
Calculate default ssh-user based on image-if of AWS instance.
[ "Calculate", "default", "ssh", "-", "user", "based", "on", "image", "-", "if", "of", "AWS", "instance", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/uimode.py#L242-L253
51,667
robertpeteuil/multi-cloud-control
mcc/uimode.py
ui_cmd_bar
def ui_cmd_bar(): """Display Command Bar.""" cmd_bar = ("\rSELECT COMMAND - {2}(R){1}un {0}(C){1}onnect " "{3}(S){1}top {0}(U){1}pdate" " {0}(Q){1}uit: ". format(C_TI, C_NORM, C_GOOD, C_ERR)) # FUTURE - TO BE USED WHEN DETAILS IMPLEMENTED # cmd_bar =...
python
def ui_cmd_bar(): """Display Command Bar.""" cmd_bar = ("\rSELECT COMMAND - {2}(R){1}un {0}(C){1}onnect " "{3}(S){1}top {0}(U){1}pdate" " {0}(Q){1}uit: ". format(C_TI, C_NORM, C_GOOD, C_ERR)) # FUTURE - TO BE USED WHEN DETAILS IMPLEMENTED # cmd_bar =...
[ "def", "ui_cmd_bar", "(", ")", ":", "cmd_bar", "=", "(", "\"\\rSELECT COMMAND - {2}(R){1}un {0}(C){1}onnect \"", "\"{3}(S){1}top {0}(U){1}pdate\"", "\" {0}(Q){1}uit: \"", ".", "format", "(", "C_TI", ",", "C_NORM", ",", "C_GOOD", ",", "C_ERR", ")", ")", "# FUTUR...
Display Command Bar.
[ "Display", "Command", "Bar", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/uimode.py#L273-L285
51,668
robertpeteuil/multi-cloud-control
mcc/uimode.py
input_flush
def input_flush(): """Flush the input buffer on posix and windows.""" try: import sys, termios # noqa termios.tcflush(sys.stdin, termios.TCIFLUSH) except ImportError: import msvcrt while msvcrt.kbhit(): msvcrt.getch()
python
def input_flush(): """Flush the input buffer on posix and windows.""" try: import sys, termios # noqa termios.tcflush(sys.stdin, termios.TCIFLUSH) except ImportError: import msvcrt while msvcrt.kbhit(): msvcrt.getch()
[ "def", "input_flush", "(", ")", ":", "try", ":", "import", "sys", ",", "termios", "# noqa", "termios", ".", "tcflush", "(", "sys", ".", "stdin", ",", "termios", ".", "TCIFLUSH", ")", "except", "ImportError", ":", "import", "msvcrt", "while", "msvcrt", "....
Flush the input buffer on posix and windows.
[ "Flush", "the", "input", "buffer", "on", "posix", "and", "windows", "." ]
f1565af1c0b6ed465ff312d3ccc592ba0609f4a2
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/uimode.py#L308-L316
51,669
inveniosoftware/invenio-oauth2server
invenio_oauth2server/provider.py
get_user
def get_user(email, password, *args, **kwargs): """Get user for grant type password. Needed for grant type 'password'. Note, grant type password is by default disabled. :param email: User email. :param password: Password. :returns: The user instance or ``None``. """ user = datastore.fi...
python
def get_user(email, password, *args, **kwargs): """Get user for grant type password. Needed for grant type 'password'. Note, grant type password is by default disabled. :param email: User email. :param password: Password. :returns: The user instance or ``None``. """ user = datastore.fi...
[ "def", "get_user", "(", "email", ",", "password", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "user", "=", "datastore", ".", "find_user", "(", "email", "=", "email", ")", "if", "user", "and", "user", ".", "active", "and", "verify_password", ...
Get user for grant type password. Needed for grant type 'password'. Note, grant type password is by default disabled. :param email: User email. :param password: Password. :returns: The user instance or ``None``.
[ "Get", "user", "for", "grant", "type", "password", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/provider.py#L29-L41
51,670
inveniosoftware/invenio-oauth2server
invenio_oauth2server/provider.py
get_token
def get_token(access_token=None, refresh_token=None): """Load an access token. Add support for personal access tokens compared to flask-oauthlib. If the access token is ``None``, it looks for the refresh token. :param access_token: The access token. (Default: ``None``) :param refresh_token: The re...
python
def get_token(access_token=None, refresh_token=None): """Load an access token. Add support for personal access tokens compared to flask-oauthlib. If the access token is ``None``, it looks for the refresh token. :param access_token: The access token. (Default: ``None``) :param refresh_token: The re...
[ "def", "get_token", "(", "access_token", "=", "None", ",", "refresh_token", "=", "None", ")", ":", "if", "access_token", ":", "t", "=", "Token", ".", "query", ".", "filter_by", "(", "access_token", "=", "access_token", ")", ".", "first", "(", ")", "if", ...
Load an access token. Add support for personal access tokens compared to flask-oauthlib. If the access token is ``None``, it looks for the refresh token. :param access_token: The access token. (Default: ``None``) :param refresh_token: The refresh token. (Default: ``None``) :returns: The token inst...
[ "Load", "an", "access", "token", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/provider.py#L45-L71
51,671
inveniosoftware/invenio-oauth2server
invenio_oauth2server/provider.py
get_client
def get_client(client_id): """Load the client. Needed for grant_type client_credentials. Add support for OAuth client_credentials access type, with user inactivation support. :param client_id: The client ID. :returns: The client instance or ``None``. """ client = Client.query.get(clie...
python
def get_client(client_id): """Load the client. Needed for grant_type client_credentials. Add support for OAuth client_credentials access type, with user inactivation support. :param client_id: The client ID. :returns: The client instance or ``None``. """ client = Client.query.get(clie...
[ "def", "get_client", "(", "client_id", ")", ":", "client", "=", "Client", ".", "query", ".", "get", "(", "client_id", ")", "if", "client", "and", "client", ".", "user", ".", "active", ":", "return", "client" ]
Load the client. Needed for grant_type client_credentials. Add support for OAuth client_credentials access type, with user inactivation support. :param client_id: The client ID. :returns: The client instance or ``None``.
[ "Load", "the", "client", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/provider.py#L75-L88
51,672
inveniosoftware/invenio-oauth2server
invenio_oauth2server/provider.py
save_token
def save_token(token, request, *args, **kwargs): """Token persistence. :param token: A dictionary with the token data. :param request: The request instance. :returns: A :class:`invenio_oauth2server.models.Token` instance. """ # Exclude the personal access tokens which doesn't expire. user =...
python
def save_token(token, request, *args, **kwargs): """Token persistence. :param token: A dictionary with the token data. :param request: The request instance. :returns: A :class:`invenio_oauth2server.models.Token` instance. """ # Exclude the personal access tokens which doesn't expire. user =...
[ "def", "save_token", "(", "token", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Exclude the personal access tokens which doesn't expire.", "user", "=", "request", ".", "user", "if", "request", ".", "user", "else", "current_user", "# Ad...
Token persistence. :param token: A dictionary with the token data. :param request: The request instance. :returns: A :class:`invenio_oauth2server.models.Token` instance.
[ "Token", "persistence", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/provider.py#L92-L141
51,673
inveniosoftware/invenio-oauth2server
invenio_oauth2server/provider.py
login_oauth2_user
def login_oauth2_user(valid, oauth): """Log in a user after having been verified.""" if valid: oauth.user.login_via_oauth2 = True _request_ctx_stack.top.user = oauth.user identity_changed.send(current_app._get_current_object(), identity=Identity(oauth.user.i...
python
def login_oauth2_user(valid, oauth): """Log in a user after having been verified.""" if valid: oauth.user.login_via_oauth2 = True _request_ctx_stack.top.user = oauth.user identity_changed.send(current_app._get_current_object(), identity=Identity(oauth.user.i...
[ "def", "login_oauth2_user", "(", "valid", ",", "oauth", ")", ":", "if", "valid", ":", "oauth", ".", "user", ".", "login_via_oauth2", "=", "True", "_request_ctx_stack", ".", "top", ".", "user", "=", "oauth", ".", "user", "identity_changed", ".", "send", "("...
Log in a user after having been verified.
[ "Log", "in", "a", "user", "after", "having", "been", "verified", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/provider.py#L145-L152
51,674
inveniosoftware/invenio-oauth2server
invenio_oauth2server/utils.py
jwt_verify_token
def jwt_verify_token(headers): """Verify the JWT token. :param dict headers: The request headers. :returns: The token data. :rtype: dict """ # Get the token from headers token = headers.get( current_app.config['OAUTH2SERVER_JWT_AUTH_HEADER'] ) if token is None: raise...
python
def jwt_verify_token(headers): """Verify the JWT token. :param dict headers: The request headers. :returns: The token data. :rtype: dict """ # Get the token from headers token = headers.get( current_app.config['OAUTH2SERVER_JWT_AUTH_HEADER'] ) if token is None: raise...
[ "def", "jwt_verify_token", "(", "headers", ")", ":", "# Get the token from headers", "token", "=", "headers", ".", "get", "(", "current_app", ".", "config", "[", "'OAUTH2SERVER_JWT_AUTH_HEADER'", "]", ")", "if", "token", "is", "None", ":", "raise", "JWTInvalidHead...
Verify the JWT token. :param dict headers: The request headers. :returns: The token data. :rtype: dict
[ "Verify", "the", "JWT", "token", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/utils.py#L36-L70
51,675
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/server.py
error_handler
def error_handler(f): """Handle uncaught OAuth errors.""" @wraps(f) def decorated(*args, **kwargs): try: return f(*args, **kwargs) except OAuth2Error as e: # Only FatalClientError are handled by Flask-OAuthlib (as these # errors should not be redirect back...
python
def error_handler(f): """Handle uncaught OAuth errors.""" @wraps(f) def decorated(*args, **kwargs): try: return f(*args, **kwargs) except OAuth2Error as e: # Only FatalClientError are handled by Flask-OAuthlib (as these # errors should not be redirect back...
[ "def", "error_handler", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "decorated", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "OAuth2Error", ...
Handle uncaught OAuth errors.
[ "Handle", "uncaught", "OAuth", "errors", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/server.py#L36-L50
51,676
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/server.py
authorize
def authorize(*args, **kwargs): """View for rendering authorization request.""" if request.method == 'GET': client = Client.query.filter_by( client_id=kwargs.get('client_id') ).first() if not client: abort(404) scopes = current_oauth2server.scopes ...
python
def authorize(*args, **kwargs): """View for rendering authorization request.""" if request.method == 'GET': client = Client.query.filter_by( client_id=kwargs.get('client_id') ).first() if not client: abort(404) scopes = current_oauth2server.scopes ...
[ "def", "authorize", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "request", ".", "method", "==", "'GET'", ":", "client", "=", "Client", ".", "query", ".", "filter_by", "(", "client_id", "=", "kwargs", ".", "get", "(", "'client_id'", ")"...
View for rendering authorization request.
[ "View", "for", "rendering", "authorization", "request", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/server.py#L61-L80
51,677
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/server.py
errors
def errors(): """Error view in case of invalid oauth requests.""" from oauthlib.oauth2.rfc6749.errors import raise_from_error try: error = None raise_from_error(request.values.get('error'), params=dict()) except OAuth2Error as raised: error = raised return render_template('in...
python
def errors(): """Error view in case of invalid oauth requests.""" from oauthlib.oauth2.rfc6749.errors import raise_from_error try: error = None raise_from_error(request.values.get('error'), params=dict()) except OAuth2Error as raised: error = raised return render_template('in...
[ "def", "errors", "(", ")", ":", "from", "oauthlib", ".", "oauth2", ".", "rfc6749", ".", "errors", "import", "raise_from_error", "try", ":", "error", "=", "None", "raise_from_error", "(", "request", ".", "values", ".", "get", "(", "'error'", ")", ",", "pa...
Error view in case of invalid oauth requests.
[ "Error", "view", "in", "case", "of", "invalid", "oauth", "requests", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/server.py#L108-L116
51,678
inveniosoftware/invenio-oauth2server
invenio_oauth2server/views/server.py
info
def info(): """Test to verify that you have been authenticated.""" if current_app.testing or current_app.debug: return jsonify(dict( user=request.oauth.user.id, client=request.oauth.client.client_id, scopes=list(request.oauth.scopes) )) else: abort...
python
def info(): """Test to verify that you have been authenticated.""" if current_app.testing or current_app.debug: return jsonify(dict( user=request.oauth.user.id, client=request.oauth.client.client_id, scopes=list(request.oauth.scopes) )) else: abort...
[ "def", "info", "(", ")", ":", "if", "current_app", ".", "testing", "or", "current_app", ".", "debug", ":", "return", "jsonify", "(", "dict", "(", "user", "=", "request", ".", "oauth", ".", "user", ".", "id", ",", "client", "=", "request", ".", "oauth...
Test to verify that you have been authenticated.
[ "Test", "to", "verify", "that", "you", "have", "been", "authenticated", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/views/server.py#L128-L137
51,679
CameronLonsdale/lantern
lantern/modules/vigenere.py
key_periods
def key_periods(ciphertext, max_key_period): """Rank all key periods for ``ciphertext`` up to and including ``max_key_period`` Example: >>> key_periods(ciphertext, 30) [2, 4, 8, 3, ...] Args: ciphertext (str): The text to analyze max_key_period (int): The maximum period the...
python
def key_periods(ciphertext, max_key_period): """Rank all key periods for ``ciphertext`` up to and including ``max_key_period`` Example: >>> key_periods(ciphertext, 30) [2, 4, 8, 3, ...] Args: ciphertext (str): The text to analyze max_key_period (int): The maximum period the...
[ "def", "key_periods", "(", "ciphertext", ",", "max_key_period", ")", ":", "if", "max_key_period", "<=", "0", ":", "raise", "ValueError", "(", "\"max_key_period must be a positive integer\"", ")", "key_scores", "=", "[", "]", "for", "period", "in", "range", "(", ...
Rank all key periods for ``ciphertext`` up to and including ``max_key_period`` Example: >>> key_periods(ciphertext, 30) [2, 4, 8, 3, ...] Args: ciphertext (str): The text to analyze max_key_period (int): The maximum period the key could be Returns: Sorted list of k...
[ "Rank", "all", "key", "periods", "for", "ciphertext", "up", "to", "and", "including", "max_key_period" ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/modules/vigenere.py#L64-L89
51,680
CameronLonsdale/lantern
lantern/modules/vigenere.py
decrypt
def decrypt(key, ciphertext): """Decrypt Vigenere encrypted ``ciphertext`` using ``key``. Example: >>> decrypt("KEY", "RIJVS") HELLO Args: key (iterable): The key to use ciphertext (str): The text to decrypt Returns: Decrypted ciphertext """ index = 0 ...
python
def decrypt(key, ciphertext): """Decrypt Vigenere encrypted ``ciphertext`` using ``key``. Example: >>> decrypt("KEY", "RIJVS") HELLO Args: key (iterable): The key to use ciphertext (str): The text to decrypt Returns: Decrypted ciphertext """ index = 0 ...
[ "def", "decrypt", "(", "key", ",", "ciphertext", ")", ":", "index", "=", "0", "decrypted", "=", "\"\"", "for", "char", "in", "ciphertext", ":", "if", "char", "in", "string", ".", "punctuation", "+", "string", ".", "whitespace", "+", "string", ".", "dig...
Decrypt Vigenere encrypted ``ciphertext`` using ``key``. Example: >>> decrypt("KEY", "RIJVS") HELLO Args: key (iterable): The key to use ciphertext (str): The text to decrypt Returns: Decrypted ciphertext
[ "Decrypt", "Vigenere", "encrypted", "ciphertext", "using", "key", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/modules/vigenere.py#L97-L123
51,681
resync/resync
resync/explorer.py
Explorer.explore
def explore(self): """INTERACTIVE exploration source capabilities. Will use sitemap URI taken either from explicit self.sitemap_name or derived from the mappings supplied. """ # Where do we start? Build options in starts which has entries # that are a pair comprised of t...
python
def explore(self): """INTERACTIVE exploration source capabilities. Will use sitemap URI taken either from explicit self.sitemap_name or derived from the mappings supplied. """ # Where do we start? Build options in starts which has entries # that are a pair comprised of t...
[ "def", "explore", "(", "self", ")", ":", "# Where do we start? Build options in starts which has entries", "# that are a pair comprised of the uri and a list of acceptable", "# capabilities", "starts", "=", "[", "]", "if", "(", "self", ".", "sitemap_name", "is", "not", "None"...
INTERACTIVE exploration source capabilities. Will use sitemap URI taken either from explicit self.sitemap_name or derived from the mappings supplied.
[ "INTERACTIVE", "exploration", "source", "capabilities", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/explorer.py#L39-L112
51,682
resync/resync
resync/explorer.py
Explorer.explore_show_head
def explore_show_head(self, uri, check_headers=None): """Do HEAD on uri and show infomation. Will also check headers against any values specified in check_headers. """ print("HEAD %s" % (uri)) if (re.match(r'^\w+:', uri)): # Looks like a URI respo...
python
def explore_show_head(self, uri, check_headers=None): """Do HEAD on uri and show infomation. Will also check headers against any values specified in check_headers. """ print("HEAD %s" % (uri)) if (re.match(r'^\w+:', uri)): # Looks like a URI respo...
[ "def", "explore_show_head", "(", "self", ",", "uri", ",", "check_headers", "=", "None", ")", ":", "print", "(", "\"HEAD %s\"", "%", "(", "uri", ")", ")", "if", "(", "re", ".", "match", "(", "r'^\\w+:'", ",", "uri", ")", ")", ":", "# Looks like a URI", ...
Do HEAD on uri and show infomation. Will also check headers against any values specified in check_headers.
[ "Do", "HEAD", "on", "uri", "and", "show", "infomation", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/explorer.py#L271-L300
51,683
resync/resync
resync/explorer.py
Explorer.allowed_entries
def allowed_entries(self, capability): """Return list of allowed entries for given capability document. Includes handling of capability = *index where the only acceptable entries are *. """ index = re.match(r'(.+)index$', capability) archive = re.match(r'(.+)\-archive$',...
python
def allowed_entries(self, capability): """Return list of allowed entries for given capability document. Includes handling of capability = *index where the only acceptable entries are *. """ index = re.match(r'(.+)index$', capability) archive = re.match(r'(.+)\-archive$',...
[ "def", "allowed_entries", "(", "self", ",", "capability", ")", ":", "index", "=", "re", ".", "match", "(", "r'(.+)index$'", ",", "capability", ")", "archive", "=", "re", ".", "match", "(", "r'(.+)\\-archive$'", ",", "capability", ")", "if", "(", "capabilit...
Return list of allowed entries for given capability document. Includes handling of capability = *index where the only acceptable entries are *.
[ "Return", "list", "of", "allowed", "entries", "for", "given", "capability", "document", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/explorer.py#L314-L335
51,684
resync/resync
resync/explorer.py
Explorer.expand_relative_uri
def expand_relative_uri(self, context, uri): """If uri is relative then expand in context. Prints warning if expansion happens. """ full_uri = urljoin(context, uri) if (full_uri != uri): print(" WARNING - expanded relative URI to %s" % (full_uri)) uri = ...
python
def expand_relative_uri(self, context, uri): """If uri is relative then expand in context. Prints warning if expansion happens. """ full_uri = urljoin(context, uri) if (full_uri != uri): print(" WARNING - expanded relative URI to %s" % (full_uri)) uri = ...
[ "def", "expand_relative_uri", "(", "self", ",", "context", ",", "uri", ")", ":", "full_uri", "=", "urljoin", "(", "context", ",", "uri", ")", "if", "(", "full_uri", "!=", "uri", ")", ":", "print", "(", "\" WARNING - expanded relative URI to %s\"", "%", "(",...
If uri is relative then expand in context. Prints warning if expansion happens.
[ "If", "uri", "is", "relative", "then", "expand", "in", "context", "." ]
98292c17b2c00f2d6f5191c6ab51fef8c292a018
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/explorer.py#L337-L346
51,685
CameronLonsdale/lantern
lantern/analysis/search.py
hill_climb
def hill_climb(nsteps, start_node, get_next_node): """Modular hill climbing algorithm. Example: >>> def get_next_node(node): ... a, b = random.sample(range(len(node)), 2) ... node[a], node[b] = node[b], node[a] ... plaintext = decrypt(node, ciphertext) ... ...
python
def hill_climb(nsteps, start_node, get_next_node): """Modular hill climbing algorithm. Example: >>> def get_next_node(node): ... a, b = random.sample(range(len(node)), 2) ... node[a], node[b] = node[b], node[a] ... plaintext = decrypt(node, ciphertext) ... ...
[ "def", "hill_climb", "(", "nsteps", ",", "start_node", ",", "get_next_node", ")", ":", "outputs", "=", "[", "]", "best_score", "=", "-", "float", "(", "'inf'", ")", "for", "step", "in", "range", "(", "nsteps", ")", ":", "next_node", ",", "score", ",", ...
Modular hill climbing algorithm. Example: >>> def get_next_node(node): ... a, b = random.sample(range(len(node)), 2) ... node[a], node[b] = node[b], node[a] ... plaintext = decrypt(node, ciphertext) ... score = lantern.score(plaintext, *fitness_functions) ...
[ "Modular", "hill", "climbing", "algorithm", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/analysis/search.py#L6-L39
51,686
inveniosoftware/invenio-oauth2server
invenio_oauth2server/forms.py
scopes_multi_checkbox
def scopes_multi_checkbox(field, **kwargs): """Render multi checkbox widget.""" kwargs.setdefault('type', 'checkbox') field_id = kwargs.pop('id', field.id) html = [u'<div class="row">'] for value, label, checked in field.iter_choices(): choice_id = u'%s-%s' % (field_id, value) opt...
python
def scopes_multi_checkbox(field, **kwargs): """Render multi checkbox widget.""" kwargs.setdefault('type', 'checkbox') field_id = kwargs.pop('id', field.id) html = [u'<div class="row">'] for value, label, checked in field.iter_choices(): choice_id = u'%s-%s' % (field_id, value) opt...
[ "def", "scopes_multi_checkbox", "(", "field", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'type'", ",", "'checkbox'", ")", "field_id", "=", "kwargs", ".", "pop", "(", "'id'", ",", "field", ".", "id", ")", "html", "=", "[", "...
Render multi checkbox widget.
[ "Render", "multi", "checkbox", "widget", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/forms.py#L26-L58
51,687
inveniosoftware/invenio-oauth2server
invenio_oauth2server/forms.py
RedirectURIField.process_formdata
def process_formdata(self, valuelist): """Process form data.""" if valuelist: self.data = '\n'.join([ x.strip() for x in filter(lambda x: x, '\n'.join(valuelist).splitlines()) ])
python
def process_formdata(self, valuelist): """Process form data.""" if valuelist: self.data = '\n'.join([ x.strip() for x in filter(lambda x: x, '\n'.join(valuelist).splitlines()) ])
[ "def", "process_formdata", "(", "self", ",", "valuelist", ")", ":", "if", "valuelist", ":", "self", ".", "data", "=", "'\\n'", ".", "join", "(", "[", "x", ".", "strip", "(", ")", "for", "x", "in", "filter", "(", "lambda", "x", ":", "x", ",", "'\\...
Process form data.
[ "Process", "form", "data", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/forms.py#L67-L73
51,688
inveniosoftware/invenio-oauth2server
invenio_oauth2server/models.py
Client.redirect_uris
def redirect_uris(self, value): """Validate and store redirect URIs for client.""" if isinstance(value, six.text_type): value = value.split("\n") value = [v.strip() for v in value] for v in value: validate_redirect_uri(v) self._redirect_uris = "\n".join...
python
def redirect_uris(self, value): """Validate and store redirect URIs for client.""" if isinstance(value, six.text_type): value = value.split("\n") value = [v.strip() for v in value] for v in value: validate_redirect_uri(v) self._redirect_uris = "\n".join...
[ "def", "redirect_uris", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "six", ".", "text_type", ")", ":", "value", "=", "value", ".", "split", "(", "\"\\n\"", ")", "value", "=", "[", "v", ".", "strip", "(", ")", "for", ...
Validate and store redirect URIs for client.
[ "Validate", "and", "store", "redirect", "URIs", "for", "client", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/models.py#L219-L229
51,689
inveniosoftware/invenio-oauth2server
invenio_oauth2server/models.py
Client.default_scopes
def default_scopes(self, scopes): """Set default scopes for client.""" validate_scopes(scopes) self._default_scopes = " ".join(set(scopes)) if scopes else ""
python
def default_scopes(self, scopes): """Set default scopes for client.""" validate_scopes(scopes) self._default_scopes = " ".join(set(scopes)) if scopes else ""
[ "def", "default_scopes", "(", "self", ",", "scopes", ")", ":", "validate_scopes", "(", "scopes", ")", "self", ".", "_default_scopes", "=", "\" \"", ".", "join", "(", "set", "(", "scopes", ")", ")", "if", "scopes", "else", "\"\"" ]
Set default scopes for client.
[ "Set", "default", "scopes", "for", "client", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/models.py#L247-L250
51,690
inveniosoftware/invenio-oauth2server
invenio_oauth2server/models.py
Client.get_users
def get_users(self): """Get number of users.""" no_users = Token.query.filter_by( client_id=self.client_id, is_personal=False, is_internal=False ).count() return no_users
python
def get_users(self): """Get number of users.""" no_users = Token.query.filter_by( client_id=self.client_id, is_personal=False, is_internal=False ).count() return no_users
[ "def", "get_users", "(", "self", ")", ":", "no_users", "=", "Token", ".", "query", ".", "filter_by", "(", "client_id", "=", "self", ".", "client_id", ",", "is_personal", "=", "False", ",", "is_internal", "=", "False", ")", ".", "count", "(", ")", "retu...
Get number of users.
[ "Get", "number", "of", "users", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/models.py#L278-L285
51,691
inveniosoftware/invenio-oauth2server
invenio_oauth2server/models.py
Token.scopes
def scopes(self, scopes): """Set scopes. :param scopes: The list of scopes. """ validate_scopes(scopes) self._scopes = " ".join(set(scopes)) if scopes else ""
python
def scopes(self, scopes): """Set scopes. :param scopes: The list of scopes. """ validate_scopes(scopes) self._scopes = " ".join(set(scopes)) if scopes else ""
[ "def", "scopes", "(", "self", ",", "scopes", ")", ":", "validate_scopes", "(", "scopes", ")", "self", ".", "_scopes", "=", "\" \"", ".", "join", "(", "set", "(", "scopes", ")", ")", "if", "scopes", "else", "\"\"" ]
Set scopes. :param scopes: The list of scopes.
[ "Set", "scopes", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/models.py#L376-L382
51,692
inveniosoftware/invenio-oauth2server
invenio_oauth2server/models.py
Token.get_visible_scopes
def get_visible_scopes(self): """Get list of non-internal scopes for token. :returns: A list of scopes. """ return [k for k, s in current_oauth2server.scope_choices() if k in self.scopes]
python
def get_visible_scopes(self): """Get list of non-internal scopes for token. :returns: A list of scopes. """ return [k for k, s in current_oauth2server.scope_choices() if k in self.scopes]
[ "def", "get_visible_scopes", "(", "self", ")", ":", "return", "[", "k", "for", "k", ",", "s", "in", "current_oauth2server", ".", "scope_choices", "(", ")", "if", "k", "in", "self", ".", "scopes", "]" ]
Get list of non-internal scopes for token. :returns: A list of scopes.
[ "Get", "list", "of", "non", "-", "internal", "scopes", "for", "token", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/models.py#L384-L390
51,693
inveniosoftware/invenio-oauth2server
invenio_oauth2server/models.py
Token.create_personal
def create_personal(cls, name, user_id, scopes=None, is_internal=False): """Create a personal access token. A token that is bound to a specific user and which doesn't expire, i.e. similar to the concept of an API key. :param name: Client name. :param user_id: User ID. :...
python
def create_personal(cls, name, user_id, scopes=None, is_internal=False): """Create a personal access token. A token that is bound to a specific user and which doesn't expire, i.e. similar to the concept of an API key. :param name: Client name. :param user_id: User ID. :...
[ "def", "create_personal", "(", "cls", ",", "name", ",", "user_id", ",", "scopes", "=", "None", ",", "is_internal", "=", "False", ")", ":", "with", "db", ".", "session", ".", "begin_nested", "(", ")", ":", "scopes", "=", "\" \"", ".", "join", "(", "sc...
Create a personal access token. A token that is bound to a specific user and which doesn't expire, i.e. similar to the concept of an API key. :param name: Client name. :param user_id: User ID. :param scopes: The list of permitted scopes. (Default: ``None``) :param is_in...
[ "Create", "a", "personal", "access", "token", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/models.py#L393-L434
51,694
inveniosoftware/invenio-oauth2server
invenio_oauth2server/validators.py
validate_redirect_uri
def validate_redirect_uri(value): """Validate a redirect URI. Redirect URIs must be a valid URL and use https unless the host is localhost for which http is accepted. :param value: The redirect URI. """ sch, netloc, path, par, query, fra = urlparse(value) if not (sch and netloc): r...
python
def validate_redirect_uri(value): """Validate a redirect URI. Redirect URIs must be a valid URL and use https unless the host is localhost for which http is accepted. :param value: The redirect URI. """ sch, netloc, path, par, query, fra = urlparse(value) if not (sch and netloc): r...
[ "def", "validate_redirect_uri", "(", "value", ")", ":", "sch", ",", "netloc", ",", "path", ",", "par", ",", "query", ",", "fra", "=", "urlparse", "(", "value", ")", "if", "not", "(", "sch", "and", "netloc", ")", ":", "raise", "InvalidRedirectURIError", ...
Validate a redirect URI. Redirect URIs must be a valid URL and use https unless the host is localhost for which http is accepted. :param value: The redirect URI.
[ "Validate", "a", "redirect", "URI", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/validators.py#L23-L38
51,695
inveniosoftware/invenio-oauth2server
invenio_oauth2server/validators.py
validate_scopes
def validate_scopes(value_list): """Validate if each element in a list is a registered scope. :param value_list: The list of scopes. :raises invenio_oauth2server.errors.ScopeDoesNotExists: The exception is raised if a scope is not registered. :returns: ``True`` if it's successfully validated. ...
python
def validate_scopes(value_list): """Validate if each element in a list is a registered scope. :param value_list: The list of scopes. :raises invenio_oauth2server.errors.ScopeDoesNotExists: The exception is raised if a scope is not registered. :returns: ``True`` if it's successfully validated. ...
[ "def", "validate_scopes", "(", "value_list", ")", ":", "for", "value", "in", "value_list", ":", "if", "value", "not", "in", "current_oauth2server", ".", "scopes", ":", "raise", "ScopeDoesNotExists", "(", "value", ")", "return", "True" ]
Validate if each element in a list is a registered scope. :param value_list: The list of scopes. :raises invenio_oauth2server.errors.ScopeDoesNotExists: The exception is raised if a scope is not registered. :returns: ``True`` if it's successfully validated.
[ "Validate", "if", "each", "element", "in", "a", "list", "is", "a", "registered", "scope", "." ]
7033d3495c1a2b830e101e43918e92a37bbb49f2
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/validators.py#L41-L52
51,696
pappasam/latexbuild
latexbuild/subprocess_extension.py
check_output_cwd
def check_output_cwd(args, cwd, timeout=None): '''Open a subprocess in another working directory Raises ValueError if system binary does not exist Raises CalledProcessError if the return code is non-zero :returns: list of standard output and standard error from subprocess :param args: a list of c...
python
def check_output_cwd(args, cwd, timeout=None): '''Open a subprocess in another working directory Raises ValueError if system binary does not exist Raises CalledProcessError if the return code is non-zero :returns: list of standard output and standard error from subprocess :param args: a list of c...
[ "def", "check_output_cwd", "(", "args", ",", "cwd", ",", "timeout", "=", "None", ")", ":", "assertions", ".", "list_is_type", "(", "args", ",", "str", ")", "assertions", ".", "is_binary", "(", "args", "[", "0", "]", ")", "stdout_stderr", "=", "[", "]",...
Open a subprocess in another working directory Raises ValueError if system binary does not exist Raises CalledProcessError if the return code is non-zero :returns: list of standard output and standard error from subprocess :param args: a list of command line arguments for subprocess :param cwd: t...
[ "Open", "a", "subprocess", "in", "another", "working", "directory" ]
596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5
https://github.com/pappasam/latexbuild/blob/596a2a0a4c42eaa5eb9503d64f9073ad5d0640d5/latexbuild/subprocess_extension.py#L15-L40
51,697
Kami/python-yubico-client
yubico_client/otp.py
OTP.get_otp_modehex_interpretation
def get_otp_modehex_interpretation(self, otp): """ Return modhex interpretation of the provided OTP. If there are multiple interpretations available, first one is used, because if the OTP uses all 16 characters in its alphabet there is only one possible interpretation of that OT...
python
def get_otp_modehex_interpretation(self, otp): """ Return modhex interpretation of the provided OTP. If there are multiple interpretations available, first one is used, because if the OTP uses all 16 characters in its alphabet there is only one possible interpretation of that OT...
[ "def", "get_otp_modehex_interpretation", "(", "self", ",", "otp", ")", ":", "try", ":", "interpretations", "=", "translate", "(", "u", "(", "otp", ")", ")", "except", "Exception", ":", "return", "otp", "if", "len", "(", "interpretations", ")", "==", "0", ...
Return modhex interpretation of the provided OTP. If there are multiple interpretations available, first one is used, because if the OTP uses all 16 characters in its alphabet there is only one possible interpretation of that OTP. :return: Modhex interpretation of the OTP. :rty...
[ "Return", "modhex", "interpretation", "of", "the", "provided", "OTP", "." ]
3334b2ee1b5b996af3ef6be57a4ea52b8e45e764
https://github.com/Kami/python-yubico-client/blob/3334b2ee1b5b996af3ef6be57a4ea52b8e45e764/yubico_client/otp.py#L30-L55
51,698
CameronLonsdale/lantern
lantern/modules/shift.py
make_shift_function
def make_shift_function(alphabet): """Construct a shift function from an alphabet. Examples: Shift cases independently >>> make_shift_function([string.ascii_uppercase, string.ascii_lowercase]) <function make_shift_function.<locals>.shift_case_sensitive> Additionally shift punc...
python
def make_shift_function(alphabet): """Construct a shift function from an alphabet. Examples: Shift cases independently >>> make_shift_function([string.ascii_uppercase, string.ascii_lowercase]) <function make_shift_function.<locals>.shift_case_sensitive> Additionally shift punc...
[ "def", "make_shift_function", "(", "alphabet", ")", ":", "def", "shift_case_sensitive", "(", "shift", ",", "symbol", ")", ":", "case", "=", "[", "case", "for", "case", "in", "alphabet", "if", "symbol", "in", "case", "]", "if", "not", "case", ":", "return...
Construct a shift function from an alphabet. Examples: Shift cases independently >>> make_shift_function([string.ascii_uppercase, string.ascii_lowercase]) <function make_shift_function.<locals>.shift_case_sensitive> Additionally shift punctuation characters >>> make_shift...
[ "Construct", "a", "shift", "function", "from", "an", "alphabet", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/modules/shift.py#L9-L43
51,699
CameronLonsdale/lantern
lantern/modules/shift.py
crack
def crack(ciphertext, *fitness_functions, min_key=0, max_key=26, shift_function=shift_case_english): """Break ``ciphertext`` by enumerating keys between ``min_key`` and ``max_key``. Example: >>> decryptions = crack("KHOOR", fitness.english.quadgrams) >>> print(''.join(decryptions[0].plaintext))...
python
def crack(ciphertext, *fitness_functions, min_key=0, max_key=26, shift_function=shift_case_english): """Break ``ciphertext`` by enumerating keys between ``min_key`` and ``max_key``. Example: >>> decryptions = crack("KHOOR", fitness.english.quadgrams) >>> print(''.join(decryptions[0].plaintext))...
[ "def", "crack", "(", "ciphertext", ",", "*", "fitness_functions", ",", "min_key", "=", "0", ",", "max_key", "=", "26", ",", "shift_function", "=", "shift_case_english", ")", ":", "if", "min_key", ">=", "max_key", ":", "raise", "ValueError", "(", "\"min_key c...
Break ``ciphertext`` by enumerating keys between ``min_key`` and ``max_key``. Example: >>> decryptions = crack("KHOOR", fitness.english.quadgrams) >>> print(''.join(decryptions[0].plaintext)) HELLO Args: ciphertext (iterable): The symbols to decrypt *fitness_functions (...
[ "Break", "ciphertext", "by", "enumerating", "keys", "between", "min_key", "and", "max_key", "." ]
235e163e96bf0719d49c54204ee576b2ca93abb6
https://github.com/CameronLonsdale/lantern/blob/235e163e96bf0719d49c54204ee576b2ca93abb6/lantern/modules/shift.py#L48-L80