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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
245,200 | deifyed/vault | libconman/target.py | Target.deploy | def deploy(self):
'''
Creates a link at the original path of this target
'''
if not os.path.exists(self.path):
makedirs(self.path)
link(self.vault_path, self.real_path) | python | def deploy(self):
'''
Creates a link at the original path of this target
'''
if not os.path.exists(self.path):
makedirs(self.path)
link(self.vault_path, self.real_path) | [
"def",
"deploy",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"makedirs",
"(",
"self",
".",
"path",
")",
"link",
"(",
"self",
".",
"vault_path",
",",
"self",
".",
"real_path",
")"
] | Creates a link at the original path of this target | [
"Creates",
"a",
"link",
"at",
"the",
"original",
"path",
"of",
"this",
"target"
] | e3c37ade6c3e6b61a76ec6cd2ba98881c7401d97 | https://github.com/deifyed/vault/blob/e3c37ade6c3e6b61a76ec6cd2ba98881c7401d97/libconman/target.py#L83-L90 |
245,201 | riccardocagnasso/useless | src/useless/common/__init__.py | parse_cstring | def parse_cstring(stream, offset):
"""
parse_cstring will parse a null-terminated string in a bytestream.
The string will be decoded with UTF-8 decoder, of course since we are
doing this byte-a-byte, it won't really work for all Unicode strings.
TODO: add proper Unicode support
... | python | def parse_cstring(stream, offset):
"""
parse_cstring will parse a null-terminated string in a bytestream.
The string will be decoded with UTF-8 decoder, of course since we are
doing this byte-a-byte, it won't really work for all Unicode strings.
TODO: add proper Unicode support
... | [
"def",
"parse_cstring",
"(",
"stream",
",",
"offset",
")",
":",
"stream",
".",
"seek",
"(",
"offset",
")",
"string",
"=",
"\"\"",
"while",
"True",
":",
"char",
"=",
"struct",
".",
"unpack",
"(",
"'c'",
",",
"stream",
".",
"read",
"(",
"1",
")",
")"... | parse_cstring will parse a null-terminated string in a bytestream.
The string will be decoded with UTF-8 decoder, of course since we are
doing this byte-a-byte, it won't really work for all Unicode strings.
TODO: add proper Unicode support | [
"parse_cstring",
"will",
"parse",
"a",
"null",
"-",
"terminated",
"string",
"in",
"a",
"bytestream",
"."
] | 5167aab82958f653148e3689c9a7e548d4fa2cba | https://github.com/riccardocagnasso/useless/blob/5167aab82958f653148e3689c9a7e548d4fa2cba/src/useless/common/__init__.py#L29-L48 |
245,202 | lambdalisue/maidenhair | src/maidenhair/classification/unite.py | unite_dataset | def unite_dataset(dataset, basecolumn, fn=None):
"""
Unite dataset via fn
Parameters
----------
dataset : list
A list of data
basecolumn : int
A number of column which will be respected in uniting dataset
fn : function
A function which recieve :attr:`data` and return... | python | def unite_dataset(dataset, basecolumn, fn=None):
"""
Unite dataset via fn
Parameters
----------
dataset : list
A list of data
basecolumn : int
A number of column which will be respected in uniting dataset
fn : function
A function which recieve :attr:`data` and return... | [
"def",
"unite_dataset",
"(",
"dataset",
",",
"basecolumn",
",",
"fn",
"=",
"None",
")",
":",
"# create default unite_fn",
"if",
"fn",
"is",
"None",
":",
"fn",
"=",
"default_unite_function",
"# classify dataset via unite_fn",
"united_dataset",
"=",
"OrderedDict",
"("... | Unite dataset via fn
Parameters
----------
dataset : list
A list of data
basecolumn : int
A number of column which will be respected in uniting dataset
fn : function
A function which recieve :attr:`data` and return classification string.
It if is None, a function whi... | [
"Unite",
"dataset",
"via",
"fn"
] | d5095c1087d1f4d71cc57410492151d2803a9f0d | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/classification/unite.py#L32-L70 |
245,203 | collectiveacuity/labPack | labpack/speech/watson.py | watsonSpeechClient._create_folder | def _create_folder(self):
''' a helper method for creating a temporary audio clip folder '''
# import dependencies
import os
from labpack.platforms.localhost import localhostClient
from labpack.records.id import labID
# create folder in user app data
record_i... | python | def _create_folder(self):
''' a helper method for creating a temporary audio clip folder '''
# import dependencies
import os
from labpack.platforms.localhost import localhostClient
from labpack.records.id import labID
# create folder in user app data
record_i... | [
"def",
"_create_folder",
"(",
"self",
")",
":",
"# import dependencies\r",
"import",
"os",
"from",
"labpack",
".",
"platforms",
".",
"localhost",
"import",
"localhostClient",
"from",
"labpack",
".",
"records",
".",
"id",
"import",
"labID",
"# create folder in user a... | a helper method for creating a temporary audio clip folder | [
"a",
"helper",
"method",
"for",
"creating",
"a",
"temporary",
"audio",
"clip",
"folder"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/speech/watson.py#L151-L172 |
245,204 | collectiveacuity/labPack | labpack/speech/watson.py | watsonSpeechClient._transcribe_files | def _transcribe_files(self, file_list, file_mimetype):
''' a helper method for multi-processing file transcription '''
# import dependencies
import queue
from threading import Thread
# define multithreading function
def _recognize_file(file_path, file_mimetype, queue)... | python | def _transcribe_files(self, file_list, file_mimetype):
''' a helper method for multi-processing file transcription '''
# import dependencies
import queue
from threading import Thread
# define multithreading function
def _recognize_file(file_path, file_mimetype, queue)... | [
"def",
"_transcribe_files",
"(",
"self",
",",
"file_list",
",",
"file_mimetype",
")",
":",
"# import dependencies\r",
"import",
"queue",
"from",
"threading",
"import",
"Thread",
"# define multithreading function\r",
"def",
"_recognize_file",
"(",
"file_path",
",",
"file... | a helper method for multi-processing file transcription | [
"a",
"helper",
"method",
"for",
"multi",
"-",
"processing",
"file",
"transcription"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/speech/watson.py#L174-L226 |
245,205 | mbodenhamer/syn | syn/sets/b/base.py | SetNode.lazy_enumerate | def lazy_enumerate(self, **kwargs):
'''Enumerate without evaluating any sets.
'''
kwargs['lazy'] = True
for item in self.enumerate(**kwargs):
yield item | python | def lazy_enumerate(self, **kwargs):
'''Enumerate without evaluating any sets.
'''
kwargs['lazy'] = True
for item in self.enumerate(**kwargs):
yield item | [
"def",
"lazy_enumerate",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'lazy'",
"]",
"=",
"True",
"for",
"item",
"in",
"self",
".",
"enumerate",
"(",
"*",
"*",
"kwargs",
")",
":",
"yield",
"item"
] | Enumerate without evaluating any sets. | [
"Enumerate",
"without",
"evaluating",
"any",
"sets",
"."
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/sets/b/base.py#L95-L100 |
245,206 | theirc/rapidsms-multitenancy | multitenancy/views.py | group_selection | def group_selection(request):
"""Allow user to select a TenantGroup if they have more than one."""
groups = get_user_groups(request.user)
count = len(groups)
if count == 1:
# Redirect to the detail page for this group
return redirect(groups[0])
context = {
'groups': groups,
... | python | def group_selection(request):
"""Allow user to select a TenantGroup if they have more than one."""
groups = get_user_groups(request.user)
count = len(groups)
if count == 1:
# Redirect to the detail page for this group
return redirect(groups[0])
context = {
'groups': groups,
... | [
"def",
"group_selection",
"(",
"request",
")",
":",
"groups",
"=",
"get_user_groups",
"(",
"request",
".",
"user",
")",
"count",
"=",
"len",
"(",
"groups",
")",
"if",
"count",
"==",
"1",
":",
"# Redirect to the detail page for this group",
"return",
"redirect",
... | Allow user to select a TenantGroup if they have more than one. | [
"Allow",
"user",
"to",
"select",
"a",
"TenantGroup",
"if",
"they",
"have",
"more",
"than",
"one",
"."
] | 121bd0a628e691a88aade2e10045cba43af2dfcb | https://github.com/theirc/rapidsms-multitenancy/blob/121bd0a628e691a88aade2e10045cba43af2dfcb/multitenancy/views.py#L8-L20 |
245,207 | theirc/rapidsms-multitenancy | multitenancy/views.py | group_dashboard | def group_dashboard(request, group_slug):
"""Dashboard for managing a TenantGroup."""
groups = get_user_groups(request.user)
group = get_object_or_404(groups, slug=group_slug)
tenants = get_user_tenants(request.user, group)
can_edit_group = request.user.has_perm('multitenancy.change_tenantgroup', gr... | python | def group_dashboard(request, group_slug):
"""Dashboard for managing a TenantGroup."""
groups = get_user_groups(request.user)
group = get_object_or_404(groups, slug=group_slug)
tenants = get_user_tenants(request.user, group)
can_edit_group = request.user.has_perm('multitenancy.change_tenantgroup', gr... | [
"def",
"group_dashboard",
"(",
"request",
",",
"group_slug",
")",
":",
"groups",
"=",
"get_user_groups",
"(",
"request",
".",
"user",
")",
"group",
"=",
"get_object_or_404",
"(",
"groups",
",",
"slug",
"=",
"group_slug",
")",
"tenants",
"=",
"get_user_tenants"... | Dashboard for managing a TenantGroup. | [
"Dashboard",
"for",
"managing",
"a",
"TenantGroup",
"."
] | 121bd0a628e691a88aade2e10045cba43af2dfcb | https://github.com/theirc/rapidsms-multitenancy/blob/121bd0a628e691a88aade2e10045cba43af2dfcb/multitenancy/views.py#L24-L40 |
245,208 | theirc/rapidsms-multitenancy | multitenancy/views.py | tenant_dashboard | def tenant_dashboard(request, group_slug, tenant_slug):
"""Dashboard for managing a tenant."""
groups = get_user_groups(request.user)
group = get_object_or_404(groups, slug=group_slug)
tenants = get_user_tenants(request.user, group)
tenant = get_object_or_404(tenants, slug=tenant_slug)
can_edit_... | python | def tenant_dashboard(request, group_slug, tenant_slug):
"""Dashboard for managing a tenant."""
groups = get_user_groups(request.user)
group = get_object_or_404(groups, slug=group_slug)
tenants = get_user_tenants(request.user, group)
tenant = get_object_or_404(tenants, slug=tenant_slug)
can_edit_... | [
"def",
"tenant_dashboard",
"(",
"request",
",",
"group_slug",
",",
"tenant_slug",
")",
":",
"groups",
"=",
"get_user_groups",
"(",
"request",
".",
"user",
")",
"group",
"=",
"get_object_or_404",
"(",
"groups",
",",
"slug",
"=",
"group_slug",
")",
"tenants",
... | Dashboard for managing a tenant. | [
"Dashboard",
"for",
"managing",
"a",
"tenant",
"."
] | 121bd0a628e691a88aade2e10045cba43af2dfcb | https://github.com/theirc/rapidsms-multitenancy/blob/121bd0a628e691a88aade2e10045cba43af2dfcb/multitenancy/views.py#L44-L56 |
245,209 | pip-services3-python/pip-services3-components-python | pip_services3_components/connect/MemoryDiscovery.py | MemoryDiscovery.read_connections | def read_connections(self, connections):
"""
Reads connections from configuration parameters.
Each section represents an individual Connectionparams
:param connections: configuration parameters to be read
"""
del self._items[:]
for key in connections.get_key_name... | python | def read_connections(self, connections):
"""
Reads connections from configuration parameters.
Each section represents an individual Connectionparams
:param connections: configuration parameters to be read
"""
del self._items[:]
for key in connections.get_key_name... | [
"def",
"read_connections",
"(",
"self",
",",
"connections",
")",
":",
"del",
"self",
".",
"_items",
"[",
":",
"]",
"for",
"key",
"in",
"connections",
".",
"get_key_names",
"(",
")",
":",
"item",
"=",
"DiscoveryItem",
"(",
")",
"item",
".",
"key",
"=",
... | Reads connections from configuration parameters.
Each section represents an individual Connectionparams
:param connections: configuration parameters to be read | [
"Reads",
"connections",
"from",
"configuration",
"parameters",
".",
"Each",
"section",
"represents",
"an",
"individual",
"Connectionparams"
] | 1de9c1bb544cf1891111e9a5f5d67653f62c9b52 | https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/connect/MemoryDiscovery.py#L67-L80 |
245,210 | pip-services3-python/pip-services3-components-python | pip_services3_components/connect/MemoryDiscovery.py | MemoryDiscovery.register | def register(self, correlation_id, key, connection):
"""
Registers connection parameters into the discovery service.
:param correlation_id: (optional) transaction id to trace execution through call chain.
:param key: a key to uniquely identify the connection parameters.
:param... | python | def register(self, correlation_id, key, connection):
"""
Registers connection parameters into the discovery service.
:param correlation_id: (optional) transaction id to trace execution through call chain.
:param key: a key to uniquely identify the connection parameters.
:param... | [
"def",
"register",
"(",
"self",
",",
"correlation_id",
",",
"key",
",",
"connection",
")",
":",
"item",
"=",
"DiscoveryItem",
"(",
")",
"item",
".",
"key",
"=",
"key",
"item",
".",
"connection",
"=",
"connection",
"self",
".",
"_items",
".",
"append",
... | Registers connection parameters into the discovery service.
:param correlation_id: (optional) transaction id to trace execution through call chain.
:param key: a key to uniquely identify the connection parameters.
:param connection: a connection to be registered. | [
"Registers",
"connection",
"parameters",
"into",
"the",
"discovery",
"service",
"."
] | 1de9c1bb544cf1891111e9a5f5d67653f62c9b52 | https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/connect/MemoryDiscovery.py#L82-L95 |
245,211 | pip-services3-python/pip-services3-components-python | pip_services3_components/connect/MemoryDiscovery.py | MemoryDiscovery.resolve_one | def resolve_one(self, correlation_id, key):
"""
Resolves a single connection parameters by its key.
:param correlation_id: (optional) transaction id to trace execution through call chain.
:param key: a key to uniquely identify the connection.
:return: a resolved connection.
... | python | def resolve_one(self, correlation_id, key):
"""
Resolves a single connection parameters by its key.
:param correlation_id: (optional) transaction id to trace execution through call chain.
:param key: a key to uniquely identify the connection.
:return: a resolved connection.
... | [
"def",
"resolve_one",
"(",
"self",
",",
"correlation_id",
",",
"key",
")",
":",
"connection",
"=",
"None",
"for",
"item",
"in",
"self",
".",
"_items",
":",
"if",
"item",
".",
"key",
"==",
"key",
"and",
"item",
".",
"connection",
"!=",
"None",
":",
"c... | Resolves a single connection parameters by its key.
:param correlation_id: (optional) transaction id to trace execution through call chain.
:param key: a key to uniquely identify the connection.
:return: a resolved connection. | [
"Resolves",
"a",
"single",
"connection",
"parameters",
"by",
"its",
"key",
"."
] | 1de9c1bb544cf1891111e9a5f5d67653f62c9b52 | https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/connect/MemoryDiscovery.py#L97-L112 |
245,212 | nefarioustim/parker | parker/stringops.py | generate_chunks | def generate_chunks(string, num_chars):
"""Yield num_chars-character chunks from string."""
for start in range(0, len(string), num_chars):
yield string[start:start+num_chars] | python | def generate_chunks(string, num_chars):
"""Yield num_chars-character chunks from string."""
for start in range(0, len(string), num_chars):
yield string[start:start+num_chars] | [
"def",
"generate_chunks",
"(",
"string",
",",
"num_chars",
")",
":",
"for",
"start",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"string",
")",
",",
"num_chars",
")",
":",
"yield",
"string",
"[",
"start",
":",
"start",
"+",
"num_chars",
"]"
] | Yield num_chars-character chunks from string. | [
"Yield",
"num_chars",
"-",
"character",
"chunks",
"from",
"string",
"."
] | ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6 | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/stringops.py#L5-L8 |
245,213 | rosenbrockc/acorn | acorn/importer.py | _load_package_config | def _load_package_config(reload_=False):
"""Loads the package configurations from the global `acorn.cfg` file.
"""
global _packages
from acorn.config import settings
packset = settings("acorn", reload_)
if packset.has_section("acorn.packages"):
for package, value in packset.items("acorn.... | python | def _load_package_config(reload_=False):
"""Loads the package configurations from the global `acorn.cfg` file.
"""
global _packages
from acorn.config import settings
packset = settings("acorn", reload_)
if packset.has_section("acorn.packages"):
for package, value in packset.items("acorn.... | [
"def",
"_load_package_config",
"(",
"reload_",
"=",
"False",
")",
":",
"global",
"_packages",
"from",
"acorn",
".",
"config",
"import",
"settings",
"packset",
"=",
"settings",
"(",
"\"acorn\"",
",",
"reload_",
")",
"if",
"packset",
".",
"has_section",
"(",
"... | Loads the package configurations from the global `acorn.cfg` file. | [
"Loads",
"the",
"package",
"configurations",
"from",
"the",
"global",
"acorn",
".",
"cfg",
"file",
"."
] | 9a44d1a1ad8bfc2c54a6b56d9efe54433a797820 | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/importer.py#L14-L22 |
245,214 | rosenbrockc/acorn | acorn/importer.py | load_decorate | def load_decorate(package):
"""Imports and decorates the package with the specified name.
"""
# We import the decoration logic from acorn and then overwrite the sys.module
# for this package with the decorated, original pandas package.
from acorn.logging.decoration import set_decorating, decorating
... | python | def load_decorate(package):
"""Imports and decorates the package with the specified name.
"""
# We import the decoration logic from acorn and then overwrite the sys.module
# for this package with the decorated, original pandas package.
from acorn.logging.decoration import set_decorating, decorating
... | [
"def",
"load_decorate",
"(",
"package",
")",
":",
"# We import the decoration logic from acorn and then overwrite the sys.module",
"# for this package with the decorated, original pandas package.",
"from",
"acorn",
".",
"logging",
".",
"decoration",
"import",
"set_decorating",
",",
... | Imports and decorates the package with the specified name. | [
"Imports",
"and",
"decorates",
"the",
"package",
"with",
"the",
"specified",
"name",
"."
] | 9a44d1a1ad8bfc2c54a6b56d9efe54433a797820 | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/importer.py#L73-L100 |
245,215 | RonenNess/Fileter | fileter/iterators/remove_files.py | RemoveFiles.process_file | def process_file(self, path, dryrun):
"""
Remove files and return filename.
"""
# if dryrun just return file path
if dryrun:
return path
# remove and return file
if self.__force or raw_input("Remove file '%s'? [y/N]" % path).lower() == "y":
... | python | def process_file(self, path, dryrun):
"""
Remove files and return filename.
"""
# if dryrun just return file path
if dryrun:
return path
# remove and return file
if self.__force or raw_input("Remove file '%s'? [y/N]" % path).lower() == "y":
... | [
"def",
"process_file",
"(",
"self",
",",
"path",
",",
"dryrun",
")",
":",
"# if dryrun just return file path",
"if",
"dryrun",
":",
"return",
"path",
"# remove and return file",
"if",
"self",
".",
"__force",
"or",
"raw_input",
"(",
"\"Remove file '%s'? [y/N]\"",
"%"... | Remove files and return filename. | [
"Remove",
"files",
"and",
"return",
"filename",
"."
] | 5372221b4049d5d46a9926573b91af17681c81f3 | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/iterators/remove_files.py#L27-L38 |
245,216 | maxfischer2781/include | include/base/import_hook.py | BaseIncludeLoader.find_module | def find_module(self, fullname, path=None):
"""
Find the appropriate loader for module ``name``
:param fullname: ``__name__`` of the module to import
:type fullname: str
:param path: ``__path__`` of the *parent* package already imported
:type path: str or None
""... | python | def find_module(self, fullname, path=None):
"""
Find the appropriate loader for module ``name``
:param fullname: ``__name__`` of the module to import
:type fullname: str
:param path: ``__path__`` of the *parent* package already imported
:type path: str or None
""... | [
"def",
"find_module",
"(",
"self",
",",
"fullname",
",",
"path",
"=",
"None",
")",
":",
"# path points to the top-level package path if any",
"# and we can only import sub-modules/-packages",
"if",
"path",
"is",
"None",
":",
"return",
"if",
"fullname",
".",
"startswith"... | Find the appropriate loader for module ``name``
:param fullname: ``__name__`` of the module to import
:type fullname: str
:param path: ``__path__`` of the *parent* package already imported
:type path: str or None | [
"Find",
"the",
"appropriate",
"loader",
"for",
"module",
"name"
] | d8b0404f4996b6abcd39fdebf282b31fad8bb6f5 | https://github.com/maxfischer2781/include/blob/d8b0404f4996b6abcd39fdebf282b31fad8bb6f5/include/base/import_hook.py#L69-L85 |
245,217 | sprockets/sprockets | sprockets/cli.py | CLI.run | def run(self):
"""Evaluate the command line arguments, performing the appropriate
actions so the application can be started.
"""
# The list command prevents any other processing of args
if self._args.list:
self._print_installed_apps(self._args.controller)
... | python | def run(self):
"""Evaluate the command line arguments, performing the appropriate
actions so the application can be started.
"""
# The list command prevents any other processing of args
if self._args.list:
self._print_installed_apps(self._args.controller)
... | [
"def",
"run",
"(",
"self",
")",
":",
"# The list command prevents any other processing of args",
"if",
"self",
".",
"_args",
".",
"list",
":",
"self",
".",
"_print_installed_apps",
"(",
"self",
".",
"_args",
".",
"controller",
")",
"sys",
".",
"exit",
"(",
"0"... | Evaluate the command line arguments, performing the appropriate
actions so the application can be started. | [
"Evaluate",
"the",
"command",
"line",
"arguments",
"performing",
"the",
"appropriate",
"actions",
"so",
"the",
"application",
"can",
"be",
"started",
"."
] | 089dbaf04da54afd95645fce31f4ff9c8bdd8fae | https://github.com/sprockets/sprockets/blob/089dbaf04da54afd95645fce31f4ff9c8bdd8fae/sprockets/cli.py#L85-L119 |
245,218 | sprockets/sprockets | sprockets/cli.py | CLI._add_cli_args | def _add_cli_args(self):
"""Add the cli arguments to the argument parser."""
# Optional cli arguments
self._arg_parser.add_argument('-l', '--list',
action='store_true',
help='List installed sprockets apps')
sel... | python | def _add_cli_args(self):
"""Add the cli arguments to the argument parser."""
# Optional cli arguments
self._arg_parser.add_argument('-l', '--list',
action='store_true',
help='List installed sprockets apps')
sel... | [
"def",
"_add_cli_args",
"(",
"self",
")",
":",
"# Optional cli arguments",
"self",
".",
"_arg_parser",
".",
"add_argument",
"(",
"'-l'",
",",
"'--list'",
",",
"action",
"=",
"'store_true'",
",",
"help",
"=",
"'List installed sprockets apps'",
")",
"self",
".",
"... | Add the cli arguments to the argument parser. | [
"Add",
"the",
"cli",
"arguments",
"to",
"the",
"argument",
"parser",
"."
] | 089dbaf04da54afd95645fce31f4ff9c8bdd8fae | https://github.com/sprockets/sprockets/blob/089dbaf04da54afd95645fce31f4ff9c8bdd8fae/sprockets/cli.py#L121-L158 |
245,219 | sprockets/sprockets | sprockets/cli.py | CLI._configure_logging | def _configure_logging(application, verbosity=0, syslog=False):
"""Configure logging for the application, setting the appropriate
verbosity and adding syslog if it's enabled.
:param str application: The application module/package name
:param int verbosity: 1 == INFO, 2 == DEBUG
... | python | def _configure_logging(application, verbosity=0, syslog=False):
"""Configure logging for the application, setting the appropriate
verbosity and adding syslog if it's enabled.
:param str application: The application module/package name
:param int verbosity: 1 == INFO, 2 == DEBUG
... | [
"def",
"_configure_logging",
"(",
"application",
",",
"verbosity",
"=",
"0",
",",
"syslog",
"=",
"False",
")",
":",
"# Create a new copy of the logging config that will be modified",
"config",
"=",
"dict",
"(",
"LOGGING",
")",
"# Increase the logging verbosity",
"if",
"... | Configure logging for the application, setting the appropriate
verbosity and adding syslog if it's enabled.
:param str application: The application module/package name
:param int verbosity: 1 == INFO, 2 == DEBUG
:param bool syslog: Enable the syslog handler | [
"Configure",
"logging",
"for",
"the",
"application",
"setting",
"the",
"appropriate",
"verbosity",
"and",
"adding",
"syslog",
"if",
"it",
"s",
"enabled",
"."
] | 089dbaf04da54afd95645fce31f4ff9c8bdd8fae | https://github.com/sprockets/sprockets/blob/089dbaf04da54afd95645fce31f4ff9c8bdd8fae/sprockets/cli.py#L161-L187 |
245,220 | sprockets/sprockets | sprockets/cli.py | CLI._get_application_module | def _get_application_module(self, controller, application):
"""Return the module for an application. If it's a entry-point
registered application name, return the module name from the entry
points data. If not, the passed in application name is returned.
:param str controller: The contr... | python | def _get_application_module(self, controller, application):
"""Return the module for an application. If it's a entry-point
registered application name, return the module name from the entry
points data. If not, the passed in application name is returned.
:param str controller: The contr... | [
"def",
"_get_application_module",
"(",
"self",
",",
"controller",
",",
"application",
")",
":",
"for",
"pkg",
"in",
"self",
".",
"_get_applications",
"(",
"controller",
")",
":",
"if",
"pkg",
".",
"name",
"==",
"application",
":",
"return",
"pkg",
".",
"mo... | Return the module for an application. If it's a entry-point
registered application name, return the module name from the entry
points data. If not, the passed in application name is returned.
:param str controller: The controller type
:param str application: The application name or modu... | [
"Return",
"the",
"module",
"for",
"an",
"application",
".",
"If",
"it",
"s",
"a",
"entry",
"-",
"point",
"registered",
"application",
"name",
"return",
"the",
"module",
"name",
"from",
"the",
"entry",
"points",
"data",
".",
"If",
"not",
"the",
"passed",
... | 089dbaf04da54afd95645fce31f4ff9c8bdd8fae | https://github.com/sprockets/sprockets/blob/089dbaf04da54afd95645fce31f4ff9c8bdd8fae/sprockets/cli.py#L189-L202 |
245,221 | sprockets/sprockets | sprockets/cli.py | CLI._get_controllers | def _get_controllers(self):
"""Iterate through the installed controller entry points and import
the module and assign the handle to the CLI._controllers dict.
:return: dict
"""
controllers = dict()
for pkg in pkg_resources.iter_entry_points(group=self.CONTROLLERS):
... | python | def _get_controllers(self):
"""Iterate through the installed controller entry points and import
the module and assign the handle to the CLI._controllers dict.
:return: dict
"""
controllers = dict()
for pkg in pkg_resources.iter_entry_points(group=self.CONTROLLERS):
... | [
"def",
"_get_controllers",
"(",
"self",
")",
":",
"controllers",
"=",
"dict",
"(",
")",
"for",
"pkg",
"in",
"pkg_resources",
".",
"iter_entry_points",
"(",
"group",
"=",
"self",
".",
"CONTROLLERS",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'Loading %s controll... | Iterate through the installed controller entry points and import
the module and assign the handle to the CLI._controllers dict.
:return: dict | [
"Iterate",
"through",
"the",
"installed",
"controller",
"entry",
"points",
"and",
"import",
"the",
"module",
"and",
"assign",
"the",
"handle",
"to",
"the",
"CLI",
".",
"_controllers",
"dict",
"."
] | 089dbaf04da54afd95645fce31f4ff9c8bdd8fae | https://github.com/sprockets/sprockets/blob/089dbaf04da54afd95645fce31f4ff9c8bdd8fae/sprockets/cli.py#L225-L236 |
245,222 | sprockets/sprockets | sprockets/cli.py | CLI._get_controller_help | def _get_controller_help(self, controller):
"""Return the value of the HELP attribute for a controller that should
describe the functionality of the controller.
:rtype: str|None
"""
if hasattr(self._controllers[controller], 'HELP'):
return self._controllers[controll... | python | def _get_controller_help(self, controller):
"""Return the value of the HELP attribute for a controller that should
describe the functionality of the controller.
:rtype: str|None
"""
if hasattr(self._controllers[controller], 'HELP'):
return self._controllers[controll... | [
"def",
"_get_controller_help",
"(",
"self",
",",
"controller",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"_controllers",
"[",
"controller",
"]",
",",
"'HELP'",
")",
":",
"return",
"self",
".",
"_controllers",
"[",
"controller",
"]",
".",
"HELP",
"return... | Return the value of the HELP attribute for a controller that should
describe the functionality of the controller.
:rtype: str|None | [
"Return",
"the",
"value",
"of",
"the",
"HELP",
"attribute",
"for",
"a",
"controller",
"that",
"should",
"describe",
"the",
"functionality",
"of",
"the",
"controller",
"."
] | 089dbaf04da54afd95645fce31f4ff9c8bdd8fae | https://github.com/sprockets/sprockets/blob/089dbaf04da54afd95645fce31f4ff9c8bdd8fae/sprockets/cli.py#L238-L247 |
245,223 | sprockets/sprockets | sprockets/cli.py | CLI._print_installed_apps | def _print_installed_apps(self, controller):
"""Print out a list of installed sprockets applications
:param str controller: The name of the controller to get apps for
"""
print('\nInstalled Sprockets %s Apps\n' % controller.upper())
print("{0:<25} {1:>25}".format('Name', 'Module... | python | def _print_installed_apps(self, controller):
"""Print out a list of installed sprockets applications
:param str controller: The name of the controller to get apps for
"""
print('\nInstalled Sprockets %s Apps\n' % controller.upper())
print("{0:<25} {1:>25}".format('Name', 'Module... | [
"def",
"_print_installed_apps",
"(",
"self",
",",
"controller",
")",
":",
"print",
"(",
"'\\nInstalled Sprockets %s Apps\\n'",
"%",
"controller",
".",
"upper",
"(",
")",
")",
"print",
"(",
"\"{0:<25} {1:>25}\"",
".",
"format",
"(",
"'Name'",
",",
"'Module'",
")"... | Print out a list of installed sprockets applications
:param str controller: The name of the controller to get apps for | [
"Print",
"out",
"a",
"list",
"of",
"installed",
"sprockets",
"applications"
] | 089dbaf04da54afd95645fce31f4ff9c8bdd8fae | https://github.com/sprockets/sprockets/blob/089dbaf04da54afd95645fce31f4ff9c8bdd8fae/sprockets/cli.py#L249-L259 |
245,224 | kankiri/pabiana | pabiana/abcs.py | Node.rslv | def rslv(self, interface: str, name: str=None) -> Tuple[str, int, Optional[str]]:
"""Return the IP address, port and optionally host IP for one of this Nodes interfaces."""
if name is None:
name = self.name
key = '{}-{}'.format(name, interface)
host = None
if 'host' in self.interfaces[key]:
host = self.... | python | def rslv(self, interface: str, name: str=None) -> Tuple[str, int, Optional[str]]:
"""Return the IP address, port and optionally host IP for one of this Nodes interfaces."""
if name is None:
name = self.name
key = '{}-{}'.format(name, interface)
host = None
if 'host' in self.interfaces[key]:
host = self.... | [
"def",
"rslv",
"(",
"self",
",",
"interface",
":",
"str",
",",
"name",
":",
"str",
"=",
"None",
")",
"->",
"Tuple",
"[",
"str",
",",
"int",
",",
"Optional",
"[",
"str",
"]",
"]",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"self",
".",
... | Return the IP address, port and optionally host IP for one of this Nodes interfaces. | [
"Return",
"the",
"IP",
"address",
"port",
"and",
"optionally",
"host",
"IP",
"for",
"one",
"of",
"this",
"Nodes",
"interfaces",
"."
] | 74acfdd81e2a1cc411c37b9ee3d6905ce4b1a39b | https://github.com/kankiri/pabiana/blob/74acfdd81e2a1cc411c37b9ee3d6905ce4b1a39b/pabiana/abcs.py#L23-L31 |
245,225 | kankiri/pabiana | pabiana/abcs.py | Area.trigger | def trigger(self, target: str, trigger: str, parameters: Dict[str, Any]={}):
"""Calls the specified Trigger of another Area with the optionally given parameters.
Args:
target: The name of the target Area.
trigger: The name of the Trigger.
parameters: The parameters of the function call.
"""
pass | python | def trigger(self, target: str, trigger: str, parameters: Dict[str, Any]={}):
"""Calls the specified Trigger of another Area with the optionally given parameters.
Args:
target: The name of the target Area.
trigger: The name of the Trigger.
parameters: The parameters of the function call.
"""
pass | [
"def",
"trigger",
"(",
"self",
",",
"target",
":",
"str",
",",
"trigger",
":",
"str",
",",
"parameters",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"{",
"}",
")",
":",
"pass"
] | Calls the specified Trigger of another Area with the optionally given parameters.
Args:
target: The name of the target Area.
trigger: The name of the Trigger.
parameters: The parameters of the function call. | [
"Calls",
"the",
"specified",
"Trigger",
"of",
"another",
"Area",
"with",
"the",
"optionally",
"given",
"parameters",
"."
] | 74acfdd81e2a1cc411c37b9ee3d6905ce4b1a39b | https://github.com/kankiri/pabiana/blob/74acfdd81e2a1cc411c37b9ee3d6905ce4b1a39b/pabiana/abcs.py#L69-L77 |
245,226 | iskandr/tinytimer | microbench/__init__.py | benchmark | def benchmark(f, n_repeats=3, warmup=True, name=""):
"""
Run the given function f repeatedly, return the average elapsed time.
"""
if warmup:
f()
total_time = 0
for i in range(n_repeats):
iter_name = "%s (iter #%d)" % (name, i + 1,)
with Timer(iter_name) as t:
... | python | def benchmark(f, n_repeats=3, warmup=True, name=""):
"""
Run the given function f repeatedly, return the average elapsed time.
"""
if warmup:
f()
total_time = 0
for i in range(n_repeats):
iter_name = "%s (iter #%d)" % (name, i + 1,)
with Timer(iter_name) as t:
... | [
"def",
"benchmark",
"(",
"f",
",",
"n_repeats",
"=",
"3",
",",
"warmup",
"=",
"True",
",",
"name",
"=",
"\"\"",
")",
":",
"if",
"warmup",
":",
"f",
"(",
")",
"total_time",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"n_repeats",
")",
":",
"iter_nam... | Run the given function f repeatedly, return the average elapsed time. | [
"Run",
"the",
"given",
"function",
"f",
"repeatedly",
"return",
"the",
"average",
"elapsed",
"time",
"."
] | ddedd6099e51bdccb2c506f34d31ff08aef15685 | https://github.com/iskandr/tinytimer/blob/ddedd6099e51bdccb2c506f34d31ff08aef15685/microbench/__init__.py#L41-L54 |
245,227 | MakerReduxCorp/PLOD | PLOD/internal.py | convert_to_dict | def convert_to_dict(item):
'''Examine an item of any type and return a true dictionary.
If the item is already a dictionary, then the item is returned as-is. Easy.
Otherwise, it attempts to interpret it. So far, this routine can handle:
* a class, function, or anything with a .__dict__ entry
... | python | def convert_to_dict(item):
'''Examine an item of any type and return a true dictionary.
If the item is already a dictionary, then the item is returned as-is. Easy.
Otherwise, it attempts to interpret it. So far, this routine can handle:
* a class, function, or anything with a .__dict__ entry
... | [
"def",
"convert_to_dict",
"(",
"item",
")",
":",
"# get type",
"actual_type",
"=",
"detect_type",
"(",
"item",
")",
"# given the type, do conversion",
"if",
"actual_type",
"==",
"\"dict\"",
":",
"return",
"item",
"elif",
"actual_type",
"==",
"\"list\"",
":",
"temp... | Examine an item of any type and return a true dictionary.
If the item is already a dictionary, then the item is returned as-is. Easy.
Otherwise, it attempts to interpret it. So far, this routine can handle:
* a class, function, or anything with a .__dict__ entry
* a legacy mongoEngine document (a... | [
"Examine",
"an",
"item",
"of",
"any",
"type",
"and",
"return",
"a",
"true",
"dictionary",
"."
] | 707502cd928e5be6bd5e46d7f6de7da0e188cf1e | https://github.com/MakerReduxCorp/PLOD/blob/707502cd928e5be6bd5e46d7f6de7da0e188cf1e/PLOD/internal.py#L22-L70 |
245,228 | MakerReduxCorp/PLOD | PLOD/internal.py | do_op | def do_op(field, op, value):
''' used for comparisons '''
if op==NOOP:
return True
if field==None:
if value==None:
return True
else:
return False
if value==None:
return False
if op==LESS:
return (field < value)
if op==LESSorEQUAL:
... | python | def do_op(field, op, value):
''' used for comparisons '''
if op==NOOP:
return True
if field==None:
if value==None:
return True
else:
return False
if value==None:
return False
if op==LESS:
return (field < value)
if op==LESSorEQUAL:
... | [
"def",
"do_op",
"(",
"field",
",",
"op",
",",
"value",
")",
":",
"if",
"op",
"==",
"NOOP",
":",
"return",
"True",
"if",
"field",
"==",
"None",
":",
"if",
"value",
"==",
"None",
":",
"return",
"True",
"else",
":",
"return",
"False",
"if",
"value",
... | used for comparisons | [
"used",
"for",
"comparisons"
] | 707502cd928e5be6bd5e46d7f6de7da0e188cf1e | https://github.com/MakerReduxCorp/PLOD/blob/707502cd928e5be6bd5e46d7f6de7da0e188cf1e/PLOD/internal.py#L212-L261 |
245,229 | MakerReduxCorp/PLOD | PLOD/internal.py | get_value | def get_value(row, field_name):
'''
Returns the value found in the field_name attribute of the row dictionary.
'''
result = None
dict_row = convert_to_dict(row)
if detect_list(field_name):
temp = row
for field in field_name:
dict_temp = convert_to_dict(temp)
... | python | def get_value(row, field_name):
'''
Returns the value found in the field_name attribute of the row dictionary.
'''
result = None
dict_row = convert_to_dict(row)
if detect_list(field_name):
temp = row
for field in field_name:
dict_temp = convert_to_dict(temp)
... | [
"def",
"get_value",
"(",
"row",
",",
"field_name",
")",
":",
"result",
"=",
"None",
"dict_row",
"=",
"convert_to_dict",
"(",
"row",
")",
"if",
"detect_list",
"(",
"field_name",
")",
":",
"temp",
"=",
"row",
"for",
"field",
"in",
"field_name",
":",
"dict_... | Returns the value found in the field_name attribute of the row dictionary. | [
"Returns",
"the",
"value",
"found",
"in",
"the",
"field_name",
"attribute",
"of",
"the",
"row",
"dictionary",
"."
] | 707502cd928e5be6bd5e46d7f6de7da0e188cf1e | https://github.com/MakerReduxCorp/PLOD/blob/707502cd928e5be6bd5e46d7f6de7da0e188cf1e/PLOD/internal.py#L280-L294 |
245,230 | MakerReduxCorp/PLOD | PLOD/internal.py | select | def select(table, index_track, field_name, op, value, includeMissing):
'''Modifies the table and index_track lists based on the comparison.
'''
result = []
result_index = []
counter = 0
for row in table:
if detect_fields(field_name, convert_to_dict(row)):
final_value = get_va... | python | def select(table, index_track, field_name, op, value, includeMissing):
'''Modifies the table and index_track lists based on the comparison.
'''
result = []
result_index = []
counter = 0
for row in table:
if detect_fields(field_name, convert_to_dict(row)):
final_value = get_va... | [
"def",
"select",
"(",
"table",
",",
"index_track",
",",
"field_name",
",",
"op",
",",
"value",
",",
"includeMissing",
")",
":",
"result",
"=",
"[",
"]",
"result_index",
"=",
"[",
"]",
"counter",
"=",
"0",
"for",
"row",
"in",
"table",
":",
"if",
"dete... | Modifies the table and index_track lists based on the comparison. | [
"Modifies",
"the",
"table",
"and",
"index_track",
"lists",
"based",
"on",
"the",
"comparison",
"."
] | 707502cd928e5be6bd5e46d7f6de7da0e188cf1e | https://github.com/MakerReduxCorp/PLOD/blob/707502cd928e5be6bd5e46d7f6de7da0e188cf1e/PLOD/internal.py#L312-L331 |
245,231 | pudo-attic/loadkit | loadkit/logger.py | capture | def capture(package, prefix, modules=[], level=logging.DEBUG):
""" Capture log messages for the given modules and archive
them to a ``LogFile`` resource. """
handler = LogFileHandler(package, prefix)
formatter = logging.Formatter(FORMAT)
handler.setFormatter(formatter)
modules = set(modules + ['... | python | def capture(package, prefix, modules=[], level=logging.DEBUG):
""" Capture log messages for the given modules and archive
them to a ``LogFile`` resource. """
handler = LogFileHandler(package, prefix)
formatter = logging.Formatter(FORMAT)
handler.setFormatter(formatter)
modules = set(modules + ['... | [
"def",
"capture",
"(",
"package",
",",
"prefix",
",",
"modules",
"=",
"[",
"]",
",",
"level",
"=",
"logging",
".",
"DEBUG",
")",
":",
"handler",
"=",
"LogFileHandler",
"(",
"package",
",",
"prefix",
")",
"formatter",
"=",
"logging",
".",
"Formatter",
"... | Capture log messages for the given modules and archive
them to a ``LogFile`` resource. | [
"Capture",
"log",
"messages",
"for",
"the",
"given",
"modules",
"and",
"archive",
"them",
"to",
"a",
"LogFile",
"resource",
"."
] | 1fb17e69e2ffaf3dac4f40b574c3b7afb2198b7c | https://github.com/pudo-attic/loadkit/blob/1fb17e69e2ffaf3dac4f40b574c3b7afb2198b7c/loadkit/logger.py#L32-L46 |
245,232 | pudo-attic/loadkit | loadkit/logger.py | load | def load(package, prefix, offset=0, limit=1000):
""" Load lines from the log file with pagination support. """
logs = package.all(LogFile, unicode(prefix))
logs = sorted(logs, key=lambda l: l.name, reverse=True)
seen = 0
record = None
tmp = tempfile.NamedTemporaryFile(suffix='.log')
for log ... | python | def load(package, prefix, offset=0, limit=1000):
""" Load lines from the log file with pagination support. """
logs = package.all(LogFile, unicode(prefix))
logs = sorted(logs, key=lambda l: l.name, reverse=True)
seen = 0
record = None
tmp = tempfile.NamedTemporaryFile(suffix='.log')
for log ... | [
"def",
"load",
"(",
"package",
",",
"prefix",
",",
"offset",
"=",
"0",
",",
"limit",
"=",
"1000",
")",
":",
"logs",
"=",
"package",
".",
"all",
"(",
"LogFile",
",",
"unicode",
"(",
"prefix",
")",
")",
"logs",
"=",
"sorted",
"(",
"logs",
",",
"key... | Load lines from the log file with pagination support. | [
"Load",
"lines",
"from",
"the",
"log",
"file",
"with",
"pagination",
"support",
"."
] | 1fb17e69e2ffaf3dac4f40b574c3b7afb2198b7c | https://github.com/pudo-attic/loadkit/blob/1fb17e69e2ffaf3dac4f40b574c3b7afb2198b7c/loadkit/logger.py#L49-L77 |
245,233 | limpyd/redis-limpyd-jobs | example.py | clean | def clean():
"""
Clean data created by this script
"""
for queue in MyQueue.collection().instances():
queue.delete()
for job in MyJob.collection().instances():
job.delete()
for person in Person.collection().instances():
person.delete() | python | def clean():
"""
Clean data created by this script
"""
for queue in MyQueue.collection().instances():
queue.delete()
for job in MyJob.collection().instances():
job.delete()
for person in Person.collection().instances():
person.delete() | [
"def",
"clean",
"(",
")",
":",
"for",
"queue",
"in",
"MyQueue",
".",
"collection",
"(",
")",
".",
"instances",
"(",
")",
":",
"queue",
".",
"delete",
"(",
")",
"for",
"job",
"in",
"MyJob",
".",
"collection",
"(",
")",
".",
"instances",
"(",
")",
... | Clean data created by this script | [
"Clean",
"data",
"created",
"by",
"this",
"script"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/example.py#L164-L173 |
245,234 | limpyd/redis-limpyd-jobs | example.py | MyJob.run | def run(self, queue):
"""
Create the fullname, and store a a message serving as result in the job
"""
# add some random time to simulate a long job
time.sleep(random.random())
# compute the fullname
obj = self.get_object()
obj.fullname.hset('%s %s' % tupl... | python | def run(self, queue):
"""
Create the fullname, and store a a message serving as result in the job
"""
# add some random time to simulate a long job
time.sleep(random.random())
# compute the fullname
obj = self.get_object()
obj.fullname.hset('%s %s' % tupl... | [
"def",
"run",
"(",
"self",
",",
"queue",
")",
":",
"# add some random time to simulate a long job",
"time",
".",
"sleep",
"(",
"random",
".",
"random",
"(",
")",
")",
"# compute the fullname",
"obj",
"=",
"self",
".",
"get_object",
"(",
")",
"obj",
".",
"ful... | Create the fullname, and store a a message serving as result in the job | [
"Create",
"the",
"fullname",
"and",
"store",
"a",
"a",
"message",
"serving",
"as",
"result",
"in",
"the",
"job"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/example.py#L58-L76 |
245,235 | limpyd/redis-limpyd-jobs | example.py | FullNameWorker.job_success | def job_success(self, job, queue, job_result):
"""
Update the queue's dates and number of jobs managed, and save into the
job the result received by the callback.
"""
# display what was done
obj = job.get_object()
message = '[%s|%s] %s [%s]' % (queue.name.hget(),... | python | def job_success(self, job, queue, job_result):
"""
Update the queue's dates and number of jobs managed, and save into the
job the result received by the callback.
"""
# display what was done
obj = job.get_object()
message = '[%s|%s] %s [%s]' % (queue.name.hget(),... | [
"def",
"job_success",
"(",
"self",
",",
"job",
",",
"queue",
",",
"job_result",
")",
":",
"# display what was done",
"obj",
"=",
"job",
".",
"get_object",
"(",
")",
"message",
"=",
"'[%s|%s] %s [%s]'",
"%",
"(",
"queue",
".",
"name",
".",
"hget",
"(",
")... | Update the queue's dates and number of jobs managed, and save into the
job the result received by the callback. | [
"Update",
"the",
"queue",
"s",
"dates",
"and",
"number",
"of",
"jobs",
"managed",
"and",
"save",
"into",
"the",
"job",
"the",
"result",
"received",
"by",
"the",
"callback",
"."
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/example.py#L122-L151 |
245,236 | quasipedia/swaggery | swaggery/introspection/introspection.py | ResourceListing.resource_listing | def resource_listing(cls, request) -> [(200, 'Ok', ResourceListingModel)]:
'''Return the list of all available resources on the system.
Resources are filtered according to the permission system, so querying
this resource as different users may bare different results.'''
apis = [api.get_... | python | def resource_listing(cls, request) -> [(200, 'Ok', ResourceListingModel)]:
'''Return the list of all available resources on the system.
Resources are filtered according to the permission system, so querying
this resource as different users may bare different results.'''
apis = [api.get_... | [
"def",
"resource_listing",
"(",
"cls",
",",
"request",
")",
"->",
"[",
"(",
"200",
",",
"'Ok'",
",",
"ResourceListingModel",
")",
"]",
":",
"apis",
"=",
"[",
"api",
".",
"get_swagger_fragment",
"(",
")",
"for",
"api",
"in",
"Api",
"if",
"not",
"api",
... | Return the list of all available resources on the system.
Resources are filtered according to the permission system, so querying
this resource as different users may bare different results. | [
"Return",
"the",
"list",
"of",
"all",
"available",
"resources",
"on",
"the",
"system",
"."
] | 89a2e1b2bebbc511c781c9e63972f65aef73cc2f | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/introspection/introspection.py#L45-L55 |
245,237 | quasipedia/swaggery | swaggery/introspection/introspection.py | ApiDeclaration._extract_models | def _extract_models(cls, apis):
'''An helper function to extract all used models from the apis.'''
# TODO: This would probably be much better if the info would be
# extracted from the classes, rather than from the swagger
# representation...
models = set()
for api in apis... | python | def _extract_models(cls, apis):
'''An helper function to extract all used models from the apis.'''
# TODO: This would probably be much better if the info would be
# extracted from the classes, rather than from the swagger
# representation...
models = set()
for api in apis... | [
"def",
"_extract_models",
"(",
"cls",
",",
"apis",
")",
":",
"# TODO: This would probably be much better if the info would be",
"# extracted from the classes, rather than from the swagger",
"# representation...",
"models",
"=",
"set",
"(",
")",
"for",
"api",
"in",
"apis",
":"... | An helper function to extract all used models from the apis. | [
"An",
"helper",
"function",
"to",
"extract",
"all",
"used",
"models",
"from",
"the",
"apis",
"."
] | 89a2e1b2bebbc511c781c9e63972f65aef73cc2f | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/introspection/introspection.py#L68-L90 |
245,238 | quasipedia/swaggery | swaggery/introspection/introspection.py | ApiDeclaration.api_declaration | def api_declaration(
cls, request,
api_path: (Ptypes.path,
String('The path for the info on the resource.'))) -> [
(200, 'Ok', ApiDeclarationModel),
(404, 'Not a valid resource.')]:
'''Return the complete specification of a single API.
... | python | def api_declaration(
cls, request,
api_path: (Ptypes.path,
String('The path for the info on the resource.'))) -> [
(200, 'Ok', ApiDeclarationModel),
(404, 'Not a valid resource.')]:
'''Return the complete specification of a single API.
... | [
"def",
"api_declaration",
"(",
"cls",
",",
"request",
",",
"api_path",
":",
"(",
"Ptypes",
".",
"path",
",",
"String",
"(",
"'The path for the info on the resource.'",
")",
")",
")",
"->",
"[",
"(",
"200",
",",
"'Ok'",
",",
"ApiDeclarationModel",
")",
",",
... | Return the complete specification of a single API.
Resources are filtered according to the permission system, so querying
this resource as different users may bare different results. | [
"Return",
"the",
"complete",
"specification",
"of",
"a",
"single",
"API",
"."
] | 89a2e1b2bebbc511c781c9e63972f65aef73cc2f | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/introspection/introspection.py#L93-L121 |
245,239 | ppo/django-guitar | guitar/middlewares.py | GuitarMiddleware._get_route_info | def _get_route_info(self, request):
"""Return information about the current URL."""
resolve_match = resolve(request.path)
app_name = resolve_match.app_name # The application namespace for the URL pattern that matches the URL.
namespace = resolve_match.namespace # The instance namesp... | python | def _get_route_info(self, request):
"""Return information about the current URL."""
resolve_match = resolve(request.path)
app_name = resolve_match.app_name # The application namespace for the URL pattern that matches the URL.
namespace = resolve_match.namespace # The instance namesp... | [
"def",
"_get_route_info",
"(",
"self",
",",
"request",
")",
":",
"resolve_match",
"=",
"resolve",
"(",
"request",
".",
"path",
")",
"app_name",
"=",
"resolve_match",
".",
"app_name",
"# The application namespace for the URL pattern that matches the URL.",
"namespace",
"... | Return information about the current URL. | [
"Return",
"information",
"about",
"the",
"current",
"URL",
"."
] | 857282219c0c4ff5907c3ad04ef012281d245348 | https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/middlewares.py#L24-L38 |
245,240 | delfick/aws_syncr | aws_syncr/amazon/amazon.py | Amazon.validate_account | def validate_account(self):
"""Make sure we are able to connect to the right account"""
self._validating = True
with self.catch_invalid_credentials():
log.info("Finding a role to check the account id")
a_role = list(self.iam.resource.roles.limit(1))
if not a_r... | python | def validate_account(self):
"""Make sure we are able to connect to the right account"""
self._validating = True
with self.catch_invalid_credentials():
log.info("Finding a role to check the account id")
a_role = list(self.iam.resource.roles.limit(1))
if not a_r... | [
"def",
"validate_account",
"(",
"self",
")",
":",
"self",
".",
"_validating",
"=",
"True",
"with",
"self",
".",
"catch_invalid_credentials",
"(",
")",
":",
"log",
".",
"info",
"(",
"\"Finding a role to check the account id\"",
")",
"a_role",
"=",
"list",
"(",
... | Make sure we are able to connect to the right account | [
"Make",
"sure",
"we",
"are",
"able",
"to",
"connect",
"to",
"the",
"right",
"account"
] | 8cd214b27c1eee98dfba4632cbb8bc0ae36356bd | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/amazon/amazon.py#L46-L61 |
245,241 | rameshg87/pyremotevbox | pyremotevbox/ZSI/ServiceContainer.py | SOAPRequestHandler.do_GET | def do_GET(self):
'''The GET command.
'''
if self.path.lower().endswith("?wsdl"):
service_path = self.path[:-5]
service = self.server.getNode(service_path)
if hasattr(service, "_wsdl"):
wsdl = service._wsdl
# update the soap:location t... | python | def do_GET(self):
'''The GET command.
'''
if self.path.lower().endswith("?wsdl"):
service_path = self.path[:-5]
service = self.server.getNode(service_path)
if hasattr(service, "_wsdl"):
wsdl = service._wsdl
# update the soap:location t... | [
"def",
"do_GET",
"(",
"self",
")",
":",
"if",
"self",
".",
"path",
".",
"lower",
"(",
")",
".",
"endswith",
"(",
"\"?wsdl\"",
")",
":",
"service_path",
"=",
"self",
".",
"path",
"[",
":",
"-",
"5",
"]",
"service",
"=",
"self",
".",
"server",
".",... | The GET command. | [
"The",
"GET",
"command",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/ServiceContainer.py#L357-L382 |
245,242 | laurenceputra/mongo_notebook_manager | mongo_notebook_manager/__init__.py | MongoNotebookManager.get_notebook_names | def get_notebook_names(self, path=''):
"""List all notebook names in the notebook dir and path."""
path = path.strip('/')
spec = {'path': path,
'type': 'notebook'}
fields = {'name': 1}
notebooks = list(self._connect_collection(self.notebook_collection).find(spec,f... | python | def get_notebook_names(self, path=''):
"""List all notebook names in the notebook dir and path."""
path = path.strip('/')
spec = {'path': path,
'type': 'notebook'}
fields = {'name': 1}
notebooks = list(self._connect_collection(self.notebook_collection).find(spec,f... | [
"def",
"get_notebook_names",
"(",
"self",
",",
"path",
"=",
"''",
")",
":",
"path",
"=",
"path",
".",
"strip",
"(",
"'/'",
")",
"spec",
"=",
"{",
"'path'",
":",
"path",
",",
"'type'",
":",
"'notebook'",
"}",
"fields",
"=",
"{",
"'name'",
":",
"1",
... | List all notebook names in the notebook dir and path. | [
"List",
"all",
"notebook",
"names",
"in",
"the",
"notebook",
"dir",
"and",
"path",
"."
] | d7f4031e236ff19b8f0658f8ad1fcd1b51815251 | https://github.com/laurenceputra/mongo_notebook_manager/blob/d7f4031e236ff19b8f0658f8ad1fcd1b51815251/mongo_notebook_manager/__init__.py#L65-L73 |
245,243 | laurenceputra/mongo_notebook_manager | mongo_notebook_manager/__init__.py | MongoNotebookManager.create_notebook | def create_notebook(self, model=None, path=''):
"""Create a new notebook and return its model with no content."""
path = path.strip('/')
if model is None:
model = {}
if 'content' not in model:
metadata = current.new_metadata(name=u'')
model['content'] ... | python | def create_notebook(self, model=None, path=''):
"""Create a new notebook and return its model with no content."""
path = path.strip('/')
if model is None:
model = {}
if 'content' not in model:
metadata = current.new_metadata(name=u'')
model['content'] ... | [
"def",
"create_notebook",
"(",
"self",
",",
"model",
"=",
"None",
",",
"path",
"=",
"''",
")",
":",
"path",
"=",
"path",
".",
"strip",
"(",
"'/'",
")",
"if",
"model",
"is",
"None",
":",
"model",
"=",
"{",
"}",
"if",
"'content'",
"not",
"in",
"mod... | Create a new notebook and return its model with no content. | [
"Create",
"a",
"new",
"notebook",
"and",
"return",
"its",
"model",
"with",
"no",
"content",
"."
] | d7f4031e236ff19b8f0658f8ad1fcd1b51815251 | https://github.com/laurenceputra/mongo_notebook_manager/blob/d7f4031e236ff19b8f0658f8ad1fcd1b51815251/mongo_notebook_manager/__init__.py#L202-L217 |
245,244 | mweb/appconfig | appconfig/appconfig.py | _get_type | def _get_type(stype):
''' Get the python type for a given string describtion for a type.
@param stype: The string representing the type to return
@return: The python type if available
'''
stype = stype.lower()
if stype == 'str':
return str
if stype == 'unicode':
if P... | python | def _get_type(stype):
''' Get the python type for a given string describtion for a type.
@param stype: The string representing the type to return
@return: The python type if available
'''
stype = stype.lower()
if stype == 'str':
return str
if stype == 'unicode':
if P... | [
"def",
"_get_type",
"(",
"stype",
")",
":",
"stype",
"=",
"stype",
".",
"lower",
"(",
")",
"if",
"stype",
"==",
"'str'",
":",
"return",
"str",
"if",
"stype",
"==",
"'unicode'",
":",
"if",
"PY2",
":",
"return",
"unicode",
"else",
":",
"return",
"str",... | Get the python type for a given string describtion for a type.
@param stype: The string representing the type to return
@return: The python type if available | [
"Get",
"the",
"python",
"type",
"for",
"a",
"given",
"string",
"describtion",
"for",
"a",
"type",
"."
] | 780c1fe3b2f537463a46e335186b7741add88a1e | https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L347-L367 |
245,245 | mweb/appconfig | appconfig/appconfig.py | _format_message | def _format_message(value, line_length, indent="", first_indent=None):
''' Return a string with newlines so that the given string fits into this
line length. At the start of the line the indent is added. This can
be used for commenting the message out within a file or to indent your
text.
... | python | def _format_message(value, line_length, indent="", first_indent=None):
''' Return a string with newlines so that the given string fits into this
line length. At the start of the line the indent is added. This can
be used for commenting the message out within a file or to indent your
text.
... | [
"def",
"_format_message",
"(",
"value",
",",
"line_length",
",",
"indent",
"=",
"\"\"",
",",
"first_indent",
"=",
"None",
")",
":",
"if",
"indent",
".",
"find",
"(",
"'\\t'",
")",
":",
"indent",
"=",
"indent",
".",
"replace",
"(",
"'\\t'",
",",
"' '... | Return a string with newlines so that the given string fits into this
line length. At the start of the line the indent is added. This can
be used for commenting the message out within a file or to indent your
text.
All \\t will be replaced with 4 spaces.
@param value: The strin... | [
"Return",
"a",
"string",
"with",
"newlines",
"so",
"that",
"the",
"given",
"string",
"fits",
"into",
"this",
"line",
"length",
".",
"At",
"the",
"start",
"of",
"the",
"line",
"the",
"indent",
"is",
"added",
".",
"This",
"can",
"be",
"used",
"for",
"com... | 780c1fe3b2f537463a46e335186b7741add88a1e | https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L370-L407 |
245,246 | mweb/appconfig | appconfig/appconfig.py | AppConfig.init_default_config | def init_default_config(self, path):
''' Initialize the config object and load the default configuration.
The path to the config file must be provided. The name of the
application is read from the config file.
The config file stores the description and the default values for
... | python | def init_default_config(self, path):
''' Initialize the config object and load the default configuration.
The path to the config file must be provided. The name of the
application is read from the config file.
The config file stores the description and the default values for
... | [
"def",
"init_default_config",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"(",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
")",
":",
"raise",
"AppConfigValueException",
"(",
"'Th... | Initialize the config object and load the default configuration.
The path to the config file must be provided. The name of the
application is read from the config file.
The config file stores the description and the default values for
all configurations including the appl... | [
"Initialize",
"the",
"config",
"object",
"and",
"load",
"the",
"default",
"configuration",
".",
"The",
"path",
"to",
"the",
"config",
"file",
"must",
"be",
"provided",
".",
"The",
"name",
"of",
"the",
"application",
"is",
"read",
"from",
"the",
"config",
"... | 780c1fe3b2f537463a46e335186b7741add88a1e | https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L77-L102 |
245,247 | mweb/appconfig | appconfig/appconfig.py | AppConfig.get_description | def get_description(self, section, key):
''' Get the description of a config key. If it does not exist an
Exception will be thrown.
@param section: the section where the key is stored.
@param key: the key to get the description for.
@return: A tuple with thre... | python | def get_description(self, section, key):
''' Get the description of a config key. If it does not exist an
Exception will be thrown.
@param section: the section where the key is stored.
@param key: the key to get the description for.
@return: A tuple with thre... | [
"def",
"get_description",
"(",
"self",
",",
"section",
",",
"key",
")",
":",
"if",
"section",
"in",
"self",
".",
"config_description",
":",
"if",
"key",
"in",
"self",
".",
"config_description",
"[",
"section",
"]",
":",
"desc",
",",
"value_type",
",",
"d... | Get the description of a config key. If it does not exist an
Exception will be thrown.
@param section: the section where the key is stored.
@param key: the key to get the description for.
@return: A tuple with three elements (description, type, default) | [
"Get",
"the",
"description",
"of",
"a",
"config",
"key",
".",
"If",
"it",
"does",
"not",
"exist",
"an",
"Exception",
"will",
"be",
"thrown",
"."
] | 780c1fe3b2f537463a46e335186b7741add88a1e | https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L104-L134 |
245,248 | mweb/appconfig | appconfig/appconfig.py | AppConfig.load_default | def load_default(self):
''' Load the default config files.
First the global config file then the user config file.
'''
appdir = AppDirs(self.application_name, self.application_author,
version=self.application_version)
file_name = os.path.join(appdir.site_data_... | python | def load_default(self):
''' Load the default config files.
First the global config file then the user config file.
'''
appdir = AppDirs(self.application_name, self.application_author,
version=self.application_version)
file_name = os.path.join(appdir.site_data_... | [
"def",
"load_default",
"(",
"self",
")",
":",
"appdir",
"=",
"AppDirs",
"(",
"self",
".",
"application_name",
",",
"self",
".",
"application_author",
",",
"version",
"=",
"self",
".",
"application_version",
")",
"file_name",
"=",
"os",
".",
"path",
".",
"j... | Load the default config files.
First the global config file then the user config file. | [
"Load",
"the",
"default",
"config",
"files",
".",
"First",
"the",
"global",
"config",
"file",
"then",
"the",
"user",
"config",
"file",
"."
] | 780c1fe3b2f537463a46e335186b7741add88a1e | https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L136-L150 |
245,249 | mweb/appconfig | appconfig/appconfig.py | AppConfig.load | def load(self, filename):
''' Load the given config file.
@param filename: the filename including the path to load.
'''
if not os.path.exists(filename):
#print 'Could not load config file [%s]' % (filename)
raise AppConfigValueException('Could not load config... | python | def load(self, filename):
''' Load the given config file.
@param filename: the filename including the path to load.
'''
if not os.path.exists(filename):
#print 'Could not load config file [%s]' % (filename)
raise AppConfigValueException('Could not load config... | [
"def",
"load",
"(",
"self",
",",
"filename",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"#print 'Could not load config file [%s]' % (filename)",
"raise",
"AppConfigValueException",
"(",
"'Could not load config file {0}'",
".",
... | Load the given config file.
@param filename: the filename including the path to load. | [
"Load",
"the",
"given",
"config",
"file",
"."
] | 780c1fe3b2f537463a46e335186b7741add88a1e | https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L152-L166 |
245,250 | mweb/appconfig | appconfig/appconfig.py | AppConfig.get | def get(self, section, key):
''' Get the value of a key in the given section. It will automatically
translate the paramter type if the parameter has a type specified
with the description.
@param section: the section where the key can be found.
@param key: the key... | python | def get(self, section, key):
''' Get the value of a key in the given section. It will automatically
translate the paramter type if the parameter has a type specified
with the description.
@param section: the section where the key can be found.
@param key: the key... | [
"def",
"get",
"(",
"self",
",",
"section",
",",
"key",
")",
":",
"section",
"=",
"section",
".",
"lower",
"(",
")",
"key",
"=",
"key",
".",
"lower",
"(",
")",
"descr",
",",
"value_type",
",",
"default",
"=",
"self",
".",
"get_description",
"(",
"se... | Get the value of a key in the given section. It will automatically
translate the paramter type if the parameter has a type specified
with the description.
@param section: the section where the key can be found.
@param key: the key the value is stored under.
@... | [
"Get",
"the",
"value",
"of",
"a",
"key",
"in",
"the",
"given",
"section",
".",
"It",
"will",
"automatically",
"translate",
"the",
"paramter",
"type",
"if",
"the",
"parameter",
"has",
"a",
"type",
"specified",
"with",
"the",
"description",
"."
] | 780c1fe3b2f537463a46e335186b7741add88a1e | https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L168-L196 |
245,251 | mweb/appconfig | appconfig/appconfig.py | AppConfig.set | def set(self, section, key, value):
''' Set the value for a key in the given section. It will check the
type of the value if it is available. If the value is not from
the given type it will be transformed to the type.
An exception will be thrown if there is a problem with the... | python | def set(self, section, key, value):
''' Set the value for a key in the given section. It will check the
type of the value if it is available. If the value is not from
the given type it will be transformed to the type.
An exception will be thrown if there is a problem with the... | [
"def",
"set",
"(",
"self",
",",
"section",
",",
"key",
",",
"value",
")",
":",
"value_type",
"=",
"str",
"if",
"self",
".",
"has_option",
"(",
"section",
",",
"key",
")",
":",
"descr",
",",
"value_type",
",",
"default",
"=",
"self",
".",
"get_descrip... | Set the value for a key in the given section. It will check the
type of the value if it is available. If the value is not from
the given type it will be transformed to the type.
An exception will be thrown if there is a problem with the
conversion.
@param sec... | [
"Set",
"the",
"value",
"for",
"a",
"key",
"in",
"the",
"given",
"section",
".",
"It",
"will",
"check",
"the",
"type",
"of",
"the",
"value",
"if",
"it",
"is",
"available",
".",
"If",
"the",
"value",
"is",
"not",
"from",
"the",
"given",
"type",
"it",
... | 780c1fe3b2f537463a46e335186b7741add88a1e | https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L198-L234 |
245,252 | mweb/appconfig | appconfig/appconfig.py | AppConfig.save | def save(self, filename=None, verbose=False):
''' Save the config to the given file or to given default location.
@param filename: the file to write the config
@param verbose: If set to true the config file will have all values
and all descriptions
'''
... | python | def save(self, filename=None, verbose=False):
''' Save the config to the given file or to given default location.
@param filename: the file to write the config
@param verbose: If set to true the config file will have all values
and all descriptions
'''
... | [
"def",
"save",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"filename",
"is",
"None",
":",
"if",
"(",
"not",
"self",
".",
"has_section",
"(",
"self",
".",
"application_name",
")",
"or",
"not",
"self",
".",
... | Save the config to the given file or to given default location.
@param filename: the file to write the config
@param verbose: If set to true the config file will have all values
and all descriptions | [
"Save",
"the",
"config",
"to",
"the",
"given",
"file",
"or",
"to",
"given",
"default",
"location",
"."
] | 780c1fe3b2f537463a46e335186b7741add88a1e | https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L236-L282 |
245,253 | mweb/appconfig | appconfig/appconfig.py | AppConfig._write_config | def _write_config(self, filedesc, verbose=False):
''' Write the current config to the given filedescriptor which has must
be opened for writing.
Only the config values different from the default value are written
If the verbose switch is turned on the config file generated w... | python | def _write_config(self, filedesc, verbose=False):
''' Write the current config to the given filedescriptor which has must
be opened for writing.
Only the config values different from the default value are written
If the verbose switch is turned on the config file generated w... | [
"def",
"_write_config",
"(",
"self",
",",
"filedesc",
",",
"verbose",
"=",
"False",
")",
":",
"desc",
"=",
"[",
"]",
"for",
"section",
"in",
"self",
".",
"sections",
"(",
")",
":",
"if",
"section",
".",
"lower",
"(",
")",
"in",
"(",
"''",
",",
"'... | Write the current config to the given filedescriptor which has must
be opened for writing.
Only the config values different from the default value are written
If the verbose switch is turned on the config file generated will
have all values including the default values s... | [
"Write",
"the",
"current",
"config",
"to",
"the",
"given",
"filedescriptor",
"which",
"has",
"must",
"be",
"opened",
"for",
"writing",
".",
"Only",
"the",
"config",
"values",
"different",
"from",
"the",
"default",
"value",
"are",
"written"
] | 780c1fe3b2f537463a46e335186b7741add88a1e | https://github.com/mweb/appconfig/blob/780c1fe3b2f537463a46e335186b7741add88a1e/appconfig/appconfig.py#L284-L316 |
245,254 | sassoo/goldman | goldman/serializers/json_7159.py | Serializer.serialize | def serialize(self, data):
""" Call json.dumps & let it rip """
super(Serializer, self).serialize(data)
self.resp.body = json.dumps(data) | python | def serialize(self, data):
""" Call json.dumps & let it rip """
super(Serializer, self).serialize(data)
self.resp.body = json.dumps(data) | [
"def",
"serialize",
"(",
"self",
",",
"data",
")",
":",
"super",
"(",
"Serializer",
",",
"self",
")",
".",
"serialize",
"(",
"data",
")",
"self",
".",
"resp",
".",
"body",
"=",
"json",
".",
"dumps",
"(",
"data",
")"
] | Call json.dumps & let it rip | [
"Call",
"json",
".",
"dumps",
"&",
"let",
"it",
"rip"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/json_7159.py#L21-L25 |
245,255 | evfredericksen/pynacea | pynhost/pynhost/ruleparser.py | surround_previous_word | def surround_previous_word(input_str):
'''
Surround last word in string with parentheses. If last non-whitespace character
is delimiter, do nothing
'''
start = None
end = None
for i, char in enumerate(reversed(input_str)):
if start is None:
if char in '{}()[]<>?|':
... | python | def surround_previous_word(input_str):
'''
Surround last word in string with parentheses. If last non-whitespace character
is delimiter, do nothing
'''
start = None
end = None
for i, char in enumerate(reversed(input_str)):
if start is None:
if char in '{}()[]<>?|':
... | [
"def",
"surround_previous_word",
"(",
"input_str",
")",
":",
"start",
"=",
"None",
"end",
"=",
"None",
"for",
"i",
",",
"char",
"in",
"enumerate",
"(",
"reversed",
"(",
"input_str",
")",
")",
":",
"if",
"start",
"is",
"None",
":",
"if",
"char",
"in",
... | Surround last word in string with parentheses. If last non-whitespace character
is delimiter, do nothing | [
"Surround",
"last",
"word",
"in",
"string",
"with",
"parentheses",
".",
"If",
"last",
"non",
"-",
"whitespace",
"character",
"is",
"delimiter",
"do",
"nothing"
] | 63ee0e6695209048bf2571aa2c3770f502e29b0a | https://github.com/evfredericksen/pynacea/blob/63ee0e6695209048bf2571aa2c3770f502e29b0a/pynhost/pynhost/ruleparser.py#L118-L150 |
245,256 | anoroozian/pyvt | pyvt/__init__.py | API._limit_call_handler | def _limit_call_handler(self):
"""
Ensure we don't exceed the N requests a minute limit by leveraging a thread lock
"""
# acquire a lock on our threading.Lock() object
with self.limit_lock:
# if we have no configured limit, exit. the lock releases based on scope
... | python | def _limit_call_handler(self):
"""
Ensure we don't exceed the N requests a minute limit by leveraging a thread lock
"""
# acquire a lock on our threading.Lock() object
with self.limit_lock:
# if we have no configured limit, exit. the lock releases based on scope
... | [
"def",
"_limit_call_handler",
"(",
"self",
")",
":",
"# acquire a lock on our threading.Lock() object",
"with",
"self",
".",
"limit_lock",
":",
"# if we have no configured limit, exit. the lock releases based on scope",
"if",
"self",
".",
"limit_per_min",
"<=",
"0",
":",
"re... | Ensure we don't exceed the N requests a minute limit by leveraging a thread lock | [
"Ensure",
"we",
"don",
"t",
"exceed",
"the",
"N",
"requests",
"a",
"minute",
"limit",
"by",
"leveraging",
"a",
"thread",
"lock"
] | bf36f833f1f1b7d93169fd9ad451e06b7d46afc1 | https://github.com/anoroozian/pyvt/blob/bf36f833f1f1b7d93169fd9ad451e06b7d46afc1/pyvt/__init__.py#L55-L79 |
245,257 | lambdalisue/django-roughpages | src/roughpages/views.py | roughpage | def roughpage(request, url):
"""
Public interface to the rough page view.
"""
if settings.APPEND_SLASH and not url.endswith('/'):
# redirect to the url which have end slash
return redirect(url + '/', permanent=True)
# get base filename from url
filename = url_to_filename(url)
... | python | def roughpage(request, url):
"""
Public interface to the rough page view.
"""
if settings.APPEND_SLASH and not url.endswith('/'):
# redirect to the url which have end slash
return redirect(url + '/', permanent=True)
# get base filename from url
filename = url_to_filename(url)
... | [
"def",
"roughpage",
"(",
"request",
",",
"url",
")",
":",
"if",
"settings",
".",
"APPEND_SLASH",
"and",
"not",
"url",
".",
"endswith",
"(",
"'/'",
")",
":",
"# redirect to the url which have end slash",
"return",
"redirect",
"(",
"url",
"+",
"'/'",
",",
"per... | Public interface to the rough page view. | [
"Public",
"interface",
"to",
"the",
"rough",
"page",
"view",
"."
] | f6a2724ece729c5deced2c2546d172561ef785ec | https://github.com/lambdalisue/django-roughpages/blob/f6a2724ece729c5deced2c2546d172561ef785ec/src/roughpages/views.py#L25-L46 |
245,258 | lambdalisue/django-roughpages | src/roughpages/views.py | render_roughpage | def render_roughpage(request, t):
"""
Internal interface to the rough page view.
"""
import django
if django.VERSION >= (1, 8):
c = {}
response = HttpResponse(t.render(c, request))
else:
c = RequestContext(request)
response = HttpResponse(t.render(c))
return r... | python | def render_roughpage(request, t):
"""
Internal interface to the rough page view.
"""
import django
if django.VERSION >= (1, 8):
c = {}
response = HttpResponse(t.render(c, request))
else:
c = RequestContext(request)
response = HttpResponse(t.render(c))
return r... | [
"def",
"render_roughpage",
"(",
"request",
",",
"t",
")",
":",
"import",
"django",
"if",
"django",
".",
"VERSION",
">=",
"(",
"1",
",",
"8",
")",
":",
"c",
"=",
"{",
"}",
"response",
"=",
"HttpResponse",
"(",
"t",
".",
"render",
"(",
"c",
",",
"r... | Internal interface to the rough page view. | [
"Internal",
"interface",
"to",
"the",
"rough",
"page",
"view",
"."
] | f6a2724ece729c5deced2c2546d172561ef785ec | https://github.com/lambdalisue/django-roughpages/blob/f6a2724ece729c5deced2c2546d172561ef785ec/src/roughpages/views.py#L50-L61 |
245,259 | ronaldguillen/wave | wave/request.py | is_form_media_type | def is_form_media_type(media_type):
"""
Return True if the media type is a valid form media type.
"""
base_media_type, params = parse_header(media_type.encode(HTTP_HEADER_ENCODING))
return (base_media_type == 'application/x-www-form-urlencoded' or
base_media_type == 'multipart/form-data'... | python | def is_form_media_type(media_type):
"""
Return True if the media type is a valid form media type.
"""
base_media_type, params = parse_header(media_type.encode(HTTP_HEADER_ENCODING))
return (base_media_type == 'application/x-www-form-urlencoded' or
base_media_type == 'multipart/form-data'... | [
"def",
"is_form_media_type",
"(",
"media_type",
")",
":",
"base_media_type",
",",
"params",
"=",
"parse_header",
"(",
"media_type",
".",
"encode",
"(",
"HTTP_HEADER_ENCODING",
")",
")",
"return",
"(",
"base_media_type",
"==",
"'application/x-www-form-urlencoded'",
"or... | Return True if the media type is a valid form media type. | [
"Return",
"True",
"if",
"the",
"media",
"type",
"is",
"a",
"valid",
"form",
"media",
"type",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L25-L31 |
245,260 | ronaldguillen/wave | wave/request.py | clone_request | def clone_request(request, method):
"""
Internal helper method to clone a request, replacing with a different
HTTP method. Used for checking permissions against other methods.
"""
ret = Request(request=request._request,
parsers=request.parsers,
authenticators=req... | python | def clone_request(request, method):
"""
Internal helper method to clone a request, replacing with a different
HTTP method. Used for checking permissions against other methods.
"""
ret = Request(request=request._request,
parsers=request.parsers,
authenticators=req... | [
"def",
"clone_request",
"(",
"request",
",",
"method",
")",
":",
"ret",
"=",
"Request",
"(",
"request",
"=",
"request",
".",
"_request",
",",
"parsers",
"=",
"request",
".",
"parsers",
",",
"authenticators",
"=",
"request",
".",
"authenticators",
",",
"neg... | Internal helper method to clone a request, replacing with a different
HTTP method. Used for checking permissions against other methods. | [
"Internal",
"helper",
"method",
"to",
"clone",
"a",
"request",
"replacing",
"with",
"a",
"different",
"HTTP",
"method",
".",
"Used",
"for",
"checking",
"permissions",
"against",
"other",
"methods",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L74-L104 |
245,261 | ronaldguillen/wave | wave/request.py | Request.user | def user(self, value):
"""
Sets the user on the current request. This is necessary to maintain
compatibility with django.contrib.auth where the user property is
set in the login and logout functions.
Note that we also set the user on Django's underlying `HttpRequest`
ins... | python | def user(self, value):
"""
Sets the user on the current request. This is necessary to maintain
compatibility with django.contrib.auth where the user property is
set in the login and logout functions.
Note that we also set the user on Django's underlying `HttpRequest`
ins... | [
"def",
"user",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_user",
"=",
"value",
"self",
".",
"_request",
".",
"user",
"=",
"value"
] | Sets the user on the current request. This is necessary to maintain
compatibility with django.contrib.auth where the user property is
set in the login and logout functions.
Note that we also set the user on Django's underlying `HttpRequest`
instance, ensuring that it is available to any... | [
"Sets",
"the",
"user",
"on",
"the",
"current",
"request",
".",
"This",
"is",
"necessary",
"to",
"maintain",
"compatibility",
"with",
"django",
".",
"contrib",
".",
"auth",
"where",
"the",
"user",
"property",
"is",
"set",
"in",
"the",
"login",
"and",
"logou... | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L197-L207 |
245,262 | ronaldguillen/wave | wave/request.py | Request.auth | def auth(self, value):
"""
Sets any non-user authentication information associated with the
request, such as an authentication token.
"""
self._auth = value
self._request.auth = value | python | def auth(self, value):
"""
Sets any non-user authentication information associated with the
request, such as an authentication token.
"""
self._auth = value
self._request.auth = value | [
"def",
"auth",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_auth",
"=",
"value",
"self",
".",
"_request",
".",
"auth",
"=",
"value"
] | Sets any non-user authentication information associated with the
request, such as an authentication token. | [
"Sets",
"any",
"non",
"-",
"user",
"authentication",
"information",
"associated",
"with",
"the",
"request",
"such",
"as",
"an",
"authentication",
"token",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L220-L226 |
245,263 | ronaldguillen/wave | wave/request.py | Request._load_data_and_files | def _load_data_and_files(self):
"""
Parses the request content into `self.data`.
"""
if not _hasattr(self, '_data'):
self._data, self._files = self._parse()
if self._files:
self._full_data = self._data.copy()
self._full_data.update(... | python | def _load_data_and_files(self):
"""
Parses the request content into `self.data`.
"""
if not _hasattr(self, '_data'):
self._data, self._files = self._parse()
if self._files:
self._full_data = self._data.copy()
self._full_data.update(... | [
"def",
"_load_data_and_files",
"(",
"self",
")",
":",
"if",
"not",
"_hasattr",
"(",
"self",
",",
"'_data'",
")",
":",
"self",
".",
"_data",
",",
"self",
".",
"_files",
"=",
"self",
".",
"_parse",
"(",
")",
"if",
"self",
".",
"_files",
":",
"self",
... | Parses the request content into `self.data`. | [
"Parses",
"the",
"request",
"content",
"into",
"self",
".",
"data",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L238-L248 |
245,264 | ronaldguillen/wave | wave/request.py | Request._load_stream | def _load_stream(self):
"""
Return the content body of the request, as a stream.
"""
meta = self._request.META
try:
content_length = int(
meta.get('CONTENT_LENGTH', meta.get('HTTP_CONTENT_LENGTH', 0))
)
except (ValueError, TypeError... | python | def _load_stream(self):
"""
Return the content body of the request, as a stream.
"""
meta = self._request.META
try:
content_length = int(
meta.get('CONTENT_LENGTH', meta.get('HTTP_CONTENT_LENGTH', 0))
)
except (ValueError, TypeError... | [
"def",
"_load_stream",
"(",
"self",
")",
":",
"meta",
"=",
"self",
".",
"_request",
".",
"META",
"try",
":",
"content_length",
"=",
"int",
"(",
"meta",
".",
"get",
"(",
"'CONTENT_LENGTH'",
",",
"meta",
".",
"get",
"(",
"'HTTP_CONTENT_LENGTH'",
",",
"0",
... | Return the content body of the request, as a stream. | [
"Return",
"the",
"content",
"body",
"of",
"the",
"request",
"as",
"a",
"stream",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/request.py#L250-L267 |
245,265 | LesPatamechanix/patalib | src/patalib/antonym.py | Antonym.generate_antonym | def generate_antonym(self, input_word):
""" Generate an antonym using a Synset
and its lemmas.
"""
results = []
synset = wordnet.synsets(input_word)
for i in synset:
if i.pos in ['n','v']:
for j in i.lemmas:
if j.antonyms():
... | python | def generate_antonym(self, input_word):
""" Generate an antonym using a Synset
and its lemmas.
"""
results = []
synset = wordnet.synsets(input_word)
for i in synset:
if i.pos in ['n','v']:
for j in i.lemmas:
if j.antonyms():
... | [
"def",
"generate_antonym",
"(",
"self",
",",
"input_word",
")",
":",
"results",
"=",
"[",
"]",
"synset",
"=",
"wordnet",
".",
"synsets",
"(",
"input_word",
")",
"for",
"i",
"in",
"synset",
":",
"if",
"i",
".",
"pos",
"in",
"[",
"'n'",
",",
"'v'",
"... | Generate an antonym using a Synset
and its lemmas. | [
"Generate",
"an",
"antonym",
"using",
"a",
"Synset",
"and",
"its",
"lemmas",
"."
] | d88cca409b1750fdeb88cece048b308f2a710955 | https://github.com/LesPatamechanix/patalib/blob/d88cca409b1750fdeb88cece048b308f2a710955/src/patalib/antonym.py#L9-L22 |
245,266 | ikalnytskyi/dooku | dooku/ext.py | ExtensionManager.get | def get(self, name, default=None):
"""
Returns an extension instance with a given name.
In case there are few extensions with a given name, the first one
will be returned. If no extensions with a given name are exist,
the `default` value will be returned.
:param name: (... | python | def get(self, name, default=None):
"""
Returns an extension instance with a given name.
In case there are few extensions with a given name, the first one
will be returned. If no extensions with a given name are exist,
the `default` value will be returned.
:param name: (... | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"value",
"=",
"self",
"[",
"name",
"]",
"except",
"KeyError",
":",
"value",
"=",
"default",
"return",
"value"
] | Returns an extension instance with a given name.
In case there are few extensions with a given name, the first one
will be returned. If no extensions with a given name are exist,
the `default` value will be returned.
:param name: (str) an extension name
:param default: (object)... | [
"Returns",
"an",
"extension",
"instance",
"with",
"a",
"given",
"name",
"."
] | 77e6c82c9c41211c86ee36ae5e591d477945fedf | https://github.com/ikalnytskyi/dooku/blob/77e6c82c9c41211c86ee36ae5e591d477945fedf/dooku/ext.py#L98-L114 |
245,267 | radjkarl/fancyTools | fancytools/math/line.py | sort | def sort(line):
"""
change point position if x1,y0 < x0,y0
"""
x0, y0, x1, y1 = line
# if (x0**2+y0**2)**0.5 < (x1**2+y1**2)**0.5:
# return (x1,y1,x0,y0)
# return line
#
# if x1 < x0:
# return (x1,y1,x0,y0)
# return line
turn = False
... | python | def sort(line):
"""
change point position if x1,y0 < x0,y0
"""
x0, y0, x1, y1 = line
# if (x0**2+y0**2)**0.5 < (x1**2+y1**2)**0.5:
# return (x1,y1,x0,y0)
# return line
#
# if x1 < x0:
# return (x1,y1,x0,y0)
# return line
turn = False
... | [
"def",
"sort",
"(",
"line",
")",
":",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"line",
"# if (x0**2+y0**2)**0.5 < (x1**2+y1**2)**0.5:",
"# return (x1,y1,x0,y0)",
"# return line",
"#",
"# if x1 < x0:",
"# return (x1,y1,x0,y0)",
"# return li... | change point position if x1,y0 < x0,y0 | [
"change",
"point",
"position",
"if",
"x1",
"y0",
"<",
"x0",
"y0"
] | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L49-L73 |
245,268 | radjkarl/fancyTools | fancytools/math/line.py | dxdy | def dxdy(line):
"""
return normalised ascent vector
"""
x0, y0, x1, y1 = line
dx = float(x1 - x0)
dy = float(y1 - y0)
f = hypot(dx, dy)
return dx / f, dy / f | python | def dxdy(line):
"""
return normalised ascent vector
"""
x0, y0, x1, y1 = line
dx = float(x1 - x0)
dy = float(y1 - y0)
f = hypot(dx, dy)
return dx / f, dy / f | [
"def",
"dxdy",
"(",
"line",
")",
":",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"line",
"dx",
"=",
"float",
"(",
"x1",
"-",
"x0",
")",
"dy",
"=",
"float",
"(",
"y1",
"-",
"y0",
")",
"f",
"=",
"hypot",
"(",
"dx",
",",
"dy",
")",
"return"... | return normalised ascent vector | [
"return",
"normalised",
"ascent",
"vector"
] | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L104-L112 |
245,269 | radjkarl/fancyTools | fancytools/math/line.py | fromAttr | def fromAttr(mid, ang, dist):
"""
create from middle, angle and distance
"""
mx, my = mid
dx = cos(ang) * dist * 0.5
dy = sin(ang) * dist * 0.5
return mx - dx, my - dy, mx + dx, my + dy | python | def fromAttr(mid, ang, dist):
"""
create from middle, angle and distance
"""
mx, my = mid
dx = cos(ang) * dist * 0.5
dy = sin(ang) * dist * 0.5
return mx - dx, my - dy, mx + dx, my + dy | [
"def",
"fromAttr",
"(",
"mid",
",",
"ang",
",",
"dist",
")",
":",
"mx",
",",
"my",
"=",
"mid",
"dx",
"=",
"cos",
"(",
"ang",
")",
"*",
"dist",
"*",
"0.5",
"dy",
"=",
"sin",
"(",
"ang",
")",
"*",
"dist",
"*",
"0.5",
"return",
"mx",
"-",
"dx"... | create from middle, angle and distance | [
"create",
"from",
"middle",
"angle",
"and",
"distance"
] | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L151-L158 |
245,270 | radjkarl/fancyTools | fancytools/math/line.py | fromAttr2 | def fromAttr2(start, ang, dist):
"""
create from start, angle and distance
"""
sx, sy = start
dx = cos(ang) * dist
dy = sin(ang) * dist
return sx, sy, sx + dx, sy + dy | python | def fromAttr2(start, ang, dist):
"""
create from start, angle and distance
"""
sx, sy = start
dx = cos(ang) * dist
dy = sin(ang) * dist
return sx, sy, sx + dx, sy + dy | [
"def",
"fromAttr2",
"(",
"start",
",",
"ang",
",",
"dist",
")",
":",
"sx",
",",
"sy",
"=",
"start",
"dx",
"=",
"cos",
"(",
"ang",
")",
"*",
"dist",
"dy",
"=",
"sin",
"(",
"ang",
")",
"*",
"dist",
"return",
"sx",
",",
"sy",
",",
"sx",
"+",
"... | create from start, angle and distance | [
"create",
"from",
"start",
"angle",
"and",
"distance"
] | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L161-L168 |
245,271 | radjkarl/fancyTools | fancytools/math/line.py | merge | def merge(l1, l2):
"""
merge 2 lines together
"""
x1, y1, x2, y2 = l1
xx1, yy1, xx2, yy2 = l2
comb = ((x1, y1, xx1, yy1),
(x1, y1, xx2, yy2),
(x2, y2, xx1, yy1),
(x2, y2, xx2, yy2))
d = [length(c) for c in comb]
i = argmax(d)
dist = d[i]
mid... | python | def merge(l1, l2):
"""
merge 2 lines together
"""
x1, y1, x2, y2 = l1
xx1, yy1, xx2, yy2 = l2
comb = ((x1, y1, xx1, yy1),
(x1, y1, xx2, yy2),
(x2, y2, xx1, yy1),
(x2, y2, xx2, yy2))
d = [length(c) for c in comb]
i = argmax(d)
dist = d[i]
mid... | [
"def",
"merge",
"(",
"l1",
",",
"l2",
")",
":",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"=",
"l1",
"xx1",
",",
"yy1",
",",
"xx2",
",",
"yy2",
"=",
"l2",
"comb",
"=",
"(",
"(",
"x1",
",",
"y1",
",",
"xx1",
",",
"yy1",
")",
",",
"(",
"x1",... | merge 2 lines together | [
"merge",
"2",
"lines",
"together"
] | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L190-L209 |
245,272 | radjkarl/fancyTools | fancytools/math/line.py | distance | def distance(line, point):
"""
infinite line to point or line to line distance
is point is given as line - use middle point of that liune
"""
x0, y0, x1, y1 = line
try:
p1, p2 = point
except ValueError:
# line is given instead of point
p1, p2 = middle(point)
n1 = ... | python | def distance(line, point):
"""
infinite line to point or line to line distance
is point is given as line - use middle point of that liune
"""
x0, y0, x1, y1 = line
try:
p1, p2 = point
except ValueError:
# line is given instead of point
p1, p2 = middle(point)
n1 = ... | [
"def",
"distance",
"(",
"line",
",",
"point",
")",
":",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"line",
"try",
":",
"p1",
",",
"p2",
"=",
"point",
"except",
"ValueError",
":",
"# line is given instead of point",
"p1",
",",
"p2",
"=",
"middle",
"(... | infinite line to point or line to line distance
is point is given as line - use middle point of that liune | [
"infinite",
"line",
"to",
"point",
"or",
"line",
"to",
"line",
"distance",
"is",
"point",
"is",
"given",
"as",
"line",
"-",
"use",
"middle",
"point",
"of",
"that",
"liune"
] | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L236-L250 |
245,273 | radjkarl/fancyTools | fancytools/math/line.py | intersection | def intersection(line1, line2):
"""
Return the coordinates of a point of intersection given two lines.
Return None if the lines are parallel, but non-colli_near.
Return an arbitrary point of intersection if the lines are colli_near.
Parameters:
line1 and line2: lines given by 4 points (x0,y0,x1... | python | def intersection(line1, line2):
"""
Return the coordinates of a point of intersection given two lines.
Return None if the lines are parallel, but non-colli_near.
Return an arbitrary point of intersection if the lines are colli_near.
Parameters:
line1 and line2: lines given by 4 points (x0,y0,x1... | [
"def",
"intersection",
"(",
"line1",
",",
"line2",
")",
":",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"=",
"line1",
"u1",
",",
"v1",
",",
"u2",
",",
"v2",
"=",
"line2",
"(",
"a",
",",
"b",
")",
",",
"(",
"c",
",",
"d",
")",
"=",
"(",
"x2",
... | Return the coordinates of a point of intersection given two lines.
Return None if the lines are parallel, but non-colli_near.
Return an arbitrary point of intersection if the lines are colli_near.
Parameters:
line1 and line2: lines given by 4 points (x0,y0,x1,y1). | [
"Return",
"the",
"coordinates",
"of",
"a",
"point",
"of",
"intersection",
"given",
"two",
"lines",
".",
"Return",
"None",
"if",
"the",
"lines",
"are",
"parallel",
"but",
"non",
"-",
"colli_near",
".",
"Return",
"an",
"arbitrary",
"point",
"of",
"intersection... | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L311-L343 |
245,274 | radjkarl/fancyTools | fancytools/math/line.py | translate | def translate(line, ascent, offs=0):
"""
offs -> shifts parallel to line
ascent -> rotate line
"""
# TODO: why do I have thuis factor here?
ascent *= -2
offs *= -2
l0 = length(line)
# change relative to line:
t0 = offs # -h+offs
t1 = l0 * ascent + offs
return translate... | python | def translate(line, ascent, offs=0):
"""
offs -> shifts parallel to line
ascent -> rotate line
"""
# TODO: why do I have thuis factor here?
ascent *= -2
offs *= -2
l0 = length(line)
# change relative to line:
t0 = offs # -h+offs
t1 = l0 * ascent + offs
return translate... | [
"def",
"translate",
"(",
"line",
",",
"ascent",
",",
"offs",
"=",
"0",
")",
":",
"# TODO: why do I have thuis factor here?",
"ascent",
"*=",
"-",
"2",
"offs",
"*=",
"-",
"2",
"l0",
"=",
"length",
"(",
"line",
")",
"# change relative to line:",
"t0",
"=",
"... | offs -> shifts parallel to line
ascent -> rotate line | [
"offs",
"-",
">",
"shifts",
"parallel",
"to",
"line",
"ascent",
"-",
">",
"rotate",
"line"
] | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L351-L365 |
245,275 | radjkarl/fancyTools | fancytools/math/line.py | splitN | def splitN(line, n):
"""
split a line n times
returns n sublines
"""
x0, y0, x1, y1 = line
out = empty((n, 4), dtype=type(line[0]))
px, py = x0, y0
dx = (x1 - x0) / n
dy = (y1 - y0) / n
for i in range(n):
o = out[i]
o[0] = px
o[1] = py
px += dx
... | python | def splitN(line, n):
"""
split a line n times
returns n sublines
"""
x0, y0, x1, y1 = line
out = empty((n, 4), dtype=type(line[0]))
px, py = x0, y0
dx = (x1 - x0) / n
dy = (y1 - y0) / n
for i in range(n):
o = out[i]
o[0] = px
o[1] = py
px += dx
... | [
"def",
"splitN",
"(",
"line",
",",
"n",
")",
":",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"line",
"out",
"=",
"empty",
"(",
"(",
"n",
",",
"4",
")",
",",
"dtype",
"=",
"type",
"(",
"line",
"[",
"0",
"]",
")",
")",
"px",
",",
"py",
"... | split a line n times
returns n sublines | [
"split",
"a",
"line",
"n",
"times",
"returns",
"n",
"sublines"
] | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/line.py#L402-L422 |
245,276 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/request_parser.py | _remove_files | def _remove_files(files):
"""
Remove all given files.
Args:
files (list): List of filenames, which will be removed.
"""
logger.debug("Request for file removal (_remove_files()).")
for fn in files:
if os.path.exists(fn):
logger.debug("Removing '%s'." % fn)
... | python | def _remove_files(files):
"""
Remove all given files.
Args:
files (list): List of filenames, which will be removed.
"""
logger.debug("Request for file removal (_remove_files()).")
for fn in files:
if os.path.exists(fn):
logger.debug("Removing '%s'." % fn)
... | [
"def",
"_remove_files",
"(",
"files",
")",
":",
"logger",
".",
"debug",
"(",
"\"Request for file removal (_remove_files()).\"",
")",
"for",
"fn",
"in",
"files",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"fn",
")",
":",
"logger",
".",
"debug",
"(",
... | Remove all given files.
Args:
files (list): List of filenames, which will be removed. | [
"Remove",
"all",
"given",
"files",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L99-L111 |
245,277 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/request_parser.py | _safe_read_meta_file | def _safe_read_meta_file(fn, error_protocol):
"""
Try to read MetadataFile. If the exception is raised, log the errors to
the `error_protocol` and return None.
"""
try:
return MetadataFile(fn)
except Exception, e:
error_protocol.append(
"Can't read MetadataFile '%s':\... | python | def _safe_read_meta_file(fn, error_protocol):
"""
Try to read MetadataFile. If the exception is raised, log the errors to
the `error_protocol` and return None.
"""
try:
return MetadataFile(fn)
except Exception, e:
error_protocol.append(
"Can't read MetadataFile '%s':\... | [
"def",
"_safe_read_meta_file",
"(",
"fn",
",",
"error_protocol",
")",
":",
"try",
":",
"return",
"MetadataFile",
"(",
"fn",
")",
"except",
"Exception",
",",
"e",
":",
"error_protocol",
".",
"append",
"(",
"\"Can't read MetadataFile '%s':\\n\\t%s\\n\"",
"%",
"(",
... | Try to read MetadataFile. If the exception is raised, log the errors to
the `error_protocol` and return None. | [
"Try",
"to",
"read",
"MetadataFile",
".",
"If",
"the",
"exception",
"is",
"raised",
"log",
"the",
"errors",
"to",
"the",
"error_protocol",
"and",
"return",
"None",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L114-L124 |
245,278 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/request_parser.py | _process_pair | def _process_pair(first_fn, second_fn, error_protocol):
"""
Look at given filenames, decide which is what and try to pair them.
"""
ebook = None
metadata = None
if _is_meta(first_fn) and not _is_meta(second_fn): # 1st meta, 2nd data
logger.debug(
"Parsed: '%s' as meta, '%... | python | def _process_pair(first_fn, second_fn, error_protocol):
"""
Look at given filenames, decide which is what and try to pair them.
"""
ebook = None
metadata = None
if _is_meta(first_fn) and not _is_meta(second_fn): # 1st meta, 2nd data
logger.debug(
"Parsed: '%s' as meta, '%... | [
"def",
"_process_pair",
"(",
"first_fn",
",",
"second_fn",
",",
"error_protocol",
")",
":",
"ebook",
"=",
"None",
"metadata",
"=",
"None",
"if",
"_is_meta",
"(",
"first_fn",
")",
"and",
"not",
"_is_meta",
"(",
"second_fn",
")",
":",
"# 1st meta, 2nd data",
"... | Look at given filenames, decide which is what and try to pair them. | [
"Look",
"at",
"given",
"filenames",
"decide",
"which",
"is",
"what",
"and",
"try",
"to",
"pair",
"them",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L127-L175 |
245,279 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/request_parser.py | _process_directory | def _process_directory(files, user_conf, error_protocol):
"""
Look at items in given directory, try to match them for same names and pair
them.
If the items can't be paired, add their representation.
Note:
All successfully processed files are removed.
Returns:
list: of items. ... | python | def _process_directory(files, user_conf, error_protocol):
"""
Look at items in given directory, try to match them for same names and pair
them.
If the items can't be paired, add their representation.
Note:
All successfully processed files are removed.
Returns:
list: of items. ... | [
"def",
"_process_directory",
"(",
"files",
",",
"user_conf",
",",
"error_protocol",
")",
":",
"items",
"=",
"[",
"]",
"banned",
"=",
"[",
"settings",
".",
"USER_IMPORT_LOG",
",",
"settings",
".",
"USER_ERROR_LOG",
"]",
"files",
"=",
"filter",
"(",
"lambda",
... | Look at items in given directory, try to match them for same names and pair
them.
If the items can't be paired, add their representation.
Note:
All successfully processed files are removed.
Returns:
list: of items. Example: [MetadataFile, DataPair, DataPair, EbookFile] | [
"Look",
"at",
"items",
"in",
"given",
"directory",
"try",
"to",
"match",
"them",
"for",
"same",
"names",
"and",
"pair",
"them",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L178-L241 |
245,280 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/request_parser.py | _index | def _index(array, item, key=None):
"""
Array search function.
Written, because ``.index()`` method for array doesn't have `key` parameter
and raises `ValueError`, if the item is not found.
Args:
array (list): List of items, which will be searched.
item (whatever): Item, which will ... | python | def _index(array, item, key=None):
"""
Array search function.
Written, because ``.index()`` method for array doesn't have `key` parameter
and raises `ValueError`, if the item is not found.
Args:
array (list): List of items, which will be searched.
item (whatever): Item, which will ... | [
"def",
"_index",
"(",
"array",
",",
"item",
",",
"key",
"=",
"None",
")",
":",
"for",
"i",
",",
"el",
"in",
"enumerate",
"(",
"array",
")",
":",
"resolved_el",
"=",
"key",
"(",
"el",
")",
"if",
"key",
"else",
"el",
"if",
"resolved_el",
"==",
"ite... | Array search function.
Written, because ``.index()`` method for array doesn't have `key` parameter
and raises `ValueError`, if the item is not found.
Args:
array (list): List of items, which will be searched.
item (whatever): Item, which will be matched to elements in `array`.
key ... | [
"Array",
"search",
"function",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L244-L266 |
245,281 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/request_parser.py | _isbn_pairing | def _isbn_pairing(items):
"""
Pair `items` with same ISBN into `DataPair` objects.
Args:
items (list): list of items, which will be searched.
Returns:
list: list with paired items. Paired items are removed, `DataPair` is \
added instead.
"""
NameWrapper = namedtup... | python | def _isbn_pairing(items):
"""
Pair `items` with same ISBN into `DataPair` objects.
Args:
items (list): list of items, which will be searched.
Returns:
list: list with paired items. Paired items are removed, `DataPair` is \
added instead.
"""
NameWrapper = namedtup... | [
"def",
"_isbn_pairing",
"(",
"items",
")",
":",
"NameWrapper",
"=",
"namedtuple",
"(",
"\"NameWrapper\"",
",",
"[",
"\"name\"",
",",
"\"obj\"",
"]",
")",
"metas",
"=",
"map",
"(",
"lambda",
"x",
":",
"NameWrapper",
"(",
"_just_name",
"(",
"x",
".",
"file... | Pair `items` with same ISBN into `DataPair` objects.
Args:
items (list): list of items, which will be searched.
Returns:
list: list with paired items. Paired items are removed, `DataPair` is \
added instead. | [
"Pair",
"items",
"with",
"same",
"ISBN",
"into",
"DataPair",
"objects",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L269-L322 |
245,282 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/request_parser.py | _create_import_log | def _create_import_log(items):
"""
Used to create log with successfully imported data.
"""
log = []
for item in items:
if isinstance(item, MetadataFile):
log.append(
"Metadata file '%s' successfully imported." % item.filename
)
elif isinstance... | python | def _create_import_log(items):
"""
Used to create log with successfully imported data.
"""
log = []
for item in items:
if isinstance(item, MetadataFile):
log.append(
"Metadata file '%s' successfully imported." % item.filename
)
elif isinstance... | [
"def",
"_create_import_log",
"(",
"items",
")",
":",
"log",
"=",
"[",
"]",
"for",
"item",
"in",
"items",
":",
"if",
"isinstance",
"(",
"item",
",",
"MetadataFile",
")",
":",
"log",
".",
"append",
"(",
"\"Metadata file '%s' successfully imported.\"",
"%",
"it... | Used to create log with successfully imported data. | [
"Used",
"to",
"create",
"log",
"with",
"successfully",
"imported",
"data",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L325-L349 |
245,283 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/request_parser.py | _process_items | def _process_items(items, user_conf, error_protocol):
"""
Parse metadata. Remove processed and sucessfully parsed items.
Returns sucessfully processed items.
"""
def process_meta(item, error_protocol):
try:
return item._parse()
except Exception, e:
error_prot... | python | def _process_items(items, user_conf, error_protocol):
"""
Parse metadata. Remove processed and sucessfully parsed items.
Returns sucessfully processed items.
"""
def process_meta(item, error_protocol):
try:
return item._parse()
except Exception, e:
error_prot... | [
"def",
"_process_items",
"(",
"items",
",",
"user_conf",
",",
"error_protocol",
")",
":",
"def",
"process_meta",
"(",
"item",
",",
"error_protocol",
")",
":",
"try",
":",
"return",
"item",
".",
"_parse",
"(",
")",
"except",
"Exception",
",",
"e",
":",
"e... | Parse metadata. Remove processed and sucessfully parsed items.
Returns sucessfully processed items. | [
"Parse",
"metadata",
".",
"Remove",
"processed",
"and",
"sucessfully",
"parsed",
"items",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/request_parser.py#L352-L386 |
245,284 | maxfischer2781/chainlet | chainlet/driver.py | ChainDriver.start | def start(self, daemon=True):
"""
Start driving the chain asynchronously, return immediately
:param daemon: ungracefully kill the driver when the program terminates
:type daemon: bool
"""
if self._run_lock.acquire(False):
try:
# there is a sho... | python | def start(self, daemon=True):
"""
Start driving the chain asynchronously, return immediately
:param daemon: ungracefully kill the driver when the program terminates
:type daemon: bool
"""
if self._run_lock.acquire(False):
try:
# there is a sho... | [
"def",
"start",
"(",
"self",
",",
"daemon",
"=",
"True",
")",
":",
"if",
"self",
".",
"_run_lock",
".",
"acquire",
"(",
"False",
")",
":",
"try",
":",
"# there is a short race window in which `start` release the lock,",
"# but `run` has not picked it up yet, but the thr... | Start driving the chain asynchronously, return immediately
:param daemon: ungracefully kill the driver when the program terminates
:type daemon: bool | [
"Start",
"driving",
"the",
"chain",
"asynchronously",
"return",
"immediately"
] | 4e17f9992b4780bd0d9309202e2847df640bffe8 | https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/driver.py#L27-L43 |
245,285 | maxfischer2781/chainlet | chainlet/driver.py | ChainDriver.run | def run(self):
"""
Start driving the chain, block until done
"""
with self._run_lock:
while self.mounts:
for mount in self.mounts:
try:
next(mount)
except StopIteration:
se... | python | def run(self):
"""
Start driving the chain, block until done
"""
with self._run_lock:
while self.mounts:
for mount in self.mounts:
try:
next(mount)
except StopIteration:
se... | [
"def",
"run",
"(",
"self",
")",
":",
"with",
"self",
".",
"_run_lock",
":",
"while",
"self",
".",
"mounts",
":",
"for",
"mount",
"in",
"self",
".",
"mounts",
":",
"try",
":",
"next",
"(",
"mount",
")",
"except",
"StopIteration",
":",
"self",
".",
"... | Start driving the chain, block until done | [
"Start",
"driving",
"the",
"chain",
"block",
"until",
"done"
] | 4e17f9992b4780bd0d9309202e2847df640bffe8 | https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/driver.py#L51-L61 |
245,286 | PyMLGame/pymlgame | pymlgame/surface.py | Surface.fill | def fill(self, color):
"""
Fill the whole screen with the given color.
:param color: Color to use for filling
:type color: tuple
"""
self.matrix = [[color for _ in range(self.height)] for _ in range(self.width)] | python | def fill(self, color):
"""
Fill the whole screen with the given color.
:param color: Color to use for filling
:type color: tuple
"""
self.matrix = [[color for _ in range(self.height)] for _ in range(self.width)] | [
"def",
"fill",
"(",
"self",
",",
"color",
")",
":",
"self",
".",
"matrix",
"=",
"[",
"[",
"color",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"height",
")",
"]",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"width",
")",
"]"
] | Fill the whole screen with the given color.
:param color: Color to use for filling
:type color: tuple | [
"Fill",
"the",
"whole",
"screen",
"with",
"the",
"given",
"color",
"."
] | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L25-L32 |
245,287 | PyMLGame/pymlgame | pymlgame/surface.py | Surface.draw_dot | def draw_dot(self, pos, color):
"""
Draw one single dot with the given color on the screen.
:param pos: Position of the dot
:param color: COlor for the dot
:type pos: tuple
:type color: tuple
"""
if 0 <= pos[0] < self.width and 0 <= pos[1] < self.height:
... | python | def draw_dot(self, pos, color):
"""
Draw one single dot with the given color on the screen.
:param pos: Position of the dot
:param color: COlor for the dot
:type pos: tuple
:type color: tuple
"""
if 0 <= pos[0] < self.width and 0 <= pos[1] < self.height:
... | [
"def",
"draw_dot",
"(",
"self",
",",
"pos",
",",
"color",
")",
":",
"if",
"0",
"<=",
"pos",
"[",
"0",
"]",
"<",
"self",
".",
"width",
"and",
"0",
"<=",
"pos",
"[",
"1",
"]",
"<",
"self",
".",
"height",
":",
"self",
".",
"matrix",
"[",
"pos",
... | Draw one single dot with the given color on the screen.
:param pos: Position of the dot
:param color: COlor for the dot
:type pos: tuple
:type color: tuple | [
"Draw",
"one",
"single",
"dot",
"with",
"the",
"given",
"color",
"on",
"the",
"screen",
"."
] | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L34-L44 |
245,288 | PyMLGame/pymlgame | pymlgame/surface.py | Surface.draw_line | def draw_line(self, start, end, color):
"""
Draw a line with the given color on the screen.
:param start: Start point of the line
:param end: End point of the line
:param color: Color of the line
:type start: tuple
:type end: tuple
:type color: tuple
... | python | def draw_line(self, start, end, color):
"""
Draw a line with the given color on the screen.
:param start: Start point of the line
:param end: End point of the line
:param color: Color of the line
:type start: tuple
:type end: tuple
:type color: tuple
... | [
"def",
"draw_line",
"(",
"self",
",",
"start",
",",
"end",
",",
"color",
")",
":",
"def",
"dist",
"(",
"p",
",",
"a",
",",
"b",
")",
":",
"return",
"(",
"abs",
"(",
"(",
"b",
"[",
"0",
"]",
"-",
"a",
"[",
"0",
"]",
")",
"*",
"(",
"a",
"... | Draw a line with the given color on the screen.
:param start: Start point of the line
:param end: End point of the line
:param color: Color of the line
:type start: tuple
:type end: tuple
:type color: tuple | [
"Draw",
"a",
"line",
"with",
"the",
"given",
"color",
"on",
"the",
"screen",
"."
] | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L46-L67 |
245,289 | PyMLGame/pymlgame | pymlgame/surface.py | Surface.draw_rect | def draw_rect(self, pos, size, color, fillcolor=None):
"""
Draw a rectangle with the given color on the screen and optionally fill it with fillcolor.
:param pos: Top left corner of the rectangle
:param size: Sieze of the rectangle
:param color: Color for borders
:param f... | python | def draw_rect(self, pos, size, color, fillcolor=None):
"""
Draw a rectangle with the given color on the screen and optionally fill it with fillcolor.
:param pos: Top left corner of the rectangle
:param size: Sieze of the rectangle
:param color: Color for borders
:param f... | [
"def",
"draw_rect",
"(",
"self",
",",
"pos",
",",
"size",
",",
"color",
",",
"fillcolor",
"=",
"None",
")",
":",
"# draw top and botton line",
"for",
"x",
"in",
"range",
"(",
"size",
"[",
"0",
"]",
")",
":",
"self",
".",
"draw_dot",
"(",
"(",
"pos",
... | Draw a rectangle with the given color on the screen and optionally fill it with fillcolor.
:param pos: Top left corner of the rectangle
:param size: Sieze of the rectangle
:param color: Color for borders
:param fillcolor: Color for infill
:type pos: tuple
:type size: tup... | [
"Draw",
"a",
"rectangle",
"with",
"the",
"given",
"color",
"on",
"the",
"screen",
"and",
"optionally",
"fill",
"it",
"with",
"fillcolor",
"."
] | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L69-L94 |
245,290 | PyMLGame/pymlgame | pymlgame/surface.py | Surface.draw_circle | def draw_circle(self, pos, radius, color, fillcolor=None):
"""
Draw a circle with the given color on the screen and optionally fill it with fillcolor.
:param pos: Center of the circle
:param radius: Radius
:param color: Color for border
:param fillcolor: Color for infill... | python | def draw_circle(self, pos, radius, color, fillcolor=None):
"""
Draw a circle with the given color on the screen and optionally fill it with fillcolor.
:param pos: Center of the circle
:param radius: Radius
:param color: Color for border
:param fillcolor: Color for infill... | [
"def",
"draw_circle",
"(",
"self",
",",
"pos",
",",
"radius",
",",
"color",
",",
"fillcolor",
"=",
"None",
")",
":",
"#TODO: This still produces rubbish but it's on a good way to success",
"def",
"dist",
"(",
"d",
",",
"p",
",",
"r",
")",
":",
"return",
"abs",... | Draw a circle with the given color on the screen and optionally fill it with fillcolor.
:param pos: Center of the circle
:param radius: Radius
:param color: Color for border
:param fillcolor: Color for infill
:type pos: tuple
:type radius: int
:type color: tuple
... | [
"Draw",
"a",
"circle",
"with",
"the",
"given",
"color",
"on",
"the",
"screen",
"and",
"optionally",
"fill",
"it",
"with",
"fillcolor",
"."
] | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L96-L126 |
245,291 | PyMLGame/pymlgame | pymlgame/surface.py | Surface.blit | def blit(self, surface, pos=(0, 0)):
"""
Blits a surface on this surface at pos
:param surface: Surface to blit
:param pos: Top left point to start blitting
:type surface: Surface
:type pos: tuple
"""
for x in range(surface.width):
for y in ra... | python | def blit(self, surface, pos=(0, 0)):
"""
Blits a surface on this surface at pos
:param surface: Surface to blit
:param pos: Top left point to start blitting
:type surface: Surface
:type pos: tuple
"""
for x in range(surface.width):
for y in ra... | [
"def",
"blit",
"(",
"self",
",",
"surface",
",",
"pos",
"=",
"(",
"0",
",",
"0",
")",
")",
":",
"for",
"x",
"in",
"range",
"(",
"surface",
".",
"width",
")",
":",
"for",
"y",
"in",
"range",
"(",
"surface",
".",
"height",
")",
":",
"px",
"=",
... | Blits a surface on this surface at pos
:param surface: Surface to blit
:param pos: Top left point to start blitting
:type surface: Surface
:type pos: tuple | [
"Blits",
"a",
"surface",
"on",
"this",
"surface",
"at",
"pos"
] | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L128-L142 |
245,292 | PyMLGame/pymlgame | pymlgame/surface.py | Surface.replace_color | def replace_color(self, before, after):
"""
Replaces a color on a surface with another one.
:param before: Change all pixels with this color
:param after: To that color
:type before: tuple
:type after: tuple
"""
#TODO: find out if this actually works
... | python | def replace_color(self, before, after):
"""
Replaces a color on a surface with another one.
:param before: Change all pixels with this color
:param after: To that color
:type before: tuple
:type after: tuple
"""
#TODO: find out if this actually works
... | [
"def",
"replace_color",
"(",
"self",
",",
"before",
",",
"after",
")",
":",
"#TODO: find out if this actually works",
"#((self.matrix[x][y] = after for y in range(self.height) if self.matrix[x][y] == before) for x in range(self.width))",
"for",
"x",
"in",
"range",
"(",
"self",
".... | Replaces a color on a surface with another one.
:param before: Change all pixels with this color
:param after: To that color
:type before: tuple
:type after: tuple | [
"Replaces",
"a",
"color",
"on",
"a",
"surface",
"with",
"another",
"one",
"."
] | 450fe77d35f9a26c107586d6954f69c3895bf504 | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/surface.py#L144-L158 |
245,293 | matthewdeanmartin/jiggle_version | build.py | detect_secrets | def detect_secrets():
"""
Call detect-secrets tool
"""
# use
# blah blah = "foo" # pragma: whitelist secret
# to ignore a false posites
errors_file = "detect-secrets-results.txt"
print(execute_get_text("pwd"))
command = "{0} detect-secrets --scan --base64-limit 4 --exclude .ide... | python | def detect_secrets():
"""
Call detect-secrets tool
"""
# use
# blah blah = "foo" # pragma: whitelist secret
# to ignore a false posites
errors_file = "detect-secrets-results.txt"
print(execute_get_text("pwd"))
command = "{0} detect-secrets --scan --base64-limit 4 --exclude .ide... | [
"def",
"detect_secrets",
"(",
")",
":",
"# use",
"# blah blah = \"foo\" # pragma: whitelist secret",
"# to ignore a false posites",
"errors_file",
"=",
"\"detect-secrets-results.txt\"",
"print",
"(",
"execute_get_text",
"(",
"\"pwd\"",
")",
")",
"command",
"=",
"\"{0} det... | Call detect-secrets tool | [
"Call",
"detect",
"-",
"secrets",
"tool"
] | 963656a0a47b7162780a5f6c8f4b8bbbebc148f5 | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/build.py#L138-L182 |
245,294 | matthewdeanmartin/jiggle_version | build.py | mypy | def mypy():
"""
Are types ok?
"""
if sys.version_info < (3, 4):
print("Mypy doesn't work on python < 3.4")
return
if IS_TRAVIS:
command = "{0} -m mypy {1} --ignore-missing-imports --strict".format(PYTHON, PROJECT_NAME).strip()
else:
command = "{0} mypy {1} --ignor... | python | def mypy():
"""
Are types ok?
"""
if sys.version_info < (3, 4):
print("Mypy doesn't work on python < 3.4")
return
if IS_TRAVIS:
command = "{0} -m mypy {1} --ignore-missing-imports --strict".format(PYTHON, PROJECT_NAME).strip()
else:
command = "{0} mypy {1} --ignor... | [
"def",
"mypy",
"(",
")",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"4",
")",
":",
"print",
"(",
"\"Mypy doesn't work on python < 3.4\"",
")",
"return",
"if",
"IS_TRAVIS",
":",
"command",
"=",
"\"{0} -m mypy {1} --ignore-missing-imports --strict\""... | Are types ok? | [
"Are",
"types",
"ok?"
] | 963656a0a47b7162780a5f6c8f4b8bbbebc148f5 | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/build.py#L336-L374 |
245,295 | matthewdeanmartin/jiggle_version | build.py | gemfury | def gemfury():
"""
Push to gem fury, a repo with private options
"""
# fury login
# fury push dist/*.gz --as=YOUR_ACCT
# fury push dist/*.whl --as=YOUR_ACCT
cp = subprocess.run(("fury login --as={0}".format(GEM_FURY).split(" ")),
stdout=subprocess.PIPE, stderr=subpro... | python | def gemfury():
"""
Push to gem fury, a repo with private options
"""
# fury login
# fury push dist/*.gz --as=YOUR_ACCT
# fury push dist/*.whl --as=YOUR_ACCT
cp = subprocess.run(("fury login --as={0}".format(GEM_FURY).split(" ")),
stdout=subprocess.PIPE, stderr=subpro... | [
"def",
"gemfury",
"(",
")",
":",
"# fury login",
"# fury push dist/*.gz --as=YOUR_ACCT",
"# fury push dist/*.whl --as=YOUR_ACCT",
"cp",
"=",
"subprocess",
".",
"run",
"(",
"(",
"\"fury login --as={0}\"",
".",
"format",
"(",
"GEM_FURY",
")",
".",
"split",
"(",
"\" \"",... | Push to gem fury, a repo with private options | [
"Push",
"to",
"gem",
"fury",
"a",
"repo",
"with",
"private",
"options"
] | 963656a0a47b7162780a5f6c8f4b8bbbebc148f5 | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/build.py#L449-L490 |
245,296 | ronaldguillen/wave | wave/utils/field_mapping.py | needs_label | def needs_label(model_field, field_name):
"""
Returns `True` if the label based on the model's verbose name
is not equal to the default label it would have based on it's field name.
"""
default_label = field_name.replace('_', ' ').capitalize()
return capfirst(model_field.verbose_name) != default... | python | def needs_label(model_field, field_name):
"""
Returns `True` if the label based on the model's verbose name
is not equal to the default label it would have based on it's field name.
"""
default_label = field_name.replace('_', ' ').capitalize()
return capfirst(model_field.verbose_name) != default... | [
"def",
"needs_label",
"(",
"model_field",
",",
"field_name",
")",
":",
"default_label",
"=",
"field_name",
".",
"replace",
"(",
"'_'",
",",
"' '",
")",
".",
"capitalize",
"(",
")",
"return",
"capfirst",
"(",
"model_field",
".",
"verbose_name",
")",
"!=",
"... | Returns `True` if the label based on the model's verbose name
is not equal to the default label it would have based on it's field name. | [
"Returns",
"True",
"if",
"the",
"label",
"based",
"on",
"the",
"model",
"s",
"verbose",
"name",
"is",
"not",
"equal",
"to",
"the",
"default",
"label",
"it",
"would",
"have",
"based",
"on",
"it",
"s",
"field",
"name",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/utils/field_mapping.py#L46-L52 |
245,297 | ronaldguillen/wave | wave/utils/field_mapping.py | get_relation_kwargs | def get_relation_kwargs(field_name, relation_info):
"""
Creates a default instance of a flat relational field.
"""
model_field, related_model, to_many, to_field, has_through_model = relation_info
kwargs = {
'queryset': related_model._default_manager,
'view_name': get_detail_view_name... | python | def get_relation_kwargs(field_name, relation_info):
"""
Creates a default instance of a flat relational field.
"""
model_field, related_model, to_many, to_field, has_through_model = relation_info
kwargs = {
'queryset': related_model._default_manager,
'view_name': get_detail_view_name... | [
"def",
"get_relation_kwargs",
"(",
"field_name",
",",
"relation_info",
")",
":",
"model_field",
",",
"related_model",
",",
"to_many",
",",
"to_field",
",",
"has_through_model",
"=",
"relation_info",
"kwargs",
"=",
"{",
"'queryset'",
":",
"related_model",
".",
"_de... | Creates a default instance of a flat relational field. | [
"Creates",
"a",
"default",
"instance",
"of",
"a",
"flat",
"relational",
"field",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/utils/field_mapping.py#L237-L283 |
245,298 | Diaoul/pyextdirect | pyextdirect/api.py | create_api_dict | def create_api_dict(bases, url, **kwargs):
"""Create an API dict
:param bases: configuration bases
:type bases: :class:`~pyextdirect.configuration.Base` or list of :class:`~pyextdirect.configuration.Base`
:param string url: URL where the router can be reached
:param \*\*kwargs: extra keyword argume... | python | def create_api_dict(bases, url, **kwargs):
"""Create an API dict
:param bases: configuration bases
:type bases: :class:`~pyextdirect.configuration.Base` or list of :class:`~pyextdirect.configuration.Base`
:param string url: URL where the router can be reached
:param \*\*kwargs: extra keyword argume... | [
"def",
"create_api_dict",
"(",
"bases",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"api",
"=",
"kwargs",
"or",
"{",
"}",
"api",
".",
"update",
"(",
"{",
"'type'",
":",
"'remoting'",
",",
"'url'",
":",
"url",
",",
"'actions'",
":",
"defaultdict",
... | Create an API dict
:param bases: configuration bases
:type bases: :class:`~pyextdirect.configuration.Base` or list of :class:`~pyextdirect.configuration.Base`
:param string url: URL where the router can be reached
:param \*\*kwargs: extra keyword arguments to populate the API dict. Most common keyword ... | [
"Create",
"an",
"API",
"dict"
] | 34ddfe882d467b3769644e8131fb90fe472eff80 | https://github.com/Diaoul/pyextdirect/blob/34ddfe882d467b3769644e8131fb90fe472eff80/pyextdirect/api.py#L36-L65 |
245,299 | maxfischer2781/chainlet | chainlet/primitives/bundle.py | bundle_sequences | def bundle_sequences(element):
"""
Convert sequence types to bundles
This converter automatically constructs a :py:class:`~.Bundle`
from any :py:class:`tuple`, :py:class:`list` or :py:class:`set`
encountered during linking.
The following two lines produce the same chain:
.. code:: python
... | python | def bundle_sequences(element):
"""
Convert sequence types to bundles
This converter automatically constructs a :py:class:`~.Bundle`
from any :py:class:`tuple`, :py:class:`list` or :py:class:`set`
encountered during linking.
The following two lines produce the same chain:
.. code:: python
... | [
"def",
"bundle_sequences",
"(",
"element",
")",
":",
"if",
"isinstance",
"(",
"element",
",",
"(",
"tuple",
",",
"list",
",",
"set",
")",
")",
":",
"return",
"Bundle",
"(",
"element",
")",
"return",
"NotImplemented"
] | Convert sequence types to bundles
This converter automatically constructs a :py:class:`~.Bundle`
from any :py:class:`tuple`, :py:class:`list` or :py:class:`set`
encountered during linking.
The following two lines produce the same chain:
.. code:: python
a >> [b, c, d] >> e
a >> Bu... | [
"Convert",
"sequence",
"types",
"to",
"bundles"
] | 4e17f9992b4780bd0d9309202e2847df640bffe8 | https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/primitives/bundle.py#L41-L57 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.