id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
43,100
woolfson-group/isambard
isambard/add_ons/knobs_into_holes.py
KnobGroup.get_coiledcoil_region
def get_coiledcoil_region(self, cc_number=0, cutoff=7.0, min_kihs=2): """ Assembly containing only assigned regions (i.e. regions with contiguous KnobsIntoHoles. """ g = self.filter_graph(self.graph, cutoff=cutoff, min_kihs=min_kihs) ccs = sorted(networkx.connected_component_subgraphs(g, copy=Tr...
python
def get_coiledcoil_region(self, cc_number=0, cutoff=7.0, min_kihs=2): """ Assembly containing only assigned regions (i.e. regions with contiguous KnobsIntoHoles. """ g = self.filter_graph(self.graph, cutoff=cutoff, min_kihs=min_kihs) ccs = sorted(networkx.connected_component_subgraphs(g, copy=Tr...
[ "def", "get_coiledcoil_region", "(", "self", ",", "cc_number", "=", "0", ",", "cutoff", "=", "7.0", ",", "min_kihs", "=", "2", ")", ":", "g", "=", "self", ".", "filter_graph", "(", "self", ".", "graph", ",", "cutoff", "=", "cutoff", ",", "min_kihs", ...
Assembly containing only assigned regions (i.e. regions with contiguous KnobsIntoHoles.
[ "Assembly", "containing", "only", "assigned", "regions", "(", "i", ".", "e", ".", "regions", "with", "contiguous", "KnobsIntoHoles", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/add_ons/knobs_into_holes.py#L304-L313
43,101
woolfson-group/isambard
isambard/add_ons/knobs_into_holes.py
KnobGroup.daisy_chain_graph
def daisy_chain_graph(self): """ Directed graph with edges from knob residue to each hole residue for each KnobIntoHole in self. """ g = networkx.DiGraph() for x in self.get_monomers(): for h in x.hole: g.add_edge(x.knob, h) return g
python
def daisy_chain_graph(self): """ Directed graph with edges from knob residue to each hole residue for each KnobIntoHole in self. """ g = networkx.DiGraph() for x in self.get_monomers(): for h in x.hole: g.add_edge(x.knob, h) return g
[ "def", "daisy_chain_graph", "(", "self", ")", ":", "g", "=", "networkx", ".", "DiGraph", "(", ")", "for", "x", "in", "self", ".", "get_monomers", "(", ")", ":", "for", "h", "in", "x", ".", "hole", ":", "g", ".", "add_edge", "(", "x", ".", "knob",...
Directed graph with edges from knob residue to each hole residue for each KnobIntoHole in self.
[ "Directed", "graph", "with", "edges", "from", "knob", "residue", "to", "each", "hole", "residue", "for", "each", "KnobIntoHole", "in", "self", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/add_ons/knobs_into_holes.py#L316-L322
43,102
woolfson-group/isambard
isambard/add_ons/knobs_into_holes.py
KnobIntoHole.knob_end
def knob_end(self): """ Coordinates of the end of the knob residue (atom in side-chain furthest from CB atom. Returns CA coordinates for GLY. """ side_chain_atoms = self.knob_residue.side_chain if not side_chain_atoms: return self.knob_residue['CA'] distances ...
python
def knob_end(self): """ Coordinates of the end of the knob residue (atom in side-chain furthest from CB atom. Returns CA coordinates for GLY. """ side_chain_atoms = self.knob_residue.side_chain if not side_chain_atoms: return self.knob_residue['CA'] distances ...
[ "def", "knob_end", "(", "self", ")", ":", "side_chain_atoms", "=", "self", ".", "knob_residue", ".", "side_chain", "if", "not", "side_chain_atoms", ":", "return", "self", ".", "knob_residue", "[", "'CA'", "]", "distances", "=", "[", "distance", "(", "self", ...
Coordinates of the end of the knob residue (atom in side-chain furthest from CB atom. Returns CA coordinates for GLY.
[ "Coordinates", "of", "the", "end", "of", "the", "knob", "residue", "(", "atom", "in", "side", "-", "chain", "furthest", "from", "CB", "atom", ".", "Returns", "CA", "coordinates", "for", "GLY", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/add_ons/knobs_into_holes.py#L440-L453
43,103
woolfson-group/isambard
isambard/add_ons/knobs_into_holes.py
KnobIntoHole.max_knob_end_distance
def max_knob_end_distance(self): """ Maximum distance between knob_end and each of the hole side-chain centres. """ return max([distance(self.knob_end, h) for h in self.hole])
python
def max_knob_end_distance(self): """ Maximum distance between knob_end and each of the hole side-chain centres. """ return max([distance(self.knob_end, h) for h in self.hole])
[ "def", "max_knob_end_distance", "(", "self", ")", ":", "return", "max", "(", "[", "distance", "(", "self", ".", "knob_end", ",", "h", ")", "for", "h", "in", "self", ".", "hole", "]", ")" ]
Maximum distance between knob_end and each of the hole side-chain centres.
[ "Maximum", "distance", "between", "knob_end", "and", "each", "of", "the", "hole", "side", "-", "chain", "centres", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/add_ons/knobs_into_holes.py#L471-L473
43,104
woolfson-group/isambard
isambard/configure.py
base_install
def base_install(): """Generates configuration setting for required functionality of ISAMBARD.""" # scwrl scwrl = {} print('{BOLD}{HEADER}Generating configuration files for ISAMBARD.{END_C}\n' 'All required input can use tab completion for paths.\n' '{BOLD}Setting up SCWRL 4.0 (Recom...
python
def base_install(): """Generates configuration setting for required functionality of ISAMBARD.""" # scwrl scwrl = {} print('{BOLD}{HEADER}Generating configuration files for ISAMBARD.{END_C}\n' 'All required input can use tab completion for paths.\n' '{BOLD}Setting up SCWRL 4.0 (Recom...
[ "def", "base_install", "(", ")", ":", "# scwrl", "scwrl", "=", "{", "}", "print", "(", "'{BOLD}{HEADER}Generating configuration files for ISAMBARD.{END_C}\\n'", "'All required input can use tab completion for paths.\\n'", "'{BOLD}Setting up SCWRL 4.0 (Recommended){END_C}'", ".", "for...
Generates configuration setting for required functionality of ISAMBARD.
[ "Generates", "configuration", "setting", "for", "required", "functionality", "of", "ISAMBARD", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/configure.py#L60-L98
43,105
woolfson-group/isambard
isambard/configure.py
optional_install
def optional_install(): """Generates configuration settings for optional functionality of ISAMBARD.""" # reduce print('{BOLD}Setting up Reduce (optional){END_C}'.format(**text_colours)) reduce = {} reduce_path = get_user_path('Please provide a path to your reduce executable.', required=False) re...
python
def optional_install(): """Generates configuration settings for optional functionality of ISAMBARD.""" # reduce print('{BOLD}Setting up Reduce (optional){END_C}'.format(**text_colours)) reduce = {} reduce_path = get_user_path('Please provide a path to your reduce executable.', required=False) re...
[ "def", "optional_install", "(", ")", ":", "# reduce", "print", "(", "'{BOLD}Setting up Reduce (optional){END_C}'", ".", "format", "(", "*", "*", "text_colours", ")", ")", "reduce", "=", "{", "}", "reduce_path", "=", "get_user_path", "(", "'Please provide a path to y...
Generates configuration settings for optional functionality of ISAMBARD.
[ "Generates", "configuration", "settings", "for", "optional", "functionality", "of", "ISAMBARD", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/configure.py#L101-L124
43,106
woolfson-group/isambard
isambard/ampal/pseudo_atoms.py
PseudoMonomer.pdb
def pdb(self): """Generates a PDB string for the `PseudoMonomer`.""" pdb_str = write_pdb( [self], ' ' if not self.tags['chain_id'] else self.tags['chain_id']) return pdb_str
python
def pdb(self): """Generates a PDB string for the `PseudoMonomer`.""" pdb_str = write_pdb( [self], ' ' if not self.tags['chain_id'] else self.tags['chain_id']) return pdb_str
[ "def", "pdb", "(", "self", ")", ":", "pdb_str", "=", "write_pdb", "(", "[", "self", "]", ",", "' '", "if", "not", "self", ".", "tags", "[", "'chain_id'", "]", "else", "self", ".", "tags", "[", "'chain_id'", "]", ")", "return", "pdb_str" ]
Generates a PDB string for the `PseudoMonomer`.
[ "Generates", "a", "PDB", "string", "for", "the", "PseudoMonomer", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/pseudo_atoms.py#L129-L133
43,107
woolfson-group/isambard
isambard/ampal/pseudo_atoms.py
Primitive.from_coordinates
def from_coordinates(cls, coordinates): """Creates a `Primitive` from a list of coordinates.""" prim = cls() for coord in coordinates: pm = PseudoMonomer(ampal_parent=prim) pa = PseudoAtom(coord, ampal_parent=pm) pm.atoms = OrderedDict([('CA', pa)]) ...
python
def from_coordinates(cls, coordinates): """Creates a `Primitive` from a list of coordinates.""" prim = cls() for coord in coordinates: pm = PseudoMonomer(ampal_parent=prim) pa = PseudoAtom(coord, ampal_parent=pm) pm.atoms = OrderedDict([('CA', pa)]) ...
[ "def", "from_coordinates", "(", "cls", ",", "coordinates", ")", ":", "prim", "=", "cls", "(", ")", "for", "coord", "in", "coordinates", ":", "pm", "=", "PseudoMonomer", "(", "ampal_parent", "=", "prim", ")", "pa", "=", "PseudoAtom", "(", "coord", ",", ...
Creates a `Primitive` from a list of coordinates.
[ "Creates", "a", "Primitive", "from", "a", "list", "of", "coordinates", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/pseudo_atoms.py#L259-L268
43,108
woolfson-group/isambard
isambard/ampal/pseudo_atoms.py
Primitive.rise_per_residue
def rise_per_residue(self): """The rise per residue at each point on the Primitive. Notes ----- Each element of the returned list is the rise per residue, at a point on the Primitive. Element i is the distance between primitive[i] and primitive[i + 1]. The final value ...
python
def rise_per_residue(self): """The rise per residue at each point on the Primitive. Notes ----- Each element of the returned list is the rise per residue, at a point on the Primitive. Element i is the distance between primitive[i] and primitive[i + 1]. The final value ...
[ "def", "rise_per_residue", "(", "self", ")", ":", "rprs", "=", "[", "distance", "(", "self", "[", "i", "]", "[", "'CA'", "]", ",", "self", "[", "i", "+", "1", "]", "[", "'CA'", "]", ")", "for", "i", "in", "range", "(", "len", "(", "self", ")"...
The rise per residue at each point on the Primitive. Notes ----- Each element of the returned list is the rise per residue, at a point on the Primitive. Element i is the distance between primitive[i] and primitive[i + 1]. The final value is None.
[ "The", "rise", "per", "residue", "at", "each", "point", "on", "the", "Primitive", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/pseudo_atoms.py#L275-L288
43,109
woolfson-group/isambard
isambard/ampal/nucleic_acid.py
Polynucleotide.sequence
def sequence(self): """Returns the sequence of the `Polynucleotide` as a string. Returns ------- sequence : str String of the monomer sequence of the `Polynucleotide`. """ seq = [x.mol_code for x in self._monomers] return ' '.join(seq)
python
def sequence(self): """Returns the sequence of the `Polynucleotide` as a string. Returns ------- sequence : str String of the monomer sequence of the `Polynucleotide`. """ seq = [x.mol_code for x in self._monomers] return ' '.join(seq)
[ "def", "sequence", "(", "self", ")", ":", "seq", "=", "[", "x", ".", "mol_code", "for", "x", "in", "self", ".", "_monomers", "]", "return", "' '", ".", "join", "(", "seq", ")" ]
Returns the sequence of the `Polynucleotide` as a string. Returns ------- sequence : str String of the monomer sequence of the `Polynucleotide`.
[ "Returns", "the", "sequence", "of", "the", "Polynucleotide", "as", "a", "string", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/nucleic_acid.py#L56-L65
43,110
woolfson-group/isambard
isambard/external_programs/dssp.py
run_dssp
def run_dssp(pdb, path=True, outfile=None): """Uses DSSP to find helices and extracts helices from a pdb file or string. Parameters ---------- pdb : str Path to pdb file or string. path : bool, optional Indicates if pdb is a path or a string. outfile : str, optional File...
python
def run_dssp(pdb, path=True, outfile=None): """Uses DSSP to find helices and extracts helices from a pdb file or string. Parameters ---------- pdb : str Path to pdb file or string. path : bool, optional Indicates if pdb is a path or a string. outfile : str, optional File...
[ "def", "run_dssp", "(", "pdb", ",", "path", "=", "True", ",", "outfile", "=", "None", ")", ":", "if", "not", "path", ":", "if", "type", "(", "pdb", ")", "==", "str", ":", "pdb", "=", "pdb", ".", "encode", "(", ")", "try", ":", "temp_pdb", "=", ...
Uses DSSP to find helices and extracts helices from a pdb file or string. Parameters ---------- pdb : str Path to pdb file or string. path : bool, optional Indicates if pdb is a path or a string. outfile : str, optional Filepath for storing the dssp output. Returns ...
[ "Uses", "DSSP", "to", "find", "helices", "and", "extracts", "helices", "from", "a", "pdb", "file", "or", "string", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/external_programs/dssp.py#L37-L76
43,111
woolfson-group/isambard
isambard/external_programs/dssp.py
extract_solvent_accessibility_dssp
def extract_solvent_accessibility_dssp(in_dssp, path=True): """Uses DSSP to extract solvent accessibilty information on every residue. Notes ----- For more information on the solvent accessibility metrics used in dssp, see: http://swift.cmbi.ru.nl/gv/dssp/HTML/descrip.html#ACC In the dssp files...
python
def extract_solvent_accessibility_dssp(in_dssp, path=True): """Uses DSSP to extract solvent accessibilty information on every residue. Notes ----- For more information on the solvent accessibility metrics used in dssp, see: http://swift.cmbi.ru.nl/gv/dssp/HTML/descrip.html#ACC In the dssp files...
[ "def", "extract_solvent_accessibility_dssp", "(", "in_dssp", ",", "path", "=", "True", ")", ":", "if", "path", ":", "with", "open", "(", "in_dssp", ",", "'r'", ")", "as", "inf", ":", "dssp_out", "=", "inf", ".", "read", "(", ")", "else", ":", "dssp_out...
Uses DSSP to extract solvent accessibilty information on every residue. Notes ----- For more information on the solvent accessibility metrics used in dssp, see: http://swift.cmbi.ru.nl/gv/dssp/HTML/descrip.html#ACC In the dssp files value is labeled 'ACC'. Parameters ---------- in_dssp...
[ "Uses", "DSSP", "to", "extract", "solvent", "accessibilty", "information", "on", "every", "residue", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/external_programs/dssp.py#L128-L177
43,112
woolfson-group/isambard
isambard/external_programs/dssp.py
extract_helices_dssp
def extract_helices_dssp(in_pdb): """Uses DSSP to find alpha-helices and extracts helices from a pdb file. Returns a length 3 list with a helix id, the chain id and a dict containing the coordinates of each residues CA. Parameters ---------- in_pdb : string Path to a PDB file. """ ...
python
def extract_helices_dssp(in_pdb): """Uses DSSP to find alpha-helices and extracts helices from a pdb file. Returns a length 3 list with a helix id, the chain id and a dict containing the coordinates of each residues CA. Parameters ---------- in_pdb : string Path to a PDB file. """ ...
[ "def", "extract_helices_dssp", "(", "in_pdb", ")", ":", "from", "ampal", ".", "pdb_parser", "import", "split_pdb_lines", "dssp_out", "=", "subprocess", ".", "check_output", "(", "[", "global_settings", "[", "'dssp'", "]", "[", "'path'", "]", ",", "in_pdb", "]"...
Uses DSSP to find alpha-helices and extracts helices from a pdb file. Returns a length 3 list with a helix id, the chain id and a dict containing the coordinates of each residues CA. Parameters ---------- in_pdb : string Path to a PDB file.
[ "Uses", "DSSP", "to", "find", "alpha", "-", "helices", "and", "extracts", "helices", "from", "a", "pdb", "file", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/external_programs/dssp.py#L180-L220
43,113
woolfson-group/isambard
isambard/external_programs/dssp.py
extract_pp_helices
def extract_pp_helices(in_pdb): """Uses DSSP to find polyproline helices in a pdb file. Returns a length 3 list with a helix id, the chain id and a dict containing the coordinates of each residues CA. Parameters ---------- in_pdb : string Path to a PDB file. """ t_phi = -75.0 ...
python
def extract_pp_helices(in_pdb): """Uses DSSP to find polyproline helices in a pdb file. Returns a length 3 list with a helix id, the chain id and a dict containing the coordinates of each residues CA. Parameters ---------- in_pdb : string Path to a PDB file. """ t_phi = -75.0 ...
[ "def", "extract_pp_helices", "(", "in_pdb", ")", ":", "t_phi", "=", "-", "75.0", "t_phi_d", "=", "29.0", "t_psi", "=", "145.0", "t_psi_d", "=", "29.0", "pph_dssp", "=", "subprocess", ".", "check_output", "(", "[", "global_settings", "[", "'dssp'", "]", "["...
Uses DSSP to find polyproline helices in a pdb file. Returns a length 3 list with a helix id, the chain id and a dict containing the coordinates of each residues CA. Parameters ---------- in_pdb : string Path to a PDB file.
[ "Uses", "DSSP", "to", "find", "polyproline", "helices", "in", "a", "pdb", "file", "." ]
ebc33b48a28ad217e18f93b910dfba46e6e71e07
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/external_programs/dssp.py#L223-L283
43,114
travispavek/testrail-python
examples/end_to_end_example.py
main
def main(): """ This will offer a step by step guide to create a new run in TestRail, update tests in the run with results, and close the run """ # Parse command line arguments args = get_args() # Instantiate the TestRail client # Use the CLI argument to identify which project to work w...
python
def main(): """ This will offer a step by step guide to create a new run in TestRail, update tests in the run with results, and close the run """ # Parse command line arguments args = get_args() # Instantiate the TestRail client # Use the CLI argument to identify which project to work w...
[ "def", "main", "(", ")", ":", "# Parse command line arguments", "args", "=", "get_args", "(", ")", "# Instantiate the TestRail client", "# Use the CLI argument to identify which project to work with", "tr", "=", "TestRail", "(", "project_dict", "[", "args", ".", "project", ...
This will offer a step by step guide to create a new run in TestRail, update tests in the run with results, and close the run
[ "This", "will", "offer", "a", "step", "by", "step", "guide", "to", "create", "a", "new", "run", "in", "TestRail", "update", "tests", "in", "the", "run", "with", "results", "and", "close", "the", "run" ]
3064432e913c27218078aa7831b9bac7422dd2cb
https://github.com/travispavek/testrail-python/blob/3064432e913c27218078aa7831b9bac7422dd2cb/examples/end_to_end_example.py#L27-L85
43,115
GGiecold/DBSCAN_multiplex
DBSCAN_multiplex.py
memory
def memory(): """Determine the machine's memory specifications. Returns ------- mem_info : dictonary Holds the current values for the total, free and used memory of the system. """ mem_info = {} if platform.linux_distribution()[0]: with open('/proc/meminfo') as file: ...
python
def memory(): """Determine the machine's memory specifications. Returns ------- mem_info : dictonary Holds the current values for the total, free and used memory of the system. """ mem_info = {} if platform.linux_distribution()[0]: with open('/proc/meminfo') as file: ...
[ "def", "memory", "(", ")", ":", "mem_info", "=", "{", "}", "if", "platform", ".", "linux_distribution", "(", ")", "[", "0", "]", ":", "with", "open", "(", "'/proc/meminfo'", ")", "as", "file", ":", "c", "=", "0", "for", "line", "in", "file", ":", ...
Determine the machine's memory specifications. Returns ------- mem_info : dictonary Holds the current values for the total, free and used memory of the system.
[ "Determine", "the", "machine", "s", "memory", "specifications", "." ]
075b1eec86d0e75166a9378d7d9a8974fc0a5e2e
https://github.com/GGiecold/DBSCAN_multiplex/blob/075b1eec86d0e75166a9378d7d9a8974fc0a5e2e/DBSCAN_multiplex.py#L92-L148
43,116
GGiecold/DBSCAN_multiplex
DBSCAN_multiplex.py
get_chunk_size
def get_chunk_size(N, n): """Given a dimension of size 'N', determine the number of rows or columns that can fit into memory. Parameters ---------- N : int The size of one of the dimension of a two-dimensional array. n : int The number of times an 'N' by 'chunks_size' arr...
python
def get_chunk_size(N, n): """Given a dimension of size 'N', determine the number of rows or columns that can fit into memory. Parameters ---------- N : int The size of one of the dimension of a two-dimensional array. n : int The number of times an 'N' by 'chunks_size' arr...
[ "def", "get_chunk_size", "(", "N", ",", "n", ")", ":", "mem_free", "=", "memory", "(", ")", "[", "'free'", "]", "if", "mem_free", ">", "60000000", ":", "chunks_size", "=", "int", "(", "(", "(", "mem_free", "-", "10000000", ")", "*", "1000", ")", "/...
Given a dimension of size 'N', determine the number of rows or columns that can fit into memory. Parameters ---------- N : int The size of one of the dimension of a two-dimensional array. n : int The number of times an 'N' by 'chunks_size' array can fit in memory. Return...
[ "Given", "a", "dimension", "of", "size", "N", "determine", "the", "number", "of", "rows", "or", "columns", "that", "can", "fit", "into", "memory", "." ]
075b1eec86d0e75166a9378d7d9a8974fc0a5e2e
https://github.com/GGiecold/DBSCAN_multiplex/blob/075b1eec86d0e75166a9378d7d9a8974fc0a5e2e/DBSCAN_multiplex.py#L151-L191
43,117
Wiredcraft/dopy
dopy/manager.py
DoManager.all_floating_ips
def all_floating_ips(self): """ Lists all of the Floating IPs available on the account. """ if self.api_version == 2: json = self.request('/floating_ips') return json['floating_ips'] else: raise DoError(v2_api_required_str)
python
def all_floating_ips(self): """ Lists all of the Floating IPs available on the account. """ if self.api_version == 2: json = self.request('/floating_ips') return json['floating_ips'] else: raise DoError(v2_api_required_str)
[ "def", "all_floating_ips", "(", "self", ")", ":", "if", "self", ".", "api_version", "==", "2", ":", "json", "=", "self", ".", "request", "(", "'/floating_ips'", ")", "return", "json", "[", "'floating_ips'", "]", "else", ":", "raise", "DoError", "(", "v2_...
Lists all of the Floating IPs available on the account.
[ "Lists", "all", "of", "the", "Floating", "IPs", "available", "on", "the", "account", "." ]
8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0
https://github.com/Wiredcraft/dopy/blob/8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0/dopy/manager.py#L462-L470
43,118
Wiredcraft/dopy
dopy/manager.py
DoManager.new_floating_ip
def new_floating_ip(self, **kwargs): """ Creates a Floating IP and assigns it to a Droplet or reserves it to a region. """ droplet_id = kwargs.get('droplet_id') region = kwargs.get('region') if self.api_version == 2: if droplet_id is not None and region is no...
python
def new_floating_ip(self, **kwargs): """ Creates a Floating IP and assigns it to a Droplet or reserves it to a region. """ droplet_id = kwargs.get('droplet_id') region = kwargs.get('region') if self.api_version == 2: if droplet_id is not None and region is no...
[ "def", "new_floating_ip", "(", "self", ",", "*", "*", "kwargs", ")", ":", "droplet_id", "=", "kwargs", ".", "get", "(", "'droplet_id'", ")", "region", "=", "kwargs", ".", "get", "(", "'region'", ")", "if", "self", ".", "api_version", "==", "2", ":", ...
Creates a Floating IP and assigns it to a Droplet or reserves it to a region.
[ "Creates", "a", "Floating", "IP", "and", "assigns", "it", "to", "a", "Droplet", "or", "reserves", "it", "to", "a", "region", "." ]
8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0
https://github.com/Wiredcraft/dopy/blob/8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0/dopy/manager.py#L472-L495
43,119
Wiredcraft/dopy
dopy/manager.py
DoManager.destroy_floating_ip
def destroy_floating_ip(self, ip_addr): """ Deletes a Floating IP and removes it from the account. """ if self.api_version == 2: self.request('/floating_ips/' + ip_addr, method='DELETE') else: raise DoError(v2_api_required_str)
python
def destroy_floating_ip(self, ip_addr): """ Deletes a Floating IP and removes it from the account. """ if self.api_version == 2: self.request('/floating_ips/' + ip_addr, method='DELETE') else: raise DoError(v2_api_required_str)
[ "def", "destroy_floating_ip", "(", "self", ",", "ip_addr", ")", ":", "if", "self", ".", "api_version", "==", "2", ":", "self", ".", "request", "(", "'/floating_ips/'", "+", "ip_addr", ",", "method", "=", "'DELETE'", ")", "else", ":", "raise", "DoError", ...
Deletes a Floating IP and removes it from the account.
[ "Deletes", "a", "Floating", "IP", "and", "removes", "it", "from", "the", "account", "." ]
8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0
https://github.com/Wiredcraft/dopy/blob/8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0/dopy/manager.py#L497-L504
43,120
Wiredcraft/dopy
dopy/manager.py
DoManager.assign_floating_ip
def assign_floating_ip(self, ip_addr, droplet_id): """ Assigns a Floating IP to a Droplet. """ if self.api_version == 2: params = {'type': 'assign','droplet_id': droplet_id} json = self.request('/floating_ips/' + ip_addr + '/actions', params=params, method='POST'...
python
def assign_floating_ip(self, ip_addr, droplet_id): """ Assigns a Floating IP to a Droplet. """ if self.api_version == 2: params = {'type': 'assign','droplet_id': droplet_id} json = self.request('/floating_ips/' + ip_addr + '/actions', params=params, method='POST'...
[ "def", "assign_floating_ip", "(", "self", ",", "ip_addr", ",", "droplet_id", ")", ":", "if", "self", ".", "api_version", "==", "2", ":", "params", "=", "{", "'type'", ":", "'assign'", ",", "'droplet_id'", ":", "droplet_id", "}", "json", "=", "self", ".",...
Assigns a Floating IP to a Droplet.
[ "Assigns", "a", "Floating", "IP", "to", "a", "Droplet", "." ]
8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0
https://github.com/Wiredcraft/dopy/blob/8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0/dopy/manager.py#L506-L516
43,121
Wiredcraft/dopy
dopy/manager.py
DoManager.unassign_floating_ip
def unassign_floating_ip(self, ip_addr): """ Unassign a Floating IP from a Droplet. The Floating IP will be reserved in the region but not assigned to a Droplet. """ if self.api_version == 2: params = {'type': 'unassign'} json = self.request('/floating_ip...
python
def unassign_floating_ip(self, ip_addr): """ Unassign a Floating IP from a Droplet. The Floating IP will be reserved in the region but not assigned to a Droplet. """ if self.api_version == 2: params = {'type': 'unassign'} json = self.request('/floating_ip...
[ "def", "unassign_floating_ip", "(", "self", ",", "ip_addr", ")", ":", "if", "self", ".", "api_version", "==", "2", ":", "params", "=", "{", "'type'", ":", "'unassign'", "}", "json", "=", "self", ".", "request", "(", "'/floating_ips/'", "+", "ip_addr", "+...
Unassign a Floating IP from a Droplet. The Floating IP will be reserved in the region but not assigned to a Droplet.
[ "Unassign", "a", "Floating", "IP", "from", "a", "Droplet", ".", "The", "Floating", "IP", "will", "be", "reserved", "in", "the", "region", "but", "not", "assigned", "to", "a", "Droplet", "." ]
8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0
https://github.com/Wiredcraft/dopy/blob/8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0/dopy/manager.py#L518-L529
43,122
Wiredcraft/dopy
dopy/manager.py
DoManager.list_floating_ip_actions
def list_floating_ip_actions(self, ip_addr): """ Retrieve a list of all actions that have been executed on a Floating IP. """ if self.api_version == 2: json = self.request('/floating_ips/' + ip_addr + '/actions') return json['actions'] else: ra...
python
def list_floating_ip_actions(self, ip_addr): """ Retrieve a list of all actions that have been executed on a Floating IP. """ if self.api_version == 2: json = self.request('/floating_ips/' + ip_addr + '/actions') return json['actions'] else: ra...
[ "def", "list_floating_ip_actions", "(", "self", ",", "ip_addr", ")", ":", "if", "self", ".", "api_version", "==", "2", ":", "json", "=", "self", ".", "request", "(", "'/floating_ips/'", "+", "ip_addr", "+", "'/actions'", ")", "return", "json", "[", "'actio...
Retrieve a list of all actions that have been executed on a Floating IP.
[ "Retrieve", "a", "list", "of", "all", "actions", "that", "have", "been", "executed", "on", "a", "Floating", "IP", "." ]
8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0
https://github.com/Wiredcraft/dopy/blob/8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0/dopy/manager.py#L531-L539
43,123
Wiredcraft/dopy
dopy/manager.py
DoManager.get_floating_ip_action
def get_floating_ip_action(self, ip_addr, action_id): """ Retrieve the status of a Floating IP action. """ if self.api_version == 2: json = self.request('/floating_ips/' + ip_addr + '/actions/' + action_id) return json['action'] else: raise DoE...
python
def get_floating_ip_action(self, ip_addr, action_id): """ Retrieve the status of a Floating IP action. """ if self.api_version == 2: json = self.request('/floating_ips/' + ip_addr + '/actions/' + action_id) return json['action'] else: raise DoE...
[ "def", "get_floating_ip_action", "(", "self", ",", "ip_addr", ",", "action_id", ")", ":", "if", "self", ".", "api_version", "==", "2", ":", "json", "=", "self", ".", "request", "(", "'/floating_ips/'", "+", "ip_addr", "+", "'/actions/'", "+", "action_id", ...
Retrieve the status of a Floating IP action.
[ "Retrieve", "the", "status", "of", "a", "Floating", "IP", "action", "." ]
8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0
https://github.com/Wiredcraft/dopy/blob/8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0/dopy/manager.py#L541-L549
43,124
etoccalino/django-rest-framework-httpsignature
utils/sign3.py
raw_sign
def raw_sign(message, secret): """Sign a message.""" digest = hmac.new(secret, message, hashlib.sha256).digest() return base64.b64encode(digest)
python
def raw_sign(message, secret): """Sign a message.""" digest = hmac.new(secret, message, hashlib.sha256).digest() return base64.b64encode(digest)
[ "def", "raw_sign", "(", "message", ",", "secret", ")", ":", "digest", "=", "hmac", ".", "new", "(", "secret", ",", "message", ",", "hashlib", ".", "sha256", ")", ".", "digest", "(", ")", "return", "base64", ".", "b64encode", "(", "digest", ")" ]
Sign a message.
[ "Sign", "a", "message", "." ]
03ac3c213153ae6084c84b8ff61e101798b342a4
https://github.com/etoccalino/django-rest-framework-httpsignature/blob/03ac3c213153ae6084c84b8ff61e101798b342a4/utils/sign3.py#L23-L26
43,125
etoccalino/django-rest-framework-httpsignature
rest_framework_httpsignature/authentication.py
SignatureAuthentication.get_signature_from_signature_string
def get_signature_from_signature_string(self, signature): """Return the signature from the signature header or None.""" match = self.SIGNATURE_RE.search(signature) if not match: return None return match.group(1)
python
def get_signature_from_signature_string(self, signature): """Return the signature from the signature header or None.""" match = self.SIGNATURE_RE.search(signature) if not match: return None return match.group(1)
[ "def", "get_signature_from_signature_string", "(", "self", ",", "signature", ")", ":", "match", "=", "self", ".", "SIGNATURE_RE", ".", "search", "(", "signature", ")", "if", "not", "match", ":", "return", "None", "return", "match", ".", "group", "(", "1", ...
Return the signature from the signature header or None.
[ "Return", "the", "signature", "from", "the", "signature", "header", "or", "None", "." ]
03ac3c213153ae6084c84b8ff61e101798b342a4
https://github.com/etoccalino/django-rest-framework-httpsignature/blob/03ac3c213153ae6084c84b8ff61e101798b342a4/rest_framework_httpsignature/authentication.py#L15-L20
43,126
etoccalino/django-rest-framework-httpsignature
rest_framework_httpsignature/authentication.py
SignatureAuthentication.get_headers_from_signature
def get_headers_from_signature(self, signature): """Returns a list of headers fields to sign. According to http://tools.ietf.org/html/draft-cavage-http-signatures-03 section 2.1.3, the headers are optional. If not specified, the single value of "Date" must be used. """ m...
python
def get_headers_from_signature(self, signature): """Returns a list of headers fields to sign. According to http://tools.ietf.org/html/draft-cavage-http-signatures-03 section 2.1.3, the headers are optional. If not specified, the single value of "Date" must be used. """ m...
[ "def", "get_headers_from_signature", "(", "self", ",", "signature", ")", ":", "match", "=", "self", ".", "SIGNATURE_HEADERS_RE", ".", "search", "(", "signature", ")", "if", "not", "match", ":", "return", "[", "'date'", "]", "headers_string", "=", "match", "....
Returns a list of headers fields to sign. According to http://tools.ietf.org/html/draft-cavage-http-signatures-03 section 2.1.3, the headers are optional. If not specified, the single value of "Date" must be used.
[ "Returns", "a", "list", "of", "headers", "fields", "to", "sign", "." ]
03ac3c213153ae6084c84b8ff61e101798b342a4
https://github.com/etoccalino/django-rest-framework-httpsignature/blob/03ac3c213153ae6084c84b8ff61e101798b342a4/rest_framework_httpsignature/authentication.py#L22-L33
43,127
etoccalino/django-rest-framework-httpsignature
rest_framework_httpsignature/authentication.py
SignatureAuthentication.header_canonical
def header_canonical(self, header_name): """Translate HTTP headers to Django header names.""" # Translate as stated in the docs: # https://docs.djangoproject.com/en/1.6/ref/request-response/#django.http.HttpRequest.META header_name = header_name.lower() if header_name == 'content...
python
def header_canonical(self, header_name): """Translate HTTP headers to Django header names.""" # Translate as stated in the docs: # https://docs.djangoproject.com/en/1.6/ref/request-response/#django.http.HttpRequest.META header_name = header_name.lower() if header_name == 'content...
[ "def", "header_canonical", "(", "self", ",", "header_name", ")", ":", "# Translate as stated in the docs:", "# https://docs.djangoproject.com/en/1.6/ref/request-response/#django.http.HttpRequest.META", "header_name", "=", "header_name", ".", "lower", "(", ")", "if", "header_name"...
Translate HTTP headers to Django header names.
[ "Translate", "HTTP", "headers", "to", "Django", "header", "names", "." ]
03ac3c213153ae6084c84b8ff61e101798b342a4
https://github.com/etoccalino/django-rest-framework-httpsignature/blob/03ac3c213153ae6084c84b8ff61e101798b342a4/rest_framework_httpsignature/authentication.py#L35-L44
43,128
etoccalino/django-rest-framework-httpsignature
rest_framework_httpsignature/authentication.py
SignatureAuthentication.build_dict_to_sign
def build_dict_to_sign(self, request, signature_headers): """Build a dict with headers and values used in the signature. "signature_headers" is a list of lowercase header names. """ d = {} for header in signature_headers: if header == '(request-target)': ...
python
def build_dict_to_sign(self, request, signature_headers): """Build a dict with headers and values used in the signature. "signature_headers" is a list of lowercase header names. """ d = {} for header in signature_headers: if header == '(request-target)': ...
[ "def", "build_dict_to_sign", "(", "self", ",", "request", ",", "signature_headers", ")", ":", "d", "=", "{", "}", "for", "header", "in", "signature_headers", ":", "if", "header", "==", "'(request-target)'", ":", "continue", "d", "[", "header", "]", "=", "r...
Build a dict with headers and values used in the signature. "signature_headers" is a list of lowercase header names.
[ "Build", "a", "dict", "with", "headers", "and", "values", "used", "in", "the", "signature", "." ]
03ac3c213153ae6084c84b8ff61e101798b342a4
https://github.com/etoccalino/django-rest-framework-httpsignature/blob/03ac3c213153ae6084c84b8ff61e101798b342a4/rest_framework_httpsignature/authentication.py#L46-L56
43,129
etoccalino/django-rest-framework-httpsignature
rest_framework_httpsignature/authentication.py
SignatureAuthentication.build_signature
def build_signature(self, user_api_key, user_secret, request): """Return the signature for the request.""" path = request.get_full_path() sent_signature = request.META.get( self.header_canonical('Authorization')) signature_headers = self.get_headers_from_signature(sent_signat...
python
def build_signature(self, user_api_key, user_secret, request): """Return the signature for the request.""" path = request.get_full_path() sent_signature = request.META.get( self.header_canonical('Authorization')) signature_headers = self.get_headers_from_signature(sent_signat...
[ "def", "build_signature", "(", "self", ",", "user_api_key", ",", "user_secret", ",", "request", ")", ":", "path", "=", "request", ".", "get_full_path", "(", ")", "sent_signature", "=", "request", ".", "META", ".", "get", "(", "self", ".", "header_canonical",...
Return the signature for the request.
[ "Return", "the", "signature", "for", "the", "request", "." ]
03ac3c213153ae6084c84b8ff61e101798b342a4
https://github.com/etoccalino/django-rest-framework-httpsignature/blob/03ac3c213153ae6084c84b8ff61e101798b342a4/rest_framework_httpsignature/authentication.py#L58-L71
43,130
ivankliuk/duckduckpy
duckduckpy/utils.py
camel_to_snake_case
def camel_to_snake_case(string): """Converts 'string' presented in camel case to snake case. e.g.: CamelCase => snake_case """ s = _1.sub(r'\1_\2', string) return _2.sub(r'\1_\2', s).lower()
python
def camel_to_snake_case(string): """Converts 'string' presented in camel case to snake case. e.g.: CamelCase => snake_case """ s = _1.sub(r'\1_\2', string) return _2.sub(r'\1_\2', s).lower()
[ "def", "camel_to_snake_case", "(", "string", ")", ":", "s", "=", "_1", ".", "sub", "(", "r'\\1_\\2'", ",", "string", ")", "return", "_2", ".", "sub", "(", "r'\\1_\\2'", ",", "s", ")", ".", "lower", "(", ")" ]
Converts 'string' presented in camel case to snake case. e.g.: CamelCase => snake_case
[ "Converts", "string", "presented", "in", "camel", "case", "to", "snake", "case", "." ]
4114d8555a1752ab5170f6a8e71cbe377aa86f4d
https://github.com/ivankliuk/duckduckpy/blob/4114d8555a1752ab5170f6a8e71cbe377aa86f4d/duckduckpy/utils.py#L38-L44
43,131
ivankliuk/duckduckpy
duckduckpy/core.py
url_assembler
def url_assembler(query_string, no_redirect=0, no_html=0, skip_disambig=0): """Assembler of parameters for building request query. Args: query_string: Query to be passed to DuckDuckGo API. no_redirect: Skip HTTP redirects (for !bang commands). Default - False. no_html: Remove HTML from ...
python
def url_assembler(query_string, no_redirect=0, no_html=0, skip_disambig=0): """Assembler of parameters for building request query. Args: query_string: Query to be passed to DuckDuckGo API. no_redirect: Skip HTTP redirects (for !bang commands). Default - False. no_html: Remove HTML from ...
[ "def", "url_assembler", "(", "query_string", ",", "no_redirect", "=", "0", ",", "no_html", "=", "0", ",", "skip_disambig", "=", "0", ")", ":", "params", "=", "[", "(", "'q'", ",", "query_string", ".", "encode", "(", "\"utf-8\"", ")", ")", ",", "(", "...
Assembler of parameters for building request query. Args: query_string: Query to be passed to DuckDuckGo API. no_redirect: Skip HTTP redirects (for !bang commands). Default - False. no_html: Remove HTML from text, e.g. bold and italics. Default - False. skip_disambig: Skip disambigu...
[ "Assembler", "of", "parameters", "for", "building", "request", "query", "." ]
4114d8555a1752ab5170f6a8e71cbe377aa86f4d
https://github.com/ivankliuk/duckduckpy/blob/4114d8555a1752ab5170f6a8e71cbe377aa86f4d/duckduckpy/core.py#L98-L119
43,132
ivankliuk/duckduckpy
duckduckpy/core.py
query
def query(query_string, secure=False, container='namedtuple', verbose=False, user_agent=api.USER_AGENT, no_redirect=False, no_html=False, skip_disambig=False): """ Generates and sends a query to DuckDuckGo API. Args: query_string: Query to be passed to DuckDuckGo API. se...
python
def query(query_string, secure=False, container='namedtuple', verbose=False, user_agent=api.USER_AGENT, no_redirect=False, no_html=False, skip_disambig=False): """ Generates and sends a query to DuckDuckGo API. Args: query_string: Query to be passed to DuckDuckGo API. se...
[ "def", "query", "(", "query_string", ",", "secure", "=", "False", ",", "container", "=", "'namedtuple'", ",", "verbose", "=", "False", ",", "user_agent", "=", "api", ".", "USER_AGENT", ",", "no_redirect", "=", "False", ",", "no_html", "=", "False", ",", ...
Generates and sends a query to DuckDuckGo API. Args: query_string: Query to be passed to DuckDuckGo API. secure: Use secure SSL/TLS connection. Default - False. Syntactic sugar is secure_query function which is passed the same parameters. container: Indicates how dic...
[ "Generates", "and", "sends", "a", "query", "to", "DuckDuckGo", "API", "." ]
4114d8555a1752ab5170f6a8e71cbe377aa86f4d
https://github.com/ivankliuk/duckduckpy/blob/4114d8555a1752ab5170f6a8e71cbe377aa86f4d/duckduckpy/core.py#L122-L214
43,133
wickman/pystachio
pystachio/container.py
ListFactory.create
def create(type_dict, *type_parameters): """ Construct a List containing type 'klazz'. """ assert len(type_parameters) == 1 klazz = TypeFactory.new(type_dict, *type_parameters[0]) assert isclass(klazz) assert issubclass(klazz, Object) return TypeMetaclass('%sList' % klazz.__name__, (Li...
python
def create(type_dict, *type_parameters): """ Construct a List containing type 'klazz'. """ assert len(type_parameters) == 1 klazz = TypeFactory.new(type_dict, *type_parameters[0]) assert isclass(klazz) assert issubclass(klazz, Object) return TypeMetaclass('%sList' % klazz.__name__, (Li...
[ "def", "create", "(", "type_dict", ",", "*", "type_parameters", ")", ":", "assert", "len", "(", "type_parameters", ")", "==", "1", "klazz", "=", "TypeFactory", ".", "new", "(", "type_dict", ",", "*", "type_parameters", "[", "0", "]", ")", "assert", "iscl...
Construct a List containing type 'klazz'.
[ "Construct", "a", "List", "containing", "type", "klazz", "." ]
601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f
https://github.com/wickman/pystachio/blob/601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f/pystachio/container.py#L15-L23
43,134
jeffh/sniffer
sniffer/scent_picker.py
load_file
def load_file(filename): "Runs the given scent.py file." mod_name = '.'.join(os.path.basename(filename).split('.')[:-1]) mod_path = os.path.dirname(filename) if mod_name in sys.modules: del sys.modules[mod_name] if mod_path not in set(sys.modules.keys()): sys.path.insert(0, mod_path...
python
def load_file(filename): "Runs the given scent.py file." mod_name = '.'.join(os.path.basename(filename).split('.')[:-1]) mod_path = os.path.dirname(filename) if mod_name in sys.modules: del sys.modules[mod_name] if mod_path not in set(sys.modules.keys()): sys.path.insert(0, mod_path...
[ "def", "load_file", "(", "filename", ")", ":", "mod_name", "=", "'.'", ".", "join", "(", "os", ".", "path", ".", "basename", "(", "filename", ")", ".", "split", "(", "'.'", ")", "[", ":", "-", "1", "]", ")", "mod_path", "=", "os", ".", "path", ...
Runs the given scent.py file.
[ "Runs", "the", "given", "scent", ".", "py", "file", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/scent_picker.py#L82-L91
43,135
wickman/pystachio
pystachio/typing.py
TypeFactory.new
def new(type_dict, type_factory, *type_parameters): """ Create a fully reified type from a type schema. """ type_tuple = (type_factory,) + type_parameters if type_tuple not in type_dict: factory = TypeFactory.get_factory(type_factory) reified_type = factory.create(type_dict, *type_para...
python
def new(type_dict, type_factory, *type_parameters): """ Create a fully reified type from a type schema. """ type_tuple = (type_factory,) + type_parameters if type_tuple not in type_dict: factory = TypeFactory.get_factory(type_factory) reified_type = factory.create(type_dict, *type_para...
[ "def", "new", "(", "type_dict", ",", "type_factory", ",", "*", "type_parameters", ")", ":", "type_tuple", "=", "(", "type_factory", ",", ")", "+", "type_parameters", "if", "type_tuple", "not", "in", "type_dict", ":", "factory", "=", "TypeFactory", ".", "get_...
Create a fully reified type from a type schema.
[ "Create", "a", "fully", "reified", "type", "from", "a", "type", "schema", "." ]
601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f
https://github.com/wickman/pystachio/blob/601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f/pystachio/typing.py#L77-L86
43,136
wickman/pystachio
pystachio/composite.py
TypeSignature.wrap
def wrap(sig): """Convert a Python class into a type signature.""" if isclass(sig) and issubclass(sig, Object): return TypeSignature(sig) elif isinstance(sig, TypeSignature): return sig
python
def wrap(sig): """Convert a Python class into a type signature.""" if isclass(sig) and issubclass(sig, Object): return TypeSignature(sig) elif isinstance(sig, TypeSignature): return sig
[ "def", "wrap", "(", "sig", ")", ":", "if", "isclass", "(", "sig", ")", "and", "issubclass", "(", "sig", ",", "Object", ")", ":", "return", "TypeSignature", "(", "sig", ")", "elif", "isinstance", "(", "sig", ",", "TypeSignature", ")", ":", "return", "...
Convert a Python class into a type signature.
[ "Convert", "a", "Python", "class", "into", "a", "type", "signature", "." ]
601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f
https://github.com/wickman/pystachio/blob/601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f/pystachio/composite.py#L90-L95
43,137
jeffh/sniffer
sniffer/scanner/base.py
BaseScanner.trigger_modified
def trigger_modified(self, filepath): """Triggers modified event if the given filepath mod time is newer.""" mod_time = self._get_modified_time(filepath) if mod_time > self._watched_files.get(filepath, 0): self._trigger('modified', filepath) self._watched_files[filepath] ...
python
def trigger_modified(self, filepath): """Triggers modified event if the given filepath mod time is newer.""" mod_time = self._get_modified_time(filepath) if mod_time > self._watched_files.get(filepath, 0): self._trigger('modified', filepath) self._watched_files[filepath] ...
[ "def", "trigger_modified", "(", "self", ",", "filepath", ")", ":", "mod_time", "=", "self", ".", "_get_modified_time", "(", "filepath", ")", "if", "mod_time", ">", "self", ".", "_watched_files", ".", "get", "(", "filepath", ",", "0", ")", ":", "self", "....
Triggers modified event if the given filepath mod time is newer.
[ "Triggers", "modified", "event", "if", "the", "given", "filepath", "mod", "time", "is", "newer", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/scanner/base.py#L39-L44
43,138
jeffh/sniffer
sniffer/scanner/base.py
BaseScanner.trigger_created
def trigger_created(self, filepath): """Triggers created event if file exists.""" if os.path.exists(filepath): self._trigger('created', filepath)
python
def trigger_created(self, filepath): """Triggers created event if file exists.""" if os.path.exists(filepath): self._trigger('created', filepath)
[ "def", "trigger_created", "(", "self", ",", "filepath", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "filepath", ")", ":", "self", ".", "_trigger", "(", "'created'", ",", "filepath", ")" ]
Triggers created event if file exists.
[ "Triggers", "created", "event", "if", "file", "exists", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/scanner/base.py#L46-L49
43,139
jeffh/sniffer
sniffer/scanner/base.py
BaseScanner.trigger_deleted
def trigger_deleted(self, filepath): """Triggers deleted event if the flie doesn't exist.""" if not os.path.exists(filepath): self._trigger('deleted', filepath)
python
def trigger_deleted(self, filepath): """Triggers deleted event if the flie doesn't exist.""" if not os.path.exists(filepath): self._trigger('deleted', filepath)
[ "def", "trigger_deleted", "(", "self", ",", "filepath", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filepath", ")", ":", "self", ".", "_trigger", "(", "'deleted'", ",", "filepath", ")" ]
Triggers deleted event if the flie doesn't exist.
[ "Triggers", "deleted", "event", "if", "the", "flie", "doesn", "t", "exist", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/scanner/base.py#L51-L54
43,140
jeffh/sniffer
sniffer/scanner/base.py
BaseScanner.log
def log(self, *message): """ Logs a messate to a defined io stream if available. """ if self._logger is None: return s = " ".join([str(m) for m in message]) self._logger.write(s+'\n') self._logger.flush()
python
def log(self, *message): """ Logs a messate to a defined io stream if available. """ if self._logger is None: return s = " ".join([str(m) for m in message]) self._logger.write(s+'\n') self._logger.flush()
[ "def", "log", "(", "self", ",", "*", "message", ")", ":", "if", "self", ".", "_logger", "is", "None", ":", "return", "s", "=", "\" \"", ".", "join", "(", "[", "str", "(", "m", ")", "for", "m", "in", "message", "]", ")", "self", ".", "_logger", ...
Logs a messate to a defined io stream if available.
[ "Logs", "a", "messate", "to", "a", "defined", "io", "stream", "if", "available", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/scanner/base.py#L102-L110
43,141
jeffh/sniffer
sniffer/scanner/base.py
BaseScanner.in_repo
def in_repo(self, filepath): """ This excludes repository directories because they cause some exceptions occationally. """ filepath = set(filepath.replace('\\', '/').split('/')) for p in ('.git', '.hg', '.svn', '.cvs', '.bzr'): if p in filepath: ...
python
def in_repo(self, filepath): """ This excludes repository directories because they cause some exceptions occationally. """ filepath = set(filepath.replace('\\', '/').split('/')) for p in ('.git', '.hg', '.svn', '.cvs', '.bzr'): if p in filepath: ...
[ "def", "in_repo", "(", "self", ",", "filepath", ")", ":", "filepath", "=", "set", "(", "filepath", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ".", "split", "(", "'/'", ")", ")", "for", "p", "in", "(", "'.git'", ",", "'.hg'", ",", "'.svn'", "...
This excludes repository directories because they cause some exceptions occationally.
[ "This", "excludes", "repository", "directories", "because", "they", "cause", "some", "exceptions", "occationally", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/scanner/base.py#L129-L138
43,142
jeffh/sniffer
sniffer/scanner/base.py
BaseScanner._modify_event
def _modify_event(self, event_name, method, func): """ Wrapper to call a list's method from one of the events """ if event_name not in self.ALL_EVENTS: raise TypeError(('event_name ("%s") can only be one of the ' 'following: %s') % (event_name, ...
python
def _modify_event(self, event_name, method, func): """ Wrapper to call a list's method from one of the events """ if event_name not in self.ALL_EVENTS: raise TypeError(('event_name ("%s") can only be one of the ' 'following: %s') % (event_name, ...
[ "def", "_modify_event", "(", "self", ",", "event_name", ",", "method", ",", "func", ")", ":", "if", "event_name", "not", "in", "self", ".", "ALL_EVENTS", ":", "raise", "TypeError", "(", "(", "'event_name (\"%s\") can only be one of the '", "'following: %s'", ")", ...
Wrapper to call a list's method from one of the events
[ "Wrapper", "to", "call", "a", "list", "s", "method", "from", "one", "of", "the", "events" ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/scanner/base.py#L166-L177
43,143
jeffh/sniffer
sniffer/scanner/base.py
PollingScanner._watch_file
def _watch_file(self, filepath, trigger_event=True): """Adds the file's modified time into its internal watchlist.""" is_new = filepath not in self._watched_files if trigger_event: if is_new: self.trigger_created(filepath) else: self.trigge...
python
def _watch_file(self, filepath, trigger_event=True): """Adds the file's modified time into its internal watchlist.""" is_new = filepath not in self._watched_files if trigger_event: if is_new: self.trigger_created(filepath) else: self.trigge...
[ "def", "_watch_file", "(", "self", ",", "filepath", ",", "trigger_event", "=", "True", ")", ":", "is_new", "=", "filepath", "not", "in", "self", ".", "_watched_files", "if", "trigger_event", ":", "if", "is_new", ":", "self", ".", "trigger_created", "(", "f...
Adds the file's modified time into its internal watchlist.
[ "Adds", "the", "file", "s", "modified", "time", "into", "its", "internal", "watchlist", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/scanner/base.py#L219-L230
43,144
jeffh/sniffer
sniffer/scanner/base.py
PollingScanner._unwatch_file
def _unwatch_file(self, filepath, trigger_event=True): """ Removes the file from the internal watchlist if exists. """ if filepath not in self._watched_files: return if trigger_event: self.trigger_deleted(filepath) del self._watched_files[filepath]
python
def _unwatch_file(self, filepath, trigger_event=True): """ Removes the file from the internal watchlist if exists. """ if filepath not in self._watched_files: return if trigger_event: self.trigger_deleted(filepath) del self._watched_files[filepath]
[ "def", "_unwatch_file", "(", "self", ",", "filepath", ",", "trigger_event", "=", "True", ")", ":", "if", "filepath", "not", "in", "self", ".", "_watched_files", ":", "return", "if", "trigger_event", ":", "self", ".", "trigger_deleted", "(", "filepath", ")", ...
Removes the file from the internal watchlist if exists.
[ "Removes", "the", "file", "from", "the", "internal", "watchlist", "if", "exists", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/scanner/base.py#L232-L240
43,145
jeffh/sniffer
sniffer/scanner/base.py
PollingScanner._is_modified
def _is_modified(self, filepath): """ Returns True if the file has been modified since last seen. Will return False if the file has not been seen before. """ if self._is_new(filepath): return False mtime = self._get_modified_time(filepath) return self....
python
def _is_modified(self, filepath): """ Returns True if the file has been modified since last seen. Will return False if the file has not been seen before. """ if self._is_new(filepath): return False mtime = self._get_modified_time(filepath) return self....
[ "def", "_is_modified", "(", "self", ",", "filepath", ")", ":", "if", "self", ".", "_is_new", "(", "filepath", ")", ":", "return", "False", "mtime", "=", "self", ".", "_get_modified_time", "(", "filepath", ")", "return", "self", ".", "_watched_files", "[", ...
Returns True if the file has been modified since last seen. Will return False if the file has not been seen before.
[ "Returns", "True", "if", "the", "file", "has", "been", "modified", "since", "last", "seen", ".", "Will", "return", "False", "if", "the", "file", "has", "not", "been", "seen", "before", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/scanner/base.py#L242-L250
43,146
jeffh/sniffer
sniffer/scanner/base.py
PollingScanner.loop
def loop(self, sleep_time=1, callback=None): """ Goes into a blocking IO loop. If polling is used, the sleep_time is the interval, in seconds, between polls. """ self.log("No supported libraries found: using polling-method.") self._running = True self.trigger_ini...
python
def loop(self, sleep_time=1, callback=None): """ Goes into a blocking IO loop. If polling is used, the sleep_time is the interval, in seconds, between polls. """ self.log("No supported libraries found: using polling-method.") self._running = True self.trigger_ini...
[ "def", "loop", "(", "self", ",", "sleep_time", "=", "1", ",", "callback", "=", "None", ")", ":", "self", ".", "log", "(", "\"No supported libraries found: using polling-method.\"", ")", "self", ".", "_running", "=", "True", "self", ".", "trigger_init", "(", ...
Goes into a blocking IO loop. If polling is used, the sleep_time is the interval, in seconds, between polls.
[ "Goes", "into", "a", "blocking", "IO", "loop", ".", "If", "polling", "is", "used", "the", "sleep_time", "is", "the", "interval", "in", "seconds", "between", "polls", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/scanner/base.py#L260-L284
43,147
jeffh/sniffer
sniffer/main.py
run
def run(sniffer_instance=None, wait_time=0.5, clear=True, args=(), debug=False): """ Runs the auto tester loop. Internally, the runner instanciates the sniffer_cls and scanner class. ``sniffer_instance`` The class to run. Usually this is set to but a subclass of scanner. Def...
python
def run(sniffer_instance=None, wait_time=0.5, clear=True, args=(), debug=False): """ Runs the auto tester loop. Internally, the runner instanciates the sniffer_cls and scanner class. ``sniffer_instance`` The class to run. Usually this is set to but a subclass of scanner. Def...
[ "def", "run", "(", "sniffer_instance", "=", "None", ",", "wait_time", "=", "0.5", ",", "clear", "=", "True", ",", "args", "=", "(", ")", ",", "debug", "=", "False", ")", ":", "if", "sniffer_instance", "is", "None", ":", "sniffer_instance", "=", "ScentS...
Runs the auto tester loop. Internally, the runner instanciates the sniffer_cls and scanner class. ``sniffer_instance`` The class to run. Usually this is set to but a subclass of scanner. Defaults to Sniffer. Sniffer class documentation for more information. ``wait_time`` The time, in ...
[ "Runs", "the", "auto", "tester", "loop", ".", "Internally", "the", "runner", "instanciates", "the", "sniffer_cls", "and", "scanner", "class", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/main.py#L17-L48
43,148
jeffh/sniffer
sniffer/main.py
main
def main(sniffer_instance=None, test_args=(), progname=sys.argv[0], args=sys.argv[1:]): """ Runs the program. This is used when you want to run this program standalone. ``sniffer_instance`` A class (usually subclassed of Sniffer) that hooks into the scanner and handles running ...
python
def main(sniffer_instance=None, test_args=(), progname=sys.argv[0], args=sys.argv[1:]): """ Runs the program. This is used when you want to run this program standalone. ``sniffer_instance`` A class (usually subclassed of Sniffer) that hooks into the scanner and handles running ...
[ "def", "main", "(", "sniffer_instance", "=", "None", ",", "test_args", "=", "(", ")", ",", "progname", "=", "sys", ".", "argv", "[", "0", "]", ",", "args", "=", "sys", ".", "argv", "[", "1", ":", "]", ")", ":", "parser", "=", "OptionParser", "(",...
Runs the program. This is used when you want to run this program standalone. ``sniffer_instance`` A class (usually subclassed of Sniffer) that hooks into the scanner and handles running the test framework. Defaults to Sniffer instance. ``test_args`` This function norma...
[ "Runs", "the", "program", ".", "This", "is", "used", "when", "you", "want", "to", "run", "this", "program", "standalone", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/main.py#L50-L94
43,149
jeffh/sniffer
sniffer/runner.py
Sniffer.set_up
def set_up(self, test_args=(), clear=True, debug=False): """ Sets properties right before calling run. ``test_args`` The arguments to pass to the test runner. ``clear`` Boolean. Set to True if we should clear console before running the tests. ``...
python
def set_up(self, test_args=(), clear=True, debug=False): """ Sets properties right before calling run. ``test_args`` The arguments to pass to the test runner. ``clear`` Boolean. Set to True if we should clear console before running the tests. ``...
[ "def", "set_up", "(", "self", ",", "test_args", "=", "(", ")", ",", "clear", "=", "True", ",", "debug", "=", "False", ")", ":", "self", ".", "test_args", "=", "test_args", "self", ".", "debug", ",", "self", ".", "clear", "=", "debug", ",", "clear" ...
Sets properties right before calling run. ``test_args`` The arguments to pass to the test runner. ``clear`` Boolean. Set to True if we should clear console before running the tests. ``debug`` Boolean. Set to True if we want to print debugging ...
[ "Sets", "properties", "right", "before", "calling", "run", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/runner.py#L55-L66
43,150
jeffh/sniffer
sniffer/runner.py
Sniffer.observe_scanner
def observe_scanner(self, scanner): """ Hooks into multiple events of a scanner. """ scanner.observe(scanner.ALL_EVENTS, self.absorb_args(self.modules.restore)) if self.clear: scanner.observe(scanner.ALL_EVENTS, self...
python
def observe_scanner(self, scanner): """ Hooks into multiple events of a scanner. """ scanner.observe(scanner.ALL_EVENTS, self.absorb_args(self.modules.restore)) if self.clear: scanner.observe(scanner.ALL_EVENTS, self...
[ "def", "observe_scanner", "(", "self", ",", "scanner", ")", ":", "scanner", ".", "observe", "(", "scanner", ".", "ALL_EVENTS", ",", "self", ".", "absorb_args", "(", "self", ".", "modules", ".", "restore", ")", ")", "if", "self", ".", "clear", ":", "sca...
Hooks into multiple events of a scanner.
[ "Hooks", "into", "multiple", "events", "of", "a", "scanner", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/runner.py#L78-L92
43,151
jeffh/sniffer
sniffer/runner.py
Sniffer.clear_on_run
def clear_on_run(self, prefix="Running Tests:"): """Clears console before running the tests.""" if platform.system() == 'Windows': os.system('cls') else: os.system('clear') if prefix: print(prefix)
python
def clear_on_run(self, prefix="Running Tests:"): """Clears console before running the tests.""" if platform.system() == 'Windows': os.system('cls') else: os.system('clear') if prefix: print(prefix)
[ "def", "clear_on_run", "(", "self", ",", "prefix", "=", "\"Running Tests:\"", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "'Windows'", ":", "os", ".", "system", "(", "'cls'", ")", "else", ":", "os", ".", "system", "(", "'clear'", ")", ...
Clears console before running the tests.
[ "Clears", "console", "before", "running", "the", "tests", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/runner.py#L94-L101
43,152
jeffh/sniffer
sniffer/runner.py
Sniffer.run
def run(self): """ Runs the unit test framework. Can be overridden to run anything. Returns True on passing and False on failure. """ try: import nose arguments = [sys.argv[0]] + list(self.test_args) return nose.run(argv=arguments) exce...
python
def run(self): """ Runs the unit test framework. Can be overridden to run anything. Returns True on passing and False on failure. """ try: import nose arguments = [sys.argv[0]] + list(self.test_args) return nose.run(argv=arguments) exce...
[ "def", "run", "(", "self", ")", ":", "try", ":", "import", "nose", "arguments", "=", "[", "sys", ".", "argv", "[", "0", "]", "]", "+", "list", "(", "self", ".", "test_args", ")", "return", "nose", ".", "run", "(", "argv", "=", "arguments", ")", ...
Runs the unit test framework. Can be overridden to run anything. Returns True on passing and False on failure.
[ "Runs", "the", "unit", "test", "framework", ".", "Can", "be", "overridden", "to", "run", "anything", ".", "Returns", "True", "on", "passing", "and", "False", "on", "failure", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/runner.py#L125-L138
43,153
jeffh/sniffer
sniffer/runner.py
ScentSniffer.run
def run(self): """ Runs the CWD's scent file. """ if not self.scent or len(self.scent.runners) == 0: print("Did not find 'scent.py', running nose:") return super(ScentSniffer, self).run() else: print("Using scent:") arguments = [sys...
python
def run(self): """ Runs the CWD's scent file. """ if not self.scent or len(self.scent.runners) == 0: print("Did not find 'scent.py', running nose:") return super(ScentSniffer, self).run() else: print("Using scent:") arguments = [sys...
[ "def", "run", "(", "self", ")", ":", "if", "not", "self", ".", "scent", "or", "len", "(", "self", ".", "scent", ".", "runners", ")", "==", "0", ":", "print", "(", "\"Did not find 'scent.py', running nose:\"", ")", "return", "super", "(", "ScentSniffer", ...
Runs the CWD's scent file.
[ "Runs", "the", "CWD", "s", "scent", "file", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/runner.py#L189-L200
43,154
wickman/pystachio
pystachio/base.py
Object.copy
def copy(self): """ Return a copy of this object. """ self_copy = self.dup() self_copy._scopes = copy.copy(self._scopes) return self_copy
python
def copy(self): """ Return a copy of this object. """ self_copy = self.dup() self_copy._scopes = copy.copy(self._scopes) return self_copy
[ "def", "copy", "(", "self", ")", ":", "self_copy", "=", "self", ".", "dup", "(", ")", "self_copy", ".", "_scopes", "=", "copy", ".", "copy", "(", "self", ".", "_scopes", ")", "return", "self_copy" ]
Return a copy of this object.
[ "Return", "a", "copy", "of", "this", "object", "." ]
601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f
https://github.com/wickman/pystachio/blob/601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f/pystachio/base.py#L106-L112
43,155
wickman/pystachio
pystachio/base.py
Object.bind
def bind(self, *args, **kw): """ Bind environment variables into this object's scope. """ new_self = self.copy() new_scopes = Object.translate_to_scopes(*args, **kw) new_self._scopes = tuple(reversed(new_scopes)) + new_self._scopes return new_self
python
def bind(self, *args, **kw): """ Bind environment variables into this object's scope. """ new_self = self.copy() new_scopes = Object.translate_to_scopes(*args, **kw) new_self._scopes = tuple(reversed(new_scopes)) + new_self._scopes return new_self
[ "def", "bind", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "new_self", "=", "self", ".", "copy", "(", ")", "new_scopes", "=", "Object", ".", "translate_to_scopes", "(", "*", "args", ",", "*", "*", "kw", ")", "new_self", ".", "_s...
Bind environment variables into this object's scope.
[ "Bind", "environment", "variables", "into", "this", "object", "s", "scope", "." ]
601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f
https://github.com/wickman/pystachio/blob/601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f/pystachio/base.py#L122-L129
43,156
wickman/pystachio
pystachio/base.py
Object.check
def check(self): """ Type check this object. """ try: si, uninterp = self.interpolate() # TODO(wickman) This should probably be pushed out to the interpolate leaves. except (Object.CoercionError, MustacheParser.Uninterpolatable) as e: return TypeCheck(False, "Unable to interpolate:...
python
def check(self): """ Type check this object. """ try: si, uninterp = self.interpolate() # TODO(wickman) This should probably be pushed out to the interpolate leaves. except (Object.CoercionError, MustacheParser.Uninterpolatable) as e: return TypeCheck(False, "Unable to interpolate:...
[ "def", "check", "(", "self", ")", ":", "try", ":", "si", ",", "uninterp", "=", "self", ".", "interpolate", "(", ")", "# TODO(wickman) This should probably be pushed out to the interpolate leaves.", "except", "(", "Object", ".", "CoercionError", ",", "MustacheParser", ...
Type check this object.
[ "Type", "check", "this", "object", "." ]
601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f
https://github.com/wickman/pystachio/blob/601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f/pystachio/base.py#L143-L152
43,157
jeffh/sniffer
sniffer/modules_restore_point.py
ModulesRestorePoint.restore
def restore(self): """ Unloads all modules that weren't loaded when save_modules was called. """ sys = set(self._sys_modules.keys()) for mod_name in sys.difference(self._saved_modules): del self._sys_modules[mod_name]
python
def restore(self): """ Unloads all modules that weren't loaded when save_modules was called. """ sys = set(self._sys_modules.keys()) for mod_name in sys.difference(self._saved_modules): del self._sys_modules[mod_name]
[ "def", "restore", "(", "self", ")", ":", "sys", "=", "set", "(", "self", ".", "_sys_modules", ".", "keys", "(", ")", ")", "for", "mod_name", "in", "sys", ".", "difference", "(", "self", ".", "_saved_modules", ")", ":", "del", "self", ".", "_sys_modul...
Unloads all modules that weren't loaded when save_modules was called.
[ "Unloads", "all", "modules", "that", "weren", "t", "loaded", "when", "save_modules", "was", "called", "." ]
8e4c3e77743aef08109ea0225b4a6536d4e60270
https://github.com/jeffh/sniffer/blob/8e4c3e77743aef08109ea0225b4a6536d4e60270/sniffer/modules_restore_point.py#L19-L25
43,158
wickman/pystachio
pystachio/parsing.py
MustacheParser.join
def join(cls, splits, *namables): """ Interpolate strings. :params splits: The output of Parser.split(string) :params namables: A sequence of Namable objects in which the interpolation should take place. Returns 2-tuple containing: joined string, list of unbound object ids (potenti...
python
def join(cls, splits, *namables): """ Interpolate strings. :params splits: The output of Parser.split(string) :params namables: A sequence of Namable objects in which the interpolation should take place. Returns 2-tuple containing: joined string, list of unbound object ids (potenti...
[ "def", "join", "(", "cls", ",", "splits", ",", "*", "namables", ")", ":", "isplits", "=", "[", "]", "unbound", "=", "[", "]", "for", "ref", "in", "splits", ":", "if", "isinstance", "(", "ref", ",", "Ref", ")", ":", "resolved", "=", "False", "for"...
Interpolate strings. :params splits: The output of Parser.split(string) :params namables: A sequence of Namable objects in which the interpolation should take place. Returns 2-tuple containing: joined string, list of unbound object ids (potentially empty)
[ "Interpolate", "strings", "." ]
601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f
https://github.com/wickman/pystachio/blob/601a2c36d7d67efa8f917e7cbf0ab8dc66c7827f/pystachio/parsing.py#L45-L74
43,159
numirias/firefed
firefed/output.py
outitem
def outitem(title, elems, indent=4): """Output formatted as list item.""" out(title) max_key_len = max(len(key) for key, _ in elems) + 1 for key, val in elems: key_spaced = ('%s:' % key).ljust(max_key_len) out('%s%s %s' % (indent * ' ', key_spaced, val)) out()
python
def outitem(title, elems, indent=4): """Output formatted as list item.""" out(title) max_key_len = max(len(key) for key, _ in elems) + 1 for key, val in elems: key_spaced = ('%s:' % key).ljust(max_key_len) out('%s%s %s' % (indent * ' ', key_spaced, val)) out()
[ "def", "outitem", "(", "title", ",", "elems", ",", "indent", "=", "4", ")", ":", "out", "(", "title", ")", "max_key_len", "=", "max", "(", "len", "(", "key", ")", "for", "key", ",", "_", "in", "elems", ")", "+", "1", "for", "key", ",", "val", ...
Output formatted as list item.
[ "Output", "formatted", "as", "list", "item", "." ]
908114fe3a1506dcaafb23ce49e99f171e5e329d
https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/output.py#L36-L43
43,160
numirias/firefed
firefed/util.py
profile_dir
def profile_dir(name): """Return path to FF profile for a given profile name or path.""" if name: possible_path = Path(name) if possible_path.exists(): return possible_path profiles = list(read_profiles()) try: if name: profile = next(p for p in profiles i...
python
def profile_dir(name): """Return path to FF profile for a given profile name or path.""" if name: possible_path = Path(name) if possible_path.exists(): return possible_path profiles = list(read_profiles()) try: if name: profile = next(p for p in profiles i...
[ "def", "profile_dir", "(", "name", ")", ":", "if", "name", ":", "possible_path", "=", "Path", "(", "name", ")", "if", "possible_path", ".", "exists", "(", ")", ":", "return", "possible_path", "profiles", "=", "list", "(", "read_profiles", "(", ")", ")", ...
Return path to FF profile for a given profile name or path.
[ "Return", "path", "to", "FF", "profile", "for", "a", "given", "profile", "name", "or", "path", "." ]
908114fe3a1506dcaafb23ce49e99f171e5e329d
https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/util.py#L70-L84
43,161
numirias/firefed
firefed/feature/feature.py
formatter
def formatter(name, default=False): """Decorate a Feature method to register it as an output formatter. All formatters are picked up by the argument parser so that they can be listed and selected on the CLI via the -f, --format argument. """ def decorator(func): func._output_format = dict(n...
python
def formatter(name, default=False): """Decorate a Feature method to register it as an output formatter. All formatters are picked up by the argument parser so that they can be listed and selected on the CLI via the -f, --format argument. """ def decorator(func): func._output_format = dict(n...
[ "def", "formatter", "(", "name", ",", "default", "=", "False", ")", ":", "def", "decorator", "(", "func", ")", ":", "func", ".", "_output_format", "=", "dict", "(", "name", "=", "name", ",", "default", "=", "default", ")", "return", "func", "return", ...
Decorate a Feature method to register it as an output formatter. All formatters are picked up by the argument parser so that they can be listed and selected on the CLI via the -f, --format argument.
[ "Decorate", "a", "Feature", "method", "to", "register", "it", "as", "an", "output", "formatter", "." ]
908114fe3a1506dcaafb23ce49e99f171e5e329d
https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/feature/feature.py#L53-L62
43,162
numirias/firefed
firefed/feature/feature.py
FeatureHelpersMixin.load_sqlite
def load_sqlite(self, db, query=None, table=None, cls=None, column_map=None): """Load data from sqlite db and return as list of specified objects.""" if column_map is None: column_map = {} db_path = self.profile_path(db, must_exist=True) def obj_factory(c...
python
def load_sqlite(self, db, query=None, table=None, cls=None, column_map=None): """Load data from sqlite db and return as list of specified objects.""" if column_map is None: column_map = {} db_path = self.profile_path(db, must_exist=True) def obj_factory(c...
[ "def", "load_sqlite", "(", "self", ",", "db", ",", "query", "=", "None", ",", "table", "=", "None", ",", "cls", "=", "None", ",", "column_map", "=", "None", ")", ":", "if", "column_map", "is", "None", ":", "column_map", "=", "{", "}", "db_path", "=...
Load data from sqlite db and return as list of specified objects.
[ "Load", "data", "from", "sqlite", "db", "and", "return", "as", "list", "of", "specified", "objects", "." ]
908114fe3a1506dcaafb23ce49e99f171e5e329d
https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/feature/feature.py#L72-L100
43,163
numirias/firefed
firefed/feature/feature.py
FeatureHelpersMixin.load_json
def load_json(self, path): """Load a JSON file from the user profile.""" with open(self.profile_path(path, must_exist=True), encoding='utf-8') as f: data = json.load(f) return data
python
def load_json(self, path): """Load a JSON file from the user profile.""" with open(self.profile_path(path, must_exist=True), encoding='utf-8') as f: data = json.load(f) return data
[ "def", "load_json", "(", "self", ",", "path", ")", ":", "with", "open", "(", "self", ".", "profile_path", "(", "path", ",", "must_exist", "=", "True", ")", ",", "encoding", "=", "'utf-8'", ")", "as", "f", ":", "data", "=", "json", ".", "load", "(",...
Load a JSON file from the user profile.
[ "Load", "a", "JSON", "file", "from", "the", "user", "profile", "." ]
908114fe3a1506dcaafb23ce49e99f171e5e329d
https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/feature/feature.py#L102-L107
43,164
numirias/firefed
firefed/feature/feature.py
FeatureHelpersMixin.load_mozlz4
def load_mozlz4(self, path): """Load a Mozilla LZ4 file from the user profile. Mozilla LZ4 is regular LZ4 with a custom string prefix. """ with open(self.profile_path(path, must_exist=True), 'rb') as f: if f.read(8) != b'mozLz40\0': raise NotMozLz4Error('Not ...
python
def load_mozlz4(self, path): """Load a Mozilla LZ4 file from the user profile. Mozilla LZ4 is regular LZ4 with a custom string prefix. """ with open(self.profile_path(path, must_exist=True), 'rb') as f: if f.read(8) != b'mozLz40\0': raise NotMozLz4Error('Not ...
[ "def", "load_mozlz4", "(", "self", ",", "path", ")", ":", "with", "open", "(", "self", ".", "profile_path", "(", "path", ",", "must_exist", "=", "True", ")", ",", "'rb'", ")", "as", "f", ":", "if", "f", ".", "read", "(", "8", ")", "!=", "b'mozLz4...
Load a Mozilla LZ4 file from the user profile. Mozilla LZ4 is regular LZ4 with a custom string prefix.
[ "Load", "a", "Mozilla", "LZ4", "file", "from", "the", "user", "profile", "." ]
908114fe3a1506dcaafb23ce49e99f171e5e329d
https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/feature/feature.py#L109-L118
43,165
numirias/firefed
firefed/feature/feature.py
FeatureHelpersMixin.csv_from_items
def csv_from_items(items, stream=None): """Write a list of items to stream in CSV format. The items need to be attrs-decorated. """ items = iter(items) first = next(items) cls = first.__class__ if stream is None: stream = sys.stdout fields = [...
python
def csv_from_items(items, stream=None): """Write a list of items to stream in CSV format. The items need to be attrs-decorated. """ items = iter(items) first = next(items) cls = first.__class__ if stream is None: stream = sys.stdout fields = [...
[ "def", "csv_from_items", "(", "items", ",", "stream", "=", "None", ")", ":", "items", "=", "iter", "(", "items", ")", "first", "=", "next", "(", "items", ")", "cls", "=", "first", ".", "__class__", "if", "stream", "is", "None", ":", "stream", "=", ...
Write a list of items to stream in CSV format. The items need to be attrs-decorated.
[ "Write", "a", "list", "of", "items", "to", "stream", "in", "CSV", "format", "." ]
908114fe3a1506dcaafb23ce49e99f171e5e329d
https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/feature/feature.py#L132-L146
43,166
numirias/firefed
firefed/feature/feature.py
FeatureHelpersMixin.profile_path
def profile_path(self, path, must_exist=False): """Return path from current profile.""" full_path = self.session.profile / path if must_exist and not full_path.exists(): raise FileNotFoundError( errno.ENOENT, os.strerror(errno.ENOENT), ...
python
def profile_path(self, path, must_exist=False): """Return path from current profile.""" full_path = self.session.profile / path if must_exist and not full_path.exists(): raise FileNotFoundError( errno.ENOENT, os.strerror(errno.ENOENT), ...
[ "def", "profile_path", "(", "self", ",", "path", ",", "must_exist", "=", "False", ")", ":", "full_path", "=", "self", ".", "session", ".", "profile", "/", "path", "if", "must_exist", "and", "not", "full_path", ".", "exists", "(", ")", ":", "raise", "Fi...
Return path from current profile.
[ "Return", "path", "from", "current", "profile", "." ]
908114fe3a1506dcaafb23ce49e99f171e5e329d
https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/feature/feature.py#L148-L157
43,167
fooelisa/pyiosxr
pyIOSXR/iosxr.py
IOSXR.make_rpc_call
def make_rpc_call(self, rpc_command): """ Allow a user to query a device directly using XML-requests. :param rpc_command: (str) rpc command such as: <Get><Operational><LLDP><NodeTable></NodeTable></LLDP></Operational></Get> """ # ~~~ hack: ~~~ ...
python
def make_rpc_call(self, rpc_command): """ Allow a user to query a device directly using XML-requests. :param rpc_command: (str) rpc command such as: <Get><Operational><LLDP><NodeTable></NodeTable></LLDP></Operational></Get> """ # ~~~ hack: ~~~ ...
[ "def", "make_rpc_call", "(", "self", ",", "rpc_command", ")", ":", "# ~~~ hack: ~~~", "if", "not", "self", ".", "is_alive", "(", ")", ":", "self", ".", "close", "(", ")", "# force close for safety", "self", ".", "open", "(", ")", "# reopen", "# ~~~ end hack ...
Allow a user to query a device directly using XML-requests. :param rpc_command: (str) rpc command such as: <Get><Operational><LLDP><NodeTable></NodeTable></LLDP></Operational></Get>
[ "Allow", "a", "user", "to", "query", "a", "device", "directly", "using", "XML", "-", "requests", "." ]
2bc11797013f1c29d2d338c32edb95068ebdf524
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L139-L152
43,168
fooelisa/pyiosxr
pyIOSXR/iosxr.py
IOSXR.open
def open(self): """ Open a connection to an IOS-XR device. Connects to the device using SSH and drops into XML mode. """ try: self.device = ConnectHandler(device_type='cisco_xr', ip=self.hostname, ...
python
def open(self): """ Open a connection to an IOS-XR device. Connects to the device using SSH and drops into XML mode. """ try: self.device = ConnectHandler(device_type='cisco_xr', ip=self.hostname, ...
[ "def", "open", "(", "self", ")", ":", "try", ":", "self", ".", "device", "=", "ConnectHandler", "(", "device_type", "=", "'cisco_xr'", ",", "ip", "=", "self", ".", "hostname", ",", "port", "=", "self", ".", "port", ",", "username", "=", "self", ".", ...
Open a connection to an IOS-XR device. Connects to the device using SSH and drops into XML mode.
[ "Open", "a", "connection", "to", "an", "IOS", "-", "XR", "device", "." ]
2bc11797013f1c29d2d338c32edb95068ebdf524
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L154-L175
43,169
fooelisa/pyiosxr
pyIOSXR/iosxr.py
IOSXR._execute_show
def _execute_show(self, show_command): """ Executes an operational show-type command. """ rpc_command = '<CLI><Exec>{show_command}</Exec></CLI>'.format( show_command=escape_xml(show_command) ) response = self._execute_rpc(rpc_command) raw_response = re...
python
def _execute_show(self, show_command): """ Executes an operational show-type command. """ rpc_command = '<CLI><Exec>{show_command}</Exec></CLI>'.format( show_command=escape_xml(show_command) ) response = self._execute_rpc(rpc_command) raw_response = re...
[ "def", "_execute_show", "(", "self", ",", "show_command", ")", ":", "rpc_command", "=", "'<CLI><Exec>{show_command}</Exec></CLI>'", ".", "format", "(", "show_command", "=", "escape_xml", "(", "show_command", ")", ")", "response", "=", "self", ".", "_execute_rpc", ...
Executes an operational show-type command.
[ "Executes", "an", "operational", "show", "-", "type", "command", "." ]
2bc11797013f1c29d2d338c32edb95068ebdf524
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L432-L441
43,170
fooelisa/pyiosxr
pyIOSXR/iosxr.py
IOSXR._execute_config_show
def _execute_config_show(self, show_command, delay_factor=.1): """ Executes a configuration show-type command. """ rpc_command = '<CLI><Configuration>{show_command}</Configuration></CLI>'.format( show_command=escape_xml(show_command) ) response = self._execute...
python
def _execute_config_show(self, show_command, delay_factor=.1): """ Executes a configuration show-type command. """ rpc_command = '<CLI><Configuration>{show_command}</Configuration></CLI>'.format( show_command=escape_xml(show_command) ) response = self._execute...
[ "def", "_execute_config_show", "(", "self", ",", "show_command", ",", "delay_factor", "=", ".1", ")", ":", "rpc_command", "=", "'<CLI><Configuration>{show_command}</Configuration></CLI>'", ".", "format", "(", "show_command", "=", "escape_xml", "(", "show_command", ")", ...
Executes a configuration show-type command.
[ "Executes", "a", "configuration", "show", "-", "type", "command", "." ]
2bc11797013f1c29d2d338c32edb95068ebdf524
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L444-L453
43,171
fooelisa/pyiosxr
pyIOSXR/iosxr.py
IOSXR.close
def close(self): """ Close the connection to the IOS-XR device. Clean up after you are done and explicitly close the router connection. """ if self.lock_on_connect or self.locked: self.unlock() # this refers to the config DB self._unlock_xml_agent() # this ...
python
def close(self): """ Close the connection to the IOS-XR device. Clean up after you are done and explicitly close the router connection. """ if self.lock_on_connect or self.locked: self.unlock() # this refers to the config DB self._unlock_xml_agent() # this ...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "lock_on_connect", "or", "self", ".", "locked", ":", "self", ".", "unlock", "(", ")", "# this refers to the config DB", "self", ".", "_unlock_xml_agent", "(", ")", "# this refers to the XML agent", "if", ...
Close the connection to the IOS-XR device. Clean up after you are done and explicitly close the router connection.
[ "Close", "the", "connection", "to", "the", "IOS", "-", "XR", "device", "." ]
2bc11797013f1c29d2d338c32edb95068ebdf524
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L455-L465
43,172
fooelisa/pyiosxr
pyIOSXR/iosxr.py
IOSXR.lock
def lock(self): """ Lock the config database. Use if Locking/Unlocking is not performaed automatically by lock=False """ if not self.locked: rpc_command = '<Lock/>' try: self._execute_rpc(rpc_command) except XMLCLIError: ...
python
def lock(self): """ Lock the config database. Use if Locking/Unlocking is not performaed automatically by lock=False """ if not self.locked: rpc_command = '<Lock/>' try: self._execute_rpc(rpc_command) except XMLCLIError: ...
[ "def", "lock", "(", "self", ")", ":", "if", "not", "self", ".", "locked", ":", "rpc_command", "=", "'<Lock/>'", "try", ":", "self", ".", "_execute_rpc", "(", "rpc_command", ")", "except", "XMLCLIError", ":", "raise", "LockError", "(", "'Unable to enter in co...
Lock the config database. Use if Locking/Unlocking is not performaed automatically by lock=False
[ "Lock", "the", "config", "database", "." ]
2bc11797013f1c29d2d338c32edb95068ebdf524
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L467-L479
43,173
fooelisa/pyiosxr
pyIOSXR/iosxr.py
IOSXR.unlock
def unlock(self): """ Unlock the IOS-XR device config. Use if Locking/Unlocking is not performaed automatically by lock=False """ if self.locked: rpc_command = '<Unlock/>' try: self._execute_rpc(rpc_command) except XMLCLIError:...
python
def unlock(self): """ Unlock the IOS-XR device config. Use if Locking/Unlocking is not performaed automatically by lock=False """ if self.locked: rpc_command = '<Unlock/>' try: self._execute_rpc(rpc_command) except XMLCLIError:...
[ "def", "unlock", "(", "self", ")", ":", "if", "self", ".", "locked", ":", "rpc_command", "=", "'<Unlock/>'", "try", ":", "self", ".", "_execute_rpc", "(", "rpc_command", ")", "except", "XMLCLIError", ":", "raise", "UnlockError", "(", "'Unable to unlock the con...
Unlock the IOS-XR device config. Use if Locking/Unlocking is not performaed automatically by lock=False
[ "Unlock", "the", "IOS", "-", "XR", "device", "config", "." ]
2bc11797013f1c29d2d338c32edb95068ebdf524
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L481-L493
43,174
fooelisa/pyiosxr
pyIOSXR/iosxr.py
IOSXR.load_candidate_config
def load_candidate_config(self, filename=None, config=None): """ Load candidate confguration. Populate the attribute candidate_config with the desired configuration and loads it into the router. You can populate it from a file or from a string. If you send both a filename and a ...
python
def load_candidate_config(self, filename=None, config=None): """ Load candidate confguration. Populate the attribute candidate_config with the desired configuration and loads it into the router. You can populate it from a file or from a string. If you send both a filename and a ...
[ "def", "load_candidate_config", "(", "self", ",", "filename", "=", "None", ",", "config", "=", "None", ")", ":", "configuration", "=", "''", "if", "filename", "is", "None", ":", "configuration", "=", "config", "else", ":", "with", "open", "(", "filename", ...
Load candidate confguration. Populate the attribute candidate_config with the desired configuration and loads it into the router. You can populate it from a file or from a string. If you send both a filename and a string containing the configuration, the file takes precedence. ...
[ "Load", "candidate", "confguration", "." ]
2bc11797013f1c29d2d338c32edb95068ebdf524
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L495-L524
43,175
fooelisa/pyiosxr
pyIOSXR/iosxr.py
IOSXR.get_candidate_config
def get_candidate_config(self, merge=False, formal=False): """ Retrieve the configuration loaded as candidate config in your configuration session. :param merge: Merge candidate config with running config to return the complete configuration including all changed ...
python
def get_candidate_config(self, merge=False, formal=False): """ Retrieve the configuration loaded as candidate config in your configuration session. :param merge: Merge candidate config with running config to return the complete configuration including all changed ...
[ "def", "get_candidate_config", "(", "self", ",", "merge", "=", "False", ",", "formal", "=", "False", ")", ":", "command", "=", "\"show configuration\"", "if", "merge", ":", "command", "+=", "\" merge\"", "if", "formal", ":", "command", "+=", "\" formal\"", "...
Retrieve the configuration loaded as candidate config in your configuration session. :param merge: Merge candidate config with running config to return the complete configuration including all changed :param formal: Return configuration in IOS-XR formal config format
[ "Retrieve", "the", "configuration", "loaded", "as", "candidate", "config", "in", "your", "configuration", "session", "." ]
2bc11797013f1c29d2d338c32edb95068ebdf524
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L526-L545
43,176
fooelisa/pyiosxr
pyIOSXR/iosxr.py
IOSXR.compare_config
def compare_config(self): """ Compare configuration to be merged with the one on the device. Compare executed candidate config with the running config and return a diff, assuming the loaded config will be merged with the existing one. :return: Config diff. """ ...
python
def compare_config(self): """ Compare configuration to be merged with the one on the device. Compare executed candidate config with the running config and return a diff, assuming the loaded config will be merged with the existing one. :return: Config diff. """ ...
[ "def", "compare_config", "(", "self", ")", ":", "_show_merge", "=", "self", ".", "_execute_config_show", "(", "'show configuration merge'", ")", "_show_run", "=", "self", ".", "_execute_config_show", "(", "'show running-config'", ")", "diff", "=", "difflib", ".", ...
Compare configuration to be merged with the one on the device. Compare executed candidate config with the running config and return a diff, assuming the loaded config will be merged with the existing one. :return: Config diff.
[ "Compare", "configuration", "to", "be", "merged", "with", "the", "one", "on", "the", "device", "." ]
2bc11797013f1c29d2d338c32edb95068ebdf524
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L547-L561
43,177
fooelisa/pyiosxr
pyIOSXR/iosxr.py
IOSXR.commit_config
def commit_config(self, label=None, comment=None, confirmed=None): """ Commit the candidate config. :param label: Commit comment, displayed in the commit entry on the device. :param comment: Commit label, displayed instead of the commit ID on the device. (Max 60 characters) ...
python
def commit_config(self, label=None, comment=None, confirmed=None): """ Commit the candidate config. :param label: Commit comment, displayed in the commit entry on the device. :param comment: Commit label, displayed instead of the commit ID on the device. (Max 60 characters) ...
[ "def", "commit_config", "(", "self", ",", "label", "=", "None", ",", "comment", "=", "None", ",", "confirmed", "=", "None", ")", ":", "rpc_command", "=", "'<Commit'", "if", "label", ":", "rpc_command", "+=", "' Label=\"%s\"'", "%", "label", "if", "comment"...
Commit the candidate config. :param label: Commit comment, displayed in the commit entry on the device. :param comment: Commit label, displayed instead of the commit ID on the device. (Max 60 characters) :param confirmed: Commit with auto-rollback if new commit is not made in 30 to 300 se...
[ "Commit", "the", "candidate", "config", "." ]
2bc11797013f1c29d2d338c32edb95068ebdf524
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L577-L597
43,178
fooelisa/pyiosxr
pyIOSXR/iosxr.py
IOSXR.rollback
def rollback(self, rb_id=1): """ Rollback the last committed configuration. :param rb_id: Rollback a specific number of steps. Default: 1 """ rpc_command = '<Unlock/><Rollback><Previous>{rb_id}</Previous></Rollback><Lock/>'.format(rb_id=rb_id) self._execute_rpc(rpc_comma...
python
def rollback(self, rb_id=1): """ Rollback the last committed configuration. :param rb_id: Rollback a specific number of steps. Default: 1 """ rpc_command = '<Unlock/><Rollback><Previous>{rb_id}</Previous></Rollback><Lock/>'.format(rb_id=rb_id) self._execute_rpc(rpc_comma...
[ "def", "rollback", "(", "self", ",", "rb_id", "=", "1", ")", ":", "rpc_command", "=", "'<Unlock/><Rollback><Previous>{rb_id}</Previous></Rollback><Lock/>'", ".", "format", "(", "rb_id", "=", "rb_id", ")", "self", ".", "_execute_rpc", "(", "rpc_command", ")" ]
Rollback the last committed configuration. :param rb_id: Rollback a specific number of steps. Default: 1
[ "Rollback", "the", "last", "committed", "configuration", "." ]
2bc11797013f1c29d2d338c32edb95068ebdf524
https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L629-L636
43,179
sinch/python-sinch-sms
sinchsms.py
_main
def _main(): """ A simple demo to be used from command line. """ import sys def log(message): print(message) def print_usage(): log('usage: %s <application key> <application secret> send <number> <message> <from_number>' % sys.argv[0]) log(' %s <application key> <applicat...
python
def _main(): """ A simple demo to be used from command line. """ import sys def log(message): print(message) def print_usage(): log('usage: %s <application key> <application secret> send <number> <message> <from_number>' % sys.argv[0]) log(' %s <application key> <applicat...
[ "def", "_main", "(", ")", ":", "import", "sys", "def", "log", "(", "message", ")", ":", "print", "(", "message", ")", "def", "print_usage", "(", ")", ":", "log", "(", "'usage: %s <application key> <application secret> send <number> <message> <from_number>'", "%", ...
A simple demo to be used from command line.
[ "A", "simple", "demo", "to", "be", "used", "from", "command", "line", "." ]
8bb8bb9ca044ee915c8e4ca0d628d28f057d6bd2
https://github.com/sinch/python-sinch-sms/blob/8bb8bb9ca044ee915c8e4ca0d628d28f057d6bd2/sinchsms.py#L97-L123
43,180
sinch/python-sinch-sms
sinchsms.py
SinchSMS._request
def _request(self, url, values=None): """ Send a request and read response. Sends a get request if values are None, post request otherwise. """ if values: json_data = json.dumps(values) request = urllib2.Request(url, json_data.encode()) request.ad...
python
def _request(self, url, values=None): """ Send a request and read response. Sends a get request if values are None, post request otherwise. """ if values: json_data = json.dumps(values) request = urllib2.Request(url, json_data.encode()) request.ad...
[ "def", "_request", "(", "self", ",", "url", ",", "values", "=", "None", ")", ":", "if", "values", ":", "json_data", "=", "json", ".", "dumps", "(", "values", ")", "request", "=", "urllib2", ".", "Request", "(", "url", ",", "json_data", ".", "encode",...
Send a request and read response. Sends a get request if values are None, post request otherwise.
[ "Send", "a", "request", "and", "read", "response", "." ]
8bb8bb9ca044ee915c8e4ca0d628d28f057d6bd2
https://github.com/sinch/python-sinch-sms/blob/8bb8bb9ca044ee915c8e4ca0d628d28f057d6bd2/sinchsms.py#L30-L55
43,181
sinch/python-sinch-sms
sinchsms.py
SinchSMS.send_message
def send_message(self, to_number, message, from_number=None): """ Send a message to the specified number and return a response dictionary. The numbers must be specified in international format starting with a '+'. Returns a dictionary that contains a 'MessageId' key with the sent messag...
python
def send_message(self, to_number, message, from_number=None): """ Send a message to the specified number and return a response dictionary. The numbers must be specified in international format starting with a '+'. Returns a dictionary that contains a 'MessageId' key with the sent messag...
[ "def", "send_message", "(", "self", ",", "to_number", ",", "message", ",", "from_number", "=", "None", ")", ":", "values", "=", "{", "'Message'", ":", "message", "}", "if", "from_number", "is", "not", "None", ":", "values", "[", "'From'", "]", "=", "fr...
Send a message to the specified number and return a response dictionary. The numbers must be specified in international format starting with a '+'. Returns a dictionary that contains a 'MessageId' key with the sent message id value or contains 'errorCode' and 'message' on error. ...
[ "Send", "a", "message", "to", "the", "specified", "number", "and", "return", "a", "response", "dictionary", "." ]
8bb8bb9ca044ee915c8e4ca0d628d28f057d6bd2
https://github.com/sinch/python-sinch-sms/blob/8bb8bb9ca044ee915c8e4ca0d628d28f057d6bd2/sinchsms.py#L57-L79
43,182
frictionlessdata/tableschema-bigquery-py
tableschema_bigquery/mapper.py
Mapper.convert_descriptor
def convert_descriptor(self, descriptor): """Convert descriptor to BigQuery """ # Fields fields = [] fallbacks = [] schema = tableschema.Schema(descriptor) for index, field in enumerate(schema.fields): converted_type = self.convert_type(field.type) ...
python
def convert_descriptor(self, descriptor): """Convert descriptor to BigQuery """ # Fields fields = [] fallbacks = [] schema = tableschema.Schema(descriptor) for index, field in enumerate(schema.fields): converted_type = self.convert_type(field.type) ...
[ "def", "convert_descriptor", "(", "self", ",", "descriptor", ")", ":", "# Fields", "fields", "=", "[", "]", "fallbacks", "=", "[", "]", "schema", "=", "tableschema", ".", "Schema", "(", "descriptor", ")", "for", "index", ",", "field", "in", "enumerate", ...
Convert descriptor to BigQuery
[ "Convert", "descriptor", "to", "BigQuery" ]
aec6f0530ba5a0a08499f5e7a10f2c179c500285
https://github.com/frictionlessdata/tableschema-bigquery-py/blob/aec6f0530ba5a0a08499f5e7a10f2c179c500285/tableschema_bigquery/mapper.py#L30-L57
43,183
frictionlessdata/tableschema-bigquery-py
tableschema_bigquery/mapper.py
Mapper.convert_row
def convert_row(self, row, schema, fallbacks): """Convert row to BigQuery """ for index, field in enumerate(schema.fields): value = row[index] if index in fallbacks: value = _uncast_value(value, field=field) else: value = field....
python
def convert_row(self, row, schema, fallbacks): """Convert row to BigQuery """ for index, field in enumerate(schema.fields): value = row[index] if index in fallbacks: value = _uncast_value(value, field=field) else: value = field....
[ "def", "convert_row", "(", "self", ",", "row", ",", "schema", ",", "fallbacks", ")", ":", "for", "index", ",", "field", "in", "enumerate", "(", "schema", ".", "fields", ")", ":", "value", "=", "row", "[", "index", "]", "if", "index", "in", "fallbacks...
Convert row to BigQuery
[ "Convert", "row", "to", "BigQuery" ]
aec6f0530ba5a0a08499f5e7a10f2c179c500285
https://github.com/frictionlessdata/tableschema-bigquery-py/blob/aec6f0530ba5a0a08499f5e7a10f2c179c500285/tableschema_bigquery/mapper.py#L59-L69
43,184
frictionlessdata/tableschema-bigquery-py
tableschema_bigquery/mapper.py
Mapper.convert_type
def convert_type(self, type): """Convert type to BigQuery """ # Mapping mapping = { 'any': 'STRING', 'array': None, 'boolean': 'BOOLEAN', 'date': 'DATE', 'datetime': 'DATETIME', 'duration': None, 'geojso...
python
def convert_type(self, type): """Convert type to BigQuery """ # Mapping mapping = { 'any': 'STRING', 'array': None, 'boolean': 'BOOLEAN', 'date': 'DATE', 'datetime': 'DATETIME', 'duration': None, 'geojso...
[ "def", "convert_type", "(", "self", ",", "type", ")", ":", "# Mapping", "mapping", "=", "{", "'any'", ":", "'STRING'", ",", "'array'", ":", "None", ",", "'boolean'", ":", "'BOOLEAN'", ",", "'date'", ":", "'DATE'", ",", "'datetime'", ":", "'DATETIME'", ",...
Convert type to BigQuery
[ "Convert", "type", "to", "BigQuery" ]
aec6f0530ba5a0a08499f5e7a10f2c179c500285
https://github.com/frictionlessdata/tableschema-bigquery-py/blob/aec6f0530ba5a0a08499f5e7a10f2c179c500285/tableschema_bigquery/mapper.py#L71-L99
43,185
frictionlessdata/tableschema-bigquery-py
tableschema_bigquery/mapper.py
Mapper.restore_descriptor
def restore_descriptor(self, converted_descriptor): """Restore descriptor rom BigQuery """ # Convert fields = [] for field in converted_descriptor['fields']: field_type = self.restore_type(field['type']) resfield = { 'name': field['name'],...
python
def restore_descriptor(self, converted_descriptor): """Restore descriptor rom BigQuery """ # Convert fields = [] for field in converted_descriptor['fields']: field_type = self.restore_type(field['type']) resfield = { 'name': field['name'],...
[ "def", "restore_descriptor", "(", "self", ",", "converted_descriptor", ")", ":", "# Convert", "fields", "=", "[", "]", "for", "field", "in", "converted_descriptor", "[", "'fields'", "]", ":", "field_type", "=", "self", ".", "restore_type", "(", "field", "[", ...
Restore descriptor rom BigQuery
[ "Restore", "descriptor", "rom", "BigQuery" ]
aec6f0530ba5a0a08499f5e7a10f2c179c500285
https://github.com/frictionlessdata/tableschema-bigquery-py/blob/aec6f0530ba5a0a08499f5e7a10f2c179c500285/tableschema_bigquery/mapper.py#L108-L125
43,186
frictionlessdata/tableschema-bigquery-py
tableschema_bigquery/mapper.py
Mapper.restore_row
def restore_row(self, row, schema): """Restore row from BigQuery """ for index, field in enumerate(schema.fields): if field.type == 'datetime': row[index] = parse(row[index]) if field.type == 'date': row[index] = parse(row[index]).date() ...
python
def restore_row(self, row, schema): """Restore row from BigQuery """ for index, field in enumerate(schema.fields): if field.type == 'datetime': row[index] = parse(row[index]) if field.type == 'date': row[index] = parse(row[index]).date() ...
[ "def", "restore_row", "(", "self", ",", "row", ",", "schema", ")", ":", "for", "index", ",", "field", "in", "enumerate", "(", "schema", ".", "fields", ")", ":", "if", "field", ".", "type", "==", "'datetime'", ":", "row", "[", "index", "]", "=", "pa...
Restore row from BigQuery
[ "Restore", "row", "from", "BigQuery" ]
aec6f0530ba5a0a08499f5e7a10f2c179c500285
https://github.com/frictionlessdata/tableschema-bigquery-py/blob/aec6f0530ba5a0a08499f5e7a10f2c179c500285/tableschema_bigquery/mapper.py#L127-L137
43,187
frictionlessdata/tableschema-bigquery-py
tableschema_bigquery/mapper.py
Mapper.restore_type
def restore_type(self, type): """Restore type from BigQuery """ # Mapping mapping = { 'BOOLEAN': 'boolean', 'DATE': 'date', 'DATETIME': 'datetime', 'INTEGER': 'integer', 'FLOAT': 'number', 'STRING': 'string', ...
python
def restore_type(self, type): """Restore type from BigQuery """ # Mapping mapping = { 'BOOLEAN': 'boolean', 'DATE': 'date', 'DATETIME': 'datetime', 'INTEGER': 'integer', 'FLOAT': 'number', 'STRING': 'string', ...
[ "def", "restore_type", "(", "self", ",", "type", ")", ":", "# Mapping", "mapping", "=", "{", "'BOOLEAN'", ":", "'boolean'", ",", "'DATE'", ":", "'date'", ",", "'DATETIME'", ":", "'datetime'", ",", "'INTEGER'", ":", "'integer'", ",", "'FLOAT'", ":", "'numbe...
Restore type from BigQuery
[ "Restore", "type", "from", "BigQuery" ]
aec6f0530ba5a0a08499f5e7a10f2c179c500285
https://github.com/frictionlessdata/tableschema-bigquery-py/blob/aec6f0530ba5a0a08499f5e7a10f2c179c500285/tableschema_bigquery/mapper.py#L139-L159
43,188
bastikr/boolean.py
boolean/boolean.py
BooleanAlgebra._start_operation
def _start_operation(self, ast, operation, precedence): """ Returns an AST where all operations of lower precedence are finalized. """ if TRACE_PARSE: print(' start_operation:', repr(operation), 'AST:', ast) op_prec = precedence[operation] while True: ...
python
def _start_operation(self, ast, operation, precedence): """ Returns an AST where all operations of lower precedence are finalized. """ if TRACE_PARSE: print(' start_operation:', repr(operation), 'AST:', ast) op_prec = precedence[operation] while True: ...
[ "def", "_start_operation", "(", "self", ",", "ast", ",", "operation", ",", "precedence", ")", ":", "if", "TRACE_PARSE", ":", "print", "(", "' start_operation:'", ",", "repr", "(", "operation", ")", ",", "'AST:'", ",", "ast", ")", "op_prec", "=", "precede...
Returns an AST where all operations of lower precedence are finalized.
[ "Returns", "an", "AST", "where", "all", "operations", "of", "lower", "precedence", "are", "finalized", "." ]
e984df480afc60605e9501a0d3d54d667e8f7dbf
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L346-L388
43,189
bastikr/boolean.py
boolean/boolean.py
BooleanAlgebra.tokenize
def tokenize(self, expr): """ Return an iterable of 3-tuple describing each token given an expression unicode string. This 3-tuple contains (token, token string, position): - token: either a Symbol instance or one of TOKEN_* token types. - token string: the original toke...
python
def tokenize(self, expr): """ Return an iterable of 3-tuple describing each token given an expression unicode string. This 3-tuple contains (token, token string, position): - token: either a Symbol instance or one of TOKEN_* token types. - token string: the original toke...
[ "def", "tokenize", "(", "self", ",", "expr", ")", ":", "if", "not", "isinstance", "(", "expr", ",", "basestring", ")", ":", "raise", "TypeError", "(", "'expr must be string but it is %s.'", "%", "type", "(", "expr", ")", ")", "# mapping of lowercase token string...
Return an iterable of 3-tuple describing each token given an expression unicode string. This 3-tuple contains (token, token string, position): - token: either a Symbol instance or one of TOKEN_* token types. - token string: the original token unicode string. - position: some sim...
[ "Return", "an", "iterable", "of", "3", "-", "tuple", "describing", "each", "token", "given", "an", "expression", "unicode", "string", "." ]
e984df480afc60605e9501a0d3d54d667e8f7dbf
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L390-L480
43,190
bastikr/boolean.py
boolean/boolean.py
BooleanAlgebra._rdistributive
def _rdistributive(self, expr, op_example): """ Recursively flatten the `expr` expression for the `op_example` AND or OR operation instance exmaple. """ if expr.isliteral: return expr expr_class = expr.__class__ args = (self._rdistributive(arg, op_ex...
python
def _rdistributive(self, expr, op_example): """ Recursively flatten the `expr` expression for the `op_example` AND or OR operation instance exmaple. """ if expr.isliteral: return expr expr_class = expr.__class__ args = (self._rdistributive(arg, op_ex...
[ "def", "_rdistributive", "(", "self", ",", "expr", ",", "op_example", ")", ":", "if", "expr", ".", "isliteral", ":", "return", "expr", "expr_class", "=", "expr", ".", "__class__", "args", "=", "(", "self", ".", "_rdistributive", "(", "arg", ",", "op_exam...
Recursively flatten the `expr` expression for the `op_example` AND or OR operation instance exmaple.
[ "Recursively", "flatten", "the", "expr", "expression", "for", "the", "op_example", "AND", "or", "OR", "operation", "instance", "exmaple", "." ]
e984df480afc60605e9501a0d3d54d667e8f7dbf
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L483-L503
43,191
bastikr/boolean.py
boolean/boolean.py
BooleanAlgebra.normalize
def normalize(self, expr, operation): """ Return a normalized expression transformed to its normal form in the given AND or OR operation. The new expression arguments will satisfy these conditions: - operation(*args) == expr (here mathematical equality is meant) - the op...
python
def normalize(self, expr, operation): """ Return a normalized expression transformed to its normal form in the given AND or OR operation. The new expression arguments will satisfy these conditions: - operation(*args) == expr (here mathematical equality is meant) - the op...
[ "def", "normalize", "(", "self", ",", "expr", ",", "operation", ")", ":", "# ensure that the operation is not NOT", "assert", "operation", "in", "(", "self", ".", "AND", ",", "self", ".", "OR", ",", ")", "# Move NOT inwards.", "expr", "=", "expr", ".", "lite...
Return a normalized expression transformed to its normal form in the given AND or OR operation. The new expression arguments will satisfy these conditions: - operation(*args) == expr (here mathematical equality is meant) - the operation does not occur in any of its arg. - NOT is...
[ "Return", "a", "normalized", "expression", "transformed", "to", "its", "normal", "form", "in", "the", "given", "AND", "or", "OR", "operation", "." ]
e984df480afc60605e9501a0d3d54d667e8f7dbf
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L505-L527
43,192
bastikr/boolean.py
boolean/boolean.py
Expression.get_literals
def get_literals(self): """ Return a list of all the literals contained in this expression. Include recursively subexpressions symbols. This includes duplicates. """ if self.isliteral: return [self] if not self.args: return [] retur...
python
def get_literals(self): """ Return a list of all the literals contained in this expression. Include recursively subexpressions symbols. This includes duplicates. """ if self.isliteral: return [self] if not self.args: return [] retur...
[ "def", "get_literals", "(", "self", ")", ":", "if", "self", ".", "isliteral", ":", "return", "[", "self", "]", "if", "not", "self", ".", "args", ":", "return", "[", "]", "return", "list", "(", "itertools", ".", "chain", ".", "from_iterable", "(", "ar...
Return a list of all the literals contained in this expression. Include recursively subexpressions symbols. This includes duplicates.
[ "Return", "a", "list", "of", "all", "the", "literals", "contained", "in", "this", "expression", ".", "Include", "recursively", "subexpressions", "symbols", ".", "This", "includes", "duplicates", "." ]
e984df480afc60605e9501a0d3d54d667e8f7dbf
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L576-L586
43,193
bastikr/boolean.py
boolean/boolean.py
Expression.literalize
def literalize(self): """ Return an expression where NOTs are only occurring as literals. Applied recursively to subexpressions. """ if self.isliteral: return self args = tuple(arg.literalize() for arg in self.args) if all(arg is self.args[i] for i, ar...
python
def literalize(self): """ Return an expression where NOTs are only occurring as literals. Applied recursively to subexpressions. """ if self.isliteral: return self args = tuple(arg.literalize() for arg in self.args) if all(arg is self.args[i] for i, ar...
[ "def", "literalize", "(", "self", ")", ":", "if", "self", ".", "isliteral", ":", "return", "self", "args", "=", "tuple", "(", "arg", ".", "literalize", "(", ")", "for", "arg", "in", "self", ".", "args", ")", "if", "all", "(", "arg", "is", "self", ...
Return an expression where NOTs are only occurring as literals. Applied recursively to subexpressions.
[ "Return", "an", "expression", "where", "NOTs", "are", "only", "occurring", "as", "literals", ".", "Applied", "recursively", "to", "subexpressions", "." ]
e984df480afc60605e9501a0d3d54d667e8f7dbf
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L596-L607
43,194
bastikr/boolean.py
boolean/boolean.py
Expression.get_symbols
def get_symbols(self): """ Return a list of all the symbols contained in this expression. Include recursively subexpressions symbols. This includes duplicates. """ return [s if isinstance(s, Symbol) else s.args[0] for s in self.get_literals()]
python
def get_symbols(self): """ Return a list of all the symbols contained in this expression. Include recursively subexpressions symbols. This includes duplicates. """ return [s if isinstance(s, Symbol) else s.args[0] for s in self.get_literals()]
[ "def", "get_symbols", "(", "self", ")", ":", "return", "[", "s", "if", "isinstance", "(", "s", ",", "Symbol", ")", "else", "s", ".", "args", "[", "0", "]", "for", "s", "in", "self", ".", "get_literals", "(", ")", "]" ]
Return a list of all the symbols contained in this expression. Include recursively subexpressions symbols. This includes duplicates.
[ "Return", "a", "list", "of", "all", "the", "symbols", "contained", "in", "this", "expression", ".", "Include", "recursively", "subexpressions", "symbols", ".", "This", "includes", "duplicates", "." ]
e984df480afc60605e9501a0d3d54d667e8f7dbf
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L609-L615
43,195
bastikr/boolean.py
boolean/boolean.py
Symbol.pretty
def pretty(self, indent=0, debug=False): """ Return a pretty formatted representation of self. """ debug_details = '' if debug: debug_details += '<isliteral=%r, iscanonical=%r>' % (self.isliteral, self.iscanonical) obj = "'%s'" % self.obj if isinstance(self.o...
python
def pretty(self, indent=0, debug=False): """ Return a pretty formatted representation of self. """ debug_details = '' if debug: debug_details += '<isliteral=%r, iscanonical=%r>' % (self.isliteral, self.iscanonical) obj = "'%s'" % self.obj if isinstance(self.o...
[ "def", "pretty", "(", "self", ",", "indent", "=", "0", ",", "debug", "=", "False", ")", ":", "debug_details", "=", "''", "if", "debug", ":", "debug_details", "+=", "'<isliteral=%r, iscanonical=%r>'", "%", "(", "self", ".", "isliteral", ",", "self", ".", ...
Return a pretty formatted representation of self.
[ "Return", "a", "pretty", "formatted", "representation", "of", "self", "." ]
e984df480afc60605e9501a0d3d54d667e8f7dbf
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L910-L919
43,196
bastikr/boolean.py
boolean/boolean.py
Function.pretty
def pretty(self, indent=0, debug=False): """ Return a pretty formatted representation of self as an indented tree. If debug is True, also prints debug information for each expression arg. For example: >>> print Expression().parse(u'not a and not b and not (a and ba and c) and c...
python
def pretty(self, indent=0, debug=False): """ Return a pretty formatted representation of self as an indented tree. If debug is True, also prints debug information for each expression arg. For example: >>> print Expression().parse(u'not a and not b and not (a and ba and c) and c...
[ "def", "pretty", "(", "self", ",", "indent", "=", "0", ",", "debug", "=", "False", ")", ":", "debug_details", "=", "''", "if", "debug", ":", "debug_details", "+=", "'<isliteral=%r, iscanonical=%r'", "%", "(", "self", ".", "isliteral", ",", "self", ".", "...
Return a pretty formatted representation of self as an indented tree. If debug is True, also prints debug information for each expression arg. For example: >>> print Expression().parse(u'not a and not b and not (a and ba and c) and c or c').pretty() OR( AND( NOT(S...
[ "Return", "a", "pretty", "formatted", "representation", "of", "self", "as", "an", "indented", "tree", "." ]
e984df480afc60605e9501a0d3d54d667e8f7dbf
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L960-L1004
43,197
bastikr/boolean.py
boolean/boolean.py
NOT.literalize
def literalize(self): """ Return an expression where NOTs are only occurring as literals. """ expr = self.demorgan() if isinstance(expr, self.__class__): return expr return expr.literalize()
python
def literalize(self): """ Return an expression where NOTs are only occurring as literals. """ expr = self.demorgan() if isinstance(expr, self.__class__): return expr return expr.literalize()
[ "def", "literalize", "(", "self", ")", ":", "expr", "=", "self", ".", "demorgan", "(", ")", "if", "isinstance", "(", "expr", ",", "self", ".", "__class__", ")", ":", "return", "expr", "return", "expr", ".", "literalize", "(", ")" ]
Return an expression where NOTs are only occurring as literals.
[ "Return", "an", "expression", "where", "NOTs", "are", "only", "occurring", "as", "literals", "." ]
e984df480afc60605e9501a0d3d54d667e8f7dbf
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1031-L1038
43,198
bastikr/boolean.py
boolean/boolean.py
NOT.simplify
def simplify(self): """ Return a simplified expr in canonical form. This means double negations are canceled out and all contained boolean objects are in their canonical form. """ if self.iscanonical: return self expr = self.cancel() if not i...
python
def simplify(self): """ Return a simplified expr in canonical form. This means double negations are canceled out and all contained boolean objects are in their canonical form. """ if self.iscanonical: return self expr = self.cancel() if not i...
[ "def", "simplify", "(", "self", ")", ":", "if", "self", ".", "iscanonical", ":", "return", "self", "expr", "=", "self", ".", "cancel", "(", ")", "if", "not", "isinstance", "(", "expr", ",", "self", ".", "__class__", ")", ":", "return", "expr", ".", ...
Return a simplified expr in canonical form. This means double negations are canceled out and all contained boolean objects are in their canonical form.
[ "Return", "a", "simplified", "expr", "in", "canonical", "form", "." ]
e984df480afc60605e9501a0d3d54d667e8f7dbf
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1040-L1059
43,199
bastikr/boolean.py
boolean/boolean.py
NOT.cancel
def cancel(self): """ Cancel itself and following NOTs as far as possible. Returns the simplified expression. """ expr = self while True: arg = expr.args[0] if not isinstance(arg, self.__class__): return expr expr = arg....
python
def cancel(self): """ Cancel itself and following NOTs as far as possible. Returns the simplified expression. """ expr = self while True: arg = expr.args[0] if not isinstance(arg, self.__class__): return expr expr = arg....
[ "def", "cancel", "(", "self", ")", ":", "expr", "=", "self", "while", "True", ":", "arg", "=", "expr", ".", "args", "[", "0", "]", "if", "not", "isinstance", "(", "arg", ",", "self", ".", "__class__", ")", ":", "return", "expr", "expr", "=", "arg...
Cancel itself and following NOTs as far as possible. Returns the simplified expression.
[ "Cancel", "itself", "and", "following", "NOTs", "as", "far", "as", "possible", ".", "Returns", "the", "simplified", "expression", "." ]
e984df480afc60605e9501a0d3d54d667e8f7dbf
https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1061-L1073