id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
242,000
scivision/histutils
histutils/__init__.py
imgwriteincr
def imgwriteincr(fn: Path, imgs, imgslice): """ writes HDF5 huge image files in increments """ if isinstance(imgslice, int): if imgslice and not (imgslice % 2000): print(f'appending images {imgslice} to {fn}') if isinstance(fn, Path): # avoid accidental overwriting of so...
python
def imgwriteincr(fn: Path, imgs, imgslice): """ writes HDF5 huge image files in increments """ if isinstance(imgslice, int): if imgslice and not (imgslice % 2000): print(f'appending images {imgslice} to {fn}') if isinstance(fn, Path): # avoid accidental overwriting of so...
[ "def", "imgwriteincr", "(", "fn", ":", "Path", ",", "imgs", ",", "imgslice", ")", ":", "if", "isinstance", "(", "imgslice", ",", "int", ")", ":", "if", "imgslice", "and", "not", "(", "imgslice", "%", "2000", ")", ":", "print", "(", "f'appending images ...
writes HDF5 huge image files in increments
[ "writes", "HDF5", "huge", "image", "files", "in", "increments" ]
859a91d3894cb57faed34881c6ea16130b90571e
https://github.com/scivision/histutils/blob/859a91d3894cb57faed34881c6ea16130b90571e/histutils/__init__.py#L381-L399
242,001
MacHu-GWU/pyknackhq-project
pyknackhq/js.py
safe_dump_js
def safe_dump_js(js, abspath, fastmode=False, compress=False, enable_verbose=True): """A stable version of dump_js, silently overwrite existing file. When your program been interrupted, you lose nothing. Typically if your program is interrupted by any reason, it only leaves a incomplete f...
python
def safe_dump_js(js, abspath, fastmode=False, compress=False, enable_verbose=True): """A stable version of dump_js, silently overwrite existing file. When your program been interrupted, you lose nothing. Typically if your program is interrupted by any reason, it only leaves a incomplete f...
[ "def", "safe_dump_js", "(", "js", ",", "abspath", ",", "fastmode", "=", "False", ",", "compress", "=", "False", ",", "enable_verbose", "=", "True", ")", ":", "abspath", "=", "str", "(", "abspath", ")", "# try stringlize", "temp_abspath", "=", "\"%s.tmp\"", ...
A stable version of dump_js, silently overwrite existing file. When your program been interrupted, you lose nothing. Typically if your program is interrupted by any reason, it only leaves a incomplete file. If you use replace=True, then you also lose your old file. So a bettr way is to: 1...
[ "A", "stable", "version", "of", "dump_js", "silently", "overwrite", "existing", "file", "." ]
dd937f24d7b0a351ba3818eb746c31b29a8cc341
https://github.com/MacHu-GWU/pyknackhq-project/blob/dd937f24d7b0a351ba3818eb746c31b29a8cc341/pyknackhq/js.py#L260-L335
242,002
political-memory/django-representatives
representatives/migrations/0017_auto_20160623_2201.py
migrate_constituencies
def migrate_constituencies(apps, schema_editor): """ Re-save constituencies to recompute fingerprints """ Constituency = apps.get_model("representatives", "Constituency") for c in Constituency.objects.all(): c.save()
python
def migrate_constituencies(apps, schema_editor): """ Re-save constituencies to recompute fingerprints """ Constituency = apps.get_model("representatives", "Constituency") for c in Constituency.objects.all(): c.save()
[ "def", "migrate_constituencies", "(", "apps", ",", "schema_editor", ")", ":", "Constituency", "=", "apps", ".", "get_model", "(", "\"representatives\"", ",", "\"Constituency\"", ")", "for", "c", "in", "Constituency", ".", "objects", ".", "all", "(", ")", ":", ...
Re-save constituencies to recompute fingerprints
[ "Re", "-", "save", "constituencies", "to", "recompute", "fingerprints" ]
811c90d0250149e913e6196f0ab11c97d396be39
https://github.com/political-memory/django-representatives/blob/811c90d0250149e913e6196f0ab11c97d396be39/representatives/migrations/0017_auto_20160623_2201.py#L7-L13
242,003
mayfield/shellish
shellish/layout/tree.py
treeprint
def treeprint(data, render_only=False, file=None, **options): """ Render a tree structure based on generic python containers. The keys should be titles and the values are children of the node or None if it's an empty leaf node; Primitives are valid leaf node labels too. E.g. sample = { ...
python
def treeprint(data, render_only=False, file=None, **options): """ Render a tree structure based on generic python containers. The keys should be titles and the values are children of the node or None if it's an empty leaf node; Primitives are valid leaf node labels too. E.g. sample = { ...
[ "def", "treeprint", "(", "data", ",", "render_only", "=", "False", ",", "file", "=", "None", ",", "*", "*", "options", ")", ":", "def", "getiter", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "collections", ".", "abc", ".", "Mapping", ...
Render a tree structure based on generic python containers. The keys should be titles and the values are children of the node or None if it's an empty leaf node; Primitives are valid leaf node labels too. E.g. sample = { "Leaf 1": None, "Leaf 2": "I have a label on me", ...
[ "Render", "a", "tree", "structure", "based", "on", "generic", "python", "containers", ".", "The", "keys", "should", "be", "titles", "and", "the", "values", "are", "children", "of", "the", "node", "or", "None", "if", "it", "s", "an", "empty", "leaf", "nod...
df0f0e4612d138c34d8cb99b66ab5b8e47f1414a
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/tree.py#L60-L116
242,004
marcosgabarda/django-belt
belt/commands.py
ProgressBarCommand.terminal_size
def terminal_size(self): """Gets the terminal columns size.""" try: _, columns = os.popen('stty size', 'r').read().split() return min(int(columns) - 10, 100) except ValueError: return self.default_terminal_size
python
def terminal_size(self): """Gets the terminal columns size.""" try: _, columns = os.popen('stty size', 'r').read().split() return min(int(columns) - 10, 100) except ValueError: return self.default_terminal_size
[ "def", "terminal_size", "(", "self", ")", ":", "try", ":", "_", ",", "columns", "=", "os", ".", "popen", "(", "'stty size'", ",", "'r'", ")", ".", "read", "(", ")", ".", "split", "(", ")", "return", "min", "(", "int", "(", "columns", ")", "-", ...
Gets the terminal columns size.
[ "Gets", "the", "terminal", "columns", "size", "." ]
81404604c4dff664b1520b01e1f638c9c6bab41b
https://github.com/marcosgabarda/django-belt/blob/81404604c4dff664b1520b01e1f638c9c6bab41b/belt/commands.py#L13-L19
242,005
marcosgabarda/django-belt
belt/commands.py
ProgressBarCommand.bar
def bar(self, progress): """Shows on the stdout the progress bar for the given progress.""" if not hasattr(self, "_limit") or not self._limit: self._limit = self.terminal_size() graph_progress = int(progress * self._limit) self.stdout.write('\r', ending='') progress_f...
python
def bar(self, progress): """Shows on the stdout the progress bar for the given progress.""" if not hasattr(self, "_limit") or not self._limit: self._limit = self.terminal_size() graph_progress = int(progress * self._limit) self.stdout.write('\r', ending='') progress_f...
[ "def", "bar", "(", "self", ",", "progress", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"_limit\"", ")", "or", "not", "self", ".", "_limit", ":", "self", ".", "_limit", "=", "self", ".", "terminal_size", "(", ")", "graph_progress", "=", "in...
Shows on the stdout the progress bar for the given progress.
[ "Shows", "on", "the", "stdout", "the", "progress", "bar", "for", "the", "given", "progress", "." ]
81404604c4dff664b1520b01e1f638c9c6bab41b
https://github.com/marcosgabarda/django-belt/blob/81404604c4dff664b1520b01e1f638c9c6bab41b/belt/commands.py#L21-L32
242,006
sahid/warm
warm/components/__init__.py
SecurityGroup._Execute
def _Execute(self, options): """Handles security groups operations.""" whitelist = dict( name=options["name"], description=options.get("description", "<empty>")) return self._agent.client.compute.security_groups.create(**whitelist)
python
def _Execute(self, options): """Handles security groups operations.""" whitelist = dict( name=options["name"], description=options.get("description", "<empty>")) return self._agent.client.compute.security_groups.create(**whitelist)
[ "def", "_Execute", "(", "self", ",", "options", ")", ":", "whitelist", "=", "dict", "(", "name", "=", "options", "[", "\"name\"", "]", ",", "description", "=", "options", ".", "get", "(", "\"description\"", ",", "\"<empty>\"", ")", ")", "return", "self",...
Handles security groups operations.
[ "Handles", "security", "groups", "operations", "." ]
baf1cb73c6769a556756b9078e60c96d4b1de2bd
https://github.com/sahid/warm/blob/baf1cb73c6769a556756b9078e60c96d4b1de2bd/warm/components/__init__.py#L167-L172
242,007
pwyliu/clancy
clancy/config.py
load_args
def load_args(args): """ Load a config file. Merges CLI args and validates. """ config = kaptan.Kaptan(handler='yaml') conf_parent = os.path.expanduser('~') conf_app = '.clancy' conf_filename = 'config.yaml' conf_dir = os.path.join(conf_parent, conf_app) for loc in [os.curdir, conf_...
python
def load_args(args): """ Load a config file. Merges CLI args and validates. """ config = kaptan.Kaptan(handler='yaml') conf_parent = os.path.expanduser('~') conf_app = '.clancy' conf_filename = 'config.yaml' conf_dir = os.path.join(conf_parent, conf_app) for loc in [os.curdir, conf_...
[ "def", "load_args", "(", "args", ")", ":", "config", "=", "kaptan", ".", "Kaptan", "(", "handler", "=", "'yaml'", ")", "conf_parent", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "conf_app", "=", "'.clancy'", "conf_filename", "=", "'config...
Load a config file. Merges CLI args and validates.
[ "Load", "a", "config", "file", ".", "Merges", "CLI", "args", "and", "validates", "." ]
cb15a5e2bb735ffce7a84b8413b04faa78c5039c
https://github.com/pwyliu/clancy/blob/cb15a5e2bb735ffce7a84b8413b04faa78c5039c/clancy/config.py#L59-L87
242,008
rsalmaso/django-fluo
fluo/middleware/locale.py
get_default_language
def get_default_language(language_code=None): """ Returns default language depending on settings.LANGUAGE_CODE merged with best match from settings.LANGUAGES Returns: language_code Raises ImproperlyConfigured if no match found """ if not language_code: language_code = settings.LAN...
python
def get_default_language(language_code=None): """ Returns default language depending on settings.LANGUAGE_CODE merged with best match from settings.LANGUAGES Returns: language_code Raises ImproperlyConfigured if no match found """ if not language_code: language_code = settings.LAN...
[ "def", "get_default_language", "(", "language_code", "=", "None", ")", ":", "if", "not", "language_code", ":", "language_code", "=", "settings", ".", "LANGUAGE_CODE", "languages", "=", "dict", "(", "settings", ".", "LANGUAGES", ")", ".", "keys", "(", ")", "#...
Returns default language depending on settings.LANGUAGE_CODE merged with best match from settings.LANGUAGES Returns: language_code Raises ImproperlyConfigured if no match found
[ "Returns", "default", "language", "depending", "on", "settings", ".", "LANGUAGE_CODE", "merged", "with", "best", "match", "from", "settings", ".", "LANGUAGES" ]
1321c1e7d6a912108f79be02a9e7f2108c57f89f
https://github.com/rsalmaso/django-fluo/blob/1321c1e7d6a912108f79be02a9e7f2108c57f89f/fluo/middleware/locale.py#L68-L93
242,009
luismasuelli/python-cantrips
cantrips/patterns/actions.py
Action.as_method
def as_method(self, docstring=""): """ Converts this action to a function or method. An optional docstring may be passed. """ method = lambda obj, *args, **kwargs: self(obj, *args, **kwargs) if docstring: method.__doc__ = docstring return method
python
def as_method(self, docstring=""): """ Converts this action to a function or method. An optional docstring may be passed. """ method = lambda obj, *args, **kwargs: self(obj, *args, **kwargs) if docstring: method.__doc__ = docstring return method
[ "def", "as_method", "(", "self", ",", "docstring", "=", "\"\"", ")", ":", "method", "=", "lambda", "obj", ",", "*", "args", ",", "*", "*", "kwargs", ":", "self", "(", "obj", ",", "*", "args", ",", "*", "*", "kwargs", ")", "if", "docstring", ":", ...
Converts this action to a function or method. An optional docstring may be passed.
[ "Converts", "this", "action", "to", "a", "function", "or", "method", ".", "An", "optional", "docstring", "may", "be", "passed", "." ]
dba2742c1d1a60863bb65f4a291464f6e68eb2ee
https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/patterns/actions.py#L12-L20
242,010
jpablo128/simplystatic
simplystatic/s2page.py
Page._create
def _create(self, rawtitle): """Create a page with this title, if it doesn't exist. This method first checks whether a page with the same slug (sanitized name) exists_on_disk. If it does, it doesn't do antyhing. Otherwise, the relevant attributes are created. Nothing is written ...
python
def _create(self, rawtitle): """Create a page with this title, if it doesn't exist. This method first checks whether a page with the same slug (sanitized name) exists_on_disk. If it does, it doesn't do antyhing. Otherwise, the relevant attributes are created. Nothing is written ...
[ "def", "_create", "(", "self", ",", "rawtitle", ")", ":", "slug", "=", "util", ".", "make_slug", "(", "rawtitle", ")", "if", "self", ".", "site", ".", "page_exists_on_disk", "(", "slug", ")", ":", "raise", "ValueError", "#print \"Attempted to create a page whi...
Create a page with this title, if it doesn't exist. This method first checks whether a page with the same slug (sanitized name) exists_on_disk. If it does, it doesn't do antyhing. Otherwise, the relevant attributes are created. Nothing is written to disc (to the source file). You must c...
[ "Create", "a", "page", "with", "this", "title", "if", "it", "doesn", "t", "exist", "." ]
91ac579c8f34fa240bef9b87adb0116c6b40b24d
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L100-L129
242,011
jpablo128/simplystatic
simplystatic/s2page.py
Page.write
def write(self): """Write the s2 page to the corresponding source file. It always writes the (serialized) config first, and then the content (normally markdown). The destination file is in the source_dir of the site. """ if not os.path.isdir(self._dirs['source_dir']): ...
python
def write(self): """Write the s2 page to the corresponding source file. It always writes the (serialized) config first, and then the content (normally markdown). The destination file is in the source_dir of the site. """ if not os.path.isdir(self._dirs['source_dir']): ...
[ "def", "write", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "_dirs", "[", "'source_dir'", "]", ")", ":", "os", ".", "mkdir", "(", "self", ".", "_dirs", "[", "'source_dir'", "]", ")", "fout", "=", "codecs...
Write the s2 page to the corresponding source file. It always writes the (serialized) config first, and then the content (normally markdown). The destination file is in the source_dir of the site.
[ "Write", "the", "s2", "page", "to", "the", "corresponding", "source", "file", "." ]
91ac579c8f34fa240bef9b87adb0116c6b40b24d
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L131-L148
242,012
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", "." ]
91ac579c8f34fa240bef9b87adb0116c6b40b24d
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L150-L186
242,013
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", "." ]
91ac579c8f34fa240bef9b87adb0116c6b40b24d
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L189-L257
242,014
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", "." ]
91ac579c8f34fa240bef9b87adb0116c6b40b24d
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L261-L296
242,015
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", "." ]
91ac579c8f34fa240bef9b87adb0116c6b40b24d
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L302-L316
242,016
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", "." ]
91ac579c8f34fa240bef9b87adb0116c6b40b24d
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L318-L344
242,017
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", "." ]
91ac579c8f34fa240bef9b87adb0116c6b40b24d
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L346-L379
242,018
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" ]
91ac579c8f34fa240bef9b87adb0116c6b40b24d
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L381-L391
242,019
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", "." ]
91ac579c8f34fa240bef9b87adb0116c6b40b24d
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L393-L417
242,020
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", "." ]
91ac579c8f34fa240bef9b87adb0116c6b40b24d
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L420-L432
242,021
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", "." ]
91ac579c8f34fa240bef9b87adb0116c6b40b24d
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2page.py#L499-L504
242,022
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" ]
4e278101943d1ceb1a6bcaf6ddc72052ecf13114
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/decorators.py#L19-L72
242,023
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" ]
4e278101943d1ceb1a6bcaf6ddc72052ecf13114
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/decorators.py#L75-L89
242,024
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" ]
4e278101943d1ceb1a6bcaf6ddc72052ecf13114
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/decorators.py#L135-L143
242,025
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", "." ]
341595d24454a79caee23750eac271f9d0626c88
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/handlers.py#L178-L199
242,026
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", "." ]
341595d24454a79caee23750eac271f9d0626c88
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/handlers.py#L247-L262
242,027
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", "." ]
341595d24454a79caee23750eac271f9d0626c88
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/handlers.py#L264-L282
242,028
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", "." ]
341595d24454a79caee23750eac271f9d0626c88
https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/handlers.py#L284-L306
242,029
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", "." ]
d68c9a083d443dfa5d7c5112de29010909cfe23f
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/data_parser.py#L27-L38
242,030
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", "." ]
afc9db073dbc72b2562ce3e444152986a555dcbf
https://github.com/francois-vincent/clingon/blob/afc9db073dbc72b2562ce3e444152986a555dcbf/examples/zipcomment.py#L11-L42
242,031
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", "." ]
07183333df26eb12c5c2b98802cde3fb3a6c1339
https://github.com/pyvec/pyvodb/blob/07183333df26eb12c5c2b98802cde3fb3a6c1339/pyvodb/cli/top.py#L57-L80
242,032
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", "." ]
d96854e2afdd70c814b16d177ff6308841b34b24
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L50-L63
242,033
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", "." ]
d96854e2afdd70c814b16d177ff6308841b34b24
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L65-L83
242,034
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", "." ]
d96854e2afdd70c814b16d177ff6308841b34b24
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L100-L151
242,035
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", "." ]
d96854e2afdd70c814b16d177ff6308841b34b24
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L153-L206
242,036
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", "." ]
d96854e2afdd70c814b16d177ff6308841b34b24
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L208-L241
242,037
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", "." ]
d96854e2afdd70c814b16d177ff6308841b34b24
https://github.com/Bystroushaak/BalancedDiscStorage/blob/d96854e2afdd70c814b16d177ff6308841b34b24/src/BalancedDiscStorage/balanced_disc_storage.py#L276-L305
242,038
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", "." ]
39cb0ae8cc5c1df5690816a18472e0366a49ab8d
https://github.com/leonidessaguisagjr/pseudol10nutil/blob/39cb0ae8cc5c1df5690816a18472e0366a49ab8d/pseudol10nutil/pseudol10nutil.py#L33-L77
242,039
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", "." ]
39cb0ae8cc5c1df5690816a18472e0366a49ab8d
https://github.com/leonidessaguisagjr/pseudol10nutil/blob/39cb0ae8cc5c1df5690816a18472e0366a49ab8d/pseudol10nutil/pseudol10nutil.py#L98-L124
242,040
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", "." ]
903b9d6427513b07986ffacf76cbca54e18d8be6
https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/pext.py#L8-L29
242,041
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" ]
903b9d6427513b07986ffacf76cbca54e18d8be6
https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/pext.py#L31-L61
242,042
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" ]
a648ce00e4467cd14d71e754240ef6c1f87a34b5
https://github.com/mattupstate/cubric/blob/a648ce00e4467cd14d71e754240ef6c1f87a34b5/cubric/tasks.py#L11-L17
242,043
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", "." ]
dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267
https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/users.py#L148-L157
242,044
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", "." ]
dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267
https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/users.py#L159-L168
242,045
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L52-L76
242,046
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L78-L97
242,047
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", "." ...
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L99-L110
242,048
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L112-L148
242,049
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L150-L163
242,050
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L165-L178
242,051
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L180-L198
242,052
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L200-L213
242,053
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L246-L275
242,054
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L277-L288
242,055
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L290-L301
242,056
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L303-L322
242,057
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L324-L342
242,058
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", "."...
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L344-L353
242,059
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L355-L363
242,060
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L365-L392
242,061
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L394-L415
242,062
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L417-L427
242,063
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L429-L439
242,064
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L441-L463
242,065
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L465-L477
242,066
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L479-L490
242,067
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L492-L510
242,068
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L512-L528
242,069
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", "." ]
0ab3c54c05133b9b0468c63e834a7ce3a6fb575b
https://github.com/OpenGov/carpenter/blob/0ab3c54c05133b9b0468c63e834a7ce3a6fb575b/carpenter/blocks/block.py#L530-L545
242,070
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", "." ]
47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea
https://github.com/FlorianLudwig/rueckenwind/blob/47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea/rw/static.py#L68-L104
242,071
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" ]
47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea
https://github.com/FlorianLudwig/rueckenwind/blob/47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea/rw/static.py#L151-L178
242,072
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", "." ]
47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea
https://github.com/FlorianLudwig/rueckenwind/blob/47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea/rw/static.py#L25-L37
242,073
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" ]
ac40a888ee9c388638a8f312c51f7500b8891b6c
https://github.com/BlueHack-Core/blueforge/blob/ac40a888ee9c388638a8f312c51f7500b8891b6c/blueforge/apis/s3.py#L8-L23
242,074
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" ]
ac40a888ee9c388638a8f312c51f7500b8891b6c
https://github.com/BlueHack-Core/blueforge/blob/ac40a888ee9c388638a8f312c51f7500b8891b6c/blueforge/apis/s3.py#L25-L29
242,075
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", "." ]
d68c9a083d443dfa5d7c5112de29010909cfe23f
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/parsed_locus.py#L38-L49
242,076
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", "." ]
72ee2f484b6202394dcda3db47245bc78ae2267d
https://github.com/shkarupa-alex/tfunicode/blob/72ee2f484b6202394dcda3db47245bc78ae2267d/tfunicode/python/ops/__init__.py#L26-L51
242,077
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" ]
72ee2f484b6202394dcda3db47245bc78ae2267d
https://github.com/shkarupa-alex/tfunicode/blob/72ee2f484b6202394dcda3db47245bc78ae2267d/tfunicode/python/ops/__init__.py#L54-L79
242,078
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", "." ]
72ee2f484b6202394dcda3db47245bc78ae2267d
https://github.com/shkarupa-alex/tfunicode/blob/72ee2f484b6202394dcda3db47245bc78ae2267d/tfunicode/python/ops/__init__.py#L131-L154
242,079
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" ]
72ee2f484b6202394dcda3db47245bc78ae2267d
https://github.com/shkarupa-alex/tfunicode/blob/72ee2f484b6202394dcda3db47245bc78ae2267d/tfunicode/python/ops/__init__.py#L305-L328
242,080
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", "." ]
6811af3daa88b42d76c4db372b58e2739d1f5595
https://github.com/Th3Gam3rz/UsefulUtils/blob/6811af3daa88b42d76c4db372b58e2739d1f5595/src/math.py#L1-L11
242,081
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", "." ]
5d3da2980d91a637f80ad7164fbf204a2dd2bd58
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L11-L52
242,082
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", "." ]
5d3da2980d91a637f80ad7164fbf204a2dd2bd58
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L82-L94
242,083
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", "." ]
5d3da2980d91a637f80ad7164fbf204a2dd2bd58
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L102-L126
242,084
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", "." ]
5d3da2980d91a637f80ad7164fbf204a2dd2bd58
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L128-L141
242,085
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", "." ]
5d3da2980d91a637f80ad7164fbf204a2dd2bd58
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L143-L152
242,086
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", "." ]
5d3da2980d91a637f80ad7164fbf204a2dd2bd58
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/library.py#L154-L174
242,087
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" ]
376041168874bbd6dee5ccfeece4a9e553223316
https://github.com/BlackEarth/bf/blob/376041168874bbd6dee5ccfeece4a9e553223316/bf/css.py#L48-L56
242,088
BlackEarth/bf
bf/css.py
CSS.merge_stylesheets
def merge_stylesheets(Class, fn, *cssfns): """merge the given CSS files, in order, into a single stylesheet. First listed takes priority. """ stylesheet = Class(fn=fn) for cssfn in cssfns: css = Class(fn=cssfn) for sel in sorted(css.styles.keys()): ...
python
def merge_stylesheets(Class, fn, *cssfns): """merge the given CSS files, in order, into a single stylesheet. First listed takes priority. """ stylesheet = Class(fn=fn) for cssfn in cssfns: css = Class(fn=cssfn) for sel in sorted(css.styles.keys()): ...
[ "def", "merge_stylesheets", "(", "Class", ",", "fn", ",", "*", "cssfns", ")", ":", "stylesheet", "=", "Class", "(", "fn", "=", "fn", ")", "for", "cssfn", "in", "cssfns", ":", "css", "=", "Class", "(", "fn", "=", "cssfn", ")", "for", "sel", "in", ...
merge the given CSS files, in order, into a single stylesheet. First listed takes priority.
[ "merge", "the", "given", "CSS", "files", "in", "order", "into", "a", "single", "stylesheet", ".", "First", "listed", "takes", "priority", "." ]
376041168874bbd6dee5ccfeece4a9e553223316
https://github.com/BlackEarth/bf/blob/376041168874bbd6dee5ccfeece4a9e553223316/bf/css.py#L76-L88
242,089
BlackEarth/bf
bf/css.py
CSS.all_selectors
def all_selectors(Class, fn): """return a sorted list of selectors that occur in the stylesheet""" selectors = [] cssparser = cssutils.CSSParser(validate=False) css = cssparser.parseFile(fn) for rule in [r for r in css.cssRules if type(r)==cssutils.css.CSSStyleRule]: ...
python
def all_selectors(Class, fn): """return a sorted list of selectors that occur in the stylesheet""" selectors = [] cssparser = cssutils.CSSParser(validate=False) css = cssparser.parseFile(fn) for rule in [r for r in css.cssRules if type(r)==cssutils.css.CSSStyleRule]: ...
[ "def", "all_selectors", "(", "Class", ",", "fn", ")", ":", "selectors", "=", "[", "]", "cssparser", "=", "cssutils", ".", "CSSParser", "(", "validate", "=", "False", ")", "css", "=", "cssparser", ".", "parseFile", "(", "fn", ")", "for", "rule", "in", ...
return a sorted list of selectors that occur in the stylesheet
[ "return", "a", "sorted", "list", "of", "selectors", "that", "occur", "in", "the", "stylesheet" ]
376041168874bbd6dee5ccfeece4a9e553223316
https://github.com/BlackEarth/bf/blob/376041168874bbd6dee5ccfeece4a9e553223316/bf/css.py#L91-L99
242,090
BlackEarth/bf
bf/css.py
CSS.selector_to_xpath
def selector_to_xpath(cls, selector, xmlns=None): """convert a css selector into an xpath expression. xmlns is option single-item dict with namespace prefix and href """ selector = selector.replace(' .', ' *.') if selector[0] == '.': selector = '*' + select...
python
def selector_to_xpath(cls, selector, xmlns=None): """convert a css selector into an xpath expression. xmlns is option single-item dict with namespace prefix and href """ selector = selector.replace(' .', ' *.') if selector[0] == '.': selector = '*' + select...
[ "def", "selector_to_xpath", "(", "cls", ",", "selector", ",", "xmlns", "=", "None", ")", ":", "selector", "=", "selector", ".", "replace", "(", "' .'", ",", "' *.'", ")", "if", "selector", "[", "0", "]", "==", "'.'", ":", "selector", "=", "'*'", "+",...
convert a css selector into an xpath expression. xmlns is option single-item dict with namespace prefix and href
[ "convert", "a", "css", "selector", "into", "an", "xpath", "expression", ".", "xmlns", "is", "option", "single", "-", "item", "dict", "with", "namespace", "prefix", "and", "href" ]
376041168874bbd6dee5ccfeece4a9e553223316
https://github.com/BlackEarth/bf/blob/376041168874bbd6dee5ccfeece4a9e553223316/bf/css.py#L102-L131
242,091
mikerhodes/actionqueues
actionqueues/aqstatemachine.py
AQStateMachine.transition_to_add
def transition_to_add(self): """Transition to add""" assert self.state in [AQStateMachineStates.init, AQStateMachineStates.add] self.state = AQStateMachineStates.add
python
def transition_to_add(self): """Transition to add""" assert self.state in [AQStateMachineStates.init, AQStateMachineStates.add] self.state = AQStateMachineStates.add
[ "def", "transition_to_add", "(", "self", ")", ":", "assert", "self", ".", "state", "in", "[", "AQStateMachineStates", ".", "init", ",", "AQStateMachineStates", ".", "add", "]", "self", ".", "state", "=", "AQStateMachineStates", ".", "add" ]
Transition to add
[ "Transition", "to", "add" ]
a7a78ab116abe88af95b5315dc9f34d40ce81eb2
https://github.com/mikerhodes/actionqueues/blob/a7a78ab116abe88af95b5315dc9f34d40ce81eb2/actionqueues/aqstatemachine.py#L44-L47
242,092
mikerhodes/actionqueues
actionqueues/aqstatemachine.py
AQStateMachine.transition_to_execute
def transition_to_execute(self): """Transition to execute""" assert self.state in [AQStateMachineStates.add] self.state = AQStateMachineStates.execute
python
def transition_to_execute(self): """Transition to execute""" assert self.state in [AQStateMachineStates.add] self.state = AQStateMachineStates.execute
[ "def", "transition_to_execute", "(", "self", ")", ":", "assert", "self", ".", "state", "in", "[", "AQStateMachineStates", ".", "add", "]", "self", ".", "state", "=", "AQStateMachineStates", ".", "execute" ]
Transition to execute
[ "Transition", "to", "execute" ]
a7a78ab116abe88af95b5315dc9f34d40ce81eb2
https://github.com/mikerhodes/actionqueues/blob/a7a78ab116abe88af95b5315dc9f34d40ce81eb2/actionqueues/aqstatemachine.py#L49-L52
242,093
mikerhodes/actionqueues
actionqueues/aqstatemachine.py
AQStateMachine.transition_to_rollback
def transition_to_rollback(self): """Transition to rollback""" assert self.state in [AQStateMachineStates.execute, AQStateMachineStates.execute_complete] self.state = AQStateMachineStates.rollback
python
def transition_to_rollback(self): """Transition to rollback""" assert self.state in [AQStateMachineStates.execute, AQStateMachineStates.execute_complete] self.state = AQStateMachineStates.rollback
[ "def", "transition_to_rollback", "(", "self", ")", ":", "assert", "self", ".", "state", "in", "[", "AQStateMachineStates", ".", "execute", ",", "AQStateMachineStates", ".", "execute_complete", "]", "self", ".", "state", "=", "AQStateMachineStates", ".", "rollback"...
Transition to rollback
[ "Transition", "to", "rollback" ]
a7a78ab116abe88af95b5315dc9f34d40ce81eb2
https://github.com/mikerhodes/actionqueues/blob/a7a78ab116abe88af95b5315dc9f34d40ce81eb2/actionqueues/aqstatemachine.py#L54-L57
242,094
mikerhodes/actionqueues
actionqueues/aqstatemachine.py
AQStateMachine.transition_to_execute_complete
def transition_to_execute_complete(self): """Transition to execute complate""" assert self.state in [AQStateMachineStates.execute] self.state = AQStateMachineStates.execute_complete
python
def transition_to_execute_complete(self): """Transition to execute complate""" assert self.state in [AQStateMachineStates.execute] self.state = AQStateMachineStates.execute_complete
[ "def", "transition_to_execute_complete", "(", "self", ")", ":", "assert", "self", ".", "state", "in", "[", "AQStateMachineStates", ".", "execute", "]", "self", ".", "state", "=", "AQStateMachineStates", ".", "execute_complete" ]
Transition to execute complate
[ "Transition", "to", "execute", "complate" ]
a7a78ab116abe88af95b5315dc9f34d40ce81eb2
https://github.com/mikerhodes/actionqueues/blob/a7a78ab116abe88af95b5315dc9f34d40ce81eb2/actionqueues/aqstatemachine.py#L59-L62
242,095
mikerhodes/actionqueues
actionqueues/aqstatemachine.py
AQStateMachine.transition_to_rollback_complete
def transition_to_rollback_complete(self): """Transition to rollback complete""" assert self.state in [AQStateMachineStates.rollback] self.state = AQStateMachineStates.rollback_complate
python
def transition_to_rollback_complete(self): """Transition to rollback complete""" assert self.state in [AQStateMachineStates.rollback] self.state = AQStateMachineStates.rollback_complate
[ "def", "transition_to_rollback_complete", "(", "self", ")", ":", "assert", "self", ".", "state", "in", "[", "AQStateMachineStates", ".", "rollback", "]", "self", ".", "state", "=", "AQStateMachineStates", ".", "rollback_complate" ]
Transition to rollback complete
[ "Transition", "to", "rollback", "complete" ]
a7a78ab116abe88af95b5315dc9f34d40ce81eb2
https://github.com/mikerhodes/actionqueues/blob/a7a78ab116abe88af95b5315dc9f34d40ce81eb2/actionqueues/aqstatemachine.py#L64-L67
242,096
romaryd/python-jsonrepo
jsonrepo/backends/memory.py
DictBackend.get
def get(self, key, sort_key): """ Get an element in dictionary """ key = self.prefixed('{}:{}'.format(key, sort_key)) self.logger.debug('Storage - get {}'.format(key)) if key not in self.cache.keys(): return None return self.cache[key]
python
def get(self, key, sort_key): """ Get an element in dictionary """ key = self.prefixed('{}:{}'.format(key, sort_key)) self.logger.debug('Storage - get {}'.format(key)) if key not in self.cache.keys(): return None return self.cache[key]
[ "def", "get", "(", "self", ",", "key", ",", "sort_key", ")", ":", "key", "=", "self", ".", "prefixed", "(", "'{}:{}'", ".", "format", "(", "key", ",", "sort_key", ")", ")", "self", ".", "logger", ".", "debug", "(", "'Storage - get {}'", ".", "format"...
Get an element in dictionary
[ "Get", "an", "element", "in", "dictionary" ]
08a9c039a5bd21e93e9a6d1bce77d43e6e10b57d
https://github.com/romaryd/python-jsonrepo/blob/08a9c039a5bd21e93e9a6d1bce77d43e6e10b57d/jsonrepo/backends/memory.py#L24-L30
242,097
romaryd/python-jsonrepo
jsonrepo/backends/memory.py
DictBackend.delete
def delete(self, key, sort_key): primary_key = key key = self.prefixed('{}:{}'.format(key, sort_key)) """ Delete an element in dictionary """ self.logger.debug('Storage - delete {}'.format(key)) if sort_key is not None: self.cache[self.prefixed(primary_key)].remove(so...
python
def delete(self, key, sort_key): primary_key = key key = self.prefixed('{}:{}'.format(key, sort_key)) """ Delete an element in dictionary """ self.logger.debug('Storage - delete {}'.format(key)) if sort_key is not None: self.cache[self.prefixed(primary_key)].remove(so...
[ "def", "delete", "(", "self", ",", "key", ",", "sort_key", ")", ":", "primary_key", "=", "key", "key", "=", "self", ".", "prefixed", "(", "'{}:{}'", ".", "format", "(", "key", ",", "sort_key", ")", ")", "self", ".", "logger", ".", "debug", "(", "'S...
Delete an element in dictionary
[ "Delete", "an", "element", "in", "dictionary" ]
08a9c039a5bd21e93e9a6d1bce77d43e6e10b57d
https://github.com/romaryd/python-jsonrepo/blob/08a9c039a5bd21e93e9a6d1bce77d43e6e10b57d/jsonrepo/backends/memory.py#L73-L86
242,098
lsst-sqre/sqre-apikit
apikit/convenience.py
set_flask_metadata
def set_flask_metadata(app, version, repository, description, api_version="1.0", name=None, auth=None, route=None): """ Sets metadata on the application to be returned via metadata routes. Parameters ---------- app : :class:`flask.Flask` instance ...
python
def set_flask_metadata(app, version, repository, description, api_version="1.0", name=None, auth=None, route=None): """ Sets metadata on the application to be returned via metadata routes. Parameters ---------- app : :class:`flask.Flask` instance ...
[ "def", "set_flask_metadata", "(", "app", ",", "version", ",", "repository", ",", "description", ",", "api_version", "=", "\"1.0\"", ",", "name", "=", "None", ",", "auth", "=", "None", ",", "route", "=", "None", ")", ":", "errstr", "=", "set_flask_metadata"...
Sets metadata on the application to be returned via metadata routes. Parameters ---------- app : :class:`flask.Flask` instance Flask application for the microservice you're adding metadata to. version: `str` Version of your microservice. repository: `str` URL of the reposi...
[ "Sets", "metadata", "on", "the", "application", "to", "be", "returned", "via", "metadata", "routes", "." ]
ff505b63d2e29303ff7f05f2bd5eabd0f6d7026e
https://github.com/lsst-sqre/sqre-apikit/blob/ff505b63d2e29303ff7f05f2bd5eabd0f6d7026e/apikit/convenience.py#L15-L101
242,099
lsst-sqre/sqre-apikit
apikit/convenience.py
raise_ise
def raise_ise(text): """Turn a failed request response into a BackendError that represents an Internal Server Error. Handy for reflecting HTTP errors from farther back in the call chain as failures of your service. Parameters ---------- text: `str` Error text. Raises ------ ...
python
def raise_ise(text): """Turn a failed request response into a BackendError that represents an Internal Server Error. Handy for reflecting HTTP errors from farther back in the call chain as failures of your service. Parameters ---------- text: `str` Error text. Raises ------ ...
[ "def", "raise_ise", "(", "text", ")", ":", "if", "isinstance", "(", "text", ",", "Exception", ")", ":", "# Just in case we are exuberantly passed the entire Exception and", "# not its textual representation.", "text", "=", "str", "(", "text", ")", "raise", "BackendErro...
Turn a failed request response into a BackendError that represents an Internal Server Error. Handy for reflecting HTTP errors from farther back in the call chain as failures of your service. Parameters ---------- text: `str` Error text. Raises ------ :class:`apikit.BackendErro...
[ "Turn", "a", "failed", "request", "response", "into", "a", "BackendError", "that", "represents", "an", "Internal", "Server", "Error", ".", "Handy", "for", "reflecting", "HTTP", "errors", "from", "farther", "back", "in", "the", "call", "chain", "as", "failures"...
ff505b63d2e29303ff7f05f2bd5eabd0f6d7026e
https://github.com/lsst-sqre/sqre-apikit/blob/ff505b63d2e29303ff7f05f2bd5eabd0f6d7026e/apikit/convenience.py#L237-L259