sequence stringlengths 492 15.9k | code stringlengths 75 8.58k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:goto; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:reference_beats; 5, identifier:estimated_beats; 6, default_parameter; 6, 7; 6, 8; 7, identifier:goto_threshold; 8, float:0.35; 9, default_parameter; 9, 10; 9, 11; 10, identifier... | def goto(reference_beats,
estimated_beats,
goto_threshold=0.35,
goto_mu=0.2,
goto_sigma=0.2):
validate(reference_beats, estimated_beats)
if estimated_beats.size == 0 or reference_beats.size == 0:
return 0.
beat_error = np.ones(reference_beats.shape[0])
paired ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_labeled_intervals; 3, parameters; 3, 4; 3, 5; 4, identifier:intervals; 5, default_parameter; 5, 6; 5, 7; 6, identifier:labels; 7, None; 8, block; 8, 9; 8, 11; 8, 24; 8, 30; 9, expression_statement; 9, 10; 10, string:'''Sort intervals, and ... | def sort_labeled_intervals(intervals, labels=None):
'''Sort intervals, and optionally, their corresponding labels
according to start time.
Parameters
----------
intervals : np.ndarray, shape=(n, 2)
The input intervals
labels : list, optional
Labels for each interval
Returns
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:bss_eval_sources; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:reference_sources; 5, identifier:estimated_sources; 6, default_parameter; 6, 7; 6, 8; 7, identifier:compute_permutation; 8, True; 9, block; 9, 10; 9, 27; 9, 44; 9, 50; 9, 89; 9, 9... | def bss_eval_sources(reference_sources, estimated_sources,
compute_permutation=True):
if estimated_sources.ndim == 1:
estimated_sources = estimated_sources[np.newaxis, :]
if reference_sources.ndim == 1:
reference_sources = reference_sources[np.newaxis, :]
validate(refere... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:bss_eval_sources_framewise; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 11; 3, 16; 4, identifier:reference_sources; 5, identifier:estimated_sources; 6, default_parameter; 6, 7; 6, 8; 7, identifier:window; 8, binary_operator:*; 8, 9; 8, 10; 9, integer:... | def bss_eval_sources_framewise(reference_sources, estimated_sources,
window=30*44100, hop=15*44100,
compute_permutation=False):
if estimated_sources.ndim == 1:
estimated_sources = estimated_sources[np.newaxis, :]
if reference_sources.ndim == ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:bss_eval_images_framewise; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 11; 3, 16; 4, identifier:reference_sources; 5, identifier:estimated_sources; 6, default_parameter; 6, 7; 6, 8; 7, identifier:window; 8, binary_operator:*; 8, 9; 8, 10; 9, integer:3... | def bss_eval_images_framewise(reference_sources, estimated_sources,
window=30*44100, hop=15*44100,
compute_permutation=False):
estimated_sources = np.atleast_3d(estimated_sources)
reference_sources = np.atleast_3d(reference_sources)
validate(refere... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:time_frequency; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 13; 3, 16; 4, identifier:gram; 5, identifier:frequencies; 6, identifier:times; 7, identifier:fs; 8, default_parameter; 8, 9; 8, 10; 9, identifier:function; 10, attribute; 10, 11; ... | def time_frequency(gram, frequencies, times, fs, function=np.sin, length=None,
n_dec=1):
if times.ndim == 1:
times = util.boundaries_to_intervals(times)
if length is None:
length = int(times[-1, 1] * fs)
times, _ = util.adjust_intervals(times, t_max=length)
n_times = g... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:match_note_offsets; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:ref_intervals; 5, identifier:est_intervals; 6, default_parameter; 6, 7; 6, 8; 7, identifier:offset_ratio; 8, float:0.2; 9, default_parameter; 9, 10; 9, 11; 10, ide... | def match_note_offsets(ref_intervals, est_intervals, offset_ratio=0.2,
offset_min_tolerance=0.05, strict=False):
if strict:
cmp_func = np.less
else:
cmp_func = np.less_equal
offset_distances = np.abs(np.subtract.outer(ref_intervals[:, 1],
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:match_note_onsets; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:ref_intervals; 5, identifier:est_intervals; 6, default_parameter; 6, 7; 6, 8; 7, identifier:onset_tolerance; 8, float:0.05; 9, default_parameter; 9, 10; 9, 11; 10, identif... | def match_note_onsets(ref_intervals, est_intervals, onset_tolerance=0.05,
strict=False):
if strict:
cmp_func = np.less
else:
cmp_func = np.less_equal
onset_distances = np.abs(np.subtract.outer(ref_intervals[:, 0],
est_inter... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:validate; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:ref_time; 5, identifier:ref_freqs; 6, identifier:est_time; 7, identifier:est_freqs; 8, block; 8, 9; 8, 19; 8, 29; 8, 43; 8, 55; 8, 70; 8, 84; 8, 96; 8, 111; 8, 128; 8, 145; 8, 165; ... | def validate(ref_time, ref_freqs, est_time, est_freqs):
util.validate_events(ref_time, max_time=MAX_TIME)
util.validate_events(est_time, max_time=MAX_TIME)
if ref_time.size == 0:
warnings.warn("Reference times are empty.")
if ref_time.ndim != 1:
raise ValueError("Reference times have inv... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:segments; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 4, identifier:intervals; 5, identifier:labels; 6, default_parameter; 6, 7; 6, 8; 7, identifier:base; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:heigh... | def segments(intervals, labels, base=None, height=None, text=False,
text_kw=None, ax=None, **kwargs):
'''Plot a segmentation as a set of disjoint rectangles.
Parameters
----------
intervals : np.ndarray, shape=(n, 2)
segment intervals, in the format returned by
:func:`mir_ev... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:labeled_intervals; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 4, identifier:intervals; 5, identifier:labels; 6, default_parameter; 6, 7; 6, 8; 7, identifier:label_set; 8, None; 9, default_parameter; 9, 10; 9, 11;... | def labeled_intervals(intervals, labels, label_set=None,
base=None, height=None, extend_labels=True,
ax=None, tick=True, **kwargs):
'''Plot labeled intervals with each label on its own row.
Parameters
----------
intervals : np.ndarray, shape=(n, 2)
seg... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:events; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:times; 5, default_parameter; 5, 6; 5, 7; 6, identifier:labels; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:base; 10, None; 11, default_parameter; ... | def events(times, labels=None, base=None, height=None, ax=None, text_kw=None,
**kwargs):
'''Plot event times as a set of vertical lines
Parameters
----------
times : np.ndarray, shape=(n,)
event times, in the format returned by
:func:`mir_eval.io.load_events` or
:func:... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:pitch; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:times; 5, identifier:frequencies; 6, default_parameter; 6, 7; 6, 8; 7, identifier:midi; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:unvoiced; 11, False;... | def pitch(times, frequencies, midi=False, unvoiced=False, ax=None, **kwargs):
'''Visualize pitch contours
Parameters
----------
times : np.ndarray, shape=(n,)
Sample times of frequencies
frequencies : np.ndarray, shape=(n,)
frequencies (in Hz) of the pitch contours.
Voicing i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:create; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:archive; 6, default_parameter; 6, 7; 6, 8; 7, identifier:interval; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:import_args; 11, block; 11, 12; 11,... | def create(self, archive, interval=None, **import_args):
archive = archive.lower() if hasattr(archive, "lower") else archive
if self.is_sync_table(archive, interval, **import_args):
manager = SyncTableJobManager(self.client)
else:
manager = FileImportJobManager(self.clien... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:copy_data; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:data_length; 5, identifier:blocksize; 6, identifier:infp; 7, identifier:outfp; 8, block; 8, 9; 8, 11; 8, 15; 8, 48; 9, expression_statement; 9, 10; 10, string:'''
A utility fun... | def copy_data(data_length, blocksize, infp, outfp):
'''
A utility function to copy data from the input file object to the output
file object. This function will use the most efficient copy method available,
which is often sendfile.
Parameters:
data_length - The amount of data to copy.
blo... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:instr; 6, block; 6, 7; 6, 9; 6, 21; 6, 36; 6, 80; 6, 117; 6, 129; 6, 141; 6, 154; 6, 241; 6, 277; 6, 287; 6, 293; 6, 299; 7, expression_statement; 7, 8; 8, string:'''
A... | def parse(self, instr):
'''
A method to parse ISO hybridization info out of an existing ISO.
Parameters:
instr - The data for the ISO hybridization.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('This... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:new; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:self; 5, identifier:mac; 6, identifier:part_entry; 7, identifier:mbr_id; 8, identifier:part_offset; 9, identifier:geometry_sectors; 10, identifier:geometry_hea... | def new(self, mac, part_entry, mbr_id, part_offset,
geometry_sectors, geometry_heads, part_type):
'''
A method to add ISO hybridization to an ISO.
Parameters:
mac - Whether this ISO should be made bootable for the Macintosh.
part_entry - The partition entry for the ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:_new; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:self; 5, identifier:vd; 6, identifier:name; 7, identifier:parent; 8, identifier:seqnum; 9, identifier:isdir; 10, identifier:length; 11, identifier:xa; 12, blo... | def _new(self, vd, name, parent, seqnum, isdir, length, xa):
'''
Internal method to create a new Directory Record.
Parameters:
vd - The Volume Descriptor this record is part of.
name - The name for this directory record.
parent - The parent of this directory record.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:new_dir; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 3, 15; 4, identifier:self; 5, identifier:vd; 6, identifier:name; 7, identifier:parent; 8, identifier:seqnum; 9, identifier:rock_ridge; 10, identifie... | def new_dir(self, vd, name, parent, seqnum, rock_ridge, rr_name, log_block_size,
rr_relocated_child, rr_relocated, xa, file_mode):
'''
Create a new directory Directory Record.
Parameters:
vd - The Volume Descriptor this record is part of.
name - The name for thi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_add_child; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:child; 6, identifier:logical_block_size; 7, identifier:allow_duplicate; 8, identifier:check_overflow; 9, block; 9, 10; 9, 12; 9, 25; 9, 37; 9, 122; 9, 13... | def _add_child(self, child, logical_block_size, allow_duplicate, check_overflow):
'''
An internal method to add a child to this object. Note that this is called both
during parsing and when adding a new object to the system, so it
it shouldn't have any functionality that is not appropri... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:remove_child; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:child; 6, identifier:index; 7, identifier:logical_block_size; 8, block; 8, 9; 8, 11; 8, 24; 8, 36; 8, 168; 8, 174; 8, 186; 8, 190; 8, 201; 8, 289; 9, express... | def remove_child(self, child, index, logical_block_size):
'''
A method to remove a child from this Directory Record.
Parameters:
child - The child DirectoryRecord object to remove.
index - The index of the child into this DirectoryRecord children list.
logical_block_si... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_record; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:entries; 6, block; 6, 7; 6, 9; 6, 13; 6, 33; 6, 53; 6, 70; 6, 93; 6, 110; 6, 130; 6, 150; 6, 170; 6, 190; 6, 207; 6, 227; 6, 247; 6, 264; 6, 284; 6, 304; 7, expression_statem... | def _record(self, entries):
'''
Return a string representing the Rock Ridge entry.
Parameters:
entries - The dr_entries or ce_entries to generate a record for.
Returns:
A string representing the Rock Ridge entry.
'''
outlist = []
if entries.sp_re... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_add_name; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:rr_name; 6, identifier:curr_dr_len; 7, block; 7, 8; 7, 10; 7, 18; 7, 44; 7, 50; 7, 61; 7, 72; 7, 85; 7, 89; 7, 185; 8, expression_statement; 8, 9; 9, string:'''
... | def _add_name(self, rr_name, curr_dr_len):
'''
An internal method to add the appropriate name records to the ISO.
Parameters:
rr_name - The Rock Ridge name to add to the ISO.
curr_dr_len - The current directory record length.
Returns:
The new directory record l... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:add_entry; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:length; 6, block; 6, 7; 6, 9; 6, 14; 6, 156; 6, 175; 7, expression_statement; 7, 8; 8, string:'''
Add a new entry to this Rock Ridge Continuation Block. This metho... | def add_entry(self, length):
'''
Add a new entry to this Rock Ridge Continuation Block. This method
attempts to find a gap that fits the new length anywhere within this
Continuation Block. If successful, it returns the offset at which
it placed this entry. If unsuccessful, it ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:data; 6, identifier:extent; 7, block; 7, 8; 7, 10; 7, 22; 7, 53; 7, 65; 7, 84; 7, 97; 7, 113; 7, 144; 7, 168; 8, expression_statement; 8, 9; 9, string:'''
Parse t... | def parse(self, data, extent):
'''
Parse the passed in data into a UDF Descriptor tag.
Parameters:
data - The data to parse.
extent - The extent to compare against for the tag location.
Returns:
Nothing.
'''
if self._initialized:
rai... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:data; 6, block; 6, 7; 6, 9; 6, 21; 6, 63; 6, 71; 6, 104; 6, 122; 6, 151; 6, 171; 6, 191; 6, 211; 6, 231; 6, 251; 6, 271; 7, expression_statement; 7, 8; 8, string:'''
Pa... | def parse(self, data):
'''
Parse the passed in data into a UDF Timestamp.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Timestamp already initialized')
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:data; 6, block; 6, 7; 6, 9; 6, 21; 6, 45; 6, 57; 6, 69; 6, 81; 6, 93; 6, 105; 6, 117; 6, 129; 6, 141; 6, 153; 6, 165; 7, expression_statement; 7, 8; 8, string:'''
Parse... | def parse(self, data):
'''
Parse the passed in data into a UDF Partition Header Descriptor.
Parameters:
data - The data to parse.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF Partition Header De... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:finish_directory_parse; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 21; 6, expression_statement; 6, 7; 7, string:'''
A method to finish up the parsing of this UDF File Entry directory.
In particular, this m... | def finish_directory_parse(self):
'''
A method to finish up the parsing of this UDF File Entry directory.
In particular, this method checks to see if it is in sorted order for
future use.
Parameters:
None.
Returns:
Nothing.
'''
if not sel... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:valstr; 6, block; 6, 7; 6, 9; 6, 21; 6, 302; 7, expression_statement; 7, 8; 8, string:'''
A method to parse an El Torito Boot Catalog out of a string.
Parameter... | def parse(self, valstr):
'''
A method to parse an El Torito Boot Catalog out of a string.
Parameters:
valstr - The string to parse the El Torito Boot Catalog out of.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibIn... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_check_iso9660_filename; 3, parameters; 3, 4; 3, 5; 4, identifier:fullname; 5, identifier:interchange_level; 6, block; 6, 7; 6, 9; 6, 19; 6, 46; 6, 60; 6, 76; 6, 106; 7, expression_statement; 7, 8; 8, string:'''
A function to check that a f... | def _check_iso9660_filename(fullname, interchange_level):
'''
A function to check that a file identifier conforms to the ISO9660 rules
for a particular interchange level.
Parameters:
fullname - The name to check.
interchange_level - The interchange level to check against.
Returns:
Not... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_yield_children; 3, parameters; 3, 4; 4, identifier:rec; 5, block; 5, 6; 5, 8; 5, 23; 5, 27; 6, expression_statement; 6, 7; 7, string:'''
An internal function to gather and yield all of the children of a Directory
Record.
Parameters... | def _yield_children(rec):
'''
An internal function to gather and yield all of the children of a Directory
Record.
Parameters:
rec - The Directory Record to get all of the children from (must be a
directory)
Yields:
Children of this Directory Record.
Returns:
Nothing.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_find_dr_record_by_name; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:vd; 5, identifier:path; 6, identifier:encoding; 7, block; 7, 8; 7, 10; 7, 26; 7, 34; 7, 41; 7, 50; 7, 69; 7, 73; 7, 81; 7, 243; 8, expression_statement; 8, 9; 9, string:'''... | def _find_dr_record_by_name(vd, path, encoding):
'''
An internal function to find an directory record on the ISO given an ISO
or Joliet path. If the entry is found, it returns the directory record
object corresponding to that entry. If the entry could not be found,
a pycdlibexception.PyCdlibInvali... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_parse_volume_descriptors; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 19; 5, 311; 5, 324; 5, 334; 5, 368; 6, expression_statement; 6, 7; 7, string:'''
An internal method to parse the volume descriptors on an ISO.
... | def _parse_volume_descriptors(self):
'''
An internal method to parse the volume descriptors on an ISO.
Parameters:
None.
Returns:
Nothing.
'''
self._cdfp.seek(16 * 2048)
while True:
curr_extent = self._cdfp.tell() // 2048
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_find_rr_record; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:rr_path; 6, block; 6, 7; 6, 9; 6, 25; 6, 35; 6, 42; 6, 51; 6, 70; 6, 74; 6, 268; 7, expression_statement; 7, 8; 8, string:'''
An internal method to find an di... | def _find_rr_record(self, rr_path):
'''
An internal method to find an directory record on the ISO given a Rock
Ridge path. If the entry is found, it returns the directory record
object corresponding to that entry. If the entry could not be found, a
pycdlibexception.PyCdlibInval... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_parse_udf_descriptors; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 18; 5, 35; 5, 130; 5, 153; 5, 176; 5, 189; 5, 206; 5, 210; 5, 220; 5, 228; 5, 240; 5, 254; 5, 272; 5, 276; 5, 280; 5, 288; 5, 300; 5, 314; 5, 324; 5, 334;... | def _parse_udf_descriptors(self):
'''
An internal method to parse the UDF descriptors on the ISO. This should
only be called if it the ISO has a valid UDF Volume Recognition Sequence
at the beginning of the ISO.
Parameters:
None.
Returns:
Nothing.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_walk_udf_directories; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:extent_to_inode; 6, block; 6, 7; 6, 9; 6, 19; 6, 44; 6, 54; 6, 66; 7, expression_statement; 7, 8; 8, string:'''
An internal method to walk a UDF filesys... | def _walk_udf_directories(self, extent_to_inode):
'''
An internal method to walk a UDF filesystem and add all the metadata
to this object.
Parameters:
extent_to_inode - A map from extent numbers to Inodes.
Returns:
Nothing.
'''
part_start = self.... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_write_directory_records; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:vd; 6, identifier:outfp; 7, identifier:progress; 8, block; 8, 9; 8, 11; 8, 19; 8, 23; 8, 27; 8, 41; 9, expression_statement; 9, 10; 10, string:''... | def _write_directory_records(self, vd, outfp, progress):
'''
An internal method to write out the directory records from a particular
Volume Descriptor.
Parameters:
vd - The Volume Descriptor to write the Directory Records from.
outfp - The file object to write data to.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_rm_dr_link; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:rec; 6, block; 6, 7; 6, 9; 6, 24; 6, 28; 6, 38; 6, 42; 6, 199; 7, expression_statement; 7, 8; 8, string:'''
An internal method to remove a Directory Record link g... | def _rm_dr_link(self, rec):
'''
An internal method to remove a Directory Record link given the record.
Parameters:
rec - The Directory Record to remove.
Returns:
The number of bytes to remove from the ISO.
'''
if not rec.is_file():
raise pycd... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_rm_udf_link; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:rec; 6, block; 6, 7; 6, 9; 6, 31; 6, 41; 6, 45; 6, 193; 6, 207; 6, 221; 7, expression_statement; 7, 8; 8, string:'''
An internal method to remove a UDF File Entr... | def _rm_udf_link(self, rec):
'''
An internal method to remove a UDF File Entry link.
Parameters:
rec - The UDF File Entry to remove.
Returns:
The number of bytes to remove from the ISO.
'''
if not rec.is_file() and not rec.is_symlink():
raise... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:rm_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:iso_path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:rr_name; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:joliet_path; 11, None; 12, ... | def rm_file(self, iso_path, rr_name=None, joliet_path=None, udf_path=None):
'''
Remove a file from the ISO.
Parameters:
iso_path - The path to the file to remove.
rr_name - The Rock Ridge name of the file to remove.
joliet_path - The Joliet path to the file to remove.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_record; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 23; 7, 27; 7, 60; 7, 72; 7, 93; 7, 114; 7, 128; 8, expression_statement; 8, 9; 9, string:'''
G... | def get_record(self, **kwargs):
'''
Get the directory record for a particular path.
Parameters:
iso_path - The absolute path on the ISO9660 filesystem to get the
record for.
rr_path - The absolute path on the Rock Ridge filesystem to get the
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:full_path_from_dirrecord; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:rec; 6, default_parameter; 6, 7; 6, 8; 7, identifier:rockridge; 8, False; 9, block; 9, 10; 9, 12; 9, 25; 9, 29; 9, 234; 9, 250; 10, expression_statemen... | def full_path_from_dirrecord(self, rec, rockridge=False):
'''
A method to get the absolute path of a directory record.
Parameters:
rec - The directory record to get the full path for.
rockridge - Whether to get the rock ridge full path.
Returns:
A string repres... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_update_bird_conf_file; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:operation; 6, block; 6, 7; 6, 11; 6, 15; 6, 21; 6, 31; 6, 41; 6, 52; 6, 63; 6, 97; 6, 120; 6, 150; 6, 166; 6, 208; 6, 220; 6, 235; 6, 250; 6, 260; 6, 307; 6, 3... | def _update_bird_conf_file(self, operation):
conf_updated = False
prefixes = []
ip_version = operation.ip_version
config_file = self.bird_configuration[ip_version]['config_file']
variable_name = self.bird_configuration[ip_version]['variable_name']
changes_counter =\
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:run; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 137; 6, if_statement; 6, 7; 6, 11; 6, 21; 7, not_operator; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:services; 11, block; 11, 12; 12, expression_statemen... | def run(self):
if not self.services:
self.log.warning("no service checks are configured")
else:
self.log.info("going to lunch %s threads", len(self.services))
if self.config.has_option('daemon', 'splay_startup'):
splay_startup = self.config.getfloat('d... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:modify_ip_prefixes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:config; 5, identifier:config_file; 6, identifier:variable_name; 7, identifier:dummy_ip_prefix; 8, identifier:reconfigure_cmd; 9, identifier:keep... | def modify_ip_prefixes(
config,
config_file,
variable_name,
dummy_ip_prefix,
reconfigure_cmd,
keep_changes,
changes_counter,
ip_version):
log = logging.getLogger(PROGRAM_NAME)
services = config.sections()
services.remove('daemon')
update_bi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:load_configuration; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:config_file; 5, identifier:config_dir; 6, identifier:service_file; 7, block; 7, 8; 7, 13; 7, 21; 7, 28; 7, 53; 7, 144; 7, 166; 7, 171; 7, 178; 7, 183; 8, expression_statement; 8... | def load_configuration(config_file, config_dir, service_file):
config_files = [config_file]
config = configparser.ConfigParser()
config.read_dict(DEFAULT_OPTIONS)
if not os.path.isfile(config_file):
raise ValueError("{f} configuration file either isn't readable or "
"doe... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:configuration_check; 3, parameters; 3, 4; 4, identifier:config; 5, block; 5, 6; 5, 16; 5, 29; 5, 39; 5, 76; 5, 94; 5, 133; 5, 212; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:log_level; 9, call; 9, 10; 9, 13; 10, att... | def configuration_check(config):
log_level = config.get('daemon', 'loglevel')
num_level = getattr(logging, log_level.upper(), None)
pidfile = config.get('daemon', 'pidfile')
if not os.path.isdir(os.path.dirname(pidfile)):
raise ValueError("{d} doesn't exit".format(d=os.path.dirname(pidfile)))
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:create_bird_config_files; 3, parameters; 3, 4; 4, identifier:bird_configuration; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 8; 6, 9; 7, identifier:ip_version; 8, identifier:bird_configuration; 9, block; 9, 10; 9, 18; 9, 46; 10, expression_state... | def create_bird_config_files(bird_configuration):
for ip_version in bird_configuration:
config_file = bird_configuration[ip_version]['config_file']
try:
touch(config_file)
except OSError as exc:
raise ValueError("failed to create {f}:{e}"
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:setup_logger; 3, parameters; 3, 4; 4, identifier:config; 5, block; 5, 6; 5, 15; 5, 34; 5, 41; 5, 45; 5, 59; 5, 71; 5, 100; 5, 106; 5, 118; 5, 139; 5, 215; 5, 281; 5, 341; 5, 437; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, iden... | def setup_logger(config):
logger = logging.getLogger(PROGRAM_NAME)
num_level = getattr(
logging,
config.get('daemon', 'loglevel').upper(),
None
)
logger.setLevel(num_level)
lengths = []
for section in config:
lengths.append(len(section))
width = sorted(lengths... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:main; 3, parameters; 4, block; 4, 5; 4, 12; 4, 16; 4, 20; 4, 28; 4, 33; 4, 53; 4, 60; 4, 103; 4, 126; 4, 134; 4, 141; 4, 157; 4, 165; 4, 190; 4, 206; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:arguments; 8, call; 8,... | def main():
arguments = docopt(__doc__)
config_file = '/etc/anycast-healthchecker.conf'
config_dir = '/etc/anycast-healthchecker.d'
config = configparser.ConfigParser()
config_files = [config_file]
config_files.extend(glob.glob(os.path.join(config_dir, '*.conf')))
config.read(config_files)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_ve_base; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:environ; 6, block; 6, 7; 6, 22; 6, 48; 6, 146; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:ve_base_value; 10, call; 10, 11; 10, 20; 11, attri... | def get_ve_base(self, environ):
ve_base_value = self.headings[self.default_heading].get('virtualenvs')
if ve_base_value:
ve_base = os.path.expanduser(ve_base_value)
else:
ve_base = environ.get('WORKON_HOME', '')
if not ve_base:
if platform.system() == ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:generate; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:callback; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:interval; 10, integer:0; 11, block; 11, 12; 11, 62; 11, 91; 11, ... | def generate(self, callback=None, interval=0):
if self.path is None:
raise RuntimeError('generate() called with no path specified')
elif self.size <= 0:
raise error.PathEmptyError(self.path)
elif not os.path.exists(self.path):
raise error.PathNotFoundError(sel... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:read_stream; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:stream; 6, default_parameter; 6, 7; 6, 8; 7, identifier:validate; 8, True; 9, block; 9, 10; 10, try_statement; 10, 11; 10, 23; 10, 38; 11, block; 11, 12; 12, express... | def read_stream(cls, stream, validate=True):
try:
content = stream.read(cls.MAX_TORRENT_FILE_SIZE)
except OSError as e:
raise error.ReadError(e.errno)
else:
try:
metainfo_enc = bdecode(content)
except BTFailure as e:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:filepaths; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:exclude; 7, tuple; 8, default_parameter; 8, 9; 8, 10; 9, identifier:hidden; 10, True; 11, default_parameter; 11, 12; 11, 13;... | def filepaths(path, exclude=(), hidden=True, empty=True):
if not os.path.exists(path):
raise error.PathNotFoundError(path)
elif not os.access(path, os.R_OK,
effective_ids=os.access in os.supports_effective_ids):
raise error.ReadError(errno.EACCES, path)
if os.path.isfi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, default_parameter; 6, 7; 6, 8; 7, identifier:provider; 8, None; 9, block; 9, 10; 9, 28; 9, 50; 9, 77; 10, if_statement; 10, 11; 10, 15; 11, not_operator; 11, 12... | def get(self, request, provider=None):
if not settings.CAS_FEDERATE:
logger.warning("CAS_FEDERATE is False, set it to True to use federation")
return redirect("cas_server:login")
renew = bool(request.GET.get('renew') and request.GET['renew'] != "False")
if self.request.se... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:service_login; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 347; 5, 376; 6, try_statement; 6, 7; 6, 231; 6, 263; 6, 288; 6, 313; 7, block; 7, 8; 7, 19; 7, 28; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identi... | def service_login(self):
try:
service_pattern = ServicePattern.validate(self.service)
service_pattern.check_user(self.user)
if self.request.session.get("warn", True) and not self.warned:
messages.add_message(
self.request,
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:not_authenticated; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 162; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:service; 10, block; 10, 11; 11, try_statement; 11, 12; 11, 132; 12, bl... | def not_authenticated(self):
if self.service:
try:
service_pattern = ServicePattern.validate(self.service)
if self.gateway and not self.ajax:
list(messages.get_messages(self.request))
return HttpResponseRedirect(self.service)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:match_path_to_api_path; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:path_definitions; 5, identifier:target_path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:base_path; 8, string:''; 9, default_parameter; 9, 10; 9, 11; 10, identifi... | def match_path_to_api_path(path_definitions, target_path, base_path='',
context=None):
if context is None:
context = {}
assert isinstance(context, collections.Mapping)
if target_path.startswith(base_path):
normalized_target_path = re.sub(NORMALIZE_SLASH_REGEX, '/',... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_read_frame; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:length; 6, block; 6, 7; 6, 18; 6, 35; 6, 47; 6, 51; 6, 75; 6, 87; 6, 91; 6, 104; 6, 110; 6, 129; 6, 153; 6, 163; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10... | def _read_frame(self, length):
response = self._read_data(length+8)
logger.debug('Read frame: 0x{0}'.format(binascii.hexlify(response)))
if response[0] != 0x01:
raise RuntimeError('Response frame does not start with 0x01!')
offset = 1
while response[offset] == 0x00:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:call_function; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:command; 6, default_parameter; 6, 7; 6, 8; 7, identifier:response_length; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:params; 1... | def call_function(self, command, response_length=0, params=[], timeout_sec=1):
data = bytearray(2+len(params))
data[0] = PN532_HOSTTOPN532
data[1] = command & 0xFF
data[2:] = params
self._write_frame(data)
if not self._wait_ready(timeout_sec):
return None
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:createGraph; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:createCollections; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:isSmart; 1... | def createGraph(self, name, createCollections = True, isSmart = False, numberOfShards = None, smartGraphAttribute = None) :
def _checkCollectionList(lst) :
for colName in lst :
if not COL.isCollection(colName) :
raise ValueError("'%s' is not a defined Collection" ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:map_v2_event_into_v1; 3, parameters; 3, 4; 4, identifier:event; 5, block; 5, 6; 5, 8; 5, 15; 5, 260; 6, expression_statement; 6, 7; 7, string:'''
Helper method to convert Sensu 2.x event into Sensu 1.x event.
'''; 8, if_statement; 8, 9;... | def map_v2_event_into_v1(event):
'''
Helper method to convert Sensu 2.x event into Sensu 1.x event.
'''
if "v2_event_mapped_into_v1" in event:
return event
if not bool(event.get('client')) and "entity" in event:
event['client'] = event['entity']
if "name" not in event['client... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 1, 14; 2, function_name:gen_df_site; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:list_csv_in; 6, identifier:list_table; 7, default_parameter; 7, 8; 7, 9; 8, identifier:url_base; 9, identifier:url_repo_input_site; 10, type; 10, 11... | def gen_df_site(
list_csv_in=list_table,
url_base=url_repo_input_site)->pd.DataFrame:
'''Generate description info of supy output results as a dataframe
Parameters
----------
path_csv_out : str, optional
path to the output csv file (the default is 'df_output.csv')
list_csv_in... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:wait_for_tasks_to_complete; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:batch_service_client; 5, identifier:job_ids; 6, identifier:timeout; 7, block; 7, 8; 7, 20; 7, 33; 7, 118; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10,... | def wait_for_tasks_to_complete(batch_service_client, job_ids, timeout):
timeout_expiration = datetime.datetime.now() + timeout
print("Monitoring all tasks for 'Completed' state, timeout in {}...".format(timeout), end='')
while datetime.datetime.now() < timeout_expiration:
print('.', end='')
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 52; 2, function_name:plot_world_with_elegans; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 39; 3, 46; 3, 49; 4, identifier:world; 5, default_parameter; 5, 6; 5, 7; 6, identifier:radius; 7, None; 8, default_parameter; ... | def plot_world_with_elegans(
world, radius=None, width=350, height=350, config=None, grid=True,
wireframe=False, species_list=None, debug=None, max_count=1000,
camera_position=(-22, 23, 32), camera_rotation=(-0.6, 0.5, 0.6),
return_id=False, predicator=None):
config = config or {}
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 31; 2, function_name:plot_trajectory2d_with_matplotlib; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:obs; 5, default_parameter; 5, 6; 5, 7; 6, identifier:plane; 7, string:'xy'; 8, default_parameter; 8, 9; 8, 10; 9... | def plot_trajectory2d_with_matplotlib(
obs, plane='xy', max_count=10, figsize=6, legend=True,
wireframe=False, grid=True, noaxis=False, plot_range=None, **kwargs):
import matplotlib.pyplot as plt
plane = plane.lower()
if len(plane) != 2 or plane[0] not in ('x', 'y', 'z') or plane[1] not in (... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 40; 2, function_name:plot_world2d_with_matplotlib; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 4, identifier:world; 5, default_parameter; 5, 6; 5, 7; 6, identifier:plane; 7, string:'xy'; 8, default_paramet... | def plot_world2d_with_matplotlib(
world, plane='xy', marker_size=3, figsize=6, grid=True,
wireframe=False, species_list=None, max_count=1000, angle=None,
legend=True, noaxis=False, scale=1.0, **kwargs):
import matplotlib.pyplot as plt
plane = plane.lower()
if len(plane) != 2 or plane... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:get_model; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:is_netfree; 6, False; 7, default_parameter; 7, 8; 7, 9; 8, identifier:without_reset; 9, False; 10, default_parameter; 10, 11; 10, 12; 11, ident... | def get_model(is_netfree=False, without_reset=False, seeds=None, effective=False):
try:
if seeds is not None or is_netfree:
m = ecell4_base.core.NetfreeModel()
else:
m = ecell4_base.core.NetworkModel()
for sp in SPECIES_ATTRIBUTES:
m.add_species_attribute(... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:run_multiprocessing; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:target; 5, identifier:jobs; 6, default_parameter; 6, 7; 6, 8; 7, identifier:n; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:nproc; 11, None; 1... | def run_multiprocessing(target, jobs, n=1, nproc=None, **kwargs):
def consumer(f, q_in, q_out):
while True:
val = q_in.get()
if val is None:
q_in.task_done()
break
i, x = val
res = (i, f(*x))
q_in.task_done()
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:readbits; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:bits; 6, block; 6, 7; 6, 14; 6, 36; 6, 40; 6, 46; 6, 105; 6, 208; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:bits; 10, integer:0; 11... | def readbits(self, bits):
if bits == 0:
return 0
if bits % 8 == 0 and self._bits_pending == 0:
return self._read_bytes_aligned(bits // 8)
out = 0
masks = self._masks
def transfer_bits(x, y, n, t):
if n == t:
return (x << t) | y,... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:export; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:swf; 6, identifier:shape; 7, dictionary_splat_pattern; 7, 8; 8, identifier:export_opts; 9, block; 9, 10; 9, 65; 9, 71; 9, 96; 9, 230; 9, 236; 9, 242; 10, if_statem... | def export(self, swf, shape, **export_opts):
if isinstance(shape, Tag):
shape_tag = shape
else:
shapes = [x for x in swf.all_tags_of_type((TagDefineShape, TagDefineSprite)) if x.characterId == shape]
if len(shapes):
shape_tag = shapes[0]
el... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:draw_residual; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:x; 5, identifier:y; 6, identifier:yerr; 7, identifier:xerr; 8, default_parameter; 8, 9; 8, 10; 9, identifier:show_errbars; 10, True; 11, defa... | def draw_residual(x, y, yerr, xerr,
show_errbars=True, ax=None,
zero_line=True, grid=True,
**kwargs):
from matplotlib import pyplot as plt
ax = plt.gca() if ax is None else ax
if show_errbars:
plotopts = dict(fmt='b.', capsize=0)
plotopts... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:combined_message_class; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 17; 5, 21; 5, 25; 5, 53; 5, 115; 5, 129; 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... | def combined_message_class(self):
if self.__combined_message_class is not None:
return self.__combined_message_class
fields = {}
field_number = 1
for field in self.body_message_class.all_fields():
fields[field.name] = _CopyField(field, number=field_number)
field_number += 1
for fie... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:_get_token; 3, parameters; 3, 4; 3, 7; 3, 12; 4, default_parameter; 4, 5; 4, 6; 5, identifier:request; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:allowed_auth_schemes; 9, tuple; 9, 10; 9, 11; 10, string:'OAuth'; 11, string:'Beare... | def _get_token(
request=None, allowed_auth_schemes=('OAuth', 'Bearer'),
allowed_query_keys=('bearer_token', 'access_token')):
allowed_auth_schemes = _listlike_guard(
allowed_auth_schemes, 'allowed_auth_schemes', iterable_only=True)
auth_header = os.environ.get('HTTP_AUTHORIZATION')
if auth_header:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_get_id_token_user; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:token; 5, identifier:issuers; 6, identifier:audiences; 7, identifier:allowed_client_ids; 8, identifier:time_now; 9, identifier:cache; 10, block; 10, 11; 11, f... | def _get_id_token_user(token, issuers, audiences, allowed_client_ids, time_now, cache):
for issuer_key, issuer in issuers.items():
issuer_cert_uri = convert_jwks_uri(issuer.jwks_uri)
try:
parsed_token = _verify_signed_jwt_with_certs(
token, time_now, cache, cert_uri=issuer_cert_uri)
except... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_verify_parsed_token; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:parsed_token; 5, identifier:issuers; 6, identifier:audiences; 7, identifier:allowed_client_ids; 8, default_parameter; 8, 9; 8, 10; 9, identifier:is_legacy_google_... | def _verify_parsed_token(parsed_token, issuers, audiences, allowed_client_ids, is_legacy_google_auth=True):
if parsed_token.get('iss') not in issuers:
_logger.warning('Issuer was not valid: %s', parsed_token.get('iss'))
return False
aud = parsed_token.get('aud')
if not aud:
_logger.warning('No aud fie... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_verify_signed_jwt_with_certs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:jwt; 5, identifier:time_now; 6, identifier:cache; 7, default_parameter; 7, 8; 7, 9; 8, identifier:cert_uri; 9, identifier:_DEFAULT_CERT_URI; 10, block; 10, 11;... | def _verify_signed_jwt_with_certs(
jwt, time_now, cache,
cert_uri=_DEFAULT_CERT_URI):
segments = jwt.split('.')
if len(segments) != 3:
raise _AppIdentityError('Token is not an id_token (Wrong number of '
'segments)')
signed = '%s.%s' % (segments[0], segments[1])
signature... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_sorted_methods; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:methods; 6, block; 6, 7; 6, 13; 6, 166; 7, if_statement; 7, 8; 7, 10; 8, not_operator; 8, 9; 9, identifier:methods; 10, block; 10, 11; 11, return_statement; 11, 1... | def _get_sorted_methods(self, methods):
if not methods:
return methods
def _sorted_methods_comparison(method_info1, method_info2):
def _score_path(path):
score = 0
parts = path.split('/')
for part in parts:
score <<= 1
if not part or part[0] != '{':
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:api_server; 3, parameters; 3, 4; 3, 5; 4, identifier:api_services; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 18; 7, 25; 7, 32; 7, 40; 7, 49; 7, 58; 7, 69; 7, 86; 7, 102; 7, 109; 7, 116; 7, 124; 7, 137; 7, 143; ... | def api_server(api_services, **kwargs):
if 'protocols' in kwargs:
raise TypeError("__init__() got an unexpected keyword argument 'protocols'")
from . import _logger as endpoints_logger
from . import __version__ as endpoints_version
endpoints_logger.info('Initializing Endpoints Framework version %s', endpoin... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__register_services; 3, parameters; 3, 4; 3, 5; 4, identifier:api_name_version_map; 5, identifier:api_config_registry; 6, block; 6, 7; 6, 15; 6, 19; 6, 116; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:generator; 10,... | def __register_services(api_name_version_map, api_config_registry):
generator = api_config.ApiConfigGenerator()
protorpc_services = []
for service_factories in api_name_version_map.itervalues():
service_classes = [service_factory.service_class
for service_factory in service_fa... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:transform_rest_request; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:orig_request; 6, identifier:params; 7, identifier:method_parameters; 8, block; 8, 9; 8, 17; 8, 21; 8, 38; 8, 78; 8, 155; 8, 170; 8, 176; 8, 189; 9,... | def transform_rest_request(self, orig_request, params, method_parameters):
request = orig_request.copy()
body_json = {}
for key, value in params.iteritems():
body_json[key] = [value]
if request.parameters:
for key, value in request.parameters.iteritems():
if key in body_json:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 66; 2, function_name:api; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 3, 36; 3, 39; 3, 42; 3, 45; 3, 48; 3, 51; 3, 54; 3, 57; 3, 60; 3, 63; 4, identifier:name; 5, identifier:version; 6, default_parameter; 6, 7; 6,... | def api(name, version, description=None, hostname=None, audiences=None,
scopes=None, allowed_client_ids=None, canonical_name=None,
auth=None, owner_domain=None, owner_name=None, package_path=None,
frontend_limits=None, title=None, documentation=None, auth_level=None,
issuers=None, namesp... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 44; 2, function_name:method; 3, parameters; 3, 4; 3, 9; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 4, default_parameter; 4, 5; 4, 6; 5, identifier:request_message; 6, attribute; 6, 7; 6, 8; 7, identifier:message_types; 8, identifier:Void... | def method(request_message=message_types.VoidMessage,
response_message=message_types.VoidMessage,
name=None,
path=None,
http_method='POST',
scopes=None,
audiences=None,
allowed_client_ids=None,
auth_level=None,
api_key_re... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:api_class; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:resource_name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:path; 10, None; 11, def... | def api_class(self, resource_name=None, path=None, audiences=None,
scopes=None, allowed_client_ids=None, auth_level=None,
api_key_required=None):
if auth_level is not None:
_logger.warn(_AUTH_LEVEL_WARNING)
def apiserving_api_decorator(api_class):
self.__classes.appen... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__field_to_subfields; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:field; 6, block; 6, 7; 6, 21; 6, 25; 6, 74; 7, if_statement; 7, 8; 7, 16; 8, not_operator; 8, 9; 9, call; 9, 10; 9, 11; 10, identifier:isinstance; 11, argument_l... | def __field_to_subfields(self, field):
if not isinstance(field, messages.MessageField):
return [[field]]
result = []
for subfield in sorted(field.message_type.all_fields(),
key=lambda f: f.number):
subfield_results = self.__field_to_subfields(subfield)
for subfie... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:__schemas_descriptor; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 175; 5, 209; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result; 9, dictionary; 10, for_statement; 10, 11; 10, 14; 10, 25; 11, ... | def __schemas_descriptor(self):
result = {}
for schema_key, schema_value in self.__parser.schemas().iteritems():
field_keys = schema_value.keys()
key_result = {}
if 'properties' in field_keys:
key_result['properties'] = schema_value['properties'].copy()
for prop_key, prop_value... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:__discovery_doc_descriptor; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:services; 6, default_parameter; 6, 7; 6, 8; 7, identifier:hostname; 8, None; 9, block; 9, 10; 9, 19; 9, 31; 9, 37; 9, 56; 9, 65; 9, 75; 9, 86; 9, 170... | def __discovery_doc_descriptor(self, services, hostname=None):
merged_api_info = self.__get_merged_api_info(services)
descriptor = self.get_descriptor_defaults(merged_api_info,
hostname=hostname)
description = merged_api_info.description
if not description a... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:__definitions_descriptor; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 123; 5, 164; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result; 9, dictionary; 10, for_statement; 10, 11; 10, 14; 10, 25; ... | def __definitions_descriptor(self):
result = {}
for def_key, def_value in self.__parser.schemas().iteritems():
if 'properties' in def_value or 'type' in def_value:
key_result = {}
required_keys = set()
if 'type' in def_value:
key_result['type'] = def_value['type']
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:__api_openapi_descriptor; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:services; 6, default_parameter; 6, 7; 6, 8; 7, identifier:hostname; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:x_google_api_nam... | def __api_openapi_descriptor(self, services, hostname=None, x_google_api_name=False):
merged_api_info = self.__get_merged_api_info(services)
descriptor = self.get_descriptor_defaults(merged_api_info,
hostname=hostname,
x... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__message_to_schema; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:message_type; 6, block; 6, 7; 6, 16; 6, 26; 6, 39; 6, 43; 6, 306; 6, 312; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:name; 10, call;... | def __message_to_schema(self, message_type):
name = self.__normalized_name(message_type)
schema = {
'id': name,
'type': 'object',
}
if message_type.__doc__:
schema['description'] = message_type.__doc__
properties = {}
for field in message_type.all_fields():
descri... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:transform_parameter_value; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:parameter_name; 5, identifier:value; 6, identifier:parameter_config; 7, block; 7, 8; 7, 35; 7, 42; 7, 84; 8, if_statement; 8, 9; 8, 14; 9, call; 9, 10; 9, 11; 10, identif... | def transform_parameter_value(parameter_name, value, parameter_config):
if isinstance(value, list):
return [transform_parameter_value('%s[%d]' % (parameter_name, index),
element, parameter_config)
for index, element in enumerate(value)]
entry = _get_parameter_co... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:extract_conf_from; 3, parameters; 3, 4; 3, 5; 3, 11; 3, 14; 4, identifier:mod; 5, default_parameter; 5, 6; 5, 7; 6, identifier:conf; 7, call; 7, 8; 7, 9; 8, identifier:ModuleConfig; 9, argument_list; 9, 10; 10, identifier:CONF_SPEC; 11, defaul... | def extract_conf_from(mod, conf=ModuleConfig(CONF_SPEC), depth=0, max_depth=2):
for key, default_value in six.iteritems(conf):
conf[key] = _get_key_from_module(mod, key, default_value)
try:
filtered_apps = [app for app in conf['apps'] if app not in BLACKLIST]
except TypeError:
pass
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:render_region; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 4, default_parameter; 4, 5; 4, 6; 5, identifier:widget; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:request; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identi... | def render_region(widget=None, request=None, view=None,
page=None, region=None):
if not isinstance(request, dict):
request.query_string = None
request.method = "GET"
if not hasattr(request, '_feincms_extra_context'):
request._feincms_extra_context = {}
leonardo_page... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:handle_ajax_method; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, identifier:method; 7, block; 7, 8; 7, 12; 7, 39; 7, 47; 7, 55; 7, 68; 7, 80; 7, 314; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; ... | def handle_ajax_method(self, request, method):
response = {}
def get_param(request, name):
try:
return request.POST[name]
except KeyError:
return request.GET.get(name, None)
widget_id = get_param(request, "widget_id")
class_name = g... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:ajax_upload; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, default_parameter; 6, 7; 6, 8; 7, identifier:folder_id; 8, None; 9, block; 9, 10; 9, 21; 9, 25; 9, 32; 9, 36; 9, 74; 9, 100; 10, expression_statement; 1... | def ajax_upload(self, request, folder_id=None):
mimetype = "application/json" if request.is_ajax() else "text/html"
content_type_key = 'content_type'
response_params = {content_type_key: mimetype}
folder = None
if folder_id:
try:
folder = Folder.object... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:collect; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 20; 5, 30; 5, 315; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:ignore_patterns; 11, list:[
... | def collect(self):
self.ignore_patterns = [
'*.png', '*.jpg', '*.js', '*.gif', '*.ttf', '*.md', '*.rst',
'*.svg']
page_themes = PageTheme.objects.all()
for finder in get_finders():
for path, storage in finder.list(self.ignore_patterns):
for t i... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:urlpatterns; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 189; 6, expression_statement; 6, 7; 7, string:'''load and decorate urls from all modules
then store it as cached property for less loading
'''; 8, if... | def urlpatterns(self):
'''load and decorate urls from all modules
then store it as cached property for less loading
'''
if not hasattr(self, '_urlspatterns'):
urlpatterns = []
for mod in leonardo.modules:
if is_leonardo_module(mod):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:reverse; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:viewname; 5, default_parameter; 5, 6; 5, 7; 6, identifier:urlconf; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:args; 10, None; 11, default_parameter; 11, 12; 1... | def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None):
if not urlconf:
urlconf = get_urlconf()
resolver = get_resolver(urlconf)
args = args or []
kwargs = kwargs or {}
prefix = get_script_prefix()
if not isinstance(viewname, six.string_types):
view = viewn... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:process_response; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, identifier:response; 7, block; 7, 8; 7, 174; 8, if_statement; 8, 9; 8, 20; 9, boolean_operator:and; 9, 10; 9, 15; 10, call; 10, 11; 10, 14; 11, att... | def process_response(self, request, response):
if request.is_ajax() and hasattr(request, 'horizon'):
queued_msgs = request.horizon['async_messages']
if type(response) == http.HttpResponseRedirect:
for tag, message, extra_tags in queued_msgs:
getattr(dj... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:process_exception; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:request; 6, identifier:exception; 7, block; 7, 8; 7, 182; 7, 198; 8, if_statement; 8, 9; 8, 20; 9, call; 9, 10; 9, 11; 10, identifier:isinstance; 11, argument... | def process_exception(self, request, exception):
if isinstance(exception, (exceptions.NotAuthorized,
exceptions.NotAuthenticated)):
auth_url = settings.LOGIN_URL
next_url = None
if request.method in ("POST", "PUT"):
referrer =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.