repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
Erotemic/utool
utool/util_graph.py
dag_longest_path
def dag_longest_path(graph, source, target): """ Finds the longest path in a dag between two nodes """ if source == target: return [source] allpaths = nx.all_simple_paths(graph, source, target) longest_path = [] for l in allpaths: if len(l) > len(longest_path): lo...
python
def dag_longest_path(graph, source, target): """ Finds the longest path in a dag between two nodes """ if source == target: return [source] allpaths = nx.all_simple_paths(graph, source, target) longest_path = [] for l in allpaths: if len(l) > len(longest_path): lo...
[ "def", "dag_longest_path", "(", "graph", ",", "source", ",", "target", ")", ":", "if", "source", "==", "target", ":", "return", "[", "source", "]", "allpaths", "=", "nx", ".", "all_simple_paths", "(", "graph", ",", "source", ",", "target", ")", "longest_...
Finds the longest path in a dag between two nodes
[ "Finds", "the", "longest", "path", "in", "a", "dag", "between", "two", "nodes" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1126-L1137
train
Finds the longest path in a dag between two nodes
Erotemic/utool
utool/util_graph.py
reverse_path
def reverse_path(dict_, root, child_to_parents): """ CommandLine: python -m utool.util_graph --exec-reverse_path --show Example: >>> # ENABLE_DOCTEST >>> from utool.util_graph import * # NOQA >>> import utool as ut >>> child_to_parents = { >>> 'chip': ['...
python
def reverse_path(dict_, root, child_to_parents): """ CommandLine: python -m utool.util_graph --exec-reverse_path --show Example: >>> # ENABLE_DOCTEST >>> from utool.util_graph import * # NOQA >>> import utool as ut >>> child_to_parents = { >>> 'chip': ['...
[ "def", "reverse_path", "(", "dict_", ",", "root", ",", "child_to_parents", ")", ":", "# Hacky but illustrative", "# TODO; implement non-hacky version", "allkeys", "=", "get_allkeys", "(", "dict_", ")", "mat", "=", "np", ".", "zeros", "(", "(", "len", "(", "allke...
CommandLine: python -m utool.util_graph --exec-reverse_path --show Example: >>> # ENABLE_DOCTEST >>> from utool.util_graph import * # NOQA >>> import utool as ut >>> child_to_parents = { >>> 'chip': ['dummy_annot'], >>> 'chipmask': ['dummy_annot'], ...
[ "CommandLine", ":", "python", "-", "m", "utool", ".", "util_graph", "--", "exec", "-", "reverse_path", "--", "show" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1319-L1380
train
This function is used to reverse the path of a dictionary of key - value pairs.
Erotemic/utool
utool/util_graph.py
get_levels
def get_levels(dict_, n=0, levels=None): r""" DEPCIRATE Args: dict_ (dict_): a dictionary n (int): (default = 0) levels (None): (default = None) CommandLine: python -m utool.util_graph --test-get_levels --show python3 -m utool.util_graph --test-get_levels --sho...
python
def get_levels(dict_, n=0, levels=None): r""" DEPCIRATE Args: dict_ (dict_): a dictionary n (int): (default = 0) levels (None): (default = None) CommandLine: python -m utool.util_graph --test-get_levels --show python3 -m utool.util_graph --test-get_levels --sho...
[ "def", "get_levels", "(", "dict_", ",", "n", "=", "0", ",", "levels", "=", "None", ")", ":", "if", "levels", "is", "None", ":", "levels_", "=", "[", "[", "]", "for", "_", "in", "range", "(", "dict_depth", "(", "dict_", ")", ")", "]", "else", ":...
r""" DEPCIRATE Args: dict_ (dict_): a dictionary n (int): (default = 0) levels (None): (default = None) CommandLine: python -m utool.util_graph --test-get_levels --show python3 -m utool.util_graph --test-get_levels --show Example: >>> # DISABLE_DOCTEST...
[ "r", "DEPCIRATE" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1383-L1435
train
r Get the levels of a dictionary
Erotemic/utool
utool/util_graph.py
simplify_graph
def simplify_graph(graph): """ strips out everything but connectivity Args: graph (nx.Graph): Returns: nx.Graph: new_graph CommandLine: python3 -m utool.util_graph simplify_graph --show python2 -m utool.util_graph simplify_graph --show python2 -c "import n...
python
def simplify_graph(graph): """ strips out everything but connectivity Args: graph (nx.Graph): Returns: nx.Graph: new_graph CommandLine: python3 -m utool.util_graph simplify_graph --show python2 -m utool.util_graph simplify_graph --show python2 -c "import n...
[ "def", "simplify_graph", "(", "graph", ")", ":", "import", "utool", "as", "ut", "nodes", "=", "sorted", "(", "list", "(", "graph", ".", "nodes", "(", ")", ")", ")", "node_lookup", "=", "ut", ".", "make_index_lookup", "(", "nodes", ")", "if", "graph", ...
strips out everything but connectivity Args: graph (nx.Graph): Returns: nx.Graph: new_graph CommandLine: python3 -m utool.util_graph simplify_graph --show python2 -m utool.util_graph simplify_graph --show python2 -c "import networkx as nx; print(nx.__version__)" ...
[ "strips", "out", "everything", "but", "connectivity" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1515-L1565
train
This function is used to simplify a networkx graph by removing everything but connectivity
Erotemic/utool
utool/util_graph.py
subgraph_from_edges
def subgraph_from_edges(G, edge_list, ref_back=True): """ Creates a networkx graph that is a subgraph of G defined by the list of edges in edge_list. Requires G to be a networkx MultiGraph or MultiDiGraph edge_list is a list of edges in either (u,v) or (u,v,d) form where u and v are nodes compr...
python
def subgraph_from_edges(G, edge_list, ref_back=True): """ Creates a networkx graph that is a subgraph of G defined by the list of edges in edge_list. Requires G to be a networkx MultiGraph or MultiDiGraph edge_list is a list of edges in either (u,v) or (u,v,d) form where u and v are nodes compr...
[ "def", "subgraph_from_edges", "(", "G", ",", "edge_list", ",", "ref_back", "=", "True", ")", ":", "# TODO: support multi-di-graph", "sub_nodes", "=", "list", "(", "{", "y", "for", "x", "in", "edge_list", "for", "y", "in", "x", "[", "0", ":", "2", "]", ...
Creates a networkx graph that is a subgraph of G defined by the list of edges in edge_list. Requires G to be a networkx MultiGraph or MultiDiGraph edge_list is a list of edges in either (u,v) or (u,v,d) form where u and v are nodes comprising an edge, and d would be a dictionary of edge attributes ...
[ "Creates", "a", "networkx", "graph", "that", "is", "a", "subgraph", "of", "G", "defined", "by", "the", "list", "of", "edges", "in", "edge_list", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1568-L1603
train
Creates a subgraph of G from a list of edges in edge_list.
Erotemic/utool
utool/util_graph.py
all_multi_paths
def all_multi_paths(graph, source, target, data=False): r""" Returns specific paths along multi-edges from the source to this table. Multipaths are identified by edge keys. Returns all paths from source to target. This function treats multi-edges as distinct and returns the key value in each edge t...
python
def all_multi_paths(graph, source, target, data=False): r""" Returns specific paths along multi-edges from the source to this table. Multipaths are identified by edge keys. Returns all paths from source to target. This function treats multi-edges as distinct and returns the key value in each edge t...
[ "def", "all_multi_paths", "(", "graph", ",", "source", ",", "target", ",", "data", "=", "False", ")", ":", "path_multiedges", "=", "list", "(", "nx_all_simple_edge_paths", "(", "graph", ",", "source", ",", "target", ",", "keys", "=", "True", ",", "data", ...
r""" Returns specific paths along multi-edges from the source to this table. Multipaths are identified by edge keys. Returns all paths from source to target. This function treats multi-edges as distinct and returns the key value in each edge tuple that defines a path. Example: >>> # DI...
[ "r", "Returns", "specific", "paths", "along", "multi", "-", "edges", "from", "the", "source", "to", "this", "table", ".", "Multipaths", "are", "identified", "by", "edge", "keys", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1613-L1666
train
r Returns all paths along multi - edges from source to target.
Erotemic/utool
utool/util_graph.py
bfs_multi_edges
def bfs_multi_edges(G, source, reverse=False, keys=True, data=False): """Produce edges in a breadth-first-search starting at source. ----- Based on http://www.ics.uci.edu/~eppstein/PADS/BFS.py by D. Eppstein, July 2004. """ from collections import deque from functools import partial if r...
python
def bfs_multi_edges(G, source, reverse=False, keys=True, data=False): """Produce edges in a breadth-first-search starting at source. ----- Based on http://www.ics.uci.edu/~eppstein/PADS/BFS.py by D. Eppstein, July 2004. """ from collections import deque from functools import partial if r...
[ "def", "bfs_multi_edges", "(", "G", ",", "source", ",", "reverse", "=", "False", ",", "keys", "=", "True", ",", "data", "=", "False", ")", ":", "from", "collections", "import", "deque", "from", "functools", "import", "partial", "if", "reverse", ":", "G",...
Produce edges in a breadth-first-search starting at source. ----- Based on http://www.ics.uci.edu/~eppstein/PADS/BFS.py by D. Eppstein, July 2004.
[ "Produce", "edges", "in", "a", "breadth", "-", "first", "-", "search", "starting", "at", "source", ".", "-----", "Based", "on", "http", ":", "//", "www", ".", "ics", ".", "uci", ".", "edu", "/", "~eppstein", "/", "PADS", "/", "BFS", ".", "py", "by"...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1673-L1703
train
Generate edges in a breadth - first - search starting at source.
Erotemic/utool
utool/util_graph.py
dfs_conditional
def dfs_conditional(G, source, state, can_cross): """ Example: >>> # ENABLE_DOCTEST >>> from utool.util_graph import * >>> G = nx.Graph() >>> G.add_edges_from([(1, 2), (2, 3), (3, 4), (4, 5)]) >>> G.adj[2][3]['lava'] = True >>> G.adj[3][4]['lava'] = True >...
python
def dfs_conditional(G, source, state, can_cross): """ Example: >>> # ENABLE_DOCTEST >>> from utool.util_graph import * >>> G = nx.Graph() >>> G.add_edges_from([(1, 2), (2, 3), (3, 4), (4, 5)]) >>> G.adj[2][3]['lava'] = True >>> G.adj[3][4]['lava'] = True >...
[ "def", "dfs_conditional", "(", "G", ",", "source", ",", "state", ",", "can_cross", ")", ":", "# stack based version", "visited", "=", "{", "source", "}", "stack", "=", "[", "(", "source", ",", "iter", "(", "G", "[", "source", "]", ")", ",", "state", ...
Example: >>> # ENABLE_DOCTEST >>> from utool.util_graph import * >>> G = nx.Graph() >>> G.add_edges_from([(1, 2), (2, 3), (3, 4), (4, 5)]) >>> G.adj[2][3]['lava'] = True >>> G.adj[3][4]['lava'] = True >>> def can_cross(G, edge, state): >>> # can only c...
[ "Example", ":", ">>>", "#", "ENABLE_DOCTEST", ">>>", "from", "utool", ".", "util_graph", "import", "*", ">>>", "G", "=", "nx", ".", "Graph", "()", ">>>", "G", ".", "add_edges_from", "(", "[", "(", "1", "2", ")", "(", "2", "3", ")", "(", "3", "4",...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1706-L1741
train
A recursive function that returns a list of nodes that can be visited and the state of the current node.
Erotemic/utool
utool/util_graph.py
bfs_conditional
def bfs_conditional(G, source, reverse=False, keys=True, data=False, yield_nodes=True, yield_if=None, continue_if=None, visited_nodes=None, yield_source=False): """ Produce edges in a breadth-first-search starting at source, but only return nodes t...
python
def bfs_conditional(G, source, reverse=False, keys=True, data=False, yield_nodes=True, yield_if=None, continue_if=None, visited_nodes=None, yield_source=False): """ Produce edges in a breadth-first-search starting at source, but only return nodes t...
[ "def", "bfs_conditional", "(", "G", ",", "source", ",", "reverse", "=", "False", ",", "keys", "=", "True", ",", "data", "=", "False", ",", "yield_nodes", "=", "True", ",", "yield_if", "=", "None", ",", "continue_if", "=", "None", ",", "visited_nodes", ...
Produce edges in a breadth-first-search starting at source, but only return nodes that satisfiy a condition, and only iterate past a node if it satisfies a different condition. conditions are callables that take (G, child, edge) and return true or false CommandLine: python -m utool.util_graph ...
[ "Produce", "edges", "in", "a", "breadth", "-", "first", "-", "search", "starting", "at", "source", "but", "only", "return", "nodes", "that", "satisfiy", "a", "condition", "and", "only", "iterate", "past", "a", "node", "if", "it", "satisfies", "a", "differe...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1744-L1826
train
Return a list of nodes that satisfy a condition
Erotemic/utool
utool/util_graph.py
color_nodes
def color_nodes(graph, labelattr='label', brightness=.878, outof=None, sat_adjust=None): """ Colors edges and nodes by nid """ import plottool as pt import utool as ut node_to_lbl = nx.get_node_attributes(graph, labelattr) unique_lbls = sorted(set(node_to_lbl.values())) ncolors =...
python
def color_nodes(graph, labelattr='label', brightness=.878, outof=None, sat_adjust=None): """ Colors edges and nodes by nid """ import plottool as pt import utool as ut node_to_lbl = nx.get_node_attributes(graph, labelattr) unique_lbls = sorted(set(node_to_lbl.values())) ncolors =...
[ "def", "color_nodes", "(", "graph", ",", "labelattr", "=", "'label'", ",", "brightness", "=", ".878", ",", "outof", "=", "None", ",", "sat_adjust", "=", "None", ")", ":", "import", "plottool", "as", "pt", "import", "utool", "as", "ut", "node_to_lbl", "="...
Colors edges and nodes by nid
[ "Colors", "edges", "and", "nodes", "by", "nid" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1829-L1865
train
Color nodes in a tree
Erotemic/utool
utool/util_graph.py
nx_contracted_nodes
def nx_contracted_nodes(G, u, v, self_loops=True, inplace=False): """ copy of networkx function with inplace modification TODO: commit to networkx """ import itertools as it if G.is_directed(): in_edges = ((w, u, d) for w, x, d in G.in_edges(v, data=True) if self_loop...
python
def nx_contracted_nodes(G, u, v, self_loops=True, inplace=False): """ copy of networkx function with inplace modification TODO: commit to networkx """ import itertools as it if G.is_directed(): in_edges = ((w, u, d) for w, x, d in G.in_edges(v, data=True) if self_loop...
[ "def", "nx_contracted_nodes", "(", "G", ",", "u", ",", "v", ",", "self_loops", "=", "True", ",", "inplace", "=", "False", ")", ":", "import", "itertools", "as", "it", "if", "G", ".", "is_directed", "(", ")", ":", "in_edges", "=", "(", "(", "w", ","...
copy of networkx function with inplace modification TODO: commit to networkx
[ "copy", "of", "networkx", "function", "with", "inplace", "modification", "TODO", ":", "commit", "to", "networkx" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L2003-L2031
train
Returns a copy of G with only the nodes that are contracted by u and v.
Erotemic/utool
utool/util_graph.py
approx_min_num_components
def approx_min_num_components(nodes, negative_edges): """ Find approximate minimum number of connected components possible Each edge represents that two nodes must be separated This code doesn't solve the problem. The problem is NP-complete and reduces to minimum clique cover (MCC). This is only an...
python
def approx_min_num_components(nodes, negative_edges): """ Find approximate minimum number of connected components possible Each edge represents that two nodes must be separated This code doesn't solve the problem. The problem is NP-complete and reduces to minimum clique cover (MCC). This is only an...
[ "def", "approx_min_num_components", "(", "nodes", ",", "negative_edges", ")", ":", "import", "utool", "as", "ut", "num", "=", "0", "g_neg", "=", "nx", ".", "Graph", "(", ")", "g_neg", ".", "add_nodes_from", "(", "nodes", ")", "g_neg", ".", "add_edges_from"...
Find approximate minimum number of connected components possible Each edge represents that two nodes must be separated This code doesn't solve the problem. The problem is NP-complete and reduces to minimum clique cover (MCC). This is only an approximate solution. Not sure what the approximation ratio i...
[ "Find", "approximate", "minimum", "number", "of", "connected", "components", "possible", "Each", "edge", "represents", "that", "two", "nodes", "must", "be", "separated" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L2034-L2122
train
This function finds approximate minimum number of connected components possible by using the NP - complete algorithm.
Erotemic/utool
utool/util_graph.py
mincost_diameter_augment
def mincost_diameter_augment(graph, max_cost, candidates=None, weight=None, cost=None): """ PROBLEM: Bounded Cost Minimum Diameter Edge Addition (BCMD) Args: graph (nx.Graph): input graph max_cost (float): maximum weighted diamter of the graph weight (str): key of the edge weight at...
python
def mincost_diameter_augment(graph, max_cost, candidates=None, weight=None, cost=None): """ PROBLEM: Bounded Cost Minimum Diameter Edge Addition (BCMD) Args: graph (nx.Graph): input graph max_cost (float): maximum weighted diamter of the graph weight (str): key of the edge weight at...
[ "def", "mincost_diameter_augment", "(", "graph", ",", "max_cost", ",", "candidates", "=", "None", ",", "weight", "=", "None", ",", "cost", "=", "None", ")", ":", "import", "utool", "as", "ut", "import", "operator", "as", "op", "if", "candidates", "is", "...
PROBLEM: Bounded Cost Minimum Diameter Edge Addition (BCMD) Args: graph (nx.Graph): input graph max_cost (float): maximum weighted diamter of the graph weight (str): key of the edge weight attribute cost (str): key of the edge cost attribute candidates (list): set of non-edg...
[ "PROBLEM", ":", "Bounded", "Cost", "Minimum", "Diameter", "Edge", "Addition", "(", "BCMD", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L2150-L2256
train
This function calculates the minimum diammation of a set of nodes in a graph and returns the minimum diammation of the nodes in the tree that are at least max_cost.
walchko/pyrk
pyrk/pyrk.py
RK4.solve
def solve(self, y, h, t_end): """ Given a function, initial conditions, step size and end value, this will calculate an unforced system. The default start time is t=0.0, but this can be changed. y - initial state h - step size n - stop time """ ts = [] ys = [] yi = y ti = 0.0 while ti < t_end...
python
def solve(self, y, h, t_end): """ Given a function, initial conditions, step size and end value, this will calculate an unforced system. The default start time is t=0.0, but this can be changed. y - initial state h - step size n - stop time """ ts = [] ys = [] yi = y ti = 0.0 while ti < t_end...
[ "def", "solve", "(", "self", ",", "y", ",", "h", ",", "t_end", ")", ":", "ts", "=", "[", "]", "ys", "=", "[", "]", "yi", "=", "y", "ti", "=", "0.0", "while", "ti", "<", "t_end", ":", "ts", ".", "append", "(", "ti", ")", "yi", "=", "self",...
Given a function, initial conditions, step size and end value, this will calculate an unforced system. The default start time is t=0.0, but this can be changed. y - initial state h - step size n - stop time
[ "Given", "a", "function", "initial", "conditions", "step", "size", "and", "end", "value", "this", "will", "calculate", "an", "unforced", "system", ".", "The", "default", "start", "time", "is", "t", "=", "0", ".", "0", "but", "this", "can", "be", "changed...
f75dce843e795343d37cfe20d780989f56f0c418
https://github.com/walchko/pyrk/blob/f75dce843e795343d37cfe20d780989f56f0c418/pyrk/pyrk.py#L23-L42
train
This function is used to solve a system by stepping the function at a given time and the step size and end value.
walchko/pyrk
pyrk/pyrk.py
RK4.step
def step(self, y, u, t, h): """ This is called by solve, but can be called by the user who wants to run through an integration with a control force. y - state at t u - control inputs at t t - time h - step size """ k1 = h * self.func(t, y, u) k2 = h * self.func(t + .5*h, y + .5*h*k1, u) k3 = h * ...
python
def step(self, y, u, t, h): """ This is called by solve, but can be called by the user who wants to run through an integration with a control force. y - state at t u - control inputs at t t - time h - step size """ k1 = h * self.func(t, y, u) k2 = h * self.func(t + .5*h, y + .5*h*k1, u) k3 = h * ...
[ "def", "step", "(", "self", ",", "y", ",", "u", ",", "t", ",", "h", ")", ":", "k1", "=", "h", "*", "self", ".", "func", "(", "t", ",", "y", ",", "u", ")", "k2", "=", "h", "*", "self", ".", "func", "(", "t", "+", ".5", "*", "h", ",", ...
This is called by solve, but can be called by the user who wants to run through an integration with a control force. y - state at t u - control inputs at t t - time h - step size
[ "This", "is", "called", "by", "solve", "but", "can", "be", "called", "by", "the", "user", "who", "wants", "to", "run", "through", "an", "integration", "with", "a", "control", "force", "." ]
f75dce843e795343d37cfe20d780989f56f0c418
https://github.com/walchko/pyrk/blob/f75dce843e795343d37cfe20d780989f56f0c418/pyrk/pyrk.py#L44-L58
train
This function is called by solve and is called by solve_one_step.
LEMS/pylems
lems/model/structure.py
With.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ return '<With ' + \ (' instance="{0}"'.format(self.instance) if self.instance else '') +\ (' list="{0}"'.format(self.list) if self.list else '') + \ (' index="{0}"'.format(self.index) if se...
python
def toxml(self): """ Exports this object into a LEMS XML object """ return '<With ' + \ (' instance="{0}"'.format(self.instance) if self.instance else '') +\ (' list="{0}"'.format(self.list) if self.list else '') + \ (' index="{0}"'.format(self.index) if se...
[ "def", "toxml", "(", "self", ")", ":", "return", "'<With '", "+", "(", "' instance=\"{0}\"'", ".", "format", "(", "self", ".", "instance", ")", "if", "self", ".", "instance", "else", "''", ")", "+", "(", "' list=\"{0}\"'", ".", "format", "(", "self", "...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/structure.py#L41-L50
train
Returns a LEMS XML object representation of this object.
LEMS/pylems
lems/model/structure.py
Tunnel.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ return '<Tunnel name="{0}"'.format(self.name) + \ ' endA="{0}"'.format(self.end_a) + \ ' endB="{0}"'.format(self.end_b) + \ ' componentA="{0}"'.format(self.component_a) + \ ...
python
def toxml(self): """ Exports this object into a LEMS XML object """ return '<Tunnel name="{0}"'.format(self.name) + \ ' endA="{0}"'.format(self.end_a) + \ ' endB="{0}"'.format(self.end_b) + \ ' componentA="{0}"'.format(self.component_a) + \ ...
[ "def", "toxml", "(", "self", ")", ":", "return", "'<Tunnel name=\"{0}\"'", ".", "format", "(", "self", ".", "name", ")", "+", "' endA=\"{0}\"'", ".", "format", "(", "self", ".", "end_a", ")", "+", "' endB=\"{0}\"'", ".", "format", "(", "self", ".", "end_...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/structure.py#L86-L95
train
Returns a LEMS XML string representation of the tunnel.
LEMS/pylems
lems/model/structure.py
EventConnection.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ return '<EventConnection' +\ (' from="{0}"'.format(self.from_) if self.from_ else '') +\ (' to="{0}"'.format(self.to) if self.to else '') +\ (' sourcePort="{0}"'.format(self.source_port) if...
python
def toxml(self): """ Exports this object into a LEMS XML object """ return '<EventConnection' +\ (' from="{0}"'.format(self.from_) if self.from_ else '') +\ (' to="{0}"'.format(self.to) if self.to else '') +\ (' sourcePort="{0}"'.format(self.source_port) if...
[ "def", "toxml", "(", "self", ")", ":", "return", "'<EventConnection'", "+", "(", "' from=\"{0}\"'", ".", "format", "(", "self", ".", "from_", ")", "if", "self", ".", "from_", "else", "''", ")", "+", "(", "' to=\"{0}\"'", ".", "format", "(", "self", "."...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/structure.py#L140-L152
train
Returns a LEMS XML string representation of the EventConnection object.
LEMS/pylems
lems/model/structure.py
MultiInstantiate.add
def add(self, child): """ Adds a typed child object to the structure object. @param child: Child object to be added. """ if isinstance(child, Assign): self.add_assign(child) else: raise ModelError('Unsupported child element')
python
def add(self, child): """ Adds a typed child object to the structure object. @param child: Child object to be added. """ if isinstance(child, Assign): self.add_assign(child) else: raise ModelError('Unsupported child element')
[ "def", "add", "(", "self", ",", "child", ")", ":", "if", "isinstance", "(", "child", ",", "Assign", ")", ":", "self", ".", "add_assign", "(", "child", ")", "else", ":", "raise", "ModelError", "(", "'Unsupported child element'", ")" ]
Adds a typed child object to the structure object. @param child: Child object to be added.
[ "Adds", "a", "typed", "child", "object", "to", "the", "structure", "object", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/structure.py#L263-L273
train
Adds a typed child object to the structure object.
LEMS/pylems
lems/model/structure.py
MultiInstantiate.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ argstr = '' if self.component: argstr += 'component="{0}" '.format(self.component) if self.component_type: argstr += 'componentType="{0}" '.format(self.component_type) if s...
python
def toxml(self): """ Exports this object into a LEMS XML object """ argstr = '' if self.component: argstr += 'component="{0}" '.format(self.component) if self.component_type: argstr += 'componentType="{0}" '.format(self.component_type) if s...
[ "def", "toxml", "(", "self", ")", ":", "argstr", "=", "''", "if", "self", ".", "component", ":", "argstr", "+=", "'component=\"{0}\" '", ".", "format", "(", "self", ".", "component", ")", "if", "self", ".", "component_type", ":", "argstr", "+=", "'compon...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/structure.py#L275-L292
train
Returns a string representation of the object as an LEMS XML object.
LEMS/pylems
lems/model/structure.py
ForEach.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ chxmlstr = '' for event_connection in self.event_connections: chxmlstr += event_connection.toxml() for for_each in self.for_eachs: chxmlstr += for_each.toxml() return '...
python
def toxml(self): """ Exports this object into a LEMS XML object """ chxmlstr = '' for event_connection in self.event_connections: chxmlstr += event_connection.toxml() for for_each in self.for_eachs: chxmlstr += for_each.toxml() return '...
[ "def", "toxml", "(", "self", ")", ":", "chxmlstr", "=", "''", "for", "event_connection", "in", "self", ".", "event_connections", ":", "chxmlstr", "+=", "event_connection", ".", "toxml", "(", ")", "for", "for_each", "in", "self", ".", "for_eachs", ":", "chx...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/structure.py#L334-L347
train
Returns a LEMS XML string representation of this object.
LEMS/pylems
lems/model/structure.py
Structure.add
def add(self, child): """ Adds a typed child object to the structure object. @param child: Child object to be added. """ if isinstance(child, With): self.add_with(child) elif isinstance(child, EventConnection): self.add_event_connection(child) ...
python
def add(self, child): """ Adds a typed child object to the structure object. @param child: Child object to be added. """ if isinstance(child, With): self.add_with(child) elif isinstance(child, EventConnection): self.add_event_connection(child) ...
[ "def", "add", "(", "self", ",", "child", ")", ":", "if", "isinstance", "(", "child", ",", "With", ")", ":", "self", ".", "add_with", "(", "child", ")", "elif", "isinstance", "(", "child", ",", "EventConnection", ")", ":", "self", ".", "add_event_connec...
Adds a typed child object to the structure object. @param child: Child object to be added.
[ "Adds", "a", "typed", "child", "object", "to", "the", "structure", "object", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/structure.py#L454-L472
train
Adds a typed child object to the structure object.
LEMS/pylems
lems/model/structure.py
Structure.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ chxmlstr = '' for with_ in self.withs: chxmlstr += with_.toxml() for event_connection in self.event_connections: chxmlstr += event_connection.toxml() for child_instance ...
python
def toxml(self): """ Exports this object into a LEMS XML object """ chxmlstr = '' for with_ in self.withs: chxmlstr += with_.toxml() for event_connection in self.event_connections: chxmlstr += event_connection.toxml() for child_instance ...
[ "def", "toxml", "(", "self", ")", ":", "chxmlstr", "=", "''", "for", "with_", "in", "self", ".", "withs", ":", "chxmlstr", "+=", "with_", ".", "toxml", "(", ")", "for", "event_connection", "in", "self", ".", "event_connections", ":", "chxmlstr", "+=", ...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/structure.py#L474-L500
train
Returns a LEMS XML string representation of the object.
glormph/msstitch
src/app/actions/prottable/bestpeptide.py
generate_proteins
def generate_proteins(pepfn, proteins, pepheader, scorecol, minlog, higherbetter=True, protcol=False): """Best peptide for each protein in a table""" protein_peptides = {} if minlog: higherbetter = False if not protcol: protcol = peptabledata.HEADER_MASTERPROTEINS ...
python
def generate_proteins(pepfn, proteins, pepheader, scorecol, minlog, higherbetter=True, protcol=False): """Best peptide for each protein in a table""" protein_peptides = {} if minlog: higherbetter = False if not protcol: protcol = peptabledata.HEADER_MASTERPROTEINS ...
[ "def", "generate_proteins", "(", "pepfn", ",", "proteins", ",", "pepheader", ",", "scorecol", ",", "minlog", ",", "higherbetter", "=", "True", ",", "protcol", "=", "False", ")", ":", "protein_peptides", "=", "{", "}", "if", "minlog", ":", "higherbetter", "...
Best peptide for each protein in a table
[ "Best", "peptide", "for", "each", "protein", "in", "a", "table" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/bestpeptide.py#L8-L46
train
Generate a list of proteins from a table of protein peptides.
LEMS/pylems
lems/model/simulation.py
Run.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ return '<Run component="{0}" variable="{1}" increment="{2}" total="{3}"/>'.format(self.component, self.variable, ...
python
def toxml(self): """ Exports this object into a LEMS XML object """ return '<Run component="{0}" variable="{1}" increment="{2}" total="{3}"/>'.format(self.component, self.variable, ...
[ "def", "toxml", "(", "self", ")", ":", "return", "'<Run component=\"{0}\" variable=\"{1}\" increment=\"{2}\" total=\"{3}\"/>'", ".", "format", "(", "self", ".", "component", ",", "self", ".", "variable", ",", "self", ".", "increment", ",", "self", ".", "total", ")...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/simulation.py#L44-L52
train
Returns a LEMS XML string representation of the object.
LEMS/pylems
lems/model/simulation.py
Record.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ return '<Record quantity="{0}" scale="{1}" color="{2}" id="{3}"/>'.format(self.quantity, self.scale, ...
python
def toxml(self): """ Exports this object into a LEMS XML object """ return '<Record quantity="{0}" scale="{1}" color="{2}" id="{3}"/>'.format(self.quantity, self.scale, ...
[ "def", "toxml", "(", "self", ")", ":", "return", "'<Record quantity=\"{0}\" scale=\"{1}\" color=\"{2}\" id=\"{3}\"/>'", ".", "format", "(", "self", ".", "quantity", ",", "self", ".", "scale", ",", "self", ".", "color", ",", "self", ".", "id", ")" ]
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/simulation.py#L86-L94
train
Returns a LEMS XML string representation of the record.
LEMS/pylems
lems/model/simulation.py
Simulation.add
def add(self, child): """ Adds a typed child object to the simulation spec. @param child: Child object to be added. """ if isinstance(child, Run): self.add_run(child) elif isinstance(child, Record): self.add_record(child) elif isinstance(...
python
def add(self, child): """ Adds a typed child object to the simulation spec. @param child: Child object to be added. """ if isinstance(child, Run): self.add_run(child) elif isinstance(child, Record): self.add_record(child) elif isinstance(...
[ "def", "add", "(", "self", ",", "child", ")", ":", "if", "isinstance", "(", "child", ",", "Run", ")", ":", "self", ".", "add_run", "(", "child", ")", "elif", "isinstance", "(", "child", ",", "Record", ")", ":", "self", ".", "add_record", "(", "chil...
Adds a typed child object to the simulation spec. @param child: Child object to be added.
[ "Adds", "a", "typed", "child", "object", "to", "the", "simulation", "spec", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/simulation.py#L345-L365
train
Adds a typed child object to the simulation spec.
LEMS/pylems
lems/model/simulation.py
Simulation.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ chxmlstr = '' for run in self.runs: chxmlstr += run.toxml() for record in self.records: chxmlstr += record.toxml() for event_record in self.event_records: c...
python
def toxml(self): """ Exports this object into a LEMS XML object """ chxmlstr = '' for run in self.runs: chxmlstr += run.toxml() for record in self.records: chxmlstr += record.toxml() for event_record in self.event_records: c...
[ "def", "toxml", "(", "self", ")", ":", "chxmlstr", "=", "''", "for", "run", "in", "self", ".", "runs", ":", "chxmlstr", "+=", "run", ".", "toxml", "(", ")", "for", "record", "in", "self", ".", "records", ":", "chxmlstr", "+=", "record", ".", "toxml...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/simulation.py#L367-L397
train
Converts this object into a LEMS XML object.
steveYeah/PyBomb
pybomb/clients/game_client.py
GameClient.fetch
def fetch(self, id_, return_fields=None): """ Wrapper for fetching details of game by ID :param id_: int :param return_fields: tuple :return: pybomb.clients.Response """ game_params = {"id": id_} if return_fields is not None: self._validate_...
python
def fetch(self, id_, return_fields=None): """ Wrapper for fetching details of game by ID :param id_: int :param return_fields: tuple :return: pybomb.clients.Response """ game_params = {"id": id_} if return_fields is not None: self._validate_...
[ "def", "fetch", "(", "self", ",", "id_", ",", "return_fields", "=", "None", ")", ":", "game_params", "=", "{", "\"id\"", ":", "id_", "}", "if", "return_fields", "is", "not", "None", ":", "self", ".", "_validate_return_fields", "(", "return_fields", ")", ...
Wrapper for fetching details of game by ID :param id_: int :param return_fields: tuple :return: pybomb.clients.Response
[ "Wrapper", "for", "fetching", "details", "of", "game", "by", "ID" ]
54045d74e642f8a1c4366c24bd6a330ae3da6257
https://github.com/steveYeah/PyBomb/blob/54045d74e642f8a1c4366c24bd6a330ae3da6257/pybomb/clients/game_client.py#L57-L76
train
Wrapper for fetching details of game by ID
glormph/msstitch
src/app/drivers/base.py
BaseDriver.define_options
def define_options(self, names, parser_options=None): """Given a list of option names, this returns a list of dicts defined in all_options and self.shared_options. These can then be used to populate the argparser with""" def copy_option(options, name): return {k: v for k, v i...
python
def define_options(self, names, parser_options=None): """Given a list of option names, this returns a list of dicts defined in all_options and self.shared_options. These can then be used to populate the argparser with""" def copy_option(options, name): return {k: v for k, v i...
[ "def", "define_options", "(", "self", ",", "names", ",", "parser_options", "=", "None", ")", ":", "def", "copy_option", "(", "options", ",", "name", ")", ":", "return", "{", "k", ":", "v", "for", "k", ",", "v", "in", "options", "[", "name", "]", "....
Given a list of option names, this returns a list of dicts defined in all_options and self.shared_options. These can then be used to populate the argparser with
[ "Given", "a", "list", "of", "option", "names", "this", "returns", "a", "list", "of", "dicts", "defined", "in", "all_options", "and", "self", ".", "shared_options", ".", "These", "can", "then", "be", "used", "to", "populate", "the", "argparser", "with" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/base.py#L30-L48
train
Given a list of option names this returns a list of dicts containing all options defined in all_options and shared_options. These can then be used to populate the argparser with the option values.
glormph/msstitch
src/app/drivers/base.py
BaseDriver.get_column_header_for_number
def get_column_header_for_number(self, column_var_names, header=False): """This function subtracts 1 from inputted column number to comply with programmers counting (i.e. from 0, not from 1). For TSV data.""" if not header: header = self.oldheader for col in column_var_names:...
python
def get_column_header_for_number(self, column_var_names, header=False): """This function subtracts 1 from inputted column number to comply with programmers counting (i.e. from 0, not from 1). For TSV data.""" if not header: header = self.oldheader for col in column_var_names:...
[ "def", "get_column_header_for_number", "(", "self", ",", "column_var_names", ",", "header", "=", "False", ")", ":", "if", "not", "header", ":", "header", "=", "self", ".", "oldheader", "for", "col", "in", "column_var_names", ":", "value", "=", "getattr", "("...
This function subtracts 1 from inputted column number to comply with programmers counting (i.e. from 0, not from 1). For TSV data.
[ "This", "function", "subtracts", "1", "from", "inputted", "column", "number", "to", "comply", "with", "programmers", "counting", "(", "i", ".", "e", ".", "from", "0", "not", "from", "1", ")", ".", "For", "TSV", "data", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/base.py#L91-L100
train
This function subtracts 1 from inputted column number to comply with programmers counting. For TSV data this function returns the column header field for the specified column_var_names.
steveYeah/PyBomb
pybomb/response.py
Response.from_response_data
def from_response_data(cls, response_data): """ Response factory :param response_data: requests.models.Response :return: pybomb.clients.Response """ response_json = response_data.json() return cls( response_data.url, response_json["numbe...
python
def from_response_data(cls, response_data): """ Response factory :param response_data: requests.models.Response :return: pybomb.clients.Response """ response_json = response_data.json() return cls( response_data.url, response_json["numbe...
[ "def", "from_response_data", "(", "cls", ",", "response_data", ")", ":", "response_json", "=", "response_data", ".", "json", "(", ")", "return", "cls", "(", "response_data", ".", "url", ",", "response_json", "[", "\"number_of_page_results\"", "]", ",", "response...
Response factory :param response_data: requests.models.Response :return: pybomb.clients.Response
[ "Response", "factory" ]
54045d74e642f8a1c4366c24bd6a330ae3da6257
https://github.com/steveYeah/PyBomb/blob/54045d74e642f8a1c4366c24bd6a330ae3da6257/pybomb/response.py#L15-L30
train
Create a new object from response data.
Erotemic/utool
utool/util_resources.py
current_memory_usage
def current_memory_usage(): """ Returns this programs current memory usage in bytes """ import psutil proc = psutil.Process(os.getpid()) #meminfo = proc.get_memory_info() meminfo = proc.memory_info() rss = meminfo[0] # Resident Set Size / Mem Usage vms = meminfo[1] # Virtual Memory...
python
def current_memory_usage(): """ Returns this programs current memory usage in bytes """ import psutil proc = psutil.Process(os.getpid()) #meminfo = proc.get_memory_info() meminfo = proc.memory_info() rss = meminfo[0] # Resident Set Size / Mem Usage vms = meminfo[1] # Virtual Memory...
[ "def", "current_memory_usage", "(", ")", ":", "import", "psutil", "proc", "=", "psutil", ".", "Process", "(", "os", ".", "getpid", "(", ")", ")", "#meminfo = proc.get_memory_info()", "meminfo", "=", "proc", ".", "memory_info", "(", ")", "rss", "=", "meminfo"...
Returns this programs current memory usage in bytes
[ "Returns", "this", "programs", "current", "memory", "usage", "in", "bytes" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_resources.py#L120-L130
train
Returns this programs current memory usage in bytes
Erotemic/utool
utool/util_resources.py
get_matching_process_ids
def get_matching_process_ids(cmd_pattern, user_pattern): """ CommandLine: export PID=30196 export PID=$(python -c "import utool as ut; print(ut.get_matching_process_ids('jonc', 'python2.7'))") export PID=$(python -c "import utool as ut; print(ut.get_matching_process_ids('jonc', 'matlab')...
python
def get_matching_process_ids(cmd_pattern, user_pattern): """ CommandLine: export PID=30196 export PID=$(python -c "import utool as ut; print(ut.get_matching_process_ids('jonc', 'python2.7'))") export PID=$(python -c "import utool as ut; print(ut.get_matching_process_ids('jonc', 'matlab')...
[ "def", "get_matching_process_ids", "(", "cmd_pattern", ",", "user_pattern", ")", ":", "import", "psutil", "import", "re", "process_list", "=", "list", "(", "psutil", ".", "process_iter", "(", ")", ")", "def", "matches_pattern", "(", "proc", ",", "user_pattern", ...
CommandLine: export PID=30196 export PID=$(python -c "import utool as ut; print(ut.get_matching_process_ids('jonc', 'python2.7'))") export PID=$(python -c "import utool as ut; print(ut.get_matching_process_ids('jonc', 'matlab'))") sudo -H echo $PID ps -o pid,comm,nice -p $PID ...
[ "CommandLine", ":", "export", "PID", "=", "30196", "export", "PID", "=", "$", "(", "python", "-", "c", "import", "utool", "as", "ut", ";", "print", "(", "ut", ".", "get_matching_process_ids", "(", "jonc", "python2", ".", "7", "))", ")", "export", "PID"...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_resources.py#L133-L177
train
Get a list of processes that match the given pattern.
Erotemic/utool
utool/util_resources.py
num_unused_cpus
def num_unused_cpus(thresh=10): """ Returns the number of cpus with utilization less than `thresh` percent """ import psutil cpu_usage = psutil.cpu_percent(percpu=True) return sum([p < thresh for p in cpu_usage])
python
def num_unused_cpus(thresh=10): """ Returns the number of cpus with utilization less than `thresh` percent """ import psutil cpu_usage = psutil.cpu_percent(percpu=True) return sum([p < thresh for p in cpu_usage])
[ "def", "num_unused_cpus", "(", "thresh", "=", "10", ")", ":", "import", "psutil", "cpu_usage", "=", "psutil", ".", "cpu_percent", "(", "percpu", "=", "True", ")", "return", "sum", "(", "[", "p", "<", "thresh", "for", "p", "in", "cpu_usage", "]", ")" ]
Returns the number of cpus with utilization less than `thresh` percent
[ "Returns", "the", "number", "of", "cpus", "with", "utilization", "less", "than", "thresh", "percent" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_resources.py#L185-L191
train
Returns the number of cpus with utilization less than thresh percent
Erotemic/utool
utool/util_resources.py
get_python_datastructure_sizes
def get_python_datastructure_sizes(): """ References: http://stackoverflow.com/questions/1331471/in-memory-size-of-python-stucture CommandLine: python -m utool.util_resources --test-get_python_datastructure_sizes Example: >>> # ENABLE_DOCTEST >>> from utool.util_resourc...
python
def get_python_datastructure_sizes(): """ References: http://stackoverflow.com/questions/1331471/in-memory-size-of-python-stucture CommandLine: python -m utool.util_resources --test-get_python_datastructure_sizes Example: >>> # ENABLE_DOCTEST >>> from utool.util_resourc...
[ "def", "get_python_datastructure_sizes", "(", ")", ":", "import", "sys", "import", "decimal", "import", "six", "empty_types", "=", "{", "'int'", ":", "0", ",", "'float'", ":", "0.0", ",", "'dict'", ":", "dict", "(", ")", ",", "'set'", ":", "set", "(", ...
References: http://stackoverflow.com/questions/1331471/in-memory-size-of-python-stucture CommandLine: python -m utool.util_resources --test-get_python_datastructure_sizes Example: >>> # ENABLE_DOCTEST >>> from utool.util_resources import * # NOQA >>> import utool as ut...
[ "References", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "1331471", "/", "in", "-", "memory", "-", "size", "-", "of", "-", "python", "-", "stucture" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_resources.py#L230-L264
train
Returns a dict of size of the python datastructure
glormph/msstitch
src/app/actions/mslookup/proteingrouping.py
get_masters
def get_masters(ppgraph): """From a protein-peptide graph dictionary (keys proteins, values peptides), return master proteins aka those which have no proteins whose peptides are supersets of them. If shared master proteins are found, report only the first, we will sort the whole proteingroup later a...
python
def get_masters(ppgraph): """From a protein-peptide graph dictionary (keys proteins, values peptides), return master proteins aka those which have no proteins whose peptides are supersets of them. If shared master proteins are found, report only the first, we will sort the whole proteingroup later a...
[ "def", "get_masters", "(", "ppgraph", ")", ":", "masters", "=", "{", "}", "for", "protein", ",", "peps", "in", "ppgraph", ".", "items", "(", ")", ":", "ismaster", "=", "True", "peps", "=", "set", "(", "peps", ")", "multimaster", "=", "set", "(", ")...
From a protein-peptide graph dictionary (keys proteins, values peptides), return master proteins aka those which have no proteins whose peptides are supersets of them. If shared master proteins are found, report only the first, we will sort the whole proteingroup later anyway. In that case, the mast...
[ "From", "a", "protein", "-", "peptide", "graph", "dictionary", "(", "keys", "proteins", "values", "peptides", ")", "return", "master", "proteins", "aka", "those", "which", "have", "no", "proteins", "whose", "peptides", "are", "supersets", "of", "them", ".", ...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteingrouping.py#L123-L155
train
Given a protein - peptide graph return a dictionary of master proteins aka those which have no proteins whose peptides are supersets of them.
glormph/msstitch
src/app/actions/mslookup/proteingrouping.py
generate_coverage
def generate_coverage(seqinfo): """From a dict containing protein accessions and sequences/PSM sequences, this function returns a generator that calculates coverages for each protein and returns the accession and coverage percentage. Coverage is done by finding peptides in the protein seq using seq.inde...
python
def generate_coverage(seqinfo): """From a dict containing protein accessions and sequences/PSM sequences, this function returns a generator that calculates coverages for each protein and returns the accession and coverage percentage. Coverage is done by finding peptides in the protein seq using seq.inde...
[ "def", "generate_coverage", "(", "seqinfo", ")", ":", "for", "acc", ",", "protinfo", "in", "seqinfo", ".", "items", "(", ")", ":", "coverage_aa_indices", "=", "set", "(", ")", "seq", "=", "protinfo", "[", "'seq'", "]", "for", "psmseq", "in", "protinfo", ...
From a dict containing protein accessions and sequences/PSM sequences, this function returns a generator that calculates coverages for each protein and returns the accession and coverage percentage. Coverage is done by finding peptides in the protein seq using seq.index and marking the range. May be slo...
[ "From", "a", "dict", "containing", "protein", "accessions", "and", "sequences", "/", "PSM", "sequences", "this", "function", "returns", "a", "generator", "that", "calculates", "coverages", "for", "each", "protein", "and", "returns", "the", "accession", "and", "c...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteingrouping.py#L158-L177
train
Generates a generator that calculates coverages for each protein and returns the accession and coverage percentage.
glormph/msstitch
src/app/actions/mslookup/proteingrouping.py
get_protein_group_content
def get_protein_group_content(pgmap, master): """For each master protein, we generate the protein group proteins complete with sequences, psm_ids and scores. Master proteins are included in this group. Returns a list of [protein, master, pep_hits, psm_hits, protein_score], which is ready to enter t...
python
def get_protein_group_content(pgmap, master): """For each master protein, we generate the protein group proteins complete with sequences, psm_ids and scores. Master proteins are included in this group. Returns a list of [protein, master, pep_hits, psm_hits, protein_score], which is ready to enter t...
[ "def", "get_protein_group_content", "(", "pgmap", ",", "master", ")", ":", "# first item (0) is only a placeholder so the lookup.INDEX things get the", "# correct number. Would be nice with a solution, but the INDEXes were", "# originally made for mzidtsv protein group adding.", "pg_content", ...
For each master protein, we generate the protein group proteins complete with sequences, psm_ids and scores. Master proteins are included in this group. Returns a list of [protein, master, pep_hits, psm_hits, protein_score], which is ready to enter the DB table.
[ "For", "each", "master", "protein", "we", "generate", "the", "protein", "group", "proteins", "complete", "with", "sequences", "psm_ids", "and", "scores", ".", "Master", "proteins", "are", "included", "in", "this", "group", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteingrouping.py#L180-L200
train
Generate the protein group proteins complete with sequences psm_ids and scores.
glormph/msstitch
src/app/actions/peptable/merge.py
build_peptidetable
def build_peptidetable(pqdb, headerfields, isobaric=False, precursor=False, fdr=False, pep=False, genecentric=False): """Fetches peptides and quants from joined lookup table, loops through them and when all of a peptides quants/data have been collected, yields p...
python
def build_peptidetable(pqdb, headerfields, isobaric=False, precursor=False, fdr=False, pep=False, genecentric=False): """Fetches peptides and quants from joined lookup table, loops through them and when all of a peptides quants/data have been collected, yields p...
[ "def", "build_peptidetable", "(", "pqdb", ",", "headerfields", ",", "isobaric", "=", "False", ",", "precursor", "=", "False", ",", "fdr", "=", "False", ",", "pep", "=", "False", ",", "genecentric", "=", "False", ")", ":", "peptidedatamap", "=", "create_fea...
Fetches peptides and quants from joined lookup table, loops through them and when all of a peptides quants/data have been collected, yields peptide quant information.
[ "Fetches", "peptides", "and", "quants", "from", "joined", "lookup", "table", "loops", "through", "them", "and", "when", "all", "of", "a", "peptides", "quants", "/", "data", "have", "been", "collected", "yields", "peptide", "quant", "information", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/peptable/merge.py#L10-L48
train
Builds a protein - level peptide - idetable from a joined lookup table.
glormph/msstitch
src/app/actions/peptable/merge.py
get_protein_data
def get_protein_data(peptide, pdata, headerfields, accfield): """These fields are currently not pool dependent so headerfields is ignored""" report = get_proteins(peptide, pdata, headerfields) return get_cov_descriptions(peptide, pdata, report)
python
def get_protein_data(peptide, pdata, headerfields, accfield): """These fields are currently not pool dependent so headerfields is ignored""" report = get_proteins(peptide, pdata, headerfields) return get_cov_descriptions(peptide, pdata, report)
[ "def", "get_protein_data", "(", "peptide", ",", "pdata", ",", "headerfields", ",", "accfield", ")", ":", "report", "=", "get_proteins", "(", "peptide", ",", "pdata", ",", "headerfields", ")", "return", "get_cov_descriptions", "(", "peptide", ",", "pdata", ",",...
These fields are currently not pool dependent so headerfields is ignored
[ "These", "fields", "are", "currently", "not", "pool", "dependent", "so", "headerfields", "is", "ignored" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/peptable/merge.py#L81-L85
train
Get protein data from a protein data set.
Erotemic/utool
utool/util_progress.py
get_num_chunks
def get_num_chunks(length, chunksize): r""" Returns the number of chunks that a list will be split into given a chunksize. Args: length (int): chunksize (int): Returns: int: n_chunks CommandLine: python -m utool.util_progress --exec-get_num_chunks:0 Exampl...
python
def get_num_chunks(length, chunksize): r""" Returns the number of chunks that a list will be split into given a chunksize. Args: length (int): chunksize (int): Returns: int: n_chunks CommandLine: python -m utool.util_progress --exec-get_num_chunks:0 Exampl...
[ "def", "get_num_chunks", "(", "length", ",", "chunksize", ")", ":", "n_chunks", "=", "int", "(", "math", ".", "ceil", "(", "length", "/", "chunksize", ")", ")", "return", "n_chunks" ]
r""" Returns the number of chunks that a list will be split into given a chunksize. Args: length (int): chunksize (int): Returns: int: n_chunks CommandLine: python -m utool.util_progress --exec-get_num_chunks:0 Example0: >>> # ENABLE_DOCTEST >>...
[ "r", "Returns", "the", "number", "of", "chunks", "that", "a", "list", "will", "be", "split", "into", "given", "a", "chunksize", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_progress.py#L116-L142
train
r Returns the number of chunks that a list will be split into given chunksize.
Erotemic/utool
utool/util_progress.py
ProgChunks
def ProgChunks(list_, chunksize, nInput=None, **kwargs): """ Yeilds an iterator in chunks and computes progress Progress version of ut.ichunks Args: list_ (list): chunksize (?): nInput (None): (default = None) Kwargs: length, freq Returns: ProgressIter:...
python
def ProgChunks(list_, chunksize, nInput=None, **kwargs): """ Yeilds an iterator in chunks and computes progress Progress version of ut.ichunks Args: list_ (list): chunksize (?): nInput (None): (default = None) Kwargs: length, freq Returns: ProgressIter:...
[ "def", "ProgChunks", "(", "list_", ",", "chunksize", ",", "nInput", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "nInput", "is", "None", ":", "nInput", "=", "len", "(", "list_", ")", "n_chunks", "=", "get_num_chunks", "(", "nInput", ",", "ch...
Yeilds an iterator in chunks and computes progress Progress version of ut.ichunks Args: list_ (list): chunksize (?): nInput (None): (default = None) Kwargs: length, freq Returns: ProgressIter: progiter_ CommandLine: python -m utool.util_progress Pr...
[ "Yeilds", "an", "iterator", "in", "chunks", "and", "computes", "progress", "Progress", "version", "of", "ut", ".", "ichunks" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_progress.py#L145-L186
train
Yeilds an iterator in chunks and computes progress
Erotemic/utool
utool/util_progress.py
progress_str
def progress_str(max_val, lbl='Progress: ', repl=False, approx=False, backspace=PROGGRESS_BACKSPACE): r""" makes format string that prints progress: %Xd/MAX_VAL with backspaces NOTE: \r can be used instead of backspaces. This function is not very relevant because of that. """ # st...
python
def progress_str(max_val, lbl='Progress: ', repl=False, approx=False, backspace=PROGGRESS_BACKSPACE): r""" makes format string that prints progress: %Xd/MAX_VAL with backspaces NOTE: \r can be used instead of backspaces. This function is not very relevant because of that. """ # st...
[ "def", "progress_str", "(", "max_val", ",", "lbl", "=", "'Progress: '", ",", "repl", "=", "False", ",", "approx", "=", "False", ",", "backspace", "=", "PROGGRESS_BACKSPACE", ")", ":", "# string that displays max value", "max_str", "=", "six", ".", "text_type", ...
r""" makes format string that prints progress: %Xd/MAX_VAL with backspaces NOTE: \r can be used instead of backspaces. This function is not very relevant because of that.
[ "r", "makes", "format", "string", "that", "prints", "progress", ":", "%Xd", "/", "MAX_VAL", "with", "backspaces" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_progress.py#L836-L869
train
r Returns a string that prints the current progress of the current directory tree item.
Erotemic/utool
utool/util_progress.py
log_progress
def log_progress(lbl='Progress: ', length=0, flushfreq=4, startafter=-1, start=True, repl=False, approx=False, disable=False, writefreq=1, with_time=False, backspace=True, pad_stdout=False, wfreq=None, ffreq=None, freq=None, total=None, num=None, with_...
python
def log_progress(lbl='Progress: ', length=0, flushfreq=4, startafter=-1, start=True, repl=False, approx=False, disable=False, writefreq=1, with_time=False, backspace=True, pad_stdout=False, wfreq=None, ffreq=None, freq=None, total=None, num=None, with_...
[ "def", "log_progress", "(", "lbl", "=", "'Progress: '", ",", "length", "=", "0", ",", "flushfreq", "=", "4", ",", "startafter", "=", "-", "1", ",", "start", "=", "True", ",", "repl", "=", "False", ",", "approx", "=", "False", ",", "disable", "=", "...
DEPRICATE FIXME: depricate for ProgressIter. still used in util_dev
[ "DEPRICATE", "FIXME", ":", "depricate", "for", "ProgressIter", ".", "still", "used", "in", "util_dev" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_progress.py#L872-L948
train
Function to log a progress message.
Erotemic/utool
utool/util_progress.py
ProgressIter.build_msg_fmtstr2
def build_msg_fmtstr2(lbl, length, invert_rate, backspace): r""" Args: lbl (str): invert_rate (bool): backspace (bool): Returns: str: msg_fmtstr_time CommandLine: python -m utool.util_progress --exec-ProgressIter.build_msg_fmt...
python
def build_msg_fmtstr2(lbl, length, invert_rate, backspace): r""" Args: lbl (str): invert_rate (bool): backspace (bool): Returns: str: msg_fmtstr_time CommandLine: python -m utool.util_progress --exec-ProgressIter.build_msg_fmt...
[ "def", "build_msg_fmtstr2", "(", "lbl", ",", "length", ",", "invert_rate", ",", "backspace", ")", ":", "with_wall", "=", "True", "tzname", "=", "time", ".", "tzname", "[", "0", "]", "if", "util_cplat", ".", "WIN32", ":", "tzname", "=", "tzname", ".", "...
r""" Args: lbl (str): invert_rate (bool): backspace (bool): Returns: str: msg_fmtstr_time CommandLine: python -m utool.util_progress --exec-ProgressIter.build_msg_fmtstr2 Setup: >>> from utool.util_progress import...
[ "r", "Args", ":", "lbl", "(", "str", ")", ":", "invert_rate", "(", "bool", ")", ":", "backspace", "(", "bool", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_progress.py#L472-L542
train
r Builds a message format string for a specific locale.
Erotemic/utool
utool/util_progress.py
ProgressIter.iter_rate
def iter_rate(self): """ pun not intended # TODO: record iteration times for analysis # TODO Incorporate this better # FIXME; pad_stdout into subfunctions import dis dis.dis(ut.ProgressIter.iter_rate) """ #class IterState(object): # de...
python
def iter_rate(self): """ pun not intended # TODO: record iteration times for analysis # TODO Incorporate this better # FIXME; pad_stdout into subfunctions import dis dis.dis(ut.ProgressIter.iter_rate) """ #class IterState(object): # de...
[ "def", "iter_rate", "(", "self", ")", ":", "#class IterState(object):", "# def __init__(state):", "# state.freq = 1", "# state.freq = 1", "# pass", "adjust", "=", "self", ".", "autoadjust", "self", ".", "_cursor_at_newline", "=", "not", "self", "."...
pun not intended # TODO: record iteration times for analysis # TODO Incorporate this better # FIXME; pad_stdout into subfunctions import dis dis.dis(ut.ProgressIter.iter_rate)
[ "pun", "not", "intended" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_progress.py#L544-L754
train
This function is used to compute the iteration rate of the current iteration.
Erotemic/utool
utool/util_progress.py
ProgressIter.ensure_newline
def ensure_newline(self): """ use before any custom printing when using the progress iter to ensure your print statement starts on a new line instead of at the end of a progress line """ DECTCEM_SHOW = '\033[?25h' # show cursor AT_END = DECTCEM_SHOW + '\n' ...
python
def ensure_newline(self): """ use before any custom printing when using the progress iter to ensure your print statement starts on a new line instead of at the end of a progress line """ DECTCEM_SHOW = '\033[?25h' # show cursor AT_END = DECTCEM_SHOW + '\n' ...
[ "def", "ensure_newline", "(", "self", ")", ":", "DECTCEM_SHOW", "=", "'\\033[?25h'", "# show cursor", "AT_END", "=", "DECTCEM_SHOW", "+", "'\\n'", "if", "not", "self", ".", "_cursor_at_newline", ":", "self", ".", "write", "(", "AT_END", ")", "self", ".", "_c...
use before any custom printing when using the progress iter to ensure your print statement starts on a new line instead of at the end of a progress line
[ "use", "before", "any", "custom", "printing", "when", "using", "the", "progress", "iter", "to", "ensure", "your", "print", "statement", "starts", "on", "a", "new", "line", "instead", "of", "at", "the", "end", "of", "a", "progress", "line" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_progress.py#L796-L806
train
ensure that the current line is at the end of the current line
Erotemic/utool
utool/util_progress.py
ProgressIter._get_timethresh_heuristics
def _get_timethresh_heuristics(self): """ resonably decent hueristics for how much time to wait before updating progress. """ if self.length > 1E5: time_thresh = 2.5 elif self.length > 1E4: time_thresh = 2.0 elif self.length > 1E3: ...
python
def _get_timethresh_heuristics(self): """ resonably decent hueristics for how much time to wait before updating progress. """ if self.length > 1E5: time_thresh = 2.5 elif self.length > 1E4: time_thresh = 2.0 elif self.length > 1E3: ...
[ "def", "_get_timethresh_heuristics", "(", "self", ")", ":", "if", "self", ".", "length", ">", "1E5", ":", "time_thresh", "=", "2.5", "elif", "self", ".", "length", ">", "1E4", ":", "time_thresh", "=", "2.0", "elif", "self", ".", "length", ">", "1E3", "...
resonably decent hueristics for how much time to wait before updating progress.
[ "resonably", "decent", "hueristics", "for", "how", "much", "time", "to", "wait", "before", "updating", "progress", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_progress.py#L808-L821
train
Returns the time - thresh of the resource table.
Erotemic/utool
utool/util_sqlite.py
get_tablenames
def get_tablenames(cur): """ Conveinience: """ cur.execute("SELECT name FROM sqlite_master WHERE type='table'") tablename_list_ = cur.fetchall() tablename_list = [str(tablename[0]) for tablename in tablename_list_ ] return tablename_list
python
def get_tablenames(cur): """ Conveinience: """ cur.execute("SELECT name FROM sqlite_master WHERE type='table'") tablename_list_ = cur.fetchall() tablename_list = [str(tablename[0]) for tablename in tablename_list_ ] return tablename_list
[ "def", "get_tablenames", "(", "cur", ")", ":", "cur", ".", "execute", "(", "\"SELECT name FROM sqlite_master WHERE type='table'\"", ")", "tablename_list_", "=", "cur", ".", "fetchall", "(", ")", "tablename_list", "=", "[", "str", "(", "tablename", "[", "0", "]",...
Conveinience:
[ "Conveinience", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_sqlite.py#L9-L14
train
Return a list of all tables in the database.
Erotemic/utool
utool/util_sqlite.py
get_table_csv
def get_table_csv(cur, tablename, exclude_columns=[]): """ Conveinience: Converts a tablename to csv format Args: tablename (str): exclude_columns (list): Returns: str: csv_table CommandLine: python -m ibeis.control.SQLDatabaseControl --test-get_table_csv Example:...
python
def get_table_csv(cur, tablename, exclude_columns=[]): """ Conveinience: Converts a tablename to csv format Args: tablename (str): exclude_columns (list): Returns: str: csv_table CommandLine: python -m ibeis.control.SQLDatabaseControl --test-get_table_csv Example:...
[ "def", "get_table_csv", "(", "cur", ",", "tablename", ",", "exclude_columns", "=", "[", "]", ")", ":", "import", "utool", "as", "ut", "colnames_", "=", "ut", ".", "get_table_columnname_list", "(", "cur", ",", "tablename", ")", "colnames", "=", "tuple", "("...
Conveinience: Converts a tablename to csv format Args: tablename (str): exclude_columns (list): Returns: str: csv_table CommandLine: python -m ibeis.control.SQLDatabaseControl --test-get_table_csv Example: >>> # DISABLE_DOCTEST >>> from ibeis.control.S...
[ "Conveinience", ":", "Converts", "a", "tablename", "to", "csv", "format" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_sqlite.py#L28-L69
train
Returns a string that can be used to convert a tablename to csv format
Erotemic/utool
utool/util_sqlite.py
get_table_columninfo_list
def get_table_columninfo_list(cur, tablename): """ Args: tablename (str): table name Returns: column_list : list of tuples with format: ( [0] column_id : id of the column [1] name : the name of the column [2] type_ : th...
python
def get_table_columninfo_list(cur, tablename): """ Args: tablename (str): table name Returns: column_list : list of tuples with format: ( [0] column_id : id of the column [1] name : the name of the column [2] type_ : th...
[ "def", "get_table_columninfo_list", "(", "cur", ",", "tablename", ")", ":", "cur", ".", "execute", "(", "'PRAGMA TABLE_INFO(\"{tablename}\")'", ".", "format", "(", "tablename", "=", "tablename", ")", ")", "colinfo_list", "=", "cur", ".", "fetchall", "(", ")", ...
Args: tablename (str): table name Returns: column_list : list of tuples with format: ( [0] column_id : id of the column [1] name : the name of the column [2] type_ : the type of the column (TEXT, INT, etc...) [3...
[ "Args", ":", "tablename", "(", "str", ")", ":", "table", "name" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_sqlite.py#L77-L106
train
Returns a list of SQLColumnRichInfo objects for the given table.
timedata-org/loady
loady/code.py
load_location
def load_location(url, base_path=None, module=False): """ Read a single Python file in as code and extract members from it. Args: url -- a URL either absolute (contains ':') or relative base_path -- if url is relative, base_path is prepended to it. The resulting URL needs to look somet...
python
def load_location(url, base_path=None, module=False): """ Read a single Python file in as code and extract members from it. Args: url -- a URL either absolute (contains ':') or relative base_path -- if url is relative, base_path is prepended to it. The resulting URL needs to look somet...
[ "def", "load_location", "(", "url", ",", "base_path", "=", "None", ",", "module", "=", "False", ")", ":", "if", "base_path", "and", "':'", "not", "in", "url", ":", "slashes", "=", "base_path", ".", "endswith", "(", "'/'", ")", "+", "url", ".", "start...
Read a single Python file in as code and extract members from it. Args: url -- a URL either absolute (contains ':') or relative base_path -- if url is relative, base_path is prepended to it. The resulting URL needs to look something like this: https://github.com/foo/bar/blob/master/bib...
[ "Read", "a", "single", "Python", "file", "in", "as", "code", "and", "extract", "members", "from", "it", "." ]
94ffcdb92f15a28f3c85f77bd293a9cb59de4cad
https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/code.py#L5-L60
train
Load a single Python file and extract members from it.
timedata-org/loady
loady/code.py
load_code
def load_code(name, base_path=None, recurse=False): """Load executable code from a URL or a path""" if '/' in name: return load_location(name, base_path, module=False) return importer.import_code(name, base_path, recurse=recurse)
python
def load_code(name, base_path=None, recurse=False): """Load executable code from a URL or a path""" if '/' in name: return load_location(name, base_path, module=False) return importer.import_code(name, base_path, recurse=recurse)
[ "def", "load_code", "(", "name", ",", "base_path", "=", "None", ",", "recurse", "=", "False", ")", ":", "if", "'/'", "in", "name", ":", "return", "load_location", "(", "name", ",", "base_path", ",", "module", "=", "False", ")", "return", "importer", "....
Load executable code from a URL or a path
[ "Load", "executable", "code", "from", "a", "URL", "or", "a", "path" ]
94ffcdb92f15a28f3c85f77bd293a9cb59de4cad
https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/code.py#L64-L69
train
Load executable code from a URL or a path
timedata-org/loady
loady/code.py
load
def load(name, base_path=None): """Load a module from a URL or a path""" if '/' in name: return load_location(name, base_path, module=True) return importer.import_symbol(name, base_path)
python
def load(name, base_path=None): """Load a module from a URL or a path""" if '/' in name: return load_location(name, base_path, module=True) return importer.import_symbol(name, base_path)
[ "def", "load", "(", "name", ",", "base_path", "=", "None", ")", ":", "if", "'/'", "in", "name", ":", "return", "load_location", "(", "name", ",", "base_path", ",", "module", "=", "True", ")", "return", "importer", ".", "import_symbol", "(", "name", ","...
Load a module from a URL or a path
[ "Load", "a", "module", "from", "a", "URL", "or", "a", "path" ]
94ffcdb92f15a28f3c85f77bd293a9cb59de4cad
https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/code.py#L73-L78
train
Load a module from a URL or a path
timedata-org/loady
loady/sys_path.py
extend
def extend(path=None, cache=None): """Extend sys.path by a list of git paths.""" if path is None: path = config.PATH try: path = path.split(':') except: pass sys.path.extend([library.to_path(p, cache) for p in path])
python
def extend(path=None, cache=None): """Extend sys.path by a list of git paths.""" if path is None: path = config.PATH try: path = path.split(':') except: pass sys.path.extend([library.to_path(p, cache) for p in path])
[ "def", "extend", "(", "path", "=", "None", ",", "cache", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "config", ".", "PATH", "try", ":", "path", "=", "path", ".", "split", "(", "':'", ")", "except", ":", "pass", "sys", "...
Extend sys.path by a list of git paths.
[ "Extend", "sys", ".", "path", "by", "a", "list", "of", "git", "paths", "." ]
94ffcdb92f15a28f3c85f77bd293a9cb59de4cad
https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/sys_path.py#L5-L14
train
Extend sys. path by a list of git paths.
timedata-org/loady
loady/sys_path.py
extender
def extender(path=None, cache=None): """A context that temporarily extends sys.path and reverts it after the context is complete.""" old_path = sys.path[:] extend(path, cache=None) try: yield finally: sys.path = old_path
python
def extender(path=None, cache=None): """A context that temporarily extends sys.path and reverts it after the context is complete.""" old_path = sys.path[:] extend(path, cache=None) try: yield finally: sys.path = old_path
[ "def", "extender", "(", "path", "=", "None", ",", "cache", "=", "None", ")", ":", "old_path", "=", "sys", ".", "path", "[", ":", "]", "extend", "(", "path", ",", "cache", "=", "None", ")", "try", ":", "yield", "finally", ":", "sys", ".", "path", ...
A context that temporarily extends sys.path and reverts it after the context is complete.
[ "A", "context", "that", "temporarily", "extends", "sys", ".", "path", "and", "reverts", "it", "after", "the", "context", "is", "complete", "." ]
94ffcdb92f15a28f3c85f77bd293a9cb59de4cad
https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/sys_path.py#L18-L27
train
A context that temporarily extends sys. path and reverts it after the context is complete.
LEMS/pylems
lems/model/dynamics.py
StateVariable.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ return '<StateVariable name="{0}" dimension="{1}"'.format(self.name, self.dimension) +\ (' exposure="{0}"'.format(self.exposure) if self.exposure else '') +\ '/>'
python
def toxml(self): """ Exports this object into a LEMS XML object """ return '<StateVariable name="{0}" dimension="{1}"'.format(self.name, self.dimension) +\ (' exposure="{0}"'.format(self.exposure) if self.exposure else '') +\ '/>'
[ "def", "toxml", "(", "self", ")", ":", "return", "'<StateVariable name=\"{0}\" dimension=\"{1}\"'", ".", "format", "(", "self", ".", "name", ",", "self", ".", "dimension", ")", "+", "(", "' exposure=\"{0}\"'", ".", "format", "(", "self", ".", "exposure", ")", ...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L43-L50
train
Returns a LEMS XML string representation of this StateVariable.
LEMS/pylems
lems/model/dynamics.py
DerivedVariable.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ return '<DerivedVariable name="{0}"'.format(self.name) +\ (' dimension="{0}"'.format(self.dimension) if self.dimension else '') +\ (' exposure="{0}"'.format(self.exposure) if self.exposure else '') +...
python
def toxml(self): """ Exports this object into a LEMS XML object """ return '<DerivedVariable name="{0}"'.format(self.name) +\ (' dimension="{0}"'.format(self.dimension) if self.dimension else '') +\ (' exposure="{0}"'.format(self.exposure) if self.exposure else '') +...
[ "def", "toxml", "(", "self", ")", ":", "return", "'<DerivedVariable name=\"{0}\"'", ".", "format", "(", "self", ".", "name", ")", "+", "(", "' dimension=\"{0}\"'", ".", "format", "(", "self", ".", "dimension", ")", "if", "self", ".", "dimension", "else", "...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L104-L116
train
Returns a LEMS XML object representation of this DerivedVariable.
LEMS/pylems
lems/model/dynamics.py
ConditionalDerivedVariable.add
def add(self, child): """ Adds a typed child object to the conditional derived variable. @param child: Child object to be added. """ if isinstance(child, Case): self.add_case(child) else: raise ModelError('Unsupported child element')
python
def add(self, child): """ Adds a typed child object to the conditional derived variable. @param child: Child object to be added. """ if isinstance(child, Case): self.add_case(child) else: raise ModelError('Unsupported child element')
[ "def", "add", "(", "self", ",", "child", ")", ":", "if", "isinstance", "(", "child", ",", "Case", ")", ":", "self", ".", "add_case", "(", "child", ")", "else", ":", "raise", "ModelError", "(", "'Unsupported child element'", ")" ]
Adds a typed child object to the conditional derived variable. @param child: Child object to be added.
[ "Adds", "a", "typed", "child", "object", "to", "the", "conditional", "derived", "variable", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L203-L213
train
Adds a typed child object to the conditional derived variable.
LEMS/pylems
lems/model/dynamics.py
ConditionalDerivedVariable.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ xmlstr = '<ConditionalDerivedVariable name="{0}"'.format(self.name) +\ (' dimension="{0}"'.format(self.dimension) if self.dimension else '') +\ (' exposure="{0}"'.format(self.exposure) if self.exposu...
python
def toxml(self): """ Exports this object into a LEMS XML object """ xmlstr = '<ConditionalDerivedVariable name="{0}"'.format(self.name) +\ (' dimension="{0}"'.format(self.dimension) if self.dimension else '') +\ (' exposure="{0}"'.format(self.exposure) if self.exposu...
[ "def", "toxml", "(", "self", ")", ":", "xmlstr", "=", "'<ConditionalDerivedVariable name=\"{0}\"'", ".", "format", "(", "self", ".", "name", ")", "+", "(", "' dimension=\"{0}\"'", ".", "format", "(", "self", ".", "dimension", ")", "if", "self", ".", "dimensi...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L216-L235
train
Returns a LEMS XML string representation of the object.
LEMS/pylems
lems/model/dynamics.py
EventHandler.add
def add(self, child): """ Adds a typed child object to the event handler. @param child: Child object to be added. """ if isinstance(child, Action): self.add_action(child) else: raise ModelError('Unsupported child element')
python
def add(self, child): """ Adds a typed child object to the event handler. @param child: Child object to be added. """ if isinstance(child, Action): self.add_action(child) else: raise ModelError('Unsupported child element')
[ "def", "add", "(", "self", ",", "child", ")", ":", "if", "isinstance", "(", "child", ",", "Action", ")", ":", "self", ".", "add_action", "(", "child", ")", "else", ":", "raise", "ModelError", "(", "'Unsupported child element'", ")" ]
Adds a typed child object to the event handler. @param child: Child object to be added.
[ "Adds", "a", "typed", "child", "object", "to", "the", "event", "handler", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L402-L412
train
Adds a typed child object to the event handler.
LEMS/pylems
lems/model/dynamics.py
OnStart.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ xmlstr = '<OnStart' chxmlstr = '' for action in self.actions: chxmlstr += action.toxml() if chxmlstr: xmlstr += '>' + chxmlstr + '</OnStart>' else: ...
python
def toxml(self): """ Exports this object into a LEMS XML object """ xmlstr = '<OnStart' chxmlstr = '' for action in self.actions: chxmlstr += action.toxml() if chxmlstr: xmlstr += '>' + chxmlstr + '</OnStart>' else: ...
[ "def", "toxml", "(", "self", ")", ":", "xmlstr", "=", "'<OnStart'", "chxmlstr", "=", "''", "for", "action", "in", "self", ".", "actions", ":", "chxmlstr", "+=", "action", ".", "toxml", "(", ")", "if", "chxmlstr", ":", "xmlstr", "+=", "'>'", "+", "chx...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L433-L450
train
Returns a LEMS XML string representation of the object.
LEMS/pylems
lems/model/dynamics.py
OnCondition.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ xmlstr = '<OnCondition test="{0}"'.format(self.test) chxmlstr = '' for action in self.actions: chxmlstr += action.toxml() if chxmlstr: xmlstr += '>' + chxmlstr + '</OnC...
python
def toxml(self): """ Exports this object into a LEMS XML object """ xmlstr = '<OnCondition test="{0}"'.format(self.test) chxmlstr = '' for action in self.actions: chxmlstr += action.toxml() if chxmlstr: xmlstr += '>' + chxmlstr + '</OnC...
[ "def", "toxml", "(", "self", ")", ":", "xmlstr", "=", "'<OnCondition test=\"{0}\"'", ".", "format", "(", "self", ".", "test", ")", "chxmlstr", "=", "''", "for", "action", "in", "self", ".", "actions", ":", "chxmlstr", "+=", "action", ".", "toxml", "(", ...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L479-L496
train
Returns a LEMS XML string representation of this object.
LEMS/pylems
lems/model/dynamics.py
OnEvent.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ xmlstr = '<OnEvent port="{0}"'.format(self.port) chxmlstr = '' for action in self.actions: chxmlstr += action.toxml() if chxmlstr: xmlstr += '>' + chxmlstr + '</OnEvent...
python
def toxml(self): """ Exports this object into a LEMS XML object """ xmlstr = '<OnEvent port="{0}"'.format(self.port) chxmlstr = '' for action in self.actions: chxmlstr += action.toxml() if chxmlstr: xmlstr += '>' + chxmlstr + '</OnEvent...
[ "def", "toxml", "(", "self", ")", ":", "xmlstr", "=", "'<OnEvent port=\"{0}\"'", ".", "format", "(", "self", ".", "port", ")", "chxmlstr", "=", "''", "for", "action", "in", "self", ".", "actions", ":", "chxmlstr", "+=", "action", ".", "toxml", "(", ")"...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L520-L537
train
Returns a LEMS XML string representation of this object.
LEMS/pylems
lems/model/dynamics.py
KineticScheme.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ return ('<KineticScheme ' 'name="{0}" ' 'nodes="{1}" ' 'edges="{2}" ' 'stateVariable="{3}" ' 'edgeSource="{4}" ' 'edgeTarge...
python
def toxml(self): """ Exports this object into a LEMS XML object """ return ('<KineticScheme ' 'name="{0}" ' 'nodes="{1}" ' 'edges="{2}" ' 'stateVariable="{3}" ' 'edgeSource="{4}" ' 'edgeTarge...
[ "def", "toxml", "(", "self", ")", ":", "return", "(", "'<KineticScheme '", "'name=\"{0}\" '", "'nodes=\"{1}\" '", "'edges=\"{2}\" '", "'stateVariable=\"{3}\" '", "'edgeSource=\"{4}\" '", "'edgeTarget=\"{5}\" '", "'forwardRate=\"{6}\" '", "'reverseRate=\"{7}\"/>'", ")", ".", "fo...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L616-L636
train
Returns a LEMS XML string representation of this object.
LEMS/pylems
lems/model/dynamics.py
Behavioral.add
def add(self, child): """ Adds a typed child object to the behavioral object. @param child: Child object to be added. """ if isinstance(child, StateVariable): self.add_state_variable(child) elif isinstance(child, DerivedVariable): self.add_derive...
python
def add(self, child): """ Adds a typed child object to the behavioral object. @param child: Child object to be added. """ if isinstance(child, StateVariable): self.add_state_variable(child) elif isinstance(child, DerivedVariable): self.add_derive...
[ "def", "add", "(", "self", ",", "child", ")", ":", "if", "isinstance", "(", "child", ",", "StateVariable", ")", ":", "self", ".", "add_state_variable", "(", "child", ")", "elif", "isinstance", "(", "child", ",", "DerivedVariable", ")", ":", "self", ".", ...
Adds a typed child object to the behavioral object. @param child: Child object to be added.
[ "Adds", "a", "typed", "child", "object", "to", "the", "behavioral", "object", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L757-L777
train
Adds a typed child object to the behavioral object.
LEMS/pylems
lems/model/dynamics.py
Behavioral.toxml
def toxml(self): """ Exports this object into a LEMS XML object """ chxmlstr = '' for state_variable in self.state_variables: chxmlstr += state_variable.toxml() for derived_variable in self.derived_variables: chxmlstr += derived_variable.toxml()...
python
def toxml(self): """ Exports this object into a LEMS XML object """ chxmlstr = '' for state_variable in self.state_variables: chxmlstr += state_variable.toxml() for derived_variable in self.derived_variables: chxmlstr += derived_variable.toxml()...
[ "def", "toxml", "(", "self", ")", ":", "chxmlstr", "=", "''", "for", "state_variable", "in", "self", ".", "state_variables", ":", "chxmlstr", "+=", "state_variable", ".", "toxml", "(", ")", "for", "derived_variable", "in", "self", ".", "derived_variables", "...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L779-L823
train
Returns a LEMS XML string representation of the object.
LEMS/pylems
lems/model/dynamics.py
Dynamics.add
def add(self, child): """ Adds a typed child object to the dynamics object. @param child: Child object to be added. """ if isinstance(child, Regime): self.add_regime(child) else: Behavioral.add(self, child)
python
def add(self, child): """ Adds a typed child object to the dynamics object. @param child: Child object to be added. """ if isinstance(child, Regime): self.add_regime(child) else: Behavioral.add(self, child)
[ "def", "add", "(", "self", ",", "child", ")", ":", "if", "isinstance", "(", "child", ",", "Regime", ")", ":", "self", ".", "add_regime", "(", "child", ")", "else", ":", "Behavioral", ".", "add", "(", "self", ",", "child", ")" ]
Adds a typed child object to the dynamics object. @param child: Child object to be added.
[ "Adds", "a", "typed", "child", "object", "to", "the", "dynamics", "object", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L876-L886
train
Adds a typed child object to the dynamics object.
glormph/msstitch
src/app/actions/mslookup/biosets.py
create_bioset_lookup
def create_bioset_lookup(lookupdb, spectrafns, set_names): """Fills lookup database with biological set names""" unique_setnames = set(set_names) lookupdb.store_biosets(((x,) for x in unique_setnames)) set_id_map = lookupdb.get_setnames() mzmlfiles = ((os.path.basename(fn), set_id_map[setname]) ...
python
def create_bioset_lookup(lookupdb, spectrafns, set_names): """Fills lookup database with biological set names""" unique_setnames = set(set_names) lookupdb.store_biosets(((x,) for x in unique_setnames)) set_id_map = lookupdb.get_setnames() mzmlfiles = ((os.path.basename(fn), set_id_map[setname]) ...
[ "def", "create_bioset_lookup", "(", "lookupdb", ",", "spectrafns", ",", "set_names", ")", ":", "unique_setnames", "=", "set", "(", "set_names", ")", "lookupdb", ".", "store_biosets", "(", "(", "(", "x", ",", ")", "for", "x", "in", "unique_setnames", ")", "...
Fills lookup database with biological set names
[ "Fills", "lookup", "database", "with", "biological", "set", "names" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/biosets.py#L4-L12
train
Fills lookup database with biological set names
Erotemic/utool
utool/util_import.py
import_star
def import_star(modname, parent=None): """ Args: modname (str): module name Tutorial: Replacement for from modname import * Usage is like this globals().update(ut.import_star('<module>')) OR ut.import_star('<module>', __name__) Ignore: >...
python
def import_star(modname, parent=None): """ Args: modname (str): module name Tutorial: Replacement for from modname import * Usage is like this globals().update(ut.import_star('<module>')) OR ut.import_star('<module>', __name__) Ignore: >...
[ "def", "import_star", "(", "modname", ",", "parent", "=", "None", ")", ":", "import", "six", "from", "os", ".", "path", "import", "dirname", "if", "parent", "is", "None", ":", "parent_module", "=", "None", "else", ":", "parent_module", "=", "sys", ".", ...
Args: modname (str): module name Tutorial: Replacement for from modname import * Usage is like this globals().update(ut.import_star('<module>')) OR ut.import_star('<module>', __name__) Ignore: >>> from utool.util_import import * # NOQA ...
[ "Args", ":", "modname", "(", "str", ")", ":", "module", "name" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L62-L125
train
Import the given module and return the new object.
Erotemic/utool
utool/util_import.py
import_star_execstr
def import_star_execstr(modname, parent=None): """ print(ut.import_star_execstr('opengm.inference')) """ from utool import util_str module_vars = import_star(modname, parent=parent) fromlist_str = ', '.join(sorted(module_vars.keys())) fromimport_prefix = 'from {modname} import ('.format(modn...
python
def import_star_execstr(modname, parent=None): """ print(ut.import_star_execstr('opengm.inference')) """ from utool import util_str module_vars = import_star(modname, parent=parent) fromlist_str = ', '.join(sorted(module_vars.keys())) fromimport_prefix = 'from {modname} import ('.format(modn...
[ "def", "import_star_execstr", "(", "modname", ",", "parent", "=", "None", ")", ":", "from", "utool", "import", "util_str", "module_vars", "=", "import_star", "(", "modname", ",", "parent", "=", "parent", ")", "fromlist_str", "=", "', '", ".", "join", "(", ...
print(ut.import_star_execstr('opengm.inference'))
[ "print", "(", "ut", ".", "import_star_execstr", "(", "opengm", ".", "inference", "))" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L128-L148
train
import_star_execstr returns a string that can be used as a from import statement
Erotemic/utool
utool/util_import.py
possible_import_patterns
def possible_import_patterns(modname): """ does not support from x import * does not support from x import z, y Example: >>> # DISABLE_DOCTEST >>> import utool as ut >>> modname = 'package.submod.submod2.module' >>> result = ut.repr3(ut.possible_import_patterns(modname))...
python
def possible_import_patterns(modname): """ does not support from x import * does not support from x import z, y Example: >>> # DISABLE_DOCTEST >>> import utool as ut >>> modname = 'package.submod.submod2.module' >>> result = ut.repr3(ut.possible_import_patterns(modname))...
[ "def", "possible_import_patterns", "(", "modname", ")", ":", "# common regexes", "WS", "=", "r'\\s'", "import_", "=", "'import'", "from_", "=", "'from'", "dot_", "=", "r'\\.'", "patterns", "=", "[", "import_", "+", "WS", "+", "modname", "]", "if", "'.'", "...
does not support from x import * does not support from x import z, y Example: >>> # DISABLE_DOCTEST >>> import utool as ut >>> modname = 'package.submod.submod2.module' >>> result = ut.repr3(ut.possible_import_patterns(modname)) >>> print(result) [ 'i...
[ "does", "not", "support", "from", "x", "import", "*", "does", "not", "support", "from", "x", "import", "z", "y" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L154-L190
train
returns a list of possible import patterns for a module
Erotemic/utool
utool/util_import.py
package_contents
def package_contents(package, with_pkg=False, with_mod=True, ignore_prefix=[], ignore_suffix=[]): r""" References: http://stackoverflow.com/questions/1707709/list-all-the-modules-that-are-part-of-a-python-package Args: package (?): with_pkg (bool): (default = Fa...
python
def package_contents(package, with_pkg=False, with_mod=True, ignore_prefix=[], ignore_suffix=[]): r""" References: http://stackoverflow.com/questions/1707709/list-all-the-modules-that-are-part-of-a-python-package Args: package (?): with_pkg (bool): (default = Fa...
[ "def", "package_contents", "(", "package", ",", "with_pkg", "=", "False", ",", "with_mod", "=", "True", ",", "ignore_prefix", "=", "[", "]", ",", "ignore_suffix", "=", "[", "]", ")", ":", "import", "pkgutil", "if", "not", "hasattr", "(", "package", ",", ...
r""" References: http://stackoverflow.com/questions/1707709/list-all-the-modules-that-are-part-of-a-python-package Args: package (?): with_pkg (bool): (default = False) with_mod (bool): (default = True) CommandLine: python -m utool.util_import --exec-package_content...
[ "r", "References", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "1707709", "/", "list", "-", "all", "-", "the", "-", "modules", "-", "that", "-", "are", "-", "part", "-", "of", "-", "a", "-", "python", "-", "package" ...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L193-L240
train
r Returns a list of all the modules that are part of a python package.
Erotemic/utool
utool/util_import.py
get_modpath_from_modname
def get_modpath_from_modname(modname, prefer_pkg=False, prefer_main=False): """ Same as get_modpath but doesnt import directly SeeAlso: get_modpath """ from os.path import dirname, basename, join, exists initname = '__init__.py' mainname = '__main__.py' if modname in sys.modules...
python
def get_modpath_from_modname(modname, prefer_pkg=False, prefer_main=False): """ Same as get_modpath but doesnt import directly SeeAlso: get_modpath """ from os.path import dirname, basename, join, exists initname = '__init__.py' mainname = '__main__.py' if modname in sys.modules...
[ "def", "get_modpath_from_modname", "(", "modname", ",", "prefer_pkg", "=", "False", ",", "prefer_main", "=", "False", ")", ":", "from", "os", ".", "path", "import", "dirname", ",", "basename", ",", "join", ",", "exists", "initname", "=", "'__init__.py'", "ma...
Same as get_modpath but doesnt import directly SeeAlso: get_modpath
[ "Same", "as", "get_modpath", "but", "doesnt", "import", "directly" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L243-L269
train
Get the path of the module with the given name.
Erotemic/utool
utool/util_import.py
check_module_installed
def check_module_installed(modname): """ Check if a python module is installed without attempting to import it. Note, that if ``modname`` indicates a child module, the parent module is always loaded. Args: modname (str): module name Returns: bool: found References: ...
python
def check_module_installed(modname): """ Check if a python module is installed without attempting to import it. Note, that if ``modname`` indicates a child module, the parent module is always loaded. Args: modname (str): module name Returns: bool: found References: ...
[ "def", "check_module_installed", "(", "modname", ")", ":", "import", "pkgutil", "if", "'.'", "in", "modname", ":", "# Prevent explicit import if possible", "parts", "=", "modname", ".", "split", "(", "'.'", ")", "base", "=", "parts", "[", "0", "]", "submods", ...
Check if a python module is installed without attempting to import it. Note, that if ``modname`` indicates a child module, the parent module is always loaded. Args: modname (str): module name Returns: bool: found References: http://stackoverflow.com/questions/14050281/mod...
[ "Check", "if", "a", "python", "module", "is", "installed", "without", "attempting", "to", "import", "it", ".", "Note", "that", "if", "modname", "indicates", "a", "child", "module", "the", "parent", "module", "is", "always", "loaded", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L272-L317
train
Check if a python module is installed without attempting to import it.
Erotemic/utool
utool/util_import.py
import_modname
def import_modname(modname): r""" Args: modname (str): module name Returns: module: module CommandLine: python -m utool.util_import --test-import_modname Example: >>> # ENABLE_DOCTEST >>> from utool.util_import import * # NOQA >>> modname_list = [...
python
def import_modname(modname): r""" Args: modname (str): module name Returns: module: module CommandLine: python -m utool.util_import --test-import_modname Example: >>> # ENABLE_DOCTEST >>> from utool.util_import import * # NOQA >>> modname_list = [...
[ "def", "import_modname", "(", "modname", ")", ":", "# The __import__ statment is weird", "if", "util_inject", ".", "PRINT_INJECT_ORDER", ":", "if", "modname", "not", "in", "sys", ".", "modules", ":", "util_inject", ".", "noinject", "(", "modname", ",", "N", "=",...
r""" Args: modname (str): module name Returns: module: module CommandLine: python -m utool.util_import --test-import_modname Example: >>> # ENABLE_DOCTEST >>> from utool.util_import import * # NOQA >>> modname_list = [ >>> 'utool', ...
[ "r", "Args", ":", "modname", "(", "str", ")", ":", "module", "name" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L320-L355
train
r Import a module from utool. util_inject. print_inject_order
Erotemic/utool
utool/util_import.py
tryimport
def tryimport(modname, pipiname=None, ensure=False): """ CommandLine: python -m utool.util_import --test-tryimport Example: >>> # ENABLE_DOCTEST >>> from utool.util_tests import * # NOQA >>> import utool as ut >>> modname = 'pyfiglet' >>> pipiname = 'git+htt...
python
def tryimport(modname, pipiname=None, ensure=False): """ CommandLine: python -m utool.util_import --test-tryimport Example: >>> # ENABLE_DOCTEST >>> from utool.util_tests import * # NOQA >>> import utool as ut >>> modname = 'pyfiglet' >>> pipiname = 'git+htt...
[ "def", "tryimport", "(", "modname", ",", "pipiname", "=", "None", ",", "ensure", "=", "False", ")", ":", "if", "pipiname", "is", "None", ":", "pipiname", "=", "modname", "try", ":", "if", "util_inject", ".", "PRINT_INJECT_ORDER", ":", "if", "modname", "n...
CommandLine: python -m utool.util_import --test-tryimport Example: >>> # ENABLE_DOCTEST >>> from utool.util_tests import * # NOQA >>> import utool as ut >>> modname = 'pyfiglet' >>> pipiname = 'git+https://github.com/pwaller/pyfiglet' >>> pyfiglet = ut.tryim...
[ "CommandLine", ":", "python", "-", "m", "utool", ".", "util_import", "--", "test", "-", "tryimport" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L358-L409
train
Try to import a module and return the module object.
Erotemic/utool
utool/util_import.py
import_module_from_fpath
def import_module_from_fpath(module_fpath): r""" imports module from a file path Args: module_fpath (str): Returns: module: module CommandLine: python -m utool.util_import --test-import_module_from_fpath Example: >>> # DISABLE_DOCTEST >>> from utool.util_i...
python
def import_module_from_fpath(module_fpath): r""" imports module from a file path Args: module_fpath (str): Returns: module: module CommandLine: python -m utool.util_import --test-import_module_from_fpath Example: >>> # DISABLE_DOCTEST >>> from utool.util_i...
[ "def", "import_module_from_fpath", "(", "module_fpath", ")", ":", "from", "os", ".", "path", "import", "basename", ",", "splitext", ",", "isdir", ",", "join", ",", "exists", ",", "dirname", ",", "split", "import", "platform", "if", "isdir", "(", "module_fpat...
r""" imports module from a file path Args: module_fpath (str): Returns: module: module CommandLine: python -m utool.util_import --test-import_module_from_fpath Example: >>> # DISABLE_DOCTEST >>> from utool.util_import import * # NOQA >>> import utool ...
[ "r", "imports", "module", "from", "a", "file", "path" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L469-L609
train
r Import a module from a file path
trendels/gevent_inotifyx
gevent_inotifyx/vendor/inotifyx/__init__.py
get_events
def get_events(fd, *args): ''' get_events(fd[, timeout]) Return a list of InotifyEvent instances representing events read from inotify. If timeout is None, this will block forever until at least one event can be read. Otherwise, timeout should be an integer or float specifying a timeout in se...
python
def get_events(fd, *args): ''' get_events(fd[, timeout]) Return a list of InotifyEvent instances representing events read from inotify. If timeout is None, this will block forever until at least one event can be read. Otherwise, timeout should be an integer or float specifying a timeout in se...
[ "def", "get_events", "(", "fd", ",", "*", "args", ")", ":", "return", "[", "InotifyEvent", "(", "wd", ",", "mask", ",", "cookie", ",", "name", ")", "for", "wd", ",", "mask", ",", "cookie", ",", "name", "in", "binding", ".", "get_events", "(", "fd",...
get_events(fd[, timeout]) Return a list of InotifyEvent instances representing events read from inotify. If timeout is None, this will block forever until at least one event can be read. Otherwise, timeout should be an integer or float specifying a timeout in seconds. If get_events times out waiting...
[ "get_events", "(", "fd", "[", "timeout", "]", ")" ]
b1e531616d150e86b13aeca450a61c66f9bbc855
https://github.com/trendels/gevent_inotifyx/blob/b1e531616d150e86b13aeca450a61c66f9bbc855/gevent_inotifyx/vendor/inotifyx/__init__.py#L107-L121
train
Get events from inotify.
trendels/gevent_inotifyx
gevent_inotifyx/vendor/inotifyx/__init__.py
InotifyEvent.get_mask_description
def get_mask_description(self): ''' Return an ASCII string describing the mask field in terms of bitwise-or'd IN_* constants, or 0. The result is valid Python code that could be eval'd to get the value of the mask field. In other words, for a given event: >>> from inot...
python
def get_mask_description(self): ''' Return an ASCII string describing the mask field in terms of bitwise-or'd IN_* constants, or 0. The result is valid Python code that could be eval'd to get the value of the mask field. In other words, for a given event: >>> from inot...
[ "def", "get_mask_description", "(", "self", ")", ":", "parts", "=", "[", "]", "for", "name", ",", "value", "in", "list", "(", "constants", ".", "items", "(", ")", ")", ":", "if", "self", ".", "mask", "&", "value", ":", "parts", ".", "append", "(", ...
Return an ASCII string describing the mask field in terms of bitwise-or'd IN_* constants, or 0. The result is valid Python code that could be eval'd to get the value of the mask field. In other words, for a given event: >>> from inotifyx import * >>> assert (event.mask == eval...
[ "Return", "an", "ASCII", "string", "describing", "the", "mask", "field", "in", "terms", "of", "bitwise", "-", "or", "d", "IN_", "*", "constants", "or", "0", ".", "The", "result", "is", "valid", "Python", "code", "that", "could", "be", "eval", "d", "to"...
b1e531616d150e86b13aeca450a61c66f9bbc855
https://github.com/trendels/gevent_inotifyx/blob/b1e531616d150e86b13aeca450a61c66f9bbc855/gevent_inotifyx/vendor/inotifyx/__init__.py#L87-L104
train
Return an ASCII string describing the mask field in terms of IN_* constants or 0.
Erotemic/utool
utool/util_print.py
print_difftext
def print_difftext(text, other=None): """ Args: text (str): CommandLine: #python -m utool.util_print --test-print_difftext #autopep8 ingest_data.py --diff | python -m utool.util_print --test-print_difftext """ if other is not None: # hack text = util_str.dif...
python
def print_difftext(text, other=None): """ Args: text (str): CommandLine: #python -m utool.util_print --test-print_difftext #autopep8 ingest_data.py --diff | python -m utool.util_print --test-print_difftext """ if other is not None: # hack text = util_str.dif...
[ "def", "print_difftext", "(", "text", ",", "other", "=", "None", ")", ":", "if", "other", "is", "not", "None", ":", "# hack", "text", "=", "util_str", ".", "difftext", "(", "text", ",", "other", ")", "colortext", "=", "util_str", ".", "color_diff_text", ...
Args: text (str): CommandLine: #python -m utool.util_print --test-print_difftext #autopep8 ingest_data.py --diff | python -m utool.util_print --test-print_difftext
[ "Args", ":", "text", "(", "str", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_print.py#L258-L277
train
Print the diff text of the current object.
Erotemic/utool
utool/util_print.py
print_locals
def print_locals(*args, **kwargs): """ Prints local variables in function. If no arguments all locals are printed. Variables can be specified directly (variable values passed in) as varargs or indirectly (variable names passed in) in kwargs by using keys and a list of strings. """ from...
python
def print_locals(*args, **kwargs): """ Prints local variables in function. If no arguments all locals are printed. Variables can be specified directly (variable values passed in) as varargs or indirectly (variable names passed in) in kwargs by using keys and a list of strings. """ from...
[ "def", "print_locals", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "utool", "import", "util_str", "from", "utool", "import", "util_dbg", "from", "utool", "import", "util_dict", "locals_", "=", "util_dbg", ".", "get_parent_frame", "(", ")", ...
Prints local variables in function. If no arguments all locals are printed. Variables can be specified directly (variable values passed in) as varargs or indirectly (variable names passed in) in kwargs by using keys and a list of strings.
[ "Prints", "local", "variables", "in", "function", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_print.py#L329-L353
train
Print local variables in function.
glormph/msstitch
src/app/readers/ml.py
get_scan_nr
def get_scan_nr(element, attribname): """General method to get a scan nr from xml element of mzML/mzIdentML""" info = element.attrib[attribname] infomap = {y[0]: y[1] for y in [x.split('=') for x in info.split()]} return infomap['scan']
python
def get_scan_nr(element, attribname): """General method to get a scan nr from xml element of mzML/mzIdentML""" info = element.attrib[attribname] infomap = {y[0]: y[1] for y in [x.split('=') for x in info.split()]} return infomap['scan']
[ "def", "get_scan_nr", "(", "element", ",", "attribname", ")", ":", "info", "=", "element", ".", "attrib", "[", "attribname", "]", "infomap", "=", "{", "y", "[", "0", "]", ":", "y", "[", "1", "]", "for", "y", "in", "[", "x", ".", "split", "(", "...
General method to get a scan nr from xml element of mzML/mzIdentML
[ "General", "method", "to", "get", "a", "scan", "nr", "from", "xml", "element", "of", "mzML", "/", "mzIdentML" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/ml.py#L1-L5
train
General method to get a scan nr from xml element of mzML or mzIdentML
Erotemic/utool
utool/util_grabdata.py
archive_files
def archive_files(archive_fpath, fpath_list, small=True, allowZip64=False, overwrite=False, verbose=True, common_prefix=False): r""" Adds the files in `fpath_list` to an zip/tar archive. Args: archive_fpath (str): path to zipfile to create fpath_list (list): path of files ...
python
def archive_files(archive_fpath, fpath_list, small=True, allowZip64=False, overwrite=False, verbose=True, common_prefix=False): r""" Adds the files in `fpath_list` to an zip/tar archive. Args: archive_fpath (str): path to zipfile to create fpath_list (list): path of files ...
[ "def", "archive_files", "(", "archive_fpath", ",", "fpath_list", ",", "small", "=", "True", ",", "allowZip64", "=", "False", ",", "overwrite", "=", "False", ",", "verbose", "=", "True", ",", "common_prefix", "=", "False", ")", ":", "import", "utool", "as",...
r""" Adds the files in `fpath_list` to an zip/tar archive. Args: archive_fpath (str): path to zipfile to create fpath_list (list): path of files to add to the zipfile small (bool): if True uses compression but the zipfile will take more time to write allowZip64 (bool...
[ "r", "Adds", "the", "files", "in", "fpath_list", "to", "an", "zip", "/", "tar", "archive", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L27-L96
train
r A function to archive the files in fpath_list to a zip archive.
Erotemic/utool
utool/util_grabdata.py
_extract_archive
def _extract_archive(archive_fpath, archive_file, archive_namelist, output_dir, force_commonprefix=True, prefix=None, dryrun=False, verbose=not QUIET, overwrite=None): """ archive_fpath = zip_fpath archive_file = zip_file """ # force extracted components int...
python
def _extract_archive(archive_fpath, archive_file, archive_namelist, output_dir, force_commonprefix=True, prefix=None, dryrun=False, verbose=not QUIET, overwrite=None): """ archive_fpath = zip_fpath archive_file = zip_file """ # force extracted components int...
[ "def", "_extract_archive", "(", "archive_fpath", ",", "archive_file", ",", "archive_namelist", ",", "output_dir", ",", "force_commonprefix", "=", "True", ",", "prefix", "=", "None", ",", "dryrun", "=", "False", ",", "verbose", "=", "not", "QUIET", ",", "overwr...
archive_fpath = zip_fpath archive_file = zip_file
[ "archive_fpath", "=", "zip_fpath", "archive_file", "=", "zip_file" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L164-L196
train
Extract the archive into the output_dir
Erotemic/utool
utool/util_grabdata.py
open_url_in_browser
def open_url_in_browser(url, browsername=None, fallback=False): r""" Opens a url in the specified or default browser Args: url (str): web url CommandLine: python -m utool.util_grabdata --test-open_url_in_browser Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >...
python
def open_url_in_browser(url, browsername=None, fallback=False): r""" Opens a url in the specified or default browser Args: url (str): web url CommandLine: python -m utool.util_grabdata --test-open_url_in_browser Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >...
[ "def", "open_url_in_browser", "(", "url", ",", "browsername", "=", "None", ",", "fallback", "=", "False", ")", ":", "import", "webbrowser", "print", "(", "'[utool] Opening url=%r in browser'", "%", "(", "url", ",", ")", ")", "if", "browsername", "is", "None", ...
r""" Opens a url in the specified or default browser Args: url (str): web url CommandLine: python -m utool.util_grabdata --test-open_url_in_browser Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> from utool.util_grabdata import * # NOQA >>> url = 'http...
[ "r", "Opens", "a", "url", "in", "the", "specified", "or", "default", "browser" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L199-L222
train
r Opens a url in the specified browser
Erotemic/utool
utool/util_grabdata.py
get_prefered_browser
def get_prefered_browser(pref_list=[], fallback=True): r""" Args: browser_preferences (list): (default = []) fallback (bool): uses default if non of preferences work (default = True) CommandLine: python -m utool.util_grabdata --test-get_prefered_browser Ignore: import w...
python
def get_prefered_browser(pref_list=[], fallback=True): r""" Args: browser_preferences (list): (default = []) fallback (bool): uses default if non of preferences work (default = True) CommandLine: python -m utool.util_grabdata --test-get_prefered_browser Ignore: import w...
[ "def", "get_prefered_browser", "(", "pref_list", "=", "[", "]", ",", "fallback", "=", "True", ")", ":", "import", "webbrowser", "import", "utool", "as", "ut", "pref_list", "=", "ut", ".", "ensure_iterable", "(", "pref_list", ")", "error_list", "=", "[", "]...
r""" Args: browser_preferences (list): (default = []) fallback (bool): uses default if non of preferences work (default = True) CommandLine: python -m utool.util_grabdata --test-get_prefered_browser Ignore: import webbrowser webbrowser._tryorder pref_list = ...
[ "r", "Args", ":", "browser_preferences", "(", "list", ")", ":", "(", "default", "=", "[]", ")", "fallback", "(", "bool", ")", ":", "uses", "default", "if", "non", "of", "preferences", "work", "(", "default", "=", "True", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L225-L282
train
r Returns a new node that is preferred to the given browser preferences.
Erotemic/utool
utool/util_grabdata.py
download_url
def download_url(url, filename=None, spoof=False, iri_fallback=True, verbose=True, new=False, chunk_size=None): r""" downloads a url to a filename. Args: url (str): url to download filename (str): path to download to. Defaults to basename of url spoof (bool): if True pr...
python
def download_url(url, filename=None, spoof=False, iri_fallback=True, verbose=True, new=False, chunk_size=None): r""" downloads a url to a filename. Args: url (str): url to download filename (str): path to download to. Defaults to basename of url spoof (bool): if True pr...
[ "def", "download_url", "(", "url", ",", "filename", "=", "None", ",", "spoof", "=", "False", ",", "iri_fallback", "=", "True", ",", "verbose", "=", "True", ",", "new", "=", "False", ",", "chunk_size", "=", "None", ")", ":", "def", "reporthook_", "(", ...
r""" downloads a url to a filename. Args: url (str): url to download filename (str): path to download to. Defaults to basename of url spoof (bool): if True pretends to by Firefox iri_fallback : falls back to requests get call if there is a UnicodeError References: http:...
[ "r", "downloads", "a", "url", "to", "a", "filename", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L285-L393
train
r Downloads a url to a file.
Erotemic/utool
utool/util_grabdata.py
url_read
def url_read(url, verbose=True): r""" Directly reads data from url """ if url.find('://') == -1: url = 'http://' + url if verbose: print('Reading data from url=%r' % (url,)) try: file_ = _urllib.request.urlopen(url) #file_ = _urllib.urlopen(url) except IOError...
python
def url_read(url, verbose=True): r""" Directly reads data from url """ if url.find('://') == -1: url = 'http://' + url if verbose: print('Reading data from url=%r' % (url,)) try: file_ = _urllib.request.urlopen(url) #file_ = _urllib.urlopen(url) except IOError...
[ "def", "url_read", "(", "url", ",", "verbose", "=", "True", ")", ":", "if", "url", ".", "find", "(", "'://'", ")", "==", "-", "1", ":", "url", "=", "'http://'", "+", "url", "if", "verbose", ":", "print", "(", "'Reading data from url=%r'", "%", "(", ...
r""" Directly reads data from url
[ "r", "Directly", "reads", "data", "from", "url" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L402-L417
train
r Directly reads data from url
Erotemic/utool
utool/util_grabdata.py
url_read_text
def url_read_text(url, verbose=True): r""" Directly reads text data from url """ data = url_read(url, verbose) text = data.decode('utf8') return text
python
def url_read_text(url, verbose=True): r""" Directly reads text data from url """ data = url_read(url, verbose) text = data.decode('utf8') return text
[ "def", "url_read_text", "(", "url", ",", "verbose", "=", "True", ")", ":", "data", "=", "url_read", "(", "url", ",", "verbose", ")", "text", "=", "data", ".", "decode", "(", "'utf8'", ")", "return", "text" ]
r""" Directly reads text data from url
[ "r", "Directly", "reads", "text", "data", "from", "url" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L420-L426
train
r Directly reads text data from url and returns it as a unicode string.
Erotemic/utool
utool/util_grabdata.py
experiment_download_multiple_urls
def experiment_download_multiple_urls(url_list): r""" References: http://stackoverflow.com/questions/1112343/capture-sigint-in-python http://stackoverflow.com/questions/16694907/download-large-file-requests GracefulInterruptHandler Ignore: import signal import sys ...
python
def experiment_download_multiple_urls(url_list): r""" References: http://stackoverflow.com/questions/1112343/capture-sigint-in-python http://stackoverflow.com/questions/16694907/download-large-file-requests GracefulInterruptHandler Ignore: import signal import sys ...
[ "def", "experiment_download_multiple_urls", "(", "url_list", ")", ":", "import", "requests", "import", "os", "session", "=", "requests", ".", "session", "(", ")", "def", "session_download_url", "(", "url", ")", ":", "filename", "=", "basename", "(", "url", ")"...
r""" References: http://stackoverflow.com/questions/1112343/capture-sigint-in-python http://stackoverflow.com/questions/16694907/download-large-file-requests GracefulInterruptHandler Ignore: import signal import sys def signal_handler(signal, frame): ...
[ "r", "References", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "1112343", "/", "capture", "-", "sigint", "-", "in", "-", "python", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "16694907", "/", "...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L429-L500
train
r Downloads the large file requests from the given list of URLs.
Erotemic/utool
utool/util_grabdata.py
clean_dropbox_link
def clean_dropbox_link(dropbox_url): """ Dropbox links should be en-mass downloaed from dl.dropbox DEPRICATE? Example: >>> # ENABLE_DOCTEST >>> from utool.util_grabdata import * # NOQA >>> dropbox_url = 'www.dropbox.com/s/123456789abcdef/foobar.zip?dl=0' >>> cleaned_ur...
python
def clean_dropbox_link(dropbox_url): """ Dropbox links should be en-mass downloaed from dl.dropbox DEPRICATE? Example: >>> # ENABLE_DOCTEST >>> from utool.util_grabdata import * # NOQA >>> dropbox_url = 'www.dropbox.com/s/123456789abcdef/foobar.zip?dl=0' >>> cleaned_ur...
[ "def", "clean_dropbox_link", "(", "dropbox_url", ")", ":", "cleaned_url", "=", "dropbox_url", ".", "replace", "(", "'www.dropbox'", ",", "'dl.dropbox'", ")", "postfix_list", "=", "[", "'?dl=0'", "]", "for", "postfix", "in", "postfix_list", ":", "if", "cleaned_ur...
Dropbox links should be en-mass downloaed from dl.dropbox DEPRICATE? Example: >>> # ENABLE_DOCTEST >>> from utool.util_grabdata import * # NOQA >>> dropbox_url = 'www.dropbox.com/s/123456789abcdef/foobar.zip?dl=0' >>> cleaned_url = clean_dropbox_link(dropbox_url) >>> r...
[ "Dropbox", "links", "should", "be", "en", "-", "mass", "downloaed", "from", "dl", ".", "dropbox" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L503-L526
train
Clean up the dropbox link
Erotemic/utool
utool/util_grabdata.py
grab_selenium_chromedriver
def grab_selenium_chromedriver(redownload=False): r""" Automatically download selenium chrome driver if needed CommandLine: python -m utool.util_grabdata --test-grab_selenium_chromedriver:1 Example: >>> # DISABLE_DOCTEST >>> ut.grab_selenium_chromedriver() >>> import se...
python
def grab_selenium_chromedriver(redownload=False): r""" Automatically download selenium chrome driver if needed CommandLine: python -m utool.util_grabdata --test-grab_selenium_chromedriver:1 Example: >>> # DISABLE_DOCTEST >>> ut.grab_selenium_chromedriver() >>> import se...
[ "def", "grab_selenium_chromedriver", "(", "redownload", "=", "False", ")", ":", "import", "utool", "as", "ut", "import", "os", "import", "stat", "# TODO: use a better download dir (but it must be in the PATh or selenium freaks out)", "chromedriver_dpath", "=", "ut", ".", "e...
r""" Automatically download selenium chrome driver if needed CommandLine: python -m utool.util_grabdata --test-grab_selenium_chromedriver:1 Example: >>> # DISABLE_DOCTEST >>> ut.grab_selenium_chromedriver() >>> import selenium.webdriver >>> driver = selenium.webdriv...
[ "r", "Automatically", "download", "selenium", "chrome", "driver", "if", "needed" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L627-L675
train
r Grab the selenium chrome driver if needed
Erotemic/utool
utool/util_grabdata.py
grab_selenium_driver
def grab_selenium_driver(driver_name=None): """ pip install selenium -U """ from selenium import webdriver if driver_name is None: driver_name = 'firefox' if driver_name.lower() == 'chrome': grab_selenium_chromedriver() return webdriver.Chrome() elif driver_name.lower...
python
def grab_selenium_driver(driver_name=None): """ pip install selenium -U """ from selenium import webdriver if driver_name is None: driver_name = 'firefox' if driver_name.lower() == 'chrome': grab_selenium_chromedriver() return webdriver.Chrome() elif driver_name.lower...
[ "def", "grab_selenium_driver", "(", "driver_name", "=", "None", ")", ":", "from", "selenium", "import", "webdriver", "if", "driver_name", "is", "None", ":", "driver_name", "=", "'firefox'", "if", "driver_name", ".", "lower", "(", ")", "==", "'chrome'", ":", ...
pip install selenium -U
[ "pip", "install", "selenium", "-", "U" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L678-L692
train
Returns a Selenium driver object.
Erotemic/utool
utool/util_grabdata.py
grab_file_url
def grab_file_url(file_url, appname='utool', download_dir=None, delay=None, spoof=False, fname=None, verbose=True, redownload=False, check_hash=False): r""" Downloads a file and returns the local path of the file. The resulting file is cached, so multiple calls to this f...
python
def grab_file_url(file_url, appname='utool', download_dir=None, delay=None, spoof=False, fname=None, verbose=True, redownload=False, check_hash=False): r""" Downloads a file and returns the local path of the file. The resulting file is cached, so multiple calls to this f...
[ "def", "grab_file_url", "(", "file_url", ",", "appname", "=", "'utool'", ",", "download_dir", "=", "None", ",", "delay", "=", "None", ",", "spoof", "=", "False", ",", "fname", "=", "None", ",", "verbose", "=", "True", ",", "redownload", "=", "False", "...
r""" Downloads a file and returns the local path of the file. The resulting file is cached, so multiple calls to this function do not result in multiple dowloads. Args: file_url (str): url to the file appname (str): (default = 'utool') download_dir custom directory (None): (def...
[ "r", "Downloads", "a", "file", "and", "returns", "the", "local", "path", "of", "the", "file", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L782-L905
train
r Downloads a file and returns the local path of the file.
Erotemic/utool
utool/util_grabdata.py
grab_zipped_url
def grab_zipped_url(zipped_url, ensure=True, appname='utool', download_dir=None, force_commonprefix=True, cleanup=False, redownload=False, spoof=False): r""" downloads and unzips the url Args: zipped_url (str): url which must be either a .zip of a .tar.gz fil...
python
def grab_zipped_url(zipped_url, ensure=True, appname='utool', download_dir=None, force_commonprefix=True, cleanup=False, redownload=False, spoof=False): r""" downloads and unzips the url Args: zipped_url (str): url which must be either a .zip of a .tar.gz fil...
[ "def", "grab_zipped_url", "(", "zipped_url", ",", "ensure", "=", "True", ",", "appname", "=", "'utool'", ",", "download_dir", "=", "None", ",", "force_commonprefix", "=", "True", ",", "cleanup", "=", "False", ",", "redownload", "=", "False", ",", "spoof", ...
r""" downloads and unzips the url Args: zipped_url (str): url which must be either a .zip of a .tar.gz file ensure (bool): eager evaluation if True(default = True) appname (str): (default = 'utool') download_dir (str): containing downloading directory force_commonprefix...
[ "r", "downloads", "and", "unzips", "the", "url" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L908-L974
train
r Grab a zipped version of a url and returns a utool. dict
Erotemic/utool
utool/util_grabdata.py
scp_pull
def scp_pull(remote_path, local_path='.', remote='localhost', user=None): r""" wrapper for scp """ import utool as ut if user is not None: remote_uri = user + '@' + remote + ':' + remote_path else: remote_uri = remote + ':' + remote_path scp_exe = 'scp' scp_args = (scp_exe, '-r',...
python
def scp_pull(remote_path, local_path='.', remote='localhost', user=None): r""" wrapper for scp """ import utool as ut if user is not None: remote_uri = user + '@' + remote + ':' + remote_path else: remote_uri = remote + ':' + remote_path scp_exe = 'scp' scp_args = (scp_exe, '-r',...
[ "def", "scp_pull", "(", "remote_path", ",", "local_path", "=", "'.'", ",", "remote", "=", "'localhost'", ",", "user", "=", "None", ")", ":", "import", "utool", "as", "ut", "if", "user", "is", "not", "None", ":", "remote_uri", "=", "user", "+", "'@'", ...
r""" wrapper for scp
[ "r", "wrapper", "for", "scp" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L1123-L1132
train
r wrapper for scp
Erotemic/utool
utool/util_grabdata.py
list_remote
def list_remote(remote_uri, verbose=False): """ remote_uri = 'user@xx.xx.xx.xx' """ remote_uri1, remote_dpath = remote_uri.split(':') if not remote_dpath: remote_dpath = '.' import utool as ut out = ut.cmd('ssh', remote_uri1, 'ls -l %s' % (remote_dpath,), verbose=verbose) import ...
python
def list_remote(remote_uri, verbose=False): """ remote_uri = 'user@xx.xx.xx.xx' """ remote_uri1, remote_dpath = remote_uri.split(':') if not remote_dpath: remote_dpath = '.' import utool as ut out = ut.cmd('ssh', remote_uri1, 'ls -l %s' % (remote_dpath,), verbose=verbose) import ...
[ "def", "list_remote", "(", "remote_uri", ",", "verbose", "=", "False", ")", ":", "remote_uri1", ",", "remote_dpath", "=", "remote_uri", ".", "split", "(", "':'", ")", "if", "not", "remote_dpath", ":", "remote_dpath", "=", "'.'", "import", "utool", "as", "u...
remote_uri = 'user@xx.xx.xx.xx'
[ "remote_uri", "=", "user" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L1135-L1148
train
List remote user s content
Erotemic/utool
utool/util_grabdata.py
rsync
def rsync(src_uri, dst_uri, exclude_dirs=[], port=22, dryrun=False): r""" Wrapper for rsync General function to push or pull a directory from a remote server to a local path Args: src_uri (str): dst_uri (str): exclude_dirs (list): (default = []) port (int): (default...
python
def rsync(src_uri, dst_uri, exclude_dirs=[], port=22, dryrun=False): r""" Wrapper for rsync General function to push or pull a directory from a remote server to a local path Args: src_uri (str): dst_uri (str): exclude_dirs (list): (default = []) port (int): (default...
[ "def", "rsync", "(", "src_uri", ",", "dst_uri", ",", "exclude_dirs", "=", "[", "]", ",", "port", "=", "22", ",", "dryrun", "=", "False", ")", ":", "from", "utool", "import", "util_cplat", "rsync_exe", "=", "'rsync'", "rsync_options", "=", "'-avhzP'", "#r...
r""" Wrapper for rsync General function to push or pull a directory from a remote server to a local path Args: src_uri (str): dst_uri (str): exclude_dirs (list): (default = []) port (int): (default = 22) dryrun (bool): (default = False) References: ...
[ "r", "Wrapper", "for", "rsync" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L1151-L1214
train
r Wrapper for rsync