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_documentation_string stringlengths 1 47.2k | 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':
... | Gets and parses file | 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] | Returns all comments | 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_... | Gets and parses file | 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] | Returns all compound origins | 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:
... | Gets and parses file | 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') | Returns parent id | 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... | Returns all modified on | 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') | Returns created by | 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... | Gets and parses file | 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] | COMMENT | 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] | Returns all database accessions | 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])
... | Gets and parses file | 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] | Gets and parses file | 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] | Returns all names | 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 ... | Gets and parses file | 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... | Returns references | 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] | Returns all outgoings | 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] | Returns all incomings | 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... | Gets and parses file | 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... | Returns mol | 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... | Returns mol file | 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] == '... | COMMENT | 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... | COMMENT | 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... | Downloads filename from ChEBI FTP site | 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() | Checks whether file is current | 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... | Returns last FTP site update time | 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_... | Get the first Tuesday of the month | 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... | 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)
... | 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)
... | 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) | 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... | 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... | 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,
... | 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... | 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),
... | 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... | 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.)... | 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... | 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... | 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, ... | 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... | 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... | 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=... | 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... | 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... | 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
... | 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... | 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... | 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
# -... | 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... | 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... | 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... | 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(
... | Returns the data dictionary of a CMS page that is used by the frontend. | 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... | 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. | 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... | 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. | 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.... | 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... | 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... | 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. | 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(
... | 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.),
... | 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... | 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'),... | 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... | Read the specified file object and return a dictionary with the parsed data.
:param file_obj: a Python file object | 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... | Define the paths associated with this model. | 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... | Store model output to laboratory archive. | 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__ + '.')
... | Parse the command line inputs and execute the subcommand. | 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... | Determine and validate the active model type. | 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... | Construct the environment variables used by payu for resubmissions. | 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... | Submit a userscript the scheduler. | 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 ... | Substitute a new timestep value using regex. | 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) | Convert an int of form yyyymmdd to a python date object. | 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,
... | Get the number of seconds from start date to start date + date_delta.
Ignores Feb 29 for caltype == NOLEAP. | 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... | Get a new_date = date + seconds.
Ignores Feb 29 for no-leap days. | 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... | Find the number of leap days between arbitrary dates. Returns a
timedelta object.
FIXME: calculate this instead of iterating. | 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... | Currently unsupported, it only works for differences in years. | 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... | Generate a default laboratory path based on user environment. | 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) | Create the laboratory directories. | 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) | Return PBS job id | 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... | Get information about the job from the PBS server | 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, '... | Submit a postprocessing script after collation | 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 ... | 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. | 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] | Convert a date object to 'year, month, day, hour, minute, second.' | 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]) | Convert a string with format 'year, month, day, hour, minute, second'
to a datetime date. | 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... | Set the environment modules used by the Environment Module system. | 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 ... | Run the modulecmd tool and use its Python-formatted output to set the
environment variables. | 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'... | Patch input.nml as a new or restart run. | 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 | Create a new directory; ignore if it already exists. | 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... | Parse input configuration file and return a config dict. | 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... | Safely create a symbolic link to an input field. | 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,) | Recursively split a filepath into all directories and files. | 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 | Patch any 60-character pathnames, to avoid a current Lustre bug. | 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... | 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. | 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
"... | 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 | 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... | 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. | 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 | Returns flag which says to copy rather than link a file. | 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)):
... | Payu integration function for creating symlinks in work directories
which point back to the original file. | 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... | Wrapper to the add_filepath function in PayuManifest. Prevents outside
code from directly calling anything in PayuManifest. | 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... | Return commit hash for HEAD of checked out branch of the
specified directory. | 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... | Construct the list of files to be tracked by the runlog. | 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... | 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:... | 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:... | Set up authentication keys and API tokens. | 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... | Formats the expiration version and adds a version postfix if needed.
:param expiration: the expiration version string.
:return: the modified expiration string. | 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:
... | Load a YAML file from disk, throw a ParserError on failure. | 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... | 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. | 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... | 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... | 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... | Render comments for obj. | 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... | Returns disk quota for username in KB | 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.... | Generates a bar graph for a project
Keyword arguments:
project -- Project
start -- start date
end -- end date | 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... | Pie chart comparing institutes usage. | 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... | Pie chart comparing machines usage. | 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... | Total trend graph for machine category. | 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.... | 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 | 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 ... | Compute Monthly Active Users (MAU) from the Executive Summary dataset.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1240849 | 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.
"""
... | 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. | 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... | 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. | https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/standards.py#L116-L127 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.