repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
JawboneHealth/jhhalchemy
jhhalchemy/migrate.py
get_upgrade_lock
def get_upgrade_lock(dbname, connect_str, timeout=LOCK_TIMEOUT): """ Wait until you can get the lock, then yield it, and eventually release it. Inspired by: http://arr.gr/blog/2016/05/mysql-named-locks-in-python-context-managers/ :param dbname: database to upgrade :param connect_str: connection st...
python
def get_upgrade_lock(dbname, connect_str, timeout=LOCK_TIMEOUT): """ Wait until you can get the lock, then yield it, and eventually release it. Inspired by: http://arr.gr/blog/2016/05/mysql-named-locks-in-python-context-managers/ :param dbname: database to upgrade :param connect_str: connection st...
[ "def", "get_upgrade_lock", "(", "dbname", ",", "connect_str", ",", "timeout", "=", "LOCK_TIMEOUT", ")", ":", "#", "# Open connection and try to get the lock", "#", "engine", "=", "sqlalchemy", ".", "create_engine", "(", "connect_str", ")", "cursor", "=", "engine", ...
Wait until you can get the lock, then yield it, and eventually release it. Inspired by: http://arr.gr/blog/2016/05/mysql-named-locks-in-python-context-managers/ :param dbname: database to upgrade :param connect_str: connection string to the database :param timeout: how long to wait between tries for t...
[ "Wait", "until", "you", "can", "get", "the", "lock", "then", "yield", "it", "and", "eventually", "release", "it", "." ]
ca0011d644e404561a142c9d7f0a8a569f1f4f27
https://github.com/JawboneHealth/jhhalchemy/blob/ca0011d644e404561a142c9d7f0a8a569f1f4f27/jhhalchemy/migrate.py#L25-L61
train
Get the upgrade lock.
JawboneHealth/jhhalchemy
jhhalchemy/migrate.py
upgrade
def upgrade(dbname, connect_str, alembic_conf): """ Get the database's upgrade lock and run alembic. :param dbname: Name of the database to upgrade/create :param connect_str: Connection string to the database (usually Flask's SQLALCHEMY_DATABASE_URI) :param alembic_conf: location of alembic.ini ...
python
def upgrade(dbname, connect_str, alembic_conf): """ Get the database's upgrade lock and run alembic. :param dbname: Name of the database to upgrade/create :param connect_str: Connection string to the database (usually Flask's SQLALCHEMY_DATABASE_URI) :param alembic_conf: location of alembic.ini ...
[ "def", "upgrade", "(", "dbname", ",", "connect_str", ",", "alembic_conf", ")", ":", "#", "# The db has to exist before we can get the lock. On the off-chance that another process creates the db between", "# checking if it exists and running the create, ignore the exception.", "#", "if", ...
Get the database's upgrade lock and run alembic. :param dbname: Name of the database to upgrade/create :param connect_str: Connection string to the database (usually Flask's SQLALCHEMY_DATABASE_URI) :param alembic_conf: location of alembic.ini
[ "Get", "the", "database", "s", "upgrade", "lock", "and", "run", "alembic", "." ]
ca0011d644e404561a142c9d7f0a8a569f1f4f27
https://github.com/JawboneHealth/jhhalchemy/blob/ca0011d644e404561a142c9d7f0a8a569f1f4f27/jhhalchemy/migrate.py#L64-L90
train
Get the database s upgrade lock and run alembic.
gofed/gofedlib
gofedlib/distribution/packagemanager.py
PackageManager.getPackages
def getPackages(self, distribution = "rawhide"): """ :param distribution: package distribution :type distribution: string :returns: [string] :raises KeyError: if distribution not found """ if self._packages == {}: file_location = "%s/data/distribution_packages.json" % getScriptDir(__file__) with op...
python
def getPackages(self, distribution = "rawhide"): """ :param distribution: package distribution :type distribution: string :returns: [string] :raises KeyError: if distribution not found """ if self._packages == {}: file_location = "%s/data/distribution_packages.json" % getScriptDir(__file__) with op...
[ "def", "getPackages", "(", "self", ",", "distribution", "=", "\"rawhide\"", ")", ":", "if", "self", ".", "_packages", "==", "{", "}", ":", "file_location", "=", "\"%s/data/distribution_packages.json\"", "%", "getScriptDir", "(", "__file__", ")", "with", "open", ...
:param distribution: package distribution :type distribution: string :returns: [string] :raises KeyError: if distribution not found
[ ":", "param", "distribution", ":", "package", "distribution", ":", "type", "distribution", ":", "string", ":", "returns", ":", "[", "string", "]", ":", "raises", "KeyError", ":", "if", "distribution", "not", "found" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/distribution/packagemanager.py#L9-L27
train
returns list of packages in distribution
geophysics-ubonn/crtomo_tools
lib/crtomo/cfg.py
crmod_config._check_and_convert_bools
def _check_and_convert_bools(self): """Replace boolean variables by the characters 'F'/'T' """ replacements = { True: 'T', False: 'F', } for key in self.bools: if isinstance(self[key], bool): self[key] = replacements[self[key]]
python
def _check_and_convert_bools(self): """Replace boolean variables by the characters 'F'/'T' """ replacements = { True: 'T', False: 'F', } for key in self.bools: if isinstance(self[key], bool): self[key] = replacements[self[key]]
[ "def", "_check_and_convert_bools", "(", "self", ")", ":", "replacements", "=", "{", "True", ":", "'T'", ",", "False", ":", "'F'", ",", "}", "for", "key", "in", "self", ".", "bools", ":", "if", "isinstance", "(", "self", "[", "key", "]", ",", "bool", ...
Replace boolean variables by the characters 'F'/'T'
[ "Replace", "boolean", "variables", "by", "the", "characters", "F", "/", "T" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/cfg.py#L81-L91
train
Replace boolean variables by the characters F / T
geophysics-ubonn/crtomo_tools
lib/crtomo/cfg.py
crmod_config.set_defaults
def set_defaults(self): """ Fill the dictionary with all defaults """ self['mswitch'] = '***FILES***' self['elem'] = '../grid/elem.dat' self['elec'] = '../grid/elec.dat' self['rho'] = '../rho/rho.dat' self['config'] = '../config/config.dat' self['w...
python
def set_defaults(self): """ Fill the dictionary with all defaults """ self['mswitch'] = '***FILES***' self['elem'] = '../grid/elem.dat' self['elec'] = '../grid/elec.dat' self['rho'] = '../rho/rho.dat' self['config'] = '../config/config.dat' self['w...
[ "def", "set_defaults", "(", "self", ")", ":", "self", "[", "'mswitch'", "]", "=", "'***FILES***'", "self", "[", "'elem'", "]", "=", "'../grid/elem.dat'", "self", "[", "'elec'", "]", "=", "'../grid/elec.dat'", "self", "[", "'rho'", "]", "=", "'../rho/rho.dat'...
Fill the dictionary with all defaults
[ "Fill", "the", "dictionary", "with", "all", "defaults" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/cfg.py#L107-L127
train
Fill the dictionary with all default values
geophysics-ubonn/crtomo_tools
lib/crtomo/cfg.py
crtomo_config.set_defaults
def set_defaults(self): """Fill the dictionary with all defaults """ self['mswitch'] = 1 self['elem'] = '../grid/elem.dat' self['elec'] = '../grid/elec.dat' self['volt'] = '../mod/volt.dat' self['inv_dir'] = '../inv' self['diff_inv'] = 'F ! difference inve...
python
def set_defaults(self): """Fill the dictionary with all defaults """ self['mswitch'] = 1 self['elem'] = '../grid/elem.dat' self['elec'] = '../grid/elec.dat' self['volt'] = '../mod/volt.dat' self['inv_dir'] = '../inv' self['diff_inv'] = 'F ! difference inve...
[ "def", "set_defaults", "(", "self", ")", ":", "self", "[", "'mswitch'", "]", "=", "1", "self", "[", "'elem'", "]", "=", "'../grid/elem.dat'", "self", "[", "'elec'", "]", "=", "'../grid/elec.dat'", "self", "[", "'volt'", "]", "=", "'../mod/volt.dat'", "self...
Fill the dictionary with all defaults
[ "Fill", "the", "dictionary", "with", "all", "defaults" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/cfg.py#L180-L214
train
Fill the dictionary with all default values
geophysics-ubonn/crtomo_tools
lib/crtomo/cfg.py
crtomo_config.write_to_file
def write_to_file(self, filename): """ Write the configuration to a file. Use the correct order of values. """ fid = open(filename, 'w') for key in self.key_order: if(key == -1): fid.write('\n') else: fid.write('{0}\n'.format(self[...
python
def write_to_file(self, filename): """ Write the configuration to a file. Use the correct order of values. """ fid = open(filename, 'w') for key in self.key_order: if(key == -1): fid.write('\n') else: fid.write('{0}\n'.format(self[...
[ "def", "write_to_file", "(", "self", ",", "filename", ")", ":", "fid", "=", "open", "(", "filename", ",", "'w'", ")", "for", "key", "in", "self", ".", "key_order", ":", "if", "(", "key", "==", "-", "1", ")", ":", "fid", ".", "write", "(", "'\\n'"...
Write the configuration to a file. Use the correct order of values.
[ "Write", "the", "configuration", "to", "a", "file", ".", "Use", "the", "correct", "order", "of", "values", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/cfg.py#L216-L227
train
Write the configuration to a file.
gofed/gofedlib
gofedlib/go/importpath/parser.py
ImportPathParser.parse
def parse(self, importpath): """Parse import path. Determine if the path is native or starts with known prefix. :param importpath: import path to parse :type importpath: str :return: bool """ # reset default values self.native = False self._prefix = "" self._package = "" url = re.sub(r'http://', ...
python
def parse(self, importpath): """Parse import path. Determine if the path is native or starts with known prefix. :param importpath: import path to parse :type importpath: str :return: bool """ # reset default values self.native = False self._prefix = "" self._package = "" url = re.sub(r'http://', ...
[ "def", "parse", "(", "self", ",", "importpath", ")", ":", "# reset default values", "self", ".", "native", "=", "False", "self", ".", "_prefix", "=", "\"\"", "self", ".", "_package", "=", "\"\"", "url", "=", "re", ".", "sub", "(", "r'http://'", ",", "'...
Parse import path. Determine if the path is native or starts with known prefix. :param importpath: import path to parse :type importpath: str :return: bool
[ "Parse", "import", "path", ".", "Determine", "if", "the", "path", "is", "native", "or", "starts", "with", "known", "prefix", "." ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/go/importpath/parser.py#L22-L50
train
Parse the import path and return a boolean indicating if it is native or not.
albert12132/templar
templar/markdown.py
sub_retab
def sub_retab(match): r"""Remove all tabs and convert them into spaces. PARAMETERS: match -- regex match; uses re_retab pattern: \1 is text before tab, \2 is a consecutive string of tabs. A simple substitution of 4 spaces would result in the following: to\tlive # original ...
python
def sub_retab(match): r"""Remove all tabs and convert them into spaces. PARAMETERS: match -- regex match; uses re_retab pattern: \1 is text before tab, \2 is a consecutive string of tabs. A simple substitution of 4 spaces would result in the following: to\tlive # original ...
[ "def", "sub_retab", "(", "match", ")", ":", "before", "=", "match", ".", "group", "(", "1", ")", "tabs", "=", "len", "(", "match", ".", "group", "(", "2", ")", ")", "return", "before", "+", "(", "' '", "*", "(", "TAB_SIZE", "*", "tabs", "-", "l...
r"""Remove all tabs and convert them into spaces. PARAMETERS: match -- regex match; uses re_retab pattern: \1 is text before tab, \2 is a consecutive string of tabs. A simple substitution of 4 spaces would result in the following: to\tlive # original to live # simple s...
[ "r", "Remove", "all", "tabs", "and", "convert", "them", "into", "spaces", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L81-L101
train
r Removes all tabs and convert them into spaces.
albert12132/templar
templar/markdown.py
handle_whitespace
def handle_whitespace(text): r"""Handles whitespace cleanup. Tabs are "smartly" retabbed (see sub_retab). Lines that contain only whitespace are truncated to a single newline. """ text = re_retab.sub(sub_retab, text) text = re_whitespace.sub('', text).strip() return text
python
def handle_whitespace(text): r"""Handles whitespace cleanup. Tabs are "smartly" retabbed (see sub_retab). Lines that contain only whitespace are truncated to a single newline. """ text = re_retab.sub(sub_retab, text) text = re_whitespace.sub('', text).strip() return text
[ "def", "handle_whitespace", "(", "text", ")", ":", "text", "=", "re_retab", ".", "sub", "(", "sub_retab", ",", "text", ")", "text", "=", "re_whitespace", ".", "sub", "(", "''", ",", "text", ")", ".", "strip", "(", ")", "return", "text" ]
r"""Handles whitespace cleanup. Tabs are "smartly" retabbed (see sub_retab). Lines that contain only whitespace are truncated to a single newline.
[ "r", "Handles", "whitespace", "cleanup", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L103-L111
train
r Handles whitespace cleanup.
albert12132/templar
templar/markdown.py
get_variables
def get_variables(text): """Extracts variables that can be used in templating engines. Each variable is defined on a single line in the following way: ~ var: text The ~ must be at the start of a newline, followed by at least one space. var can be any sequence of characters that does not conta...
python
def get_variables(text): """Extracts variables that can be used in templating engines. Each variable is defined on a single line in the following way: ~ var: text The ~ must be at the start of a newline, followed by at least one space. var can be any sequence of characters that does not conta...
[ "def", "get_variables", "(", "text", ")", ":", "variables", "=", "{", "var", ":", "value", "for", "var", ",", "value", "in", "re_vars", ".", "findall", "(", "text", ")", "}", "text", "=", "re_vars", ".", "sub", "(", "''", ",", "text", ")", "return"...
Extracts variables that can be used in templating engines. Each variable is defined on a single line in the following way: ~ var: text The ~ must be at the start of a newline, followed by at least one space. var can be any sequence of characters that does not contain a ":". text can be any se...
[ "Extracts", "variables", "that", "can", "be", "used", "in", "templating", "engines", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L120-L137
train
Extracts variables that can be used in templating engines.
albert12132/templar
templar/markdown.py
get_references
def get_references(text): """Retrieves all link references within the text. Link references can be defined anywhere in the text, and look like this: [id]: www.example.com "optional title" A link (either <a> or <img>) can then refer to the link reference: [this is a link][id] Lin...
python
def get_references(text): """Retrieves all link references within the text. Link references can be defined anywhere in the text, and look like this: [id]: www.example.com "optional title" A link (either <a> or <img>) can then refer to the link reference: [this is a link][id] Lin...
[ "def", "get_references", "(", "text", ")", ":", "references", "=", "{", "}", "for", "ref_id", ",", "link", ",", "_", ",", "title", "in", "re_references", ".", "findall", "(", "text", ")", ":", "ref_id", "=", "re", ".", "sub", "(", "r'<(.*?)>'", ",", ...
Retrieves all link references within the text. Link references can be defined anywhere in the text, and look like this: [id]: www.example.com "optional title" A link (either <a> or <img>) can then refer to the link reference: [this is a link][id] Link IDs are case insensitive. Link ...
[ "Retrieves", "all", "link", "references", "within", "the", "text", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L155-L180
train
Retrieves all link references within the text.
albert12132/templar
templar/markdown.py
get_footnote_backreferences
def get_footnote_backreferences(text, markdown_obj): """Retrieves all footnote backreferences within the text. Fotnote backreferences can be defined anywhere in the text, and look like this: [^id]: text The corresponding footnote reference can then be placed anywhere in the text ...
python
def get_footnote_backreferences(text, markdown_obj): """Retrieves all footnote backreferences within the text. Fotnote backreferences can be defined anywhere in the text, and look like this: [^id]: text The corresponding footnote reference can then be placed anywhere in the text ...
[ "def", "get_footnote_backreferences", "(", "text", ",", "markdown_obj", ")", ":", "footnotes", "=", "OrderedDict", "(", ")", "for", "footnote_id", ",", "footnote", "in", "re_footnote_backreferences", ".", "findall", "(", "text", ")", ":", "footnote_id", "=", "re...
Retrieves all footnote backreferences within the text. Fotnote backreferences can be defined anywhere in the text, and look like this: [^id]: text The corresponding footnote reference can then be placed anywhere in the text This is some text.[^id] Footnote IDs are case insensiti...
[ "Retrieves", "all", "footnote", "backreferences", "within", "the", "text", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L194-L221
train
Retrieves all footnote backreferences within the text.
albert12132/templar
templar/markdown.py
hash_blocks
def hash_blocks(text, hashes): """Hashes HTML block tags. PARAMETERS: text -- str; Markdown text hashes -- dict; a dictionary of all hashes, where keys are hashes and values are their unhashed versions. When HTML block tags are used, all content inside the tags is preserved as-...
python
def hash_blocks(text, hashes): """Hashes HTML block tags. PARAMETERS: text -- str; Markdown text hashes -- dict; a dictionary of all hashes, where keys are hashes and values are their unhashed versions. When HTML block tags are used, all content inside the tags is preserved as-...
[ "def", "hash_blocks", "(", "text", ",", "hashes", ")", ":", "def", "sub", "(", "match", ")", ":", "block", "=", "match", ".", "group", "(", "1", ")", "hashed", "=", "hash_text", "(", "block", ",", "'block'", ")", "hashes", "[", "hashed", "]", "=", ...
Hashes HTML block tags. PARAMETERS: text -- str; Markdown text hashes -- dict; a dictionary of all hashes, where keys are hashes and values are their unhashed versions. When HTML block tags are used, all content inside the tags is preserved as-is, without any Markdown processing. S...
[ "Hashes", "HTML", "block", "tags", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L282-L299
train
Hashes HTML block tags.
albert12132/templar
templar/markdown.py
hash_lists
def hash_lists(text, hashes, markdown_obj): """Hashes ordered and unordered lists. re_list captures as many consecutive list items as possible and groups them into one list. Before hashing the lists, the items are recursively converted from Markdown to HTML. Upon unhashing, the lists will be ready ...
python
def hash_lists(text, hashes, markdown_obj): """Hashes ordered and unordered lists. re_list captures as many consecutive list items as possible and groups them into one list. Before hashing the lists, the items are recursively converted from Markdown to HTML. Upon unhashing, the lists will be ready ...
[ "def", "hash_lists", "(", "text", ",", "hashes", ",", "markdown_obj", ")", ":", "for", "style", ",", "marker", "in", "(", "(", "'u'", ",", "'[+*-]'", ")", ",", "(", "'o'", ",", "r'\\d+\\.'", ")", ")", ":", "list_re", "=", "re", ".", "compile", "(",...
Hashes ordered and unordered lists. re_list captures as many consecutive list items as possible and groups them into one list. Before hashing the lists, the items are recursively converted from Markdown to HTML. Upon unhashing, the lists will be ready in their final form. An attempt at list format...
[ "Hashes", "ordered", "and", "unordered", "lists", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L320-L370
train
Hashes ordered and unordered lists.
albert12132/templar
templar/markdown.py
hash_codeblocks
def hash_codeblocks(text, hashes): """Hashes codeblocks (<pre> elements). Codeblocks are strictly defined to be (non-list) lines that are indented at least 4 spaces from the newline. Exactly 4 spaces will be stripped from the beginning of the line -- any leading whitespace after that is preserved. ...
python
def hash_codeblocks(text, hashes): """Hashes codeblocks (<pre> elements). Codeblocks are strictly defined to be (non-list) lines that are indented at least 4 spaces from the newline. Exactly 4 spaces will be stripped from the beginning of the line -- any leading whitespace after that is preserved. ...
[ "def", "hash_codeblocks", "(", "text", ",", "hashes", ")", ":", "def", "sub", "(", "match", ")", ":", "block", "=", "match", ".", "group", "(", "1", ")", ".", "rstrip", "(", "'\\n'", ")", "block", "=", "re", ".", "sub", "(", "r'(?:(?<=\\n)|(?<=\\A)) ...
Hashes codeblocks (<pre> elements). Codeblocks are strictly defined to be (non-list) lines that are indented at least 4 spaces from the newline. Exactly 4 spaces will be stripped from the beginning of the line -- any leading whitespace after that is preserved. Codeblock lines that are separated on...
[ "Hashes", "codeblocks", "(", "<pre", ">", "elements", ")", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L382-L408
train
Hashes codeblocks in text.
albert12132/templar
templar/markdown.py
hash_blockquotes
def hash_blockquotes(text, hashes, markdown_obj): """Hashes block quotes. Block quotes are defined to be lines that start with "> " (the space is not optional). All Markdown syntax in a blockquote is recursively converted, which allows (among other things) headers, codeblocks, and blockquotes ...
python
def hash_blockquotes(text, hashes, markdown_obj): """Hashes block quotes. Block quotes are defined to be lines that start with "> " (the space is not optional). All Markdown syntax in a blockquote is recursively converted, which allows (among other things) headers, codeblocks, and blockquotes ...
[ "def", "hash_blockquotes", "(", "text", ",", "hashes", ",", "markdown_obj", ")", ":", "def", "sub", "(", "match", ")", ":", "block", "=", "match", ".", "group", "(", "1", ")", ".", "strip", "(", ")", "block", "=", "re", ".", "sub", "(", "r'(?:(?<=\...
Hashes block quotes. Block quotes are defined to be lines that start with "> " (the space is not optional). All Markdown syntax in a blockquote is recursively converted, which allows (among other things) headers, codeblocks, and blockquotes to be used inside of blockquotes. The "> " is simply ...
[ "Hashes", "block", "quotes", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L418-L438
train
Hashes block quotes.
albert12132/templar
templar/markdown.py
hash_codes
def hash_codes(text, hashes): """Hashes inline code tags. Code tags can begin with an arbitrary number of back-ticks, as long as the close contains the same number of back-ticks. This allows back-ticks to be used within the code tag. HTML entities (&, <, >, ", ') are automatically escaped inside t...
python
def hash_codes(text, hashes): """Hashes inline code tags. Code tags can begin with an arbitrary number of back-ticks, as long as the close contains the same number of back-ticks. This allows back-ticks to be used within the code tag. HTML entities (&, <, >, ", ') are automatically escaped inside t...
[ "def", "hash_codes", "(", "text", ",", "hashes", ")", ":", "def", "sub", "(", "match", ")", ":", "code", "=", "'<code>{}</code>'", ".", "format", "(", "escape", "(", "match", ".", "group", "(", "2", ")", ")", ")", "hashed", "=", "hash_text", "(", "...
Hashes inline code tags. Code tags can begin with an arbitrary number of back-ticks, as long as the close contains the same number of back-ticks. This allows back-ticks to be used within the code tag. HTML entities (&, <, >, ", ') are automatically escaped inside the code tag.
[ "Hashes", "inline", "code", "tags", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L491-L506
train
Hashes inline code tags.
albert12132/templar
templar/markdown.py
hash_inline_links
def hash_inline_links(text, hashes, markdown_obj): """Hashes an <a> link or an <img> link. This function only converts inline link styles: [text here](path/to/resource "optional title") ![alt text here](path/to/resource "optional title") For reference style links, see hash_reference_links...
python
def hash_inline_links(text, hashes, markdown_obj): """Hashes an <a> link or an <img> link. This function only converts inline link styles: [text here](path/to/resource "optional title") ![alt text here](path/to/resource "optional title") For reference style links, see hash_reference_links...
[ "def", "hash_inline_links", "(", "text", ",", "hashes", ",", "markdown_obj", ")", ":", "def", "sub", "(", "match", ")", ":", "is_img", "=", "match", ".", "group", "(", "1", ")", "!=", "''", "content", "=", "match", ".", "group", "(", "2", ")", "lin...
Hashes an <a> link or an <img> link. This function only converts inline link styles: [text here](path/to/resource "optional title") ![alt text here](path/to/resource "optional title") For reference style links, see hash_reference_links
[ "Hashes", "an", "<a", ">", "link", "or", "an", "<img", ">", "link", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L525-L554
train
Hashes inline links.
albert12132/templar
templar/markdown.py
hash_reference_links
def hash_reference_links(text, hashes, markdown_obj): """Hashes an <a> link or an <img> link. This function only converts reference link styles: [text here][ref id] ![alt text here][ref id] For inline style links, see hash_inline_links. Reference ids can be defined anywhere in the Ma...
python
def hash_reference_links(text, hashes, markdown_obj): """Hashes an <a> link or an <img> link. This function only converts reference link styles: [text here][ref id] ![alt text here][ref id] For inline style links, see hash_inline_links. Reference ids can be defined anywhere in the Ma...
[ "def", "hash_reference_links", "(", "text", ",", "hashes", ",", "markdown_obj", ")", ":", "def", "sub", "(", "match", ")", ":", "is_img", "=", "match", ".", "group", "(", "1", ")", "!=", "''", "content", "=", "match", ".", "group", "(", "2", ")", "...
Hashes an <a> link or an <img> link. This function only converts reference link styles: [text here][ref id] ![alt text here][ref id] For inline style links, see hash_inline_links. Reference ids can be defined anywhere in the Markdown text. Reference ids can also be omitted, in which ...
[ "Hashes", "an", "<a", ">", "link", "or", "an", "<img", ">", "link", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L564-L605
train
Hashes an implicit link or inline style link.
albert12132/templar
templar/markdown.py
hash_footnote_reference
def hash_footnote_reference(text, hashes, markdown_obj): """Hashes a footnote [^id] reference This function converts footnote styles: text here[^id] Footnotes can be defined anywhere in the Markdown text. """ footnotes = markdown_obj.footnotes numbers = {f: i+1 for i, f in enumerate(f...
python
def hash_footnote_reference(text, hashes, markdown_obj): """Hashes a footnote [^id] reference This function converts footnote styles: text here[^id] Footnotes can be defined anywhere in the Markdown text. """ footnotes = markdown_obj.footnotes numbers = {f: i+1 for i, f in enumerate(f...
[ "def", "hash_footnote_reference", "(", "text", ",", "hashes", ",", "markdown_obj", ")", ":", "footnotes", "=", "markdown_obj", ".", "footnotes", "numbers", "=", "{", "f", ":", "i", "+", "1", "for", "i", ",", "f", "in", "enumerate", "(", "footnotes", ")",...
Hashes a footnote [^id] reference This function converts footnote styles: text here[^id] Footnotes can be defined anywhere in the Markdown text.
[ "Hashes", "a", "footnote", "[", "^id", "]", "reference" ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L611-L631
train
Hashes a footnote reference text here.
albert12132/templar
templar/markdown.py
hash_tags
def hash_tags(text, hashes): """Hashes any non-block tags. Only the tags themselves are hashed -- the contains surrounded by tags are not touched. Indeed, there is no notion of "contained" text for non-block tags. Inline tags that are to be hashed are not white-listed, which allows users to de...
python
def hash_tags(text, hashes): """Hashes any non-block tags. Only the tags themselves are hashed -- the contains surrounded by tags are not touched. Indeed, there is no notion of "contained" text for non-block tags. Inline tags that are to be hashed are not white-listed, which allows users to de...
[ "def", "hash_tags", "(", "text", ",", "hashes", ")", ":", "def", "sub", "(", "match", ")", ":", "hashed", "=", "hash_text", "(", "match", ".", "group", "(", "0", ")", ",", "'tag'", ")", "hashes", "[", "hashed", "]", "=", "match", ".", "group", "(...
Hashes any non-block tags. Only the tags themselves are hashed -- the contains surrounded by tags are not touched. Indeed, there is no notion of "contained" text for non-block tags. Inline tags that are to be hashed are not white-listed, which allows users to define their own tags. These user-defi...
[ "Hashes", "any", "non", "-", "block", "tags", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L634-L650
train
Hashes any non - block tags.
albert12132/templar
templar/markdown.py
unhash
def unhash(text, hashes): """Unhashes all hashed entites in the hashes dictionary. The pattern for hashes is defined by re_hash. After everything is unhashed, <pre> blocks are "pulled out" of whatever indentation level in which they used to be (e.g. in a list). """ def retrieve_match(match): ...
python
def unhash(text, hashes): """Unhashes all hashed entites in the hashes dictionary. The pattern for hashes is defined by re_hash. After everything is unhashed, <pre> blocks are "pulled out" of whatever indentation level in which they used to be (e.g. in a list). """ def retrieve_match(match): ...
[ "def", "unhash", "(", "text", ",", "hashes", ")", ":", "def", "retrieve_match", "(", "match", ")", ":", "return", "hashes", "[", "match", ".", "group", "(", "0", ")", "]", "while", "re_hash", ".", "search", "(", "text", ")", ":", "text", "=", "re_h...
Unhashes all hashed entites in the hashes dictionary. The pattern for hashes is defined by re_hash. After everything is unhashed, <pre> blocks are "pulled out" of whatever indentation level in which they used to be (e.g. in a list).
[ "Unhashes", "all", "hashed", "entites", "in", "the", "hashes", "dictionary", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L673-L685
train
Unhashes all hashed entites in the text.
albert12132/templar
templar/markdown.py
emphasis_sub
def emphasis_sub(match): """Substitutes <strong>, <em>, and <strong><em> tags.""" level = len(match.group(1)) content = match.group(2) if level == 3: return '<strong><em>{0}</em></strong>'.format(content) elif level == 2: return '<strong>{0}</strong>'.format(content) elif level =...
python
def emphasis_sub(match): """Substitutes <strong>, <em>, and <strong><em> tags.""" level = len(match.group(1)) content = match.group(2) if level == 3: return '<strong><em>{0}</em></strong>'.format(content) elif level == 2: return '<strong>{0}</strong>'.format(content) elif level =...
[ "def", "emphasis_sub", "(", "match", ")", ":", "level", "=", "len", "(", "match", ".", "group", "(", "1", ")", ")", "content", "=", "match", ".", "group", "(", "2", ")", "if", "level", "==", "3", ":", "return", "'<strong><em>{0}</em></strong>'", ".", ...
Substitutes <strong>, <em>, and <strong><em> tags.
[ "Substitutes", "<strong", ">", "<em", ">", "and", "<strong", ">", "<em", ">", "tags", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L720-L729
train
Substitutes <strong > and <em > tags.
albert12132/templar
templar/markdown.py
atx_header_sub
def atx_header_sub(match): """Substitutes atx headers (headers defined using #'s).""" level = len(match.group(1)) title = match.group(2) id_class = '' ids = match.group(3) if match.group(3) else '' id_match = re.search('#([\w-]+)', ids) if id_match: id_class += ' id="' + id_match.gr...
python
def atx_header_sub(match): """Substitutes atx headers (headers defined using #'s).""" level = len(match.group(1)) title = match.group(2) id_class = '' ids = match.group(3) if match.group(3) else '' id_match = re.search('#([\w-]+)', ids) if id_match: id_class += ' id="' + id_match.gr...
[ "def", "atx_header_sub", "(", "match", ")", ":", "level", "=", "len", "(", "match", ".", "group", "(", "1", ")", ")", "title", "=", "match", ".", "group", "(", "2", ")", "id_class", "=", "''", "ids", "=", "match", ".", "group", "(", "3", ")", "...
Substitutes atx headers (headers defined using #'s).
[ "Substitutes", "atx", "headers", "(", "headers", "defined", "using", "#", "s", ")", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L772-L785
train
Substitutes atx headers ( headers defined using. s ).
albert12132/templar
templar/markdown.py
paragraph_sub
def paragraph_sub(match): """Captures paragraphs.""" text = re.sub(r' \n', r'\n<br/>\n', match.group(0).strip()) return '<p>{}</p>'.format(text)
python
def paragraph_sub(match): """Captures paragraphs.""" text = re.sub(r' \n', r'\n<br/>\n', match.group(0).strip()) return '<p>{}</p>'.format(text)
[ "def", "paragraph_sub", "(", "match", ")", ":", "text", "=", "re", ".", "sub", "(", "r' \\n'", ",", "r'\\n<br/>\\n'", ",", "match", ".", "group", "(", "0", ")", ".", "strip", "(", ")", ")", "return", "'<p>{}</p>'", ".", "format", "(", "text", ")" ]
Captures paragraphs.
[ "Captures", "paragraphs", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L845-L848
train
Captures paragraphs.
albert12132/templar
templar/markdown.py
slug_sub
def slug_sub(match): """Assigns id-less headers a slug that is derived from their titles. Slugs are generated by lower-casing the titles, stripping all punctuation, and converting spaces to hyphens (-). """ level = match.group(1) title = match.group(2) slug = title.lower() slug = re.sub(...
python
def slug_sub(match): """Assigns id-less headers a slug that is derived from their titles. Slugs are generated by lower-casing the titles, stripping all punctuation, and converting spaces to hyphens (-). """ level = match.group(1) title = match.group(2) slug = title.lower() slug = re.sub(...
[ "def", "slug_sub", "(", "match", ")", ":", "level", "=", "match", ".", "group", "(", "1", ")", "title", "=", "match", ".", "group", "(", "2", ")", "slug", "=", "title", ".", "lower", "(", ")", "slug", "=", "re", ".", "sub", "(", "r'<.+?>|[^\\w-]'...
Assigns id-less headers a slug that is derived from their titles. Slugs are generated by lower-casing the titles, stripping all punctuation, and converting spaces to hyphens (-).
[ "Assigns", "id", "-", "less", "headers", "a", "slug", "that", "is", "derived", "from", "their", "titles", ".", "Slugs", "are", "generated", "by", "lower", "-", "casing", "the", "titles", "stripping", "all", "punctuation", "and", "converting", "spaces", "to",...
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/markdown.py#L877-L890
train
Assigns id - less headers a slug that is derived from their titles.
gofed/gofedlib
gofedlib/graphs/graphutils.py
GraphUtils.truncateGraph
def truncateGraph(graph, root_nodes): """Create a set of all nodes containg the root_nodes and all nodes reacheable from them """ subgraph = Graph() for node in root_nodes: subgraph = GraphUtils.joinGraphs(subgraph, GraphUtils.getReacheableSubgraph(graph, node)) return subgraph
python
def truncateGraph(graph, root_nodes): """Create a set of all nodes containg the root_nodes and all nodes reacheable from them """ subgraph = Graph() for node in root_nodes: subgraph = GraphUtils.joinGraphs(subgraph, GraphUtils.getReacheableSubgraph(graph, node)) return subgraph
[ "def", "truncateGraph", "(", "graph", ",", "root_nodes", ")", ":", "subgraph", "=", "Graph", "(", ")", "for", "node", "in", "root_nodes", ":", "subgraph", "=", "GraphUtils", ".", "joinGraphs", "(", "subgraph", ",", "GraphUtils", ".", "getReacheableSubgraph", ...
Create a set of all nodes containg the root_nodes and all nodes reacheable from them
[ "Create", "a", "set", "of", "all", "nodes", "containg", "the", "root_nodes", "and", "all", "nodes", "reacheable", "from", "them" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/graphs/graphutils.py#L136-L144
train
Create a set of all nodes containg the root_nodes and all nodes reacheable from them and return the resulting subgraph
gofed/gofedlib
gofedlib/graphs/graphutils.py
GraphUtils.filterGraph
def filterGraph(graph, node_fnc): """Remove all nodes for with node_fnc does not hold """ nodes = filter(lambda l: node_fnc(l), graph.nodes()) edges = {} gedges = graph.edges() for u in gedges: if u not in nodes: continue for v in gedges[u]: if v not in nodes: continue try: edge...
python
def filterGraph(graph, node_fnc): """Remove all nodes for with node_fnc does not hold """ nodes = filter(lambda l: node_fnc(l), graph.nodes()) edges = {} gedges = graph.edges() for u in gedges: if u not in nodes: continue for v in gedges[u]: if v not in nodes: continue try: edge...
[ "def", "filterGraph", "(", "graph", ",", "node_fnc", ")", ":", "nodes", "=", "filter", "(", "lambda", "l", ":", "node_fnc", "(", "l", ")", ",", "graph", ".", "nodes", "(", ")", ")", "edges", "=", "{", "}", "gedges", "=", "graph", ".", "edges", "(...
Remove all nodes for with node_fnc does not hold
[ "Remove", "all", "nodes", "for", "with", "node_fnc", "does", "not", "hold" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/graphs/graphutils.py#L147-L165
train
Remove all nodes for with node_fnc does not hold
peterbe/gg
gg/builtins/commit/gg_commit.py
commit
def commit(config, no_verify): """Commit the current branch with all files.""" repo = config.repo active_branch = repo.active_branch if active_branch.name == "master": error_out( "Can't commit when on the master branch. " "You really ought to do work in branches." ...
python
def commit(config, no_verify): """Commit the current branch with all files.""" repo = config.repo active_branch = repo.active_branch if active_branch.name == "master": error_out( "Can't commit when on the master branch. " "You really ought to do work in branches." ...
[ "def", "commit", "(", "config", ",", "no_verify", ")", ":", "repo", "=", "config", ".", "repo", "active_branch", "=", "repo", ".", "active_branch", "if", "active_branch", ".", "name", "==", "\"master\"", ":", "error_out", "(", "\"Can't commit when on the master ...
Commit the current branch with all files.
[ "Commit", "the", "current", "branch", "with", "all", "files", "." ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/commit/gg_commit.py#L26-L241
train
Commit the current branch with all files.
peterbe/gg
gg/builtins/commit/gg_commit.py
_humanize_time
def _humanize_time(amount, units): """Chopped and changed from http://stackoverflow.com/a/6574789/205832""" intervals = (1, 60, 60 * 60, 60 * 60 * 24, 604800, 2419200, 29030400) names = ( ("second", "seconds"), ("minute", "minutes"), ("hour", "hours"), ("day", "days"), ...
python
def _humanize_time(amount, units): """Chopped and changed from http://stackoverflow.com/a/6574789/205832""" intervals = (1, 60, 60 * 60, 60 * 60 * 24, 604800, 2419200, 29030400) names = ( ("second", "seconds"), ("minute", "minutes"), ("hour", "hours"), ("day", "days"), ...
[ "def", "_humanize_time", "(", "amount", ",", "units", ")", ":", "intervals", "=", "(", "1", ",", "60", ",", "60", "*", "60", ",", "60", "*", "60", "*", "24", ",", "604800", ",", "2419200", ",", "29030400", ")", "names", "=", "(", "(", "\"second\"...
Chopped and changed from http://stackoverflow.com/a/6574789/205832
[ "Chopped", "and", "changed", "from", "http", ":", "//", "stackoverflow", ".", "com", "/", "a", "/", "6574789", "/", "205832" ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/commit/gg_commit.py#L244-L266
train
Convert amount to human readable format
tslight/treepick
treepick/paths.py
Paths.listdir
def listdir(self, path): ''' Return a list of all non dotfiles in a given directory. ''' for f in os.listdir(path): if not f.startswith('.'): yield f
python
def listdir(self, path): ''' Return a list of all non dotfiles in a given directory. ''' for f in os.listdir(path): if not f.startswith('.'): yield f
[ "def", "listdir", "(", "self", ",", "path", ")", ":", "for", "f", "in", "os", ".", "listdir", "(", "path", ")", ":", "if", "not", "f", ".", "startswith", "(", "'.'", ")", ":", "yield", "f" ]
Return a list of all non dotfiles in a given directory.
[ "Return", "a", "list", "of", "all", "non", "dotfiles", "in", "a", "given", "directory", "." ]
7adf838900f11e8845e17d8c79bb2b23617aec2c
https://github.com/tslight/treepick/blob/7adf838900f11e8845e17d8c79bb2b23617aec2c/treepick/paths.py#L27-L33
train
Return a list of all non dotfiles in a given directory.
tslight/treepick
treepick/paths.py
Paths.getchildren
def getchildren(self): ''' Create list of absolute paths to be used to instantiate path objects for traversal, based on whether or not hidden attribute is set. ''' try: if self.hidden: return [os.path.join(self.name, child) for ...
python
def getchildren(self): ''' Create list of absolute paths to be used to instantiate path objects for traversal, based on whether or not hidden attribute is set. ''' try: if self.hidden: return [os.path.join(self.name, child) for ...
[ "def", "getchildren", "(", "self", ")", ":", "try", ":", "if", "self", ".", "hidden", ":", "return", "[", "os", ".", "path", ".", "join", "(", "self", ".", "name", ",", "child", ")", "for", "child", "in", "sorted", "(", "self", ".", "listdir", "(...
Create list of absolute paths to be used to instantiate path objects for traversal, based on whether or not hidden attribute is set.
[ "Create", "list", "of", "absolute", "paths", "to", "be", "used", "to", "instantiate", "path", "objects", "for", "traversal", "based", "on", "whether", "or", "not", "hidden", "attribute", "is", "set", "." ]
7adf838900f11e8845e17d8c79bb2b23617aec2c
https://github.com/tslight/treepick/blob/7adf838900f11e8845e17d8c79bb2b23617aec2c/treepick/paths.py#L35-L48
train
Returns a list of absolute paths to be used to instantiate path objects for traversal based on whether hidden attribute is set.
tslight/treepick
treepick/paths.py
Paths.getpaths
def getpaths(self): ''' If we have children, use a list comprehension to instantiate new paths objects to traverse. ''' self.children = self.getchildren() if self.children is None: return if self.paths is None: self.paths = [Paths(self.scre...
python
def getpaths(self): ''' If we have children, use a list comprehension to instantiate new paths objects to traverse. ''' self.children = self.getchildren() if self.children is None: return if self.paths is None: self.paths = [Paths(self.scre...
[ "def", "getpaths", "(", "self", ")", ":", "self", ".", "children", "=", "self", ".", "getchildren", "(", ")", "if", "self", ".", "children", "is", "None", ":", "return", "if", "self", ".", "paths", "is", "None", ":", "self", ".", "paths", "=", "[",...
If we have children, use a list comprehension to instantiate new paths objects to traverse.
[ "If", "we", "have", "children", "use", "a", "list", "comprehension", "to", "instantiate", "new", "paths", "objects", "to", "traverse", "." ]
7adf838900f11e8845e17d8c79bb2b23617aec2c
https://github.com/tslight/treepick/blob/7adf838900f11e8845e17d8c79bb2b23617aec2c/treepick/paths.py#L50-L66
train
get paths of all children of this class
tslight/treepick
treepick/paths.py
Paths.traverse
def traverse(self): ''' Recursive generator that lazily unfolds the filesystem. ''' yield self, 0 if self.name in self.expanded: for path in self.getpaths(): for child, depth in path.traverse(): yield child, depth + 1
python
def traverse(self): ''' Recursive generator that lazily unfolds the filesystem. ''' yield self, 0 if self.name in self.expanded: for path in self.getpaths(): for child, depth in path.traverse(): yield child, depth + 1
[ "def", "traverse", "(", "self", ")", ":", "yield", "self", ",", "0", "if", "self", ".", "name", "in", "self", ".", "expanded", ":", "for", "path", "in", "self", ".", "getpaths", "(", ")", ":", "for", "child", ",", "depth", "in", "path", ".", "tra...
Recursive generator that lazily unfolds the filesystem.
[ "Recursive", "generator", "that", "lazily", "unfolds", "the", "filesystem", "." ]
7adf838900f11e8845e17d8c79bb2b23617aec2c
https://github.com/tslight/treepick/blob/7adf838900f11e8845e17d8c79bb2b23617aec2c/treepick/paths.py#L68-L76
train
Recursive generator that lazily unfolds the filesystem.
geophysics-ubonn/crtomo_tools
src/grid_extralines_gen_decouplings.py
line_line_intersect
def line_line_intersect(x, y): """Compute the intersection point of two lines Parameters ---------- x = x4 array: x1, x2, x3, x4 y = x4 array: y1, y2, y3, y4 line 1 is defined by p1,p2 line 2 is defined by p3,p4 Returns ------- Ix: x-coordinate of intersection Iy: y-coordin...
python
def line_line_intersect(x, y): """Compute the intersection point of two lines Parameters ---------- x = x4 array: x1, x2, x3, x4 y = x4 array: y1, y2, y3, y4 line 1 is defined by p1,p2 line 2 is defined by p3,p4 Returns ------- Ix: x-coordinate of intersection Iy: y-coordin...
[ "def", "line_line_intersect", "(", "x", ",", "y", ")", ":", "A", "=", "x", "[", "0", "]", "*", "y", "[", "1", "]", "-", "y", "[", "0", "]", "*", "x", "[", "1", "]", "B", "=", "x", "[", "2", "]", "*", "y", "[", "3", "]", "-", "y", "[...
Compute the intersection point of two lines Parameters ---------- x = x4 array: x1, x2, x3, x4 y = x4 array: y1, y2, y3, y4 line 1 is defined by p1,p2 line 2 is defined by p3,p4 Returns ------- Ix: x-coordinate of intersection Iy: y-coordinate of intersection
[ "Compute", "the", "intersection", "point", "of", "two", "lines" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/grid_extralines_gen_decouplings.py#L116-L137
train
Compute the intersection point of two lines in a .
geophysics-ubonn/crtomo_tools
src/grid_extralines_gen_decouplings.py
distances
def distances(x, y, px, py, plot=False): """ Compute shortest distance of points (px, py) to the line described by the end points in (x, y). Parameters ---------- x,y: x and y coordinates of line px: x coordinates of data points py: y coordiante of data points Returns ------- ...
python
def distances(x, y, px, py, plot=False): """ Compute shortest distance of points (px, py) to the line described by the end points in (x, y). Parameters ---------- x,y: x and y coordinates of line px: x coordinates of data points py: y coordiante of data points Returns ------- ...
[ "def", "distances", "(", "x", ",", "y", ",", "px", ",", "py", ",", "plot", "=", "False", ")", ":", "length_line", "=", "np", ".", "sqrt", "(", "(", "x", "[", "1", "]", "-", "x", "[", "0", "]", ")", "**", "2", "+", "(", "y", "[", "1", "]...
Compute shortest distance of points (px, py) to the line described by the end points in (x, y). Parameters ---------- x,y: x and y coordinates of line px: x coordinates of data points py: y coordiante of data points Returns ------- distances: list of distances
[ "Compute", "shortest", "distance", "of", "points", "(", "px", "py", ")", "to", "the", "line", "described", "by", "the", "end", "points", "in", "(", "x", "y", ")", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/grid_extralines_gen_decouplings.py#L140-L201
train
Compute shortest distance of points in x y to the line described by the end points in x y.
geophysics-ubonn/crtomo_tools
src/grid_extralines_gen_decouplings.py
get_decouplings_for_line
def get_decouplings_for_line(grid, line, settings, fids=None): """Compute the element pairs for regulazisation decoupling, given a grid object and a line, denoted by start and end coordinates, in the grid. Parameters ---------- grid: a crtomo.grid.crt_grid object line: np.array/list with 4 entr...
python
def get_decouplings_for_line(grid, line, settings, fids=None): """Compute the element pairs for regulazisation decoupling, given a grid object and a line, denoted by start and end coordinates, in the grid. Parameters ---------- grid: a crtomo.grid.crt_grid object line: np.array/list with 4 entr...
[ "def", "get_decouplings_for_line", "(", "grid", ",", "line", ",", "settings", ",", "fids", "=", "None", ")", ":", "key", "=", "'presort'", "# x/z coordinates of 'macro'-line", "x", "=", "[", "line", "[", "0", "]", ",", "line", "[", "2", "]", "]", "y", ...
Compute the element pairs for regulazisation decoupling, given a grid object and a line, denoted by start and end coordinates, in the grid. Parameters ---------- grid: a crtomo.grid.crt_grid object line: np.array/list with 4 entries: x1, y1, x2, x2, denoting start and end point fids: ...
[ "Compute", "the", "element", "pairs", "for", "regulazisation", "decoupling", "given", "a", "grid", "object", "and", "a", "line", "denoted", "by", "start", "and", "end", "coordinates", "in", "the", "grid", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/grid_extralines_gen_decouplings.py#L204-L325
train
Compute the element pairs for regulazisation decoupling for a given line in a given grid.
redhat-openstack/python-tripleo-helper
tripleohelper/utils.py
pkg_data_filename
def pkg_data_filename(resource_name, filename=None): """Returns the path of a file installed along the package """ resource_filename = pkg_resources.resource_filename( tripleohelper.__name__, resource_name ) if filename is not None: resource_filename = os.path.join(resource_f...
python
def pkg_data_filename(resource_name, filename=None): """Returns the path of a file installed along the package """ resource_filename = pkg_resources.resource_filename( tripleohelper.__name__, resource_name ) if filename is not None: resource_filename = os.path.join(resource_f...
[ "def", "pkg_data_filename", "(", "resource_name", ",", "filename", "=", "None", ")", ":", "resource_filename", "=", "pkg_resources", ".", "resource_filename", "(", "tripleohelper", ".", "__name__", ",", "resource_name", ")", "if", "filename", "is", "not", "None", ...
Returns the path of a file installed along the package
[ "Returns", "the", "path", "of", "a", "file", "installed", "along", "the", "package" ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/utils.py#L23-L32
train
Returns the path of a file installed along the package
zeldamods/evfl
evfl/actor.py
Actor.write_extra_data
def write_extra_data(self, stream: WriteStream) -> None: """Writes the param container and string pointer arrays. Unlike other write_extra_data functions, this can be called before write().""" if self.params: stream.align(8) if self._params_offset_writer: ...
python
def write_extra_data(self, stream: WriteStream) -> None: """Writes the param container and string pointer arrays. Unlike other write_extra_data functions, this can be called before write().""" if self.params: stream.align(8) if self._params_offset_writer: ...
[ "def", "write_extra_data", "(", "self", ",", "stream", ":", "WriteStream", ")", "->", "None", ":", "if", "self", ".", "params", ":", "stream", ".", "align", "(", "8", ")", "if", "self", ".", "_params_offset_writer", ":", "self", ".", "_params_offset_writer...
Writes the param container and string pointer arrays. Unlike other write_extra_data functions, this can be called before write().
[ "Writes", "the", "param", "container", "and", "string", "pointer", "arrays", ".", "Unlike", "other", "write_extra_data", "functions", "this", "can", "be", "called", "before", "write", "()", "." ]
208b39ab817de5bbef419cdae4606255695e83ac
https://github.com/zeldamods/evfl/blob/208b39ab817de5bbef419cdae4606255695e83ac/evfl/actor.py#L79-L106
train
Writes the param container and string pointer arrays.
peterbe/gg
gg/builtins/merge/gg_merge.py
merge
def merge(config): """Merge the current branch into master.""" repo = config.repo active_branch = repo.active_branch if active_branch.name == "master": error_out("You're already on the master branch.") if repo.is_dirty(): error_out( 'Repo is "dirty". ({})'.format( ...
python
def merge(config): """Merge the current branch into master.""" repo = config.repo active_branch = repo.active_branch if active_branch.name == "master": error_out("You're already on the master branch.") if repo.is_dirty(): error_out( 'Repo is "dirty". ({})'.format( ...
[ "def", "merge", "(", "config", ")", ":", "repo", "=", "config", ".", "repo", "active_branch", "=", "repo", ".", "active_branch", "if", "active_branch", ".", "name", "==", "\"master\"", ":", "error_out", "(", "\"You're already on the master branch.\"", ")", "if",...
Merge the current branch into master.
[ "Merge", "the", "current", "branch", "into", "master", "." ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/merge/gg_merge.py#L8-L48
train
Merge the current branch into master.
edx/edx-celeryutils
celery_utils/chordable_django_backend.py
chord_task
def chord_task(*args, **kwargs): u""" Override of the default task decorator to specify use of this backend. """ given_backend = kwargs.get(u'backend', None) if not isinstance(given_backend, ChordableDjangoBackend): kwargs[u'backend'] = ChordableDjangoBackend(kwargs.get('app', current_app)) ...
python
def chord_task(*args, **kwargs): u""" Override of the default task decorator to specify use of this backend. """ given_backend = kwargs.get(u'backend', None) if not isinstance(given_backend, ChordableDjangoBackend): kwargs[u'backend'] = ChordableDjangoBackend(kwargs.get('app', current_app)) ...
[ "def", "chord_task", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "given_backend", "=", "kwargs", ".", "get", "(", "u'backend'", ",", "None", ")", "if", "not", "isinstance", "(", "given_backend", ",", "ChordableDjangoBackend", ")", ":", "kwargs", ...
u""" Override of the default task decorator to specify use of this backend.
[ "u", "Override", "of", "the", "default", "task", "decorator", "to", "specify", "use", "of", "this", "backend", "." ]
d8745f5f0929ad154fad779a19fbefe7f51e9498
https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/chordable_django_backend.py#L89-L96
train
u Override of the default task decorator to specify use of this backend.
edx/edx-celeryutils
celery_utils/chordable_django_backend.py
ChordableDjangoBackend._cleanup
def _cleanup(self, status, expires_multiplier=1): u""" Clean up expired records. Will remove all entries for any ChordData whose callback result is in state <status> that was marked completed more than (self.expires * <expires_multipler>) ago. """ # self.expires ...
python
def _cleanup(self, status, expires_multiplier=1): u""" Clean up expired records. Will remove all entries for any ChordData whose callback result is in state <status> that was marked completed more than (self.expires * <expires_multipler>) ago. """ # self.expires ...
[ "def", "_cleanup", "(", "self", ",", "status", ",", "expires_multiplier", "=", "1", ")", ":", "# self.expires is inherited, and defaults to 1 day (or setting CELERY_TASK_RESULT_EXPIRES)", "expires", "=", "self", ".", "expires", "if", "isinstance", "(", "self", ".", "exp...
u""" Clean up expired records. Will remove all entries for any ChordData whose callback result is in state <status> that was marked completed more than (self.expires * <expires_multipler>) ago.
[ "u", "Clean", "up", "expired", "records", "." ]
d8745f5f0929ad154fad779a19fbefe7f51e9498
https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/chordable_django_backend.py#L113-L133
train
u Clean up expired records.
edx/edx-celeryutils
celery_utils/chordable_django_backend.py
ChordableDjangoBackend.on_chord_part_return
def on_chord_part_return(self, task, state, result, propagate=False): # pylint: disable=redefined-outer-name u""" Update the linking ChordData object and execute callback if needed. Parameters ---------- subtask: The subtask that just finished executing. Most useful values ...
python
def on_chord_part_return(self, task, state, result, propagate=False): # pylint: disable=redefined-outer-name u""" Update the linking ChordData object and execute callback if needed. Parameters ---------- subtask: The subtask that just finished executing. Most useful values ...
[ "def", "on_chord_part_return", "(", "self", ",", "task", ",", "state", ",", "result", ",", "propagate", "=", "False", ")", ":", "# pylint: disable=redefined-outer-name", "with", "transaction", ".", "atomic", "(", ")", ":", "chord_data", "=", "ChordData", ".", ...
u""" Update the linking ChordData object and execute callback if needed. Parameters ---------- subtask: The subtask that just finished executing. Most useful values are stored on subtask.request. state: the status of the just-finished subtask. ...
[ "u", "Update", "the", "linking", "ChordData", "object", "and", "execute", "callback", "if", "needed", "." ]
d8745f5f0929ad154fad779a19fbefe7f51e9498
https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/chordable_django_backend.py#L151-L179
train
Update the ChordData object and execute callback if needed.
edx/edx-celeryutils
celery_utils/chordable_django_backend.py
ChordableDjangoBackend.apply_chord
def apply_chord(self, header, partial_args, group_id, body, **options): u""" Instantiate a linking ChordData object before executing subtasks. Parameters ---------- header: a list of incomplete subtask signatures, with partial different-per-instance arguments...
python
def apply_chord(self, header, partial_args, group_id, body, **options): u""" Instantiate a linking ChordData object before executing subtasks. Parameters ---------- header: a list of incomplete subtask signatures, with partial different-per-instance arguments...
[ "def", "apply_chord", "(", "self", ",", "header", ",", "partial_args", ",", "group_id", ",", "body", ",", "*", "*", "options", ")", ":", "callback_entry", "=", "TaskMeta", ".", "objects", ".", "create", "(", "task_id", "=", "body", ".", "id", ")", "cho...
u""" Instantiate a linking ChordData object before executing subtasks. Parameters ---------- header: a list of incomplete subtask signatures, with partial different-per-instance arguments already set. partial_args: list of same-per-instance subtask argume...
[ "u", "Instantiate", "a", "linking", "ChordData", "object", "before", "executing", "subtasks", "." ]
d8745f5f0929ad154fad779a19fbefe7f51e9498
https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/chordable_django_backend.py#L181-L208
train
u This method creates a ChordData object and applies it to the given header and partial_args.
edx/edx-celeryutils
celery_utils/chordable_django_backend.py
ChordableDjangoBackend.get_suitable_app
def get_suitable_app(cls, given_app): u""" Return a clone of given_app with ChordableDjangoBackend, if needed. """ if not isinstance(getattr(given_app, 'backend', None), ChordableDjangoBackend): return_app = deepcopy(given_app) return_app.backend = ChordableDjango...
python
def get_suitable_app(cls, given_app): u""" Return a clone of given_app with ChordableDjangoBackend, if needed. """ if not isinstance(getattr(given_app, 'backend', None), ChordableDjangoBackend): return_app = deepcopy(given_app) return_app.backend = ChordableDjango...
[ "def", "get_suitable_app", "(", "cls", ",", "given_app", ")", ":", "if", "not", "isinstance", "(", "getattr", "(", "given_app", ",", "'backend'", ",", "None", ")", ",", "ChordableDjangoBackend", ")", ":", "return_app", "=", "deepcopy", "(", "given_app", ")",...
u""" Return a clone of given_app with ChordableDjangoBackend, if needed.
[ "u", "Return", "a", "clone", "of", "given_app", "with", "ChordableDjangoBackend", "if", "needed", "." ]
d8745f5f0929ad154fad779a19fbefe7f51e9498
https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/chordable_django_backend.py#L221-L230
train
u Return a clone of given_app with ChordableDjangoBackend if needed.
gebn/wood
wood/integrations/cloudflare.py
Invalidator.invalidate
def invalidate(self, comparison: Comparison[Entity, Entity]) -> None: """ Invalidate paths in a zone. See https://api.cloudflare.com /#zone-purge-individual-files-by-url-and-cache-tags :param comparison: The comparison whose changes to invalidate. :raises requests.exceptions.Req...
python
def invalidate(self, comparison: Comparison[Entity, Entity]) -> None: """ Invalidate paths in a zone. See https://api.cloudflare.com /#zone-purge-individual-files-by-url-and-cache-tags :param comparison: The comparison whose changes to invalidate. :raises requests.exceptions.Req...
[ "def", "invalidate", "(", "self", ",", "comparison", ":", "Comparison", "[", "Entity", ",", "Entity", "]", ")", "->", "None", ":", "@", "backoff", ".", "on_exception", "(", "backoff", ".", "expo", ",", "requests", ".", "exceptions", ".", "RequestException"...
Invalidate paths in a zone. See https://api.cloudflare.com /#zone-purge-individual-files-by-url-and-cache-tags :param comparison: The comparison whose changes to invalidate. :raises requests.exceptions.RequestException: On request failure. :raises RuntimeError: If the request succeeded ...
[ "Invalidate", "paths", "in", "a", "zone", ".", "See", "https", ":", "//", "api", ".", "cloudflare", ".", "com", "/", "#zone", "-", "purge", "-", "individual", "-", "files", "-", "by", "-", "url", "-", "and", "-", "cache", "-", "tags" ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/integrations/cloudflare.py#L44-L102
train
Invalidate the cache for the specified paths in a specific zone.
rhayes777/PyAutoFit
autofit/mapper/prior_model.py
PriorModel.linked_model_for_class
def linked_model_for_class(self, cls, make_constants_variable=False, **kwargs): """ Create a PriorModel wrapping the specified class with attributes from this instance. Priors can be overridden using keyword arguments. Any constructor arguments of the new class for which there is no attribute as...
python
def linked_model_for_class(self, cls, make_constants_variable=False, **kwargs): """ Create a PriorModel wrapping the specified class with attributes from this instance. Priors can be overridden using keyword arguments. Any constructor arguments of the new class for which there is no attribute as...
[ "def", "linked_model_for_class", "(", "self", ",", "cls", ",", "make_constants_variable", "=", "False", ",", "*", "*", "kwargs", ")", ":", "constructor_args", "=", "inspect", ".", "getfullargspec", "(", "cls", ")", ".", "args", "attribute_tuples", "=", "self",...
Create a PriorModel wrapping the specified class with attributes from this instance. Priors can be overridden using keyword arguments. Any constructor arguments of the new class for which there is no attribute associated with this class and no keyword argument are created from config. If make_c...
[ "Create", "a", "PriorModel", "wrapping", "the", "specified", "class", "with", "attributes", "from", "this", "instance", ".", "Priors", "can", "be", "overridden", "using", "keyword", "arguments", ".", "Any", "constructor", "arguments", "of", "the", "new", "class"...
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/prior_model.py#L293-L331
train
Creates a new PriorModel wrapping the specified class with attributes from this instance.
rhayes777/PyAutoFit
autofit/mapper/prior_model.py
PriorModel.prior_tuples
def prior_tuples(self): """ Returns ------- priors: [(String, Prior))] """ return [prior for tuple_prior in self.tuple_prior_tuples for prior in tuple_prior[1].prior_tuples] + self.direct_prior_tuples + [prior for prior_model in ...
python
def prior_tuples(self): """ Returns ------- priors: [(String, Prior))] """ return [prior for tuple_prior in self.tuple_prior_tuples for prior in tuple_prior[1].prior_tuples] + self.direct_prior_tuples + [prior for prior_model in ...
[ "def", "prior_tuples", "(", "self", ")", ":", "return", "[", "prior", "for", "tuple_prior", "in", "self", ".", "tuple_prior_tuples", "for", "prior", "in", "tuple_prior", "[", "1", "]", ".", "prior_tuples", "]", "+", "self", ".", "direct_prior_tuples", "+", ...
Returns ------- priors: [(String, Prior))]
[ "Returns", "-------", "priors", ":", "[", "(", "String", "Prior", "))", "]" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/prior_model.py#L379-L389
train
Returns a list of priors for all prior tuples in the current object.
rhayes777/PyAutoFit
autofit/mapper/prior_model.py
PriorModel.constant_tuples
def constant_tuples(self): """ Returns ------- constants: [(String, Constant)] """ return [constant_tuple for tuple_prior in self.tuple_prior_tuples for constant_tuple in tuple_prior[1].constant_tuples] + self.direct_constant_tuples
python
def constant_tuples(self): """ Returns ------- constants: [(String, Constant)] """ return [constant_tuple for tuple_prior in self.tuple_prior_tuples for constant_tuple in tuple_prior[1].constant_tuples] + self.direct_constant_tuples
[ "def", "constant_tuples", "(", "self", ")", ":", "return", "[", "constant_tuple", "for", "tuple_prior", "in", "self", ".", "tuple_prior_tuples", "for", "constant_tuple", "in", "tuple_prior", "[", "1", "]", ".", "constant_tuples", "]", "+", "self", ".", "direct...
Returns ------- constants: [(String, Constant)]
[ "Returns", "-------", "constants", ":", "[", "(", "String", "Constant", ")", "]" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/prior_model.py#L404-L411
train
Returns a list of constant tuples for all of the tuples in the cluster.
rhayes777/PyAutoFit
autofit/mapper/prior_model.py
PriorModel.instance_for_arguments
def instance_for_arguments(self, arguments: {Prior: float}): """ Create an instance of the associated class for a set of arguments Parameters ---------- arguments: {Prior: float} Dictionary mapping_matrix priors to attribute analysis_path and value pairs Ret...
python
def instance_for_arguments(self, arguments: {Prior: float}): """ Create an instance of the associated class for a set of arguments Parameters ---------- arguments: {Prior: float} Dictionary mapping_matrix priors to attribute analysis_path and value pairs Ret...
[ "def", "instance_for_arguments", "(", "self", ",", "arguments", ":", "{", "Prior", ":", "float", "}", ")", ":", "for", "prior", ",", "value", "in", "arguments", ".", "items", "(", ")", ":", "prior", ".", "assert_within_limits", "(", "value", ")", "model_...
Create an instance of the associated class for a set of arguments Parameters ---------- arguments: {Prior: float} Dictionary mapping_matrix priors to attribute analysis_path and value pairs Returns ------- An instance of the class
[ "Create", "an", "instance", "of", "the", "associated", "class", "for", "a", "set", "of", "arguments" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/prior_model.py#L422-L444
train
Create an instance of the associated class for a set of arguments.
rhayes777/PyAutoFit
autofit/mapper/prior_model.py
PriorModel.gaussian_prior_model_for_arguments
def gaussian_prior_model_for_arguments(self, arguments): """ Create a new instance of model mapper with a set of Gaussian priors based on tuples provided by a previous \ nonlinear search. Parameters ---------- arguments: [(float, float)] Tuples providing the ...
python
def gaussian_prior_model_for_arguments(self, arguments): """ Create a new instance of model mapper with a set of Gaussian priors based on tuples provided by a previous \ nonlinear search. Parameters ---------- arguments: [(float, float)] Tuples providing the ...
[ "def", "gaussian_prior_model_for_arguments", "(", "self", ",", "arguments", ")", ":", "new_model", "=", "copy", ".", "deepcopy", "(", "self", ")", "model_arguments", "=", "{", "t", ".", "name", ":", "arguments", "[", "t", ".", "prior", "]", "for", "t", "...
Create a new instance of model mapper with a set of Gaussian priors based on tuples provided by a previous \ nonlinear search. Parameters ---------- arguments: [(float, float)] Tuples providing the mean and sigma of gaussians Returns ------- new_mode...
[ "Create", "a", "new", "instance", "of", "model", "mapper", "with", "a", "set", "of", "Gaussian", "priors", "based", "on", "tuples", "provided", "by", "a", "previous", "\\", "nonlinear", "search", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/prior_model.py#L446-L476
train
Create a new model mapper with a set of Gaussian priors based on tuples provided by a previous nonlinear search.
rhayes777/PyAutoFit
autofit/mapper/prior_model.py
CollectionPriorModel.instance_for_arguments
def instance_for_arguments(self, arguments): """ Parameters ---------- arguments: {Prior: float} A dictionary of arguments Returns ------- model_instances: [object] A list of instances constructed from the list of prior models. """...
python
def instance_for_arguments(self, arguments): """ Parameters ---------- arguments: {Prior: float} A dictionary of arguments Returns ------- model_instances: [object] A list of instances constructed from the list of prior models. """...
[ "def", "instance_for_arguments", "(", "self", ",", "arguments", ")", ":", "result", "=", "ModelInstance", "(", ")", "for", "key", ",", "value", "in", "self", ".", "__dict__", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "AbstractPr...
Parameters ---------- arguments: {Prior: float} A dictionary of arguments Returns ------- model_instances: [object] A list of instances constructed from the list of prior models.
[ "Parameters", "----------", "arguments", ":", "{", "Prior", ":", "float", "}", "A", "dictionary", "of", "arguments" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/prior_model.py#L574-L591
train
Returns a ModelInstance object for the given dictionary of arguments.
rhayes777/PyAutoFit
autofit/mapper/prior_model.py
CollectionPriorModel.gaussian_prior_model_for_arguments
def gaussian_prior_model_for_arguments(self, arguments): """ Parameters ---------- arguments: {Prior: float} A dictionary of arguments Returns ------- prior_models: [PriorModel] A new list of prior models with gaussian priors """ ...
python
def gaussian_prior_model_for_arguments(self, arguments): """ Parameters ---------- arguments: {Prior: float} A dictionary of arguments Returns ------- prior_models: [PriorModel] A new list of prior models with gaussian priors """ ...
[ "def", "gaussian_prior_model_for_arguments", "(", "self", ",", "arguments", ")", ":", "return", "CollectionPriorModel", "(", "{", "key", ":", "value", ".", "gaussian_prior_model_for_arguments", "(", "arguments", ")", "if", "isinstance", "(", "value", ",", "AbstractP...
Parameters ---------- arguments: {Prior: float} A dictionary of arguments Returns ------- prior_models: [PriorModel] A new list of prior models with gaussian priors
[ "Parameters", "----------", "arguments", ":", "{", "Prior", ":", "float", "}", "A", "dictionary", "of", "arguments" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/prior_model.py#L593-L612
train
Returns a new prior model for the given arguments.
rhayes777/PyAutoFit
autofit/mapper/prior_model.py
CollectionPriorModel.prior_tuples
def prior_tuples(self): """ Returns ------- priors: [(String, Union(Prior, TuplePrior))] """ return set([prior for prior_model in self.prior_models for prior in prior_model.prior_tuples])
python
def prior_tuples(self): """ Returns ------- priors: [(String, Union(Prior, TuplePrior))] """ return set([prior for prior_model in self.prior_models for prior in prior_model.prior_tuples])
[ "def", "prior_tuples", "(", "self", ")", ":", "return", "set", "(", "[", "prior", "for", "prior_model", "in", "self", ".", "prior_models", "for", "prior", "in", "prior_model", ".", "prior_tuples", "]", ")" ]
Returns ------- priors: [(String, Union(Prior, TuplePrior))]
[ "Returns", "-------", "priors", ":", "[", "(", "String", "Union", "(", "Prior", "TuplePrior", "))", "]" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/prior_model.py#L616-L622
train
Returns a set of priors that are used to store the current set of priors.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.get
def get(self, path, params=None): """ Send a GET request to the Wordpress REST API v1.1 and return the response :param path: aka resource :param params: querystring args :return: requests.reponse object """ api_url = self.api_base_url + path headers = Non...
python
def get(self, path, params=None): """ Send a GET request to the Wordpress REST API v1.1 and return the response :param path: aka resource :param params: querystring args :return: requests.reponse object """ api_url = self.api_base_url + path headers = Non...
[ "def", "get", "(", "self", ",", "path", ",", "params", "=", "None", ")", ":", "api_url", "=", "self", ".", "api_base_url", "+", "path", "headers", "=", "None", "try", ":", "headers", "=", "{", "\"Authorization\"", ":", "'Bearer {}'", ".", "format", "("...
Send a GET request to the Wordpress REST API v1.1 and return the response :param path: aka resource :param params: querystring args :return: requests.reponse object
[ "Send", "a", "GET", "request", "to", "the", "Wordpress", "REST", "API", "v1", ".", "1", "and", "return", "the", "response", ":", "param", "path", ":", "aka", "resource", ":", "param", "params", ":", "querystring", "args", ":", "return", ":", "requests", ...
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L48-L68
train
Send a GET request to the Wordpress REST API v1. 1 and return the response
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.load_post
def load_post(self, wp_post_id): """ Refresh local content for a single post from the the WordPress REST API. This can be called from a webhook on the WordPress side when a post is updated. :param wp_post_id: the wordpress post ID :return: the fully loaded local post object ...
python
def load_post(self, wp_post_id): """ Refresh local content for a single post from the the WordPress REST API. This can be called from a webhook on the WordPress side when a post is updated. :param wp_post_id: the wordpress post ID :return: the fully loaded local post object ...
[ "def", "load_post", "(", "self", ",", "wp_post_id", ")", ":", "path", "=", "\"sites/{}/posts/{}\"", ".", "format", "(", "self", ".", "site_id", ",", "wp_post_id", ")", "response", "=", "self", ".", "get", "(", "path", ")", "if", "response", ".", "ok", ...
Refresh local content for a single post from the the WordPress REST API. This can be called from a webhook on the WordPress side when a post is updated. :param wp_post_id: the wordpress post ID :return: the fully loaded local post object
[ "Refresh", "local", "content", "for", "a", "single", "post", "from", "the", "the", "WordPress", "REST", "API", ".", "This", "can", "be", "called", "from", "a", "webhook", "on", "the", "WordPress", "side", "when", "a", "post", "is", "updated", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L70-L96
train
Load a single post from the WordPress REST API.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.load_site
def load_site(self, purge_first=False, full=False, modified_after=None, type=None, status=None, batch_size=None): """ Sync content from a WordPress.com site via the REST API. :param purge_first: Should we remove all local content first? Careful, destructive! :param full: If True, crawl ...
python
def load_site(self, purge_first=False, full=False, modified_after=None, type=None, status=None, batch_size=None): """ Sync content from a WordPress.com site via the REST API. :param purge_first: Should we remove all local content first? Careful, destructive! :param full: If True, crawl ...
[ "def", "load_site", "(", "self", ",", "purge_first", "=", "False", ",", "full", "=", "False", ",", "modified_after", "=", "None", ",", "type", "=", "None", ",", "status", "=", "None", ",", "batch_size", "=", "None", ")", ":", "# capture loading vars", "s...
Sync content from a WordPress.com site via the REST API. :param purge_first: Should we remove all local content first? Careful, destructive! :param full: If True, crawl backwards chronologically through all content, not just recently modified Default is False, only load recently mo...
[ "Sync", "content", "from", "a", "WordPress", ".", "com", "site", "via", "the", "REST", "API", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L98-L152
train
Loads the content of a WordPress. com site.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.load_categories
def load_categories(self, max_pages=30): """ Load all WordPress categories from the given site. :param max_pages: kill counter to avoid infinite looping :return: None """ logger.info("loading categories") # clear them all out so we don't get dupes if requested ...
python
def load_categories(self, max_pages=30): """ Load all WordPress categories from the given site. :param max_pages: kill counter to avoid infinite looping :return: None """ logger.info("loading categories") # clear them all out so we don't get dupes if requested ...
[ "def", "load_categories", "(", "self", ",", "max_pages", "=", "30", ")", ":", "logger", ".", "info", "(", "\"loading categories\"", ")", "# clear them all out so we don't get dupes if requested", "if", "self", ".", "purge_first", ":", "Category", ".", "objects", "."...
Load all WordPress categories from the given site. :param max_pages: kill counter to avoid infinite looping :return: None
[ "Load", "all", "WordPress", "categories", "from", "the", "given", "site", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L154-L207
train
Load all WordPress categories from the given site.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.get_new_category
def get_new_category(self, api_category): """ Instantiate a new Category from api data. :param api_category: the api data for the Category :return: the new Category """ return Category(site_id=self.site_id, wp_id=api_category["ID"], ...
python
def get_new_category(self, api_category): """ Instantiate a new Category from api data. :param api_category: the api data for the Category :return: the new Category """ return Category(site_id=self.site_id, wp_id=api_category["ID"], ...
[ "def", "get_new_category", "(", "self", ",", "api_category", ")", ":", "return", "Category", "(", "site_id", "=", "self", ".", "site_id", ",", "wp_id", "=", "api_category", "[", "\"ID\"", "]", ",", "*", "*", "self", ".", "api_object_data", "(", "\"category...
Instantiate a new Category from api data. :param api_category: the api data for the Category :return: the new Category
[ "Instantiate", "a", "new", "Category", "from", "api", "data", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L209-L218
train
Instantiate a new Category from api data.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.load_tags
def load_tags(self, max_pages=30): """ Load all WordPress tags from the given site. :param max_pages: kill counter to avoid infinite looping :return: None """ logger.info("loading tags") # clear them all out so we don't get dupes if requested if self.pur...
python
def load_tags(self, max_pages=30): """ Load all WordPress tags from the given site. :param max_pages: kill counter to avoid infinite looping :return: None """ logger.info("loading tags") # clear them all out so we don't get dupes if requested if self.pur...
[ "def", "load_tags", "(", "self", ",", "max_pages", "=", "30", ")", ":", "logger", ".", "info", "(", "\"loading tags\"", ")", "# clear them all out so we don't get dupes if requested", "if", "self", ".", "purge_first", ":", "Tag", ".", "objects", ".", "filter", "...
Load all WordPress tags from the given site. :param max_pages: kill counter to avoid infinite looping :return: None
[ "Load", "all", "WordPress", "tags", "from", "the", "given", "site", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L220-L273
train
Load all WordPress tags from the given site.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.get_new_tag
def get_new_tag(self, api_tag): """ Instantiate a new Tag from api data. :param api_tag: the api data for the Tag :return: the new Tag """ return Tag(site_id=self.site_id, wp_id=api_tag["ID"], **self.api_object_data("tag", api_tag))
python
def get_new_tag(self, api_tag): """ Instantiate a new Tag from api data. :param api_tag: the api data for the Tag :return: the new Tag """ return Tag(site_id=self.site_id, wp_id=api_tag["ID"], **self.api_object_data("tag", api_tag))
[ "def", "get_new_tag", "(", "self", ",", "api_tag", ")", ":", "return", "Tag", "(", "site_id", "=", "self", ".", "site_id", ",", "wp_id", "=", "api_tag", "[", "\"ID\"", "]", ",", "*", "*", "self", ".", "api_object_data", "(", "\"tag\"", ",", "api_tag", ...
Instantiate a new Tag from api data. :param api_tag: the api data for the Tag :return: the new Tag
[ "Instantiate", "a", "new", "Tag", "from", "api", "data", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L275-L284
train
Instantiate a new Tag from api data.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.load_authors
def load_authors(self, max_pages=10): """ Load all WordPress authors from the given site. :param max_pages: kill counter to avoid infinite looping :return: None """ logger.info("loading authors") # clear them all out so we don't get dupes if requested if...
python
def load_authors(self, max_pages=10): """ Load all WordPress authors from the given site. :param max_pages: kill counter to avoid infinite looping :return: None """ logger.info("loading authors") # clear them all out so we don't get dupes if requested if...
[ "def", "load_authors", "(", "self", ",", "max_pages", "=", "10", ")", ":", "logger", ".", "info", "(", "\"loading authors\"", ")", "# clear them all out so we don't get dupes if requested", "if", "self", ".", "purge_first", ":", "Author", ".", "objects", ".", "fil...
Load all WordPress authors from the given site. :param max_pages: kill counter to avoid infinite looping :return: None
[ "Load", "all", "WordPress", "authors", "from", "the", "given", "site", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L286-L340
train
Load all WordPress authors from the given site.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.get_new_author
def get_new_author(self, api_author): """ Instantiate a new Author from api data. :param api_author: the api data for the Author :return: the new Author """ return Author(site_id=self.site_id, wp_id=api_author["ID"], **self.api...
python
def get_new_author(self, api_author): """ Instantiate a new Author from api data. :param api_author: the api data for the Author :return: the new Author """ return Author(site_id=self.site_id, wp_id=api_author["ID"], **self.api...
[ "def", "get_new_author", "(", "self", ",", "api_author", ")", ":", "return", "Author", "(", "site_id", "=", "self", ".", "site_id", ",", "wp_id", "=", "api_author", "[", "\"ID\"", "]", ",", "*", "*", "self", ".", "api_object_data", "(", "\"author\"", ","...
Instantiate a new Author from api data. :param api_author: the api data for the Author :return: the new Author
[ "Instantiate", "a", "new", "Author", "from", "api", "data", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L342-L351
train
Instantiate a new Author from api data.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.load_media
def load_media(self, max_pages=150): """ Load all WordPress media from the given site. :param max_pages: kill counter to avoid infinite looping :return: None """ logger.info("loading media") # clear them all out so we don't get dupes if self.purge_first:...
python
def load_media(self, max_pages=150): """ Load all WordPress media from the given site. :param max_pages: kill counter to avoid infinite looping :return: None """ logger.info("loading media") # clear them all out so we don't get dupes if self.purge_first:...
[ "def", "load_media", "(", "self", ",", "max_pages", "=", "150", ")", ":", "logger", ".", "info", "(", "\"loading media\"", ")", "# clear them all out so we don't get dupes", "if", "self", ".", "purge_first", ":", "logger", ".", "warning", "(", "\"purging ALL media...
Load all WordPress media from the given site. :param max_pages: kill counter to avoid infinite looping :return: None
[ "Load", "all", "WordPress", "media", "from", "the", "given", "site", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L353-L408
train
Load all WordPress media from the given site.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.set_media_params_after
def set_media_params_after(self, params): """ If we're not doing a full run, limit to media uploaded to wordpress 'recently'. 'Recently' in this case means 90 days before the date we're processing content from. The wp.com REST API doesn't have a way to limit based on media modification d...
python
def set_media_params_after(self, params): """ If we're not doing a full run, limit to media uploaded to wordpress 'recently'. 'Recently' in this case means 90 days before the date we're processing content from. The wp.com REST API doesn't have a way to limit based on media modification d...
[ "def", "set_media_params_after", "(", "self", ",", "params", ")", ":", "if", "not", "self", ".", "full", ":", "if", "self", ".", "modified_after", ":", "ninety_days_ago", "=", "self", ".", "modified_after", "-", "timedelta", "(", "days", "=", "90", ")", ...
If we're not doing a full run, limit to media uploaded to wordpress 'recently'. 'Recently' in this case means 90 days before the date we're processing content from. The wp.com REST API doesn't have a way to limit based on media modification date, but this should be relatively close. :...
[ "If", "we", "re", "not", "doing", "a", "full", "run", "limit", "to", "media", "uploaded", "to", "wordpress", "recently", ".", "Recently", "in", "this", "case", "means", "90", "days", "before", "the", "date", "we", "re", "processing", "content", "from", "...
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L410-L425
train
Set the GET params dict to include the after key.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.get_new_media
def get_new_media(self, api_media): """ Instantiate a new Media from api data. :param api_media: the api data for the Media :return: the new Media """ return Media(site_id=self.site_id, wp_id=api_media["ID"], **self.api_object_da...
python
def get_new_media(self, api_media): """ Instantiate a new Media from api data. :param api_media: the api data for the Media :return: the new Media """ return Media(site_id=self.site_id, wp_id=api_media["ID"], **self.api_object_da...
[ "def", "get_new_media", "(", "self", ",", "api_media", ")", ":", "return", "Media", "(", "site_id", "=", "self", ".", "site_id", ",", "wp_id", "=", "api_media", "[", "\"ID\"", "]", ",", "*", "*", "self", ".", "api_object_data", "(", "\"media\"", ",", "...
Instantiate a new Media from api data. :param api_media: the api data for the Media :return: the new Media
[ "Instantiate", "a", "new", "Media", "from", "api", "data", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L427-L436
train
Instantiate a new Media from api data.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.get_ref_data_map
def get_ref_data_map(self, bulk_mode=True): """ Get referential data from the local db into the self.ref_data_map dictionary. This allows for fast FK lookups when looping through posts. :param bulk_mode: if True, actually get all of the existing ref data else t...
python
def get_ref_data_map(self, bulk_mode=True): """ Get referential data from the local db into the self.ref_data_map dictionary. This allows for fast FK lookups when looping through posts. :param bulk_mode: if True, actually get all of the existing ref data else t...
[ "def", "get_ref_data_map", "(", "self", ",", "bulk_mode", "=", "True", ")", ":", "if", "bulk_mode", ":", "self", ".", "ref_data_map", "=", "{", "\"authors\"", ":", "{", "a", ".", "wp_id", ":", "a", "for", "a", "in", "Author", ".", "objects", ".", "fi...
Get referential data from the local db into the self.ref_data_map dictionary. This allows for fast FK lookups when looping through posts. :param bulk_mode: if True, actually get all of the existing ref data else this would be too much memory, so just build empty dicts ...
[ "Get", "referential", "data", "from", "the", "local", "db", "into", "the", "self", ".", "ref_data_map", "dictionary", ".", "This", "allows", "for", "fast", "FK", "lookups", "when", "looping", "through", "posts", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L438-L461
train
Get referential data from the local db into the self. ref_data_map dictionary.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.load_posts
def load_posts(self, post_type=None, max_pages=200, status=None): """ Load all WordPress posts of a given post_type from a site. :param post_type: post, page, attachment, or any custom post type set up in the WP API :param max_pages: kill counter to avoid infinite looping :param...
python
def load_posts(self, post_type=None, max_pages=200, status=None): """ Load all WordPress posts of a given post_type from a site. :param post_type: post, page, attachment, or any custom post type set up in the WP API :param max_pages: kill counter to avoid infinite looping :param...
[ "def", "load_posts", "(", "self", ",", "post_type", "=", "None", ",", "max_pages", "=", "200", ",", "status", "=", "None", ")", ":", "logger", ".", "info", "(", "\"loading posts with post_type=%s\"", ",", "post_type", ")", "# clear them all out so we don't get dup...
Load all WordPress posts of a given post_type from a site. :param post_type: post, page, attachment, or any custom post type set up in the WP API :param max_pages: kill counter to avoid infinite looping :param status: load posts with the given status, including any of: "publish", "p...
[ "Load", "all", "WordPress", "posts", "of", "a", "given", "post_type", "from", "a", "site", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L463-L498
train
Load all WordPress posts of a given post_type from a site.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.set_posts_param_modified_after
def set_posts_param_modified_after(self, params, post_type, status): """ Set modified_after date to "continue where we left off" if appropriate :param params: the GET params dict, which may be updated to include the "modified_after" key :param post_type: post, page, attachment, or any c...
python
def set_posts_param_modified_after(self, params, post_type, status): """ Set modified_after date to "continue where we left off" if appropriate :param params: the GET params dict, which may be updated to include the "modified_after" key :param post_type: post, page, attachment, or any c...
[ "def", "set_posts_param_modified_after", "(", "self", ",", "params", ",", "post_type", ",", "status", ")", ":", "if", "not", "self", ".", "purge_first", "and", "not", "self", ".", "full", "and", "not", "self", ".", "modified_after", ":", "if", "status", "=...
Set modified_after date to "continue where we left off" if appropriate :param params: the GET params dict, which may be updated to include the "modified_after" key :param post_type: post, page, attachment, or any custom post type set up in the WP API :param status: publish, private, draft, etc....
[ "Set", "modified_after", "date", "to", "continue", "where", "we", "left", "off", "if", "appropriate" ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L500-L519
train
Set modified_after date to continue where we left off if appropriate
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.process_posts_response
def process_posts_response(self, response, path, params, max_pages): """ Insert / update all posts in a posts list response, in batches. :param response: a response that contains a list of posts from the WP API :param path: the path we're using to get the list of posts (for subsquent pa...
python
def process_posts_response(self, response, path, params, max_pages): """ Insert / update all posts in a posts list response, in batches. :param response: a response that contains a list of posts from the WP API :param path: the path we're using to get the list of posts (for subsquent pa...
[ "def", "process_posts_response", "(", "self", ",", "response", ",", "path", ",", "params", ",", "max_pages", ")", ":", "page", "=", "1", "num_processed_posts", "=", "0", "api_posts_found", "=", "None", "while", "response", ".", "ok", "and", "response", ".", ...
Insert / update all posts in a posts list response, in batches. :param response: a response that contains a list of posts from the WP API :param path: the path we're using to get the list of posts (for subsquent pages) :param params: the path we're using to get the list of posts (for subsquent ...
[ "Insert", "/", "update", "all", "posts", "in", "a", "posts", "list", "response", "in", "batches", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L521-L585
train
Process posts from a WP API.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.load_wp_post
def load_wp_post(self, api_post, bulk_mode=True, post_categories=None, post_tags=None, post_media_attachments=None, posts=None): """ Load a single post from API data. :param api_post: the API data for the post :param bulk_mode: If True, minimize db operations by bulk creating post objec...
python
def load_wp_post(self, api_post, bulk_mode=True, post_categories=None, post_tags=None, post_media_attachments=None, posts=None): """ Load a single post from API data. :param api_post: the API data for the post :param bulk_mode: If True, minimize db operations by bulk creating post objec...
[ "def", "load_wp_post", "(", "self", ",", "api_post", ",", "bulk_mode", "=", "True", ",", "post_categories", "=", "None", ",", "post_tags", "=", "None", ",", "post_media_attachments", "=", "None", ",", "posts", "=", "None", ")", ":", "# initialize reference var...
Load a single post from API data. :param api_post: the API data for the post :param bulk_mode: If True, minimize db operations by bulk creating post objects :param post_categories: a mapping of Categories in the site, keyed by post ID :param post_tags: a mapping of Tags in the site, key...
[ "Load", "a", "single", "post", "from", "API", "data", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L587-L633
train
Load a single post from API data.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.process_post_author
def process_post_author(self, bulk_mode, api_author): """ Create or update an Author related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_author: the data in the api for the Author :return: the up-to-date Author object ...
python
def process_post_author(self, bulk_mode, api_author): """ Create or update an Author related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_author: the data in the api for the Author :return: the up-to-date Author object ...
[ "def", "process_post_author", "(", "self", ",", "bulk_mode", ",", "api_author", ")", ":", "# get from the ref data map if in bulk mode, else look it up from the db", "if", "bulk_mode", ":", "author", "=", "self", ".", "ref_data_map", "[", "\"authors\"", "]", ".", "get",...
Create or update an Author related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_author: the data in the api for the Author :return: the up-to-date Author object
[ "Create", "or", "update", "an", "Author", "related", "to", "a", "post", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L635-L664
train
Process an author related to a post.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.get_or_create_author
def get_or_create_author(self, api_author): """ Find or create an Author object given API data. :param api_author: the API data for the Author :return: a tuple of an Author instance and a boolean indicating whether the author was created or not """ return Author.objects....
python
def get_or_create_author(self, api_author): """ Find or create an Author object given API data. :param api_author: the API data for the Author :return: a tuple of an Author instance and a boolean indicating whether the author was created or not """ return Author.objects....
[ "def", "get_or_create_author", "(", "self", ",", "api_author", ")", ":", "return", "Author", ".", "objects", ".", "get_or_create", "(", "site_id", "=", "self", ".", "site_id", ",", "wp_id", "=", "api_author", "[", "\"ID\"", "]", ",", "defaults", "=", "self...
Find or create an Author object given API data. :param api_author: the API data for the Author :return: a tuple of an Author instance and a boolean indicating whether the author was created or not
[ "Find", "or", "create", "an", "Author", "object", "given", "API", "data", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L666-L675
train
Find or create an Author object given API data.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.process_post_categories
def process_post_categories(self, bulk_mode, api_post, post_categories): """ Create or update Categories related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_post: the API data for the post :param post_categories: a mappin...
python
def process_post_categories(self, bulk_mode, api_post, post_categories): """ Create or update Categories related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_post: the API data for the post :param post_categories: a mappin...
[ "def", "process_post_categories", "(", "self", ",", "bulk_mode", ",", "api_post", ",", "post_categories", ")", ":", "post_categories", "[", "api_post", "[", "\"ID\"", "]", "]", "=", "[", "]", "for", "api_category", "in", "six", ".", "itervalues", "(", "api_p...
Create or update Categories related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_post: the API data for the post :param post_categories: a mapping of Categories keyed by post ID :return: None
[ "Create", "or", "update", "Categories", "related", "to", "a", "post", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L677-L690
train
Process the API post data and add the corresponding Categories to the post_categories dict.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.process_post_category
def process_post_category(self, bulk_mode, api_category): """ Create or update a Category related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_category: the API data for the Category :return: the Category object ""...
python
def process_post_category(self, bulk_mode, api_category): """ Create or update a Category related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_category: the API data for the Category :return: the Category object ""...
[ "def", "process_post_category", "(", "self", ",", "bulk_mode", ",", "api_category", ")", ":", "category", "=", "None", "# try to get from the ref data map if in bulk mode", "if", "bulk_mode", ":", "category", "=", "self", ".", "ref_data_map", "[", "\"categories\"", "]...
Create or update a Category related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_category: the API data for the Category :return: the Category object
[ "Create", "or", "update", "a", "Category", "related", "to", "a", "post", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L692-L719
train
Process a post category and return the Category object.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.process_post_tags
def process_post_tags(self, bulk_mode, api_post, post_tags): """ Create or update Tags related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_post: the API data for the post :param post_tags: a mapping of Tags keyed by post ...
python
def process_post_tags(self, bulk_mode, api_post, post_tags): """ Create or update Tags related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_post: the API data for the post :param post_tags: a mapping of Tags keyed by post ...
[ "def", "process_post_tags", "(", "self", ",", "bulk_mode", ",", "api_post", ",", "post_tags", ")", ":", "post_tags", "[", "api_post", "[", "\"ID\"", "]", "]", "=", "[", "]", "for", "api_tag", "in", "six", ".", "itervalues", "(", "api_post", "[", "\"tags\...
Create or update Tags related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_post: the API data for the post :param post_tags: a mapping of Tags keyed by post ID :return: None
[ "Create", "or", "update", "Tags", "related", "to", "a", "post", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L721-L734
train
Process the API data for a post.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.process_post_tag
def process_post_tag(self, bulk_mode, api_tag): """ Create or update a Tag related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_tag: the API data for the Tag :return: the Tag object """ tag = None ...
python
def process_post_tag(self, bulk_mode, api_tag): """ Create or update a Tag related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_tag: the API data for the Tag :return: the Tag object """ tag = None ...
[ "def", "process_post_tag", "(", "self", ",", "bulk_mode", ",", "api_tag", ")", ":", "tag", "=", "None", "# try to get from the ref data map if in bulk mode", "if", "bulk_mode", ":", "tag", "=", "self", ".", "ref_data_map", "[", "\"tags\"", "]", ".", "get", "(", ...
Create or update a Tag related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_tag: the API data for the Tag :return: the Tag object
[ "Create", "or", "update", "a", "Tag", "related", "to", "a", "post", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L736-L762
train
Process a post tag and return the Tag object
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.process_post_media_attachments
def process_post_media_attachments(self, bulk_mode, api_post, post_media_attachments): """ Create or update Media objects related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_post: the API data for the Post :param post_med...
python
def process_post_media_attachments(self, bulk_mode, api_post, post_media_attachments): """ Create or update Media objects related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_post: the API data for the Post :param post_med...
[ "def", "process_post_media_attachments", "(", "self", ",", "bulk_mode", ",", "api_post", ",", "post_media_attachments", ")", ":", "post_media_attachments", "[", "api_post", "[", "\"ID\"", "]", "]", "=", "[", "]", "for", "api_attachment", "in", "six", ".", "iterv...
Create or update Media objects related to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_post: the API data for the Post :param post_media_attachments: a mapping of Media objects keyed by post ID :return: None
[ "Create", "or", "update", "Media", "objects", "related", "to", "a", "post", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L764-L778
train
Processes the API data for a post and adds or updates the Media objects related to that post.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.process_post_media_attachment
def process_post_media_attachment(self, bulk_mode, api_media_attachment): """ Create or update a Media attached to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_media_attachment: the API data for the Media :return: the Media a...
python
def process_post_media_attachment(self, bulk_mode, api_media_attachment): """ Create or update a Media attached to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_media_attachment: the API data for the Media :return: the Media a...
[ "def", "process_post_media_attachment", "(", "self", ",", "bulk_mode", ",", "api_media_attachment", ")", ":", "attachment", "=", "None", "# try to get from the ref data map if in bulk mode", "if", "bulk_mode", ":", "attachment", "=", "self", ".", "ref_data_map", "[", "\...
Create or update a Media attached to a post. :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_media_attachment: the API data for the Media :return: the Media attachment object
[ "Create", "or", "update", "a", "Media", "attached", "to", "a", "post", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L780-L805
train
Process a Media Attachment in bulk mode.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.get_or_create_media
def get_or_create_media(self, api_media): """ Find or create a Media object given API data. :param api_media: the API data for the Media :return: a tuple of an Media instance and a boolean indicating whether the Media was created or not """ return Media.objects.get_or_cr...
python
def get_or_create_media(self, api_media): """ Find or create a Media object given API data. :param api_media: the API data for the Media :return: a tuple of an Media instance and a boolean indicating whether the Media was created or not """ return Media.objects.get_or_cr...
[ "def", "get_or_create_media", "(", "self", ",", "api_media", ")", ":", "return", "Media", ".", "objects", ".", "get_or_create", "(", "site_id", "=", "self", ".", "site_id", ",", "wp_id", "=", "api_media", "[", "\"ID\"", "]", ",", "defaults", "=", "self", ...
Find or create a Media object given API data. :param api_media: the API data for the Media :return: a tuple of an Media instance and a boolean indicating whether the Media was created or not
[ "Find", "or", "create", "a", "Media", "object", "given", "API", "data", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L807-L816
train
Find or create a Media object given API data.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.process_existing_post
def process_existing_post(existing_post, api_post, author, post_categories, post_tags, post_media_attachments): """ Sync attributes for a single post from WP API data. :param existing_post: Post object that needs to be sync'd :param api_post: the API data for the Post :param aut...
python
def process_existing_post(existing_post, api_post, author, post_categories, post_tags, post_media_attachments): """ Sync attributes for a single post from WP API data. :param existing_post: Post object that needs to be sync'd :param api_post: the API data for the Post :param aut...
[ "def", "process_existing_post", "(", "existing_post", ",", "api_post", ",", "author", ",", "post_categories", ",", "post_tags", ",", "post_media_attachments", ")", ":", "# don't bother checking what's different, just update all fields", "existing_post", ".", "author", "=", ...
Sync attributes for a single post from WP API data. :param existing_post: Post object that needs to be sync'd :param api_post: the API data for the Post :param author: the Author object of the post (should already exist in the db) :param post_categories: the Categories to attach to the ...
[ "Sync", "attributes", "for", "a", "single", "post", "from", "WP", "API", "data", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L819-L861
train
Process an existing post from WP API data.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.process_post_many_to_many_field
def process_post_many_to_many_field(existing_post, field, related_objects): """ Sync data for a many-to-many field related to a post using set differences. :param existing_post: Post object that needs to be sync'd :param field: the many-to-many field to update :param related_obj...
python
def process_post_many_to_many_field(existing_post, field, related_objects): """ Sync data for a many-to-many field related to a post using set differences. :param existing_post: Post object that needs to be sync'd :param field: the many-to-many field to update :param related_obj...
[ "def", "process_post_many_to_many_field", "(", "existing_post", ",", "field", ",", "related_objects", ")", ":", "to_add", "=", "set", "(", "related_objects", ".", "get", "(", "existing_post", ".", "wp_id", ",", "set", "(", ")", ")", ")", "-", "set", "(", "...
Sync data for a many-to-many field related to a post using set differences. :param existing_post: Post object that needs to be sync'd :param field: the many-to-many field to update :param related_objects: the list of objects for the field, that need to be sync'd to the Post :return: Non...
[ "Sync", "data", "for", "a", "many", "-", "to", "-", "many", "field", "related", "to", "a", "post", "using", "set", "differences", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L864-L879
train
Sync data for a many - to - many field related to a post.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.process_new_post
def process_new_post(self, bulk_mode, api_post, posts, author, post_categories, post_tags, post_media_attachments): """ Instantiate a new Post object using data from the WP API. Related fields -- author, categories, tags, and attachments should be processed in advance :param bulk_mode: ...
python
def process_new_post(self, bulk_mode, api_post, posts, author, post_categories, post_tags, post_media_attachments): """ Instantiate a new Post object using data from the WP API. Related fields -- author, categories, tags, and attachments should be processed in advance :param bulk_mode: ...
[ "def", "process_new_post", "(", "self", ",", "bulk_mode", ",", "api_post", ",", "posts", ",", "author", ",", "post_categories", ",", "post_tags", ",", "post_media_attachments", ")", ":", "post", "=", "Post", "(", "site_id", "=", "self", ".", "site_id", ",", ...
Instantiate a new Post object using data from the WP API. Related fields -- author, categories, tags, and attachments should be processed in advance :param bulk_mode: If True, minimize db operations by bulk creating post objects :param api_post: the API data for the Post :param posts: t...
[ "Instantiate", "a", "new", "Post", "object", "using", "data", "from", "the", "WP", "API", ".", "Related", "fields", "--", "author", "categories", "tags", "and", "attachments", "should", "be", "processed", "in", "advance" ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L881-L926
train
Create a new post object from the API data.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.bulk_create_posts
def bulk_create_posts(self, posts, post_categories, post_tags, post_media_attachments): """ Actually do a db bulk creation of posts, and link up the many-to-many fields :param posts: the list of Post objects to bulk create :param post_categories: a mapping of Categories to add to newly ...
python
def bulk_create_posts(self, posts, post_categories, post_tags, post_media_attachments): """ Actually do a db bulk creation of posts, and link up the many-to-many fields :param posts: the list of Post objects to bulk create :param post_categories: a mapping of Categories to add to newly ...
[ "def", "bulk_create_posts", "(", "self", ",", "posts", ",", "post_categories", ",", "post_tags", ",", "post_media_attachments", ")", ":", "Post", ".", "objects", ".", "bulk_create", "(", "posts", ")", "# attach many-to-ones", "for", "post_wp_id", ",", "categories"...
Actually do a db bulk creation of posts, and link up the many-to-many fields :param posts: the list of Post objects to bulk create :param post_categories: a mapping of Categories to add to newly created Posts :param post_tags: a mapping of Tags to add to newly created Posts :param post_...
[ "Actually", "do", "a", "db", "bulk", "creation", "of", "posts", "and", "link", "up", "the", "many", "-", "to", "-", "many", "fields" ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L928-L948
train
Bulk create posts.
observermedia/django-wordpress-rest
wordpress/loading.py
WPAPILoader.sync_deleted_attachments
def sync_deleted_attachments(self, api_post): """ Remove Posts with post_type=attachment that have been removed from the given Post on the WordPress side. Logic: - get the list of Posts with post_type = attachment whose parent_id = this post_id - get the corresponding list from ...
python
def sync_deleted_attachments(self, api_post): """ Remove Posts with post_type=attachment that have been removed from the given Post on the WordPress side. Logic: - get the list of Posts with post_type = attachment whose parent_id = this post_id - get the corresponding list from ...
[ "def", "sync_deleted_attachments", "(", "self", ",", "api_post", ")", ":", "existing_IDs", "=", "set", "(", "Post", ".", "objects", ".", "filter", "(", "site_id", "=", "self", ".", "site_id", ",", "post_type", "=", "\"attachment\"", ",", "parent__icontains", ...
Remove Posts with post_type=attachment that have been removed from the given Post on the WordPress side. Logic: - get the list of Posts with post_type = attachment whose parent_id = this post_id - get the corresponding list from WP API - perform set difference - delete extra loc...
[ "Remove", "Posts", "with", "post_type", "=", "attachment", "that", "have", "been", "removed", "from", "the", "given", "Post", "on", "the", "WordPress", "side", "." ]
f0d96891d8ac5a69c8ba90e044876e756fad1bfe
https://github.com/observermedia/django-wordpress-rest/blob/f0d96891d8ac5a69c8ba90e044876e756fad1bfe/wordpress/loading.py#L950-L1020
train
This method is used to delete extra local attachments from a given post on the WordPress side.
tslight/treepick
treepick/actions.py
Actions.prevparent
def prevparent(self, parent, depth): ''' Subtract lines from our curline if the name of a node is prefixed with the parent directory when traversing the grandparent object. ''' pdir = os.path.dirname(self.name) if depth > 1: # can't jump to parent of root node! ...
python
def prevparent(self, parent, depth): ''' Subtract lines from our curline if the name of a node is prefixed with the parent directory when traversing the grandparent object. ''' pdir = os.path.dirname(self.name) if depth > 1: # can't jump to parent of root node! ...
[ "def", "prevparent", "(", "self", ",", "parent", ",", "depth", ")", ":", "pdir", "=", "os", ".", "path", ".", "dirname", "(", "self", ".", "name", ")", "if", "depth", ">", "1", ":", "# can't jump to parent of root node!", "for", "c", ",", "d", "in", ...
Subtract lines from our curline if the name of a node is prefixed with the parent directory when traversing the grandparent object.
[ "Subtract", "lines", "from", "our", "curline", "if", "the", "name", "of", "a", "node", "is", "prefixed", "with", "the", "parent", "directory", "when", "traversing", "the", "grandparent", "object", "." ]
7adf838900f11e8845e17d8c79bb2b23617aec2c
https://github.com/tslight/treepick/blob/7adf838900f11e8845e17d8c79bb2b23617aec2c/treepick/actions.py#L92-L115
train
Return the name of the previous parent directory.
peterbe/gg
gg/builtins/github.py
token
def token(config, token): """Store and fetch a GitHub access token""" if not token: info_out( "To generate a personal API token, go to:\n\n\t" "https://github.com/settings/tokens\n\n" "To read more about it, go to:\n\n\t" "https://help.github.com/articles/...
python
def token(config, token): """Store and fetch a GitHub access token""" if not token: info_out( "To generate a personal API token, go to:\n\n\t" "https://github.com/settings/tokens\n\n" "To read more about it, go to:\n\n\t" "https://help.github.com/articles/...
[ "def", "token", "(", "config", ",", "token", ")", ":", "if", "not", "token", ":", "info_out", "(", "\"To generate a personal API token, go to:\\n\\n\\t\"", "\"https://github.com/settings/tokens\\n\\n\"", "\"To read more about it, go to:\\n\\n\\t\"", "\"https://help.github.com/artic...
Store and fetch a GitHub access token
[ "Store", "and", "fetch", "a", "GitHub", "access", "token" ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/github.py#L32-L61
train
Store and fetch a GitHub access token
reorx/torext
torext/handlers/base.py
log_response
def log_response(handler): """ Acturally, logging response is not a server's responsibility, you should use http tools like Chrome Developer Tools to analyse the response. Although this function and its setting(LOG_RESPONSE) is not recommended to use, if you are laze as I was and working in develop...
python
def log_response(handler): """ Acturally, logging response is not a server's responsibility, you should use http tools like Chrome Developer Tools to analyse the response. Although this function and its setting(LOG_RESPONSE) is not recommended to use, if you are laze as I was and working in develop...
[ "def", "log_response", "(", "handler", ")", ":", "content_type", "=", "handler", ".", "_headers", ".", "get", "(", "'Content-Type'", ",", "None", ")", "headers_str", "=", "handler", ".", "_generate_headers", "(", ")", "block", "=", "'Response Infomations:\\n'", ...
Acturally, logging response is not a server's responsibility, you should use http tools like Chrome Developer Tools to analyse the response. Although this function and its setting(LOG_RESPONSE) is not recommended to use, if you are laze as I was and working in development, nothing could stop you.
[ "Acturally", "logging", "response", "is", "not", "a", "server", "s", "responsibility", "you", "should", "use", "http", "tools", "like", "Chrome", "Developer", "Tools", "to", "analyse", "the", "response", "." ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/base.py#L25-L53
train
Log the response to the log file.
reorx/torext
torext/handlers/base.py
log_request
def log_request(handler): """ Logging request is opposite to response, sometime its necessary, feel free to enable it. """ block = 'Request Infomations:\n' + _format_headers_log(handler.request.headers) if handler.request.arguments: block += '+----Arguments----+\n' for k, v in h...
python
def log_request(handler): """ Logging request is opposite to response, sometime its necessary, feel free to enable it. """ block = 'Request Infomations:\n' + _format_headers_log(handler.request.headers) if handler.request.arguments: block += '+----Arguments----+\n' for k, v in h...
[ "def", "log_request", "(", "handler", ")", ":", "block", "=", "'Request Infomations:\\n'", "+", "_format_headers_log", "(", "handler", ".", "request", ".", "headers", ")", "if", "handler", ".", "request", ".", "arguments", ":", "block", "+=", "'+----Arguments---...
Logging request is opposite to response, sometime its necessary, feel free to enable it.
[ "Logging", "request", "is", "opposite", "to", "response", "sometime", "its", "necessary", "feel", "free", "to", "enable", "it", "." ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/base.py#L56-L68
train
Log the request to the log.
reorx/torext
torext/handlers/base.py
BaseHandler._exception_default_handler
def _exception_default_handler(self, e): """This method is a copy of tornado.web.RequestHandler._handle_request_exception """ if isinstance(e, HTTPError): if e.log_message: format = "%d %s: " + e.log_message args = [e.status_code, self._request_summary...
python
def _exception_default_handler(self, e): """This method is a copy of tornado.web.RequestHandler._handle_request_exception """ if isinstance(e, HTTPError): if e.log_message: format = "%d %s: " + e.log_message args = [e.status_code, self._request_summary...
[ "def", "_exception_default_handler", "(", "self", ",", "e", ")", ":", "if", "isinstance", "(", "e", ",", "HTTPError", ")", ":", "if", "e", ".", "log_message", ":", "format", "=", "\"%d %s: \"", "+", "e", ".", "log_message", "args", "=", "[", "e", ".", ...
This method is a copy of tornado.web.RequestHandler._handle_request_exception
[ "This", "method", "is", "a", "copy", "of", "tornado", ".", "web", ".", "RequestHandler", ".", "_handle_request_exception" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/base.py#L94-L110
train
This method is a copy of tornado. web. RequestHandler. _handle_request_exception
reorx/torext
torext/handlers/base.py
BaseHandler._handle_request_exception
def _handle_request_exception(self, e): """This method handle HTTPError exceptions the same as how tornado does, leave other exceptions to be handled by user defined handler function maped in class attribute `EXCEPTION_HANDLERS` Common HTTP status codes: 200 OK 3...
python
def _handle_request_exception(self, e): """This method handle HTTPError exceptions the same as how tornado does, leave other exceptions to be handled by user defined handler function maped in class attribute `EXCEPTION_HANDLERS` Common HTTP status codes: 200 OK 3...
[ "def", "_handle_request_exception", "(", "self", ",", "e", ")", ":", "handle_func", "=", "self", ".", "_exception_default_handler", "if", "self", ".", "EXCEPTION_HANDLERS", ":", "for", "excs", ",", "func_name", "in", "self", ".", "EXCEPTION_HANDLERS", ".", "item...
This method handle HTTPError exceptions the same as how tornado does, leave other exceptions to be handled by user defined handler function maped in class attribute `EXCEPTION_HANDLERS` Common HTTP status codes: 200 OK 301 Moved Permanently 302 Found ...
[ "This", "method", "handle", "HTTPError", "exceptions", "the", "same", "as", "how", "tornado", "does", "leave", "other", "exceptions", "to", "be", "handled", "by", "user", "defined", "handler", "function", "maped", "in", "class", "attribute", "EXCEPTION_HANDLERS" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/base.py#L112-L139
train
This method handles HTTPError exceptions by user defined handler function.
reorx/torext
torext/handlers/base.py
BaseHandler.flush
def flush(self, *args, **kwgs): """ Before `RequestHandler.flush` was called, we got the final _write_buffer. This method will not be called in wsgi mode """ if settings['LOG_RESPONSE'] and not self._status_code == 500: log_response(self) super(BaseHandler, ...
python
def flush(self, *args, **kwgs): """ Before `RequestHandler.flush` was called, we got the final _write_buffer. This method will not be called in wsgi mode """ if settings['LOG_RESPONSE'] and not self._status_code == 500: log_response(self) super(BaseHandler, ...
[ "def", "flush", "(", "self", ",", "*", "args", ",", "*", "*", "kwgs", ")", ":", "if", "settings", "[", "'LOG_RESPONSE'", "]", "and", "not", "self", ".", "_status_code", "==", "500", ":", "log_response", "(", "self", ")", "super", "(", "BaseHandler", ...
Before `RequestHandler.flush` was called, we got the final _write_buffer. This method will not be called in wsgi mode
[ "Before", "RequestHandler", ".", "flush", "was", "called", "we", "got", "the", "final", "_write_buffer", "." ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/base.py#L166-L175
train
This method is called by the server to flush the internal write buffer.
reorx/torext
torext/handlers/base.py
BaseHandler.write_json
def write_json(self, chunk, code=None, headers=None): """A convenient method that binds `chunk`, `code`, `headers` together chunk could be any type of (str, dict, list) """ assert chunk is not None, 'None cound not be written in write_json' self.set_header("Content-Type", "appli...
python
def write_json(self, chunk, code=None, headers=None): """A convenient method that binds `chunk`, `code`, `headers` together chunk could be any type of (str, dict, list) """ assert chunk is not None, 'None cound not be written in write_json' self.set_header("Content-Type", "appli...
[ "def", "write_json", "(", "self", ",", "chunk", ",", "code", "=", "None", ",", "headers", "=", "None", ")", ":", "assert", "chunk", "is", "not", "None", ",", "'None cound not be written in write_json'", "self", ".", "set_header", "(", "\"Content-Type\"", ",", ...
A convenient method that binds `chunk`, `code`, `headers` together chunk could be any type of (str, dict, list)
[ "A", "convenient", "method", "that", "binds", "chunk", "code", "headers", "together" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/base.py#L177-L202
train
A convenient method that binds chunk code and headers together
reorx/torext
torext/handlers/base.py
BaseHandler.write_file
def write_file(self, file_path, mime_type=None): """Copy from tornado.web.StaticFileHandler """ if not os.path.exists(file_path): raise HTTPError(404) if not os.path.isfile(file_path): raise HTTPError(403, "%s is not a file", file_path) stat_result = os.s...
python
def write_file(self, file_path, mime_type=None): """Copy from tornado.web.StaticFileHandler """ if not os.path.exists(file_path): raise HTTPError(404) if not os.path.isfile(file_path): raise HTTPError(403, "%s is not a file", file_path) stat_result = os.s...
[ "def", "write_file", "(", "self", ",", "file_path", ",", "mime_type", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "file_path", ")", ":", "raise", "HTTPError", "(", "404", ")", "if", "not", "os", ".", "path", ".", "isf...
Copy from tornado.web.StaticFileHandler
[ "Copy", "from", "tornado", ".", "web", ".", "StaticFileHandler" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/base.py#L204-L237
train
Write the file to the response.
reorx/torext
torext/handlers/base.py
BaseHandler.decode_signed_value
def decode_signed_value(self, name, value, max_age_days=None): """Do what `RequestHandler.get_secure_cookie` does(when `value` is not None), but with a more friendly name What opposite to it is `RequestHandler.create_signed_value` """ kwgs = {} if max_age_days is not Non...
python
def decode_signed_value(self, name, value, max_age_days=None): """Do what `RequestHandler.get_secure_cookie` does(when `value` is not None), but with a more friendly name What opposite to it is `RequestHandler.create_signed_value` """ kwgs = {} if max_age_days is not Non...
[ "def", "decode_signed_value", "(", "self", ",", "name", ",", "value", ",", "max_age_days", "=", "None", ")", ":", "kwgs", "=", "{", "}", "if", "max_age_days", "is", "not", "None", ":", "kwgs", "[", "'max_age_days'", "]", "=", "max_age_days", "return", "t...
Do what `RequestHandler.get_secure_cookie` does(when `value` is not None), but with a more friendly name What opposite to it is `RequestHandler.create_signed_value`
[ "Do", "what", "RequestHandler", ".", "get_secure_cookie", "does", "(", "when", "value", "is", "not", "None", ")", "but", "with", "a", "more", "friendly", "name" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/base.py#L239-L248
train
Decode a signed value from a cookie.
reorx/torext
torext/handlers/base.py
BaseHandler.prepare
def prepare(self): """Behaves like a middleware between raw request and handling process, If `PREPARES` is defined on handler class, which should be a list, for example, ['auth', 'context'], method whose name is constitute by prefix '_prepare_' and string in this list will be ex...
python
def prepare(self): """Behaves like a middleware between raw request and handling process, If `PREPARES` is defined on handler class, which should be a list, for example, ['auth', 'context'], method whose name is constitute by prefix '_prepare_' and string in this list will be ex...
[ "def", "prepare", "(", "self", ")", ":", "if", "settings", "[", "'LOG_REQUEST'", "]", ":", "log_request", "(", "self", ")", "for", "i", "in", "self", ".", "PREPARES", ":", "getattr", "(", "self", ",", "'prepare_'", "+", "i", ")", "(", ")", "if", "s...
Behaves like a middleware between raw request and handling process, If `PREPARES` is defined on handler class, which should be a list, for example, ['auth', 'context'], method whose name is constitute by prefix '_prepare_' and string in this list will be executed by sequence. In this ex...
[ "Behaves", "like", "a", "middleware", "between", "raw", "request", "and", "handling", "process" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/base.py#L250-L265
train
This method is used to prepare the raw request and handling process.
reorx/torext
torext/handlers/base.py
BaseHandler.render_string
def render_string(self, template_name, **kwargs): """This method was rewritten to support multiple template engine (Determine by `TEMPLATE_ENGINE` setting, could be `tornado` and `jinja2`), it will only affect on template rendering process, ui modules feature, which is mostly exposed in ...
python
def render_string(self, template_name, **kwargs): """This method was rewritten to support multiple template engine (Determine by `TEMPLATE_ENGINE` setting, could be `tornado` and `jinja2`), it will only affect on template rendering process, ui modules feature, which is mostly exposed in ...
[ "def", "render_string", "(", "self", ",", "template_name", ",", "*", "*", "kwargs", ")", ":", "if", "'tornado'", "==", "settings", "[", "'TEMPLATE_ENGINE'", "]", ":", "return", "super", "(", "BaseHandler", ",", "self", ")", ".", "render_string", "(", "temp...
This method was rewritten to support multiple template engine (Determine by `TEMPLATE_ENGINE` setting, could be `tornado` and `jinja2`), it will only affect on template rendering process, ui modules feature, which is mostly exposed in `render` method, is kept to be used as normal.
[ "This", "method", "was", "rewritten", "to", "support", "multiple", "template", "engine", "(", "Determine", "by", "TEMPLATE_ENGINE", "setting", "could", "be", "tornado", "and", "jinja2", ")", "it", "will", "only", "affect", "on", "template", "rendering", "process...
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/base.py#L267-L280
train
This method is rewritten to support multiple template engine and jinja2 templates.
reorx/torext
torext/handlers/base.py
WSGIStreamHandler.finish
def finish(self): """Finishes this response, ending the HTTP request.""" if self._finished: raise RuntimeError("finish() called twice. May be caused " "by using async operations without the " "@asynchronous decorator.") i...
python
def finish(self): """Finishes this response, ending the HTTP request.""" if self._finished: raise RuntimeError("finish() called twice. May be caused " "by using async operations without the " "@asynchronous decorator.") i...
[ "def", "finish", "(", "self", ")", ":", "if", "self", ".", "_finished", ":", "raise", "RuntimeError", "(", "\"finish() called twice. May be caused \"", "\"by using async operations without the \"", "\"@asynchronous decorator.\"", ")", "if", "not", "hasattr", "(", "self",...
Finishes this response, ending the HTTP request.
[ "Finishes", "this", "response", "ending", "the", "HTTP", "request", "." ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/handlers/base.py#L291-L329
train
Finishes this response ending the HTTP request.
testedminds/sand
sand/csv.py
csv_to_dicts
def csv_to_dicts(file, header=None): """Reads a csv and returns a List of Dicts with keys given by header row.""" with open(file) as csvfile: return [row for row in csv.DictReader(csvfile, fieldnames=header)]
python
def csv_to_dicts(file, header=None): """Reads a csv and returns a List of Dicts with keys given by header row.""" with open(file) as csvfile: return [row for row in csv.DictReader(csvfile, fieldnames=header)]
[ "def", "csv_to_dicts", "(", "file", ",", "header", "=", "None", ")", ":", "with", "open", "(", "file", ")", "as", "csvfile", ":", "return", "[", "row", "for", "row", "in", "csv", ".", "DictReader", "(", "csvfile", ",", "fieldnames", "=", "header", ")...
Reads a csv and returns a List of Dicts with keys given by header row.
[ "Reads", "a", "csv", "and", "returns", "a", "List", "of", "Dicts", "with", "keys", "given", "by", "header", "row", "." ]
234f0eedb0742920cdf26da9bc84bf3f863a2f02
https://github.com/testedminds/sand/blob/234f0eedb0742920cdf26da9bc84bf3f863a2f02/sand/csv.py#L23-L26
train
Reads a csv and returns a List of Dicts with keys given by header row.