repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
geophysics-ubonn/crtomo_tools
lib/crtomo/eitManager.py
eitMan.model
def model(self, **kwargs): """Run the forward modeling for all frequencies. Use :py:func:`crtomo.eitManager.eitMan.measurements` to retrieve the resulting synthetic measurement spectra. Parameters ---------- **kwargs : dict, optional All kwargs are directly ...
python
def model(self, **kwargs): """Run the forward modeling for all frequencies. Use :py:func:`crtomo.eitManager.eitMan.measurements` to retrieve the resulting synthetic measurement spectra. Parameters ---------- **kwargs : dict, optional All kwargs are directly ...
[ "def", "model", "(", "self", ",", "**", "kwargs", ")", ":", "for", "key", ",", "td", "in", "self", ".", "tds", ".", "items", "(", ")", ":", "td", ".", "model", "(", "**", "kwargs", ")" ]
Run the forward modeling for all frequencies. Use :py:func:`crtomo.eitManager.eitMan.measurements` to retrieve the resulting synthetic measurement spectra. Parameters ---------- **kwargs : dict, optional All kwargs are directly provide to the underlying ...
[ "Run", "the", "forward", "modeling", "for", "all", "frequencies", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L474-L488
train
geophysics-ubonn/crtomo_tools
lib/crtomo/eitManager.py
eitMan.measurements
def measurements(self): """Return modeled measurements 1. dimension: frequency 2. dimension: config-number 3. dimension: 2: magnitude and phase (resistivity) """ m_all = np.array([self.tds[key].measurements() for key in sorted(self.tds.keys())]...
python
def measurements(self): """Return modeled measurements 1. dimension: frequency 2. dimension: config-number 3. dimension: 2: magnitude and phase (resistivity) """ m_all = np.array([self.tds[key].measurements() for key in sorted(self.tds.keys())]...
[ "def", "measurements", "(", "self", ")", ":", "m_all", "=", "np", ".", "array", "(", "[", "self", ".", "tds", "[", "key", "]", ".", "measurements", "(", ")", "for", "key", "in", "sorted", "(", "self", ".", "tds", ".", "keys", "(", ")", ")", "]"...
Return modeled measurements 1. dimension: frequency 2. dimension: config-number 3. dimension: 2: magnitude and phase (resistivity)
[ "Return", "modeled", "measurements" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L490-L500
train
geophysics-ubonn/crtomo_tools
lib/crtomo/eitManager.py
eitMan.get_measurement_responses
def get_measurement_responses(self): """Return a dictionary of sip_responses for the modeled SIP spectra Note that this function does NOT check that each frequency contains the same configurations! Returns ------- responses : dict Dictionary with configurati...
python
def get_measurement_responses(self): """Return a dictionary of sip_responses for the modeled SIP spectra Note that this function does NOT check that each frequency contains the same configurations! Returns ------- responses : dict Dictionary with configurati...
[ "def", "get_measurement_responses", "(", "self", ")", ":", "configs", "=", "self", ".", "tds", "[", "sorted", "(", "self", ".", "tds", ".", "keys", "(", ")", ")", "[", "0", "]", "]", ".", "configs", ".", "configs", "measurements", "=", "self", ".", ...
Return a dictionary of sip_responses for the modeled SIP spectra Note that this function does NOT check that each frequency contains the same configurations! Returns ------- responses : dict Dictionary with configurations as keys
[ "Return", "a", "dictionary", "of", "sip_responses", "for", "the", "modeled", "SIP", "spectra" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L502-L527
train
reorx/torext
examples/formal_project/manage.py
create_database
def create_database(name, number=1, force_clear=False): """Command to create a database """ print 'Got:' print 'name', name, type(name) print 'number', number, type(number) print 'force_clear', force_clear, type(force_clear)
python
def create_database(name, number=1, force_clear=False): """Command to create a database """ print 'Got:' print 'name', name, type(name) print 'number', number, type(number) print 'force_clear', force_clear, type(force_clear)
[ "def", "create_database", "(", "name", ",", "number", "=", "1", ",", "force_clear", "=", "False", ")", ":", "print", "'Got:'", "print", "'name'", ",", "name", ",", "type", "(", "name", ")", "print", "'number'", ",", "number", ",", "type", "(", "number"...
Command to create a database
[ "Command", "to", "create", "a", "database" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/examples/formal_project/manage.py#L10-L16
train
NiklasRosenstein/py-bundler
bundler/nativedeps/windll.py
_get_long_path_name
def _get_long_path_name(path): """ Returns the long path name for a Windows path, i.e. the properly cased path of an existing file or directory. """ # Thanks to http://stackoverflow.com/a/3694799/791713 buf = ctypes.create_unicode_buffer(len(path) + 1) GetLongPathNameW = ctypes.windll.kernel32.GetLongPat...
python
def _get_long_path_name(path): """ Returns the long path name for a Windows path, i.e. the properly cased path of an existing file or directory. """ # Thanks to http://stackoverflow.com/a/3694799/791713 buf = ctypes.create_unicode_buffer(len(path) + 1) GetLongPathNameW = ctypes.windll.kernel32.GetLongPat...
[ "def", "_get_long_path_name", "(", "path", ")", ":", "buf", "=", "ctypes", ".", "create_unicode_buffer", "(", "len", "(", "path", ")", "+", "1", ")", "GetLongPathNameW", "=", "ctypes", ".", "windll", ".", "kernel32", ".", "GetLongPathNameW", "res", "=", "G...
Returns the long path name for a Windows path, i.e. the properly cased path of an existing file or directory.
[ "Returns", "the", "long", "path", "name", "for", "a", "Windows", "path", "i", ".", "e", ".", "the", "properly", "cased", "path", "of", "an", "existing", "file", "or", "directory", "." ]
80dd6dc971667ba015f7f67481417c45cc757231
https://github.com/NiklasRosenstein/py-bundler/blob/80dd6dc971667ba015f7f67481417c45cc757231/bundler/nativedeps/windll.py#L44-L57
train
NiklasRosenstein/py-bundler
bundler/nativedeps/windll.py
get_dependency_walker
def get_dependency_walker(): """ Checks if `depends.exe` is in the system PATH. If not, it will be downloaded and extracted to a temporary directory. Note that the file will not be deleted afterwards. Returns the path to the Dependency Walker executable. """ for dirname in os.getenv('PATH', '').split(os...
python
def get_dependency_walker(): """ Checks if `depends.exe` is in the system PATH. If not, it will be downloaded and extracted to a temporary directory. Note that the file will not be deleted afterwards. Returns the path to the Dependency Walker executable. """ for dirname in os.getenv('PATH', '').split(os...
[ "def", "get_dependency_walker", "(", ")", ":", "for", "dirname", "in", "os", ".", "getenv", "(", "'PATH'", ",", "''", ")", ".", "split", "(", "os", ".", "pathsep", ")", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "dirname", ",", "'de...
Checks if `depends.exe` is in the system PATH. If not, it will be downloaded and extracted to a temporary directory. Note that the file will not be deleted afterwards. Returns the path to the Dependency Walker executable.
[ "Checks", "if", "depends", ".", "exe", "is", "in", "the", "system", "PATH", ".", "If", "not", "it", "will", "be", "downloaded", "and", "extracted", "to", "a", "temporary", "directory", ".", "Note", "that", "the", "file", "will", "not", "be", "deleted", ...
80dd6dc971667ba015f7f67481417c45cc757231
https://github.com/NiklasRosenstein/py-bundler/blob/80dd6dc971667ba015f7f67481417c45cc757231/bundler/nativedeps/windll.py#L60-L94
train
reorx/torext
torext/script.py
Manager.prepare
def prepare(self, setup_func): """This decorator wrap a function which setup a environment before running a command @manager.prepare(setup_func) def some_command(): pass """ assert inspect.isfunction(setup_func) argsspec = inspect.getargspec(setup_func...
python
def prepare(self, setup_func): """This decorator wrap a function which setup a environment before running a command @manager.prepare(setup_func) def some_command(): pass """ assert inspect.isfunction(setup_func) argsspec = inspect.getargspec(setup_func...
[ "def", "prepare", "(", "self", ",", "setup_func", ")", ":", "assert", "inspect", ".", "isfunction", "(", "setup_func", ")", "argsspec", "=", "inspect", ".", "getargspec", "(", "setup_func", ")", "if", "argsspec", ".", "args", ":", "raise", "ValueError", "(...
This decorator wrap a function which setup a environment before running a command @manager.prepare(setup_func) def some_command(): pass
[ "This", "decorator", "wrap", "a", "function", "which", "setup", "a", "environment", "before", "running", "a", "command" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/script.py#L220-L239
train
Nic30/hwtGraph
hwtGraph/elk/fromHwt/utils.py
addPort
def addPort(n: LNode, intf: Interface): """ Add LayoutExternalPort for interface """ d = PortTypeFromDir(intf._direction) ext_p = LayoutExternalPort( n, name=intf._name, direction=d, node2lnode=n._node2lnode) ext_p.originObj = originObjOfPort(intf) n.children.append(ext_p) addPor...
python
def addPort(n: LNode, intf: Interface): """ Add LayoutExternalPort for interface """ d = PortTypeFromDir(intf._direction) ext_p = LayoutExternalPort( n, name=intf._name, direction=d, node2lnode=n._node2lnode) ext_p.originObj = originObjOfPort(intf) n.children.append(ext_p) addPor...
[ "def", "addPort", "(", "n", ":", "LNode", ",", "intf", ":", "Interface", ")", ":", "d", "=", "PortTypeFromDir", "(", "intf", ".", "_direction", ")", "ext_p", "=", "LayoutExternalPort", "(", "n", ",", "name", "=", "intf", ".", "_name", ",", "direction",...
Add LayoutExternalPort for interface
[ "Add", "LayoutExternalPort", "for", "interface" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/utils.py#L231-L241
train
tslight/treepick
treepick/draw.py
Draw.drawtree
def drawtree(self): ''' Loop over the object, process path attribute sets, and drawlines based on their current contents. ''' self.win.erase() self.line = 0 for child, depth in self.traverse(): child.curline = self.curline child.picked = se...
python
def drawtree(self): ''' Loop over the object, process path attribute sets, and drawlines based on their current contents. ''' self.win.erase() self.line = 0 for child, depth in self.traverse(): child.curline = self.curline child.picked = se...
[ "def", "drawtree", "(", "self", ")", ":", "self", ".", "win", ".", "erase", "(", ")", "self", ".", "line", "=", "0", "for", "child", ",", "depth", "in", "self", ".", "traverse", "(", ")", ":", "child", ".", "curline", "=", "self", ".", "curline",...
Loop over the object, process path attribute sets, and drawlines based on their current contents.
[ "Loop", "over", "the", "object", "process", "path", "attribute", "sets", "and", "drawlines", "based", "on", "their", "current", "contents", "." ]
7adf838900f11e8845e17d8c79bb2b23617aec2c
https://github.com/tslight/treepick/blob/7adf838900f11e8845e17d8c79bb2b23617aec2c/treepick/draw.py#L64-L90
train
albert12132/templar
templar/api/config.py
import_config
def import_config(config_path): """Import a Config from a given path, relative to the current directory. The module specified by the config file must contain a variable called `configuration` that is assigned to a Config object. """ if not os.path.isfile(config_path): raise ConfigBuilderErr...
python
def import_config(config_path): """Import a Config from a given path, relative to the current directory. The module specified by the config file must contain a variable called `configuration` that is assigned to a Config object. """ if not os.path.isfile(config_path): raise ConfigBuilderErr...
[ "def", "import_config", "(", "config_path", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "config_path", ")", ":", "raise", "ConfigBuilderError", "(", "'Could not find config file: '", "+", "config_path", ")", "loader", "=", "importlib", ".", "...
Import a Config from a given path, relative to the current directory. The module specified by the config file must contain a variable called `configuration` that is assigned to a Config object.
[ "Import", "a", "Config", "from", "a", "given", "path", "relative", "to", "the", "current", "directory", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/api/config.py#L216-L233
train
rhayes777/PyAutoFit
autofit/optimize/optimizer.py
grid
def grid(fitness_function, no_dimensions, step_size): """ Grid search using a fitness function over a given number of dimensions and a given step size between inclusive limits of 0 and 1. Parameters ---------- fitness_function: function A function that takes a tuple of floats as an argu...
python
def grid(fitness_function, no_dimensions, step_size): """ Grid search using a fitness function over a given number of dimensions and a given step size between inclusive limits of 0 and 1. Parameters ---------- fitness_function: function A function that takes a tuple of floats as an argu...
[ "def", "grid", "(", "fitness_function", ",", "no_dimensions", ",", "step_size", ")", ":", "best_fitness", "=", "float", "(", "\"-inf\"", ")", "best_arguments", "=", "None", "for", "arguments", "in", "make_lists", "(", "no_dimensions", ",", "step_size", ")", ":...
Grid search using a fitness function over a given number of dimensions and a given step size between inclusive limits of 0 and 1. Parameters ---------- fitness_function: function A function that takes a tuple of floats as an argument no_dimensions: int The number of dimensions of th...
[ "Grid", "search", "using", "a", "fitness", "function", "over", "a", "given", "number", "of", "dimensions", "and", "a", "given", "step", "size", "between", "inclusive", "limits", "of", "0", "and", "1", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/optimizer.py#L1-L29
train
rhayes777/PyAutoFit
autofit/optimize/optimizer.py
make_lists
def make_lists(no_dimensions, step_size, centre_steps=True): """ Create a list of lists of floats covering every combination across no_dimensions of points of integer step size between 0 and 1 inclusive. Parameters ---------- no_dimensions: int The number of dimensions, that is the leng...
python
def make_lists(no_dimensions, step_size, centre_steps=True): """ Create a list of lists of floats covering every combination across no_dimensions of points of integer step size between 0 and 1 inclusive. Parameters ---------- no_dimensions: int The number of dimensions, that is the leng...
[ "def", "make_lists", "(", "no_dimensions", ",", "step_size", ",", "centre_steps", "=", "True", ")", ":", "if", "no_dimensions", "==", "0", ":", "return", "[", "[", "]", "]", "sub_lists", "=", "make_lists", "(", "no_dimensions", "-", "1", ",", "step_size", ...
Create a list of lists of floats covering every combination across no_dimensions of points of integer step size between 0 and 1 inclusive. Parameters ---------- no_dimensions: int The number of dimensions, that is the length of the lists step_size: float The step size centre_ste...
[ "Create", "a", "list", "of", "lists", "of", "floats", "covering", "every", "combination", "across", "no_dimensions", "of", "points", "of", "integer", "step", "size", "between", "0", "and", "1", "inclusive", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/optimizer.py#L32-L55
train
Nic30/hwtGraph
hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py
portCnt
def portCnt(port): """ recursively count number of ports without children """ if port.children: return sum(map(lambda p: portCnt(p), port.children)) else: return 1
python
def portCnt(port): """ recursively count number of ports without children """ if port.children: return sum(map(lambda p: portCnt(p), port.children)) else: return 1
[ "def", "portCnt", "(", "port", ")", ":", "if", "port", ".", "children", ":", "return", "sum", "(", "map", "(", "lambda", "p", ":", "portCnt", "(", "p", ")", ",", "port", ".", "children", ")", ")", "else", ":", "return", "1" ]
recursively count number of ports without children
[ "recursively", "count", "number", "of", "ports", "without", "children" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py#L43-L50
train
Nic30/hwtGraph
hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py
copyPort
def copyPort(port, targetLNode, reverseDir, topPortName=None): """ Create identical port on targetNode """ newP = _copyPort(port, targetLNode, reverseDir) if topPortName is not None: newP.name = topPortName return newP
python
def copyPort(port, targetLNode, reverseDir, topPortName=None): """ Create identical port on targetNode """ newP = _copyPort(port, targetLNode, reverseDir) if topPortName is not None: newP.name = topPortName return newP
[ "def", "copyPort", "(", "port", ",", "targetLNode", ",", "reverseDir", ",", "topPortName", "=", "None", ")", ":", "newP", "=", "_copyPort", "(", "port", ",", "targetLNode", ",", "reverseDir", ")", "if", "topPortName", "is", "not", "None", ":", "newP", "....
Create identical port on targetNode
[ "Create", "identical", "port", "on", "targetNode" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py#L76-L85
train
Nic30/hwtGraph
hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py
walkSignalPorts
def walkSignalPorts(rootPort: LPort): """ recursively walk ports without any children """ if rootPort.children: for ch in rootPort.children: yield from walkSignalPorts(ch) else: yield rootPort
python
def walkSignalPorts(rootPort: LPort): """ recursively walk ports without any children """ if rootPort.children: for ch in rootPort.children: yield from walkSignalPorts(ch) else: yield rootPort
[ "def", "walkSignalPorts", "(", "rootPort", ":", "LPort", ")", ":", "if", "rootPort", ".", "children", ":", "for", "ch", "in", "rootPort", ".", "children", ":", "yield", "from", "walkSignalPorts", "(", "ch", ")", "else", ":", "yield", "rootPort" ]
recursively walk ports without any children
[ "recursively", "walk", "ports", "without", "any", "children" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py#L88-L96
train
zalando-stups/lizzy-client
lizzy_client/cli.py
agent_error
def agent_error(e: requests.HTTPError, fatal=True): """ Prints an agent error and exits """ try: data = e.response.json() details = data['detail'] # type: str except JSONDecodeError: details = e.response.text or str(e.response) lines = ('[AGENT] {}'.format(line) for lin...
python
def agent_error(e: requests.HTTPError, fatal=True): """ Prints an agent error and exits """ try: data = e.response.json() details = data['detail'] # type: str except JSONDecodeError: details = e.response.text or str(e.response) lines = ('[AGENT] {}'.format(line) for lin...
[ "def", "agent_error", "(", "e", ":", "requests", ".", "HTTPError", ",", "fatal", "=", "True", ")", ":", "try", ":", "data", "=", "e", ".", "response", ".", "json", "(", ")", "details", "=", "data", "[", "'detail'", "]", "except", "JSONDecodeError", "...
Prints an agent error and exits
[ "Prints", "an", "agent", "error", "and", "exits" ]
0af9733ca5a25ebd0a9dc1453f2a7592efcee56a
https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L99-L115
train
zalando-stups/lizzy-client
lizzy_client/cli.py
parse_stack_refs
def parse_stack_refs(stack_references: List[str]) -> List[str]: ''' Check if items included in `stack_references` are Senza definition file paths or stack name reference. If Senza definition file path, substitute the definition file path by the stack name in the same position on the list. ''' ...
python
def parse_stack_refs(stack_references: List[str]) -> List[str]: ''' Check if items included in `stack_references` are Senza definition file paths or stack name reference. If Senza definition file path, substitute the definition file path by the stack name in the same position on the list. ''' ...
[ "def", "parse_stack_refs", "(", "stack_references", ":", "List", "[", "str", "]", ")", "->", "List", "[", "str", "]", ":", "stack_names", "=", "[", "]", "references", "=", "list", "(", "stack_references", ")", "references", ".", "reverse", "(", ")", "whi...
Check if items included in `stack_references` are Senza definition file paths or stack name reference. If Senza definition file path, substitute the definition file path by the stack name in the same position on the list.
[ "Check", "if", "items", "included", "in", "stack_references", "are", "Senza", "definition", "file", "paths", "or", "stack", "name", "reference", ".", "If", "Senza", "definition", "file", "path", "substitute", "the", "definition", "file", "path", "by", "the", "...
0af9733ca5a25ebd0a9dc1453f2a7592efcee56a
https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L147-L171
train
zalando-stups/lizzy-client
lizzy_client/cli.py
list_stacks
def list_stacks(stack_ref: List[str], all: bool, remote: str, region: str, watch: int, output: str): """List Lizzy stacks""" lizzy = setup_lizzy_client(remote) stack_references = parse_stack_refs(stack_ref) while True: rows = [] for stack in lizzy.get_stacks(stack_refere...
python
def list_stacks(stack_ref: List[str], all: bool, remote: str, region: str, watch: int, output: str): """List Lizzy stacks""" lizzy = setup_lizzy_client(remote) stack_references = parse_stack_refs(stack_ref) while True: rows = [] for stack in lizzy.get_stacks(stack_refere...
[ "def", "list_stacks", "(", "stack_ref", ":", "List", "[", "str", "]", ",", "all", ":", "bool", ",", "remote", ":", "str", ",", "region", ":", "str", ",", "watch", ":", "int", ",", "output", ":", "str", ")", ":", "lizzy", "=", "setup_lizzy_client", ...
List Lizzy stacks
[ "List", "Lizzy", "stacks" ]
0af9733ca5a25ebd0a9dc1453f2a7592efcee56a
https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L348-L374
train
zalando-stups/lizzy-client
lizzy_client/cli.py
traffic
def traffic(stack_name: str, stack_version: Optional[str], percentage: Optional[int], region: Optional[str], remote: Optional[str], output: Optional[str]): '''Manage stack traffic''' lizzy = setup_lizzy_client(remote) if percentage is None: ...
python
def traffic(stack_name: str, stack_version: Optional[str], percentage: Optional[int], region: Optional[str], remote: Optional[str], output: Optional[str]): '''Manage stack traffic''' lizzy = setup_lizzy_client(remote) if percentage is None: ...
[ "def", "traffic", "(", "stack_name", ":", "str", ",", "stack_version", ":", "Optional", "[", "str", "]", ",", "percentage", ":", "Optional", "[", "int", "]", ",", "region", ":", "Optional", "[", "str", "]", ",", "remote", ":", "Optional", "[", "str", ...
Manage stack traffic
[ "Manage", "stack", "traffic" ]
0af9733ca5a25ebd0a9dc1453f2a7592efcee56a
https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L387-L418
train
zalando-stups/lizzy-client
lizzy_client/cli.py
scale
def scale(stack_name: str, stack_version: Optional[str], new_scale: int, region: Optional[str], remote: Optional[str]): '''Rescale a stack''' lizzy = setup_lizzy_client(remote) with Action('Requesting rescale..'): stack_id = '{stack_name}-{stack_version}'.for...
python
def scale(stack_name: str, stack_version: Optional[str], new_scale: int, region: Optional[str], remote: Optional[str]): '''Rescale a stack''' lizzy = setup_lizzy_client(remote) with Action('Requesting rescale..'): stack_id = '{stack_name}-{stack_version}'.for...
[ "def", "scale", "(", "stack_name", ":", "str", ",", "stack_version", ":", "Optional", "[", "str", "]", ",", "new_scale", ":", "int", ",", "region", ":", "Optional", "[", "str", "]", ",", "remote", ":", "Optional", "[", "str", "]", ")", ":", "lizzy", ...
Rescale a stack
[ "Rescale", "a", "stack" ]
0af9733ca5a25ebd0a9dc1453f2a7592efcee56a
https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L428-L438
train
zalando-stups/lizzy-client
lizzy_client/cli.py
delete
def delete(stack_ref: List[str], region: str, dry_run: bool, force: bool, remote: str): """Delete Cloud Formation stacks""" lizzy = setup_lizzy_client(remote) stack_refs = get_stack_refs(stack_ref) all_with_version = all(stack.version is not None for stack in stack_...
python
def delete(stack_ref: List[str], region: str, dry_run: bool, force: bool, remote: str): """Delete Cloud Formation stacks""" lizzy = setup_lizzy_client(remote) stack_refs = get_stack_refs(stack_ref) all_with_version = all(stack.version is not None for stack in stack_...
[ "def", "delete", "(", "stack_ref", ":", "List", "[", "str", "]", ",", "region", ":", "str", ",", "dry_run", ":", "bool", ",", "force", ":", "bool", ",", "remote", ":", "str", ")", ":", "lizzy", "=", "setup_lizzy_client", "(", "remote", ")", "stack_re...
Delete Cloud Formation stacks
[ "Delete", "Cloud", "Formation", "stacks" ]
0af9733ca5a25ebd0a9dc1453f2a7592efcee56a
https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L449-L478
train
unt-libraries/pyuntl
pyuntl/metadata_generator.py
pydict2xml
def pydict2xml(filename, metadata_dict, **kwargs): """Create an XML file. Takes a path to where the XML file should be created and a metadata dictionary. """ try: f = open(filename, 'w') f.write(pydict2xmlstring(metadata_dict, **kwargs).encode('utf-8')) f.close() except:...
python
def pydict2xml(filename, metadata_dict, **kwargs): """Create an XML file. Takes a path to where the XML file should be created and a metadata dictionary. """ try: f = open(filename, 'w') f.write(pydict2xmlstring(metadata_dict, **kwargs).encode('utf-8')) f.close() except:...
[ "def", "pydict2xml", "(", "filename", ",", "metadata_dict", ",", "**", "kwargs", ")", ":", "try", ":", "f", "=", "open", "(", "filename", ",", "'w'", ")", "f", ".", "write", "(", "pydict2xmlstring", "(", "metadata_dict", ",", "**", "kwargs", ")", ".", ...
Create an XML file. Takes a path to where the XML file should be created and a metadata dictionary.
[ "Create", "an", "XML", "file", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/metadata_generator.py#L96-L109
train
unt-libraries/pyuntl
pyuntl/metadata_generator.py
pydict2xmlstring
def pydict2xmlstring(metadata_dict, **kwargs): """Create an XML string from a metadata dictionary.""" ordering = kwargs.get('ordering', UNTL_XML_ORDER) root_label = kwargs.get('root_label', 'metadata') root_namespace = kwargs.get('root_namespace', None) elements_namespace = kwargs.get('elements_name...
python
def pydict2xmlstring(metadata_dict, **kwargs): """Create an XML string from a metadata dictionary.""" ordering = kwargs.get('ordering', UNTL_XML_ORDER) root_label = kwargs.get('root_label', 'metadata') root_namespace = kwargs.get('root_namespace', None) elements_namespace = kwargs.get('elements_name...
[ "def", "pydict2xmlstring", "(", "metadata_dict", ",", "**", "kwargs", ")", ":", "ordering", "=", "kwargs", ".", "get", "(", "'ordering'", ",", "UNTL_XML_ORDER", ")", "root_label", "=", "kwargs", ".", "get", "(", "'root_label'", ",", "'metadata'", ")", "root_...
Create an XML string from a metadata dictionary.
[ "Create", "an", "XML", "string", "from", "a", "metadata", "dictionary", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/metadata_generator.py#L112-L170
train
unt-libraries/pyuntl
pyuntl/metadata_generator.py
create_dict_subelement
def create_dict_subelement(root, subelement, content, **kwargs): """Create a XML subelement from a Python dictionary.""" attribs = kwargs.get('attribs', None) namespace = kwargs.get('namespace', None) key = subelement # Add subelement's namespace and attributes. if namespace and attribs: ...
python
def create_dict_subelement(root, subelement, content, **kwargs): """Create a XML subelement from a Python dictionary.""" attribs = kwargs.get('attribs', None) namespace = kwargs.get('namespace', None) key = subelement # Add subelement's namespace and attributes. if namespace and attribs: ...
[ "def", "create_dict_subelement", "(", "root", ",", "subelement", ",", "content", ",", "**", "kwargs", ")", ":", "attribs", "=", "kwargs", ".", "get", "(", "'attribs'", ",", "None", ")", "namespace", "=", "kwargs", ".", "get", "(", "'namespace'", ",", "No...
Create a XML subelement from a Python dictionary.
[ "Create", "a", "XML", "subelement", "from", "a", "Python", "dictionary", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/metadata_generator.py#L173-L201
train
unt-libraries/pyuntl
pyuntl/metadata_generator.py
highwiredict2xmlstring
def highwiredict2xmlstring(highwire_elements, ordering=HIGHWIRE_ORDER): """Create an XML string from the highwire data dictionary.""" # Sort the elements by the ordering list. highwire_elements.sort(key=lambda obj: ordering.index(obj.name)) root = Element('metadata') for element in highwire_elements...
python
def highwiredict2xmlstring(highwire_elements, ordering=HIGHWIRE_ORDER): """Create an XML string from the highwire data dictionary.""" # Sort the elements by the ordering list. highwire_elements.sort(key=lambda obj: ordering.index(obj.name)) root = Element('metadata') for element in highwire_elements...
[ "def", "highwiredict2xmlstring", "(", "highwire_elements", ",", "ordering", "=", "HIGHWIRE_ORDER", ")", ":", "highwire_elements", ".", "sort", "(", "key", "=", "lambda", "obj", ":", "ordering", ".", "index", "(", "obj", ".", "name", ")", ")", "root", "=", ...
Create an XML string from the highwire data dictionary.
[ "Create", "an", "XML", "string", "from", "the", "highwire", "data", "dictionary", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/metadata_generator.py#L204-L216
train
geophysics-ubonn/crtomo_tools
lib/crtomo/binaries.py
get
def get(binary_name): """return a valid path to the given binary. Return an error if no existing binary can be found. Parameters ---------- binary_name: string a binary name used as a key in the 'binaries' dictionary above Return ------ string full path to binary ""...
python
def get(binary_name): """return a valid path to the given binary. Return an error if no existing binary can be found. Parameters ---------- binary_name: string a binary name used as a key in the 'binaries' dictionary above Return ------ string full path to binary ""...
[ "def", "get", "(", "binary_name", ")", ":", "if", "binary_name", "not", "in", "binaries", ":", "raise", "Exception", "(", "'binary_name: {0} not found'", ".", "format", "(", "binary_name", ")", ")", "system", "=", "platform", ".", "system", "(", ")", "binary...
return a valid path to the given binary. Return an error if no existing binary can be found. Parameters ---------- binary_name: string a binary name used as a key in the 'binaries' dictionary above Return ------ string full path to binary
[ "return", "a", "valid", "path", "to", "the", "given", "binary", ".", "Return", "an", "error", "if", "no", "existing", "binary", "can", "be", "found", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/binaries.py#L79-L103
train
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", ")", ":", "engine", "=", "sqlalchemy", ".", "create_engine", "(", "connect_str", ")", "cursor", "=", "engine", ".", "execute", "(", "\"SELECT GET_LOCK('upgrade_{}', ...
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
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", ")", ":", "if", "not", "sqlalchemy_utils", ".", "database_exists", "(", "connect_str", ")", ":", "logger", ".", "info", "(", "'Creating {}'", ".", "format", "(", "dbname", ")", ")", ...
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
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
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", ")", ":", "self", ".", "native", "=", "False", "self", ".", "_prefix", "=", "\"\"", "self", ".", "_package", "=", "\"\"", "url", "=", "re", ".", "sub", "(", "r'http://'", ",", "''", ",", "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
[ "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
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", ")", ":", "r", "before", "=", "match", ".", "group", "(", "1", ")", "tabs", "=", "len", "(", "match", ".", "group", "(", "2", ")", ")", "return", "before", "+", "(", "' '", "*", "(", "TAB_SIZE", "*", "tabs", "-...
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
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", ")", ":", "r", "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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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", ")", ":", "u", "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
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", ")", ":", "u", "expires", "=", "self", ".", "expires", "if", "isinstance", "(", "self", ".", "expires", ",", "timedelta", ")", "else", "timedelta", "(", "seconds", "=", ...
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
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", ")", ":", "u", "with", "transaction", ".", "atomic", "(", ")", ":", "chord_data", "=", "ChordData", ".", "objects", ".", "select_for_updat...
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
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", ")", ":", "u", "callback_entry", "=", "TaskMeta", ".", "objects", ".", "create", "(", "task_id", "=", "body", ".", "id", ")", "ch...
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
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", ")", ":", "u", "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
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
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
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
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
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\"", ")", "if", "self", ".", "purge_first", ":", "Category", ".", "objects", ".", "filter", "(", "site_id", "=", "self", ".", "...
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
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
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\"", ")", "if", "self", ".", "purge_first", ":", "Tag", ".", "objects", ".", "filter", "(", "site_id", "=", "self", ".", "site_id", ")", ...
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
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
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\"", ")", "if", "self", ".", "purge_first", ":", "Author", ".", "objects", ".", "filter", "(", "site_id", "=", "self", ".", "site_id"...
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
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\"", ",", "a...
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
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\"", ")", "if", "self", ".", "purge_first", ":", "logger", ".", "warning", "(", "\"purging ALL media from site %s\"", ",", "self", ".", "sit...
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
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\"", ",", "api_me...
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
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
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", ")", "if", "self", ".", "purge_first", ...
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
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
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", ")", ":", "if", "post_categories", ...
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
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", ")", ":", "if", "bulk_mode", ":", "author", "=", "self", ".", "ref_data_map", "[", "\"authors\"", "]", ".", "get", "(", "api_author", "[", "\"ID\"", "]", ")", "if", "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
[ "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
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
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
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", "if", "bulk_mode", ":", "category", "=", "self", ".", "ref_data_map", "[", "\"categories\"", "]", ".", "get", "(", "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
[ "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
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
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", "if", "bulk_mode", ":", "tag", "=", "self", ".", "ref_data_map", "[", "\"tags\"", "]", ".", "get", "(", "api_tag", "[", "\"ID\"", "]", ")", "if", ...
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
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
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", "if", "bulk_mode", ":", "attachment", "=", "self", ".", "ref_data_map", "[", "\"media\"", "]", ".", "get", "(", "api_media_at...
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
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
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", ")", ":", "existing_post", ".", "author", "=", "author", "existing_post", ".", "post_date", "=", "api_post"...
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
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
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", ")", "for", "post_wp_id", ",", "categories", "in", "six", ".", ...
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
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
tslight/treepick
treepick/actions.py
Actions.nextparent
def nextparent(self, parent, depth): ''' Add lines to current line by traversing the grandparent object again and once we reach our current line counting every line that is prefixed with the parent directory. ''' if depth > 1: # can't jump to parent of root node! ...
python
def nextparent(self, parent, depth): ''' Add lines to current line by traversing the grandparent object again and once we reach our current line counting every line that is prefixed with the parent directory. ''' if depth > 1: # can't jump to parent of root node! ...
[ "def", "nextparent", "(", "self", ",", "parent", ",", "depth", ")", ":", "if", "depth", ">", "1", ":", "pdir", "=", "os", ".", "path", ".", "dirname", "(", "self", ".", "name", ")", "line", "=", "0", "for", "c", ",", "d", "in", "parent", ".", ...
Add lines to current line by traversing the grandparent object again and once we reach our current line counting every line that is prefixed with the parent directory.
[ "Add", "lines", "to", "current", "line", "by", "traversing", "the", "grandparent", "object", "again", "and", "once", "we", "reach", "our", "current", "line", "counting", "every", "line", "that", "is", "prefixed", "with", "the", "parent", "directory", "." ]
7adf838900f11e8845e17d8c79bb2b23617aec2c
https://github.com/tslight/treepick/blob/7adf838900f11e8845e17d8c79bb2b23617aec2c/treepick/actions.py#L70-L90
train
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", ":", "for", "c", ",", "d", "in", "parent", ".", "traverse", "(", ")...
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
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
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
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
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
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
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
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
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
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
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
peterbe/gg
gg/main.py
cli
def cli(config, configfile, verbose): """A glorious command line tool to make your life with git, GitHub and Bugzilla much easier.""" config.verbose = verbose config.configfile = configfile if not os.path.isfile(configfile): state.write(configfile, {})
python
def cli(config, configfile, verbose): """A glorious command line tool to make your life with git, GitHub and Bugzilla much easier.""" config.verbose = verbose config.configfile = configfile if not os.path.isfile(configfile): state.write(configfile, {})
[ "def", "cli", "(", "config", ",", "configfile", ",", "verbose", ")", ":", "config", ".", "verbose", "=", "verbose", "config", ".", "configfile", "=", "configfile", "if", "not", "os", ".", "path", ".", "isfile", "(", "configfile", ")", ":", "state", "."...
A glorious command line tool to make your life with git, GitHub and Bugzilla much easier.
[ "A", "glorious", "command", "line", "tool", "to", "make", "your", "life", "with", "git", "GitHub", "and", "Bugzilla", "much", "easier", "." ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/main.py#L36-L42
train
ghukill/pyfc4
pyfc4/models.py
Repository.parse_uri
def parse_uri(self, uri=None): ''' parses and cleans up possible uri inputs, return instance of rdflib.term.URIRef Args: uri (rdflib.term.URIRef,str): input URI Returns: rdflib.term.URIRef ''' # no uri provided, assume root if not uri: return rdflib.term.URIRef(self.root) # string uri prov...
python
def parse_uri(self, uri=None): ''' parses and cleans up possible uri inputs, return instance of rdflib.term.URIRef Args: uri (rdflib.term.URIRef,str): input URI Returns: rdflib.term.URIRef ''' # no uri provided, assume root if not uri: return rdflib.term.URIRef(self.root) # string uri prov...
[ "def", "parse_uri", "(", "self", ",", "uri", "=", "None", ")", ":", "if", "not", "uri", ":", "return", "rdflib", ".", "term", ".", "URIRef", "(", "self", ".", "root", ")", "elif", "type", "(", "uri", ")", "==", "str", ":", "if", "type", "(", "u...
parses and cleans up possible uri inputs, return instance of rdflib.term.URIRef Args: uri (rdflib.term.URIRef,str): input URI Returns: rdflib.term.URIRef
[ "parses", "and", "cleans", "up", "possible", "uri", "inputs", "return", "instance", "of", "rdflib", ".", "term", ".", "URIRef" ]
59011df592f08978c4a901a908862d112a5dcf02
https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L105-L138
train
ghukill/pyfc4
pyfc4/models.py
Repository.create_resource
def create_resource(self, resource_type=None, uri=None): ''' Convenience method for creating a new resource Note: A Resource is instantiated, but is not yet created. Still requires resource.create(). Args: uri (rdflib.term.URIRef, str): uri of resource to create resource_type (NonRDFSource (Binary), B...
python
def create_resource(self, resource_type=None, uri=None): ''' Convenience method for creating a new resource Note: A Resource is instantiated, but is not yet created. Still requires resource.create(). Args: uri (rdflib.term.URIRef, str): uri of resource to create resource_type (NonRDFSource (Binary), B...
[ "def", "create_resource", "(", "self", ",", "resource_type", "=", "None", ",", "uri", "=", "None", ")", ":", "if", "resource_type", "in", "[", "NonRDFSource", ",", "Binary", ",", "BasicContainer", ",", "DirectContainer", ",", "IndirectContainer", "]", ":", "...
Convenience method for creating a new resource Note: A Resource is instantiated, but is not yet created. Still requires resource.create(). Args: uri (rdflib.term.URIRef, str): uri of resource to create resource_type (NonRDFSource (Binary), BasicContainer, DirectContainer, IndirectContainer): resource type...
[ "Convenience", "method", "for", "creating", "a", "new", "resource" ]
59011df592f08978c4a901a908862d112a5dcf02
https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L141-L159
train