repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
jpablo128/simplystatic
simplystatic/s2page.py
Page.rename
def rename(self, new_title): """Rename an existing s2 page. For an existing s2 page, updates the directory and file name, as well as the internal configuration information (since it contains the title and the slug) """ if not isinstance(new_title, str) and \ ...
python
def rename(self, new_title): """Rename an existing s2 page. For an existing s2 page, updates the directory and file name, as well as the internal configuration information (since it contains the title and the slug) """ if not isinstance(new_title, str) and \ ...
[ "def", "rename", "(", "self", ",", "new_title", ")", ":", "if", "not", "isinstance", "(", "new_title", ",", "str", ")", "and", "not", "isinstance", "(", "new_title", ",", "unicode", ")", ":", "raise", "TypeError", "# print \"Cannot rename page. New title must be...
Rename an existing s2 page. For an existing s2 page, updates the directory and file name, as well as the internal configuration information (since it contains the title and the slug)
[ "Rename", "an", "existing", "s2", "page", "." ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L150-L186
jpablo128/simplystatic
simplystatic/s2page.py
Page.render
def render(self): """Render this page and return the rendition. Converts the markdown content to html, and then renders the (mako) template specified in the config, using that html. The task of writing of the rendition to a real file is responsibility of the generate method. ...
python
def render(self): """Render this page and return the rendition. Converts the markdown content to html, and then renders the (mako) template specified in the config, using that html. The task of writing of the rendition to a real file is responsibility of the generate method. ...
[ "def", "render", "(", "self", ")", ":", "(", "pthemedir", ",", "ptemplatefname", ")", "=", "self", ".", "_theme_and_template_fp", "(", ")", "mylookup", "=", "TemplateLookup", "(", "directories", "=", "[", "self", ".", "site", ".", "dirs", "[", "'s2'", "]...
Render this page and return the rendition. Converts the markdown content to html, and then renders the (mako) template specified in the config, using that html. The task of writing of the rendition to a real file is responsibility of the generate method.
[ "Render", "this", "page", "and", "return", "the", "rendition", "." ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L189-L257
jpablo128/simplystatic
simplystatic/s2page.py
Page.generate
def generate(self): """Generate the page html file. Just open the destination file for writing and write the result of rendering this page. """ generated_content = '' if 'published' in (self._config['status'][0]).lower(): if os.path.isdir(self.dirs['www_dir'...
python
def generate(self): """Generate the page html file. Just open the destination file for writing and write the result of rendering this page. """ generated_content = '' if 'published' in (self._config['status'][0]).lower(): if os.path.isdir(self.dirs['www_dir'...
[ "def", "generate", "(", "self", ")", ":", "generated_content", "=", "''", "if", "'published'", "in", "(", "self", ".", "_config", "[", "'status'", "]", "[", "0", "]", ")", ".", "lower", "(", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "...
Generate the page html file. Just open the destination file for writing and write the result of rendering this page.
[ "Generate", "the", "page", "html", "file", "." ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L261-L296
jpablo128/simplystatic
simplystatic/s2page.py
Page._create_config
def _create_config(self): """Create the default configuration dictionary for this page.""" configinfo = {'creation_date': [ datetime.datetime.now().date().isoformat()], 'author': [self.site.site_config['default_author']], 'status': [u'draft'], ...
python
def _create_config(self): """Create the default configuration dictionary for this page.""" configinfo = {'creation_date': [ datetime.datetime.now().date().isoformat()], 'author': [self.site.site_config['default_author']], 'status': [u'draft'], ...
[ "def", "_create_config", "(", "self", ")", ":", "configinfo", "=", "{", "'creation_date'", ":", "[", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "date", "(", ")", ".", "isoformat", "(", ")", "]", ",", "'author'", ":", "[", "self", ".", ...
Create the default configuration dictionary for this page.
[ "Create", "the", "default", "configuration", "dictionary", "for", "this", "page", "." ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L302-L316
jpablo128/simplystatic
simplystatic/s2page.py
Page._load
def _load(self, slug): """Load the page. The _file_name param is known, because this method is only called after having checked that the page exists. """ #here we know that the slug exists self._slug = slug page_dir = os.path.join(self.site.dirs['source'], self._slug) ...
python
def _load(self, slug): """Load the page. The _file_name param is known, because this method is only called after having checked that the page exists. """ #here we know that the slug exists self._slug = slug page_dir = os.path.join(self.site.dirs['source'], self._slug) ...
[ "def", "_load", "(", "self", ",", "slug", ")", ":", "#here we know that the slug exists", "self", ".", "_slug", "=", "slug", "page_dir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "site", ".", "dirs", "[", "'source'", "]", ",", "self", ".",...
Load the page. The _file_name param is known, because this method is only called after having checked that the page exists.
[ "Load", "the", "page", ".", "The", "_file_name", "param", "is", "known", "because", "this", "method", "is", "only", "called", "after", "having", "checked", "that", "the", "page", "exists", "." ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L318-L344
jpablo128/simplystatic
simplystatic/s2page.py
Page._check_config
def _check_config(self): """Verify that the configuration is correct.""" required_data = ['creation_date', 'author', 'status', 'lang', 'tags', 'title', 's...
python
def _check_config(self): """Verify that the configuration is correct.""" required_data = ['creation_date', 'author', 'status', 'lang', 'tags', 'title', 's...
[ "def", "_check_config", "(", "self", ")", ":", "required_data", "=", "[", "'creation_date'", ",", "'author'", ",", "'status'", ",", "'lang'", ",", "'tags'", ",", "'title'", ",", "'slug'", ",", "'theme'", ",", "'template'", ",", "'page_id'", "]", "isok", "=...
Verify that the configuration is correct.
[ "Verify", "that", "the", "configuration", "is", "correct", "." ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L346-L379
jpablo128/simplystatic
simplystatic/s2page.py
Page._theme_and_template_fp
def _theme_and_template_fp(self): """Return the full paths for theme and template in this page""" ptheme = self._config['theme'][0] if ptheme == "": ptheme = self.site.site_config['default_theme'] pthemedir = os.path.join(self.site.dirs['themes'], ptheme) ptemplate = ...
python
def _theme_and_template_fp(self): """Return the full paths for theme and template in this page""" ptheme = self._config['theme'][0] if ptheme == "": ptheme = self.site.site_config['default_theme'] pthemedir = os.path.join(self.site.dirs['themes'], ptheme) ptemplate = ...
[ "def", "_theme_and_template_fp", "(", "self", ")", ":", "ptheme", "=", "self", ".", "_config", "[", "'theme'", "]", "[", "0", "]", "if", "ptheme", "==", "\"\"", ":", "ptheme", "=", "self", ".", "site", ".", "site_config", "[", "'default_theme'", "]", "...
Return the full paths for theme and template in this page
[ "Return", "the", "full", "paths", "for", "theme", "and", "template", "in", "this", "page" ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L381-L391
jpablo128/simplystatic
simplystatic/s2page.py
Page._parse_text
def _parse_text(self, page_text): """Extract the s2config and the content from the raw page text.""" # 1 sanitize: remove leading blank lines # 2 separate "config text" from content, store content # 3 convert config text + \n to obtain Meta, this is the config. lines = page_tex...
python
def _parse_text(self, page_text): """Extract the s2config and the content from the raw page text.""" # 1 sanitize: remove leading blank lines # 2 separate "config text" from content, store content # 3 convert config text + \n to obtain Meta, this is the config. lines = page_tex...
[ "def", "_parse_text", "(", "self", ",", "page_text", ")", ":", "# 1 sanitize: remove leading blank lines", "# 2 separate \"config text\" from content, store content", "# 3 convert config text + \\n to obtain Meta, this is the config.", "lines", "=", "page_text", ".", "split", "(", ...
Extract the s2config and the content from the raw page text.
[ "Extract", "the", "s2config", "and", "the", "content", "from", "the", "raw", "page", "text", "." ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L393-L417
jpablo128/simplystatic
simplystatic/s2page.py
Page._config_to_text
def _config_to_text(self): """Render the configuration as text.""" r = u'' # unicode('',"UTF-8") for k in self._config: # if k == 'creation_date': # r += k + ": " + self._config[k][0] + '\n' # else: #uk = unicode(k,"UTF-8") cosa = ...
python
def _config_to_text(self): """Render the configuration as text.""" r = u'' # unicode('',"UTF-8") for k in self._config: # if k == 'creation_date': # r += k + ": " + self._config[k][0] + '\n' # else: #uk = unicode(k,"UTF-8") cosa = ...
[ "def", "_config_to_text", "(", "self", ")", ":", "r", "=", "u''", "# unicode('',\"UTF-8\")", "for", "k", "in", "self", ".", "_config", ":", "# if k == 'creation_date':", "# r += k + \": \" + self._config[k][0] + '\\n'", "# else:", "#uk = unicode(k,\"UTF-8\")", "cosa", ...
Render the configuration as text.
[ "Render", "the", "configuration", "as", "text", "." ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L420-L432
jpablo128/simplystatic
simplystatic/s2page.py
Page.creation_date
def creation_date(self, value): # pylint: disable-msg=E0102 """Set the date in the configuraton (setter)""" if not isinstance(value, datetime.date): raise TypeError self._config['creation_date'][0] = value.isoformat()
python
def creation_date(self, value): # pylint: disable-msg=E0102 """Set the date in the configuraton (setter)""" if not isinstance(value, datetime.date): raise TypeError self._config['creation_date'][0] = value.isoformat()
[ "def", "creation_date", "(", "self", ",", "value", ")", ":", "# pylint: disable-msg=E0102", "if", "not", "isinstance", "(", "value", ",", "datetime", ".", "date", ")", ":", "raise", "TypeError", "self", ".", "_config", "[", "'creation_date'", "]", "[", "0", ...
Set the date in the configuraton (setter)
[ "Set", "the", "date", "in", "the", "configuraton", "(", "setter", ")" ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L475-L479
jpablo128/simplystatic
simplystatic/s2page.py
Page.tags
def tags(self, value): # pylint: disable-msg=E0102 """Set the tags in the configuraton (setter)""" if not isinstance(value, list): raise TypeError self._config['tags'] = value
python
def tags(self, value): # pylint: disable-msg=E0102 """Set the tags in the configuraton (setter)""" if not isinstance(value, list): raise TypeError self._config['tags'] = value
[ "def", "tags", "(", "self", ",", "value", ")", ":", "# pylint: disable-msg=E0102", "if", "not", "isinstance", "(", "value", ",", "list", ")", ":", "raise", "TypeError", "self", ".", "_config", "[", "'tags'", "]", "=", "value" ]
Set the tags in the configuraton (setter)
[ "Set", "the", "tags", "in", "the", "configuraton", "(", "setter", ")" ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L487-L491
jpablo128/simplystatic
simplystatic/s2page.py
Page.author
def author(self): """Return the full path of the theme used by this page.""" r = self.site.site_config['default_author'] if 'author' in self._config: r = self._config['author'] return r
python
def author(self): """Return the full path of the theme used by this page.""" r = self.site.site_config['default_author'] if 'author' in self._config: r = self._config['author'] return r
[ "def", "author", "(", "self", ")", ":", "r", "=", "self", ".", "site", ".", "site_config", "[", "'default_author'", "]", "if", "'author'", "in", "self", ".", "_config", ":", "r", "=", "self", ".", "_config", "[", "'author'", "]", "return", "r" ]
Return the full path of the theme used by this page.
[ "Return", "the", "full", "path", "of", "the", "theme", "used", "by", "this", "page", "." ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L499-L504
jalanb/pysyte
pysyte/decorators.py
_represent_arguments
def _represent_arguments(*arguments, **keyword_arguments): """Represent the aruments in a form suitable as a key (hashable) And which will be recognisable to user in error messages >>> print(_represent_arguments([1, 2], **{'fred':'here'})) [1, 2], fred='here' """ argument_strings = [repr(a) for...
python
def _represent_arguments(*arguments, **keyword_arguments): """Represent the aruments in a form suitable as a key (hashable) And which will be recognisable to user in error messages >>> print(_represent_arguments([1, 2], **{'fred':'here'})) [1, 2], fred='here' """ argument_strings = [repr(a) for...
[ "def", "_represent_arguments", "(", "*", "arguments", ",", "*", "*", "keyword_arguments", ")", ":", "argument_strings", "=", "[", "repr", "(", "a", ")", "for", "a", "in", "arguments", "]", "keyword_strings", "=", "[", "'='", ".", "join", "(", "(", "k", ...
Represent the aruments in a form suitable as a key (hashable) And which will be recognisable to user in error messages >>> print(_represent_arguments([1, 2], **{'fred':'here'})) [1, 2], fred='here'
[ "Represent", "the", "aruments", "in", "a", "form", "suitable", "as", "a", "key", "(", "hashable", ")" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/decorators.py#L6-L16
jalanb/pysyte
pysyte/decorators.py
memoize
def memoize(method): """A new method which acts like the given method but memoizes arguments See https://en.wikipedia.org/wiki/Memoization for the general idea >>> @memoize ... def test(arg): ... print('called') ... return arg + 1 >>> test(1) called 2 >>> test(2) cal...
python
def memoize(method): """A new method which acts like the given method but memoizes arguments See https://en.wikipedia.org/wiki/Memoization for the general idea >>> @memoize ... def test(arg): ... print('called') ... return arg + 1 >>> test(1) called 2 >>> test(2) cal...
[ "def", "memoize", "(", "method", ")", ":", "method", ".", "cache", "=", "{", "}", "def", "invalidate", "(", "*", "arguments", ",", "*", "*", "keyword_arguments", ")", ":", "key", "=", "_represent_arguments", "(", "*", "arguments", ",", "*", "*", "keywo...
A new method which acts like the given method but memoizes arguments See https://en.wikipedia.org/wiki/Memoization for the general idea >>> @memoize ... def test(arg): ... print('called') ... return arg + 1 >>> test(1) called 2 >>> test(2) called 3 >>> test(1) ...
[ "A", "new", "method", "which", "acts", "like", "the", "given", "method", "but", "memoizes", "arguments" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/decorators.py#L19-L72
jalanb/pysyte
pysyte/decorators.py
debug
def debug(method): """Decorator to debug the given method""" def new_method(*args, **kwargs): import pdb try: import pudb except ImportError: pudb = pdb try: pudb.runcall(method, *args, **kwargs) except pdb.bdb.BdbQuit: sys....
python
def debug(method): """Decorator to debug the given method""" def new_method(*args, **kwargs): import pdb try: import pudb except ImportError: pudb = pdb try: pudb.runcall(method, *args, **kwargs) except pdb.bdb.BdbQuit: sys....
[ "def", "debug", "(", "method", ")", ":", "def", "new_method", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "import", "pdb", "try", ":", "import", "pudb", "except", "ImportError", ":", "pudb", "=", "pdb", "try", ":", "pudb", ".", "runcall", ...
Decorator to debug the given method
[ "Decorator", "to", "debug", "the", "given", "method" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/decorators.py#L75-L89
jalanb/pysyte
pysyte/decorators.py
streamer
def streamer(main_method): """Open a stream for the first file in arguments, or stdin""" def main(arguments): streams = [StringIO(get_clipboard_data())] if (arguments and '-c' in arguments) else [] streams = streams or ([file(_, 'r') for _ in arguments if os.path.isfile(argument)] if arguments e...
python
def streamer(main_method): """Open a stream for the first file in arguments, or stdin""" def main(arguments): streams = [StringIO(get_clipboard_data())] if (arguments and '-c' in arguments) else [] streams = streams or ([file(_, 'r') for _ in arguments if os.path.isfile(argument)] if arguments e...
[ "def", "streamer", "(", "main_method", ")", ":", "def", "main", "(", "arguments", ")", ":", "streams", "=", "[", "StringIO", "(", "get_clipboard_data", "(", ")", ")", "]", "if", "(", "arguments", "and", "'-c'", "in", "arguments", ")", "else", "[", "]",...
Open a stream for the first file in arguments, or stdin
[ "Open", "a", "stream", "for", "the", "first", "file", "in", "arguments", "or", "stdin" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/decorators.py#L113-L120
jalanb/pysyte
pysyte/decorators.py
old_streamer
def old_streamer(main_method): """Open a stream for the first file in arguments, or stdin""" if not arguments: return [sys.stdin] elif arguments[0] == '-c': return [StringIO(get_clipboard_data())] for argument in arguments: if os.path.isfile(argument): return file(arg...
python
def old_streamer(main_method): """Open a stream for the first file in arguments, or stdin""" if not arguments: return [sys.stdin] elif arguments[0] == '-c': return [StringIO(get_clipboard_data())] for argument in arguments: if os.path.isfile(argument): return file(arg...
[ "def", "old_streamer", "(", "main_method", ")", ":", "if", "not", "arguments", ":", "return", "[", "sys", ".", "stdin", "]", "elif", "arguments", "[", "0", "]", "==", "'-c'", ":", "return", "[", "StringIO", "(", "get_clipboard_data", "(", ")", ")", "]"...
Open a stream for the first file in arguments, or stdin
[ "Open", "a", "stream", "for", "the", "first", "file", "in", "arguments", "or", "stdin" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/decorators.py#L123-L132
jalanb/pysyte
pysyte/decorators.py
globber
def globber(main_method, globs): """Recognise globs in args""" import os from glob import glob def main(arguments): lists_of_paths = [_ for _ in arguments if glob(pathname, recursive=True)] return main_method(arguments, lists_of_paths) return main
python
def globber(main_method, globs): """Recognise globs in args""" import os from glob import glob def main(arguments): lists_of_paths = [_ for _ in arguments if glob(pathname, recursive=True)] return main_method(arguments, lists_of_paths) return main
[ "def", "globber", "(", "main_method", ",", "globs", ")", ":", "import", "os", "from", "glob", "import", "glob", "def", "main", "(", "arguments", ")", ":", "lists_of_paths", "=", "[", "_", "for", "_", "in", "arguments", "if", "glob", "(", "pathname", ",...
Recognise globs in args
[ "Recognise", "globs", "in", "args" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/decorators.py#L135-L143
shi-cong/PYSTUDY
PYSTUDY/modulelib.py
get_curent_module_classes
def get_curent_module_classes(module): """ 获取制定模块的所有类 :param module: 模块 :return: 类的列表 """ classes = [] for name, obj in inspect.getmembers(module): if inspect.isclass(obj): classes.append(obj) return classes
python
def get_curent_module_classes(module): """ 获取制定模块的所有类 :param module: 模块 :return: 类的列表 """ classes = [] for name, obj in inspect.getmembers(module): if inspect.isclass(obj): classes.append(obj) return classes
[ "def", "get_curent_module_classes", "(", "module", ")", ":", "classes", "=", "[", "]", "for", "name", ",", "obj", "in", "inspect", ".", "getmembers", "(", "module", ")", ":", "if", "inspect", ".", "isclass", "(", "obj", ")", ":", "classes", ".", "appen...
获取制定模块的所有类 :param module: 模块 :return: 类的列表
[ "获取制定模块的所有类", ":", "param", "module", ":", "模块", ":", "return", ":", "类的列表" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/modulelib.py#L8-L18
shi-cong/PYSTUDY
PYSTUDY/modulelib.py
is_subclass
def is_subclass(obj, cls): """ 判断某一个类或者对象是否是某一个类的子类 :param obj: 类或对象 :param cls: 类 :return: True or False """ try: for i in obj.__bases__: if i is cls or isinstance(i, cls): return True for i in obj.__bases__: if isinstance(i, cls): ...
python
def is_subclass(obj, cls): """ 判断某一个类或者对象是否是某一个类的子类 :param obj: 类或对象 :param cls: 类 :return: True or False """ try: for i in obj.__bases__: if i is cls or isinstance(i, cls): return True for i in obj.__bases__: if isinstance(i, cls): ...
[ "def", "is_subclass", "(", "obj", ",", "cls", ")", ":", "try", ":", "for", "i", "in", "obj", ".", "__bases__", ":", "if", "i", "is", "cls", "or", "isinstance", "(", "i", ",", "cls", ")", ":", "return", "True", "for", "i", "in", "obj", ".", "__b...
判断某一个类或者对象是否是某一个类的子类 :param obj: 类或对象 :param cls: 类 :return: True or False
[ "判断某一个类或者对象是否是某一个类的子类", ":", "param", "obj", ":", "类或对象", ":", "param", "cls", ":", "类", ":", "return", ":", "True", "or", "False" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/modulelib.py#L22-L38
mdeous/fatbotslim
fatbotslim/handlers.py
CommandHandler._dispatch_trigger
def _dispatch_trigger(self, msg): """ Dispatches the message to the corresponding method. """ if not msg.args[0].startswith(self.trigger_char): return split_args = msg.args[0].split() trigger = split_args[0].lstrip(self.trigger_char) if trigger in self...
python
def _dispatch_trigger(self, msg): """ Dispatches the message to the corresponding method. """ if not msg.args[0].startswith(self.trigger_char): return split_args = msg.args[0].split() trigger = split_args[0].lstrip(self.trigger_char) if trigger in self...
[ "def", "_dispatch_trigger", "(", "self", ",", "msg", ")", ":", "if", "not", "msg", ".", "args", "[", "0", "]", ".", "startswith", "(", "self", ".", "trigger_char", ")", ":", "return", "split_args", "=", "msg", ".", "args", "[", "0", "]", ".", "spli...
Dispatches the message to the corresponding method.
[ "Dispatches", "the", "message", "to", "the", "corresponding", "method", "." ]
train
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/handlers.py#L178-L199
mdeous/fatbotslim
fatbotslim/handlers.py
HelpHandler.help
def help(self, msg): """ help [command] - displays available commands, or help message for given command """ commands = {} for handler in self.irc.handlers: if isinstance(handler, CommandHandler): for command in handler.triggers: me...
python
def help(self, msg): """ help [command] - displays available commands, or help message for given command """ commands = {} for handler in self.irc.handlers: if isinstance(handler, CommandHandler): for command in handler.triggers: me...
[ "def", "help", "(", "self", ",", "msg", ")", ":", "commands", "=", "{", "}", "for", "handler", "in", "self", ".", "irc", ".", "handlers", ":", "if", "isinstance", "(", "handler", ",", "CommandHandler", ")", ":", "for", "command", "in", "handler", "."...
help [command] - displays available commands, or help message for given command
[ "help", "[", "command", "]", "-", "displays", "available", "commands", "or", "help", "message", "for", "given", "command" ]
train
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/handlers.py#L210-L237
mdeous/fatbotslim
fatbotslim/handlers.py
RightsHandler.set_restriction
def set_restriction(self, command, user, event_types): """ Adds restriction for given `command`. :param command: command on which the restriction should be set. :type command: str :param user: username for which the restriction applies. :type user: str :param eve...
python
def set_restriction(self, command, user, event_types): """ Adds restriction for given `command`. :param command: command on which the restriction should be set. :type command: str :param user: username for which the restriction applies. :type user: str :param eve...
[ "def", "set_restriction", "(", "self", ",", "command", ",", "user", ",", "event_types", ")", ":", "self", ".", "commands_rights", "[", "command", "]", "[", "user", ".", "lower", "(", ")", "]", "=", "event_types", "if", "command", "not", "in", "self", "...
Adds restriction for given `command`. :param command: command on which the restriction should be set. :type command: str :param user: username for which the restriction applies. :type user: str :param event_types: types of events for which the command is allowed. :type e...
[ "Adds", "restriction", "for", "given", "command", "." ]
train
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/handlers.py#L247-L262
mdeous/fatbotslim
fatbotslim/handlers.py
RightsHandler.del_restriction
def del_restriction(self, command, user, event_types): """ Removes restriction for given `command`. :param command: command on which the restriction should be removed. :type command: str :param user: username for which restriction should be removed. :type user: str ...
python
def del_restriction(self, command, user, event_types): """ Removes restriction for given `command`. :param command: command on which the restriction should be removed. :type command: str :param user: username for which restriction should be removed. :type user: str ...
[ "def", "del_restriction", "(", "self", ",", "command", ",", "user", ",", "event_types", ")", ":", "if", "user", ".", "lower", "(", ")", "in", "self", ".", "commands_rights", "[", "command", "]", ":", "for", "event_type", "in", "event_types", ":", "try", ...
Removes restriction for given `command`. :param command: command on which the restriction should be removed. :type command: str :param user: username for which restriction should be removed. :type user: str :param event_types: types of events that should be removed from restrict...
[ "Removes", "restriction", "for", "given", "command", "." ]
train
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/handlers.py#L264-L282
mdeous/fatbotslim
fatbotslim/handlers.py
RightsHandler.handle_rights
def handle_rights(self, msg): """ Catch-all command that is called whenever a restricted command is triggered. :param msg: message that triggered the command. :type msg: :class:`fatbotslim.irc.Message` """ command = msg.args[0][1:] if command in self.commands_rig...
python
def handle_rights(self, msg): """ Catch-all command that is called whenever a restricted command is triggered. :param msg: message that triggered the command. :type msg: :class:`fatbotslim.irc.Message` """ command = msg.args[0][1:] if command in self.commands_rig...
[ "def", "handle_rights", "(", "self", ",", "msg", ")", ":", "command", "=", "msg", ".", "args", "[", "0", "]", "[", "1", ":", "]", "if", "command", "in", "self", ".", "commands_rights", ":", "if", "msg", ".", "src", ".", "name", ".", "lower", "(",...
Catch-all command that is called whenever a restricted command is triggered. :param msg: message that triggered the command. :type msg: :class:`fatbotslim.irc.Message`
[ "Catch", "-", "all", "command", "that", "is", "called", "whenever", "a", "restricted", "command", "is", "triggered", "." ]
train
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/handlers.py#L284-L306
edwards-lab/libGWAS
libgwas/data_parser.py
check_inclusions
def check_inclusions(item, included=[], excluded=[]): """Everything passes if both are empty, otherwise, we have to check if \ empty or is present.""" if (len(included) == 0): if len(excluded) == 0 or item not in excluded: return True else: return False else: ...
python
def check_inclusions(item, included=[], excluded=[]): """Everything passes if both are empty, otherwise, we have to check if \ empty or is present.""" if (len(included) == 0): if len(excluded) == 0 or item not in excluded: return True else: return False else: ...
[ "def", "check_inclusions", "(", "item", ",", "included", "=", "[", "]", ",", "excluded", "=", "[", "]", ")", ":", "if", "(", "len", "(", "included", ")", "==", "0", ")", ":", "if", "len", "(", "excluded", ")", "==", "0", "or", "item", "not", "i...
Everything passes if both are empty, otherwise, we have to check if \ empty or is present.
[ "Everything", "passes", "if", "both", "are", "empty", "otherwise", "we", "have", "to", "check", "if", "\\", "empty", "or", "is", "present", "." ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/data_parser.py#L27-L38
francois-vincent/clingon
examples/zipcomment.py
toto
def toto(arch_name, comment='', clear=False, read_comment=False, list_members=False, time_show=False): """ Small utility for changing comment in a zip file without changing the file modification datetime. """ if comment and clear: clingon.RunnerError("You cannot specify --comment and --clear...
python
def toto(arch_name, comment='', clear=False, read_comment=False, list_members=False, time_show=False): """ Small utility for changing comment in a zip file without changing the file modification datetime. """ if comment and clear: clingon.RunnerError("You cannot specify --comment and --clear...
[ "def", "toto", "(", "arch_name", ",", "comment", "=", "''", ",", "clear", "=", "False", ",", "read_comment", "=", "False", ",", "list_members", "=", "False", ",", "time_show", "=", "False", ")", ":", "if", "comment", "and", "clear", ":", "clingon", "."...
Small utility for changing comment in a zip file without changing the file modification datetime.
[ "Small", "utility", "for", "changing", "comment", "in", "a", "zip", "file", "without", "changing", "the", "file", "modification", "datetime", "." ]
train
https://github.com/francois-vincent/clingon/blob/afc9db073dbc72b2562ce3e444152986a555dcbf/examples/zipcomment.py#L11-L42
pyvec/pyvodb
pyvodb/cli/top.py
cli
def cli(ctx, data, verbose, color, format, editor): """Query a meetup database. """ ctx.obj['verbose'] = verbose if verbose: logging.basicConfig(level=logging.INFO) logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) ctx.obj['datadir'] = os.path.abspath(data) if 'db' no...
python
def cli(ctx, data, verbose, color, format, editor): """Query a meetup database. """ ctx.obj['verbose'] = verbose if verbose: logging.basicConfig(level=logging.INFO) logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) ctx.obj['datadir'] = os.path.abspath(data) if 'db' no...
[ "def", "cli", "(", "ctx", ",", "data", ",", "verbose", ",", "color", ",", "format", ",", "editor", ")", ":", "ctx", ".", "obj", "[", "'verbose'", "]", "=", "verbose", "if", "verbose", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ...
Query a meetup database.
[ "Query", "a", "meetup", "database", "." ]
train
https://github.com/pyvec/pyvodb/blob/07183333df26eb12c5c2b98802cde3fb3a6c1339/pyvodb/cli/top.py#L57-L80
Bystroushaak/BalancedDiscStorage
src/BalancedDiscStorage/balanced_disc_storage.py
BalancedDiscStorage._assert_path_is_rw
def _assert_path_is_rw(self): """ Make sure, that `self.path` exists, is directory a readable/writeable. Raises: IOError: In case that any of the assumptions failed. ValueError: In case that `self.path` is not set. """ if not self.path: raise ...
python
def _assert_path_is_rw(self): """ Make sure, that `self.path` exists, is directory a readable/writeable. Raises: IOError: In case that any of the assumptions failed. ValueError: In case that `self.path` is not set. """ if not self.path: raise ...
[ "def", "_assert_path_is_rw", "(", "self", ")", ":", "if", "not", "self", ".", "path", ":", "raise", "ValueError", "(", "\"`path` argument must be set!\"", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "path", ")", ":", "raise", "I...
Make sure, that `self.path` exists, is directory a readable/writeable. Raises: IOError: In case that any of the assumptions failed. ValueError: In case that `self.path` is not set.
[ "Make", "sure", "that", "self", ".", "path", "exists", "is", "directory", "a", "readable", "/", "writeable", "." ]
train
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L28-L48
Bystroushaak/BalancedDiscStorage
src/BalancedDiscStorage/balanced_disc_storage.py
BalancedDiscStorage._get_file_iterator
def _get_file_iterator(self, file_obj): """ For given `file_obj` return iterator, which will read the file in `self.read_bs` chunks. Args: file_obj (file): File-like object. Return: iterator: Iterator reading the file-like object in chunks. """ ...
python
def _get_file_iterator(self, file_obj): """ For given `file_obj` return iterator, which will read the file in `self.read_bs` chunks. Args: file_obj (file): File-like object. Return: iterator: Iterator reading the file-like object in chunks. """ ...
[ "def", "_get_file_iterator", "(", "self", ",", "file_obj", ")", ":", "file_obj", ".", "seek", "(", "0", ")", "return", "iter", "(", "lambda", ":", "file_obj", ".", "read", "(", "self", ".", "read_bs", ")", ",", "''", ")" ]
For given `file_obj` return iterator, which will read the file in `self.read_bs` chunks. Args: file_obj (file): File-like object. Return: iterator: Iterator reading the file-like object in chunks.
[ "For", "given", "file_obj", "return", "iterator", "which", "will", "read", "the", "file", "in", "self", ".", "read_bs", "chunks", "." ]
train
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L50-L63
Bystroushaak/BalancedDiscStorage
src/BalancedDiscStorage/balanced_disc_storage.py
BalancedDiscStorage._get_hash
def _get_hash(self, file_obj): """ Compute hash for the `file_obj`. Attr: file_obj (obj): File-like object with ``.write()`` and ``.seek()``. Returns: str: Hexdigest of the hash. """ size = 0 hash_buider = self.hash_builder() for ...
python
def _get_hash(self, file_obj): """ Compute hash for the `file_obj`. Attr: file_obj (obj): File-like object with ``.write()`` and ``.seek()``. Returns: str: Hexdigest of the hash. """ size = 0 hash_buider = self.hash_builder() for ...
[ "def", "_get_hash", "(", "self", ",", "file_obj", ")", ":", "size", "=", "0", "hash_buider", "=", "self", ".", "hash_builder", "(", ")", "for", "piece", "in", "self", ".", "_get_file_iterator", "(", "file_obj", ")", ":", "hash_buider", ".", "update", "("...
Compute hash for the `file_obj`. Attr: file_obj (obj): File-like object with ``.write()`` and ``.seek()``. Returns: str: Hexdigest of the hash.
[ "Compute", "hash", "for", "the", "file_obj", "." ]
train
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L65-L83
Bystroushaak/BalancedDiscStorage
src/BalancedDiscStorage/balanced_disc_storage.py
BalancedDiscStorage._create_dir_path
def _create_dir_path(self, file_hash, path=None, hash_list=None): """ Create proper filesystem paths for given `file_hash`. Args: file_hash (str): Hash of the file for which the path should be created. path (str, default None): Recursion argument, d...
python
def _create_dir_path(self, file_hash, path=None, hash_list=None): """ Create proper filesystem paths for given `file_hash`. Args: file_hash (str): Hash of the file for which the path should be created. path (str, default None): Recursion argument, d...
[ "def", "_create_dir_path", "(", "self", ",", "file_hash", ",", "path", "=", "None", ",", "hash_list", "=", "None", ")", ":", "# first, non-recursive call - parse `file_hash`", "if", "hash_list", "is", "None", ":", "hash_list", "=", "list", "(", "file_hash", ")",...
Create proper filesystem paths for given `file_hash`. Args: file_hash (str): Hash of the file for which the path should be created. path (str, default None): Recursion argument, don't set this. hash_list (list, default None): Recursion argument, don't s...
[ "Create", "proper", "filesystem", "paths", "for", "given", "file_hash", "." ]
train
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L100-L151
Bystroushaak/BalancedDiscStorage
src/BalancedDiscStorage/balanced_disc_storage.py
BalancedDiscStorage.file_path_from_hash
def file_path_from_hash(self, file_hash, path=None, hash_list=None): """ For given `file_hash`, return path on filesystem. Args: file_hash (str): Hash of the file, for which you wish to know the path. path (str, default None): Recursion argument, do...
python
def file_path_from_hash(self, file_hash, path=None, hash_list=None): """ For given `file_hash`, return path on filesystem. Args: file_hash (str): Hash of the file, for which you wish to know the path. path (str, default None): Recursion argument, do...
[ "def", "file_path_from_hash", "(", "self", ",", "file_hash", ",", "path", "=", "None", ",", "hash_list", "=", "None", ")", ":", "# first, non-recursive call - parse `file_hash`", "if", "hash_list", "is", "None", ":", "hash_list", "=", "list", "(", "file_hash", "...
For given `file_hash`, return path on filesystem. Args: file_hash (str): Hash of the file, for which you wish to know the path. path (str, default None): Recursion argument, don't set this. hash_list (list, default None): Recursion argument, don't set t...
[ "For", "given", "file_hash", "return", "path", "on", "filesystem", "." ]
train
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L153-L206
Bystroushaak/BalancedDiscStorage
src/BalancedDiscStorage/balanced_disc_storage.py
BalancedDiscStorage.add_file
def add_file(self, file_obj): """ Add new file into the storage. Args: file_obj (file): Opened file-like object. Returns: obj: Path where the file-like object is stored contained with hash\ in :class:`.PathAndHash` object. Raises: ...
python
def add_file(self, file_obj): """ Add new file into the storage. Args: file_obj (file): Opened file-like object. Returns: obj: Path where the file-like object is stored contained with hash\ in :class:`.PathAndHash` object. Raises: ...
[ "def", "add_file", "(", "self", ",", "file_obj", ")", ":", "BalancedDiscStorage", ".", "_check_interface", "(", "file_obj", ")", "file_hash", "=", "self", ".", "_get_hash", "(", "file_obj", ")", "dir_path", "=", "self", ".", "_create_dir_path", "(", "file_hash...
Add new file into the storage. Args: file_obj (file): Opened file-like object. Returns: obj: Path where the file-like object is stored contained with hash\ in :class:`.PathAndHash` object. Raises: AssertionError: If the `file_obj` is not fi...
[ "Add", "new", "file", "into", "the", "storage", "." ]
train
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L208-L241
Bystroushaak/BalancedDiscStorage
src/BalancedDiscStorage/balanced_disc_storage.py
BalancedDiscStorage.delete_by_file
def delete_by_file(self, file_obj): """ Remove file from the storage. File is identified by opened `file_obj`, from which the hashes / path are computed. Args: file_obj (file): Opened file-like object, which is used to compute hashes. Raises: ...
python
def delete_by_file(self, file_obj): """ Remove file from the storage. File is identified by opened `file_obj`, from which the hashes / path are computed. Args: file_obj (file): Opened file-like object, which is used to compute hashes. Raises: ...
[ "def", "delete_by_file", "(", "self", ",", "file_obj", ")", ":", "BalancedDiscStorage", ".", "_check_interface", "(", "file_obj", ")", "file_hash", "=", "self", ".", "_get_hash", "(", "file_obj", ")", "return", "self", ".", "delete_by_hash", "(", "file_hash", ...
Remove file from the storage. File is identified by opened `file_obj`, from which the hashes / path are computed. Args: file_obj (file): Opened file-like object, which is used to compute hashes. Raises: IOError: If the `file_obj` is not in storage.
[ "Remove", "file", "from", "the", "storage", ".", "File", "is", "identified", "by", "opened", "file_obj", "from", "which", "the", "hashes", "/", "path", "are", "computed", "." ]
train
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L243-L259
Bystroushaak/BalancedDiscStorage
src/BalancedDiscStorage/balanced_disc_storage.py
BalancedDiscStorage.delete_by_hash
def delete_by_hash(self, file_hash): """ Remove file/archive by it's `file_hash`. Args: file_hash (str): Hash, which is used to find the file in storage. Raises: IOError: If the file for given `file_hash` was not found in \ storage. ...
python
def delete_by_hash(self, file_hash): """ Remove file/archive by it's `file_hash`. Args: file_hash (str): Hash, which is used to find the file in storage. Raises: IOError: If the file for given `file_hash` was not found in \ storage. ...
[ "def", "delete_by_hash", "(", "self", ",", "file_hash", ")", ":", "full_path", "=", "self", ".", "file_path_from_hash", "(", "file_hash", ")", "return", "self", ".", "delete_by_path", "(", "full_path", ")" ]
Remove file/archive by it's `file_hash`. Args: file_hash (str): Hash, which is used to find the file in storage. Raises: IOError: If the file for given `file_hash` was not found in \ storage.
[ "Remove", "file", "/", "archive", "by", "it", "s", "file_hash", "." ]
train
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L261-L274
Bystroushaak/BalancedDiscStorage
src/BalancedDiscStorage/balanced_disc_storage.py
BalancedDiscStorage._recursive_remove_blank_dirs
def _recursive_remove_blank_dirs(self, path): """ Make sure, that blank directories are removed from the storage. Args: path (str): Path which you suspect that is blank. """ path = os.path.abspath(path) # never delete root of the storage or smaller paths ...
python
def _recursive_remove_blank_dirs(self, path): """ Make sure, that blank directories are removed from the storage. Args: path (str): Path which you suspect that is blank. """ path = os.path.abspath(path) # never delete root of the storage or smaller paths ...
[ "def", "_recursive_remove_blank_dirs", "(", "self", ",", "path", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "# never delete root of the storage or smaller paths", "if", "path", "==", "self", ".", "path", "or", "len", "(", "path...
Make sure, that blank directories are removed from the storage. Args: path (str): Path which you suspect that is blank.
[ "Make", "sure", "that", "blank", "directories", "are", "removed", "from", "the", "storage", "." ]
train
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L276-L305
Bystroushaak/BalancedDiscStorage
src/BalancedDiscStorage/balanced_disc_storage.py
BalancedDiscStorage.delete_by_path
def delete_by_path(self, path): """ Delete file/directory identified by `path` argument. Warning: `path` have to be in :attr:`path`. Args: path (str): Path of the file / directory you want to remove. Raises: IOError: If the file / directory ...
python
def delete_by_path(self, path): """ Delete file/directory identified by `path` argument. Warning: `path` have to be in :attr:`path`. Args: path (str): Path of the file / directory you want to remove. Raises: IOError: If the file / directory ...
[ "def", "delete_by_path", "(", "self", ",", "path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "raise", "IOError", "(", "\"Unknown path '%s'!\"", "%", "path", ")", "if", "not", "path", ".", "startswith", "(", "self",...
Delete file/directory identified by `path` argument. Warning: `path` have to be in :attr:`path`. Args: path (str): Path of the file / directory you want to remove. Raises: IOError: If the file / directory doesn't exists, or is not in \ ...
[ "Delete", "file", "/", "directory", "identified", "by", "path", "argument", "." ]
train
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L307-L337
maxweisspoker/simplebitcoinfuncs
simplebitcoinfuncs/bip32.py
BIP32.crack
def crack(mpub,priv,pathtopriv): ''' Input mpub is master xpub key string. Input priv is xprv string. Path is the path string (e.g. 'm/3/6/2') from the mpub to the priv. Path cannot contain any hardened keys. ''' mpub = str(mpub) priv = b58d(priv) ...
python
def crack(mpub,priv,pathtopriv): ''' Input mpub is master xpub key string. Input priv is xprv string. Path is the path string (e.g. 'm/3/6/2') from the mpub to the priv. Path cannot contain any hardened keys. ''' mpub = str(mpub) priv = b58d(priv) ...
[ "def", "crack", "(", "mpub", ",", "priv", ",", "pathtopriv", ")", ":", "mpub", "=", "str", "(", "mpub", ")", "priv", "=", "b58d", "(", "priv", ")", "if", "int", "(", "priv", "[", "18", ":", "26", "]", ",", "16", ")", ">=", "2147483648", ":", ...
Input mpub is master xpub key string. Input priv is xprv string. Path is the path string (e.g. 'm/3/6/2') from the mpub to the priv. Path cannot contain any hardened keys.
[ "Input", "mpub", "is", "master", "xpub", "key", "string", ".", "Input", "priv", "is", "xprv", "string", ".", "Path", "is", "the", "path", "string", "(", "e", ".", "g", ".", "m", "/", "3", "/", "6", "/", "2", ")", "from", "the", "mpub", "to", "t...
train
https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/bip32.py#L196-L234
leonidessaguisagjr/pseudol10nutil
pseudol10nutil/pseudol10nutil.py
PseudoL10nUtil.pseudolocalize
def pseudolocalize(self, s): """ Performs pseudo-localization on a string. The specific transforms to be applied to the string is defined in the transforms field of the object. :param s: String to pseudo-localize. :returns: Copy of the string s with the transforms applied. If ...
python
def pseudolocalize(self, s): """ Performs pseudo-localization on a string. The specific transforms to be applied to the string is defined in the transforms field of the object. :param s: String to pseudo-localize. :returns: Copy of the string s with the transforms applied. If ...
[ "def", "pseudolocalize", "(", "self", ",", "s", ")", ":", "if", "not", "s", ":", "# If the string is empty or None", "return", "u\"\"", "if", "not", "isinstance", "(", "s", ",", "six", ".", "text_type", ")", ":", "raise", "TypeError", "(", "\"String to pseud...
Performs pseudo-localization on a string. The specific transforms to be applied to the string is defined in the transforms field of the object. :param s: String to pseudo-localize. :returns: Copy of the string s with the transforms applied. If the input string is an empty st...
[ "Performs", "pseudo", "-", "localization", "on", "a", "string", ".", "The", "specific", "transforms", "to", "be", "applied", "to", "the", "string", "is", "defined", "in", "the", "transforms", "field", "of", "the", "object", "." ]
train
https://github.com/leonidessaguisagjr/pseudol10nutil/blob/39cb0ae8cc5c1df5690816a18472e0366a49ab8d/pseudol10nutil/pseudol10nutil.py#L33-L77
leonidessaguisagjr/pseudol10nutil
pseudol10nutil/pseudol10nutil.py
POFileUtil.pseudolocalizefile
def pseudolocalizefile(self, input_filename, output_filename, input_encoding='UTF-8', output_encoding='UTF-8', overwrite_existing=True): """ Method for pseudo-localizing the message catalog file. :param input_filename: Filename of the source (input) message catalog fi...
python
def pseudolocalizefile(self, input_filename, output_filename, input_encoding='UTF-8', output_encoding='UTF-8', overwrite_existing=True): """ Method for pseudo-localizing the message catalog file. :param input_filename: Filename of the source (input) message catalog fi...
[ "def", "pseudolocalizefile", "(", "self", ",", "input_filename", ",", "output_filename", ",", "input_encoding", "=", "'UTF-8'", ",", "output_encoding", "=", "'UTF-8'", ",", "overwrite_existing", "=", "True", ")", ":", "leading_trailing_double_quotes", "=", "re", "."...
Method for pseudo-localizing the message catalog file. :param input_filename: Filename of the source (input) message catalog file. :param output_filename: Filename of the target (output) message catalog file. :param input_encoding: String indicating the encoding of the input file. Optional, de...
[ "Method", "for", "pseudo", "-", "localizing", "the", "message", "catalog", "file", "." ]
train
https://github.com/leonidessaguisagjr/pseudol10nutil/blob/39cb0ae8cc5c1df5690816a18472e0366a49ab8d/pseudol10nutil/pseudol10nutil.py#L98-L124
noobermin/lspreader
lspreader/pext.py
add_quantities
def add_quantities(d, coords=None, massE=0.511e6): ''' Add physically interesting quantities to pext data. Parameters: ----------- d : pext array Keywords: --------- coords : sequence of positions for angle calculation. None or by default, calculate no angle...
python
def add_quantities(d, coords=None, massE=0.511e6): ''' Add physically interesting quantities to pext data. Parameters: ----------- d : pext array Keywords: --------- coords : sequence of positions for angle calculation. None or by default, calculate no angle...
[ "def", "add_quantities", "(", "d", ",", "coords", "=", "None", ",", "massE", "=", "0.511e6", ")", ":", "keys", ",", "items", "=", "zip", "(", "*", "calc_quantities", "(", "d", ",", "coords", "=", "coords", ",", "massE", "=", "massE", ")", ".", "ite...
Add physically interesting quantities to pext data. Parameters: ----------- d : pext array Keywords: --------- coords : sequence of positions for angle calculation. None or by default, calculate no angles. For 2D, takes the angle depending on the orde...
[ "Add", "physically", "interesting", "quantities", "to", "pext", "data", "." ]
train
https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/pext.py#L8-L29
noobermin/lspreader
lspreader/pext.py
calc_quantities
def calc_quantities(d, coords=None, massE=0.511e6): ''' Calculate physically interesting quantities from pext Parameters: ----------- d : pext array Keywords: --------- coords : sequence of positions for angle calculation. None or by default, calculate no angles...
python
def calc_quantities(d, coords=None, massE=0.511e6): ''' Calculate physically interesting quantities from pext Parameters: ----------- d : pext array Keywords: --------- coords : sequence of positions for angle calculation. None or by default, calculate no angles...
[ "def", "calc_quantities", "(", "d", ",", "coords", "=", "None", ",", "massE", "=", "0.511e6", ")", ":", "quants", "=", "dict", "(", ")", "quants", "[", "'u_norm'", "]", "=", "np", ".", "sqrt", "(", "d", "[", "'ux'", "]", "**", "2", "+", "d", "[...
Calculate physically interesting quantities from pext Parameters: ----------- d : pext array Keywords: --------- coords : sequence of positions for angle calculation. None or by default, calculate no angles. For 2D, takes the angle depending on the order ...
[ "Calculate", "physically", "interesting", "quantities", "from", "pext" ]
train
https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/pext.py#L31-L61
aquatix/python-utilkit
utilkit/versionutil.py
get_repo_version
def get_repo_version(url): """ Get the current version on GitHub `url` looks like 'https://raw.githubusercontent.com/aquatix/ns-notifications/master/VERSION' """ response = requests.get(url) if response.status_code == 404: return None else: return response.text.replace('\n', ...
python
def get_repo_version(url): """ Get the current version on GitHub `url` looks like 'https://raw.githubusercontent.com/aquatix/ns-notifications/master/VERSION' """ response = requests.get(url) if response.status_code == 404: return None else: return response.text.replace('\n', ...
[ "def", "get_repo_version", "(", "url", ")", ":", "response", "=", "requests", ".", "get", "(", "url", ")", "if", "response", ".", "status_code", "==", "404", ":", "return", "None", "else", ":", "return", "response", ".", "text", ".", "replace", "(", "'...
Get the current version on GitHub `url` looks like 'https://raw.githubusercontent.com/aquatix/ns-notifications/master/VERSION'
[ "Get", "the", "current", "version", "on", "GitHub", "url", "looks", "like", "https", ":", "//", "raw", ".", "githubusercontent", ".", "com", "/", "aquatix", "/", "ns", "-", "notifications", "/", "master", "/", "VERSION" ]
train
https://github.com/aquatix/python-utilkit/blob/1b4a4175381d2175592208619315f399610f915c/utilkit/versionutil.py#L7-L16
mattupstate/cubric
cubric/tasks.py
create_server
def create_server(initialize=True): """Create a server""" with provider() as p: host_string = p.create_server() if initialize: env.host_string = host_string initialize_server()
python
def create_server(initialize=True): """Create a server""" with provider() as p: host_string = p.create_server() if initialize: env.host_string = host_string initialize_server()
[ "def", "create_server", "(", "initialize", "=", "True", ")", ":", "with", "provider", "(", ")", "as", "p", ":", "host_string", "=", "p", ".", "create_server", "(", ")", "if", "initialize", ":", "env", ".", "host_string", "=", "host_string", "initialize_ser...
Create a server
[ "Create", "a", "server" ]
train
https://github.com/mattupstate/cubric/blob/a648ce00e4467cd14d71e754240ef6c1f87a34b5/cubric/tasks.py#L11-L17
EnigmaBridge/client.py
ebclient/eb_registration.py
BaseRegistrationRequest.try_call
def try_call(self, client_data=None, api_data=None, aux_data=None, *args, **kwargs): """ Calls the request catching all exceptions :param client_data: :param api_data: :param aux_data: :param args: :param kwargs: :return: """ try: ...
python
def try_call(self, client_data=None, api_data=None, aux_data=None, *args, **kwargs): """ Calls the request catching all exceptions :param client_data: :param api_data: :param aux_data: :param args: :param kwargs: :return: """ try: ...
[ "def", "try_call", "(", "self", ",", "client_data", "=", "None", ",", "api_data", "=", "None", ",", "aux_data", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "self", ".", "call", "(", "client_data", ",", "a...
Calls the request catching all exceptions :param client_data: :param api_data: :param aux_data: :param args: :param kwargs: :return:
[ "Calls", "the", "request", "catching", "all", "exceptions", ":", "param", "client_data", ":", ":", "param", "api_data", ":", ":", "param", "aux_data", ":", ":", "param", "args", ":", ":", "param", "kwargs", ":", ":", "return", ":" ]
train
https://github.com/EnigmaBridge/client.py/blob/0fafe3902da394da88e9f960751d695ca65bbabd/ebclient/eb_registration.py#L46-L60
EnigmaBridge/client.py
ebclient/eb_registration.py
BaseRegistrationRequest.call
def call(self, client_data=None, api_data=None, aux_data=None, *args, **kwargs): """ Calls the request with input data using given configuration (retry, timeout, ...). :param client_data: :param api_data: :param aux_data: :param args: :param kwargs: :retur...
python
def call(self, client_data=None, api_data=None, aux_data=None, *args, **kwargs): """ Calls the request with input data using given configuration (retry, timeout, ...). :param client_data: :param api_data: :param aux_data: :param args: :param kwargs: :retur...
[ "def", "call", "(", "self", ",", "client_data", "=", "None", ",", "api_data", "=", "None", ",", "aux_data", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "build_request", "(", "client_data", "=", "client_data", ",", "...
Calls the request with input data using given configuration (retry, timeout, ...). :param client_data: :param api_data: :param aux_data: :param args: :param kwargs: :return:
[ "Calls", "the", "request", "with", "input", "data", "using", "given", "configuration", "(", "retry", "timeout", "...", ")", ".", ":", "param", "client_data", ":", ":", "param", "api_data", ":", ":", "param", "aux_data", ":", ":", "param", "args", ":", ":...
train
https://github.com/EnigmaBridge/client.py/blob/0fafe3902da394da88e9f960751d695ca65bbabd/ebclient/eb_registration.py#L62-L92
EnigmaBridge/client.py
ebclient/eb_registration.py
BaseRegistrationRequest.build_request
def build_request(self, input_data=None, api_data=None, aux_data=None, *args, **kwargs): """ Builds request :param input_data: :param api_data: :param aux_data: :param args: :param kwargs: :return: """ if input_data is not None: ...
python
def build_request(self, input_data=None, api_data=None, aux_data=None, *args, **kwargs): """ Builds request :param input_data: :param api_data: :param aux_data: :param args: :param kwargs: :return: """ if input_data is not None: ...
[ "def", "build_request", "(", "self", ",", "input_data", "=", "None", ",", "api_data", "=", "None", ",", "aux_data", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "input_data", "is", "not", "None", ":", "self", ".", "client_d...
Builds request :param input_data: :param api_data: :param aux_data: :param args: :param kwargs: :return:
[ "Builds", "request" ]
train
https://github.com/EnigmaBridge/client.py/blob/0fafe3902da394da88e9f960751d695ca65bbabd/ebclient/eb_registration.py#L100-L147
thomasbiddle/Kippt-for-Python
kippt/users.py
User.list
def list(self, list_id): """ Retrieve the list given for the user. """ r = requests.get( "https://kippt.com/api/users/%s/lists/%s" % (self.id, list_id), headers=self.kippt.header ) return (r.json())
python
def list(self, list_id): """ Retrieve the list given for the user. """ r = requests.get( "https://kippt.com/api/users/%s/lists/%s" % (self.id, list_id), headers=self.kippt.header ) return (r.json())
[ "def", "list", "(", "self", ",", "list_id", ")", ":", "r", "=", "requests", ".", "get", "(", "\"https://kippt.com/api/users/%s/lists/%s\"", "%", "(", "self", ".", "id", ",", "list_id", ")", ",", "headers", "=", "self", ".", "kippt", ".", "header", ")", ...
Retrieve the list given for the user.
[ "Retrieve", "the", "list", "given", "for", "the", "user", "." ]
train
https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/users.py#L148-L157
thomasbiddle/Kippt-for-Python
kippt/users.py
User.relationship
def relationship(self): """ Retrieve what the relationship between the user and then authenticated user is. """ r = requests.get( "https://kippt.com/api/users/%s/relationship" % (self.id), headers=self.kippt.header ) return (r.json())
python
def relationship(self): """ Retrieve what the relationship between the user and then authenticated user is. """ r = requests.get( "https://kippt.com/api/users/%s/relationship" % (self.id), headers=self.kippt.header ) return (r.json())
[ "def", "relationship", "(", "self", ")", ":", "r", "=", "requests", ".", "get", "(", "\"https://kippt.com/api/users/%s/relationship\"", "%", "(", "self", ".", "id", ")", ",", "headers", "=", "self", ".", "kippt", ".", "header", ")", "return", "(", "r", "...
Retrieve what the relationship between the user and then authenticated user is.
[ "Retrieve", "what", "the", "relationship", "between", "the", "user", "and", "then", "authenticated", "user", "is", "." ]
train
https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/users.py#L159-L168
thomasbiddle/Kippt-for-Python
kippt/users.py
User.follow
def follow(self): """ Follow a user." """ data = json.dumps({"action": "follow"}) r = requests.post( "https://kippt.com/api/users/%s/relationship" % (self.id), headers=self.kippt.header, data=data ) return (r.json())
python
def follow(self): """ Follow a user." """ data = json.dumps({"action": "follow"}) r = requests.post( "https://kippt.com/api/users/%s/relationship" % (self.id), headers=self.kippt.header, data=data ) return (r.json())
[ "def", "follow", "(", "self", ")", ":", "data", "=", "json", ".", "dumps", "(", "{", "\"action\"", ":", "\"follow\"", "}", ")", "r", "=", "requests", ".", "post", "(", "\"https://kippt.com/api/users/%s/relationship\"", "%", "(", "self", ".", "id", ")", "...
Follow a user."
[ "Follow", "a", "user", "." ]
train
https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/users.py#L170-L180
OpenGov/carpenter
carpenter/blocks/block.py
TableBlock._find_titles
def _find_titles(self, row_index, column_index): ''' Helper method to find all titles for a particular cell. ''' titles = [] for column_search in range(self.start[1], column_index): cell = self.table[row_index][column_search] if cell == None or (isinstanc...
python
def _find_titles(self, row_index, column_index): ''' Helper method to find all titles for a particular cell. ''' titles = [] for column_search in range(self.start[1], column_index): cell = self.table[row_index][column_search] if cell == None or (isinstanc...
[ "def", "_find_titles", "(", "self", ",", "row_index", ",", "column_index", ")", ":", "titles", "=", "[", "]", "for", "column_search", "in", "range", "(", "self", ".", "start", "[", "1", "]", ",", "column_index", ")", ":", "cell", "=", "self", ".", "t...
Helper method to find all titles for a particular cell.
[ "Helper", "method", "to", "find", "all", "titles", "for", "a", "particular", "cell", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L52-L76
OpenGov/carpenter
carpenter/blocks/block.py
TableBlock.copy_raw_block
def copy_raw_block(self): ''' Copies the block as it was originally specified by start and end into a new table. Returns: A copy of the block with no block transformations. ''' ctable = [] r, c = 0, 0 try: for row_index in range(self.start...
python
def copy_raw_block(self): ''' Copies the block as it was originally specified by start and end into a new table. Returns: A copy of the block with no block transformations. ''' ctable = [] r, c = 0, 0 try: for row_index in range(self.start...
[ "def", "copy_raw_block", "(", "self", ")", ":", "ctable", "=", "[", "]", "r", ",", "c", "=", "0", ",", "0", "try", ":", "for", "row_index", "in", "range", "(", "self", ".", "start", "[", "0", "]", ",", "self", ".", "end", "[", "0", "]", ")", ...
Copies the block as it was originally specified by start and end into a new table. Returns: A copy of the block with no block transformations.
[ "Copies", "the", "block", "as", "it", "was", "originally", "specified", "by", "start", "and", "end", "into", "a", "new", "table", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L78-L97
OpenGov/carpenter
carpenter/blocks/block.py
TableBlock.copy_numbered_block
def copy_numbered_block(self): ''' Copies the block as it was originally specified by start and end into a new table. Additionally inserts the original table indices in the first row of the block. Returns: A copy of the block with no block transformations. ''' ...
python
def copy_numbered_block(self): ''' Copies the block as it was originally specified by start and end into a new table. Additionally inserts the original table indices in the first row of the block. Returns: A copy of the block with no block transformations. ''' ...
[ "def", "copy_numbered_block", "(", "self", ")", ":", "raw_block", "=", "self", ".", "copy_raw_block", "(", ")", "# Inserts the column number in row 0", "raw_block", ".", "insert", "(", "0", ",", "range", "(", "self", ".", "start", "[", "1", "]", ",", "self",...
Copies the block as it was originally specified by start and end into a new table. Additionally inserts the original table indices in the first row of the block. Returns: A copy of the block with no block transformations.
[ "Copies", "the", "block", "as", "it", "was", "originally", "specified", "by", "start", "and", "end", "into", "a", "new", "table", ".", "Additionally", "inserts", "the", "original", "table", "indices", "in", "the", "first", "row", "of", "the", "block", "." ...
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L99-L110
OpenGov/carpenter
carpenter/blocks/block.py
TableBlock.convert_to_row_table
def convert_to_row_table(self, add_units=True): ''' Converts the block into row titled elements. These elements are copied into the return table, which can be much longer than the original block. Args: add_units: Indicates if units should be appened to each row item. ...
python
def convert_to_row_table(self, add_units=True): ''' Converts the block into row titled elements. These elements are copied into the return table, which can be much longer than the original block. Args: add_units: Indicates if units should be appened to each row item. ...
[ "def", "convert_to_row_table", "(", "self", ",", "add_units", "=", "True", ")", ":", "rtable", "=", "[", "]", "if", "add_units", ":", "relavent_units", "=", "self", ".", "get_relavent_units", "(", ")", "# Create a row for each data element", "for", "row_index", ...
Converts the block into row titled elements. These elements are copied into the return table, which can be much longer than the original block. Args: add_units: Indicates if units should be appened to each row item. Returns: A row-titled table representing the data in ...
[ "Converts", "the", "block", "into", "row", "titled", "elements", ".", "These", "elements", "are", "copied", "into", "the", "return", "table", "which", "can", "be", "much", "longer", "than", "the", "original", "block", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L112-L148
OpenGov/carpenter
carpenter/blocks/block.py
TableBlock.flag_is_related
def flag_is_related(self, flag): ''' Checks for relationship between a flag and this block. Returns: True if the flag is related to this block. ''' same_worksheet = flag.worksheet == self.worksheet if isinstance(flag.location, (tuple, list)): retu...
python
def flag_is_related(self, flag): ''' Checks for relationship between a flag and this block. Returns: True if the flag is related to this block. ''' same_worksheet = flag.worksheet == self.worksheet if isinstance(flag.location, (tuple, list)): retu...
[ "def", "flag_is_related", "(", "self", ",", "flag", ")", ":", "same_worksheet", "=", "flag", ".", "worksheet", "==", "self", ".", "worksheet", "if", "isinstance", "(", "flag", ".", "location", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "(...
Checks for relationship between a flag and this block. Returns: True if the flag is related to this block.
[ "Checks", "for", "relationship", "between", "a", "flag", "and", "this", "block", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L150-L163
OpenGov/carpenter
carpenter/blocks/block.py
TableBlock.unit_is_related
def unit_is_related(self, location, worksheet): ''' Checks for relationship between a unit location and this block. Returns: True if the location is related to this block. ''' same_worksheet = worksheet == self.worksheet if isinstance(location, (tuple, list))...
python
def unit_is_related(self, location, worksheet): ''' Checks for relationship between a unit location and this block. Returns: True if the location is related to this block. ''' same_worksheet = worksheet == self.worksheet if isinstance(location, (tuple, list))...
[ "def", "unit_is_related", "(", "self", ",", "location", ",", "worksheet", ")", ":", "same_worksheet", "=", "worksheet", "==", "self", ".", "worksheet", "if", "isinstance", "(", "location", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "(", "lo...
Checks for relationship between a unit location and this block. Returns: True if the location is related to this block.
[ "Checks", "for", "relationship", "between", "a", "unit", "location", "and", "this", "block", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L165-L178
OpenGov/carpenter
carpenter/blocks/block.py
TableBlock.get_relavent_flags
def get_relavent_flags(self): ''' Retrieves the relevant flags for this data block. Returns: All flags related to this block. ''' relavent_flags = {} for code, flags_list in self.flags.items(): relavent_flags[code] = [] for flag in fl...
python
def get_relavent_flags(self): ''' Retrieves the relevant flags for this data block. Returns: All flags related to this block. ''' relavent_flags = {} for code, flags_list in self.flags.items(): relavent_flags[code] = [] for flag in fl...
[ "def", "get_relavent_flags", "(", "self", ")", ":", "relavent_flags", "=", "{", "}", "for", "code", ",", "flags_list", "in", "self", ".", "flags", ".", "items", "(", ")", ":", "relavent_flags", "[", "code", "]", "=", "[", "]", "for", "flag", "in", "f...
Retrieves the relevant flags for this data block. Returns: All flags related to this block.
[ "Retrieves", "the", "relevant", "flags", "for", "this", "data", "block", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L180-L198
OpenGov/carpenter
carpenter/blocks/block.py
TableBlock.get_relavent_units
def get_relavent_units(self): ''' Retrieves the relevant units for this data block. Returns: All flags related to this block. ''' relavent_units = {} for location,unit in self.units.items(): if self.unit_is_related(location, self.worksheet): ...
python
def get_relavent_units(self): ''' Retrieves the relevant units for this data block. Returns: All flags related to this block. ''' relavent_units = {} for location,unit in self.units.items(): if self.unit_is_related(location, self.worksheet): ...
[ "def", "get_relavent_units", "(", "self", ")", ":", "relavent_units", "=", "{", "}", "for", "location", ",", "unit", "in", "self", ".", "units", ".", "items", "(", ")", ":", "if", "self", ".", "unit_is_related", "(", "location", ",", "self", ".", "work...
Retrieves the relevant units for this data block. Returns: All flags related to this block.
[ "Retrieves", "the", "relevant", "units", "for", "this", "data", "block", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L200-L213
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator.validate_block
def validate_block(self): ''' This method is a multi-stage process which repairs row titles, then repairs column titles, then checks for invalid rows, and finally for invalid columns. This maybe should have been written via state machines... Also suggested as being possibly writ...
python
def validate_block(self): ''' This method is a multi-stage process which repairs row titles, then repairs column titles, then checks for invalid rows, and finally for invalid columns. This maybe should have been written via state machines... Also suggested as being possibly writ...
[ "def", "validate_block", "(", "self", ")", ":", "# Don't allow for 0 width or 0 height blocks", "if", "self", ".", "_check_zero_size", "(", ")", ":", "return", "False", "# Single width or height blocks should be considered", "self", ".", "_check_one_size", "(", ")", "# Re...
This method is a multi-stage process which repairs row titles, then repairs column titles, then checks for invalid rows, and finally for invalid columns. This maybe should have been written via state machines... Also suggested as being possibly written with code-injection.
[ "This", "method", "is", "a", "multi", "-", "stage", "process", "which", "repairs", "row", "titles", "then", "repairs", "column", "titles", "then", "checks", "for", "invalid", "rows", "and", "finally", "for", "invalid", "columns", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L246-L275
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._check_zero_size
def _check_zero_size(self): ''' Checks for zero height or zero width blocks and flags the occurrence. Returns: True if the block is size 0. ''' block_zero = self.end[0] <= self.start[0] or self.end[1] <= self.start[1] if block_zero: self.flag_chan...
python
def _check_zero_size(self): ''' Checks for zero height or zero width blocks and flags the occurrence. Returns: True if the block is size 0. ''' block_zero = self.end[0] <= self.start[0] or self.end[1] <= self.start[1] if block_zero: self.flag_chan...
[ "def", "_check_zero_size", "(", "self", ")", ":", "block_zero", "=", "self", ".", "end", "[", "0", "]", "<=", "self", ".", "start", "[", "0", "]", "or", "self", ".", "end", "[", "1", "]", "<=", "self", ".", "start", "[", "1", "]", "if", "block_...
Checks for zero height or zero width blocks and flags the occurrence. Returns: True if the block is size 0.
[ "Checks", "for", "zero", "height", "or", "zero", "width", "blocks", "and", "flags", "the", "occurrence", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L277-L288
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._check_one_size
def _check_one_size(self): ''' Checks for single height or single width blocks and flags the occurrence. Returns: True if the block is size 1. ''' block_one = self.end[0] == self.start[0]+1 or self.end[1] == self.start[1]+1 if block_one: self.flag...
python
def _check_one_size(self): ''' Checks for single height or single width blocks and flags the occurrence. Returns: True if the block is size 1. ''' block_one = self.end[0] == self.start[0]+1 or self.end[1] == self.start[1]+1 if block_one: self.flag...
[ "def", "_check_one_size", "(", "self", ")", ":", "block_one", "=", "self", ".", "end", "[", "0", "]", "==", "self", ".", "start", "[", "0", "]", "+", "1", "or", "self", ".", "end", "[", "1", "]", "==", "self", ".", "start", "[", "1", "]", "+"...
Checks for single height or single width blocks and flags the occurrence. Returns: True if the block is size 1.
[ "Checks", "for", "single", "height", "or", "single", "width", "blocks", "and", "flags", "the", "occurrence", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L290-L301
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._repair_row
def _repair_row(self): ''' Searches for missing titles that can be inferred from the surrounding data and automatically repairs those titles. ''' # Repair any title rows check_for_title = True for row_index in range(self.start[0], self.end[0]): table_r...
python
def _repair_row(self): ''' Searches for missing titles that can be inferred from the surrounding data and automatically repairs those titles. ''' # Repair any title rows check_for_title = True for row_index in range(self.start[0], self.end[0]): table_r...
[ "def", "_repair_row", "(", "self", ")", ":", "# Repair any title rows", "check_for_title", "=", "True", "for", "row_index", "in", "range", "(", "self", ".", "start", "[", "0", "]", ",", "self", ".", "end", "[", "0", "]", ")", ":", "table_row", "=", "se...
Searches for missing titles that can be inferred from the surrounding data and automatically repairs those titles.
[ "Searches", "for", "missing", "titles", "that", "can", "be", "inferred", "from", "the", "surrounding", "data", "and", "automatically", "repairs", "those", "titles", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L303-L322
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._repair_column
def _repair_column(self): ''' Same as _repair_row but for columns. ''' # Repair any title columns check_for_title = True for column_index in range(self.start[1], self.end[1]): table_column = TableTranspose(self.table)[column_index] column_start = t...
python
def _repair_column(self): ''' Same as _repair_row but for columns. ''' # Repair any title columns check_for_title = True for column_index in range(self.start[1], self.end[1]): table_column = TableTranspose(self.table)[column_index] column_start = t...
[ "def", "_repair_column", "(", "self", ")", ":", "# Repair any title columns", "check_for_title", "=", "True", "for", "column_index", "in", "range", "(", "self", ".", "start", "[", "1", "]", ",", "self", ".", "end", "[", "1", "]", ")", ":", "table_column", ...
Same as _repair_row but for columns.
[ "Same", "as", "_repair_row", "but", "for", "columns", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L324-L342
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._fill_row_holes
def _fill_row_holes(self): ''' Fill any remaining row title cells that are empty. This must be done after the other passes to avoid preemptively filling in empty cells reserved for other operations. ''' for row_index in range(self.start[0], self.max_title_row): table_...
python
def _fill_row_holes(self): ''' Fill any remaining row title cells that are empty. This must be done after the other passes to avoid preemptively filling in empty cells reserved for other operations. ''' for row_index in range(self.start[0], self.max_title_row): table_...
[ "def", "_fill_row_holes", "(", "self", ")", ":", "for", "row_index", "in", "range", "(", "self", ".", "start", "[", "0", "]", ",", "self", ".", "max_title_row", ")", ":", "table_row", "=", "self", ".", "table", "[", "row_index", "]", "row_start", "=", ...
Fill any remaining row title cells that are empty. This must be done after the other passes to avoid preemptively filling in empty cells reserved for other operations.
[ "Fill", "any", "remaining", "row", "title", "cells", "that", "are", "empty", ".", "This", "must", "be", "done", "after", "the", "other", "passes", "to", "avoid", "preemptively", "filling", "in", "empty", "cells", "reserved", "for", "other", "operations", "."...
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L344-L353
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._fill_column_holes
def _fill_column_holes(self): ''' Same as _fill_row_holes but for columns. ''' for column_index in range(self.start[1], self.end[1]): table_column = TableTranspose(self.table)[column_index] column_start = table_column[self.start[0]] if is_text_cell(col...
python
def _fill_column_holes(self): ''' Same as _fill_row_holes but for columns. ''' for column_index in range(self.start[1], self.end[1]): table_column = TableTranspose(self.table)[column_index] column_start = table_column[self.start[0]] if is_text_cell(col...
[ "def", "_fill_column_holes", "(", "self", ")", ":", "for", "column_index", "in", "range", "(", "self", ".", "start", "[", "1", "]", ",", "self", ".", "end", "[", "1", "]", ")", ":", "table_column", "=", "TableTranspose", "(", "self", ".", "table", ")...
Same as _fill_row_holes but for columns.
[ "Same", "as", "_fill_row_holes", "but", "for", "columns", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L355-L363
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._validate_rows
def _validate_rows(self): ''' Checks for any missing data row by row. It also checks for changes in cell type and flags multiple switches as an error. ''' for row_index in range(self.start[0], self.end[0]): table_row = self.table[row_index] used_row = self...
python
def _validate_rows(self): ''' Checks for any missing data row by row. It also checks for changes in cell type and flags multiple switches as an error. ''' for row_index in range(self.start[0], self.end[0]): table_row = self.table[row_index] used_row = self...
[ "def", "_validate_rows", "(", "self", ")", ":", "for", "row_index", "in", "range", "(", "self", ".", "start", "[", "0", "]", ",", "self", ".", "end", "[", "0", "]", ")", ":", "table_row", "=", "self", ".", "table", "[", "row_index", "]", "used_row"...
Checks for any missing data row by row. It also checks for changes in cell type and flags multiple switches as an error.
[ "Checks", "for", "any", "missing", "data", "row", "by", "row", ".", "It", "also", "checks", "for", "changes", "in", "cell", "type", "and", "flags", "multiple", "switches", "as", "an", "error", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L365-L392
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._validate_columns
def _validate_columns(self): ''' Same as _validate_rows but for columns. Also ignore used_cells as _validate_rows should update used_cells. ''' for column_index in range(self.start[1], self.end[1]): table_column = TableTranspose(self.table)[column_index] ...
python
def _validate_columns(self): ''' Same as _validate_rows but for columns. Also ignore used_cells as _validate_rows should update used_cells. ''' for column_index in range(self.start[1], self.end[1]): table_column = TableTranspose(self.table)[column_index] ...
[ "def", "_validate_columns", "(", "self", ")", ":", "for", "column_index", "in", "range", "(", "self", ".", "start", "[", "1", "]", ",", "self", ".", "end", "[", "1", "]", ")", ":", "table_column", "=", "TableTranspose", "(", "self", ".", "table", ")"...
Same as _validate_rows but for columns. Also ignore used_cells as _validate_rows should update used_cells.
[ "Same", "as", "_validate_rows", "but", "for", "columns", ".", "Also", "ignore", "used_cells", "as", "_validate_rows", "should", "update", "used_cells", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L394-L415
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._stringify_row
def _stringify_row(self, row_index): ''' Stringifies an entire row, filling in blanks with prior titles as they are found. ''' table_row = self.table[row_index] prior_cell = None for column_index in range(self.start[1], self.end[1]): cell, changed = self._chec...
python
def _stringify_row(self, row_index): ''' Stringifies an entire row, filling in blanks with prior titles as they are found. ''' table_row = self.table[row_index] prior_cell = None for column_index in range(self.start[1], self.end[1]): cell, changed = self._chec...
[ "def", "_stringify_row", "(", "self", ",", "row_index", ")", ":", "table_row", "=", "self", ".", "table", "[", "row_index", "]", "prior_cell", "=", "None", "for", "column_index", "in", "range", "(", "self", ".", "start", "[", "1", "]", ",", "self", "."...
Stringifies an entire row, filling in blanks with prior titles as they are found.
[ "Stringifies", "an", "entire", "row", "filling", "in", "blanks", "with", "prior", "titles", "as", "they", "are", "found", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L417-L427
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._stringify_column
def _stringify_column(self, column_index): ''' Same as _stringify_row but for columns. ''' table_column = TableTranspose(self.table)[column_index] prior_cell = None for row_index in range(self.start[0], self.end[0]): cell, changed = self._check_interpret_cell(...
python
def _stringify_column(self, column_index): ''' Same as _stringify_row but for columns. ''' table_column = TableTranspose(self.table)[column_index] prior_cell = None for row_index in range(self.start[0], self.end[0]): cell, changed = self._check_interpret_cell(...
[ "def", "_stringify_column", "(", "self", ",", "column_index", ")", ":", "table_column", "=", "TableTranspose", "(", "self", ".", "table", ")", "[", "column_index", "]", "prior_cell", "=", "None", "for", "row_index", "in", "range", "(", "self", ".", "start", ...
Same as _stringify_row but for columns.
[ "Same", "as", "_stringify_row", "but", "for", "columns", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L429-L439
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._check_interpret_cell
def _check_interpret_cell(self, cell, prior_cell, row_index, column_index): ''' Helper function which checks cell type and performs cell translation to strings where necessary. Returns: A tuple of the form '(cell, changed)' where 'changed' indicates if 'cell' differs from ...
python
def _check_interpret_cell(self, cell, prior_cell, row_index, column_index): ''' Helper function which checks cell type and performs cell translation to strings where necessary. Returns: A tuple of the form '(cell, changed)' where 'changed' indicates if 'cell' differs from ...
[ "def", "_check_interpret_cell", "(", "self", ",", "cell", ",", "prior_cell", ",", "row_index", ",", "column_index", ")", ":", "changed", "=", "False", "if", "(", "not", "is_empty_cell", "(", "cell", ")", "and", "not", "is_text_cell", "(", "cell", ")", ")",...
Helper function which checks cell type and performs cell translation to strings where necessary. Returns: A tuple of the form '(cell, changed)' where 'changed' indicates if 'cell' differs from input.
[ "Helper", "function", "which", "checks", "cell", "type", "and", "performs", "cell", "translation", "to", "strings", "where", "necessary", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L441-L463
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._check_fill_title_row
def _check_fill_title_row(self, row_index): ''' Checks the given row to see if it is all titles and fills any blanks cells if that is the case. ''' table_row = self.table[row_index] # Determine if the whole row is titles prior_row = self.table[row_index-1] if row_...
python
def _check_fill_title_row(self, row_index): ''' Checks the given row to see if it is all titles and fills any blanks cells if that is the case. ''' table_row = self.table[row_index] # Determine if the whole row is titles prior_row = self.table[row_index-1] if row_...
[ "def", "_check_fill_title_row", "(", "self", ",", "row_index", ")", ":", "table_row", "=", "self", ".", "table", "[", "row_index", "]", "# Determine if the whole row is titles", "prior_row", "=", "self", ".", "table", "[", "row_index", "-", "1", "]", "if", "ro...
Checks the given row to see if it is all titles and fills any blanks cells if that is the case.
[ "Checks", "the", "given", "row", "to", "see", "if", "it", "is", "all", "titles", "and", "fills", "any", "blanks", "cells", "if", "that", "is", "the", "case", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L465-L477
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._check_fill_title_column
def _check_fill_title_column(self, column_index): ''' Same as _check_fill_title_row but for columns. ''' # Determine if the whole column is titles table_column = TableTranspose(self.table)[column_index] prior_column = TableTranspose(self.table)[column_index-1] if column_i...
python
def _check_fill_title_column(self, column_index): ''' Same as _check_fill_title_row but for columns. ''' # Determine if the whole column is titles table_column = TableTranspose(self.table)[column_index] prior_column = TableTranspose(self.table)[column_index-1] if column_i...
[ "def", "_check_fill_title_column", "(", "self", ",", "column_index", ")", ":", "# Determine if the whole column is titles", "table_column", "=", "TableTranspose", "(", "self", ".", "table", ")", "[", "column_index", "]", "prior_column", "=", "TableTranspose", "(", "se...
Same as _check_fill_title_row but for columns.
[ "Same", "as", "_check_fill_title_row", "but", "for", "columns", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L479-L490
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._check_stringify_year_row
def _check_stringify_year_row(self, row_index): ''' Checks the given row to see if it is labeled year data and fills any blank years within that data. ''' table_row = self.table[row_index] # State trackers prior_year = None for column_index in range(self.s...
python
def _check_stringify_year_row(self, row_index): ''' Checks the given row to see if it is labeled year data and fills any blank years within that data. ''' table_row = self.table[row_index] # State trackers prior_year = None for column_index in range(self.s...
[ "def", "_check_stringify_year_row", "(", "self", ",", "row_index", ")", ":", "table_row", "=", "self", ".", "table", "[", "row_index", "]", "# State trackers", "prior_year", "=", "None", "for", "column_index", "in", "range", "(", "self", ".", "start", "[", "...
Checks the given row to see if it is labeled year data and fills any blank years within that data.
[ "Checks", "the", "given", "row", "to", "see", "if", "it", "is", "labeled", "year", "data", "and", "fills", "any", "blank", "years", "within", "that", "data", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L492-L510
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._check_stringify_year_column
def _check_stringify_year_column(self, column_index): ''' Same as _check_stringify_year_row but for columns. ''' table_column = TableTranspose(self.table)[column_index] # State trackers prior_year = None for row_index in range(self.start[0]+1, self.end[0]): ...
python
def _check_stringify_year_column(self, column_index): ''' Same as _check_stringify_year_row but for columns. ''' table_column = TableTranspose(self.table)[column_index] # State trackers prior_year = None for row_index in range(self.start[0]+1, self.end[0]): ...
[ "def", "_check_stringify_year_column", "(", "self", ",", "column_index", ")", ":", "table_column", "=", "TableTranspose", "(", "self", ".", "table", ")", "[", "column_index", "]", "# State trackers", "prior_year", "=", "None", "for", "row_index", "in", "range", ...
Same as _check_stringify_year_row but for columns.
[ "Same", "as", "_check_stringify_year_row", "but", "for", "columns", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L512-L528
OpenGov/carpenter
carpenter/blocks/block.py
BlockValidator._check_years
def _check_years(self, cell, prior_year): ''' Helper method which defines the rules for checking for existence of a year indicator. If the cell is blank then prior_year is used to determine validity. ''' # Anything outside these values shouldn't auto # categorize to strin...
python
def _check_years(self, cell, prior_year): ''' Helper method which defines the rules for checking for existence of a year indicator. If the cell is blank then prior_year is used to determine validity. ''' # Anything outside these values shouldn't auto # categorize to strin...
[ "def", "_check_years", "(", "self", ",", "cell", ",", "prior_year", ")", ":", "# Anything outside these values shouldn't auto", "# categorize to strings", "min_year", "=", "1900", "max_year", "=", "2100", "# Empty cells could represent the prior cell's title,", "# but an empty ...
Helper method which defines the rules for checking for existence of a year indicator. If the cell is blank then prior_year is used to determine validity.
[ "Helper", "method", "which", "defines", "the", "rules", "for", "checking", "for", "existence", "of", "a", "year", "indicator", ".", "If", "the", "cell", "is", "blank", "then", "prior_year", "is", "used", "to", "determine", "validity", "." ]
train
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L530-L545
FlorianLudwig/rueckenwind
rw/static.py
file_hash
def file_hash(content): """Generate hash for file or string and avoid strings starting with "ad" to workaround ad blocks being over aggressiv. The current implementation is based on sha256. :param str|FileIO content: The content to hash, either as string or as file-like object """ h =...
python
def file_hash(content): """Generate hash for file or string and avoid strings starting with "ad" to workaround ad blocks being over aggressiv. The current implementation is based on sha256. :param str|FileIO content: The content to hash, either as string or as file-like object """ h =...
[ "def", "file_hash", "(", "content", ")", ":", "h", "=", "hashlib", ".", "sha256", "(", ")", "if", "isinstance", "(", "content", ",", "bytes_type", ")", ":", "h", ".", "update", "(", "content", ")", "else", ":", "data", "=", "True", "while", "data", ...
Generate hash for file or string and avoid strings starting with "ad" to workaround ad blocks being over aggressiv. The current implementation is based on sha256. :param str|FileIO content: The content to hash, either as string or as file-like object
[ "Generate", "hash", "for", "file", "or", "string", "and", "avoid", "strings", "starting", "with", "ad", "to", "workaround", "ad", "blocks", "being", "over", "aggressiv", "." ]
train
https://github.com/FlorianLudwig/rueckenwind/blob/47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea/rw/static.py#L68-L104
FlorianLudwig/rueckenwind
rw/static.py
init
def init(scope, app, settings): """Plugin for serving static files in development mode""" cfg = settings.get('rw.static', {}) static = Static() scope['static'] = static scope['template_env'].globals['static'] = static for base_uri, sources in cfg.items(): full_paths = [] for sour...
python
def init(scope, app, settings): """Plugin for serving static files in development mode""" cfg = settings.get('rw.static', {}) static = Static() scope['static'] = static scope['template_env'].globals['static'] = static for base_uri, sources in cfg.items(): full_paths = [] for sour...
[ "def", "init", "(", "scope", ",", "app", ",", "settings", ")", ":", "cfg", "=", "settings", ".", "get", "(", "'rw.static'", ",", "{", "}", ")", "static", "=", "Static", "(", ")", "scope", "[", "'static'", "]", "=", "static", "scope", "[", "'templat...
Plugin for serving static files in development mode
[ "Plugin", "for", "serving", "static", "files", "in", "development", "mode" ]
train
https://github.com/FlorianLudwig/rueckenwind/blob/47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea/rw/static.py#L151-L178
FlorianLudwig/rueckenwind
rw/static.py
StaticHandler.get_absolute_path
def get_absolute_path(cls, roots, path): """Returns the absolute location of ``path`` relative to one of the ``roots``. ``roots`` is the path configured for this `StaticFileHandler` (in most cases the ``static_path`` `Application` setting). """ for root in roots: ...
python
def get_absolute_path(cls, roots, path): """Returns the absolute location of ``path`` relative to one of the ``roots``. ``roots`` is the path configured for this `StaticFileHandler` (in most cases the ``static_path`` `Application` setting). """ for root in roots: ...
[ "def", "get_absolute_path", "(", "cls", ",", "roots", ",", "path", ")", ":", "for", "root", "in", "roots", ":", "abspath", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "root", ",", "path", ")", ")", "if", "abs...
Returns the absolute location of ``path`` relative to one of the ``roots``. ``roots`` is the path configured for this `StaticFileHandler` (in most cases the ``static_path`` `Application` setting).
[ "Returns", "the", "absolute", "location", "of", "path", "relative", "to", "one", "of", "the", "roots", "." ]
train
https://github.com/FlorianLudwig/rueckenwind/blob/47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea/rw/static.py#L25-L37
FlorianLudwig/rueckenwind
rw/static.py
StaticHandler.validate_absolute_path
def validate_absolute_path(self, roots, absolute_path): """Validate and return the absolute path. ``root`` is the configured path for the `StaticFileHandler`, and ``path`` is the result of `get_absolute_path` This is an instance method called during request processing, so it ma...
python
def validate_absolute_path(self, roots, absolute_path): """Validate and return the absolute path. ``root`` is the configured path for the `StaticFileHandler`, and ``path`` is the result of `get_absolute_path` This is an instance method called during request processing, so it ma...
[ "def", "validate_absolute_path", "(", "self", ",", "roots", ",", "absolute_path", ")", ":", "if", "absolute_path", "is", "None", ":", "raise", "tornado", ".", "web", ".", "HTTPError", "(", "404", ")", "for", "root", "in", "roots", ":", "if", "(", "absolu...
Validate and return the absolute path. ``root`` is the configured path for the `StaticFileHandler`, and ``path`` is the result of `get_absolute_path` This is an instance method called during request processing, so it may raise `HTTPError` or use methods like `RequestHandler.red...
[ "Validate", "and", "return", "the", "absolute", "path", "." ]
train
https://github.com/FlorianLudwig/rueckenwind/blob/47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea/rw/static.py#L39-L65
BlueHack-Core/blueforge
blueforge/apis/s3.py
S3.upload_file_to_bucket
def upload_file_to_bucket(self, bucket, file_path, key, is_public=False): """ Upload files to S3 Bucket """ with open(file_path, 'rb') as data: self.__s3.upload_fileobj(data, bucket, key) if is_public: self.__s3.put_object_acl(ACL='public-read', Bucket=bucket, Key=key) ...
python
def upload_file_to_bucket(self, bucket, file_path, key, is_public=False): """ Upload files to S3 Bucket """ with open(file_path, 'rb') as data: self.__s3.upload_fileobj(data, bucket, key) if is_public: self.__s3.put_object_acl(ACL='public-read', Bucket=bucket, Key=key) ...
[ "def", "upload_file_to_bucket", "(", "self", ",", "bucket", ",", "file_path", ",", "key", ",", "is_public", "=", "False", ")", ":", "with", "open", "(", "file_path", ",", "'rb'", ")", "as", "data", ":", "self", ".", "__s3", ".", "upload_fileobj", "(", ...
Upload files to S3 Bucket
[ "Upload", "files", "to", "S3", "Bucket" ]
train
https://github.com/BlueHack-Core/blueforge/blob/ac40a888ee9c388638a8f312c51f7500b8891b6c/blueforge/apis/s3.py#L8-L23
BlueHack-Core/blueforge
blueforge/apis/s3.py
S3.download_file_from_bucket
def download_file_from_bucket(self, bucket, file_path, key): """ Download file from S3 Bucket """ with open(file_path, 'wb') as data: self.__s3.download_fileobj(bucket, key, data) return file_path
python
def download_file_from_bucket(self, bucket, file_path, key): """ Download file from S3 Bucket """ with open(file_path, 'wb') as data: self.__s3.download_fileobj(bucket, key, data) return file_path
[ "def", "download_file_from_bucket", "(", "self", ",", "bucket", ",", "file_path", ",", "key", ")", ":", "with", "open", "(", "file_path", ",", "'wb'", ")", "as", "data", ":", "self", ".", "__s3", ".", "download_fileobj", "(", "bucket", ",", "key", ",", ...
Download file from S3 Bucket
[ "Download", "file", "from", "S3", "Bucket" ]
train
https://github.com/BlueHack-Core/blueforge/blob/ac40a888ee9c388638a8f312c51f7500b8891b6c/blueforge/apis/s3.py#L25-L29
edwards-lab/libGWAS
libgwas/parsed_locus.py
ParsedLocus.next
def next(self): """Move to the next valid locus. Will only return valid loci or exit via StopIteration exception """ while True: self.cur_idx += 1 if self.__datasource.populate_iteration(self): return self raise StopIteration
python
def next(self): """Move to the next valid locus. Will only return valid loci or exit via StopIteration exception """ while True: self.cur_idx += 1 if self.__datasource.populate_iteration(self): return self raise StopIteration
[ "def", "next", "(", "self", ")", ":", "while", "True", ":", "self", ".", "cur_idx", "+=", "1", "if", "self", ".", "__datasource", ".", "populate_iteration", "(", "self", ")", ":", "return", "self", "raise", "StopIteration" ]
Move to the next valid locus. Will only return valid loci or exit via StopIteration exception
[ "Move", "to", "the", "next", "valid", "locus", "." ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/parsed_locus.py#L38-L49
tBaxter/tango-shared-core
build/lib/tango_shared/templatetags/formatting.py
replace
def replace(value, arg): """ Replaces one string with another in a given string usage: {{ foo|replace:"aaa|xxx"}} """ replacement = arg.split('|') try: return value.replace(replacement[0], replacement[1]) except: return value
python
def replace(value, arg): """ Replaces one string with another in a given string usage: {{ foo|replace:"aaa|xxx"}} """ replacement = arg.split('|') try: return value.replace(replacement[0], replacement[1]) except: return value
[ "def", "replace", "(", "value", ",", "arg", ")", ":", "replacement", "=", "arg", ".", "split", "(", "'|'", ")", "try", ":", "return", "value", ".", "replace", "(", "replacement", "[", "0", "]", ",", "replacement", "[", "1", "]", ")", "except", ":",...
Replaces one string with another in a given string usage: {{ foo|replace:"aaa|xxx"}}
[ "Replaces", "one", "string", "with", "another", "in", "a", "given", "string", "usage", ":", "{{", "foo|replace", ":", "aaa|xxx", "}}" ]
train
https://github.com/tBaxter/tango-shared-core/blob/35fc10aef1ceedcdb4d6d866d44a22efff718812/build/lib/tango_shared/templatetags/formatting.py#L12-L22
tBaxter/tango-shared-core
build/lib/tango_shared/templatetags/formatting.py
humanized_join
def humanized_join(value, add_links=False): """ Given a list of strings, format them with commas and spaces, but with 'and' at the end. >>> humanized_join(['apples', 'oranges', 'pears']) "apples, oranges, and pears" In a template, if mylist = ['apples', 'oranges', 'pears'] then {{ mylist|h...
python
def humanized_join(value, add_links=False): """ Given a list of strings, format them with commas and spaces, but with 'and' at the end. >>> humanized_join(['apples', 'oranges', 'pears']) "apples, oranges, and pears" In a template, if mylist = ['apples', 'oranges', 'pears'] then {{ mylist|h...
[ "def", "humanized_join", "(", "value", ",", "add_links", "=", "False", ")", ":", "if", "add_links", ":", "try", ":", "value", "=", "[", "'<a href=\"%s\">%s</a>'", "%", "(", "item", ".", "get_absolute_url", "(", ")", ",", "item", ")", "for", "item", "in",...
Given a list of strings, format them with commas and spaces, but with 'and' at the end. >>> humanized_join(['apples', 'oranges', 'pears']) "apples, oranges, and pears" In a template, if mylist = ['apples', 'oranges', 'pears'] then {{ mylist|humanized_join }} will output "apples, oranges, and p...
[ "Given", "a", "list", "of", "strings", "format", "them", "with", "commas", "and", "spaces", "but", "with", "and", "at", "the", "end", "." ]
train
https://github.com/tBaxter/tango-shared-core/blob/35fc10aef1ceedcdb4d6d866d44a22efff718812/build/lib/tango_shared/templatetags/formatting.py#L36-L72
shkarupa-alex/tfunicode
tfunicode/python/ops/__init__.py
_combine_sparse_successor
def _combine_sparse_successor(parent_indices, parent_shape, child_indices, child_values, child_shape, name=None): """Combines two string `SparseTensor`s, where second `SparseTensor` is the result of expanding first `SparseTensor`'s values. Args: parent_indices: 2D int64 `Tensor` with parent `Sparse...
python
def _combine_sparse_successor(parent_indices, parent_shape, child_indices, child_values, child_shape, name=None): """Combines two string `SparseTensor`s, where second `SparseTensor` is the result of expanding first `SparseTensor`'s values. Args: parent_indices: 2D int64 `Tensor` with parent `Sparse...
[ "def", "_combine_sparse_successor", "(", "parent_indices", ",", "parent_shape", ",", "child_indices", ",", "child_values", ",", "child_shape", ",", "name", "=", "None", ")", ":", "with", "ops", ".", "name_scope", "(", "name", ",", "\"CombineSparseSuccessor\"", ","...
Combines two string `SparseTensor`s, where second `SparseTensor` is the result of expanding first `SparseTensor`'s values. Args: parent_indices: 2D int64 `Tensor` with parent `SparseTensor` indices parent_shape: 1D int64 `Tensor` with parent `SparseTensor` dense_shape child_indices: 2D ...
[ "Combines", "two", "string", "SparseTensor", "s", "where", "second", "SparseTensor", "is", "the", "result", "of", "expanding", "first", "SparseTensor", "s", "values", "." ]
train
https://github.com/shkarupa-alex/tfunicode/blob/72ee2f484b6202394dcda3db47245bc78ae2267d/tfunicode/python/ops/__init__.py#L26-L51
shkarupa-alex/tfunicode
tfunicode/python/ops/__init__.py
expand_char_ngrams
def expand_char_ngrams(source, minn, maxn, itself='ASIS', name=None): """Split unicode strings into char ngrams. Ngrams size configures with minn and max Args: source: `Tensor` or `SparseTensor` of any shape, strings to split minn: Minimum length of char ngram minn: Maximum length o...
python
def expand_char_ngrams(source, minn, maxn, itself='ASIS', name=None): """Split unicode strings into char ngrams. Ngrams size configures with minn and max Args: source: `Tensor` or `SparseTensor` of any shape, strings to split minn: Minimum length of char ngram minn: Maximum length o...
[ "def", "expand_char_ngrams", "(", "source", ",", "minn", ",", "maxn", ",", "itself", "=", "'ASIS'", ",", "name", "=", "None", ")", ":", "with", "ops", ".", "name_scope", "(", "name", ",", "\"ExpandCharNgrams\"", ",", "[", "source", "]", ")", ":", "sour...
Split unicode strings into char ngrams. Ngrams size configures with minn and max Args: source: `Tensor` or `SparseTensor` of any shape, strings to split minn: Minimum length of char ngram minn: Maximum length of char ngram itself: Scalar value, strategy for source word preservin...
[ "Split", "unicode", "strings", "into", "char", "ngrams", ".", "Ngrams", "size", "configures", "with", "minn", "and", "max" ]
train
https://github.com/shkarupa-alex/tfunicode/blob/72ee2f484b6202394dcda3db47245bc78ae2267d/tfunicode/python/ops/__init__.py#L54-L79
shkarupa-alex/tfunicode
tfunicode/python/ops/__init__.py
transform_normalize_unicode
def transform_normalize_unicode(source, form, name=None): """Normalize unicode strings tensor. Args: source: `Tensor` or `SparseTensor` of any shape, strings to normalize. form: Scalar value, name of normalization algorithm. One of `"NFD"`, `"NFC"`, `"NFKD"`, `"NFKC"`. name:...
python
def transform_normalize_unicode(source, form, name=None): """Normalize unicode strings tensor. Args: source: `Tensor` or `SparseTensor` of any shape, strings to normalize. form: Scalar value, name of normalization algorithm. One of `"NFD"`, `"NFC"`, `"NFKD"`, `"NFKC"`. name:...
[ "def", "transform_normalize_unicode", "(", "source", ",", "form", ",", "name", "=", "None", ")", ":", "with", "ops", ".", "name_scope", "(", "name", ",", "\"TransformNormalizeUnicode\"", ",", "[", "source", "]", ")", ":", "source", "=", "convert_to_tensor_or_s...
Normalize unicode strings tensor. Args: source: `Tensor` or `SparseTensor` of any shape, strings to normalize. form: Scalar value, name of normalization algorithm. One of `"NFD"`, `"NFC"`, `"NFKD"`, `"NFKC"`. name: A name for the operation (optional). Returns: `Tenso...
[ "Normalize", "unicode", "strings", "tensor", "." ]
train
https://github.com/shkarupa-alex/tfunicode/blob/72ee2f484b6202394dcda3db47245bc78ae2267d/tfunicode/python/ops/__init__.py#L131-L154
shkarupa-alex/tfunicode
tfunicode/python/ops/__init__.py
transform_regex_replace
def transform_regex_replace(source, pattern, rewrite, name=None): """Replace all substrings from `needle` to corresponding strings in `haystack` with source. Args: source: `Tensor` or `SparseTensor` of any shape, source strings for replacing. pattern: List of RE2 patterns to search in source ...
python
def transform_regex_replace(source, pattern, rewrite, name=None): """Replace all substrings from `needle` to corresponding strings in `haystack` with source. Args: source: `Tensor` or `SparseTensor` of any shape, source strings for replacing. pattern: List of RE2 patterns to search in source ...
[ "def", "transform_regex_replace", "(", "source", ",", "pattern", ",", "rewrite", ",", "name", "=", "None", ")", ":", "with", "ops", ".", "name_scope", "(", "name", ",", "\"TransformRegexReplace\"", ",", "[", "source", "]", ")", ":", "source", "=", "convert...
Replace all substrings from `needle` to corresponding strings in `haystack` with source. Args: source: `Tensor` or `SparseTensor` of any shape, source strings for replacing. pattern: List of RE2 patterns to search in source rewrite: List of strings to replace with. Should have same length a...
[ "Replace", "all", "substrings", "from", "needle", "to", "corresponding", "strings", "in", "haystack", "with", "source", "." ]
train
https://github.com/shkarupa-alex/tfunicode/blob/72ee2f484b6202394dcda3db47245bc78ae2267d/tfunicode/python/ops/__init__.py#L181-L204
shkarupa-alex/tfunicode
tfunicode/python/ops/__init__.py
transform_string_replace
def transform_string_replace(source, needle, haystack, name=None): """Replace all substrings from `needle` to corresponding strings in `haystack` with source. Args: source: `Tensor` or `SparseTensor` of any shape, source strings for replacing. needle: List of strings to search in source ...
python
def transform_string_replace(source, needle, haystack, name=None): """Replace all substrings from `needle` to corresponding strings in `haystack` with source. Args: source: `Tensor` or `SparseTensor` of any shape, source strings for replacing. needle: List of strings to search in source ...
[ "def", "transform_string_replace", "(", "source", ",", "needle", ",", "haystack", ",", "name", "=", "None", ")", ":", "with", "ops", ".", "name_scope", "(", "name", ",", "\"TransformStringReplace\"", ",", "[", "source", "]", ")", ":", "source", "=", "conve...
Replace all substrings from `needle` to corresponding strings in `haystack` with source. Args: source: `Tensor` or `SparseTensor` of any shape, source strings for replacing. needle: List of strings to search in source haystack: List of strings to replace with. Should have same length as `ne...
[ "Replace", "all", "substrings", "from", "needle", "to", "corresponding", "strings", "in", "haystack", "with", "source", "." ]
train
https://github.com/shkarupa-alex/tfunicode/blob/72ee2f484b6202394dcda3db47245bc78ae2267d/tfunicode/python/ops/__init__.py#L207-L230
shkarupa-alex/tfunicode
tfunicode/python/ops/__init__.py
transform_wrap_with
def transform_wrap_with(source, left, right, name=None): """Wrap source strings with "left" and "right" strings Args: source: `Tensor` or `SparseTensor` of any shape, strings to replace digits. left: Scalar string to add in the beginning right: Scalar string to add in the ending ...
python
def transform_wrap_with(source, left, right, name=None): """Wrap source strings with "left" and "right" strings Args: source: `Tensor` or `SparseTensor` of any shape, strings to replace digits. left: Scalar string to add in the beginning right: Scalar string to add in the ending ...
[ "def", "transform_wrap_with", "(", "source", ",", "left", ",", "right", ",", "name", "=", "None", ")", ":", "with", "ops", ".", "name_scope", "(", "name", ",", "\"TransformWrapWith\"", ",", "[", "source", "]", ")", ":", "source", "=", "convert_to_tensor_or...
Wrap source strings with "left" and "right" strings Args: source: `Tensor` or `SparseTensor` of any shape, strings to replace digits. left: Scalar string to add in the beginning right: Scalar string to add in the ending name: A name for the operation (optional). Returns: ...
[ "Wrap", "source", "strings", "with", "left", "and", "right", "strings" ]
train
https://github.com/shkarupa-alex/tfunicode/blob/72ee2f484b6202394dcda3db47245bc78ae2267d/tfunicode/python/ops/__init__.py#L305-L328
zagfai/webtul
webtul/log.py
display
def display(level='DEBUG'): """display(level='DEBUG') forwards logs to stdout""" logger = get_logger() sh = logging.StreamHandler() sh.setLevel(getattr(logging, level)) sh.setFormatter(DEFAULT_LOG_FORMAT) logger.addHandler(sh)
python
def display(level='DEBUG'): """display(level='DEBUG') forwards logs to stdout""" logger = get_logger() sh = logging.StreamHandler() sh.setLevel(getattr(logging, level)) sh.setFormatter(DEFAULT_LOG_FORMAT) logger.addHandler(sh)
[ "def", "display", "(", "level", "=", "'DEBUG'", ")", ":", "logger", "=", "get_logger", "(", ")", "sh", "=", "logging", ".", "StreamHandler", "(", ")", "sh", ".", "setLevel", "(", "getattr", "(", "logging", ",", "level", ")", ")", "sh", ".", "setForma...
display(level='DEBUG') forwards logs to stdout
[ "display", "(", "level", "=", "DEBUG", ")", "forwards", "logs", "to", "stdout" ]
train
https://github.com/zagfai/webtul/blob/58c49928070b56ef54a45b4af20d800b269ad8ce/webtul/log.py#L121-L127
Th3Gam3rz/UsefulUtils
src/math.py
specialRound
def specialRound(number, rounding): """A method used to round a number in the way that UsefulUtils rounds.""" temp = 0 if rounding == 0: temp = number else: temp = round(number, rounding) if temp % 1 == 0: return int(temp) else: return float(temp)
python
def specialRound(number, rounding): """A method used to round a number in the way that UsefulUtils rounds.""" temp = 0 if rounding == 0: temp = number else: temp = round(number, rounding) if temp % 1 == 0: return int(temp) else: return float(temp)
[ "def", "specialRound", "(", "number", ",", "rounding", ")", ":", "temp", "=", "0", "if", "rounding", "==", "0", ":", "temp", "=", "number", "else", ":", "temp", "=", "round", "(", "number", ",", "rounding", ")", "if", "temp", "%", "1", "==", "0", ...
A method used to round a number in the way that UsefulUtils rounds.
[ "A", "method", "used", "to", "round", "a", "number", "in", "the", "way", "that", "UsefulUtils", "rounds", "." ]
train
https://github.com/Th3Gam3rz/UsefulUtils/blob/6811af3daa88b42d76c4db372b58e2739d1f5595/src/math.py#L1-L11
Nekroze/librarian
librarian/library.py
Where_filter_gen
def Where_filter_gen(*data): """ Generate an sqlite "LIKE" filter generator based on the given data. This functions arguments should be a N length series of field and data tuples. """ where = [] def Fwhere(field, pattern): """Add where filter for the given field with the given patte...
python
def Where_filter_gen(*data): """ Generate an sqlite "LIKE" filter generator based on the given data. This functions arguments should be a N length series of field and data tuples. """ where = [] def Fwhere(field, pattern): """Add where filter for the given field with the given patte...
[ "def", "Where_filter_gen", "(", "*", "data", ")", ":", "where", "=", "[", "]", "def", "Fwhere", "(", "field", ",", "pattern", ")", ":", "\"\"\"Add where filter for the given field with the given pattern.\"\"\"", "where", ".", "append", "(", "\"WHERE {0} LIKE '{1}'\"",...
Generate an sqlite "LIKE" filter generator based on the given data. This functions arguments should be a N length series of field and data tuples.
[ "Generate", "an", "sqlite", "LIKE", "filter", "generator", "based", "on", "the", "given", "data", ".", "This", "functions", "arguments", "should", "be", "a", "N", "length", "series", "of", "field", "and", "data", "tuples", "." ]
train
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L11-L52
Nekroze/librarian
librarian/library.py
Library.cache_card
def cache_card(self, card): """ Cache the card for faster future lookups. Removes the oldest card when the card cache stores more cards then this libraries cache limit. """ code = card.code self.card_cache[code] = card if code in self.card_cache_list: ...
python
def cache_card(self, card): """ Cache the card for faster future lookups. Removes the oldest card when the card cache stores more cards then this libraries cache limit. """ code = card.code self.card_cache[code] = card if code in self.card_cache_list: ...
[ "def", "cache_card", "(", "self", ",", "card", ")", ":", "code", "=", "card", ".", "code", "self", ".", "card_cache", "[", "code", "]", "=", "card", "if", "code", "in", "self", ".", "card_cache_list", ":", "self", ".", "card_cache_list", ".", "remove",...
Cache the card for faster future lookups. Removes the oldest card when the card cache stores more cards then this libraries cache limit.
[ "Cache", "the", "card", "for", "faster", "future", "lookups", ".", "Removes", "the", "oldest", "card", "when", "the", "card", "cache", "stores", "more", "cards", "then", "this", "libraries", "cache", "limit", "." ]
train
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L82-L94
Nekroze/librarian
librarian/library.py
Library.load_card
def load_card(self, code, cache=True): """ Load a card with the given code from the database. This calls each save event hook on the save string before commiting it to the database. Will cache each resulting card for faster future lookups with this method while respecting the li...
python
def load_card(self, code, cache=True): """ Load a card with the given code from the database. This calls each save event hook on the save string before commiting it to the database. Will cache each resulting card for faster future lookups with this method while respecting the li...
[ "def", "load_card", "(", "self", ",", "code", ",", "cache", "=", "True", ")", ":", "card", "=", "self", ".", "card_cache", ".", "get", "(", "code", ",", "None", ")", "if", "card", "is", "None", ":", "code", "=", "code", "if", "isinstance", "(", "...
Load a card with the given code from the database. This calls each save event hook on the save string before commiting it to the database. Will cache each resulting card for faster future lookups with this method while respecting the libraries cache limit. However only if the cache argu...
[ "Load", "a", "card", "with", "the", "given", "code", "from", "the", "database", ".", "This", "calls", "each", "save", "event", "hook", "on", "the", "save", "string", "before", "commiting", "it", "to", "the", "database", "." ]
train
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L102-L126
Nekroze/librarian
librarian/library.py
Library.save_card
def save_card(self, card, cache=False): """ Save the given card to the database. This calls each save event hook on the save string before commiting it to the database. """ if cache: self.cache_card(card) carddict = card.save() with sqlite3.connect(sel...
python
def save_card(self, card, cache=False): """ Save the given card to the database. This calls each save event hook on the save string before commiting it to the database. """ if cache: self.cache_card(card) carddict = card.save() with sqlite3.connect(sel...
[ "def", "save_card", "(", "self", ",", "card", ",", "cache", "=", "False", ")", ":", "if", "cache", ":", "self", ".", "cache_card", "(", "card", ")", "carddict", "=", "card", ".", "save", "(", ")", "with", "sqlite3", ".", "connect", "(", "self", "."...
Save the given card to the database. This calls each save event hook on the save string before commiting it to the database.
[ "Save", "the", "given", "card", "to", "the", "database", ".", "This", "calls", "each", "save", "event", "hook", "on", "the", "save", "string", "before", "commiting", "it", "to", "the", "database", "." ]
train
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L128-L141
Nekroze/librarian
librarian/library.py
Library.retrieve_all
def retrieve_all(self): """ A generator that iterates over each card in the library database. This is best used in for loops as it will only load a card from the library as needed rather then all at once. """ with sqlite3.connect(self.dbname) as carddb: for r...
python
def retrieve_all(self): """ A generator that iterates over each card in the library database. This is best used in for loops as it will only load a card from the library as needed rather then all at once. """ with sqlite3.connect(self.dbname) as carddb: for r...
[ "def", "retrieve_all", "(", "self", ")", ":", "with", "sqlite3", ".", "connect", "(", "self", ".", "dbname", ")", "as", "carddb", ":", "for", "row", "in", "carddb", ".", "execute", "(", "\"SELECT code FROM CARDS\"", ")", ":", "yield", "self", ".", "load_...
A generator that iterates over each card in the library database. This is best used in for loops as it will only load a card from the library as needed rather then all at once.
[ "A", "generator", "that", "iterates", "over", "each", "card", "in", "the", "library", "database", "." ]
train
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L143-L152
Nekroze/librarian
librarian/library.py
Library.filter_search
def filter_search(self, code=None, name=None, abilities=None, attributes=None, info=None): """ Return a list of codes and names pertaining to cards that have the given information values stored. Can take a code integer, name string, abilities dict {phase: ability ...
python
def filter_search(self, code=None, name=None, abilities=None, attributes=None, info=None): """ Return a list of codes and names pertaining to cards that have the given information values stored. Can take a code integer, name string, abilities dict {phase: ability ...
[ "def", "filter_search", "(", "self", ",", "code", "=", "None", ",", "name", "=", "None", ",", "abilities", "=", "None", ",", "attributes", "=", "None", ",", "info", "=", "None", ")", ":", "command", "=", "\"SELECT code, name FROM CARDS \"", "command", "+="...
Return a list of codes and names pertaining to cards that have the given information values stored. Can take a code integer, name string, abilities dict {phase: ability list/"*"}, attributes list, info dict {key, value list/"*"}. In the above argument examples "*" is a string that may ...
[ "Return", "a", "list", "of", "codes", "and", "names", "pertaining", "to", "cards", "that", "have", "the", "given", "information", "values", "stored", "." ]
train
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L154-L174
BlackEarth/bf
bf/css.py
CSS.to_unit
def to_unit(C, val, unit=None): """convert a string measurement to a Unum""" md = re.match(r'^(?P<num>[\d\.]+)(?P<unit>.*)$', val) if md is not None: un = float(md.group('num')) * CSS.units[md.group('unit')] if unit is not None: return un.asUnit(unit...
python
def to_unit(C, val, unit=None): """convert a string measurement to a Unum""" md = re.match(r'^(?P<num>[\d\.]+)(?P<unit>.*)$', val) if md is not None: un = float(md.group('num')) * CSS.units[md.group('unit')] if unit is not None: return un.asUnit(unit...
[ "def", "to_unit", "(", "C", ",", "val", ",", "unit", "=", "None", ")", ":", "md", "=", "re", ".", "match", "(", "r'^(?P<num>[\\d\\.]+)(?P<unit>.*)$'", ",", "val", ")", "if", "md", "is", "not", "None", ":", "un", "=", "float", "(", "md", ".", "group...
convert a string measurement to a Unum
[ "convert", "a", "string", "measurement", "to", "a", "Unum" ]
train
https://github.com/BlackEarth/bf/blob/376041168874bbd6dee5ccfeece4a9e553223316/bf/css.py#L48-L56