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
244,100
PSU-OIT-ARC/django-local-settings
local_settings/strategy.py
guess_strategy_type
def guess_strategy_type(file_name_or_ext): """Guess strategy type to use for file by extension. Args: file_name_or_ext: Either a file name with an extension or just an extension Returns: Strategy: Type corresponding to extension or None if there's no corresponding s...
python
def guess_strategy_type(file_name_or_ext): """Guess strategy type to use for file by extension. Args: file_name_or_ext: Either a file name with an extension or just an extension Returns: Strategy: Type corresponding to extension or None if there's no corresponding s...
[ "def", "guess_strategy_type", "(", "file_name_or_ext", ")", ":", "if", "'.'", "not", "in", "file_name_or_ext", ":", "ext", "=", "file_name_or_ext", "else", ":", "name", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "file_name_or_ext", ")", "ext",...
Guess strategy type to use for file by extension. Args: file_name_or_ext: Either a file name with an extension or just an extension Returns: Strategy: Type corresponding to extension or None if there's no corresponding strategy type
[ "Guess", "strategy", "type", "to", "use", "for", "file", "by", "extension", "." ]
758810fbd9411c2046a187afcac6532155cac694
https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/strategy.py#L232-L250
244,101
PSU-OIT-ARC/django-local-settings
local_settings/strategy.py
INIStrategy.read_file
def read_file(self, file_name, section=None): """Read settings from specified ``section`` of config file.""" file_name, section = self.parse_file_name_and_section(file_name, section) if not os.path.isfile(file_name): raise SettingsFileNotFoundError(file_name) parser = self.ma...
python
def read_file(self, file_name, section=None): """Read settings from specified ``section`` of config file.""" file_name, section = self.parse_file_name_and_section(file_name, section) if not os.path.isfile(file_name): raise SettingsFileNotFoundError(file_name) parser = self.ma...
[ "def", "read_file", "(", "self", ",", "file_name", ",", "section", "=", "None", ")", ":", "file_name", ",", "section", "=", "self", ".", "parse_file_name_and_section", "(", "file_name", ",", "section", ")", "if", "not", "os", ".", "path", ".", "isfile", ...
Read settings from specified ``section`` of config file.
[ "Read", "settings", "from", "specified", "section", "of", "config", "file", "." ]
758810fbd9411c2046a187afcac6532155cac694
https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/strategy.py#L122-L152
244,102
PSU-OIT-ARC/django-local-settings
local_settings/strategy.py
INIStrategy.get_default_section
def get_default_section(self, file_name): """Returns first non-DEFAULT section; falls back to DEFAULT.""" if not os.path.isfile(file_name): return 'DEFAULT' parser = self.make_parser() with open(file_name) as fp: parser.read_file(fp) sections = parser.sect...
python
def get_default_section(self, file_name): """Returns first non-DEFAULT section; falls back to DEFAULT.""" if not os.path.isfile(file_name): return 'DEFAULT' parser = self.make_parser() with open(file_name) as fp: parser.read_file(fp) sections = parser.sect...
[ "def", "get_default_section", "(", "self", ",", "file_name", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "file_name", ")", ":", "return", "'DEFAULT'", "parser", "=", "self", ".", "make_parser", "(", ")", "with", "open", "(", "file_name"...
Returns first non-DEFAULT section; falls back to DEFAULT.
[ "Returns", "first", "non", "-", "DEFAULT", "section", ";", "falls", "back", "to", "DEFAULT", "." ]
758810fbd9411c2046a187afcac6532155cac694
https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/strategy.py#L176-L185
244,103
collectiveacuity/labPack
labpack/platforms/heroku.py
herokuClient._validate_install
def _validate_install(self): ''' a method to validate heroku is installed ''' self.printer('Checking heroku installation ... ', flush=True) # import dependencies from os import devnull from subprocess import call, check_output # validate cli installation...
python
def _validate_install(self): ''' a method to validate heroku is installed ''' self.printer('Checking heroku installation ... ', flush=True) # import dependencies from os import devnull from subprocess import call, check_output # validate cli installation...
[ "def", "_validate_install", "(", "self", ")", ":", "self", ".", "printer", "(", "'Checking heroku installation ... '", ",", "flush", "=", "True", ")", "# import dependencies\r", "from", "os", "import", "devnull", "from", "subprocess", "import", "call", ",", "check...
a method to validate heroku is installed
[ "a", "method", "to", "validate", "heroku", "is", "installed" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/heroku.py#L65-L86
244,104
collectiveacuity/labPack
labpack/platforms/heroku.py
herokuClient._update_netrc
def _update_netrc(self, netrc_path, auth_token, account_email): ''' a method to replace heroku login details in netrc file ''' # define patterns import re record_end = '(\n\n|\n\w|$)' heroku_regex = re.compile('(machine\sapi\.heroku\.com.*?\nmachine\sgit\.heroku\...
python
def _update_netrc(self, netrc_path, auth_token, account_email): ''' a method to replace heroku login details in netrc file ''' # define patterns import re record_end = '(\n\n|\n\w|$)' heroku_regex = re.compile('(machine\sapi\.heroku\.com.*?\nmachine\sgit\.heroku\...
[ "def", "_update_netrc", "(", "self", ",", "netrc_path", ",", "auth_token", ",", "account_email", ")", ":", "# define patterns\r", "import", "re", "record_end", "=", "'(\\n\\n|\\n\\w|$)'", "heroku_regex", "=", "re", ".", "compile", "(", "'(machine\\sapi\\.heroku\\.com....
a method to replace heroku login details in netrc file
[ "a", "method", "to", "replace", "heroku", "login", "details", "in", "netrc", "file" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/heroku.py#L88-L117
244,105
collectiveacuity/labPack
labpack/platforms/heroku.py
herokuClient._validate_login
def _validate_login(self): ''' a method to validate user can access heroku account ''' title = '%s.validate_login' % self.__class__.__name__ # verbosity windows_insert = ' On windows, run in cmd.exe' self.printer('Checking heroku credentials ......
python
def _validate_login(self): ''' a method to validate user can access heroku account ''' title = '%s.validate_login' % self.__class__.__name__ # verbosity windows_insert = ' On windows, run in cmd.exe' self.printer('Checking heroku credentials ......
[ "def", "_validate_login", "(", "self", ")", ":", "title", "=", "'%s.validate_login'", "%", "self", ".", "__class__", ".", "__name__", "# verbosity\r", "windows_insert", "=", "' On windows, run in cmd.exe'", "self", ".", "printer", "(", "'Checking heroku credentials ... ...
a method to validate user can access heroku account
[ "a", "method", "to", "validate", "user", "can", "access", "heroku", "account" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/heroku.py#L119-L185
244,106
collectiveacuity/labPack
labpack/platforms/heroku.py
herokuClient.access
def access(self, app_subdomain): ''' a method to validate user can access app ''' title = '%s.access' % self.__class__.__name__ # validate input input_fields = { 'app_subdomain': app_subdomain } for key, value in input_fields.items(): ...
python
def access(self, app_subdomain): ''' a method to validate user can access app ''' title = '%s.access' % self.__class__.__name__ # validate input input_fields = { 'app_subdomain': app_subdomain } for key, value in input_fields.items(): ...
[ "def", "access", "(", "self", ",", "app_subdomain", ")", ":", "title", "=", "'%s.access'", "%", "self", ".", "__class__", ".", "__name__", "# validate input\r", "input_fields", "=", "{", "'app_subdomain'", ":", "app_subdomain", "}", "for", "key", ",", "value",...
a method to validate user can access app
[ "a", "method", "to", "validate", "user", "can", "access", "app" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/heroku.py#L187-L237
244,107
collectiveacuity/labPack
labpack/platforms/heroku.py
herokuClient.deploy_docker
def deploy_docker(self, dockerfile_path, virtualbox_name='default'): ''' a method to deploy app to heroku using docker ''' title = '%s.deploy_docker' % self.__class__.__name__ # validate inputs input_fields = { 'dockerfile_path': dockerfile_path, 'virtualb...
python
def deploy_docker(self, dockerfile_path, virtualbox_name='default'): ''' a method to deploy app to heroku using docker ''' title = '%s.deploy_docker' % self.__class__.__name__ # validate inputs input_fields = { 'dockerfile_path': dockerfile_path, 'virtualb...
[ "def", "deploy_docker", "(", "self", ",", "dockerfile_path", ",", "virtualbox_name", "=", "'default'", ")", ":", "title", "=", "'%s.deploy_docker'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs\r", "input_fields", "=", "{", "'dockerfile_path'",...
a method to deploy app to heroku using docker
[ "a", "method", "to", "deploy", "app", "to", "heroku", "using", "docker" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/heroku.py#L239-L319
244,108
quasipedia/swaggery
swaggery/appinit.py
init
def init(): '''Initialise a WSGI application to be loaded by uWSGI.''' # Load values from config file config_file = os.path.realpath(os.path.join(os.getcwd(), 'swaggery.ini')) config = configparser.RawConfigParser(allow_no_value=True) config.read(config_file) log_level = config.get('application'...
python
def init(): '''Initialise a WSGI application to be loaded by uWSGI.''' # Load values from config file config_file = os.path.realpath(os.path.join(os.getcwd(), 'swaggery.ini')) config = configparser.RawConfigParser(allow_no_value=True) config.read(config_file) log_level = config.get('application'...
[ "def", "init", "(", ")", ":", "# Load values from config file", "config_file", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "getcwd", "(", ")", ",", "'swaggery.ini'", ")", ")", "config", "=", "configparser...
Initialise a WSGI application to be loaded by uWSGI.
[ "Initialise", "a", "WSGI", "application", "to", "be", "loaded", "by", "uWSGI", "." ]
89a2e1b2bebbc511c781c9e63972f65aef73cc2f
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/appinit.py#L10-L26
244,109
ravenac95/lxc4u
lxc4u/service.py
LXCService.list_names
def list_names(cls): """Lists all known LXC names""" response = subwrap.run(['lxc-ls']) output = response.std_out return map(str.strip, output.splitlines())
python
def list_names(cls): """Lists all known LXC names""" response = subwrap.run(['lxc-ls']) output = response.std_out return map(str.strip, output.splitlines())
[ "def", "list_names", "(", "cls", ")", ":", "response", "=", "subwrap", ".", "run", "(", "[", "'lxc-ls'", "]", ")", "output", "=", "response", ".", "std_out", "return", "map", "(", "str", ".", "strip", ",", "output", ".", "splitlines", "(", ")", ")" ]
Lists all known LXC names
[ "Lists", "all", "known", "LXC", "names" ]
4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32
https://github.com/ravenac95/lxc4u/blob/4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32/lxc4u/service.py#L18-L22
244,110
ravenac95/lxc4u
lxc4u/service.py
LXCService.info
def info(cls, name, get_state=True, get_pid=True): """Retrieves and parses info about an LXC""" # Run lxc-info quietly command = ['lxc-info', '-n', name] response = subwrap.run(command) lines = map(split_info_line, response.std_out.splitlines()) return dict(lines)
python
def info(cls, name, get_state=True, get_pid=True): """Retrieves and parses info about an LXC""" # Run lxc-info quietly command = ['lxc-info', '-n', name] response = subwrap.run(command) lines = map(split_info_line, response.std_out.splitlines()) return dict(lines)
[ "def", "info", "(", "cls", ",", "name", ",", "get_state", "=", "True", ",", "get_pid", "=", "True", ")", ":", "# Run lxc-info quietly", "command", "=", "[", "'lxc-info'", ",", "'-n'", ",", "name", "]", "response", "=", "subwrap", ".", "run", "(", "comm...
Retrieves and parses info about an LXC
[ "Retrieves", "and", "parses", "info", "about", "an", "LXC" ]
4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32
https://github.com/ravenac95/lxc4u/blob/4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32/lxc4u/service.py#L62-L68
244,111
rameshg87/pyremotevbox
pyremotevbox/ZSI/generate/wsdl2python.py
WriteServiceModule.getClientModuleName
def getClientModuleName(self): """client module name. """ name = GetModuleBaseNameFromWSDL(self._wsdl) if not name: raise WsdlGeneratorError, 'could not determine a service name' if self.client_module_suffix is None: return name return '%...
python
def getClientModuleName(self): """client module name. """ name = GetModuleBaseNameFromWSDL(self._wsdl) if not name: raise WsdlGeneratorError, 'could not determine a service name' if self.client_module_suffix is None: return name return '%...
[ "def", "getClientModuleName", "(", "self", ")", ":", "name", "=", "GetModuleBaseNameFromWSDL", "(", "self", ".", "_wsdl", ")", "if", "not", "name", ":", "raise", "WsdlGeneratorError", ",", "'could not determine a service name'", "if", "self", ".", "client_module_suf...
client module name.
[ "client", "module", "name", "." ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L74-L84
244,112
rameshg87/pyremotevbox
pyremotevbox/ZSI/generate/wsdl2python.py
WriteServiceModule.getTypesModuleName
def getTypesModuleName(self): """types module name. """ if self.types_module_name is not None: return self.types_module_name name = GetModuleBaseNameFromWSDL(self._wsdl) if not name: raise WsdlGeneratorError, 'could not determine a service name' ...
python
def getTypesModuleName(self): """types module name. """ if self.types_module_name is not None: return self.types_module_name name = GetModuleBaseNameFromWSDL(self._wsdl) if not name: raise WsdlGeneratorError, 'could not determine a service name' ...
[ "def", "getTypesModuleName", "(", "self", ")", ":", "if", "self", ".", "types_module_name", "is", "not", "None", ":", "return", "self", ".", "types_module_name", "name", "=", "GetModuleBaseNameFromWSDL", "(", "self", ".", "_wsdl", ")", "if", "not", "name", "...
types module name.
[ "types", "module", "name", "." ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L102-L115
244,113
rameshg87/pyremotevbox
pyremotevbox/ZSI/generate/wsdl2python.py
WriteServiceModule.gatherNamespaces
def gatherNamespaces(self): '''This method must execute once.. Grab all schemas representing each targetNamespace. ''' if self.usedNamespaces is not None: return self.logger.debug('gatherNamespaces') self.usedNamespaces = {} # Add all sc...
python
def gatherNamespaces(self): '''This method must execute once.. Grab all schemas representing each targetNamespace. ''' if self.usedNamespaces is not None: return self.logger.debug('gatherNamespaces') self.usedNamespaces = {} # Add all sc...
[ "def", "gatherNamespaces", "(", "self", ")", ":", "if", "self", ".", "usedNamespaces", "is", "not", "None", ":", "return", "self", ".", "logger", ".", "debug", "(", "'gatherNamespaces'", ")", "self", ".", "usedNamespaces", "=", "{", "}", "# Add all schemas d...
This method must execute once.. Grab all schemas representing each targetNamespace.
[ "This", "method", "must", "execute", "once", "..", "Grab", "all", "schemas", "representing", "each", "targetNamespace", "." ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L146-L175
244,114
rameshg87/pyremotevbox
pyremotevbox/ZSI/generate/wsdl2python.py
WriteServiceModule.writeTypes
def writeTypes(self, fd): """write out types module to file descriptor. """ print >>fd, '#'*50 print >>fd, '# file: %s.py' %self.getTypesModuleName() print >>fd, '#' print >>fd, '# schema types generated by "%s"' %self.__class__ print >>fd, '# %s' %' '.join(sys...
python
def writeTypes(self, fd): """write out types module to file descriptor. """ print >>fd, '#'*50 print >>fd, '# file: %s.py' %self.getTypesModuleName() print >>fd, '#' print >>fd, '# schema types generated by "%s"' %self.__class__ print >>fd, '# %s' %' '.join(sys...
[ "def", "writeTypes", "(", "self", ",", "fd", ")", ":", "print", ">>", "fd", ",", "'#'", "*", "50", "print", ">>", "fd", ",", "'# file: %s.py'", "%", "self", ".", "getTypesModuleName", "(", ")", "print", ">>", "fd", ",", "'#'", "print", ">>", "fd", ...
write out types module to file descriptor.
[ "write", "out", "types", "module", "to", "file", "descriptor", "." ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L215-L233
244,115
rameshg87/pyremotevbox
pyremotevbox/ZSI/generate/wsdl2python.py
SchemaDescription.fromSchema
def fromSchema(self, schema): ''' Can be called multiple times, but will not redefine a previously defined type definition or element declaration. ''' ns = schema.getTargetNamespace() assert self.targetNamespace is None or self.targetNamespace == ns,\ 'SchemaDescrip...
python
def fromSchema(self, schema): ''' Can be called multiple times, but will not redefine a previously defined type definition or element declaration. ''' ns = schema.getTargetNamespace() assert self.targetNamespace is None or self.targetNamespace == ns,\ 'SchemaDescrip...
[ "def", "fromSchema", "(", "self", ",", "schema", ")", ":", "ns", "=", "schema", ".", "getTargetNamespace", "(", ")", "assert", "self", ".", "targetNamespace", "is", "None", "or", "self", ".", "targetNamespace", "==", "ns", ",", "'SchemaDescription instance rep...
Can be called multiple times, but will not redefine a previously defined type definition or element declaration.
[ "Can", "be", "called", "multiple", "times", "but", "will", "not", "redefine", "a", "previously", "defined", "type", "definition", "or", "element", "declaration", "." ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L401-L422
244,116
rameshg87/pyremotevbox
pyremotevbox/ZSI/generate/wsdl2python.py
SchemaDescription.write
def write(self, fd): """write out to file descriptor. """ print >>fd, self.classHead for t in self.items: print >>fd, t print >>fd, self.classFoot
python
def write(self, fd): """write out to file descriptor. """ print >>fd, self.classHead for t in self.items: print >>fd, t print >>fd, self.classFoot
[ "def", "write", "(", "self", ",", "fd", ")", ":", "print", ">>", "fd", ",", "self", ".", "classHead", "for", "t", "in", "self", ".", "items", ":", "print", ">>", "fd", ",", "t", "print", ">>", "fd", ",", "self", ".", "classFoot" ]
write out to file descriptor.
[ "write", "out", "to", "file", "descriptor", "." ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L430-L436
244,117
rameshg87/pyremotevbox
pyremotevbox/ZSI/generate/wsdl2python.py
ElementWriter.fromSchemaItem
def fromSchemaItem(self, item): """set up global elements. """ if item.isElement() is False or item.isLocal() is True: raise TypeError, 'expecting global element declaration: %s' %item.getItemTrace() local = False qName = item.getAttribute('type') if not qNam...
python
def fromSchemaItem(self, item): """set up global elements. """ if item.isElement() is False or item.isLocal() is True: raise TypeError, 'expecting global element declaration: %s' %item.getItemTrace() local = False qName = item.getAttribute('type') if not qNam...
[ "def", "fromSchemaItem", "(", "self", ",", "item", ")", ":", "if", "item", ".", "isElement", "(", ")", "is", "False", "or", "item", ".", "isLocal", "(", ")", "is", "True", ":", "raise", "TypeError", ",", "'expecting global element declaration: %s'", "%", "...
set up global elements.
[ "set", "up", "global", "elements", "." ]
123dffff27da57c8faa3ac1dd4c68b1cf4558b1a
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L462-L493
244,118
yougov/yg.lockfile
yg/lockfile/__init__.py
LockBase.acquire
def acquire(self): """ Attempt to acquire the lock every `delay` seconds until the lock is acquired or until `timeout` has expired. Raises FileLockTimeout if the timeout is exceeded. Errors opening the lock file (other than if it exists) are passed through. """ ...
python
def acquire(self): """ Attempt to acquire the lock every `delay` seconds until the lock is acquired or until `timeout` has expired. Raises FileLockTimeout if the timeout is exceeded. Errors opening the lock file (other than if it exists) are passed through. """ ...
[ "def", "acquire", "(", "self", ")", ":", "self", ".", "lock", "=", "retry_call", "(", "self", ".", "_attempt", ",", "retries", "=", "float", "(", "'inf'", ")", ",", "trap", "=", "zc", ".", "lockfile", ".", "LockError", ",", "cleanup", "=", "functools...
Attempt to acquire the lock every `delay` seconds until the lock is acquired or until `timeout` has expired. Raises FileLockTimeout if the timeout is exceeded. Errors opening the lock file (other than if it exists) are passed through.
[ "Attempt", "to", "acquire", "the", "lock", "every", "delay", "seconds", "until", "the", "lock", "is", "acquired", "or", "until", "timeout", "has", "expired", "." ]
e6bf1e5e6a9aedc657b1fcf5601693da50744cfe
https://github.com/yougov/yg.lockfile/blob/e6bf1e5e6a9aedc657b1fcf5601693da50744cfe/yg/lockfile/__init__.py#L67-L82
244,119
yougov/yg.lockfile
yg/lockfile/__init__.py
LockBase.release
def release(self): """ Release the lock and cleanup """ lock = vars(self).pop('lock', missing) lock is not missing and self._release(lock)
python
def release(self): """ Release the lock and cleanup """ lock = vars(self).pop('lock', missing) lock is not missing and self._release(lock)
[ "def", "release", "(", "self", ")", ":", "lock", "=", "vars", "(", "self", ")", ".", "pop", "(", "'lock'", ",", "missing", ")", "lock", "is", "not", "missing", "and", "self", ".", "_release", "(", "lock", ")" ]
Release the lock and cleanup
[ "Release", "the", "lock", "and", "cleanup" ]
e6bf1e5e6a9aedc657b1fcf5601693da50744cfe
https://github.com/yougov/yg.lockfile/blob/e6bf1e5e6a9aedc657b1fcf5601693da50744cfe/yg/lockfile/__init__.py#L84-L89
244,120
praekelt/panya
panya/generic/views.py
GenericBase._resolve_view_params
def _resolve_view_params(self, request, defaults, *args, **kwargs): """ Resolves view params with least ammount of resistance. Firstly check for params on urls passed args, then on class init args or members, and lastly on class get methods . """ params = copy.copy(defau...
python
def _resolve_view_params(self, request, defaults, *args, **kwargs): """ Resolves view params with least ammount of resistance. Firstly check for params on urls passed args, then on class init args or members, and lastly on class get methods . """ params = copy.copy(defau...
[ "def", "_resolve_view_params", "(", "self", ",", "request", ",", "defaults", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "params", "=", "copy", ".", "copy", "(", "defaults", ")", "params", ".", "update", "(", "self", ".", "params", ")", "par...
Resolves view params with least ammount of resistance. Firstly check for params on urls passed args, then on class init args or members, and lastly on class get methods .
[ "Resolves", "view", "params", "with", "least", "ammount", "of", "resistance", ".", "Firstly", "check", "for", "params", "on", "urls", "passed", "args", "then", "on", "class", "init", "args", "or", "members", "and", "lastly", "on", "class", "get", "methods", ...
0fd621e15a7c11a2716a9554a2f820d6259818e5
https://github.com/praekelt/panya/blob/0fd621e15a7c11a2716a9554a2f820d6259818e5/panya/generic/views.py#L50-L85
244,121
praekelt/panya
panya/generic/views.py
GenericForm.handle_valid
def handle_valid(self, form=None, *args, **kwargs): """ Called after the form has validated. """ # Take a chance and try save a subclass of a ModelForm. if hasattr(form, 'save'): form.save() # Also try and call handle_valid method of the form itself. i...
python
def handle_valid(self, form=None, *args, **kwargs): """ Called after the form has validated. """ # Take a chance and try save a subclass of a ModelForm. if hasattr(form, 'save'): form.save() # Also try and call handle_valid method of the form itself. i...
[ "def", "handle_valid", "(", "self", ",", "form", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Take a chance and try save a subclass of a ModelForm.", "if", "hasattr", "(", "form", ",", "'save'", ")", ":", "form", ".", "save", "(", "...
Called after the form has validated.
[ "Called", "after", "the", "form", "has", "validated", "." ]
0fd621e15a7c11a2716a9554a2f820d6259818e5
https://github.com/praekelt/panya/blob/0fd621e15a7c11a2716a9554a2f820d6259818e5/panya/generic/views.py#L172-L181
244,122
lwcook/horsetail-matching
horsetailmatching/weightedsum.py
WeightedSum.evalMetric
def evalMetric(self, x, w1=None, w2=None): '''Evaluates the weighted sum metric at given values of the design variables. :param iterable x: values of the design variables, this is passed as the first argument to the function fqoi :param float w1: value to weight the mean by...
python
def evalMetric(self, x, w1=None, w2=None): '''Evaluates the weighted sum metric at given values of the design variables. :param iterable x: values of the design variables, this is passed as the first argument to the function fqoi :param float w1: value to weight the mean by...
[ "def", "evalMetric", "(", "self", ",", "x", ",", "w1", "=", "None", ",", "w2", "=", "None", ")", ":", "if", "w1", "is", "None", ":", "w1", "=", "self", ".", "w1", "if", "w2", "is", "None", ":", "w2", "=", "self", ".", "w2", "if", "self", "....
Evaluates the weighted sum metric at given values of the design variables. :param iterable x: values of the design variables, this is passed as the first argument to the function fqoi :param float w1: value to weight the mean by :param float w2: value to weight the std by ...
[ "Evaluates", "the", "weighted", "sum", "metric", "at", "given", "values", "of", "the", "design", "variables", "." ]
f3d5f8d01249debbca978f412ce4eae017458119
https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/weightedsum.py#L96-L143
244,123
IntegralDefense/critsapi
critsapi/critsapi.py
CRITsAPI.add_event
def add_event(self, source, reference, event_title, event_type, method='', description='', bucket_list=[], campaign='', confidence='', date=...
python
def add_event(self, source, reference, event_title, event_type, method='', description='', bucket_list=[], campaign='', confidence='', date=...
[ "def", "add_event", "(", "self", ",", "source", ",", "reference", ",", "event_title", ",", "event_type", ",", "method", "=", "''", ",", "description", "=", "''", ",", "bucket_list", "=", "[", "]", ",", "campaign", "=", "''", ",", "confidence", "=", "''...
Adds an event. If the event name already exists, it will return that event instead. Args: source: Source of the information reference: A reference where more information can be found event_title: The title of the event event_type: The type of event. See y...
[ "Adds", "an", "event", ".", "If", "the", "event", "name", "already", "exists", "it", "will", "return", "that", "event", "instead", "." ]
e770bd81e124eaaeb5f1134ba95f4a35ff345c5a
https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L117-L183
244,124
IntegralDefense/critsapi
critsapi/critsapi.py
CRITsAPI.add_sample_file
def add_sample_file(self, sample_path, source, reference, method='', file_format='raw', file_password='', sample_name='', campai...
python
def add_sample_file(self, sample_path, source, reference, method='', file_format='raw', file_password='', sample_name='', campai...
[ "def", "add_sample_file", "(", "self", ",", "sample_path", ",", "source", ",", "reference", ",", "method", "=", "''", ",", "file_format", "=", "'raw'", ",", "file_password", "=", "''", ",", "sample_name", "=", "''", ",", "campaign", "=", "''", ",", "conf...
Adds a file sample. For meta data only use add_sample_meta. Args: sample_path: The path on disk of the sample to upload source: Source of the information reference: A reference where more information can be found method: The method for obtaining the sample. ...
[ "Adds", "a", "file", "sample", ".", "For", "meta", "data", "only", "use", "add_sample_meta", "." ]
e770bd81e124eaaeb5f1134ba95f4a35ff345c5a
https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L185-L246
244,125
IntegralDefense/critsapi
critsapi/critsapi.py
CRITsAPI.add_sample_meta
def add_sample_meta(self, source, reference, method='', filename='', md5='', sha1='', sha256='', size='', ...
python
def add_sample_meta(self, source, reference, method='', filename='', md5='', sha1='', sha256='', size='', ...
[ "def", "add_sample_meta", "(", "self", ",", "source", ",", "reference", ",", "method", "=", "''", ",", "filename", "=", "''", ",", "md5", "=", "''", ",", "sha1", "=", "''", ",", "sha256", "=", "''", ",", "size", "=", "''", ",", "mimetype", "=", "...
Adds a metadata sample. To add an actual file, use add_sample_file. Args: source: Source of the information reference: A reference where more information can be found method: The method for obtaining the sample. filename: The name of the file. md5: An...
[ "Adds", "a", "metadata", "sample", ".", "To", "add", "an", "actual", "file", "use", "add_sample_file", "." ]
e770bd81e124eaaeb5f1134ba95f4a35ff345c5a
https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L248-L309
244,126
IntegralDefense/critsapi
critsapi/critsapi.py
CRITsAPI.add_email
def add_email(self, email_path, source, reference, method='', upload_type='raw', campaign='', confidence='', description='', bucket_list=[], ...
python
def add_email(self, email_path, source, reference, method='', upload_type='raw', campaign='', confidence='', description='', bucket_list=[], ...
[ "def", "add_email", "(", "self", ",", "email_path", ",", "source", ",", "reference", ",", "method", "=", "''", ",", "upload_type", "=", "'raw'", ",", "campaign", "=", "''", ",", "confidence", "=", "''", ",", "description", "=", "''", ",", "bucket_list", ...
Add an email object to CRITs. Only RAW, MSG, and EML are supported currently. Args: email_path: The path on disk of the email. source: Source of the information reference: A reference where more information can be found method: The method for obtaining th...
[ "Add", "an", "email", "object", "to", "CRITs", ".", "Only", "RAW", "MSG", "and", "EML", "are", "supported", "currently", "." ]
e770bd81e124eaaeb5f1134ba95f4a35ff345c5a
https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L311-L369
244,127
IntegralDefense/critsapi
critsapi/critsapi.py
CRITsAPI.add_backdoor
def add_backdoor(self, backdoor_name, source, reference, method='', aliases=[], version='', campaign='', confidence='', description...
python
def add_backdoor(self, backdoor_name, source, reference, method='', aliases=[], version='', campaign='', confidence='', description...
[ "def", "add_backdoor", "(", "self", ",", "backdoor_name", ",", "source", ",", "reference", ",", "method", "=", "''", ",", "aliases", "=", "[", "]", ",", "version", "=", "''", ",", "campaign", "=", "''", ",", "confidence", "=", "''", ",", "description",...
Add a backdoor object to CRITs. Args: backdoor_name: The primary name of the backdoor source: Source of the information reference: A reference where more information can be found method: The method for obtaining the backdoor information. aliases: List...
[ "Add", "a", "backdoor", "object", "to", "CRITs", "." ]
e770bd81e124eaaeb5f1134ba95f4a35ff345c5a
https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L371-L421
244,128
IntegralDefense/critsapi
critsapi/critsapi.py
CRITsAPI.get_events
def get_events(self, event_title, regex=False): """ Search for events with the provided title Args: event_title: The title of the event Returns: An event JSON object returned from the server with the following: { "meta":{ ...
python
def get_events(self, event_title, regex=False): """ Search for events with the provided title Args: event_title: The title of the event Returns: An event JSON object returned from the server with the following: { "meta":{ ...
[ "def", "get_events", "(", "self", ",", "event_title", ",", "regex", "=", "False", ")", ":", "regex_val", "=", "0", "if", "regex", ":", "regex_val", "=", "1", "r", "=", "requests", ".", "get", "(", "'{0}/events/?api_key={1}&username={2}&c-title='", "'{3}&regex=...
Search for events with the provided title Args: event_title: The title of the event Returns: An event JSON object returned from the server with the following: { "meta":{ "limit": 20, "next": null, "offset": 0, ...
[ "Search", "for", "events", "with", "the", "provided", "title" ]
e770bd81e124eaaeb5f1134ba95f4a35ff345c5a
https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L471-L501
244,129
IntegralDefense/critsapi
critsapi/critsapi.py
CRITsAPI.get_samples
def get_samples(self, md5='', sha1='', sha256=''): """ Searches for a sample in CRITs. Currently only hashes allowed. Args: md5: md5sum sha1: sha1sum sha256: sha256sum Returns: JSON response or None if not found """ params ...
python
def get_samples(self, md5='', sha1='', sha256=''): """ Searches for a sample in CRITs. Currently only hashes allowed. Args: md5: md5sum sha1: sha1sum sha256: sha256sum Returns: JSON response or None if not found """ params ...
[ "def", "get_samples", "(", "self", ",", "md5", "=", "''", ",", "sha1", "=", "''", ",", "sha256", "=", "''", ")", ":", "params", "=", "{", "'api_key'", ":", "self", ".", "api_key", ",", "'username'", ":", "self", ".", "username", "}", "if", "md5", ...
Searches for a sample in CRITs. Currently only hashes allowed. Args: md5: md5sum sha1: sha1sum sha256: sha256sum Returns: JSON response or None if not found
[ "Searches", "for", "a", "sample", "in", "CRITs", ".", "Currently", "only", "hashes", "allowed", "." ]
e770bd81e124eaaeb5f1134ba95f4a35ff345c5a
https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L503-L533
244,130
IntegralDefense/critsapi
critsapi/critsapi.py
CRITsAPI.get_backdoor
def get_backdoor(self, name, version=''): """ Searches for the backdoor based on name and version. Args: name: The name of the backdoor. This can be an alias. version: The version. Returns: Returns a JSON object contain one or more backdoor results or...
python
def get_backdoor(self, name, version=''): """ Searches for the backdoor based on name and version. Args: name: The name of the backdoor. This can be an alias. version: The version. Returns: Returns a JSON object contain one or more backdoor results or...
[ "def", "get_backdoor", "(", "self", ",", "name", ",", "version", "=", "''", ")", ":", "params", "=", "{", "}", "params", "[", "'or'", "]", "=", "1", "params", "[", "'c-name'", "]", "=", "name", "params", "[", "'c-aliases__in'", "]", "=", "name", "r...
Searches for the backdoor based on name and version. Args: name: The name of the backdoor. This can be an alias. version: The version. Returns: Returns a JSON object contain one or more backdoor results or None if not found.
[ "Searches", "for", "the", "backdoor", "based", "on", "name", "and", "version", "." ]
e770bd81e124eaaeb5f1134ba95f4a35ff345c5a
https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L563-L598
244,131
IntegralDefense/critsapi
critsapi/critsapi.py
CRITsAPI.has_relationship
def has_relationship(self, left_id, left_type, right_id, right_type, rel_type='Related To'): """ Checks if the two objects are related Args: left_id: The CRITs ID of the first indicator left_type: The CRITs TLO type of the first indicator ...
python
def has_relationship(self, left_id, left_type, right_id, right_type, rel_type='Related To'): """ Checks if the two objects are related Args: left_id: The CRITs ID of the first indicator left_type: The CRITs TLO type of the first indicator ...
[ "def", "has_relationship", "(", "self", ",", "left_id", ",", "left_type", ",", "right_id", ",", "right_type", ",", "rel_type", "=", "'Related To'", ")", ":", "data", "=", "self", ".", "get_object", "(", "left_id", ",", "left_type", ")", "if", "not", "data"...
Checks if the two objects are related Args: left_id: The CRITs ID of the first indicator left_type: The CRITs TLO type of the first indicator right_id: The CRITs ID of the second indicator right_type: The CRITs TLO type of the second indicator rel_typ...
[ "Checks", "if", "the", "two", "objects", "are", "related" ]
e770bd81e124eaaeb5f1134ba95f4a35ff345c5a
https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L600-L629
244,132
IntegralDefense/critsapi
critsapi/critsapi.py
CRITsAPI.forge_relationship
def forge_relationship(self, left_id, left_type, right_id, right_type, rel_type='Related To', rel_date=None, rel_confidence='high', rel_reason=''): """ Forges a relationship between two TLOs. Args: left_id: The CRITs ID of the fi...
python
def forge_relationship(self, left_id, left_type, right_id, right_type, rel_type='Related To', rel_date=None, rel_confidence='high', rel_reason=''): """ Forges a relationship between two TLOs. Args: left_id: The CRITs ID of the fi...
[ "def", "forge_relationship", "(", "self", ",", "left_id", ",", "left_type", ",", "right_id", ",", "right_type", ",", "rel_type", "=", "'Related To'", ",", "rel_date", "=", "None", ",", "rel_confidence", "=", "'high'", ",", "rel_reason", "=", "''", ")", ":", ...
Forges a relationship between two TLOs. Args: left_id: The CRITs ID of the first indicator left_type: The CRITs TLO type of the first indicator right_id: The CRITs ID of the second indicator right_type: The CRITs TLO type of the second indicator rel_t...
[ "Forges", "a", "relationship", "between", "two", "TLOs", "." ]
e770bd81e124eaaeb5f1134ba95f4a35ff345c5a
https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L631-L680
244,133
IntegralDefense/critsapi
critsapi/critsapi.py
CRITsAPI._type_translation
def _type_translation(self, str_type): """ Internal method to translate the named CRITs TLO type to a URL specific string. """ if str_type == 'Indicator': return 'indicators' if str_type == 'Domain': return 'domains' if str_type == 'IP': ...
python
def _type_translation(self, str_type): """ Internal method to translate the named CRITs TLO type to a URL specific string. """ if str_type == 'Indicator': return 'indicators' if str_type == 'Domain': return 'domains' if str_type == 'IP': ...
[ "def", "_type_translation", "(", "self", ",", "str_type", ")", ":", "if", "str_type", "==", "'Indicator'", ":", "return", "'indicators'", "if", "str_type", "==", "'Domain'", ":", "return", "'domains'", "if", "str_type", "==", "'IP'", ":", "return", "'ips'", ...
Internal method to translate the named CRITs TLO type to a URL specific string.
[ "Internal", "method", "to", "translate", "the", "named", "CRITs", "TLO", "type", "to", "a", "URL", "specific", "string", "." ]
e770bd81e124eaaeb5f1134ba95f4a35ff345c5a
https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L763-L786
244,134
radjkarl/fancyTools
DUMP/intersection.py
lineSeqmentsDoIntersect
def lineSeqmentsDoIntersect(line1, line2): """ Return True if line segment line1 intersects line segment line2 and line1 and line2 are not parallel. """ (x1, y1), (x2, y2) = line1 (u1, v1), (u2, v2) = line2 (a, b), (c, d) = (x2 - x1, u1 - u2), (y2 - y1, v1 - v2) e, f = u1 - x1, v...
python
def lineSeqmentsDoIntersect(line1, line2): """ Return True if line segment line1 intersects line segment line2 and line1 and line2 are not parallel. """ (x1, y1), (x2, y2) = line1 (u1, v1), (u2, v2) = line2 (a, b), (c, d) = (x2 - x1, u1 - u2), (y2 - y1, v1 - v2) e, f = u1 - x1, v...
[ "def", "lineSeqmentsDoIntersect", "(", "line1", ",", "line2", ")", ":", "(", "x1", ",", "y1", ")", ",", "(", "x2", ",", "y2", ")", "=", "line1", "(", "u1", ",", "v1", ")", ",", "(", "u2", ",", "v2", ")", "=", "line2", "(", "a", ",", "b", ")...
Return True if line segment line1 intersects line segment line2 and line1 and line2 are not parallel.
[ "Return", "True", "if", "line", "segment", "line1", "intersects", "line", "segment", "line2", "and", "line1", "and", "line2", "are", "not", "parallel", "." ]
4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/DUMP/intersection.py#L41-L59
244,135
fakedrake/overlay_parse
overlay_parse/matchers.py
mf
def mf(pred, props=None, value_fn=None, props_on_match=False, priority=None): """ Matcher factory. """ if isinstance(pred, BaseMatcher): ret = pred if props_on_match else pred.props if isinstance(pred, basestring) or \ type(pred).__name__ == 'SRE_Pattern': ret = RegexMatcher...
python
def mf(pred, props=None, value_fn=None, props_on_match=False, priority=None): """ Matcher factory. """ if isinstance(pred, BaseMatcher): ret = pred if props_on_match else pred.props if isinstance(pred, basestring) or \ type(pred).__name__ == 'SRE_Pattern': ret = RegexMatcher...
[ "def", "mf", "(", "pred", ",", "props", "=", "None", ",", "value_fn", "=", "None", ",", "props_on_match", "=", "False", ",", "priority", "=", "None", ")", ":", "if", "isinstance", "(", "pred", ",", "BaseMatcher", ")", ":", "ret", "=", "pred", "if", ...
Matcher factory.
[ "Matcher", "factory", "." ]
9ac362d6aef1ea41aff7375af088c6ebef93d0cd
https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L255-L279
244,136
fakedrake/overlay_parse
overlay_parse/matchers.py
ListMatcher._merge_ovls
def _merge_ovls(self, ovls): """ Merge ovls and also setup the value and props. """ ret = reduce(lambda x, y: x.merge(y), ovls) ret.value = self.value(ovls=ovls) ret.set_props(self.props) return ret
python
def _merge_ovls(self, ovls): """ Merge ovls and also setup the value and props. """ ret = reduce(lambda x, y: x.merge(y), ovls) ret.value = self.value(ovls=ovls) ret.set_props(self.props) return ret
[ "def", "_merge_ovls", "(", "self", ",", "ovls", ")", ":", "ret", "=", "reduce", "(", "lambda", "x", ",", "y", ":", "x", ".", "merge", "(", "y", ")", ",", "ovls", ")", "ret", ".", "value", "=", "self", ".", "value", "(", "ovls", "=", "ovls", "...
Merge ovls and also setup the value and props.
[ "Merge", "ovls", "and", "also", "setup", "the", "value", "and", "props", "." ]
9ac362d6aef1ea41aff7375af088c6ebef93d0cd
https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L145-L153
244,137
fakedrake/overlay_parse
overlay_parse/matchers.py
ListMatcher._fit_overlay_lists
def _fit_overlay_lists(self, text, start, matchers, **kw): """ Return a list of overlays that start at start. """ if matchers: for o in matchers[0].fit_overlays(text, start): for rest in self._fit_overlay_lists(text, o.end, matchers[1:]): ...
python
def _fit_overlay_lists(self, text, start, matchers, **kw): """ Return a list of overlays that start at start. """ if matchers: for o in matchers[0].fit_overlays(text, start): for rest in self._fit_overlay_lists(text, o.end, matchers[1:]): ...
[ "def", "_fit_overlay_lists", "(", "self", ",", "text", ",", "start", ",", "matchers", ",", "*", "*", "kw", ")", ":", "if", "matchers", ":", "for", "o", "in", "matchers", "[", "0", "]", ".", "fit_overlays", "(", "text", ",", "start", ")", ":", "for"...
Return a list of overlays that start at start.
[ "Return", "a", "list", "of", "overlays", "that", "start", "at", "start", "." ]
9ac362d6aef1ea41aff7375af088c6ebef93d0cd
https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L155-L166
244,138
fakedrake/overlay_parse
overlay_parse/matchers.py
ListMatcher.offset_overlays
def offset_overlays(self, text, offset=0, run_deps=True, **kw): """ The heavy lifting is done by fit_overlays. Override just that for alternatie implementation. """ if run_deps and self.dependencies: text.overlay(self.dependencies) for ovlf in self.matchers[...
python
def offset_overlays(self, text, offset=0, run_deps=True, **kw): """ The heavy lifting is done by fit_overlays. Override just that for alternatie implementation. """ if run_deps and self.dependencies: text.overlay(self.dependencies) for ovlf in self.matchers[...
[ "def", "offset_overlays", "(", "self", ",", "text", ",", "offset", "=", "0", ",", "run_deps", "=", "True", ",", "*", "*", "kw", ")", ":", "if", "run_deps", "and", "self", ".", "dependencies", ":", "text", ".", "overlay", "(", "self", ".", "dependenci...
The heavy lifting is done by fit_overlays. Override just that for alternatie implementation.
[ "The", "heavy", "lifting", "is", "done", "by", "fit_overlays", ".", "Override", "just", "that", "for", "alternatie", "implementation", "." ]
9ac362d6aef1ea41aff7375af088c6ebef93d0cd
https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L168-L182
244,139
fakedrake/overlay_parse
overlay_parse/matchers.py
MatcherMatcher._maybe_run_matchers
def _maybe_run_matchers(self, text, run_matchers): """ OverlayedText should be smart enough to not run twice the same matchers but this is an extra handle of control over that. """ if run_matchers is True or \ (run_matchers is not False and text not in self._overlayed...
python
def _maybe_run_matchers(self, text, run_matchers): """ OverlayedText should be smart enough to not run twice the same matchers but this is an extra handle of control over that. """ if run_matchers is True or \ (run_matchers is not False and text not in self._overlayed...
[ "def", "_maybe_run_matchers", "(", "self", ",", "text", ",", "run_matchers", ")", ":", "if", "run_matchers", "is", "True", "or", "(", "run_matchers", "is", "not", "False", "and", "text", "not", "in", "self", ".", "_overlayed_already", ")", ":", "text", "."...
OverlayedText should be smart enough to not run twice the same matchers but this is an extra handle of control over that.
[ "OverlayedText", "should", "be", "smart", "enough", "to", "not", "run", "twice", "the", "same", "matchers", "but", "this", "is", "an", "extra", "handle", "of", "control", "over", "that", "." ]
9ac362d6aef1ea41aff7375af088c6ebef93d0cd
https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L218-L227
244,140
nefarioustim/parker
parker/parsedpage.py
ParsedPage.get_nodes_by_selector
def get_nodes_by_selector(self, selector, not_selector=None): """Return a collection of filtered nodes. Filtered based on the @selector and @not_selector parameters. """ nodes = self.parsed(selector) if not_selector is not None: nodes = nodes.not_(not_selector) ...
python
def get_nodes_by_selector(self, selector, not_selector=None): """Return a collection of filtered nodes. Filtered based on the @selector and @not_selector parameters. """ nodes = self.parsed(selector) if not_selector is not None: nodes = nodes.not_(not_selector) ...
[ "def", "get_nodes_by_selector", "(", "self", ",", "selector", ",", "not_selector", "=", "None", ")", ":", "nodes", "=", "self", ".", "parsed", "(", "selector", ")", "if", "not_selector", "is", "not", "None", ":", "nodes", "=", "nodes", ".", "not_", "(", ...
Return a collection of filtered nodes. Filtered based on the @selector and @not_selector parameters.
[ "Return", "a", "collection", "of", "filtered", "nodes", "." ]
ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6
https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/parsedpage.py#L21-L31
244,141
nefarioustim/parker
parker/parsedpage.py
ParsedPage.get_text_from_node
def get_text_from_node(self, node, regex=None, group=1): """Get text from node and filter if necessary.""" text = self._get_stripped_text_from_node(node) if regex is not None: text = self._filter_by_regex(regex, text, group) return text
python
def get_text_from_node(self, node, regex=None, group=1): """Get text from node and filter if necessary.""" text = self._get_stripped_text_from_node(node) if regex is not None: text = self._filter_by_regex(regex, text, group) return text
[ "def", "get_text_from_node", "(", "self", ",", "node", ",", "regex", "=", "None", ",", "group", "=", "1", ")", ":", "text", "=", "self", ".", "_get_stripped_text_from_node", "(", "node", ")", "if", "regex", "is", "not", "None", ":", "text", "=", "self"...
Get text from node and filter if necessary.
[ "Get", "text", "from", "node", "and", "filter", "if", "necessary", "." ]
ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6
https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/parsedpage.py#L33-L40
244,142
nefarioustim/parker
parker/parsedpage.py
ParsedPage._get_stripped_text_from_node
def _get_stripped_text_from_node(self, node): """Return the stripped text content of a node.""" return ( node.text_content() .replace(u"\u00A0", " ") .replace("\t", "") .replace("\n", "") .strip() )
python
def _get_stripped_text_from_node(self, node): """Return the stripped text content of a node.""" return ( node.text_content() .replace(u"\u00A0", " ") .replace("\t", "") .replace("\n", "") .strip() )
[ "def", "_get_stripped_text_from_node", "(", "self", ",", "node", ")", ":", "return", "(", "node", ".", "text_content", "(", ")", ".", "replace", "(", "u\"\\u00A0\"", ",", "\" \"", ")", ".", "replace", "(", "\"\\t\"", ",", "\"\"", ")", ".", "replace", "("...
Return the stripped text content of a node.
[ "Return", "the", "stripped", "text", "content", "of", "a", "node", "." ]
ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6
https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/parsedpage.py#L55-L63
244,143
etcher-be/emiz
emiz/avwx/speech.py
wind
def wind(direction: Number, speed: Number, gust: Number, vardir: typing.List[Number] = None, unit: str = 'kt') -> str: """ Format wind details into a spoken word string """ unit = SPOKEN_UNITS.get(unit, unit) val = translate.wind(direction, speed, gust, vardir, un...
python
def wind(direction: Number, speed: Number, gust: Number, vardir: typing.List[Number] = None, unit: str = 'kt') -> str: """ Format wind details into a spoken word string """ unit = SPOKEN_UNITS.get(unit, unit) val = translate.wind(direction, speed, gust, vardir, un...
[ "def", "wind", "(", "direction", ":", "Number", ",", "speed", ":", "Number", ",", "gust", ":", "Number", ",", "vardir", ":", "typing", ".", "List", "[", "Number", "]", "=", "None", ",", "unit", ":", "str", "=", "'kt'", ")", "->", "str", ":", "uni...
Format wind details into a spoken word string
[ "Format", "wind", "details", "into", "a", "spoken", "word", "string" ]
1c3e32711921d7e600e85558ffe5d337956372de
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L20-L31
244,144
etcher-be/emiz
emiz/avwx/speech.py
temperature
def temperature(header: str, temp: Number, unit: str = 'C') -> str: """ Format temperature details into a spoken word string """ if not (temp and temp.value): return header + ' unknown' if unit in SPOKEN_UNITS: unit = SPOKEN_UNITS[unit] use_s = '' if temp.spoken in ('one', 'minus...
python
def temperature(header: str, temp: Number, unit: str = 'C') -> str: """ Format temperature details into a spoken word string """ if not (temp and temp.value): return header + ' unknown' if unit in SPOKEN_UNITS: unit = SPOKEN_UNITS[unit] use_s = '' if temp.spoken in ('one', 'minus...
[ "def", "temperature", "(", "header", ":", "str", ",", "temp", ":", "Number", ",", "unit", ":", "str", "=", "'C'", ")", "->", "str", ":", "if", "not", "(", "temp", "and", "temp", ".", "value", ")", ":", "return", "header", "+", "' unknown'", "if", ...
Format temperature details into a spoken word string
[ "Format", "temperature", "details", "into", "a", "spoken", "word", "string" ]
1c3e32711921d7e600e85558ffe5d337956372de
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L34-L43
244,145
etcher-be/emiz
emiz/avwx/speech.py
visibility
def visibility(vis: Number, unit: str = 'm') -> str: """ Format visibility details into a spoken word string """ if not vis: return 'Visibility unknown' if vis.value is None or '/' in vis.repr: ret_vis = vis.spoken else: ret_vis = translate.visibility(vis, unit=unit) ...
python
def visibility(vis: Number, unit: str = 'm') -> str: """ Format visibility details into a spoken word string """ if not vis: return 'Visibility unknown' if vis.value is None or '/' in vis.repr: ret_vis = vis.spoken else: ret_vis = translate.visibility(vis, unit=unit) ...
[ "def", "visibility", "(", "vis", ":", "Number", ",", "unit", ":", "str", "=", "'m'", ")", "->", "str", ":", "if", "not", "vis", ":", "return", "'Visibility unknown'", "if", "vis", ".", "value", "is", "None", "or", "'/'", "in", "vis", ".", "repr", "...
Format visibility details into a spoken word string
[ "Format", "visibility", "details", "into", "a", "spoken", "word", "string" ]
1c3e32711921d7e600e85558ffe5d337956372de
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L46-L69
244,146
etcher-be/emiz
emiz/avwx/speech.py
altimeter
def altimeter(alt: Number, unit: str = 'inHg') -> str: """ Format altimeter details into a spoken word string """ ret = 'Altimeter ' if not alt: ret += 'unknown' elif unit == 'inHg': ret += core.spoken_number(alt.repr[:2]) + ' point ' + core.spoken_number(alt.repr[2:]) elif u...
python
def altimeter(alt: Number, unit: str = 'inHg') -> str: """ Format altimeter details into a spoken word string """ ret = 'Altimeter ' if not alt: ret += 'unknown' elif unit == 'inHg': ret += core.spoken_number(alt.repr[:2]) + ' point ' + core.spoken_number(alt.repr[2:]) elif u...
[ "def", "altimeter", "(", "alt", ":", "Number", ",", "unit", ":", "str", "=", "'inHg'", ")", "->", "str", ":", "ret", "=", "'Altimeter '", "if", "not", "alt", ":", "ret", "+=", "'unknown'", "elif", "unit", "==", "'inHg'", ":", "ret", "+=", "core", "...
Format altimeter details into a spoken word string
[ "Format", "altimeter", "details", "into", "a", "spoken", "word", "string" ]
1c3e32711921d7e600e85558ffe5d337956372de
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L72-L83
244,147
etcher-be/emiz
emiz/avwx/speech.py
other
def other(wxcodes: typing.List[str]) -> str: """ Format wx codes into a spoken word string """ ret = [] for code in wxcodes: item = translate.wxcode(code) if item.startswith('Vicinity'): item = item.lstrip('Vicinity ') + ' in the Vicinity' ret.append(item) ret...
python
def other(wxcodes: typing.List[str]) -> str: """ Format wx codes into a spoken word string """ ret = [] for code in wxcodes: item = translate.wxcode(code) if item.startswith('Vicinity'): item = item.lstrip('Vicinity ') + ' in the Vicinity' ret.append(item) ret...
[ "def", "other", "(", "wxcodes", ":", "typing", ".", "List", "[", "str", "]", ")", "->", "str", ":", "ret", "=", "[", "]", "for", "code", "in", "wxcodes", ":", "item", "=", "translate", ".", "wxcode", "(", "code", ")", "if", "item", ".", "startswi...
Format wx codes into a spoken word string
[ "Format", "wx", "codes", "into", "a", "spoken", "word", "string" ]
1c3e32711921d7e600e85558ffe5d337956372de
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L86-L96
244,148
etcher-be/emiz
emiz/avwx/speech.py
type_and_times
def type_and_times(type_: str, start: Timestamp, end: Timestamp, probability: Number = None) -> str: """ Format line type and times into the beginning of a spoken line string """ if not type_: return '' if type_ == 'BECMG': return f"At {start.dt.hour or 'midnight'} zulu becoming" ...
python
def type_and_times(type_: str, start: Timestamp, end: Timestamp, probability: Number = None) -> str: """ Format line type and times into the beginning of a spoken line string """ if not type_: return '' if type_ == 'BECMG': return f"At {start.dt.hour or 'midnight'} zulu becoming" ...
[ "def", "type_and_times", "(", "type_", ":", "str", ",", "start", ":", "Timestamp", ",", "end", ":", "Timestamp", ",", "probability", ":", "Number", "=", "None", ")", "->", "str", ":", "if", "not", "type_", ":", "return", "''", "if", "type_", "==", "'...
Format line type and times into the beginning of a spoken line string
[ "Format", "line", "type", "and", "times", "into", "the", "beginning", "of", "a", "spoken", "line", "string" ]
1c3e32711921d7e600e85558ffe5d337956372de
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L99-L114
244,149
etcher-be/emiz
emiz/avwx/speech.py
wind_shear
def wind_shear(shear: str, unit_alt: str = 'ft', unit_wind: str = 'kt') -> str: """ Format wind shear string into a spoken word string """ unit_alt = SPOKEN_UNITS.get(unit_alt, unit_alt) unit_wind = SPOKEN_UNITS.get(unit_wind, unit_wind) return translate.wind_shear(shear, unit_alt, unit_wind, sp...
python
def wind_shear(shear: str, unit_alt: str = 'ft', unit_wind: str = 'kt') -> str: """ Format wind shear string into a spoken word string """ unit_alt = SPOKEN_UNITS.get(unit_alt, unit_alt) unit_wind = SPOKEN_UNITS.get(unit_wind, unit_wind) return translate.wind_shear(shear, unit_alt, unit_wind, sp...
[ "def", "wind_shear", "(", "shear", ":", "str", ",", "unit_alt", ":", "str", "=", "'ft'", ",", "unit_wind", ":", "str", "=", "'kt'", ")", "->", "str", ":", "unit_alt", "=", "SPOKEN_UNITS", ".", "get", "(", "unit_alt", ",", "unit_alt", ")", "unit_wind", ...
Format wind shear string into a spoken word string
[ "Format", "wind", "shear", "string", "into", "a", "spoken", "word", "string" ]
1c3e32711921d7e600e85558ffe5d337956372de
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L117-L123
244,150
etcher-be/emiz
emiz/avwx/speech.py
metar
def metar(data: MetarData, units: Units) -> str: """ Convert MetarData into a string for text-to-speech """ speech = [] if data.wind_direction and data.wind_speed: speech.append(wind(data.wind_direction, data.wind_speed, data.wind_gust, data.wind_variable_direction...
python
def metar(data: MetarData, units: Units) -> str: """ Convert MetarData into a string for text-to-speech """ speech = [] if data.wind_direction and data.wind_speed: speech.append(wind(data.wind_direction, data.wind_speed, data.wind_gust, data.wind_variable_direction...
[ "def", "metar", "(", "data", ":", "MetarData", ",", "units", ":", "Units", ")", "->", "str", ":", "speech", "=", "[", "]", "if", "data", ".", "wind_direction", "and", "data", ".", "wind_speed", ":", "speech", ".", "append", "(", "wind", "(", "data", ...
Convert MetarData into a string for text-to-speech
[ "Convert", "MetarData", "into", "a", "string", "for", "text", "-", "to", "-", "speech" ]
1c3e32711921d7e600e85558ffe5d337956372de
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L126-L147
244,151
etcher-be/emiz
emiz/avwx/speech.py
taf_line
def taf_line(line: TafLineData, units: Units) -> str: """ Convert TafLineData into a string for text-to-speech """ speech = [] start = type_and_times(line.type, line.start_time, line.end_time, line.probability) if line.wind_direction and line.wind_speed: speech.append(wind(line.wind_dire...
python
def taf_line(line: TafLineData, units: Units) -> str: """ Convert TafLineData into a string for text-to-speech """ speech = [] start = type_and_times(line.type, line.start_time, line.end_time, line.probability) if line.wind_direction and line.wind_speed: speech.append(wind(line.wind_dire...
[ "def", "taf_line", "(", "line", ":", "TafLineData", ",", "units", ":", "Units", ")", "->", "str", ":", "speech", "=", "[", "]", "start", "=", "type_and_times", "(", "line", ".", "type", ",", "line", ".", "start_time", ",", "line", ".", "end_time", ",...
Convert TafLineData into a string for text-to-speech
[ "Convert", "TafLineData", "into", "a", "string", "for", "text", "-", "to", "-", "speech" ]
1c3e32711921d7e600e85558ffe5d337956372de
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L150-L173
244,152
etcher-be/emiz
emiz/avwx/speech.py
taf
def taf(data: TafData, units: Units) -> str: """ Convert TafData into a string for text-to-speech """ try: month = data.start_time.dt.strftime(r'%B') day = ordinal(data.start_time.dt.day) ret = f"Starting on {month} {day} - " except AttributeError: ret = '' return...
python
def taf(data: TafData, units: Units) -> str: """ Convert TafData into a string for text-to-speech """ try: month = data.start_time.dt.strftime(r'%B') day = ordinal(data.start_time.dt.day) ret = f"Starting on {month} {day} - " except AttributeError: ret = '' return...
[ "def", "taf", "(", "data", ":", "TafData", ",", "units", ":", "Units", ")", "->", "str", ":", "try", ":", "month", "=", "data", ".", "start_time", ".", "dt", ".", "strftime", "(", "r'%B'", ")", "day", "=", "ordinal", "(", "data", ".", "start_time",...
Convert TafData into a string for text-to-speech
[ "Convert", "TafData", "into", "a", "string", "for", "text", "-", "to", "-", "speech" ]
1c3e32711921d7e600e85558ffe5d337956372de
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L176-L186
244,153
fogcitymarathoner/s3_mysql_backup
s3_mysql_backup/scripts/get_bucket.py
get_bucket
def get_bucket(): """ Get listing of S3 Bucket """ args = parser.parse_args() bucket = s3_bucket(args.aws_access_key_id, args.aws_secret_access_key, args.bucket_name) for b in bucket.list(): print(''.join([i if ord(i) < 128 else ' ' for i in b.name]))
python
def get_bucket(): """ Get listing of S3 Bucket """ args = parser.parse_args() bucket = s3_bucket(args.aws_access_key_id, args.aws_secret_access_key, args.bucket_name) for b in bucket.list(): print(''.join([i if ord(i) < 128 else ' ' for i in b.name]))
[ "def", "get_bucket", "(", ")", ":", "args", "=", "parser", ".", "parse_args", "(", ")", "bucket", "=", "s3_bucket", "(", "args", ".", "aws_access_key_id", ",", "args", ".", "aws_secret_access_key", ",", "args", ".", "bucket_name", ")", "for", "b", "in", ...
Get listing of S3 Bucket
[ "Get", "listing", "of", "S3", "Bucket" ]
8a0fb3e51a7b873eb4287d4954548a0dbab0e734
https://github.com/fogcitymarathoner/s3_mysql_backup/blob/8a0fb3e51a7b873eb4287d4954548a0dbab0e734/s3_mysql_backup/scripts/get_bucket.py#L13-L21
244,154
collectiveacuity/labPack
labpack/mapping/data.py
walk_data
def walk_data(input_data): ''' a generator function for retrieving data in a nested dictionary :param input_data: dictionary or list with nested data :return: string with dot_path, object with value of endpoint ''' def _walk_dict(input_dict, path_to_root): if not path_to_root: ...
python
def walk_data(input_data): ''' a generator function for retrieving data in a nested dictionary :param input_data: dictionary or list with nested data :return: string with dot_path, object with value of endpoint ''' def _walk_dict(input_dict, path_to_root): if not path_to_root: ...
[ "def", "walk_data", "(", "input_data", ")", ":", "def", "_walk_dict", "(", "input_dict", ",", "path_to_root", ")", ":", "if", "not", "path_to_root", ":", "yield", "'.'", ",", "input_dict", "for", "key", ",", "value", "in", "input_dict", ".", "items", "(", ...
a generator function for retrieving data in a nested dictionary :param input_data: dictionary or list with nested data :return: string with dot_path, object with value of endpoint
[ "a", "generator", "function", "for", "retrieving", "data", "in", "a", "nested", "dictionary" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/mapping/data.py#L5-L46
244,155
collectiveacuity/labPack
labpack/mapping/data.py
transform_data
def transform_data(function, input_data): ''' a function to apply a function to each value in a nested dictionary :param function: callable function with a single input of any datatype :param input_data: dictionary or list with nested data to transform :return: dictionary or list with data transformed...
python
def transform_data(function, input_data): ''' a function to apply a function to each value in a nested dictionary :param function: callable function with a single input of any datatype :param input_data: dictionary or list with nested data to transform :return: dictionary or list with data transformed...
[ "def", "transform_data", "(", "function", ",", "input_data", ")", ":", "# construct copy", "try", ":", "from", "copy", "import", "deepcopy", "output_data", "=", "deepcopy", "(", "input_data", ")", "except", ":", "raise", "ValueError", "(", "'transform_data() input...
a function to apply a function to each value in a nested dictionary :param function: callable function with a single input of any datatype :param input_data: dictionary or list with nested data to transform :return: dictionary or list with data transformed by function
[ "a", "function", "to", "apply", "a", "function", "to", "each", "value", "in", "a", "nested", "dictionary" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/mapping/data.py#L69-L102
244,156
collectiveacuity/labPack
labpack/mapping/data.py
clean_data
def clean_data(input_value): ''' a function to transform a value into a json or yaml valid datatype :param input_value: object of any datatype :return: object with json valid datatype ''' # pass normal json/yaml datatypes if input_value.__class__.__name__ in ['bool', 'str', 'float', 'int', 'NoneT...
python
def clean_data(input_value): ''' a function to transform a value into a json or yaml valid datatype :param input_value: object of any datatype :return: object with json valid datatype ''' # pass normal json/yaml datatypes if input_value.__class__.__name__ in ['bool', 'str', 'float', 'int', 'NoneT...
[ "def", "clean_data", "(", "input_value", ")", ":", "# pass normal json/yaml datatypes", "if", "input_value", ".", "__class__", ".", "__name__", "in", "[", "'bool'", ",", "'str'", ",", "'float'", ",", "'int'", ",", "'NoneType'", "]", ":", "pass", "# transform byt...
a function to transform a value into a json or yaml valid datatype :param input_value: object of any datatype :return: object with json valid datatype
[ "a", "function", "to", "transform", "a", "value", "into", "a", "json", "or", "yaml", "valid", "datatype" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/mapping/data.py#L104-L135
244,157
collectiveacuity/labPack
labpack/mapping/data.py
reconstruct_dict
def reconstruct_dict(dot_paths, values): ''' a method for reconstructing a dictionary from the values along dot paths ''' output_dict = {} for i in range(len(dot_paths)): if i + 1 <= len(values): path_segments = segment_path(dot_paths[i]) current_nest = output_...
python
def reconstruct_dict(dot_paths, values): ''' a method for reconstructing a dictionary from the values along dot paths ''' output_dict = {} for i in range(len(dot_paths)): if i + 1 <= len(values): path_segments = segment_path(dot_paths[i]) current_nest = output_...
[ "def", "reconstruct_dict", "(", "dot_paths", ",", "values", ")", ":", "output_dict", "=", "{", "}", "for", "i", "in", "range", "(", "len", "(", "dot_paths", ")", ")", ":", "if", "i", "+", "1", "<=", "len", "(", "values", ")", ":", "path_segments", ...
a method for reconstructing a dictionary from the values along dot paths
[ "a", "method", "for", "reconstructing", "a", "dictionary", "from", "the", "values", "along", "dot", "paths" ]
52949ece35e72e3cc308f54d9ffa6bfbd96805b8
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/mapping/data.py#L137-L177
244,158
mbodenhamer/syn
syn/base_utils/order.py
topological_sorting
def topological_sorting(nodes, relations): '''An implementation of Kahn's algorithm. ''' ret = [] nodes = set(nodes) | _nodes(relations) inc = _incoming(relations) out = _outgoing(relations) free = _free_nodes(nodes, inc) while free: n = free.pop() ret.append(n) ...
python
def topological_sorting(nodes, relations): '''An implementation of Kahn's algorithm. ''' ret = [] nodes = set(nodes) | _nodes(relations) inc = _incoming(relations) out = _outgoing(relations) free = _free_nodes(nodes, inc) while free: n = free.pop() ret.append(n) ...
[ "def", "topological_sorting", "(", "nodes", ",", "relations", ")", ":", "ret", "=", "[", "]", "nodes", "=", "set", "(", "nodes", ")", "|", "_nodes", "(", "relations", ")", "inc", "=", "_incoming", "(", "relations", ")", "out", "=", "_outgoing", "(", ...
An implementation of Kahn's algorithm.
[ "An", "implementation", "of", "Kahn", "s", "algorithm", "." ]
aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258
https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/order.py#L47-L69
244,159
ronaldguillen/wave
wave/exceptions.py
_force_text_recursive
def _force_text_recursive(data): """ Descend into a nested data structure, forcing any lazy translation strings into plain text. """ if isinstance(data, list): ret = [ _force_text_recursive(item) for item in data ] if isinstance(data, ReturnList): retu...
python
def _force_text_recursive(data): """ Descend into a nested data structure, forcing any lazy translation strings into plain text. """ if isinstance(data, list): ret = [ _force_text_recursive(item) for item in data ] if isinstance(data, ReturnList): retu...
[ "def", "_force_text_recursive", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "list", ")", ":", "ret", "=", "[", "_force_text_recursive", "(", "item", ")", "for", "item", "in", "data", "]", "if", "isinstance", "(", "data", ",", "ReturnList...
Descend into a nested data structure, forcing any lazy translation strings into plain text.
[ "Descend", "into", "a", "nested", "data", "structure", "forcing", "any", "lazy", "translation", "strings", "into", "plain", "text", "." ]
20bb979c917f7634d8257992e6d449dc751256a9
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/exceptions.py#L20-L40
244,160
OlivierB/Bashutils
bashutils/colors.py
color_text
def color_text(text, color="none", bcolor="none", effect="none"): """ Return a formated text with bash color """ istty = False try: istty = sys.stdout.isatty() except: pass if not istty or not COLOR_ON: return text else: if not effect in COLOR_EFFET.keys()...
python
def color_text(text, color="none", bcolor="none", effect="none"): """ Return a formated text with bash color """ istty = False try: istty = sys.stdout.isatty() except: pass if not istty or not COLOR_ON: return text else: if not effect in COLOR_EFFET.keys()...
[ "def", "color_text", "(", "text", ",", "color", "=", "\"none\"", ",", "bcolor", "=", "\"none\"", ",", "effect", "=", "\"none\"", ")", ":", "istty", "=", "False", "try", ":", "istty", "=", "sys", ".", "stdout", ".", "isatty", "(", ")", "except", ":", ...
Return a formated text with bash color
[ "Return", "a", "formated", "text", "with", "bash", "color" ]
487762049f5d09f14f8a6c764bc0a823f332d8a1
https://github.com/OlivierB/Bashutils/blob/487762049f5d09f14f8a6c764bc0a823f332d8a1/bashutils/colors.py#L68-L94
244,161
radjkarl/fancyTools
fancytools/os/countLines.py
countLines
def countLines(filename, buf_size=1048576): """ fast counting to the lines of a given filename through only reading out a limited buffer """ f = open(filename) try: lines = 1 read_f = f.read # loop optimization buf = read_f(buf_size) # Empty file if not b...
python
def countLines(filename, buf_size=1048576): """ fast counting to the lines of a given filename through only reading out a limited buffer """ f = open(filename) try: lines = 1 read_f = f.read # loop optimization buf = read_f(buf_size) # Empty file if not b...
[ "def", "countLines", "(", "filename", ",", "buf_size", "=", "1048576", ")", ":", "f", "=", "open", "(", "filename", ")", "try", ":", "lines", "=", "1", "read_f", "=", "f", ".", "read", "# loop optimization", "buf", "=", "read_f", "(", "buf_size", ")", ...
fast counting to the lines of a given filename through only reading out a limited buffer
[ "fast", "counting", "to", "the", "lines", "of", "a", "given", "filename", "through", "only", "reading", "out", "a", "limited", "buffer" ]
4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/os/countLines.py#L5-L23
244,162
pybel/pybel-artifactory
src/pybel_artifactory/hashing.py
_names_to_bytes
def _names_to_bytes(names): """Reproducibly converts an iterable of strings to bytes :param iter[str] names: An iterable of strings :rtype: bytes """ names = sorted(names) names_bytes = json.dumps(names).encode('utf8') return names_bytes
python
def _names_to_bytes(names): """Reproducibly converts an iterable of strings to bytes :param iter[str] names: An iterable of strings :rtype: bytes """ names = sorted(names) names_bytes = json.dumps(names).encode('utf8') return names_bytes
[ "def", "_names_to_bytes", "(", "names", ")", ":", "names", "=", "sorted", "(", "names", ")", "names_bytes", "=", "json", ".", "dumps", "(", "names", ")", ".", "encode", "(", "'utf8'", ")", "return", "names_bytes" ]
Reproducibly converts an iterable of strings to bytes :param iter[str] names: An iterable of strings :rtype: bytes
[ "Reproducibly", "converts", "an", "iterable", "of", "strings", "to", "bytes" ]
720107780a59be2ef08885290dfa519b1da62871
https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/hashing.py#L19-L27
244,163
pybel/pybel-artifactory
src/pybel_artifactory/hashing.py
hash_names
def hash_names(names, hash_function=None): """Return the hash of an iterable of strings, or a dict if multiple hash functions given. :param iter[str] names: An iterable of strings :param hash_function: A hash function or list of hash functions, like :func:`hashlib.md5` or :func:`hashlib.sha512` :rtype:...
python
def hash_names(names, hash_function=None): """Return the hash of an iterable of strings, or a dict if multiple hash functions given. :param iter[str] names: An iterable of strings :param hash_function: A hash function or list of hash functions, like :func:`hashlib.md5` or :func:`hashlib.sha512` :rtype:...
[ "def", "hash_names", "(", "names", ",", "hash_function", "=", "None", ")", ":", "hash_function", "=", "hash_function", "or", "hashlib", ".", "md5", "names_bytes", "=", "_names_to_bytes", "(", "names", ")", "return", "hash_function", "(", "names_bytes", ")", "....
Return the hash of an iterable of strings, or a dict if multiple hash functions given. :param iter[str] names: An iterable of strings :param hash_function: A hash function or list of hash functions, like :func:`hashlib.md5` or :func:`hashlib.sha512` :rtype: str
[ "Return", "the", "hash", "of", "an", "iterable", "of", "strings", "or", "a", "dict", "if", "multiple", "hash", "functions", "given", "." ]
720107780a59be2ef08885290dfa519b1da62871
https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/hashing.py#L30-L39
244,164
pybel/pybel-artifactory
src/pybel_artifactory/hashing.py
get_bel_resource_hash
def get_bel_resource_hash(location, hash_function=None): """Get a BEL resource file and returns its semantic hash. :param str location: URL of a resource :param hash_function: A hash function or list of hash functions, like :func:`hashlib.md5` or :code:`hashlib.sha512` :return: The hexadecimal digest o...
python
def get_bel_resource_hash(location, hash_function=None): """Get a BEL resource file and returns its semantic hash. :param str location: URL of a resource :param hash_function: A hash function or list of hash functions, like :func:`hashlib.md5` or :code:`hashlib.sha512` :return: The hexadecimal digest o...
[ "def", "get_bel_resource_hash", "(", "location", ",", "hash_function", "=", "None", ")", ":", "resource", "=", "get_bel_resource", "(", "location", ")", "return", "hash_names", "(", "resource", "[", "'Values'", "]", ",", "hash_function", "=", "hash_function", ")...
Get a BEL resource file and returns its semantic hash. :param str location: URL of a resource :param hash_function: A hash function or list of hash functions, like :func:`hashlib.md5` or :code:`hashlib.sha512` :return: The hexadecimal digest of the hash of the values in the resource :rtype: str :ra...
[ "Get", "a", "BEL", "resource", "file", "and", "returns", "its", "semantic", "hash", "." ]
720107780a59be2ef08885290dfa519b1da62871
https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/hashing.py#L42-L56
244,165
dankelley/nota
nota/notaclass.py
Nota.book_name
def book_name(self, number): '''Return name of book with given index.''' try: name = self.cur.execute("SELECT name FROM book WHERE number = ?;", [number]).fetchone() except: self.error("cannot look up name of book number %s" % number) return(str(name[0]))
python
def book_name(self, number): '''Return name of book with given index.''' try: name = self.cur.execute("SELECT name FROM book WHERE number = ?;", [number]).fetchone() except: self.error("cannot look up name of book number %s" % number) return(str(name[0]))
[ "def", "book_name", "(", "self", ",", "number", ")", ":", "try", ":", "name", "=", "self", ".", "cur", ".", "execute", "(", "\"SELECT name FROM book WHERE number = ?;\"", ",", "[", "number", "]", ")", ".", "fetchone", "(", ")", "except", ":", "self", "."...
Return name of book with given index.
[ "Return", "name", "of", "book", "with", "given", "index", "." ]
245cd575db60daaea6eebd5edc1d048c5fe23c9b
https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L271-L277
244,166
dankelley/nota
nota/notaclass.py
Nota.book_number
def book_number(self, name): '''Return number of book with given name.''' try: number = self.cur.execute("SELECT number FROM book WHERE name= ?;", [name]).fetchone() except: self.error("cannot look up number of book with name %s" % name) return(number)
python
def book_number(self, name): '''Return number of book with given name.''' try: number = self.cur.execute("SELECT number FROM book WHERE name= ?;", [name]).fetchone() except: self.error("cannot look up number of book with name %s" % name) return(number)
[ "def", "book_number", "(", "self", ",", "name", ")", ":", "try", ":", "number", "=", "self", ".", "cur", ".", "execute", "(", "\"SELECT number FROM book WHERE name= ?;\"", ",", "[", "name", "]", ")", ".", "fetchone", "(", ")", "except", ":", "self", ".",...
Return number of book with given name.
[ "Return", "number", "of", "book", "with", "given", "name", "." ]
245cd575db60daaea6eebd5edc1d048c5fe23c9b
https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L280-L286
244,167
dankelley/nota
nota/notaclass.py
Nota.list_books
def list_books(self): ''' Return the list of book names ''' names = [] try: for n in self.cur.execute("SELECT name FROM book;").fetchall(): names.extend(n) except: self.error("ERROR: cannot find database table 'book'") return(names)
python
def list_books(self): ''' Return the list of book names ''' names = [] try: for n in self.cur.execute("SELECT name FROM book;").fetchall(): names.extend(n) except: self.error("ERROR: cannot find database table 'book'") return(names)
[ "def", "list_books", "(", "self", ")", ":", "names", "=", "[", "]", "try", ":", "for", "n", "in", "self", ".", "cur", ".", "execute", "(", "\"SELECT name FROM book;\"", ")", ".", "fetchall", "(", ")", ":", "names", ".", "extend", "(", "n", ")", "ex...
Return the list of book names
[ "Return", "the", "list", "of", "book", "names" ]
245cd575db60daaea6eebd5edc1d048c5fe23c9b
https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L289-L297
244,168
dankelley/nota
nota/notaclass.py
Nota.create_book
def create_book(self, name): """Create a new book""" name = name.strip() if not len(name): self.error("Cannot have a blank book name") # The next could be relaxed, if users want commas in book names, but # I prefer to keep it, in case later there could be a syntax for...
python
def create_book(self, name): """Create a new book""" name = name.strip() if not len(name): self.error("Cannot have a blank book name") # The next could be relaxed, if users want commas in book names, but # I prefer to keep it, in case later there could be a syntax for...
[ "def", "create_book", "(", "self", ",", "name", ")", ":", "name", "=", "name", ".", "strip", "(", ")", "if", "not", "len", "(", "name", ")", ":", "self", ".", "error", "(", "\"Cannot have a blank book name\"", ")", "# The next could be relaxed, if users want c...
Create a new book
[ "Create", "a", "new", "book" ]
245cd575db60daaea6eebd5edc1d048c5fe23c9b
https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L300-L318
244,169
dankelley/nota
nota/notaclass.py
Nota.initialize
def initialize(self, author=""): ''' Initialize the database. This is dangerous since it removes any existing content.''' self.cur.execute("CREATE TABLE version(major, minor);") self.cur.execute("INSERT INTO version(major, minor) VALUES (?,?);", (self.appversion[0], self...
python
def initialize(self, author=""): ''' Initialize the database. This is dangerous since it removes any existing content.''' self.cur.execute("CREATE TABLE version(major, minor);") self.cur.execute("INSERT INTO version(major, minor) VALUES (?,?);", (self.appversion[0], self...
[ "def", "initialize", "(", "self", ",", "author", "=", "\"\"", ")", ":", "self", ".", "cur", ".", "execute", "(", "\"CREATE TABLE version(major, minor);\"", ")", "self", ".", "cur", ".", "execute", "(", "\"INSERT INTO version(major, minor) VALUES (?,?);\"", ",", "(...
Initialize the database. This is dangerous since it removes any existing content.
[ "Initialize", "the", "database", ".", "This", "is", "dangerous", "since", "it", "removes", "any", "existing", "content", "." ]
245cd575db60daaea6eebd5edc1d048c5fe23c9b
https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L369-L384
244,170
dankelley/nota
nota/notaclass.py
Nota.keyword_hookup
def keyword_hookup(self, noteId, keywords): ''' Unhook existing cross-linking entries. ''' try: self.cur.execute("DELETE FROM notekeyword WHERE noteid=?", [noteId]) except: self.error("ERROR: cannot unhook previous keywords") # Now, hook up new the...
python
def keyword_hookup(self, noteId, keywords): ''' Unhook existing cross-linking entries. ''' try: self.cur.execute("DELETE FROM notekeyword WHERE noteid=?", [noteId]) except: self.error("ERROR: cannot unhook previous keywords") # Now, hook up new the...
[ "def", "keyword_hookup", "(", "self", ",", "noteId", ",", "keywords", ")", ":", "try", ":", "self", ".", "cur", ".", "execute", "(", "\"DELETE FROM notekeyword WHERE noteid=?\"", ",", "[", "noteId", "]", ")", "except", ":", "self", ".", "error", "(", "\"ER...
Unhook existing cross-linking entries.
[ "Unhook", "existing", "cross", "-", "linking", "entries", "." ]
245cd575db60daaea6eebd5edc1d048c5fe23c9b
https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L505-L531
244,171
dankelley/nota
nota/notaclass.py
Nota.list_keywords
def list_keywords(self): ''' Return the list of keywords ''' names = [] try: for n in self.cur.execute("SELECT keyword FROM keyword;").fetchall(): # Strip out leading and trailing whitespaces (can be artifacts of old data) k = n[0].strip() ...
python
def list_keywords(self): ''' Return the list of keywords ''' names = [] try: for n in self.cur.execute("SELECT keyword FROM keyword;").fetchall(): # Strip out leading and trailing whitespaces (can be artifacts of old data) k = n[0].strip() ...
[ "def", "list_keywords", "(", "self", ")", ":", "names", "=", "[", "]", "try", ":", "for", "n", "in", "self", ".", "cur", ".", "execute", "(", "\"SELECT keyword FROM keyword;\"", ")", ".", "fetchall", "(", ")", ":", "# Strip out leading and trailing whitespaces...
Return the list of keywords
[ "Return", "the", "list", "of", "keywords" ]
245cd575db60daaea6eebd5edc1d048c5fe23c9b
https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L534-L547
244,172
dankelley/nota
nota/notaclass.py
Nota.find_recent
def find_recent(self, nrecent=4): '''Find recent non-trashed notes''' try: rows = self.cur.execute("SELECT noteId FROM note WHERE book > 0 ORDER BY date DESC LIMIT %d;"%nrecent).fetchall() except: self.error("nota.find_recent() cannot look up note list") # Possibl...
python
def find_recent(self, nrecent=4): '''Find recent non-trashed notes''' try: rows = self.cur.execute("SELECT noteId FROM note WHERE book > 0 ORDER BY date DESC LIMIT %d;"%nrecent).fetchall() except: self.error("nota.find_recent() cannot look up note list") # Possibl...
[ "def", "find_recent", "(", "self", ",", "nrecent", "=", "4", ")", ":", "try", ":", "rows", "=", "self", ".", "cur", ".", "execute", "(", "\"SELECT noteId FROM note WHERE book > 0 ORDER BY date DESC LIMIT %d;\"", "%", "nrecent", ")", ".", "fetchall", "(", ")", ...
Find recent non-trashed notes
[ "Find", "recent", "non", "-", "trashed", "notes" ]
245cd575db60daaea6eebd5edc1d048c5fe23c9b
https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L918-L945
244,173
dasevilla/rovi-python
roviclient/video.py
VideoApi._cosmoid_request
def _cosmoid_request(self, resource, cosmoid, **kwargs): """ Maps to the Generic API method for requests who's only parameter is ``cosmoid`` """ params = { 'cosmoid': cosmoid, } params.update(kwargs) return self.make_request(resource, params)
python
def _cosmoid_request(self, resource, cosmoid, **kwargs): """ Maps to the Generic API method for requests who's only parameter is ``cosmoid`` """ params = { 'cosmoid': cosmoid, } params.update(kwargs) return self.make_request(resource, params)
[ "def", "_cosmoid_request", "(", "self", ",", "resource", ",", "cosmoid", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'cosmoid'", ":", "cosmoid", ",", "}", "params", ".", "update", "(", "kwargs", ")", "return", "self", ".", "make_request", "...
Maps to the Generic API method for requests who's only parameter is ``cosmoid``
[ "Maps", "to", "the", "Generic", "API", "method", "for", "requests", "who", "s", "only", "parameter", "is", "cosmoid" ]
46039d6ebfcf2ff20b4edb4636cb972682cf6af4
https://github.com/dasevilla/rovi-python/blob/46039d6ebfcf2ff20b4edb4636cb972682cf6af4/roviclient/video.py#L15-L25
244,174
dasevilla/rovi-python
roviclient/video.py
VideoApi.season_info
def season_info(self, cosmoid, season, **kwargs): """ Returns information about a season of a TV series Maps to the `season info <http://prod-doc.rovicorp.com/mashery/index.php/V1.MetaData.VideoService.Video:Season>`_ API method. """ resource = 'season/%d/info' % season ...
python
def season_info(self, cosmoid, season, **kwargs): """ Returns information about a season of a TV series Maps to the `season info <http://prod-doc.rovicorp.com/mashery/index.php/V1.MetaData.VideoService.Video:Season>`_ API method. """ resource = 'season/%d/info' % season ...
[ "def", "season_info", "(", "self", ",", "cosmoid", ",", "season", ",", "*", "*", "kwargs", ")", ":", "resource", "=", "'season/%d/info'", "%", "season", "return", "self", ".", "_cosmoid_request", "(", "resource", ",", "cosmoid", ",", "*", "*", "kwargs", ...
Returns information about a season of a TV series Maps to the `season info <http://prod-doc.rovicorp.com/mashery/index.php/V1.MetaData.VideoService.Video:Season>`_ API method.
[ "Returns", "information", "about", "a", "season", "of", "a", "TV", "series" ]
46039d6ebfcf2ff20b4edb4636cb972682cf6af4
https://github.com/dasevilla/rovi-python/blob/46039d6ebfcf2ff20b4edb4636cb972682cf6af4/roviclient/video.py#L36-L51
244,175
dasevilla/rovi-python
roviclient/video.py
VideoApi.episode_info
def episode_info(self, cosmoid, season, episode, **kwargs): """ Returns information about an episode in a television series Maps to the `episode info <http://prod-doc.rovicorp.com/mashery/index.php/V1.MetaData.VideoService.Video:SeasonEpisode>`_ API method. """ resource = 'seas...
python
def episode_info(self, cosmoid, season, episode, **kwargs): """ Returns information about an episode in a television series Maps to the `episode info <http://prod-doc.rovicorp.com/mashery/index.php/V1.MetaData.VideoService.Video:SeasonEpisode>`_ API method. """ resource = 'seas...
[ "def", "episode_info", "(", "self", ",", "cosmoid", ",", "season", ",", "episode", ",", "*", "*", "kwargs", ")", ":", "resource", "=", "'season/%d/episode/%d/info'", "%", "(", "season", ",", "episode", ")", "return", "self", ".", "_cosmoid_request", "(", "...
Returns information about an episode in a television series Maps to the `episode info <http://prod-doc.rovicorp.com/mashery/index.php/V1.MetaData.VideoService.Video:SeasonEpisode>`_ API method.
[ "Returns", "information", "about", "an", "episode", "in", "a", "television", "series" ]
46039d6ebfcf2ff20b4edb4636cb972682cf6af4
https://github.com/dasevilla/rovi-python/blob/46039d6ebfcf2ff20b4edb4636cb972682cf6af4/roviclient/video.py#L53-L62
244,176
rikrd/inspire
inspirespeech/__init__.py
_load_zip_wav
def _load_zip_wav(zfile, offset=0, count=None): """Load a wav file into an array from frame start to fram end :param zfile: ZipExtFile file-like object from where to load the audio :param offset: First sample to load :param count: Maximum number of samples to load :return: The audio samples in a nu...
python
def _load_zip_wav(zfile, offset=0, count=None): """Load a wav file into an array from frame start to fram end :param zfile: ZipExtFile file-like object from where to load the audio :param offset: First sample to load :param count: Maximum number of samples to load :return: The audio samples in a nu...
[ "def", "_load_zip_wav", "(", "zfile", ",", "offset", "=", "0", ",", "count", "=", "None", ")", ":", "buf", "=", "StringIO", ".", "StringIO", "(", "zfile", ".", "read", "(", ")", ")", "sample_rate", ",", "audio", "=", "wavfile", ".", "read", "(", "b...
Load a wav file into an array from frame start to fram end :param zfile: ZipExtFile file-like object from where to load the audio :param offset: First sample to load :param count: Maximum number of samples to load :return: The audio samples in a numpy array of floats
[ "Load", "a", "wav", "file", "into", "an", "array", "from", "frame", "start", "to", "fram", "end" ]
e281c0266a9a9633f34ab70f9c3ad58036c19b59
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L39-L56
244,177
rikrd/inspire
inspirespeech/__init__.py
get_edit_scripts
def get_edit_scripts(pron_a, pron_b, edit_costs=(1.0, 1.0, 1.0)): """Get the edit scripts to transform between two given pronunciations. :param pron_a: Source pronunciation as list of strings, each string corresponding to a phoneme :param pron_b: Target pronunciation as list of strings, each string corresp...
python
def get_edit_scripts(pron_a, pron_b, edit_costs=(1.0, 1.0, 1.0)): """Get the edit scripts to transform between two given pronunciations. :param pron_a: Source pronunciation as list of strings, each string corresponding to a phoneme :param pron_b: Target pronunciation as list of strings, each string corresp...
[ "def", "get_edit_scripts", "(", "pron_a", ",", "pron_b", ",", "edit_costs", "=", "(", "1.0", ",", "1.0", ",", "1.0", ")", ")", ":", "op_costs", "=", "{", "'insert'", ":", "lambda", "x", ":", "edit_costs", "[", "0", "]", ",", "'match'", ":", "lambda",...
Get the edit scripts to transform between two given pronunciations. :param pron_a: Source pronunciation as list of strings, each string corresponding to a phoneme :param pron_b: Target pronunciation as list of strings, each string corresponding to a phoneme :param edit_costs: Costs of insert, replace and d...
[ "Get", "the", "edit", "scripts", "to", "transform", "between", "two", "given", "pronunciations", "." ]
e281c0266a9a9633f34ab70f9c3ad58036c19b59
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L712-L727
244,178
rikrd/inspire
inspirespeech/__init__.py
Submission._what_default
def _what_default(self, pronunciation): """Provide the default prediction of the what task. This function is used to predict the probability of a given pronunciation being reported for a given token. :param pronunciation: The list or array of confusion probabilities at each index """ ...
python
def _what_default(self, pronunciation): """Provide the default prediction of the what task. This function is used to predict the probability of a given pronunciation being reported for a given token. :param pronunciation: The list or array of confusion probabilities at each index """ ...
[ "def", "_what_default", "(", "self", ",", "pronunciation", ")", ":", "token_default", "=", "self", "[", "'metadata'", "]", "[", "'token_default'", "]", "[", "'what'", "]", "index_count", "=", "2", "*", "len", "(", "pronunciation", ")", "+", "1", "predictio...
Provide the default prediction of the what task. This function is used to predict the probability of a given pronunciation being reported for a given token. :param pronunciation: The list or array of confusion probabilities at each index
[ "Provide", "the", "default", "prediction", "of", "the", "what", "task", "." ]
e281c0266a9a9633f34ab70f9c3ad58036c19b59
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L259-L285
244,179
rikrd/inspire
inspirespeech/__init__.py
Submission.where_task
def where_task(self, token_id, presented_pronunciation, confusion_probability): """Provide the prediction of the where task. This function is used to predict the probability of a given pronunciation being reported for a given token. :param token_id: The token for which the prediction is being ...
python
def where_task(self, token_id, presented_pronunciation, confusion_probability): """Provide the prediction of the where task. This function is used to predict the probability of a given pronunciation being reported for a given token. :param token_id: The token for which the prediction is being ...
[ "def", "where_task", "(", "self", ",", "token_id", ",", "presented_pronunciation", ",", "confusion_probability", ")", ":", "self", "[", "'tokens'", "]", ".", "setdefault", "(", "token_id", ",", "{", "}", ")", ".", "setdefault", "(", "'where'", ",", "self", ...
Provide the prediction of the where task. This function is used to predict the probability of a given pronunciation being reported for a given token. :param token_id: The token for which the prediction is being provided :param confusion_probability: The list or array of confusion probabilities...
[ "Provide", "the", "prediction", "of", "the", "where", "task", "." ]
e281c0266a9a9633f34ab70f9c3ad58036c19b59
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L311-L323
244,180
rikrd/inspire
inspirespeech/__init__.py
Submission.what_task
def what_task(self, token_id, presented_pronunciation, index, phonemes, phonemes_probability, warn=True, default=True): """Provide the prediction of the what task. This function is used to predict the probability of a given phoneme being reported at a given index for a given t...
python
def what_task(self, token_id, presented_pronunciation, index, phonemes, phonemes_probability, warn=True, default=True): """Provide the prediction of the what task. This function is used to predict the probability of a given phoneme being reported at a given index for a given t...
[ "def", "what_task", "(", "self", ",", "token_id", ",", "presented_pronunciation", ",", "index", ",", "phonemes", ",", "phonemes_probability", ",", "warn", "=", "True", ",", "default", "=", "True", ")", ":", "if", "phonemes_probability", "is", "not", "None", ...
Provide the prediction of the what task. This function is used to predict the probability of a given phoneme being reported at a given index for a given token. :param token_id: The token for which the prediction is provided :param index: The index of the token for which the prediction ...
[ "Provide", "the", "prediction", "of", "the", "what", "task", "." ]
e281c0266a9a9633f34ab70f9c3ad58036c19b59
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L325-L371
244,181
rikrd/inspire
inspirespeech/__init__.py
Submission.full_task
def full_task(self, token_id, presented_pronunciation, pronunciation, pronunciation_probability, warn=True, default=True): """Provide the prediction of the full task. This function is used to predict the probability of a given pronunciation being reported for a given token. :...
python
def full_task(self, token_id, presented_pronunciation, pronunciation, pronunciation_probability, warn=True, default=True): """Provide the prediction of the full task. This function is used to predict the probability of a given pronunciation being reported for a given token. :...
[ "def", "full_task", "(", "self", ",", "token_id", ",", "presented_pronunciation", ",", "pronunciation", ",", "pronunciation_probability", ",", "warn", "=", "True", ",", "default", "=", "True", ")", ":", "if", "pronunciation_probability", "is", "not", "None", "an...
Provide the prediction of the full task. This function is used to predict the probability of a given pronunciation being reported for a given token. :param token_id: The token for which the prediction is provided :param pronunciation: The pronunciation for which the prediction is being made (a...
[ "Provide", "the", "prediction", "of", "the", "full", "task", "." ]
e281c0266a9a9633f34ab70f9c3ad58036c19b59
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L373-L417
244,182
rikrd/inspire
inspirespeech/__init__.py
Submission.load
def load(fileobj): """Load the submission from a file-like object :param fileobj: File-like object :return: the loaded submission """ with gzip.GzipFile(fileobj=fileobj, mode='r') as z: submission = Submission(metadata=json.loads(z.readline())) for line ...
python
def load(fileobj): """Load the submission from a file-like object :param fileobj: File-like object :return: the loaded submission """ with gzip.GzipFile(fileobj=fileobj, mode='r') as z: submission = Submission(metadata=json.loads(z.readline())) for line ...
[ "def", "load", "(", "fileobj", ")", ":", "with", "gzip", ".", "GzipFile", "(", "fileobj", "=", "fileobj", ",", "mode", "=", "'r'", ")", "as", "z", ":", "submission", "=", "Submission", "(", "metadata", "=", "json", ".", "loads", "(", "z", ".", "rea...
Load the submission from a file-like object :param fileobj: File-like object :return: the loaded submission
[ "Load", "the", "submission", "from", "a", "file", "-", "like", "object" ]
e281c0266a9a9633f34ab70f9c3ad58036c19b59
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L481-L494
244,183
rikrd/inspire
inspirespeech/__init__.py
Submission.load_metadata
def load_metadata(fileobj): """Load the submission from a file. :param filename: where to load the submission from """ with gzip.GzipFile(fileobj=fileobj, mode='r') as z: return json.loads(z.readline())
python
def load_metadata(fileobj): """Load the submission from a file. :param filename: where to load the submission from """ with gzip.GzipFile(fileobj=fileobj, mode='r') as z: return json.loads(z.readline())
[ "def", "load_metadata", "(", "fileobj", ")", ":", "with", "gzip", ".", "GzipFile", "(", "fileobj", "=", "fileobj", ",", "mode", "=", "'r'", ")", "as", "z", ":", "return", "json", ".", "loads", "(", "z", ".", "readline", "(", ")", ")" ]
Load the submission from a file. :param filename: where to load the submission from
[ "Load", "the", "submission", "from", "a", "file", "." ]
e281c0266a9a9633f34ab70f9c3ad58036c19b59
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L502-L508
244,184
rikrd/inspire
inspirespeech/__init__.py
Submission.submit
def submit(self, password=''): """Submits the participation to the web site. The passwords is sent as plain text. :return: the evaluation results. """ url = '{}/api/submit'.format(BASE_URL) try: r = requests.post(url, data=self...
python
def submit(self, password=''): """Submits the participation to the web site. The passwords is sent as plain text. :return: the evaluation results. """ url = '{}/api/submit'.format(BASE_URL) try: r = requests.post(url, data=self...
[ "def", "submit", "(", "self", ",", "password", "=", "''", ")", ":", "url", "=", "'{}/api/submit'", ".", "format", "(", "BASE_URL", ")", "try", ":", "r", "=", "requests", ".", "post", "(", "url", ",", "data", "=", "self", ".", "dumps", "(", ")", "...
Submits the participation to the web site. The passwords is sent as plain text. :return: the evaluation results.
[ "Submits", "the", "participation", "to", "the", "web", "site", "." ]
e281c0266a9a9633f34ab70f9c3ad58036c19b59
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L525-L550
244,185
rikrd/inspire
inspirespeech/__init__.py
Submission.evaluate
def evaluate(self, password=''): """Evaluates the development set. The passwords is sent as plain text. :return: the evaluation results. """ # Make a copy only keeping the development set dev_submission = self if self['metadata'].get('evaluation_setting', {}).g...
python
def evaluate(self, password=''): """Evaluates the development set. The passwords is sent as plain text. :return: the evaluation results. """ # Make a copy only keeping the development set dev_submission = self if self['metadata'].get('evaluation_setting', {}).g...
[ "def", "evaluate", "(", "self", ",", "password", "=", "''", ")", ":", "# Make a copy only keeping the development set", "dev_submission", "=", "self", "if", "self", "[", "'metadata'", "]", ".", "get", "(", "'evaluation_setting'", ",", "{", "}", ")", ".", "get"...
Evaluates the development set. The passwords is sent as plain text. :return: the evaluation results.
[ "Evaluates", "the", "development", "set", "." ]
e281c0266a9a9633f34ab70f9c3ad58036c19b59
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L552-L584
244,186
stephanepechard/projy
projy/collectors/AuthorMailCollector.py
AuthorMailCollector.author_mail_from_git
def author_mail_from_git(self): """ Get the author mail from git information. """ try: # launch git command and get answer cmd = Popen(["git", "config", "--get", "user.email"], stdout=PIPE) stdoutdata = cmd.communicate() if (stdoutdata[0]): ...
python
def author_mail_from_git(self): """ Get the author mail from git information. """ try: # launch git command and get answer cmd = Popen(["git", "config", "--get", "user.email"], stdout=PIPE) stdoutdata = cmd.communicate() if (stdoutdata[0]): ...
[ "def", "author_mail_from_git", "(", "self", ")", ":", "try", ":", "# launch git command and get answer", "cmd", "=", "Popen", "(", "[", "\"git\"", ",", "\"config\"", ",", "\"--get\"", ",", "\"user.email\"", "]", ",", "stdout", "=", "PIPE", ")", "stdoutdata", "...
Get the author mail from git information.
[ "Get", "the", "author", "mail", "from", "git", "information", "." ]
3146b0e3c207b977e1b51fcb33138746dae83c23
https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/collectors/AuthorMailCollector.py#L24-L39
244,187
stephanepechard/projy
projy/collectors/AuthorMailCollector.py
AuthorMailCollector.author_mail_from_system
def author_mail_from_system(self): """ Get the author mail from system information. It is probably often innacurate. """ self.author_mail = getpass.getuser() + '@' + socket.gethostname() return self.author_mail
python
def author_mail_from_system(self): """ Get the author mail from system information. It is probably often innacurate. """ self.author_mail = getpass.getuser() + '@' + socket.gethostname() return self.author_mail
[ "def", "author_mail_from_system", "(", "self", ")", ":", "self", ".", "author_mail", "=", "getpass", ".", "getuser", "(", ")", "+", "'@'", "+", "socket", ".", "gethostname", "(", ")", "return", "self", ".", "author_mail" ]
Get the author mail from system information. It is probably often innacurate.
[ "Get", "the", "author", "mail", "from", "system", "information", ".", "It", "is", "probably", "often", "innacurate", "." ]
3146b0e3c207b977e1b51fcb33138746dae83c23
https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/collectors/AuthorMailCollector.py#L42-L47
244,188
emory-libraries/eulcommon
eulcommon/djangoextras/http/decorators.py
content_negotiation
def content_negotiation(formats, default_type='text/html'): """ Provides basic content negotiation and returns a view method based on the best match of content types as indicated in formats. :param formats: dictionary of content types and corresponding methods :param default_type: string the decora...
python
def content_negotiation(formats, default_type='text/html'): """ Provides basic content negotiation and returns a view method based on the best match of content types as indicated in formats. :param formats: dictionary of content types and corresponding methods :param default_type: string the decora...
[ "def", "content_negotiation", "(", "formats", ",", "default_type", "=", "'text/html'", ")", ":", "def", "_decorator", "(", "view_method", ")", ":", "@", "wraps", "(", "view_method", ")", "def", "_wrapped", "(", "request", ",", "*", "args", ",", "*", "*", ...
Provides basic content negotiation and returns a view method based on the best match of content types as indicated in formats. :param formats: dictionary of content types and corresponding methods :param default_type: string the decorated method is the return type for. Example usage:: def rdf...
[ "Provides", "basic", "content", "negotiation", "and", "returns", "a", "view", "method", "based", "on", "the", "best", "match", "of", "content", "types", "as", "indicated", "in", "formats", "." ]
dc63a9b3b5e38205178235e0d716d1b28158d3a9
https://github.com/emory-libraries/eulcommon/blob/dc63a9b3b5e38205178235e0d716d1b28158d3a9/eulcommon/djangoextras/http/decorators.py#L23-L94
244,189
slarse/clanimtk
clanimtk/decorator.py
animation
def animation(frame_function: types.FrameFunction) -> types.Animation: """Turn a FrameFunction into an Animation. Args: frame_function: A function that returns a FrameGenerator. Returns: an Animation decorator function. """ animation_ = core.Animation(frame_function) @functool...
python
def animation(frame_function: types.FrameFunction) -> types.Animation: """Turn a FrameFunction into an Animation. Args: frame_function: A function that returns a FrameGenerator. Returns: an Animation decorator function. """ animation_ = core.Animation(frame_function) @functool...
[ "def", "animation", "(", "frame_function", ":", "types", ".", "FrameFunction", ")", "->", "types", ".", "Animation", ":", "animation_", "=", "core", ".", "Animation", "(", "frame_function", ")", "@", "functools", ".", "wraps", "(", "frame_function", ")", "de...
Turn a FrameFunction into an Animation. Args: frame_function: A function that returns a FrameGenerator. Returns: an Animation decorator function.
[ "Turn", "a", "FrameFunction", "into", "an", "Animation", "." ]
cb93d2e914c3ecc4e0007745ff4d546318cf3902
https://github.com/slarse/clanimtk/blob/cb93d2e914c3ecc4e0007745ff4d546318cf3902/clanimtk/decorator.py#L18-L33
244,190
slarse/clanimtk
clanimtk/decorator.py
multiline_frame_function
def multiline_frame_function(frame_function: types.FrameFunction, height: int, offset: int = 0, *args, **kwargs) -> types.FrameGenerator: """Multiline a singlelined frame function. Simply chains sever...
python
def multiline_frame_function(frame_function: types.FrameFunction, height: int, offset: int = 0, *args, **kwargs) -> types.FrameGenerator: """Multiline a singlelined frame function. Simply chains sever...
[ "def", "multiline_frame_function", "(", "frame_function", ":", "types", ".", "FrameFunction", ",", "height", ":", "int", ",", "offset", ":", "int", "=", "0", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "types", ".", "FrameGenerator", ":", "fram...
Multiline a singlelined frame function. Simply chains several frame generators together, and applies the specified offset to each one. Args: frame_function: A function that returns a singleline FrameGenerator. height: The amount of frame generators to stack vertically (determines the he...
[ "Multiline", "a", "singlelined", "frame", "function", ".", "Simply", "chains", "several", "frame", "generators", "together", "and", "applies", "the", "specified", "offset", "to", "each", "one", "." ]
cb93d2e914c3ecc4e0007745ff4d546318cf3902
https://github.com/slarse/clanimtk/blob/cb93d2e914c3ecc4e0007745ff4d546318cf3902/clanimtk/decorator.py#L108-L133
244,191
JIC-CSB/jicbioimage.segment
jicbioimage/segment/__init__.py
SegmentedImage.region_by_identifier
def region_by_identifier(self, identifier): """Return region of interest corresponding to the supplied identifier. :param identifier: integer corresponding to the segment of interest :returns: `jicbioimage.core.region.Region` """ if identifier < 0: raise(ValueError(...
python
def region_by_identifier(self, identifier): """Return region of interest corresponding to the supplied identifier. :param identifier: integer corresponding to the segment of interest :returns: `jicbioimage.core.region.Region` """ if identifier < 0: raise(ValueError(...
[ "def", "region_by_identifier", "(", "self", ",", "identifier", ")", ":", "if", "identifier", "<", "0", ":", "raise", "(", "ValueError", "(", "\"Identifier must be a positive integer.\"", ")", ")", "if", "not", "np", ".", "equal", "(", "np", ".", "mod", "(", ...
Return region of interest corresponding to the supplied identifier. :param identifier: integer corresponding to the segment of interest :returns: `jicbioimage.core.region.Region`
[ "Return", "region", "of", "interest", "corresponding", "to", "the", "supplied", "identifier", "." ]
289e5ab834913326a097e57bea458ea0737efb0c
https://github.com/JIC-CSB/jicbioimage.segment/blob/289e5ab834913326a097e57bea458ea0737efb0c/jicbioimage/segment/__init__.py#L175-L191
244,192
JIC-CSB/jicbioimage.segment
jicbioimage/segment/__init__.py
SegmentedImage.merge_regions
def merge_regions(self, id1, id2): """Merge two regions into one. The merged region will take on the id1 identifier. :param id1: region 1 identifier :param id2: region 2 identifier """ region2 = self.region_by_identifier(id2) self[region2] = id1
python
def merge_regions(self, id1, id2): """Merge two regions into one. The merged region will take on the id1 identifier. :param id1: region 1 identifier :param id2: region 2 identifier """ region2 = self.region_by_identifier(id2) self[region2] = id1
[ "def", "merge_regions", "(", "self", ",", "id1", ",", "id2", ")", ":", "region2", "=", "self", ".", "region_by_identifier", "(", "id2", ")", "self", "[", "region2", "]", "=", "id1" ]
Merge two regions into one. The merged region will take on the id1 identifier. :param id1: region 1 identifier :param id2: region 2 identifier
[ "Merge", "two", "regions", "into", "one", "." ]
289e5ab834913326a097e57bea458ea0737efb0c
https://github.com/JIC-CSB/jicbioimage.segment/blob/289e5ab834913326a097e57bea458ea0737efb0c/jicbioimage/segment/__init__.py#L236-L245
244,193
jspricke/python-icstask
icstask.py
task2ics
def task2ics(): """Command line tool to convert from Taskwarrior to iCalendar""" from argparse import ArgumentParser, FileType from sys import stdout parser = ArgumentParser(description='Converter from Taskwarrior to iCalendar syntax.') parser.add_argument('indir', nargs='?', help='Input Taskwarrio...
python
def task2ics(): """Command line tool to convert from Taskwarrior to iCalendar""" from argparse import ArgumentParser, FileType from sys import stdout parser = ArgumentParser(description='Converter from Taskwarrior to iCalendar syntax.') parser.add_argument('indir', nargs='?', help='Input Taskwarrio...
[ "def", "task2ics", "(", ")", ":", "from", "argparse", "import", "ArgumentParser", ",", "FileType", "from", "sys", "import", "stdout", "parser", "=", "ArgumentParser", "(", "description", "=", "'Converter from Taskwarrior to iCalendar syntax.'", ")", "parser", ".", "...
Command line tool to convert from Taskwarrior to iCalendar
[ "Command", "line", "tool", "to", "convert", "from", "Taskwarrior", "to", "iCalendar" ]
0802233cca569c2174bd96aed0682d04a2a63790
https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L338-L350
244,194
jspricke/python-icstask
icstask.py
ics2task
def ics2task(): """Command line tool to convert from iCalendar to Taskwarrior""" from argparse import ArgumentParser, FileType from sys import stdin parser = ArgumentParser(description='Converter from iCalendar to Taskwarrior syntax.') parser.add_argument('infile', nargs='?', type=FileType('r'), de...
python
def ics2task(): """Command line tool to convert from iCalendar to Taskwarrior""" from argparse import ArgumentParser, FileType from sys import stdin parser = ArgumentParser(description='Converter from iCalendar to Taskwarrior syntax.') parser.add_argument('infile', nargs='?', type=FileType('r'), de...
[ "def", "ics2task", "(", ")", ":", "from", "argparse", "import", "ArgumentParser", ",", "FileType", "from", "sys", "import", "stdin", "parser", "=", "ArgumentParser", "(", "description", "=", "'Converter from iCalendar to Taskwarrior syntax.'", ")", "parser", ".", "a...
Command line tool to convert from iCalendar to Taskwarrior
[ "Command", "line", "tool", "to", "convert", "from", "iCalendar", "to", "Taskwarrior" ]
0802233cca569c2174bd96aed0682d04a2a63790
https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L353-L367
244,195
jspricke/python-icstask
icstask.py
IcsTask._update
def _update(self): """Reload Taskwarrior files if the mtime is newer""" update = False with self._lock: for fname in ['pending.data', 'completed.data']: data_file = join(self._data_location, fname) if exists(data_file): mtime = get...
python
def _update(self): """Reload Taskwarrior files if the mtime is newer""" update = False with self._lock: for fname in ['pending.data', 'completed.data']: data_file = join(self._data_location, fname) if exists(data_file): mtime = get...
[ "def", "_update", "(", "self", ")", ":", "update", "=", "False", "with", "self", ".", "_lock", ":", "for", "fname", "in", "[", "'pending.data'", ",", "'completed.data'", "]", ":", "data_file", "=", "join", "(", "self", ".", "_data_location", ",", "fname"...
Reload Taskwarrior files if the mtime is newer
[ "Reload", "Taskwarrior", "files", "if", "the", "mtime", "is", "newer" ]
0802233cca569c2174bd96aed0682d04a2a63790
https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L47-L67
244,196
jspricke/python-icstask
icstask.py
IcsTask.to_vobjects
def to_vobjects(self, filename, uids=None): """Return iCal objects and etags of all Taskwarrior entries in uids filename -- the Taskwarrior project uids -- the UIDs of the Taskwarrior tasks (all if None) """ self._update() if not uids: uids = self.get_uids(f...
python
def to_vobjects(self, filename, uids=None): """Return iCal objects and etags of all Taskwarrior entries in uids filename -- the Taskwarrior project uids -- the UIDs of the Taskwarrior tasks (all if None) """ self._update() if not uids: uids = self.get_uids(f...
[ "def", "to_vobjects", "(", "self", ",", "filename", ",", "uids", "=", "None", ")", ":", "self", ".", "_update", "(", ")", "if", "not", "uids", ":", "uids", "=", "self", ".", "get_uids", "(", "filename", ")", "project", "=", "basename", "(", "filename...
Return iCal objects and etags of all Taskwarrior entries in uids filename -- the Taskwarrior project uids -- the UIDs of the Taskwarrior tasks (all if None)
[ "Return", "iCal", "objects", "and", "etags", "of", "all", "Taskwarrior", "entries", "in", "uids" ]
0802233cca569c2174bd96aed0682d04a2a63790
https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L89-L108
244,197
jspricke/python-icstask
icstask.py
IcsTask.to_vobject
def to_vobject(self, project=None, uid=None): """Return vObject object of Taskwarrior tasks If filename and UID are specified, the vObject only contains that task. If only a filename is specified, the vObject contains all events in the project. Otherwise the vObject contains all all obje...
python
def to_vobject(self, project=None, uid=None): """Return vObject object of Taskwarrior tasks If filename and UID are specified, the vObject only contains that task. If only a filename is specified, the vObject contains all events in the project. Otherwise the vObject contains all all obje...
[ "def", "to_vobject", "(", "self", ",", "project", "=", "None", ",", "uid", "=", "None", ")", ":", "self", ".", "_update", "(", ")", "vtodos", "=", "iCalendar", "(", ")", "if", "uid", ":", "uid", "=", "uid", ".", "split", "(", "'@'", ")", "[", "...
Return vObject object of Taskwarrior tasks If filename and UID are specified, the vObject only contains that task. If only a filename is specified, the vObject contains all events in the project. Otherwise the vObject contains all all objects of all files associated with the IcsTask object. ...
[ "Return", "vObject", "object", "of", "Taskwarrior", "tasks", "If", "filename", "and", "UID", "are", "specified", "the", "vObject", "only", "contains", "that", "task", ".", "If", "only", "a", "filename", "is", "specified", "the", "vObject", "contains", "all", ...
0802233cca569c2174bd96aed0682d04a2a63790
https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L110-L138
244,198
jspricke/python-icstask
icstask.py
IcsTask.get_filesnames
def get_filesnames(self): """Return a list of all Taskwarrior projects as virtual files in the data directory""" self._update() projects = set(list(self._tasks.keys()) + self._task_projects + ['all_projects', 'unaffiliated']) return [join(self._data_location, p.split()[0]) for p in proje...
python
def get_filesnames(self): """Return a list of all Taskwarrior projects as virtual files in the data directory""" self._update() projects = set(list(self._tasks.keys()) + self._task_projects + ['all_projects', 'unaffiliated']) return [join(self._data_location, p.split()[0]) for p in proje...
[ "def", "get_filesnames", "(", "self", ")", ":", "self", ".", "_update", "(", ")", "projects", "=", "set", "(", "list", "(", "self", ".", "_tasks", ".", "keys", "(", ")", ")", "+", "self", ".", "_task_projects", "+", "[", "'all_projects'", ",", "'unaf...
Return a list of all Taskwarrior projects as virtual files in the data directory
[ "Return", "a", "list", "of", "all", "Taskwarrior", "projects", "as", "virtual", "files", "in", "the", "data", "directory" ]
0802233cca569c2174bd96aed0682d04a2a63790
https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L269-L273
244,199
jspricke/python-icstask
icstask.py
IcsTask.move_vobject
def move_vobject(self, uuid, from_project, to_project): """Update the project of the task with the UID uuid""" if to_project not in self.get_filesnames(): return uuid = uuid.split('@')[0] with self._lock: run(['task', 'rc.verbose=nothing', 'rc.data.location={self...
python
def move_vobject(self, uuid, from_project, to_project): """Update the project of the task with the UID uuid""" if to_project not in self.get_filesnames(): return uuid = uuid.split('@')[0] with self._lock: run(['task', 'rc.verbose=nothing', 'rc.data.location={self...
[ "def", "move_vobject", "(", "self", ",", "uuid", ",", "from_project", ",", "to_project", ")", ":", "if", "to_project", "not", "in", "self", ".", "get_filesnames", "(", ")", ":", "return", "uuid", "=", "uuid", ".", "split", "(", "'@'", ")", "[", "0", ...
Update the project of the task with the UID uuid
[ "Update", "the", "project", "of", "the", "task", "with", "the", "UID", "uuid" ]
0802233cca569c2174bd96aed0682d04a2a63790
https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L328-L335