repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
rraadd88/rohan
rohan/dandage/align/align_annot.py
dqueries2queriessam
def dqueries2queriessam(cfg,dqueries): """ Aligns queries to genome and gets SAM file step#1 :param cfg: configuration dict :param dqueries: dataframe of queries """ datatmpd=cfg['datatmpd'] dqueries=set_index(dqueries,'query id') queryls=dqueries.loc[:,'query sequence'].apply(l...
python
def dqueries2queriessam(cfg,dqueries): """ Aligns queries to genome and gets SAM file step#1 :param cfg: configuration dict :param dqueries: dataframe of queries """ datatmpd=cfg['datatmpd'] dqueries=set_index(dqueries,'query id') queryls=dqueries.loc[:,'query sequence'].apply(l...
[ "def", "dqueries2queriessam", "(", "cfg", ",", "dqueries", ")", ":", "datatmpd", "=", "cfg", "[", "'datatmpd'", "]", "dqueries", "=", "set_index", "(", "dqueries", ",", "'query id'", ")", "queryls", "=", "dqueries", ".", "loc", "[", ":", ",", "'query seque...
Aligns queries to genome and gets SAM file step#1 :param cfg: configuration dict :param dqueries: dataframe of queries
[ "Aligns", "queries", "to", "genome", "and", "gets", "SAM", "file", "step#1" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/align/align_annot.py#L25-L72
train
Aligns queries to genome and gets SAM file for each sequence in dqueries
rraadd88/rohan
rohan/dandage/align/align_annot.py
queriessam2dalignbed
def queriessam2dalignbed(cfg): """ Processes SAM file to get the genomic coordinates in BED format step#2 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] alignmentbedp=cfg['alignmentbedp'] dalignbedp=cfg['dalignbedp'] logging.info(basename(dalignbedp)) if not exists(...
python
def queriessam2dalignbed(cfg): """ Processes SAM file to get the genomic coordinates in BED format step#2 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] alignmentbedp=cfg['alignmentbedp'] dalignbedp=cfg['dalignbedp'] logging.info(basename(dalignbedp)) if not exists(...
[ "def", "queriessam2dalignbed", "(", "cfg", ")", ":", "datatmpd", "=", "cfg", "[", "'datatmpd'", "]", "alignmentbedp", "=", "cfg", "[", "'alignmentbedp'", "]", "dalignbedp", "=", "cfg", "[", "'dalignbedp'", "]", "logging", ".", "info", "(", "basename", "(", ...
Processes SAM file to get the genomic coordinates in BED format step#2 :param cfg: configuration dict
[ "Processes", "SAM", "file", "to", "get", "the", "genomic", "coordinates", "in", "BED", "format", "step#2" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/align/align_annot.py#L74-L154
train
Processes the alignmentbed file and returns a pandas. DataFrame with the genomic coordinates in BED format.
rraadd88/rohan
rohan/dandage/align/align_annot.py
dalignbed2annotationsbed
def dalignbed2annotationsbed(cfg): """ Get annotations from the aligned BED file step#3 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] alignmentbedp=cfg['alignmentbedp'] alignmentbedsortedp=alignmentbedp+'.sorted.bed' logging.info(basename(alignmentbedsortedp)) ...
python
def dalignbed2annotationsbed(cfg): """ Get annotations from the aligned BED file step#3 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] alignmentbedp=cfg['alignmentbedp'] alignmentbedsortedp=alignmentbedp+'.sorted.bed' logging.info(basename(alignmentbedsortedp)) ...
[ "def", "dalignbed2annotationsbed", "(", "cfg", ")", ":", "datatmpd", "=", "cfg", "[", "'datatmpd'", "]", "alignmentbedp", "=", "cfg", "[", "'alignmentbedp'", "]", "alignmentbedsortedp", "=", "alignmentbedp", "+", "'.sorted.bed'", "logging", ".", "info", "(", "ba...
Get annotations from the aligned BED file step#3 :param cfg: configuration dict
[ "Get", "annotations", "from", "the", "aligned", "BED", "file", "step#3" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/align/align_annot.py#L156-L183
train
Get the annotations from the aligned BED file step#3
rraadd88/rohan
rohan/dandage/align/align_annot.py
dalignbed2dalignbedqueries
def dalignbed2dalignbedqueries(cfg): """ Get query seqeunces from the BED file step#4 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] dalignbed=del_Unnamed(pd.read_csv(cfg['dalignbedp'],sep='\t')) dqueries=set_index(del_Unnamed(pd.read_csv(cfg['dqueriesp'],sep='\t')),'query ...
python
def dalignbed2dalignbedqueries(cfg): """ Get query seqeunces from the BED file step#4 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] dalignbed=del_Unnamed(pd.read_csv(cfg['dalignbedp'],sep='\t')) dqueries=set_index(del_Unnamed(pd.read_csv(cfg['dqueriesp'],sep='\t')),'query ...
[ "def", "dalignbed2dalignbedqueries", "(", "cfg", ")", ":", "datatmpd", "=", "cfg", "[", "'datatmpd'", "]", "dalignbed", "=", "del_Unnamed", "(", "pd", ".", "read_csv", "(", "cfg", "[", "'dalignbedp'", "]", ",", "sep", "=", "'\\t'", ")", ")", "dqueries", ...
Get query seqeunces from the BED file step#4 :param cfg: configuration dict
[ "Get", "query", "seqeunces", "from", "the", "BED", "file", "step#4" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/align/align_annot.py#L185-L202
train
Get query seqeunces from the BED file step#4
rraadd88/rohan
rohan/dandage/align/align_annot.py
alignmentbed2dalignedfasta
def alignmentbed2dalignedfasta(cfg): """ Get sequences in FASTA format from BED file step#5 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] alignmentbedp=cfg['alignmentbedp'] dalignedfastap=cfg['dalignedfastap'] logging.info(basename(dalignedfastap)) if not e...
python
def alignmentbed2dalignedfasta(cfg): """ Get sequences in FASTA format from BED file step#5 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] alignmentbedp=cfg['alignmentbedp'] dalignedfastap=cfg['dalignedfastap'] logging.info(basename(dalignedfastap)) if not e...
[ "def", "alignmentbed2dalignedfasta", "(", "cfg", ")", ":", "datatmpd", "=", "cfg", "[", "'datatmpd'", "]", "alignmentbedp", "=", "cfg", "[", "'alignmentbedp'", "]", "dalignedfastap", "=", "cfg", "[", "'dalignedfastap'", "]", "logging", ".", "info", "(", "basen...
Get sequences in FASTA format from BED file step#5 :param cfg: configuration dict
[ "Get", "sequences", "in", "FASTA", "format", "from", "BED", "file", "step#5" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/align/align_annot.py#L204-L227
train
Get sequences in FASTA format from BED file and write to daligned FASTA file
rraadd88/rohan
rohan/dandage/align/align_annot.py
dalignbed2dalignbedqueriesseq
def dalignbed2dalignbedqueriesseq(cfg): """ Get sequences from BED file step#6 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] dalignbedqueries=del_Unnamed(pd.read_csv(cfg['dalignbedqueriesp'],sep='\t')) dalignedfasta=del_Unnamed(pd.read_csv(cfg['dalignedfastap'],sep='\t')) ...
python
def dalignbed2dalignbedqueriesseq(cfg): """ Get sequences from BED file step#6 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] dalignbedqueries=del_Unnamed(pd.read_csv(cfg['dalignbedqueriesp'],sep='\t')) dalignedfasta=del_Unnamed(pd.read_csv(cfg['dalignedfastap'],sep='\t')) ...
[ "def", "dalignbed2dalignbedqueriesseq", "(", "cfg", ")", ":", "datatmpd", "=", "cfg", "[", "'datatmpd'", "]", "dalignbedqueries", "=", "del_Unnamed", "(", "pd", ".", "read_csv", "(", "cfg", "[", "'dalignbedqueriesp'", "]", ",", "sep", "=", "'\\t'", ")", ")",...
Get sequences from BED file step#6 :param cfg: configuration dict
[ "Get", "sequences", "from", "BED", "file", "step#6" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/align/align_annot.py#L229-L248
train
Get sequences from BED file step 6
rraadd88/rohan
rohan/dandage/align/align_annot.py
dalignbedqueriesseq2dalignbedstats
def dalignbedqueriesseq2dalignbedstats(cfg): """ Gets scores for queries step#7 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] dalignbedqueriesseq=del_Unnamed(pd.read_csv(cfg['dalignbedqueriesseqp'],sep='\t')) dalignbedstatsp=cfg['dalignbedstatsp'] logging.info(b...
python
def dalignbedqueriesseq2dalignbedstats(cfg): """ Gets scores for queries step#7 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] dalignbedqueriesseq=del_Unnamed(pd.read_csv(cfg['dalignbedqueriesseqp'],sep='\t')) dalignbedstatsp=cfg['dalignbedstatsp'] logging.info(b...
[ "def", "dalignbedqueriesseq2dalignbedstats", "(", "cfg", ")", ":", "datatmpd", "=", "cfg", "[", "'datatmpd'", "]", "dalignbedqueriesseq", "=", "del_Unnamed", "(", "pd", ".", "read_csv", "(", "cfg", "[", "'dalignbedqueriesseqp'", "]", ",", "sep", "=", "'\\t'", ...
Gets scores for queries step#7 :param cfg: configuration dict
[ "Gets", "scores", "for", "queries", "step#7" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/align/align_annot.py#L250-L271
train
Gets scores for queries step#7 Gets scores for queries step#7 Gets scores for queries step#7 Gets scores for queries step#7 Gets scores for queries step#7 Gets scores for queries step#7 Gets scores for queries step#7 Gets Gets TTS scores for queries step#7 Gets TTS TTS TTS TTSTTS
rraadd88/rohan
rohan/dandage/align/align_annot.py
dannots2dalignbed2dannotsagg
def dannots2dalignbed2dannotsagg(cfg): """ Aggregate annotations per query step#8 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] daannotp=f'{datatmpd}/08_dannot.tsv' cfg['daannotp']=daannotp dannotsaggp=cfg['dannotsaggp'] logging.info(basename(daannotp)) if...
python
def dannots2dalignbed2dannotsagg(cfg): """ Aggregate annotations per query step#8 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] daannotp=f'{datatmpd}/08_dannot.tsv' cfg['daannotp']=daannotp dannotsaggp=cfg['dannotsaggp'] logging.info(basename(daannotp)) if...
[ "def", "dannots2dalignbed2dannotsagg", "(", "cfg", ")", ":", "datatmpd", "=", "cfg", "[", "'datatmpd'", "]", "daannotp", "=", "f'{datatmpd}/08_dannot.tsv'", "cfg", "[", "'daannotp'", "]", "=", "daannotp", "dannotsaggp", "=", "cfg", "[", "'dannotsaggp'", "]", "lo...
Aggregate annotations per query step#8 :param cfg: configuration dict
[ "Aggregate", "annotations", "per", "query", "step#8" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/align/align_annot.py#L272-L332
train
reads annotations from annotationsbedp and aggregates them into one single record
rraadd88/rohan
rohan/dandage/align/align_annot.py
dannotsagg2dannots2dalignbedannot
def dannotsagg2dannots2dalignbedannot(cfg): """ Map aggregated annotations to queries step#9 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] dannotsagg=del_Unnamed(pd.read_csv(cfg['dannotsaggp'],sep='\t')) dalignbedstats=del_Unnamed(pd.read_csv(cfg['dalignbedstatsp'],se...
python
def dannotsagg2dannots2dalignbedannot(cfg): """ Map aggregated annotations to queries step#9 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] dannotsagg=del_Unnamed(pd.read_csv(cfg['dannotsaggp'],sep='\t')) dalignbedstats=del_Unnamed(pd.read_csv(cfg['dalignbedstatsp'],se...
[ "def", "dannotsagg2dannots2dalignbedannot", "(", "cfg", ")", ":", "datatmpd", "=", "cfg", "[", "'datatmpd'", "]", "dannotsagg", "=", "del_Unnamed", "(", "pd", ".", "read_csv", "(", "cfg", "[", "'dannotsaggp'", "]", ",", "sep", "=", "'\\t'", ")", ")", "dali...
Map aggregated annotations to queries step#9 :param cfg: configuration dict
[ "Map", "aggregated", "annotations", "to", "queries", "step#9" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/align/align_annot.py#L334-L363
train
Map aggregated annotations to queries step 9
rraadd88/rohan
rohan/dandage/align/align_annot.py
dalignbedannot2daggbyquery
def dalignbedannot2daggbyquery(cfg): """ Aggregate annotations per alignment to annotations per query. step#10 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] dalignbedannot=del_Unnamed(pd.read_csv(cfg['dalignbedannotp'],sep='\t',low_memory=False)) daggbyqueryp=f'{data...
python
def dalignbedannot2daggbyquery(cfg): """ Aggregate annotations per alignment to annotations per query. step#10 :param cfg: configuration dict """ datatmpd=cfg['datatmpd'] dalignbedannot=del_Unnamed(pd.read_csv(cfg['dalignbedannotp'],sep='\t',low_memory=False)) daggbyqueryp=f'{data...
[ "def", "dalignbedannot2daggbyquery", "(", "cfg", ")", ":", "datatmpd", "=", "cfg", "[", "'datatmpd'", "]", "dalignbedannot", "=", "del_Unnamed", "(", "pd", ".", "read_csv", "(", "cfg", "[", "'dalignbedannotp'", "]", ",", "sep", "=", "'\\t'", ",", "low_memory...
Aggregate annotations per alignment to annotations per query. step#10 :param cfg: configuration dict
[ "Aggregate", "annotations", "per", "alignment", "to", "annotations", "per", "query", ".", "step#10" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/align/align_annot.py#L365-L400
train
step 10 - alignbed annotations per alignment to annotations per query.
rraadd88/rohan
rohan/dandage/align/align_annot.py
queries2alignments
def queries2alignments(cfg): """ All the processes in alignannoted detection are here. :param cfg: Configuration settings provided in .yml file """ from rohan.dandage.align import get_genomes get_genomes(cfg) cfg['datad']=cfg['prjd'] cfg['plotd']=cfg['datad'] dalignannotedp...
python
def queries2alignments(cfg): """ All the processes in alignannoted detection are here. :param cfg: Configuration settings provided in .yml file """ from rohan.dandage.align import get_genomes get_genomes(cfg) cfg['datad']=cfg['prjd'] cfg['plotd']=cfg['datad'] dalignannotedp...
[ "def", "queries2alignments", "(", "cfg", ")", ":", "from", "rohan", ".", "dandage", ".", "align", "import", "get_genomes", "get_genomes", "(", "cfg", ")", "cfg", "[", "'datad'", "]", "=", "cfg", "[", "'prjd'", "]", "cfg", "[", "'plotd'", "]", "=", "cfg...
All the processes in alignannoted detection are here. :param cfg: Configuration settings provided in .yml file
[ "All", "the", "processes", "in", "alignannoted", "detection", "are", "here", ".", ":", "param", "cfg", ":", "Configuration", "settings", "provided", "in", ".", "yml", "file" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/align/align_annot.py#L402-L486
train
This function takes in a configuration file and returns a list of all the processes in alignannoted detection.
jmbeach/KEP.py
src/keppy/project.py
Project.parse_channels
def parse_channels(self): """Creates an array of Channel objects from the project""" channels = [] for channel in self._project_dict["channels"]: channels.append(Channel(channel, self._is_sixteen_bit, self._ignore_list)) return channels
python
def parse_channels(self): """Creates an array of Channel objects from the project""" channels = [] for channel in self._project_dict["channels"]: channels.append(Channel(channel, self._is_sixteen_bit, self._ignore_list)) return channels
[ "def", "parse_channels", "(", "self", ")", ":", "channels", "=", "[", "]", "for", "channel", "in", "self", ".", "_project_dict", "[", "\"channels\"", "]", ":", "channels", ".", "append", "(", "Channel", "(", "channel", ",", "self", ".", "_is_sixteen_bit", ...
Creates an array of Channel objects from the project
[ "Creates", "an", "array", "of", "Channel", "objects", "from", "the", "project" ]
68cda64ab649640a486534867c81274c41e39446
https://github.com/jmbeach/KEP.py/blob/68cda64ab649640a486534867c81274c41e39446/src/keppy/project.py#L20-L25
train
Creates an array of Channel objects from the project
jmbeach/KEP.py
src/keppy/project.py
Project.update
def update(self): """Updates the dictionary of the project""" for channel in self.channels: channel.update() for i in range(len(self._project_dict["channels"])): channel_dict = self._project_dict["channels"][i] for channel in self.channels: if ...
python
def update(self): """Updates the dictionary of the project""" for channel in self.channels: channel.update() for i in range(len(self._project_dict["channels"])): channel_dict = self._project_dict["channels"][i] for channel in self.channels: if ...
[ "def", "update", "(", "self", ")", ":", "for", "channel", "in", "self", ".", "channels", ":", "channel", ".", "update", "(", ")", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_project_dict", "[", "\"channels\"", "]", ")", ")", ":", "ch...
Updates the dictionary of the project
[ "Updates", "the", "dictionary", "of", "the", "project" ]
68cda64ab649640a486534867c81274c41e39446
https://github.com/jmbeach/KEP.py/blob/68cda64ab649640a486534867c81274c41e39446/src/keppy/project.py#L32-L40
train
Updates the dictionary of the project
tjcsl/cslbot
cslbot/commands/distro.py
cmd
def cmd(send, *_): """Gets a random distro. Syntax: {command} """ url = get('http://distrowatch.com/random.php').url match = re.search('=(.*)', url) if match: send(match.group(1)) else: send("no distro found")
python
def cmd(send, *_): """Gets a random distro. Syntax: {command} """ url = get('http://distrowatch.com/random.php').url match = re.search('=(.*)', url) if match: send(match.group(1)) else: send("no distro found")
[ "def", "cmd", "(", "send", ",", "*", "_", ")", ":", "url", "=", "get", "(", "'http://distrowatch.com/random.php'", ")", ".", "url", "match", "=", "re", ".", "search", "(", "'=(.*)'", ",", "url", ")", "if", "match", ":", "send", "(", "match", ".", "...
Gets a random distro. Syntax: {command}
[ "Gets", "a", "random", "distro", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/distro.py#L26-L37
train
Gets a random distro. Syntax: {command}
jlesquembre/autopilot
src/autopilot/render.py
should_skip_file
def should_skip_file(name): """ Checks if a file should be skipped based on its name. If it should be skipped, returns the reason, otherwise returns None. """ if name.endswith(('~', '.bak')): return 'Skipping backup file %(filename)s' if name.endswith(('.pyc', '.pyo')): retu...
python
def should_skip_file(name): """ Checks if a file should be skipped based on its name. If it should be skipped, returns the reason, otherwise returns None. """ if name.endswith(('~', '.bak')): return 'Skipping backup file %(filename)s' if name.endswith(('.pyc', '.pyo')): retu...
[ "def", "should_skip_file", "(", "name", ")", ":", "if", "name", ".", "endswith", "(", "(", "'~'", ",", "'.bak'", ")", ")", ":", "return", "'Skipping backup file %(filename)s'", "if", "name", ".", "endswith", "(", "(", "'.pyc'", ",", "'.pyo'", ")", ")", "...
Checks if a file should be skipped based on its name. If it should be skipped, returns the reason, otherwise returns None.
[ "Checks", "if", "a", "file", "should", "be", "skipped", "based", "on", "its", "name", "." ]
ca5f36269ba0173bd29c39db6971dac57a58513d
https://github.com/jlesquembre/autopilot/blob/ca5f36269ba0173bd29c39db6971dac57a58513d/src/autopilot/render.py#L20-L33
train
Checks if a file should be skipped based on its name. Returns the reason if it should be skipped otherwise returns None.
jlesquembre/autopilot
src/autopilot/render.py
_parse_license_name
def _parse_license_name(long_name): ''' Check if the license name on the PyPI licenses list. Prepends 'OSI Approved :: ' if required. If the license is 'Other/Proprietary License' or unknow, asummes that is a private license. ''' licenses_path = utils.get_data_dir() / 'license_list.txt' with lic...
python
def _parse_license_name(long_name): ''' Check if the license name on the PyPI licenses list. Prepends 'OSI Approved :: ' if required. If the license is 'Other/Proprietary License' or unknow, asummes that is a private license. ''' licenses_path = utils.get_data_dir() / 'license_list.txt' with lic...
[ "def", "_parse_license_name", "(", "long_name", ")", ":", "licenses_path", "=", "utils", ".", "get_data_dir", "(", ")", "/", "'license_list.txt'", "with", "licenses_path", ".", "open", "(", "'rt'", ")", "as", "f", ":", "licenses", "=", "[", "line", ".", "s...
Check if the license name on the PyPI licenses list. Prepends 'OSI Approved :: ' if required. If the license is 'Other/Proprietary License' or unknow, asummes that is a private license.
[ "Check", "if", "the", "license", "name", "on", "the", "PyPI", "licenses", "list", ".", "Prepends", "OSI", "Approved", "::", "if", "required", ".", "If", "the", "license", "is", "Other", "/", "Proprietary", "License", "or", "unknow", "asummes", "that", "is"...
ca5f36269ba0173bd29c39db6971dac57a58513d
https://github.com/jlesquembre/autopilot/blob/ca5f36269ba0173bd29c39db6971dac57a58513d/src/autopilot/render.py#L133-L151
train
Check if the license name is a private license.
tjcsl/cslbot
cslbot/commands/ddate.py
cmd
def cmd(send, *_): """Returns the Discordian date. Syntax: {command} """ try: output = subprocess.check_output(['ddate'], universal_newlines=True) except subprocess.CalledProcessError: output = 'Today is the day you install ddate!' for line in output.splitlines(): send(...
python
def cmd(send, *_): """Returns the Discordian date. Syntax: {command} """ try: output = subprocess.check_output(['ddate'], universal_newlines=True) except subprocess.CalledProcessError: output = 'Today is the day you install ddate!' for line in output.splitlines(): send(...
[ "def", "cmd", "(", "send", ",", "*", "_", ")", ":", "try", ":", "output", "=", "subprocess", ".", "check_output", "(", "[", "'ddate'", "]", ",", "universal_newlines", "=", "True", ")", "except", "subprocess", ".", "CalledProcessError", ":", "output", "="...
Returns the Discordian date. Syntax: {command}
[ "Returns", "the", "Discordian", "date", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/ddate.py#L24-L35
train
Returns the Discordian date.
tjcsl/cslbot
cslbot/commands/mode.py
cmd
def cmd(send, msg, args): """Sets a mode. Syntax: {command} [--chan <chan>] <mode> """ parser = arguments.ArgParser(args['config']) parser.add_argument('--chan', '--channel', action=arguments.ChanParser) try: cmdargs, extra = parser.parse_known_args(msg) except arguments.ArgumentEx...
python
def cmd(send, msg, args): """Sets a mode. Syntax: {command} [--chan <chan>] <mode> """ parser = arguments.ArgParser(args['config']) parser.add_argument('--chan', '--channel', action=arguments.ChanParser) try: cmdargs, extra = parser.parse_known_args(msg) except arguments.ArgumentEx...
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "parser", "=", "arguments", ".", "ArgParser", "(", "args", "[", "'config'", "]", ")", "parser", ".", "add_argument", "(", "'--chan'", ",", "'--channel'", ",", "action", "=", "arguments", "."...
Sets a mode. Syntax: {command} [--chan <chan>] <mode>
[ "Sets", "a", "mode", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/mode.py#L23-L51
train
Sets a mode.
rraadd88/rohan
rohan/dandage/plot/shape.py
df2plotshape
def df2plotshape(dlen,xlabel_unit,ylabel_unit, suptitle='',fix='h',xlabel_skip=[], test=False): """ _xlen: _ylen: title: """ dlen['xlabel']=dlen.apply(lambda x : f"{x['_xlen']}" if not x['title'] in xlabel_skip else '',axis=1) dlen['ylabel']=dlen.apply(lamb...
python
def df2plotshape(dlen,xlabel_unit,ylabel_unit, suptitle='',fix='h',xlabel_skip=[], test=False): """ _xlen: _ylen: title: """ dlen['xlabel']=dlen.apply(lambda x : f"{x['_xlen']}" if not x['title'] in xlabel_skip else '',axis=1) dlen['ylabel']=dlen.apply(lamb...
[ "def", "df2plotshape", "(", "dlen", ",", "xlabel_unit", ",", "ylabel_unit", ",", "suptitle", "=", "''", ",", "fix", "=", "'h'", ",", "xlabel_skip", "=", "[", "]", ",", "test", "=", "False", ")", ":", "dlen", "[", "'xlabel'", "]", "=", "dlen", ".", ...
_xlen: _ylen: title:
[ "_xlen", ":", "_ylen", ":", "title", ":" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/plot/shape.py#L53-L107
train
Plot the shape of a single cell.
davisagli/eye
eye/views.py
as_json
def as_json(context): """Return an object's representation as JSON""" info = { 'info': cgi.escape(pprint.pformat(context.context)), } return Response(content_type='application/json', body=json.dumps(info))
python
def as_json(context): """Return an object's representation as JSON""" info = { 'info': cgi.escape(pprint.pformat(context.context)), } return Response(content_type='application/json', body=json.dumps(info))
[ "def", "as_json", "(", "context", ")", ":", "info", "=", "{", "'info'", ":", "cgi", ".", "escape", "(", "pprint", ".", "pformat", "(", "context", ".", "context", ")", ")", ",", "}", "return", "Response", "(", "content_type", "=", "'application/json'", ...
Return an object's representation as JSON
[ "Return", "an", "object", "s", "representation", "as", "JSON" ]
4007b6b490ac667c8423c6cc789b303e93f9d03d
https://github.com/davisagli/eye/blob/4007b6b490ac667c8423c6cc789b303e93f9d03d/eye/views.py#L8-L13
train
Return an object s representation as JSON
davisagli/eye
eye/views.py
as_tree
def as_tree(context): """Return info about an object's members as JSON""" tree = _build_tree(context, 2, 1) if type(tree) == dict: tree = [tree] return Response(content_type='application/json', body=json.dumps(tree))
python
def as_tree(context): """Return info about an object's members as JSON""" tree = _build_tree(context, 2, 1) if type(tree) == dict: tree = [tree] return Response(content_type='application/json', body=json.dumps(tree))
[ "def", "as_tree", "(", "context", ")", ":", "tree", "=", "_build_tree", "(", "context", ",", "2", ",", "1", ")", "if", "type", "(", "tree", ")", "==", "dict", ":", "tree", "=", "[", "tree", "]", "return", "Response", "(", "content_type", "=", "'app...
Return info about an object's members as JSON
[ "Return", "info", "about", "an", "object", "s", "members", "as", "JSON" ]
4007b6b490ac667c8423c6cc789b303e93f9d03d
https://github.com/davisagli/eye/blob/4007b6b490ac667c8423c6cc789b303e93f9d03d/eye/views.py#L16-L23
train
Return info about an object s members as JSON
acutesoftware/virtual-AI-simulator
vais/z_prototypes/game_rpg_simulation1.py
main
def main(): """ Prototype to see how an RPG simulation might be used in the AIKIF framework. The idea is to build a simple character and run a simulation to see how it succeeds in a random world against another players character character stats world locations ""...
python
def main(): """ Prototype to see how an RPG simulation might be used in the AIKIF framework. The idea is to build a simple character and run a simulation to see how it succeeds in a random world against another players character character stats world locations ""...
[ "def", "main", "(", ")", ":", "character1", "=", "Character", "(", "'Albogh'", ",", "str", "=", "4", ",", "int", "=", "7", ",", "sta", "=", "50", ")", "character2", "=", "Character", "(", "'Zoltor'", ",", "str", "=", "6", ",", "int", "=", "6", ...
Prototype to see how an RPG simulation might be used in the AIKIF framework. The idea is to build a simple character and run a simulation to see how it succeeds in a random world against another players character character stats world locations
[ "Prototype", "to", "see", "how", "an", "RPG", "simulation", "might", "be", "used", "in", "the", "AIKIF", "framework", ".", "The", "idea", "is", "to", "build", "a", "simple", "character", "and", "run", "a", "simulation", "to", "see", "how", "it", "succeed...
57de679a5b1a58c38fefe6aea58af1f3a7e79c58
https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/z_prototypes/game_rpg_simulation1.py#L7-L28
train
This function is used to see how an RPG simulation might be used
ktdreyer/txkoji
txkoji/build.py
Build.duration
def duration(self): """ Return a timedelta for this build. Measure the time between this build's start and end time, or "now" if the build has not yet finished. :returns: timedelta object """ if self.completion_ts: end = self.completed else: ...
python
def duration(self): """ Return a timedelta for this build. Measure the time between this build's start and end time, or "now" if the build has not yet finished. :returns: timedelta object """ if self.completion_ts: end = self.completed else: ...
[ "def", "duration", "(", "self", ")", ":", "if", "self", ".", "completion_ts", ":", "end", "=", "self", ".", "completed", "else", ":", "end", "=", "datetime", ".", "utcnow", "(", ")", "return", "end", "-", "self", ".", "started" ]
Return a timedelta for this build. Measure the time between this build's start and end time, or "now" if the build has not yet finished. :returns: timedelta object
[ "Return", "a", "timedelta", "for", "this", "build", "." ]
a7de380f29f745bf11730b27217208f6d4da7733
https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/build.py#L32-L45
train
Return a timedelta for this build.
ktdreyer/txkoji
txkoji/build.py
Build.url
def url(self): """ Return a kojiweb URL for this resource. :returns: ``str``, kojiweb URL like "http://cbs.centos.org/koji/buildinfo?buildID=21155" """ endpoint = 'buildinfo?buildID=%d' % self.build_id return posixpath.join(self.connection.weburl, endpo...
python
def url(self): """ Return a kojiweb URL for this resource. :returns: ``str``, kojiweb URL like "http://cbs.centos.org/koji/buildinfo?buildID=21155" """ endpoint = 'buildinfo?buildID=%d' % self.build_id return posixpath.join(self.connection.weburl, endpo...
[ "def", "url", "(", "self", ")", ":", "endpoint", "=", "'buildinfo?buildID=%d'", "%", "self", ".", "build_id", "return", "posixpath", ".", "join", "(", "self", ".", "connection", ".", "weburl", ",", "endpoint", ")" ]
Return a kojiweb URL for this resource. :returns: ``str``, kojiweb URL like "http://cbs.centos.org/koji/buildinfo?buildID=21155"
[ "Return", "a", "kojiweb", "URL", "for", "this", "resource", "." ]
a7de380f29f745bf11730b27217208f6d4da7733
https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/build.py#L48-L56
train
Return a kojiweb URL for this resource.
ktdreyer/txkoji
txkoji/build.py
Build.estimate_completion
def estimate_completion(self): """ Estimate completion time for a build. This calls getAverageBuildDuration on the hub for this package. This value is a very rough guess, an average for all completed builds in the system. For now this is better than nothing, but I'm rec...
python
def estimate_completion(self): """ Estimate completion time for a build. This calls getAverageBuildDuration on the hub for this package. This value is a very rough guess, an average for all completed builds in the system. For now this is better than nothing, but I'm rec...
[ "def", "estimate_completion", "(", "self", ")", ":", "if", "self", ".", "state", "!=", "build_states", ".", "BUILDING", ":", "# Build is already complete. Return the exact completion time:", "defer", ".", "returnValue", "(", "self", ".", "completed", ")", "avg_delta",...
Estimate completion time for a build. This calls getAverageBuildDuration on the hub for this package. This value is a very rough guess, an average for all completed builds in the system. For now this is better than nothing, but I'm recording a few thoughts here for posterity: ...
[ "Estimate", "completion", "time", "for", "a", "build", "." ]
a7de380f29f745bf11730b27217208f6d4da7733
https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/build.py#L59-L88
train
Estimate the completion time for a build.
ktdreyer/txkoji
txkoji/build.py
Build.target
def target(self): """ Find the target name for this build. :returns: deferred that when fired returns the build task's target name. If we could not determine the build task, or the task's target, return None. """ task = yield self.task() ...
python
def target(self): """ Find the target name for this build. :returns: deferred that when fired returns the build task's target name. If we could not determine the build task, or the task's target, return None. """ task = yield self.task() ...
[ "def", "target", "(", "self", ")", ":", "task", "=", "yield", "self", ".", "task", "(", ")", "if", "not", "task", ":", "yield", "defer", ".", "succeed", "(", "None", ")", "defer", ".", "returnValue", "(", "None", ")", "defer", ".", "returnValue", "...
Find the target name for this build. :returns: deferred that when fired returns the build task's target name. If we could not determine the build task, or the task's target, return None.
[ "Find", "the", "target", "name", "for", "this", "build", "." ]
a7de380f29f745bf11730b27217208f6d4da7733
https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/build.py#L118-L130
train
Find the target name for this build.
ktdreyer/txkoji
txkoji/build.py
Build.task
def task(self): """ Find the task for this build. Wraps the getTaskInfo RPC. :returns: deferred that when fired returns the Task object, or None if we could not determine the task for this build. """ # If we have no .task_id, this is a no-op to return ...
python
def task(self): """ Find the task for this build. Wraps the getTaskInfo RPC. :returns: deferred that when fired returns the Task object, or None if we could not determine the task for this build. """ # If we have no .task_id, this is a no-op to return ...
[ "def", "task", "(", "self", ")", ":", "# If we have no .task_id, this is a no-op to return None.", "if", "not", "self", ".", "task_id", ":", "return", "defer", ".", "succeed", "(", "None", ")", "return", "self", ".", "connection", ".", "getTaskInfo", "(", "self"...
Find the task for this build. Wraps the getTaskInfo RPC. :returns: deferred that when fired returns the Task object, or None if we could not determine the task for this build.
[ "Find", "the", "task", "for", "this", "build", "." ]
a7de380f29f745bf11730b27217208f6d4da7733
https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/build.py#L132-L144
train
Returns the Task object that this build was created for.
ktdreyer/txkoji
txkoji/build.py
Build.task_id
def task_id(self): """ Hack to return a task ID for a build, including container CG builds. We have something for this in Brewweb, but not yet for upstream Koji: https://pagure.io/koji/issue/215 """ if self['task_id']: return self['task_id'] if self.e...
python
def task_id(self): """ Hack to return a task ID for a build, including container CG builds. We have something for this in Brewweb, but not yet for upstream Koji: https://pagure.io/koji/issue/215 """ if self['task_id']: return self['task_id'] if self.e...
[ "def", "task_id", "(", "self", ")", ":", "if", "self", "[", "'task_id'", "]", ":", "return", "self", "[", "'task_id'", "]", "if", "self", ".", "extra", "and", "'container_koji_task_id'", "in", "self", ".", "extra", ":", "return", "self", ".", "extra", ...
Hack to return a task ID for a build, including container CG builds. We have something for this in Brewweb, but not yet for upstream Koji: https://pagure.io/koji/issue/215
[ "Hack", "to", "return", "a", "task", "ID", "for", "a", "build", "including", "container", "CG", "builds", "." ]
a7de380f29f745bf11730b27217208f6d4da7733
https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/build.py#L147-L157
train
Return the task ID for this build.
The-Politico/politico-civic-election-night
electionnight/serializers/election.py
PersonSerializer.get_images
def get_images(self, obj): """Object of images serialized by tag name.""" return {str(i.tag): i.image.url for i in obj.images.all()}
python
def get_images(self, obj): """Object of images serialized by tag name.""" return {str(i.tag): i.image.url for i in obj.images.all()}
[ "def", "get_images", "(", "self", ",", "obj", ")", ":", "return", "{", "str", "(", "i", ".", "tag", ")", ":", "i", ".", "image", ".", "url", "for", "i", "in", "obj", ".", "images", ".", "all", "(", ")", "}" ]
Object of images serialized by tag name.
[ "Object", "of", "images", "serialized", "by", "tag", "name", "." ]
a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6
https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/serializers/election.py#L102-L104
train
Object of images serialized by tag name.
The-Politico/politico-civic-election-night
electionnight/serializers/election.py
CandidateElectionSerializer.get_override_winner
def get_override_winner(self, obj): """Winner marked in backend.""" if obj.election.division.level.name == DivisionLevel.DISTRICT: division = obj.election.division.parent else: division = obj.election.division vote = obj.votes.filter(division=division).first() ...
python
def get_override_winner(self, obj): """Winner marked in backend.""" if obj.election.division.level.name == DivisionLevel.DISTRICT: division = obj.election.division.parent else: division = obj.election.division vote = obj.votes.filter(division=division).first() ...
[ "def", "get_override_winner", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "election", ".", "division", ".", "level", ".", "name", "==", "DivisionLevel", ".", "DISTRICT", ":", "division", "=", "obj", ".", "election", ".", "division", ".", "parent...
Winner marked in backend.
[ "Winner", "marked", "in", "backend", "." ]
a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6
https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/serializers/election.py#L128-L136
train
Returns True if the user has already set the override winning attribute.
The-Politico/politico-civic-election-night
electionnight/serializers/election.py
ElectionSerializer.get_override_votes
def get_override_votes(self, obj): """ Votes entered into backend. Only used if ``override_ap_votes = True``. """ if hasattr(obj, "meta"): # TODO: REVISIT THIS if obj.meta.override_ap_votes: all_votes = None for ce in obj.candidate_ele...
python
def get_override_votes(self, obj): """ Votes entered into backend. Only used if ``override_ap_votes = True``. """ if hasattr(obj, "meta"): # TODO: REVISIT THIS if obj.meta.override_ap_votes: all_votes = None for ce in obj.candidate_ele...
[ "def", "get_override_votes", "(", "self", ",", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "\"meta\"", ")", ":", "# TODO: REVISIT THIS", "if", "obj", ".", "meta", ".", "override_ap_votes", ":", "all_votes", "=", "None", "for", "ce", "in", "obj", "...
Votes entered into backend. Only used if ``override_ap_votes = True``.
[ "Votes", "entered", "into", "backend", ".", "Only", "used", "if", "override_ap_votes", "=", "True", "." ]
a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6
https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/serializers/election.py#L191-L205
train
Returns a list of all votes that have been set in the backend.
The-Politico/politico-civic-election-night
electionnight/serializers/election.py
ElectionSerializer.get_candidates
def get_candidates(self, obj): """ CandidateElections. """ return CandidateElectionSerializer( obj.candidate_elections.all(), many=True ).data
python
def get_candidates(self, obj): """ CandidateElections. """ return CandidateElectionSerializer( obj.candidate_elections.all(), many=True ).data
[ "def", "get_candidates", "(", "self", ",", "obj", ")", ":", "return", "CandidateElectionSerializer", "(", "obj", ".", "candidate_elections", ".", "all", "(", ")", ",", "many", "=", "True", ")", ".", "data" ]
CandidateElections.
[ "CandidateElections", "." ]
a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6
https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/serializers/election.py#L207-L213
train
Returns a list of all CandidateElections for the given object.
mfcovington/djangocms-lab-carousel
cms_lab_carousel/models.py
Slide.save
def save(self, *args, **kwargs): """ Before saving, if slide is for a publication, use publication info for slide's title, subtitle, description. """ if self.publication: publication = self.publication if not self.title: self.title = publi...
python
def save(self, *args, **kwargs): """ Before saving, if slide is for a publication, use publication info for slide's title, subtitle, description. """ if self.publication: publication = self.publication if not self.title: self.title = publi...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "publication", ":", "publication", "=", "self", ".", "publication", "if", "not", "self", ".", "title", ":", "self", ".", "title", "=", "publication", ...
Before saving, if slide is for a publication, use publication info for slide's title, subtitle, description.
[ "Before", "saving", "if", "slide", "is", "for", "a", "publication", "use", "publication", "info", "for", "slide", "s", "title", "subtitle", "description", "." ]
1f8e43df3d20cd28f090d0c2b780ad01705db41f
https://github.com/mfcovington/djangocms-lab-carousel/blob/1f8e43df3d20cd28f090d0c2b780ad01705db41f/cms_lab_carousel/models.py#L238-L273
train
Save the object to the database.
jeffh/describe
describe/spec/runners.py
ExampleRunner.execute
def execute(self, context=None, stdout=None, stderr=None): """Does all the work of running an example. This includes: - building up the context. - capturing stdout & stderr - execute before functions - run example, catching any exceptions - execute after function...
python
def execute(self, context=None, stdout=None, stderr=None): """Does all the work of running an example. This includes: - building up the context. - capturing stdout & stderr - execute before functions - run example, catching any exceptions - execute after function...
[ "def", "execute", "(", "self", ",", "context", "=", "None", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ")", ":", "total_benchmark", "=", "Benchmark", "(", ")", "self", ".", "context", "=", "context", "or", "Context", "(", ")", "if", "sel...
Does all the work of running an example. This includes: - building up the context. - capturing stdout & stderr - execute before functions - run example, catching any exceptions - execute after functions - record the results & timings to formatter and original exa...
[ "Does", "all", "the", "work", "of", "running", "an", "example", "." ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/spec/runners.py#L30-L64
train
Executes the example.
jeffh/describe
describe/spec/runners.py
ExampleRunner.run
def run(self, context=None, stdout=None, stderr=None): "Like execute, but records a skip if the should_skip method returns True." if self.should_skip(): self._record_skipped_example(self.formatter) self.num_skipped += 1 else: self.execute(context, stdout, stde...
python
def run(self, context=None, stdout=None, stderr=None): "Like execute, but records a skip if the should_skip method returns True." if self.should_skip(): self._record_skipped_example(self.formatter) self.num_skipped += 1 else: self.execute(context, stdout, stde...
[ "def", "run", "(", "self", ",", "context", "=", "None", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ")", ":", "if", "self", ".", "should_skip", "(", ")", ":", "self", ".", "_record_skipped_example", "(", "self", ".", "formatter", ")", "se...
Like execute, but records a skip if the should_skip method returns True.
[ "Like", "execute", "but", "records", "a", "skip", "if", "the", "should_skip", "method", "returns", "True", "." ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/spec/runners.py#L66-L73
train
Like execute but records a skip if the should_skip method returns True.
jeffh/describe
describe/spec/runners.py
ExampleRunner._setup
def _setup(self): "Resets the state and prepares for running the example." self.example.error = None self.example.traceback = '' # inject function contexts from parent functions c = Context(parent=self.context) #for parent in reversed(self.example.parents): # c...
python
def _setup(self): "Resets the state and prepares for running the example." self.example.error = None self.example.traceback = '' # inject function contexts from parent functions c = Context(parent=self.context) #for parent in reversed(self.example.parents): # c...
[ "def", "_setup", "(", "self", ")", ":", "self", ".", "example", ".", "error", "=", "None", "self", ".", "example", ".", "traceback", "=", "''", "# inject function contexts from parent functions", "c", "=", "Context", "(", "parent", "=", "self", ".", "context...
Resets the state and prepares for running the example.
[ "Resets", "the", "state", "and", "prepares", "for", "running", "the", "example", "." ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/spec/runners.py#L76-L87
train
Resets the state and prepares for running the example.
jeffh/describe
describe/spec/runners.py
ExampleRunner._execute_example_group
def _execute_example_group(self): "Handles the execution of Example Group" for example in self.example: runner = self.__class__(example, self.formatter) runner.is_root_runner = False successes, failures, skipped = runner.run(self.context) self.num_successe...
python
def _execute_example_group(self): "Handles the execution of Example Group" for example in self.example: runner = self.__class__(example, self.formatter) runner.is_root_runner = False successes, failures, skipped = runner.run(self.context) self.num_successe...
[ "def", "_execute_example_group", "(", "self", ")", ":", "for", "example", "in", "self", ".", "example", ":", "runner", "=", "self", ".", "__class__", "(", "example", ",", "self", ".", "formatter", ")", "runner", ".", "is_root_runner", "=", "False", "succes...
Handles the execution of Example Group
[ "Handles", "the", "execution", "of", "Example", "Group" ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/spec/runners.py#L110-L118
train
Handles the execution of Example Group
jeffh/describe
describe/spec/runners.py
ExampleRunner._execute_example
def _execute_example(self): "Handles the execution of the Example" test_benchmark = Benchmark() try: with Registry(), test_benchmark: if accepts_arg(self.example.testfn): self.example.testfn(self.context) else: s...
python
def _execute_example(self): "Handles the execution of the Example" test_benchmark = Benchmark() try: with Registry(), test_benchmark: if accepts_arg(self.example.testfn): self.example.testfn(self.context) else: s...
[ "def", "_execute_example", "(", "self", ")", ":", "test_benchmark", "=", "Benchmark", "(", ")", "try", ":", "with", "Registry", "(", ")", ",", "test_benchmark", ":", "if", "accepts_arg", "(", "self", ".", "example", ".", "testfn", ")", ":", "self", ".", ...
Handles the execution of the Example
[ "Handles", "the", "execution", "of", "the", "Example" ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/spec/runners.py#L120-L138
train
Handles the execution of the Example
jeffh/describe
describe/spec/runners.py
ExampleRunner._teardown
def _teardown(self): "Handles the restoration of any potential global state set." self.example.after(self.context) if self.is_root_runner: run.after_all.execute(self.context) #self.context = self.context._parent self.has_ran = True
python
def _teardown(self): "Handles the restoration of any potential global state set." self.example.after(self.context) if self.is_root_runner: run.after_all.execute(self.context) #self.context = self.context._parent self.has_ran = True
[ "def", "_teardown", "(", "self", ")", ":", "self", ".", "example", ".", "after", "(", "self", ".", "context", ")", "if", "self", ".", "is_root_runner", ":", "run", ".", "after_all", ".", "execute", "(", "self", ".", "context", ")", "#self.context = self....
Handles the restoration of any potential global state set.
[ "Handles", "the", "restoration", "of", "any", "potential", "global", "state", "set", "." ]
6a33ffecc3340b57e60bc8a7095521882ff9a156
https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/spec/runners.py#L140-L146
train
Handles the restoration of any potential global state set.
rraadd88/rohan
rohan/dandage/plot/annot.py
annot_boxplot
def annot_boxplot(ax,dmetrics,xoffwithin=0.85,xoff=1.6, yoff=0,annotby='xs', test=False): """ :param dmetrics: hue in index, x in columns #todos #x|y off in % xmin,xmax=ax.get_xlim() (xmax-xmin)+(xmax-xmin)*0.35+xmin """ xlabel=ax.get_xlabel() ...
python
def annot_boxplot(ax,dmetrics,xoffwithin=0.85,xoff=1.6, yoff=0,annotby='xs', test=False): """ :param dmetrics: hue in index, x in columns #todos #x|y off in % xmin,xmax=ax.get_xlim() (xmax-xmin)+(xmax-xmin)*0.35+xmin """ xlabel=ax.get_xlabel() ...
[ "def", "annot_boxplot", "(", "ax", ",", "dmetrics", ",", "xoffwithin", "=", "0.85", ",", "xoff", "=", "1.6", ",", "yoff", "=", "0", ",", "annotby", "=", "'xs'", ",", "test", "=", "False", ")", ":", "xlabel", "=", "ax", ".", "get_xlabel", "(", ")", ...
:param dmetrics: hue in index, x in columns #todos #x|y off in % xmin,xmax=ax.get_xlim() (xmax-xmin)+(xmax-xmin)*0.35+xmin
[ ":", "param", "dmetrics", ":", "hue", "in", "index", "x", "in", "columns", "#todos", "#x|y", "off", "in", "%", "xmin", "xmax", "=", "ax", ".", "get_xlim", "()", "(", "xmax", "-", "xmin", ")", "+", "(", "xmax", "-", "xmin", ")", "*", "0", ".", "...
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/plot/annot.py#L139-L168
train
annotate a boxplot with the given data metrics
rraadd88/rohan
rohan/dandage/plot/annot.py
annot_heatmap
def annot_heatmap(ax,dannot, xoff=0,yoff=0, kws_text={},# zip annot_left='(',annot_right=')', annothalf='upper', ): """ kws_text={'marker','s','linewidth','facecolors','edgecolors'} """ for xtli,xtl in enumerate(ax.g...
python
def annot_heatmap(ax,dannot, xoff=0,yoff=0, kws_text={},# zip annot_left='(',annot_right=')', annothalf='upper', ): """ kws_text={'marker','s','linewidth','facecolors','edgecolors'} """ for xtli,xtl in enumerate(ax.g...
[ "def", "annot_heatmap", "(", "ax", ",", "dannot", ",", "xoff", "=", "0", ",", "yoff", "=", "0", ",", "kws_text", "=", "{", "}", ",", "# zip", "annot_left", "=", "'('", ",", "annot_right", "=", "')'", ",", "annothalf", "=", "'upper'", ",", ")", ":",...
kws_text={'marker','s','linewidth','facecolors','edgecolors'}
[ "kws_text", "=", "{", "marker", "s", "linewidth", "facecolors", "edgecolors", "}" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/plot/annot.py#L170-L187
train
annotate the tables of the tables
rraadd88/rohan
rohan/dandage/plot/annot.py
pval2annot
def pval2annot(pval,alternative=None,alpha=None,fmt='*',#swarm=False linebreak=True, ): """ fmt: *|<|'num' """ if alternative is None and alpha is None: ValueError('both alternative and alpha are None') if alpha is None: alpha=0.025 if alternative=='two-s...
python
def pval2annot(pval,alternative=None,alpha=None,fmt='*',#swarm=False linebreak=True, ): """ fmt: *|<|'num' """ if alternative is None and alpha is None: ValueError('both alternative and alpha are None') if alpha is None: alpha=0.025 if alternative=='two-s...
[ "def", "pval2annot", "(", "pval", ",", "alternative", "=", "None", ",", "alpha", "=", "None", ",", "fmt", "=", "'*'", ",", "#swarm=False", "linebreak", "=", "True", ",", ")", ":", "if", "alternative", "is", "None", "and", "alpha", "is", "None", ":", ...
fmt: *|<|'num'
[ "fmt", ":", "*", "|<|", "num" ]
b0643a3582a2fffc0165ace69fb80880d92bfb10
https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/plot/annot.py#L190-L211
train
converts a P value to an annotation string
klahnakoski/mo-json
mo_json/encoder.py
pypy_json_encode
def pypy_json_encode(value, pretty=False): """ pypy DOES NOT OPTIMIZE GENERATOR CODE WELL """ global _dealing_with_problem if pretty: return pretty_json(value) try: _buffer = UnicodeBuilder(2048) _value2json(value, _buffer) output = _buffer.build() return...
python
def pypy_json_encode(value, pretty=False): """ pypy DOES NOT OPTIMIZE GENERATOR CODE WELL """ global _dealing_with_problem if pretty: return pretty_json(value) try: _buffer = UnicodeBuilder(2048) _value2json(value, _buffer) output = _buffer.build() return...
[ "def", "pypy_json_encode", "(", "value", ",", "pretty", "=", "False", ")", ":", "global", "_dealing_with_problem", "if", "pretty", ":", "return", "pretty_json", "(", "value", ")", "try", ":", "_buffer", "=", "UnicodeBuilder", "(", "2048", ")", "_value2json", ...
pypy DOES NOT OPTIMIZE GENERATOR CODE WELL
[ "pypy", "DOES", "NOT", "OPTIMIZE", "GENERATOR", "CODE", "WELL" ]
0d44d6a7e37f0ea50e583c30c2cbc42488d5de7f
https://github.com/klahnakoski/mo-json/blob/0d44d6a7e37f0ea50e583c30c2cbc42488d5de7f/mo_json/encoder.py#L69-L96
train
JSON encode a value into a pypy object
klahnakoski/mo-json
mo_json/encoder.py
problem_serializing
def problem_serializing(value, e=None): """ THROW ERROR ABOUT SERIALIZING """ from mo_logs import Log try: typename = type(value).__name__ except Exception: typename = "<error getting name>" try: rep = text_type(repr(value)) except Exception as _: rep = ...
python
def problem_serializing(value, e=None): """ THROW ERROR ABOUT SERIALIZING """ from mo_logs import Log try: typename = type(value).__name__ except Exception: typename = "<error getting name>" try: rep = text_type(repr(value)) except Exception as _: rep = ...
[ "def", "problem_serializing", "(", "value", ",", "e", "=", "None", ")", ":", "from", "mo_logs", "import", "Log", "try", ":", "typename", "=", "type", "(", "value", ")", ".", "__name__", "except", "Exception", ":", "typename", "=", "\"<error getting name>\"",...
THROW ERROR ABOUT SERIALIZING
[ "THROW", "ERROR", "ABOUT", "SERIALIZING" ]
0d44d6a7e37f0ea50e583c30c2cbc42488d5de7f
https://github.com/klahnakoski/mo-json/blob/0d44d6a7e37f0ea50e583c30c2cbc42488d5de7f/mo_json/encoder.py#L421-L449
train
This function is called when a value is not serializable.
klahnakoski/mo-json
mo_json/encoder.py
unicode_key
def unicode_key(key): """ CONVERT PROPERTY VALUE TO QUOTED NAME OF SAME """ if not isinstance(key, (text_type, binary_type)): from mo_logs import Log Log.error("{{key|quote}} is not a valid key", key=key) return quote(text_type(key))
python
def unicode_key(key): """ CONVERT PROPERTY VALUE TO QUOTED NAME OF SAME """ if not isinstance(key, (text_type, binary_type)): from mo_logs import Log Log.error("{{key|quote}} is not a valid key", key=key) return quote(text_type(key))
[ "def", "unicode_key", "(", "key", ")", ":", "if", "not", "isinstance", "(", "key", ",", "(", "text_type", ",", "binary_type", ")", ")", ":", "from", "mo_logs", "import", "Log", "Log", ".", "error", "(", "\"{{key|quote}} is not a valid key\"", ",", "key", "...
CONVERT PROPERTY VALUE TO QUOTED NAME OF SAME
[ "CONVERT", "PROPERTY", "VALUE", "TO", "QUOTED", "NAME", "OF", "SAME" ]
0d44d6a7e37f0ea50e583c30c2cbc42488d5de7f
https://github.com/klahnakoski/mo-json/blob/0d44d6a7e37f0ea50e583c30c2cbc42488d5de7f/mo_json/encoder.py#L490-L497
train
CONVERT PROPERTY VALUE TO QUOTED NAME OF SAME
tjcsl/cslbot
cslbot/commands/uptime.py
cmd
def cmd(send, _, args): """Shows the bot's uptime. Syntax: {command} """ curr = datetime.now() uptime = args['handler'].uptime load_avg = ', '.join([str(x) for x in os.getloadavg()]) starttime = curr - uptime['start'] reloaded = curr - uptime['reloaded'] send("Time since start: %s,...
python
def cmd(send, _, args): """Shows the bot's uptime. Syntax: {command} """ curr = datetime.now() uptime = args['handler'].uptime load_avg = ', '.join([str(x) for x in os.getloadavg()]) starttime = curr - uptime['start'] reloaded = curr - uptime['reloaded'] send("Time since start: %s,...
[ "def", "cmd", "(", "send", ",", "_", ",", "args", ")", ":", "curr", "=", "datetime", ".", "now", "(", ")", "uptime", "=", "args", "[", "'handler'", "]", ".", "uptime", "load_avg", "=", "', '", ".", "join", "(", "[", "str", "(", "x", ")", "for",...
Shows the bot's uptime. Syntax: {command}
[ "Shows", "the", "bot", "s", "uptime", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/uptime.py#L25-L37
train
Shows the bot s uptime. Syntax : { command }
marrow/util
marrow/util/context/cwd.py
pcwd
def pcwd(func): """A decorator to provide the functionality of the PreserveWorkingDirectory context manager for functions and methods.""" @wraps(func) def inner(*args, **kw): with PreserveWorkingDirectory(): return func(*args, **kw) return inner
python
def pcwd(func): """A decorator to provide the functionality of the PreserveWorkingDirectory context manager for functions and methods.""" @wraps(func) def inner(*args, **kw): with PreserveWorkingDirectory(): return func(*args, **kw) return inner
[ "def", "pcwd", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "inner", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "with", "PreserveWorkingDirectory", "(", ")", ":", "return", "func", "(", "*", "args", ",", "*", "*", "kw", "...
A decorator to provide the functionality of the PreserveWorkingDirectory context manager for functions and methods.
[ "A", "decorator", "to", "provide", "the", "functionality", "of", "the", "PreserveWorkingDirectory", "context", "manager", "for", "functions", "and", "methods", "." ]
abb8163dbd1fa0692d42a44d129b12ae2b39cdf2
https://github.com/marrow/util/blob/abb8163dbd1fa0692d42a44d129b12ae2b39cdf2/marrow/util/context/cwd.py#L32-L41
train
A decorator to provide the functionality of the PreserveWorkingDirectory context manager for functions and methods.
codenerix/django-codenerix-pos
codenerix_pos/consumers.py
POSConsumer.recv
def recv(self, message, ref, pos): """ Called when a message is received with decoded JSON content """ # Get action action = message.get('action', None) # Show the message we got if action != 'pingdog': self.debug("{} - Receive: {} (ref:{}) - {}".for...
python
def recv(self, message, ref, pos): """ Called when a message is received with decoded JSON content """ # Get action action = message.get('action', None) # Show the message we got if action != 'pingdog': self.debug("{} - Receive: {} (ref:{}) - {}".for...
[ "def", "recv", "(", "self", ",", "message", ",", "ref", ",", "pos", ")", ":", "# Get action", "action", "=", "message", ".", "get", "(", "'action'", ",", "None", ")", "# Show the message we got", "if", "action", "!=", "'pingdog'", ":", "self", ".", "debu...
Called when a message is received with decoded JSON content
[ "Called", "when", "a", "message", "is", "received", "with", "decoded", "JSON", "content" ]
d59f233dd421a6bfe0e9e2674468de2b632643b8
https://github.com/codenerix/django-codenerix-pos/blob/d59f233dd421a6bfe0e9e2674468de2b632643b8/codenerix_pos/consumers.py#L128-L209
train
Called when a message is received with decoded JSON content.
tjcsl/cslbot
cslbot/commands/sha512.py
cmd
def cmd(send, msg, _): """SHA512 hashes something. Syntax: {command} <msg> """ msg = msg.encode('utf-8') send(hashlib.sha512(msg).hexdigest())
python
def cmd(send, msg, _): """SHA512 hashes something. Syntax: {command} <msg> """ msg = msg.encode('utf-8') send(hashlib.sha512(msg).hexdigest())
[ "def", "cmd", "(", "send", ",", "msg", ",", "_", ")", ":", "msg", "=", "msg", ".", "encode", "(", "'utf-8'", ")", "send", "(", "hashlib", ".", "sha512", "(", "msg", ")", ".", "hexdigest", "(", ")", ")" ]
SHA512 hashes something. Syntax: {command} <msg>
[ "SHA512", "hashes", "something", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/sha512.py#L24-L31
train
SHA512 hashes something.
The-Politico/politico-civic-election-night
electionnight/viewsets/office.py
OfficeMixin.get_queryset
def get_queryset(self): """ Returns a queryset of all executive offices holding an election on a date. """ try: date = ElectionDay.objects.get(date=self.kwargs['date']) except Exception: raise APIException( 'No elections on {}.'.for...
python
def get_queryset(self): """ Returns a queryset of all executive offices holding an election on a date. """ try: date = ElectionDay.objects.get(date=self.kwargs['date']) except Exception: raise APIException( 'No elections on {}.'.for...
[ "def", "get_queryset", "(", "self", ")", ":", "try", ":", "date", "=", "ElectionDay", ".", "objects", ".", "get", "(", "date", "=", "self", ".", "kwargs", "[", "'date'", "]", ")", "except", "Exception", ":", "raise", "APIException", "(", "'No elections o...
Returns a queryset of all executive offices holding an election on a date.
[ "Returns", "a", "queryset", "of", "all", "executive", "offices", "holding", "an", "election", "on", "a", "date", "." ]
a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6
https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/viewsets/office.py#L9-L25
train
Returns a queryset of all executive offices holding an election on a date.
The-Politico/politico-civic-election-night
electionnight/viewsets/office.py
OfficeMixin.get_serializer_context
def get_serializer_context(self): """Adds ``election_day`` to serializer context.""" context = super(OfficeMixin, self).get_serializer_context() context['election_date'] = self.kwargs['date'] return context
python
def get_serializer_context(self): """Adds ``election_day`` to serializer context.""" context = super(OfficeMixin, self).get_serializer_context() context['election_date'] = self.kwargs['date'] return context
[ "def", "get_serializer_context", "(", "self", ")", ":", "context", "=", "super", "(", "OfficeMixin", ",", "self", ")", ".", "get_serializer_context", "(", ")", "context", "[", "'election_date'", "]", "=", "self", ".", "kwargs", "[", "'date'", "]", "return", ...
Adds ``election_day`` to serializer context.
[ "Adds", "election_day", "to", "serializer", "context", "." ]
a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6
https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/viewsets/office.py#L27-L31
train
Adds election_day to serializer context.
tjcsl/cslbot
cslbot/commands/slap.py
cmd
def cmd(send, msg, args): """Slap somebody. Syntax: {command} <nick> [for <reason>] """ implements = ['the golden gate bridge', 'a large trout', 'a clue-by-four', 'a fresh haddock', 'moon', 'an Itanium', 'fwilson', 'a wombat'] methods = ['around a bit', 'upside the head'] if not msg: c...
python
def cmd(send, msg, args): """Slap somebody. Syntax: {command} <nick> [for <reason>] """ implements = ['the golden gate bridge', 'a large trout', 'a clue-by-four', 'a fresh haddock', 'moon', 'an Itanium', 'fwilson', 'a wombat'] methods = ['around a bit', 'upside the head'] if not msg: c...
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "implements", "=", "[", "'the golden gate bridge'", ",", "'a large trout'", ",", "'a clue-by-four'", ",", "'a fresh haddock'", ",", "'moon'", ",", "'an Itanium'", ",", "'fwilson'", ",", "'a wombat'", ...
Slap somebody. Syntax: {command} <nick> [for <reason>]
[ "Slap", "somebody", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/slap.py#L24-L84
train
Slap somebody.
tjcsl/cslbot
cslbot/commands/nicks.py
cmd
def cmd(send, msg, args): """Gets previous nicks. Syntax: {command} <nick> """ if not msg: with args['handler'].data_lock: users = list(args['handler'].channels[args['target']].users()) if args['target'] != 'private' else [args['nick']] msg = choice(users) chain = get_c...
python
def cmd(send, msg, args): """Gets previous nicks. Syntax: {command} <nick> """ if not msg: with args['handler'].data_lock: users = list(args['handler'].channels[args['target']].users()) if args['target'] != 'private' else [args['nick']] msg = choice(users) chain = get_c...
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "if", "not", "msg", ":", "with", "args", "[", "'handler'", "]", ".", "data_lock", ":", "users", "=", "list", "(", "args", "[", "'handler'", "]", ".", "channels", "[", "args", "[", "'ta...
Gets previous nicks. Syntax: {command} <nick>
[ "Gets", "previous", "nicks", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/nicks.py#L25-L39
train
Gets previous nicks.
asphalt-framework/asphalt-sqlalchemy
asphalt/sqlalchemy/utils.py
clear_database
def clear_database(engine: Connectable, schemas: Iterable[str] = ()) -> None: """ Clear any tables from an existing database. :param engine: the engine or connection to use :param schemas: full list of schema names to expect (ignored for SQLite) """ assert check_argument_types() metadatas ...
python
def clear_database(engine: Connectable, schemas: Iterable[str] = ()) -> None: """ Clear any tables from an existing database. :param engine: the engine or connection to use :param schemas: full list of schema names to expect (ignored for SQLite) """ assert check_argument_types() metadatas ...
[ "def", "clear_database", "(", "engine", ":", "Connectable", ",", "schemas", ":", "Iterable", "[", "str", "]", "=", "(", ")", ")", "->", "None", ":", "assert", "check_argument_types", "(", ")", "metadatas", "=", "[", "]", "all_schemas", "=", "(", "None", ...
Clear any tables from an existing database. :param engine: the engine or connection to use :param schemas: full list of schema names to expect (ignored for SQLite)
[ "Clear", "any", "tables", "from", "an", "existing", "database", "." ]
5abb7d9977ee92299359b76496ff34624421de05
https://github.com/asphalt-framework/asphalt-sqlalchemy/blob/5abb7d9977ee92299359b76496ff34624421de05/asphalt/sqlalchemy/utils.py#L8-L27
train
Clear any tables from an existing database.
tjcsl/cslbot
cslbot/commands/inspect.py
cmd
def cmd(send, msg, args): """'Inspects a bot attribute. Syntax: {command} <attr> """ if not hasattr(args['handler'], msg): send("That attribute was not found in the handler.") return send(str(getattr(args['handler'], msg)))
python
def cmd(send, msg, args): """'Inspects a bot attribute. Syntax: {command} <attr> """ if not hasattr(args['handler'], msg): send("That attribute was not found in the handler.") return send(str(getattr(args['handler'], msg)))
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "if", "not", "hasattr", "(", "args", "[", "'handler'", "]", ",", "msg", ")", ":", "send", "(", "\"That attribute was not found in the handler.\"", ")", "return", "send", "(", "str", "(", "geta...
Inspects a bot attribute. Syntax: {command} <attr>
[ "Inspects", "a", "bot", "attribute", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/inspect.py#L22-L31
train
Inspects a bot attribute.
tjcsl/cslbot
cslbot/commands/tumblr.py
cmd
def cmd(send, msg, args): """Searches tumblr Syntax: {command} <blogname> <--submit content|--random> """ parser = arguments.ArgParser(args['config']) parser.add_argument('blogname', action=arguments.TumblrParser) group = parser.add_mutually_exclusive_group() group.add_argument('--submit', n...
python
def cmd(send, msg, args): """Searches tumblr Syntax: {command} <blogname> <--submit content|--random> """ parser = arguments.ArgParser(args['config']) parser.add_argument('blogname', action=arguments.TumblrParser) group = parser.add_mutually_exclusive_group() group.add_argument('--submit', n...
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "parser", "=", "arguments", ".", "ArgParser", "(", "args", "[", "'config'", "]", ")", "parser", ".", "add_argument", "(", "'blogname'", ",", "action", "=", "arguments", ".", "TumblrParser", ...
Searches tumblr Syntax: {command} <blogname> <--submit content|--random>
[ "Searches", "tumblr", "Syntax", ":", "{", "command", "}", "<blogname", ">", "<", "--", "submit", "content|", "--", "random", ">" ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/tumblr.py#L29-L84
train
Searches tumblr for a single entry in a tumblr blog.
tjcsl/cslbot
cslbot/commands/s.py
cmd
def cmd(send, msg, args): """Corrects a previous message. Syntax: {command}/<msg>/<replacement>/<ig|nick> """ if not msg: send("Invalid Syntax.") return char = msg[0] msg = [x.replace(r'\/', '/') for x in re.split(r'(?<!\\)\%s' % char, msg[1:], maxsplit=2)] # fix for people...
python
def cmd(send, msg, args): """Corrects a previous message. Syntax: {command}/<msg>/<replacement>/<ig|nick> """ if not msg: send("Invalid Syntax.") return char = msg[0] msg = [x.replace(r'\/', '/') for x in re.split(r'(?<!\\)\%s' % char, msg[1:], maxsplit=2)] # fix for people...
[ "def", "cmd", "(", "send", ",", "msg", ",", "args", ")", ":", "if", "not", "msg", ":", "send", "(", "\"Invalid Syntax.\"", ")", "return", "char", "=", "msg", "[", "0", "]", "msg", "=", "[", "x", ".", "replace", "(", "r'\\/'", ",", "'/'", ")", "...
Corrects a previous message. Syntax: {command}/<msg>/<replacement>/<ig|nick>
[ "Corrects", "a", "previous", "message", "." ]
aebe07be47141f61d7c180706bddfb707f19b2b5
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/s.py#L80-L124
train
Corrects a previous message.
JoeVirtual/KonFoo
konfoo/core.py
Container.to_json
def to_json(self, *attributes, **options): """ Returns the selected field *attributes* for each :class:`Field` *nested* in the `Container` as a JSON formatted string. The *attributes* of each :class:`Field` for containers *nested* in the `Container` are viewed as well (chained method ca...
python
def to_json(self, *attributes, **options): """ Returns the selected field *attributes* for each :class:`Field` *nested* in the `Container` as a JSON formatted string. The *attributes* of each :class:`Field` for containers *nested* in the `Container` are viewed as well (chained method ca...
[ "def", "to_json", "(", "self", ",", "*", "attributes", ",", "*", "*", "options", ")", ":", "nested", "=", "options", ".", "pop", "(", "'nested'", ",", "False", ")", "fieldnames", "=", "options", ".", "pop", "(", "'fieldnames'", ",", "attributes", ")", ...
Returns the selected field *attributes* for each :class:`Field` *nested* in the `Container` as a JSON formatted string. The *attributes* of each :class:`Field` for containers *nested* in the `Container` are viewed as well (chained method call). :param str attributes: selected :class:`F...
[ "Returns", "the", "selected", "field", "*", "attributes", "*", "for", "each", ":", "class", ":", "Field", "*", "nested", "*", "in", "the", "Container", "as", "a", "JSON", "formatted", "string", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L188-L216
train
Returns the selected field attributes for each object in the Container as a JSON formatted string.
JoeVirtual/KonFoo
konfoo/core.py
Container.to_list
def to_list(self, *attributes, **options): """ Returns a **flatten** list of ``('field path', attribute)`` or ``('field path', tuple(attributes))`` tuples for each :class:`Field` *nested* in the `Container`. :param str attributes: selected :class:`Field` attributes. Fallback...
python
def to_list(self, *attributes, **options): """ Returns a **flatten** list of ``('field path', attribute)`` or ``('field path', tuple(attributes))`` tuples for each :class:`Field` *nested* in the `Container`. :param str attributes: selected :class:`Field` attributes. Fallback...
[ "def", "to_list", "(", "self", ",", "*", "attributes", ",", "*", "*", "options", ")", ":", "# Name of the Container", "name", "=", "options", ".", "pop", "(", "'name'", ",", "self", ".", "__class__", ".", "__name__", ")", "fields", "=", "list", "(", ")...
Returns a **flatten** list of ``('field path', attribute)`` or ``('field path', tuple(attributes))`` tuples for each :class:`Field` *nested* in the `Container`. :param str attributes: selected :class:`Field` attributes. Fallback is the field :attr:`~Field.value`. :keyword st...
[ "Returns", "a", "**", "flatten", "**", "list", "of", "(", "field", "path", "attribute", ")", "or", "(", "field", "path", "tuple", "(", "attributes", "))", "tuples", "for", "each", ":", "class", ":", "Field", "*", "nested", "*", "in", "the", "Container"...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L235-L270
train
Returns a list of tuples for each object in the Container.
JoeVirtual/KonFoo
konfoo/core.py
Container.to_dict
def to_dict(self, *attributes, **options): """ Returns a **flatten** :class:`ordered dictionary <collections.OrderedDict>` of ``{'field path': attribute}`` or ``{'field path': tuple(attributes)}`` pairs for each :class:`Field` *nested* in the `Container`. :param str attributes: selected...
python
def to_dict(self, *attributes, **options): """ Returns a **flatten** :class:`ordered dictionary <collections.OrderedDict>` of ``{'field path': attribute}`` or ``{'field path': tuple(attributes)}`` pairs for each :class:`Field` *nested* in the `Container`. :param str attributes: selected...
[ "def", "to_dict", "(", "self", ",", "*", "attributes", ",", "*", "*", "options", ")", ":", "# Name of the Container", "name", "=", "options", ".", "pop", "(", "'name'", ",", "self", ".", "__class__", ".", "__name__", ")", "# Save to file", "save", "=", "...
Returns a **flatten** :class:`ordered dictionary <collections.OrderedDict>` of ``{'field path': attribute}`` or ``{'field path': tuple(attributes)}`` pairs for each :class:`Field` *nested* in the `Container`. :param str attributes: selected :class:`Field` attributes. Fallback is the...
[ "Returns", "a", "**", "flatten", "**", ":", "class", ":", "ordered", "dictionary", "<collections", ".", "OrderedDict", ">", "of", "{", "field", "path", ":", "attribute", "}", "or", "{", "field", "path", ":", "tuple", "(", "attributes", ")", "}", "pairs",...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L273-L303
train
Returns a flattened dictionary of the object s fields.
JoeVirtual/KonFoo
konfoo/core.py
Container.to_csv
def to_csv(self, *attributes, **options): """ Returns a **flatten** list of dictionaries containing the field *path* and the selected field *attributes* for each :class:`Field` *nested* in the `Container`. :param str attributes: selected :class:`Field` attributes. Fallback i...
python
def to_csv(self, *attributes, **options): """ Returns a **flatten** list of dictionaries containing the field *path* and the selected field *attributes* for each :class:`Field` *nested* in the `Container`. :param str attributes: selected :class:`Field` attributes. Fallback i...
[ "def", "to_csv", "(", "self", ",", "*", "attributes", ",", "*", "*", "options", ")", ":", "keys", "=", "self", ".", "_get_fieldnames", "(", "*", "attributes", ",", "*", "*", "options", ")", "options", "[", "'chain'", "]", "=", "True", "return", "[", ...
Returns a **flatten** list of dictionaries containing the field *path* and the selected field *attributes* for each :class:`Field` *nested* in the `Container`. :param str attributes: selected :class:`Field` attributes. Fallback is the field :attr:`~Field.value`. :keyword str...
[ "Returns", "a", "**", "flatten", "**", "list", "of", "dictionaries", "containing", "the", "field", "*", "path", "*", "and", "the", "selected", "field", "*", "attributes", "*", "for", "each", ":", "class", ":", "Field", "*", "nested", "*", "in", "the", ...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L317-L336
train
Returns a list of dictionaries containing the field path* and the selected field attributes.
JoeVirtual/KonFoo
konfoo/core.py
Container.write_csv
def write_csv(self, file, *attributes, **options): """ Writes the field *path* and the selected field *attributes* for each :class:`Field` *nested* in the `Container` to a ``.csv`` *file*. :param str file: name and location of the ``.csv`` *file*. :param str attributes: selected :class...
python
def write_csv(self, file, *attributes, **options): """ Writes the field *path* and the selected field *attributes* for each :class:`Field` *nested* in the `Container` to a ``.csv`` *file*. :param str file: name and location of the ``.csv`` *file*. :param str attributes: selected :class...
[ "def", "write_csv", "(", "self", ",", "file", ",", "*", "attributes", ",", "*", "*", "options", ")", ":", "with", "open", "(", "file", ",", "'w'", ",", "newline", "=", "''", ")", "as", "file_handle", ":", "fieldnames", "=", "self", ".", "_get_fieldna...
Writes the field *path* and the selected field *attributes* for each :class:`Field` *nested* in the `Container` to a ``.csv`` *file*. :param str file: name and location of the ``.csv`` *file*. :param str attributes: selected :class:`Field` attributes. Fallback is the field :attr:`~...
[ "Writes", "the", "field", "*", "path", "*", "and", "the", "selected", "field", "*", "attributes", "*", "for", "each", ":", "class", ":", "Field", "*", "nested", "*", "in", "the", "Container", "to", "a", ".", "csv", "*", "file", "*", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L339-L360
train
Writes the values of the selected fields for each object in the object to a. csv file.
JoeVirtual/KonFoo
konfoo/core.py
Container.save
def save(self, file, *attributes, **options): """ Saves the selected field *attributes* for each :class:`Field` *nested* in the `Container` to an ``.ini`` *file*. :param str file: name and location of the ``.ini`` *file*. :param str attributes: selected :class:`Field` attributes. ...
python
def save(self, file, *attributes, **options): """ Saves the selected field *attributes* for each :class:`Field` *nested* in the `Container` to an ``.ini`` *file*. :param str file: name and location of the ``.ini`` *file*. :param str attributes: selected :class:`Field` attributes. ...
[ "def", "save", "(", "self", ",", "file", ",", "*", "attributes", ",", "*", "*", "options", ")", ":", "options", "[", "'save'", "]", "=", "True", "parser", "=", "ConfigParser", "(", ")", "parser", ".", "read_dict", "(", "self", ".", "to_dict", "(", ...
Saves the selected field *attributes* for each :class:`Field` *nested* in the `Container` to an ``.ini`` *file*. :param str file: name and location of the ``.ini`` *file*. :param str attributes: selected :class:`Field` attributes. Fallback is the field :attr:`~Field.value`. ...
[ "Saves", "the", "selected", "field", "*", "attributes", "*", "for", "each", ":", "class", ":", "Field", "*", "nested", "*", "in", "the", "Container", "to", "an", ".", "ini", "*", "file", "*", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L363-L424
train
Save the selected fields in the current object to an. ini file.
JoeVirtual/KonFoo
konfoo/core.py
Container.load
def load(self, file, **options): """ Loads the field *value* for each :class:`Field` *nested* in the `Container` from an ``.ini`` *file*. :param str file: name and location of the ``.ini`` *file*. :keyword str section: section in the ``.ini`` *file* to lookup the value for e...
python
def load(self, file, **options): """ Loads the field *value* for each :class:`Field` *nested* in the `Container` from an ``.ini`` *file*. :param str file: name and location of the ``.ini`` *file*. :keyword str section: section in the ``.ini`` *file* to lookup the value for e...
[ "def", "load", "(", "self", ",", "file", ",", "*", "*", "options", ")", ":", "section", "=", "options", ".", "pop", "(", "'section'", ",", "self", ".", "__class__", ".", "__name__", ")", "parser", "=", "ConfigParser", "(", ")", "parser", ".", "read",...
Loads the field *value* for each :class:`Field` *nested* in the `Container` from an ``.ini`` *file*. :param str file: name and location of the ``.ini`` *file*. :keyword str section: section in the ``.ini`` *file* to lookup the value for each :class:`Field` in the `Container`. ...
[ "Loads", "the", "field", "*", "value", "*", "for", "each", ":", "class", ":", "Field", "*", "nested", "*", "in", "the", "Container", "from", "an", ".", "ini", "*", "file", "*", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L428-L538
train
Loads the object containing the key value for each field in the object.
JoeVirtual/KonFoo
konfoo/core.py
Structure.read_from
def read_from(self, provider, **options): """ All :class:`Pointer` fields in the `Structure` read the necessary number of bytes from the data :class:`Provider` for their referenced :attr:`~Pointer.data` object. Null pointer are ignored. :param Provider provider: data :class:`Provider`. ...
python
def read_from(self, provider, **options): """ All :class:`Pointer` fields in the `Structure` read the necessary number of bytes from the data :class:`Provider` for their referenced :attr:`~Pointer.data` object. Null pointer are ignored. :param Provider provider: data :class:`Provider`. ...
[ "def", "read_from", "(", "self", ",", "provider", ",", "*", "*", "options", ")", ":", "for", "item", "in", "self", ".", "values", "(", ")", ":", "# Container or Pointer", "if", "is_mixin", "(", "item", ")", ":", "item", ".", "read_from", "(", "provider...
All :class:`Pointer` fields in the `Structure` read the necessary number of bytes from the data :class:`Provider` for their referenced :attr:`~Pointer.data` object. Null pointer are ignored. :param Provider provider: data :class:`Provider`. :keyword bool nested: if ``True`` all :class:`...
[ "All", ":", "class", ":", "Pointer", "fields", "in", "the", "Structure", "read", "the", "necessary", "number", "of", "bytes", "from", "the", "data", ":", "class", ":", "Provider", "for", "their", "referenced", ":", "attr", ":", "~Pointer", ".", "data", "...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L649-L665
train
Reads the necessary number of bytes from the data provider for the items in the structure.
JoeVirtual/KonFoo
konfoo/core.py
Structure.deserialize
def deserialize(self, buffer=bytes(), index=Index(), **options): """ De-serializes the `Structure` from the byte *buffer* starting at the begin of the *buffer* or with the given *index* by mapping the bytes to the :attr:`~Field.value` for each :class:`Field` in the `Structure` in accorda...
python
def deserialize(self, buffer=bytes(), index=Index(), **options): """ De-serializes the `Structure` from the byte *buffer* starting at the begin of the *buffer* or with the given *index* by mapping the bytes to the :attr:`~Field.value` for each :class:`Field` in the `Structure` in accorda...
[ "def", "deserialize", "(", "self", ",", "buffer", "=", "bytes", "(", ")", ",", "index", "=", "Index", "(", ")", ",", "*", "*", "options", ")", ":", "for", "item", "in", "self", ".", "values", "(", ")", ":", "index", "=", "item", ".", "deserialize...
De-serializes the `Structure` from the byte *buffer* starting at the begin of the *buffer* or with the given *index* by mapping the bytes to the :attr:`~Field.value` for each :class:`Field` in the `Structure` in accordance with the decoding *byte order* for the de-serialization and the d...
[ "De", "-", "serializes", "the", "Structure", "from", "the", "byte", "*", "buffer", "*", "starting", "at", "the", "begin", "of", "the", "*", "buffer", "*", "or", "with", "the", "given", "*", "index", "*", "by", "mapping", "the", "bytes", "to", "the", ...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L669-L700
train
Deserializes the a objects from the byte stream.
JoeVirtual/KonFoo
konfoo/core.py
Structure.serialize
def serialize(self, buffer=bytearray(), index=Index(), **options): """ Serializes the `Structure` to the byte *buffer* starting at begin of the *buffer* or with the given *index* by mapping the :attr:`~Field.value` for each :class:`Field` in the `Structure` to the byte *buffer* in accord...
python
def serialize(self, buffer=bytearray(), index=Index(), **options): """ Serializes the `Structure` to the byte *buffer* starting at begin of the *buffer* or with the given *index* by mapping the :attr:`~Field.value` for each :class:`Field` in the `Structure` to the byte *buffer* in accord...
[ "def", "serialize", "(", "self", ",", "buffer", "=", "bytearray", "(", ")", ",", "index", "=", "Index", "(", ")", ",", "*", "*", "options", ")", ":", "for", "item", "in", "self", ".", "values", "(", ")", ":", "index", "=", "item", ".", "serialize...
Serializes the `Structure` to the byte *buffer* starting at begin of the *buffer* or with the given *index* by mapping the :attr:`~Field.value` for each :class:`Field` in the `Structure` to the byte *buffer* in accordance with the encoding *byte order* for the serialization and the encod...
[ "Serializes", "the", "Structure", "to", "the", "byte", "*", "buffer", "*", "starting", "at", "begin", "of", "the", "*", "buffer", "*", "or", "with", "the", "given", "*", "index", "*", "by", "mapping", "the", ":", "attr", ":", "~Field", ".", "value", ...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L704-L735
train
Serializes the structure to a byte stream.
JoeVirtual/KonFoo
konfoo/core.py
Structure.index_fields
def index_fields(self, index=Index(), **options): """ Indexes all fields in the `Structure` starting with the given *index* and returns the :class:`Index` after the last :class:`Field` in the `Structure`. :param Index index: start :class:`Index` for the first :class:`Field` ...
python
def index_fields(self, index=Index(), **options): """ Indexes all fields in the `Structure` starting with the given *index* and returns the :class:`Index` after the last :class:`Field` in the `Structure`. :param Index index: start :class:`Index` for the first :class:`Field` ...
[ "def", "index_fields", "(", "self", ",", "index", "=", "Index", "(", ")", ",", "*", "*", "options", ")", ":", "for", "name", ",", "item", "in", "self", ".", "items", "(", ")", ":", "# Container", "if", "is_container", "(", "item", ")", ":", "index"...
Indexes all fields in the `Structure` starting with the given *index* and returns the :class:`Index` after the last :class:`Field` in the `Structure`. :param Index index: start :class:`Index` for the first :class:`Field` in the `Structure`. :keyword bool nested: if ``True`` ...
[ "Indexes", "all", "fields", "in", "the", "Structure", "starting", "with", "the", "given", "*", "index", "*", "and", "returns", "the", ":", "class", ":", "Index", "after", "the", "last", ":", "class", ":", "Field", "in", "the", "Structure", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L738-L762
train
Indexes all fields in the given index and returns the last index after the first field in the Structure.
JoeVirtual/KonFoo
konfoo/core.py
Structure.initialize_fields
def initialize_fields(self, content): """ Initializes the :class:`Field` members in the `Structure` with the *values* in the *content* dictionary. :param dict content: a dictionary contains the :class:`Field` values for each member in the `Structure`. """ for name, v...
python
def initialize_fields(self, content): """ Initializes the :class:`Field` members in the `Structure` with the *values* in the *content* dictionary. :param dict content: a dictionary contains the :class:`Field` values for each member in the `Structure`. """ for name, v...
[ "def", "initialize_fields", "(", "self", ",", "content", ")", ":", "for", "name", ",", "value", "in", "content", ".", "items", "(", ")", ":", "item", "=", "self", "[", "name", "]", "# Container or Pointer", "if", "is_mixin", "(", "item", ")", ":", "ite...
Initializes the :class:`Field` members in the `Structure` with the *values* in the *content* dictionary. :param dict content: a dictionary contains the :class:`Field` values for each member in the `Structure`.
[ "Initializes", "the", ":", "class", ":", "Field", "members", "in", "the", "Structure", "with", "the", "*", "values", "*", "in", "the", "*", "content", "*", "dictionary", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L799-L815
train
Initializes the fields in the structure with the values in the content dictionary.
JoeVirtual/KonFoo
konfoo/core.py
Structure.view_fields
def view_fields(self, *attributes, **options): """ Returns an :class:`ordered dictionary <collections.OrderedDict>` which contains the ``{'member name': field attribute}`` or the ``{'member name': dict(field attributes)}`` pairs for each :class:`Field` *nested* in the `Structure`. ...
python
def view_fields(self, *attributes, **options): """ Returns an :class:`ordered dictionary <collections.OrderedDict>` which contains the ``{'member name': field attribute}`` or the ``{'member name': dict(field attributes)}`` pairs for each :class:`Field` *nested* in the `Structure`. ...
[ "def", "view_fields", "(", "self", ",", "*", "attributes", ",", "*", "*", "options", ")", ":", "members", "=", "OrderedDict", "(", ")", "for", "name", ",", "item", "in", "self", ".", "items", "(", ")", ":", "# Container", "if", "is_container", "(", "...
Returns an :class:`ordered dictionary <collections.OrderedDict>` which contains the ``{'member name': field attribute}`` or the ``{'member name': dict(field attributes)}`` pairs for each :class:`Field` *nested* in the `Structure`. The *attributes* of each :class:`Field` for containers *...
[ "Returns", "an", ":", "class", ":", "ordered", "dictionary", "<collections", ".", "OrderedDict", ">", "which", "contains", "the", "{", "member", "name", ":", "field", "attribute", "}", "or", "the", "{", "member", "name", ":", "dict", "(", "field", "attribu...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L818-L855
train
Returns an ordered dictionary of the fields of the current object.
JoeVirtual/KonFoo
konfoo/core.py
Structure.field_items
def field_items(self, path=str(), **options): """ Returns a **flatten** list of ``('field path', field item)`` tuples for each :class:`Field` *nested* in the `Structure`. :param str path: field path of the `Structure`. :keyword bool nested: if ``True`` all :class:`Pointer` fields in the...
python
def field_items(self, path=str(), **options): """ Returns a **flatten** list of ``('field path', field item)`` tuples for each :class:`Field` *nested* in the `Structure`. :param str path: field path of the `Structure`. :keyword bool nested: if ``True`` all :class:`Pointer` fields in the...
[ "def", "field_items", "(", "self", ",", "path", "=", "str", "(", ")", ",", "*", "*", "options", ")", ":", "parent", "=", "path", "if", "path", "else", "str", "(", ")", "items", "=", "list", "(", ")", "for", "name", ",", "item", "in", "self", "....
Returns a **flatten** list of ``('field path', field item)`` tuples for each :class:`Field` *nested* in the `Structure`. :param str path: field path of the `Structure`. :keyword bool nested: if ``True`` all :class:`Pointer` fields in the :attr:`~Pointer.data` objects of all :class:`...
[ "Returns", "a", "**", "flatten", "**", "list", "of", "(", "field", "path", "field", "item", ")", "tuples", "for", "each", ":", "class", ":", "Field", "*", "nested", "*", "in", "the", "Structure", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L858-L886
train
Returns a list of tuples containing the field path and field item for each nested field in the structure.
JoeVirtual/KonFoo
konfoo/core.py
Structure.describe
def describe(self, name=str(), **options): """ Returns the **metadata** of the `Structure` as an :class:`ordered dictionary <collections.OrderedDict>`. .. code-block:: python metadata = { 'class': self.__class__.__name__, 'name': name if name else se...
python
def describe(self, name=str(), **options): """ Returns the **metadata** of the `Structure` as an :class:`ordered dictionary <collections.OrderedDict>`. .. code-block:: python metadata = { 'class': self.__class__.__name__, 'name': name if name else se...
[ "def", "describe", "(", "self", ",", "name", "=", "str", "(", ")", ",", "*", "*", "options", ")", ":", "members", "=", "list", "(", ")", "metadata", "=", "OrderedDict", "(", ")", "metadata", "[", "'class'", "]", "=", "self", ".", "__class__", ".", ...
Returns the **metadata** of the `Structure` as an :class:`ordered dictionary <collections.OrderedDict>`. .. code-block:: python metadata = { 'class': self.__class__.__name__, 'name': name if name else self.__class__.__name__, 'size': len(self...
[ "Returns", "the", "**", "metadata", "**", "of", "the", "Structure", "as", "an", ":", "class", ":", "ordered", "dictionary", "<collections", ".", "OrderedDict", ">", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L889-L931
train
Returns the metadata of the structure as an ordered dictionary.
JoeVirtual/KonFoo
konfoo/core.py
Sequence.append
def append(self, item): """ Appends the *item* to the end of the `Sequence`. :param item: any :class:`Structure`, :class:`Sequence`, :class:`Array` or :class:`Field` instance. """ if not is_any(item): raise MemberTypeError(self, item, member=len(self)) se...
python
def append(self, item): """ Appends the *item* to the end of the `Sequence`. :param item: any :class:`Structure`, :class:`Sequence`, :class:`Array` or :class:`Field` instance. """ if not is_any(item): raise MemberTypeError(self, item, member=len(self)) se...
[ "def", "append", "(", "self", ",", "item", ")", ":", "if", "not", "is_any", "(", "item", ")", ":", "raise", "MemberTypeError", "(", "self", ",", "item", ",", "member", "=", "len", "(", "self", ")", ")", "self", ".", "_data", ".", "append", "(", "...
Appends the *item* to the end of the `Sequence`. :param item: any :class:`Structure`, :class:`Sequence`, :class:`Array` or :class:`Field` instance.
[ "Appends", "the", "*", "item", "*", "to", "the", "end", "of", "the", "Sequence", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1036-L1044
train
Appends the item to the end of the Sequence.
JoeVirtual/KonFoo
konfoo/core.py
Sequence.insert
def insert(self, index, item): """ Inserts the *item* before the *index* into the `Sequence`. :param int index: `Sequence` index. :param item: any :class:`Structure`, :class:`Sequence`, :class:`Array` or :class:`Field` instance. """ if not is_any(item): r...
python
def insert(self, index, item): """ Inserts the *item* before the *index* into the `Sequence`. :param int index: `Sequence` index. :param item: any :class:`Structure`, :class:`Sequence`, :class:`Array` or :class:`Field` instance. """ if not is_any(item): r...
[ "def", "insert", "(", "self", ",", "index", ",", "item", ")", ":", "if", "not", "is_any", "(", "item", ")", ":", "raise", "MemberTypeError", "(", "self", ",", "item", ",", "member", "=", "len", "(", "self", ")", ")", "self", ".", "_data", ".", "i...
Inserts the *item* before the *index* into the `Sequence`. :param int index: `Sequence` index. :param item: any :class:`Structure`, :class:`Sequence`, :class:`Array` or :class:`Field` instance.
[ "Inserts", "the", "*", "item", "*", "before", "the", "*", "index", "*", "into", "the", "Sequence", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1046-L1055
train
Inserts the item before the index in the Sequence.
JoeVirtual/KonFoo
konfoo/core.py
Sequence.extend
def extend(self, iterable): """ Extends the `Sequence` by appending items from the *iterable*. :param iterable: any *iterable* that contains items of :class:`Structure`, :class:`Sequence`, :class:`Array` or :class:`Field` instances. If the *iterable* is one of these instances it...
python
def extend(self, iterable): """ Extends the `Sequence` by appending items from the *iterable*. :param iterable: any *iterable* that contains items of :class:`Structure`, :class:`Sequence`, :class:`Array` or :class:`Field` instances. If the *iterable* is one of these instances it...
[ "def", "extend", "(", "self", ",", "iterable", ")", ":", "# Sequence", "if", "is_sequence", "(", "iterable", ")", ":", "self", ".", "_data", ".", "extend", "(", "iterable", ")", "# Structure", "elif", "is_structure", "(", "iterable", ")", ":", "members", ...
Extends the `Sequence` by appending items from the *iterable*. :param iterable: any *iterable* that contains items of :class:`Structure`, :class:`Sequence`, :class:`Array` or :class:`Field` instances. If the *iterable* is one of these instances itself then the *iterable* itself ...
[ "Extends", "the", "Sequence", "by", "appending", "items", "from", "the", "*", "iterable", "*", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1080-L1102
train
Extends the Sequence by appending items from the iterable.
JoeVirtual/KonFoo
konfoo/core.py
Sequence.read_from
def read_from(self, provider, **options): """ All :class:`Pointer` fields in the `Sequence` read the necessary number of bytes from the data :class:`Provider` for their referenced :attr:`~Pointer.data` object. Null pointer are ignored. :param Provider provider: data :class:`Provider`. ...
python
def read_from(self, provider, **options): """ All :class:`Pointer` fields in the `Sequence` read the necessary number of bytes from the data :class:`Provider` for their referenced :attr:`~Pointer.data` object. Null pointer are ignored. :param Provider provider: data :class:`Provider`. ...
[ "def", "read_from", "(", "self", ",", "provider", ",", "*", "*", "options", ")", ":", "for", "item", "in", "iter", "(", "self", ")", ":", "# Container or Pointer", "if", "is_mixin", "(", "item", ")", ":", "item", ".", "read_from", "(", "provider", ",",...
All :class:`Pointer` fields in the `Sequence` read the necessary number of bytes from the data :class:`Provider` for their referenced :attr:`~Pointer.data` object. Null pointer are ignored. :param Provider provider: data :class:`Provider`. :keyword bool nested: if ``True`` all :class:`P...
[ "All", ":", "class", ":", "Pointer", "fields", "in", "the", "Sequence", "read", "the", "necessary", "number", "of", "bytes", "from", "the", "data", ":", "class", ":", "Provider", "for", "their", "referenced", ":", "attr", ":", "~Pointer", ".", "data", "o...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1105-L1121
train
Reads the necessary number of bytes from the data provider.
JoeVirtual/KonFoo
konfoo/core.py
Sequence.container_size
def container_size(self): """ Returns the accumulated bit size of all fields in the `Sequence` as a tuple in the form of ``(number of bytes, remaining number of bits)``. """ length = 0 for name, item in enumerate(self): # Container if is_container(item): ...
python
def container_size(self): """ Returns the accumulated bit size of all fields in the `Sequence` as a tuple in the form of ``(number of bytes, remaining number of bits)``. """ length = 0 for name, item in enumerate(self): # Container if is_container(item): ...
[ "def", "container_size", "(", "self", ")", ":", "length", "=", "0", "for", "name", ",", "item", "in", "enumerate", "(", "self", ")", ":", "# Container", "if", "is_container", "(", "item", ")", ":", "byte_length", ",", "bit_length", "=", "item", ".", "c...
Returns the accumulated bit size of all fields in the `Sequence` as a tuple in the form of ``(number of bytes, remaining number of bits)``.
[ "Returns", "the", "accumulated", "bit", "size", "of", "all", "fields", "in", "the", "Sequence", "as", "a", "tuple", "in", "the", "form", "of", "(", "number", "of", "bytes", "remaining", "number", "of", "bits", ")", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1220-L1235
train
Returns the accumulated bit size of all containers and fields in the Sequence as a tuple of number of bytes remaining number of bits.
JoeVirtual/KonFoo
konfoo/core.py
Sequence.first_field
def first_field(self): """ Returns the first :class:`Field` in the `Sequence` or ``None`` for an empty `Sequence`. """ for name, item in enumerate(self): # Container if is_container(item): field = item.first_field() # Container is n...
python
def first_field(self): """ Returns the first :class:`Field` in the `Sequence` or ``None`` for an empty `Sequence`. """ for name, item in enumerate(self): # Container if is_container(item): field = item.first_field() # Container is n...
[ "def", "first_field", "(", "self", ")", ":", "for", "name", ",", "item", "in", "enumerate", "(", "self", ")", ":", "# Container", "if", "is_container", "(", "item", ")", ":", "field", "=", "item", ".", "first_field", "(", ")", "# Container is not empty", ...
Returns the first :class:`Field` in the `Sequence` or ``None`` for an empty `Sequence`.
[ "Returns", "the", "first", ":", "class", ":", "Field", "in", "the", "Sequence", "or", "None", "for", "an", "empty", "Sequence", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1237-L1253
train
Returns the first Field in the Sequence or None if an empty Sequence.
JoeVirtual/KonFoo
konfoo/core.py
Sequence.initialize_fields
def initialize_fields(self, content): """ Initializes the :class:`Field` items in the `Sequence` with the *values* in the *content* list. :param list content: a list contains the :class:`Field` values for each item in the `Sequence`. """ for name, pair in enumerate(z...
python
def initialize_fields(self, content): """ Initializes the :class:`Field` items in the `Sequence` with the *values* in the *content* list. :param list content: a list contains the :class:`Field` values for each item in the `Sequence`. """ for name, pair in enumerate(z...
[ "def", "initialize_fields", "(", "self", ",", "content", ")", ":", "for", "name", ",", "pair", "in", "enumerate", "(", "zip", "(", "self", ",", "content", ")", ")", ":", "item", ",", "value", "=", "pair", "# Container or Pointer", "if", "is_mixin", "(", ...
Initializes the :class:`Field` items in the `Sequence` with the *values* in the *content* list. :param list content: a list contains the :class:`Field` values for each item in the `Sequence`.
[ "Initializes", "the", ":", "class", ":", "Field", "items", "in", "the", "Sequence", "with", "the", "*", "values", "*", "in", "the", "*", "content", "*", "list", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1255-L1271
train
Initializes the fields of the items in the Sequence with the values in the content list.
JoeVirtual/KonFoo
konfoo/core.py
Sequence.view_fields
def view_fields(self, *attributes, **options): """ Returns a list with the selected field *attribute* or a list with the dictionaries of the selected field *attributes* for each :class:`Field` *nested* in the `Sequence`. The *attributes* of each :class:`Field` for containers *nested* in...
python
def view_fields(self, *attributes, **options): """ Returns a list with the selected field *attribute* or a list with the dictionaries of the selected field *attributes* for each :class:`Field` *nested* in the `Sequence`. The *attributes* of each :class:`Field` for containers *nested* in...
[ "def", "view_fields", "(", "self", ",", "*", "attributes", ",", "*", "*", "options", ")", ":", "items", "=", "list", "(", ")", "for", "index", ",", "item", "in", "enumerate", "(", "self", ")", ":", "if", "is_container", "(", "item", ")", ":", "# Co...
Returns a list with the selected field *attribute* or a list with the dictionaries of the selected field *attributes* for each :class:`Field` *nested* in the `Sequence`. The *attributes* of each :class:`Field` for containers *nested* in the `Sequence` are viewed as well (chained method ...
[ "Returns", "a", "list", "with", "the", "selected", "field", "*", "attribute", "*", "or", "a", "list", "with", "the", "dictionaries", "of", "the", "selected", "field", "*", "attributes", "*", "for", "each", ":", "class", ":", "Field", "*", "nested", "*", ...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1274-L1313
train
Returns a list with the selected field attributes or a list with the selected field attributes for each container and nested in the Sequence.
JoeVirtual/KonFoo
konfoo/core.py
Sequence.field_items
def field_items(self, path=str(), **options): """ Returns a **flatten** list of ``('field path', field item)`` tuples for each :class:`Field` *nested* in the `Sequence`. :param str path: field path of the `Sequence`. :keyword bool nested: if ``True`` all :class:`Pointer` fields in the ...
python
def field_items(self, path=str(), **options): """ Returns a **flatten** list of ``('field path', field item)`` tuples for each :class:`Field` *nested* in the `Sequence`. :param str path: field path of the `Sequence`. :keyword bool nested: if ``True`` all :class:`Pointer` fields in the ...
[ "def", "field_items", "(", "self", ",", "path", "=", "str", "(", ")", ",", "*", "*", "options", ")", ":", "items", "=", "list", "(", ")", "for", "index", ",", "item", "in", "enumerate", "(", "self", ")", ":", "if", "path", ":", "item_path", "=", ...
Returns a **flatten** list of ``('field path', field item)`` tuples for each :class:`Field` *nested* in the `Sequence`. :param str path: field path of the `Sequence`. :keyword bool nested: if ``True`` all :class:`Pointer` fields in the :attr:`~Pointer.data` objects of all :class:`Po...
[ "Returns", "a", "**", "flatten", "**", "list", "of", "(", "field", "path", "field", "item", ")", "tuples", "for", "each", ":", "class", ":", "Field", "*", "nested", "*", "in", "the", "Sequence", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1316-L1345
train
Returns a list of tuples containing the field items for each field in the sequence.
JoeVirtual/KonFoo
konfoo/core.py
Array.resize
def resize(self, capacity): """ Re-sizes the `Array` by appending new *array elements* or removing *array elements* from the end. :param int capacity: new capacity of the `Array` in number of *array elements*. """ count = max(int(capacity), 0) - len(self) if count == 0:...
python
def resize(self, capacity): """ Re-sizes the `Array` by appending new *array elements* or removing *array elements* from the end. :param int capacity: new capacity of the `Array` in number of *array elements*. """ count = max(int(capacity), 0) - len(self) if count == 0:...
[ "def", "resize", "(", "self", ",", "capacity", ")", ":", "count", "=", "max", "(", "int", "(", "capacity", ")", ",", "0", ")", "-", "len", "(", "self", ")", "if", "count", "==", "0", ":", "pass", "elif", "-", "count", "==", "len", "(", "self", ...
Re-sizes the `Array` by appending new *array elements* or removing *array elements* from the end. :param int capacity: new capacity of the `Array` in number of *array elements*.
[ "Re", "-", "sizes", "the", "Array", "by", "appending", "new", "*", "array", "elements", "*", "or", "removing", "*", "array", "elements", "*", "from", "the", "end", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1472-L1489
train
Re - sizes the array by appending new array elements to the end.
JoeVirtual/KonFoo
konfoo/core.py
Array.initialize_fields
def initialize_fields(self, content): """ Initializes the :class:`Field` elements in the `Array` with the *values* in the *content* list. If the *content* list is shorter than the `Array` then the *content* list is used as a rotating fill pattern for the :class:`Field` elements ...
python
def initialize_fields(self, content): """ Initializes the :class:`Field` elements in the `Array` with the *values* in the *content* list. If the *content* list is shorter than the `Array` then the *content* list is used as a rotating fill pattern for the :class:`Field` elements ...
[ "def", "initialize_fields", "(", "self", ",", "content", ")", ":", "if", "isinstance", "(", "content", ",", "(", "list", ",", "tuple", ")", ")", ":", "capacity", "=", "len", "(", "content", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(",...
Initializes the :class:`Field` elements in the `Array` with the *values* in the *content* list. If the *content* list is shorter than the `Array` then the *content* list is used as a rotating fill pattern for the :class:`Field` elements in the `Array`. :param list content: a li...
[ "Initializes", "the", ":", "class", ":", "Field", "elements", "in", "the", "Array", "with", "the", "*", "values", "*", "in", "the", "*", "content", "*", "list", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1491-L1528
train
Initializes the fields of the Entry objects in the array with the values in the content list.
JoeVirtual/KonFoo
konfoo/core.py
Field.deserialize
def deserialize(self, buffer=bytes(), index=Index(), **options): """ De-serializes the `Field` from the byte *buffer* starting at the begin of the *buffer* or with the given *index* by unpacking the bytes to the :attr:`value` of the `Field` in accordance with the decoding *byte order* fo...
python
def deserialize(self, buffer=bytes(), index=Index(), **options): """ De-serializes the `Field` from the byte *buffer* starting at the begin of the *buffer* or with the given *index* by unpacking the bytes to the :attr:`value` of the `Field` in accordance with the decoding *byte order* fo...
[ "def", "deserialize", "(", "self", ",", "buffer", "=", "bytes", "(", ")", ",", "index", "=", "Index", "(", ")", ",", "*", "*", "options", ")", ":", "self", ".", "index", "=", "index", "self", ".", "_value", "=", "self", ".", "unpack", "(", "buffe...
De-serializes the `Field` from the byte *buffer* starting at the begin of the *buffer* or with the given *index* by unpacking the bytes to the :attr:`value` of the `Field` in accordance with the decoding *byte order* for the de-serialization and the decoding :attr:`byte_order` of the `Fi...
[ "De", "-", "serializes", "the", "Field", "from", "the", "byte", "*", "buffer", "*", "starting", "at", "the", "begin", "of", "the", "*", "buffer", "*", "or", "with", "the", "given", "*", "index", "*", "by", "unpacking", "the", "bytes", "to", "the", ":...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1746-L1774
train
Deserializes the object from the given byte stream.
JoeVirtual/KonFoo
konfoo/core.py
Field.serialize
def serialize(self, buffer=bytearray(), index=Index(), **options): """ Serializes the `Field` to the byte *buffer* starting at the begin of the *buffer* or with the given *index* by packing the :attr:`value` of the `Field` to the byte *buffer* in accordance with the encoding *byte order*...
python
def serialize(self, buffer=bytearray(), index=Index(), **options): """ Serializes the `Field` to the byte *buffer* starting at the begin of the *buffer* or with the given *index* by packing the :attr:`value` of the `Field` to the byte *buffer* in accordance with the encoding *byte order*...
[ "def", "serialize", "(", "self", ",", "buffer", "=", "bytearray", "(", ")", ",", "index", "=", "Index", "(", ")", ",", "*", "*", "options", ")", ":", "self", ".", "index", "=", "index", "buffer", "+=", "self", ".", "pack", "(", "buffer", ",", "*"...
Serializes the `Field` to the byte *buffer* starting at the begin of the *buffer* or with the given *index* by packing the :attr:`value` of the `Field` to the byte *buffer* in accordance with the encoding *byte order* for the serialization and the encoding :attr:`byte_order` of the `Fiel...
[ "Serializes", "the", "Field", "to", "the", "byte", "*", "buffer", "*", "starting", "at", "the", "begin", "of", "the", "*", "buffer", "*", "or", "with", "the", "given", "*", "index", "*", "by", "packing", "the", ":", "attr", ":", "value", "of", "the",...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1778-L1805
train
Serializes the object into a byte stream.
JoeVirtual/KonFoo
konfoo/core.py
Field.index_field
def index_field(self, index=Index()): """ Indexes the `Field` with the given *index* und returns the :class:`Index` after the `Field`. :param Index index: start :class:`Index` for the `Field`. """ # Set field index # Note: Updates the field alignment offset as well ...
python
def index_field(self, index=Index()): """ Indexes the `Field` with the given *index* und returns the :class:`Index` after the `Field`. :param Index index: start :class:`Index` for the `Field`. """ # Set field index # Note: Updates the field alignment offset as well ...
[ "def", "index_field", "(", "self", ",", "index", "=", "Index", "(", ")", ")", ":", "# Set field index", "# Note: Updates the field alignment offset as well", "self", ".", "index", "=", "index", "# Bit offset for the next field", "byte", ",", "bit", ",", "address", "...
Indexes the `Field` with the given *index* und returns the :class:`Index` after the `Field`. :param Index index: start :class:`Index` for the `Field`.
[ "Indexes", "the", "Field", "with", "the", "given", "*", "index", "*", "und", "returns", "the", ":", "class", ":", "Index", "after", "the", "Field", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1807-L1839
train
Returns the index after the Field with the given index.
JoeVirtual/KonFoo
konfoo/core.py
Field.describe
def describe(self, name=str(), **options): """ Returns the **metadata** of a `Field` as an :class:`ordered dictionary <collections.OrderedDict>`. .. code-block:: python metadata = { 'address': self.index.address, 'alignment': [self.alignment.byte_siz...
python
def describe(self, name=str(), **options): """ Returns the **metadata** of a `Field` as an :class:`ordered dictionary <collections.OrderedDict>`. .. code-block:: python metadata = { 'address': self.index.address, 'alignment': [self.alignment.byte_siz...
[ "def", "describe", "(", "self", ",", "name", "=", "str", "(", ")", ",", "*", "*", "options", ")", ":", "metadata", "=", "{", "'address'", ":", "self", ".", "index", ".", "address", ",", "'alignment'", ":", "list", "(", "self", ".", "alignment", ")"...
Returns the **metadata** of a `Field` as an :class:`ordered dictionary <collections.OrderedDict>`. .. code-block:: python metadata = { 'address': self.index.address, 'alignment': [self.alignment.byte_size, self.alignment.bit_offset], 'class':...
[ "Returns", "the", "**", "metadata", "**", "of", "a", "Field", "as", "an", ":", "class", ":", "ordered", "dictionary", "<collections", ".", "OrderedDict", ">", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L1842-L1877
train
Returns the metadata of a field as an OrderedDict.
JoeVirtual/KonFoo
konfoo/core.py
Stream.name
def name(self): """ Returns the type name of the `Stream` field (read-only).""" size = len(self) if size > 0: return self.item_type.name.capitalize() + str(size) else: return self.item_type.name.capitalize()
python
def name(self): """ Returns the type name of the `Stream` field (read-only).""" size = len(self) if size > 0: return self.item_type.name.capitalize() + str(size) else: return self.item_type.name.capitalize()
[ "def", "name", "(", "self", ")", ":", "size", "=", "len", "(", "self", ")", "if", "size", ">", "0", ":", "return", "self", ".", "item_type", ".", "name", ".", "capitalize", "(", ")", "+", "str", "(", "size", ")", "else", ":", "return", "self", ...
Returns the type name of the `Stream` field (read-only).
[ "Returns", "the", "type", "name", "of", "the", "Stream", "field", "(", "read", "-", "only", ")", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L2000-L2006
train
Returns the type name of the Stream field ( read - only.
JoeVirtual/KonFoo
konfoo/core.py
Stream.resize
def resize(self, size): """ Re-sizes the `Stream` field by appending zero bytes or removing bytes from the end. :param int size: `Stream` size in number of bytes. """ count = max(int(size), 0) - len(self) if count == 0: pass elif -count == len(self):...
python
def resize(self, size): """ Re-sizes the `Stream` field by appending zero bytes or removing bytes from the end. :param int size: `Stream` size in number of bytes. """ count = max(int(size), 0) - len(self) if count == 0: pass elif -count == len(self):...
[ "def", "resize", "(", "self", ",", "size", ")", ":", "count", "=", "max", "(", "int", "(", "size", ")", ",", "0", ")", "-", "len", "(", "self", ")", "if", "count", "==", "0", ":", "pass", "elif", "-", "count", "==", "len", "(", "self", ")", ...
Re-sizes the `Stream` field by appending zero bytes or removing bytes from the end. :param int size: `Stream` size in number of bytes.
[ "Re", "-", "sizes", "the", "Stream", "field", "by", "appending", "zero", "bytes", "or", "removing", "bytes", "from", "the", "end", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L2064-L2082
train
Re - sizes the stream field by appending zero bytes or removing bytes from the end.
JoeVirtual/KonFoo
konfoo/core.py
String.value
def value(self): """ Field value as an ascii encoded string.""" length = self._value.find(b'\x00') if length >= 0: return self._value[:length].decode('ascii') else: return self._value.decode('ascii')
python
def value(self): """ Field value as an ascii encoded string.""" length = self._value.find(b'\x00') if length >= 0: return self._value[:length].decode('ascii') else: return self._value.decode('ascii')
[ "def", "value", "(", "self", ")", ":", "length", "=", "self", ".", "_value", ".", "find", "(", "b'\\x00'", ")", "if", "length", ">=", "0", ":", "return", "self", ".", "_value", "[", ":", "length", "]", ".", "decode", "(", "'ascii'", ")", "else", ...
Field value as an ascii encoded string.
[ "Field", "value", "as", "an", "ascii", "encoded", "string", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L2188-L2194
train
Field value as an ascii encoded string.
JoeVirtual/KonFoo
konfoo/core.py
Decimal._set_alignment
def _set_alignment(self, group_size, bit_offset=0, auto_align=False): """ Sets the alignment of the ``Decimal`` field. :param int group_size: size of the aligned `Field` group in bytes, can be between ``1`` and ``8``. :param int bit_offset: bit offset of the `Decimal` field within t...
python
def _set_alignment(self, group_size, bit_offset=0, auto_align=False): """ Sets the alignment of the ``Decimal`` field. :param int group_size: size of the aligned `Field` group in bytes, can be between ``1`` and ``8``. :param int bit_offset: bit offset of the `Decimal` field within t...
[ "def", "_set_alignment", "(", "self", ",", "group_size", ",", "bit_offset", "=", "0", ",", "auto_align", "=", "False", ")", ":", "# Field alignment offset", "field_offset", "=", "int", "(", "bit_offset", ")", "# Auto alignment", "if", "auto_align", ":", "# Field...
Sets the alignment of the ``Decimal`` field. :param int group_size: size of the aligned `Field` group in bytes, can be between ``1`` and ``8``. :param int bit_offset: bit offset of the `Decimal` field within the aligned `Field` group, can be between ``0`` and ``63``. :pa...
[ "Sets", "the", "alignment", "of", "the", "Decimal", "field", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L2647-L2690
train
Sets the alignment of the log entry.
JoeVirtual/KonFoo
konfoo/core.py
Decimal._set_bit_size
def _set_bit_size(self, size, step=1, auto_align=False): """ Sets the *size* of the `Decimal` field. :param int size: is the *size* of the `Decimal` field in bits, can be between ``1`` and ``64``. :param int step: is the minimal required step *size* for the `Decimal` fie...
python
def _set_bit_size(self, size, step=1, auto_align=False): """ Sets the *size* of the `Decimal` field. :param int size: is the *size* of the `Decimal` field in bits, can be between ``1`` and ``64``. :param int step: is the minimal required step *size* for the `Decimal` fie...
[ "def", "_set_bit_size", "(", "self", ",", "size", ",", "step", "=", "1", ",", "auto_align", "=", "False", ")", ":", "# Field size", "bit_size", "=", "int", "(", "size", ")", "# Invalid field size", "if", "bit_size", "%", "step", "!=", "0", "or", "not", ...
Sets the *size* of the `Decimal` field. :param int size: is the *size* of the `Decimal` field in bits, can be between ``1`` and ``64``. :param int step: is the minimal required step *size* for the `Decimal` field in bits. :param bool auto_align: if ``True`` the `Decimal`...
[ "Sets", "the", "*", "size", "*", "of", "the", "Decimal", "field", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L2692-L2724
train
Sets the bit size of the record.
JoeVirtual/KonFoo
konfoo/core.py
Decimal.as_unsigned
def as_unsigned(self): """ Returns the field *value* of the `Decimal` field as an unsigned integer.""" return self._cast(self._value, self._min(False), self._max(False), False)
python
def as_unsigned(self): """ Returns the field *value* of the `Decimal` field as an unsigned integer.""" return self._cast(self._value, self._min(False), self._max(False), False)
[ "def", "as_unsigned", "(", "self", ")", ":", "return", "self", ".", "_cast", "(", "self", ".", "_value", ",", "self", ".", "_min", "(", "False", ")", ",", "self", ".", "_max", "(", "False", ")", ",", "False", ")" ]
Returns the field *value* of the `Decimal` field as an unsigned integer.
[ "Returns", "the", "field", "*", "value", "*", "of", "the", "Decimal", "field", "as", "an", "unsigned", "integer", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L2760-L2762
train
Returns the field value of the Decimal field as an unsigned integer.
JoeVirtual/KonFoo
konfoo/core.py
Decimal.as_signed
def as_signed(self): """ Returns the field *value* of the `Decimal` field as a signed integer.""" return self._cast(self._value, self._min(True), self._max(True), True)
python
def as_signed(self): """ Returns the field *value* of the `Decimal` field as a signed integer.""" return self._cast(self._value, self._min(True), self._max(True), True)
[ "def", "as_signed", "(", "self", ")", ":", "return", "self", ".", "_cast", "(", "self", ".", "_value", ",", "self", ".", "_min", "(", "True", ")", ",", "self", ".", "_max", "(", "True", ")", ",", "True", ")" ]
Returns the field *value* of the `Decimal` field as a signed integer.
[ "Returns", "the", "field", "*", "value", "*", "of", "the", "Decimal", "field", "as", "a", "signed", "integer", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L2764-L2766
train
Returns the field value of the Decimal field as a signed integer.
JoeVirtual/KonFoo
konfoo/core.py
Enum.value
def value(self): """ Field value as an enum name string. Fall back is an unsigned integer number.""" if self._enum and issubclass(self._enum, Enumeration): name = self._enum.get_name(self._value) if name: return name return self._value
python
def value(self): """ Field value as an enum name string. Fall back is an unsigned integer number.""" if self._enum and issubclass(self._enum, Enumeration): name = self._enum.get_name(self._value) if name: return name return self._value
[ "def", "value", "(", "self", ")", ":", "if", "self", ".", "_enum", "and", "issubclass", "(", "self", ".", "_enum", ",", "Enumeration", ")", ":", "name", "=", "self", ".", "_enum", ".", "get_name", "(", "self", ".", "_value", ")", "if", "name", ":",...
Field value as an enum name string. Fall back is an unsigned integer number.
[ "Field", "value", "as", "an", "enum", "name", "string", ".", "Fall", "back", "is", "an", "unsigned", "integer", "number", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L3761-L3767
train
Field value as an enum name string. Fall back is an unsigned integer number. Fall back is an unsigned integer number. Fall back is an unsigned integer number. Fall back is an unsigned integer number.
JoeVirtual/KonFoo
konfoo/core.py
Fraction.name
def name(self): """ Returns the type name of the `Fraction` field (read-only).""" return "{0}{1}.{2}".format(self.item_type.name.capitalize(), self._bits_integer, self.bit_size)
python
def name(self): """ Returns the type name of the `Fraction` field (read-only).""" return "{0}{1}.{2}".format(self.item_type.name.capitalize(), self._bits_integer, self.bit_size)
[ "def", "name", "(", "self", ")", ":", "return", "\"{0}{1}.{2}\"", ".", "format", "(", "self", ".", "item_type", ".", "name", ".", "capitalize", "(", ")", ",", "self", ".", "_bits_integer", ",", "self", ".", "bit_size", ")" ]
Returns the type name of the `Fraction` field (read-only).
[ "Returns", "the", "type", "name", "of", "the", "Fraction", "field", "(", "read", "-", "only", ")", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L4173-L4177
train
Returns the name of the Fraction field ( read - only.
JoeVirtual/KonFoo
konfoo/core.py
Pointer.data_size
def data_size(self): """ Returns the size of the :attr:`data` object in bytes (read-only).""" # Container if is_container(self._data): byte_length, bit_length = self._data.container_size() return byte_length + math.ceil(bit_length / 8) # Field elif is_fiel...
python
def data_size(self): """ Returns the size of the :attr:`data` object in bytes (read-only).""" # Container if is_container(self._data): byte_length, bit_length = self._data.container_size() return byte_length + math.ceil(bit_length / 8) # Field elif is_fiel...
[ "def", "data_size", "(", "self", ")", ":", "# Container", "if", "is_container", "(", "self", ".", "_data", ")", ":", "byte_length", ",", "bit_length", "=", "self", ".", "_data", ".", "container_size", "(", ")", "return", "byte_length", "+", "math", ".", ...
Returns the size of the :attr:`data` object in bytes (read-only).
[ "Returns", "the", "size", "of", "the", ":", "attr", ":", "data", "object", "in", "bytes", "(", "read", "-", "only", ")", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L4908-L4918
train
Returns the size of the data object in bytes.
JoeVirtual/KonFoo
konfoo/core.py
Pointer.deserialize_data
def deserialize_data(self, buffer=bytes(), byte_order=None): """ De-serializes the :attr:`data` object referenced by the `Pointer` field from the byte *buffer* by mapping the bytes to the :attr:`~Field.value` for each :class:`Field` in the :attr:`data` object in accordance with the decod...
python
def deserialize_data(self, buffer=bytes(), byte_order=None): """ De-serializes the :attr:`data` object referenced by the `Pointer` field from the byte *buffer* by mapping the bytes to the :attr:`~Field.value` for each :class:`Field` in the :attr:`data` object in accordance with the decod...
[ "def", "deserialize_data", "(", "self", ",", "buffer", "=", "bytes", "(", ")", ",", "byte_order", "=", "None", ")", ":", "index", "=", "Index", "(", "0", ",", "0", ",", "self", ".", "address", ",", "self", ".", "base_address", ",", "False", ")", "i...
De-serializes the :attr:`data` object referenced by the `Pointer` field from the byte *buffer* by mapping the bytes to the :attr:`~Field.value` for each :class:`Field` in the :attr:`data` object in accordance with the decoding *byte order* for the de-serialization and the decoding :attr:...
[ "De", "-", "serializes", "the", ":", "attr", ":", "data", "object", "referenced", "by", "the", "Pointer", "field", "from", "the", "byte", "*", "buffer", "*", "by", "mapping", "the", "bytes", "to", "the", ":", "attr", ":", "~Field", ".", "value", "for",...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L4938-L4967
train
Deserializes the data of the internal object referenced by the Pointer field into a new index.
JoeVirtual/KonFoo
konfoo/core.py
Pointer.serialize_data
def serialize_data(self, byte_order=None): """ Serializes the :attr:`data` object referenced by the `Pointer` field to bytes by mapping the :attr:`~Field.value` for each :class:`Field` in the :attr:`data` object to a number of bytes in accordance with the encoding *byte order* for the se...
python
def serialize_data(self, byte_order=None): """ Serializes the :attr:`data` object referenced by the `Pointer` field to bytes by mapping the :attr:`~Field.value` for each :class:`Field` in the :attr:`data` object to a number of bytes in accordance with the encoding *byte order* for the se...
[ "def", "serialize_data", "(", "self", ",", "byte_order", "=", "None", ")", ":", "if", "self", ".", "_data", "is", "None", ":", "return", "bytes", "(", ")", "if", "byte_order", "not", "in", "(", "'little'", ",", "'big'", ",", "Byteorder", ".", "little",...
Serializes the :attr:`data` object referenced by the `Pointer` field to bytes by mapping the :attr:`~Field.value` for each :class:`Field` in the :attr:`data` object to a number of bytes in accordance with the encoding *byte order* for the serialization and the encoding :attr:`byte_order`...
[ "Serializes", "the", ":", "attr", ":", "data", "object", "referenced", "by", "the", "Pointer", "field", "to", "bytes", "by", "mapping", "the", ":", "attr", ":", "~Field", ".", "value", "for", "each", ":", "class", ":", "Field", "in", "the", ":", "attr"...
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L4969-L4997
train
Serializes the data of the object to bytes by mapping the value of each field to the number of bytes required by the serialization.
JoeVirtual/KonFoo
konfoo/core.py
Pointer.index_data
def index_data(self): """ Indexes each :class:`Field` in the :attr:`data` object referenced by the `Pointer` field. """ # Start index for the Data Object index = Index(0, 0, self.address, self.base_address, False) # Container if is_container(self._data): ...
python
def index_data(self): """ Indexes each :class:`Field` in the :attr:`data` object referenced by the `Pointer` field. """ # Start index for the Data Object index = Index(0, 0, self.address, self.base_address, False) # Container if is_container(self._data): ...
[ "def", "index_data", "(", "self", ")", ":", "# Start index for the Data Object", "index", "=", "Index", "(", "0", ",", "0", ",", "self", ".", "address", ",", "self", ".", "base_address", ",", "False", ")", "# Container", "if", "is_container", "(", "self", ...
Indexes each :class:`Field` in the :attr:`data` object referenced by the `Pointer` field.
[ "Indexes", "each", ":", "class", ":", "Field", "in", "the", ":", "attr", ":", "data", "object", "referenced", "by", "the", "Pointer", "field", "." ]
0c62ef5c2bed4deaf908b34082e4de2544532fdc
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L4999-L5014
train
Indexes each Field in the data object referenced by the Pointer field.