sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:put_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:self; 5, identifier:file; 6, identifier:object_type; 7, identifier:object_id; 8, identifier:width; 9, identifier:height; 10, identifier:mimetype; 11, iden... | def put_file(self, file, object_type, object_id, width, height, mimetype,
reproducible):
raise NotImplementedError('put_file() has to be implemented') |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_original_images; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 44; 7, 178; 8, function_definition; 8, 9; 8, 10; 8, 12; 9, function_name:test; 10, parameters; 10, 11; ... | def _original_images(self, **kwargs):
def test(image):
if not image.original:
return False
for filter, value in kwargs.items():
if getattr(image, filter) != value:
return False
return True
if Session.object_session(s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:from_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:file; 6, default_parameter; 6, 7; 6, 8; 7, identifier:store; 8, identifier:current_store; 9, default_parameter; 9, 10; 9, 11; 10, identifier:extra_args;... | def from_file(self, file, store=current_store,
extra_args=None, extra_kwargs=None):
if isinstance(file, cgi.FieldStorage):
file = file.file
data = io.BytesIO()
shutil.copyfileobj(file, data)
data.seek(0)
return self.from_raw_file(data, store, origina... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:copy_modules; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:filespath; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:modules_path; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:ve... | def copy_modules(filespath=None, modules_path=None, verbose=None):
''' Copy over the tree module files into your path '''
if not modules_path:
modulepath = os.getenv("MODULEPATH")
if not modulepath:
modules_path = input('Enter the root path for your module files:')
else:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:_repr_html_; 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:indices; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:iops; 10, None; 11, default_parameter; 11... | def _repr_html_(self, indices=None, iops=None, lx=None, li=None, lls=None):
filter_ = self._current_slice_
vals = self.flat
if indices is None: indices = self._indices(filter_)
if iops is None:
ravi = self._raveled_index(filter_)
iops = OrderedDict([name, iop.prop... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:optimize_restarts; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:num_restarts; 7, integer:10; 8, default_parameter; 8, 9; 8, 10; 9, identifier:robust; 10, False... | def optimize_restarts(self, num_restarts=10, robust=False, verbose=True, parallel=False, num_processes=None, **kwargs):
initial_length = len(self.optimization_runs)
initial_parameters = self.optimizer_array.copy()
if parallel:
try:
pool = mp.Pool(processes=num_process... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:optimizer_array; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 42; 5, 102; 5, 123; 6, if_statement; 6, 7; 6, 28; 7, boolean_operator:or; 7, 8; 7, 19; 8, comparison_operator:is; 8, 9; 8, 18; 9, call; 9, 10; 9, 15; 10, attribute; 10... | def optimizer_array(self):
if self.__dict__.get('_optimizer_copy_', None) is None or self.size != self._optimizer_copy_.size:
self._optimizer_copy_ = np.empty(self.size)
if not self._optimizer_copy_transformed:
self._optimizer_copy_.flat = self.param_array.flat
[np.pu... |
0, module; 0, 1; 1, ERROR; 1, 2; 1, 281; 2, function_definition; 2, 3; 2, 4; 2, 6; 3, function_name:_parse_content; 4, parameters; 4, 5; 5, identifier:fh; 6, block; 6, 7; 6, 14; 6, 18; 6, 104; 6, 159; 6, 170; 6, 181; 6, 191; 6, 249; 6, 256; 6, 262; 6, 268; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, i... | def _parse_content(fh):
content = iter(fh)
deps = {}
for line in content:
if 'fades' not in line:
continue
if '
continue
line = line.strip()
index_of_last_fades = line.rfind('fades')
index_of_first_hash = line.index('
if index_of_first_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_parse_docstring; 3, parameters; 3, 4; 4, identifier:fh; 5, block; 5, 6; 5, 17; 5, 51; 5, 70; 5, 136; 5, 143; 5, 158; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:find_fades; 9, attribute; 9, 10; 9, 16; 10, call; 10, ... | def _parse_docstring(fh):
find_fades = re.compile(r'\b(fades)\b:').search
for line in fh:
if line.startswith("'"):
quote = "'"
break
if line.startswith('"'):
quote = '"'
break
else:
return {}
if line[1] == quote:
endquote = ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_venv_match; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:installed; 6, identifier:requirements; 7, block; 7, 8; 7, 17; 7, 21; 7, 133; 8, if_statement; 8, 9; 8, 11; 9, not_operator; 9, 10; 10, identifier:requirements; 11, ... | def _venv_match(self, installed, requirements):
if not requirements:
return None if installed else []
satisfying_deps = []
for repo, req_deps in requirements.items():
useful_inst = set()
if repo not in installed:
return None
if repo... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:encrypt; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:content; 5, default_parameter; 5, 6; 5, 7; 6, identifier:salt; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:key; 10, None; 11... | def encrypt(content, salt=None, key=None,
private_key=None, dh=None, auth_secret=None,
keyid=None, keylabel="P-256",
rs=4096, version="aes128gcm"):
def encrypt_record(key, nonce, counter, buf, last):
encryptor = Cipher(
algorithms.AES(key),
modes.G... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_format_ase2clusgeo; 3, parameters; 3, 4; 3, 5; 4, identifier:obj; 5, default_parameter; 5, 6; 5, 7; 6, identifier:all_atomtypes; 7, None; 8, block; 8, 9; 8, 16; 8, 41; 8, 53; 8, 57; 8, 61; 8, 107; 8, 111; 8, 118; 8, 120; 8, 133; 9, expression_... | def _format_ase2clusgeo(obj, all_atomtypes=None):
totalAN = len(obj)
if all_atomtypes is not None:
atomtype_set = set(all_atomtypes)
else:
atomtype_set = set(obj.get_atomic_numbers())
atomtype_lst = np.sort(list(atomtype_set))
n_atoms_per_type_lst = []
pos_lst = []
for atomty... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:zmax; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 13; 3, 16; 3, 19; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:return_times; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:func; 10, attribute; 10, 11; 10, 12; 11, i... | def zmax(self, return_times=False, func=np.mean,
interp_kwargs=None, minimize_kwargs=None,
approximate=False):
if return_times and func is not None:
raise ValueError("Cannot return times if reducing "
"using an input function. Pass `func=None` i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:align_circulation_with_z; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:circulation; 7, None; 8, block; 8, 9; 8, 22; 8, 32; 8, 38; 8, 44; 8, 80; 8, 105; 8, 137; 8, 145; 8, 153; 8, 294; 9, if_stat... | def align_circulation_with_z(self, circulation=None):
if circulation is None:
circulation = self.circulation()
circulation = atleast_2d(circulation, insert_axis=1)
cart = self.cartesian
pos = cart.xyz
vel = np.vstack((cart.v_x.value[None],
car... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:fast_lyapunov_max; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:w0; 5, identifier:hamiltonian; 6, identifier:dt; 7, identifier:n_steps; 8, default_parameter; 8, 9; 8, 10; 9, identi... | def fast_lyapunov_max(w0, hamiltonian, dt, n_steps, d0=1e-5,
n_steps_per_pullback=10, noffset_orbits=2, t1=0.,
atol=1E-10, rtol=1E-10, nmax=0, return_orbit=True):
from .lyapunov import dop853_lyapunov_max, dop853_lyapunov_max_dont_save
if isinstance(hamiltonian, Poten... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:estimate_dt_n_steps; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 16; 4, identifier:w0; 5, identifier:hamiltonian; 6, identifier:n_periods; 7, identifier:n_steps_per_period; 8, default_parameter; 8, 9; 8, 10; 9, identifier:dE_thresho... | def estimate_dt_n_steps(w0, hamiltonian, n_periods, n_steps_per_period,
dE_threshold=1E-9, func=np.nanmax,
**integrate_kwargs):
if not isinstance(w0, PhaseSpacePosition):
w0 = np.asarray(w0)
w0 = PhaseSpacePosition.from_w(w0, units=hamiltonian.units)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:plot_projections; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 19; 3, 22; 3, 25; 4, identifier:x; 5, default_parameter; 5, 6; 5, 7; 6, identifier:relative_to; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:autolim; 10, True; 11... | def plot_projections(x, relative_to=None, autolim=True, axes=None,
subplots_kwargs=dict(), labels=None, plot_function=None,
**kwargs):
x = np.array(x, copy=True)
ndim = x.shape[0]
if axes is None:
axes = _get_axes(dim=ndim, subplots_kwargs=subplots_kwargs)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:compute_coeffs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 4, identifier:density_func; 5, identifier:nmax; 6, identifier:lmax; 7, identifier:M; 8, identifier:r_s; 9, default_parameter; 9, 10; 9... | def compute_coeffs(density_func, nmax, lmax, M, r_s, args=(),
skip_odd=False, skip_even=False, skip_m=False,
S_only=False, progress=False, **nquad_opts):
from gala._cconfig import GSL_ENABLED
if not GSL_ENABLED:
raise ValueError("Gala was compiled without GSL and so... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:compute_coeffs_discrete; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:xyz; 5, identifier:mass; 6, identifier:nmax; 7, identifier:lmax; 8, identifier:r_s; 9, default_parameter; 9, 10; 9, 11; 10, identifi... | def compute_coeffs_discrete(xyz, mass, nmax, lmax, r_s,
skip_odd=False, skip_even=False, skip_m=False,
compute_var=False):
lmin = 0
lstride = 1
if skip_odd or skip_even:
lstride = 2
if skip_even:
lmin = 1
Snlm = np.zeros((nmax+1... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:to_coord_frame; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:frame; 6, default_parameter; 6, 7; 6, 8; 7, identifier:galactocentric_frame; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block... | def to_coord_frame(self, frame, galactocentric_frame=None, **kwargs):
if self.ndim != 3:
raise ValueError("Can only change representation for "
"ndim=3 instances.")
if galactocentric_frame is None:
galactocentric_frame = coord.Galactocentric()
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_plot_prepare; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:components; 6, identifier:units; 7, block; 7, 8; 7, 21; 7, 28; 7, 64; 7, 68; 7, 72; 7, 229; 8, if_statement; 8, 9; 8, 12; 9, comparison_operator:is; 9, 10; 9, 11;... | def _plot_prepare(self, components, units):
if components is None:
components = self.pos.components
n_comps = len(components)
if units is not None:
if isinstance(units, u.UnitBase):
units = [units]*n_comps
elif len(units) != n_comps:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:recommend; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:client_data; 6, identifier:limit; 7, default_parameter; 7, 8; 7, 9; 8, identifier:extra_data; 9, dictionary; 10, block; 10, 11; 10, 21; 10, 30; 10, 43; 10, 56;... | def recommend(self, client_data, limit, extra_data={}):
preinstalled_addon_ids = client_data.get("installed_addons", [])
extended_limit = limit + len(preinstalled_addon_ids)
ensemble_suggestions = self._ensemble_recommender.recommend(
client_data, extended_limit, extra_data
)... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_recommend; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:client_data; 6, identifier:limit; 7, default_parameter; 7, 8; 7, 9; 8, identifier:extra_data; 9, dictionary; 10, block; 10, 11; 10, 20; 10, 30; 10, 39; 10, 43... | def _recommend(self, client_data, limit, extra_data={}):
self.logger.info("Ensemble recommend invoked")
preinstalled_addon_ids = client_data.get("installed_addons", [])
extended_limit = limit + len(preinstalled_addon_ids)
flattened_results = []
ensemble_weights = self._weight_cac... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_build_features_caches; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 18; 5, 30; 5, 41; 5, 50; 5, 68; 5, 98; 5, 119; 5, 158; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:_donors_pool; 9, subscript; 9, 10... | def _build_features_caches(self):
_donors_pool = self._donors_pool.get()[0]
_lr_curves = self._lr_curves.get()[0]
if _donors_pool is None or _lr_curves is None:
return None
self.num_donors = len(_donors_pool)
self.continuous_features = np.zeros((self.num_donors, len(C... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:pdos_select; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:atoms; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:spin; 10, None; 11, default_parameter; 11, 12; 11,... | def pdos_select( self, atoms=None, spin=None, l=None, m=None ):
valid_m_values = { 's': [],
'p': [ 'x', 'y', 'z' ],
'd': [ 'xy', 'yz', 'z2-r2', 'xz', 'x2-y2' ],
'f': [ 'y(3x2-y2)', 'xyz', 'yz2', 'z3', 'xz2', 'z(x2-y2)', 'x(x2-3y2)'... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_describe; 3, parameters; 3, 4; 3, 5; 4, identifier:node; 5, identifier:parent; 6, block; 6, 7; 6, 14; 6, 24; 6, 210; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 13; 9, pattern_list; 9, 10; 9, 11; 9, 12; 10, identifier:name; 11, iden... | def _describe(node, parent):
name, logger, children = node
is_placeholder = isinstance(logger, logging.PlaceHolder)
if is_placeholder:
yield '<--[%s]' % name
else:
parent_is_correct = (parent is None) or (logger.parent is parent)
if not logger.propagate:
arrow = ' '... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:resample; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 21; 5, 27; 5, 33; 5, 60; 5, 81; 5, 93; 5, 101; 5, 109; 5, 134; 5, 162; 5, 184; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:just_... | def resample(self):
if self.just_resampled:
warnings.warn(
"Resampling without additional data; this may not perform as "
"desired.",
ResamplerWarning
)
self._just_resampled = True
self._resample_count += 1
if self._... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:expected_information_gain; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:expparams; 6, block; 6, 7; 6, 9; 6, 15; 6, 61; 6, 81; 6, 105; 6, 129; 6, 165; 6, 179; 6, 201; 6, 224; 7, expression_statement; 7, 8; 8, identifier:r; 9, exp... | def expected_information_gain(self, expparams):
r
n_eps = expparams.size
if n_eps > 1 and not self.model.is_n_outcomes_constant:
risk = np.empty(n_eps)
for idx in range(n_eps):
risk[idx] = self.expected_information_gain(expparams[idx, np.newaxis])
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:iter_actions; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 27; 5, 36; 5, 40; 5, 54; 5, 200; 5, 214; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ns; 9, string:'{urn:schemas-upnp-org:service-1-0}'... | def iter_actions(self):
ns = '{urn:schemas-upnp-org:service-1-0}'
scpd_body = requests.get(self.base_url + self.scpd_url).content
tree = XML.fromstring(scpd_body)
vartypes = {}
srvStateTables = tree.findall('{}serviceStateTable'.format(ns))
for srvStateTable in srvStateTa... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_event_xml; 3, parameters; 3, 4; 4, identifier:xml_event; 5, block; 5, 6; 5, 10; 5, 19; 5, 28; 5, 280; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result; 9, dictionary; 10, expression_statement; 10, 11; 11, ass... | def parse_event_xml(xml_event):
result = {}
tree = XML.fromstring(xml_event)
properties = tree.findall(
'{urn:schemas-upnp-org:event-1-0}property')
for prop in properties:
for variable in prop:
if variable.tag == "LastChange":
last_change_tree = XML.fromstring... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_restore_coordinator; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 36; 5, 42; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:transport_info; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11... | def _restore_coordinator(self):
transport_info = self.device.get_current_transport_info()
if transport_info is not None:
if transport_info['current_transport_state'] == 'PLAYING':
self.device.pause()
self._restore_queue()
if self.is_playing_queue and self.play... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_loading_order; 3, parameters; 3, 4; 4, identifier:step_files; 5, block; 5, 6; 5, 10; 5, 14; 5, 18; 5, 121; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:tools; 9, list:[]; 10, expression_statement; 10, 11; 11, ass... | def sort_loading_order(step_files):
tools = []
workflows = []
workflows_with_subworkflows = []
for f in step_files:
if f.startswith('http://') or f.startswith('https://'):
tools.append(f)
else:
obj = load_yaml(f)
if obj.get('class', '') == 'Workflow':
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:add_input; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 14; 7, 53; 7, 57; 7, 63; 7, 79; 7, 95; 7, 109; 7, 118; 7, 205; 7, 211; 7, 228; 7, 241; 7, 265; 8, expression_s... | def add_input(self, **kwargs):
self._closed()
def _get_item(args):
if not args:
raise ValueError("No parameter specified.")
item = args.popitem()
if args:
raise ValueError("Too many parameters, not clear what to do "
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:to_obj; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:wd; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:pack; 10, False; 11, default_parameter; 11, 12; 11, 13; 12, iden... | def to_obj(self, wd=False, pack=False, relpath=None):
self._closed()
obj = CommentedMap()
obj['cwlVersion'] = 'v1.0'
obj['class'] = 'Workflow'
try:
obj['doc'] = self.documentation
except (AttributeError, ValueError):
pass
try:
o... |
0, module; 0, 1; 1, ERROR; 1, 2; 1, 21; 1, 22; 1, 26; 1, 30; 1, 62; 1, 86; 1, 90; 1, 174; 1, 178; 1, 208; 1, 226; 2, function_definition; 2, 3; 2, 4; 2, 9; 3, function_name:to_script; 4, parameters; 4, 5; 4, 6; 5, identifier:self; 6, default_parameter; 6, 7; 6, 8; 7, identifier:wf_name; 8, string:'wf'; 9, block; 9, 10;... | def to_script(self, wf_name='wf'):
self._closed()
script = []
# print('doc =
')
params = []
returns = []
for name, typ in self.wf_inputs.items():
params.append('{}=\'{}\''.format(name, typ))
returns.append(name)
script.append('{} = {... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:save; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 4, identifier:self; 5, identifier:fname; 6, default_parameter; 6, 7; 6, 8; 7, identifier:mode; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:validate... | def save(self, fname, mode=None, validate=True, encoding='utf-8',
wd=False, inline=False, relative=False, pack=False):
self._closed()
if mode is None:
mode = 'abs'
if pack:
mode = 'pack'
elif wd:
mode = 'wd'
eli... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_snodas_ds; 3, parameters; 3, 4; 3, 5; 4, identifier:dem_dt; 5, default_parameter; 5, 6; 5, 7; 6, identifier:code; 7, integer:1036; 8, block; 8, 9; 8, 12; 8, 15; 8, 19; 8, 23; 8, 35; 8, 53; 8, 105; 8, 339; 9, import_statement; 9, 10; 10, dot... | def get_snodas_ds(dem_dt, code=1036):
import tarfile
import gzip
snodas_ds = None
snodas_url_str = None
outdir = os.path.join(datadir, 'snodas')
if not os.path.exists(outdir):
os.makedirs(outdir)
if dem_dt >= datetime(2003,9,30) and dem_dt < datetime(2010,1,1):
snodas_url_str... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:get_modscag_fn_list; 3, parameters; 3, 4; 3, 5; 3, 13; 4, identifier:dem_dt; 5, default_parameter; 5, 6; 5, 7; 6, identifier:tile_list; 7, tuple; 7, 8; 7, 9; 7, 10; 7, 11; 7, 12; 8, string:'h08v04'; 9, string:'h09v04'; 10, string:'h10v04'; 11,... | def get_modscag_fn_list(dem_dt, tile_list=('h08v04', 'h09v04', 'h10v04', 'h08v05', 'h09v05'), pad_days=7):
import re
import requests
from bs4 import BeautifulSoup
auth = iolib.get_auth()
pad_days = timedelta(days=pad_days)
dt_list = timelib.dt_range(dem_dt-pad_days, dem_dt+pad_days+timedelta(1),... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_decode_record; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:s; 6, default_parameter; 6, 7; 6, 8; 7, identifier:line; 8, integer:0; 9, block; 9, 10; 9, 12; 9, 21; 9, 26; 9, 93; 9, 99; 9, 114; 9, 126; 9, 132; 9, 147; 9, 154... | def _decode_record(self, s, line=0):
'''Decode one record of HEX file.
@param s line with HEX record.
@param line line number (for error messages).
@raise EndOfFile if EOF record encountered.
'''
s = s.rstrip('\r\n')
if not s:
return
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:_get_start_end; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:start; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:end; 10, None; 11, default_parameter; 11, 12; 11, 13; ... | def _get_start_end(self, start=None, end=None, size=None):
if (start,end) == (None,None) and self._buf == {}:
raise EmptyIntelHexError
if size is not None:
if None not in (start, end):
raise ValueError("tobinarray: you can't use start,end and size"
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:dump; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:tofile; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:width; 10, integer:16; 11, default_parameter; 11, 12; 11, 13; 1... | def dump(self, tofile=None, width=16, withpadding=False):
if not isinstance(width,int) or width < 1:
raise ValueError('width must be a positive integer.')
width = int(width)
if tofile is None:
tofile = sys.stdout
if self.start_addr is not None:
cs = se... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:add_recipe_folder; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:recipe_folder; 6, default_parameter; 6, 7; 6, 8; 7, identifier:whitelist; 8, None; 9, block; 9, 10; 9, 22; 9, 31; 9, 94; 10, if_statement; 10, 11; 10, 14; 11,... | def add_recipe_folder(self, recipe_folder, whitelist=None):
if whitelist is not None:
whitelist = set(whitelist)
if recipe_folder == '':
recipe_folder = '.'
for yaml_file in [x for x in os.listdir(recipe_folder) if x.endswith('.yaml')]:
if whitelist is not Non... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:run; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:include_reset; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:accelerated; 10, True; 11, block; 11, 12; 11, 20; 11, 31; 11, 35... | def run(self, include_reset=True, accelerated=True):
self._start_tick = self.tick_count
if self._check_stop_conditions(self.sensor_graph):
return
if include_reset:
pass
i = None
for i, stim in enumerate(self.stimuli):
if stim.time != 0:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_convert_default_value; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:default; 6, block; 6, 7; 6, 14; 6, 45; 6, 73; 6, 85; 6, 99; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:is; 8, 9; 8, 10; 9, identifier:default; 10, No... | def _convert_default_value(self, default):
if default is None:
return None
if isinstance(default, str):
if self.special_type == 'string':
return default.encode('utf-8') + b'\0'
raise DataError("You can only pass a unicode string if you are declaring a ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:latch; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 26; 5, 39; 5, 53; 5, 102; 5, 123; 5, 135; 5, 169; 6, if_statement; 6, 7; 6, 15; 7, comparison_operator:==; 7, 8; 7, 14; 8, call; 8, 9; 8, 10; 9, identifier:len; 10, argument_lis... | def latch(self):
if len(self.current_value) == 0:
raise DataError("There was no data in a config variable during latching", name=self.name)
remaining = len(self.current_value) % self.unit_size
if remaining > 0:
self.current_value += bytearray(remaining)
if self.sp... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_contents_dir; 3, parameters; 3, 4; 4, identifier:node; 5, block; 5, 6; 5, 10; 5, 46; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:contents; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 28; 11, identifier:n; ... | def get_contents_dir(node):
contents = []
for n in sorted(node.children(), key=lambda t: t.name):
contents.append('%s %s\n' % (n.get_csig(), n.name))
return ''.join(contents) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prepare; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 43; 5, 80; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:depends; 11, None; 12, block; 12... | def prepare(self):
if self.depends is not None:
for d in self.depends:
if d.missing():
msg = "Explicit dependency `%s' not found, needed by target `%s'."
raise SCons.Errors.StopError(msg % (d, self))
if self.implicit is not None:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:scan; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 20; 5, 28; 5, 34; 5, 43; 5, 51; 5, 59; 5, 125; 5, 136; 5, 144; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifi... | def scan(self):
if self.implicit is not None:
return
self.implicit = []
self.implicit_set = set()
self._children_reset()
if not self.has_builder():
return
build_env = self.get_build_env()
executor = self.get_executor()
if implicit_c... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_binfo; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 24; 5, 30; 5, 38; 5, 44; 5, 77; 5, 111; 5, 117; 5, 139; 5, 155; 5, 163; 5, 183; 5, 193; 5, 213; 6, try_statement; 6, 7; 6, 12; 7, block; 7, 8; 8, return_statement; 8,... | def get_binfo(self):
try:
return self.binfo
except AttributeError:
pass
binfo = self.new_binfo()
self.binfo = binfo
executor = self.get_executor()
ignore_set = self.ignore_set
if self.has_builder():
binfo.bact = str(executor)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:main; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:argv; 6, None; 7, block; 7, 8; 7, 23; 7, 30; 7, 36; 7, 42; 7, 46; 7, 54; 7, 89; 7, 96; 7, 104; 7, 112; 7, 120; 7, 126; 7, 134; 7, 152; 7, 156; 7, 215; 7, 230; 7, 235; 7,... | def main(argv=None):
if argv is None:
argv = sys.argv[1:]
args = parse_global_args(argv)
type_system.interactive = True
line = args.commands
timeout_thread = None
timeout_stop_event = threading.Event()
if args.timeout:
timeout_thread = threading.Thread(target=timeout_thread_h... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:DialectAddToEnv; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:env; 5, identifier:dialect; 6, identifier:suffixes; 7, identifier:ppsuffixes; 8, default_parameter; 8, 9; 8, 10; 9, identifier:support_module; 10, integer:0; 11, block... | def DialectAddToEnv(env, dialect, suffixes, ppsuffixes, support_module = 0):
ComputeFortranSuffixes(suffixes, ppsuffixes)
fscan = SCons.Scanner.Fortran.FortranScan("%sPATH" % dialect)
for suffix in suffixes + ppsuffixes:
SCons.Tool.SourceFileScanner.add_scanner(suffix, fscan)
env.AppendUnique(FO... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:MergeFlags; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:args; 6, default_parameter; 6, 7; 6, 8; 7, identifier:unique; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:dict; 11, None; 12, block; 12, ... | def MergeFlags(self, args, unique=1, dict=None):
if dict is None:
dict = self
if not SCons.Util.is_Dict(args):
args = self.ParseFlags(args)
if not unique:
self.Append(**args)
return self
for key, value in args.items():
if not va... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:Append; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kw; 7, block; 7, 8; 7, 15; 7, 304; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:kw; 11, call; 11, 12; 11, 13; ... | def Append(self, **kw):
kw = copy_non_reserved_keywords(kw)
for key, val in kw.items():
try:
if key == 'CPPDEFINES' and SCons.Util.is_String(self._dict[key]):
self._dict[key] = [self._dict[key]]
orig = self._dict[key]
except Key... |
0, module; 0, 1; 0, 95; 0, 115; 0, 156; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 93; 2, function_name:ParseDepends; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:filename; 6, default_parameter; 6, 7; 6, 8; 7, identifier:must_exist; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identif... | def ParseDepends(self, filename, must_exist=None, only_one=0):
filename = self.subst(filename)
try:
fp = open(filename, 'r')
except IOError:
if must_exist:
raise
return
lines = SCons.Util.LogicalLines(fp).readlines()
lines = [l ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:Prepend; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kw; 7, block; 7, 8; 7, 15; 7, 187; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:kw; 11, call; 11, 12; 11, 13;... | def Prepend(self, **kw):
kw = copy_non_reserved_keywords(kw)
for key, val in kw.items():
try:
orig = self._dict[key]
except KeyError:
self._dict[key] = val
else:
try:
update_dict = orig.update
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:PrependUnique; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:delete_existing; 7, integer:0; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kw; 10, block; 10, 11; 10, 18; 10, 272; 11, exp... | def PrependUnique(self, delete_existing=0, **kw):
kw = copy_non_reserved_keywords(kw)
for key, val in kw.items():
if SCons.Util.is_List(val):
val = _delete_duplicates(val, not delete_existing)
if key not in self._dict or self._dict[key] in ('', None):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:wait_idle; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:timeout; 7, float:1.0; 8, block; 8, 9; 8, 83; 8, 102; 8, 111; 9, function_definition; 9, 10; 9, 11; 9, 12; 10, function_name:_awaiter; 11,... | def wait_idle(self, timeout=1.0):
async def _awaiter():
background_work = {x.join() for x in self._work_queues}
for event in self._events:
if not event.is_set():
background_work.add(event.wait())
_done, pending = await asyncio.wait(backgrou... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_process_long_opt; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:rargs; 6, identifier:values; 7, block; 7, 8; 7, 17; 7, 56; 7, 98; 7, 106; 7, 281; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:a... | def _process_long_opt(self, rargs, values):
arg = rargs.pop(0)
if "=" in arg:
(opt, next_arg) = arg.split("=", 1)
rargs.insert(0, next_arg)
had_explicit_value = True
else:
opt = arg
had_explicit_value = False
try:
op... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:Tag; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 9; 4, identifier:env; 5, identifier:target; 6, identifier:source; 7, list_splat_pattern; 7, 8; 8, identifier:more_tags; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kw_tags; 11, block; 11, 1... | def Tag(env, target, source, *more_tags, **kw_tags):
if not target:
target=source
first_tag=None
else:
first_tag=source
if first_tag:
kw_tags[first_tag[0]] = ''
if len(kw_tags) == 0 and len(more_tags) == 0:
raise UserError("No tags given.")
for x in more_tags:... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:find_vc_pdir; 3, parameters; 3, 4; 4, identifier:msvc_version; 5, block; 5, 6; 5, 10; 5, 35; 5, 202; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:root; 9, string:'Software\\'; 10, try_statement; 10, 11; 10, 18; 11, bl... | def find_vc_pdir(msvc_version):
root = 'Software\\'
try:
hkeys = _VCVER_TO_PRODUCT_DIR[msvc_version]
except KeyError:
debug("Unknown version of MSVC: %s" % msvc_version)
raise UnsupportedVersion("Unknown version %s" % msvc_version)
for hkroot, key in hkeys:
try:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:allocate_stream; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:stream_type; 6, default_parameter; 6, 7; 6, 8; 7, identifier:stream_id; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:previous; 11, ... | def allocate_stream(self, stream_type, stream_id=None, previous=None, attach=False):
if stream_type not in DataStream.TypeToString:
raise ArgumentError("Unknown stream type in allocate_stream", stream_type=stream_type)
if stream_id is not None and stream_id >= StreamAllocator.StartingID:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_products; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:product_type; 6, block; 6, 7; 6, 26; 6, 83; 6, 96; 6, 107; 6, 126; 7, if_statement; 7, 8; 7, 23; 8, boolean_operator:and; 8, 9; 8, 18; 9, boolean_operator:and; 9, 10; 9... | def find_products(self, product_type):
if self.filter_prods and product_type in self.LIST_PRODUCTS and product_type not in self.desired_prods:
return []
if product_type in self.LIST_PRODUCTS:
found_products = self.products.get(product_type, [])
else:
found_pro... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:add_node; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:node_descriptor; 6, block; 6, 7; 6, 35; 6, 48; 6, 52; 6, 190; 6, 221; 6, 230; 6, 243; 6, 251; 7, if_statement; 7, 8; 7, 24; 8, boolean_operator:and; 8, 9; 8, 14; 9, comparis... | def add_node(self, node_descriptor):
if self._max_nodes is not None and len(self.nodes) >= self._max_nodes:
raise ResourceUsageError("Maximum number of nodes exceeded", max_nodes=self._max_nodes)
node, inputs, processor = parse_node_descriptor(node_descriptor, self.model)
in_root = F... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:check_streamers; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:blacklist; 7, None; 8, block; 8, 9; 8, 13; 8, 19; 8, 161; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identi... | def check_streamers(self, blacklist=None):
ready = []
selected = set()
for i, streamer in enumerate(self.streamers):
if blacklist is not None and i in blacklist:
continue
if i in selected:
continue
marked = False
if ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_nodes; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 26; 5, 30; 5, 69; 5, 76; 5, 90; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:node_map; 9, dictionary_comprehension; 9, 10; 9, 16; 10, pair; 10, 1... | def sort_nodes(self):
node_map = {id(node): i for i, node in enumerate(self.nodes)}
node_deps = {}
for node, inputs, _outputs in self.iterate_bfs():
node_index = node_map[id(node)]
deps = {node_map[id(x)] for x in inputs}
node_deps[node_index] = deps
n... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:mark_typed_list; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, identifier:type_object; 7, block; 7, 8; 7, 23; 7, 38; 7, 80; 7, 103; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11... | def mark_typed_list(self, name, type_object):
if not hasattr(type_object, 'dump'):
raise ArgumentError("The passed type object %s is missing required method: dump()" % type_object)
if not hasattr(type_object, 'Restore'):
raise ArgumentError("The passed type object %s is missing r... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:mark_typed_map; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, identifier:type_object; 7, block; 7, 8; 7, 23; 7, 38; 7, 88; 7, 119; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11,... | def mark_typed_map(self, name, type_object):
if not hasattr(type_object, 'dump'):
raise ArgumentError("The passed type object %s is missing required method: dump()" % type_object)
if not hasattr(type_object, 'Restore'):
raise ArgumentError("The passed type object %s is missing re... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:mark_typed_object; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, identifier:type_object; 7, block; 7, 8; 7, 23; 7, 38; 7, 56; 7, 75; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 1... | def mark_typed_object(self, name, type_object):
if not hasattr(type_object, 'dump'):
raise ArgumentError("The passed type object %s is missing required method: dump()" % type_object)
if not hasattr(type_object, 'Restore'):
raise ArgumentError("The passed type object %s is missing... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:scan; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:node; 5, identifier:env; 6, default_parameter; 6, 7; 6, 8; 7, identifier:libpath; 8, tuple; 9, block; 9, 10; 9, 23; 9, 31; 9, 63; 9, 95; 9, 99; 9, 128; 9, 132; 9, 144; 9, 154; 9, 162; 9, 221;... | def scan(node, env, libpath = ()):
try:
libs = env['LIBS']
except KeyError:
return []
libs = _subst_libs(env, libs)
try:
prefix = env['LIBPREFIXES']
if not SCons.Util.is_List(prefix):
prefix = [ prefix ]
except KeyError:
prefix = [ '' ]
try:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:render_recursive_template; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:template_folder; 5, identifier:info; 6, identifier:out_folder; 7, default_parameter; 7, 8; 7, 9; 8, identifier:preserve; 9, None; 10, default_parameter; 10,... | def render_recursive_template(template_folder, info, out_folder, preserve=None, dry_run=False):
if isinstance(preserve, str):
raise ArgumentError("You must pass a list of strings to preserve, not a string", preserve=preserve)
if preserve is None:
preserve = []
preserve = set(preserve)
te... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:Update; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:env; 6, default_parameter; 6, 7; 6, 8; 7, identifier:args; 8, None; 9, block; 9, 10; 9, 14; 9, 38; 9, 137; 9, 148; 9, 207; 9, 231; 9, 316; 10, expression_statement; 10, ... | def Update(self, env, args=None):
values = {}
for option in self.options:
if not option.default is None:
values[option.key] = option.default
for filename in self.files:
if os.path.exists(filename):
dir = os.path.split(os.path.abspath(filena... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:GenerateHelpText; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:env; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, block; 9, 10; 9, 73; 9, 130; 9, 144; 10, if_statement; 10, 11; 10, 15; 10, 43; 10, 65; 1... | def GenerateHelpText(self, env, sort=None):
if callable(sort):
options = sorted(self.options, key=cmp_to_key(lambda x,y: sort(x.key,y.key)))
elif sort is True:
options = sorted(self.options, key=lambda x: x.key)
else:
options = self.options
def format(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:render_tree; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 13; 4, identifier:root; 5, identifier:child_func; 6, default_parameter; 6, 7; 6, 8; 7, identifier:prune; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:margin; 11, list:[... | def render_tree(root, child_func, prune=0, margin=[0], visited=None):
rname = str(root)
if visited is None:
visited = {}
children = child_func(root)
retval = ""
for pipe in margin[:-1]:
if pipe:
retval = retval + "| "
else:
retval = retval + " "
i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:print_tree; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 16; 4, identifier:root; 5, identifier:child_func; 6, default_parameter; 6, 7; 6, 8; 7, identifier:prune; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:showtags; 11... | def print_tree(root, child_func, prune=0, showtags=0, margin=[0], visited=None):
rname = str(root)
if visited is None:
visited = {}
if showtags:
if showtags == 2:
legend = (' E = exists\n' +
' R = exists in repository only\n' +
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:unique; 3, parameters; 3, 4; 4, identifier:s; 5, block; 5, 6; 5, 13; 5, 20; 5, 24; 5, 51; 5, 53; 5, 124; 5, 126; 5, 130; 5, 146; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:n; 9, call; 9, 10; 9, 11; 10, identifier:le... | def unique(s):
n = len(s)
if n == 0:
return []
u = {}
try:
for x in s:
u[x] = 1
except TypeError:
pass
else:
return list(u.keys())
del u
try:
t = sorted(s)
except TypeError:
pass
else:
assert n > 0
last =... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:setup_client; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:client_id; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:user_data; 10, None; 11, default_parameter; 1... | def setup_client(self, client_id=None, user_data=None, scan=True, broadcast=False):
if client_id is None:
client_id = str(uuid.uuid4())
if client_id in self._clients:
raise ArgumentError("Duplicate client_id: {}".format(client_id))
async def _client_callback(conn_string,... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_parse_conn_string; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:conn_string; 6, block; 6, 7; 6, 11; 6, 47; 6, 61; 6, 74; 6, 83; 6, 241; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:disconnection_requ... | def _parse_conn_string(self, conn_string):
disconnection_required = False
if conn_string is None or 'device' not in conn_string:
if self._default_device_info is not None and self._device_info != self._default_device_info:
disconnection_required = True
self._de... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:main; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:argv; 6, None; 7, block; 7, 8; 7, 23; 7, 29; 7, 40; 7, 62; 7, 68; 7, 97; 7, 106; 7, 133; 7, 145; 7, 157; 7, 161; 7, 169; 7, 276; 7, 284; 7, 290; 7, 307; 7, 317; 8, if_st... | def main(argv=None):
if argv is None:
argv = sys.argv[1:]
parser = build_args()
args = parser.parse_args(args=argv)
recipe_name, _ext = os.path.splitext(os.path.basename(args.recipe))
rm = RecipeManager()
rm.add_recipe_folder(os.path.dirname(args.recipe), whitelist=[os.path.basename(args... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:assign_utc; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:reading_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:uptime; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:prefer; 11, string:"before"; 1... | def assign_utc(self, reading_id, uptime=None, prefer="before"):
if prefer not in ("before", "after"):
raise ArgumentError("Invalid prefer parameter: {}, must be 'before' or 'after'".format(prefer))
if len(self._anchor_points) == 0:
return None
if reading_id > self._anchor... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_text_contents; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, try_statement; 6, 7; 6, 19; 6, 28; 7, block; 7, 8; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:self; 11, call; 11, 12; 11, 15; 12, att... | def get_text_contents(self):
try:
self = self.disambiguate(must_exist=1)
except SCons.Errors.UserError:
return ''
else:
return self.get_text_contents() |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_lookup; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:p; 6, identifier:directory; 7, identifier:fsclass; 8, default_parameter; 8, 9; 8, 10; 9, identifier:create; 10, integer:1; 11, block; 11, 12; 11, 28; 11, 3... | def _lookup(self, p, directory, fsclass, create=1):
if isinstance(p, Base):
p.must_be_same(fsclass)
return p
p = str(p)
if not os_sep_is_slash:
p = p.replace(OS_SEP, '/')
if p[0:1] == '
p = p[1:]
directory = self.Top
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:_glob1; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:pattern; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ondisk; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:source; 11, False; 12, default... | def _glob1(self, pattern, ondisk=True, source=False, strings=False):
search_dir_list = self.get_all_rdirs()
for srcdir in self.srcdir_list():
search_dir_list.extend(srcdir.get_all_rdirs())
selfEntry = self.Entry
names = []
for dir in search_dir_list:
node_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:release_target_info; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 6, if_statement; 6, 7; 6, 17; 7, parenthesized_expression; 7, 8; 8, boolean_operator:or; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, iden... | def release_target_info(self):
if (self.released_target_info or SCons.Node.interactive):
return
if not hasattr(self.attributes, 'keep_targetinfo'):
self.changed(allowcache=True)
self.get_contents_sig()
self.get_build_env()
self.executor = None
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:find_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:filename; 6, identifier:paths; 7, default_parameter; 7, 8; 7, 9; 8, identifier:verbose; 9, None; 10, block; 10, 11; 10, 21; 10, 58; 10, 104; 10, 117; 10, 142; ... | def find_file(self, filename, paths, verbose=None):
memo_key = self._find_file_key(filename, paths)
try:
memo_dict = self._memo['find_file']
except KeyError:
memo_dict = {}
self._memo['find_file'] = memo_dict
else:
try:
retu... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:build_report; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:device_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:max_size; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:device_uptime... | def build_report(self, device_id, max_size=None, device_uptime=0, report_id=None, auth_chain=None):
if self.walker is None or self.index is None:
raise InternalError("You can only build a report with a DataStreamer if you create it with a SensorLog and a streamer index")
if self.requires_sig... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:scan; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:wait; 7, None; 8, block; 8, 9; 8, 21; 8, 33; 8, 37; 8, 47; 8, 58; 8, 80; 8, 89; 8, 99; 8, 105; 8, 111; 8, 175; 9, expression_statement; 9, 10; ... | def scan(self, wait=None):
min_scan = self.adapter.get_config('minimum_scan_time', 0.0)
probe_required = self.adapter.get_config('probe_required', False)
wait_time = None
elapsed = monotonic() - self._start_time
if elapsed < min_scan:
wait_time = min_scan - elapsed
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:send_rpc; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:address; 6, identifier:rpc_id; 7, identifier:call_payload; 8, default_parameter; 8, 9; 8, 10; 9, identifier:timeout; 10, float:3.0; 11, block; 11, 12; 11,... | def send_rpc(self, address, rpc_id, call_payload, timeout=3.0):
if not self.connected:
raise HardwareError("Cannot send an RPC if we are not in a connected state")
if timeout is None:
timeout = 3.0
status = -1
payload = b''
recording = None
if self... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:__xml_scan; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:node; 5, identifier:env; 6, identifier:path; 7, identifier:arg; 8, block; 8, 9; 8, 25; 8, 49; 8, 62; 8, 241; 8, 250; 8, 259; 8, 275; 8, 285; 8, 289; 8, 332; 8, 338; 8, 344; 8, 350... | def __xml_scan(node, env, path, arg):
if not os.path.isfile(str(node)):
return []
if env.get('DOCBOOK_SCANENT',''):
contents = node.get_text_contents()
return sentity_re.findall(contents)
xsl_file = os.path.join(scriptpath,'utils','xmldepend.xsl')
if not has_libxml2 or prefer_xsl... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:DocbookMan; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 11; 4, identifier:env; 5, identifier:target; 6, default_parameter; 6, 7; 6, 8; 7, identifier:source; 8, None; 9, list_splat_pattern; 9, 10; 10, identifier:args; 11, dictionary_splat_pattern... | def DocbookMan(env, target, source=None, *args, **kw):
target, source = __extend_targets_sources(target, source)
__init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_MAN', ['manpages','docbook.xsl'])
__builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder)
result = []
for ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:Builder; 3, parameters; 3, 4; 4, dictionary_splat_pattern; 4, 5; 5, identifier:kw; 6, block; 6, 7; 6, 11; 6, 133; 6, 223; 6, 231; 6, 245; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:composite; 10, None; 11, if_state... | def Builder(**kw):
composite = None
if 'generator' in kw:
if 'action' in kw:
raise UserError("You must not specify both an action and a generator.")
kw['action'] = SCons.Action.CommandGeneratorAction(kw['generator'], {})
del kw['generator']
elif 'action' in kw:
so... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_node_errors; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:builder; 5, identifier:env; 6, identifier:tlist; 7, identifier:slist; 8, block; 8, 9; 8, 325; 9, for_statement; 9, 10; 9, 11; 9, 12; 10, identifier:t; 11, identifier:tlist; 12, ... | def _node_errors(builder, env, tlist, slist):
for t in tlist:
if t.side_effect:
raise UserError("Multiple ways to build the same target were specified for: %s" % t)
if t.has_explicit_builder():
if (not t.env is None and not t.env is env and
not (getattr(t.... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_order_pases; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:passes; 6, block; 6, 7; 6, 14; 6, 18; 6, 91; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:passes; 10, call; 10, 11; 10, 12; 11, identifier:se... | def _order_pases(self, passes):
passes = set(passes)
pass_deps = {}
for opt in passes:
_, before, after = self._known_passes[opt]
if opt not in pass_deps:
pass_deps[opt] = set()
for after_pass in after:
pass_deps[opt].add(after_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prepare; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 34; 5, 40; 5, 66; 5, 78; 5, 84; 5, 90; 6, global_statement; 6, 7; 7, identifier:print_prepare; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, ide... | def prepare(self):
global print_prepare
T = self.tm.trace
if T: T.write(self.trace_message(u'Task.prepare()', self.node))
self.exception_raise()
if self.tm.message:
self.display(self.tm.message)
self.tm.message = None
executor = self.targets[0].get... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:make_ready_current; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 34; 5, 40; 5, 44; 5, 128; 6, global_statement; 6, 7; 7, identifier:print_prepare; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, ident... | def make_ready_current(self):
global print_prepare
T = self.tm.trace
if T: T.write(self.trace_message(u'Task.make_ready_current()',
self.node))
self.out_of_date = []
needs_executing = False
for t in self.targets:
try:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:postprocess; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 32; 5, 41; 5, 49; 5, 53; 5, 106; 5, 183; 5, 238; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:T; 9, attribute; 9, 10; 9, 13; 10, attribut... | def postprocess(self):
T = self.tm.trace
if T: T.write(self.trace_message(u'Task.postprocess()', self.node))
targets = set(self.targets)
pending_children = self.tm.pending_children
parents = {}
for t in targets:
if t.waiting_parents:
if T: T.wr... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:update_dependency; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:tile; 6, identifier:depinfo; 7, default_parameter; 7, 8; 7, 9; 8, identifier:destdir; 9, None; 10, block; 10, 11; 10, 34; 10, 38; 10, 42; 10, 60; 10, 2... | def update_dependency(self, tile, depinfo, destdir=None):
if destdir is None:
destdir = os.path.join(tile.folder, 'build', 'deps', depinfo['unique_id'])
has_version = False
had_version = False
if os.path.exists(destdir):
has_version = True
had_version ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:stop; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 24; 5, 82; 5, 86; 5, 102; 5, 116; 5, 129; 5, 133; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:stopped; 10, block; 10, 11; 11,... | async def stop(self):
if self.stopped:
return
self._logger.debug("Stopping task %s", self.name)
if self._finalizer is not None:
try:
result = self._finalizer(self)
if inspect.isawaitable(result):
await result
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:link_cloud; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:username; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:password; 10, None; 11, default_parameter; 11, 12; 11, ... | def link_cloud(self, username=None, password=None, device_id=None):
reg = ComponentRegistry()
domain = self.get('cloud:server')
if username is None:
prompt_str = "Please enter your IOTile.cloud email: "
username = input(prompt_str)
if password is None:
prompt_str = "Please enter ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:main; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:argv; 6, None; 7, block; 7, 8; 7, 23; 7, 297; 8, if_statement; 8, 9; 8, 12; 9, comparison_operator:is; 9, 10; 9, 11; 10, identifier:argv; 11, None; 12, block; 12, 13; 13... | def main(argv=None):
if argv is None:
argv = sys.argv[1:]
try:
executor = None
parser = build_args()
args = parser.parse_args(args=argv)
model = DeviceModel()
parser = SensorGraphFileParser()
parser.parse_file(args.sensor_graph)
parser.compile(mode... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_update_pot_file; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:target; 5, identifier:source; 6, identifier:env; 7, block; 7, 8; 7, 11; 7, 14; 7, 18; 7, 27; 7, 37; 7, 45; 7, 53; 7, 64; 7, 81; 7, 91; 7, 166; 7, 183; 7, 193; 7, 200; 7, 205; 7, 2... | def _update_pot_file(target, source, env):
import re
import os
import SCons.Action
nop = lambda target, source, env: 0
save_cwd = env.fs.getcwd()
save_os_cwd = os.getcwd()
chdir = target[0].dir
chdir_str = repr(chdir.get_abspath())
env.Execute(SCons.Action.Action(nop, "Entering " + c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.