repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
libChEBI/libChEBIpy
libchebipy/_parsers.py
__parse_chemical_data
def __parse_chemical_data(): '''Gets and parses file''' filename = get_file('chemical_data.tsv') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') if tokens[3] == 'FORMULA': ...
python
def __parse_chemical_data(): '''Gets and parses file''' filename = get_file('chemical_data.tsv') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') if tokens[3] == 'FORMULA': ...
[ "def", "__parse_chemical_data", "(", ")", ":", "filename", "=", "get_file", "(", "'chemical_data.tsv'", ")", "with", "io", ".", "open", "(", "filename", ",", "'r'", ",", "encoding", "=", "'cp1252'", ")", "as", "textfile", ":", "next", "(", "textfile", ")",...
Gets and parses file
[ "Gets", "and", "parses", "file" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L99-L127
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_all_comments
def get_all_comments(chebi_ids): '''Returns all comments''' all_comments = [get_comments(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_comments for x in sublist]
python
def get_all_comments(chebi_ids): '''Returns all comments''' all_comments = [get_comments(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_comments for x in sublist]
[ "def", "get_all_comments", "(", "chebi_ids", ")", ":", "all_comments", "=", "[", "get_comments", "(", "chebi_id", ")", "for", "chebi_id", "in", "chebi_ids", "]", "return", "[", "x", "for", "sublist", "in", "all_comments", "for", "x", "in", "sublist", "]" ]
Returns all comments
[ "Returns", "all", "comments" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L138-L141
libChEBI/libChEBIpy
libchebipy/_parsers.py
__parse_comments
def __parse_comments(): '''Gets and parses file''' filename = get_file('comments.tsv') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') chebi_id = int(tokens[1]) if chebi_...
python
def __parse_comments(): '''Gets and parses file''' filename = get_file('comments.tsv') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') chebi_id = int(tokens[1]) if chebi_...
[ "def", "__parse_comments", "(", ")", ":", "filename", "=", "get_file", "(", "'comments.tsv'", ")", "with", "io", ".", "open", "(", "filename", ",", "'r'", ",", "encoding", "=", "'cp1252'", ")", "as", "textfile", ":", "next", "(", "textfile", ")", "for", ...
Gets and parses file
[ "Gets", "and", "parses", "file" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L144-L164
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_all_compound_origins
def get_all_compound_origins(chebi_ids): '''Returns all compound origins''' all_compound_origins = [get_compound_origins(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_compound_origins for x in sublist]
python
def get_all_compound_origins(chebi_ids): '''Returns all compound origins''' all_compound_origins = [get_compound_origins(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_compound_origins for x in sublist]
[ "def", "get_all_compound_origins", "(", "chebi_ids", ")", ":", "all_compound_origins", "=", "[", "get_compound_origins", "(", "chebi_id", ")", "for", "chebi_id", "in", "chebi_ids", "]", "return", "[", "x", "for", "sublist", "in", "all_compound_origins", "for", "x"...
Returns all compound origins
[ "Returns", "all", "compound", "origins" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L175-L179
libChEBI/libChEBIpy
libchebipy/_parsers.py
__parse_compound_origins
def __parse_compound_origins(): '''Gets and parses file''' filename = get_file('compound_origins.tsv') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') if len(tokens) > 10: ...
python
def __parse_compound_origins(): '''Gets and parses file''' filename = get_file('compound_origins.tsv') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') if len(tokens) > 10: ...
[ "def", "__parse_compound_origins", "(", ")", ":", "filename", "=", "get_file", "(", "'compound_origins.tsv'", ")", "with", "io", ".", "open", "(", "filename", ",", "'r'", ",", "encoding", "=", "'cp1252'", ")", "as", "textfile", ":", "next", "(", "textfile", ...
Gets and parses file
[ "Gets", "and", "parses", "file" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L182-L204
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_parent_id
def get_parent_id(chebi_id): '''Returns parent id''' if len(__PARENT_IDS) == 0: __parse_compounds() return __PARENT_IDS[chebi_id] if chebi_id in __PARENT_IDS else float('NaN')
python
def get_parent_id(chebi_id): '''Returns parent id''' if len(__PARENT_IDS) == 0: __parse_compounds() return __PARENT_IDS[chebi_id] if chebi_id in __PARENT_IDS else float('NaN')
[ "def", "get_parent_id", "(", "chebi_id", ")", ":", "if", "len", "(", "__PARENT_IDS", ")", "==", "0", ":", "__parse_compounds", "(", ")", "return", "__PARENT_IDS", "[", "chebi_id", "]", "if", "chebi_id", "in", "__PARENT_IDS", "else", "float", "(", "'NaN'", ...
Returns parent id
[ "Returns", "parent", "id" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L223-L228
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_all_modified_on
def get_all_modified_on(chebi_ids): '''Returns all modified on''' all_modified_ons = [get_modified_on(chebi_id) for chebi_id in chebi_ids] all_modified_ons = [modified_on for modified_on in all_modified_ons if modified_on is not None] return None if len(all_modified_ons) == 0 els...
python
def get_all_modified_on(chebi_ids): '''Returns all modified on''' all_modified_ons = [get_modified_on(chebi_id) for chebi_id in chebi_ids] all_modified_ons = [modified_on for modified_on in all_modified_ons if modified_on is not None] return None if len(all_modified_ons) == 0 els...
[ "def", "get_all_modified_on", "(", "chebi_ids", ")", ":", "all_modified_ons", "=", "[", "get_modified_on", "(", "chebi_id", ")", "for", "chebi_id", "in", "chebi_ids", "]", "all_modified_ons", "=", "[", "modified_on", "for", "modified_on", "in", "all_modified_ons", ...
Returns all modified on
[ "Returns", "all", "modified", "on" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L263-L268
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_star
def get_star(chebi_id): '''Returns created by''' if len(__STARS) == 0: __parse_compounds() return __STARS[chebi_id] if chebi_id in __STARS else float('NaN')
python
def get_star(chebi_id): '''Returns created by''' if len(__STARS) == 0: __parse_compounds() return __STARS[chebi_id] if chebi_id in __STARS else float('NaN')
[ "def", "get_star", "(", "chebi_id", ")", ":", "if", "len", "(", "__STARS", ")", "==", "0", ":", "__parse_compounds", "(", ")", "return", "__STARS", "[", "chebi_id", "]", "if", "chebi_id", "in", "__STARS", "else", "float", "(", "'NaN'", ")" ]
Returns created by
[ "Returns", "created", "by" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L279-L284
libChEBI/libChEBIpy
libchebipy/_parsers.py
__parse_compounds
def __parse_compounds(): '''Gets and parses file''' filename = get_file('compounds.tsv.gz') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') chebi_id = int(tokens[0]) __ST...
python
def __parse_compounds(): '''Gets and parses file''' filename = get_file('compounds.tsv.gz') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') chebi_id = int(tokens[0]) __ST...
[ "def", "__parse_compounds", "(", ")", ":", "filename", "=", "get_file", "(", "'compounds.tsv.gz'", ")", "with", "io", ".", "open", "(", "filename", ",", "'r'", ",", "encoding", "=", "'cp1252'", ")", "as", "textfile", ":", "next", "(", "textfile", ")", "f...
Gets and parses file
[ "Gets", "and", "parses", "file" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L287-L320
libChEBI/libChEBIpy
libchebipy/_parsers.py
__put_all_ids
def __put_all_ids(parent_id, child_id): '''COMMENT''' if parent_id in __ALL_IDS: __ALL_IDS[parent_id].append(child_id) else: __ALL_IDS[parent_id] = [child_id]
python
def __put_all_ids(parent_id, child_id): '''COMMENT''' if parent_id in __ALL_IDS: __ALL_IDS[parent_id].append(child_id) else: __ALL_IDS[parent_id] = [child_id]
[ "def", "__put_all_ids", "(", "parent_id", ",", "child_id", ")", ":", "if", "parent_id", "in", "__ALL_IDS", ":", "__ALL_IDS", "[", "parent_id", "]", ".", "append", "(", "child_id", ")", "else", ":", "__ALL_IDS", "[", "parent_id", "]", "=", "[", "child_id", ...
COMMENT
[ "COMMENT" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L323-L328
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_all_database_accessions
def get_all_database_accessions(chebi_ids): '''Returns all database accessions''' all_database_accessions = [get_database_accessions(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_database_accessions for x in sublist]
python
def get_all_database_accessions(chebi_ids): '''Returns all database accessions''' all_database_accessions = [get_database_accessions(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_database_accessions for x in sublist]
[ "def", "get_all_database_accessions", "(", "chebi_ids", ")", ":", "all_database_accessions", "=", "[", "get_database_accessions", "(", "chebi_id", ")", "for", "chebi_id", "in", "chebi_ids", "]", "return", "[", "x", "for", "sublist", "in", "all_database_accessions", ...
Returns all database accessions
[ "Returns", "all", "database", "accessions" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L340-L344
libChEBI/libChEBIpy
libchebipy/_parsers.py
__parse_database_accessions
def __parse_database_accessions(): '''Gets and parses file''' filename = get_file('database_accession.tsv') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') chebi_id = int(tokens[1]) ...
python
def __parse_database_accessions(): '''Gets and parses file''' filename = get_file('database_accession.tsv') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') chebi_id = int(tokens[1]) ...
[ "def", "__parse_database_accessions", "(", ")", ":", "filename", "=", "get_file", "(", "'database_accession.tsv'", ")", "with", "io", ".", "open", "(", "filename", ",", "'r'", ",", "encoding", "=", "'cp1252'", ")", "as", "textfile", ":", "next", "(", "textfi...
Gets and parses file
[ "Gets", "and", "parses", "file" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L347-L364
libChEBI/libChEBIpy
libchebipy/_parsers.py
__parse_inchi
def __parse_inchi(): '''Gets and parses file''' filename = get_file('chebiId_inchi.tsv') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') __INCHIS[int(tokens[0])] = tokens[1]
python
def __parse_inchi(): '''Gets and parses file''' filename = get_file('chebiId_inchi.tsv') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') __INCHIS[int(tokens[0])] = tokens[1]
[ "def", "__parse_inchi", "(", ")", ":", "filename", "=", "get_file", "(", "'chebiId_inchi.tsv'", ")", "with", "io", ".", "open", "(", "filename", ",", "'r'", ",", "encoding", "=", "'cp1252'", ")", "as", "textfile", ":", "next", "(", "textfile", ")", "for"...
Gets and parses file
[ "Gets", "and", "parses", "file" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L375-L384
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_all_names
def get_all_names(chebi_ids): '''Returns all names''' all_names = [get_names(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_names for x in sublist]
python
def get_all_names(chebi_ids): '''Returns all names''' all_names = [get_names(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_names for x in sublist]
[ "def", "get_all_names", "(", "chebi_ids", ")", ":", "all_names", "=", "[", "get_names", "(", "chebi_id", ")", "for", "chebi_id", "in", "chebi_ids", "]", "return", "[", "x", "for", "sublist", "in", "all_names", "for", "x", "in", "sublist", "]" ]
Returns all names
[ "Returns", "all", "names" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L395-L398
libChEBI/libChEBIpy
libchebipy/_parsers.py
__parse_names
def __parse_names(): '''Gets and parses file''' filename = get_file('names.tsv.gz') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') chebi_id = int(tokens[1]) if chebi_id ...
python
def __parse_names(): '''Gets and parses file''' filename = get_file('names.tsv.gz') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split('\t') chebi_id = int(tokens[1]) if chebi_id ...
[ "def", "__parse_names", "(", ")", ":", "filename", "=", "get_file", "(", "'names.tsv.gz'", ")", "with", "io", ".", "open", "(", "filename", ",", "'r'", ",", "encoding", "=", "'cp1252'", ")", "as", "textfile", ":", "next", "(", "textfile", ")", "for", "...
Gets and parses file
[ "Gets", "and", "parses", "file" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L401-L422
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_references
def get_references(chebi_ids): '''Returns references''' references = [] chebi_ids = [str(chebi_id) for chebi_id in chebi_ids] filename = get_file('reference.tsv.gz') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens...
python
def get_references(chebi_ids): '''Returns references''' references = [] chebi_ids = [str(chebi_id) for chebi_id in chebi_ids] filename = get_file('reference.tsv.gz') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens...
[ "def", "get_references", "(", "chebi_ids", ")", ":", "references", "=", "[", "]", "chebi_ids", "=", "[", "str", "(", "chebi_id", ")", "for", "chebi_id", "in", "chebi_ids", "]", "filename", "=", "get_file", "(", "'reference.tsv.gz'", ")", "with", "io", ".",...
Returns references
[ "Returns", "references" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L425-L447
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_all_outgoings
def get_all_outgoings(chebi_ids): '''Returns all outgoings''' all_outgoings = [get_outgoings(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_outgoings for x in sublist]
python
def get_all_outgoings(chebi_ids): '''Returns all outgoings''' all_outgoings = [get_outgoings(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_outgoings for x in sublist]
[ "def", "get_all_outgoings", "(", "chebi_ids", ")", ":", "all_outgoings", "=", "[", "get_outgoings", "(", "chebi_id", ")", "for", "chebi_id", "in", "chebi_ids", "]", "return", "[", "x", "for", "sublist", "in", "all_outgoings", "for", "x", "in", "sublist", "]"...
Returns all outgoings
[ "Returns", "all", "outgoings" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L458-L461
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_all_incomings
def get_all_incomings(chebi_ids): '''Returns all incomings''' all_incomings = [get_incomings(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_incomings for x in sublist]
python
def get_all_incomings(chebi_ids): '''Returns all incomings''' all_incomings = [get_incomings(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_incomings for x in sublist]
[ "def", "get_all_incomings", "(", "chebi_ids", ")", ":", "all_incomings", "=", "[", "get_incomings", "(", "chebi_id", ")", "for", "chebi_id", "in", "chebi_ids", "]", "return", "[", "x", "for", "sublist", "in", "all_incomings", "for", "x", "in", "sublist", "]"...
Returns all incomings
[ "Returns", "all", "incomings" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L472-L475
libChEBI/libChEBIpy
libchebipy/_parsers.py
__parse_relation
def __parse_relation(): '''Gets and parses file''' relation_filename = get_file('relation.tsv') vertice_filename = get_file('vertice.tsv') relation_textfile = open(relation_filename, 'r') vertice_textfile = open(vertice_filename, 'r') # Parse vertice: vertices = {} next(vertice_textfil...
python
def __parse_relation(): '''Gets and parses file''' relation_filename = get_file('relation.tsv') vertice_filename = get_file('vertice.tsv') relation_textfile = open(relation_filename, 'r') vertice_textfile = open(vertice_filename, 'r') # Parse vertice: vertices = {} next(vertice_textfil...
[ "def", "__parse_relation", "(", ")", ":", "relation_filename", "=", "get_file", "(", "'relation.tsv'", ")", "vertice_filename", "=", "get_file", "(", "'vertice.tsv'", ")", "relation_textfile", "=", "open", "(", "relation_filename", ",", "'r'", ")", "vertice_textfile...
Gets and parses file
[ "Gets", "and", "parses", "file" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L478-L513
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_mol
def get_mol(chebi_id): '''Returns mol''' chebi_id_regexp = '^\\d+\\,' + str(chebi_id) + '\\,.*' mol_file_end_regexp = '\",mol,\\dD' this_structure = [] filename = get_file('structures.csv.gz') with io.open(filename, 'r', encoding='cp1252') as textfile: in_chebi_id = False next...
python
def get_mol(chebi_id): '''Returns mol''' chebi_id_regexp = '^\\d+\\,' + str(chebi_id) + '\\,.*' mol_file_end_regexp = '\",mol,\\dD' this_structure = [] filename = get_file('structures.csv.gz') with io.open(filename, 'r', encoding='cp1252') as textfile: in_chebi_id = False next...
[ "def", "get_mol", "(", "chebi_id", ")", ":", "chebi_id_regexp", "=", "'^\\\\d+\\\\,'", "+", "str", "(", "chebi_id", ")", "+", "'\\\\,.*'", "mol_file_end_regexp", "=", "'\\\",mol,\\\\dD'", "this_structure", "=", "[", "]", "filename", "=", "get_file", "(", "'struc...
Returns mol
[ "Returns", "mol" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L532-L567
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_mol_filename
def get_mol_filename(chebi_id): '''Returns mol file''' mol = get_mol(chebi_id) if mol is None: return None file_descriptor, mol_filename = tempfile.mkstemp(str(chebi_id) + '_', '.mol') mol_file = open(mol_filename, 'w') mol_file.writ...
python
def get_mol_filename(chebi_id): '''Returns mol file''' mol = get_mol(chebi_id) if mol is None: return None file_descriptor, mol_filename = tempfile.mkstemp(str(chebi_id) + '_', '.mol') mol_file = open(mol_filename, 'w') mol_file.writ...
[ "def", "get_mol_filename", "(", "chebi_id", ")", ":", "mol", "=", "get_mol", "(", "chebi_id", ")", "if", "mol", "is", "None", ":", "return", "None", "file_descriptor", ",", "mol_filename", "=", "tempfile", ".", "mkstemp", "(", "str", "(", "chebi_id", ")", ...
Returns mol file
[ "Returns", "mol", "file" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L570-L584
libChEBI/libChEBIpy
libchebipy/_parsers.py
__parse_structures
def __parse_structures(): '''COMMENT''' filename = get_file('structures.csv.gz') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split(',') if len(tokens) == 5: if tokens[3] == '...
python
def __parse_structures(): '''COMMENT''' filename = get_file('structures.csv.gz') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().split(',') if len(tokens) == 5: if tokens[3] == '...
[ "def", "__parse_structures", "(", ")", ":", "filename", "=", "get_file", "(", "'structures.csv.gz'", ")", "with", "io", ".", "open", "(", "filename", ",", "'r'", ",", "encoding", "=", "'cp1252'", ")", "as", "textfile", ":", "next", "(", "textfile", ")", ...
COMMENT
[ "COMMENT" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L587-L607
libChEBI/libChEBIpy
libchebipy/_parsers.py
__get_default_structure_ids
def __get_default_structure_ids(): '''COMMENT''' if len(__DEFAULT_STRUCTURE_IDS) == 0: filename = get_file('default_structures.tsv') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().sp...
python
def __get_default_structure_ids(): '''COMMENT''' if len(__DEFAULT_STRUCTURE_IDS) == 0: filename = get_file('default_structures.tsv') with io.open(filename, 'r', encoding='cp1252') as textfile: next(textfile) for line in textfile: tokens = line.strip().sp...
[ "def", "__get_default_structure_ids", "(", ")", ":", "if", "len", "(", "__DEFAULT_STRUCTURE_IDS", ")", "==", "0", ":", "filename", "=", "get_file", "(", "'default_structures.tsv'", ")", "with", "io", ".", "open", "(", "filename", ",", "'r'", ",", "encoding", ...
COMMENT
[ "COMMENT" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L610-L622
libChEBI/libChEBIpy
libchebipy/_parsers.py
get_file
def get_file(filename): '''Downloads filename from ChEBI FTP site''' destination = __DOWNLOAD_PARAMS['path'] filepath = os.path.join(destination, filename) if not __is_current(filepath): if not os.path.exists(destination): os.makedirs(destination) url = 'ftp://ftp.ebi.ac.u...
python
def get_file(filename): '''Downloads filename from ChEBI FTP site''' destination = __DOWNLOAD_PARAMS['path'] filepath = os.path.join(destination, filename) if not __is_current(filepath): if not os.path.exists(destination): os.makedirs(destination) url = 'ftp://ftp.ebi.ac.u...
[ "def", "get_file", "(", "filename", ")", ":", "destination", "=", "__DOWNLOAD_PARAMS", "[", "'path'", "]", "filepath", "=", "os", ".", "path", ".", "join", "(", "destination", ",", "filename", ")", "if", "not", "__is_current", "(", "filepath", ")", ":", ...
Downloads filename from ChEBI FTP site
[ "Downloads", "filename", "from", "ChEBI", "FTP", "site" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L625-L661
libChEBI/libChEBIpy
libchebipy/_parsers.py
__is_current
def __is_current(filepath): '''Checks whether file is current''' if not __DOWNLOAD_PARAMS['auto_update']: return True if not os.path.isfile(filepath): return False return datetime.datetime.utcfromtimestamp(os.path.getmtime(filepath)) \ > __get_last_update_time()
python
def __is_current(filepath): '''Checks whether file is current''' if not __DOWNLOAD_PARAMS['auto_update']: return True if not os.path.isfile(filepath): return False return datetime.datetime.utcfromtimestamp(os.path.getmtime(filepath)) \ > __get_last_update_time()
[ "def", "__is_current", "(", "filepath", ")", ":", "if", "not", "__DOWNLOAD_PARAMS", "[", "'auto_update'", "]", ":", "return", "True", "if", "not", "os", ".", "path", ".", "isfile", "(", "filepath", ")", ":", "return", "False", "return", "datetime", ".", ...
Checks whether file is current
[ "Checks", "whether", "file", "is", "current" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L664-L673
libChEBI/libChEBIpy
libchebipy/_parsers.py
__get_last_update_time
def __get_last_update_time(): '''Returns last FTP site update time''' now = datetime.datetime.utcnow() # Get the first Tuesday of the month first_tuesday = __get_first_tuesday(now) if first_tuesday < now: return first_tuesday else: first_of_month = datetime.datetime(now.year, n...
python
def __get_last_update_time(): '''Returns last FTP site update time''' now = datetime.datetime.utcnow() # Get the first Tuesday of the month first_tuesday = __get_first_tuesday(now) if first_tuesday < now: return first_tuesday else: first_of_month = datetime.datetime(now.year, n...
[ "def", "__get_last_update_time", "(", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "# Get the first Tuesday of the month", "first_tuesday", "=", "__get_first_tuesday", "(", "now", ")", "if", "first_tuesday", "<", "now", ":", "return"...
Returns last FTP site update time
[ "Returns", "last", "FTP", "site", "update", "time" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L676-L688
libChEBI/libChEBIpy
libchebipy/_parsers.py
__get_first_tuesday
def __get_first_tuesday(this_date): '''Get the first Tuesday of the month''' month_range = calendar.monthrange(this_date.year, this_date.month) first_of_month = datetime.datetime(this_date.year, this_date.month, 1) first_tuesday_day = (calendar.TUESDAY - month_range[0]) % 7 first_tuesday = first_of_...
python
def __get_first_tuesday(this_date): '''Get the first Tuesday of the month''' month_range = calendar.monthrange(this_date.year, this_date.month) first_of_month = datetime.datetime(this_date.year, this_date.month, 1) first_tuesday_day = (calendar.TUESDAY - month_range[0]) % 7 first_tuesday = first_of_...
[ "def", "__get_first_tuesday", "(", "this_date", ")", ":", "month_range", "=", "calendar", ".", "monthrange", "(", "this_date", ".", "year", ",", "this_date", ".", "month", ")", "first_of_month", "=", "datetime", ".", "datetime", "(", "this_date", ".", "year", ...
Get the first Tuesday of the month
[ "Get", "the", "first", "Tuesday", "of", "the", "month" ]
train
https://github.com/libChEBI/libChEBIpy/blob/89f223a91f518619d5e3910070d283adcac1626e/libchebipy/_parsers.py#L691-L697
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_logger_id
def write_logger_id(self, manufacturer, logger_id, extension=None, validate=True): """ Write the manufacturer and logger id header line:: writer.write_logger_id('XXX', 'ABC', extension='FLIGHT:1') # -> AXXXABCFLIGHT:1 Some older loggers have deci...
python
def write_logger_id(self, manufacturer, logger_id, extension=None, validate=True): """ Write the manufacturer and logger id header line:: writer.write_logger_id('XXX', 'ABC', extension='FLIGHT:1') # -> AXXXABCFLIGHT:1 Some older loggers have deci...
[ "def", "write_logger_id", "(", "self", ",", "manufacturer", ",", "logger_id", ",", "extension", "=", "None", ",", "validate", "=", "True", ")", ":", "if", "validate", ":", "if", "not", "patterns", ".", "MANUFACTURER_CODE", ".", "match", "(", "manufacturer", ...
Write the manufacturer and logger id header line:: writer.write_logger_id('XXX', 'ABC', extension='FLIGHT:1') # -> AXXXABCFLIGHT:1 Some older loggers have decimal logger ids which can be written like this:: writer.write_logger_id('FIL', '13961', validate=False) ...
[ "Write", "the", "manufacturer", "and", "logger", "id", "header", "line", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L85-L117
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_fix_accuracy
def write_fix_accuracy(self, accuracy=None): """ Write the GPS fix accuracy header:: writer.write_fix_accuracy() # -> HFFXA500 writer.write_fix_accuracy(25) # -> HFFXA025 :param accuracy: the estimated GPS fix accuracy in meters (optional) ...
python
def write_fix_accuracy(self, accuracy=None): """ Write the GPS fix accuracy header:: writer.write_fix_accuracy() # -> HFFXA500 writer.write_fix_accuracy(25) # -> HFFXA025 :param accuracy: the estimated GPS fix accuracy in meters (optional) ...
[ "def", "write_fix_accuracy", "(", "self", ",", "accuracy", "=", "None", ")", ":", "if", "accuracy", "is", "None", ":", "accuracy", "=", "500", "accuracy", "=", "int", "(", "accuracy", ")", "if", "not", "0", "<", "accuracy", "<", "1000", ":", "raise", ...
Write the GPS fix accuracy header:: writer.write_fix_accuracy() # -> HFFXA500 writer.write_fix_accuracy(25) # -> HFFXA025 :param accuracy: the estimated GPS fix accuracy in meters (optional)
[ "Write", "the", "GPS", "fix", "accuracy", "header", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L153-L173
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_gps_datum
def write_gps_datum(self, code=None, gps_datum=None): """ Write the mandatory GPS datum header:: writer.write_gps_datum() # -> HFDTM100GPSDATUM:WGS-1984 writer.write_gps_datum(33, 'Guam-1963') # -> HFDTM033GPSDATUM:Guam-1963 Note that the defaul...
python
def write_gps_datum(self, code=None, gps_datum=None): """ Write the mandatory GPS datum header:: writer.write_gps_datum() # -> HFDTM100GPSDATUM:WGS-1984 writer.write_gps_datum(33, 'Guam-1963') # -> HFDTM033GPSDATUM:Guam-1963 Note that the defaul...
[ "def", "write_gps_datum", "(", "self", ",", "code", "=", "None", ",", "gps_datum", "=", "None", ")", ":", "if", "code", "is", "None", ":", "code", "=", "100", "if", "gps_datum", "is", "None", ":", "gps_datum", "=", "'WGS-1984'", "self", ".", "write_fr_...
Write the mandatory GPS datum header:: writer.write_gps_datum() # -> HFDTM100GPSDATUM:WGS-1984 writer.write_gps_datum(33, 'Guam-1963') # -> HFDTM033GPSDATUM:Guam-1963 Note that the default GPS datum is WGS-1984 and you should use that unless you have ve...
[ "Write", "the", "mandatory", "GPS", "datum", "header", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L222-L251
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_headers
def write_headers(self, headers): """ Write all the necessary headers in the correct order:: writer.write_headers({ 'manufacturer_code': 'XCS', 'logger_id': 'TBX', 'date': datetime.date(1987, 2, 24), 'fix_accuracy': 50, ...
python
def write_headers(self, headers): """ Write all the necessary headers in the correct order:: writer.write_headers({ 'manufacturer_code': 'XCS', 'logger_id': 'TBX', 'date': datetime.date(1987, 2, 24), 'fix_accuracy': 50, ...
[ "def", "write_headers", "(", "self", ",", "headers", ")", ":", "for", "header", "in", "self", ".", "REQUIRED_HEADERS", ":", "if", "header", "not", "in", "headers", ":", "raise", "ValueError", "(", "'%s header missing'", "%", "header", ")", "self", ".", "wr...
Write all the necessary headers in the correct order:: writer.write_headers({ 'manufacturer_code': 'XCS', 'logger_id': 'TBX', 'date': datetime.date(1987, 2, 24), 'fix_accuracy': 50, 'pilot': 'Tobias Bieniek', 'c...
[ "Write", "all", "the", "necessary", "headers", "in", "the", "correct", "order", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L348-L438
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_task_metadata
def write_task_metadata( self, declaration_datetime=None, flight_date=None, task_number=None, turnpoints=None, text=None): """ Write the task declaration metadata record:: writer.write_task_metadata( datetime.datetime(2014, 4, 13, 12, 53, 02), ...
python
def write_task_metadata( self, declaration_datetime=None, flight_date=None, task_number=None, turnpoints=None, text=None): """ Write the task declaration metadata record:: writer.write_task_metadata( datetime.datetime(2014, 4, 13, 12, 53, 02), ...
[ "def", "write_task_metadata", "(", "self", ",", "declaration_datetime", "=", "None", ",", "flight_date", "=", "None", ",", "task_number", "=", "None", ",", "turnpoints", "=", "None", ",", "text", "=", "None", ")", ":", "if", "declaration_datetime", "is", "No...
Write the task declaration metadata record:: writer.write_task_metadata( datetime.datetime(2014, 4, 13, 12, 53, 02), task_number=42, turnpoints=3, ) # -> C140413125302000000004203 There are sensible defaults in place for all p...
[ "Write", "the", "task", "declaration", "metadata", "record", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L484-L550
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_task_point
def write_task_point(self, latitude=None, longitude=None, text='', distance_min=None, distance_max=None, bearing1=None, bearing2=None): """ Write a task declaration point:: writer.write_task_point( latitude=(51 + 7.345 / 60.)...
python
def write_task_point(self, latitude=None, longitude=None, text='', distance_min=None, distance_max=None, bearing1=None, bearing2=None): """ Write a task declaration point:: writer.write_task_point( latitude=(51 + 7.345 / 60.)...
[ "def", "write_task_point", "(", "self", ",", "latitude", "=", "None", ",", "longitude", "=", "None", ",", "text", "=", "''", ",", "distance_min", "=", "None", ",", "distance_max", "=", "None", ",", "bearing1", "=", "None", ",", "bearing2", "=", "None", ...
Write a task declaration point:: writer.write_task_point( latitude=(51 + 7.345 / 60.), longitude=(6 + 24.765 / 60.), text='Meiersberg', ) # -> C5107345N00624765EMeiersberg If no ``latitude`` or ``longitude`` is passed, the fie...
[ "Write", "a", "task", "declaration", "point", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L552-L607
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_task_points
def write_task_points(self, points): """ Write multiple task declaration points with one call:: writer.write_task_points([ (None, None, 'TAKEOFF'), (51.40375, 6.41275, 'START'), (50.38210, 8.82105, 'TURN 1'), (50.59045, 7.03555...
python
def write_task_points(self, points): """ Write multiple task declaration points with one call:: writer.write_task_points([ (None, None, 'TAKEOFF'), (51.40375, 6.41275, 'START'), (50.38210, 8.82105, 'TURN 1'), (50.59045, 7.03555...
[ "def", "write_task_points", "(", "self", ",", "points", ")", ":", "for", "args", "in", "points", ":", "if", "len", "(", "args", ")", "not", "in", "[", "3", ",", "7", "]", ":", "raise", "ValueError", "(", "'Invalid number of task point tuple items'", ")", ...
Write multiple task declaration points with one call:: writer.write_task_points([ (None, None, 'TAKEOFF'), (51.40375, 6.41275, 'START'), (50.38210, 8.82105, 'TURN 1'), (50.59045, 7.03555, 'TURN 2', 0, 32.5, 0, 180), (51.40375, ...
[ "Write", "multiple", "task", "declaration", "points", "with", "one", "call", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L609-L639
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_security
def write_security(self, security, bytes_per_line=75): """ Write the security signature:: writer.write_security('ABCDEF') # -> GABCDEF If a signature of more than 75 bytes is used the G record will be broken into multiple lines according to the IGC file specific...
python
def write_security(self, security, bytes_per_line=75): """ Write the security signature:: writer.write_security('ABCDEF') # -> GABCDEF If a signature of more than 75 bytes is used the G record will be broken into multiple lines according to the IGC file specific...
[ "def", "write_security", "(", "self", ",", "security", ",", "bytes_per_line", "=", "75", ")", ":", "for", "start", "in", "range", "(", "0", ",", "len", "(", "security", ")", ",", "bytes_per_line", ")", ":", "self", ".", "write_record", "(", "'G'", ",",...
Write the security signature:: writer.write_security('ABCDEF') # -> GABCDEF If a signature of more than 75 bytes is used the G record will be broken into multiple lines according to the IGC file specification. This rule can be configured with the ``bytes_per_line`` para...
[ "Write", "the", "security", "signature", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L641-L659
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_fix
def write_fix(self, time=None, latitude=None, longitude=None, valid=False, pressure_alt=None, gps_alt=None, extensions=None): """ Write a fix record:: writer.write_fix( datetime.time(12, 34, 56), latitude=51.40375, longitude=...
python
def write_fix(self, time=None, latitude=None, longitude=None, valid=False, pressure_alt=None, gps_alt=None, extensions=None): """ Write a fix record:: writer.write_fix( datetime.time(12, 34, 56), latitude=51.40375, longitude=...
[ "def", "write_fix", "(", "self", ",", "time", "=", "None", ",", "latitude", "=", "None", ",", "longitude", "=", "None", ",", "valid", "=", "False", ",", "pressure_alt", "=", "None", ",", "gps_alt", "=", "None", ",", "extensions", "=", "None", ")", ":...
Write a fix record:: writer.write_fix( datetime.time(12, 34, 56), latitude=51.40375, longitude=6.41275, valid=True, pressure_alt=1234, gps_alt=1432, ) # -> B1234565124225N00624765EA012340...
[ "Write", "a", "fix", "record", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L661-L719
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_event
def write_event(self, *args): """ Write an event record:: writer.write_event(datetime.time(12, 34, 56), 'PEV') # -> B123456PEV writer.write_event(datetime.time(12, 34, 56), 'PEV', 'Some Text') # -> B123456PEVSome Text writer.write_event('PEV...
python
def write_event(self, *args): """ Write an event record:: writer.write_event(datetime.time(12, 34, 56), 'PEV') # -> B123456PEV writer.write_event(datetime.time(12, 34, 56), 'PEV', 'Some Text') # -> B123456PEVSome Text writer.write_event('PEV...
[ "def", "write_event", "(", "self", ",", "*", "args", ")", ":", "num_args", "=", "len", "(", "args", ")", "if", "not", "(", "1", "<=", "num_args", "<=", "3", ")", ":", "raise", "ValueError", "(", "'Invalid number of parameters received'", ")", "if", "num_...
Write an event record:: writer.write_event(datetime.time(12, 34, 56), 'PEV') # -> B123456PEV writer.write_event(datetime.time(12, 34, 56), 'PEV', 'Some Text') # -> B123456PEVSome Text writer.write_event('PEV') # uses utcnow() # -> B121503PEV ...
[ "Write", "an", "event", "record", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L721-L767
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_satellites
def write_satellites(self, *args): """ Write a satellite constellation record:: writer.write_satellites(datetime.time(12, 34, 56), [1, 2, 5, 22]) # -> F12345601020522 :param time: UTC time of the satellite constellation record (default: :meth:`~datetime.date...
python
def write_satellites(self, *args): """ Write a satellite constellation record:: writer.write_satellites(datetime.time(12, 34, 56), [1, 2, 5, 22]) # -> F12345601020522 :param time: UTC time of the satellite constellation record (default: :meth:`~datetime.date...
[ "def", "write_satellites", "(", "self", ",", "*", "args", ")", ":", "num_args", "=", "len", "(", "args", ")", "if", "num_args", "not", "in", "(", "1", ",", "2", ")", ":", "raise", "ValueError", "(", "'Invalid number of parameters received'", ")", "if", "...
Write a satellite constellation record:: writer.write_satellites(datetime.time(12, 34, 56), [1, 2, 5, 22]) # -> F12345601020522 :param time: UTC time of the satellite constellation record (default: :meth:`~datetime.datetime.utcnow`) :param satellites: a list of sate...
[ "Write", "a", "satellite", "constellation", "record", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L769-L806
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_k_record
def write_k_record(self, *args): """ Write a K record:: writer.write_k_record_extensions([ ('FXA', 3), ('SIU', 2), ('ENL', 3), ]) writer.write_k_record(datetime.time(2, 3, 4), ['023', 13, 2]) # -> J030810FXA1112SIU1315ENL # -...
python
def write_k_record(self, *args): """ Write a K record:: writer.write_k_record_extensions([ ('FXA', 3), ('SIU', 2), ('ENL', 3), ]) writer.write_k_record(datetime.time(2, 3, 4), ['023', 13, 2]) # -> J030810FXA1112SIU1315ENL # -...
[ "def", "write_k_record", "(", "self", ",", "*", "args", ")", ":", "num_args", "=", "len", "(", "args", ")", "if", "num_args", "not", "in", "(", "1", ",", "2", ")", ":", "raise", "ValueError", "(", "'Invalid number of parameters received'", ")", "if", "nu...
Write a K record:: writer.write_k_record_extensions([ ('FXA', 3), ('SIU', 2), ('ENL', 3), ]) writer.write_k_record(datetime.time(2, 3, 4), ['023', 13, 2]) # -> J030810FXA1112SIU1315ENL # -> K02030402313002 :param time: UTC time of t...
[ "Write", "a", "K", "record", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L808-L862
Turbo87/aerofiles
aerofiles/igc/writer.py
Writer.write_comment
def write_comment(self, code, text): """ Write a comment record:: writer.write_comment('PLT', 'Arrived at the first turnpoint') # -> LPLTArrived at the first turnpoint :param code: a three-letter-code describing the source of the comment (e.g. ``PLT`` for pi...
python
def write_comment(self, code, text): """ Write a comment record:: writer.write_comment('PLT', 'Arrived at the first turnpoint') # -> LPLTArrived at the first turnpoint :param code: a three-letter-code describing the source of the comment (e.g. ``PLT`` for pi...
[ "def", "write_comment", "(", "self", ",", "code", ",", "text", ")", ":", "if", "not", "patterns", ".", "THREE_LETTER_CODE", ".", "match", "(", "code", ")", ":", "raise", "ValueError", "(", "'Invalid source'", ")", "self", ".", "write_record", "(", "'L'", ...
Write a comment record:: writer.write_comment('PLT', 'Arrived at the first turnpoint') # -> LPLTArrived at the first turnpoint :param code: a three-letter-code describing the source of the comment (e.g. ``PLT`` for pilot) :param text: the text that should be added t...
[ "Write", "a", "comment", "record", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/writer.py#L864-L879
dreipol/djangocms-spa
djangocms_spa/content_helpers.py
get_frontend_data_dict_for_cms_page
def get_frontend_data_dict_for_cms_page(cms_page, cms_page_title, request, editable=False): """ Returns the data dictionary of a CMS page that is used by the frontend. """ placeholders = list(cms_page.placeholders.all()) placeholder_frontend_data_dict = get_frontend_data_dict_for_placeholders( ...
python
def get_frontend_data_dict_for_cms_page(cms_page, cms_page_title, request, editable=False): """ Returns the data dictionary of a CMS page that is used by the frontend. """ placeholders = list(cms_page.placeholders.all()) placeholder_frontend_data_dict = get_frontend_data_dict_for_placeholders( ...
[ "def", "get_frontend_data_dict_for_cms_page", "(", "cms_page", ",", "cms_page_title", ",", "request", ",", "editable", "=", "False", ")", ":", "placeholders", "=", "list", "(", "cms_page", ".", "placeholders", ".", "all", "(", ")", ")", "placeholder_frontend_data_...
Returns the data dictionary of a CMS page that is used by the frontend.
[ "Returns", "the", "data", "dictionary", "of", "a", "CMS", "page", "that", "is", "used", "by", "the", "frontend", "." ]
train
https://github.com/dreipol/djangocms-spa/blob/eb0048eb29aef6314431c3c1800b363c40619818/djangocms_spa/content_helpers.py#L11-L45
dreipol/djangocms-spa
djangocms_spa/content_helpers.py
get_frontend_data_dict_for_placeholders
def get_frontend_data_dict_for_placeholders(placeholders, request, editable=False): """ Takes a list of placeholder instances and returns the data that is used by the frontend to render all contents. The returned dict is grouped by placeholder slots. """ data_dict = {} for placeholder in placeho...
python
def get_frontend_data_dict_for_placeholders(placeholders, request, editable=False): """ Takes a list of placeholder instances and returns the data that is used by the frontend to render all contents. The returned dict is grouped by placeholder slots. """ data_dict = {} for placeholder in placeho...
[ "def", "get_frontend_data_dict_for_placeholders", "(", "placeholders", ",", "request", ",", "editable", "=", "False", ")", ":", "data_dict", "=", "{", "}", "for", "placeholder", "in", "placeholders", ":", "if", "placeholder", ":", "plugins", "=", "[", "]", "# ...
Takes a list of placeholder instances and returns the data that is used by the frontend to render all contents. The returned dict is grouped by placeholder slots.
[ "Takes", "a", "list", "of", "placeholder", "instances", "and", "returns", "the", "data", "that", "is", "used", "by", "the", "frontend", "to", "render", "all", "contents", ".", "The", "returned", "dict", "is", "grouped", "by", "placeholder", "slots", "." ]
train
https://github.com/dreipol/djangocms-spa/blob/eb0048eb29aef6314431c3c1800b363c40619818/djangocms_spa/content_helpers.py#L48-L102
dreipol/djangocms-spa
djangocms_spa/content_helpers.py
get_frontend_data_dict_for_plugin
def get_frontend_data_dict_for_plugin(request, plugin, editable): """ Returns a serializable data dict of a CMS plugin and all its children. It expects a `render_json_plugin()` method from each plugin. Make sure you implement it for your custom plugins and monkey patch all third-party plugins. """ j...
python
def get_frontend_data_dict_for_plugin(request, plugin, editable): """ Returns a serializable data dict of a CMS plugin and all its children. It expects a `render_json_plugin()` method from each plugin. Make sure you implement it for your custom plugins and monkey patch all third-party plugins. """ j...
[ "def", "get_frontend_data_dict_for_plugin", "(", "request", ",", "plugin", ",", "editable", ")", ":", "json_data", "=", "{", "}", "instance", ",", "plugin", "=", "plugin", ".", "get_plugin_instance", "(", ")", "if", "not", "instance", ":", "return", "json_data...
Returns a serializable data dict of a CMS plugin and all its children. It expects a `render_json_plugin()` method from each plugin. Make sure you implement it for your custom plugins and monkey patch all third-party plugins.
[ "Returns", "a", "serializable", "data", "dict", "of", "a", "CMS", "plugin", "and", "all", "its", "children", ".", "It", "expects", "a", "render_json_plugin", "()", "method", "from", "each", "plugin", ".", "Make", "sure", "you", "implement", "it", "for", "y...
train
https://github.com/dreipol/djangocms-spa/blob/eb0048eb29aef6314431c3c1800b363c40619818/djangocms_spa/content_helpers.py#L105-L135
dreipol/djangocms-spa
djangocms_spa/content_helpers.py
get_frontend_data_dict_for_partials
def get_frontend_data_dict_for_partials(partials, request, editable=False, renderer=None): """ We call global page elements that are used to render a template `partial`. The contents of a partial do not change from one page to another. In a django CMS project partials are implemented as static placeholders....
python
def get_frontend_data_dict_for_partials(partials, request, editable=False, renderer=None): """ We call global page elements that are used to render a template `partial`. The contents of a partial do not change from one page to another. In a django CMS project partials are implemented as static placeholders....
[ "def", "get_frontend_data_dict_for_partials", "(", "partials", ",", "request", ",", "editable", "=", "False", ",", "renderer", "=", "None", ")", ":", "# Split static placeholders from partials that have a custom callback.", "static_placeholder_names", "=", "[", "]", "custom...
We call global page elements that are used to render a template `partial`. The contents of a partial do not change from one page to another. In a django CMS project partials are implemented as static placeholders. But there are usually other parts (e.g. menu) that work pretty much the same way. Because we don't...
[ "We", "call", "global", "page", "elements", "that", "are", "used", "to", "render", "a", "template", "partial", ".", "The", "contents", "of", "a", "partial", "do", "not", "change", "from", "one", "page", "to", "another", ".", "In", "a", "django", "CMS", ...
train
https://github.com/dreipol/djangocms-spa/blob/eb0048eb29aef6314431c3c1800b363c40619818/djangocms_spa/content_helpers.py#L162-L201
dreipol/djangocms-spa
djangocms_spa/content_helpers.py
get_global_placeholder_data
def get_global_placeholder_data(placeholder_frontend_data_dict): """ In some rare cases you need to post process the placeholder data and add additional, global data to the route object. Define your post-processor in the DJANGOCMS_SPA_VUE_JS_PLACEHOLDER_DATA_POST_PROCESSOR setting variable (e.g. `my_app...
python
def get_global_placeholder_data(placeholder_frontend_data_dict): """ In some rare cases you need to post process the placeholder data and add additional, global data to the route object. Define your post-processor in the DJANGOCMS_SPA_VUE_JS_PLACEHOLDER_DATA_POST_PROCESSOR setting variable (e.g. `my_app...
[ "def", "get_global_placeholder_data", "(", "placeholder_frontend_data_dict", ")", ":", "post_processer", "=", "settings", ".", "DJANGOCMS_SPA_PLACEHOLDER_DATA_POST_PROCESSOR", "if", "not", "post_processer", ":", "return", "{", "}", "func", "=", "get_function_by_path", "(", ...
In some rare cases you need to post process the placeholder data and add additional, global data to the route object. Define your post-processor in the DJANGOCMS_SPA_VUE_JS_PLACEHOLDER_DATA_POST_PROCESSOR setting variable (e.g. `my_app.my_module.my_function` and return the data you need.
[ "In", "some", "rare", "cases", "you", "need", "to", "post", "process", "the", "placeholder", "data", "and", "add", "additional", "global", "data", "to", "the", "route", "object", ".", "Define", "your", "post", "-", "processor", "in", "the", "DJANGOCMS_SPA_VU...
train
https://github.com/dreipol/djangocms-spa/blob/eb0048eb29aef6314431c3c1800b363c40619818/djangocms_spa/content_helpers.py#L216-L227
Turbo87/aerofiles
aerofiles/flarmcfg/writer.py
Writer.write_waypoint
def write_waypoint(self, latitude=None, longitude=None, description=None): """ Adds a waypoint to the current task declaration. The first and the last waypoint added will be treated as takeoff and landing location, respectively. :: writer.write_waypoint( ...
python
def write_waypoint(self, latitude=None, longitude=None, description=None): """ Adds a waypoint to the current task declaration. The first and the last waypoint added will be treated as takeoff and landing location, respectively. :: writer.write_waypoint( ...
[ "def", "write_waypoint", "(", "self", ",", "latitude", "=", "None", ",", "longitude", "=", "None", ",", "description", "=", "None", ")", ":", "if", "not", "description", ":", "description", "=", "''", "latitude", "=", "self", ".", "format_latitude", "(", ...
Adds a waypoint to the current task declaration. The first and the last waypoint added will be treated as takeoff and landing location, respectively. :: writer.write_waypoint( latitude=(51 + 7.345 / 60.), longitude=(6 + 24.765 / 60.), ...
[ "Adds", "a", "waypoint", "to", "the", "current", "task", "declaration", ".", "The", "first", "and", "the", "last", "waypoint", "added", "will", "be", "treated", "as", "takeoff", "and", "landing", "location", "respectively", "." ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/flarmcfg/writer.py#L150-L182
Turbo87/aerofiles
aerofiles/flarmcfg/writer.py
Writer.write_waypoints
def write_waypoints(self, points): """ Write multiple task declaration points with one call:: writer.write_waypoints([ (None, None, 'TAKEOFF'), (51.40375, 6.41275, 'START'), (50.38210, 8.82105, 'TURN 1'), (50.59045, 7.03555, 'T...
python
def write_waypoints(self, points): """ Write multiple task declaration points with one call:: writer.write_waypoints([ (None, None, 'TAKEOFF'), (51.40375, 6.41275, 'START'), (50.38210, 8.82105, 'TURN 1'), (50.59045, 7.03555, 'T...
[ "def", "write_waypoints", "(", "self", ",", "points", ")", ":", "for", "args", "in", "points", ":", "if", "len", "(", "args", ")", "!=", "3", ":", "raise", "ValueError", "(", "'Invalid number of task point tuple items'", ")", "self", ".", "write_waypoint", "...
Write multiple task declaration points with one call:: writer.write_waypoints([ (None, None, 'TAKEOFF'), (51.40375, 6.41275, 'START'), (50.38210, 8.82105, 'TURN 1'), (50.59045, 7.03555, 'TURN 2'), (51.40375, 6.41275, 'FINISH'),...
[ "Write", "multiple", "task", "declaration", "points", "with", "one", "call", "::" ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/flarmcfg/writer.py#L184-L212
Turbo87/aerofiles
aerofiles/igc/reader.py
Reader.read
def read(self, file_obj): """ Read the specified file object and return a dictionary with the parsed data. :param file_obj: a Python file object """ self.reader = LowLevelReader(file_obj) logger_id = [[], None] fix_records = [[], []] task = [[], {"waypo...
python
def read(self, file_obj): """ Read the specified file object and return a dictionary with the parsed data. :param file_obj: a Python file object """ self.reader = LowLevelReader(file_obj) logger_id = [[], None] fix_records = [[], []] task = [[], {"waypo...
[ "def", "read", "(", "self", ",", "file_obj", ")", ":", "self", ".", "reader", "=", "LowLevelReader", "(", "file_obj", ")", "logger_id", "=", "[", "[", "]", ",", "None", "]", "fix_records", "=", "[", "[", "]", ",", "[", "]", "]", "task", "=", "[",...
Read the specified file object and return a dictionary with the parsed data. :param file_obj: a Python file object
[ "Read", "the", "specified", "file", "object", "and", "return", "a", "dictionary", "with", "the", "parsed", "data", "." ]
train
https://github.com/Turbo87/aerofiles/blob/d8b7b04a1fcea5c98f89500de1164619a4ec7ef4/aerofiles/igc/reader.py#L20-L149
payu-org/payu
payu/models/model.py
Model.set_model_pathnames
def set_model_pathnames(self): """Define the paths associated with this model.""" self.control_path = self.expt.control_path self.input_basepath = self.expt.lab.input_basepath self.work_path = self.expt.work_path self.codebase_path = self.expt.lab.codebase_path if len(se...
python
def set_model_pathnames(self): """Define the paths associated with this model.""" self.control_path = self.expt.control_path self.input_basepath = self.expt.lab.input_basepath self.work_path = self.expt.work_path self.codebase_path = self.expt.lab.codebase_path if len(se...
[ "def", "set_model_pathnames", "(", "self", ")", ":", "self", ".", "control_path", "=", "self", ".", "expt", ".", "control_path", "self", ".", "input_basepath", "=", "self", ".", "expt", ".", "lab", ".", "input_basepath", "self", ".", "work_path", "=", "sel...
Define the paths associated with this model.
[ "Define", "the", "paths", "associated", "with", "this", "model", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/models/model.py#L64-L97
payu-org/payu
payu/models/model.py
Model.archive
def archive(self): """Store model output to laboratory archive.""" # Traverse the model directory deleting symlinks, zero length files # and empty directories for path, dirs, files in os.walk(self.work_path, topdown=False): for f_name in files: f_path = os.pa...
python
def archive(self): """Store model output to laboratory archive.""" # Traverse the model directory deleting symlinks, zero length files # and empty directories for path, dirs, files in os.walk(self.work_path, topdown=False): for f_name in files: f_path = os.pa...
[ "def", "archive", "(", "self", ")", ":", "# Traverse the model directory deleting symlinks, zero length files", "# and empty directories", "for", "path", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "self", ".", "work_path", ",", "topdown", "=", "False",...
Store model output to laboratory archive.
[ "Store", "model", "output", "to", "laboratory", "archive", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/models/model.py#L298-L309
payu-org/payu
payu/cli.py
parse
def parse(): """Parse the command line inputs and execute the subcommand.""" # Build the list of subcommand modules modnames = [mod for (_, mod, _) in pkgutil.iter_modules(payu.subcommands.__path__, prefix=payu.subcommands.__name__ + '.') ...
python
def parse(): """Parse the command line inputs and execute the subcommand.""" # Build the list of subcommand modules modnames = [mod for (_, mod, _) in pkgutil.iter_modules(payu.subcommands.__path__, prefix=payu.subcommands.__name__ + '.') ...
[ "def", "parse", "(", ")", ":", "# Build the list of subcommand modules", "modnames", "=", "[", "mod", "for", "(", "_", ",", "mod", ",", "_", ")", "in", "pkgutil", ".", "iter_modules", "(", "payu", ".", "subcommands", ".", "__path__", ",", "prefix", "=", ...
Parse the command line inputs and execute the subcommand.
[ "Parse", "the", "command", "line", "inputs", "and", "execute", "the", "subcommand", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/cli.py#L28-L59
payu-org/payu
payu/cli.py
get_model_type
def get_model_type(model_type, config): """Determine and validate the active model type.""" # If no model type is given, then check the config file if not model_type: model_type = config.get('model') # If there is still no model type, try the parent directory if not model_type: mod...
python
def get_model_type(model_type, config): """Determine and validate the active model type.""" # If no model type is given, then check the config file if not model_type: model_type = config.get('model') # If there is still no model type, try the parent directory if not model_type: mod...
[ "def", "get_model_type", "(", "model_type", ",", "config", ")", ":", "# If no model type is given, then check the config file", "if", "not", "model_type", ":", "model_type", "=", "config", ".", "get", "(", "'model'", ")", "# If there is still no model type, try the parent d...
Determine and validate the active model type.
[ "Determine", "and", "validate", "the", "active", "model", "type", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/cli.py#L62-L77
payu-org/payu
payu/cli.py
set_env_vars
def set_env_vars(init_run=None, n_runs=None, lab_path=None, dir_path=None, reproduce=None): """Construct the environment variables used by payu for resubmissions.""" payu_env_vars = {} # Setup Python dynamic library link lib_paths = sysconfig.get_config_vars('LIBDIR') payu_env_vars...
python
def set_env_vars(init_run=None, n_runs=None, lab_path=None, dir_path=None, reproduce=None): """Construct the environment variables used by payu for resubmissions.""" payu_env_vars = {} # Setup Python dynamic library link lib_paths = sysconfig.get_config_vars('LIBDIR') payu_env_vars...
[ "def", "set_env_vars", "(", "init_run", "=", "None", ",", "n_runs", "=", "None", ",", "lab_path", "=", "None", ",", "dir_path", "=", "None", ",", "reproduce", "=", "None", ")", ":", "payu_env_vars", "=", "{", "}", "# Setup Python dynamic library link", "lib_...
Construct the environment variables used by payu for resubmissions.
[ "Construct", "the", "environment", "variables", "used", "by", "payu", "for", "resubmissions", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/cli.py#L80-L121
payu-org/payu
payu/cli.py
submit_job
def submit_job(pbs_script, pbs_config, pbs_vars=None): """Submit a userscript the scheduler.""" # Initialisation if pbs_vars is None: pbs_vars = {} pbs_flags = [] pbs_queue = pbs_config.get('queue', 'normal') pbs_flags.append('-q {queue}'.format(queue=pbs_queue)) pbs_project = pb...
python
def submit_job(pbs_script, pbs_config, pbs_vars=None): """Submit a userscript the scheduler.""" # Initialisation if pbs_vars is None: pbs_vars = {} pbs_flags = [] pbs_queue = pbs_config.get('queue', 'normal') pbs_flags.append('-q {queue}'.format(queue=pbs_queue)) pbs_project = pb...
[ "def", "submit_job", "(", "pbs_script", ",", "pbs_config", ",", "pbs_vars", "=", "None", ")", ":", "# Initialisation", "if", "pbs_vars", "is", "None", ":", "pbs_vars", "=", "{", "}", "pbs_flags", "=", "[", "]", "pbs_queue", "=", "pbs_config", ".", "get", ...
Submit a userscript the scheduler.
[ "Submit", "a", "userscript", "the", "scheduler", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/cli.py#L124-L200
payu-org/payu
payu/namcouple.py
Namcouple.substitute_timestep
def substitute_timestep(self, regex, timestep): """ Substitute a new timestep value using regex. """ # Make one change at a time, each change affects subsequent matches. timestep_changed = False while True: matches = re.finditer(regex, self.str, re.MULTILINE ...
python
def substitute_timestep(self, regex, timestep): """ Substitute a new timestep value using regex. """ # Make one change at a time, each change affects subsequent matches. timestep_changed = False while True: matches = re.finditer(regex, self.str, re.MULTILINE ...
[ "def", "substitute_timestep", "(", "self", ",", "regex", ",", "timestep", ")", ":", "# Make one change at a time, each change affects subsequent matches.", "timestep_changed", "=", "False", "while", "True", ":", "matches", "=", "re", ".", "finditer", "(", "regex", ","...
Substitute a new timestep value using regex.
[ "Substitute", "a", "new", "timestep", "value", "using", "regex", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/namcouple.py#L35-L59
payu-org/payu
payu/calendar.py
int_to_date
def int_to_date(date): """ Convert an int of form yyyymmdd to a python date object. """ year = date // 10**4 month = date % 10**4 // 10**2 day = date % 10**2 return datetime.date(year, month, day)
python
def int_to_date(date): """ Convert an int of form yyyymmdd to a python date object. """ year = date // 10**4 month = date % 10**4 // 10**2 day = date % 10**2 return datetime.date(year, month, day)
[ "def", "int_to_date", "(", "date", ")", ":", "year", "=", "date", "//", "10", "**", "4", "month", "=", "date", "%", "10", "**", "4", "//", "10", "**", "2", "day", "=", "date", "%", "10", "**", "2", "return", "datetime", ".", "date", "(", "year"...
Convert an int of form yyyymmdd to a python date object.
[ "Convert", "an", "int", "of", "form", "yyyymmdd", "to", "a", "python", "date", "object", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/calendar.py#L7-L16
payu-org/payu
payu/calendar.py
runtime_from_date
def runtime_from_date(start_date, years, months, days, seconds, caltype): """ Get the number of seconds from start date to start date + date_delta. Ignores Feb 29 for caltype == NOLEAP. """ end_date = start_date + relativedelta(years=years, months=months, ...
python
def runtime_from_date(start_date, years, months, days, seconds, caltype): """ Get the number of seconds from start date to start date + date_delta. Ignores Feb 29 for caltype == NOLEAP. """ end_date = start_date + relativedelta(years=years, months=months, ...
[ "def", "runtime_from_date", "(", "start_date", ",", "years", ",", "months", ",", "days", ",", "seconds", ",", "caltype", ")", ":", "end_date", "=", "start_date", "+", "relativedelta", "(", "years", "=", "years", ",", "months", "=", "months", ",", "days", ...
Get the number of seconds from start date to start date + date_delta. Ignores Feb 29 for caltype == NOLEAP.
[ "Get", "the", "number", "of", "seconds", "from", "start", "date", "to", "start", "date", "+", "date_delta", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/calendar.py#L24-L38
payu-org/payu
payu/calendar.py
date_plus_seconds
def date_plus_seconds(init_date, seconds, caltype): """ Get a new_date = date + seconds. Ignores Feb 29 for no-leap days. """ end_date = init_date + datetime.timedelta(seconds=seconds) if caltype == NOLEAP: end_date += get_leapdays(init_date, end_date) if end_date.month == 2 a...
python
def date_plus_seconds(init_date, seconds, caltype): """ Get a new_date = date + seconds. Ignores Feb 29 for no-leap days. """ end_date = init_date + datetime.timedelta(seconds=seconds) if caltype == NOLEAP: end_date += get_leapdays(init_date, end_date) if end_date.month == 2 a...
[ "def", "date_plus_seconds", "(", "init_date", ",", "seconds", ",", "caltype", ")", ":", "end_date", "=", "init_date", "+", "datetime", ".", "timedelta", "(", "seconds", "=", "seconds", ")", "if", "caltype", "==", "NOLEAP", ":", "end_date", "+=", "get_leapday...
Get a new_date = date + seconds. Ignores Feb 29 for no-leap days.
[ "Get", "a", "new_date", "=", "date", "+", "seconds", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/calendar.py#L41-L55
payu-org/payu
payu/calendar.py
get_leapdays
def get_leapdays(init_date, final_date): """ Find the number of leap days between arbitrary dates. Returns a timedelta object. FIXME: calculate this instead of iterating. """ curr_date = init_date leap_days = 0 while curr_date != final_date: if curr_date.month == 2 and curr_d...
python
def get_leapdays(init_date, final_date): """ Find the number of leap days between arbitrary dates. Returns a timedelta object. FIXME: calculate this instead of iterating. """ curr_date = init_date leap_days = 0 while curr_date != final_date: if curr_date.month == 2 and curr_d...
[ "def", "get_leapdays", "(", "init_date", ",", "final_date", ")", ":", "curr_date", "=", "init_date", "leap_days", "=", "0", "while", "curr_date", "!=", "final_date", ":", "if", "curr_date", ".", "month", "==", "2", "and", "curr_date", ".", "day", "==", "29...
Find the number of leap days between arbitrary dates. Returns a timedelta object. FIXME: calculate this instead of iterating.
[ "Find", "the", "number", "of", "leap", "days", "between", "arbitrary", "dates", ".", "Returns", "a", "timedelta", "object", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/calendar.py#L58-L76
payu-org/payu
payu/calendar.py
calculate_leapdays
def calculate_leapdays(init_date, final_date): """Currently unsupported, it only works for differences in years.""" leap_days = (final_date.year - 1) // 4 - (init_date.year - 1) // 4 leap_days -= (final_date.year - 1) // 100 - (init_date.year - 1) // 100 leap_days += (final_date.year - 1) // 400 - (ini...
python
def calculate_leapdays(init_date, final_date): """Currently unsupported, it only works for differences in years.""" leap_days = (final_date.year - 1) // 4 - (init_date.year - 1) // 4 leap_days -= (final_date.year - 1) // 100 - (init_date.year - 1) // 100 leap_days += (final_date.year - 1) // 400 - (ini...
[ "def", "calculate_leapdays", "(", "init_date", ",", "final_date", ")", ":", "leap_days", "=", "(", "final_date", ".", "year", "-", "1", ")", "//", "4", "-", "(", "init_date", ".", "year", "-", "1", ")", "//", "4", "leap_days", "-=", "(", "final_date", ...
Currently unsupported, it only works for differences in years.
[ "Currently", "unsupported", "it", "only", "works", "for", "differences", "in", "years", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/calendar.py#L79-L88
payu-org/payu
payu/laboratory.py
Laboratory.get_default_lab_path
def get_default_lab_path(self, config): """Generate a default laboratory path based on user environment.""" # Default path settings # Append project name if present (NCI-specific) default_project = os.environ.get('PROJECT', '') default_short_path = os.path.join('/short', default...
python
def get_default_lab_path(self, config): """Generate a default laboratory path based on user environment.""" # Default path settings # Append project name if present (NCI-specific) default_project = os.environ.get('PROJECT', '') default_short_path = os.path.join('/short', default...
[ "def", "get_default_lab_path", "(", "self", ",", "config", ")", ":", "# Default path settings", "# Append project name if present (NCI-specific)", "default_project", "=", "os", ".", "environ", ".", "get", "(", "'PROJECT'", ",", "''", ")", "default_short_path", "=", "o...
Generate a default laboratory path based on user environment.
[ "Generate", "a", "default", "laboratory", "path", "based", "on", "user", "environment", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/laboratory.py#L51-L69
payu-org/payu
payu/laboratory.py
Laboratory.initialize
def initialize(self): """Create the laboratory directories.""" mkdir_p(self.archive_path) mkdir_p(self.bin_path) mkdir_p(self.codebase_path) mkdir_p(self.input_basepath)
python
def initialize(self): """Create the laboratory directories.""" mkdir_p(self.archive_path) mkdir_p(self.bin_path) mkdir_p(self.codebase_path) mkdir_p(self.input_basepath)
[ "def", "initialize", "(", "self", ")", ":", "mkdir_p", "(", "self", ".", "archive_path", ")", "mkdir_p", "(", "self", ".", "bin_path", ")", "mkdir_p", "(", "self", ".", "codebase_path", ")", "mkdir_p", "(", "self", ".", "input_basepath", ")" ]
Create the laboratory directories.
[ "Create", "the", "laboratory", "directories", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/laboratory.py#L71-L76
payu-org/payu
payu/scheduler/pbs.py
get_job_id
def get_job_id(short=True): """ Return PBS job id """ jobid = os.environ.get('PBS_JOBID', '') if short: # Strip off '.rman2' jobid = jobid.split('.')[0] return(jobid)
python
def get_job_id(short=True): """ Return PBS job id """ jobid = os.environ.get('PBS_JOBID', '') if short: # Strip off '.rman2' jobid = jobid.split('.')[0] return(jobid)
[ "def", "get_job_id", "(", "short", "=", "True", ")", ":", "jobid", "=", "os", ".", "environ", ".", "get", "(", "'PBS_JOBID'", ",", "''", ")", "if", "short", ":", "# Strip off '.rman2'", "jobid", "=", "jobid", ".", "split", "(", "'.'", ")", "[", "0", ...
Return PBS job id
[ "Return", "PBS", "job", "id" ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/scheduler/pbs.py#L18-L29
payu-org/payu
payu/scheduler/pbs.py
get_job_info
def get_job_info(): """ Get information about the job from the PBS server """ jobid = get_job_id() if jobid == '': return None info = get_qstat_info('-ft {0}'.format(jobid), 'Job Id:') # Select the dict for this job (there should only be one entry in any case) info = info['Jo...
python
def get_job_info(): """ Get information about the job from the PBS server """ jobid = get_job_id() if jobid == '': return None info = get_qstat_info('-ft {0}'.format(jobid), 'Job Id:') # Select the dict for this job (there should only be one entry in any case) info = info['Jo...
[ "def", "get_job_info", "(", ")", ":", "jobid", "=", "get_job_id", "(", ")", "if", "jobid", "==", "''", ":", "return", "None", "info", "=", "get_qstat_info", "(", "'-ft {0}'", ".", "format", "(", "jobid", ")", ",", "'Job Id:'", ")", "# Select the dict for t...
Get information about the job from the PBS server
[ "Get", "information", "about", "the", "job", "from", "the", "PBS", "server" ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/scheduler/pbs.py#L32-L50
payu-org/payu
payu/experiment.py
Experiment.postprocess
def postprocess(self): """Submit a postprocessing script after collation""" assert self.postscript envmod.setup() envmod.module('load', 'pbs') cmd = 'qsub {script}'.format(script=self.postscript) cmd = shlex.split(cmd) rc = sp.call(cmd) assert rc == 0, '...
python
def postprocess(self): """Submit a postprocessing script after collation""" assert self.postscript envmod.setup() envmod.module('load', 'pbs') cmd = 'qsub {script}'.format(script=self.postscript) cmd = shlex.split(cmd) rc = sp.call(cmd) assert rc == 0, '...
[ "def", "postprocess", "(", "self", ")", ":", "assert", "self", ".", "postscript", "envmod", ".", "setup", "(", ")", "envmod", ".", "module", "(", "'load'", ",", "'pbs'", ")", "cmd", "=", "'qsub {script}'", ".", "format", "(", "script", "=", "self", "."...
Submit a postprocessing script after collation
[ "Submit", "a", "postprocessing", "script", "after", "collation" ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/experiment.py#L796-L806
payu-org/payu
payu/models/um.py
date_to_um_dump_date
def date_to_um_dump_date(date): """ Convert a time date object to a um dump format date which is <decade><year><month><day>0 To accommodate two digit months and days the UM uses letters. e.g. 1st oct is writing 01a10. """ assert(date.month <= 12) decade = date.year // 10 # UM can ...
python
def date_to_um_dump_date(date): """ Convert a time date object to a um dump format date which is <decade><year><month><day>0 To accommodate two digit months and days the UM uses letters. e.g. 1st oct is writing 01a10. """ assert(date.month <= 12) decade = date.year // 10 # UM can ...
[ "def", "date_to_um_dump_date", "(", "date", ")", ":", "assert", "(", "date", ".", "month", "<=", "12", ")", "decade", "=", "date", ".", "year", "//", "10", "# UM can only handle 36 decades then goes back to the beginning.", "decade", "=", "decade", "%", "36", "y...
Convert a time date object to a um dump format date which is <decade><year><month><day>0 To accommodate two digit months and days the UM uses letters. e.g. 1st oct is writing 01a10.
[ "Convert", "a", "time", "date", "object", "to", "a", "um", "dump", "format", "date", "which", "is", "<decade", ">", "<year", ">", "<month", ">", "<day", ">", "0" ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/models/um.py#L181-L209
payu-org/payu
payu/models/um.py
date_to_um_date
def date_to_um_date(date): """ Convert a date object to 'year, month, day, hour, minute, second.' """ assert date.hour == 0 and date.minute == 0 and date.second == 0 return [date.year, date.month, date.day, 0, 0, 0]
python
def date_to_um_date(date): """ Convert a date object to 'year, month, day, hour, minute, second.' """ assert date.hour == 0 and date.minute == 0 and date.second == 0 return [date.year, date.month, date.day, 0, 0, 0]
[ "def", "date_to_um_date", "(", "date", ")", ":", "assert", "date", ".", "hour", "==", "0", "and", "date", ".", "minute", "==", "0", "and", "date", ".", "second", "==", "0", "return", "[", "date", ".", "year", ",", "date", ".", "month", ",", "date",...
Convert a date object to 'year, month, day, hour, minute, second.'
[ "Convert", "a", "date", "object", "to", "year", "month", "day", "hour", "minute", "second", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/models/um.py#L212-L219
payu-org/payu
payu/models/um.py
um_date_to_date
def um_date_to_date(d): """ Convert a string with format 'year, month, day, hour, minute, second' to a datetime date. """ return datetime.datetime(year=d[0], month=d[1], day=d[2], hour=d[3], minute=d[4], second=d[5])
python
def um_date_to_date(d): """ Convert a string with format 'year, month, day, hour, minute, second' to a datetime date. """ return datetime.datetime(year=d[0], month=d[1], day=d[2], hour=d[3], minute=d[4], second=d[5])
[ "def", "um_date_to_date", "(", "d", ")", ":", "return", "datetime", ".", "datetime", "(", "year", "=", "d", "[", "0", "]", ",", "month", "=", "d", "[", "1", "]", ",", "day", "=", "d", "[", "2", "]", ",", "hour", "=", "d", "[", "3", "]", ","...
Convert a string with format 'year, month, day, hour, minute, second' to a datetime date.
[ "Convert", "a", "string", "with", "format", "year", "month", "day", "hour", "minute", "second", "to", "a", "datetime", "date", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/models/um.py#L222-L229
payu-org/payu
payu/envmod.py
setup
def setup(basepath=DEFAULT_BASEPATH): """Set the environment modules used by the Environment Module system.""" module_version = os.environ.get('MODULE_VERSION', DEFAULT_VERSION) moduleshome = os.path.join(basepath, module_version) # Abort if MODULESHOME does not exist if not os.path.isdir(modulesh...
python
def setup(basepath=DEFAULT_BASEPATH): """Set the environment modules used by the Environment Module system.""" module_version = os.environ.get('MODULE_VERSION', DEFAULT_VERSION) moduleshome = os.path.join(basepath, module_version) # Abort if MODULESHOME does not exist if not os.path.isdir(modulesh...
[ "def", "setup", "(", "basepath", "=", "DEFAULT_BASEPATH", ")", ":", "module_version", "=", "os", ".", "environ", ".", "get", "(", "'MODULE_VERSION'", ",", "DEFAULT_VERSION", ")", "moduleshome", "=", "os", ".", "path", ".", "join", "(", "basepath", ",", "mo...
Set the environment modules used by the Environment Module system.
[ "Set", "the", "environment", "modules", "used", "by", "the", "Environment", "Module", "system", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/envmod.py#L21-L65
payu-org/payu
payu/envmod.py
module
def module(command, *args): """Run the modulecmd tool and use its Python-formatted output to set the environment variables.""" if 'MODULESHOME' not in os.environ: print('payu: warning: No Environment Modules found; skipping {0} call.' ''.format(command)) return modulecmd ...
python
def module(command, *args): """Run the modulecmd tool and use its Python-formatted output to set the environment variables.""" if 'MODULESHOME' not in os.environ: print('payu: warning: No Environment Modules found; skipping {0} call.' ''.format(command)) return modulecmd ...
[ "def", "module", "(", "command", ",", "*", "args", ")", ":", "if", "'MODULESHOME'", "not", "in", "os", ".", "environ", ":", "print", "(", "'payu: warning: No Environment Modules found; skipping {0} call.'", "''", ".", "format", "(", "command", ")", ")", "return"...
Run the modulecmd tool and use its Python-formatted output to set the environment variables.
[ "Run", "the", "modulecmd", "tool", "and", "use", "its", "Python", "-", "formatted", "output", "to", "set", "the", "environment", "variables", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/envmod.py#L68-L83
payu-org/payu
payu/models/mom6.py
Mom6.init_config
def init_config(self): """Patch input.nml as a new or restart run.""" input_fpath = os.path.join(self.work_path, 'input.nml') input_nml = f90nml.read(input_fpath) if self.expt.counter == 0 or self.expt.repeat_run: input_type = 'n' else: input_type = 'r'...
python
def init_config(self): """Patch input.nml as a new or restart run.""" input_fpath = os.path.join(self.work_path, 'input.nml') input_nml = f90nml.read(input_fpath) if self.expt.counter == 0 or self.expt.repeat_run: input_type = 'n' else: input_type = 'r'...
[ "def", "init_config", "(", "self", ")", ":", "input_fpath", "=", "os", ".", "path", ".", "join", "(", "self", ".", "work_path", ",", "'input.nml'", ")", "input_nml", "=", "f90nml", ".", "read", "(", "input_fpath", ")", "if", "self", ".", "expt", ".", ...
Patch input.nml as a new or restart run.
[ "Patch", "input", ".", "nml", "as", "a", "new", "or", "restart", "run", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/models/mom6.py#L63-L76
payu-org/payu
payu/fsops.py
mkdir_p
def mkdir_p(path): """Create a new directory; ignore if it already exists.""" try: os.makedirs(path) except EnvironmentError as exc: if exc.errno != errno.EEXIST: raise
python
def mkdir_p(path): """Create a new directory; ignore if it already exists.""" try: os.makedirs(path) except EnvironmentError as exc: if exc.errno != errno.EEXIST: raise
[ "def", "mkdir_p", "(", "path", ")", ":", "try", ":", "os", ".", "makedirs", "(", "path", ")", "except", "EnvironmentError", "as", "exc", ":", "if", "exc", ".", "errno", "!=", "errno", ".", "EEXIST", ":", "raise" ]
Create a new directory; ignore if it already exists.
[ "Create", "a", "new", "directory", ";", "ignore", "if", "it", "already", "exists", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/fsops.py#L27-L34
payu-org/payu
payu/fsops.py
read_config
def read_config(config_fname=None): """Parse input configuration file and return a config dict.""" if not config_fname: config_fname = DEFAULT_CONFIG_FNAME try: with open(config_fname, 'r') as config_file: config = yaml.load(config_file) except IOError as exc: if ex...
python
def read_config(config_fname=None): """Parse input configuration file and return a config dict.""" if not config_fname: config_fname = DEFAULT_CONFIG_FNAME try: with open(config_fname, 'r') as config_file: config = yaml.load(config_file) except IOError as exc: if ex...
[ "def", "read_config", "(", "config_fname", "=", "None", ")", ":", "if", "not", "config_fname", ":", "config_fname", "=", "DEFAULT_CONFIG_FNAME", "try", ":", "with", "open", "(", "config_fname", ",", "'r'", ")", "as", "config_file", ":", "config", "=", "yaml"...
Parse input configuration file and return a config dict.
[ "Parse", "input", "configuration", "file", "and", "return", "a", "config", "dict", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/fsops.py#L37-L75
payu-org/payu
payu/fsops.py
make_symlink
def make_symlink(src_path, lnk_path): """Safely create a symbolic link to an input field.""" # Check for Lustre 60-character symbolic link path bug if CHECK_LUSTRE_PATH_LEN: src_path = patch_lustre_path(src_path) lnk_path = patch_lustre_path(lnk_path) # os.symlink will happily make a s...
python
def make_symlink(src_path, lnk_path): """Safely create a symbolic link to an input field.""" # Check for Lustre 60-character symbolic link path bug if CHECK_LUSTRE_PATH_LEN: src_path = patch_lustre_path(src_path) lnk_path = patch_lustre_path(lnk_path) # os.symlink will happily make a s...
[ "def", "make_symlink", "(", "src_path", ",", "lnk_path", ")", ":", "# Check for Lustre 60-character symbolic link path bug", "if", "CHECK_LUSTRE_PATH_LEN", ":", "src_path", "=", "patch_lustre_path", "(", "src_path", ")", "lnk_path", "=", "patch_lustre_path", "(", "lnk_pat...
Safely create a symbolic link to an input field.
[ "Safely", "create", "a", "symbolic", "link", "to", "an", "input", "field", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/fsops.py#L78-L105
payu-org/payu
payu/fsops.py
splitpath
def splitpath(path): """Recursively split a filepath into all directories and files.""" head, tail = os.path.split(path) if tail == '': return head, elif head == '': return tail, else: return splitpath(head) + (tail,)
python
def splitpath(path): """Recursively split a filepath into all directories and files.""" head, tail = os.path.split(path) if tail == '': return head, elif head == '': return tail, else: return splitpath(head) + (tail,)
[ "def", "splitpath", "(", "path", ")", ":", "head", ",", "tail", "=", "os", ".", "path", ".", "split", "(", "path", ")", "if", "tail", "==", "''", ":", "return", "head", ",", "elif", "head", "==", "''", ":", "return", "tail", ",", "else", ":", "...
Recursively split a filepath into all directories and files.
[ "Recursively", "split", "a", "filepath", "into", "all", "directories", "and", "files", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/fsops.py#L108-L117
payu-org/payu
payu/fsops.py
patch_lustre_path
def patch_lustre_path(f_path): """Patch any 60-character pathnames, to avoid a current Lustre bug.""" if CHECK_LUSTRE_PATH_LEN and len(f_path) == 60: if os.path.isabs(f_path): f_path = '/.' + f_path else: f_path = './' + f_path return f_path
python
def patch_lustre_path(f_path): """Patch any 60-character pathnames, to avoid a current Lustre bug.""" if CHECK_LUSTRE_PATH_LEN and len(f_path) == 60: if os.path.isabs(f_path): f_path = '/.' + f_path else: f_path = './' + f_path return f_path
[ "def", "patch_lustre_path", "(", "f_path", ")", ":", "if", "CHECK_LUSTRE_PATH_LEN", "and", "len", "(", "f_path", ")", "==", "60", ":", "if", "os", ".", "path", ".", "isabs", "(", "f_path", ")", ":", "f_path", "=", "'/.'", "+", "f_path", "else", ":", ...
Patch any 60-character pathnames, to avoid a current Lustre bug.
[ "Patch", "any", "60", "-", "character", "pathnames", "to", "avoid", "a", "current", "Lustre", "bug", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/fsops.py#L120-L129
payu-org/payu
payu/manifest.py
PayuManifest.check_fast
def check_fast(self, reproduce=False, **args): """ Check hash value for all filepaths using a fast hash function and fall back to slower full hash functions if fast hashes fail to agree. """ hashvals = {} fast_check = self.check_file( filepaths=self.data.keys...
python
def check_fast(self, reproduce=False, **args): """ Check hash value for all filepaths using a fast hash function and fall back to slower full hash functions if fast hashes fail to agree. """ hashvals = {} fast_check = self.check_file( filepaths=self.data.keys...
[ "def", "check_fast", "(", "self", ",", "reproduce", "=", "False", ",", "*", "*", "args", ")", ":", "hashvals", "=", "{", "}", "fast_check", "=", "self", ".", "check_file", "(", "filepaths", "=", "self", ".", "data", ".", "keys", "(", ")", ",", "has...
Check hash value for all filepaths using a fast hash function and fall back to slower full hash functions if fast hashes fail to agree.
[ "Check", "hash", "value", "for", "all", "filepaths", "using", "a", "fast", "hash", "function", "and", "fall", "back", "to", "slower", "full", "hash", "functions", "if", "fast", "hashes", "fail", "to", "agree", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/manifest.py#L50-L127
payu-org/payu
payu/manifest.py
PayuManifest.add_filepath
def add_filepath(self, filepath, fullpath, copy=False): """ Bespoke function to add filepath & fullpath to manifest object without hashing. Can defer hashing until all files are added. Hashing all at once is much faster as overhead for threading is spread over all files "...
python
def add_filepath(self, filepath, fullpath, copy=False): """ Bespoke function to add filepath & fullpath to manifest object without hashing. Can defer hashing until all files are added. Hashing all at once is much faster as overhead for threading is spread over all files "...
[ "def", "add_filepath", "(", "self", ",", "filepath", ",", "fullpath", ",", "copy", "=", "False", ")", ":", "# Ignore directories", "if", "os", ".", "path", ".", "isdir", "(", "fullpath", ")", ":", "return", "False", "# Ignore anything matching the ignore pattern...
Bespoke function to add filepath & fullpath to manifest object without hashing. Can defer hashing until all files are added. Hashing all at once is much faster as overhead for threading is spread over all files
[ "Bespoke", "function", "to", "add", "filepath", "&", "fullpath", "to", "manifest", "object", "without", "hashing", ".", "Can", "defer", "hashing", "until", "all", "files", "are", "added", ".", "Hashing", "all", "at", "once", "is", "much", "faster", "as", "...
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/manifest.py#L129-L160
payu-org/payu
payu/manifest.py
PayuManifest.add_fast
def add_fast(self, filepath, hashfn=None, force=False): """ Bespoke function to add filepaths but set shortcircuit to True, which means only the first calculable hash will be stored. In this way only one "fast" hashing function need be called for each filepath. """ if has...
python
def add_fast(self, filepath, hashfn=None, force=False): """ Bespoke function to add filepaths but set shortcircuit to True, which means only the first calculable hash will be stored. In this way only one "fast" hashing function need be called for each filepath. """ if has...
[ "def", "add_fast", "(", "self", ",", "filepath", ",", "hashfn", "=", "None", ",", "force", "=", "False", ")", ":", "if", "hashfn", "is", "None", ":", "hashfn", "=", "fast_hashes", "self", ".", "add", "(", "filepath", ",", "hashfn", ",", "force", ",",...
Bespoke function to add filepaths but set shortcircuit to True, which means only the first calculable hash will be stored. In this way only one "fast" hashing function need be called for each filepath.
[ "Bespoke", "function", "to", "add", "filepaths", "but", "set", "shortcircuit", "to", "True", "which", "means", "only", "the", "first", "calculable", "hash", "will", "be", "stored", ".", "In", "this", "way", "only", "one", "fast", "hashing", "function", "need...
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/manifest.py#L162-L170
payu-org/payu
payu/manifest.py
PayuManifest.copy_file
def copy_file(self, filepath): """ Returns flag which says to copy rather than link a file. """ copy_file = False try: copy_file = self.data[filepath]['copy'] except KeyError: return False return copy_file
python
def copy_file(self, filepath): """ Returns flag which says to copy rather than link a file. """ copy_file = False try: copy_file = self.data[filepath]['copy'] except KeyError: return False return copy_file
[ "def", "copy_file", "(", "self", ",", "filepath", ")", ":", "copy_file", "=", "False", "try", ":", "copy_file", "=", "self", ".", "data", "[", "filepath", "]", "[", "'copy'", "]", "except", "KeyError", ":", "return", "False", "return", "copy_file" ]
Returns flag which says to copy rather than link a file.
[ "Returns", "flag", "which", "says", "to", "copy", "rather", "than", "link", "a", "file", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/manifest.py#L172-L181
payu-org/payu
payu/manifest.py
PayuManifest.make_link
def make_link(self, filepath): """ Payu integration function for creating symlinks in work directories which point back to the original file. """ # Check file exists. It may have been deleted but still in manifest if not os.path.exists(self.fullpath(filepath)): ...
python
def make_link(self, filepath): """ Payu integration function for creating symlinks in work directories which point back to the original file. """ # Check file exists. It may have been deleted but still in manifest if not os.path.exists(self.fullpath(filepath)): ...
[ "def", "make_link", "(", "self", ",", "filepath", ")", ":", "# Check file exists. It may have been deleted but still in manifest", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "fullpath", "(", "filepath", ")", ")", ":", "print", "(", "'File n...
Payu integration function for creating symlinks in work directories which point back to the original file.
[ "Payu", "integration", "function", "for", "creating", "symlinks", "in", "work", "directories", "which", "point", "back", "to", "the", "original", "file", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/manifest.py#L183-L217
payu-org/payu
payu/manifest.py
Manifest.add_filepath
def add_filepath(self, manifest, filepath, fullpath, copy=False): """ Wrapper to the add_filepath function in PayuManifest. Prevents outside code from directly calling anything in PayuManifest. """ filepath = os.path.normpath(filepath) if self.manifests[manifest].add_file...
python
def add_filepath(self, manifest, filepath, fullpath, copy=False): """ Wrapper to the add_filepath function in PayuManifest. Prevents outside code from directly calling anything in PayuManifest. """ filepath = os.path.normpath(filepath) if self.manifests[manifest].add_file...
[ "def", "add_filepath", "(", "self", ",", "manifest", ",", "filepath", ",", "fullpath", ",", "copy", "=", "False", ")", ":", "filepath", "=", "os", ".", "path", ".", "normpath", "(", "filepath", ")", "if", "self", ".", "manifests", "[", "manifest", "]",...
Wrapper to the add_filepath function in PayuManifest. Prevents outside code from directly calling anything in PayuManifest.
[ "Wrapper", "to", "the", "add_filepath", "function", "in", "PayuManifest", ".", "Prevents", "outside", "code", "from", "directly", "calling", "anything", "in", "PayuManifest", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/manifest.py#L393-L401
payu-org/payu
payu/runlog.py
commit_hash
def commit_hash(dir='.'): """ Return commit hash for HEAD of checked out branch of the specified directory. """ cmd = ['git', 'rev-parse', 'HEAD'] try: with open(os.devnull, 'w') as devnull: revision_hash = subprocess.check_output( cmd, cwd=d...
python
def commit_hash(dir='.'): """ Return commit hash for HEAD of checked out branch of the specified directory. """ cmd = ['git', 'rev-parse', 'HEAD'] try: with open(os.devnull, 'w') as devnull: revision_hash = subprocess.check_output( cmd, cwd=d...
[ "def", "commit_hash", "(", "dir", "=", "'.'", ")", ":", "cmd", "=", "[", "'git'", ",", "'rev-parse'", ",", "'HEAD'", "]", "try", ":", "with", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "as", "devnull", ":", "revision_hash", "=", "subprocess"...
Return commit hash for HEAD of checked out branch of the specified directory.
[ "Return", "commit", "hash", "for", "HEAD", "of", "checked", "out", "branch", "of", "the", "specified", "directory", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/runlog.py#L283-L304
payu-org/payu
payu/runlog.py
Runlog.create_manifest
def create_manifest(self): """Construct the list of files to be tracked by the runlog.""" config_path = os.path.join(self.expt.control_path, DEFAULT_CONFIG_FNAME) self.manifest = [] if os.path.isfile(config_path): self.manifest.append(conf...
python
def create_manifest(self): """Construct the list of files to be tracked by the runlog.""" config_path = os.path.join(self.expt.control_path, DEFAULT_CONFIG_FNAME) self.manifest = [] if os.path.isfile(config_path): self.manifest.append(conf...
[ "def", "create_manifest", "(", "self", ")", ":", "config_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "expt", ".", "control_path", ",", "DEFAULT_CONFIG_FNAME", ")", "self", ".", "manifest", "=", "[", "]", "if", "os", ".", "path", ".", ...
Construct the list of files to be tracked by the runlog.
[ "Construct", "the", "list", "of", "files", "to", "be", "tracked", "by", "the", "runlog", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/runlog.py#L53-L71
payu-org/payu
payu/runlog.py
Runlog.push
def push(self): """Push the changes to the remote repository. Usage: payu push This command pushes local runlog changes to the remote runlog repository, currently named `payu`, using the SSH key associated with this experiment. For an experiment `test`, it is equivalen...
python
def push(self): """Push the changes to the remote repository. Usage: payu push This command pushes local runlog changes to the remote runlog repository, currently named `payu`, using the SSH key associated with this experiment. For an experiment `test`, it is equivalen...
[ "def", "push", "(", "self", ")", ":", "expt_name", "=", "self", ".", "config", ".", "get", "(", "'name'", ",", "self", ".", "expt", ".", "name", ")", "default_ssh_key", "=", "'id_rsa_payu_'", "+", "expt_name", "ssh_key", "=", "self", ".", "config", "."...
Push the changes to the remote repository. Usage: payu push This command pushes local runlog changes to the remote runlog repository, currently named `payu`, using the SSH key associated with this experiment. For an experiment `test`, it is equivalent to the following command:...
[ "Push", "the", "changes", "to", "the", "remote", "repository", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/runlog.py#L107-L138
payu-org/payu
payu/runlog.py
Runlog.github_setup
def github_setup(self): """Set up authentication keys and API tokens.""" github_auth = self.authenticate() github_username = github_auth[0] expt_name = self.config.get('name', self.expt.name) expt_description = self.expt.config.get('description') if not expt_description:...
python
def github_setup(self): """Set up authentication keys and API tokens.""" github_auth = self.authenticate() github_username = github_auth[0] expt_name = self.config.get('name', self.expt.name) expt_description = self.expt.config.get('description') if not expt_description:...
[ "def", "github_setup", "(", "self", ")", ":", "github_auth", "=", "self", ".", "authenticate", "(", ")", "github_username", "=", "github_auth", "[", "0", "]", "expt_name", "=", "self", ".", "config", ".", "get", "(", "'name'", ",", "self", ".", "expt", ...
Set up authentication keys and API tokens.
[ "Set", "up", "authentication", "keys", "and", "API", "tokens", "." ]
train
https://github.com/payu-org/payu/blob/1442a9a226012eff248b8097cc1eaabc3e224867/payu/runlog.py#L140-L264
mozilla/python_moztelemetry
moztelemetry/shared_telemetry_utils.py
add_expiration_postfix
def add_expiration_postfix(expiration): """ Formats the expiration version and adds a version postfix if needed. :param expiration: the expiration version string. :return: the modified expiration string. """ if re.match(r'^[1-9][0-9]*$', expiration): return expiration + ".0a1" if re.ma...
python
def add_expiration_postfix(expiration): """ Formats the expiration version and adds a version postfix if needed. :param expiration: the expiration version string. :return: the modified expiration string. """ if re.match(r'^[1-9][0-9]*$', expiration): return expiration + ".0a1" if re.ma...
[ "def", "add_expiration_postfix", "(", "expiration", ")", ":", "if", "re", ".", "match", "(", "r'^[1-9][0-9]*$'", ",", "expiration", ")", ":", "return", "expiration", "+", "\".0a1\"", "if", "re", ".", "match", "(", "r'^[1-9][0-9]*\\.0$'", ",", "expiration", ")"...
Formats the expiration version and adds a version postfix if needed. :param expiration: the expiration version string. :return: the modified expiration string.
[ "Formats", "the", "expiration", "version", "and", "adds", "a", "version", "postfix", "if", "needed", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/shared_telemetry_utils.py#L123-L135
mozilla/python_moztelemetry
moztelemetry/shared_telemetry_utils.py
load_yaml_file
def load_yaml_file(filename): """ Load a YAML file from disk, throw a ParserError on failure.""" try: with open(filename, 'r') as f: return yaml.safe_load(f) except IOError as e: raise ParserError('Error opening ' + filename + ': ' + e.message) except ValueError as e: ...
python
def load_yaml_file(filename): """ Load a YAML file from disk, throw a ParserError on failure.""" try: with open(filename, 'r') as f: return yaml.safe_load(f) except IOError as e: raise ParserError('Error opening ' + filename + ': ' + e.message) except ValueError as e: ...
[ "def", "load_yaml_file", "(", "filename", ")", ":", "try", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "return", "yaml", ".", "safe_load", "(", "f", ")", "except", "IOError", "as", "e", ":", "raise", "ParserError", "(", "'E...
Load a YAML file from disk, throw a ParserError on failure.
[ "Load", "a", "YAML", "file", "from", "disk", "throw", "a", "ParserError", "on", "failure", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/shared_telemetry_utils.py#L138-L147
mozilla/python_moztelemetry
moztelemetry/shared_telemetry_utils.py
StringTable.stringIndex
def stringIndex(self, string): """Returns the index in the table of the provided string. Adds the string to the table if it's not there. :param string: the input string. """ if string in self.table: return self.table[string] else: result = self.cur...
python
def stringIndex(self, string): """Returns the index in the table of the provided string. Adds the string to the table if it's not there. :param string: the input string. """ if string in self.table: return self.table[string] else: result = self.cur...
[ "def", "stringIndex", "(", "self", ",", "string", ")", ":", "if", "string", "in", "self", ".", "table", ":", "return", "self", ".", "table", "[", "string", "]", "else", ":", "result", "=", "self", ".", "current_index", "self", ".", "table", "[", "str...
Returns the index in the table of the provided string. Adds the string to the table if it's not there. :param string: the input string.
[ "Returns", "the", "index", "in", "the", "table", "of", "the", "provided", "string", ".", "Adds", "the", "string", "to", "the", "table", "if", "it", "s", "not", "there", ".", ":", "param", "string", ":", "the", "input", "string", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/shared_telemetry_utils.py#L54-L65
mozilla/python_moztelemetry
moztelemetry/shared_telemetry_utils.py
StringTable.writeDefinition
def writeDefinition(self, f, name): """Writes the string table to a file as a C const char array. This writes out the string table as one single C char array for memory size reasons, separating the individual strings with '\0' characters. This way we can index directly into the string a...
python
def writeDefinition(self, f, name): """Writes the string table to a file as a C const char array. This writes out the string table as one single C char array for memory size reasons, separating the individual strings with '\0' characters. This way we can index directly into the string a...
[ "def", "writeDefinition", "(", "self", ",", "f", ",", "name", ")", ":", "entries", "=", "self", ".", "table", ".", "items", "(", ")", "entries", ".", "sort", "(", "key", "=", "lambda", "x", ":", "x", "[", "1", "]", ")", "# Avoid null-in-string warnin...
Writes the string table to a file as a C const char array. This writes out the string table as one single C char array for memory size reasons, separating the individual strings with '\0' characters. This way we can index directly into the string array and avoid the additional storage c...
[ "Writes", "the", "string", "table", "to", "a", "file", "as", "a", "C", "const", "char", "array", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/shared_telemetry_utils.py#L74-L110
Karaage-Cluster/karaage
karaage/templatetags/karaage_tags.py
comments
def comments(context, obj): """ Render comments for obj. """ content_type = ContentType.objects.get_for_model(obj.__class__) comment_list = LogEntry.objects.filter( content_type=content_type, object_id=obj.pk, action_flag=COMMENT ) return { 'obj': obj, 'commen...
python
def comments(context, obj): """ Render comments for obj. """ content_type = ContentType.objects.get_for_model(obj.__class__) comment_list = LogEntry.objects.filter( content_type=content_type, object_id=obj.pk, action_flag=COMMENT ) return { 'obj': obj, 'commen...
[ "def", "comments", "(", "context", ",", "obj", ")", ":", "content_type", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "obj", ".", "__class__", ")", "comment_list", "=", "LogEntry", ".", "objects", ".", "filter", "(", "content_type", "=", ...
Render comments for obj.
[ "Render", "comments", "for", "obj", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/templatetags/karaage_tags.py#L98-L110
Karaage-Cluster/karaage
karaage/machines/xmlrpc.py
get_disk_quota
def get_disk_quota(username, machine_name=None): """ Returns disk quota for username in KB """ try: ua = Account.objects.get( username=username, date_deleted__isnull=True) except Account.DoesNotExist: return 'Account not found' result = ua.get_disk_quota...
python
def get_disk_quota(username, machine_name=None): """ Returns disk quota for username in KB """ try: ua = Account.objects.get( username=username, date_deleted__isnull=True) except Account.DoesNotExist: return 'Account not found' result = ua.get_disk_quota...
[ "def", "get_disk_quota", "(", "username", ",", "machine_name", "=", "None", ")", ":", "try", ":", "ua", "=", "Account", ".", "objects", ".", "get", "(", "username", "=", "username", ",", "date_deleted__isnull", "=", "True", ")", "except", "Account", ".", ...
Returns disk quota for username in KB
[ "Returns", "disk", "quota", "for", "username", "in", "KB" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/machines/xmlrpc.py#L25-L41
Karaage-Cluster/karaage
karaage/plugins/kgusage/tasks.py
_gen_project_trend_graph
def _gen_project_trend_graph(project, start, end, force_overwrite=False): """Generates a bar graph for a project Keyword arguments: project -- Project start -- start date end -- end date """ filename = graphs.get_project_trend_graph_filename(project, start, end) csv_filename = os.path....
python
def _gen_project_trend_graph(project, start, end, force_overwrite=False): """Generates a bar graph for a project Keyword arguments: project -- Project start -- start date end -- end date """ filename = graphs.get_project_trend_graph_filename(project, start, end) csv_filename = os.path....
[ "def", "_gen_project_trend_graph", "(", "project", ",", "start", ",", "end", ",", "force_overwrite", "=", "False", ")", ":", "filename", "=", "graphs", ".", "get_project_trend_graph_filename", "(", "project", ",", "start", ",", "end", ")", "csv_filename", "=", ...
Generates a bar graph for a project Keyword arguments: project -- Project start -- start date end -- end date
[ "Generates", "a", "bar", "graph", "for", "a", "project" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/tasks.py#L365-L477
Karaage-Cluster/karaage
karaage/plugins/kgusage/tasks.py
_gen_institute_graph
def _gen_institute_graph(start, end, force_overwrite=False): """ Pie chart comparing institutes usage. """ filename = graphs.get_institute_graph_filename(start, end) csv_filename = os.path.join(GRAPH_ROOT, filename + '.csv') png_filename = os.path.join(GRAPH_ROOT, filename + '.png') _check_director...
python
def _gen_institute_graph(start, end, force_overwrite=False): """ Pie chart comparing institutes usage. """ filename = graphs.get_institute_graph_filename(start, end) csv_filename = os.path.join(GRAPH_ROOT, filename + '.csv') png_filename = os.path.join(GRAPH_ROOT, filename + '.png') _check_director...
[ "def", "_gen_institute_graph", "(", "start", ",", "end", ",", "force_overwrite", "=", "False", ")", ":", "filename", "=", "graphs", ".", "get_institute_graph_filename", "(", "start", ",", "end", ")", "csv_filename", "=", "os", ".", "path", ".", "join", "(", ...
Pie chart comparing institutes usage.
[ "Pie", "chart", "comparing", "institutes", "usage", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/tasks.py#L480-L521
Karaage-Cluster/karaage
karaage/plugins/kgusage/tasks.py
_gen_machine_graph
def _gen_machine_graph(start, end, force_overwrite=False): """ Pie chart comparing machines usage. """ filename = graphs.get_machine_graph_filename(start, end) csv_filename = os.path.join(GRAPH_ROOT, filename + '.csv') png_filename = os.path.join(GRAPH_ROOT, filename + '.png') _check_directory_exis...
python
def _gen_machine_graph(start, end, force_overwrite=False): """ Pie chart comparing machines usage. """ filename = graphs.get_machine_graph_filename(start, end) csv_filename = os.path.join(GRAPH_ROOT, filename + '.csv') png_filename = os.path.join(GRAPH_ROOT, filename + '.png') _check_directory_exis...
[ "def", "_gen_machine_graph", "(", "start", ",", "end", ",", "force_overwrite", "=", "False", ")", ":", "filename", "=", "graphs", ".", "get_machine_graph_filename", "(", "start", ",", "end", ")", "csv_filename", "=", "os", ".", "path", ".", "join", "(", "G...
Pie chart comparing machines usage.
[ "Pie", "chart", "comparing", "machines", "usage", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/tasks.py#L524-L561
Karaage-Cluster/karaage
karaage/plugins/kgusage/tasks.py
_gen_trend_graph
def _gen_trend_graph(start, end, force_overwrite=False): """ Total trend graph for machine category. """ filename = graphs.get_trend_graph_filename(start, end) csv_filename = os.path.join(GRAPH_ROOT, filename + '.csv') png_filename = os.path.join(GRAPH_ROOT, filename + '.png') _check_directory_exis...
python
def _gen_trend_graph(start, end, force_overwrite=False): """ Total trend graph for machine category. """ filename = graphs.get_trend_graph_filename(start, end) csv_filename = os.path.join(GRAPH_ROOT, filename + '.csv') png_filename = os.path.join(GRAPH_ROOT, filename + '.png') _check_directory_exis...
[ "def", "_gen_trend_graph", "(", "start", ",", "end", ",", "force_overwrite", "=", "False", ")", ":", "filename", "=", "graphs", ".", "get_trend_graph_filename", "(", "start", ",", "end", ")", "csv_filename", "=", "os", ".", "path", ".", "join", "(", "GRAPH...
Total trend graph for machine category.
[ "Total", "trend", "graph", "for", "machine", "category", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/tasks.py#L564-L636
mozilla/python_moztelemetry
moztelemetry/standards.py
daynum_to_date
def daynum_to_date(daynum, max_days=1000000): """ Convert a number of days to a date. If it's out of range, default to a max date. If it is not a number (or a numeric string), return None. Using a max_days of more than 2932896 (9999-12-31) will throw an exception if the specified daynum exceeds the max....
python
def daynum_to_date(daynum, max_days=1000000): """ Convert a number of days to a date. If it's out of range, default to a max date. If it is not a number (or a numeric string), return None. Using a max_days of more than 2932896 (9999-12-31) will throw an exception if the specified daynum exceeds the max....
[ "def", "daynum_to_date", "(", "daynum", ",", "max_days", "=", "1000000", ")", ":", "if", "daynum", "is", "None", ":", "return", "None", "try", ":", "daycount", "=", "int", "(", "daynum", ")", "except", "ValueError", ":", "return", "None", "if", "daycount...
Convert a number of days to a date. If it's out of range, default to a max date. If it is not a number (or a numeric string), return None. Using a max_days of more than 2932896 (9999-12-31) will throw an exception if the specified daynum exceeds the max. :param daynum: A number of days since Jan 1, 1970
[ "Convert", "a", "number", "of", "days", "to", "a", "date", ".", "If", "it", "s", "out", "of", "range", "default", "to", "a", "max", "date", ".", "If", "it", "is", "not", "a", "number", "(", "or", "a", "numeric", "string", ")", "return", "None", "...
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/standards.py#L22-L39
mozilla/python_moztelemetry
moztelemetry/standards.py
mau
def mau(dataframe, target_day, past_days=28, future_days=10, date_format="%Y%m%d"): """Compute Monthly Active Users (MAU) from the Executive Summary dataset. See https://bugzilla.mozilla.org/show_bug.cgi?id=1240849 """ target_day_date = datetime.strptime(target_day, date_format) # Compute activity ...
python
def mau(dataframe, target_day, past_days=28, future_days=10, date_format="%Y%m%d"): """Compute Monthly Active Users (MAU) from the Executive Summary dataset. See https://bugzilla.mozilla.org/show_bug.cgi?id=1240849 """ target_day_date = datetime.strptime(target_day, date_format) # Compute activity ...
[ "def", "mau", "(", "dataframe", ",", "target_day", ",", "past_days", "=", "28", ",", "future_days", "=", "10", ",", "date_format", "=", "\"%Y%m%d\"", ")", ":", "target_day_date", "=", "datetime", ".", "strptime", "(", "target_day", ",", "date_format", ")", ...
Compute Monthly Active Users (MAU) from the Executive Summary dataset. See https://bugzilla.mozilla.org/show_bug.cgi?id=1240849
[ "Compute", "Monthly", "Active", "Users", "(", "MAU", ")", "from", "the", "Executive", "Summary", "dataset", ".", "See", "https", ":", "//", "bugzilla", ".", "mozilla", ".", "org", "/", "show_bug", ".", "cgi?id", "=", "1240849" ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/standards.py#L74-L93
mozilla/python_moztelemetry
moztelemetry/standards.py
snap_to_beginning_of_week
def snap_to_beginning_of_week(day, weekday_start="Sunday"): """ Get the first day of the current week. :param day: The input date to snap. :param weekday_start: Either "Monday" or "Sunday", indicating the first day of the week. :returns: A date representing the first day of the current week. """ ...
python
def snap_to_beginning_of_week(day, weekday_start="Sunday"): """ Get the first day of the current week. :param day: The input date to snap. :param weekday_start: Either "Monday" or "Sunday", indicating the first day of the week. :returns: A date representing the first day of the current week. """ ...
[ "def", "snap_to_beginning_of_week", "(", "day", ",", "weekday_start", "=", "\"Sunday\"", ")", ":", "delta_days", "=", "(", "(", "day", ".", "weekday", "(", ")", "+", "1", ")", "%", "7", ")", "if", "weekday_start", "is", "\"Sunday\"", "else", "day", ".", ...
Get the first day of the current week. :param day: The input date to snap. :param weekday_start: Either "Monday" or "Sunday", indicating the first day of the week. :returns: A date representing the first day of the current week.
[ "Get", "the", "first", "day", "of", "the", "current", "week", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/standards.py#L96-L104
mozilla/python_moztelemetry
moztelemetry/standards.py
get_last_week_range
def get_last_week_range(weekday_start="Sunday"): """ Gets the date for the first and the last day of the previous complete week. :param weekday_start: Either "Monday" or "Sunday", indicating the first day of the week. :returns: A tuple containing two date objects, for the first and the last day of the week...
python
def get_last_week_range(weekday_start="Sunday"): """ Gets the date for the first and the last day of the previous complete week. :param weekday_start: Either "Monday" or "Sunday", indicating the first day of the week. :returns: A tuple containing two date objects, for the first and the last day of the week...
[ "def", "get_last_week_range", "(", "weekday_start", "=", "\"Sunday\"", ")", ":", "today", "=", "date", ".", "today", "(", ")", "# Get the first day of the past complete week.", "start_of_week", "=", "snap_to_beginning_of_week", "(", "today", ",", "weekday_start", ")", ...
Gets the date for the first and the last day of the previous complete week. :param weekday_start: Either "Monday" or "Sunday", indicating the first day of the week. :returns: A tuple containing two date objects, for the first and the last day of the week respectively.
[ "Gets", "the", "date", "for", "the", "first", "and", "the", "last", "day", "of", "the", "previous", "complete", "week", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/standards.py#L116-L127