code stringlengths 51 2.34k | sequence stringlengths 1.16k 13.1k | docstring stringlengths 11 171 |
|---|---|---|
def check_user(user, password):
return ((user == attowiki.user or attowiki.user is None) and
(password == attowiki.password or attowiki.password is None)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_user'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'u... | check the auth for user and password. |
def read(self, length=None):
if length is None:
return self.reader.read()
result = self.reader.read(length)
if len(result) != length:
raise BufferError(
'No more data left to read (need {}, got {}: {}); last read {}'
.format(length, len(res... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Read the given amount of bytes. |
def handle_onchain_secretreveal(
target_state: TargetTransferState,
state_change: ContractReceiveSecretReveal,
channel_state: NettingChannelState,
) -> TransitionResult[TargetTransferState]:
valid_secret = is_valid_secret_reveal(
state_change=state_change,
transfer_secrethash... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16', '22']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_onchain_secretreveal'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '12']}; {'id': '4', 'type': 'typed_para... | Validates and handles a ContractReceiveSecretReveal state change. |
def clean_expired_user_attempts(attempt_time: datetime = None) -> int:
if settings.AXES_COOLOFF_TIME is None:
log.debug('AXES: Skipping clean for expired access attempts because no AXES_COOLOFF_TIME is configured')
return 0
threshold = get_cool_off_threshold(attempt_time)
count, _ = AccessAt... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean_expired_user_attempts'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_default_paramete... | Clean expired user attempts from the database. |
def inten(function):
"Decorator. Attempts to convert return value to int"
def wrapper(*args, **kwargs):
return coerce_to_int(function(*args, **kwargs))
return wrapper | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'inten'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'function'};... | Decorator. Attempts to convert return value to int |
def run(self, url):
url = self.process_url(url)
if not url:
return
response = self.make_request(self.http, url)
selector = self.process_response(response)
entities = []
for root in self.get_roots(selector):
entity = self.entity(root)
en... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Request URL, scrape response and return an EntityList. |
def accept_all(self):
keys = self.list_keys()
for key in keys[self.PEND]:
try:
shutil.move(
os.path.join(
self.opts['pki_dir'],
self.PEND,
key),
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'accept_all'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Accept all keys in pre |
def dispatch_hook(cls, _pkt=None, *args, **kargs):
cls = conf.raw_layer
if _pkt is not None:
ptype = orb(_pkt[0])
return globals().get(_param_set_cls.get(ptype), conf.raw_layer)
return cls | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dispatch_hook'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '10']}; {'id': '4', 'type': 'identifier', 'children': ... | Returns the right parameter set class. |
def focus_prev_matching(self, querystring):
self.focus_property(lambda x: x._message.matches(querystring),
self._tree.prev_position) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'focus_prev_matching'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | focus previous matching message in depth first order |
def custom_prompt(msg, delims="", completer=lambda: None):
try:
orig_delims = readline.get_completer_delims()
orig_completer = readline.get_completer()
readline.set_completer_delims(delims)
readline.set_completer(completer)
try:
ret = input(msg)
finally:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'custom_prompt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Start up a prompt that with particular delims and completer |
def serialize(self, format):
if PY3:
return self.prov_g.serialize(format=format).decode('utf-8')
else:
return self.prov_g.serialize(format=format) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'serialize'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Serialize provenance graph in the specified format |
def forget(self, label_name):
self._bayes.pop(label_name)
baye_dir = self._get_baye_dir(label_name)
logger.info("Deleting label training {} : {}".format(
label_name, baye_dir
))
rm_rf(baye_dir) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'forget'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Forget training for label 'label_name' |
def __get_user_env_vars(self):
return (os.environ.get(self.GP_URL_ENV_VAR),
os.environ.get(self.GP_INSTANCE_ID_ENV_VAR),
os.environ.get(self.GP_USER_ID_ENV_VAR),
os.environ.get(self.GP_PASSWORD_ENV_VAR),
os.environ.get(self.GP_IAM_API_KEY_ENV_VAR)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__get_user_env_vars'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Return the user defined environment variables |
def generate_transpose(node_name, in_name, out_name, axes, base_name, func_counter):
trans = nnabla_pb2.Function()
trans.type = "Transpose"
set_function_name(trans, node_name, base_name, func_counter)
trans.input.extend([in_name])
trans.output.extend([out_name])
tp = trans.transpose_param
tp... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_transpose'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier'... | Generate a Transpose operator to transpose the specified buffer. |
def point(self, x, y, z=0, m=0):
pointShape = _Shape(self.shapeType)
pointShape.points.append([x, y, z, m])
self._shapes.append(pointShape) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'point'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [],... | Creates a point shape. |
def edit(env, securitygroup_id, rule_id, remote_ip, remote_group,
direction, ethertype, port_max, port_min, protocol):
mgr = SoftLayer.NetworkManager(env.client)
data = {}
if remote_ip:
data['remote_ip'] = remote_ip
if remote_group:
data['remote_group'] = remote_group
if dir... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'edit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12', '13']}; {'id': '4', 'type': 'i... | Edit a security group rule in a security group. |
def close(self, signalnum=None, frame=None):
self._running = False
self._log_debug("Closing all tail objects")
self._active = False
for fid in self._tails:
self._tails[fid].close()
for n in range(0,self._number_of_consumer_processes):
if self._proc[n] is n... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Closes all currently open Tail objects |
def story_node_add_arc_element_update_characters_locations(sender, instance, created, *args, **kwargs):
arc_node = ArcElementNode.objects.get(pk=instance.pk)
logger.debug('Scanning arc_node %s' % arc_node)
if arc_node.arc_element_type == 'root':
logger.debug("root node. skipping...")
else:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'story_node_add_arc_element_update_characters_locations'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '9']}; {... | If an arc element is added to a story element node, add any missing elements or locations. |
def reset_highlights(self):
for dtype in ["specimens", "samples", "sites", "locations", "ages"]:
wind = self.FindWindowByName(dtype + '_btn')
wind.Unbind(wx.EVT_PAINT, handler=self.highlight_button)
self.Refresh()
self.bSizer_msg.ShowItems(False)
self.hbox.Fit(sel... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reset_highlights'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Remove red outlines from all buttons |
def translateDNA_6Frames(sequence) :
trans = (
translateDNA(sequence, 'f1'),
translateDNA(sequence, 'f2'),
translateDNA(sequence, 'f3'),
translateDNA(sequence, 'r1'),
translateDNA(sequence, 'r2'),
translateDNA(sequence, 'r3'),
)
return trans | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'translateDNA_6Frames'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | returns 6 translation of sequence. One for each reading frame |
def _parse_triggered_hits(self, file_obj):
for _ in range(self.n_triggered_hits):
dom_id, pmt_id = unpack('<ib', file_obj.read(5))
tdc_time = unpack('>I', file_obj.read(4))[0]
tot = unpack('<b', file_obj.read(1))[0]
trigger_mask = unpack('<Q', file_obj.read(8))
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_triggered_hits'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Parse and store triggered hits. |
def create_migration(initial=False):
settings = DjangoSettings()
if 'south' not in (name.lower() for name in settings.INSTALLED_APPS):
print("Temporarily adding 'south' into INSTALLED_APPS.")
settings.INSTALLED_APPS.append('south')
kwargs = dict(initial=True) if initial else dict(auto=True)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_migration'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '... | Create a South migration for this project |
def size(self):
size = 0
try:
tip = self.get_changeset()
for topnode, dirs, files in tip.walk('/'):
for f in files:
size += tip.get_file_size(f.path)
for dir in dirs:
for f in files:
s... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'size'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Returns combined size in bytes for all repository files |
def _format_type(lines, element, spacer=""):
rlines = []
rlines.append(element.signature)
_format_summary(rlines, element)
rlines.append("")
_format_generic(rlines, element, ["summary"])
if len(element.executables) > 0:
rlines.append("\nEMBEDDED PROCEDURES")
for key, value in lis... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_format_type'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Formats a derived type for full documentation output. |
def clear(self):
for i, value in enumerate(self.buffer):
self.buffer[i] = 0 | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Clear contents of display buffer. |
def _shutdown(self):
if self._proc:
ret = _shutdown_proc(self._proc, 3)
logging.info("Shutdown with return code: %s", ret)
self._proc = None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_shutdown'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Terminate the sub-process. |
def _ExtractClientIdFromPath(entry, event):
match = re.match(r".*(C\.[0-9a-fA-F]{16}).*", entry.http_request_path)
if match:
event.client = match.group(1) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_ExtractClientIdFromPath'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [... | Extracts a Client ID from an APIAuditEntry's HTTP request path. |
def com_google_fonts_check_name_description_max_length(ttFont):
failed = False
for name in ttFont['name'].names:
if (name.nameID == NameID.DESCRIPTION and
len(name.string.decode(name.getEncoding())) > 200):
failed = True
break
if failed:
yield WARN, ("A few name table entries with ID={... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'com_google_fonts_check_name_description_max_length'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'ident... | Description strings in the name table must not exceed 200 characters. |
def case_insensitive_file_search(directory, pattern):
try:
return os.path.join(
directory,
[filename for filename in os.listdir(directory)
if re.search(pattern, filename, re.IGNORECASE)][0])
except IndexError:
print("{0} not found".format(pattern))
ra... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'case_insensitive_file_search'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children... | Looks for file with pattern with case insensitive search |
def str_deps(self):
lines = []
app = lines.append
app("Dependencies of node %s:" % str(self))
for i, dep in enumerate(self.deps):
app("%d) %s, status=%s" % (i, dep.info, str(dep.status)))
return "\n".join(lines) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'str_deps'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Return the string representation of the dependencies of the node. |
def os_requires_version(ostack_release, pkg):
def wrap(f):
@wraps(f)
def wrapped_f(*args):
if os_release(pkg) < ostack_release:
raise Exception("This hook is not supported on releases"
" before %s" % ostack_release)
f(*args)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'os_requires_version'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Decorator for hook to specify minimum supported release |
def remove_mixins(target):
mixedins_by_name = Mixin.get_mixedins_by_name(target).copy()
for _name in mixedins_by_name:
while True:
try:
Mixin.remove_mixin(target, _name)
except Mixin.MixInError:
break | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_mixins'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'tar... | Tries to get back target in a no mixin consistent state. |
def from_notebook_node(self, nb, resources=None, **kw):
from weasyprint import HTML, CSS
nb = copy.deepcopy(nb)
output, resources = super(OneCodexPDFExporter, self).from_notebook_node(
nb, resources=resources, **kw
)
buf = BytesIO()
HTML(string=output).write_p... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_notebook_node'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'childre... | Takes output of OneCodexHTMLExporter and runs Weasyprint to get a PDF. |
def _get_implicit_requirements(
self,
fields,
requirements
):
for name, field in six.iteritems(fields):
source = field.source
requires = getattr(field, 'requires', None) or [source]
for require in requires:
if not require:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_implicit_requirements'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'child... | Extract internal prefetch requirements from serializer fields. |
def compile_(self):
from Cython import Build
argv = copy.deepcopy(sys.argv)
sys.argv = [sys.argv[0], 'build_ext', '--build-lib='+self.buildpath]
exc_modules = [
distutils.extension.Extension(
'hydpy.cythons.autogen.'+self.cyname,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compile_'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Translate cython code to C code and compile it. |
def _create_stacking_set(estimators, estimators_features, estimators_weight, X, combination):
n_samples = X.shape[0]
valid_estimators = np.nonzero(estimators_weight)[0]
n_valid_estimators = valid_estimators.shape[0]
X_stacking = np.zeros((n_samples, n_valid_estimators))
for e in range(n_valid_estima... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_stacking_set'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'c... | Private function used to create the stacking training set. |
def _clone_args(self):
keys = list(self.keys)
kw = {}
if self.allow_any or self.extras:
kw['allow_extra'] = list(self.extras)
if self.allow_any:
kw['allow_extra'].append('*')
kw['allow_extra_trafaret'] = self.extras_trafaret
if self.ign... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_clone_args'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | return args to create new Dict clone |
def find_optconf(self, pconfs):
self.set_pconfs(pconfs)
optconf = self.manager.select_qadapter(pconfs)
return optconf | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_optconf'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Find the optimal Parallel configuration. |
def search(self, start_ts, end_ts):
query = '_ts: [%s TO %s]' % (start_ts, end_ts)
return self._stream_search(query) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Called to query Solr for documents in a time range. |
def complete_url(self, url):
if self.base_url:
return urlparse.urljoin(self.base_url, url)
else:
return url | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'complete_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Completes a given URL with this instance's URL base. |
def objify(self, doc, columns=None):
cols = columns or doc[METADATA][COLUMNS]
data = {}
for col in cols:
if col not in doc[METADATA][LENGTHS]:
d = [np.nan]
else:
d = decompress(doc[DATA][doc[METADATA][LENGTHS][col][0]: doc[METADATA][LENGTHS... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'objify'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Decode a Pymongo SON object into an Pandas DataFrame |
def UpdateKnowledgeBase(self, response, provides):
if isinstance(response, rdf_anomaly.Anomaly):
return
if isinstance(response, rdf_client.User):
self.knowledge_base.MergeOrAddUser(response)
return
if isinstance(response, rdf_protodict.Dict):
response_dict = response.ToDict()
f... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'UpdateKnowledgeBase'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [... | Set values in the knowledge base based on responses. |
def __RegisterDescriptor(self, new_descriptor):
if not isinstance(new_descriptor, (
extended_descriptor.ExtendedMessageDescriptor,
extended_descriptor.ExtendedEnumDescriptor)):
raise ValueError('Cannot add descriptor of type %s' % (
type(new_descriptor... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__RegisterDescriptor'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Register the given descriptor in this registry. |
def dropping(n):
if n < 0:
raise ValueError("Cannot drop fewer than zero ({}) items".format(n))
def dropping_transducer(reducer):
return Dropping(reducer, n)
return dropping_transducer | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dropping'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'n'}; {'i... | Create a transducer which drops the first n items |
def _uriPrefix(element):
i = element.tag.find('}')
if i < 0:
return ""
return element.tag[:i+1] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_uriPrefix'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'elemen... | Return xmlns prefix of the given element. |
def connect(self):
if self._sock:
return
try:
sock = self._connect()
except socket.error:
e = sys.exc_info()[1]
raise ConnectionError(self._error_message(e))
self._sock = sock
try:
self.on_connect()
except SSDBEr... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Connects to the SSDB server if not already connected |
def revert_metadata(files):
for file_path in files:
tags = EasyMP3(file_path)
tags.delete()
tags.save() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'revert_metadata'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'f... | Removes all tags from a mp3 file |
def exclude_chars(text, exclusion=None):
exclusion = [] if exclusion is None else exclusion
regexp = r"|".join([select_regexp_char(x) for x in exclusion]) or r''
return re.sub(regexp, '', text) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'exclude_chars'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Clean text string of simbols in exclusion list. |
def read(self):
if not self.fname:
return
try:
with open(self.fname, "r") as f:
wpid = int(f.read() or 0)
if wpid <= 0:
return
return wpid
except IOError:
return | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Validate pidfile and make it stale if needed |
def normcdf(x, log=False):
y = np.atleast_1d(x).copy()
flib.normcdf(y)
if log:
if (y>0).all():
return np.log(y)
return -np.inf
return y | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normcdf'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'};... | Normal cumulative density function. |
def init_quotas(sender, instance, created=False, **kwargs):
if not created:
return
for field in sender.get_quotas_fields():
try:
field.get_or_create_quota(scope=instance)
except CreationConditionFailedQuotaError:
pass | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init_quotas'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [],... | Initialize new instances quotas |
def airwires(board, showgui=0):
'search for airwires in eagle board'
board = Path(board).expand().abspath()
file_out = tempfile.NamedTemporaryFile(suffix='.txt', delete=0)
file_out.close()
ulp = ulp_templ.replace('FILE_NAME', file_out.name)
file_ulp = tempfile.NamedTemporaryFile(suffix='.ulp', d... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'airwires'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'boa... | search for airwires in eagle board |
async def _storeAppt(self, appt):
await self._hivedict.set(appt.iden, appt.pack()) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_storeAppt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Store a single appointment |
def export_account_state(self, account_state):
return {
'address': account_state['address'],
'type': account_state['type'],
'credit_value': '{}'.format(account_state['credit_value']),
'debit_value': '{}'.format(account_state['debit_value']),
'lock_tran... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'export_account_state'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Make an account state presentable to external consumers |
def path_yield(path):
for part in (x for x in path.strip(SEP).split(SEP) if x not in (None, '')):
yield part | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'path_yield'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}... | Yield on all path parts. |
def cmd_rc(self, args):
if len(args) != 2:
print("Usage: rc <channel|all> <pwmvalue>")
return
value = int(args[1])
if value > 65535 or value < -1:
raise ValueError("PWM value must be a positive integer between 0 and 65535")
if value == -1:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cmd_rc'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | handle RC value override |
def AnalizarRemito(self, ret, archivo=None):
"Extrae el resultado del remito, si existen en la respuesta XML"
if ret:
self.CodRemito = ret.get("codRemito")
self.TipoComprobante = ret.get("tipoComprobante")
self.PuntoEmision = ret.get("puntoEmision")
datos_... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'AnalizarRemito'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Extrae el resultado del remito, si existen en la respuesta XML |
def _generate_class_comment(self, data_type):
if is_struct_type(data_type):
class_type = 'struct'
elif is_union_type(data_type):
class_type = 'union'
else:
raise TypeError('Can\'t handle type %r' % type(data_type))
self.emit(comment_prefix)
sel... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_generate_class_comment'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | Emits a generic class comment for a union or struct. |
def extract(domain):
translations_dir = _get_translations_dir()
domain = _get_translations_domain(domain)
babel_cfg = _get_babel_cfg()
pot = os.path.join(translations_dir, f'{domain}.pot')
return _run(f'extract -F {babel_cfg} -o {pot} .') | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'domain'};... | Extract newly added translations keys from source code. |
def comments_nb_counts():
recid = request.view_args.get('recid')
if recid is None:
return
elif recid == 0:
return 0
else:
return CmtRECORDCOMMENT.count(*[
CmtRECORDCOMMENT.id_bibrec == recid,
CmtRECORDCOMMENT.star_score == 0,
CmtRECORDCOMMENT.s... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'comments_nb_counts'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '16']}; {'id':... | Get number of comments for the record `recid`. |
def _compass_position(self, player_x, player_y):
map_dim = self._map.size_x
third = map_dim * (1/3.0)
for direction in mgz.const.COMPASS:
point = mgz.const.COMPASS[direction]
xlower = point[0] * map_dim
xupper = (point[0] * map_dim) + third
ylower ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_compass_position'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | Get compass position of player. |
def track_to_ref(track, with_track_no=False):
if with_track_no and track.track_no > 0:
name = '%d - ' % track.track_no
else:
name = ''
for artist in track.artists:
if len(name) > 0:
name += ', '
name += artist.name
if (len(name)) > 0:
name += ' - '
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'track_to_ref'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Convert a mopidy track to a mopidy ref. |
def start_aeidon():
extensions = ['ass', 'srt', 'ssa', 'sub']
Config.filenames = prep_files(Config.args, extensions)
Config.patterns = pattern_logic_aeidon()
for filename in Config.filenames:
AeidonProject(filename) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start_aeidon'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '13', '25', '33']}; ... | Prepare filenames and patterns then process subtitles with aeidon. |
def cli():
objcli = WrHierCli(sys.argv[1:])
fouts_txt = objcli.get_fouts()
if fouts_txt:
for fout_txt in fouts_txt:
objcli.wrtxt_hier(fout_txt)
else:
objcli.prt_hier(sys.stdout) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '18', '26']}; {'id': '5', 'ty... | Command-line script to print a GO term's lower-level hierarchy. |
def _get_error_message(self, response):
error_message = 'An error occurred processing your request.'
try:
content = response.json()
error_message = content['errors'][0]['message']
except TypeError:
error_message = content['errors']
except ValueError:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_error_message'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Parse and return the first error message |
def _store(self, con):
self._con = con
self._transaction = False
self._closed = False
self._usage = 0 | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_store'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Store a database connection for subsequent use. |
def _set_camera_properties(self, msg):
focal_x = msg.K[0]
focal_y = msg.K[4]
center_x = msg.K[2]
center_y = msg.K[5]
im_height = msg.height
im_width = msg.width
self._camera_intr = CameraIntrinsics(self._frame, focal_x, focal_y,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_camera_properties'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],... | Set the camera intrinsics from an info msg. |
def removeItem(self, item):
try:
self.tree.removeItem(item)
except AttributeError, e:
raise VersionError('Saved versions are immutable') | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'removeItem'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Removes an item if the tree is mutable |
def assert_wildtype_matches(self, mutation):
readwt = self.getAminoAcid(self.getAtomLine(mutation.Chain, mutation.ResidueID))
assert(mutation.WildTypeAA == residue_type_3to1_map[readwt]) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'assert_wildtype_matches'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | Check that the wildtype of the Mutation object matches the PDB sequence. |
def cd(self, remote):
try:
self.conn.cwd(remote)
except Exception:
return False
else:
return self.pwd() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Change working directory on server |
def handle_pubrec(self):
self.logger.info("PUBREC received")
ret, mid = self.in_packet.read_uint16()
if ret != NC.ERR_SUCCESS:
return ret
evt = event.EventPubrec(mid)
self.push_event(evt)
return NC.ERR_SUCCESS | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_pubrec'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Handle incoming PUBREC packet. |
def compile_kernel(self, instance, verbose):
logging.debug('compile_kernel ' + instance.name)
func = None
try:
func = self.dev.compile(instance.name, instance.kernel_string)
except Exception as e:
if "uses too much shared data" in str(e):
logging.d... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compile_kernel'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | compile the kernel for this specific instance |
def aggregate(self):
from nefertari.elasticsearch import ES
aggregations_params = self.pop_aggregations_params()
if self.view._auth_enabled:
self.check_aggregations_privacy(aggregations_params)
self.stub_wrappers()
return ES(self.view.Model.__name__).aggregate(
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'aggregate'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Perform aggregation and return response. |
def resetTimeout(self):
if self.__timeoutCall is not None and self.timeOut is not None:
self.__timeoutCall.reset(self.timeOut) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resetTimeout'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Reset the timeout count down |
def action_cancel(self):
self.write({'state': 'cancelled'})
for rec in self:
rec.message_post(
subtype='mt_comment',
body=_(
'Change request <b>%s</b> has been cancelled by %s.'
) % (rec.display_name, self.env.user.name)... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'action_cancel'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Set a change request as cancelled. |
def do_printPolicy(self,args):
parser = CommandArgumentParser("printPolicy")
args = vars(parser.parse_args(args))
policy = self.client.describe_policies(AutoScalingGroupName=self.scalingGroup)
pprint(policy) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_printPolicy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Print the autoscaling policy |
def _set_operable_view(self, session):
for obj_name in self._operable_views:
if self._operable_views[obj_name] == ACTIVE:
try:
getattr(session, 'use_active_' + obj_name + '_view')()
except AttributeError:
pass
else:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_operable_view'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Sets the underlying operable views to match current view |
def show_list(self, the_list, cur_p=''):
current_page_num = int(cur_p) if cur_p else 1
current_page_num = 1 if current_page_num < 1 else current_page_num
num_of_cat = MCollect.count_of_user(self.userinfo.uid)
page_num = int(num_of_cat / CMS_CFG['list_num']) + 1
kwd = {'current_pa... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | List of the user collections. |
def visit_FunctionDef(self, node):
node = self.get_function_node(node)
if node is not None:
node._async = False | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'visit_FunctionDef'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Visit a function node. |
def add_parser_from_field(self, name, field_cls):
self.__parser_map__[name] = _field2method(field_cls, method_name=name) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_parser_from_field'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children':... | Register a new parser method with name ``name``, given a marshmallow ``Field``. |
def print_controllers():
_check_import()
pp = pprint.PrettyPrinter(indent=2)
for discovery in find_all_controllers():
pp.pprint(discovery.controller) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_controllers'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9', '20']}; {'... | Pretty-print all controllers found |
def get(self, name, defval=None):
for frame in reversed(self.frames):
valu = frame.get(name, s_common.novalu)
if valu != s_common.novalu:
return valu
task = self.ctors.get(name)
if task is not None:
func, args, kwargs = task
item = ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Retrieve a value from the closest scope frame. |
def avroize_type(field_type, name_prefix=""):
if isinstance(field_type, MutableSequence):
for field in field_type:
avroize_type(field, name_prefix)
elif isinstance(field_type, MutableMapping):
if field_type["type"] in ("enum", "record"):
if "name" not in field_type:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'avroize_type'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | adds missing information to a type so that CWL types are valid in schema_salad. |
def sortedSemver(versions, sort="asc"):
if versions and isinstance(versions, (list, tuple)):
if PY2:
return sorted(versions, cmp=semver.compare, reverse=True if sort.upper() == "DESC" else False)
else:
from functools import cmp_to_key
return sorted(versions, key=c... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sortedSemver'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Semantically sort the list of version Numbers |
def _plot(self):
for serie in self.series[::-1 if self.stack_from_top else 1]:
self.line(serie)
for serie in self.secondary_series[::-1 if self.stack_from_top else 1]:
self.line(serie, True) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_plot'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Plot stacked serie lines and stacked secondary lines |
def text(self):
if self.driver.w3c:
return self.driver.execute(Command.W3C_GET_ALERT_TEXT)["value"]
else:
return self.driver.execute(Command.GET_ALERT_TEXT)["value"] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'text'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Gets the text of the Alert. |
def register_routes(self):
routes = self.flatten_urls(self.urls)
self.controllers = {}
controller_names = set()
for route in routes:
cname = route['endpoint'].split('.')[0]
controller_names.add(cname)
for cname in controller_names:
attr = getat... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register_routes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Function creates instances of controllers, adds into bottle routes |
def zoomset_cb(self, setting, value, channel):
if not self.gui_up:
return
info = channel.extdata._info_info
if info is None:
return
scale_x, scale_y = value
if scale_x == scale_y:
text = self.fv.scale2text(scale_x)
else:
tex... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zoomset_cb'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], '... | This callback is called when the main window is zoomed. |
def start_of_day(self) -> datetime:
self.value = datetime(self.value.year, self.value.month, self.value.day)
return self.value | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start_of_day'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Returns start of day |
def _find_special(self):
charnames = self._get_char_names()
for eventdir in glob.glob('/sys/class/input/event*'):
char_name = os.path.split(eventdir)[1]
if char_name in charnames:
continue
name_file = os.path.join(eventdir, 'device', 'name')
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_special'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Look for special devices. |
def _set_config(c):
func = sdl2.SDL_GL_SetAttribute
func(sdl2.SDL_GL_RED_SIZE, c['red_size'])
func(sdl2.SDL_GL_GREEN_SIZE, c['green_size'])
func(sdl2.SDL_GL_BLUE_SIZE, c['blue_size'])
func(sdl2.SDL_GL_ALPHA_SIZE, c['alpha_size'])
func(sdl2.SDL_GL_DEPTH_SIZE, c['depth_size'])
func(sdl2.SDL_GL... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_config'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c'}; ... | Set gl configuration for SDL2 |
def IsRunning(self):
current_urn = self.Get(self.Schema.CURRENT_FLOW_URN)
if not current_urn:
return False
try:
current_flow = aff4.FACTORY.Open(
urn=current_urn, aff4_type=flow.GRRFlow, token=self.token, mode="r")
except aff4.InstantiationError:
logging.error("Unable to open... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'IsRunning'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Returns True if there's a currently running iteration of this job. |
def to_dict(self):
return dict(
raw=self.raw,
scheme=self.scheme,
authority=self.authority,
netloc=self.authority,
path=self.path,
query=self.query,
fragment=self.fragment,
userinfo=self.userinfo,
usernam... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Return a dict of the attributes. |
def build(self, **values: Any) -> str:
converted_values = {
key: self._converters[key].to_url(value)
for key, value in values.items()
if key in self._converters
}
result = self._builder.format(**converted_values).split('|', 1)[1]
query_string = urlenco... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Build this rule into a path using the values given. |
def start(self):
self.thread_handler.run(target=self.start_blocking)
self.thread_handler.start_run_loop() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Start the MQTT client. |
def slew(self, value):
if float(value) != self.filepos:
pos = float(value) * self.filesize
self.mlog.f.seek(int(pos))
self.find_message() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'slew'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | move to a given position in the file |
def jsonify_log_record(self, log_record):
return self.json_serializer(log_record,
default=self.json_default,
cls=self.json_encoder,
indent=self.json_indent,
ensure_asci... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'jsonify_log_record'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Returns a json string of the log record. |
def handle_data(self, context, data, dt):
if self.rule.should_trigger(dt):
self.callback(context, data) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Calls the callable only when the rule is triggered. |
def bytes_to_str(s, encoding='utf-8'):
if six.PY3 and isinstance(s, bytes):
return s.decode(encoding)
return s | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bytes_to_str'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Returns a str if a bytes object is given. |
def add_command(self, command, function, description=None):
super(Program, self).add_command(command, function, description)
self.service.register(command, function) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_command'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [],... | Register a new function for command |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.