labNo
float64
1
10
taskNo
float64
0
4
questioner
stringclasses
2 values
question
stringlengths
9
201
code
stringlengths
18
30.3k
startLine
float64
0
192
endLine
float64
0
196
questionType
stringclasses
4 values
answer
stringlengths
2
905
src
stringclasses
3 values
code_processed
stringlengths
12
28.3k
id
stringlengths
2
5
raw_code
stringlengths
20
30.3k
raw_comment
stringlengths
10
242
comment
stringlengths
9
207
q_code
stringlengths
66
30.3k
null
null
null
What does this function do?
def _deduplicate_loggers(loggers): return ('{}:{}'.format(logger, level) for (logger, level) in dict((it.split(':') for it in loggers)).iteritems())
null
null
null
Avoid saving multiple logging levels for the same loggers to a save file, that just takes space and the list can potentially grow unbounded if for some odd reason people use :option`--save`` all the time.
pcsd
def deduplicate loggers loggers return '{} {}' format logger level for logger level in dict it split ' ' for it in loggers iteritems
9279
def _deduplicate_loggers(loggers): return ('{}:{}'.format(logger, level) for (logger, level) in dict((it.split(':') for it in loggers)).iteritems())
Avoid saving multiple logging levels for the same loggers to a save file, that just takes space and the list can potentially grow unbounded if for some odd reason people use :option`--save`` all the time.
avoid saving multiple logging levels for the same loggers to a save file , that just takes space and the list can potentially grow unbounded if for some odd reason people use : option - - save all the time .
Question: What does this function do? Code: def _deduplicate_loggers(loggers): return ('{}:{}'.format(logger, level) for (logger, level) in dict((it.split(':') for it in loggers)).iteritems())
null
null
null
What does this function do?
def delete_exploration_summary(exploration_id): exp_models.ExpSummaryModel.get(exploration_id).delete()
null
null
null
Delete an exploration summary model.
pcsd
def delete exploration summary exploration id exp models Exp Summary Model get exploration id delete
9280
def delete_exploration_summary(exploration_id): exp_models.ExpSummaryModel.get(exploration_id).delete()
Delete an exploration summary model.
delete an exploration summary model .
Question: What does this function do? Code: def delete_exploration_summary(exploration_id): exp_models.ExpSummaryModel.get(exploration_id).delete()
null
null
null
What does this function do?
@pytest.mark.parametrize(u'mode', modes) def test_gaussian_eval_2D(mode): model = Gaussian2D(1, 0, 0, 20, 20) x = np.arange((-100), 101) y = np.arange((-100), 101) (x, y) = np.meshgrid(x, y) values = model(x, y) disc_values = discretize_model(model, ((-100), 101), ((-100), 101), mode=mode) assert_allclose(values...
null
null
null
Discretize Gaussian with different modes and check if result is at least similar to Gaussian1D.eval()
pcsd
@pytest mark parametrize u'mode' modes def test gaussian eval 2D mode model = Gaussian2D 1 0 0 20 20 x = np arange -100 101 y = np arange -100 101 x y = np meshgrid x y values = model x y disc values = discretize model model -100 101 -100 101 mode=mode assert allclose values disc values atol=0 001
9285
@pytest.mark.parametrize(u'mode', modes) def test_gaussian_eval_2D(mode): model = Gaussian2D(1, 0, 0, 20, 20) x = np.arange((-100), 101) y = np.arange((-100), 101) (x, y) = np.meshgrid(x, y) values = model(x, y) disc_values = discretize_model(model, ((-100), 101), ((-100), 101), mode=mode) assert_allclose(values...
Discretize Gaussian with different modes and check if result is at least similar to Gaussian1D.eval()
discretize gaussian with different modes and check if result is at least similar to gaussian1d . eval ( )
Question: What does this function do? Code: @pytest.mark.parametrize(u'mode', modes) def test_gaussian_eval_2D(mode): model = Gaussian2D(1, 0, 0, 20, 20) x = np.arange((-100), 101) y = np.arange((-100), 101) (x, y) = np.meshgrid(x, y) values = model(x, y) disc_values = discretize_model(model, ((-100), 101), ((...
null
null
null
What does this function do?
def remove_bgp_config(net_connect, cmd='no router bgp', as_number=''): bgp_cmd = '{} {}'.format(cmd, str(as_number)) cmd_list = [bgp_cmd] output = net_connect.send_config_set(cmd_list) if (net_connect.device_type == 'cisco_xr_ssh'): output += net_connect.commit() print output
null
null
null
Remove BGP from the config
pcsd
def remove bgp config net connect cmd='no router bgp' as number='' bgp cmd = '{} {}' format cmd str as number cmd list = [bgp cmd] output = net connect send config set cmd list if net connect device type == 'cisco xr ssh' output += net connect commit print output
9289
def remove_bgp_config(net_connect, cmd='no router bgp', as_number=''): bgp_cmd = '{} {}'.format(cmd, str(as_number)) cmd_list = [bgp_cmd] output = net_connect.send_config_set(cmd_list) if (net_connect.device_type == 'cisco_xr_ssh'): output += net_connect.commit() print output
Remove BGP from the config
remove bgp from the config
Question: What does this function do? Code: def remove_bgp_config(net_connect, cmd='no router bgp', as_number=''): bgp_cmd = '{} {}'.format(cmd, str(as_number)) cmd_list = [bgp_cmd] output = net_connect.send_config_set(cmd_list) if (net_connect.device_type == 'cisco_xr_ssh'): output += net_connect.commit() pr...
null
null
null
What does this function do?
def convert_remote_torrent_to_json(torrent): torrent_name = torrent['name'] if ((torrent_name is None) or (len(torrent_name.strip()) == 0)): torrent_name = 'Unnamed torrent' relevance_score = relevance_score_remote_torrent(torrent_name) return {'id': torrent['torrent_id'], 'infohash': torrent['infohash'].encode('...
null
null
null
This method converts a torrent that has been received by remote peers in the network to a JSON dictionary.
pcsd
def convert remote torrent to json torrent torrent name = torrent['name'] if torrent name is None or len torrent name strip == 0 torrent name = 'Unnamed torrent' relevance score = relevance score remote torrent torrent name return {'id' torrent['torrent id'] 'infohash' torrent['infohash'] encode 'hex' 'name' torrent na...
9290
def convert_remote_torrent_to_json(torrent): torrent_name = torrent['name'] if ((torrent_name is None) or (len(torrent_name.strip()) == 0)): torrent_name = 'Unnamed torrent' relevance_score = relevance_score_remote_torrent(torrent_name) return {'id': torrent['torrent_id'], 'infohash': torrent['infohash'].encode('...
This method converts a torrent that has been received by remote peers in the network to a JSON dictionary.
this method converts a torrent that has been received by remote peers in the network to a json dictionary .
Question: What does this function do? Code: def convert_remote_torrent_to_json(torrent): torrent_name = torrent['name'] if ((torrent_name is None) or (len(torrent_name.strip()) == 0)): torrent_name = 'Unnamed torrent' relevance_score = relevance_score_remote_torrent(torrent_name) return {'id': torrent['torrent...
null
null
null
What does this function do?
def get_objects(si, args): datacenter_list = si.content.rootFolder.childEntity if args.datacenter_name: datacenter_obj = get_obj_in_list(args.datacenter_name, datacenter_list) else: datacenter_obj = datacenter_list[0] datastore_list = datacenter_obj.datastoreFolder.childEntity if args.datastore_name: datasto...
null
null
null
Return a dict containing the necessary objects for deployment.
pcsd
def get objects si args datacenter list = si content root Folder child Entity if args datacenter name datacenter obj = get obj in list args datacenter name datacenter list else datacenter obj = datacenter list[0] datastore list = datacenter obj datastore Folder child Entity if args datastore name datastore obj = get ob...
9292
def get_objects(si, args): datacenter_list = si.content.rootFolder.childEntity if args.datacenter_name: datacenter_obj = get_obj_in_list(args.datacenter_name, datacenter_list) else: datacenter_obj = datacenter_list[0] datastore_list = datacenter_obj.datastoreFolder.childEntity if args.datastore_name: datasto...
Return a dict containing the necessary objects for deployment.
return a dict containing the necessary objects for deployment .
Question: What does this function do? Code: def get_objects(si, args): datacenter_list = si.content.rootFolder.childEntity if args.datacenter_name: datacenter_obj = get_obj_in_list(args.datacenter_name, datacenter_list) else: datacenter_obj = datacenter_list[0] datastore_list = datacenter_obj.datastoreFolder...
null
null
null
What does this function do?
@frappe.whitelist() def unzip_file(name): file_obj = frappe.get_doc(u'File', name) file_obj.unzip()
null
null
null
Unzip the given file and make file records for each of the extracted files
pcsd
@frappe whitelist def unzip file name file obj = frappe get doc u'File' name file obj unzip
9302
@frappe.whitelist() def unzip_file(name): file_obj = frappe.get_doc(u'File', name) file_obj.unzip()
Unzip the given file and make file records for each of the extracted files
unzip the given file and make file records for each of the extracted files
Question: What does this function do? Code: @frappe.whitelist() def unzip_file(name): file_obj = frappe.get_doc(u'File', name) file_obj.unzip()
null
null
null
What does this function do?
@handle_response_format @treeio_login_required @_process_mass_form def index_owned(request, response_format='html'): query = (Q(object__in=Object.filter_by_request(request, Object.objects)) & Q(author=request.user.profile)) if request.GET: query = (query & _get_filter_query(request.GET)) filters = FilterForm(requ...
null
null
null
Change Control owned by me page
pcsd
@handle response format @treeio login required @ process mass form def index owned request response format='html' query = Q object in=Object filter by request request Object objects & Q author=request user profile if request GET query = query & get filter query request GET filters = Filter Form request user profile 'au...
9304
@handle_response_format @treeio_login_required @_process_mass_form def index_owned(request, response_format='html'): query = (Q(object__in=Object.filter_by_request(request, Object.objects)) & Q(author=request.user.profile)) if request.GET: query = (query & _get_filter_query(request.GET)) filters = FilterForm(requ...
Change Control owned by me page
change control owned by me page
Question: What does this function do? Code: @handle_response_format @treeio_login_required @_process_mass_form def index_owned(request, response_format='html'): query = (Q(object__in=Object.filter_by_request(request, Object.objects)) & Q(author=request.user.profile)) if request.GET: query = (query & _get_filter_...
null
null
null
What does this function do?
def present(name, character_set=None, collate=None, **connection_args): ret = {'name': name, 'changes': {}, 'result': True, 'comment': 'Database {0} is already present'.format(name)} existing = __salt__['mysql.db_get'](name, **connection_args) if existing: alter = False if (character_set and (character_set != ex...
null
null
null
Ensure that the named database is present with the specified properties name The name of the database to manage
pcsd
def present name character set=None collate=None **connection args ret = {'name' name 'changes' {} 'result' True 'comment' 'Database {0} is already present' format name } existing = salt ['mysql db get'] name **connection args if existing alter = False if character set and character set != existing get 'character set' ...
9307
def present(name, character_set=None, collate=None, **connection_args): ret = {'name': name, 'changes': {}, 'result': True, 'comment': 'Database {0} is already present'.format(name)} existing = __salt__['mysql.db_get'](name, **connection_args) if existing: alter = False if (character_set and (character_set != ex...
Ensure that the named database is present with the specified properties name The name of the database to manage
ensure that the named database is present with the specified properties name
Question: What does this function do? Code: def present(name, character_set=None, collate=None, **connection_args): ret = {'name': name, 'changes': {}, 'result': True, 'comment': 'Database {0} is already present'.format(name)} existing = __salt__['mysql.db_get'](name, **connection_args) if existing: alter = Fal...
null
null
null
What does this function do?
def extend_data(data, length, offset): if (length >= offset): new_data = (data[(- offset):] * (alignValue(length, offset) // offset)) return (data + new_data[:length]) else: return (data + data[(- offset):((- offset) + length)])
null
null
null
Extend data using a length and an offset.
pcsd
def extend data data length offset if length >= offset new data = data[ - offset ] * align Value length offset // offset return data + new data[ length] else return data + data[ - offset - offset + length ]
9314
def extend_data(data, length, offset): if (length >= offset): new_data = (data[(- offset):] * (alignValue(length, offset) // offset)) return (data + new_data[:length]) else: return (data + data[(- offset):((- offset) + length)])
Extend data using a length and an offset.
extend data using a length and an offset .
Question: What does this function do? Code: def extend_data(data, length, offset): if (length >= offset): new_data = (data[(- offset):] * (alignValue(length, offset) // offset)) return (data + new_data[:length]) else: return (data + data[(- offset):((- offset) + length)])
null
null
null
What does this function do?
@curry def leaves_of_type(types, expr): if (not isinstance(expr, types)): return set([expr]) else: return set.union(*map(leaves_of_type(types), expr._inputs))
null
null
null
Leaves of an expression skipping all operations of type ``types``
pcsd
@curry def leaves of type types expr if not isinstance expr types return set [expr] else return set union *map leaves of type types expr inputs
9317
@curry def leaves_of_type(types, expr): if (not isinstance(expr, types)): return set([expr]) else: return set.union(*map(leaves_of_type(types), expr._inputs))
Leaves of an expression skipping all operations of type ``types``
leaves of an expression skipping all operations of type types
Question: What does this function do? Code: @curry def leaves_of_type(types, expr): if (not isinstance(expr, types)): return set([expr]) else: return set.union(*map(leaves_of_type(types), expr._inputs))
null
null
null
What does this function do?
def _translate_volume_summary_view(context, vol): d = {} d['id'] = vol['id'] d['status'] = vol['status'] d['size'] = vol['size'] d['availabilityZone'] = vol['availability_zone'] d['createdAt'] = vol['created_at'] if (vol['attach_status'] == 'attached'): d['attachments'] = [_translate_attachment_detail_view(vol...
null
null
null
Maps keys for volumes summary view.
pcsd
def translate volume summary view context vol d = {} d['id'] = vol['id'] d['status'] = vol['status'] d['size'] = vol['size'] d['availability Zone'] = vol['availability zone'] d['created At'] = vol['created at'] if vol['attach status'] == 'attached' d['attachments'] = [ translate attachment detail view vol['id'] vol['in...
9321
def _translate_volume_summary_view(context, vol): d = {} d['id'] = vol['id'] d['status'] = vol['status'] d['size'] = vol['size'] d['availabilityZone'] = vol['availability_zone'] d['createdAt'] = vol['created_at'] if (vol['attach_status'] == 'attached'): d['attachments'] = [_translate_attachment_detail_view(vol...
Maps keys for volumes summary view.
maps keys for volumes summary view .
Question: What does this function do? Code: def _translate_volume_summary_view(context, vol): d = {} d['id'] = vol['id'] d['status'] = vol['status'] d['size'] = vol['size'] d['availabilityZone'] = vol['availability_zone'] d['createdAt'] = vol['created_at'] if (vol['attach_status'] == 'attached'): d['attachm...
null
null
null
What does this function do?
def _conv_comp(comp, first, last, chs): ccomp = dict(ctfkind=np.array([comp[first]['coeff_type']]), save_calibrated=False) _add_kind(ccomp) n_col = comp[first]['ncoeff'] n_row = ((last - first) + 1) col_names = comp[first]['sensors'][:n_col] row_names = [comp[p]['sensor_name'] for p in range(first, (last + 1))] ...
null
null
null
Add a new converted compensation data item.
pcsd
def conv comp comp first last chs ccomp = dict ctfkind=np array [comp[first]['coeff type']] save calibrated=False add kind ccomp n col = comp[first]['ncoeff'] n row = last - first + 1 col names = comp[first]['sensors'][ n col] row names = [comp[p]['sensor name'] for p in range first last + 1 ] data = np empty n row n c...
9324
def _conv_comp(comp, first, last, chs): ccomp = dict(ctfkind=np.array([comp[first]['coeff_type']]), save_calibrated=False) _add_kind(ccomp) n_col = comp[first]['ncoeff'] n_row = ((last - first) + 1) col_names = comp[first]['sensors'][:n_col] row_names = [comp[p]['sensor_name'] for p in range(first, (last + 1))] ...
Add a new converted compensation data item.
add a new converted compensation data item .
Question: What does this function do? Code: def _conv_comp(comp, first, last, chs): ccomp = dict(ctfkind=np.array([comp[first]['coeff_type']]), save_calibrated=False) _add_kind(ccomp) n_col = comp[first]['ncoeff'] n_row = ((last - first) + 1) col_names = comp[first]['sensors'][:n_col] row_names = [comp[p]['sen...
null
null
null
What does this function do?
def replaceBads(s): bads = [' ', '(', ')'] x = s for bad in bads: x = x.replace(bad, '_') return x
null
null
null
Replaces bad characters with good characters!
pcsd
def replace Bads s bads = [' ' ' ' ' '] x = s for bad in bads x = x replace bad ' ' return x
9325
def replaceBads(s): bads = [' ', '(', ')'] x = s for bad in bads: x = x.replace(bad, '_') return x
Replaces bad characters with good characters!
replaces bad characters with good characters !
Question: What does this function do? Code: def replaceBads(s): bads = [' ', '(', ')'] x = s for bad in bads: x = x.replace(bad, '_') return x
null
null
null
What does this function do?
def dojs(dogis=False, warnings=True): use_compressor = 'jsmin' try: import closure use_compressor = 'closure' print 'using local Closure Compiler' except Exception as E: print ('No closure (%s)' % E) print 'Download from http://closure-compiler.googlecode.com/files/compiler-latest.zip' try: import clo...
null
null
null
Minifies the JavaScript
pcsd
def dojs dogis=False warnings=True use compressor = 'jsmin' try import closure use compressor = 'closure' print 'using local Closure Compiler' except Exception as E print 'No closure %s ' % E print 'Download from http //closure-compiler googlecode com/files/compiler-latest zip' try import closure ws use compressor = 'c...
9327
def dojs(dogis=False, warnings=True): use_compressor = 'jsmin' try: import closure use_compressor = 'closure' print 'using local Closure Compiler' except Exception as E: print ('No closure (%s)' % E) print 'Download from http://closure-compiler.googlecode.com/files/compiler-latest.zip' try: import clo...
Minifies the JavaScript
minifies the javascript
Question: What does this function do? Code: def dojs(dogis=False, warnings=True): use_compressor = 'jsmin' try: import closure use_compressor = 'closure' print 'using local Closure Compiler' except Exception as E: print ('No closure (%s)' % E) print 'Download from http://closure-compiler.googlecode.com/...
null
null
null
What does this function do?
def download_mission(): cmds = vehicle.commands cmds.download() cmds.wait_ready()
null
null
null
Download the current mission from the vehicle.
pcsd
def download mission cmds = vehicle commands cmds download cmds wait ready
9344
def download_mission(): cmds = vehicle.commands cmds.download() cmds.wait_ready()
Download the current mission from the vehicle.
download the current mission from the vehicle .
Question: What does this function do? Code: def download_mission(): cmds = vehicle.commands cmds.download() cmds.wait_ready()
null
null
null
What does this function do?
@register.inclusion_tag(u'admin/pagination.html') def pagination(cl): (paginator, page_num) = (cl.paginator, cl.page_num) pagination_required = (((not cl.show_all) or (not cl.can_show_all)) and cl.multi_page) if (not pagination_required): page_range = [] else: ON_EACH_SIDE = 3 ON_ENDS = 2 if (paginator.num_...
null
null
null
Generates the series of links to the pages in a paginated list.
pcsd
@register inclusion tag u'admin/pagination html' def pagination cl paginator page num = cl paginator cl page num pagination required = not cl show all or not cl can show all and cl multi page if not pagination required page range = [] else ON EACH SIDE = 3 ON ENDS = 2 if paginator num pages <= 10 page range = range pag...
9349
@register.inclusion_tag(u'admin/pagination.html') def pagination(cl): (paginator, page_num) = (cl.paginator, cl.page_num) pagination_required = (((not cl.show_all) or (not cl.can_show_all)) and cl.multi_page) if (not pagination_required): page_range = [] else: ON_EACH_SIDE = 3 ON_ENDS = 2 if (paginator.num_...
Generates the series of links to the pages in a paginated list.
generates the series of links to the pages in a paginated list .
Question: What does this function do? Code: @register.inclusion_tag(u'admin/pagination.html') def pagination(cl): (paginator, page_num) = (cl.paginator, cl.page_num) pagination_required = (((not cl.show_all) or (not cl.can_show_all)) and cl.multi_page) if (not pagination_required): page_range = [] else: ON_E...
null
null
null
What does this function do?
def import_set(dset, in_stream, headers=True): dset.wipe() if is_py3: rows = csv.reader(in_stream.splitlines(), delimiter=' DCTB ') else: rows = csv.reader(in_stream.splitlines(), delimiter=' DCTB ', encoding=DEFAULT_ENCODING) for (i, row) in enumerate(rows): if (not row): continue if ((i == 0) and heade...
null
null
null
Returns dataset from TSV stream.
pcsd
def import set dset in stream headers=True dset wipe if is py3 rows = csv reader in stream splitlines delimiter=' DCTB ' else rows = csv reader in stream splitlines delimiter=' DCTB ' encoding=DEFAULT ENCODING for i row in enumerate rows if not row continue if i == 0 and headers dset headers = row else dset append row
9358
def import_set(dset, in_stream, headers=True): dset.wipe() if is_py3: rows = csv.reader(in_stream.splitlines(), delimiter=' DCTB ') else: rows = csv.reader(in_stream.splitlines(), delimiter=' DCTB ', encoding=DEFAULT_ENCODING) for (i, row) in enumerate(rows): if (not row): continue if ((i == 0) and heade...
Returns dataset from TSV stream.
returns dataset from tsv stream .
Question: What does this function do? Code: def import_set(dset, in_stream, headers=True): dset.wipe() if is_py3: rows = csv.reader(in_stream.splitlines(), delimiter=' DCTB ') else: rows = csv.reader(in_stream.splitlines(), delimiter=' DCTB ', encoding=DEFAULT_ENCODING) for (i, row) in enumerate(rows): if ...
null
null
null
What does this function do?
def make_callable_template(key, typer, recvr=None): def generic(self): return typer name = ('%s_CallableTemplate' % (key,)) bases = (CallableTemplate,) class_dict = dict(key=key, generic=generic, recvr=recvr) return type(name, bases, class_dict)
null
null
null
Create a callable template with the given key and typer function.
pcsd
def make callable template key typer recvr=None def generic self return typer name = '%s Callable Template' % key bases = Callable Template class dict = dict key=key generic=generic recvr=recvr return type name bases class dict
9363
def make_callable_template(key, typer, recvr=None): def generic(self): return typer name = ('%s_CallableTemplate' % (key,)) bases = (CallableTemplate,) class_dict = dict(key=key, generic=generic, recvr=recvr) return type(name, bases, class_dict)
Create a callable template with the given key and typer function.
create a callable template with the given key and typer function .
Question: What does this function do? Code: def make_callable_template(key, typer, recvr=None): def generic(self): return typer name = ('%s_CallableTemplate' % (key,)) bases = (CallableTemplate,) class_dict = dict(key=key, generic=generic, recvr=recvr) return type(name, bases, class_dict)
null
null
null
What does this function do?
def update_contenttypes(app, created_models, verbosity=2, **kwargs): ContentType.objects.clear_cache() app_models = get_models(app) if (not app_models): return app_label = app_models[0]._meta.app_label app_models = dict(((model._meta.object_name.lower(), model) for model in app_models)) content_types = dict(((c...
null
null
null
Creates content types for models in the given app, removing any model entries that no longer have a matching model class.
pcsd
def update contenttypes app created models verbosity=2 **kwargs Content Type objects clear cache app models = get models app if not app models return app label = app models[0] meta app label app models = dict model meta object name lower model for model in app models content types = dict ct model ct for ct in Content T...
9365
def update_contenttypes(app, created_models, verbosity=2, **kwargs): ContentType.objects.clear_cache() app_models = get_models(app) if (not app_models): return app_label = app_models[0]._meta.app_label app_models = dict(((model._meta.object_name.lower(), model) for model in app_models)) content_types = dict(((c...
Creates content types for models in the given app, removing any model entries that no longer have a matching model class.
creates content types for models in the given app , removing any model entries that no longer have a matching model class .
Question: What does this function do? Code: def update_contenttypes(app, created_models, verbosity=2, **kwargs): ContentType.objects.clear_cache() app_models = get_models(app) if (not app_models): return app_label = app_models[0]._meta.app_label app_models = dict(((model._meta.object_name.lower(), model) for ...
null
null
null
What does this function do?
def verify(cypher, key): return gluechops(cypher, key['e'], key['n'], encrypt_int)
null
null
null
Verifies a cypher with the public key \'key\'
pcsd
def verify cypher key return gluechops cypher key['e'] key['n'] encrypt int
9367
def verify(cypher, key): return gluechops(cypher, key['e'], key['n'], encrypt_int)
Verifies a cypher with the public key \'key\'
verifies a cypher with the public key key
Question: What does this function do? Code: def verify(cypher, key): return gluechops(cypher, key['e'], key['n'], encrypt_int)
null
null
null
What does this function do?
def dict_from_expr(expr, **args): (rep, opt) = _dict_from_expr(expr, build_options(args)) return (rep, opt.gens)
null
null
null
Transform an expression into a multinomial form.
pcsd
def dict from expr expr **args rep opt = dict from expr expr build options args return rep opt gens
9377
def dict_from_expr(expr, **args): (rep, opt) = _dict_from_expr(expr, build_options(args)) return (rep, opt.gens)
Transform an expression into a multinomial form.
transform an expression into a multinomial form .
Question: What does this function do? Code: def dict_from_expr(expr, **args): (rep, opt) = _dict_from_expr(expr, build_options(args)) return (rep, opt.gens)
null
null
null
What does this function do?
def _int_to_json(value): if isinstance(value, int): value = str(value) return value
null
null
null
Coerce \'value\' to an JSON-compatible representation.
pcsd
def int to json value if isinstance value int value = str value return value
9379
def _int_to_json(value): if isinstance(value, int): value = str(value) return value
Coerce \'value\' to an JSON-compatible representation.
coerce value to an json - compatible representation .
Question: What does this function do? Code: def _int_to_json(value): if isinstance(value, int): value = str(value) return value
null
null
null
What does this function do?
def _upgrade(fields, sig): sig.update(chord_size=fields.get(u'chord_size')) return sig
null
null
null
Used by custom signatures in .from_dict, to keep common fields.
pcsd
def upgrade fields sig sig update chord size=fields get u'chord size' return sig
9388
def _upgrade(fields, sig): sig.update(chord_size=fields.get(u'chord_size')) return sig
Used by custom signatures in .from_dict, to keep common fields.
used by custom signatures in . from _ dict , to keep common fields .
Question: What does this function do? Code: def _upgrade(fields, sig): sig.update(chord_size=fields.get(u'chord_size')) return sig
null
null
null
What does this function do?
def _get_info(eeg, montage, eog=()): info = _empty_info(sfreq=eeg.srate) path = None if ((not isinstance(eeg.chanlocs, np.ndarray)) and (eeg.nbchan == 1)): eeg.chanlocs = [eeg.chanlocs] if (len(eeg.chanlocs) > 0): (ch_names, pos) = (list(), list()) kind = 'user_defined' selection = np.arange(len(eeg.chanloc...
null
null
null
Get measurement info.
pcsd
def get info eeg montage eog= info = empty info sfreq=eeg srate path = None if not isinstance eeg chanlocs np ndarray and eeg nbchan == 1 eeg chanlocs = [eeg chanlocs] if len eeg chanlocs > 0 ch names pos = list list kind = 'user defined' selection = np arange len eeg chanlocs locs available = True for chanloc in eeg c...
9392
def _get_info(eeg, montage, eog=()): info = _empty_info(sfreq=eeg.srate) path = None if ((not isinstance(eeg.chanlocs, np.ndarray)) and (eeg.nbchan == 1)): eeg.chanlocs = [eeg.chanlocs] if (len(eeg.chanlocs) > 0): (ch_names, pos) = (list(), list()) kind = 'user_defined' selection = np.arange(len(eeg.chanloc...
Get measurement info.
get measurement info .
Question: What does this function do? Code: def _get_info(eeg, montage, eog=()): info = _empty_info(sfreq=eeg.srate) path = None if ((not isinstance(eeg.chanlocs, np.ndarray)) and (eeg.nbchan == 1)): eeg.chanlocs = [eeg.chanlocs] if (len(eeg.chanlocs) > 0): (ch_names, pos) = (list(), list()) kind = 'user_d...
null
null
null
What does this function do?
def _write_file(iface, data, folder, pattern): filename = os.path.join(folder, pattern.format(iface)) if (not os.path.exists(folder)): msg = '{0} cannot be written. {1} does not exist' msg = msg.format(filename, folder) log.error(msg) raise AttributeError(msg) with salt.utils.flopen(filename, 'w') as fout: ...
null
null
null
Writes a file to disk
pcsd
def write file iface data folder pattern filename = os path join folder pattern format iface if not os path exists folder msg = '{0} cannot be written {1} does not exist' msg = msg format filename folder log error msg raise Attribute Error msg with salt utils flopen filename 'w' as fout fout write data return filename
9398
def _write_file(iface, data, folder, pattern): filename = os.path.join(folder, pattern.format(iface)) if (not os.path.exists(folder)): msg = '{0} cannot be written. {1} does not exist' msg = msg.format(filename, folder) log.error(msg) raise AttributeError(msg) with salt.utils.flopen(filename, 'w') as fout: ...
Writes a file to disk
writes a file to disk
Question: What does this function do? Code: def _write_file(iface, data, folder, pattern): filename = os.path.join(folder, pattern.format(iface)) if (not os.path.exists(folder)): msg = '{0} cannot be written. {1} does not exist' msg = msg.format(filename, folder) log.error(msg) raise AttributeError(msg) w...
null
null
null
What does this function do?
def _read_comp_coeff(fid, d): d['ncomp'] = _read_int2(fid) d['comp'] = list() for k in range(d['ncomp']): comp = dict() d['comp'].append(comp) comp['sensor_name'] = _read_string(fid, 32) comp['coeff_type'] = _read_int(fid) _read_int(fid) comp['ncoeff'] = _read_int2(fid) comp['coeffs'] = np.zeros(comp['...
null
null
null
Read compensation coefficients.
pcsd
def read comp coeff fid d d['ncomp'] = read int2 fid d['comp'] = list for k in range d['ncomp'] comp = dict d['comp'] append comp comp['sensor name'] = read string fid 32 comp['coeff type'] = read int fid read int fid comp['ncoeff'] = read int2 fid comp['coeffs'] = np zeros comp['ncoeff'] comp['sensors'] = [ read strin...
9403
def _read_comp_coeff(fid, d): d['ncomp'] = _read_int2(fid) d['comp'] = list() for k in range(d['ncomp']): comp = dict() d['comp'].append(comp) comp['sensor_name'] = _read_string(fid, 32) comp['coeff_type'] = _read_int(fid) _read_int(fid) comp['ncoeff'] = _read_int2(fid) comp['coeffs'] = np.zeros(comp['...
Read compensation coefficients.
read compensation coefficients .
Question: What does this function do? Code: def _read_comp_coeff(fid, d): d['ncomp'] = _read_int2(fid) d['comp'] = list() for k in range(d['ncomp']): comp = dict() d['comp'].append(comp) comp['sensor_name'] = _read_string(fid, 32) comp['coeff_type'] = _read_int(fid) _read_int(fid) comp['ncoeff'] = _re...
null
null
null
What does this function do?
def is_sparse(array): return isinstance(array, (ABCSparseArray, ABCSparseSeries))
null
null
null
return if we are a sparse array
pcsd
def is sparse array return isinstance array ABC Sparse Array ABC Sparse Series
9406
def is_sparse(array): return isinstance(array, (ABCSparseArray, ABCSparseSeries))
return if we are a sparse array
return if we are a sparse array
Question: What does this function do? Code: def is_sparse(array): return isinstance(array, (ABCSparseArray, ABCSparseSeries))
null
null
null
What does this function do?
def create_manifest(filename, manifest, console, uac_admin=False, uac_uiaccess=False): if (not manifest): manifest = ManifestFromXMLFile(filename) name = os.path.basename(filename) manifest.name = os.path.splitext(os.path.splitext(name)[0])[0] elif (isinstance(manifest, string_types) and ('<' in manifest)): m...
null
null
null
Create assembly manifest.
pcsd
def create manifest filename manifest console uac admin=False uac uiaccess=False if not manifest manifest = Manifest From XML File filename name = os path basename filename manifest name = os path splitext os path splitext name [0] [0] elif isinstance manifest string types and '<' in manifest manifest = Manifest From X...
9412
def create_manifest(filename, manifest, console, uac_admin=False, uac_uiaccess=False): if (not manifest): manifest = ManifestFromXMLFile(filename) name = os.path.basename(filename) manifest.name = os.path.splitext(os.path.splitext(name)[0])[0] elif (isinstance(manifest, string_types) and ('<' in manifest)): m...
Create assembly manifest.
create assembly manifest .
Question: What does this function do? Code: def create_manifest(filename, manifest, console, uac_admin=False, uac_uiaccess=False): if (not manifest): manifest = ManifestFromXMLFile(filename) name = os.path.basename(filename) manifest.name = os.path.splitext(os.path.splitext(name)[0])[0] elif (isinstance(mani...
null
null
null
What does this function do?
def read_torrent_name(torrent_file, default_name=None): try: with open(torrent_file, 'rb') as fp: torrent_info = bdecode(fp.read()) except IOError as e: logger.error('Unable to open torrent file: %s', torrent_file) return if torrent_info: try: return torrent_info['info']['name'] except KeyError: i...
null
null
null
Read the torrent file and return the torrent name. If the torrent name cannot be determined, it will return the `default_name`.
pcsd
def read torrent name torrent file default name=None try with open torrent file 'rb' as fp torrent info = bdecode fp read except IO Error as e logger error 'Unable to open torrent file %s' torrent file return if torrent info try return torrent info['info']['name'] except Key Error if default name logger warning "Couldn...
9413
def read_torrent_name(torrent_file, default_name=None): try: with open(torrent_file, 'rb') as fp: torrent_info = bdecode(fp.read()) except IOError as e: logger.error('Unable to open torrent file: %s', torrent_file) return if torrent_info: try: return torrent_info['info']['name'] except KeyError: i...
Read the torrent file and return the torrent name. If the torrent name cannot be determined, it will return the `default_name`.
read the torrent file and return the torrent name .
Question: What does this function do? Code: def read_torrent_name(torrent_file, default_name=None): try: with open(torrent_file, 'rb') as fp: torrent_info = bdecode(fp.read()) except IOError as e: logger.error('Unable to open torrent file: %s', torrent_file) return if torrent_info: try: return torre...
null
null
null
What does this function do?
def get_file_size(upload_file): return upload_file.size
null
null
null
Helper method for getting file size of an upload file. Can be used for mocking test file sizes.
pcsd
def get file size upload file return upload file size
9416
def get_file_size(upload_file): return upload_file.size
Helper method for getting file size of an upload file. Can be used for mocking test file sizes.
helper method for getting file size of an upload file .
Question: What does this function do? Code: def get_file_size(upload_file): return upload_file.size
null
null
null
What does this function do?
def absent(name): ret = {'changes': {}, 'comment': '', 'name': name, 'result': True} if (name not in __salt__['layman.list_local']()): ret['comment'] = 'Overlay {0} already absent'.format(name) elif __opts__['test']: ret['comment'] = 'Overlay {0} is set to be deleted'.format(name) ret['result'] = None return...
null
null
null
Verify that the overlay is absent name The name of the overlay to delete
pcsd
def absent name ret = {'changes' {} 'comment' '' 'name' name 'result' True} if name not in salt ['layman list local'] ret['comment'] = 'Overlay {0} already absent' format name elif opts ['test'] ret['comment'] = 'Overlay {0} is set to be deleted' format name ret['result'] = None return ret else changes = salt ['layman ...
9432
def absent(name): ret = {'changes': {}, 'comment': '', 'name': name, 'result': True} if (name not in __salt__['layman.list_local']()): ret['comment'] = 'Overlay {0} already absent'.format(name) elif __opts__['test']: ret['comment'] = 'Overlay {0} is set to be deleted'.format(name) ret['result'] = None return...
Verify that the overlay is absent name The name of the overlay to delete
verify that the overlay is absent name
Question: What does this function do? Code: def absent(name): ret = {'changes': {}, 'comment': '', 'name': name, 'result': True} if (name not in __salt__['layman.list_local']()): ret['comment'] = 'Overlay {0} already absent'.format(name) elif __opts__['test']: ret['comment'] = 'Overlay {0} is set to be delete...
null
null
null
What does this function do?
def consumer_oauth_url_request(backend, url, user_or_id, redirect_uri='/', json=True): user = UserSocialAuth.resolve_user_or_id(user_or_id) oauth_info = user.social_auth.filter(provider=backend.AUTH_BACKEND.name)[0] token = Token.from_string(oauth_info.tokens['access_token']) request = build_consumer_oauth_request(...
null
null
null
Builds and retrieves an OAuth signed response.
pcsd
def consumer oauth url request backend url user or id redirect uri='/' json=True user = User Social Auth resolve user or id user or id oauth info = user social auth filter provider=backend AUTH BACKEND name [0] token = Token from string oauth info tokens['access token'] request = build consumer oauth request backend to...
9434
def consumer_oauth_url_request(backend, url, user_or_id, redirect_uri='/', json=True): user = UserSocialAuth.resolve_user_or_id(user_or_id) oauth_info = user.social_auth.filter(provider=backend.AUTH_BACKEND.name)[0] token = Token.from_string(oauth_info.tokens['access_token']) request = build_consumer_oauth_request(...
Builds and retrieves an OAuth signed response.
builds and retrieves an oauth signed response .
Question: What does this function do? Code: def consumer_oauth_url_request(backend, url, user_or_id, redirect_uri='/', json=True): user = UserSocialAuth.resolve_user_or_id(user_or_id) oauth_info = user.social_auth.filter(provider=backend.AUTH_BACKEND.name)[0] token = Token.from_string(oauth_info.tokens['access_to...
null
null
null
What does this function do?
def encode(lst): io = cStringIO.StringIO() _i.transport = io _i.sendEncoded(lst) return io.getvalue()
null
null
null
Encode a list s-expression.
pcsd
def encode lst io = c String IO String IO i transport = io i send Encoded lst return io getvalue
9442
def encode(lst): io = cStringIO.StringIO() _i.transport = io _i.sendEncoded(lst) return io.getvalue()
Encode a list s-expression.
encode a list s - expression .
Question: What does this function do? Code: def encode(lst): io = cStringIO.StringIO() _i.transport = io _i.sendEncoded(lst) return io.getvalue()
null
null
null
What does this function do?
def get_input(msg): tmp = None try: tmp = raw_input(('[!] %s' % msg)) except: tmp = None return tmp
null
null
null
fetch user input and unify input prompts
pcsd
def get input msg tmp = None try tmp = raw input '[!] %s' % msg except tmp = None return tmp
9443
def get_input(msg): tmp = None try: tmp = raw_input(('[!] %s' % msg)) except: tmp = None return tmp
fetch user input and unify input prompts
fetch user input and unify input prompts
Question: What does this function do? Code: def get_input(msg): tmp = None try: tmp = raw_input(('[!] %s' % msg)) except: tmp = None return tmp
null
null
null
What does this function do?
def contains_one_of(*fields): message = 'Must contain any one of the following fields: {0}'.format(', '.join(fields)) def check_contains(endpoint_fields): for field in fields: if (field in endpoint_fields): return errors = {} for field in fields: errors[field] = 'one of these must have a value' retu...
null
null
null
Enables ensuring that one of multiple optional fields is set
pcsd
def contains one of *fields message = 'Must contain any one of the following fields {0}' format ' ' join fields def check contains endpoint fields for field in fields if field in endpoint fields return errors = {} for field in fields errors[field] = 'one of these must have a value' return errors check contains doc = me...
9446
def contains_one_of(*fields): message = 'Must contain any one of the following fields: {0}'.format(', '.join(fields)) def check_contains(endpoint_fields): for field in fields: if (field in endpoint_fields): return errors = {} for field in fields: errors[field] = 'one of these must have a value' retu...
Enables ensuring that one of multiple optional fields is set
enables ensuring that one of multiple optional fields is set
Question: What does this function do? Code: def contains_one_of(*fields): message = 'Must contain any one of the following fields: {0}'.format(', '.join(fields)) def check_contains(endpoint_fields): for field in fields: if (field in endpoint_fields): return errors = {} for field in fields: errors[f...
null
null
null
What does this function do?
def _normexpr(expr): textbuf = [] for part in expr.parts: if isinstance(part, six.string_types): textbuf.append(part) else: if textbuf: text = u''.join(textbuf) if text: (yield text) textbuf = [] (yield part) if textbuf: text = u''.join(textbuf) if text: (yield text)
null
null
null
Normalize an Expression object\'s parts, collapsing multiple adjacent text blocks and removing empty text blocks. Generates a sequence of parts.
pcsd
def normexpr expr textbuf = [] for part in expr parts if isinstance part six string types textbuf append part else if textbuf text = u'' join textbuf if text yield text textbuf = [] yield part if textbuf text = u'' join textbuf if text yield text
9450
def _normexpr(expr): textbuf = [] for part in expr.parts: if isinstance(part, six.string_types): textbuf.append(part) else: if textbuf: text = u''.join(textbuf) if text: (yield text) textbuf = [] (yield part) if textbuf: text = u''.join(textbuf) if text: (yield text)
Normalize an Expression object\'s parts, collapsing multiple adjacent text blocks and removing empty text blocks. Generates a sequence of parts.
normalize an expression objects parts , collapsing multiple adjacent text blocks and removing empty text blocks .
Question: What does this function do? Code: def _normexpr(expr): textbuf = [] for part in expr.parts: if isinstance(part, six.string_types): textbuf.append(part) else: if textbuf: text = u''.join(textbuf) if text: (yield text) textbuf = [] (yield part) if textbuf: text = u''.join(...
null
null
null
What does this function do?
def readInFilter(fname): filter = '' tmpfd = open(fname, 'r') for line in tmpfd: if ('#' in line): line = (line.split('#')[0] + '\n') filter += line tmpfd.close() return filter
null
null
null
Read in a BPF filter provided by a command line argument
pcsd
def read In Filter fname filter = '' tmpfd = open fname 'r' for line in tmpfd if '#' in line line = line split '#' [0] + ' ' filter += line tmpfd close return filter
9458
def readInFilter(fname): filter = '' tmpfd = open(fname, 'r') for line in tmpfd: if ('#' in line): line = (line.split('#')[0] + '\n') filter += line tmpfd.close() return filter
Read in a BPF filter provided by a command line argument
read in a bpf filter provided by a command line argument
Question: What does this function do? Code: def readInFilter(fname): filter = '' tmpfd = open(fname, 'r') for line in tmpfd: if ('#' in line): line = (line.split('#')[0] + '\n') filter += line tmpfd.close() return filter
null
null
null
What does this function do?
def cell_update(context, cell_name, values): return IMPL.cell_update(context, cell_name, values)
null
null
null
Update a child Cell entry.
pcsd
def cell update context cell name values return IMPL cell update context cell name values
9469
def cell_update(context, cell_name, values): return IMPL.cell_update(context, cell_name, values)
Update a child Cell entry.
update a child cell entry .
Question: What does this function do? Code: def cell_update(context, cell_name, values): return IMPL.cell_update(context, cell_name, values)
null
null
null
What does this function do?
def evaluate_filters(doc, filters): if isinstance(filters, dict): for (key, value) in filters.iteritems(): f = get_filter(None, {key: value}) if (not compare(doc.get(f.fieldname), f.operator, f.value)): return False elif isinstance(filters, (list, tuple)): for d in filters: f = get_filter(None, d) ...
null
null
null
Returns true if doc matches filters
pcsd
def evaluate filters doc filters if isinstance filters dict for key value in filters iteritems f = get filter None {key value} if not compare doc get f fieldname f operator f value return False elif isinstance filters list tuple for d in filters f = get filter None d if not compare doc get f fieldname f operator f valu...
9473
def evaluate_filters(doc, filters): if isinstance(filters, dict): for (key, value) in filters.iteritems(): f = get_filter(None, {key: value}) if (not compare(doc.get(f.fieldname), f.operator, f.value)): return False elif isinstance(filters, (list, tuple)): for d in filters: f = get_filter(None, d) ...
Returns true if doc matches filters
returns true if doc matches filters
Question: What does this function do? Code: def evaluate_filters(doc, filters): if isinstance(filters, dict): for (key, value) in filters.iteritems(): f = get_filter(None, {key: value}) if (not compare(doc.get(f.fieldname), f.operator, f.value)): return False elif isinstance(filters, (list, tuple)): ...
null
null
null
What does this function do?
def _check_origin(origin, info, coord_frame='head', disp=False): if isinstance(origin, string_types): if (origin != 'auto'): raise ValueError(('origin must be a numerical array, or "auto", not %s' % (origin,))) if (coord_frame == 'head'): (R, origin) = fit_sphere_to_headshape(info, verbose=False, units='m')[...
null
null
null
Check or auto-determine the origin.
pcsd
def check origin origin info coord frame='head' disp=False if isinstance origin string types if origin != 'auto' raise Value Error 'origin must be a numerical array or "auto" not %s' % origin if coord frame == 'head' R origin = fit sphere to headshape info verbose=False units='m' [ 2] logger info ' Automatic origin fit...
9475
def _check_origin(origin, info, coord_frame='head', disp=False): if isinstance(origin, string_types): if (origin != 'auto'): raise ValueError(('origin must be a numerical array, or "auto", not %s' % (origin,))) if (coord_frame == 'head'): (R, origin) = fit_sphere_to_headshape(info, verbose=False, units='m')[...
Check or auto-determine the origin.
check or auto - determine the origin .
Question: What does this function do? Code: def _check_origin(origin, info, coord_frame='head', disp=False): if isinstance(origin, string_types): if (origin != 'auto'): raise ValueError(('origin must be a numerical array, or "auto", not %s' % (origin,))) if (coord_frame == 'head'): (R, origin) = fit_spher...
null
null
null
What does this function do?
def list_networks(service_instance): return list_objects(service_instance, vim.Network)
null
null
null
Returns a list of networks associated with a given service instance. service_instance The Service Instance Object from which to obtain networks.
pcsd
def list networks service instance return list objects service instance vim Network
9476
def list_networks(service_instance): return list_objects(service_instance, vim.Network)
Returns a list of networks associated with a given service instance. service_instance The Service Instance Object from which to obtain networks.
returns a list of networks associated with a given service instance .
Question: What does this function do? Code: def list_networks(service_instance): return list_objects(service_instance, vim.Network)
null
null
null
What does this function do?
def patch_nsis(): RE_NSIS = re.compile('^(\\s*LangString\\s+\\w+\\s+\\$\\{LANG_)(\\w+)\\}\\s+(".*)', re.I) RE_NSIS = re.compile('^(\\s*LangString\\s+)(\\w+)(\\s+\\$\\{LANG_)(\\w+)\\}\\s+(".*)', re.I) languages = [os.path.split(path)[1] for path in glob.glob(os.path.join(MO_DIR, '*'))] src = open(NSIS, 'r') new = [...
null
null
null
Patch translation into the NSIS script
pcsd
def patch nsis RE NSIS = re compile '^ \\s*Lang String\\s+\\w+\\s+\\$\\{LANG \\w+ \\}\\s+ " * ' re I RE NSIS = re compile '^ \\s*Lang String\\s+ \\w+ \\s+\\$\\{LANG \\w+ \\}\\s+ " * ' re I languages = [os path split path [1] for path in glob glob os path join MO DIR '*' ] src = open NSIS 'r' new = [] for line in src m ...
9482
def patch_nsis(): RE_NSIS = re.compile('^(\\s*LangString\\s+\\w+\\s+\\$\\{LANG_)(\\w+)\\}\\s+(".*)', re.I) RE_NSIS = re.compile('^(\\s*LangString\\s+)(\\w+)(\\s+\\$\\{LANG_)(\\w+)\\}\\s+(".*)', re.I) languages = [os.path.split(path)[1] for path in glob.glob(os.path.join(MO_DIR, '*'))] src = open(NSIS, 'r') new = [...
Patch translation into the NSIS script
patch translation into the nsis script
Question: What does this function do? Code: def patch_nsis(): RE_NSIS = re.compile('^(\\s*LangString\\s+\\w+\\s+\\$\\{LANG_)(\\w+)\\}\\s+(".*)', re.I) RE_NSIS = re.compile('^(\\s*LangString\\s+)(\\w+)(\\s+\\$\\{LANG_)(\\w+)\\}\\s+(".*)', re.I) languages = [os.path.split(path)[1] for path in glob.glob(os.path.join...
null
null
null
What does this function do?
def authenhandler(req, **kwargs): os.environ.update(req.subprocess_env) _str_to_bool = (lambda s: (s.lower() in ('1', 'true', 'on', 'yes'))) options = req.get_options() permission_name = options.get('DjangoPermissionName', None) staff_only = _str_to_bool(options.get('DjangoRequireStaffStatus', 'on')) superuser_on...
null
null
null
Authentication handler that checks against Django\'s auth database.
pcsd
def authenhandler req **kwargs os environ update req subprocess env str to bool = lambda s s lower in '1' 'true' 'on' 'yes' options = req get options permission name = options get 'Django Permission Name' None staff only = str to bool options get 'Django Require Staff Status' 'on' superuser only = str to bool options g...
9484
def authenhandler(req, **kwargs): os.environ.update(req.subprocess_env) _str_to_bool = (lambda s: (s.lower() in ('1', 'true', 'on', 'yes'))) options = req.get_options() permission_name = options.get('DjangoPermissionName', None) staff_only = _str_to_bool(options.get('DjangoRequireStaffStatus', 'on')) superuser_on...
Authentication handler that checks against Django\'s auth database.
authentication handler that checks against djangos auth database .
Question: What does this function do? Code: def authenhandler(req, **kwargs): os.environ.update(req.subprocess_env) _str_to_bool = (lambda s: (s.lower() in ('1', 'true', 'on', 'yes'))) options = req.get_options() permission_name = options.get('DjangoPermissionName', None) staff_only = _str_to_bool(options.get('...
null
null
null
What does this function do?
def _register(event, handler): k = handler.__name__ setattr(cp.tools, k, cp.Tool(event, handler)) cp.config.update({('tools.%s.on' % k): True})
null
null
null
Registers the given event handler (e.g., "on_end_request").
pcsd
def register event handler k = handler name setattr cp tools k cp Tool event handler cp config update { 'tools %s on' % k True}
9486
def _register(event, handler): k = handler.__name__ setattr(cp.tools, k, cp.Tool(event, handler)) cp.config.update({('tools.%s.on' % k): True})
Registers the given event handler (e.g., "on_end_request").
registers the given event handler .
Question: What does this function do? Code: def _register(event, handler): k = handler.__name__ setattr(cp.tools, k, cp.Tool(event, handler)) cp.config.update({('tools.%s.on' % k): True})
null
null
null
What does this function do?
def get_relations(cursor, table_name): my_field_dict = _name_to_index(cursor, table_name) constraints = [] relations = {} try: cursor.execute('\n SELECT column_name, referenced_table_name, referenced_column_name\n FROM information_schema.key_column_usage\n WHERE table_name = %s\n ...
null
null
null
Returns a dictionary of {field_index: (field_index_other_table, other_table)} representing all relationships to the given table. Indexes are 0-based.
pcsd
def get relations cursor table name my field dict = name to index cursor table name constraints = [] relations = {} try cursor execute ' SELECT column name referenced table name referenced column name FROM information schema key column usage WHERE table name = %s AND table schema = DATABASE AND referenced table name IS...
9487
def get_relations(cursor, table_name): my_field_dict = _name_to_index(cursor, table_name) constraints = [] relations = {} try: cursor.execute('\n SELECT column_name, referenced_table_name, referenced_column_name\n FROM information_schema.key_column_usage\n WHERE table_name = %s\n ...
Returns a dictionary of {field_index: (field_index_other_table, other_table)} representing all relationships to the given table. Indexes are 0-based.
returns a dictionary of { field _ index : } representing all relationships to the given table .
Question: What does this function do? Code: def get_relations(cursor, table_name): my_field_dict = _name_to_index(cursor, table_name) constraints = [] relations = {} try: cursor.execute('\n SELECT column_name, referenced_table_name, referenced_column_name\n FROM information_schema.key_col...
null
null
null
What does this function do?
def _normalize_dir(string): return re.sub('\\\\$', '', string.lower())
null
null
null
Normalize the directory to make comparison possible
pcsd
def normalize dir string return re sub '\\\\$' '' string lower
9488
def _normalize_dir(string): return re.sub('\\\\$', '', string.lower())
Normalize the directory to make comparison possible
normalize the directory to make comparison possible
Question: What does this function do? Code: def _normalize_dir(string): return re.sub('\\\\$', '', string.lower())
null
null
null
What does this function do?
@utils.arg('image', metavar='<image>', help=_('Name or ID of image.')) @deprecated_image def do_image_show(cs, args): image = _find_image(cs, args.image) _print_image(image)
null
null
null
Show details about the given image.
pcsd
@utils arg 'image' metavar='<image>' help= 'Name or ID of image ' @deprecated image def do image show cs args image = find image cs args image print image image
9496
@utils.arg('image', metavar='<image>', help=_('Name or ID of image.')) @deprecated_image def do_image_show(cs, args): image = _find_image(cs, args.image) _print_image(image)
Show details about the given image.
show details about the given image .
Question: What does this function do? Code: @utils.arg('image', metavar='<image>', help=_('Name or ID of image.')) @deprecated_image def do_image_show(cs, args): image = _find_image(cs, args.image) _print_image(image)
null
null
null
What does this function do?
def _oneD_norm_2(a): raise NotImplementedError
null
null
null
Compute the L2-norm of 1D-array *a*.
pcsd
def one D norm 2 a raise Not Implemented Error
9498
def _oneD_norm_2(a): raise NotImplementedError
Compute the L2-norm of 1D-array *a*.
compute the l2 - norm of 1d - array * a * .
Question: What does this function do? Code: def _oneD_norm_2(a): raise NotImplementedError
null
null
null
What does this function do?
def compute_distance_matrix_from_metadata(column_data): data_row = array(column_data) data_col = reshape(data_row, (1, len(data_row))) dist_mtx = abs((data_row - data_col.T)) return dist_mtx
null
null
null
calculates distance matrix on a single column of a mapping file inputs: column_data (list of values)
pcsd
def compute distance matrix from metadata column data data row = array column data data col = reshape data row 1 len data row dist mtx = abs data row - data col T return dist mtx
9499
def compute_distance_matrix_from_metadata(column_data): data_row = array(column_data) data_col = reshape(data_row, (1, len(data_row))) dist_mtx = abs((data_row - data_col.T)) return dist_mtx
calculates distance matrix on a single column of a mapping file inputs: column_data (list of values)
calculates distance matrix on a single column of a mapping file inputs : column _ data
Question: What does this function do? Code: def compute_distance_matrix_from_metadata(column_data): data_row = array(column_data) data_col = reshape(data_row, (1, len(data_row))) dist_mtx = abs((data_row - data_col.T)) return dist_mtx
null
null
null
What does this function do?
def get_limited_to_project(headers): global _ENFORCER if (not _ENFORCER): _ENFORCER = policy.Enforcer() if (not _ENFORCER.enforce('context_is_admin', {}, {'roles': headers.get('X-Roles', '').split(',')})): return headers.get('X-Tenant-Id')
null
null
null
Return the tenant the request should be limited to.
pcsd
def get limited to project headers global ENFORCER if not ENFORCER ENFORCER = policy Enforcer if not ENFORCER enforce 'context is admin' {} {'roles' headers get 'X-Roles' '' split ' ' } return headers get 'X-Tenant-Id'
9501
def get_limited_to_project(headers): global _ENFORCER if (not _ENFORCER): _ENFORCER = policy.Enforcer() if (not _ENFORCER.enforce('context_is_admin', {}, {'roles': headers.get('X-Roles', '').split(',')})): return headers.get('X-Tenant-Id')
Return the tenant the request should be limited to.
return the tenant the request should be limited to .
Question: What does this function do? Code: def get_limited_to_project(headers): global _ENFORCER if (not _ENFORCER): _ENFORCER = policy.Enforcer() if (not _ENFORCER.enforce('context_is_admin', {}, {'roles': headers.get('X-Roles', '').split(',')})): return headers.get('X-Tenant-Id')
null
null
null
What does this function do?
def _write_conf(conf, path=MAIN_CF): with salt.utils.fopen(path, 'w') as fh_: for line in conf: if isinstance(line, dict): fh_.write(' '.join(line)) else: fh_.write(line) fh_.write('\n')
null
null
null
Write out configuration file.
pcsd
def write conf conf path=MAIN CF with salt utils fopen path 'w' as fh for line in conf if isinstance line dict fh write ' ' join line else fh write line fh write ' '
9512
def _write_conf(conf, path=MAIN_CF): with salt.utils.fopen(path, 'w') as fh_: for line in conf: if isinstance(line, dict): fh_.write(' '.join(line)) else: fh_.write(line) fh_.write('\n')
Write out configuration file.
write out configuration file .
Question: What does this function do? Code: def _write_conf(conf, path=MAIN_CF): with salt.utils.fopen(path, 'w') as fh_: for line in conf: if isinstance(line, dict): fh_.write(' '.join(line)) else: fh_.write(line) fh_.write('\n')
null
null
null
What does this function do?
def _get_node(name): attempts = 10 while (attempts >= 0): try: return list_nodes_full()[name] except KeyError: attempts -= 1 log.debug("Failed to get the data for node '{0}'. Remaining attempts: {1}".format(name, attempts)) time.sleep(0.5) return {}
null
null
null
Helper function that returns all information about a named node. name The name of the node for which to get information.
pcsd
def get node name attempts = 10 while attempts >= 0 try return list nodes full [name] except Key Error attempts -= 1 log debug "Failed to get the data for node '{0}' Remaining attempts {1}" format name attempts time sleep 0 5 return {}
9523
def _get_node(name): attempts = 10 while (attempts >= 0): try: return list_nodes_full()[name] except KeyError: attempts -= 1 log.debug("Failed to get the data for node '{0}'. Remaining attempts: {1}".format(name, attempts)) time.sleep(0.5) return {}
Helper function that returns all information about a named node. name The name of the node for which to get information.
helper function that returns all information about a named node .
Question: What does this function do? Code: def _get_node(name): attempts = 10 while (attempts >= 0): try: return list_nodes_full()[name] except KeyError: attempts -= 1 log.debug("Failed to get the data for node '{0}'. Remaining attempts: {1}".format(name, attempts)) time.sleep(0.5) return {}
null
null
null
What does this function do?
def getNextChildIndex(xmlElement): for (childIndex, child) in enumerate(xmlElement.parent.children): if (child == xmlElement): return (childIndex + 1) return len(xmlElement.parent.children)
null
null
null
Get the next child index.
pcsd
def get Next Child Index xml Element for child Index child in enumerate xml Element parent children if child == xml Element return child Index + 1 return len xml Element parent children
9527
def getNextChildIndex(xmlElement): for (childIndex, child) in enumerate(xmlElement.parent.children): if (child == xmlElement): return (childIndex + 1) return len(xmlElement.parent.children)
Get the next child index.
get the next child index .
Question: What does this function do? Code: def getNextChildIndex(xmlElement): for (childIndex, child) in enumerate(xmlElement.parent.children): if (child == xmlElement): return (childIndex + 1) return len(xmlElement.parent.children)
null
null
null
What does this function do?
def get_jid(jid): ret = {} for returner_ in __opts__[CONFIG_KEY]: ret.update(_mminion().returners['{0}.get_jid'.format(returner_)](jid)) return ret
null
null
null
Merge the return data from all returners
pcsd
def get jid jid ret = {} for returner in opts [CONFIG KEY] ret update mminion returners['{0} get jid' format returner ] jid return ret
9534
def get_jid(jid): ret = {} for returner_ in __opts__[CONFIG_KEY]: ret.update(_mminion().returners['{0}.get_jid'.format(returner_)](jid)) return ret
Merge the return data from all returners
merge the return data from all returners
Question: What does this function do? Code: def get_jid(jid): ret = {} for returner_ in __opts__[CONFIG_KEY]: ret.update(_mminion().returners['{0}.get_jid'.format(returner_)](jid)) return ret
null
null
null
What does this function do?
def demo1(sess): filenames = tf.gfile.ListDirectory(FLAGS.train_dir) filenames = sorted(filenames) filenames = [os.path.join(FLAGS.train_dir, f) for f in filenames if (f[(-4):] == '.png')] assert (len(filenames) >= 1) fps = 30 print 'Producing video file...' filename = os.path.join(FLAGS.train_dir, 'demo1.mp4') ...
null
null
null
Demo based on images dumped during training
pcsd
def demo1 sess filenames = tf gfile List Directory FLAGS train dir filenames = sorted filenames filenames = [os path join FLAGS train dir f for f in filenames if f[ -4 ] == ' png' ] assert len filenames >= 1 fps = 30 print 'Producing video file ' filename = os path join FLAGS train dir 'demo1 mp4' clip = mpe Image Sequ...
9535
def demo1(sess): filenames = tf.gfile.ListDirectory(FLAGS.train_dir) filenames = sorted(filenames) filenames = [os.path.join(FLAGS.train_dir, f) for f in filenames if (f[(-4):] == '.png')] assert (len(filenames) >= 1) fps = 30 print 'Producing video file...' filename = os.path.join(FLAGS.train_dir, 'demo1.mp4') ...
Demo based on images dumped during training
demo based on images dumped during training
Question: What does this function do? Code: def demo1(sess): filenames = tf.gfile.ListDirectory(FLAGS.train_dir) filenames = sorted(filenames) filenames = [os.path.join(FLAGS.train_dir, f) for f in filenames if (f[(-4):] == '.png')] assert (len(filenames) >= 1) fps = 30 print 'Producing video file...' filenam...
null
null
null
What does this function do?
def _fill_and_one_pad_stride(stride, n): try: return (((1,) + _fill_shape(stride, n)) + (1,)) except TypeError: raise base.IncompatibleShapeError('stride is {} ({}), must be either an integer or an iterable of integers of size {}'.format(stride, type(stride), n))
null
null
null
Expands the provided stride to size n and pads it with 1s.
pcsd
def fill and one pad stride stride n try return 1 + fill shape stride n + 1 except Type Error raise base Incompatible Shape Error 'stride is {} {} must be either an integer or an iterable of integers of size {}' format stride type stride n
9538
def _fill_and_one_pad_stride(stride, n): try: return (((1,) + _fill_shape(stride, n)) + (1,)) except TypeError: raise base.IncompatibleShapeError('stride is {} ({}), must be either an integer or an iterable of integers of size {}'.format(stride, type(stride), n))
Expands the provided stride to size n and pads it with 1s.
expands the provided stride to size n and pads it with 1s .
Question: What does this function do? Code: def _fill_and_one_pad_stride(stride, n): try: return (((1,) + _fill_shape(stride, n)) + (1,)) except TypeError: raise base.IncompatibleShapeError('stride is {} ({}), must be either an integer or an iterable of integers of size {}'.format(stride, type(stride), n))
null
null
null
What does this function do?
def find_system_symbol(img, instruction_addr, sdk_info=None): return DSymSymbol.objects.lookup_symbol(instruction_addr=instruction_addr, image_addr=img['image_addr'], image_vmaddr=img['image_vmaddr'], uuid=img['uuid'], cpu_name=get_cpu_name(img['cpu_type'], img['cpu_subtype']), object_path=img['name'], sdk_info=sdk_in...
null
null
null
Finds a system symbol.
pcsd
def find system symbol img instruction addr sdk info=None return D Sym Symbol objects lookup symbol instruction addr=instruction addr image addr=img['image addr'] image vmaddr=img['image vmaddr'] uuid=img['uuid'] cpu name=get cpu name img['cpu type'] img['cpu subtype'] object path=img['name'] sdk info=sdk info
9549
def find_system_symbol(img, instruction_addr, sdk_info=None): return DSymSymbol.objects.lookup_symbol(instruction_addr=instruction_addr, image_addr=img['image_addr'], image_vmaddr=img['image_vmaddr'], uuid=img['uuid'], cpu_name=get_cpu_name(img['cpu_type'], img['cpu_subtype']), object_path=img['name'], sdk_info=sdk_in...
Finds a system symbol.
finds a system symbol .
Question: What does this function do? Code: def find_system_symbol(img, instruction_addr, sdk_info=None): return DSymSymbol.objects.lookup_symbol(instruction_addr=instruction_addr, image_addr=img['image_addr'], image_vmaddr=img['image_vmaddr'], uuid=img['uuid'], cpu_name=get_cpu_name(img['cpu_type'], img['cpu_subty...
null
null
null
What does this function do?
def post_form_view(request): return post_form_response()
null
null
null
A view that returns a POST form (without a token)
pcsd
def post form view request return post form response
9550
def post_form_view(request): return post_form_response()
A view that returns a POST form (without a token)
a view that returns a post form
Question: What does this function do? Code: def post_form_view(request): return post_form_response()
null
null
null
What does this function do?
def sdm_zero(): return []
null
null
null
Return the zero module element.
pcsd
def sdm zero return []
9554
def sdm_zero(): return []
Return the zero module element.
return the zero module element .
Question: What does this function do? Code: def sdm_zero(): return []
null
null
null
What does this function do?
def _iterate_sagittal_slices(array, limits=None): shape = array.shape[0] for ind in range(shape): if (limits and (ind not in limits)): continue (yield (ind, array[ind, :, :]))
null
null
null
Iterate sagittal slices.
pcsd
def iterate sagittal slices array limits=None shape = array shape[0] for ind in range shape if limits and ind not in limits continue yield ind array[ind ]
9555
def _iterate_sagittal_slices(array, limits=None): shape = array.shape[0] for ind in range(shape): if (limits and (ind not in limits)): continue (yield (ind, array[ind, :, :]))
Iterate sagittal slices.
iterate sagittal slices .
Question: What does this function do? Code: def _iterate_sagittal_slices(array, limits=None): shape = array.shape[0] for ind in range(shape): if (limits and (ind not in limits)): continue (yield (ind, array[ind, :, :]))
null
null
null
What does this function do?
def import_files(lib, paths, query): for path in paths: if (not os.path.exists(syspath(normpath(path)))): raise ui.UserError(u'no such file or directory: {0}'.format(displayable_path(path))) if (config['import']['quiet'] and config['import']['timid']): raise ui.UserError("can't be both quiet and timid") if (c...
null
null
null
Import the files in the given list of paths or matching the query.
pcsd
def import files lib paths query for path in paths if not os path exists syspath normpath path raise ui User Error u'no such file or directory {0}' format displayable path path if config['import']['quiet'] and config['import']['timid'] raise ui User Error "can't be both quiet and timid" if config['import']['log'] get i...
9561
def import_files(lib, paths, query): for path in paths: if (not os.path.exists(syspath(normpath(path)))): raise ui.UserError(u'no such file or directory: {0}'.format(displayable_path(path))) if (config['import']['quiet'] and config['import']['timid']): raise ui.UserError("can't be both quiet and timid") if (c...
Import the files in the given list of paths or matching the query.
import the files in the given list of paths or matching the query .
Question: What does this function do? Code: def import_files(lib, paths, query): for path in paths: if (not os.path.exists(syspath(normpath(path)))): raise ui.UserError(u'no such file or directory: {0}'.format(displayable_path(path))) if (config['import']['quiet'] and config['import']['timid']): raise ui.Us...
null
null
null
What does this function do?
def vm_info(name, quiet=False): data = query(quiet=True) return _find_vm(name, data, quiet)
null
null
null
Return the information on the named VM
pcsd
def vm info name quiet=False data = query quiet=True return find vm name data quiet
9563
def vm_info(name, quiet=False): data = query(quiet=True) return _find_vm(name, data, quiet)
Return the information on the named VM
return the information on the named vm
Question: What does this function do? Code: def vm_info(name, quiet=False): data = query(quiet=True) return _find_vm(name, data, quiet)
null
null
null
What does this function do?
def depend(): log('* Installing package dependencies') run('sudo apt-get -qy update') run('sudo apt-get -qy install kvm cloud-utils genisoimage qemu-kvm qemu-utils e2fsprogs curl python-setuptools mtools zip') run('sudo easy_install pexpect')
null
null
null
Install package dependencies
pcsd
def depend log '* Installing package dependencies' run 'sudo apt-get -qy update' run 'sudo apt-get -qy install kvm cloud-utils genisoimage qemu-kvm qemu-utils e2fsprogs curl python-setuptools mtools zip' run 'sudo easy install pexpect'
9582
def depend(): log('* Installing package dependencies') run('sudo apt-get -qy update') run('sudo apt-get -qy install kvm cloud-utils genisoimage qemu-kvm qemu-utils e2fsprogs curl python-setuptools mtools zip') run('sudo easy_install pexpect')
Install package dependencies
install package dependencies
Question: What does this function do? Code: def depend(): log('* Installing package dependencies') run('sudo apt-get -qy update') run('sudo apt-get -qy install kvm cloud-utils genisoimage qemu-kvm qemu-utils e2fsprogs curl python-setuptools mtools zip') run('sudo easy_install pexpect')
null
null
null
What does this function do?
def create_structure(): folders = ['log', 'storage', os.path.join('storage', 'analyses'), os.path.join('storage', 'binaries'), os.path.join('storage', 'baseline')] try: create_folders(root=CUCKOO_ROOT, folders=folders) except CuckooOperationalError as e: raise CuckooStartupError(e)
null
null
null
Creates Cuckoo directories.
pcsd
def create structure folders = ['log' 'storage' os path join 'storage' 'analyses' os path join 'storage' 'binaries' os path join 'storage' 'baseline' ] try create folders root=CUCKOO ROOT folders=folders except Cuckoo Operational Error as e raise Cuckoo Startup Error e
9591
def create_structure(): folders = ['log', 'storage', os.path.join('storage', 'analyses'), os.path.join('storage', 'binaries'), os.path.join('storage', 'baseline')] try: create_folders(root=CUCKOO_ROOT, folders=folders) except CuckooOperationalError as e: raise CuckooStartupError(e)
Creates Cuckoo directories.
creates cuckoo directories .
Question: What does this function do? Code: def create_structure(): folders = ['log', 'storage', os.path.join('storage', 'analyses'), os.path.join('storage', 'binaries'), os.path.join('storage', 'baseline')] try: create_folders(root=CUCKOO_ROOT, folders=folders) except CuckooOperationalError as e: raise Cucko...
null
null
null
What does this function do?
@register.filter def all_ancestors_are_published(page, language): page = page.parent while page: if (not page.is_published(language)): return False page = page.parent return True
null
null
null
Returns False if any of the ancestors of page (and language) are unpublished, otherwise True.
pcsd
@register filter def all ancestors are published page language page = page parent while page if not page is published language return False page = page parent return True
9592
@register.filter def all_ancestors_are_published(page, language): page = page.parent while page: if (not page.is_published(language)): return False page = page.parent return True
Returns False if any of the ancestors of page (and language) are unpublished, otherwise True.
returns false if any of the ancestors of page are unpublished , otherwise true .
Question: What does this function do? Code: @register.filter def all_ancestors_are_published(page, language): page = page.parent while page: if (not page.is_published(language)): return False page = page.parent return True
null
null
null
What does this function do?
def get_attrib_file(path, size): attribs = [] path = os.path.join(path, ATTRIB_FILE) try: f = open(path, 'r') except: return [None for unused in xrange(size)] for unused in xrange(size): line = f.readline().strip('\r\n ') if line: if (line.lower() == 'none'): line = None try: line = int(line)...
null
null
null
Read job\'s attributes from file
pcsd
def get attrib file path size attribs = [] path = os path join path ATTRIB FILE try f = open path 'r' except return [None for unused in xrange size ] for unused in xrange size line = f readline strip '\r ' if line if line lower == 'none' line = None try line = int line except pass attribs append line else attribs appen...
9600
def get_attrib_file(path, size): attribs = [] path = os.path.join(path, ATTRIB_FILE) try: f = open(path, 'r') except: return [None for unused in xrange(size)] for unused in xrange(size): line = f.readline().strip('\r\n ') if line: if (line.lower() == 'none'): line = None try: line = int(line)...
Read job\'s attributes from file
read jobs attributes from file
Question: What does this function do? Code: def get_attrib_file(path, size): attribs = [] path = os.path.join(path, ATTRIB_FILE) try: f = open(path, 'r') except: return [None for unused in xrange(size)] for unused in xrange(size): line = f.readline().strip('\r\n ') if line: if (line.lower() == 'none'...
null
null
null
What does this function do?
def _extend_port_trunk_details(core_plugin, port_res, port_db): if port_db.trunk_port: subports = {x.port_id: {'segmentation_id': x.segmentation_id, 'segmentation_type': x.segmentation_type, 'port_id': x.port_id} for x in port_db.trunk_port.sub_ports} ports = core_plugin.get_ports(context.get_admin_context(), filt...
null
null
null
Add trunk details to a port.
pcsd
def extend port trunk details core plugin port res port db if port db trunk port subports = {x port id {'segmentation id' x segmentation id 'segmentation type' x segmentation type 'port id' x port id} for x in port db trunk port sub ports} ports = core plugin get ports context get admin context filters={'id' subports} ...
9603
def _extend_port_trunk_details(core_plugin, port_res, port_db): if port_db.trunk_port: subports = {x.port_id: {'segmentation_id': x.segmentation_id, 'segmentation_type': x.segmentation_type, 'port_id': x.port_id} for x in port_db.trunk_port.sub_ports} ports = core_plugin.get_ports(context.get_admin_context(), filt...
Add trunk details to a port.
add trunk details to a port .
Question: What does this function do? Code: def _extend_port_trunk_details(core_plugin, port_res, port_db): if port_db.trunk_port: subports = {x.port_id: {'segmentation_id': x.segmentation_id, 'segmentation_type': x.segmentation_type, 'port_id': x.port_id} for x in port_db.trunk_port.sub_ports} ports = core_plu...
null
null
null
What does this function do?
def isint(x): try: a = float(x) b = int(a) except ValueError: return False else: return (a == b)
null
null
null
Check if argument is int
pcsd
def isint x try a = float x b = int a except Value Error return False else return a == b
9604
def isint(x): try: a = float(x) b = int(a) except ValueError: return False else: return (a == b)
Check if argument is int
check if argument is int
Question: What does this function do? Code: def isint(x): try: a = float(x) b = int(a) except ValueError: return False else: return (a == b)
null
null
null
What does this function do?
def capture_card_hold(db, participant, amount, hold): typecheck(hold, braintree.Transaction, amount, Decimal) username = participant.username assert (participant.id == int(hold.custom_fields[u'participant_id'])) route = ExchangeRoute.from_address(participant, u'braintree-cc', hold.credit_card[u'token']) assert isi...
null
null
null
Capture the previously created hold on the participant\'s credit card.
pcsd
def capture card hold db participant amount hold typecheck hold braintree Transaction amount Decimal username = participant username assert participant id == int hold custom fields[u'participant id'] route = Exchange Route from address participant u'braintree-cc' hold credit card[u'token'] assert isinstance route Excha...
9608
def capture_card_hold(db, participant, amount, hold): typecheck(hold, braintree.Transaction, amount, Decimal) username = participant.username assert (participant.id == int(hold.custom_fields[u'participant_id'])) route = ExchangeRoute.from_address(participant, u'braintree-cc', hold.credit_card[u'token']) assert isi...
Capture the previously created hold on the participant\'s credit card.
capture the previously created hold on the participants credit card .
Question: What does this function do? Code: def capture_card_hold(db, participant, amount, hold): typecheck(hold, braintree.Transaction, amount, Decimal) username = participant.username assert (participant.id == int(hold.custom_fields[u'participant_id'])) route = ExchangeRoute.from_address(participant, u'braintr...
null
null
null
What does this function do?
def redirect(url, code=None): if (code is None): code = (303 if (request.get('SERVER_PROTOCOL') == 'HTTP/1.1') else 302) location = urljoin(request.url, url) raise HTTPResponse('', status=code, header=dict(Location=location))
null
null
null
Aborts execution and causes a 303 or 302 redirect, depending on the HTTP protocol version.
pcsd
def redirect url code=None if code is None code = 303 if request get 'SERVER PROTOCOL' == 'HTTP/1 1' else 302 location = urljoin request url url raise HTTP Response '' status=code header=dict Location=location
9611
def redirect(url, code=None): if (code is None): code = (303 if (request.get('SERVER_PROTOCOL') == 'HTTP/1.1') else 302) location = urljoin(request.url, url) raise HTTPResponse('', status=code, header=dict(Location=location))
Aborts execution and causes a 303 or 302 redirect, depending on the HTTP protocol version.
aborts execution and causes a 303 or 302 redirect , depending on the http protocol version .
Question: What does this function do? Code: def redirect(url, code=None): if (code is None): code = (303 if (request.get('SERVER_PROTOCOL') == 'HTTP/1.1') else 302) location = urljoin(request.url, url) raise HTTPResponse('', status=code, header=dict(Location=location))
null
null
null
What does this function do?
@contextmanager def cd(path): cwd = os.getcwd() os.chdir(path) try: (yield) finally: os.chdir(cwd)
null
null
null
Context manager for temporary CWD
pcsd
@contextmanager def cd path cwd = os getcwd os chdir path try yield finally os chdir cwd
9618
@contextmanager def cd(path): cwd = os.getcwd() os.chdir(path) try: (yield) finally: os.chdir(cwd)
Context manager for temporary CWD
context manager for temporary cwd
Question: What does this function do? Code: @contextmanager def cd(path): cwd = os.getcwd() os.chdir(path) try: (yield) finally: os.chdir(cwd)
null
null
null
What does this function do?
def is_valid(target): if nick_re.match(target): return True else: return False
null
null
null
Checks if a string is a valid IRC nick.
pcsd
def is valid target if nick re match target return True else return False
9621
def is_valid(target): if nick_re.match(target): return True else: return False
Checks if a string is a valid IRC nick.
checks if a string is a valid irc nick .
Question: What does this function do? Code: def is_valid(target): if nick_re.match(target): return True else: return False
null
null
null
What does this function do?
def get_all_tensor_children(tensor): children_list = [] children_list.append(tensor) if tensor.op: for t in tensor.op.outputs: children_list += get_all_tensor_children(t) return list(set(children_list))
null
null
null
Get all parents tensors.
pcsd
def get all tensor children tensor children list = [] children list append tensor if tensor op for t in tensor op outputs children list += get all tensor children t return list set children list
9630
def get_all_tensor_children(tensor): children_list = [] children_list.append(tensor) if tensor.op: for t in tensor.op.outputs: children_list += get_all_tensor_children(t) return list(set(children_list))
Get all parents tensors.
get all parents tensors .
Question: What does this function do? Code: def get_all_tensor_children(tensor): children_list = [] children_list.append(tensor) if tensor.op: for t in tensor.op.outputs: children_list += get_all_tensor_children(t) return list(set(children_list))
null
null
null
What does this function do?
def package_dirname(package): if isinstance(package, str): package = __import__(package, fromlist=['']) filename = package.__file__ dirname = os.path.dirname(filename) return dirname
null
null
null
Return the directory path where package is located.
pcsd
def package dirname package if isinstance package str package = import package fromlist=[''] filename = package file dirname = os path dirname filename return dirname
9646
def package_dirname(package): if isinstance(package, str): package = __import__(package, fromlist=['']) filename = package.__file__ dirname = os.path.dirname(filename) return dirname
Return the directory path where package is located.
return the directory path where package is located .
Question: What does this function do? Code: def package_dirname(package): if isinstance(package, str): package = __import__(package, fromlist=['']) filename = package.__file__ dirname = os.path.dirname(filename) return dirname
null
null
null
What does this function do?
def _flatten_artist_credit(credit): artist_parts = [] artist_sort_parts = [] artist_credit_parts = [] for el in credit: if isinstance(el, six.string_types): artist_parts.append(el) artist_credit_parts.append(el) artist_sort_parts.append(el) else: alias = _preferred_alias(el['artist'].get('alias-list...
null
null
null
Given a list representing an ``artist-credit`` block, flatten the data into a triple of joined artist name strings: canonical, sort, and credit.
pcsd
def flatten artist credit credit artist parts = [] artist sort parts = [] artist credit parts = [] for el in credit if isinstance el six string types artist parts append el artist credit parts append el artist sort parts append el else alias = preferred alias el['artist'] get 'alias-list' if alias cur artist name = ali...
9656
def _flatten_artist_credit(credit): artist_parts = [] artist_sort_parts = [] artist_credit_parts = [] for el in credit: if isinstance(el, six.string_types): artist_parts.append(el) artist_credit_parts.append(el) artist_sort_parts.append(el) else: alias = _preferred_alias(el['artist'].get('alias-list...
Given a list representing an ``artist-credit`` block, flatten the data into a triple of joined artist name strings: canonical, sort, and credit.
given a list representing an artist - credit block , flatten the data into a triple of joined artist name strings : canonical , sort , and credit .
Question: What does this function do? Code: def _flatten_artist_credit(credit): artist_parts = [] artist_sort_parts = [] artist_credit_parts = [] for el in credit: if isinstance(el, six.string_types): artist_parts.append(el) artist_credit_parts.append(el) artist_sort_parts.append(el) else: alias ...
null
null
null
What does this function do?
def get_ssl_adapter_class(name='pyopenssl'): adapter = ssl_adapters[name.lower()] if isinstance(adapter, basestring): last_dot = adapter.rfind('.') attr_name = adapter[(last_dot + 1):] mod_path = adapter[:last_dot] try: mod = sys.modules[mod_path] if (mod is None): raise KeyError() except KeyError...
null
null
null
Return an SSL adapter class for the given name.
pcsd
def get ssl adapter class name='pyopenssl' adapter = ssl adapters[name lower ] if isinstance adapter basestring last dot = adapter rfind ' ' attr name = adapter[ last dot + 1 ] mod path = adapter[ last dot] try mod = sys modules[mod path] if mod is None raise Key Error except Key Error mod = import mod path globals loc...
9659
def get_ssl_adapter_class(name='pyopenssl'): adapter = ssl_adapters[name.lower()] if isinstance(adapter, basestring): last_dot = adapter.rfind('.') attr_name = adapter[(last_dot + 1):] mod_path = adapter[:last_dot] try: mod = sys.modules[mod_path] if (mod is None): raise KeyError() except KeyError...
Return an SSL adapter class for the given name.
return an ssl adapter class for the given name .
Question: What does this function do? Code: def get_ssl_adapter_class(name='pyopenssl'): adapter = ssl_adapters[name.lower()] if isinstance(adapter, basestring): last_dot = adapter.rfind('.') attr_name = adapter[(last_dot + 1):] mod_path = adapter[:last_dot] try: mod = sys.modules[mod_path] if (mod i...
null
null
null
What does this function do?
def s_lego(lego_type, value=None, options={}): name = ('LEGO_%08x' % len(blocks.CURRENT.names)) if (not legos.BIN.has_key(lego_type)): raise sex.SullyRuntimeError(('INVALID LEGO TYPE SPECIFIED: %s' % lego_type)) lego = legos.BIN[lego_type](name, blocks.CURRENT, value, options) blocks.CURRENT.push(lego) blocks.CU...
null
null
null
Legos are pre-built blocks... TODO: finish this doc
pcsd
def s lego lego type value=None options={} name = 'LEGO %08x' % len blocks CURRENT names if not legos BIN has key lego type raise sex Sully Runtime Error 'INVALID LEGO TYPE SPECIFIED %s' % lego type lego = legos BIN[lego type] name blocks CURRENT value options blocks CURRENT push lego blocks CURRENT pop
9664
def s_lego(lego_type, value=None, options={}): name = ('LEGO_%08x' % len(blocks.CURRENT.names)) if (not legos.BIN.has_key(lego_type)): raise sex.SullyRuntimeError(('INVALID LEGO TYPE SPECIFIED: %s' % lego_type)) lego = legos.BIN[lego_type](name, blocks.CURRENT, value, options) blocks.CURRENT.push(lego) blocks.CU...
Legos are pre-built blocks... TODO: finish this doc
legos are pre - built blocks . . .
Question: What does this function do? Code: def s_lego(lego_type, value=None, options={}): name = ('LEGO_%08x' % len(blocks.CURRENT.names)) if (not legos.BIN.has_key(lego_type)): raise sex.SullyRuntimeError(('INVALID LEGO TYPE SPECIFIED: %s' % lego_type)) lego = legos.BIN[lego_type](name, blocks.CURRENT, value,...
null
null
null
What does this function do?
@login_required @require_POST def add_member(request, group_slug): prof = get_object_or_404(GroupProfile, slug=group_slug) if (not _user_can_edit(request.user, prof)): raise PermissionDenied form = AddUserForm(request.POST) if form.is_valid(): for user in form.cleaned_data['users']: user.groups.add(prof.grou...
null
null
null
Add a member to the group.
pcsd
@login required @require POST def add member request group slug prof = get object or 404 Group Profile slug=group slug if not user can edit request user prof raise Permission Denied form = Add User Form request POST if form is valid for user in form cleaned data['users'] user groups add prof group msg = '{users} added ...
9668
@login_required @require_POST def add_member(request, group_slug): prof = get_object_or_404(GroupProfile, slug=group_slug) if (not _user_can_edit(request.user, prof)): raise PermissionDenied form = AddUserForm(request.POST) if form.is_valid(): for user in form.cleaned_data['users']: user.groups.add(prof.grou...
Add a member to the group.
add a member to the group .
Question: What does this function do? Code: @login_required @require_POST def add_member(request, group_slug): prof = get_object_or_404(GroupProfile, slug=group_slug) if (not _user_can_edit(request.user, prof)): raise PermissionDenied form = AddUserForm(request.POST) if form.is_valid(): for user in form.clea...
null
null
null
What does this function do?
def files_contains(file1, file2, attributes=None): local_file = open(file1, 'U').readlines() history_data = open(file2, 'U').read() lines_diff = int(attributes.get('lines_diff', 0)) line_diff_count = 0 while local_file: contains = local_file.pop(0).rstrip('\n\r') if (contains not in history_data): line_diff...
null
null
null
Check the contents of file2 for substrings found in file1, on a per-line basis.
pcsd
def files contains file1 file2 attributes=None local file = open file1 'U' readlines history data = open file2 'U' read lines diff = int attributes get 'lines diff' 0 line diff count = 0 while local file contains = local file pop 0 rstrip ' \r' if contains not in history data line diff count += 1 if line diff count > l...
9673
def files_contains(file1, file2, attributes=None): local_file = open(file1, 'U').readlines() history_data = open(file2, 'U').read() lines_diff = int(attributes.get('lines_diff', 0)) line_diff_count = 0 while local_file: contains = local_file.pop(0).rstrip('\n\r') if (contains not in history_data): line_diff...
Check the contents of file2 for substrings found in file1, on a per-line basis.
check the contents of file2 for substrings found in file1 , on a per - line basis .
Question: What does this function do? Code: def files_contains(file1, file2, attributes=None): local_file = open(file1, 'U').readlines() history_data = open(file2, 'U').read() lines_diff = int(attributes.get('lines_diff', 0)) line_diff_count = 0 while local_file: contains = local_file.pop(0).rstrip('\n\r') ...
null
null
null
What does this function do?
def changes(): _version = version() f = open(os.path.join(get_base_dir(), 'CHANGES.txt'), 'r') lines = [] for line in f: if line.startswith('====='): if (len(lines) > 1): break if lines: lines.append(line) elif line.startswith(_version): lines.append(line) f.close() return ''.join(lines[:(-1)])...
null
null
null
Extract part of changelog pertaining to version.
pcsd
def changes version = version f = open os path join get base dir 'CHANGES txt' 'r' lines = [] for line in f if line startswith '=====' if len lines > 1 break if lines lines append line elif line startswith version lines append line f close return '' join lines[ -1 ]
9676
def changes(): _version = version() f = open(os.path.join(get_base_dir(), 'CHANGES.txt'), 'r') lines = [] for line in f: if line.startswith('====='): if (len(lines) > 1): break if lines: lines.append(line) elif line.startswith(_version): lines.append(line) f.close() return ''.join(lines[:(-1)])...
Extract part of changelog pertaining to version.
extract part of changelog pertaining to version .
Question: What does this function do? Code: def changes(): _version = version() f = open(os.path.join(get_base_dir(), 'CHANGES.txt'), 'r') lines = [] for line in f: if line.startswith('====='): if (len(lines) > 1): break if lines: lines.append(line) elif line.startswith(_version): lines.append...
null
null
null
What does this function do?
def _is_single_paragraph(node): if (len(node) == 0): return False elif (len(node) > 1): for subnode in node[1:]: if (not isinstance(subnode, nodes.system_message)): return False if isinstance(node[0], nodes.paragraph): return True return False
null
null
null
True if the node only contains one paragraph (and system messages).
pcsd
def is single paragraph node if len node == 0 return False elif len node > 1 for subnode in node[1 ] if not isinstance subnode nodes system message return False if isinstance node[0] nodes paragraph return True return False
9686
def _is_single_paragraph(node): if (len(node) == 0): return False elif (len(node) > 1): for subnode in node[1:]: if (not isinstance(subnode, nodes.system_message)): return False if isinstance(node[0], nodes.paragraph): return True return False
True if the node only contains one paragraph (and system messages).
true if the node only contains one paragraph .
Question: What does this function do? Code: def _is_single_paragraph(node): if (len(node) == 0): return False elif (len(node) > 1): for subnode in node[1:]: if (not isinstance(subnode, nodes.system_message)): return False if isinstance(node[0], nodes.paragraph): return True return False
null
null
null
What does this function do?
def get_docker_version_info(): result = None if is_service_running('docker'): version_info = yaml.safe_load(get_version_output('/usr/bin/docker', 'version')) if ('Server' in version_info): result = {'api_version': version_info['Server']['API version'], 'version': version_info['Server']['Version']} return resu...
null
null
null
Parses and returns the docker version info
pcsd
def get docker version info result = None if is service running 'docker' version info = yaml safe load get version output '/usr/bin/docker' 'version' if 'Server' in version info result = {'api version' version info['Server']['API version'] 'version' version info['Server']['Version']} return result
9704
def get_docker_version_info(): result = None if is_service_running('docker'): version_info = yaml.safe_load(get_version_output('/usr/bin/docker', 'version')) if ('Server' in version_info): result = {'api_version': version_info['Server']['API version'], 'version': version_info['Server']['Version']} return resu...
Parses and returns the docker version info
parses and returns the docker version info
Question: What does this function do? Code: def get_docker_version_info(): result = None if is_service_running('docker'): version_info = yaml.safe_load(get_version_output('/usr/bin/docker', 'version')) if ('Server' in version_info): result = {'api_version': version_info['Server']['API version'], 'version': ...
null
null
null
What does this function do?
def stem_text(text): text = utils.to_unicode(text) p = PorterStemmer() return ' '.join((p.stem(word) for word in text.split()))
null
null
null
Return lowercase and (porter-)stemmed version of string `text`.
pcsd
def stem text text text = utils to unicode text p = Porter Stemmer return ' ' join p stem word for word in text split
9707
def stem_text(text): text = utils.to_unicode(text) p = PorterStemmer() return ' '.join((p.stem(word) for word in text.split()))
Return lowercase and (porter-)stemmed version of string `text`.
return lowercase and stemmed version of string text .
Question: What does this function do? Code: def stem_text(text): text = utils.to_unicode(text) p = PorterStemmer() return ' '.join((p.stem(word) for word in text.split()))
null
null
null
What does this function do?
@transaction.non_atomic_requests @require_POST @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_level('staff') def export_ora2_data(request, course_id): course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) try: lms.djangoapps.instructor_task.api.submi...
null
null
null
Pushes a Celery task which will aggregate ora2 responses for a course into a .csv
pcsd
@transaction non atomic requests @require POST @ensure csrf cookie @cache control no cache=True no store=True must revalidate=True @require level 'staff' def export ora2 data request course id course key = Slash Separated Course Key from deprecated string course id try lms djangoapps instructor task api submit export o...
9709
@transaction.non_atomic_requests @require_POST @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_level('staff') def export_ora2_data(request, course_id): course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) try: lms.djangoapps.instructor_task.api.submi...
Pushes a Celery task which will aggregate ora2 responses for a course into a .csv
pushes a celery task which will aggregate ora2 responses for a course into a . csv
Question: What does this function do? Code: @transaction.non_atomic_requests @require_POST @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) @require_level('staff') def export_ora2_data(request, course_id): course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) ...
null
null
null
What does this function do?
def add_callers(target, source): new_callers = {} for (func, caller) in target.iteritems(): new_callers[func] = caller for (func, caller) in source.iteritems(): if (func in new_callers): if isinstance(caller, tuple): new_callers[func] = tuple([(i[0] + i[1]) for i in zip(caller, new_callers[func])]) els...
null
null
null
Combine two caller lists in a single list.
pcsd
def add callers target source new callers = {} for func caller in target iteritems new callers[func] = caller for func caller in source iteritems if func in new callers if isinstance caller tuple new callers[func] = tuple [ i[0] + i[1] for i in zip caller new callers[func] ] else new callers[func] += caller else new ca...
9734
def add_callers(target, source): new_callers = {} for (func, caller) in target.iteritems(): new_callers[func] = caller for (func, caller) in source.iteritems(): if (func in new_callers): if isinstance(caller, tuple): new_callers[func] = tuple([(i[0] + i[1]) for i in zip(caller, new_callers[func])]) els...
Combine two caller lists in a single list.
combine two caller lists in a single list .
Question: What does this function do? Code: def add_callers(target, source): new_callers = {} for (func, caller) in target.iteritems(): new_callers[func] = caller for (func, caller) in source.iteritems(): if (func in new_callers): if isinstance(caller, tuple): new_callers[func] = tuple([(i[0] + i[1]) f...
null
null
null
What does this function do?
def check_extras(dist, attr, value): try: for (k, v) in value.items(): list(pkg_resources.parse_requirements(v)) except (TypeError, ValueError, AttributeError): raise DistutilsSetupError("'extras_require' must be a dictionary whose values are strings or lists of strings containing valid project/version require...
null
null
null
Verify that extras_require mapping is valid
pcsd
def check extras dist attr value try for k v in value items list pkg resources parse requirements v except Type Error Value Error Attribute Error raise Distutils Setup Error "'extras require' must be a dictionary whose values are strings or lists of strings containing valid project/version requirement specifiers "
9744
def check_extras(dist, attr, value): try: for (k, v) in value.items(): list(pkg_resources.parse_requirements(v)) except (TypeError, ValueError, AttributeError): raise DistutilsSetupError("'extras_require' must be a dictionary whose values are strings or lists of strings containing valid project/version require...
Verify that extras_require mapping is valid
verify that extras _ require mapping is valid
Question: What does this function do? Code: def check_extras(dist, attr, value): try: for (k, v) in value.items(): list(pkg_resources.parse_requirements(v)) except (TypeError, ValueError, AttributeError): raise DistutilsSetupError("'extras_require' must be a dictionary whose values are strings or lists of s...
null
null
null
What does this function do?
def get_barcode(curr_seq, barcode_len): raw_barcode = curr_seq[0:barcode_len] raw_seq = curr_seq[barcode_len:] return (raw_barcode, raw_seq)
null
null
null
Split sequence into barcode and remaining sequence Linker and primer part of remaining sequence, as one must first read the barcode to find the associated primer from the mapping file
pcsd
def get barcode curr seq barcode len raw barcode = curr seq[0 barcode len] raw seq = curr seq[barcode len ] return raw barcode raw seq
9745
def get_barcode(curr_seq, barcode_len): raw_barcode = curr_seq[0:barcode_len] raw_seq = curr_seq[barcode_len:] return (raw_barcode, raw_seq)
Split sequence into barcode and remaining sequence Linker and primer part of remaining sequence, as one must first read the barcode to find the associated primer from the mapping file
split sequence into barcode and remaining sequence
Question: What does this function do? Code: def get_barcode(curr_seq, barcode_len): raw_barcode = curr_seq[0:barcode_len] raw_seq = curr_seq[barcode_len:] return (raw_barcode, raw_seq)
null
null
null
What does this function do?
def getSharedFace(firstEdge, faces, secondEdge): for firstEdgeFaceIndex in firstEdge.faceIndexes: for secondEdgeFaceIndex in secondEdge.faceIndexes: if (firstEdgeFaceIndex == secondEdgeFaceIndex): return faces[firstEdgeFaceIndex] return None
null
null
null
Get the face which is shared by two edges.
pcsd
def get Shared Face first Edge faces second Edge for first Edge Face Index in first Edge face Indexes for second Edge Face Index in second Edge face Indexes if first Edge Face Index == second Edge Face Index return faces[first Edge Face Index] return None
9758
def getSharedFace(firstEdge, faces, secondEdge): for firstEdgeFaceIndex in firstEdge.faceIndexes: for secondEdgeFaceIndex in secondEdge.faceIndexes: if (firstEdgeFaceIndex == secondEdgeFaceIndex): return faces[firstEdgeFaceIndex] return None
Get the face which is shared by two edges.
get the face which is shared by two edges .
Question: What does this function do? Code: def getSharedFace(firstEdge, faces, secondEdge): for firstEdgeFaceIndex in firstEdge.faceIndexes: for secondEdgeFaceIndex in secondEdge.faceIndexes: if (firstEdgeFaceIndex == secondEdgeFaceIndex): return faces[firstEdgeFaceIndex] return None
null
null
null
What does this function do?
@register.filter(u'escape', is_safe=True) @stringfilter def escape_filter(value): return mark_for_escaping(value)
null
null
null
Marks the value as a string that should not be auto-escaped.
pcsd
@register filter u'escape' is safe=True @stringfilter def escape filter value return mark for escaping value
9759
@register.filter(u'escape', is_safe=True) @stringfilter def escape_filter(value): return mark_for_escaping(value)
Marks the value as a string that should not be auto-escaped.
marks the value as a string that should not be auto - escaped .
Question: What does this function do? Code: @register.filter(u'escape', is_safe=True) @stringfilter def escape_filter(value): return mark_for_escaping(value)
null
null
null
What does this function do?
def saveimage(filename, im): if (len(im.shape) == 3): cv2.imwrite(filename, (255 * im[:, :, ::(-1)])) else: cv2.imwrite(filename, (255 * im))
null
null
null
Saves an image with pixel values in [0,1]
pcsd
def saveimage filename im if len im shape == 3 cv2 imwrite filename 255 * im[ -1 ] else cv2 imwrite filename 255 * im
9762
def saveimage(filename, im): if (len(im.shape) == 3): cv2.imwrite(filename, (255 * im[:, :, ::(-1)])) else: cv2.imwrite(filename, (255 * im))
Saves an image with pixel values in [0,1]
saves an image with pixel values in [ 0 , 1 ]
Question: What does this function do? Code: def saveimage(filename, im): if (len(im.shape) == 3): cv2.imwrite(filename, (255 * im[:, :, ::(-1)])) else: cv2.imwrite(filename, (255 * im))
null
null
null
What does this function do?
def _dummy_closure(x): return (lambda : x)
null
null
null
A dummy function allowing us to build cell objects.
pcsd
def dummy closure x return lambda x
9787
def _dummy_closure(x): return (lambda : x)
A dummy function allowing us to build cell objects.
a dummy function allowing us to build cell objects .
Question: What does this function do? Code: def _dummy_closure(x): return (lambda : x)
null
null
null
What does this function do?
def aggregate_host_get_all(context, aggregate_id): return IMPL.aggregate_host_get_all(context, aggregate_id)
null
null
null
Get hosts for the specified aggregate.
pcsd
def aggregate host get all context aggregate id return IMPL aggregate host get all context aggregate id
9788
def aggregate_host_get_all(context, aggregate_id): return IMPL.aggregate_host_get_all(context, aggregate_id)
Get hosts for the specified aggregate.
get hosts for the specified aggregate .
Question: What does this function do? Code: def aggregate_host_get_all(context, aggregate_id): return IMPL.aggregate_host_get_all(context, aggregate_id)
null
null
null
What does this function do?
@requires_sklearn_0_15 def test_unsupervised_spatial_filter(): from sklearn.decomposition import PCA from sklearn.kernel_ridge import KernelRidge raw = io.read_raw_fif(raw_fname) events = read_events(event_name) picks = pick_types(raw.info, meg=True, stim=False, ecg=False, eog=False, exclude='bads') picks = picks...
null
null
null
Test unsupervised spatial filter.
pcsd
@requires sklearn 0 15 def test unsupervised spatial filter from sklearn decomposition import PCA from sklearn kernel ridge import Kernel Ridge raw = io read raw fif raw fname events = read events event name picks = pick types raw info meg=True stim=False ecg=False eog=False exclude='bads' picks = picks[1 13 3] epochs ...
9789
@requires_sklearn_0_15 def test_unsupervised_spatial_filter(): from sklearn.decomposition import PCA from sklearn.kernel_ridge import KernelRidge raw = io.read_raw_fif(raw_fname) events = read_events(event_name) picks = pick_types(raw.info, meg=True, stim=False, ecg=False, eog=False, exclude='bads') picks = picks...
Test unsupervised spatial filter.
test unsupervised spatial filter .
Question: What does this function do? Code: @requires_sklearn_0_15 def test_unsupervised_spatial_filter(): from sklearn.decomposition import PCA from sklearn.kernel_ridge import KernelRidge raw = io.read_raw_fif(raw_fname) events = read_events(event_name) picks = pick_types(raw.info, meg=True, stim=False, ecg=F...
null
null
null
What does this function do?
def simplify_presentation(C): rels = C._reidemeister_relators rels_arr = _simplification_technique_1(rels) group = C._schreier_free_group C._reidemeister_relators = [group.dtype(tuple(r)).identity_cyclic_reduction() for r in rels_arr if r]
null
null
null
Relies upon ``_simplification_technique_1`` for its functioning.
pcsd
def simplify presentation C rels = C reidemeister relators rels arr = simplification technique 1 rels group = C schreier free group C reidemeister relators = [group dtype tuple r identity cyclic reduction for r in rels arr if r]
9794
def simplify_presentation(C): rels = C._reidemeister_relators rels_arr = _simplification_technique_1(rels) group = C._schreier_free_group C._reidemeister_relators = [group.dtype(tuple(r)).identity_cyclic_reduction() for r in rels_arr if r]
Relies upon ``_simplification_technique_1`` for its functioning.
relies upon _ simplification _ technique _ 1 for its functioning .
Question: What does this function do? Code: def simplify_presentation(C): rels = C._reidemeister_relators rels_arr = _simplification_technique_1(rels) group = C._schreier_free_group C._reidemeister_relators = [group.dtype(tuple(r)).identity_cyclic_reduction() for r in rels_arr if r]
null
null
null
What does this function do?
def generate_key(): return str(hashlib.sha224(str(random.getrandbits(128)).encode(u'utf-8')).hexdigest())
null
null
null
Generate key for use to authentication
pcsd
def generate key return str hashlib sha224 str random getrandbits 128 encode u'utf-8' hexdigest
9795
def generate_key(): return str(hashlib.sha224(str(random.getrandbits(128)).encode(u'utf-8')).hexdigest())
Generate key for use to authentication
generate key for use to authentication
Question: What does this function do? Code: def generate_key(): return str(hashlib.sha224(str(random.getrandbits(128)).encode(u'utf-8')).hexdigest())
null
null
null
What does this function do?
def convert_to_seconds(varnames): return preprocess_args(cvsecs, varnames)
null
null
null
Converts the specified variables to seconds
pcsd
def convert to seconds varnames return preprocess args cvsecs varnames
9801
def convert_to_seconds(varnames): return preprocess_args(cvsecs, varnames)
Converts the specified variables to seconds
converts the specified variables to seconds
Question: What does this function do? Code: def convert_to_seconds(varnames): return preprocess_args(cvsecs, varnames)
null
null
null
What does this function do?
def setup_platform(hass, config, add_devices, discovery_info=None): dev = [] for resource in config[CONF_RESOURCES]: if ('arg' not in resource): resource['arg'] = '' dev.append(SystemMonitorSensor(resource[CONF_TYPE], resource['arg'])) add_devices(dev)
null
null
null
Set up the system monitor sensors.
pcsd
def setup platform hass config add devices discovery info=None dev = [] for resource in config[CONF RESOURCES] if 'arg' not in resource resource['arg'] = '' dev append System Monitor Sensor resource[CONF TYPE] resource['arg'] add devices dev
9804
def setup_platform(hass, config, add_devices, discovery_info=None): dev = [] for resource in config[CONF_RESOURCES]: if ('arg' not in resource): resource['arg'] = '' dev.append(SystemMonitorSensor(resource[CONF_TYPE], resource['arg'])) add_devices(dev)
Set up the system monitor sensors.
set up the system monitor sensors .
Question: What does this function do? Code: def setup_platform(hass, config, add_devices, discovery_info=None): dev = [] for resource in config[CONF_RESOURCES]: if ('arg' not in resource): resource['arg'] = '' dev.append(SystemMonitorSensor(resource[CONF_TYPE], resource['arg'])) add_devices(dev)
null
null
null
What does this function do?
def symlink(src, dst, mkdirs=0): if (not os.path.exists(src)): raise IOError(("No such file or directory: '%s'" % src)) if mkdirs: makedirs(os.path.dirname(dst)) os.symlink(os.path.abspath(src), dst)
null
null
null
Copy a file or a directory.
pcsd
def symlink src dst mkdirs=0 if not os path exists src raise IO Error "No such file or directory '%s'" % src if mkdirs makedirs os path dirname dst os symlink os path abspath src dst
9816
def symlink(src, dst, mkdirs=0): if (not os.path.exists(src)): raise IOError(("No such file or directory: '%s'" % src)) if mkdirs: makedirs(os.path.dirname(dst)) os.symlink(os.path.abspath(src), dst)
Copy a file or a directory.
copy a file or a directory .
Question: What does this function do? Code: def symlink(src, dst, mkdirs=0): if (not os.path.exists(src)): raise IOError(("No such file or directory: '%s'" % src)) if mkdirs: makedirs(os.path.dirname(dst)) os.symlink(os.path.abspath(src), dst)
null
null
null
What does this function do?
def multiControllerNet(): net = Mininet(controller=Controller, switch=OVSSwitch) info('*** Creating (reference) controllers\n') c1 = net.addController('c1', port=6633) c2 = net.addController('c2', port=6634) info('*** Creating switches\n') s1 = net.addSwitch('s1') s2 = net.addSwitch('s2') info('*** Creating hos...
null
null
null
Create a network from semi-scratch with multiple controllers.
pcsd
def multi Controller Net net = Mininet controller=Controller switch=OVS Switch info '*** Creating reference controllers ' c1 = net add Controller 'c1' port=6633 c2 = net add Controller 'c2' port=6634 info '*** Creating switches ' s1 = net add Switch 's1' s2 = net add Switch 's2' info '*** Creating hosts ' hosts1 = [net...
9819
def multiControllerNet(): net = Mininet(controller=Controller, switch=OVSSwitch) info('*** Creating (reference) controllers\n') c1 = net.addController('c1', port=6633) c2 = net.addController('c2', port=6634) info('*** Creating switches\n') s1 = net.addSwitch('s1') s2 = net.addSwitch('s2') info('*** Creating hos...
Create a network from semi-scratch with multiple controllers.
create a network from semi - scratch with multiple controllers .
Question: What does this function do? Code: def multiControllerNet(): net = Mininet(controller=Controller, switch=OVSSwitch) info('*** Creating (reference) controllers\n') c1 = net.addController('c1', port=6633) c2 = net.addController('c2', port=6634) info('*** Creating switches\n') s1 = net.addSwitch('s1') s...