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
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/network.py
Network.set_up_network
def set_up_network( self, genes: List[Gene], gene_filter: bool = False, disease_associations: Optional[Dict] = None ) -> None: """Set up the network. Filter genes out if requested and add attributes to the vertices. :param genes: A list of G...
python
def set_up_network( self, genes: List[Gene], gene_filter: bool = False, disease_associations: Optional[Dict] = None ) -> None: """Set up the network. Filter genes out if requested and add attributes to the vertices. :param genes: A list of G...
[ "def", "set_up_network", "(", "self", ",", "genes", ":", "List", "[", "Gene", "]", ",", "gene_filter", ":", "bool", "=", "False", ",", "disease_associations", ":", "Optional", "[", "Dict", "]", "=", "None", ")", "->", "None", ":", "if", "gene_filter", ...
Set up the network. Filter genes out if requested and add attributes to the vertices. :param genes: A list of Gene objects. :param gene_filter: Removes all genes that are not in list <genes> if True. :param disease_associations: Diseases associated with genes.
[ "Set", "up", "the", "network", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/network.py#L38-L55
train
Set up the network.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/network.py
Network.filter_genes
def filter_genes(self, relevant_entrez: list) -> None: """Filter out the genes that are not in list relevant_entrez. :param list relevant_entrez: Entrez IDs of genes which are to be kept. """ logger.info("In filter_genes()") irrelevant_genes = self.graph.vs.select(name_notin=rel...
python
def filter_genes(self, relevant_entrez: list) -> None: """Filter out the genes that are not in list relevant_entrez. :param list relevant_entrez: Entrez IDs of genes which are to be kept. """ logger.info("In filter_genes()") irrelevant_genes = self.graph.vs.select(name_notin=rel...
[ "def", "filter_genes", "(", "self", ",", "relevant_entrez", ":", "list", ")", "->", "None", ":", "logger", ".", "info", "(", "\"In filter_genes()\"", ")", "irrelevant_genes", "=", "self", ".", "graph", ".", "vs", ".", "select", "(", "name_notin", "=", "rel...
Filter out the genes that are not in list relevant_entrez. :param list relevant_entrez: Entrez IDs of genes which are to be kept.
[ "Filter", "out", "the", "genes", "that", "are", "not", "in", "list", "relevant_entrez", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/network.py#L57-L64
train
Filter out the genes that are not in list relevant_entrez.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/network.py
Network._add_vertex_attributes
def _add_vertex_attributes(self, genes: List[Gene], disease_associations: Optional[dict] = None) -> None: """Add attributes to vertices. :param genes: A list of genes containing attribute information. """ self._set_default_vertex_attributes() self....
python
def _add_vertex_attributes(self, genes: List[Gene], disease_associations: Optional[dict] = None) -> None: """Add attributes to vertices. :param genes: A list of genes containing attribute information. """ self._set_default_vertex_attributes() self....
[ "def", "_add_vertex_attributes", "(", "self", ",", "genes", ":", "List", "[", "Gene", "]", ",", "disease_associations", ":", "Optional", "[", "dict", "]", "=", "None", ")", "->", "None", ":", "self", ".", "_set_default_vertex_attributes", "(", ")", "self", ...
Add attributes to vertices. :param genes: A list of genes containing attribute information.
[ "Add", "attributes", "to", "vertices", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/network.py#L66-L89
train
Add attributes to vertices.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/network.py
Network._set_default_vertex_attributes
def _set_default_vertex_attributes(self) -> None: """Assign default values on attributes to all vertices.""" self.graph.vs["l2fc"] = 0 self.graph.vs["padj"] = 0.5 self.graph.vs["symbol"] = self.graph.vs["name"] self.graph.vs["diff_expressed"] = False self.graph.vs["up_reg...
python
def _set_default_vertex_attributes(self) -> None: """Assign default values on attributes to all vertices.""" self.graph.vs["l2fc"] = 0 self.graph.vs["padj"] = 0.5 self.graph.vs["symbol"] = self.graph.vs["name"] self.graph.vs["diff_expressed"] = False self.graph.vs["up_reg...
[ "def", "_set_default_vertex_attributes", "(", "self", ")", "->", "None", ":", "self", ".", "graph", ".", "vs", "[", "\"l2fc\"", "]", "=", "0", "self", ".", "graph", ".", "vs", "[", "\"padj\"", "]", "=", "0.5", "self", ".", "graph", ".", "vs", "[", ...
Assign default values on attributes to all vertices.
[ "Assign", "default", "values", "on", "attributes", "to", "all", "vertices", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/network.py#L91-L98
train
Assign default values on attributes to all vertices.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/network.py
Network._add_vertex_attributes_by_genes
def _add_vertex_attributes_by_genes(self, genes: List[Gene]) -> None: """Assign values to attributes on vertices. :param genes: A list of Gene objects from which values will be extracted. """ for gene in genes: try: vertex = self.graph.vs.find(name=str(gene.e...
python
def _add_vertex_attributes_by_genes(self, genes: List[Gene]) -> None: """Assign values to attributes on vertices. :param genes: A list of Gene objects from which values will be extracted. """ for gene in genes: try: vertex = self.graph.vs.find(name=str(gene.e...
[ "def", "_add_vertex_attributes_by_genes", "(", "self", ",", "genes", ":", "List", "[", "Gene", "]", ")", "->", "None", ":", "for", "gene", "in", "genes", ":", "try", ":", "vertex", "=", "self", ".", "graph", ".", "vs", ".", "find", "(", "name", "=", ...
Assign values to attributes on vertices. :param genes: A list of Gene objects from which values will be extracted.
[ "Assign", "values", "to", "attributes", "on", "vertices", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/network.py#L100-L112
train
Assign values to attributes on vertices.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/network.py
Network._add_disease_associations
def _add_disease_associations(self, disease_associations: dict) -> None: """Add disease association annotation to the network. :param disease_associations: Dictionary of disease-gene associations. """ if disease_associations is not None: for target_id, disease_id_list in dis...
python
def _add_disease_associations(self, disease_associations: dict) -> None: """Add disease association annotation to the network. :param disease_associations: Dictionary of disease-gene associations. """ if disease_associations is not None: for target_id, disease_id_list in dis...
[ "def", "_add_disease_associations", "(", "self", ",", "disease_associations", ":", "dict", ")", "->", "None", ":", "if", "disease_associations", "is", "not", "None", ":", "for", "target_id", ",", "disease_id_list", "in", "disease_associations", ".", "items", "(", ...
Add disease association annotation to the network. :param disease_associations: Dictionary of disease-gene associations.
[ "Add", "disease", "association", "annotation", "to", "the", "network", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/network.py#L114-L122
train
Add the disease - gene associations to the network.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/network.py
Network.get_upregulated_genes
def get_upregulated_genes(self) -> VertexSeq: """Get genes that are up-regulated. :return: Up-regulated genes. """ up_regulated = self.graph.vs.select(self._is_upregulated_gene) logger.info(f"No. of up-regulated genes after laying on network: {len(up_regulated)}") return...
python
def get_upregulated_genes(self) -> VertexSeq: """Get genes that are up-regulated. :return: Up-regulated genes. """ up_regulated = self.graph.vs.select(self._is_upregulated_gene) logger.info(f"No. of up-regulated genes after laying on network: {len(up_regulated)}") return...
[ "def", "get_upregulated_genes", "(", "self", ")", "->", "VertexSeq", ":", "up_regulated", "=", "self", ".", "graph", ".", "vs", ".", "select", "(", "self", ".", "_is_upregulated_gene", ")", "logger", ".", "info", "(", "f\"No. of up-regulated genes after laying on ...
Get genes that are up-regulated. :return: Up-regulated genes.
[ "Get", "genes", "that", "are", "up", "-", "regulated", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/network.py#L124-L131
train
Get genes that are up - regulated.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/network.py
Network.get_downregulated_genes
def get_downregulated_genes(self) -> VertexSeq: """Get genes that are down-regulated. :return: Down-regulated genes. """ down_regulated = self.graph.vs.select(self._is_downregulated_gene) logger.info(f"No. of down-regulated genes after laying on network: {len(down_regulated)}") ...
python
def get_downregulated_genes(self) -> VertexSeq: """Get genes that are down-regulated. :return: Down-regulated genes. """ down_regulated = self.graph.vs.select(self._is_downregulated_gene) logger.info(f"No. of down-regulated genes after laying on network: {len(down_regulated)}") ...
[ "def", "get_downregulated_genes", "(", "self", ")", "->", "VertexSeq", ":", "down_regulated", "=", "self", ".", "graph", ".", "vs", ".", "select", "(", "self", ".", "_is_downregulated_gene", ")", "logger", ".", "info", "(", "f\"No. of down-regulated genes after la...
Get genes that are down-regulated. :return: Down-regulated genes.
[ "Get", "genes", "that", "are", "down", "-", "regulated", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/network.py#L133-L140
train
Get genes that are down - regulated.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/network.py
Network.print_summary
def print_summary(self, heading: str) -> None: """Print the summary of a graph. :param str heading: Title of the graph. """ logger.info(heading) logger.info("Number of nodes: {}".format(len(self.graph.vs))) logger.info("Number of edges: {}".format(len(self.graph.es)))
python
def print_summary(self, heading: str) -> None: """Print the summary of a graph. :param str heading: Title of the graph. """ logger.info(heading) logger.info("Number of nodes: {}".format(len(self.graph.vs))) logger.info("Number of edges: {}".format(len(self.graph.es)))
[ "def", "print_summary", "(", "self", ",", "heading", ":", "str", ")", "->", "None", ":", "logger", ".", "info", "(", "heading", ")", "logger", ".", "info", "(", "\"Number of nodes: {}\"", ".", "format", "(", "len", "(", "self", ".", "graph", ".", "vs",...
Print the summary of a graph. :param str heading: Title of the graph.
[ "Print", "the", "summary", "of", "a", "graph", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/network.py#L151-L158
train
Print the summary of a graph.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/network.py
Network.get_differentially_expressed_genes
def get_differentially_expressed_genes(self, diff_type: str) -> VertexSeq: """Get the differentially expressed genes based on diff_type. :param str diff_type: Differential expression type chosen by the user; all, down, or up. :return list: A list of differentially expressed genes. """ ...
python
def get_differentially_expressed_genes(self, diff_type: str) -> VertexSeq: """Get the differentially expressed genes based on diff_type. :param str diff_type: Differential expression type chosen by the user; all, down, or up. :return list: A list of differentially expressed genes. """ ...
[ "def", "get_differentially_expressed_genes", "(", "self", ",", "diff_type", ":", "str", ")", "->", "VertexSeq", ":", "if", "diff_type", "==", "\"up\"", ":", "diff_expr", "=", "self", ".", "graph", ".", "vs", ".", "select", "(", "up_regulated_eq", "=", "True"...
Get the differentially expressed genes based on diff_type. :param str diff_type: Differential expression type chosen by the user; all, down, or up. :return list: A list of differentially expressed genes.
[ "Get", "the", "differentially", "expressed", "genes", "based", "on", "diff_type", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/network.py#L160-L172
train
Get the differentially expressed genes based on diff_type.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/network.py
Network.write_adj_list
def write_adj_list(self, path: str) -> None: """Write the network as an adjacency list to a file. :param path: File path to write the adjacency list. """ adj_list = self.get_adjlist() with open(path, mode="w") as file: for i, line in enumerate(adj_list): ...
python
def write_adj_list(self, path: str) -> None: """Write the network as an adjacency list to a file. :param path: File path to write the adjacency list. """ adj_list = self.get_adjlist() with open(path, mode="w") as file: for i, line in enumerate(adj_list): ...
[ "def", "write_adj_list", "(", "self", ",", "path", ":", "str", ")", "->", "None", ":", "adj_list", "=", "self", ".", "get_adjlist", "(", ")", "with", "open", "(", "path", ",", "mode", "=", "\"w\"", ")", "as", "file", ":", "for", "i", ",", "line", ...
Write the network as an adjacency list to a file. :param path: File path to write the adjacency list.
[ "Write", "the", "network", "as", "an", "adjacency", "list", "to", "a", "file", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/network.py#L174-L183
train
Write the network as an adjacency list to a file.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/network.py
Network.get_attribute_from_indices
def get_attribute_from_indices(self, indices: list, attribute_name: str): """Get attribute values for the requested indices. :param indices: Indices of vertices for which the attribute values are requested. :param attribute_name: The name of the attribute. :return: A list of attribute v...
python
def get_attribute_from_indices(self, indices: list, attribute_name: str): """Get attribute values for the requested indices. :param indices: Indices of vertices for which the attribute values are requested. :param attribute_name: The name of the attribute. :return: A list of attribute v...
[ "def", "get_attribute_from_indices", "(", "self", ",", "indices", ":", "list", ",", "attribute_name", ":", "str", ")", ":", "return", "list", "(", "np", ".", "array", "(", "self", ".", "graph", ".", "vs", "[", "attribute_name", "]", ")", "[", "indices", ...
Get attribute values for the requested indices. :param indices: Indices of vertices for which the attribute values are requested. :param attribute_name: The name of the attribute. :return: A list of attribute values for the requested indices.
[ "Get", "attribute", "values", "for", "the", "requested", "indices", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/network.py#L192-L199
train
Get the attribute values for the requested indices.
rsgalloway/grit
grit/server/cherrypy/__init__.py
plat_specific_errors
def plat_specific_errors(*errnames): """Return error numbers for all errors in errnames on this platform. The 'errno' module contains different global constants depending on the specific platform (OS). This function will return the list of numeric values for a given list of potential names. """...
python
def plat_specific_errors(*errnames): """Return error numbers for all errors in errnames on this platform. The 'errno' module contains different global constants depending on the specific platform (OS). This function will return the list of numeric values for a given list of potential names. """...
[ "def", "plat_specific_errors", "(", "*", "errnames", ")", ":", "errno_names", "=", "dir", "(", "errno", ")", "nums", "=", "[", "getattr", "(", "errno", ",", "k", ")", "for", "k", "in", "errnames", "if", "k", "in", "errno_names", "]", "# de-dupe the list"...
Return error numbers for all errors in errnames on this platform. The 'errno' module contains different global constants depending on the specific platform (OS). This function will return the list of numeric values for a given list of potential names.
[ "Return", "error", "numbers", "for", "all", "errors", "in", "errnames", "on", "this", "platform", ".", "The", "errno", "module", "contains", "different", "global", "constants", "depending", "on", "the", "specific", "platform", "(", "OS", ")", ".", "This", "f...
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L98-L108
train
Return error numbers for all errors in errnames on this platform.
rsgalloway/grit
grit/server/cherrypy/__init__.py
read_headers
def read_headers(rfile, hdict=None): """Read headers from the given stream into the given header dict. If hdict is None, a new header dict is created. Returns the populated header dict. Headers which are repeated are folded together using a comma if their specification so dictates. ...
python
def read_headers(rfile, hdict=None): """Read headers from the given stream into the given header dict. If hdict is None, a new header dict is created. Returns the populated header dict. Headers which are repeated are folded together using a comma if their specification so dictates. ...
[ "def", "read_headers", "(", "rfile", ",", "hdict", "=", "None", ")", ":", "if", "hdict", "is", "None", ":", "hdict", "=", "{", "}", "while", "True", ":", "line", "=", "rfile", ".", "readline", "(", ")", "if", "not", "line", ":", "# No more data--ille...
Read headers from the given stream into the given header dict. If hdict is None, a new header dict is created. Returns the populated header dict. Headers which are repeated are folded together using a comma if their specification so dictates. This function raises ValueError when the r...
[ "Read", "headers", "from", "the", "given", "stream", "into", "the", "given", "header", "dict", ".", "If", "hdict", "is", "None", "a", "new", "header", "dict", "is", "created", ".", "Returns", "the", "populated", "header", "dict", ".", "Headers", "which", ...
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L137-L183
train
Read headers from the given stream into the given header dict.
rsgalloway/grit
grit/server/cherrypy/__init__.py
format_exc
def format_exc(limit=None): """Like print_exc() but return a string. Backport for Python 2.3.""" try: etype, value, tb = sys.exc_info() return ''.join(traceback.format_exception(etype, value, tb, limit)) finally: etype = value = tb = None
python
def format_exc(limit=None): """Like print_exc() but return a string. Backport for Python 2.3.""" try: etype, value, tb = sys.exc_info() return ''.join(traceback.format_exception(etype, value, tb, limit)) finally: etype = value = tb = None
[ "def", "format_exc", "(", "limit", "=", "None", ")", ":", "try", ":", "etype", ",", "value", ",", "tb", "=", "sys", ".", "exc_info", "(", ")", "return", "''", ".", "join", "(", "traceback", ".", "format_exception", "(", "etype", ",", "value", ",", ...
Like print_exc() but return a string. Backport for Python 2.3.
[ "Like", "print_exc", "()", "but", "return", "a", "string", ".", "Backport", "for", "Python", "2", ".", "3", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L1327-L1333
train
Like print_exc but return a string. Backport for Python 2. 3.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPRequest.parse_request
def parse_request(self): """Parse the next HTTP request start-line and message-headers.""" self.rfile = SizeCheckWrapper(self.conn.rfile, self.server.max_request_header_size) try: self.read_request_line() except MaxSizeExceeded: ...
python
def parse_request(self): """Parse the next HTTP request start-line and message-headers.""" self.rfile = SizeCheckWrapper(self.conn.rfile, self.server.max_request_header_size) try: self.read_request_line() except MaxSizeExceeded: ...
[ "def", "parse_request", "(", "self", ")", ":", "self", ".", "rfile", "=", "SizeCheckWrapper", "(", "self", ".", "conn", ".", "rfile", ",", "self", ".", "server", ".", "max_request_header_size", ")", "try", ":", "self", ".", "read_request_line", "(", ")", ...
Parse the next HTTP request start-line and message-headers.
[ "Parse", "the", "next", "HTTP", "request", "start", "-", "line", "and", "message", "-", "headers", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L513-L536
train
Parse the next HTTP request start - line and message - headers.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPRequest.read_request_headers
def read_request_headers(self): """Read self.rfile into self.inheaders. Return success.""" # then all the http headers try: read_headers(self.rfile, self.inheaders) except ValueError, ex: self.simple_response("400 Bad Request", ex.args[0]) ret...
python
def read_request_headers(self): """Read self.rfile into self.inheaders. Return success.""" # then all the http headers try: read_headers(self.rfile, self.inheaders) except ValueError, ex: self.simple_response("400 Bad Request", ex.args[0]) ret...
[ "def", "read_request_headers", "(", "self", ")", ":", "# then all the http headers", "try", ":", "read_headers", "(", "self", ".", "rfile", ",", "self", ".", "inheaders", ")", "except", "ValueError", ",", "ex", ":", "self", ".", "simple_response", "(", "\"400 ...
Read self.rfile into self.inheaders. Return success.
[ "Read", "self", ".", "rfile", "into", "self", ".", "inheaders", ".", "Return", "success", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L633-L706
train
Read the HTTP headers into the internal inheaders. Return success.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPRequest.parse_request_uri
def parse_request_uri(self, uri): """Parse a Request-URI into (scheme, authority, path). Note that Request-URI's must be one of:: Request-URI = "*" | absoluteURI | abs_path | authority Therefore, a Request-URI which starts with a double forward-slash...
python
def parse_request_uri(self, uri): """Parse a Request-URI into (scheme, authority, path). Note that Request-URI's must be one of:: Request-URI = "*" | absoluteURI | abs_path | authority Therefore, a Request-URI which starts with a double forward-slash...
[ "def", "parse_request_uri", "(", "self", ",", "uri", ")", ":", "if", "uri", "==", "\"*\"", ":", "return", "None", ",", "None", ",", "uri", "i", "=", "uri", ".", "find", "(", "'://'", ")", "if", "i", ">", "0", "and", "'?'", "not", "in", "uri", "...
Parse a Request-URI into (scheme, authority, path). Note that Request-URI's must be one of:: Request-URI = "*" | absoluteURI | abs_path | authority Therefore, a Request-URI which starts with a double forward-slash cannot be a "net_path":: ...
[ "Parse", "a", "Request", "-", "URI", "into", "(", "scheme", "authority", "path", ")", ".", "Note", "that", "Request", "-", "URI", "s", "must", "be", "one", "of", "::", "Request", "-", "URI", "=", "*", "|", "absoluteURI", "|", "abs_path", "|", "author...
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L708-L745
train
Parse a Request - URI into scheme authority path and paramaters.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPRequest.respond
def respond(self): """Call the gateway and write its iterable output.""" mrbs = self.server.max_request_body_size if self.chunked_read: self.rfile = ChunkedRFile(self.conn.rfile, mrbs) else: cl = int(self.inheaders.get("Content-Length", 0)) if mrbs and...
python
def respond(self): """Call the gateway and write its iterable output.""" mrbs = self.server.max_request_body_size if self.chunked_read: self.rfile = ChunkedRFile(self.conn.rfile, mrbs) else: cl = int(self.inheaders.get("Content-Length", 0)) if mrbs and...
[ "def", "respond", "(", "self", ")", ":", "mrbs", "=", "self", ".", "server", ".", "max_request_body_size", "if", "self", ".", "chunked_read", ":", "self", ".", "rfile", "=", "ChunkedRFile", "(", "self", ".", "conn", ".", "rfile", ",", "mrbs", ")", "els...
Call the gateway and write its iterable output.
[ "Call", "the", "gateway", "and", "write", "its", "iterable", "output", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L747-L768
train
Call the gateway and write its iterable output.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPRequest.simple_response
def simple_response(self, status, msg=""): """Write a simple response back to the client.""" status = str(status) buf = [self.server.protocol + " " + status + CRLF, "Content-Length: %s\r\n" % len(msg), "Content-Type: text/plain\r\n"] ...
python
def simple_response(self, status, msg=""): """Write a simple response back to the client.""" status = str(status) buf = [self.server.protocol + " " + status + CRLF, "Content-Length: %s\r\n" % len(msg), "Content-Type: text/plain\r\n"] ...
[ "def", "simple_response", "(", "self", ",", "status", ",", "msg", "=", "\"\"", ")", ":", "status", "=", "str", "(", "status", ")", "buf", "=", "[", "self", ".", "server", ".", "protocol", "+", "\" \"", "+", "status", "+", "CRLF", ",", "\"Content-Leng...
Write a simple response back to the client.
[ "Write", "a", "simple", "response", "back", "to", "the", "client", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L770-L801
train
Write a simple response back to the client.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPRequest.write
def write(self, chunk): """Write unbuffered data to the client.""" if self.chunked_write and chunk: buf = [hex(len(chunk))[2:], CRLF, chunk, CRLF] self.conn.wfile.sendall("".join(buf)) else: self.conn.wfile.sendall(chunk)
python
def write(self, chunk): """Write unbuffered data to the client.""" if self.chunked_write and chunk: buf = [hex(len(chunk))[2:], CRLF, chunk, CRLF] self.conn.wfile.sendall("".join(buf)) else: self.conn.wfile.sendall(chunk)
[ "def", "write", "(", "self", ",", "chunk", ")", ":", "if", "self", ".", "chunked_write", "and", "chunk", ":", "buf", "=", "[", "hex", "(", "len", "(", "chunk", ")", ")", "[", "2", ":", "]", ",", "CRLF", ",", "chunk", ",", "CRLF", "]", "self", ...
Write unbuffered data to the client.
[ "Write", "unbuffered", "data", "to", "the", "client", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L803-L809
train
Write unbuffered data to the client.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPRequest.send_headers
def send_headers(self): """Assert, process, and send the HTTP response message-headers. You must set self.status, and self.outheaders before calling this. """ hkeys = [key.lower() for key, value in self.outheaders] status = int(self.status[:3]) if status...
python
def send_headers(self): """Assert, process, and send the HTTP response message-headers. You must set self.status, and self.outheaders before calling this. """ hkeys = [key.lower() for key, value in self.outheaders] status = int(self.status[:3]) if status...
[ "def", "send_headers", "(", "self", ")", ":", "hkeys", "=", "[", "key", ".", "lower", "(", ")", "for", "key", ",", "value", "in", "self", ".", "outheaders", "]", "status", "=", "int", "(", "self", ".", "status", "[", ":", "3", "]", ")", "if", "...
Assert, process, and send the HTTP response message-headers. You must set self.status, and self.outheaders before calling this.
[ "Assert", "process", "and", "send", "the", "HTTP", "response", "message", "-", "headers", ".", "You", "must", "set", "self", ".", "status", "and", "self", ".", "outheaders", "before", "calling", "this", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L811-L875
train
Assert process and send the HTTP response message - headers.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPConnection.communicate
def communicate(self): """Read each request and respond appropriately.""" request_seen = False try: while True: # (re)set req to None so that if something goes wrong in # the RequestHandlerClass constructor, the error doesn't # get writ...
python
def communicate(self): """Read each request and respond appropriately.""" request_seen = False try: while True: # (re)set req to None so that if something goes wrong in # the RequestHandlerClass constructor, the error doesn't # get writ...
[ "def", "communicate", "(", "self", ")", ":", "request_seen", "=", "False", "try", ":", "while", "True", ":", "# (re)set req to None so that if something goes wrong in", "# the RequestHandlerClass constructor, the error doesn't", "# get written to the previous request.", "req", "=...
Read each request and respond appropriately.
[ "Read", "each", "request", "and", "respond", "appropriately", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L1232-L1300
train
Read each request and respond appropriately.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPConnection.close
def close(self): """Close the socket underlying this connection.""" self.rfile.close() if not self.linger: # Python's socket module does NOT call close on the kernel socket # when you call socket.close(). We do so manually here because we # want this ...
python
def close(self): """Close the socket underlying this connection.""" self.rfile.close() if not self.linger: # Python's socket module does NOT call close on the kernel socket # when you call socket.close(). We do so manually here because we # want this ...
[ "def", "close", "(", "self", ")", ":", "self", ".", "rfile", ".", "close", "(", ")", "if", "not", "self", ".", "linger", ":", "# Python's socket module does NOT call close on the kernel socket", "# when you call socket.close(). We do so manually here because we", "# want th...
Close the socket underlying this connection.
[ "Close", "the", "socket", "underlying", "this", "connection", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L1304-L1324
train
Close the socket underlying this connection.
rsgalloway/grit
grit/server/cherrypy/__init__.py
ThreadPool.start
def start(self): """Start the pool of threads.""" for i in range(self.min): self._threads.append(WorkerThread(self.server)) for worker in self._threads: worker.setName("CP Server " + worker.getName()) worker.start() for worker in self._threads: ...
python
def start(self): """Start the pool of threads.""" for i in range(self.min): self._threads.append(WorkerThread(self.server)) for worker in self._threads: worker.setName("CP Server " + worker.getName()) worker.start() for worker in self._threads: ...
[ "def", "start", "(", "self", ")", ":", "for", "i", "in", "range", "(", "self", ".", "min", ")", ":", "self", ".", "_threads", ".", "append", "(", "WorkerThread", "(", "self", ".", "server", ")", ")", "for", "worker", "in", "self", ".", "_threads", ...
Start the pool of threads.
[ "Start", "the", "pool", "of", "threads", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L1397-L1406
train
Start the pool of threads.
rsgalloway/grit
grit/server/cherrypy/__init__.py
ThreadPool.grow
def grow(self, amount): """Spawn new worker threads (not above self.max).""" for i in range(amount): if self.max > 0 and len(self._threads) >= self.max: break worker = WorkerThread(self.server) worker.setName("CP Server " + worker.getName()) ...
python
def grow(self, amount): """Spawn new worker threads (not above self.max).""" for i in range(amount): if self.max > 0 and len(self._threads) >= self.max: break worker = WorkerThread(self.server) worker.setName("CP Server " + worker.getName()) ...
[ "def", "grow", "(", "self", ",", "amount", ")", ":", "for", "i", "in", "range", "(", "amount", ")", ":", "if", "self", ".", "max", ">", "0", "and", "len", "(", "self", ".", "_threads", ")", ">=", "self", ".", "max", ":", "break", "worker", "=",...
Spawn new worker threads (not above self.max).
[ "Spawn", "new", "worker", "threads", "(", "not", "above", "self", ".", "max", ")", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L1418-L1426
train
Grow the pool of worker threads.
rsgalloway/grit
grit/server/cherrypy/__init__.py
ThreadPool.shrink
def shrink(self, amount): """Kill off worker threads (not below self.min).""" # Grow/shrink the pool if necessary. # Remove any dead threads from our list for t in self._threads: if not t.isAlive(): self._threads.remove(t) amount -= 1 ...
python
def shrink(self, amount): """Kill off worker threads (not below self.min).""" # Grow/shrink the pool if necessary. # Remove any dead threads from our list for t in self._threads: if not t.isAlive(): self._threads.remove(t) amount -= 1 ...
[ "def", "shrink", "(", "self", ",", "amount", ")", ":", "# Grow/shrink the pool if necessary.", "# Remove any dead threads from our list", "for", "t", "in", "self", ".", "_threads", ":", "if", "not", "t", ".", "isAlive", "(", ")", ":", "self", ".", "_threads", ...
Kill off worker threads (not below self.min).
[ "Kill", "off", "worker", "threads", "(", "not", "below", "self", ".", "min", ")", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L1428-L1443
train
Kills off worker threads and shrinks the pool.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPServer.start
def start(self): """Run the server forever.""" # We don't have to trap KeyboardInterrupt or SystemExit here, # because cherrpy.server already does so, calling self.stop() for us. # If you're using this server with another framework, you should # trap those exceptions in whatever ...
python
def start(self): """Run the server forever.""" # We don't have to trap KeyboardInterrupt or SystemExit here, # because cherrpy.server already does so, calling self.stop() for us. # If you're using this server with another framework, you should # trap those exceptions in whatever ...
[ "def", "start", "(", "self", ")", ":", "# We don't have to trap KeyboardInterrupt or SystemExit here,", "# because cherrpy.server already does so, calling self.stop() for us.", "# If you're using this server with another framework, you should", "# trap those exceptions in whatever code block calls...
Run the server forever.
[ "Run", "the", "server", "forever", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L1633-L1721
train
Start the server forever.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPServer.bind
def bind(self, family, type, proto=0): """Create (or recreate) the actual socket object.""" self.socket = socket.socket(family, type, proto) prevent_socket_inheritance(self.socket) self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) if self.nodelay and not isinstanc...
python
def bind(self, family, type, proto=0): """Create (or recreate) the actual socket object.""" self.socket = socket.socket(family, type, proto) prevent_socket_inheritance(self.socket) self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) if self.nodelay and not isinstanc...
[ "def", "bind", "(", "self", ",", "family", ",", "type", ",", "proto", "=", "0", ")", ":", "self", ".", "socket", "=", "socket", ".", "socket", "(", "family", ",", "type", ",", "proto", ")", "prevent_socket_inheritance", "(", "self", ".", "socket", ")...
Create (or recreate) the actual socket object.
[ "Create", "(", "or", "recreate", ")", "the", "actual", "socket", "object", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L1723-L1745
train
Create or recreate the actual socket object.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPServer.tick
def tick(self): """Accept a new connection and put it on the Queue.""" try: s, addr = self.socket.accept() if not self.ready: return prevent_socket_inheritance(s) if hasattr(s, 'settimeout'): s.settimeout(self.t...
python
def tick(self): """Accept a new connection and put it on the Queue.""" try: s, addr = self.socket.accept() if not self.ready: return prevent_socket_inheritance(s) if hasattr(s, 'settimeout'): s.settimeout(self.t...
[ "def", "tick", "(", "self", ")", ":", "try", ":", "s", ",", "addr", "=", "self", ".", "socket", ".", "accept", "(", ")", "if", "not", "self", ".", "ready", ":", "return", "prevent_socket_inheritance", "(", "s", ")", "if", "hasattr", "(", "s", ",", ...
Accept a new connection and put it on the Queue.
[ "Accept", "a", "new", "connection", "and", "put", "it", "on", "the", "Queue", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L1747-L1825
train
Accept a new connection and put it on the Queue.
rsgalloway/grit
grit/server/cherrypy/__init__.py
HTTPServer.stop
def stop(self): """Gracefully shutdown a server that is serving forever.""" self.ready = False sock = getattr(self, "socket", None) if sock: if not isinstance(self.bind_addr, basestring): # Touch our own socket to make accept() return immediately. ...
python
def stop(self): """Gracefully shutdown a server that is serving forever.""" self.ready = False sock = getattr(self, "socket", None) if sock: if not isinstance(self.bind_addr, basestring): # Touch our own socket to make accept() return immediately. ...
[ "def", "stop", "(", "self", ")", ":", "self", ".", "ready", "=", "False", "sock", "=", "getattr", "(", "self", ",", "\"socket\"", ",", "None", ")", "if", "sock", ":", "if", "not", "isinstance", "(", "self", ".", "bind_addr", ",", "basestring", ")", ...
Gracefully shutdown a server that is serving forever.
[ "Gracefully", "shutdown", "a", "server", "that", "is", "serving", "forever", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L1837-L1875
train
Gracefully shutdown a server that is serving forever.
rsgalloway/grit
grit/server/cherrypy/__init__.py
WSGIGateway.start_response
def start_response(self, status, headers, exc_info = None): """WSGI callable to begin the HTTP response.""" # "The application may call start_response more than once, # if and only if the exc_info argument is provided." if self.started_response and not exc_info: raise Asserti...
python
def start_response(self, status, headers, exc_info = None): """WSGI callable to begin the HTTP response.""" # "The application may call start_response more than once, # if and only if the exc_info argument is provided." if self.started_response and not exc_info: raise Asserti...
[ "def", "start_response", "(", "self", ",", "status", ",", "headers", ",", "exc_info", "=", "None", ")", ":", "# \"The application may call start_response more than once,", "# if and only if the exc_info argument is provided.\"", "if", "self", ".", "started_response", "and", ...
WSGI callable to begin the HTTP response.
[ "WSGI", "callable", "to", "begin", "the", "HTTP", "response", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L1976-L2002
train
WSGI callable to begin the HTTP response.
rsgalloway/grit
grit/server/cherrypy/__init__.py
WSGIGateway.write
def write(self, chunk): """WSGI callable to write unbuffered data to the client. This method is also used internally by start_response (to write data from the iterable returned by the WSGI application). """ if not self.started_response: raise AssertionError("...
python
def write(self, chunk): """WSGI callable to write unbuffered data to the client. This method is also used internally by start_response (to write data from the iterable returned by the WSGI application). """ if not self.started_response: raise AssertionError("...
[ "def", "write", "(", "self", ",", "chunk", ")", ":", "if", "not", "self", ".", "started_response", ":", "raise", "AssertionError", "(", "\"WSGI write called before start_response.\"", ")", "if", "not", "self", ".", "req", ".", "sent_headers", ":", "self", ".",...
WSGI callable to write unbuffered data to the client. This method is also used internally by start_response (to write data from the iterable returned by the WSGI application).
[ "WSGI", "callable", "to", "write", "unbuffered", "data", "to", "the", "client", ".", "This", "method", "is", "also", "used", "internally", "by", "start_response", "(", "to", "write", "data", "from", "the", "iterable", "returned", "by", "the", "WSGI", "applic...
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L2004-L2017
train
This method writes unbuffered data to the client.
rsgalloway/grit
grit/server/cherrypy/__init__.py
WSGIGateway_10.get_environ
def get_environ(self): """Return a new environ dict targeting the given wsgi.version""" req = self.req env = { # set a non-standard environ entry so the WSGI app can know what # the *real* server protocol is (and what features to support). # See http://www.faq...
python
def get_environ(self): """Return a new environ dict targeting the given wsgi.version""" req = self.req env = { # set a non-standard environ entry so the WSGI app can know what # the *real* server protocol is (and what features to support). # See http://www.faq...
[ "def", "get_environ", "(", "self", ")", ":", "req", "=", "self", ".", "req", "env", "=", "{", "# set a non-standard environ entry so the WSGI app can know what", "# the *real* server protocol is (and what features to support).", "# See http://www.faqs.org/rfcs/rfc2145.html.", "'ACT...
Return a new environ dict targeting the given wsgi.version
[ "Return", "a", "new", "environ", "dict", "targeting", "the", "given", "wsgi", ".", "version" ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L2022-L2072
train
Return a new environ dict with the current WSGI version.
rsgalloway/grit
grit/server/cherrypy/__init__.py
WSGIGateway_u0.get_environ
def get_environ(self): """Return a new environ dict targeting the given wsgi.version""" req = self.req env_10 = WSGIGateway_10.get_environ(self) env = dict([(k.decode('ISO-8859-1'), v) for k, v in env_10.iteritems()]) env[u'wsgi.version'] = ('u', 0) # Request-URI...
python
def get_environ(self): """Return a new environ dict targeting the given wsgi.version""" req = self.req env_10 = WSGIGateway_10.get_environ(self) env = dict([(k.decode('ISO-8859-1'), v) for k, v in env_10.iteritems()]) env[u'wsgi.version'] = ('u', 0) # Request-URI...
[ "def", "get_environ", "(", "self", ")", ":", "req", "=", "self", ".", "req", "env_10", "=", "WSGIGateway_10", ".", "get_environ", "(", "self", ")", "env", "=", "dict", "(", "[", "(", "k", ".", "decode", "(", "'ISO-8859-1'", ")", ",", "v", ")", "for...
Return a new environ dict targeting the given wsgi.version
[ "Return", "a", "new", "environ", "dict", "targeting", "the", "given", "wsgi", ".", "version" ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/__init__.py#L2085-L2107
train
Return a new environ dict targeting the given wsgi. version
openvax/varlens
varlens/read_evidence/pileup_element.py
PileupElement.fields
def fields(self): ''' Fields that should be considered for our notion of object equality. ''' return ( self.locus, self.offset_start, self.offset_end, self.alignment_key)
python
def fields(self): ''' Fields that should be considered for our notion of object equality. ''' return ( self.locus, self.offset_start, self.offset_end, self.alignment_key)
[ "def", "fields", "(", "self", ")", ":", "return", "(", "self", ".", "locus", ",", "self", ".", "offset_start", ",", "self", ".", "offset_end", ",", "self", ".", "alignment_key", ")" ]
Fields that should be considered for our notion of object equality.
[ "Fields", "that", "should", "be", "considered", "for", "our", "notion", "of", "object", "equality", "." ]
715d3ede5893757b2fcba4117515621bca7b1e5d
https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/read_evidence/pileup_element.py#L57-L62
train
Returns a tuple of the fields that should be considered for our notion of object equality.
openvax/varlens
varlens/read_evidence/pileup_element.py
PileupElement.bases
def bases(self): ''' The sequenced bases in the alignment that align to this locus in the genome, as a string. Empty string in the case of a deletion. String of length > 1 if there is an insertion here. ''' sequence = self.alignment.query_sequence assert ...
python
def bases(self): ''' The sequenced bases in the alignment that align to this locus in the genome, as a string. Empty string in the case of a deletion. String of length > 1 if there is an insertion here. ''' sequence = self.alignment.query_sequence assert ...
[ "def", "bases", "(", "self", ")", ":", "sequence", "=", "self", ".", "alignment", ".", "query_sequence", "assert", "self", ".", "offset_end", "<=", "len", "(", "sequence", ")", ",", "\"End offset=%d > sequence length=%d. CIGAR=%s. SEQUENCE=%s\"", "%", "(", "self",...
The sequenced bases in the alignment that align to this locus in the genome, as a string. Empty string in the case of a deletion. String of length > 1 if there is an insertion here.
[ "The", "sequenced", "bases", "in", "the", "alignment", "that", "align", "to", "this", "locus", "in", "the", "genome", "as", "a", "string", "." ]
715d3ede5893757b2fcba4117515621bca7b1e5d
https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/read_evidence/pileup_element.py#L71-L86
train
Returns the sequenced bases in the alignment that align to this locus in the genome as a string.
openvax/varlens
varlens/read_evidence/pileup_element.py
PileupElement.min_base_quality
def min_base_quality(self): ''' The minimum of the base qualities. In the case of a deletion, in which case there are no bases in this PileupElement, the minimum is taken over the sequenced bases immediately before and after the deletion. ''' try: return min(s...
python
def min_base_quality(self): ''' The minimum of the base qualities. In the case of a deletion, in which case there are no bases in this PileupElement, the minimum is taken over the sequenced bases immediately before and after the deletion. ''' try: return min(s...
[ "def", "min_base_quality", "(", "self", ")", ":", "try", ":", "return", "min", "(", "self", ".", "base_qualities", ")", "except", "ValueError", ":", "# We are mid-deletion. We return the minimum of the adjacent bases.", "assert", "self", ".", "offset_start", "==", "se...
The minimum of the base qualities. In the case of a deletion, in which case there are no bases in this PileupElement, the minimum is taken over the sequenced bases immediately before and after the deletion.
[ "The", "minimum", "of", "the", "base", "qualities", ".", "In", "the", "case", "of", "a", "deletion", "in", "which", "case", "there", "are", "no", "bases", "in", "this", "PileupElement", "the", "minimum", "is", "taken", "over", "the", "sequenced", "bases", ...
715d3ede5893757b2fcba4117515621bca7b1e5d
https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/read_evidence/pileup_element.py#L98-L114
train
Returns the minimum base quality of the PileupElement.
openvax/varlens
varlens/read_evidence/pileup_element.py
PileupElement.from_pysam_alignment
def from_pysam_alignment(locus, pileup_read): ''' Factory function to create a new PileupElement from a pysam `PileupRead`. Parameters ---------- locus : varcode.Locus Reference locus for which to construct a PileupElement. Must include exactly on...
python
def from_pysam_alignment(locus, pileup_read): ''' Factory function to create a new PileupElement from a pysam `PileupRead`. Parameters ---------- locus : varcode.Locus Reference locus for which to construct a PileupElement. Must include exactly on...
[ "def", "from_pysam_alignment", "(", "locus", ",", "pileup_read", ")", ":", "assert", "not", "pileup_read", ".", "is_refskip", ",", "(", "\"Can't create a PileupElement in a refskip (typically an intronic \"", "\"gap in an RNA alignment)\"", ")", "# Pysam has an `aligned_pairs` me...
Factory function to create a new PileupElement from a pysam `PileupRead`. Parameters ---------- locus : varcode.Locus Reference locus for which to construct a PileupElement. Must include exactly one base. pileup_read : pysam.calignmentfile.PileupRead ...
[ "Factory", "function", "to", "create", "a", "new", "PileupElement", "from", "a", "pysam", "PileupRead", "." ]
715d3ede5893757b2fcba4117515621bca7b1e5d
https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/read_evidence/pileup_element.py#L117-L206
train
This function creates a new PileupElement from a pysam. PileupRead instance and an alignment of a base and a reference locus.
polyaxon/hestia
hestia/http.py
safe_request
def safe_request( url, method=None, params=None, data=None, json=None, headers=None, allow_redirects=False, timeout=30, verify_ssl=True, ): """A slightly safer version of `request`.""" session = requests.Session() kwargs = {} if json: kwargs['json'] = json ...
python
def safe_request( url, method=None, params=None, data=None, json=None, headers=None, allow_redirects=False, timeout=30, verify_ssl=True, ): """A slightly safer version of `request`.""" session = requests.Session() kwargs = {} if json: kwargs['json'] = json ...
[ "def", "safe_request", "(", "url", ",", "method", "=", "None", ",", "params", "=", "None", ",", "data", "=", "None", ",", "json", "=", "None", ",", "headers", "=", "None", ",", "allow_redirects", "=", "False", ",", "timeout", "=", "30", ",", "verify_...
A slightly safer version of `request`.
[ "A", "slightly", "safer", "version", "of", "request", "." ]
382ed139cff8bf35c987cfc30a31b72c0d6b808e
https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/http.py#L12-L56
train
A slightly safer version of request.
klmitch/turnstile
turnstile/remote.py
remote
def remote(func): """ Decorator to mark a function as invoking a remote procedure call. When invoked in server mode, the function will be called; when invoked in client mode, an RPC will be initiated. """ @functools.wraps(func) def wrapper(self, *args, **kwargs): if self.mode == 'se...
python
def remote(func): """ Decorator to mark a function as invoking a remote procedure call. When invoked in server mode, the function will be called; when invoked in client mode, an RPC will be initiated. """ @functools.wraps(func) def wrapper(self, *args, **kwargs): if self.mode == 'se...
[ "def", "remote", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "mode", "==", "'server'", ":", "# In server mode, call th...
Decorator to mark a function as invoking a remote procedure call. When invoked in server mode, the function will be called; when invoked in client mode, an RPC will be initiated.
[ "Decorator", "to", "mark", "a", "function", "as", "invoking", "a", "remote", "procedure", "call", ".", "When", "invoked", "in", "server", "mode", "the", "function", "will", "be", "called", ";", "when", "invoked", "in", "client", "mode", "an", "RPC", "will"...
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L171-L210
train
Decorator to mark a function as invoking a remote procedure call.
klmitch/turnstile
turnstile/remote.py
_create_server
def _create_server(host, port): """ Helper function. Creates a listening socket on the designated host and port. Modeled on the socket.create_connection() function. """ exc = socket.error("getaddrinfo returns an empty list") for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)...
python
def _create_server(host, port): """ Helper function. Creates a listening socket on the designated host and port. Modeled on the socket.create_connection() function. """ exc = socket.error("getaddrinfo returns an empty list") for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)...
[ "def", "_create_server", "(", "host", ",", "port", ")", ":", "exc", "=", "socket", ".", "error", "(", "\"getaddrinfo returns an empty list\"", ")", "for", "res", "in", "socket", ".", "getaddrinfo", "(", "host", ",", "port", ",", "0", ",", "socket", ".", ...
Helper function. Creates a listening socket on the designated host and port. Modeled on the socket.create_connection() function.
[ "Helper", "function", ".", "Creates", "a", "listening", "socket", "on", "the", "designated", "host", "and", "port", ".", "Modeled", "on", "the", "socket", ".", "create_connection", "()", "function", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L213-L238
train
Create a listening socket on the designated Taxonomy host and port.
klmitch/turnstile
turnstile/remote.py
Connection.close
def close(self): """ Close the connection. :param purge: If True (the default), the receive buffer will be purged. """ # Close the underlying socket if self._sock: with utils.ignore_except(): self._sock.close() ...
python
def close(self): """ Close the connection. :param purge: If True (the default), the receive buffer will be purged. """ # Close the underlying socket if self._sock: with utils.ignore_except(): self._sock.close() ...
[ "def", "close", "(", "self", ")", ":", "# Close the underlying socket", "if", "self", ".", "_sock", ":", "with", "utils", ".", "ignore_except", "(", ")", ":", "self", ".", "_sock", ".", "close", "(", ")", "self", ".", "_sock", "=", "None", "# Purge the m...
Close the connection. :param purge: If True (the default), the receive buffer will be purged.
[ "Close", "the", "connection", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L49-L65
train
Closes the connection and the underlying socket.
klmitch/turnstile
turnstile/remote.py
Connection.send
def send(self, cmd, *payload): """ Send a command message to the other end. :param cmd: The command to send to the other end. :param payload: The command payload. Note that all elements of the payload must be serializable to JSON. """ # If it's ...
python
def send(self, cmd, *payload): """ Send a command message to the other end. :param cmd: The command to send to the other end. :param payload: The command payload. Note that all elements of the payload must be serializable to JSON. """ # If it's ...
[ "def", "send", "(", "self", ",", "cmd", ",", "*", "payload", ")", ":", "# If it's closed, raise an error up front", "if", "not", "self", ".", "_sock", ":", "raise", "ConnectionClosed", "(", "\"Connection closed\"", ")", "# Construct the outgoing message", "msg", "="...
Send a command message to the other end. :param cmd: The command to send to the other end. :param payload: The command payload. Note that all elements of the payload must be serializable to JSON.
[ "Send", "a", "command", "message", "to", "the", "other", "end", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L67-L94
train
Send a command message to the other end.
klmitch/turnstile
turnstile/remote.py
Connection._recvbuf_pop
def _recvbuf_pop(self): """ Internal helper to pop a message off the receive buffer. If the message is an Exception, that exception will be raised; otherwise, a tuple of command and payload will be returned. """ # Pop a message off the recv buffer and return (or raise) ...
python
def _recvbuf_pop(self): """ Internal helper to pop a message off the receive buffer. If the message is an Exception, that exception will be raised; otherwise, a tuple of command and payload will be returned. """ # Pop a message off the recv buffer and return (or raise) ...
[ "def", "_recvbuf_pop", "(", "self", ")", ":", "# Pop a message off the recv buffer and return (or raise) it", "msg", "=", "self", ".", "_recvbuf", ".", "pop", "(", "0", ")", "if", "isinstance", "(", "msg", ",", "Exception", ")", ":", "raise", "msg", "return", ...
Internal helper to pop a message off the receive buffer. If the message is an Exception, that exception will be raised; otherwise, a tuple of command and payload will be returned.
[ "Internal", "helper", "to", "pop", "a", "message", "off", "the", "receive", "buffer", ".", "If", "the", "message", "is", "an", "Exception", "that", "exception", "will", "be", "raised", ";", "otherwise", "a", "tuple", "of", "command", "and", "payload", "wil...
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L96-L107
train
Internal helper to pop a message off the receive buffer and return it.
klmitch/turnstile
turnstile/remote.py
Connection.recv
def recv(self): """ Receive a message from the other end. Returns a tuple of the command (a string) and payload (a list). """ # See if we have a message to process... if self._recvbuf: return self._recvbuf_pop() # If it's closed, don't try to read m...
python
def recv(self): """ Receive a message from the other end. Returns a tuple of the command (a string) and payload (a list). """ # See if we have a message to process... if self._recvbuf: return self._recvbuf_pop() # If it's closed, don't try to read m...
[ "def", "recv", "(", "self", ")", ":", "# See if we have a message to process...", "if", "self", ".", "_recvbuf", ":", "return", "self", ".", "_recvbuf_pop", "(", ")", "# If it's closed, don't try to read more data", "if", "not", "self", ".", "_sock", ":", "raise", ...
Receive a message from the other end. Returns a tuple of the command (a string) and payload (a list).
[ "Receive", "a", "message", "from", "the", "other", "end", ".", "Returns", "a", "tuple", "of", "the", "command", "(", "a", "string", ")", "and", "payload", "(", "a", "list", ")", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L109-L165
train
Receive a message from the other end.
klmitch/turnstile
turnstile/remote.py
SimpleRPC.ping
def ping(self): """ Ping the server. Returns the time interval, in seconds, required for the server to respond to the PING message. """ # Make sure we're connected if not self.conn: self.connect() # Send the ping and wait for the response se...
python
def ping(self): """ Ping the server. Returns the time interval, in seconds, required for the server to respond to the PING message. """ # Make sure we're connected if not self.conn: self.connect() # Send the ping and wait for the response se...
[ "def", "ping", "(", "self", ")", ":", "# Make sure we're connected", "if", "not", "self", ".", "conn", ":", "self", ".", "connect", "(", ")", "# Send the ping and wait for the response", "self", ".", "conn", ".", "send", "(", "'PING'", ",", "time", ".", "tim...
Ping the server. Returns the time interval, in seconds, required for the server to respond to the PING message.
[ "Ping", "the", "server", ".", "Returns", "the", "time", "interval", "in", "seconds", "required", "for", "the", "server", "to", "respond", "to", "the", "PING", "message", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L288-L308
train
Ping the server and return the time interval in seconds required for the server to respond to the PING message.
klmitch/turnstile
turnstile/remote.py
SimpleRPC.connect
def connect(self): """ Connect to the server. This method causes the SimpleRPC object to switch to client mode. Note some methods, such as the ping() method, implicitly call this method. """ # Make sure we're in client mode if self.mode and self.mode != 'client...
python
def connect(self): """ Connect to the server. This method causes the SimpleRPC object to switch to client mode. Note some methods, such as the ping() method, implicitly call this method. """ # Make sure we're in client mode if self.mode and self.mode != 'client...
[ "def", "connect", "(", "self", ")", ":", "# Make sure we're in client mode", "if", "self", ".", "mode", "and", "self", ".", "mode", "!=", "'client'", ":", "raise", "ValueError", "(", "\"%s is not in client mode\"", "%", "self", ".", "__class__", ".", "__name__",...
Connect to the server. This method causes the SimpleRPC object to switch to client mode. Note some methods, such as the ping() method, implicitly call this method.
[ "Connect", "to", "the", "server", ".", "This", "method", "causes", "the", "SimpleRPC", "object", "to", "switch", "to", "client", "mode", ".", "Note", "some", "methods", "such", "as", "the", "ping", "()", "method", "implicitly", "call", "this", "method", "....
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L310-L358
train
Connect to the server and return the SimpleRPC object.
klmitch/turnstile
turnstile/remote.py
SimpleRPC.listen
def listen(self): """ Listen for clients. This method causes the SimpleRPC object to switch to server mode. One thread will be created for each client. """ # Make sure we're in server mode if self.mode and self.mode != 'server': raise ValueError("%s...
python
def listen(self): """ Listen for clients. This method causes the SimpleRPC object to switch to server mode. One thread will be created for each client. """ # Make sure we're in server mode if self.mode and self.mode != 'server': raise ValueError("%s...
[ "def", "listen", "(", "self", ")", ":", "# Make sure we're in server mode", "if", "self", ".", "mode", "and", "self", ".", "mode", "!=", "'server'", ":", "raise", "ValueError", "(", "\"%s is not in server mode\"", "%", "self", ".", "__class__", ".", "__name__", ...
Listen for clients. This method causes the SimpleRPC object to switch to server mode. One thread will be created for each client.
[ "Listen", "for", "clients", ".", "This", "method", "causes", "the", "SimpleRPC", "object", "to", "switch", "to", "server", "mode", ".", "One", "thread", "will", "be", "created", "for", "each", "client", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L360-L402
train
Listen for clients.
klmitch/turnstile
turnstile/remote.py
SimpleRPC._get_remote_method
def _get_remote_method(self, funcname): """ Look up the named remote method. Broken out from serve() for testing purposes. :param funcname: The name of the function to look up. """ func = getattr(self, funcname) if not callable(func) or not getattr(func, '_remo...
python
def _get_remote_method(self, funcname): """ Look up the named remote method. Broken out from serve() for testing purposes. :param funcname: The name of the function to look up. """ func = getattr(self, funcname) if not callable(func) or not getattr(func, '_remo...
[ "def", "_get_remote_method", "(", "self", ",", "funcname", ")", ":", "func", "=", "getattr", "(", "self", ",", "funcname", ")", "if", "not", "callable", "(", "func", ")", "or", "not", "getattr", "(", "func", ",", "'_remote'", ",", "False", ")", ":", ...
Look up the named remote method. Broken out from serve() for testing purposes. :param funcname: The name of the function to look up.
[ "Look", "up", "the", "named", "remote", "method", ".", "Broken", "out", "from", "serve", "()", "for", "testing", "purposes", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L404-L417
train
Look up the named remote method.
klmitch/turnstile
turnstile/remote.py
SimpleRPC.serve
def serve(self, conn, addr, auth=False): """ Handle a single client. :param conn: The Connection instance. :param addr: The address of the client, for logging purposes. :param auth: A boolean specifying whether the connection should be considered authenticat...
python
def serve(self, conn, addr, auth=False): """ Handle a single client. :param conn: The Connection instance. :param addr: The address of the client, for logging purposes. :param auth: A boolean specifying whether the connection should be considered authenticat...
[ "def", "serve", "(", "self", ",", "conn", ",", "addr", ",", "auth", "=", "False", ")", ":", "try", ":", "# Handle data from the client", "while", "True", ":", "# Get the command", "try", ":", "cmd", ",", "payload", "=", "conn", ".", "recv", "(", ")", "...
Handle a single client. :param conn: The Connection instance. :param addr: The address of the client, for logging purposes. :param auth: A boolean specifying whether the connection should be considered authenticated or not. Provided for debugging.
[ "Handle", "a", "single", "client", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L419-L514
train
Handle a single client.
klmitch/turnstile
turnstile/remote.py
RemoteLimitData.get_limits
def get_limits(self, limit_sum=None): """ Gets the current limit data if it is different from the data indicated by limit_sum. The db argument is used for hydrating the limit objects. Raises a NoChangeException if the limit_sum represents no change, otherwise returns a tuple ...
python
def get_limits(self, limit_sum=None): """ Gets the current limit data if it is different from the data indicated by limit_sum. The db argument is used for hydrating the limit objects. Raises a NoChangeException if the limit_sum represents no change, otherwise returns a tuple ...
[ "def", "get_limits", "(", "self", ",", "limit_sum", "=", "None", ")", ":", "with", "self", ".", "limit_lock", ":", "# Grab the checksum and limit list", "try", ":", "return", "self", ".", "limit_rpc", ".", "get_limits", "(", "limit_sum", ")", "except", "contro...
Gets the current limit data if it is different from the data indicated by limit_sum. The db argument is used for hydrating the limit objects. Raises a NoChangeException if the limit_sum represents no change, otherwise returns a tuple consisting of the current limit_sum and a list of Li...
[ "Gets", "the", "current", "limit", "data", "if", "it", "is", "different", "from", "the", "data", "indicated", "by", "limit_sum", ".", "The", "db", "argument", "is", "used", "for", "hydrating", "the", "limit", "objects", ".", "Raises", "a", "NoChangeException...
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L573-L593
train
Gets the current limit data if it is different from the data .
klmitch/turnstile
turnstile/remote.py
RemoteControlDaemon.get_limits
def get_limits(self): """ Retrieve the LimitData object the middleware will use for getting the limits. This implementation returns a RemoteLimitData instance that can access the LimitData stored in the RemoteControlDaemon process. """ # Set one up if we don't a...
python
def get_limits(self): """ Retrieve the LimitData object the middleware will use for getting the limits. This implementation returns a RemoteLimitData instance that can access the LimitData stored in the RemoteControlDaemon process. """ # Set one up if we don't a...
[ "def", "get_limits", "(", "self", ")", ":", "# Set one up if we don't already have it", "if", "not", "self", ".", "remote_limits", ":", "self", ".", "remote_limits", "=", "RemoteLimitData", "(", "self", ".", "remote", ")", "return", "self", ".", "remote_limits" ]
Retrieve the LimitData object the middleware will use for getting the limits. This implementation returns a RemoteLimitData instance that can access the LimitData stored in the RemoteControlDaemon process.
[ "Retrieve", "the", "LimitData", "object", "the", "middleware", "will", "use", "for", "getting", "the", "limits", ".", "This", "implementation", "returns", "a", "RemoteLimitData", "instance", "that", "can", "access", "the", "LimitData", "stored", "in", "the", "Re...
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L643-L654
train
Retrieve the LimitData object that can be used for the current object.
klmitch/turnstile
turnstile/remote.py
RemoteControlDaemon.db
def db(self): """ Obtain a handle for the database. This allows lazy initialization of the database handle. """ # Initialize the database handle; we're running in a separate # process, so we need to get_database() ourself if not self._db: self._db = ...
python
def db(self): """ Obtain a handle for the database. This allows lazy initialization of the database handle. """ # Initialize the database handle; we're running in a separate # process, so we need to get_database() ourself if not self._db: self._db = ...
[ "def", "db", "(", "self", ")", ":", "# Initialize the database handle; we're running in a separate", "# process, so we need to get_database() ourself", "if", "not", "self", ".", "_db", ":", "self", ".", "_db", "=", "self", ".", "config", ".", "get_database", "(", ")",...
Obtain a handle for the database. This allows lazy initialization of the database handle.
[ "Obtain", "a", "handle", "for", "the", "database", ".", "This", "allows", "lazy", "initialization", "of", "the", "database", "handle", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/remote.py#L678-L689
train
Returns a handle for the database.
kata198/python-subprocess2
subprocess2/__init__.py
waitUpTo
def waitUpTo(self, timeoutSeconds, pollInterval=DEFAULT_POLL_INTERVAL): ''' Popen.waitUpTo - Wait up to a certain number of seconds for the process to end. @param timeoutSeconds <float> - Number of seconds to wait @param pollInterval <float> (default .05) - Number of seconds in bet...
python
def waitUpTo(self, timeoutSeconds, pollInterval=DEFAULT_POLL_INTERVAL): ''' Popen.waitUpTo - Wait up to a certain number of seconds for the process to end. @param timeoutSeconds <float> - Number of seconds to wait @param pollInterval <float> (default .05) - Number of seconds in bet...
[ "def", "waitUpTo", "(", "self", ",", "timeoutSeconds", ",", "pollInterval", "=", "DEFAULT_POLL_INTERVAL", ")", ":", "i", "=", "0", "numWaits", "=", "timeoutSeconds", "/", "float", "(", "pollInterval", ")", "ret", "=", "self", ".", "poll", "(", ")", "if", ...
Popen.waitUpTo - Wait up to a certain number of seconds for the process to end. @param timeoutSeconds <float> - Number of seconds to wait @param pollInterval <float> (default .05) - Number of seconds in between each poll @return - Returncode of application, or None if did not term...
[ "Popen", ".", "waitUpTo", "-", "Wait", "up", "to", "a", "certain", "number", "of", "seconds", "for", "the", "process", "to", "end", "." ]
8544b0b651d8e14de9fdd597baa704182e248b01
https://github.com/kata198/python-subprocess2/blob/8544b0b651d8e14de9fdd597baa704182e248b01/subprocess2/__init__.py#L63-L85
train
Wait up to a certain number of seconds for the process to end.
kata198/python-subprocess2
subprocess2/__init__.py
waitOrTerminate
def waitOrTerminate(self, timeoutSeconds, pollInterval=DEFAULT_POLL_INTERVAL, terminateToKillSeconds=SUBPROCESS2_DEFAULT_TERMINATE_TO_KILL_SECONDS): ''' waitOrTerminate - Wait up to a certain number of seconds for the process to end. If the process is running after the timeout has been exceeded...
python
def waitOrTerminate(self, timeoutSeconds, pollInterval=DEFAULT_POLL_INTERVAL, terminateToKillSeconds=SUBPROCESS2_DEFAULT_TERMINATE_TO_KILL_SECONDS): ''' waitOrTerminate - Wait up to a certain number of seconds for the process to end. If the process is running after the timeout has been exceeded...
[ "def", "waitOrTerminate", "(", "self", ",", "timeoutSeconds", ",", "pollInterval", "=", "DEFAULT_POLL_INTERVAL", ",", "terminateToKillSeconds", "=", "SUBPROCESS2_DEFAULT_TERMINATE_TO_KILL_SECONDS", ")", ":", "returnCode", "=", "self", ".", "waitUpTo", "(", "timeoutSeconds...
waitOrTerminate - Wait up to a certain number of seconds for the process to end. If the process is running after the timeout has been exceeded, a SIGTERM will be sent. Optionally, an additional SIGKILL can be sent after some configurable interval. See #terminateToKillSeconds doc below ...
[ "waitOrTerminate", "-", "Wait", "up", "to", "a", "certain", "number", "of", "seconds", "for", "the", "process", "to", "end", "." ]
8544b0b651d8e14de9fdd597baa704182e248b01
https://github.com/kata198/python-subprocess2/blob/8544b0b651d8e14de9fdd597baa704182e248b01/subprocess2/__init__.py#L89-L147
train
Wait up to a certain number of seconds for the application to finish.
kata198/python-subprocess2
subprocess2/__init__.py
runInBackground
def runInBackground(self, pollInterval=.1, encoding=False): ''' runInBackground - Create a background thread which will manage this process, automatically read from streams, and perform any cleanups The object returned is a "BackgroundTaskInfo" object, and represents the state of the process. It ...
python
def runInBackground(self, pollInterval=.1, encoding=False): ''' runInBackground - Create a background thread which will manage this process, automatically read from streams, and perform any cleanups The object returned is a "BackgroundTaskInfo" object, and represents the state of the process. It ...
[ "def", "runInBackground", "(", "self", ",", "pollInterval", "=", ".1", ",", "encoding", "=", "False", ")", ":", "from", ".", "BackgroundTask", "import", "BackgroundTaskThread", "taskInfo", "=", "BackgroundTaskInfo", "(", "encoding", ")", "thread", "=", "Backgrou...
runInBackground - Create a background thread which will manage this process, automatically read from streams, and perform any cleanups The object returned is a "BackgroundTaskInfo" object, and represents the state of the process. It is updated automatically as the program runs, and if stdout or s...
[ "runInBackground", "-", "Create", "a", "background", "thread", "which", "will", "manage", "this", "process", "automatically", "read", "from", "streams", "and", "perform", "any", "cleanups" ]
8544b0b651d8e14de9fdd597baa704182e248b01
https://github.com/kata198/python-subprocess2/blob/8544b0b651d8e14de9fdd597baa704182e248b01/subprocess2/__init__.py#L152-L172
train
This method runs the process in background.
jstitch/MambuPy
MambuPy/rest/mambutask.py
MambuTasks.convertDict2Attrs
def convertDict2Attrs(self, *args, **kwargs): """The trick for iterable Mambu Objects comes here: You iterate over each element of the responded List from Mambu, and create a Mambu Task object for each one, initializing them one at a time, and changing the attrs attribute (which just ...
python
def convertDict2Attrs(self, *args, **kwargs): """The trick for iterable Mambu Objects comes here: You iterate over each element of the responded List from Mambu, and create a Mambu Task object for each one, initializing them one at a time, and changing the attrs attribute (which just ...
[ "def", "convertDict2Attrs", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "n", ",", "a", "in", "enumerate", "(", "self", ".", "attrs", ")", ":", "# ok ok, I'm modifying elements of a list while iterating it. BAD PRACTICE!", "try", ":",...
The trick for iterable Mambu Objects comes here: You iterate over each element of the responded List from Mambu, and create a Mambu Task object for each one, initializing them one at a time, and changing the attrs attribute (which just holds a list of plain dictionaries) with a MambuTas...
[ "The", "trick", "for", "iterable", "Mambu", "Objects", "comes", "here", ":" ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambutask.py#L107-L130
train
This method converts a dictionary of plain dictionaries into a list of Mambu Task objects.
cloudmesh-cmd3/cmd3
cmd3/plugins/shell_plugins.py
shell_plugins.do_setup
def do_setup(self, arg, arguments): """ :: Usage: setup init [--force] Copies a cmd3.yaml file into ~/.cloudmesh/cmd3.yaml """ if arguments["init"]: Console.ok("Initialize cmd3.yaml file") from cmd3.yaml_setup import create...
python
def do_setup(self, arg, arguments): """ :: Usage: setup init [--force] Copies a cmd3.yaml file into ~/.cloudmesh/cmd3.yaml """ if arguments["init"]: Console.ok("Initialize cmd3.yaml file") from cmd3.yaml_setup import create...
[ "def", "do_setup", "(", "self", ",", "arg", ",", "arguments", ")", ":", "if", "arguments", "[", "\"init\"", "]", ":", "Console", ".", "ok", "(", "\"Initialize cmd3.yaml file\"", ")", "from", "cmd3", ".", "yaml_setup", "import", "create_cmd3_yaml_file", "force"...
:: Usage: setup init [--force] Copies a cmd3.yaml file into ~/.cloudmesh/cmd3.yaml
[ "::" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/shell_plugins.py#L14-L28
train
\ ~. cloudmesh \ cmd3. yaml_setup \ ~.
cloudmesh-cmd3/cmd3
cmd3/plugins/shell_plugins.py
shell_plugins.do_plugins
def do_plugins(self, args, arguments): """ :: Usage: plugins add COMMAND [--dryrun] [-q] plugins delete COMMAND [--dryrun] [-q] plugins list [--output=FORMAT] [-q] plugins activate Arguments: FORMA...
python
def do_plugins(self, args, arguments): """ :: Usage: plugins add COMMAND [--dryrun] [-q] plugins delete COMMAND [--dryrun] [-q] plugins list [--output=FORMAT] [-q] plugins activate Arguments: FORMA...
[ "def", "do_plugins", "(", "self", ",", "args", ",", "arguments", ")", ":", "# pprint(arguments)", "quiet", "=", "arguments", "[", "\"-q\"", "]", "if", "arguments", "[", "\"activate\"", "]", ":", "Console", ".", "error", "(", "\"this method is not yet supported.\...
:: Usage: plugins add COMMAND [--dryrun] [-q] plugins delete COMMAND [--dryrun] [-q] plugins list [--output=FORMAT] [-q] plugins activate Arguments: FORMAT format is either yaml, json, or list [default=yaml] ...
[ "::" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/shell_plugins.py#L31-L118
train
This command is used to add and delete plugins for a given command.
jstitch/MambuPy
MambuPy/rest/mambugroup.py
MambuGroup.preprocess
def preprocess(self): """Preprocessing. Flattens the object. Important data comes on the 'theGroup' dictionary inside of the response. Instead, every element of the 'theGroup' dictionary is taken out to the main attrs dictionary. Notes on the group get some html tags removed. ...
python
def preprocess(self): """Preprocessing. Flattens the object. Important data comes on the 'theGroup' dictionary inside of the response. Instead, every element of the 'theGroup' dictionary is taken out to the main attrs dictionary. Notes on the group get some html tags removed. ...
[ "def", "preprocess", "(", "self", ")", ":", "super", "(", "MambuGroup", ",", "self", ")", ".", "preprocess", "(", ")", "try", ":", "for", "k", ",", "v", "in", "self", "[", "'theGroup'", "]", ".", "items", "(", ")", ":", "self", "[", "k", "]", "...
Preprocessing. Flattens the object. Important data comes on the 'theGroup' dictionary inside of the response. Instead, every element of the 'theGroup' dictionary is taken out to the main attrs dictionary. Notes on the group get some html tags removed. .. todo:: use mambuutil.strip_tag...
[ "Preprocessing", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambugroup.py#L39-L74
train
This method is used to preprocess the object.
jstitch/MambuPy
MambuPy/rest/mambugroup.py
MambuGroup.setClients
def setClients(self, *args, **kwargs): """Adds the clients for this group to a 'clients' field. The 'groupMembers' field of the group holds the encodedKeys of the member clients of the group. Since Mambu REST API accepts both ids or encodedKeys to retrieve entities, we use that here. ...
python
def setClients(self, *args, **kwargs): """Adds the clients for this group to a 'clients' field. The 'groupMembers' field of the group holds the encodedKeys of the member clients of the group. Since Mambu REST API accepts both ids or encodedKeys to retrieve entities, we use that here. ...
[ "def", "setClients", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "requests", "=", "0", "if", "'fullDetails'", "in", "kwargs", ":", "fullDetails", "=", "kwargs", "[", "'fullDetails'", "]", "kwargs", ".", "pop", "(", "'fullDetails'", ...
Adds the clients for this group to a 'clients' field. The 'groupMembers' field of the group holds the encodedKeys of the member clients of the group. Since Mambu REST API accepts both ids or encodedKeys to retrieve entities, we use that here. You may wish to get the full details of eac...
[ "Adds", "the", "clients", "for", "this", "group", "to", "a", "clients", "field", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambugroup.py#L77-L112
train
Adds the clients for this group to a list of clients.
jstitch/MambuPy
MambuPy/rest/mambugroup.py
MambuGroup.setActivities
def setActivities(self, *args, **kwargs): """Adds the activities for this group to a 'activities' field. Activities are MambuActivity objects. Activities get sorted by activity timestamp. Returns the number of requests done to Mambu. """ def activityDate(activity): ...
python
def setActivities(self, *args, **kwargs): """Adds the activities for this group to a 'activities' field. Activities are MambuActivity objects. Activities get sorted by activity timestamp. Returns the number of requests done to Mambu. """ def activityDate(activity): ...
[ "def", "setActivities", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "activityDate", "(", "activity", ")", ":", "\"\"\"Util function used for sorting activities according to timestamp\"\"\"", "try", ":", "return", "activity", "[", "'activ...
Adds the activities for this group to a 'activities' field. Activities are MambuActivity objects. Activities get sorted by activity timestamp. Returns the number of requests done to Mambu.
[ "Adds", "the", "activities", "for", "this", "group", "to", "a", "activities", "field", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambugroup.py#L142-L167
train
Adds the activities for this group to a activities field.
jstitch/MambuPy
MambuPy/rest/mambugroup.py
MambuGroups.convertDict2Attrs
def convertDict2Attrs(self, *args, **kwargs): """The trick for iterable Mambu Objects comes here: You iterate over each element of the responded List from Mambu, and create a Mambu Group object for each one, initializing them one at a time, and changing the attrs attribute (which just ...
python
def convertDict2Attrs(self, *args, **kwargs): """The trick for iterable Mambu Objects comes here: You iterate over each element of the responded List from Mambu, and create a Mambu Group object for each one, initializing them one at a time, and changing the attrs attribute (which just ...
[ "def", "convertDict2Attrs", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "n", ",", "c", "in", "enumerate", "(", "self", ".", "attrs", ")", ":", "# ok ok, I'm modifying elements of a list while iterating it. BAD PRACTICE!", "try", ":",...
The trick for iterable Mambu Objects comes here: You iterate over each element of the responded List from Mambu, and create a Mambu Group object for each one, initializing them one at a time, and changing the attrs attribute (which just holds a list of plain dictionaries) with a MambuGr...
[ "The", "trick", "for", "iterable", "Mambu", "Objects", "comes", "here", ":" ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambugroup.py#L189-L217
train
This function converts a dictionary of plain dictionaries into a list of Mambu Group objects.
azogue/i2csense
i2csense/bh1750.py
BH1750.set_sensitivity
def set_sensitivity(self, sensitivity=DEFAULT_SENSITIVITY): """Set the sensitivity value. Valid values are 31 (lowest) to 254 (highest), default is 69. """ if sensitivity < 31: self._mtreg = 31 elif sensitivity > 254: self._mtreg = 254 else: ...
python
def set_sensitivity(self, sensitivity=DEFAULT_SENSITIVITY): """Set the sensitivity value. Valid values are 31 (lowest) to 254 (highest), default is 69. """ if sensitivity < 31: self._mtreg = 31 elif sensitivity > 254: self._mtreg = 254 else: ...
[ "def", "set_sensitivity", "(", "self", ",", "sensitivity", "=", "DEFAULT_SENSITIVITY", ")", ":", "if", "sensitivity", "<", "31", ":", "self", ".", "_mtreg", "=", "31", "elif", "sensitivity", ">", "254", ":", "self", ".", "_mtreg", "=", "254", "else", ":"...
Set the sensitivity value. Valid values are 31 (lowest) to 254 (highest), default is 69.
[ "Set", "the", "sensitivity", "value", "." ]
ecc6806dcee9de827a5414a9e836d271fedca9b9
https://github.com/azogue/i2csense/blob/ecc6806dcee9de827a5414a9e836d271fedca9b9/i2csense/bh1750.py#L92-L106
train
Set the sensitivity value.
azogue/i2csense
i2csense/bh1750.py
BH1750._get_result
def _get_result(self) -> float: """Return current measurement result in lx.""" try: data = self._bus.read_word_data(self._i2c_add, self._mode) self._ok = True except OSError as exc: self.log_error("Bad reading in bus: %s", exc) self._ok = False ...
python
def _get_result(self) -> float: """Return current measurement result in lx.""" try: data = self._bus.read_word_data(self._i2c_add, self._mode) self._ok = True except OSError as exc: self.log_error("Bad reading in bus: %s", exc) self._ok = False ...
[ "def", "_get_result", "(", "self", ")", "->", "float", ":", "try", ":", "data", "=", "self", ".", "_bus", ".", "read_word_data", "(", "self", ".", "_i2c_add", ",", "self", ".", "_mode", ")", "self", ".", "_ok", "=", "True", "except", "OSError", "as",...
Return current measurement result in lx.
[ "Return", "current", "measurement", "result", "in", "lx", "." ]
ecc6806dcee9de827a5414a9e836d271fedca9b9
https://github.com/azogue/i2csense/blob/ecc6806dcee9de827a5414a9e836d271fedca9b9/i2csense/bh1750.py#L108-L121
train
Return current measurement result in lx.
azogue/i2csense
i2csense/bh1750.py
BH1750._wait_for_result
def _wait_for_result(self): """Wait for the sensor to be ready for measurement.""" basetime = 0.018 if self._low_res else 0.128 sleep(basetime * (self._mtreg / 69.0) + self._delay)
python
def _wait_for_result(self): """Wait for the sensor to be ready for measurement.""" basetime = 0.018 if self._low_res else 0.128 sleep(basetime * (self._mtreg / 69.0) + self._delay)
[ "def", "_wait_for_result", "(", "self", ")", ":", "basetime", "=", "0.018", "if", "self", ".", "_low_res", "else", "0.128", "sleep", "(", "basetime", "*", "(", "self", ".", "_mtreg", "/", "69.0", ")", "+", "self", ".", "_delay", ")" ]
Wait for the sensor to be ready for measurement.
[ "Wait", "for", "the", "sensor", "to", "be", "ready", "for", "measurement", "." ]
ecc6806dcee9de827a5414a9e836d271fedca9b9
https://github.com/azogue/i2csense/blob/ecc6806dcee9de827a5414a9e836d271fedca9b9/i2csense/bh1750.py#L123-L126
train
Wait for the sensor to be ready for measurement.
azogue/i2csense
i2csense/bh1750.py
BH1750.update
def update(self): """Update the measured light level in lux.""" if not self._continuous_sampling \ or self._light_level < 0 \ or self._operation_mode != self._mode: self._reset() self._set_mode(self._operation_mode) self._wait_for_resul...
python
def update(self): """Update the measured light level in lux.""" if not self._continuous_sampling \ or self._light_level < 0 \ or self._operation_mode != self._mode: self._reset() self._set_mode(self._operation_mode) self._wait_for_resul...
[ "def", "update", "(", "self", ")", ":", "if", "not", "self", ".", "_continuous_sampling", "or", "self", ".", "_light_level", "<", "0", "or", "self", ".", "_operation_mode", "!=", "self", ".", "_mode", ":", "self", ".", "_reset", "(", ")", "self", ".", ...
Update the measured light level in lux.
[ "Update", "the", "measured", "light", "level", "in", "lux", "." ]
ecc6806dcee9de827a5414a9e836d271fedca9b9
https://github.com/azogue/i2csense/blob/ecc6806dcee9de827a5414a9e836d271fedca9b9/i2csense/bh1750.py#L128-L138
train
Update the measured light level in lux.
jpscaletti/authcode
authcode/utils.py
get_uhmac
def get_uhmac(user, secret): """Make an unique identifier for the user (stored in the session), so it can stay logged between requests. By hashing a snippet of the current password hash salt, it makes possible to automatically logout from all other devices just by changing (or refreshing) the passw...
python
def get_uhmac(user, secret): """Make an unique identifier for the user (stored in the session), so it can stay logged between requests. By hashing a snippet of the current password hash salt, it makes possible to automatically logout from all other devices just by changing (or refreshing) the passw...
[ "def", "get_uhmac", "(", "user", ",", "secret", ")", ":", "secret", "=", "to_bytes", "(", "secret", ")", "key", "=", "'|'", ".", "join", "(", "[", "hashlib", ".", "sha1", "(", "secret", ")", ".", "hexdigest", "(", ")", ",", "str", "(", "user", "....
Make an unique identifier for the user (stored in the session), so it can stay logged between requests. By hashing a snippet of the current password hash salt, it makes possible to automatically logout from all other devices just by changing (or refreshing) the password.
[ "Make", "an", "unique", "identifier", "for", "the", "user", "(", "stored", "in", "the", "session", ")", "so", "it", "can", "stay", "logged", "between", "requests", "." ]
91529b6d0caec07d1452758d937e1e0745826139
https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/utils.py#L42-L60
train
Make an unique identifier for the user and secret.
jpscaletti/authcode
authcode/utils.py
get_token
def get_token(user, secret, timestamp=None): """Make a timestamped one-time-use token that can be used to identifying the user. By hashing the `last_sign_in` attribute and a snippet of the current password hash salt, it produces a token that will be invalidated as soon as the user log in again or t...
python
def get_token(user, secret, timestamp=None): """Make a timestamped one-time-use token that can be used to identifying the user. By hashing the `last_sign_in` attribute and a snippet of the current password hash salt, it produces a token that will be invalidated as soon as the user log in again or t...
[ "def", "get_token", "(", "user", ",", "secret", ",", "timestamp", "=", "None", ")", ":", "timestamp", "=", "int", "(", "timestamp", "or", "time", "(", ")", ")", "secret", "=", "to_bytes", "(", "secret", ")", "key", "=", "'|'", ".", "join", "(", "["...
Make a timestamped one-time-use token that can be used to identifying the user. By hashing the `last_sign_in` attribute and a snippet of the current password hash salt, it produces a token that will be invalidated as soon as the user log in again or the is changed. A hash of the user ID is used, s...
[ "Make", "a", "timestamped", "one", "-", "time", "-", "use", "token", "that", "can", "be", "used", "to", "identifying", "the", "user", "." ]
91529b6d0caec07d1452758d937e1e0745826139
https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/utils.py#L63-L90
train
Generate a timestamped one - time - use token that can be used to identify a user.
jpscaletti/authcode
authcode/utils.py
LazyUser.__get_user
def __get_user(self): """Return the real user object. """ storage = object.__getattribute__(self, '_LazyUser__storage') user = getattr(self.__auth, 'get_user')() setattr(storage, self.__user_name, user) return user
python
def __get_user(self): """Return the real user object. """ storage = object.__getattribute__(self, '_LazyUser__storage') user = getattr(self.__auth, 'get_user')() setattr(storage, self.__user_name, user) return user
[ "def", "__get_user", "(", "self", ")", ":", "storage", "=", "object", ".", "__getattribute__", "(", "self", ",", "'_LazyUser__storage'", ")", "user", "=", "getattr", "(", "self", ".", "__auth", ",", "'get_user'", ")", "(", ")", "setattr", "(", "storage", ...
Return the real user object.
[ "Return", "the", "real", "user", "object", "." ]
91529b6d0caec07d1452758d937e1e0745826139
https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/utils.py#L116-L122
train
Return the real user object.
cloudmesh-cmd3/cmd3
cmd3/plugins/browser.py
browser._expand_filename
def _expand_filename(self, line): """expands the filename if there is a . as leading path""" # expand . newline = line path = os.getcwd() if newline.startswith("."): newline = newline.replace(".", path, 1) # expand ~ newline = os.path.expanduser(newlin...
python
def _expand_filename(self, line): """expands the filename if there is a . as leading path""" # expand . newline = line path = os.getcwd() if newline.startswith("."): newline = newline.replace(".", path, 1) # expand ~ newline = os.path.expanduser(newlin...
[ "def", "_expand_filename", "(", "self", ",", "line", ")", ":", "# expand .", "newline", "=", "line", "path", "=", "os", ".", "getcwd", "(", ")", "if", "newline", ".", "startswith", "(", "\".\"", ")", ":", "newline", "=", "newline", ".", "replace", "(",...
expands the filename if there is a . as leading path
[ "expands", "the", "filename", "if", "there", "is", "a", ".", "as", "leading", "path" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/browser.py#L14-L23
train
expands the filename if there is a. as leading path
cloudmesh-cmd3/cmd3
cmd3/plugins/browser.py
browser.do_open
def do_open(self, args, arguments): """ :: Usage: open FILENAME ARGUMENTS: FILENAME the file to open in the cwd if . is specified. If file in in cwd you must specify it with ./FILENAME ...
python
def do_open(self, args, arguments): """ :: Usage: open FILENAME ARGUMENTS: FILENAME the file to open in the cwd if . is specified. If file in in cwd you must specify it with ./FILENAME ...
[ "def", "do_open", "(", "self", ",", "args", ",", "arguments", ")", ":", "filename", "=", "arguments", "[", "'FILENAME'", "]", "filename", "=", "self", ".", "_expand_filename", "(", "filename", ")", "Console", ".", "ok", "(", "\"open {0}\"", ".", "format", ...
:: Usage: open FILENAME ARGUMENTS: FILENAME the file to open in the cwd if . is specified. If file in in cwd you must specify it with ./FILENAME Opens the given URL in a browser window.
[ "::" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/browser.py#L26-L56
train
Open the given file in a browser window.
jstitch/MambuPy
MambuPy/rest/mambustruct.py
setCustomField
def setCustomField(mambuentity, customfield="", *args, **kwargs): """Modifies the customField field for the given object with something related to the value of the given field. If the dataType == "USER_LINK" then instead of using the value of the CF, it will be a MambuUser object. Same if dataType...
python
def setCustomField(mambuentity, customfield="", *args, **kwargs): """Modifies the customField field for the given object with something related to the value of the given field. If the dataType == "USER_LINK" then instead of using the value of the CF, it will be a MambuUser object. Same if dataType...
[ "def", "setCustomField", "(", "mambuentity", ",", "customfield", "=", "\"\"", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", ".", "import", "mambuuser", "from", ".", "import", "mambuclient", "try", ":", "customFieldValue", "=", "mambuentity", ...
Modifies the customField field for the given object with something related to the value of the given field. If the dataType == "USER_LINK" then instead of using the value of the CF, it will be a MambuUser object. Same if dataType == "CLIENT_LINK", but with a MambuClient. Default case: just uses t...
[ "Modifies", "the", "customField", "field", "for", "the", "given", "object", "with", "something", "related", "to", "the", "value", "of", "the", "given", "field", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambustruct.py#L837-L878
train
Modifies the customField field for the given object with something related to the value of the given field.
jstitch/MambuPy
MambuPy/rest/mambustruct.py
MambuStruct.serializeFields
def serializeFields(data): """Turns every attribute of the Mambu object in to a string representation. If the object is an iterable one, it goes down to each of its elements and turns its attributes too, recursively. The base case is when it's a MambuStruct class (this one) so it ...
python
def serializeFields(data): """Turns every attribute of the Mambu object in to a string representation. If the object is an iterable one, it goes down to each of its elements and turns its attributes too, recursively. The base case is when it's a MambuStruct class (this one) so it ...
[ "def", "serializeFields", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "MambuStruct", ")", ":", "return", "data", ".", "serializeStruct", "(", ")", "try", ":", "it", "=", "iter", "(", "data", ")", "except", "TypeError", "as", "terr", ":...
Turns every attribute of the Mambu object in to a string representation. If the object is an iterable one, it goes down to each of its elements and turns its attributes too, recursively. The base case is when it's a MambuStruct class (this one) so it just 'serializes' the attr atribute...
[ "Turns", "every", "attribute", "of", "the", "Mambu", "object", "in", "to", "a", "string", "representation", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambustruct.py#L121-L150
train
Turns every attribute of the Mambu object in to a string representation.
jstitch/MambuPy
MambuPy/rest/mambustruct.py
MambuStruct.has_key
def has_key(self, key): """Dict-like behaviour""" try: if type(self.attrs) == dict: return key in self.attrs else: raise AttributeError # if attrs is not a dict except AttributeError: # if attrs doesnt exist raise No...
python
def has_key(self, key): """Dict-like behaviour""" try: if type(self.attrs) == dict: return key in self.attrs else: raise AttributeError # if attrs is not a dict except AttributeError: # if attrs doesnt exist raise No...
[ "def", "has_key", "(", "self", ",", "key", ")", ":", "try", ":", "if", "type", "(", "self", ".", "attrs", ")", "==", "dict", ":", "return", "key", "in", "self", ".", "attrs", "else", ":", "raise", "AttributeError", "# if attrs is not a dict", "except", ...
Dict-like behaviour
[ "Dict", "-", "like", "behaviour" ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambustruct.py#L268-L276
train
Check if a key exists in the object.
jstitch/MambuPy
MambuPy/rest/mambustruct.py
MambuStruct.get
def get(self, key, default=None): """Dict-like behaviour""" if type(self.attrs) == dict: return self.attrs.get(key, default) else: raise NotImplementedError
python
def get(self, key, default=None): """Dict-like behaviour""" if type(self.attrs) == dict: return self.attrs.get(key, default) else: raise NotImplementedError
[ "def", "get", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "if", "type", "(", "self", ".", "attrs", ")", "==", "dict", ":", "return", "self", ".", "attrs", ".", "get", "(", "key", ",", "default", ")", "else", ":", "raise", "N...
Dict-like behaviour
[ "Dict", "-", "like", "behaviour" ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambustruct.py#L278-L283
train
Get a key from the attribute dictionary.
jstitch/MambuPy
MambuPy/rest/mambustruct.py
MambuStruct.init
def init(self, attrs={}, *args, **kwargs): """Default initialization from a dictionary responded by Mambu in to the elements of the Mambu object. It assings the response to attrs attribute and converts each of its elements from a string to an adequate python object: number, dat...
python
def init(self, attrs={}, *args, **kwargs): """Default initialization from a dictionary responded by Mambu in to the elements of the Mambu object. It assings the response to attrs attribute and converts each of its elements from a string to an adequate python object: number, dat...
[ "def", "init", "(", "self", ",", "attrs", "=", "{", "}", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "attrs", "=", "attrs", "self", ".", "preprocess", "(", ")", "self", ".", "convertDict2Attrs", "(", "*", "args", ",", "*", ...
Default initialization from a dictionary responded by Mambu in to the elements of the Mambu object. It assings the response to attrs attribute and converts each of its elements from a string to an adequate python object: number, datetime, etc. Basically it stores the response ...
[ "Default", "initialization", "from", "a", "dictionary", "responded", "by", "Mambu" ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambustruct.py#L299-L355
train
Default initialization from a dictionary responded by Mambu.
jstitch/MambuPy
MambuPy/rest/mambustruct.py
MambuStruct.connect
def connect(self, *args, **kwargs): """Connect to Mambu, make the request to the REST API. If there's no urlfunc to use, nothing is done here. When done, initializes the attrs attribute of the Mambu object by calling the init method. Please refer to that code and pydoc for furt...
python
def connect(self, *args, **kwargs): """Connect to Mambu, make the request to the REST API. If there's no urlfunc to use, nothing is done here. When done, initializes the attrs attribute of the Mambu object by calling the init method. Please refer to that code and pydoc for furt...
[ "def", "connect", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "copy", "import", "deepcopy", "if", "args", ":", "self", ".", "__args", "=", "deepcopy", "(", "args", ")", "if", "kwargs", ":", "for", "k", ",", "v", "in"...
Connect to Mambu, make the request to the REST API. If there's no urlfunc to use, nothing is done here. When done, initializes the attrs attribute of the Mambu object by calling the init method. Please refer to that code and pydoc for further information. Uses urllib module to...
[ "Connect", "to", "Mambu", "make", "the", "request", "to", "the", "REST", "API", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambustruct.py#L516-L664
train
Connect to Mambu.
jstitch/MambuPy
MambuPy/rest/mambustruct.py
MambuStruct._process_fields
def _process_fields(self): """Default info massage to appropiate format/style. This processing is called on preprocess and postprocess, AKA before and after conversion of fields to appropiate format/style. Perfect example: custom fields on certain objects is a mess (IMH...
python
def _process_fields(self): """Default info massage to appropiate format/style. This processing is called on preprocess and postprocess, AKA before and after conversion of fields to appropiate format/style. Perfect example: custom fields on certain objects is a mess (IMH...
[ "def", "_process_fields", "(", "self", ")", ":", "try", ":", "try", ":", "if", "self", ".", "has_key", "(", "self", ".", "customFieldName", ")", ":", "self", "[", "self", ".", "customFieldName", "]", "=", "[", "c", "for", "c", "in", "self", "[", "s...
Default info massage to appropiate format/style. This processing is called on preprocess and postprocess, AKA before and after conversion of fields to appropiate format/style. Perfect example: custom fields on certain objects is a mess (IMHO) when retrieved from Mambu, so some ...
[ "Default", "info", "massage", "to", "appropiate", "format", "/", "style", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambustruct.py#L666-L723
train
This method is called by the object s methods to process the fields in the AKA object.
jstitch/MambuPy
MambuPy/rest/mambustruct.py
MambuStruct.convertDict2Attrs
def convertDict2Attrs(self, *args, **kwargs): """Each element on the atttrs attribute gest converted to a proper python object, depending on type. Some default constantFields are left as is (strings), because they are better treated as strings. """ constantFields = ['id'...
python
def convertDict2Attrs(self, *args, **kwargs): """Each element on the atttrs attribute gest converted to a proper python object, depending on type. Some default constantFields are left as is (strings), because they are better treated as strings. """ constantFields = ['id'...
[ "def", "convertDict2Attrs", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "constantFields", "=", "[", "'id'", ",", "'groupName'", ",", "'name'", ",", "'homePhone'", ",", "'mobilePhone1'", ",", "'phoneNumber'", ",", "'postcode'", ",", "'...
Each element on the atttrs attribute gest converted to a proper python object, depending on type. Some default constantFields are left as is (strings), because they are better treated as strings.
[ "Each", "element", "on", "the", "atttrs", "attribute", "gest", "converted", "to", "a", "proper", "python", "object", "depending", "on", "type", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambustruct.py#L739-L791
train
Convert the attributes of the attribute object to a proper python object.
jstitch/MambuPy
MambuPy/rest/mambustruct.py
MambuStruct.util_dateFormat
def util_dateFormat(self, field, formato=None): """Converts a datetime field to a datetime using some specified format. What this really means is that, if specified format includes only for instance just year and month, day and further info gets ignored and the objects get a datetime wi...
python
def util_dateFormat(self, field, formato=None): """Converts a datetime field to a datetime using some specified format. What this really means is that, if specified format includes only for instance just year and month, day and further info gets ignored and the objects get a datetime wi...
[ "def", "util_dateFormat", "(", "self", ",", "field", ",", "formato", "=", "None", ")", ":", "if", "not", "formato", ":", "try", ":", "formato", "=", "self", ".", "__formatoFecha", "except", "AttributeError", ":", "formato", "=", "\"%Y-%m-%dT%H:%M:%S+0000\"", ...
Converts a datetime field to a datetime using some specified format. What this really means is that, if specified format includes only for instance just year and month, day and further info gets ignored and the objects get a datetime with year and month, and day 1, hour 0, minute 0, etc...
[ "Converts", "a", "datetime", "field", "to", "a", "datetime", "using", "some", "specified", "format", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambustruct.py#L793-L814
train
Converts a datetime field to a datetime using some specified format.
jstitch/MambuPy
MambuPy/rest/mambustruct.py
MambuStruct.create
def create(self, data, *args, **kwargs): """Creates an entity in Mambu This method must be implemented in child classes Args: data (dictionary): dictionary with data to send, this dictionary is specific for each Mambu entity """ # if m...
python
def create(self, data, *args, **kwargs): """Creates an entity in Mambu This method must be implemented in child classes Args: data (dictionary): dictionary with data to send, this dictionary is specific for each Mambu entity """ # if m...
[ "def", "create", "(", "self", ",", "data", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# if module of the function is diferent from the module of the object", "# that means create is not implemented in child class", "if", "self", ".", "create", ".", "__func__", ...
Creates an entity in Mambu This method must be implemented in child classes Args: data (dictionary): dictionary with data to send, this dictionary is specific for each Mambu entity
[ "Creates", "an", "entity", "in", "Mambu" ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambustruct.py#L816-L834
train
Creates an entity in Mambu object in the specified object
ExoticObjects/django-sql-server-bcp
django_sql_server_bcp/__init__.py
BCPFormat.make
def make(self, cmd_args, db_args): ''' Runs bcp FORMAT command to create a format file that will assist in creating the bulk data file ''' with NamedTemporaryFile(delete=True) as f: format_file = f.name + '.bcp-format' format_args = cmd_args + ['format', NULL_FILE, '-...
python
def make(self, cmd_args, db_args): ''' Runs bcp FORMAT command to create a format file that will assist in creating the bulk data file ''' with NamedTemporaryFile(delete=True) as f: format_file = f.name + '.bcp-format' format_args = cmd_args + ['format', NULL_FILE, '-...
[ "def", "make", "(", "self", ",", "cmd_args", ",", "db_args", ")", ":", "with", "NamedTemporaryFile", "(", "delete", "=", "True", ")", "as", "f", ":", "format_file", "=", "f", ".", "name", "+", "'.bcp-format'", "format_args", "=", "cmd_args", "+", "[", ...
Runs bcp FORMAT command to create a format file that will assist in creating the bulk data file
[ "Runs", "bcp", "FORMAT", "command", "to", "create", "a", "format", "file", "that", "will", "assist", "in", "creating", "the", "bulk", "data", "file" ]
3bfc593a18091cf837a9c31cbbe7025ecc5e3226
https://github.com/ExoticObjects/django-sql-server-bcp/blob/3bfc593a18091cf837a9c31cbbe7025ecc5e3226/django_sql_server_bcp/__init__.py#L110-L119
train
Runs bcp FORMAT command to create a format file that will assist in creating the bulk data file
ExoticObjects/django-sql-server-bcp
django_sql_server_bcp/__init__.py
BCPFormat.load
def load(self, filename=None): ''' Reads a non-XML bcp FORMAT file and parses it into fields list used for creating bulk data file ''' fields = [] with open(filename, 'r') as f: format_data = f.read().strip() lines = format_data.split('\n') self._sql_...
python
def load(self, filename=None): ''' Reads a non-XML bcp FORMAT file and parses it into fields list used for creating bulk data file ''' fields = [] with open(filename, 'r') as f: format_data = f.read().strip() lines = format_data.split('\n') self._sql_...
[ "def", "load", "(", "self", ",", "filename", "=", "None", ")", ":", "fields", "=", "[", "]", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "format_data", "=", "f", ".", "read", "(", ")", ".", "strip", "(", ")", "lines", "=",...
Reads a non-XML bcp FORMAT file and parses it into fields list used for creating bulk data file
[ "Reads", "a", "non", "-", "XML", "bcp", "FORMAT", "file", "and", "parses", "it", "into", "fields", "list", "used", "for", "creating", "bulk", "data", "file" ]
3bfc593a18091cf837a9c31cbbe7025ecc5e3226
https://github.com/ExoticObjects/django-sql-server-bcp/blob/3bfc593a18091cf837a9c31cbbe7025ecc5e3226/django_sql_server_bcp/__init__.py#L121-L140
train
Reads a non - XML bcp FORMAT file and parses it into fields list used for creating bulk data file
transifex/transifex-python-library
txlib/api/resources.py
Resource.retrieve_content
def retrieve_content(self): """Retrieve the content of a resource.""" path = self._construct_path_to_source_content() res = self._http.get(path) self._populated_fields['content'] = res['content'] return res['content']
python
def retrieve_content(self): """Retrieve the content of a resource.""" path = self._construct_path_to_source_content() res = self._http.get(path) self._populated_fields['content'] = res['content'] return res['content']
[ "def", "retrieve_content", "(", "self", ")", ":", "path", "=", "self", ".", "_construct_path_to_source_content", "(", ")", "res", "=", "self", ".", "_http", ".", "get", "(", "path", ")", "self", ".", "_populated_fields", "[", "'content'", "]", "=", "res", ...
Retrieve the content of a resource.
[ "Retrieve", "the", "content", "of", "a", "resource", "." ]
9fea86b718973de35ccca6d54bd1f445c9632406
https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/api/resources.py#L27-L32
train
Retrieve the content of a resource.
transifex/transifex-python-library
txlib/api/resources.py
Resource._update
def _update(self, **kwargs): """Use separate URL for updating the source file.""" if 'content' in kwargs: content = kwargs.pop('content') path = self._construct_path_to_source_content() self._http.put(path, json.dumps({'content': content})) super(Resource, sel...
python
def _update(self, **kwargs): """Use separate URL for updating the source file.""" if 'content' in kwargs: content = kwargs.pop('content') path = self._construct_path_to_source_content() self._http.put(path, json.dumps({'content': content})) super(Resource, sel...
[ "def", "_update", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "'content'", "in", "kwargs", ":", "content", "=", "kwargs", ".", "pop", "(", "'content'", ")", "path", "=", "self", ".", "_construct_path_to_source_content", "(", ")", "self", ".", ...
Use separate URL for updating the source file.
[ "Use", "separate", "URL", "for", "updating", "the", "source", "file", "." ]
9fea86b718973de35ccca6d54bd1f445c9632406
https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/api/resources.py#L34-L40
train
Use separate URL for updating the source file.
cloudmesh-cmd3/cmd3
fabfile/clean.py
all
def all(): """clean the dis and uninstall cloudmesh""" dir() cmd3() banner("CLEAN PREVIOUS CLOUDMESH INSTALLS") r = int(local("pip freeze |fgrep cloudmesh | wc -l", capture=True)) while r > 0: local('echo "y\n" | pip uninstall cloudmesh') r = int(local("pip freeze |fgrep cloudmes...
python
def all(): """clean the dis and uninstall cloudmesh""" dir() cmd3() banner("CLEAN PREVIOUS CLOUDMESH INSTALLS") r = int(local("pip freeze |fgrep cloudmesh | wc -l", capture=True)) while r > 0: local('echo "y\n" | pip uninstall cloudmesh') r = int(local("pip freeze |fgrep cloudmes...
[ "def", "all", "(", ")", ":", "dir", "(", ")", "cmd3", "(", ")", "banner", "(", "\"CLEAN PREVIOUS CLOUDMESH INSTALLS\"", ")", "r", "=", "int", "(", "local", "(", "\"pip freeze |fgrep cloudmesh | wc -l\"", ",", "capture", "=", "True", ")", ")", "while", "r", ...
clean the dis and uninstall cloudmesh
[ "clean", "the", "dis", "and", "uninstall", "cloudmesh" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/fabfile/clean.py#L24-L32
train
clean the dis and uninstall cloudmesh
frostming/marko
marko/inline.py
InlineElement.find
def find(cls, text): """This method should return an iterable containing matches of this element.""" if isinstance(cls.pattern, string_types): cls.pattern = re.compile(cls.pattern) return cls.pattern.finditer(text)
python
def find(cls, text): """This method should return an iterable containing matches of this element.""" if isinstance(cls.pattern, string_types): cls.pattern = re.compile(cls.pattern) return cls.pattern.finditer(text)
[ "def", "find", "(", "cls", ",", "text", ")", ":", "if", "isinstance", "(", "cls", ".", "pattern", ",", "string_types", ")", ":", "cls", ".", "pattern", "=", "re", ".", "compile", "(", "cls", ".", "pattern", ")", "return", "cls", ".", "pattern", "."...
This method should return an iterable containing matches of this element.
[ "This", "method", "should", "return", "an", "iterable", "containing", "matches", "of", "this", "element", "." ]
1cd030b665fa37bad1f8b3a25a89ce1a7c491dde
https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/inline.py#L39-L43
train
This method should return an iterable containing matches of this element.
youversion/crony
crony/crony.py
main
def main(): """Entry point for running crony. 1. If a --cronitor/-c is specified, a "run" ping is sent to cronitor. 2. The argument string passed to crony is ran. 3. Next steps depend on the exit code of the command ran. * If the exit status is 0 and a --cronitor/-c is specified, a "complete" p...
python
def main(): """Entry point for running crony. 1. If a --cronitor/-c is specified, a "run" ping is sent to cronitor. 2. The argument string passed to crony is ran. 3. Next steps depend on the exit code of the command ran. * If the exit status is 0 and a --cronitor/-c is specified, a "complete" p...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Monitor your crons with cronitor.io & sentry.io'", ",", "epilog", "=", "'https://github.com/youversion/crony'", ",", "prog", "=", "'crony'", ")", "parser", ".", ...
Entry point for running crony. 1. If a --cronitor/-c is specified, a "run" ping is sent to cronitor. 2. The argument string passed to crony is ran. 3. Next steps depend on the exit code of the command ran. * If the exit status is 0 and a --cronitor/-c is specified, a "complete" ping is sent ...
[ "Entry", "point", "for", "running", "crony", "." ]
c93d14b809a2e878f1b9d6d53d5a04947896583b
https://github.com/youversion/crony/blob/c93d14b809a2e878f1b9d6d53d5a04947896583b/crony/crony.py#L232-L290
train
Entry point for the main function of the crony script.
youversion/crony
crony/crony.py
CommandCenter.cronitor
def cronitor(self): """Wrap run with requests to cronitor.""" url = f'https://cronitor.link/{self.opts.cronitor}/{{}}' try: run_url = url.format('run') self.logger.debug(f'Pinging {run_url}') requests.get(run_url, timeout=self.opts.timeout) except re...
python
def cronitor(self): """Wrap run with requests to cronitor.""" url = f'https://cronitor.link/{self.opts.cronitor}/{{}}' try: run_url = url.format('run') self.logger.debug(f'Pinging {run_url}') requests.get(run_url, timeout=self.opts.timeout) except re...
[ "def", "cronitor", "(", "self", ")", ":", "url", "=", "f'https://cronitor.link/{self.opts.cronitor}/{{}}'", "try", ":", "run_url", "=", "url", ".", "format", "(", "'run'", ")", "self", ".", "logger", ".", "debug", "(", "f'Pinging {run_url}'", ")", "requests", ...
Wrap run with requests to cronitor.
[ "Wrap", "run", "with", "requests", "to", "cronitor", "." ]
c93d14b809a2e878f1b9d6d53d5a04947896583b
https://github.com/youversion/crony/blob/c93d14b809a2e878f1b9d6d53d5a04947896583b/crony/crony.py#L76-L100
train
Wrap run with requests to cronitor.
youversion/crony
crony/crony.py
CommandCenter.load_config
def load_config(self, custom_config): """Attempt to load config from file. If the command specified a --config parameter, then load that config file. Otherwise, the user's home directory takes precedence over a system wide config. Config file in the user's dir should be named ".cronyrc"...
python
def load_config(self, custom_config): """Attempt to load config from file. If the command specified a --config parameter, then load that config file. Otherwise, the user's home directory takes precedence over a system wide config. Config file in the user's dir should be named ".cronyrc"...
[ "def", "load_config", "(", "self", ",", "custom_config", ")", ":", "self", ".", "config", "=", "configparser", ".", "ConfigParser", "(", ")", "if", "custom_config", ":", "self", ".", "config", ".", "read", "(", "custom_config", ")", "return", "f'Loading conf...
Attempt to load config from file. If the command specified a --config parameter, then load that config file. Otherwise, the user's home directory takes precedence over a system wide config. Config file in the user's dir should be named ".cronyrc". System wide config should be located at...
[ "Attempt", "to", "load", "config", "from", "file", "." ]
c93d14b809a2e878f1b9d6d53d5a04947896583b
https://github.com/youversion/crony/blob/c93d14b809a2e878f1b9d6d53d5a04947896583b/crony/crony.py#L102-L127
train
Attempt to load config from file.
youversion/crony
crony/crony.py
CommandCenter.log
def log(self, output, exit_status): """Log given CompletedProcess and return exit status code.""" if exit_status != 0: self.logger.error(f'Error running command! Exit status: {exit_status}, {output}') return exit_status
python
def log(self, output, exit_status): """Log given CompletedProcess and return exit status code.""" if exit_status != 0: self.logger.error(f'Error running command! Exit status: {exit_status}, {output}') return exit_status
[ "def", "log", "(", "self", ",", "output", ",", "exit_status", ")", ":", "if", "exit_status", "!=", "0", ":", "self", ".", "logger", ".", "error", "(", "f'Error running command! Exit status: {exit_status}, {output}'", ")", "return", "exit_status" ]
Log given CompletedProcess and return exit status code.
[ "Log", "given", "CompletedProcess", "and", "return", "exit", "status", "code", "." ]
c93d14b809a2e878f1b9d6d53d5a04947896583b
https://github.com/youversion/crony/blob/c93d14b809a2e878f1b9d6d53d5a04947896583b/crony/crony.py#L129-L134
train
Log given CompletedProcess and return exit status code.
youversion/crony
crony/crony.py
CommandCenter.run
def run(self): """Run command and report errors to Sentry.""" self.logger.debug(f'Running command: {self.cmd}') def execute(cmd): output = "" popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_ne...
python
def run(self): """Run command and report errors to Sentry.""" self.logger.debug(f'Running command: {self.cmd}') def execute(cmd): output = "" popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_ne...
[ "def", "run", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "f'Running command: {self.cmd}'", ")", "def", "execute", "(", "cmd", ")", ":", "output", "=", "\"\"", "popen", "=", "subprocess", ".", "Popen", "(", "cmd", ",", "stdout", "=...
Run command and report errors to Sentry.
[ "Run", "command", "and", "report", "errors", "to", "Sentry", "." ]
c93d14b809a2e878f1b9d6d53d5a04947896583b
https://github.com/youversion/crony/blob/c93d14b809a2e878f1b9d6d53d5a04947896583b/crony/crony.py#L136-L158
train
Run command and report errors to Sentry.
youversion/crony
crony/crony.py
CommandCenter.setup_dir
def setup_dir(self): """Change directory for script if necessary.""" cd = self.opts.cd or self.config['crony'].get('directory') if cd: self.logger.debug(f'Adding cd to {cd}') self.cmd = f'cd {cd} && {self.cmd}'
python
def setup_dir(self): """Change directory for script if necessary.""" cd = self.opts.cd or self.config['crony'].get('directory') if cd: self.logger.debug(f'Adding cd to {cd}') self.cmd = f'cd {cd} && {self.cmd}'
[ "def", "setup_dir", "(", "self", ")", ":", "cd", "=", "self", ".", "opts", ".", "cd", "or", "self", ".", "config", "[", "'crony'", "]", ".", "get", "(", "'directory'", ")", "if", "cd", ":", "self", ".", "logger", ".", "debug", "(", "f'Adding cd to ...
Change directory for script if necessary.
[ "Change", "directory", "for", "script", "if", "necessary", "." ]
c93d14b809a2e878f1b9d6d53d5a04947896583b
https://github.com/youversion/crony/blob/c93d14b809a2e878f1b9d6d53d5a04947896583b/crony/crony.py#L160-L165
train
Change directory for script if necessary.
youversion/crony
crony/crony.py
CommandCenter.setup_logging
def setup_logging(self): """Setup python logging handler.""" date_format = '%Y-%m-%dT%H:%M:%S' log_format = '%(asctime)s %(levelname)s: %(message)s' if self.opts.verbose: lvl = logging.DEBUG else: lvl = logging.INFO # Requests is a bit chatty ...
python
def setup_logging(self): """Setup python logging handler.""" date_format = '%Y-%m-%dT%H:%M:%S' log_format = '%(asctime)s %(levelname)s: %(message)s' if self.opts.verbose: lvl = logging.DEBUG else: lvl = logging.INFO # Requests is a bit chatty ...
[ "def", "setup_logging", "(", "self", ")", ":", "date_format", "=", "'%Y-%m-%dT%H:%M:%S'", "log_format", "=", "'%(asctime)s %(levelname)s: %(message)s'", "if", "self", ".", "opts", ".", "verbose", ":", "lvl", "=", "logging", ".", "DEBUG", "else", ":", "lvl", "=",...
Setup python logging handler.
[ "Setup", "python", "logging", "handler", "." ]
c93d14b809a2e878f1b9d6d53d5a04947896583b
https://github.com/youversion/crony/blob/c93d14b809a2e878f1b9d6d53d5a04947896583b/crony/crony.py#L167-L207
train
Setup python logging handler.
youversion/crony
crony/crony.py
CommandCenter.setup_path
def setup_path(self): """Setup PATH env var if necessary.""" path = self.opts.path or self.config['crony'].get('path') if path: self.logger.debug(f'Adding {path} to PATH environment variable') self.cmd = f'export PATH={path}:$PATH && {self.cmd}'
python
def setup_path(self): """Setup PATH env var if necessary.""" path = self.opts.path or self.config['crony'].get('path') if path: self.logger.debug(f'Adding {path} to PATH environment variable') self.cmd = f'export PATH={path}:$PATH && {self.cmd}'
[ "def", "setup_path", "(", "self", ")", ":", "path", "=", "self", ".", "opts", ".", "path", "or", "self", ".", "config", "[", "'crony'", "]", ".", "get", "(", "'path'", ")", "if", "path", ":", "self", ".", "logger", ".", "debug", "(", "f'Adding {pat...
Setup PATH env var if necessary.
[ "Setup", "PATH", "env", "var", "if", "necessary", "." ]
c93d14b809a2e878f1b9d6d53d5a04947896583b
https://github.com/youversion/crony/blob/c93d14b809a2e878f1b9d6d53d5a04947896583b/crony/crony.py#L209-L214
train
Setup PATH env var if necessary.
youversion/crony
crony/crony.py
CommandCenter.setup_venv
def setup_venv(self): """Setup virtualenv if necessary.""" venv = self.opts.venv if not venv: venv = os.environ.get('CRONY_VENV') if not venv and self.config['crony']: venv = self.config['crony'].get('venv') if venv: if not venv.endswit...
python
def setup_venv(self): """Setup virtualenv if necessary.""" venv = self.opts.venv if not venv: venv = os.environ.get('CRONY_VENV') if not venv and self.config['crony']: venv = self.config['crony'].get('venv') if venv: if not venv.endswit...
[ "def", "setup_venv", "(", "self", ")", ":", "venv", "=", "self", ".", "opts", ".", "venv", "if", "not", "venv", ":", "venv", "=", "os", ".", "environ", ".", "get", "(", "'CRONY_VENV'", ")", "if", "not", "venv", "and", "self", ".", "config", "[", ...
Setup virtualenv if necessary.
[ "Setup", "virtualenv", "if", "necessary", "." ]
c93d14b809a2e878f1b9d6d53d5a04947896583b
https://github.com/youversion/crony/blob/c93d14b809a2e878f1b9d6d53d5a04947896583b/crony/crony.py#L216-L229
train
Setup virtualenv if necessary.
rsgalloway/grit
grit/repo/local.py
get_repos
def get_repos(path): """ Returns list of found branches. :return: List of grit.Local objects """ p = str(path) ret = [] if not os.path.exists(p): return ret for d in os.listdir(p): pd = os.path.join(p, d) if os.path.exists(pd) and is_repo(pd): ret.app...
python
def get_repos(path): """ Returns list of found branches. :return: List of grit.Local objects """ p = str(path) ret = [] if not os.path.exists(p): return ret for d in os.listdir(p): pd = os.path.join(p, d) if os.path.exists(pd) and is_repo(pd): ret.app...
[ "def", "get_repos", "(", "path", ")", ":", "p", "=", "str", "(", "path", ")", "ret", "=", "[", "]", "if", "not", "os", ".", "path", ".", "exists", "(", "p", ")", ":", "return", "ret", "for", "d", "in", "os", ".", "listdir", "(", "p", ")", "...
Returns list of found branches. :return: List of grit.Local objects
[ "Returns", "list", "of", "found", "branches", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/local.py#L32-L46
train
Returns list of found branches.
rsgalloway/grit
grit/repo/local.py
get_repo_parent
def get_repo_parent(path): """ Returns parent repo or input path if none found. :return: grit.Local or path """ # path is a repository if is_repo(path): return Local(path) # path is inside a repository elif not os.path.isdir(path): _rel = '' while path and path ...
python
def get_repo_parent(path): """ Returns parent repo or input path if none found. :return: grit.Local or path """ # path is a repository if is_repo(path): return Local(path) # path is inside a repository elif not os.path.isdir(path): _rel = '' while path and path ...
[ "def", "get_repo_parent", "(", "path", ")", ":", "# path is a repository", "if", "is_repo", "(", "path", ")", ":", "return", "Local", "(", "path", ")", "# path is inside a repository", "elif", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", ...
Returns parent repo or input path if none found. :return: grit.Local or path
[ "Returns", "parent", "repo", "or", "input", "path", "if", "none", "found", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/local.py#L48-L67
train
Returns parent repo or input path if none found.