sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:is_prime; 3, parameters; 3, 4; 3, 5; 4, identifier:n; 5, default_parameter; 5, 6; 5, 7; 6, identifier:k; 7, integer:64; 8, block; 8, 9; 8, 16; 8, 29; 8, 46; 8, 50; 8, 56; 8, 83; 8, 113; 9, if_statement; 9, 10; 9, 13; 10, comparison_operator:==;... | def is_prime(n, k=64):
if n == 2:
return True
if n < 2 or n % 2 == 0:
return False
for i in range(3, 2048):
if n % i == 0:
return False
s = 0
d = n - 1
while True:
q, r = divmod(d, 2)
if r == 1:
break
s += 1
d = q
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:iterrows; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:workbook; 7, None; 8, block; 8, 9; 8, 13; 8, 17; 8, 21; 8, 27; 8, 141; 8, 173; 8, 187; 8, 245; 8, 315; 9, expression_statement; 9, 10; 10, ... | def iterrows(self, workbook=None):
resolved_tables = []
max_height = 0
max_width = 0
self.__formula_values = {}
for name, (table, (row, col)) in list(self.__tables.items()):
self.__tables[None] = (table, (row, col))
data = table.get_data(workbook, row, col... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:format_listfield_nodes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:field_name; 5, identifier:field; 6, identifier:field_id; 7, identifier:state; 8, identifier:lineno; 9, block; 9, 10; 9, 18; 9, 29; 9, 37; 9, 50; 9, 54; 9, 58; 9,... | def format_listfield_nodes(field_name, field, field_id, state, lineno):
itemtype_node = nodes.definition_list_item()
itemtype_node += nodes.term(text='Item type')
itemtype_def = nodes.definition()
itemtype_def += make_python_xref_nodes_for_type(
field.itemtype,
state,
hide_namesp... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:format_choicefield_nodes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:field_name; 5, identifier:field; 6, identifier:field_id; 7, identifier:state; 8, identifier:lineno; 9, block; 9, 10; 9, 18; 9, 97; 9, 105; 9, 119; 9, 127; 9, 1... | def format_choicefield_nodes(field_name, field, field_id, state, lineno):
choice_dl = nodes.definition_list()
for choice_value, choice_doc in field.allowed.items():
item = nodes.definition_list_item()
item_term = nodes.term()
item_term += nodes.literal(text=repr(choice_value))
it... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:format_configchoicefield_nodes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:field_name; 5, identifier:field; 6, identifier:field_id; 7, identifier:state; 8, identifier:lineno; 9, block; 9, 10; 9, 18; 9, 119; 9, 127; 9, 141; 9, 14... | def format_configchoicefield_nodes(field_name, field, field_id, state, lineno):
choice_dl = nodes.definition_list()
for choice_value, choice_class in field.typemap.items():
item = nodes.definition_list_item()
item_term = nodes.term()
item_term += nodes.literal(text=repr(choice_value))
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:format_registryfield_nodes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:field_name; 5, identifier:field; 6, identifier:field_id; 7, identifier:state; 8, identifier:lineno; 9, block; 9, 10; 9, 18; 9, 26; 9, 192; 9, 200; 9, 214; 9,... | def format_registryfield_nodes(field_name, field, field_id, state, lineno):
from lsst.pex.config.registry import ConfigurableWrapper
choice_dl = nodes.definition_list()
for choice_value, choice_class in field.registry.items():
if hasattr(choice_class, '__module__') \
and hasattr(choi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:translate_argv; 3, parameters; 3, 4; 4, identifier:raw_args; 5, block; 5, 6; 5, 10; 5, 57; 5, 64; 5, 86; 5, 93; 5, 147; 5, 154; 5, 165; 5, 172; 5, 183; 5, 190; 5, 204; 5, 211; 5, 225; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8,... | def translate_argv(raw_args):
kwargs = {}
def get_parameter(param_str):
for i, a in enumerate(raw_args):
if a == param_str:
assert len(raw_args) == i+2 and raw_args[i+1][0] != '-', \
'All arguments must have a value, e.g. `-testing true`'
r... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:run; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 37; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:document; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, id... | def run(self):
document = self.state.document
if not document.settings.file_insertion_enabled:
return [document.reporter.warning('File insertion disabled',
line=self.lineno)]
try:
location = self.state_machine.get_source_and_l... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:aggregate_duplicates; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:X; 5, identifier:Y; 6, default_parameter; 6, 7; 6, 8; 7, identifier:aggregator; 8, string:"mean"; 9, default_parameter; 9, 10; 9, 11; 10, identifier:precision; 11, iden... | def aggregate_duplicates(X, Y, aggregator="mean", precision=precision):
if callable(aggregator):
pass
elif "min" in aggregator.lower():
aggregator = np.min
elif "max" in aggregator.lower():
aggregator = np.max
elif "median" in aggregator.lower():
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:install; 3, parameters; 3, 4; 3, 5; 4, identifier:application; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 27; 7, 46; 7, 65; 7, 84; 7, 95; 8, if_statement; 8, 9; 8, 17; 9, comparison_operator:is; 9, 10; 9, 16; 10... | def install(application, **kwargs):
if getattr(application, 'statsd', None) is not None:
LOGGER.warning('Statsd collector is already installed')
return False
if 'host' not in kwargs:
kwargs['host'] = os.environ.get('STATSD_HOST', '127.0.0.1')
if 'port' not in kwargs:
kwargs['... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sign; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:user_id; 5, default_parameter; 5, 6; 5, 7; 6, identifier:user_type; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:today; 10, None; 11, default_parameter; 11, 12; 11, 13; 1... | def sign(user_id, user_type=None, today=None, session=None):
if session is None:
session = Session()
else:
session = session
if today is None:
today = date.today()
else:
today = today
user = (
session
.query(User)
.filter(User.user_id == user_i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:display; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:obj; 5, default_parameter; 5, 6; 5, 7; 6, identifier:skiphidden; 7, True; 8, dictionary_splat_pattern; 8, 9; 9, identifier:printargs; 10, block; 10, 11; 10, 18; 10, 37; 10, 87; 10, 122; 1... | def display(obj, skiphidden=True, **printargs):
top = findnode(obj)
maxhex = len(hex(ctypes.sizeof(top.type))) - 2
def addrformat(addr):
if isinstance(addr, int):
return "0x{0:0{1}X}".format(addr, maxhex)
else:
intpart = int(addr)
fracbits = int((addr - in... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:assemble; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 8; 4, identifier:self; 5, identifier:module; 6, list_splat_pattern; 6, 7; 7, identifier:modules; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 47; 11, expression_s... | def assemble(self, module, *modules, **kwargs):
mgr = AssemblyManager(
vector=self,
modules=[module] + list(modules),
name=kwargs.get("name", "assembly"),
id_=kwargs.get("id", "assembly"),
)
return mgr.assemble() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:getback; 3, parameters; 3, 4; 3, 5; 4, identifier:config; 5, default_parameter; 5, 6; 5, 7; 6, identifier:force; 7, False; 8, block; 8, 9; 8, 15; 8, 21; 8, 33; 8, 71; 8, 77; 8, 86; 8, 96; 8, 100; 8, 104; 8, 122; 8, 136; 8, 146; 8, 157; 8, 198; ... | def getback(config, force=False):
repo = config.repo
active_branch = repo.active_branch
if active_branch.name == "master":
error_out("You're already on the master branch.")
if repo.is_dirty():
error_out(
'Repo is "dirty". ({})'.format(
", ".join([repr(x.b_path... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:untldict_normalizer; 3, parameters; 3, 4; 3, 5; 4, identifier:untl_dict; 5, identifier:normalizations; 6, block; 6, 7; 6, 99; 7, for_statement; 7, 8; 7, 11; 7, 16; 8, pattern_list; 8, 9; 8, 10; 9, identifier:element_type; 10, identifier:element... | def untldict_normalizer(untl_dict, normalizations):
for element_type, element_list in untl_dict.items():
if element_type in normalizations:
norm_qualifier_list = normalizations.get(element_type)
for element in element_list:
qualifier = element.get('qualifier', None)
... |
0, module; 0, 1; 1, ERROR; 1, 2; 1, 207; 1, 214; 1, 223; 1, 237; 1, 254; 1, 263; 1, 269; 1, 286; 2, function_definition; 2, 3; 2, 4; 2, 9; 3, function_name:start; 4, parameters; 4, 5; 4, 6; 5, identifier:config; 6, default_parameter; 6, 7; 6, 8; 7, identifier:bugnumber; 8, string:""; 9, block; 9, 10; 9, 16; 9, 40; 9, 7... | def start(config, bugnumber=""):
repo = config.repo
if bugnumber:
summary, bugnumber, url = get_summary(config, bugnumber)
else:
url = None
summary = None
if summary:
summary = input('Summary ["{}"]: '.format(summary)).strip() or summary
else:
summary = input(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 12; 2, function_name:getPortSideView; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:side; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:List; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, string:"LPort"; 12, block; 12, 13; 13, if... | def getPortSideView(self, side) -> List["LPort"]:
if side == PortSide.WEST:
return self.west
elif side == PortSide.EAST:
return self.east
elif side == PortSide.NORTH:
return self.north
elif side == PortSide.SOUTH:
return self.south
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:command_line_config; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 20; 5, 24; 5, 28; 5, 108; 5, 208; 5, 241; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:args; 9, subscript; 9, 10; 9, 13; 10, attr... | def command_line_config(self):
args = sys.argv[1:]
args_dict = {}
existed_keys = []
new_keys = []
for t in args:
if not t.startswith('--'):
raise errors.ArgsParseError('Bad arg: %s' % t)
try:
key, value = tuple(t[2:].split('... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:create_form_data; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 18; 7, 28; 7, 38; 7, 48; 7, 56; 7, 197; 7, 201; 7, 261; 7, 309; 7, 321; 8, expression_statement; 8, 9; ... | def create_form_data(self, **kwargs):
children = kwargs.get('children', [])
sort_order = kwargs.get('sort_order', None)
solr_response = kwargs.get('solr_response', None)
superuser = kwargs.get('superuser', False)
vocabularies = self.get_vocabularies()
for element in child... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_untl; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:sort_structure; 6, block; 6, 7; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 14; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, ide... | def sort_untl(self, sort_structure):
self.children.sort(key=lambda obj: sort_structure.index(obj.tag)) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:top; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:sort_by; 6, block; 6, 7; 6, 19; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:sort; 10, call; 10, 11; 10, 12; 11, identifier:sorted; 12, argument_list;... | def top(self, sort_by):
sort = sorted(self.results, key=sort_by)
return sort |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:portTryReduce; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:root; 6, type; 6, 7; 7, identifier:LNode; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:port; 10, type; 10, 11; 11, identifier:LPort; 12, block; 12, 13; 1... | def portTryReduce(root: LNode, port: LPort):
if not port.children:
return
for p in port.children:
portTryReduce(root, p)
target_nodes = {}
ch_cnt = countDirectlyConnected(port, target_nodes)
if not target_nodes:
return
new_target, children_edge_to_destroy = max(target_nod... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 14; 2, function_name:countDirectlyConnected; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:port; 6, type; 6, 7; 7, identifier:LPort; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:result; 10, type; 10, 11; 11, identifier:dict; 12,... | def countDirectlyConnected(port: LPort, result: dict) -> int:
inEdges = port.incomingEdges
outEdges = port.outgoingEdges
if port.children:
ch_cnt = 0
for ch in port.children:
ch_cnt += countDirectlyConnected(ch, result)
return ch_cnt
elif not inEdges and not outEdges:... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:untlxml2py; 3, parameters; 3, 4; 4, identifier:untl_filename; 5, block; 5, 6; 5, 10; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:parent_stack; 9, list:[]; 10, for_statement; 10, 11; 10, 14; 10, 23; 11, pattern_list; ... | def untlxml2py(untl_filename):
parent_stack = []
for event, element in iterparse(untl_filename, events=('start', 'end')):
if NAMESPACE_REGEX.search(element.tag, 0):
element_tag = NAMESPACE_REGEX.search(element.tag, 0).group(1)
else:
element_tag = element.tag
if el... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:post2pydict; 3, parameters; 3, 4; 3, 5; 4, identifier:post; 5, identifier:ignore_list; 6, block; 6, 7; 6, 15; 6, 19; 6, 30; 6, 77; 6, 377; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:root_element; 10, call; 10, 11; ... | def post2pydict(post, ignore_list):
root_element = PYUNTL_DISPATCH['metadata']()
untl_form_dict = {}
form_post = dict(post.copy())
for key, value_list in form_post.items():
if key not in ignore_list:
(element_tag, element_attribute) = key.split('-', 1)
if element_tag not ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:untlpy2dcpy; 3, parameters; 3, 4; 3, 5; 4, identifier:untl_elements; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 12; 7, 16; 7, 26; 7, 36; 7, 46; 7, 56; 7, 66; 7, 76; 7, 102; 7, 110; 7, 236; 7, 289; 7, 340; 8, exp... | def untlpy2dcpy(untl_elements, **kwargs):
sDate = None
eDate = None
ark = kwargs.get('ark', None)
domain_name = kwargs.get('domain_name', None)
scheme = kwargs.get('scheme', 'http')
resolve_values = kwargs.get('resolve_values', None)
resolve_urls = kwargs.get('resolve_urls', None)
verbos... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:untlpy2highwirepy; 3, parameters; 3, 4; 3, 5; 4, identifier:untl_elements; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 12; 7, 16; 7, 20; 7, 24; 7, 34; 7, 180; 7, 190; 8, expression_statement; 8, 9; 9, assignment;... | def untlpy2highwirepy(untl_elements, **kwargs):
highwire_list = []
title = None
publisher = None
creation = None
escape = kwargs.get('escape', False)
for element in untl_elements.children:
if element.tag in HIGHWIRE_CONVERSION_DISPATCH:
highwire_element = HIGHWIRE_CONVERSION_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:untlpy2etd_ms; 3, parameters; 3, 4; 3, 5; 4, identifier:untl_elements; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 12; 7, 16; 7, 20; 7, 28; 7, 287; 7, 340; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, ... | def untlpy2etd_ms(untl_elements, **kwargs):
degree_children = {}
date_exists = False
seen_creation = False
etd_ms_root = ETD_MS_CONVERSION_DISPATCH['thesis']()
for element in untl_elements.children:
etd_ms_element = None
if element.tag in ETD_MS_CONVERSION_DISPATCH:
if el... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:global_request; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:kind; 6, default_parameter; 6, 7; 6, 8; 7, identifier:data; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:wait; 11, True; 12, block; 12, 13;... | def global_request(self, kind, data=None, wait=True):
if wait:
self.completion_event = threading.Event()
m = Message()
m.add_byte(cMSG_GLOBAL_REQUEST)
m.add_string(kind)
m.add_boolean(wait)
if data is not None:
m.add(*data)
self._log(DEBUG,... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_by_range; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:model_cls; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 19; 9, 28; 9, 46; 9, 66; 9, 103; 10, expressio... | def get_by_range(model_cls, *args, **kwargs):
start_timestamp = kwargs.get('start_timestamp')
end_timestamp = kwargs.get('end_timestamp')
if (start_timestamp is not None) and (end_timestamp is not None) and (start_timestamp > end_timestamp):
raise InvalidTimestampRange
models = model_cls.read_ti... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:add_data; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:data; 6, default_parameter; 6, 7; 6, 8; 7, identifier:metadata; 8, None; 9, block; 9, 10; 9, 19; 9, 60; 9, 68; 9, 108; 9, 125; 9, 129; 9, 170; 10, expression_statement... | def add_data(self, data, metadata=None):
subdata = np.atleast_2d(data)
if subdata.shape[1] != self.grid.nr_of_elements:
if subdata.shape[0] == self.grid.nr_of_elements:
subdata = subdata.T
else:
raise Exception(
'Number of value... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:linked_model_for_class; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:cls; 6, default_parameter; 6, 7; 6, 8; 7, identifier:make_constants_variable; 8, False; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs;... | def linked_model_for_class(self, cls, make_constants_variable=False, **kwargs):
constructor_args = inspect.getfullargspec(cls).args
attribute_tuples = self.attribute_tuples
new_model = PriorModel(cls)
for attribute_tuple in attribute_tuples:
name = attribute_tuple.name
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:load_categories; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_pages; 7, integer:30; 8, block; 8, 9; 8, 16; 8, 38; 8, 49; 8, 56; 8, 60; 8, 70; 8, 89; 9, expression_statement; 9, 10; 10, call;... | def load_categories(self, max_pages=30):
logger.info("loading categories")
if self.purge_first:
Category.objects.filter(site_id=self.site_id).delete()
path = "sites/{}/categories".format(self.site_id)
params = {"number": 100}
page = 1
response = self.get(path,... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:load_tags; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_pages; 7, integer:30; 8, block; 8, 9; 8, 16; 8, 38; 8, 49; 8, 56; 8, 60; 8, 70; 8, 89; 9, expression_statement; 9, 10; 10, call; 10, 1... | def load_tags(self, max_pages=30):
logger.info("loading tags")
if self.purge_first:
Tag.objects.filter(site_id=self.site_id).delete()
path = "sites/{}/tags".format(self.site_id)
params = {"number": 1000}
page = 1
response = self.get(path, params)
if no... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:load_authors; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_pages; 7, integer:10; 8, block; 8, 9; 8, 16; 8, 38; 8, 49; 8, 56; 8, 60; 8, 70; 8, 89; 9, expression_statement; 9, 10; 10, call; 10... | def load_authors(self, max_pages=10):
logger.info("loading authors")
if self.purge_first:
Author.objects.filter(site_id=self.site_id).delete()
path = "sites/{}/users".format(self.site_id)
params = {"number": 100}
page = 1
response = self.get(path, params)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:load_media; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_pages; 7, integer:150; 8, block; 8, 9; 8, 16; 8, 48; 8, 59; 8, 66; 8, 73; 8, 77; 8, 87; 8, 106; 9, expression_statement; 9, 10; 10, c... | def load_media(self, max_pages=150):
logger.info("loading media")
if self.purge_first:
logger.warning("purging ALL media from site %s", self.site_id)
Media.objects.filter(site_id=self.site_id).delete()
path = "sites/{}/media".format(self.site_id)
params = {"number... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:load_wp_post; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:api_post; 6, default_parameter; 6, 7; 6, 8; 7, identifier:bulk_mode; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:post_c... | def load_wp_post(self, api_post, bulk_mode=True, post_categories=None, post_tags=None, post_media_attachments=None, posts=None):
if post_categories is None:
post_categories = {}
if post_tags is None:
post_tags = {}
if post_media_attachments is None:
post_media... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sync_deleted_attachments; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:api_post; 6, block; 6, 7; 6, 46; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:existing_IDs; 10, call; 10, 11; 10, 12; 11, identif... | def sync_deleted_attachments(self, api_post):
existing_IDs = set(Post.objects.filter(site_id=self.site_id,
post_type="attachment",
parent__icontains='"ID":{}'.format(api_post["ID"]))
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 25; 2, function_name:http_request; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 4, identifier:self; 5, identifier:verb; 6, identifier:uri; 7, default_parameter; 7, 8; 7, 9; 8, identifier:data; 9, None; 10, default_parameter; 10, 11; 10... | def http_request(self,
verb,
uri,
data=None,
headers=None,
files=None,
response_format=None,
is_rdf = True,
stream = False
):
'''
Primary route for all HTTP requests to repository. Ability to set most parameters for requests library,
with some additional convenience parameters as well.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:create; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:specify_uri; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:ignore_tombstone; 10, False; 11, default_... | def create(self, specify_uri=False, ignore_tombstone=False, serialization_format=None, stream=False, auto_refresh=None):
'''
Primary method to create resources.
Args:
specify_uri (bool): If True, uses PUT verb and sets the URI during creation. If False, uses POST and gets repository minted URI
ignore_tombs... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:refresh; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:refresh_binary; 7, True; 8, block; 8, 9; 8, 11; 8, 24; 8, 50; 9, expression_statement; 9, 10; 10, string:'''
Performs GET request and refr... | def refresh(self, refresh_binary=True):
'''
Performs GET request and refreshes RDF information for resource.
Args:
None
Returns:
None
'''
updated_self = self.repo.get_resource(self.uri)
if not isinstance(self, type(updated_self)):
raise Exception('Instantiated %s, but repository reports this reso... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:update; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sparql_query_only; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:auto_refresh; 10, None; 11, default_parameter; 11... | def update(self, sparql_query_only=False, auto_refresh=None, update_binary=True):
'''
Method to update resources in repository. Firing this method computes the difference in the local modified graph and the original one,
creates an instance of SparqlUpdate and builds a sparql query that represents these differen... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:update_gunicorns; 3, parameters; 4, block; 4, 5; 4, 7; 4, 11; 4, 22; 4, 26; 4, 45; 4, 66; 4, 79; 4, 88; 4, 97; 4, 241; 4, 265; 4, 284; 5, global_statement; 5, 6; 6, identifier:tick; 7, expression_statement; 7, 8; 8, augmented_assignment:+=; 8, ... | def update_gunicorns():
global tick
tick += 1
if (tick * screen_delay) % ps_delay != 0:
return
tick = 0
for pid in gunicorns:
gunicorns[pid].update({"workers": 0, "mem": 0})
ps = Popen(PS_ARGS, stdout=PIPE).communicate()[0].split("\n")
headings = ps.pop(0).split()
name_co... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:handle_keypress; 3, parameters; 3, 4; 4, identifier:screen; 5, block; 5, 6; 5, 8; 5, 25; 6, global_statement; 6, 7; 7, identifier:selected_pid; 8, try_statement; 8, 9; 8, 22; 9, block; 9, 10; 10, expression_statement; 10, 11; 11, assignment; 11... | def handle_keypress(screen):
global selected_pid
try:
key = screen.getkey().upper()
except:
return
if key in ("KEY_DOWN", "J"):
move_selection()
elif key in ("KEY_UP", "K"):
move_selection(reverse=True)
elif key in ("A", "+"):
send_signal("TTIN")
i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:renderContent; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 18; 5, 40; 5, 71; 5, 77; 5, 147; 5, 167; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:stm; 9, attribute; 9, 10; 9, 11; 10, identifier:s... | def renderContent(self):
stm = self.stm
portCtx = self.portCtx
for o in stm._outputs:
if not self.isVirtual:
portCtx.register(o, PortType.OUTPUT)
canHaveRamPorts = isinstance(stm, IfContainer) and arr_any(
chain(stm._inputs, stm._outputs),
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:generate; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:project; 6, block; 6, 7; 6, 30; 6, 34; 6, 53; 6, 94; 6, 113; 6, 132; 6, 151; 6, 170; 6, 189; 6, 208; 6, 218; 6, 226; 7, for_statement; 7, 8; 7, 9; 7, 12; 8, identifier:assig... | def generate(self, project):
for assignment in self.s2n_mapping:
if assignment["ipprefix"] == project:
self._name = assignment["package"]
return self
name = project
if name.startswith("github.com"):
name = re.sub(r"^github\.com", "github", name)
if name.startswith("gopkg.in"):
name = re.sub(r"g... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_read_elem_nodes; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:fid; 6, block; 6, 7; 6, 11; 6, 29; 6, 72; 6, 96; 6, 140; 6, 288; 6, 294; 6, 300; 6, 306; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:nod... | def _read_elem_nodes(self, fid):
nodes = {}
nodes_raw = np.empty((self.header['nr_nodes'], 3), dtype=float)
for nr in range(0, self.header['nr_nodes']):
node_line = fid.readline().lstrip()
nodes_raw[nr, :] = np.fromstring(
node_line, dtype=float, sep=' ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:errorhandle; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:resp; 6, block; 6, 7; 6, 201; 7, if_statement; 7, 8; 7, 13; 7, 141; 7, 190; 8, comparison_operator:==; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, i... | def errorhandle(self, resp):
if self.format == 'json':
parsed = xmltodict.parse(resp)
errors = parsed[self.RESPONSE_TOKEN][self.ERROR_TOKEN]
if type(errors) is list and len(errors) > 1:
messages = ", ".join([" ".join(["{}: {}".format(k,v) for k, v ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:cleanup; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:config; 5, identifier:searchstring; 6, default_parameter; 6, 7; 6, 8; 7, identifier:force; 8, False; 9, block; 9, 10; 9, 16; 9, 27; 9, 68; 9, 75; 9, 83; 9, 89; 9, 101; 9, 105; 9, 109; 9, 1... | def cleanup(config, searchstring, force=False):
repo = config.repo
branches_ = list(find(repo, searchstring))
if not branches_:
error_out("No branches found")
elif len(branches_) > 1:
error_out(
"More than one branch found.{}".format(
"\n\t".join([""] + [x.nam... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:construct; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:data; 6, block; 6, 7; 6, 11; 6, 15; 6, 94; 6, 100; 6, 143; 6, 149; 6, 171; 6, 184; 6, 188; 6, 192; 6, 236; 6, 245; 6, 254; 7, expression_statement; 7, 8; 8, assignment; 8, ... | def construct(self, data):
occurrences = {}
main_occurrences = {}
for pkg in data["data"]["dependencies"]:
package = pkg["package"]
for item in pkg["dependencies"]:
dep = item["name"]
if package != ".":
deps = map(lambda l: "%s/%s" % (package, l), item["location"])
else:
deps = item["l... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:td_is_finished; 3, parameters; 3, 4; 4, identifier:tomodir; 5, block; 5, 6; 5, 18; 5, 120; 5, 292; 6, if_statement; 6, 7; 6, 12; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:is_tomodir; 10, argument_list; 10, 11; 11, identifier:to... | def td_is_finished(tomodir):
if not is_tomodir(tomodir):
raise Exception('Supplied directory is not a tomodir!')
if(os.path.isfile(tomodir + os.sep + 'config/config.dat') and
os.path.isfile(tomodir + os.sep + 'rho/rho.dat') and
os.path.isfile(tomodir + os.sep + 'grid/elem.dat') and
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sipdir_is_finished; 3, parameters; 3, 4; 4, identifier:sipdir; 5, block; 5, 6; 5, 18; 5, 42; 5, 59; 5, 63; 5, 67; 5, 96; 6, if_statement; 6, 7; 6, 12; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:is_sipdir; 10, argument_list; 10, ... | def sipdir_is_finished(sipdir):
if not is_sipdir(sipdir):
raise Exception('Directory is not a valid SIP directory!')
subdirs_raw = sorted(glob.glob(sipdir + os.sep + 'invmod' + os.sep + '*'))
subdirs = [x for x in subdirs_raw if os.path.isdir(x)]
crmod_finished = True
crtomo_finished = True
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 38; 2, function_name:list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:source_ids; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sen... | def list(self, source_ids=None, seniority="all", stage=None,
date_start="1494539999", date_end=TIMESTAMP_NOW, filter_id=None,
page=1, limit=30, sort_by='ranking', filter_reference=None, order_by=None):
query_params = {}
query_params["date_end"] = _validate_timestamp(date_end, "da... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:iterdupes; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:compare; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:filt; 10, None; 11, block; 11, 12; 11, 14; 11, 24; 11, 28; 11, 3... | def iterdupes(self, compare=None, filt=None):
''' streaming item iterator with low overhead duplicate file detection
Parameters:
- compare compare function between files (defaults to md5sum)
'''
if not compare: compare = self.md5sum
seen_siz = {}
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 10; 2, function_name:objects_to_root; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:objects; 6, type; 6, 7; 7, identifier:List; 8, type; 8, 9; 9, identifier:Root; 10, block; 10, 11; 10, 118; 10, 192; 10, 199; 11, function_definition; 11,... | def objects_to_root(objects: List) -> Root:
def _to_tree(objs: Iterable) -> Dict:
path_tree = {}
for obj in objs:
is_dir = obj.key.endswith('/')
chunks = [chunk for chunk in obj.key.split('/') if chunk]
chunk_count = len(chunks)
tmp = path_tree
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:xml_file; 6, block; 6, 7; 6, 9; 6, 13; 6, 34; 6, 337; 7, expression_statement; 7, 8; 8, string:"Get a list of parsed recipes from BeerXML input"; 9, expression_statement; 9, 10... | def parse(self, xml_file):
"Get a list of parsed recipes from BeerXML input"
recipes = []
with open(xml_file, "rt") as f:
tree = ElementTree.parse(f)
for recipeNode in tree.iter():
if self.to_lower(recipeNode.tag) != "recipe":
continue
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_parse_extra; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:fp; 6, block; 6, 7; 6, 11; 6, 15; 6, 22; 6, 146; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:comment; 10, string:''; 11, expression_statemen... | def _parse_extra(self, fp):
comment = ''
section = ''
fp.seek(0)
for line in fp:
line = line.rstrip()
if not line:
if comment:
comment += '\n'
continue
if line.startswith('
comment += ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 43; 1, 47; 2, function_name:_sample_action_fluent; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 15; 3, 23; 3, 33; 3, 39; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:name; 7, type; 7, 8; 8, identifier:str; 9, typed_parameter; 9, 10; 9, 11; 10, identifi... | def _sample_action_fluent(self,
name: str,
dtype: tf.DType,
size: Sequence[int],
constraints: Dict[str, Constraints],
default_value: tf.Tensor,
prob: float) -> tf.Tensor:
'''Samples the action fluent with given `name`, `dtype`, and `size`.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 1, 31; 2, function_name:UnitToLNode; 3, parameters; 3, 4; 3, 8; 3, 17; 3, 26; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:u; 6, type; 6, 7; 7, identifier:Unit; 8, typed_default_parameter; 8, 9; 8, 10; 8, 16; 9, identifier:node; 10, type; 10, 11; 11, generic_... | def UnitToLNode(u: Unit, node: Optional[LNode]=None,
toL: Optional[dict]=None,
optimizations=[]) -> LNode:
if toL is None:
toL = {}
if node is None:
root = LNode(name=u._name, originObj=u, node2lnode=toL)
else:
root = node
stmPorts = {}
netCtx ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_hypergeometric_stats; 3, parameters; 3, 4; 3, 5; 4, identifier:N; 5, identifier:indices; 6, block; 6, 7; 6, 17; 6, 38; 6, 44; 6, 60; 6, 76; 6, 82; 6, 88; 6, 92; 6, 96; 6, 100; 6, 221; 7, assert_statement; 7, 8; 8, call; 8, 9; 8, 10; 9, iden... | def get_hypergeometric_stats(N, indices):
assert isinstance(N, (int, np.integer))
assert isinstance(indices, np.ndarray) and \
np.issubdtype(indices.dtype, np.uint16)
K = indices.size
pvals = np.empty(N+1, dtype=np.float64)
folds = np.empty(N+1, dtype=np.float64)
pvals[0] = 1.0
f... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:purge_existing_ovb; 3, parameters; 3, 4; 3, 5; 4, identifier:nova_api; 5, identifier:neutron; 6, block; 6, 7; 6, 14; 6, 55; 6, 137; 6, 228; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:LOG; 11,... | def purge_existing_ovb(nova_api, neutron):
LOG.info('Cleaning up OVB environment from the tenant.')
for server in nova_api.servers.list():
if server.name in ('bmc', 'undercloud'):
server.delete()
if server.name.startswith('baremetal_'):
server.delete()
for router in n... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:reduceUselessAssignments; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:root; 6, type; 6, 7; 7, identifier:LNode; 8, block; 8, 9; 8, 25; 8, 29; 8, 223; 9, for_statement; 9, 10; 9, 11; 9, 14; 10, identifier:n; 11, attribute;... | def reduceUselessAssignments(root: LNode):
for n in root.children:
if n.children:
reduceUselessAssignments(n)
do_update = False
for n in root.children:
if isinstance(n.originObj, Assignment)\
and not n.originObj.indexes\
and len(n.west) == 1:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:determine_completeness; 3, parameters; 3, 4; 4, identifier:py_untl; 5, block; 5, 6; 5, 91; 5, 107; 5, 111; 5, 199; 5, 222; 5, 228; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:completeness_dict; 9, dictionary; 9, 10; ... | def determine_completeness(py_untl):
completeness_dict = {
'title': {'present': False, 'weight': 10, },
'description': {'present': False, 'weight': 1, },
'language': {'present': False, 'weight': 1, },
'collection': {'present': False, 'weight': 10, },
'institution': {'present'... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:read_char_lengths; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:filename; 6, identifier:electrode_filename; 7, block; 7, 8; 7, 144; 7, 161; 7, 167; 8, if_statement; 8, 9; 8, 17; 8, 133; 9, call; 9, 10; 9, 15; 10, attribute... | def read_char_lengths(self, filename, electrode_filename):
if os.path.isfile(filename):
data = np.atleast_1d(np.loadtxt(filename))
if data.size == 4:
characteristic_length = data
if characteristic_length[0] < 0:
try:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:parse_atom_tag_data; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, identifier:tag_content; 7, block; 7, 8; 7, 10; 7, 16; 8, expression_statement; 8, 9; 9, string:'''Parse the atom tag data.'''; 10, expression_state... | def parse_atom_tag_data(self, name, tag_content):
'''Parse the atom tag data.'''
current_atom_site = self.current_atom_site
if current_atom_site.IsHETATM:
return
elif name == 'PDBx:atom_site':
self._BLOCK = None
current_atom_site = self.current_atom_si... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:link; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 4, default_parameter; 4, 5; 4, 6; 5, identifier:origin; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:rel; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:value; 1... | def link(origin=None, rel=None, value=None, attributes=None, source=None):
'''
Action function generator to create a link based on the context's current link, or on provided parameters
:param origin: IRI/string, or list of same; origins for the created relationships.
If None, the action context provides... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:foreach; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:origin; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:rel; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:target; 12, ... | def foreach(origin=None, rel=None, target=None, attributes=None):
'''
Action function generator to compute a combination of links
:return: Versa action function to do the actual work
'''
def _foreach(ctx):
'''
Versa action function utility to compute a list of values from a list of e... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_method_documentation; 3, parameters; 3, 4; 4, identifier:method; 5, block; 5, 6; 5, 11; 5, 43; 5, 50; 5, 54; 5, 177; 5, 188; 5, 203; 5, 343; 5, 354; 6, import_from_statement; 6, 7; 6, 9; 7, dotted_name; 7, 8; 8, identifier:inspect; 9, dotte... | def get_method_documentation(method):
from inspect import getargspec
result = {
'name': method.__name__,
'friendly_name': ' '.join([name.capitalize() for name in method.__name__.split('_')]),
}
arg_specs = getargspec(method)
arguments = {}
if not arg_specs.defaults:
if le... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_dictionary_list; 3, parameters; 3, 4; 3, 5; 4, identifier:dict_list; 5, identifier:sort_key; 6, block; 6, 7; 6, 20; 6, 32; 7, if_statement; 7, 8; 7, 17; 8, boolean_operator:or; 8, 9; 8, 11; 9, not_operator; 9, 10; 10, identifier:dict_list;... | def sort_dictionary_list(dict_list, sort_key):
if not dict_list or len(dict_list) == 0:
return dict_list
dict_list.sort(key=itemgetter(sort_key))
return dict_list |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_push; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:title; 6, identifier:view; 7, identifier:class_name; 8, identifier:is_class; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block; 11, ... | def _push(self, title, view, class_name, is_class, **kwargs):
set_view_attr(view, "title", title, cls_name=class_name)
module_name = view.__module__
method_name = view.__name__
_endpoint = build_endpoint_route_name(view, "index" if is_class else method_name, class_name)
endpoint ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:render; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 14; 5, 216; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:menu_list; 9, list:[]; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, ... | def render(self):
menu_list = []
menu_index = 0
for _, menu in copy.deepcopy(self.MENU).items():
subnav = []
menu["kwargs"]["_id"] = str(menu_index)
menu["kwargs"]["active"] = False
if "visible" in menu["kwargs"]:
menu["kwargs"]["vi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:add_item; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:url; 6, default_parameter; 6, 7; 6, 8; 7, identifier:title; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:selection; 11, None... | def add_item(self, url, title=None, selection=None,
jsonp=None, redirect=None, response_info=False):
parameters = {
'username' : self.user,
'password' : self.password,
'url' : url,
}
if title is not N... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_determine_representative_chains; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 18; 5, 150; 5, 171; 5, 177; 6, expression_statement; 6, 7; 7, string:''' Quotient the chains to get equivalence classes of chains. These ... | def _determine_representative_chains(self):
''' Quotient the chains to get equivalence classes of chains. These will be used for the actual mapping.'''
equivalence_fiber = {}
matched_chains = set()
for chain_id, equivalent_chains in self.identical_sequences.iteritems():
match... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_align_with_substrings; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:chains_to_skip; 7, call; 7, 8; 7, 9; 8, identifier:set; 9, argument_list; 10, block; 10, 11; 10, 13; 10, 186; 10, 195; 10, 2... | def _align_with_substrings(self, chains_to_skip = set()):
'''Simple substring-based matching'''
for c in self.representative_chains:
if c not in chains_to_skip:
fasta_sequence = self.fasta[c]
substring_matches = {}
for uniparc_id, uniparc_seque... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_chain_mutations; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:pdb_id_1; 6, identifier:chain_1; 7, identifier:pdb_id_2; 8, identifier:chain_2; 9, block; 9, 10; 9, 12; 9, 21; 9, 30; 9, 42; 9, 54; 9, 66; 9, 88... | def get_chain_mutations(self, pdb_id_1, chain_1, pdb_id_2, chain_2):
'''Returns a list of tuples each containing a SEQRES Mutation object and an ATOM Mutation object representing the
mutations from pdb_id_1, chain_1 to pdb_id_2, chain_2.
SequenceMaps are constructed in this function betwee... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:make; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:apps; 6, block; 6, 7; 6, 368; 7, for_statement; 7, 8; 7, 11; 7, 33; 8, tuple_pattern; 8, 9; 8, 10; 9, identifier:appname; 10, identifier:app; 11, call; 11, 12; 11, 13; 12, ident... | def make(self, apps):
for (appname, app) in sorted(apps.items(), key=lambda x: (x[1].priority, x[0])):
logger.info('Getting report results from %r', appname)
for report_data in app.report_data:
if report_data.subreport != self.name:
continue
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_report_parts; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:apps; 6, identifier:formats; 7, block; 7, 8; 7, 41; 7, 48; 7, 139; 7, 143; 7, 179; 7, 212; 7, 221; 7, 225; 7, 300; 8, for_statement; 8, 9; 8, 10; 8, 11; 9, ide... | def get_report_parts(self, apps, formats):
for fmt in formats:
width = 100 if fmt is not None else tui.get_terminal_size()[0]
for sr in self.subreports:
sr.make_format(fmt, width)
logger.debug('Build a map for arguments and run\'s statistics ...')
value_ma... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_convert; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:chain_id; 6, identifier:residue_id; 7, identifier:from_scheme; 8, identifier:to_scheme; 9, block; 9, 10; 9, 12; 9, 50; 9, 105; 9, 160; 9, 198; 10, expressi... | def _convert(self, chain_id, residue_id, from_scheme, to_scheme):
'''The actual 'private' conversion function.'''
if from_scheme == 'rosetta':
atom_id = self.rosetta_to_atom_sequence_maps.get(chain_id, {})[residue_id]
if to_scheme == 'atom':
return atom_id
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_create_sequences; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 40; 5, 71; 5, 86; 5, 96; 5, 106; 5, 149; 5, 153; 5, 259; 5, 336; 6, expression_statement; 6, 7; 7, string:'''Get all of the Sequences - Rosetta, ATOM, SEQRES, ... | def _create_sequences(self):
'''Get all of the Sequences - Rosetta, ATOM, SEQRES, FASTA, UniParc.'''
try:
self.pdb.construct_pdb_to_rosetta_residue_map(self.rosetta_scripts_path, rosetta_database_path = self.rosetta_database_path, cache_dir = self.cache_dir)
except PDBMissingMainchai... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:search_update_index; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 17; 5, 35; 5, 43; 5, 104; 5, 262; 5, 274; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:doc_id; 9, call; 9, 10; 9, 13; 10, attribute; 10,... | def search_update_index(self):
doc_id = self.search_get_document_id(self.key)
fields = [search.AtomField('class_name', name) for name in self.search_get_class_names()]
index = self.search_get_index()
if self.searchable_fields is None:
searchable_fields = []
for fi... |
0, module; 0, 1; 0, 64; 0, 73; 0, 86; 0, 103; 0, 126; 0, 136; 0, 194; 0, 225; 0, 242; 0, 255; 1, function_definition; 1, 2; 1, 3; 1, 20; 1, 33; 2, function_name:index_siblings; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:pid; 5, default_parameter; 5, 6; 5, 7; 6, identifier:include_pid; 7, False;... | def index_siblings(pid, include_pid=False, children=None,
neighbors_eager=False, eager=False, with_deposits=True):
assert not (neighbors_eager and eager), \
if children is None:
parent_pid = PIDNodeVersioning(pid=pid).parents.first()
children = PIDNodeVersioning(pid=parent_pid... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:iter_paths; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pathnames; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:mapfunc; 10, None; 11, block; 11, 12; 11, 20; 11, 40; 12, exp... | def iter_paths(self, pathnames=None, mapfunc=None):
pathnames = pathnames or self._pathnames
if self.recursive and not pathnames:
pathnames = ['.']
elif not pathnames:
yield []
if mapfunc is not None:
for mapped_paths in map(mapfunc, pathnames):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:process; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:source; 5, identifier:target; 6, identifier:rdfsonly; 7, default_parameter; 7, 8; 7, 9; 8, identifier:base; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:log... | def process(source, target, rdfsonly, base=None, logger=logging):
'''
Prepare a statement into a triple ready for rdflib graph
'''
for link in source.match():
s, p, o = link[:3]
if s == (base or '') + '@docheader': continue
if p in RESOURCE_MAPPING: p = RESOURCE_MAPPING[p]
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:show_more; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 4, identifier:request; 5, identifier:post_process_fun; 6, identifier:get_fun; 7, identifier:object_class; 8, default_parameter; 8, 9; 8, 10; 9, identifier:should_cache; 10, ... | def show_more(request, post_process_fun, get_fun, object_class, should_cache=True, template='common_json.html', to_json_kwargs=None):
if not should_cache and 'json_orderby' in request.GET:
return render_json(request, {
'error': "Can't order the result according to the JSON field, because the cac... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 28; 2, function_name:cache_control; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 4, default_parameter; 4, 5; 4, 6; 5, identifier:max_age; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:private; 9, False; 10, default_parameter; 10,... | def cache_control(max_age=None, private=False, public=False, s_maxage=None,
must_revalidate=False, proxy_revalidate=False, no_cache=False,
no_store=False):
if all([private, public]):
raise ValueError("'private' and 'public' are mutually exclusive")
if isinstance(max_age, timedelta):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:plot_places; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 15; 5, 25; 5, 29; 5, 33; 5, 90; 5, 133; 5, 149; 5, 159; 5, 169; 5, 212; 6, expression_statement; 6, 7; 7, string:'''Plot places where the agent has been and generate... | def plot_places(self):
'''Plot places where the agent has been and generated a spirograph.
'''
from matplotlib import pyplot as plt
fig, ax = plt.subplots()
x = []
y = []
if len(self.arg_history) > 1:
xs = []
ys = []
for p in se... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:df; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:unit; 6, string:'GB'; 7, block; 7, 8; 7, 10; 7, 14; 7, 25; 7, 32; 7, 38; 7, 56; 7, 66; 7, 75; 7, 101; 7, 112; 7, 130; 7, 317; 8, expression_statement; 8, 9; 9, string:'''A... | def df(unit = 'GB'):
'''A wrapper for the df shell command.'''
details = {}
headers = ['Filesystem', 'Type', 'Size', 'Used', 'Available', 'Capacity', 'MountedOn']
n = len(headers)
unit = df_conversions[unit]
p = subprocess.Popen(args = ['df', '-TP'], stdout = subprocess.PIPE)
stdout, stderr ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:vote_mean; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:candidates; 5, identifier:votes; 6, identifier:n_winners; 7, block; 7, 8; 7, 21; 7, 45; 7, 67; 7, 78; 7, 95; 7, 110; 7, 114; 7, 143; 8, expression_statement; 8, 9; 9, assignment; 9, 10; ... | def vote_mean(candidates, votes, n_winners):
sums = {str(candidate): [] for candidate in candidates}
for vote in votes:
for v in vote:
sums[str(v[0])].append(v[1])
for s in sums:
sums[s] = sum(sums[s]) / len(sums[s])
ordering = list(sums.items())
ordering.sort(key=operato... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:vote; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:candidates; 6, block; 6, 7; 6, 24; 6, 41; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:ranks; 10, list_comprehension; 10, 11; 10, 21; 11, tuple; 11, ... | def vote(self, candidates):
ranks = [(c, self.evaluate(c)[0]) for c in candidates]
ranks.sort(key=operator.itemgetter(1), reverse=True)
return ranks |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:gather_votes; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:candidates; 6, block; 6, 7; 6, 11; 6, 38; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:votes; 10, list:[]; 11, for_statement; 11, 12; 11, 13;... | def gather_votes(self, candidates):
votes = []
for a in self.get_agents(addr=False):
vote = a.vote(candidates)
votes.append(vote)
return votes |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:install_dependencies; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:feature; 6, None; 7, block; 7, 8; 7, 11; 7, 19; 7, 29; 7, 49; 7, 106; 7, 116; 7, 128; 7, 159; 7, 168; 7, 176; 7, 191; 7, 207; 7, 344; 8, import_statement... | def install_dependencies(feature=None):
import subprocess
echo(green('\nInstall dependencies:'))
echo(green('-' * 40))
req_path = os.path.realpath(os.path.dirname(__file__) + '/../_requirements')
if not feature:
echo(yellow('Please specify a feature to install. \n'))
for index, item ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:resolve_handler; 3, parameters; 3, 4; 3, 5; 4, identifier:request; 5, identifier:view_handlers; 6, block; 6, 7; 6, 11; 6, 50; 6, 57; 6, 63; 6, 69; 6, 135; 6, 141; 6, 147; 6, 176; 6, 199; 6, 205; 6, 222; 6, 233; 6, 250; 7, expression_statement; ... | def resolve_handler(request, view_handlers):
view = None
if request._context:
route_name = request._context[-1].route.name
if route_name and VIEW_SEPARATOR in route_name:
view = route_name.split(VIEW_SEPARATOR, 1)[1] or None
if view not in view_handlers:
raise NotFound
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:url_for; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:args; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kw; 8, block; 8, 9; 8, 30; 8, 40; 8, 50; 8, 62; 8, 109; 9, expression_statement; 9, 10; 10, assignment; 10, 11... | def url_for(*args, **kw):
self, target, args = args[0], args[1], list(args[2:])
query = kw.pop('_query', None)
relative = kw.pop('_relative', False)
url = build_url(self._context, target, args, kw)
if query:
if isinstance(query, dict):
query = sorted(q... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 35; 2, function_name:execute; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 4, identifier:command; 5, default_parameter; 5, 6; 5, 7; 6, identifier:return_output; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:l... | def execute(command, return_output=True, log_file=None, log_settings=None, error_logfile=None, timeout=None, line_function=None, poll_timing = 0.01, logger=None, working_folder=None, env=None):
tmp_log = False
if log_settings:
log_folder = log_settings.get('LOG_FOLDER')
else:
tmp_log = True
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:add_backbone_atoms_linearly_from_loop_filepaths; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:loop_json_filepath; 6, identifier:fasta_filepath; 7, identifier:residue_ids; 8, block; 8, 9; 8, 11; 8, 23; 8, 33; 8, 43; 8... | def add_backbone_atoms_linearly_from_loop_filepaths(self, loop_json_filepath, fasta_filepath, residue_ids):
'''A utility wrapper around add_backbone_atoms_linearly. Adds backbone atoms in a straight line from the first to
the last residue of residue_ids.
loop_json_filepath is a path to a J... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:add_atoms_linearly; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:start_atom; 6, identifier:end_atom; 7, identifier:new_atoms; 8, default_parameter; 8, 9; 8, 10; 9, identifier:jitterbug; 10, float:0.2; 11, bloc... | def add_atoms_linearly(self, start_atom, end_atom, new_atoms, jitterbug = 0.2):
'''A low-level function which adds new_atoms between start_atom and end_atom. This function does not validate the
input i.e. the calling functions are responsible for ensuring that the insertion makes sense.
Re... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:dispatch_request; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 18; 5, 27; 5, 37; 5, 62; 5, 71; 5, 96; 5, 207; 5, 216; 5, 225; 5, 234; 5, 243; 5, 254; 5, 271; 5, 349; 5, 373; 5, 380; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, ... | def dispatch_request(self):
if current_user.is_authenticated:
return redirect(self.next)
if 'social_data' in session:
del session['social_data']
res = self.app.authorized_response()
if res is None:
if self.flash: flash(self.auth_failed_msg, 'danger')
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:get_duration_measures; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:source_file_path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:output_path; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:phonemic... | def get_duration_measures(source_file_path,
output_path=None,
phonemic=False,
semantic=False,
quiet=False,
similarity_file = None,
threshold = None):
args = Arg... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:tokenize; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 20; 5, 53; 5, 57; 5, 61; 6, if_statement; 6, 7; 6, 11; 7, not_operator; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:quiet; 11, block; 11, 12; 1... | def tokenize(self):
if not self.quiet:
print
print "Finding compound words..."
compound_word_dict = {}
for compound_length in range(5,1,-1):
compound_word_dict[compound_length] = [name for name in self.names if len(name.split()) == compound_length]
cur... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:clean; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 24; 5, 34; 5, 38; 5, 133; 5, 137; 5, 141; 5, 198; 5, 263; 6, if_statement; 6, 7; 6, 11; 7, not_operator; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:quie... | def clean(self):
if not self.quiet:
print
print "Preprocessing input..."
print "Raw response:"
print self.display()
if not self.quiet:
print
print "Cleaning words..."
current_index = 0
while current_index < len(self.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.