sequence stringlengths 1.19k 35k | code stringlengths 75 8.58k |
|---|---|
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'contigs_to_positions'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def contigs_to_positions(contigs, binning=10000):
positions = np.zeros_like(contigs)
index = 0
for _, chunk in itertools.groubpy(contigs):
l = len(chunk)
positions[index : index + l] = np.arange(list(chunk)) * binning
index += l
return positions |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_nearest'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def find_nearest(sorted_list, x):
if x <= sorted_list[0]:
return sorted_list[0]
elif x >= sorted_list[-1]:
return sorted_list[-1]
else:
lower = find_le(sorted_list, x)
upper = find_ge(sorted_list, x)
if (x - lower) > (upper - x):
return upper
else:... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def execute(input_params, engine, cwd=None):
try:
taskengine_exe = config.get('engine')
except NoConfigOptionError:
raise TaskEngineNotFoundError(
"Task Engine config option not set." +
"\nPlease verify the 'engine' configuration setting.")
if not os.path.exists(taske... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_fasta'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def merge_fasta(fasta_file, output_dir):
def chunk_lexicographic_order(chunk):
chunk_fields = chunk.split("_")
chunk_name = chunk_fields[:-1]
chunk_id = chunk_fields[-1]
return (chunk_name, int(chunk_id))
def are_consecutive(chunk1, chunk2):
if None in {chunk1, chunk2}:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_block'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '11']}; {'id': '4', 'type': 'identifier', 'children': []... | def print_block(self, section_key, f=sys.stdout, file_format="mwtab"):
if file_format == "mwtab":
for key, value in self[section_key].items():
if section_key == "METABOLOMICS WORKBENCH" and key not in ("VERSION", "CREATED_ON"):
continue
if key in (... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'retry'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'childre... | def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, status_codes=[],
logger=None):
if backoff is None or backoff <= 0:
raise ValueError("backoff must be a number greater than 0")
tries = math.floor(tries)
if tries < 0:
raise ValueError("tries must be a number 0 or greater")
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lcopt_bw2_autosetup'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19']}; {'id': '4', 'type': 'defaul... | def lcopt_bw2_autosetup(ei_username=None, ei_password=None, write_config=None, ecoinvent_version='3.3', ecoinvent_system_model = "cutoff", overwrite=False):
ei_name = "Ecoinvent{}_{}_{}".format(*ecoinvent_version.split('.'), ecoinvent_system_model)
config = check_for_config()
if config is None:
co... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lcopt_bw2_forwast_setup'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13']}; {'id': '4', 'type': 'default_parame... | def lcopt_bw2_forwast_setup(use_autodownload=True, forwast_path=None, db_name=FORWAST_PROJECT_NAME, overwrite=False):
if use_autodownload:
forwast_filepath = forwast_autodownload(FORWAST_URL)
elif forwast_path is not None:
forwast_filepath = forwast_path
else:
raise ValueErro... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate_samples_factors'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'child... | def _validate_samples_factors(mwtabfile, validate_samples=True, validate_factors=True):
from_subject_samples = {i["local_sample_id"] for i in mwtabfile["SUBJECT_SAMPLE_FACTORS"]["SUBJECT_SAMPLE_FACTORS"]}
from_subject_factors = {i["factors"] for i in mwtabfile["SUBJECT_SAMPLE_FACTORS"]["SUBJECT_SAMPLE_FACTORS"]... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'schema'},... | def convert(schema):
if isinstance(schema, vol.Schema):
schema = schema.schema
if isinstance(schema, Mapping):
val = []
for key, value in schema.items():
description = None
if isinstance(key, vol.Marker):
pkey = key.schema
descripti... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_jsmin'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'... | def _jsmin(self):
self.theA = '\n'
self._action(3)
while self.theA != '\000':
if self.theA == ' ':
if isAlphanum(self.theB):
self._action(1)
else:
self._action(2)
elif self.theA == '\n':
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tokenizer'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'},... | def tokenizer(text):
stream = deque(text.split("\n"))
while len(stream) > 0:
line = stream.popleft()
if line.startswith("
yield KeyValue("
yield KeyValue("HEADER", line)
for identifier in line.split(" "):
if ":" in identifier:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_proxy'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def _proxy(self, url, urlparams=None):
for k,v in request.params.iteritems():
urlparams[k]=v
query = urlencode(urlparams)
full_url = url
if query:
if not full_url.endswith("?"):
full_url += "?"
full_url += query
req = urllib2.Re... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'attempt_open_query_permutations'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', '... | def attempt_open_query_permutations(url, orig_file_path, is_header_file):
directory = dirname(convert_to_platform_safe(orig_file_path)) + "/"
try:
filenames = [f for f in os.listdir(directory)
if isfile(join(directory, f))]
except OSError:
return
if is_header_file:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search_databases'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier'... | def search_databases(self, search_term, location=None, markets_only=False, databases_to_search=None, allow_internal=False):
dict_list = []
if allow_internal:
internal_dict = {}
for k, v in self.database['items'].items():
if v.get('lcopt_type') == 'intermediate':
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_parameter_map'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def create_parameter_map(self):
names = self.modelInstance.names
db = self.modelInstance.database['items']
parameter_map = {}
def get_names_index(my_thing):
return[i for i, x in enumerate(names) if x == my_thing][0]
for k, this_item in db.items():
if this_... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'apply'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13']}; {'id': '4', 'type': 'default_parameter', 'children': ... | def apply(config_override=None, tag_override=None, rollback=None, skip_missing=None):
config = get_config(config_override)
databases = config['databases']
if rollback and not tag_override:
raise RuntimeError(
'To rollback a migration you need to specify the database tag with `--tag`')
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_configure_common'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': 'identi... | def _configure_common(
self,
prefix,
fallback_level,
fallback_format,
handler_name,
handler,
custom_args=''
):
log_level = self.config.get_option(
'LOGGING', prefix + 'log_level',
None, fallback_level... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_file'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'identifier', 'child... | def get_file(self, name, save_to, add_to_cache=True,
force_refresh=False, _lock_exclusive=False):
uname, version = split_name(name)
lock = None
if self.local_store:
lock = self.lock_manager.lock_for(uname)
if _lock_exclusive:
lock.lock_exc... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_stream'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def get_stream(self, name, force_refresh=False, serve_from_cache=False):
uname, version = split_name(name)
lock = None
if self.local_store:
lock = self.lock_manager.lock_for(uname)
lock.lock_shared()
try:
if not self.remote_store or (version is not Non... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'put_file'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'identifier', 'child... | def put_file(self,
name,
filename,
to_local_store=True,
to_remote_store=True,
compress_hint=True):
if not to_local_store and not to_remote_store:
raise ValueError("Neither to_local_store nor to_remote_store set "
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'operat... | def check(operations, loud=False):
if not CHECKERS:
load_checkers()
roll_call = []
everything_ok = True
if loud and operations:
title = "Preflyt Checklist"
sys.stderr.write("{}\n{}\n".format(title, "=" * len(title)))
for operation in operations:
if operation.get('chec... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'deci2sexa'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'identifier'... | def deci2sexa(deci, pre=3, trunc=False, lower=None, upper=None,
b=False, upper_trim=False):
if lower is not None and upper is not None:
deci = normalize(deci, lower=lower, upper=upper, b=b)
sign = 1
if deci < 0:
deci = abs(deci)
sign = -1
hd, f1 = divmod(deci, 1)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'phmsdms'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'hmsdms'},... | def phmsdms(hmsdms):
units = None
sign = None
pattern1 = re.compile(r"([-+]?[0-9]*\.?[0-9]+[^0-9\-+]*)")
pattern2 = re.compile(r"([-+]?[0-9]*\.?[0-9]+)")
hmsdms = hmsdms.lower()
hdlist = pattern1.findall(hmsdms)
parts = [None, None, None]
def _fill_right_not_none():
rp = reversed... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pposition'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'hd... | def pposition(hd, details=False):
p = re.split(r"[^\d\-+.]*", hd)
if len(p) not in [2, 6]:
raise ValueError("Input must contain either 2 or 6 numbers.")
if len(p) == 2:
x, y = float(p[0]), float(p[1])
if details:
numvals = 2
raw_x = p[0]
raw_y = p[... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '68']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Create'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11', '14', '17', '20', '23', '26', '29', '32', '35... | def Create(name,template,group_id,network_id,cpu=None,memory=None,alias=None,password=None,ip_address=None,
storage_type="standard",type="standard",primary_dns=None,secondary_dns=None,
additional_disks=[],custom_fields=[],ttl=None,managed_os=False,description=None,
source_server_password=None,cp... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '66']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Clone'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24', '27', '30', '33', '36', '39... | def Clone(self,network_id,name=None,cpu=None,memory=None,group_id=None,alias=None,password=None,ip_address=None,
storage_type=None,type=None,primary_dns=None,secondary_dns=None,
custom_fields=None,ttl=None,managed_os=False,description=None,
source_server_password=None,cpu_autoscale_policy_id=None,a... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Call'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def Call(method,url,payload=None,session=None,debug=False):
if session is not None:
token = session['token']
http_session = session['http_session']
else:
if not clc._LOGIN_TOKEN_V2:
API._Login()
token = clc._LOGIN_TOKEN_V2
http_session = clc._REQUESTS_SESSION
if payload is None:
payload =... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'processFiles'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'args... | def processFiles(args):
to_process = []
for filename in args['filenames']:
file = dict()
if args['include']:
file['include'] = INCLUDE_STRING + ''.join(
['-I' + item for item in args['include']])
else:
file['include'] = INCLUDE_STRING
file[... |
{'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', '19', '32', '46', '68', '95'... | def main():
parser = argparse.ArgumentParser(description='DistanceClassifier for classification based on distance measure in feature space.',
add_help=False)
parser.add_argument('INPUT_FILE', type=str, help='Data file to perform DistanceClassifier on; ensure that the class l... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def delete(self, name, version, _lock=True):
link_path = self._link_path(name)
if _lock:
file_lock = _exclusive_lock(self._lock_path('links', name))
else:
file_lock = _no_lock()
with file_lock:
logger.debug('Acquired or inherited lock for link %s.', na... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wait_socks'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [],... | def wait_socks(sock_events, inmask=1, outmask=2, timeout=None):
results = []
for sock, mask in sock_events:
if isinstance(sock, zmq.backend.Socket):
mask = _check_events(sock, mask, inmask, outmask)
if mask:
results.append((sock, mask))
if results:
ret... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sync_ldap_user_membership'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childr... | def sync_ldap_user_membership(self, user, ldap_groups):
groupname_field = 'name'
actualGroups = user.groups.values_list('name', flat=True)
user_Membership_total = len(ldap_groups)
user_Membership_added = 0
user_Membership_deleted = 0
user_Membership_errors = 0
lda... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def get(self, block=True, timeout=None):
if not self._data:
if not block:
raise Empty()
current = compat.getcurrent()
waketime = None if timeout is None else time.time() + timeout
if timeout is not None:
scheduler.schedule_at(waketi... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'put'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def put(self, item, block=True, timeout=None):
if self.full():
if not block:
raise Full()
current = compat.getcurrent()
waketime = None if timeout is None else time.time() + timeout
if timeout is not None:
scheduler.schedule_at(wake... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_compress_tokens'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def _compress_tokens(tokens):
recorder = None
def _edge_case_stray_end_quoted(tokens, index):
tokens[index] = Token(type=TokenType.UnquotedLiteral,
content=tokens[index].content,
line=tokens[index].line,
col=tokens... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_dependencies'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | def _parse_dependencies(string):
contents = _get_contents_between(string, '(', ')')
unsorted_dependencies = contents.split(',')
_check_parameters(unsorted_dependencies, ('?',))
buildable_dependencies = []
given_dependencies = []
for dependency in unsorted_dependencies:
if dependency[0] =... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wait_fds'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], '... | def wait_fds(fd_events, inmask=1, outmask=2, timeout=None):
current = compat.getcurrent()
activated = {}
poll_regs = {}
callback_refs = {}
def activate(fd, event):
if not activated and timeout != 0:
scheduler.schedule(current)
if timeout:
scheduler._re... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'processAndSetDefaults'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def processAndSetDefaults(self):
if not self.input:
raise ValueError(NO_INPUT_FILE)
if not self.output:
if not self.build_directory:
File()
pass
else:
pass
if not self.build_directory:
pass
for dependency... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'schedule'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'children': ['5... | def schedule(target=None, args=(), kwargs=None):
if target is None:
def decorator(target):
return schedule(target, args=args, kwargs=kwargs)
return decorator
if isinstance(target, compat.greenlet) or target is compat.main_greenlet:
glet = target
else:
glet = green... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'schedule_at'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': []... | def schedule_at(unixtime, target=None, args=(), kwargs=None):
if target is None:
def decorator(target):
return schedule_at(unixtime, target, args=args, kwargs=kwargs)
return decorator
if isinstance(target, compat.greenlet) or target is compat.main_greenlet:
glet = target
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'schedule_recurring'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifi... | def schedule_recurring(interval, target=None, maxtimes=0, starting_at=0,
args=(), kwargs=None):
starting_at = starting_at or time.time()
if target is None:
def decorator(target):
return schedule_recurring(
interval, target, maxtimes, starting_at, args, ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'assert_output'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | def assert_output(output, assert_equal):
sorted_output = sorted(output)
sorted_assert = sorted(assert_equal)
if sorted_output != sorted_assert:
raise ValueError(ASSERT_ERROR.format(sorted_output, sorted_assert)) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_input'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children':... | def get_input(prompt, check, *, redo_prompt=None, repeat_prompt=False):
if isinstance(check, str):
check = (check,)
to_join = []
for item in check:
if item:
to_join.append(str(item))
else:
to_join.append("''")
prompt += " [{}]: ".format('/'.join(to_join))
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'install_build_requires'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def install_build_requires(pkg_targets):
def pip_install(pkg_name, pkg_vers=None):
pkg_name_version = '%s==%s' % (pkg_name, pkg_vers) if pkg_vers else pkg_name
print '[WARNING] %s not found, attempting to install using a raw "pip install" call!' % pkg_name_version
subprocess.Popen('pip insta... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'PackagePublishUI'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def PackagePublishUI(package,type,visibility):
linux_lst = {'L': {'selected': False, 'Description': 'All Linux'}}
windows_lst = {'W': {'selected': False, 'Description': 'All Windows'}}
for r in clc.v1.Server.GetTemplates():
r['selected'] = False
if re.search("Windows",r['Description']): windows_lst[str(r['... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_construct_select_query'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'dictionary_splat_pattern', 'chil... | def _construct_select_query(**filter_definition):
table_name = filter_definition.pop('table')
distinct = filter_definition.pop('distinct', False)
select_count = filter_definition.pop('count', False)
if distinct and select_count:
raise UnsupportedDefinitionError('SELECT (DISTINCT ...) is not supp... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encode'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def encode(df, encoding='utf8', verbosity=1):
if verbosity > 0:
pbar = progressbar.ProgressBar(maxval=df.shape[1])
pbar.start()
for colnum, col in enumerate(df.columns):
if isinstance(df[col], pd.Series):
if verbosity:
pbar.update(colnum)
if df[col... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'data_worker'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'dictionary_splat_pattern', 'children': ['5']... | def data_worker(**kwargs):
if kwargs is not None:
if "function" in kwargs:
function = kwargs["function"]
else:
Exception("Invalid arguments, no function specified")
if "input" in kwargs:
input_queue = kwargs["input"]
else:
Exception("In... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'makeproperty'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'childr... | def makeproperty(ns, cls=None, name=None, docstring='', descendant=True):
def get_property(self):
if cls is None:
xpath = '%s:%s' % (ns, name)
else:
xpath = '%s:%s' % (ns, cls.__name__)
xpath = self._node.xpath(xpath, namespaces=SLDNode._nsmap)... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'ERROR', 'children': ['2', '43', '144', '161', '220']}; {'id': '2', 'type': 'function_definition', 'children': ['3', '4', '6', '38']}, {'id': '3', 'type': 'function_name', 'children': [], 'value': '_parse_from_string'}; {'id': '4', 'type': 'parameter... | def _parse_from_string(string_input):
read_lines = list(filter(None, string_input.split('\n')))
if read_lines[0].startswith('
comment = read_lines.pop(0)
else:
comment = ''
if len(read_lines) > 1:
order = int(math.sqrt(len(read_lines)))
else:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'solve'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | def solve(self, verbose=False, allow_brute_force=True):
while not self.is_solved:
self._update()
singles_found = False or self._fill_naked_singles() or self._fill_hidden_singles()
if not singles_found:
if allow_brute_force:
solution = None
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_fill_hidden_singles'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def _fill_hidden_singles(self):
for i in utils.range_(self.side):
box_i = (i // self.order) * self.order
for j in utils.range_(self.side):
box_j = (j // self.order) * self.order
if self[i][j] > 0:
continue
p = self._poss... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | def sort(self, request, reverse=False):
field = self.model._meta.fields.get(self.columns_sort)
if not field:
return self.collection
if reverse:
field = field.desc()
return self.collection.order_by(field) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_docstring'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier',... | def process_docstring(app, what, name, obj, options, lines):
aliases = getattr(app, "_sigaliases", None)
if aliases is None:
if what == "module":
aliases = get_aliases(inspect.getsource(obj).splitlines())
app._sigaliases = aliases
sig_marker = ":" + SIG_FIELD + ":"
is_cla... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}, {'id':... | def main(argv=None):
parser = ArgumentParser(prog="pygenstub")
parser.add_argument("--version", action="version", version="%(prog)s " + __version__)
parser.add_argument("files", nargs="*", help="generate stubs for given files")
parser.add_argument(
"-m",
"--module",
action="appen... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_code'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, ... | def get_code(self):
stub = []
for deco in self.decorators:
if (deco in DECORATORS) or deco.endswith(".setter"):
stub.append("@" + deco)
parameters = []
for name, type_, has_default in self.parameters:
decl = "%(n)s%(t)s%(d)s" % {
"n... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'query_metric_stats'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18']}; {'id': '4', 'type': 'ide... | def query_metric_stats(self, metric_type, metric_id=None, start=None, end=None, bucketDuration=None, **query_options):
if start is not None:
if type(start) is datetime:
query_options['start'] = datetime_to_time_millis(start)
else:
query_options['start'] = ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '25']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_files'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19', '22']}; {'id': '4', 'type': 'default_p... | def find_files(path='', ext='', level=None, typ=list, dirs=False, files=True, verbosity=0):
gen = generate_files(path, ext=ext, level=level, dirs=dirs, files=files, verbosity=verbosity)
if isinstance(typ(), collections.Mapping):
return typ((ff['path'], ff) for ff in gen)
elif typ is not None:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'limitted_dump'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19']}; {'id': '4', 'type': 'default_para... | def limitted_dump(cursor=None, twitter=None, path='tweets.json', limit=450, rate=TWITTER_SEARCH_RATE_LIMIT, indent=-1):
if not twitter:
twitter = get_twitter()
cursor = cursor or 'python'
if isinstance(cursor, basestring):
cursor = get_cursor(twitter, search=cursor)
newline = '\n' if ind... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | async def sort(self, request, reverse=False):
return sorted(
self.collection, key=lambda o: getattr(o, self.columns_sort, 0), reverse=reverse) |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_request'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': 'identifier', 'c... | def _request(self, path, key, data, method, key_is_cik, extra_headers={}):
if method == 'GET':
if len(data) > 0:
url = path + '?' + data
else:
url = path
body = None
else:
url = path
body = data
headers =... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_intervals'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def parse_intervals(path, as_context=False):
def _regions_from_range():
if as_context:
ctxs = list(set(pf.lines[start - 1: stop - 1]))
return [
ContextInterval(filename, ctx)
for ctx in ctxs
]
else:
return [LineInterval(... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'graphiter'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children':... | def graphiter(self, graph, target, ascendants=0, descendants=1):
asc = 0 + ascendants
if asc != 0:
asc -= 1
desc = 0 + descendants
if desc != 0:
desc -= 1
t = str(target)
if descendants != 0 and self.downwards[t] is True:
self.downwards... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'map_aliases_to_device_objects'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [... | def map_aliases_to_device_objects(self):
all_devices = self.get_all_devices_in_portal()
for dev_o in all_devices:
dev_o['portals_aliases'] = self.get_portal_by_name(
self.portal_name()
)[2... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_sorted_device_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'childr... | def print_sorted_device_list(self, device_list=None, sort_key='sn'):
dev_list = device_list if device_list is not None else self.get_all_devices_in_portal()
sorted_dev_list = []
if sort_key == 'sn':
sort_keys = [ k[sort_key] for k in dev_list if k[sort_key] is not None ]
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'enrich'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | def enrich(self, columns):
for column in columns:
if column not in self.data.columns:
return self.data
first_column = list(self.data[columns[0]])
count = 0
append_df = pandas.DataFrame()
for cell in first_column:
if len(cell) >= 1:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_metadata'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | def parse_metadata(cls, obj, xml):
for child in xml.xpath("ti:description", namespaces=XPATH_NAMESPACES):
lg = child.get("{http://www.w3.org/XML/1998/namespace}lang")
if lg is not None:
obj.set_cts_property("description", child.text, lg)
for child in xml.xpath("ti... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | def setup(self, app):
super().setup(app)
self.handlers = OrderedDict()
app.ps.jinja2.cfg.template_folders.append(op.join(PLUGIN_ROOT, 'templates'))
@app.ps.jinja2.filter
def admtest(value, a, b=None):
return a if value else b
@app.ps.jinja2.filter
def ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'passageLoop'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'identifier', 'ch... | def passageLoop(parent, new_tree, xpath1, xpath2=None, preceding_siblings=False, following_siblings=False):
current_1, queue_1 = __formatXpath__(xpath1)
if xpath2 is None:
result_1, loop = performXpath(parent, current_1)
if loop is True:
queue_1 = xpath1
central = None
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cancellable_wait'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '14']}; {'id': '4', 'type': 'identifier', 'childre... | async def cancellable_wait(self, *awaitables: Awaitable[_R], timeout: float = None) -> _R:
futures = [asyncio.ensure_future(a, loop=self.loop) for a in awaitables + (self.wait(),)]
try:
done, pending = await asyncio.wait(
futures,
timeout=timeout,
... |
{'id': '0', 'type': 'module', 'children': ['1', '10', '12', '23', '29', '33', '37', '210', '218', '227', '245']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_tweets_count_times'}, {'id': '3', 'type': 'parameters', 'children'... | def get_tweets_count_times(twitter, count, query=None):
r
oldest_id, newest_id = _get_oldest_id(query=query)
newest_id = newest_id or oldest_id
all_tweets = []
i = 0
while i < count:
i += 1
if oldest_id <= newest_id:
tweets = get_tweets(query=query, max_id=oldest_id - 1, ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': ... | def register(cls, code, name, hash_name=None, hash_new=None):
if not _is_app_specific_func(code):
raise ValueError(
"only application-specific functions can be registered")
name_mapping_data = [
(cls._func_from_name, name,
"function name is already re... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '25']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compile_vocab'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': ... | def compile_vocab(docs, limit=1e6, verbose=0, tokenizer=Tokenizer(stem=None, lower=None, strip=None)):
tokenizer = make_tokenizer(tokenizer)
d = Dictionary()
try:
limit = min(limit, docs.count())
docs = docs.iterator()
except (AttributeError, TypeError):
pass
for i, doc in en... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | def parse(self, resource):
textgroups = []
texts = []
invalids = []
for folder in resource:
cts_files = glob("{base_folder}/data/*/__cts__.xml".format(base_folder=folder))
for cts_file in cts_files:
textgroup, cts_file = self._parse_textgroup(cts_f... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_address_label'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def generate_address_label(self):
if self.organisation_name:
self.address_label.append(self.organisation_name)
if self.department_name:
self.address_label.append(self.department_name)
if self.po_box_number:
self.address_label.append('PO Box ' + self.po_box_num... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'verify_token'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | def verify_token(token, public_key_or_address, signing_algorithm="ES256K"):
decoded_token = decode_token(token)
decoded_token_payload = decoded_token["payload"]
if "subject" not in decoded_token_payload:
raise ValueError("Token doesn't have a subject")
if "publicKey" not in decoded_token_payload... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_translations'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def get_translations(self, locale):
locale = self.normalize_locale(locale)
if locale in self.translations:
return self.translations[locale]
translations = {}
for path in self.dirs:
file = os.path.join(path, '{}.py'.format(locale))
if not os.path.isfile... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_request'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def process_request(self, session):
debugger = self.debugger()
debugger_session_id = debugger.session_id() if debugger is not None else None
try:
request = session.read_request()
if debugger_session_id is not None:
debugger.request(
debugger_session_id, request, session.protocol_version(), session.... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_point_in_section_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':... | def find_point_in_section_list(point, section_list):
if point < section_list[0] or point > section_list[-1]:
return None
if point in section_list:
if point == section_list[-1]:
return section_list[-2]
ind = section_list.bisect(point)-1
if ind == 0:
return ... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_range_ix_in_section_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'ch... | def find_range_ix_in_section_list(start, end, section_list):
if start > section_list[-1] or end < section_list[0]:
return [0, 0]
if start < section_list[0]:
start_section = section_list[0]
else:
start_section = find_point_in_section_list(start, section_list)
if end > section_list... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_range_in_section_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'child... | def find_range_in_section_list(start, end, section_list):
ind = find_range_ix_in_section_list(start, end, section_list)
return section_list[ind[0]: ind[1]] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_range_ix_in_point_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'chil... | def find_range_ix_in_point_list(start, end, point_list):
return [point_list.bisect_left(start), point_list.bisect_right(end)] |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def check(self, type_spec, arg_name, decorated_function):
def raise_exception(x_spec):
exc_text = 'Argument "%s" for function "%s" has invalid type' % (
arg_name, Verifier.function_name(decorated_function)
)
exc_text += ' (%s should be %s)' % (x_spec, type_spec)
raise TypeError(exc_text)
if isinstan... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def check(self, type_spec, arg_name, decorated_function):
def raise_exception(text_spec):
exc_text = 'Argument "%s" for function "%s" has invalid type' % (
arg_name, Verifier.function_name(decorated_function)
)
exc_text += ' (%s)' % text_spec
raise TypeError(exc_text)
if isinstance(type_spec, (tuple... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | def check(self, value_spec, arg_name, decorated_function):
def raise_exception(text_spec):
exc_text = 'Argument "%s" for function "%s" has invalid value' % (
arg_name, Verifier.function_name(decorated_function)
)
exc_text += ' (%s)' % text_spec
raise ValueError(exc_text)
if isinstance(value_spec, (t... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cache_control'}, {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5'... | def cache_control(validator=None, storage=None):
def default_validator(*args, **kwargs):
return True
if validator is None:
validator = default_validator
if storage is None:
storage = WGlobalSingletonCacheStorage()
def first_level_decorator(decorated_function):
def second_level_decorator(original_function, *... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_int_string'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5... | def parse_int_string(int_string: str) -> List[int]:
cleaned = " ".join(int_string.strip().split())
cleaned = cleaned.replace(" - ", "-")
cleaned = cleaned.replace(",", " ")
tokens = cleaned.split(" ")
indices: Set[int] = set()
for token in tokens:
if "-" in token:
endpoints =... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'locations_within'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | def locations_within(a, b, tolerance):
ret = ''
b = dict(b)
for (key, value) in a.items():
if key not in b:
raise ValueError("b does not have the key: " + key)
if abs(int(value) - int(b[key])) > tolerance:
ret += 'key {0} differs: {1} {2}'.format(key, int(value),
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'persistence2stats'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifie... | def persistence2stats(rev_docs, min_persisted=5, min_visible=1209600,
include=None, exclude=None, verbose=False):
rev_docs = mwxml.utilities.normalize(rev_docs)
min_persisted = int(min_persisted)
min_visible = int(min_visible)
include = include if include is not None else lambda t:... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_index'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | def update_index(self):
idx = {}
for _, p in sorted(self.permissions.items(), key=lambda x: str(x[0])):
branch = idx
parent_p = const.PERM_DENY
for k in p.namespace.keys:
if not k in branch:
branch[k] = {"__": parent_p}
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'type_check'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func_h... | def type_check(func_handle):
def checkType(var_name, var_val, annot):
if var_name in annot:
var_anno = annot[var_name]
if var_val is None:
type_ok = True
elif (type(var_val) is bool):
type_ok = (type(var_val) in var_anno)
else:
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteProcessKey'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | def qteProcessKey(self, event, targetObj):
msgObj = QtmacsMessage((targetObj, event), None)
msgObj.setSignalName('qtesigKeypressed')
self.qteMain.qtesigKeypressed.emit(msgObj)
if event.key() in (QtCore.Qt.Key_Shift, QtCore.Qt.Key_Control,
QtCore.Qt.Key_Meta, Qt... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'timerEvent'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | def timerEvent(self, event):
self.killTimer(event.timerId())
if event.timerId() == self._qteTimerRunMacro:
self._qteTimerRunMacro = None
while True:
if len(self._qteMacroQueue) > 0:
(macroName, qteWidget, event) = self._qteMacroQueue.pop(0)
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '37']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteNextApplet'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '10', '17', '22', '27', '32']}; {'id': '4', 'type': 'identi... | def qteNextApplet(self, numSkip: int=1, ofsApp: (QtmacsApplet, str)=None,
skipInvisible: bool=True, skipVisible: bool=False,
skipMiniApplet: bool=True,
windowObj: QtmacsWindow=None):
if isinstance(ofsApp, str):
ofsApp = self.qteGetApp... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_qteRunQueuedMacro'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '16']}; {'id': '4', 'type': 'identifier', 'childr... | def _qteRunQueuedMacro(self, macroName: str,
widgetObj: QtGui.QWidget=None,
keysequence: QtmacsKeysequence=None):
app = qteGetAppletFromWidget(widgetObj)
if app is not None:
if sip.isdeleted(app):
msg = 'Ignored macro <b>{... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteNewApplet'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '14']}; {'id': '4', 'type': 'identifier', 'children': [... | def qteNewApplet(self, appletName: str, appletID: str=None,
windowObj: QtmacsWindow=None):
if windowObj is None:
windowObj = self.qteActiveWindow()
if windowObj is None:
msg = 'Cannot determine the currently active window.'
self.qteLog... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteAddMiniApplet'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | def qteAddMiniApplet(self, appletObj: QtmacsApplet):
if self._qteMiniApplet is not None:
msg = 'Cannot replace mini applet more than once.'
self.qteLogger.warning(msg)
return False
if appletObj.layout() is None:
appLayout = QtGui.QHBoxLayout()
... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteKillMiniApplet'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | def qteKillMiniApplet(self):
if self._qteMiniApplet is None:
return
if not self.qteIsMiniApplet(self._qteMiniApplet):
msg = ('Mini applet does not have its mini applet flag set.'
' Ignored.')
self.qteLogger.warning(msg)
if self._qteMiniApple... |
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qteSplitApplet'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '12', '17']}; {'id': '4', 'type': 'identifier', 'children'... | def qteSplitApplet(self, applet: (QtmacsApplet, str)=None,
splitHoriz: bool=True,
windowObj: QtmacsWindow=None):
if isinstance(applet, str):
newAppObj = self.qteGetAppletHandle(applet)
else:
newAppObj = applet
if windowObj is ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.