partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
cli
Usage: sugartex [OPTIONS] [TO] Reads from stdin and writes to stdout. Can have single argument/option only. When no args or the arg is not from options then run Pandoc SugarTeX filter that iterates over math blocks. Options: --kiwi Same as above but with kiwi flavor, --help Show ...
sugartex/sugartex_pandoc_filter.py
def cli(): """ Usage: sugartex [OPTIONS] [TO] Reads from stdin and writes to stdout. Can have single argument/option only. When no args or the arg is not from options then run Pandoc SugarTeX filter that iterates over math blocks. Options: --kiwi Same as above but with kiwi flavo...
def cli(): """ Usage: sugartex [OPTIONS] [TO] Reads from stdin and writes to stdout. Can have single argument/option only. When no args or the arg is not from options then run Pandoc SugarTeX filter that iterates over math blocks. Options: --kiwi Same as above but with kiwi flavo...
[ "Usage", ":", "sugartex", "[", "OPTIONS", "]", "[", "TO", "]" ]
kiwi0fruit/sugartex
python
https://github.com/kiwi0fruit/sugartex/blob/9eb13703cb02d3e2163c9c5f29df280f6bf49cec/sugartex/sugartex_pandoc_filter.py#L25-L43
[ "def", "cli", "(", ")", ":", "if", "len", "(", "sys", ".", "argv", ")", ">", "1", ":", "if", "sys", ".", "argv", "[", "1", "]", "==", "'--kiwi'", ":", "kiwi_hack", "(", ")", "elif", "sys", ".", "argv", "[", "1", "]", ".", "lower", "(", ")",...
9eb13703cb02d3e2163c9c5f29df280f6bf49cec
train
find_databases
define ribosomal proteins and location of curated databases
ctbBio/rp16.py
def find_databases(databases): """ define ribosomal proteins and location of curated databases """ # 16 ribosomal proteins in their expected order proteins = ['L15', 'L18', 'L6', 'S8', 'L5', 'L24', 'L14', 'S17', 'L16', 'S3', 'L22', 'S19', 'L2', 'L4', 'L3', 'S10'] # curated databases ...
def find_databases(databases): """ define ribosomal proteins and location of curated databases """ # 16 ribosomal proteins in their expected order proteins = ['L15', 'L18', 'L6', 'S8', 'L5', 'L24', 'L14', 'S17', 'L16', 'S3', 'L22', 'S19', 'L2', 'L4', 'L3', 'S10'] # curated databases ...
[ "define", "ribosomal", "proteins", "and", "location", "of", "curated", "databases" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rp16.py#L21-L48
[ "def", "find_databases", "(", "databases", ")", ":", "# 16 ribosomal proteins in their expected order", "proteins", "=", "[", "'L15'", ",", "'L18'", ",", "'L6'", ",", "'S8'", ",", "'L5'", ",", "'L24'", ",", "'L14'", ",", "'S17'", ",", "'L16'", ",", "'S3'", "...
83b2566b3a5745437ec651cd6cafddd056846240
train
scaffold_hits
get hits from each search against each RP scaffolds[scaffold] = # ORfs s2rp[scaffold] = {rp:[hits]}
ctbBio/rp16.py
def scaffold_hits(searches, fasta, max_hits): """ get hits from each search against each RP scaffolds[scaffold] = # ORfs s2rp[scaffold] = {rp:[hits]} """ # initialize ## scaffolds[scaffold] = # ORFs scaffolds = {} for seq in parse_fasta(fasta): scaffold = seq[0].split()[0].sp...
def scaffold_hits(searches, fasta, max_hits): """ get hits from each search against each RP scaffolds[scaffold] = # ORfs s2rp[scaffold] = {rp:[hits]} """ # initialize ## scaffolds[scaffold] = # ORFs scaffolds = {} for seq in parse_fasta(fasta): scaffold = seq[0].split()[0].sp...
[ "get", "hits", "from", "each", "search", "against", "each", "RP", "scaffolds", "[", "scaffold", "]", "=", "#", "ORfs", "s2rp", "[", "scaffold", "]", "=", "{", "rp", ":", "[", "hits", "]", "}" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rp16.py#L50-L75
[ "def", "scaffold_hits", "(", "searches", ",", "fasta", ",", "max_hits", ")", ":", "# initialize", "## scaffolds[scaffold] = # ORFs", "scaffolds", "=", "{", "}", "for", "seq", "in", "parse_fasta", "(", "fasta", ")", ":", "scaffold", "=", "seq", "[", "0", "]",...
83b2566b3a5745437ec651cd6cafddd056846240
train
find_next
which protein has the best hit, the one to the 'right' or to the 'left?'
ctbBio/rp16.py
def find_next(start, stop, i2hits): """ which protein has the best hit, the one to the 'right' or to the 'left?' """ if start not in i2hits and stop in i2hits: index = stop elif stop not in i2hits and start in i2hits: index = start elif start not in i2hits and stop not in i2hits:...
def find_next(start, stop, i2hits): """ which protein has the best hit, the one to the 'right' or to the 'left?' """ if start not in i2hits and stop in i2hits: index = stop elif stop not in i2hits and start in i2hits: index = start elif start not in i2hits and stop not in i2hits:...
[ "which", "protein", "has", "the", "best", "hit", "the", "one", "to", "the", "right", "or", "to", "the", "left?" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rp16.py#L77-L102
[ "def", "find_next", "(", "start", ",", "stop", ",", "i2hits", ")", ":", "if", "start", "not", "in", "i2hits", "and", "stop", "in", "i2hits", ":", "index", "=", "stop", "elif", "stop", "not", "in", "i2hits", "and", "start", "in", "i2hits", ":", "index...
83b2566b3a5745437ec651cd6cafddd056846240
train
find_ribosomal
determine which hits represent real ribosomal proteins, identify each in syntenic block max_hits_rp = maximum number of hits to consider per ribosomal protein per scaffold
ctbBio/rp16.py
def find_ribosomal(rps, scaffolds, s2rp, min_hits, max_hits_rp, max_errors): """ determine which hits represent real ribosomal proteins, identify each in syntenic block max_hits_rp = maximum number of hits to consider per ribosomal protein per scaffold """ for scaffold, proteins in list(s2rp.items()...
def find_ribosomal(rps, scaffolds, s2rp, min_hits, max_hits_rp, max_errors): """ determine which hits represent real ribosomal proteins, identify each in syntenic block max_hits_rp = maximum number of hits to consider per ribosomal protein per scaffold """ for scaffold, proteins in list(s2rp.items()...
[ "determine", "which", "hits", "represent", "real", "ribosomal", "proteins", "identify", "each", "in", "syntenic", "block", "max_hits_rp", "=", "maximum", "number", "of", "hits", "to", "consider", "per", "ribosomal", "protein", "per", "scaffold" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rp16.py#L134-L150
[ "def", "find_ribosomal", "(", "rps", ",", "scaffolds", ",", "s2rp", ",", "min_hits", ",", "max_hits_rp", ",", "max_errors", ")", ":", "for", "scaffold", ",", "proteins", "in", "list", "(", "s2rp", ".", "items", "(", ")", ")", ":", "# for each scaffold, get...
83b2566b3a5745437ec651cd6cafddd056846240
train
ribosomal
find ribosomal proteins max_hits = maximum number of blast hits to consider for an orf if 1, only consider best blast hit for each ORF max_hits_rp = maximum number of hits to consider per ribosomal protein per scaffold if 1, only consider best RP match to contig max_er...
ctbBio/rp16.py
def ribosomal(scaffolds, DBdir, min_hits, evalue_thresh, bit_thresh, \ method = 'usearch', threads = 6, \ max_hits = 1, max_hits_rp = 1, max_errors = 35): """ find ribosomal proteins max_hits = maximum number of blast hits to consider for an orf if 1, only c...
def ribosomal(scaffolds, DBdir, min_hits, evalue_thresh, bit_thresh, \ method = 'usearch', threads = 6, \ max_hits = 1, max_hits_rp = 1, max_errors = 35): """ find ribosomal proteins max_hits = maximum number of blast hits to consider for an orf if 1, only c...
[ "find", "ribosomal", "proteins", "max_hits", "=", "maximum", "number", "of", "blast", "hits", "to", "consider", "for", "an", "orf", "if", "1", "only", "consider", "best", "blast", "hit", "for", "each", "ORF", "max_hits_rp", "=", "maximum", "number", "of", ...
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rp16.py#L152-L178
[ "def", "ribosomal", "(", "scaffolds", ",", "DBdir", ",", "min_hits", ",", "evalue_thresh", ",", "bit_thresh", ",", "method", "=", "'usearch'", ",", "threads", "=", "6", ",", "max_hits", "=", "1", ",", "max_hits_rp", "=", "1", ",", "max_errors", "=", "35"...
83b2566b3a5745437ec651cd6cafddd056846240
train
filter_rep_set
Parse the rep set file and remove all sequences not associated with unique OTUs. :@type inF: file :@param inF: The representative sequence set :@rtype: list :@return: The set of sequences associated with unique OTUs
bin/filter_rep_set.py
def filter_rep_set(inF, otuSet): """ Parse the rep set file and remove all sequences not associated with unique OTUs. :@type inF: file :@param inF: The representative sequence set :@rtype: list :@return: The set of sequences associated with unique OTUs """ seqs = [] for record ...
def filter_rep_set(inF, otuSet): """ Parse the rep set file and remove all sequences not associated with unique OTUs. :@type inF: file :@param inF: The representative sequence set :@rtype: list :@return: The set of sequences associated with unique OTUs """ seqs = [] for record ...
[ "Parse", "the", "rep", "set", "file", "and", "remove", "all", "sequences", "not", "associated", "with", "unique", "OTUs", "." ]
smdabdoub/phylotoast
python
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/filter_rep_set.py#L32-L47
[ "def", "filter_rep_set", "(", "inF", ",", "otuSet", ")", ":", "seqs", "=", "[", "]", "for", "record", "in", "SeqIO", ".", "parse", "(", "inF", ",", "\"fasta\"", ")", ":", "if", "record", ".", "id", "in", "otuSet", ":", "seqs", ".", "append", "(", ...
0b74ef171e6a84761710548501dfac71285a58a3
train
ArcGISParser._init_data_map
OVERRIDDEN: Initialize required FGDC data map with XPATHS and specialized functions
gis_metadata/arcgis_metadata_parser.py
def _init_data_map(self): """ OVERRIDDEN: Initialize required FGDC data map with XPATHS and specialized functions """ if self._data_map is not None: return # Initiation happens once # Parse and validate the ArcGIS metadata root if self._xml_tree is None: agis_...
def _init_data_map(self): """ OVERRIDDEN: Initialize required FGDC data map with XPATHS and specialized functions """ if self._data_map is not None: return # Initiation happens once # Parse and validate the ArcGIS metadata root if self._xml_tree is None: agis_...
[ "OVERRIDDEN", ":", "Initialize", "required", "FGDC", "data", "map", "with", "XPATHS", "and", "specialized", "functions" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/arcgis_metadata_parser.py#L117-L257
[ "def", "_init_data_map", "(", "self", ")", ":", "if", "self", ".", "_data_map", "is", "not", "None", ":", "return", "# Initiation happens once", "# Parse and validate the ArcGIS metadata root", "if", "self", ".", "_xml_tree", "is", "None", ":", "agis_root", "=", "...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
ArcGISParser._parse_digital_forms
Concatenates a list of Digital Form data structures parsed from the metadata
gis_metadata/arcgis_metadata_parser.py
def _parse_digital_forms(self, prop=DIGITAL_FORMS): """ Concatenates a list of Digital Form data structures parsed from the metadata """ xpath_map = self._data_structures[prop] # Parse base digital form fields: 'name', 'content', 'decompression', 'version', 'specification' xpath_root =...
def _parse_digital_forms(self, prop=DIGITAL_FORMS): """ Concatenates a list of Digital Form data structures parsed from the metadata """ xpath_map = self._data_structures[prop] # Parse base digital form fields: 'name', 'content', 'decompression', 'version', 'specification' xpath_root =...
[ "Concatenates", "a", "list", "of", "Digital", "Form", "data", "structures", "parsed", "from", "the", "metadata" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/arcgis_metadata_parser.py#L259-L289
[ "def", "_parse_digital_forms", "(", "self", ",", "prop", "=", "DIGITAL_FORMS", ")", ":", "xpath_map", "=", "self", ".", "_data_structures", "[", "prop", "]", "# Parse base digital form fields: 'name', 'content', 'decompression', 'version', 'specification'", "xpath_root", "=",...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
ArcGISParser._parse_report_item
:return: the text for each element at the configured path if type attribute matches
gis_metadata/arcgis_metadata_parser.py
def _parse_report_item(self, prop): """ :return: the text for each element at the configured path if type attribute matches""" item_type = None if prop == 'attribute_accuracy': item_type = 'DQQuanAttAcc' elif prop == 'dataset_completeness': item_type = 'DQCompOm...
def _parse_report_item(self, prop): """ :return: the text for each element at the configured path if type attribute matches""" item_type = None if prop == 'attribute_accuracy': item_type = 'DQQuanAttAcc' elif prop == 'dataset_completeness': item_type = 'DQCompOm...
[ ":", "return", ":", "the", "text", "for", "each", "element", "at", "the", "configured", "path", "if", "type", "attribute", "matches" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/arcgis_metadata_parser.py#L291-L306
[ "def", "_parse_report_item", "(", "self", ",", "prop", ")", ":", "item_type", "=", "None", "if", "prop", "==", "'attribute_accuracy'", ":", "item_type", "=", "'DQQuanAttAcc'", "elif", "prop", "==", "'dataset_completeness'", ":", "item_type", "=", "'DQCompOm'", "...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
ArcGISParser._update_dates
Update operation for ArcGIS Dates metadata :see: gis_metadata.utils._complex_definitions[DATES]
gis_metadata/arcgis_metadata_parser.py
def _update_dates(self, **update_props): """ Update operation for ArcGIS Dates metadata :see: gis_metadata.utils._complex_definitions[DATES] """ tree_to_update = update_props['tree_to_update'] xpath_root = self._data_map['_dates_root'] if self.dates: ...
def _update_dates(self, **update_props): """ Update operation for ArcGIS Dates metadata :see: gis_metadata.utils._complex_definitions[DATES] """ tree_to_update = update_props['tree_to_update'] xpath_root = self._data_map['_dates_root'] if self.dates: ...
[ "Update", "operation", "for", "ArcGIS", "Dates", "metadata", ":", "see", ":", "gis_metadata", ".", "utils", ".", "_complex_definitions", "[", "DATES", "]" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/arcgis_metadata_parser.py#L385-L405
[ "def", "_update_dates", "(", "self", ",", "*", "*", "update_props", ")", ":", "tree_to_update", "=", "update_props", "[", "'tree_to_update'", "]", "xpath_root", "=", "self", ".", "_data_map", "[", "'_dates_root'", "]", "if", "self", ".", "dates", ":", "date_...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
ArcGISParser._update_report_item
Update the text for each element at the configured path if attribute matches
gis_metadata/arcgis_metadata_parser.py
def _update_report_item(self, **update_props): """ Update the text for each element at the configured path if attribute matches """ tree_to_update = update_props['tree_to_update'] prop = update_props['prop'] values = wrap_value(update_props['values']) xroot = self._get_xroot_for...
def _update_report_item(self, **update_props): """ Update the text for each element at the configured path if attribute matches """ tree_to_update = update_props['tree_to_update'] prop = update_props['prop'] values = wrap_value(update_props['values']) xroot = self._get_xroot_for...
[ "Update", "the", "text", "for", "each", "element", "at", "the", "configured", "path", "if", "attribute", "matches" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/arcgis_metadata_parser.py#L407-L440
[ "def", "_update_report_item", "(", "self", ",", "*", "*", "update_props", ")", ":", "tree_to_update", "=", "update_props", "[", "'tree_to_update'", "]", "prop", "=", "update_props", "[", "'prop'", "]", "values", "=", "wrap_value", "(", "update_props", "[", "'v...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
VCNL40xxBase._wait_response
Wait for a response to be ready (the provided ready bits are set). If the specified timeout (in seconds) is exceeded and error will be thrown.
Adafruit_VCNL40xx/VCNL40xx.py
def _wait_response(self, ready, timeout_sec): """Wait for a response to be ready (the provided ready bits are set). If the specified timeout (in seconds) is exceeded and error will be thrown. """ # Wait for the measurement to be ready (or a timeout elapses). start = time....
def _wait_response(self, ready, timeout_sec): """Wait for a response to be ready (the provided ready bits are set). If the specified timeout (in seconds) is exceeded and error will be thrown. """ # Wait for the measurement to be ready (or a timeout elapses). start = time....
[ "Wait", "for", "a", "response", "to", "be", "ready", "(", "the", "provided", "ready", "bits", "are", "set", ")", ".", "If", "the", "specified", "timeout", "(", "in", "seconds", ")", "is", "exceeded", "and", "error", "will", "be", "thrown", "." ]
adafruit/Adafruit_Python_VCNL40xx
python
https://github.com/adafruit/Adafruit_Python_VCNL40xx/blob/f88ec755fd23017028b6dec1be0607ff4a018e10/Adafruit_VCNL40xx/VCNL40xx.py#L66-L82
[ "def", "_wait_response", "(", "self", ",", "ready", ",", "timeout_sec", ")", ":", "# Wait for the measurement to be ready (or a timeout elapses).", "start", "=", "time", ".", "time", "(", ")", "while", "True", ":", "# Check if the timeout has elapsed.", "if", "(", "ti...
f88ec755fd23017028b6dec1be0607ff4a018e10
train
VCNL40xxBase.read_proximity
Read the sensor proximity and return it as an unsigned 16-bit value. The larger the value the closer an object is to the sensor.
Adafruit_VCNL40xx/VCNL40xx.py
def read_proximity(self, timeout_sec=1): """Read the sensor proximity and return it as an unsigned 16-bit value. The larger the value the closer an object is to the sensor. """ # Ask for a proximity measurement and wait for the response. self._device.write8(VCNL40xx_COMMAND, VCNL...
def read_proximity(self, timeout_sec=1): """Read the sensor proximity and return it as an unsigned 16-bit value. The larger the value the closer an object is to the sensor. """ # Ask for a proximity measurement and wait for the response. self._device.write8(VCNL40xx_COMMAND, VCNL...
[ "Read", "the", "sensor", "proximity", "and", "return", "it", "as", "an", "unsigned", "16", "-", "bit", "value", ".", "The", "larger", "the", "value", "the", "closer", "an", "object", "is", "to", "the", "sensor", "." ]
adafruit/Adafruit_Python_VCNL40xx
python
https://github.com/adafruit/Adafruit_Python_VCNL40xx/blob/f88ec755fd23017028b6dec1be0607ff4a018e10/Adafruit_VCNL40xx/VCNL40xx.py#L84-L92
[ "def", "read_proximity", "(", "self", ",", "timeout_sec", "=", "1", ")", ":", "# Ask for a proximity measurement and wait for the response.", "self", ".", "_device", ".", "write8", "(", "VCNL40xx_COMMAND", ",", "VCNL40xx_MEASUREPROXIMITY", ")", "self", ".", "_wait_respo...
f88ec755fd23017028b6dec1be0607ff4a018e10
train
VCNL40xxBase.read_ambient
Read the ambient light sensor and return it as an unsigned 16-bit value.
Adafruit_VCNL40xx/VCNL40xx.py
def read_ambient(self, timeout_sec=1): """Read the ambient light sensor and return it as an unsigned 16-bit value. """ # Ask for an ambient measurement and wait for the response. self._device.write8(VCNL40xx_COMMAND, VCNL40xx_MEASUREAMBIENT) self._wait_response(VCNL40xx_AMBIENTRE...
def read_ambient(self, timeout_sec=1): """Read the ambient light sensor and return it as an unsigned 16-bit value. """ # Ask for an ambient measurement and wait for the response. self._device.write8(VCNL40xx_COMMAND, VCNL40xx_MEASUREAMBIENT) self._wait_response(VCNL40xx_AMBIENTRE...
[ "Read", "the", "ambient", "light", "sensor", "and", "return", "it", "as", "an", "unsigned", "16", "-", "bit", "value", "." ]
adafruit/Adafruit_Python_VCNL40xx
python
https://github.com/adafruit/Adafruit_Python_VCNL40xx/blob/f88ec755fd23017028b6dec1be0607ff4a018e10/Adafruit_VCNL40xx/VCNL40xx.py#L94-L101
[ "def", "read_ambient", "(", "self", ",", "timeout_sec", "=", "1", ")", ":", "# Ask for an ambient measurement and wait for the response.", "self", ".", "_device", ".", "write8", "(", "VCNL40xx_COMMAND", ",", "VCNL40xx_MEASUREAMBIENT", ")", "self", ".", "_wait_response",...
f88ec755fd23017028b6dec1be0607ff4a018e10
train
VCNL4010._clear_interrupt
Clear the specified interrupt bit in the interrupt status register.
Adafruit_VCNL40xx/VCNL40xx.py
def _clear_interrupt(self, intbit): """Clear the specified interrupt bit in the interrupt status register. """ int_status = self._device.readU8(VCNL4010_INTSTAT); int_status &= ~intbit; self._device.write8(VCNL4010_INTSTAT, int_status);
def _clear_interrupt(self, intbit): """Clear the specified interrupt bit in the interrupt status register. """ int_status = self._device.readU8(VCNL4010_INTSTAT); int_status &= ~intbit; self._device.write8(VCNL4010_INTSTAT, int_status);
[ "Clear", "the", "specified", "interrupt", "bit", "in", "the", "interrupt", "status", "register", "." ]
adafruit/Adafruit_Python_VCNL40xx
python
https://github.com/adafruit/Adafruit_Python_VCNL40xx/blob/f88ec755fd23017028b6dec1be0607ff4a018e10/Adafruit_VCNL40xx/VCNL40xx.py#L123-L128
[ "def", "_clear_interrupt", "(", "self", ",", "intbit", ")", ":", "int_status", "=", "self", ".", "_device", ".", "readU8", "(", "VCNL4010_INTSTAT", ")", "int_status", "&=", "~", "intbit", "self", ".", "_device", ".", "write8", "(", "VCNL4010_INTSTAT", ",", ...
f88ec755fd23017028b6dec1be0607ff4a018e10
train
VCNL4010.read_proximity
Read the sensor proximity and return it as an unsigned 16-bit value. The larger the value the closer an object is to the sensor.
Adafruit_VCNL40xx/VCNL40xx.py
def read_proximity(self, timeout_sec=1): """Read the sensor proximity and return it as an unsigned 16-bit value. The larger the value the closer an object is to the sensor. """ # Clear any interrupts. self._clear_interrupt(VCNL4010_INT_PROX_READY) # Call base class read_p...
def read_proximity(self, timeout_sec=1): """Read the sensor proximity and return it as an unsigned 16-bit value. The larger the value the closer an object is to the sensor. """ # Clear any interrupts. self._clear_interrupt(VCNL4010_INT_PROX_READY) # Call base class read_p...
[ "Read", "the", "sensor", "proximity", "and", "return", "it", "as", "an", "unsigned", "16", "-", "bit", "value", ".", "The", "larger", "the", "value", "the", "closer", "an", "object", "is", "to", "the", "sensor", "." ]
adafruit/Adafruit_Python_VCNL40xx
python
https://github.com/adafruit/Adafruit_Python_VCNL40xx/blob/f88ec755fd23017028b6dec1be0607ff4a018e10/Adafruit_VCNL40xx/VCNL40xx.py#L130-L137
[ "def", "read_proximity", "(", "self", ",", "timeout_sec", "=", "1", ")", ":", "# Clear any interrupts.", "self", ".", "_clear_interrupt", "(", "VCNL4010_INT_PROX_READY", ")", "# Call base class read_proximity and return result.", "return", "super", "(", "VCNL4010", ",", ...
f88ec755fd23017028b6dec1be0607ff4a018e10
train
VCNL4010.read_ambient
Read the ambient light sensor and return it as an unsigned 16-bit value.
Adafruit_VCNL40xx/VCNL40xx.py
def read_ambient(self, timeout_sec=1): """Read the ambient light sensor and return it as an unsigned 16-bit value. """ # Clear any interrupts. self._clear_interrupt(VCNL4010_INT_ALS_READY) # Call base class read_ambient and return result. return super(VCNL4010, self).read...
def read_ambient(self, timeout_sec=1): """Read the ambient light sensor and return it as an unsigned 16-bit value. """ # Clear any interrupts. self._clear_interrupt(VCNL4010_INT_ALS_READY) # Call base class read_ambient and return result. return super(VCNL4010, self).read...
[ "Read", "the", "ambient", "light", "sensor", "and", "return", "it", "as", "an", "unsigned", "16", "-", "bit", "value", "." ]
adafruit/Adafruit_Python_VCNL40xx
python
https://github.com/adafruit/Adafruit_Python_VCNL40xx/blob/f88ec755fd23017028b6dec1be0607ff4a018e10/Adafruit_VCNL40xx/VCNL40xx.py#L139-L145
[ "def", "read_ambient", "(", "self", ",", "timeout_sec", "=", "1", ")", ":", "# Clear any interrupts.", "self", ".", "_clear_interrupt", "(", "VCNL4010_INT_ALS_READY", ")", "# Call base class read_ambient and return result.", "return", "super", "(", "VCNL4010", ",", "sel...
f88ec755fd23017028b6dec1be0607ff4a018e10
train
SimAlg.move
Swaps two nodes
cpalgorithm/Rombach.py
def move(self): """Swaps two nodes""" a = random.randint(0, len(self.state) - 1) b = random.randint(0, len(self.state) - 1) self.state[[a,b]] = self.state[[b,a]]
def move(self): """Swaps two nodes""" a = random.randint(0, len(self.state) - 1) b = random.randint(0, len(self.state) - 1) self.state[[a,b]] = self.state[[b,a]]
[ "Swaps", "two", "nodes" ]
skojaku/core-periphery-detection
python
https://github.com/skojaku/core-periphery-detection/blob/d724e6441066622506ddb54d81ee9a1cfd15f766/cpalgorithm/Rombach.py#L19-L23
[ "def", "move", "(", "self", ")", ":", "a", "=", "random", ".", "randint", "(", "0", ",", "len", "(", "self", ".", "state", ")", "-", "1", ")", "b", "=", "random", ".", "randint", "(", "0", ",", "len", "(", "self", ".", "state", ")", "-", "1...
d724e6441066622506ddb54d81ee9a1cfd15f766
train
Rombach.detect
Detect a single core-periphery pair. Parameters ---------- G : NetworkX graph object Examples -------- >>> import networkx as nx >>> import cpalgorithm as cpa >>> G = nx.karate_club_graph() # load the karate club network. >>> rb = cp.Rombach(algorithm='ls') # label switching algorithm >>> rb....
cpalgorithm/Rombach.py
def detect(self, G): """Detect a single core-periphery pair. Parameters ---------- G : NetworkX graph object Examples -------- >>> import networkx as nx >>> import cpalgorithm as cpa >>> G = nx.karate_club_graph() # load the karate club network. >>> rb = cp.Rombach(algorithm='ls') # label swi...
def detect(self, G): """Detect a single core-periphery pair. Parameters ---------- G : NetworkX graph object Examples -------- >>> import networkx as nx >>> import cpalgorithm as cpa >>> G = nx.karate_club_graph() # load the karate club network. >>> rb = cp.Rombach(algorithm='ls') # label swi...
[ "Detect", "a", "single", "core", "-", "periphery", "pair", ".", "Parameters", "----------", "G", ":", "NetworkX", "graph", "object", "Examples", "--------", ">>>", "import", "networkx", "as", "nx", ">>>", "import", "cpalgorithm", "as", "cpa", ">>>", "G", "="...
skojaku/core-periphery-detection
python
https://github.com/skojaku/core-periphery-detection/blob/d724e6441066622506ddb54d81ee9a1cfd15f766/cpalgorithm/Rombach.py#L111-L152
[ "def", "detect", "(", "self", ",", "G", ")", ":", "Qbest", "=", "-", "100", "cbest", "=", "0", "xbest", "=", "0", "qbest", "=", "0", "for", "i", "in", "range", "(", "self", ".", "num_runs", ")", ":", "if", "self", ".", "algorithm", "==", "'ls'"...
d724e6441066622506ddb54d81ee9a1cfd15f766
train
BE.detect
Detect a single core-periphery pair using the Borgatti-Everett algorithm. Parameters ---------- G : NetworkX graph object Examples -------- >>> import networkx as nx >>> import cpalgorithm as cpa >>> G = nx.karate_club_graph() # load the karate club network. >>> be = cpa.BE() >>> be.detect(G)
cpalgorithm/BE.py
def detect(self, G): """Detect a single core-periphery pair using the Borgatti-Everett algorithm. Parameters ---------- G : NetworkX graph object Examples -------- >>> import networkx as nx >>> import cpalgorithm as cpa >>> G = nx.karate_club_graph() # load the karate club network. >>> be = c...
def detect(self, G): """Detect a single core-periphery pair using the Borgatti-Everett algorithm. Parameters ---------- G : NetworkX graph object Examples -------- >>> import networkx as nx >>> import cpalgorithm as cpa >>> G = nx.karate_club_graph() # load the karate club network. >>> be = c...
[ "Detect", "a", "single", "core", "-", "periphery", "pair", "using", "the", "Borgatti", "-", "Everett", "algorithm", ".", "Parameters", "----------", "G", ":", "NetworkX", "graph", "object", "Examples", "--------", ">>>", "import", "networkx", "as", "nx", ">>>"...
skojaku/core-periphery-detection
python
https://github.com/skojaku/core-periphery-detection/blob/d724e6441066622506ddb54d81ee9a1cfd15f766/cpalgorithm/BE.py#L52-L77
[ "def", "detect", "(", "self", ",", "G", ")", ":", "node_pairs", ",", "w", ",", "node2id", ",", "id2node", "=", "self", ".", "_to_edge_list", "(", "G", ")", "cppairs", "=", "_cp", ".", "detect_be", "(", "edges", "=", "node_pairs", ",", "ws", "=", "w...
d724e6441066622506ddb54d81ee9a1cfd15f766
train
CertificateBuilder.self_signed
A bool - if the certificate should be self-signed.
certbuilder/__init__.py
def self_signed(self, value): """ A bool - if the certificate should be self-signed. """ self._self_signed = bool(value) if self._self_signed: self._issuer = None
def self_signed(self, value): """ A bool - if the certificate should be self-signed. """ self._self_signed = bool(value) if self._self_signed: self._issuer = None
[ "A", "bool", "-", "if", "the", "certificate", "should", "be", "self", "-", "signed", "." ]
wbond/certbuilder
python
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L122-L130
[ "def", "self_signed", "(", "self", ",", "value", ")", ":", "self", ".", "_self_signed", "=", "bool", "(", "value", ")", "if", "self", ".", "_self_signed", ":", "self", ".", "_issuer", "=", "None" ]
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
train
CertificateBuilder.serial_number
An int representable in 160 bits or less - must uniquely identify this certificate when combined with the issuer name.
certbuilder/__init__.py
def serial_number(self, value): """ An int representable in 160 bits or less - must uniquely identify this certificate when combined with the issuer name. """ if not isinstance(value, int_types): raise TypeError(_pretty_message( ''' se...
def serial_number(self, value): """ An int representable in 160 bits or less - must uniquely identify this certificate when combined with the issuer name. """ if not isinstance(value, int_types): raise TypeError(_pretty_message( ''' se...
[ "An", "int", "representable", "in", "160", "bits", "or", "less", "-", "must", "uniquely", "identify", "this", "certificate", "when", "combined", "with", "the", "issuer", "name", "." ]
wbond/certbuilder
python
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L133-L165
[ "def", "serial_number", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "int_types", ")", ":", "raise", "TypeError", "(", "_pretty_message", "(", "'''\n serial_number must be an integer, not %s\n '''", ","...
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
train
CertificateBuilder.issuer
An asn1crypto.x509.Certificate object of the issuer. Used to populate both the issuer field, but also the authority key identifier extension.
certbuilder/__init__.py
def issuer(self, value): """ An asn1crypto.x509.Certificate object of the issuer. Used to populate both the issuer field, but also the authority key identifier extension. """ is_oscrypto = isinstance(value, asymmetric.Certificate) if not isinstance(value, x509.Certificat...
def issuer(self, value): """ An asn1crypto.x509.Certificate object of the issuer. Used to populate both the issuer field, but also the authority key identifier extension. """ is_oscrypto = isinstance(value, asymmetric.Certificate) if not isinstance(value, x509.Certificat...
[ "An", "asn1crypto", ".", "x509", ".", "Certificate", "object", "of", "the", "issuer", ".", "Used", "to", "populate", "both", "the", "issuer", "field", "but", "also", "the", "authority", "key", "identifier", "extension", "." ]
wbond/certbuilder
python
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L168-L192
[ "def", "issuer", "(", "self", ",", "value", ")", ":", "is_oscrypto", "=", "isinstance", "(", "value", ",", "asymmetric", ".", "Certificate", ")", "if", "not", "isinstance", "(", "value", ",", "x509", ".", "Certificate", ")", "and", "not", "is_oscrypto", ...
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
train
CertificateBuilder.begin_date
A datetime.datetime object of when the certificate becomes valid.
certbuilder/__init__.py
def begin_date(self, value): """ A datetime.datetime object of when the certificate becomes valid. """ if not isinstance(value, datetime): raise TypeError(_pretty_message( ''' begin_date must be an instance of datetime.datetime, not %s ...
def begin_date(self, value): """ A datetime.datetime object of when the certificate becomes valid. """ if not isinstance(value, datetime): raise TypeError(_pretty_message( ''' begin_date must be an instance of datetime.datetime, not %s ...
[ "A", "datetime", ".", "datetime", "object", "of", "when", "the", "certificate", "becomes", "valid", "." ]
wbond/certbuilder
python
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L195-L208
[ "def", "begin_date", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "datetime", ")", ":", "raise", "TypeError", "(", "_pretty_message", "(", "'''\n begin_date must be an instance of datetime.datetime, not %s\n ...
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
train
CertificateBuilder.end_date
A datetime.datetime object of when the certificate is last to be considered valid.
certbuilder/__init__.py
def end_date(self, value): """ A datetime.datetime object of when the certificate is last to be considered valid. """ if not isinstance(value, datetime): raise TypeError(_pretty_message( ''' end_date must be an instance of datetime.dat...
def end_date(self, value): """ A datetime.datetime object of when the certificate is last to be considered valid. """ if not isinstance(value, datetime): raise TypeError(_pretty_message( ''' end_date must be an instance of datetime.dat...
[ "A", "datetime", ".", "datetime", "object", "of", "when", "the", "certificate", "is", "last", "to", "be", "considered", "valid", "." ]
wbond/certbuilder
python
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L211-L225
[ "def", "end_date", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "datetime", ")", ":", "raise", "TypeError", "(", "_pretty_message", "(", "'''\n end_date must be an instance of datetime.datetime, not %s\n ...
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
train
CertificateBuilder._get_crl_url
Grabs the first URL out of a asn1crypto.x509.CRLDistributionPoints object :param distribution_points: The x509.CRLDistributionPoints object to pull the URL out of :return: A unicode string or None
certbuilder/__init__.py
def _get_crl_url(self, distribution_points): """ Grabs the first URL out of a asn1crypto.x509.CRLDistributionPoints object :param distribution_points: The x509.CRLDistributionPoints object to pull the URL out of :return: A unicode string or None ...
def _get_crl_url(self, distribution_points): """ Grabs the first URL out of a asn1crypto.x509.CRLDistributionPoints object :param distribution_points: The x509.CRLDistributionPoints object to pull the URL out of :return: A unicode string or None ...
[ "Grabs", "the", "first", "URL", "out", "of", "a", "asn1crypto", ".", "x509", ".", "CRLDistributionPoints", "object" ]
wbond/certbuilder
python
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L544-L564
[ "def", "_get_crl_url", "(", "self", ",", "distribution_points", ")", ":", "if", "distribution_points", "is", "None", ":", "return", "None", "for", "distribution_point", "in", "distribution_points", ":", "name", "=", "distribution_point", "[", "'distribution_point'", ...
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
train
CertificateBuilder._make_crl_distribution_points
Constructs an asn1crypto.x509.CRLDistributionPoints object :param name: A unicode string of the attribute name to use in exceptions :param value: Either a unicode string of a URL, or a 2-element tuple of a unicode string of a URL, plus an asn1crypto.x509.Certificate...
certbuilder/__init__.py
def _make_crl_distribution_points(self, name, value): """ Constructs an asn1crypto.x509.CRLDistributionPoints object :param name: A unicode string of the attribute name to use in exceptions :param value: Either a unicode string of a URL, or a 2-element tuple of ...
def _make_crl_distribution_points(self, name, value): """ Constructs an asn1crypto.x509.CRLDistributionPoints object :param name: A unicode string of the attribute name to use in exceptions :param value: Either a unicode string of a URL, or a 2-element tuple of ...
[ "Constructs", "an", "asn1crypto", ".", "x509", ".", "CRLDistributionPoints", "object" ]
wbond/certbuilder
python
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L566-L642
[ "def", "_make_crl_distribution_points", "(", "self", ",", "name", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "is_tuple", "=", "isinstance", "(", "value", ",", "tuple", ")", "if", "not", "is_tuple", "and", "not", "isinstance...
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
train
CertificateBuilder.ocsp_url
Location of the OCSP responder for this certificate. Will be one of the following types: - None for no OCSP responder - A unicode string of the URL to the OCSP responder
certbuilder/__init__.py
def ocsp_url(self): """ Location of the OCSP responder for this certificate. Will be one of the following types: - None for no OCSP responder - A unicode string of the URL to the OCSP responder """ if self._authority_information_access is None: ret...
def ocsp_url(self): """ Location of the OCSP responder for this certificate. Will be one of the following types: - None for no OCSP responder - A unicode string of the URL to the OCSP responder """ if self._authority_information_access is None: ret...
[ "Location", "of", "the", "OCSP", "responder", "for", "this", "certificate", ".", "Will", "be", "one", "of", "the", "following", "types", ":" ]
wbond/certbuilder
python
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L645-L661
[ "def", "ocsp_url", "(", "self", ")", ":", "if", "self", ".", "_authority_information_access", "is", "None", ":", "return", "None", "for", "ad", "in", "self", ".", "_authority_information_access", ":", "if", "ad", "[", "'access_method'", "]", ".", "native", "...
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
train
CertificateBuilder.ocsp_no_check
A bool - if the certificate should have the OCSP no check extension. Only applicable to certificates created for signing OCSP responses. Such certificates should normally be issued for a very short period of time since they are effectively whitelisted by clients.
certbuilder/__init__.py
def ocsp_no_check(self, value): """ A bool - if the certificate should have the OCSP no check extension. Only applicable to certificates created for signing OCSP responses. Such certificates should normally be issued for a very short period of time since they are effectively whit...
def ocsp_no_check(self, value): """ A bool - if the certificate should have the OCSP no check extension. Only applicable to certificates created for signing OCSP responses. Such certificates should normally be issued for a very short period of time since they are effectively whit...
[ "A", "bool", "-", "if", "the", "certificate", "should", "have", "the", "OCSP", "no", "check", "extension", ".", "Only", "applicable", "to", "certificates", "created", "for", "signing", "OCSP", "responses", ".", "Such", "certificates", "should", "normally", "be...
wbond/certbuilder
python
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L688-L699
[ "def", "ocsp_no_check", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "self", ".", "_ocsp_no_check", "=", "None", "else", ":", "self", ".", "_ocsp_no_check", "=", "bool", "(", "value", ")" ]
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
train
CertificateBuilder.build
Validates the certificate information, constructs the ASN.1 structure and then signs it :param signing_private_key: An asn1crypto.keys.PrivateKeyInfo or oscrypto.asymmetric.PrivateKey object for the private key to sign the certificate with. If the key is self-signed,...
certbuilder/__init__.py
def build(self, signing_private_key): """ Validates the certificate information, constructs the ASN.1 structure and then signs it :param signing_private_key: An asn1crypto.keys.PrivateKeyInfo or oscrypto.asymmetric.PrivateKey object for the private key to sign th...
def build(self, signing_private_key): """ Validates the certificate information, constructs the ASN.1 structure and then signs it :param signing_private_key: An asn1crypto.keys.PrivateKeyInfo or oscrypto.asymmetric.PrivateKey object for the private key to sign th...
[ "Validates", "the", "certificate", "information", "constructs", "the", "ASN", ".", "1", "structure", "and", "then", "signs", "it" ]
wbond/certbuilder
python
https://github.com/wbond/certbuilder/blob/969dae884fa7f73988bbf1dcbec4fb51e234a3c5/certbuilder/__init__.py#L803-L927
[ "def", "build", "(", "self", ",", "signing_private_key", ")", ":", "is_oscrypto", "=", "isinstance", "(", "signing_private_key", ",", "asymmetric", ".", "PrivateKey", ")", "if", "not", "isinstance", "(", "signing_private_key", ",", "keys", ".", "PrivateKeyInfo", ...
969dae884fa7f73988bbf1dcbec4fb51e234a3c5
train
Surprise.detect
Detect a single core-periphery pair using the Borgatti-Everett algorithm. Parameters ---------- G : NetworkX graph object Examples -------- >>> import networkx as nx >>> import cpalgorithm as cpa >>> G = nx.karate_club_graph() # load the karate club network. >>> spr = cpa.Surprise() >>> spr.d...
cpalgorithm/Surprise.py
def detect(self, G): """Detect a single core-periphery pair using the Borgatti-Everett algorithm. Parameters ---------- G : NetworkX graph object Examples -------- >>> import networkx as nx >>> import cpalgorithm as cpa >>> G = nx.karate_club_graph() # load the karate club network. >>> spr = ...
def detect(self, G): """Detect a single core-periphery pair using the Borgatti-Everett algorithm. Parameters ---------- G : NetworkX graph object Examples -------- >>> import networkx as nx >>> import cpalgorithm as cpa >>> G = nx.karate_club_graph() # load the karate club network. >>> spr = ...
[ "Detect", "a", "single", "core", "-", "periphery", "pair", "using", "the", "Borgatti", "-", "Everett", "algorithm", ".", "Parameters", "----------", "G", ":", "NetworkX", "graph", "object", "Examples", "--------", ">>>", "import", "networkx", "as", "nx", ">>>"...
skojaku/core-periphery-detection
python
https://github.com/skojaku/core-periphery-detection/blob/d724e6441066622506ddb54d81ee9a1cfd15f766/cpalgorithm/Surprise.py#L51-L86
[ "def", "detect", "(", "self", ",", "G", ")", ":", "nodes", "=", "G", ".", "nodes", "(", ")", "N", "=", "len", "(", "nodes", ")", "Cbest", "=", "np", ".", "zeros", "(", "N", ")", "qbest", "=", "0", "for", "it", "in", "range", "(", "self", "....
d724e6441066622506ddb54d81ee9a1cfd15f766
train
remodel_run
Passes a connection from the connection pool so that we can call .run() on a query without an explicit connection
remodel/monkey.py
def remodel_run(self, c=None, **global_optargs): """ Passes a connection from the connection pool so that we can call .run() on a query without an explicit connection """ if not c: with remodel.connection.get_conn() as conn: return run(self, conn, **global_optargs) else: ...
def remodel_run(self, c=None, **global_optargs): """ Passes a connection from the connection pool so that we can call .run() on a query without an explicit connection """ if not c: with remodel.connection.get_conn() as conn: return run(self, conn, **global_optargs) else: ...
[ "Passes", "a", "connection", "from", "the", "connection", "pool", "so", "that", "we", "can", "call", ".", "run", "()", "on", "a", "query", "without", "an", "explicit", "connection" ]
linkyndy/remodel
python
https://github.com/linkyndy/remodel/blob/0c6030ab673c349322eae01607d87fa776f2eaec/remodel/monkey.py#L8-L18
[ "def", "remodel_run", "(", "self", ",", "c", "=", "None", ",", "*", "*", "global_optargs", ")", ":", "if", "not", "c", ":", "with", "remodel", ".", "connection", ".", "get_conn", "(", ")", "as", "conn", ":", "return", "run", "(", "self", ",", "conn...
0c6030ab673c349322eae01607d87fa776f2eaec
train
emptylineless
Removes empty line. Example usage:: {% emptylineless %} test1 test2 test3 {% endemptylineless %} This example would return this HTML:: test1 test2 test3
modelsdoc/templatetags/modelsdoc_tags.py
def emptylineless(parser, token): """ Removes empty line. Example usage:: {% emptylineless %} test1 test2 test3 {% endemptylineless %} This example would return this HTML:: test1 test2 test3 """ nodeli...
def emptylineless(parser, token): """ Removes empty line. Example usage:: {% emptylineless %} test1 test2 test3 {% endemptylineless %} This example would return this HTML:: test1 test2 test3 """ nodeli...
[ "Removes", "empty", "line", "." ]
tell-k/django-modelsdoc
python
https://github.com/tell-k/django-modelsdoc/blob/c9d336e76251feb142347b3a41365430d3365436/modelsdoc/templatetags/modelsdoc_tags.py#L31-L54
[ "def", "emptylineless", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "'endemptylineless'", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "return", "EmptylinelessNode", "(", "nodelist", ")" ]
c9d336e76251feb142347b3a41365430d3365436
train
LowRankCore.detect
Detect a single core-periphery pair. Parameters ---------- G : NetworkX graph object Examples -------- >>> import networkx as nx >>> import cpalgorithm as cpa >>> G = nx.karate_club_graph() # load the karate club network. >>> lrc = cp.LowRankCore() >>> lrc.detect(G)
cpalgorithm/Cucuringu.py
def detect(self, G): """Detect a single core-periphery pair. Parameters ---------- G : NetworkX graph object Examples -------- >>> import networkx as nx >>> import cpalgorithm as cpa >>> G = nx.karate_club_graph() # load the karate club network. >>> lrc = cp.LowRankCore() >>> lrc.detect(G) ...
def detect(self, G): """Detect a single core-periphery pair. Parameters ---------- G : NetworkX graph object Examples -------- >>> import networkx as nx >>> import cpalgorithm as cpa >>> G = nx.karate_club_graph() # load the karate club network. >>> lrc = cp.LowRankCore() >>> lrc.detect(G) ...
[ "Detect", "a", "single", "core", "-", "periphery", "pair", ".", "Parameters", "----------", "G", ":", "NetworkX", "graph", "object", "Examples", "--------", ">>>", "import", "networkx", "as", "nx", ">>>", "import", "cpalgorithm", "as", "cpa", ">>>", "G", "="...
skojaku/core-periphery-detection
python
https://github.com/skojaku/core-periphery-detection/blob/d724e6441066622506ddb54d81ee9a1cfd15f766/cpalgorithm/Cucuringu.py#L54-L74
[ "def", "detect", "(", "self", ",", "G", ")", ":", "self", ".", "c_", ",", "self", ".", "x_", "=", "self", ".", "_low_rank_core", "(", "G", ")", "self", ".", "Q_", "=", "self", ".", "_score", "(", "G", ",", "self", ".", "c_", ",", "self", ".",...
d724e6441066622506ddb54d81ee9a1cfd15f766
train
http_purge_url
Do an HTTP PURGE of the given asset. The URL is run through urlparse and must point to the varnish instance not the varnishadm
varnish.py
def http_purge_url(url): """ Do an HTTP PURGE of the given asset. The URL is run through urlparse and must point to the varnish instance not the varnishadm """ url = urlparse(url) connection = HTTPConnection(url.hostname, url.port or 80) path = url.path or '/' connection.request('PURGE',...
def http_purge_url(url): """ Do an HTTP PURGE of the given asset. The URL is run through urlparse and must point to the varnish instance not the varnishadm """ url = urlparse(url) connection = HTTPConnection(url.hostname, url.port or 80) path = url.path or '/' connection.request('PURGE',...
[ "Do", "an", "HTTP", "PURGE", "of", "the", "given", "asset", ".", "The", "URL", "is", "run", "through", "urlparse", "and", "must", "point", "to", "the", "varnish", "instance", "not", "the", "varnishadm" ]
justquick/python-varnish
python
https://github.com/justquick/python-varnish/blob/8f114c74898e6c5ade2ce49c8b595040bd150465/varnish.py#L47-L60
[ "def", "http_purge_url", "(", "url", ")", ":", "url", "=", "urlparse", "(", "url", ")", "connection", "=", "HTTPConnection", "(", "url", ".", "hostname", ",", "url", ".", "port", "or", "80", ")", "path", "=", "url", ".", "path", "or", "'/'", "connect...
8f114c74898e6c5ade2ce49c8b595040bd150465
train
run
Non-threaded batch command runner returning output results
varnish.py
def run(addr, *commands, **kwargs): """ Non-threaded batch command runner returning output results """ results = [] handler = VarnishHandler(addr, **kwargs) for cmd in commands: if isinstance(cmd, tuple) and len(cmd)>1: results.extend([getattr(handler, c[0].replace('.','_'))(...
def run(addr, *commands, **kwargs): """ Non-threaded batch command runner returning output results """ results = [] handler = VarnishHandler(addr, **kwargs) for cmd in commands: if isinstance(cmd, tuple) and len(cmd)>1: results.extend([getattr(handler, c[0].replace('.','_'))(...
[ "Non", "-", "threaded", "batch", "command", "runner", "returning", "output", "results" ]
justquick/python-varnish
python
https://github.com/justquick/python-varnish/blob/8f114c74898e6c5ade2ce49c8b595040bd150465/varnish.py#L289-L302
[ "def", "run", "(", "addr", ",", "*", "commands", ",", "*", "*", "kwargs", ")", ":", "results", "=", "[", "]", "handler", "=", "VarnishHandler", "(", "addr", ",", "*", "*", "kwargs", ")", "for", "cmd", "in", "commands", ":", "if", "isinstance", "(",...
8f114c74898e6c5ade2ce49c8b595040bd150465
train
VarnishHandler.fetch
Run a command on the Varnish backend and return the result return value is a tuple of ((status, length), content)
varnish.py
def fetch(self, command): """ Run a command on the Varnish backend and return the result return value is a tuple of ((status, length), content) """ logging.debug('SENT: %s: %s' % (self.host, command)) self.write('%s\n' % command) while 1: buffer = self...
def fetch(self, command): """ Run a command on the Varnish backend and return the result return value is a tuple of ((status, length), content) """ logging.debug('SENT: %s: %s' % (self.host, command)) self.write('%s\n' % command) while 1: buffer = self...
[ "Run", "a", "command", "on", "the", "Varnish", "backend", "and", "return", "the", "result", "return", "value", "is", "a", "tuple", "of", "((", "status", "length", ")", "content", ")" ]
justquick/python-varnish
python
https://github.com/justquick/python-varnish/blob/8f114c74898e6c5ade2ce49c8b595040bd150465/varnish.py#L83-L101
[ "def", "fetch", "(", "self", ",", "command", ")", ":", "logging", ".", "debug", "(", "'SENT: %s: %s'", "%", "(", "self", ".", "host", ",", "command", ")", ")", "self", ".", "write", "(", "'%s\\n'", "%", "command", ")", "while", "1", ":", "buffer", ...
8f114c74898e6c5ade2ce49c8b595040bd150465
train
VarnishHandler.ping
ping [timestamp] Ping the Varnish cache process, keeping the connection alive.
varnish.py
def ping(self, timestamp=None): """ ping [timestamp] Ping the Varnish cache process, keeping the connection alive. """ cmd = 'ping' if timestamp: cmd += ' %s' % timestamp return tuple(map(float, self.fetch(cmd)[1].split()[1:]))
def ping(self, timestamp=None): """ ping [timestamp] Ping the Varnish cache process, keeping the connection alive. """ cmd = 'ping' if timestamp: cmd += ' %s' % timestamp return tuple(map(float, self.fetch(cmd)[1].split()[1:]))
[ "ping", "[", "timestamp", "]", "Ping", "the", "Varnish", "cache", "process", "keeping", "the", "connection", "alive", "." ]
justquick/python-varnish
python
https://github.com/justquick/python-varnish/blob/8f114c74898e6c5ade2ce49c8b595040bd150465/varnish.py#L123-L130
[ "def", "ping", "(", "self", ",", "timestamp", "=", "None", ")", ":", "cmd", "=", "'ping'", "if", "timestamp", ":", "cmd", "+=", "' %s'", "%", "timestamp", "return", "tuple", "(", "map", "(", "float", ",", "self", ".", "fetch", "(", "cmd", ")", "[",...
8f114c74898e6c5ade2ce49c8b595040bd150465
train
VarnishHandler.help
help [command] Display a list of available commands. If the command is specified, display help for this command.
varnish.py
def help(self, command=None): """ help [command] Display a list of available commands. If the command is specified, display help for this command. """ cmd = 'help' if command: cmd += ' %s' % command return self.fetch(cmd)[1]
def help(self, command=None): """ help [command] Display a list of available commands. If the command is specified, display help for this command. """ cmd = 'help' if command: cmd += ' %s' % command return self.fetch(cmd)[1]
[ "help", "[", "command", "]", "Display", "a", "list", "of", "available", "commands", ".", "If", "the", "command", "is", "specified", "display", "help", "for", "this", "command", "." ]
justquick/python-varnish
python
https://github.com/justquick/python-varnish/blob/8f114c74898e6c5ade2ce49c8b595040bd150465/varnish.py#L136-L144
[ "def", "help", "(", "self", ",", "command", "=", "None", ")", ":", "cmd", "=", "'help'", "if", "command", ":", "cmd", "+=", "' %s'", "%", "command", "return", "self", ".", "fetch", "(", "cmd", ")", "[", "1", "]" ]
8f114c74898e6c5ade2ce49c8b595040bd150465
train
VarnishHandler.vcl_list
vcl.list List available configurations and their respective reference counts. The active configuration is indicated with an asterisk ("*").
varnish.py
def vcl_list(self): """ vcl.list List available configurations and their respective reference counts. The active configuration is indicated with an asterisk ("*"). """ vcls = {} for line in self.fetch('vcl.list')[1].splitlines(): a = line.sp...
def vcl_list(self): """ vcl.list List available configurations and their respective reference counts. The active configuration is indicated with an asterisk ("*"). """ vcls = {} for line in self.fetch('vcl.list')[1].splitlines(): a = line.sp...
[ "vcl", ".", "list", "List", "available", "configurations", "and", "their", "respective", "reference", "counts", ".", "The", "active", "configuration", "is", "indicated", "with", "an", "asterisk", "(", "*", ")", "." ]
justquick/python-varnish
python
https://github.com/justquick/python-varnish/blob/8f114c74898e6c5ade2ce49c8b595040bd150465/varnish.py#L185-L195
[ "def", "vcl_list", "(", "self", ")", ":", "vcls", "=", "{", "}", "for", "line", "in", "self", ".", "fetch", "(", "'vcl.list'", ")", "[", "1", "]", ".", "splitlines", "(", ")", ":", "a", "=", "line", ".", "split", "(", ")", "vcls", "[", "a", "...
8f114c74898e6c5ade2ce49c8b595040bd150465
train
VarnishHandler.param_show
param.show [-l] [param] Display a list if run-time parameters and their values. If the -l option is specified, the list includes a brief explanation of each parameter. If a param is specified, display only the value and explanation for this parameter.
varnish.py
def param_show(self, param, l=False): """ param.show [-l] [param] Display a list if run-time parameters and their values. If the -l option is specified, the list includes a brief explanation of each parameter. If a param is specified, display only the value and ...
def param_show(self, param, l=False): """ param.show [-l] [param] Display a list if run-time parameters and their values. If the -l option is specified, the list includes a brief explanation of each parameter. If a param is specified, display only the value and ...
[ "param", ".", "show", "[", "-", "l", "]", "[", "param", "]", "Display", "a", "list", "if", "run", "-", "time", "parameters", "and", "their", "values", ".", "If", "the", "-", "l", "option", "is", "specified", "the", "list", "includes", "a", "brief", ...
justquick/python-varnish
python
https://github.com/justquick/python-varnish/blob/8f114c74898e6c5ade2ce49c8b595040bd150465/varnish.py#L198-L207
[ "def", "param_show", "(", "self", ",", "param", ",", "l", "=", "False", ")", ":", "cmd", "=", "'param.show '", "if", "l", ":", "cmd", "+=", "'-l '", "return", "self", ".", "fetch", "(", "cmd", "+", "param", ")" ]
8f114c74898e6c5ade2ce49c8b595040bd150465
train
main
function to
SuperMarkdown/SuperMarkdown.py
def main(): """function to """ # parse arg to find file(s) parser = argparse.ArgumentParser() parser.add_argument("-f", "--file", help="convert the markdown file to HTML") parser.add_argument("-d", "--directory", help="convert the markdown files in the...
def main(): """function to """ # parse arg to find file(s) parser = argparse.ArgumentParser() parser.add_argument("-f", "--file", help="convert the markdown file to HTML") parser.add_argument("-d", "--directory", help="convert the markdown files in the...
[ "function", "to" ]
madeindjs/Super-Markdown
python
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L108-L143
[ "def", "main", "(", ")", ":", "# parse arg to find file(s)", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "\"-f\"", ",", "\"--file\"", ",", "help", "=", "\"convert the markdown file to HTML\"", ")", "parser", ".",...
fe2da746afa6a27aaaad27a2db1dca234f802eb0
train
SuperMarkdown.add_content
add the content of the file(s) (or the text in string) in HTML body
SuperMarkdown/SuperMarkdown.py
def add_content(self, text=None, *markdown_files): """add the content of the file(s) (or the text in string) in HTML body""" for markdown_file in markdown_files: self.markdown_text += self._text_file(markdown_file) if text: self.markdown_text += text
def add_content(self, text=None, *markdown_files): """add the content of the file(s) (or the text in string) in HTML body""" for markdown_file in markdown_files: self.markdown_text += self._text_file(markdown_file) if text: self.markdown_text += text
[ "add", "the", "content", "of", "the", "file", "(", "s", ")", "(", "or", "the", "text", "in", "string", ")", "in", "HTML", "body" ]
madeindjs/Super-Markdown
python
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L31-L37
[ "def", "add_content", "(", "self", ",", "text", "=", "None", ",", "*", "markdown_files", ")", ":", "for", "markdown_file", "in", "markdown_files", ":", "self", ".", "markdown_text", "+=", "self", ".", "_text_file", "(", "markdown_file", ")", "if", "text", ...
fe2da746afa6a27aaaad27a2db1dca234f802eb0
train
SuperMarkdown.add_stylesheets
add stylesheet files in HTML head
SuperMarkdown/SuperMarkdown.py
def add_stylesheets(self, *css_files): """add stylesheet files in HTML head""" for css_file in css_files: self.main_soup.style.append(self._text_file(css_file))
def add_stylesheets(self, *css_files): """add stylesheet files in HTML head""" for css_file in css_files: self.main_soup.style.append(self._text_file(css_file))
[ "add", "stylesheet", "files", "in", "HTML", "head" ]
madeindjs/Super-Markdown
python
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L43-L46
[ "def", "add_stylesheets", "(", "self", ",", "*", "css_files", ")", ":", "for", "css_file", "in", "css_files", ":", "self", ".", "main_soup", ".", "style", ".", "append", "(", "self", ".", "_text_file", "(", "css_file", ")", ")" ]
fe2da746afa6a27aaaad27a2db1dca234f802eb0
train
SuperMarkdown.add_javascripts
add javascripts files in HTML body
SuperMarkdown/SuperMarkdown.py
def add_javascripts(self, *js_files): """add javascripts files in HTML body""" # create the script tag if don't exists if self.main_soup.script is None: script_tag = self.main_soup.new_tag('script') self.main_soup.body.append(script_tag) for js_file in js_files: ...
def add_javascripts(self, *js_files): """add javascripts files in HTML body""" # create the script tag if don't exists if self.main_soup.script is None: script_tag = self.main_soup.new_tag('script') self.main_soup.body.append(script_tag) for js_file in js_files: ...
[ "add", "javascripts", "files", "in", "HTML", "body" ]
madeindjs/Super-Markdown
python
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L48-L56
[ "def", "add_javascripts", "(", "self", ",", "*", "js_files", ")", ":", "# create the script tag if don't exists", "if", "self", ".", "main_soup", ".", "script", "is", "None", ":", "script_tag", "=", "self", ".", "main_soup", ".", "new_tag", "(", "'script'", ")...
fe2da746afa6a27aaaad27a2db1dca234f802eb0
train
SuperMarkdown.export
return the object in a file
SuperMarkdown/SuperMarkdown.py
def export(self): """return the object in a file""" with open(self.export_url, 'w', encoding='utf-8') as file: file.write(self.build()) if self.open_browser: webbrowser.open_new_tab(self.export_url)
def export(self): """return the object in a file""" with open(self.export_url, 'w', encoding='utf-8') as file: file.write(self.build()) if self.open_browser: webbrowser.open_new_tab(self.export_url)
[ "return", "the", "object", "in", "a", "file" ]
madeindjs/Super-Markdown
python
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L58-L64
[ "def", "export", "(", "self", ")", ":", "with", "open", "(", "self", ".", "export_url", ",", "'w'", ",", "encoding", "=", "'utf-8'", ")", "as", "file", ":", "file", ".", "write", "(", "self", ".", "build", "(", ")", ")", "if", "self", ".", "open_...
fe2da746afa6a27aaaad27a2db1dca234f802eb0
train
SuperMarkdown.build
convert Markdown text as html. return the html file as string
SuperMarkdown/SuperMarkdown.py
def build(self): """convert Markdown text as html. return the html file as string""" markdown_html = markdown.markdown(self.markdown_text, extensions=[ TocExtension(), 'fenced_code', 'markdown_checklist.extension', 'markdown.extensions.tables']) markdown_soup = Be...
def build(self): """convert Markdown text as html. return the html file as string""" markdown_html = markdown.markdown(self.markdown_text, extensions=[ TocExtension(), 'fenced_code', 'markdown_checklist.extension', 'markdown.extensions.tables']) markdown_soup = Be...
[ "convert", "Markdown", "text", "as", "html", ".", "return", "the", "html", "file", "as", "string" ]
madeindjs/Super-Markdown
python
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L66-L84
[ "def", "build", "(", "self", ")", ":", "markdown_html", "=", "markdown", ".", "markdown", "(", "self", ".", "markdown_text", ",", "extensions", "=", "[", "TocExtension", "(", ")", ",", "'fenced_code'", ",", "'markdown_checklist.extension'", ",", "'markdown.exten...
fe2da746afa6a27aaaad27a2db1dca234f802eb0
train
SuperMarkdown._text_file
return the content of a file
SuperMarkdown/SuperMarkdown.py
def _text_file(self, url): """return the content of a file""" try: with open(url, 'r', encoding='utf-8') as file: return file.read() except FileNotFoundError: print('File `{}` not found'.format(url)) sys.exit(0)
def _text_file(self, url): """return the content of a file""" try: with open(url, 'r', encoding='utf-8') as file: return file.read() except FileNotFoundError: print('File `{}` not found'.format(url)) sys.exit(0)
[ "return", "the", "content", "of", "a", "file" ]
madeindjs/Super-Markdown
python
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L86-L93
[ "def", "_text_file", "(", "self", ",", "url", ")", ":", "try", ":", "with", "open", "(", "url", ",", "'r'", ",", "encoding", "=", "'utf-8'", ")", "as", "file", ":", "return", "file", ".", "read", "(", ")", "except", "FileNotFoundError", ":", "print",...
fe2da746afa6a27aaaad27a2db1dca234f802eb0
train
SuperMarkdown._text_to_graphiz
create a graphviz graph from text
SuperMarkdown/SuperMarkdown.py
def _text_to_graphiz(self, text): """create a graphviz graph from text""" dot = Source(text, format='svg') return dot.pipe().decode('utf-8')
def _text_to_graphiz(self, text): """create a graphviz graph from text""" dot = Source(text, format='svg') return dot.pipe().decode('utf-8')
[ "create", "a", "graphviz", "graph", "from", "text" ]
madeindjs/Super-Markdown
python
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L95-L98
[ "def", "_text_to_graphiz", "(", "self", ",", "text", ")", ":", "dot", "=", "Source", "(", "text", ",", "format", "=", "'svg'", ")", "return", "dot", ".", "pipe", "(", ")", ".", "decode", "(", "'utf-8'", ")" ]
fe2da746afa6a27aaaad27a2db1dca234f802eb0
train
SuperMarkdown._add_mermaid_js
add js libraries and css files of mermaid js_file
SuperMarkdown/SuperMarkdown.py
def _add_mermaid_js(self): """add js libraries and css files of mermaid js_file""" self.add_javascripts('{}/js/jquery-1.11.3.min.js'.format(self.resources_path)) self.add_javascripts('{}/js/mermaid.min.js'.format(self.resources_path)) self.add_stylesheets('{}/css/mermaid.css'.format(self...
def _add_mermaid_js(self): """add js libraries and css files of mermaid js_file""" self.add_javascripts('{}/js/jquery-1.11.3.min.js'.format(self.resources_path)) self.add_javascripts('{}/js/mermaid.min.js'.format(self.resources_path)) self.add_stylesheets('{}/css/mermaid.css'.format(self...
[ "add", "js", "libraries", "and", "css", "files", "of", "mermaid", "js_file" ]
madeindjs/Super-Markdown
python
https://github.com/madeindjs/Super-Markdown/blob/fe2da746afa6a27aaaad27a2db1dca234f802eb0/SuperMarkdown/SuperMarkdown.py#L100-L105
[ "def", "_add_mermaid_js", "(", "self", ")", ":", "self", ".", "add_javascripts", "(", "'{}/js/jquery-1.11.3.min.js'", ".", "format", "(", "self", ".", "resources_path", ")", ")", "self", ".", "add_javascripts", "(", "'{}/js/mermaid.min.js'", ".", "format", "(", ...
fe2da746afa6a27aaaad27a2db1dca234f802eb0
train
CPAlgorithm.score
Get score of core-periphery pairs. Parameters ---------- G : Graph object. c : Dict object, the keys and values of which are the name of node and its ID of belonging core-periphery pair. Returns ------- q : List. q[i] is the quality of core-periphery pair i.
cpalgorithm/CPAlgorithm.py
def score(*args): """Get score of core-periphery pairs. Parameters ---------- G : Graph object. c : Dict object, the keys and values of which are the name of node and its ID of belonging core-periphery pair. Returns ------- q : List. q[i] is the quality of core-periphery pair i. """...
def score(*args): """Get score of core-periphery pairs. Parameters ---------- G : Graph object. c : Dict object, the keys and values of which are the name of node and its ID of belonging core-periphery pair. Returns ------- q : List. q[i] is the quality of core-periphery pair i. """...
[ "Get", "score", "of", "core", "-", "periphery", "pairs", ".", "Parameters", "----------", "G", ":", "Graph", "object", ".", "c", ":", "Dict", "object", "the", "keys", "and", "values", "of", "which", "are", "the", "name", "of", "node", "and", "its", "ID...
skojaku/core-periphery-detection
python
https://github.com/skojaku/core-periphery-detection/blob/d724e6441066622506ddb54d81ee9a1cfd15f766/cpalgorithm/CPAlgorithm.py#L41-L63
[ "def", "score", "(", "*", "args", ")", ":", "self", "=", "args", "[", "0", "]", "if", "len", "(", "args", ")", "==", "1", ":", "return", "self", ".", "qs_", "else", ":", "G", "=", "args", "[", "1", "]", "c", "=", "args", "[", "2", "]", "x...
d724e6441066622506ddb54d81ee9a1cfd15f766
train
CPAlgorithm._to_edge_list
Transform NetworkX object to an edge list. Parameters ---------- G : Graph object. Returns ------- node_pairs : (M, 2) numpy array, where M is the number of edges. node_pairs[i,0] and node_pairs[i,1] are the endpoints of the ith edge. w : Mx1 numpy array. w[i] is the weight of the ith edge. ...
cpalgorithm/CPAlgorithm.py
def _to_edge_list(self, G): """Transform NetworkX object to an edge list. Parameters ---------- G : Graph object. Returns ------- node_pairs : (M, 2) numpy array, where M is the number of edges. node_pairs[i,0] and node_pairs[i,1] are the endpoints of the ith edge. w : Mx1 numpy array. w[i]...
def _to_edge_list(self, G): """Transform NetworkX object to an edge list. Parameters ---------- G : Graph object. Returns ------- node_pairs : (M, 2) numpy array, where M is the number of edges. node_pairs[i,0] and node_pairs[i,1] are the endpoints of the ith edge. w : Mx1 numpy array. w[i]...
[ "Transform", "NetworkX", "object", "to", "an", "edge", "list", ".", "Parameters", "----------", "G", ":", "Graph", "object", ".", "Returns", "-------", "node_pairs", ":", "(", "M", "2", ")", "numpy", "array", "where", "M", "is", "the", "number", "of", "e...
skojaku/core-periphery-detection
python
https://github.com/skojaku/core-periphery-detection/blob/d724e6441066622506ddb54d81ee9a1cfd15f766/cpalgorithm/CPAlgorithm.py#L65-L95
[ "def", "_to_edge_list", "(", "self", ",", "G", ")", ":", "node2id", "=", "dict", "(", "zip", "(", "G", ".", "nodes", ",", "range", "(", "len", "(", "G", ".", "nodes", ")", ")", ")", ")", "id2node", "=", "dict", "(", "(", "v", ",", "k", ")", ...
d724e6441066622506ddb54d81ee9a1cfd15f766
train
StringGenerator.getSource
Extract the identifier out of this construct: ${mylist}: mylist
strgen/__init__.py
def getSource(self): """Extract the identifier out of this construct: ${mylist}: mylist """ bracket = self.next() # we should only be here because that was a bracket if not bracket == u'{': raise Exception(u"parse error getting source") c = u'' identif...
def getSource(self): """Extract the identifier out of this construct: ${mylist}: mylist """ bracket = self.next() # we should only be here because that was a bracket if not bracket == u'{': raise Exception(u"parse error getting source") c = u'' identif...
[ "Extract", "the", "identifier", "out", "of", "this", "construct", ":", "$", "{", "mylist", "}", ":", "mylist" ]
paul-wolf/strgen
python
https://github.com/paul-wolf/strgen/blob/ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f/strgen/__init__.py#L334-L353
[ "def", "getSource", "(", "self", ")", ":", "bracket", "=", "self", ".", "next", "(", ")", "# we should only be here because that was a bracket", "if", "not", "bracket", "==", "u'{'", ":", "raise", "Exception", "(", "u\"parse error getting source\"", ")", "c", "=",...
ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f
train
StringGenerator.getCharacterSet
Get a character set with individual members or ranges. Current index is on '[', the start of the character set.
strgen/__init__.py
def getCharacterSet(self): '''Get a character set with individual members or ranges. Current index is on '[', the start of the character set. ''' chars = u'' c = None cnt = 1 start = 0 while True: escaped_slash = False c...
def getCharacterSet(self): '''Get a character set with individual members or ranges. Current index is on '[', the start of the character set. ''' chars = u'' c = None cnt = 1 start = 0 while True: escaped_slash = False c...
[ "Get", "a", "character", "set", "with", "individual", "members", "or", "ranges", "." ]
paul-wolf/strgen
python
https://github.com/paul-wolf/strgen/blob/ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f/strgen/__init__.py#L368-L419
[ "def", "getCharacterSet", "(", "self", ")", ":", "chars", "=", "u''", "c", "=", "None", "cnt", "=", "1", "start", "=", "0", "while", "True", ":", "escaped_slash", "=", "False", "c", "=", "self", ".", "next", "(", ")", "# print \"pattern : \", self.patt...
ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f
train
StringGenerator.getLiteral
Get a sequence of non-special characters.
strgen/__init__.py
def getLiteral(self): '''Get a sequence of non-special characters.''' # we are on the first non-special character chars = u'' c = self.current() while True: if c and c == u"\\": c = self.next() if c: chars += c ...
def getLiteral(self): '''Get a sequence of non-special characters.''' # we are on the first non-special character chars = u'' c = self.current() while True: if c and c == u"\\": c = self.next() if c: chars += c ...
[ "Get", "a", "sequence", "of", "non", "-", "special", "characters", "." ]
paul-wolf/strgen
python
https://github.com/paul-wolf/strgen/blob/ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f/strgen/__init__.py#L421-L439
[ "def", "getLiteral", "(", "self", ")", ":", "# we are on the first non-special character", "chars", "=", "u''", "c", "=", "self", ".", "current", "(", ")", "while", "True", ":", "if", "c", "and", "c", "==", "u\"\\\\\"", ":", "c", "=", "self", ".", "next"...
ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f
train
StringGenerator.getSequence
Get a sequence of nodes.
strgen/__init__.py
def getSequence(self, level=0): '''Get a sequence of nodes.''' seq = [] op = '' left_operand = None right_operand = None sequence_closed = False while True: c = self.next() if not c: break if c and c not in self...
def getSequence(self, level=0): '''Get a sequence of nodes.''' seq = [] op = '' left_operand = None right_operand = None sequence_closed = False while True: c = self.next() if not c: break if c and c not in self...
[ "Get", "a", "sequence", "of", "nodes", "." ]
paul-wolf/strgen
python
https://github.com/paul-wolf/strgen/blob/ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f/strgen/__init__.py#L441-L501
[ "def", "getSequence", "(", "self", ",", "level", "=", "0", ")", ":", "seq", "=", "[", "]", "op", "=", "''", "left_operand", "=", "None", "right_operand", "=", "None", "sequence_closed", "=", "False", "while", "True", ":", "c", "=", "self", ".", "next...
ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f
train
StringGenerator.dump
Print the parse tree and then call render for an example.
strgen/__init__.py
def dump(self, **kwargs): import sys '''Print the parse tree and then call render for an example.''' if not self.seq: self.seq = self.getSequence() print("StringGenerator version: %s" % (__version__)) print("Python version: %s" % sys.version) # this doesn't wo...
def dump(self, **kwargs): import sys '''Print the parse tree and then call render for an example.''' if not self.seq: self.seq = self.getSequence() print("StringGenerator version: %s" % (__version__)) print("Python version: %s" % sys.version) # this doesn't wo...
[ "Print", "the", "parse", "tree", "and", "then", "call", "render", "for", "an", "example", "." ]
paul-wolf/strgen
python
https://github.com/paul-wolf/strgen/blob/ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f/strgen/__init__.py#L521-L531
[ "def", "dump", "(", "self", ",", "*", "*", "kwargs", ")", ":", "import", "sys", "if", "not", "self", ".", "seq", ":", "self", ".", "seq", "=", "self", ".", "getSequence", "(", ")", "print", "(", "\"StringGenerator version: %s\"", "%", "(", "__version__...
ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f
train
StringGenerator.render_list
Return a list of generated strings. Args: cnt (int): length of list unique (bool): whether to make entries unique Returns: list. We keep track of total attempts because a template may specify something impossible to attain, like [1-9]{} with cnt==10...
strgen/__init__.py
def render_list(self, cnt, unique=False, progress_callback=None, **kwargs): '''Return a list of generated strings. Args: cnt (int): length of list unique (bool): whether to make entries unique Returns: list. We keep track of total attempts because a...
def render_list(self, cnt, unique=False, progress_callback=None, **kwargs): '''Return a list of generated strings. Args: cnt (int): length of list unique (bool): whether to make entries unique Returns: list. We keep track of total attempts because a...
[ "Return", "a", "list", "of", "generated", "strings", "." ]
paul-wolf/strgen
python
https://github.com/paul-wolf/strgen/blob/ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f/strgen/__init__.py#L533-L570
[ "def", "render_list", "(", "self", ",", "cnt", ",", "unique", "=", "False", ",", "progress_callback", "=", "None", ",", "*", "*", "kwargs", ")", ":", "rendered_list", "=", "[", "]", "i", "=", "0", "total_attempts", "=", "0", "while", "True", ":", "if...
ca1a1484bed5a31dc9ceaef1ab62dd5582cc0d9f
train
S3utils.connect
Establish the connection. This is done automatically for you. If you lose the connection, you can manually run this to be re-connected.
s3utils/s3utils.py
def connect(self): """ Establish the connection. This is done automatically for you. If you lose the connection, you can manually run this to be re-connected. """ self.conn = boto.connect_s3(self.AWS_ACCESS_KEY_ID, self.AWS_SECRET_ACCESS_KEY, debug=self.S3UTILS_DEBUG_LEVEL) ...
def connect(self): """ Establish the connection. This is done automatically for you. If you lose the connection, you can manually run this to be re-connected. """ self.conn = boto.connect_s3(self.AWS_ACCESS_KEY_ID, self.AWS_SECRET_ACCESS_KEY, debug=self.S3UTILS_DEBUG_LEVEL) ...
[ "Establish", "the", "connection", ".", "This", "is", "done", "automatically", "for", "you", "." ]
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L145-L155
[ "def", "connect", "(", "self", ")", ":", "self", ".", "conn", "=", "boto", ".", "connect_s3", "(", "self", ".", "AWS_ACCESS_KEY_ID", ",", "self", ".", "AWS_SECRET_ACCESS_KEY", ",", "debug", "=", "self", ".", "S3UTILS_DEBUG_LEVEL", ")", "self", ".", "bucket...
aea41388a023dcf1e95588402077e31097514cf1
train
S3utils.connect_cloudfront
Connect to Cloud Front. This is done automatically for you when needed.
s3utils/s3utils.py
def connect_cloudfront(self): "Connect to Cloud Front. This is done automatically for you when needed." self.conn_cloudfront = connect_cloudfront(self.AWS_ACCESS_KEY_ID, self.AWS_SECRET_ACCESS_KEY, debug=self.S3UTILS_DEBUG_LEVEL)
def connect_cloudfront(self): "Connect to Cloud Front. This is done automatically for you when needed." self.conn_cloudfront = connect_cloudfront(self.AWS_ACCESS_KEY_ID, self.AWS_SECRET_ACCESS_KEY, debug=self.S3UTILS_DEBUG_LEVEL)
[ "Connect", "to", "Cloud", "Front", ".", "This", "is", "done", "automatically", "for", "you", "when", "needed", "." ]
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L166-L168
[ "def", "connect_cloudfront", "(", "self", ")", ":", "self", ".", "conn_cloudfront", "=", "connect_cloudfront", "(", "self", ".", "AWS_ACCESS_KEY_ID", ",", "self", ".", "AWS_SECRET_ACCESS_KEY", ",", "debug", "=", "self", ".", "S3UTILS_DEBUG_LEVEL", ")" ]
aea41388a023dcf1e95588402077e31097514cf1
train
S3utils.mkdir
Create a folder on S3. Examples -------- >>> s3utils.mkdir("path/to/my_folder") Making directory: path/to/my_folder
s3utils/s3utils.py
def mkdir(self, target_folder): """ Create a folder on S3. Examples -------- >>> s3utils.mkdir("path/to/my_folder") Making directory: path/to/my_folder """ self.printv("Making directory: %s" % target_folder) self.k.key = re.sub(r"^/|/$", "...
def mkdir(self, target_folder): """ Create a folder on S3. Examples -------- >>> s3utils.mkdir("path/to/my_folder") Making directory: path/to/my_folder """ self.printv("Making directory: %s" % target_folder) self.k.key = re.sub(r"^/|/$", "...
[ "Create", "a", "folder", "on", "S3", "." ]
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L171-L183
[ "def", "mkdir", "(", "self", ",", "target_folder", ")", ":", "self", ".", "printv", "(", "\"Making directory: %s\"", "%", "target_folder", ")", "self", ".", "k", ".", "key", "=", "re", ".", "sub", "(", "r\"^/|/$\"", ",", "\"\"", ",", "target_folder", ")"...
aea41388a023dcf1e95588402077e31097514cf1
train
S3utils.rm
Delete the path and anything under the path. Example ------- >>> s3utils.rm("path/to/file_or_folder")
s3utils/s3utils.py
def rm(self, path): """ Delete the path and anything under the path. Example ------- >>> s3utils.rm("path/to/file_or_folder") """ list_of_files = list(self.ls(path)) if list_of_files: if len(list_of_files) == 1: self.buck...
def rm(self, path): """ Delete the path and anything under the path. Example ------- >>> s3utils.rm("path/to/file_or_folder") """ list_of_files = list(self.ls(path)) if list_of_files: if len(list_of_files) == 1: self.buck...
[ "Delete", "the", "path", "and", "anything", "under", "the", "path", "." ]
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L186-L204
[ "def", "rm", "(", "self", ",", "path", ")", ":", "list_of_files", "=", "list", "(", "self", ".", "ls", "(", "path", ")", ")", "if", "list_of_files", ":", "if", "len", "(", "list_of_files", ")", "==", "1", ":", "self", ".", "bucket", ".", "delete_ke...
aea41388a023dcf1e95588402077e31097514cf1
train
S3utils.__put_key
Copy a file to s3.
s3utils/s3utils.py
def __put_key(self, local_file, target_file, acl='public-read', del_after_upload=False, overwrite=True, source="filename"): """Copy a file to s3.""" action_word = "moving" if del_after_upload else "copying" try: self.k.key = target_file # setting the path (key) of file in the conta...
def __put_key(self, local_file, target_file, acl='public-read', del_after_upload=False, overwrite=True, source="filename"): """Copy a file to s3.""" action_word = "moving" if del_after_upload else "copying" try: self.k.key = target_file # setting the path (key) of file in the conta...
[ "Copy", "a", "file", "to", "s3", "." ]
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L207-L238
[ "def", "__put_key", "(", "self", ",", "local_file", ",", "target_file", ",", "acl", "=", "'public-read'", ",", "del_after_upload", "=", "False", ",", "overwrite", "=", "True", ",", "source", "=", "\"filename\"", ")", ":", "action_word", "=", "\"moving\"", "i...
aea41388a023dcf1e95588402077e31097514cf1
train
S3utils.cp
Copy a file or folder from local to s3. Parameters ---------- local_path : string Path to file or folder. Or if you want to copy only the contents of folder, add /* at the end of folder name target_path : string Target path on S3 bucket. acl : string, ...
s3utils/s3utils.py
def cp(self, local_path, target_path, acl='public-read', del_after_upload=False, overwrite=True, invalidate=False): """ Copy a file or folder from local to s3. Parameters ---------- local_path : string Path to file or folder. Or if you want to copy only t...
def cp(self, local_path, target_path, acl='public-read', del_after_upload=False, overwrite=True, invalidate=False): """ Copy a file or folder from local to s3. Parameters ---------- local_path : string Path to file or folder. Or if you want to copy only t...
[ "Copy", "a", "file", "or", "folder", "from", "local", "to", "s3", "." ]
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L240-L336
[ "def", "cp", "(", "self", ",", "local_path", ",", "target_path", ",", "acl", "=", "'public-read'", ",", "del_after_upload", "=", "False", ",", "overwrite", "=", "True", ",", "invalidate", "=", "False", ")", ":", "result", "=", "None", "if", "overwrite", ...
aea41388a023dcf1e95588402077e31097514cf1
train
S3utils.mv
Similar to Linux mv command. Move the file to the S3 and deletes the local copy It is basically s3utils.cp that has del_after_upload=True Examples -------- >>> s3utils.mv("path/to/folder","/test/") moving /path/to/myfolder/test2.txt to test/myfolder/test2.txt ...
s3utils/s3utils.py
def mv(self, local_file, target_file, acl='public-read', overwrite=True, invalidate=False): """ Similar to Linux mv command. Move the file to the S3 and deletes the local copy It is basically s3utils.cp that has del_after_upload=True Examples -------- >>> s...
def mv(self, local_file, target_file, acl='public-read', overwrite=True, invalidate=False): """ Similar to Linux mv command. Move the file to the S3 and deletes the local copy It is basically s3utils.cp that has del_after_upload=True Examples -------- >>> s...
[ "Similar", "to", "Linux", "mv", "command", "." ]
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L483-L507
[ "def", "mv", "(", "self", ",", "local_file", ",", "target_file", ",", "acl", "=", "'public-read'", ",", "overwrite", "=", "True", ",", "invalidate", "=", "False", ")", ":", "self", ".", "cp", "(", "local_file", ",", "target_file", ",", "acl", "=", "acl...
aea41388a023dcf1e95588402077e31097514cf1
train
S3utils.cp_cropduster_image
Deal with saving cropduster images to S3. Cropduster is a Django library for resizing editorial images. S3utils was originally written to put cropduster images on S3 bucket. Extra Items in your Django Settings ----------------------------------- MEDIA_ROOT : string Django m...
s3utils/s3utils.py
def cp_cropduster_image(self, the_image_path, del_after_upload=False, overwrite=False, invalidate=False): """ Deal with saving cropduster images to S3. Cropduster is a Django library for resizing editorial images. S3utils was originally written to put cropduster images on S3 bucket. Ext...
def cp_cropduster_image(self, the_image_path, del_after_upload=False, overwrite=False, invalidate=False): """ Deal with saving cropduster images to S3. Cropduster is a Django library for resizing editorial images. S3utils was originally written to put cropduster images on S3 bucket. Ext...
[ "Deal", "with", "saving", "cropduster", "images", "to", "S3", ".", "Cropduster", "is", "a", "Django", "library", "for", "resizing", "editorial", "images", ".", "S3utils", "was", "originally", "written", "to", "put", "cropduster", "images", "on", "S3", "bucket"...
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L510-L551
[ "def", "cp_cropduster_image", "(", "self", ",", "the_image_path", ",", "del_after_upload", "=", "False", ",", "overwrite", "=", "False", ",", "invalidate", "=", "False", ")", ":", "local_file", "=", "os", ".", "path", ".", "join", "(", "settings", ".", "ME...
aea41388a023dcf1e95588402077e31097514cf1
train
S3utils.__get_grants
Return grant permission, grant owner, grant owner email and grant id as a list. It needs you to set k.key to a key on amazon (file path) before running this. note that Amazon returns a list of grants for each file. options: - private: Owner gets FULL_CONTROL. No one else has any ac...
s3utils/s3utils.py
def __get_grants(self, target_file, all_grant_data): """ Return grant permission, grant owner, grant owner email and grant id as a list. It needs you to set k.key to a key on amazon (file path) before running this. note that Amazon returns a list of grants for each file. option...
def __get_grants(self, target_file, all_grant_data): """ Return grant permission, grant owner, grant owner email and grant id as a list. It needs you to set k.key to a key on amazon (file path) before running this. note that Amazon returns a list of grants for each file. option...
[ "Return", "grant", "permission", "grant", "owner", "grant", "owner", "email", "and", "grant", "id", "as", "a", "list", ".", "It", "needs", "you", "to", "set", "k", ".", "key", "to", "a", "key", "on", "amazon", "(", "file", "path", ")", "before", "run...
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L553-L579
[ "def", "__get_grants", "(", "self", ",", "target_file", ",", "all_grant_data", ")", ":", "self", ".", "k", ".", "key", "=", "target_file", "the_grants", "=", "self", ".", "k", ".", "get_acl", "(", ")", ".", "acl", ".", "grants", "grant_list", "=", "[",...
aea41388a023dcf1e95588402077e31097514cf1
train
S3utils.chmod
sets permissions for a file on S3 Parameters ---------- target_file : string Path to file on S3 acl : string, optional File permissions on S3. Default is public-read options: - private: Owner gets FULL_CONTROL. No one else has any a...
s3utils/s3utils.py
def chmod(self, target_file, acl='public-read'): """ sets permissions for a file on S3 Parameters ---------- target_file : string Path to file on S3 acl : string, optional File permissions on S3. Default is public-read options: ...
def chmod(self, target_file, acl='public-read'): """ sets permissions for a file on S3 Parameters ---------- target_file : string Path to file on S3 acl : string, optional File permissions on S3. Default is public-read options: ...
[ "sets", "permissions", "for", "a", "file", "on", "S3" ]
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L582-L610
[ "def", "chmod", "(", "self", ",", "target_file", ",", "acl", "=", "'public-read'", ")", ":", "self", ".", "k", ".", "key", "=", "target_file", "# setting the path (key) of file in the container", "self", ".", "k", ".", "set_acl", "(", "acl", ")", "# setting th...
aea41388a023dcf1e95588402077e31097514cf1
train
S3utils.ls
gets the list of file names (keys) in a s3 folder Parameters ---------- folder : string Path to file on S3 num: integer, optional number of results to return, by default it returns all results. begin_from_file: string, optional which file t...
s3utils/s3utils.py
def ls(self, folder="", begin_from_file="", num=-1, get_grants=False, all_grant_data=False): """ gets the list of file names (keys) in a s3 folder Parameters ---------- folder : string Path to file on S3 num: integer, optional number of results ...
def ls(self, folder="", begin_from_file="", num=-1, get_grants=False, all_grant_data=False): """ gets the list of file names (keys) in a s3 folder Parameters ---------- folder : string Path to file on S3 num: integer, optional number of results ...
[ "gets", "the", "list", "of", "file", "names", "(", "keys", ")", "in", "a", "s3", "folder" ]
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L613-L667
[ "def", "ls", "(", "self", ",", "folder", "=", "\"\"", ",", "begin_from_file", "=", "\"\"", ",", "num", "=", "-", "1", ",", "get_grants", "=", "False", ",", "all_grant_data", "=", "False", ")", ":", "# S3 object key can't start with /", "folder", "=", "re",...
aea41388a023dcf1e95588402077e31097514cf1
train
S3utils.ll
Get the list of files and permissions from S3. This is similar to LL (ls -lah) in Linux: List of files with permissions. Parameters ---------- folder : string Path to file on S3 num: integer, optional number of results to return, by default it returns ...
s3utils/s3utils.py
def ll(self, folder="", begin_from_file="", num=-1, all_grant_data=False): """ Get the list of files and permissions from S3. This is similar to LL (ls -lah) in Linux: List of files with permissions. Parameters ---------- folder : string Path to file on S3 ...
def ll(self, folder="", begin_from_file="", num=-1, all_grant_data=False): """ Get the list of files and permissions from S3. This is similar to LL (ls -lah) in Linux: List of files with permissions. Parameters ---------- folder : string Path to file on S3 ...
[ "Get", "the", "list", "of", "files", "and", "permissions", "from", "S3", "." ]
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L669-L764
[ "def", "ll", "(", "self", ",", "folder", "=", "\"\"", ",", "begin_from_file", "=", "\"\"", ",", "num", "=", "-", "1", ",", "all_grant_data", "=", "False", ")", ":", "return", "self", ".", "ls", "(", "folder", "=", "folder", ",", "begin_from_file", "=...
aea41388a023dcf1e95588402077e31097514cf1
train
S3utils.invalidate
Invalidate the CDN (distribution) cache for a certain file of files. This might take up to 15 minutes to be effective. You can check for the invalidation status using check_invalidation_request. Examples -------- >>> from s3utils import S3utils >>> s3utils = S3utils( ...
s3utils/s3utils.py
def invalidate(self, files_to_be_invalidated): """ Invalidate the CDN (distribution) cache for a certain file of files. This might take up to 15 minutes to be effective. You can check for the invalidation status using check_invalidation_request. Examples -------- >...
def invalidate(self, files_to_be_invalidated): """ Invalidate the CDN (distribution) cache for a certain file of files. This might take up to 15 minutes to be effective. You can check for the invalidation status using check_invalidation_request. Examples -------- >...
[ "Invalidate", "the", "CDN", "(", "distribution", ")", "cache", "for", "a", "certain", "file", "of", "files", ".", "This", "might", "take", "up", "to", "15", "minutes", "to", "be", "effective", "." ]
seperman/s3utils
python
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L767-L802
[ "def", "invalidate", "(", "self", ",", "files_to_be_invalidated", ")", ":", "if", "not", "isinstance", "(", "files_to_be_invalidated", ",", "Iterable", ")", ":", "files_to_be_invalidated", "=", "(", "files_to_be_invalidated", ",", ")", "# Your CDN is called distribution...
aea41388a023dcf1e95588402077e31097514cf1
train
anchor
Parses a tag that's supposed to be in this format: {% anchor field title %}
django_sorting/templatetags/sorting_tags.py
def anchor(parser, token): """ Parses a tag that's supposed to be in this format: {% anchor field title %} """ bits = [b.strip('"\'') for b in token.split_contents()] if len(bits) < 2: raise TemplateSyntaxError, "anchor tag takes at least 1 argument" try: title = bits[2] ...
def anchor(parser, token): """ Parses a tag that's supposed to be in this format: {% anchor field title %} """ bits = [b.strip('"\'') for b in token.split_contents()] if len(bits) < 2: raise TemplateSyntaxError, "anchor tag takes at least 1 argument" try: title = bits[2] ...
[ "Parses", "a", "tag", "that", "s", "supposed", "to", "be", "in", "this", "format", ":", "{", "%", "anchor", "field", "title", "%", "}" ]
directeur/django-sorting
python
https://github.com/directeur/django-sorting/blob/209f6639cbce196bdc10aced1959935d254257ff/django_sorting/templatetags/sorting_tags.py#L18-L29
[ "def", "anchor", "(", "parser", ",", "token", ")", ":", "bits", "=", "[", "b", ".", "strip", "(", "'\"\\''", ")", "for", "b", "in", "token", ".", "split_contents", "(", ")", "]", "if", "len", "(", "bits", ")", "<", "2", ":", "raise", "TemplateSyn...
209f6639cbce196bdc10aced1959935d254257ff
train
get_path
Get the path from a given url, including the querystring. Args: url (str) Returns: str
sigauth/helpers.py
def get_path(url): """ Get the path from a given url, including the querystring. Args: url (str) Returns: str """ url = urlsplit(url) path = url.path if url.query: path += "?{}".format(url.query) return path
def get_path(url): """ Get the path from a given url, including the querystring. Args: url (str) Returns: str """ url = urlsplit(url) path = url.path if url.query: path += "?{}".format(url.query) return path
[ "Get", "the", "path", "from", "a", "given", "url", "including", "the", "querystring", "." ]
uktrade/directory-signature-auth
python
https://github.com/uktrade/directory-signature-auth/blob/1a1b1e887b25a938133d7bcc146d3fecf1079313/sigauth/helpers.py#L79-L94
[ "def", "get_path", "(", "url", ")", ":", "url", "=", "urlsplit", "(", "url", ")", "path", "=", "url", ".", "path", "if", "url", ".", "query", ":", "path", "+=", "\"?{}\"", ".", "format", "(", "url", ".", "query", ")", "return", "path" ]
1a1b1e887b25a938133d7bcc146d3fecf1079313
train
Build.run
Reads data from disk and generates CSV files.
receita/tools/build.py
def run(self): """Reads data from disk and generates CSV files.""" # Try to create the directory if not os.path.exists(self.output): try: os.mkdir(self.output) except: print 'failed to create output directory %s' % self.output # Be...
def run(self): """Reads data from disk and generates CSV files.""" # Try to create the directory if not os.path.exists(self.output): try: os.mkdir(self.output) except: print 'failed to create output directory %s' % self.output # Be...
[ "Reads", "data", "from", "disk", "and", "generates", "CSV", "files", "." ]
vkruoso/receita-tools
python
https://github.com/vkruoso/receita-tools/blob/fd62a252c76541c9feac6470b9048b31348ffe86/receita/tools/build.py#L144-L175
[ "def", "run", "(", "self", ")", ":", "# Try to create the directory", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "output", ")", ":", "try", ":", "os", ".", "mkdir", "(", "self", ".", "output", ")", "except", ":", "print", "'fail...
fd62a252c76541c9feac6470b9048b31348ffe86
train
Index.process_fields
Process a list of simple string field definitions and assign their order based on prefix.
marrow/mongo/core/index.py
def process_fields(self, fields): """Process a list of simple string field definitions and assign their order based on prefix.""" result = [] strip = ''.join(self.PREFIX_MAP) for field in fields: direction = self.PREFIX_MAP[''] if field[0] in self.PREFIX_MAP: direction = self.PREFIX_MAP[fiel...
def process_fields(self, fields): """Process a list of simple string field definitions and assign their order based on prefix.""" result = [] strip = ''.join(self.PREFIX_MAP) for field in fields: direction = self.PREFIX_MAP[''] if field[0] in self.PREFIX_MAP: direction = self.PREFIX_MAP[fiel...
[ "Process", "a", "list", "of", "simple", "string", "field", "definitions", "and", "assign", "their", "order", "based", "on", "prefix", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/index.py#L60-L75
[ "def", "process_fields", "(", "self", ",", "fields", ")", ":", "result", "=", "[", "]", "strip", "=", "''", ".", "join", "(", "self", ".", "PREFIX_MAP", ")", "for", "field", "in", "fields", ":", "direction", "=", "self", ".", "PREFIX_MAP", "[", "''",...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Index.create
Create this index in the specified collection; keyword arguments are passed to PyMongo. http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.create_index
marrow/mongo/core/index.py
def create(self, collection, **kw): """Create this index in the specified collection; keyword arguments are passed to PyMongo. http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.create_index """ options = dict( name = self.__name__, unique = self.unique...
def create(self, collection, **kw): """Create this index in the specified collection; keyword arguments are passed to PyMongo. http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.create_index """ options = dict( name = self.__name__, unique = self.unique...
[ "Create", "this", "index", "in", "the", "specified", "collection", ";", "keyword", "arguments", "are", "passed", "to", "PyMongo", ".", "http", ":", "//", "api", ".", "mongodb", ".", "com", "/", "python", "/", "current", "/", "api", "/", "pymongo", "/", ...
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/index.py#L77-L101
[ "def", "create", "(", "self", ",", "collection", ",", "*", "*", "kw", ")", ":", "options", "=", "dict", "(", "name", "=", "self", ".", "__name__", ",", "unique", "=", "self", ".", "unique", ",", "background", "=", "self", ".", "background", ",", "s...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
API.rubricator
Rubrics search http://api.2gis.ru/doc/firms/list/rubricator/
dgis/__init__.py
def rubricator(self, **kwargs): """Rubrics search http://api.2gis.ru/doc/firms/list/rubricator/ """ # `show_children' parameter must be an integer kwargs['show_children'] = int(kwargs.pop('show_children', False)) return self._rubricator(**kwargs)
def rubricator(self, **kwargs): """Rubrics search http://api.2gis.ru/doc/firms/list/rubricator/ """ # `show_children' parameter must be an integer kwargs['show_children'] = int(kwargs.pop('show_children', False)) return self._rubricator(**kwargs)
[ "Rubrics", "search" ]
svartalf/python-2gis
python
https://github.com/svartalf/python-2gis/blob/6eccd6073c99494b7abf20b38a5455cbd55d6420/dgis/__init__.py#L46-L55
[ "def", "rubricator", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# `show_children' parameter must be an integer", "kwargs", "[", "'show_children'", "]", "=", "int", "(", "kwargs", ".", "pop", "(", "'show_children'", ",", "False", ")", ")", "return", "self...
6eccd6073c99494b7abf20b38a5455cbd55d6420
train
API.search
Firms search http://api.2gis.ru/doc/firms/searches/search/
dgis/__init__.py
def search(self, **kwargs): """Firms search http://api.2gis.ru/doc/firms/searches/search/ """ point = kwargs.pop('point', False) if point: kwargs['point'] = '%s,%s' % (point[0], point[1]) bound = kwargs.pop('bound', False) if bound: kwar...
def search(self, **kwargs): """Firms search http://api.2gis.ru/doc/firms/searches/search/ """ point = kwargs.pop('point', False) if point: kwargs['point'] = '%s,%s' % (point[0], point[1]) bound = kwargs.pop('bound', False) if bound: kwar...
[ "Firms", "search" ]
svartalf/python-2gis
python
https://github.com/svartalf/python-2gis/blob/6eccd6073c99494b7abf20b38a5455cbd55d6420/dgis/__init__.py#L62-L82
[ "def", "search", "(", "self", ",", "*", "*", "kwargs", ")", ":", "point", "=", "kwargs", ".", "pop", "(", "'point'", ",", "False", ")", "if", "point", ":", "kwargs", "[", "'point'", "]", "=", "'%s,%s'", "%", "(", "point", "[", "0", "]", ",", "p...
6eccd6073c99494b7abf20b38a5455cbd55d6420
train
API.search_in_rubric
Firms search in rubric http://api.2gis.ru/doc/firms/searches/searchinrubric/
dgis/__init__.py
def search_in_rubric(self, **kwargs): """Firms search in rubric http://api.2gis.ru/doc/firms/searches/searchinrubric/ """ point = kwargs.pop('point', False) if point: kwargs['point'] = '%s,%s' % point bound = kwargs.pop('bound', False) if bound: ...
def search_in_rubric(self, **kwargs): """Firms search in rubric http://api.2gis.ru/doc/firms/searches/searchinrubric/ """ point = kwargs.pop('point', False) if point: kwargs['point'] = '%s,%s' % point bound = kwargs.pop('bound', False) if bound: ...
[ "Firms", "search", "in", "rubric" ]
svartalf/python-2gis
python
https://github.com/svartalf/python-2gis/blob/6eccd6073c99494b7abf20b38a5455cbd55d6420/dgis/__init__.py#L89-L109
[ "def", "search_in_rubric", "(", "self", ",", "*", "*", "kwargs", ")", ":", "point", "=", "kwargs", ".", "pop", "(", "'point'", ",", "False", ")", "if", "point", ":", "kwargs", "[", "'point'", "]", "=", "'%s,%s'", "%", "point", "bound", "=", "kwargs",...
6eccd6073c99494b7abf20b38a5455cbd55d6420
train
API.geo_search
Geo search http://api.2gis.ru/doc/geo/search/
dgis/__init__.py
def geo_search(self, **kwargs): """Geo search http://api.2gis.ru/doc/geo/search/ """ if 'types' in kwargs: kwargs['types'] = ','.join(kwargs['types']) bound = kwargs.pop('bound', False) if bound: kwargs['bound[point1]'] = bound[0] kw...
def geo_search(self, **kwargs): """Geo search http://api.2gis.ru/doc/geo/search/ """ if 'types' in kwargs: kwargs['types'] = ','.join(kwargs['types']) bound = kwargs.pop('bound', False) if bound: kwargs['bound[point1]'] = bound[0] kw...
[ "Geo", "search" ]
svartalf/python-2gis
python
https://github.com/svartalf/python-2gis/blob/6eccd6073c99494b7abf20b38a5455cbd55d6420/dgis/__init__.py#L144-L158
[ "def", "geo_search", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "'types'", "in", "kwargs", ":", "kwargs", "[", "'types'", "]", "=", "','", ".", "join", "(", "kwargs", "[", "'types'", "]", ")", "bound", "=", "kwargs", ".", "pop", "(", "...
6eccd6073c99494b7abf20b38a5455cbd55d6420
train
RetoxRefreshMixin.refresh
Refresh the list and the screen
retox/ui.py
def refresh(self): ''' Refresh the list and the screen ''' self._screen.force_update() self._screen.refresh() self._update(1)
def refresh(self): ''' Refresh the list and the screen ''' self._screen.force_update() self._screen.refresh() self._update(1)
[ "Refresh", "the", "list", "and", "the", "screen" ]
tonybaloney/retox
python
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/ui.py#L54-L60
[ "def", "refresh", "(", "self", ")", ":", "self", ".", "_screen", ".", "force_update", "(", ")", "self", ".", "_screen", ".", "refresh", "(", ")", "self", ".", "_update", "(", "1", ")" ]
4635e31001d2ac083423f46766249ac8daca7c9c
train
VirtualEnvironmentFrame.start
Mark an action as started :param activity: The virtualenv activity name :type activity: ``str`` :param action: The virtualenv action :type action: :class:`tox.session.Action`
retox/ui.py
def start(self, activity, action): ''' Mark an action as started :param activity: The virtualenv activity name :type activity: ``str`` :param action: The virtualenv action :type action: :class:`tox.session.Action` ''' try: self._start_actio...
def start(self, activity, action): ''' Mark an action as started :param activity: The virtualenv activity name :type activity: ``str`` :param action: The virtualenv action :type action: :class:`tox.session.Action` ''' try: self._start_actio...
[ "Mark", "an", "action", "as", "started" ]
tonybaloney/retox
python
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/ui.py#L233-L247
[ "def", "start", "(", "self", ",", "activity", ",", "action", ")", ":", "try", ":", "self", ".", "_start_action", "(", "activity", ",", "action", ")", "except", "ValueError", ":", "retox_log", ".", "debug", "(", "\"Could not find action %s in env %s\"", "%", ...
4635e31001d2ac083423f46766249ac8daca7c9c
train
VirtualEnvironmentFrame.stop
Mark a task as completed :param activity: The virtualenv activity name :type activity: ``str`` :param action: The virtualenv action :type action: :class:`tox.session.Action`
retox/ui.py
def stop(self, activity, action): ''' Mark a task as completed :param activity: The virtualenv activity name :type activity: ``str`` :param action: The virtualenv action :type action: :class:`tox.session.Action` ''' try: self._remove_runnin...
def stop(self, activity, action): ''' Mark a task as completed :param activity: The virtualenv activity name :type activity: ``str`` :param action: The virtualenv action :type action: :class:`tox.session.Action` ''' try: self._remove_runnin...
[ "Mark", "a", "task", "as", "completed" ]
tonybaloney/retox
python
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/ui.py#L249-L264
[ "def", "stop", "(", "self", ",", "activity", ",", "action", ")", ":", "try", ":", "self", ".", "_remove_running_action", "(", "activity", ",", "action", ")", "except", "ValueError", ":", "retox_log", ".", "debug", "(", "\"Could not find action %s in env %s\"", ...
4635e31001d2ac083423f46766249ac8daca7c9c
train
VirtualEnvironmentFrame.finish
Move laggard tasks over :param activity: The virtualenv status :type activity: ``str``
retox/ui.py
def finish(self, status): ''' Move laggard tasks over :param activity: The virtualenv status :type activity: ``str`` ''' retox_log.info("Completing %s with status %s" % (self.name, status)) result = Screen.COLOUR_GREEN if not status else Screen.COLOUR_RED ...
def finish(self, status): ''' Move laggard tasks over :param activity: The virtualenv status :type activity: ``str`` ''' retox_log.info("Completing %s with status %s" % (self.name, status)) result = Screen.COLOUR_GREEN if not status else Screen.COLOUR_RED ...
[ "Move", "laggard", "tasks", "over" ]
tonybaloney/retox
python
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/ui.py#L266-L279
[ "def", "finish", "(", "self", ",", "status", ")", ":", "retox_log", ".", "info", "(", "\"Completing %s with status %s\"", "%", "(", "self", ".", "name", ",", "status", ")", ")", "result", "=", "Screen", ".", "COLOUR_GREEN", "if", "not", "status", "else", ...
4635e31001d2ac083423f46766249ac8daca7c9c
train
VirtualEnvironmentFrame.reset
Reset the frame between jobs
retox/ui.py
def reset(self): ''' Reset the frame between jobs ''' self.palette['title'] = (Screen.COLOUR_WHITE, Screen.A_BOLD, Screen.COLOUR_BLUE) self._completed_view.options = [] self._task_view.options = [] self.refresh()
def reset(self): ''' Reset the frame between jobs ''' self.palette['title'] = (Screen.COLOUR_WHITE, Screen.A_BOLD, Screen.COLOUR_BLUE) self._completed_view.options = [] self._task_view.options = [] self.refresh()
[ "Reset", "the", "frame", "between", "jobs" ]
tonybaloney/retox
python
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/ui.py#L281-L288
[ "def", "reset", "(", "self", ")", ":", "self", ".", "palette", "[", "'title'", "]", "=", "(", "Screen", ".", "COLOUR_WHITE", ",", "Screen", ".", "A_BOLD", ",", "Screen", ".", "COLOUR_BLUE", ")", "self", ".", "_completed_view", ".", "options", "=", "[",...
4635e31001d2ac083423f46766249ac8daca7c9c
train
Decorator.default_arguments
Returns the available kwargs of the called class
decorating/decorator.py
def default_arguments(cls): """Returns the available kwargs of the called class""" func = cls.__init__ args = func.__code__.co_varnames defaults = func.__defaults__ index = -len(defaults) return {k: v for k, v in zip(args[index:], defaults)}
def default_arguments(cls): """Returns the available kwargs of the called class""" func = cls.__init__ args = func.__code__.co_varnames defaults = func.__defaults__ index = -len(defaults) return {k: v for k, v in zip(args[index:], defaults)}
[ "Returns", "the", "available", "kwargs", "of", "the", "called", "class" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/decorator.py#L134-L140
[ "def", "default_arguments", "(", "cls", ")", ":", "func", "=", "cls", ".", "__init__", "args", "=", "func", ".", "__code__", ".", "co_varnames", "defaults", "=", "func", ".", "__defaults__", "index", "=", "-", "len", "(", "defaults", ")", "return", "{", ...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
Decorator.recreate
Recreate the class based in your args, multiple uses
decorating/decorator.py
def recreate(cls, *args, **kwargs): """Recreate the class based in your args, multiple uses""" cls.check_arguments(kwargs) first_is_callable = True if any(args) and callable(args[0]) else False signature = cls.default_arguments() allowed_arguments = {k: v for k, v in kwargs.items...
def recreate(cls, *args, **kwargs): """Recreate the class based in your args, multiple uses""" cls.check_arguments(kwargs) first_is_callable = True if any(args) and callable(args[0]) else False signature = cls.default_arguments() allowed_arguments = {k: v for k, v in kwargs.items...
[ "Recreate", "the", "class", "based", "in", "your", "args", "multiple", "uses" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/decorator.py#L143-L155
[ "def", "recreate", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cls", ".", "check_arguments", "(", "kwargs", ")", "first_is_callable", "=", "True", "if", "any", "(", "args", ")", "and", "callable", "(", "args", "[", "0", "]", "...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
Decorator.check_arguments
Put warnings of arguments whose can't be handle by the class
decorating/decorator.py
def check_arguments(cls, passed): """Put warnings of arguments whose can't be handle by the class""" defaults = list(cls.default_arguments().keys()) template = ("Pass arg {argument:!r} in {cname:!r}, can be a typo? " "Supported key arguments: {defaults}") fails = [] ...
def check_arguments(cls, passed): """Put warnings of arguments whose can't be handle by the class""" defaults = list(cls.default_arguments().keys()) template = ("Pass arg {argument:!r} in {cname:!r}, can be a typo? " "Supported key arguments: {defaults}") fails = [] ...
[ "Put", "warnings", "of", "arguments", "whose", "can", "t", "be", "handle", "by", "the", "class" ]
ryukinix/decorating
python
https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/decorator.py#L158-L171
[ "def", "check_arguments", "(", "cls", ",", "passed", ")", ":", "defaults", "=", "list", "(", "cls", ".", "default_arguments", "(", ")", ".", "keys", "(", ")", ")", "template", "=", "(", "\"Pass arg {argument:!r} in {cname:!r}, can be a typo? \"", "\"Supported key ...
df78c3f87800205701704c0bc0fb9b6bb908ba7e
train
Builder.process
process the specified type then process its children
suds/builder.py
def process(self, data, type, history): """ process the specified type then process its children """ if type in history: return if type.enum(): return history.append(type) resolved = type.resolve() value = None if type.multi_occurrence(): ...
def process(self, data, type, history): """ process the specified type then process its children """ if type in history: return if type.enum(): return history.append(type) resolved = type.resolve() value = None if type.multi_occurrence(): ...
[ "process", "the", "specified", "type", "then", "process", "its", "children" ]
ovnicraft/suds2
python
https://github.com/ovnicraft/suds2/blob/e5b540792206a41efc22f5d5b9cfac2dbe7a7992/suds/builder.py#L60-L90
[ "def", "process", "(", "self", ",", "data", ",", "type", ",", "history", ")", ":", "if", "type", "in", "history", ":", "return", "if", "type", ".", "enum", "(", ")", ":", "return", "history", ".", "append", "(", "type", ")", "resolved", "=", "type"...
e5b540792206a41efc22f5d5b9cfac2dbe7a7992
train
Builder.skip_child
get whether or not to skip the specified child
suds/builder.py
def skip_child(self, child, ancestry): """ get whether or not to skip the specified child """ if child.any(): return True for x in ancestry: if x.choice(): return True return False
def skip_child(self, child, ancestry): """ get whether or not to skip the specified child """ if child.any(): return True for x in ancestry: if x.choice(): return True return False
[ "get", "whether", "or", "not", "to", "skip", "the", "specified", "child" ]
ovnicraft/suds2
python
https://github.com/ovnicraft/suds2/blob/e5b540792206a41efc22f5d5b9cfac2dbe7a7992/suds/builder.py#L99-L105
[ "def", "skip_child", "(", "self", ",", "child", ",", "ancestry", ")", ":", "if", "child", ".", "any", "(", ")", ":", "return", "True", "for", "x", "in", "ancestry", ":", "if", "x", ".", "choice", "(", ")", ":", "return", "True", "return", "False" ]
e5b540792206a41efc22f5d5b9cfac2dbe7a7992
train
notify_items
Signal endpoint that actually sends knocks whenever an instance is created / saved
knocker/signals.py
def notify_items(**kwargs): """ Signal endpoint that actually sends knocks whenever an instance is created / saved """ instance = kwargs.get('instance') created = kwargs.get('created', False) if hasattr(instance, 'send_knock') and active_knocks(instance): try: # This is a stu...
def notify_items(**kwargs): """ Signal endpoint that actually sends knocks whenever an instance is created / saved """ instance = kwargs.get('instance') created = kwargs.get('created', False) if hasattr(instance, 'send_knock') and active_knocks(instance): try: # This is a stu...
[ "Signal", "endpoint", "that", "actually", "sends", "knocks", "whenever", "an", "instance", "is", "created", "/", "saved" ]
nephila/django-knocker
python
https://github.com/nephila/django-knocker/blob/d25380d43a1f91285f1581dcf9db8510fe87f354/knocker/signals.py#L12-L31
[ "def", "notify_items", "(", "*", "*", "kwargs", ")", ":", "instance", "=", "kwargs", ".", "get", "(", "'instance'", ")", "created", "=", "kwargs", ".", "get", "(", "'created'", ",", "False", ")", "if", "hasattr", "(", "instance", ",", "'send_knock'", "...
d25380d43a1f91285f1581dcf9db8510fe87f354
train
active_knocks
Checks whether knocks are enabled for the model given as argument :param obj: model instance :return True if knocks are active
knocker/signals.py
def active_knocks(obj): """ Checks whether knocks are enabled for the model given as argument :param obj: model instance :return True if knocks are active """ if not hasattr(_thread_locals, 'knock_enabled'): return True return _thread_locals.knock_enabled.get(obj.__class__, True)
def active_knocks(obj): """ Checks whether knocks are enabled for the model given as argument :param obj: model instance :return True if knocks are active """ if not hasattr(_thread_locals, 'knock_enabled'): return True return _thread_locals.knock_enabled.get(obj.__class__, True)
[ "Checks", "whether", "knocks", "are", "enabled", "for", "the", "model", "given", "as", "argument" ]
nephila/django-knocker
python
https://github.com/nephila/django-knocker/blob/d25380d43a1f91285f1581dcf9db8510fe87f354/knocker/signals.py#L34-L43
[ "def", "active_knocks", "(", "obj", ")", ":", "if", "not", "hasattr", "(", "_thread_locals", ",", "'knock_enabled'", ")", ":", "return", "True", "return", "_thread_locals", ".", "knock_enabled", ".", "get", "(", "obj", ".", "__class__", ",", "True", ")" ]
d25380d43a1f91285f1581dcf9db8510fe87f354
train
pause_knocks
Context manager to suspend sending knocks for the given model :param obj: model instance
knocker/signals.py
def pause_knocks(obj): """ Context manager to suspend sending knocks for the given model :param obj: model instance """ if not hasattr(_thread_locals, 'knock_enabled'): _thread_locals.knock_enabled = {} obj.__class__._disconnect() _thread_locals.knock_enabled[obj.__class__] = False ...
def pause_knocks(obj): """ Context manager to suspend sending knocks for the given model :param obj: model instance """ if not hasattr(_thread_locals, 'knock_enabled'): _thread_locals.knock_enabled = {} obj.__class__._disconnect() _thread_locals.knock_enabled[obj.__class__] = False ...
[ "Context", "manager", "to", "suspend", "sending", "knocks", "for", "the", "given", "model" ]
nephila/django-knocker
python
https://github.com/nephila/django-knocker/blob/d25380d43a1f91285f1581dcf9db8510fe87f354/knocker/signals.py#L47-L59
[ "def", "pause_knocks", "(", "obj", ")", ":", "if", "not", "hasattr", "(", "_thread_locals", ",", "'knock_enabled'", ")", ":", "_thread_locals", ".", "knock_enabled", "=", "{", "}", "obj", ".", "__class__", ".", "_disconnect", "(", ")", "_thread_locals", ".",...
d25380d43a1f91285f1581dcf9db8510fe87f354
train
RetoxReporter._loopreport
Loop over the report progress
retox/reporter.py
def _loopreport(self): ''' Loop over the report progress ''' while 1: eventlet.sleep(0.2) ac2popenlist = {} for action in self.session._actions: for popen in action._popenlist: if popen.poll() is None: ...
def _loopreport(self): ''' Loop over the report progress ''' while 1: eventlet.sleep(0.2) ac2popenlist = {} for action in self.session._actions: for popen in action._popenlist: if popen.poll() is None: ...
[ "Loop", "over", "the", "report", "progress" ]
tonybaloney/retox
python
https://github.com/tonybaloney/retox/blob/4635e31001d2ac083423f46766249ac8daca7c9c/retox/reporter.py#L49-L65
[ "def", "_loopreport", "(", "self", ")", ":", "while", "1", ":", "eventlet", ".", "sleep", "(", "0.2", ")", "ac2popenlist", "=", "{", "}", "for", "action", "in", "self", ".", "session", ".", "_actions", ":", "for", "popen", "in", "action", ".", "_pope...
4635e31001d2ac083423f46766249ac8daca7c9c
train
send
Send markdown email Args: email (str/obj): A markdown string or EmailContent object subject (str): subject line from_email (str): sender email address to_email (str/list): recipient email addresses cc (str/list): CC email addresses (string or a list) bcc (str/list):...
mdmail/api.py
def send(email, subject=None, from_email=None, to_email=None, cc=None, bcc=None, reply_to=None, smtp=None): """Send markdown email Args: email (str/obj): A markdown string or EmailContent object subject (str): subject line from_email (str): sender email addre...
def send(email, subject=None, from_email=None, to_email=None, cc=None, bcc=None, reply_to=None, smtp=None): """Send markdown email Args: email (str/obj): A markdown string or EmailContent object subject (str): subject line from_email (str): sender email addre...
[ "Send", "markdown", "email" ]
yejianye/mdmail
python
https://github.com/yejianye/mdmail/blob/ef03da8d5836b5ae0a4ad8c44f2fe4936a896644/mdmail/api.py#L11-L63
[ "def", "send", "(", "email", ",", "subject", "=", "None", ",", "from_email", "=", "None", ",", "to_email", "=", "None", ",", "cc", "=", "None", ",", "bcc", "=", "None", ",", "reply_to", "=", "None", ",", "smtp", "=", "None", ")", ":", "if", "is_s...
ef03da8d5836b5ae0a4ad8c44f2fe4936a896644
train
Date._process_tz
Process timezone casting and conversion.
marrow/mongo/core/field/date.py
def _process_tz(self, dt, naive, tz): """Process timezone casting and conversion.""" def _tz(t): if t in (None, 'naive'): return t if t == 'local': if __debug__ and not localtz: raise ValueError("Requested conversion to local timezone, but `localtz` not installed.") t = localtz ...
def _process_tz(self, dt, naive, tz): """Process timezone casting and conversion.""" def _tz(t): if t in (None, 'naive'): return t if t == 'local': if __debug__ and not localtz: raise ValueError("Requested conversion to local timezone, but `localtz` not installed.") t = localtz ...
[ "Process", "timezone", "casting", "and", "conversion", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/field/date.py#L59-L102
[ "def", "_process_tz", "(", "self", ",", "dt", ",", "naive", ",", "tz", ")", ":", "def", "_tz", "(", "t", ")", ":", "if", "t", "in", "(", "None", ",", "'naive'", ")", ":", "return", "t", "if", "t", "==", "'local'", ":", "if", "__debug__", "and",...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Document._prepare_defaults
Trigger assignment of default values.
marrow/mongo/core/document.py
def _prepare_defaults(self): """Trigger assignment of default values.""" for name, field in self.__fields__.items(): if field.assign: getattr(self, name)
def _prepare_defaults(self): """Trigger assignment of default values.""" for name, field in self.__fields__.items(): if field.assign: getattr(self, name)
[ "Trigger", "assignment", "of", "default", "values", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/document.py#L71-L76
[ "def", "_prepare_defaults", "(", "self", ")", ":", "for", "name", ",", "field", "in", "self", ".", "__fields__", ".", "items", "(", ")", ":", "if", "field", ".", "assign", ":", "getattr", "(", "self", ",", "name", ")" ]
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Document.from_mongo
Convert data coming in from the MongoDB wire driver into a Document instance.
marrow/mongo/core/document.py
def from_mongo(cls, doc): """Convert data coming in from the MongoDB wire driver into a Document instance.""" if doc is None: # To support simplified iterative use, None should return None. return None if isinstance(doc, Document): # No need to perform processing on existing Document instances. retu...
def from_mongo(cls, doc): """Convert data coming in from the MongoDB wire driver into a Document instance.""" if doc is None: # To support simplified iterative use, None should return None. return None if isinstance(doc, Document): # No need to perform processing on existing Document instances. retu...
[ "Convert", "data", "coming", "in", "from", "the", "MongoDB", "wire", "driver", "into", "a", "Document", "instance", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/document.py#L81-L98
[ "def", "from_mongo", "(", "cls", ",", "doc", ")", ":", "if", "doc", "is", "None", ":", "# To support simplified iterative use, None should return None.", "return", "None", "if", "isinstance", "(", "doc", ",", "Document", ")", ":", "# No need to perform processing on e...
2066dc73e281b8a46cb5fc965267d6b8e1b18467
train
Document.pop
Retrieve and remove a value from the backing store, optionally with a default.
marrow/mongo/core/document.py
def pop(self, name, default=SENTINEL): """Retrieve and remove a value from the backing store, optionally with a default.""" if default is SENTINEL: return self.__data__.pop(name) return self.__data__.pop(name, default)
def pop(self, name, default=SENTINEL): """Retrieve and remove a value from the backing store, optionally with a default.""" if default is SENTINEL: return self.__data__.pop(name) return self.__data__.pop(name, default)
[ "Retrieve", "and", "remove", "a", "value", "from", "the", "backing", "store", "optionally", "with", "a", "default", "." ]
marrow/mongo
python
https://github.com/marrow/mongo/blob/2066dc73e281b8a46cb5fc965267d6b8e1b18467/marrow/mongo/core/document.py#L246-L252
[ "def", "pop", "(", "self", ",", "name", ",", "default", "=", "SENTINEL", ")", ":", "if", "default", "is", "SENTINEL", ":", "return", "self", ".", "__data__", ".", "pop", "(", "name", ")", "return", "self", ".", "__data__", ".", "pop", "(", "name", ...
2066dc73e281b8a46cb5fc965267d6b8e1b18467