sequence stringlengths 1.19k 35k | code stringlengths 75 8.58k |
|---|---|
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'databasesKEGG'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def databasesKEGG(organism,ens_ids):
all_genes=urlopen("http://rest.kegg.jp/list/"+organism).read()
all_genes=all_genes.split("\n")
dbs=[]
while len(dbs) == 0:
for g in all_genes:
if len(dbs) == 0:
kid = g.split("\t")[0]
gene=urlopen("http://rest.kegg.... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def process(self, form, post):
if not isinstance(form, FormMeta):
raise TypeError('Given form is not a valid WTForm.')
re_field_name = re.compile(r'\%([a-zA-Z0-9_]*)\%')
class F(form):
pass
for field, data in post.iteritems():
if field in F():
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'distinct_values'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def distinct_values(t_old, t_new):
res = []
res.append([' -- NOT IN check -- '])
for new_col in t_new.header:
dist_new = t_new.get_distinct_values_from_cols([new_col])
for old_col in t_old.header:
if old_col == new_col:
dist_old = t_old.get_distinct_values_from... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'most_similar_catchments'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier... | def most_similar_catchments(self, subject_catchment, similarity_dist_function, records_limit=500,
include_subject_catchment='auto'):
if include_subject_catchment not in ['auto', 'force', 'exclude']:
raise ValueError("Parameter `include_subject_catchment={}` invalid.".... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'readSAM'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'SAMf... | def readSAM(SAMfile,header=False):
if header==True:
f=open(SAMfile,"r+")
head=[]
for line in f.readlines():
if line[0]=="@":
head.append(line)
else:
continue
f.close()
sam=pd.read_table(SAMfile,sep="this_gives_one_column",co... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'SAMflags'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'}, {'i... | def SAMflags(x):
flags=[]
if x & 1:
l="1: Read paired"
else:
l="0: Read unpaired"
flags.append(l)
if x & 2 :
l="1: Read mapped in proper pair"
else:
l="0: Read not mapped in proper pair"
flags.append(l)
if x & 4 :
l="1: Read unmapped"
else:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '74']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'BLASTquery'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '11', '14', '17', '18', '21', '24', '25', '28'... | def BLASTquery(query,database,program,filter=None,\
format_type=None, expect=None,\
nucl_reward=None, nucl_penalty=None,\
gapcosts=None, matrix=None,\
hitlist_size=None, descriptions=None,\
alignments=None,\
ncbi_gi=None, threshol... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_star'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def run_star(job, fastqs, univ_options, star_options):
assert star_options['type'] in ('star', 'starlong')
work_dir = os.getcwd()
input_files = {
'rna_cutadapt_1.fastq': fastqs[0],
'rna_cutadapt_2.fastq': fastqs[1],
'star_index.tar.gz': star_options['index']}
input_files = get_fi... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_and_index_star'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'childre... | def sort_and_index_star(job, star_bams, univ_options, star_options):
star_options['samtools']['n'] = star_options['n']
sort = job.wrapJobFn(sort_bamfile, star_bams['rnaAligned.out.bam'], 'rna', univ_options,
samtools_options=star_options['samtools'],
disk=Promis... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'evaluate'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, ... | def evaluate(self):
ops = []
rpn = []
for token in self.expr:
if isinstance(token, int):
while len(ops) and token <= ops[-1]:
rpn.append(ops.pop())
ops.append(token)
else:
rpn.append(token)
while ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_ensure_patient_group_is_ok'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children'... | def _ensure_patient_group_is_ok(patient_object, patient_name=None):
from protect.addons.common import TCGAToGTEx
assert isinstance(patient_object, (set, dict)), '%s,%s' % (patient_object, patient_name)
test_set = set(patient_object)
if 'tumor_type' not in patient_object:
raise ParameterError(('T... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_default_entries'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def _add_default_entries(input_dict, defaults_dict):
for key, value in defaults_dict.iteritems():
if key == 'patients':
print('Cannot default `patients`.')
continue
if isinstance(value, dict):
if key not in input_dict or input_dict[key] is None:
in... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}, {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '24', '35', '56', '78', '105... | def main():
parser = argparse.ArgumentParser(prog='ProTECT',
description='Prediction of T-Cell Epitopes for Cancer Therapy',
epilog='Contact Arjun Rao (aarao@ucsc.edu) if you encounter '
'any problems whil... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'align_dna'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [... | def align_dna(job, fastqs, sample_type, univ_options, bwa_options):
bwa = job.wrapJobFn(run_bwa, fastqs, sample_type, univ_options, bwa_options,
disk=PromisedRequirement(bwa_disk, fastqs, bwa_options['index']),
memory=univ_options['java_Xmx'],
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}... | def create(cls, entry):
try:
module = import_module(entry)
except ImportError:
module = None
mod_path, _, cls_name = entry.rpartition('.')
if not mod_path:
raise
else:
try:
entry = module.default_bot
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'populate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | def populate(self, installed_bots=None):
if self.ready:
return
with self._lock:
if self.ready:
return
if self.loading:
raise RuntimeError("populate() isn't re-entrant")
self.loading = True
for entry in installed_... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_initkwargs'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '17']}; {'id': '4', 'type': 'identif... | def get_initkwargs(cls, form_list, initial_dict=None,
instance_dict=None, condition_dict=None, *args, **kwargs):
kwargs.update({
'initial_dict': initial_dict or {},
'instance_dict': instance_dict or {},
'condition_dict': condition_dict or {},
})
init_f... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'post'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def post(self, *args, **kwargs):
wizard_prev_step = self.request.POST.get('wizard_prev_step', None)
if wizard_prev_step and wizard_prev_step in self.get_form_list():
self.storage.current_step = wizard_prev_step
form = self.get_form(
data=self.storage.get_step_data... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_config_file'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def parse_config_file(job, config_file):
job.fileStore.logToMaster('Parsing config file')
config_file = os.path.abspath(config_file)
if not os.path.exists(config_file):
raise ParameterError('The config file was not found at specified location. Please verify ' +
'and retr... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_star'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def run_star(job, fastqs, univ_options, star_options):
assert star_options['type'] in ('star', 'starlong')
job.fileStore.logToMaster('Running STAR on %s' %univ_options['patient'])
work_dir = job.fileStore.getLocalTempDir()
input_files = {
'rna_cutadapt_1.fastq': fastqs['rna_cutadapt_1.fastq'],
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_bwa'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [],... | def run_bwa(job, fastqs, sample_type, univ_options, bwa_options):
job.fileStore.logToMaster('Running bwa on %s:%s' % (univ_options['patient'], sample_type))
work_dir = job.fileStore.getLocalTempDir()
fq_extn = '.gz' if fastqs['gzipped'] else ''
input_files = {
'dna_1.fastq' + fq_extn: fastqs[sam... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_radia'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def merge_radia(job, perchrom_rvs):
job.fileStore.logToMaster('Running merge_radia')
work_dir = job.fileStore.getLocalTempDir()
input_files = {filename: jsid for perchrom_files in perchrom_rvs.values()
for filename, jsid in perchrom_files.items()}
input_files = get_files_from_filestor... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_mutect'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def merge_mutect(job, perchrom_rvs):
job.fileStore.logToMaster('Running merge_mutect')
work_dir = job.fileStore.getLocalTempDir()
input_files = {filename: jsid for perchrom_files in perchrom_rvs.values()
for filename, jsid in perchrom_files.items()}
input_files = get_files_from_filest... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_mutation_aggregator'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identi... | def run_mutation_aggregator(job, fusion_output, radia_output, mutect_output, indel_output,
univ_options):
job.fileStore.logToMaster('Aggregating mutations for %s' % univ_options['patient'])
work_dir = job.fileStore.getLocalTempDir()
input_files = {
'mutect.vcf': mutect_ou... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_phlat_calls'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children'... | def merge_phlat_calls(job, tumor_phlat, normal_phlat, rna_phlat):
job.fileStore.logToMaster('Merging Phlat calls')
work_dir = job.fileStore.getLocalTempDir()
input_files = {
'tumor_dna': tumor_phlat,
'normal_dna': normal_phlat,
'tumor_rna': rna_phlat}
input_files = get_files_from... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'docker_call'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16']}; {'id': '4', 'type': 'identifier... | def docker_call(tool, tool_parameters, work_dir, java_opts=None, outfile=None,
dockerhub='aarjunrao', interactive=False):
if outfile:
assert isinstance(outfile, file), 'outfile was not passsed a file'
assert outfile.mode in ['w', 'a', 'wb', 'ab'], 'outfile not writeable'
asse... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_file_from_gdc'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children... | def get_file_from_gdc(job, gdc_url, gdc_download_token, write_to_jobstore=True):
work_dir = job.fileStore.getLocalTempDir()
parsed_url = urlparse(gdc_url)
assert parsed_url.scheme == 'gdc', 'Unexpected url scheme: %s' % gdc_url
file_dir = '/'.join([work_dir, parsed_url.netloc])
currwd = os.getcwd()
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_key_hippie'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def make_key_hippie(obj, typed=True):
ftype = type if typed else lambda o: None
if is_hashable(obj):
return obj, ftype(obj)
if isinstance(obj, set):
obj = sorted(obj)
if isinstance(obj, (list, tuple)):
return tuple(make_key_hippie(e, typed) for e in obj)
if isinstance(obj, di... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_radia'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'childr... | def run_radia(job, rna_bam, tumor_bam, normal_bam, univ_options, radia_options):
if 'rna_genome' in rna_bam.keys():
rna_bam = rna_bam['rna_genome']
elif set(rna_bam.keys()) == {'rna_genome_sorted.bam', 'rna_genome_sorted.bam.bai'}:
pass
else:
raise RuntimeError('An improperly formatt... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_bamfile'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children'... | def sort_bamfile(job, bamfile, sample_type, univ_options, samtools_options):
work_dir = os.getcwd()
in_bamfile = ''.join([sample_type, '.bam'])
out_bamfile = '_'.join([sample_type, 'sorted.bam'])
input_files = {
in_bamfile: bamfile}
input_files = get_files_from_filestore(job, input_files, wo... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'recursive_sort'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'da... | def recursive_sort(data_structure):
if not isinstance(data_structure, _primitive_types):
is_meta = isinstance(data_structure, Meta)
was_dict = isinstance(data_structure, WasDict)
if not (is_meta or was_dict):
was_dict = isinstance(data_structure, dict)
if not was_dict... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tree_diff'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def tree_diff(a, b, n=5, sort=False):
a = dump(a)
b = dump(b)
if not sort:
a = vformat(a).split("\n")
b = vformat(b).split("\n")
else:
a = vformat(recursive_sort(a)).split("\n")
b = vformat(recursive_sort(b)).split("\n")
return "\n".join(difflib.unified_diff(a, b, n=n... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_perchrom_mutations'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'ch... | def merge_perchrom_mutations(job, chrom, mutations, univ_options):
work_dir = os.getcwd()
from protect.mutation_calling.muse import process_muse_vcf
from protect.mutation_calling.mutect import process_mutect_vcf
from protect.mutation_calling.radia import process_radia_vcf
from protect.mutation_calli... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def check(domain, prefix, code, strategies='*'):
if strategies == '*' or 'dns_txt' in strategies:
if check_dns_txt(domain, prefix, code):
return True
if strategies == '*' or 'dns_cname' in strategies:
if check_dns_cname(domain, prefix, code):
return True
if strategies... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register_cache_buster'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children':... | def register_cache_buster(self, app, config=None):
if not (config is None or isinstance(config, dict)):
raise ValueError("`config` must be an instance of dict or None")
bust_map = {}
unbust_map = {}
app.logger.debug('Starting computing hashes for static assets')
for d... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_inventory'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6... | def parse_inventory(inventory_output=None):
udi = {
"name": "",
"description": "",
"pid": "",
"vid": "",
"sn": ""
}
if inventory_output is None:
return udi
capture_next = False
chassis_udi_text = None
for line in inventory_output.split('\n'):
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'yaml_file_to_dict'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def yaml_file_to_dict(script_name, path=None):
def load_yaml(file_path):
with open(file_path, 'r') as yamlfile:
try:
dictionary = yaml.load(yamlfile)
except yaml.YAMLError:
return {}
return dictionary
def merge(user, default):
if is... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_hop_info_from_url'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],... | def make_hop_info_from_url(url, verify_reachability=None):
parsed = urlparse(url)
username = None if parsed.username is None else unquote(parsed.username)
password = None if parsed.password is None else unquote(parsed.password)
try:
enable_password = parse_qs(parsed.query)["enable_password"][0]
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sendmail'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11']}; {'id': '4', 'type': 'identifier', 'childr... | async def sendmail(
self, sender, recipients, message, mail_options=None, rcpt_options=None
):
if isinstance(recipients, str):
recipients = [recipients]
if mail_options is None:
mail_options = []
if rcpt_options is None:
rcpt_options = []
a... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_fsm'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': 'identifier', 'ch... | def run_fsm(self, name, command, events, transitions, timeout, max_transitions=20):
return self._chain.target_device.run_fsm(name, command, events, transitions, timeout, max_transitions) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_view_details'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | def _get_view_details(self, urlpatterns, parent=''):
for pattern in urlpatterns:
if isinstance(pattern, (URLPattern, RegexURLPattern)):
try:
d = describe_pattern(pattern)
docstr = pattern.callback.__doc__
method = None
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scan_module'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def scan_module(self, modpath, node):
used_origins = self.map.setdefault(modpath, set())
def get_origins(modpath, name):
origins = set()
def walk_origins(modpath, name):
for origin in self.import_map.get_origins(modpath, name):
if origin not in... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'operations'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | def operations(self, op_types=None):
if not op_types:
op_types = ['message', 'action', 'sync', 'viewlock', 'savedchapter']
while self._handle.tell() < self._eof:
current_time = mgz.util.convert_to_timestamp(self._time / 1000)
try:
operation = mgz.body.... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id'... | def run(self):
ctx = FSM.Context(self.name, self.device)
transition_counter = 0
timeout = self.timeout
self.log("{} Start".format(self.name))
while transition_counter < self.max_transitions:
transition_counter += 1
try:
start_time = time()
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']},... | def build(port=8000, fixtures=None):
extractor = Extractor()
parser = Parser(extractor.url_details, fixtures)
parser.parse()
url_details = parser.results
_store = get_store(url_details)
store = json.dumps(_store)
variables = str(Variable('let', 'store', store))
functions = DATA_FINDER + ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gpg_decrypt'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def gpg_decrypt(cfg, gpg_config=None):
def decrypt(obj):
if isinstance(obj, list):
res_v = []
for item in obj:
res_v.append(decrypt(item))
return res_v
elif isinstance(obj, dict):
if '_gpg' in obj:
try:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_teams'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},... | def get_teams(self):
if self._cache['teams']:
return self._cache['teams']
teams = []
for j, player in enumerate(self._header.initial.players):
added = False
for i in range(0, len(self._header.initial.players)):
if player.attributes.my_diplomacy... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_settings'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | def get_settings(self):
postgame = self.get_postgame()
return {
'type': (
self._header.lobby.game_type_id,
self._header.lobby.game_type
),
'difficulty': (
self._header.scenario.game_settings.difficulty_id,
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_map'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {... | def get_map(self):
if self._cache['map']:
return self._cache['map']
map_id = self._header.scenario.game_settings.map_id
instructions = self._header.scenario.messages.instructions
size = mgz.const.MAP_SIZES.get(self._header.map_info.size_x)
dimension = self._header.map... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def update(self, *sources, follow_symlinks: bool=False,
maximum_depth: int=20):
for source in sources:
if isinstance(source, self.klass):
self.path_map[source.this.name.value] = source
self.class_cache[source.this.name.value] = source
co... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'error_view'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}, ... | def error_view(template_dir=None):
if not template_dir:
template_dir = "Pylot/Error"
template_page = "%s/index.html" % template_dir
class Error(Pylot):
@classmethod
def register(cls, app, **kwargs):
super(cls, cls).register(app, **kwargs)
@app.errorhandler(400... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_device_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def update_device_list(self, sessions):
if sessions is None:
_LOGGER.error('Error updating Emby devices.')
return
new_devices = []
active_devices = []
dev_update = False
for device in sessions:
dev_name = '{}.{}'.format(device['DeviceId'], devi... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}, {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '19', '25', '33', '43'... | def main():
parser = get_parser()
args = parser.parse_args()
ARCHIVE = args.archive_path
archive = (not args.no_archive)
os.environ['F2FORMAT_VERSION'] = args.python
os.environ['F2FORMAT_ENCODING'] = args.encoding
def find(root):
flst = list()
temp = os.listdir(root)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'random_useragent'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '... | def random_useragent(filename=True):
import random
default_ua = 'urlfetch/%s' % __version__
if isinstance(filename, basestring):
filenames = [filename]
else:
filenames = []
if filename and UAFILE:
filenames.append(UAFILE)
for filename in filenames:
try:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode_multipart'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def encode_multipart(data, files):
body = BytesIO()
boundary = choose_boundary()
part_boundary = b('--%s\r\n' % boundary)
writer = codecs.lookup('utf-8')[3]
if isinstance(data, dict):
for name, values in data.items():
if not isinstance(values, (list, tuple, set)):
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'assemble'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'code'}, ... | def assemble(code):
final = []
for line in code:
if isinstance(line, Label):
final.append(line)
continue
mnemonic, operands = line[0], line[1:]
operand_fmts = opcode_table[mnemonic]['operands']
final_operands = []
for i, operand in enumerate(operan... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_new'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | def _add_new(self, host_object):
i = self._get_insertion_point(host_object)
for listed in self[i:]:
if not listed.is_subdomain(host_object):
break
self.hosts.pop(i)
self.hosts.insert(i, host_object.to_unicode()) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_instruction'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | def write_instruction(fout, start_pos, ins):
opcode, operands = ins.opcode, ins.operands
fmt_operands = opcode_table[opcode]['operands']
if ins.wide:
fout.write(pack('>B', 0xC4))
fout.write(pack('>B', opcode))
fout.write(pack('>H', operands[0].value))
if opcode == 0x84:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_instruction'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def read_instruction(fio, start_pos):
op = fio.read(1)
if not op:
return None
op = ord(op)
ins = opcode_table[op]
operands = ins['operands']
name = ins['mnemonic']
final_operands = []
if operands:
for fmt, type_ in operands:
final_operands.append(
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_by_type'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'file... | def sort_by_type(file_list):
ret_dict = defaultdict(list)
for filepath in file_list:
_, ext = os.path.splitext(filepath)
ret_dict[ext.replace('.', '')].append(filepath)
return ret_dict |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_triple'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def _check_triple(self, triple):
subj, pred, obj = triple
if self._should_ignore_predicate(pred):
log.info("Ignoring triple with predicate '{}'"
.format(self._field_name_from_uri(pred)))
return
classes = []
log.warning("Possible member %s foun... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_ontology'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def parse_ontology(self):
start = time.clock()
log.info("Parsing ontology file for %s" % self.__class__.__name__)
for subj, pred, obj in self._schema_nodes():
if subj not in self.attributes_by_class:
if obj == rt.URIRef(self.lexicon['class']) and \
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'new_frame_event'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | def new_frame_event(self):
for out_pool in self.outframe_pool.values():
if not out_pool.available():
return
frame_nos = {}
for in_buff in self.input_buffer.values():
if not in_buff.available():
return
in_frame = in_buff.peek()
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GaussianFilterCore'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children':... | def GaussianFilterCore(x_sigma=0.0, y_sigma=0.0):
def filter_1D(sigma):
alpha = 1.0 / (2.0 * (max(sigma, 0.0001) ** 2.0))
coefs = []
coef = 1.0
while coef > 0.0001:
coefs.append(coef)
coef = math.exp(-(alpha * (float(len(coefs) ** 2))))
fil_dim = len(c... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'either'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'... | def either(self):
if not hasattr(self, 'children'):
return Either(Required(self))
else:
ret = []
groups = [[self]]
while groups:
children = groups.pop(0)
types = [type(c) for c in children]
if Either in types... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'TranslateManagedObject'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children'... | def TranslateManagedObject(mObj, xlateOrg, xlateMap):
from UcsBase import UcsUtils, WriteUcsWarning
from Mos import OrgOrg
xMO = mObj.Clone()
xMO.SetHandle(mObj.GetHandle())
if (xlateOrg != None):
matchObj = re.match(r'^(org-[\-\.:_a-zA-Z0-9]{1,16}/)*org-[\-\.:_a-zA-Z0-9]{1,16}', xMO.Dn)
if matchObj:
if Ucs... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ImportUcsSession'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def ImportUcsSession(filePath, key):
from UcsBase import UcsUtils, WriteUcsWarning, UcsValidationException
if filePath is None:
raise UcsValidationException("filePath parameter is not provided.")
if key is None:
raise UcsValidationException("key parameter is not provided.")
if not os.path.isfile(filePath) or no... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ImportUcsBackup'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children'... | def ImportUcsBackup(self, path=None, merge=False, dumpXml=False):
from UcsBase import WriteUcsWarning, UcsUtils, ManagedObject, WriteObject, UcsUtils, UcsException, \
UcsValidationException
from Ucs import ConfigConfig
from Mos import MgmtImporter
from datetime import datetime
if (self._transactionInProgre... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_suffix_links'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def _set_suffix_links(self):
'''
Sets all suffix links in all nodes in this trie.
'''
self._suffix_links_set = True
for current, parent in self.bfs():
if parent is None:
continue
current.longest_prefix = parent.longest_prefix
if... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_write_mo'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'mo'}, {... | def _write_mo(mo):
classNotFound = False
if (UcsUtils.FindClassIdInMoMetaIgnoreCase(mo.classId) == None):
classNotFound = True
tabsize = 8
outstr = "\n"
if classNotFound:
outstr += "Managed Object\t\t\t:\t" + str(UcsUtils.WordU(mo.classId)) + "\n"
else:
outstr += "Managed Object\t\t\t:\t" + str(mo.propMoMet... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'LoadFromXml'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def LoadFromXml(self, node, handle):
self.SetHandle(handle)
if node.hasAttributes():
attributes = node.attributes
attCount = len(attributes)
for i in range(attCount):
attNode = attributes.item(i)
attr = UcsUtils.WordU(attNode.localName)
if (UcsUtils.FindClassIdInMoMetaIgnoreCase(self.classId) !... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetJavaInstallationPath'}, {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '10']}, {... | def GetJavaInstallationPath():
import os, platform
if platform.system() == "Linux":
path = os.environ.get('JAVA_HOME')
if not path:
raise UcsValidationException(
"Please make sure JAVA is installed and variable JAVA_HOME is set properly.")
else:
path = os.path.join(path, 'bin')
path = os.p... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetSyncMoConfig'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'C... | def GetSyncMoConfig(ConfigDoc):
moConfigMap = {}
configList = ConfigDoc.getElementsByTagName("mo")
for moConfigNode in configList:
classId = None
noun = None
version = None
actionVersion = None
action = None
ignoreReason = None
status = None
excludeList = None
if moConfigNode.hasAttribu... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '27']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'duration'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'chil... | def duration(t, now=None, precision=1, pad=', ', words=None,
justnow=datetime.timedelta(seconds=10)):
'''
Time delta compared to ``t``. You can override ``now`` to specify what time
to compare to.
:param t: timestamp, :class:`datetime.date` or :class:`datetime.datetime`
object... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | def search(self, query_string):
query = self.create_query()
parser = QueryParser(query_string, query)
parser.parse()
return self.query(query) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wrap_error'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': ... | def wrap_error(
self, data, renderer_context, keys_are_fields, issue_is_title):
response = renderer_context.get("response", None)
status_code = str(response and response.status_code)
errors = []
for field, issues in data.items():
if isinstance(issues, six.string_t... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lunr'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def lunr(ref, fields, documents, languages=None):
if languages is not None and lang.LANGUAGE_SUPPORT:
if isinstance(languages, basestring):
languages = [languages]
unsupported_languages = set(languages) - set(lang.SUPPORTED_LANGUAGES)
if unsupported_languages:
raise R... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_trie'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def build_trie(pattern_filename, pattern_format, encoding, on_word_boundaries):
'''
Constructs a finite state machine for performing string rewriting.
Arguments:
- `pattern_filename`:
- `pattern_format`:
- `encoding`:
- `on_word_boundaries`:
'''
boundaries = on_word_boundaries
if... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_parser'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', ... | def make_parser(add_help=True, exclude_args=None):
if exclude_args is None:
exclude_args = []
parser = argparse.ArgumentParser(add_help=add_help)
parser.description = ("Filter, transform and export a list of JSON "
"objects on stdin to JSON or CSV on stdout")
if "--colu... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']},... | def parse(parser=None, args=None):
if not parser:
parser = make_parser()
try:
parsed_args = parser.parse_args(args)
except SystemExit as err:
raise CommandLineExit(err.code)
try:
columns = parsed_args.columns
except AttributeError:
columns = collections.Ordere... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_value'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18']}; {'id': '4', 'type': 'identifier'... | def read_value(ftype, prompt, default=None, minval=None, maxval=None,
allowed_single_chars=None, question_mark=True):
result = None
if question_mark:
cquestion_mark = ' ? '
else:
cquestion_mark = ''
if minval is not None:
try:
iminval = ftype(minval)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'select_configuration'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def select_configuration(self, obresult):
logger = logging.getLogger(__name__)
logger.debug('calling default configuration selector')
ref = obresult.get_sample_frame()
extr = self.datamodel.extractor_map['fits']
if ref:
result = extr.extract('insconf', ref)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pause_debugplot'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children'... | def pause_debugplot(debugplot, optional_prompt=None, pltshow=False,
tight_layout=True):
if debugplot not in DEBUGPLOT_CODES:
raise ValueError('Invalid debugplot value:', debugplot)
if debugplot < 0:
debugplot_ = -debugplot
pltclose = True
else:
debugplot_ ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mode_half_sample'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def mode_half_sample(a, is_sorted=False):
'''
Estimate the mode using the Half Sample mode.
A method to estimate the mode, as described in
D. R. Bickel and R. Frühwirth (contributed equally),
"On a fast, robust estimator of the mode: Comparisons to other
robust estimators with applications,"
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'author_id_normalize_and_schema'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'childr... | def author_id_normalize_and_schema(uid, schema=None):
def _get_uid_normalized_in_schema(_uid, _schema):
regex, template = _RE_AUTHORS_UID[_schema]
match = regex.match(_uid)
if match:
return template.format(match.group('uid'))
if idutils.is_orcid(uid) and schema in (None, 'ORC... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_schema_path'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def get_schema_path(schema, resolved=False):
def _strip_first_path_elem(path):
stripped_path = path.split(os.path.sep, 1)[1:]
return ''.join(stripped_path)
def _schema_to_normalized_path(schema):
path = os.path.normpath(os.path.sep + urlsplit(schema).path)
if path.startswith(os.p... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_license_from_url'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def get_license_from_url(url):
if not url:
return
split_url = urlsplit(url, scheme='http')
if split_url.netloc.lower() == 'creativecommons.org':
if 'publicdomain' in split_url.path:
match = _RE_PUBLIC_DOMAIN_URL.match(split_url.path)
if match is None:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_old_publication_info_to_new'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'childr... | def convert_old_publication_info_to_new(publication_infos):
result = []
hidden_publication_infos = []
for publication_info in publication_infos:
_publication_info = copy.deepcopy(publication_info)
journal_title = _publication_info.get('journal_title')
try:
journal_title =... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'construct_reference_system'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'chil... | def construct_reference_system(
symbols,
candidates=None,
options=None,
):
if hasattr(options, 'no_hydrogen') and options.no_hydrogen:
add_hydrogen = False
else:
add_hydrogen = True
references = {}
sorted_candidates = [
'H2',
'H2O',
'NH3',
'N2'... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gen_triplets_master'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': ... | def gen_triplets_master(wv_master, geometry=None, debugplot=0):
nlines_master = wv_master.size
wv_previous = wv_master[0]
for i in range(1, nlines_master):
if wv_previous >= wv_master[i]:
raise ValueError('Wavelengths:\n--> ' +
str(wv_previous) + '\n--> ' + s... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'match_wv_arrays'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def match_wv_arrays(wv_master, wv_expected_all_peaks, delta_wv_max):
wv_verified_all_peaks = np.zeros_like(wv_expected_all_peaks)
wv_unused = np.ones_like(wv_expected_all_peaks, dtype=bool)
minimum_delta_wv = np.ones_like(wv_expected_all_peaks, dtype=float)
minimum_delta_wv *= np.infty
for i in rang... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '41']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_publication_info'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29', '32',... | def add_publication_info(
self,
year=None,
cnum=None,
artid=None,
page_end=None,
page_start=None,
journal_issue=None,
journal_title=None,
journal_volume=None,
pubinfo_freetext=None,
material=None,
parent_record=None,
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_operation'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12']}; {'id': '4', 'ty... | def compute_operation(file1, file2, operation, output, display,
args_z1z2, args_bbox, args_keystitle, args_geometry):
with fits.open(file1) as hdulist:
image_header1 = hdulist[0].header
image1 = hdulist[0].data.astype(np.float)
naxis1 = image_header1['naxis1']
naxis2 = ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'summary'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def summary(x, rm_nan=False, debug=False):
if type(x) is np.ndarray:
xx = np.copy(x)
else:
if type(x) is list:
xx = np.array(x)
else:
raise ValueError('x=' + str(x) + ' must be a numpy.ndarray')
if xx.ndim is not 1:
raise ValueError('xx.dim=' + str(xx.... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_peaks_spectrum'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'childr... | def find_peaks_spectrum(sx, nwinwidth, threshold=0, debugplot=0):
if type(sx) is not np.ndarray:
raise ValueError("sx=" + str(sx) + " must be a numpy.ndarray")
elif sx.ndim is not 1:
raise ValueError("sx.ndim=" + str(sx.ndim) + " must be 1")
sx_shape = sx.shape
nmed = nwinwidth//2
if... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'shortlex'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def shortlex(start, other, excludestart=False):
if not excludestart:
yield start
queue = collections.deque([(start, other)])
while queue:
current, other = queue.popleft()
while other:
first, other = other[0], other[1:]
result = current | first
yiel... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reverse_shortlex'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def reverse_shortlex(end, other, excludeend=False):
if not excludeend:
yield end
queue = collections.deque([(end, other)])
while queue:
current, other = queue.popleft()
while other:
first, other = other[0], other[1:]
result = current & first
yield ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gnuplot'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def gnuplot(script_name, args_dict={}, data=[], silent=True):
'''
Call a Gnuplot script, passing it arguments and
datasets.
Args:
scipt_name(str): The name of the Gnuplot script.
args_dict(dict): A dictionary of parameters to pass
to the script. The `key` is the name of the ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def read(self, skip=[], goto_metal=None, goto_reaction=None):
if len(skip) > 0:
for skip_f in skip:
self.omit_folders.append(skip_f)
if os.path.isfile(self.data_base + '/publication.txt'):
self.user_base_level -= 1
self.stdout.write('----------------------... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'location'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def location(self, wave_field, depth=None, index=None):
if not isinstance(wave_field, WaveField):
wave_field = WaveField[wave_field]
if index is None and depth is not None:
for i, layer in enumerate(self[:-1]):
if layer.depth <= depth < layer.depth_base:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.