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?
@pytest.fixture def context(): return Context(TLSv1_METHOD)
null
null
null
A simple TLS 1.0 context.
pcsd
@pytest fixture def context return Context TL Sv1 METHOD
1975
@pytest.fixture def context(): return Context(TLSv1_METHOD)
A simple TLS 1.0 context.
a simple tls 1 . 0 context .
Question: What does this function do? Code: @pytest.fixture def context(): return Context(TLSv1_METHOD)
null
null
null
What does this function do?
def split_dataset_collection_instance(dataset_collection_instance, collection_type): return _split_dataset_collection(dataset_collection_instance.collection, collection_type)
null
null
null
Split up collection into collection.
pcsd
def split dataset collection instance dataset collection instance collection type return split dataset collection dataset collection instance collection collection type
1981
def split_dataset_collection_instance(dataset_collection_instance, collection_type): return _split_dataset_collection(dataset_collection_instance.collection, collection_type)
Split up collection into collection.
split up collection into collection .
Question: What does this function do? Code: def split_dataset_collection_instance(dataset_collection_instance, collection_type): return _split_dataset_collection(dataset_collection_instance.collection, collection_type)
null
null
null
What does this function do?
def network_get_all(context, project_only='allow_none'): return IMPL.network_get_all(context, project_only)
null
null
null
Return all defined networks.
pcsd
def network get all context project only='allow none' return IMPL network get all context project only
1984
def network_get_all(context, project_only='allow_none'): return IMPL.network_get_all(context, project_only)
Return all defined networks.
return all defined networks .
Question: What does this function do? Code: def network_get_all(context, project_only='allow_none'): return IMPL.network_get_all(context, project_only)
null
null
null
What does this function do?
def match_dict_keys(keys, prefix, delims): if (not prefix): return (None, 0, [repr(k) for k in keys if isinstance(k, (str, bytes))]) quote_match = re.search('["\']', prefix) quote = quote_match.group() try: prefix_str = eval((prefix + quote), {}) except Exception: return (None, 0, []) pattern = (('[^' + ''....
null
null
null
Used by dict_key_matches, matching the prefix to a list of keys
pcsd
def match dict keys keys prefix delims if not prefix return None 0 [repr k for k in keys if isinstance k str bytes ] quote match = re search '["\']' prefix quote = quote match group try prefix str = eval prefix + quote {} except Exception return None 0 [] pattern = '[^' + '' join '\\' + c for c in delims + ']*$' token ...
1992
def match_dict_keys(keys, prefix, delims): if (not prefix): return (None, 0, [repr(k) for k in keys if isinstance(k, (str, bytes))]) quote_match = re.search('["\']', prefix) quote = quote_match.group() try: prefix_str = eval((prefix + quote), {}) except Exception: return (None, 0, []) pattern = (('[^' + ''....
Used by dict_key_matches, matching the prefix to a list of keys
used by dict _ key _ matches , matching the prefix to a list of keys
Question: What does this function do? Code: def match_dict_keys(keys, prefix, delims): if (not prefix): return (None, 0, [repr(k) for k in keys if isinstance(k, (str, bytes))]) quote_match = re.search('["\']', prefix) quote = quote_match.group() try: prefix_str = eval((prefix + quote), {}) except Exception:...
null
null
null
What does this function do?
def is_dir_url(link): link_path = url_to_path(link.url_without_fragment) return os.path.isdir(link_path)
null
null
null
Return whether a file:// Link points to a directory. ``link`` must not have any other scheme but file://. Call is_file_url() first.
pcsd
def is dir url link link path = url to path link url without fragment return os path isdir link path
1996
def is_dir_url(link): link_path = url_to_path(link.url_without_fragment) return os.path.isdir(link_path)
Return whether a file:// Link points to a directory. ``link`` must not have any other scheme but file://. Call is_file_url() first.
return whether a file : / / link points to a directory .
Question: What does this function do? Code: def is_dir_url(link): link_path = url_to_path(link.url_without_fragment) return os.path.isdir(link_path)
null
null
null
What does this function do?
@conf.commands.register def bind_layers(lower, upper, __fval=None, **fval): if (__fval is not None): fval.update(__fval) bind_top_down(lower, upper, **fval) bind_bottom_up(lower, upper, **fval)
null
null
null
Bind 2 layers on some specific fields\' values
pcsd
@conf commands register def bind layers lower upper fval=None **fval if fval is not None fval update fval bind top down lower upper **fval bind bottom up lower upper **fval
2003
@conf.commands.register def bind_layers(lower, upper, __fval=None, **fval): if (__fval is not None): fval.update(__fval) bind_top_down(lower, upper, **fval) bind_bottom_up(lower, upper, **fval)
Bind 2 layers on some specific fields\' values
bind 2 layers on some specific fields values
Question: What does this function do? Code: @conf.commands.register def bind_layers(lower, upper, __fval=None, **fval): if (__fval is not None): fval.update(__fval) bind_top_down(lower, upper, **fval) bind_bottom_up(lower, upper, **fval)
null
null
null
What does this function do?
@no_debug_mode def check_sample_correctishness_channelwise(f): batch_size = 27 pool_size = 4 n = (pool_size * 21) rng = np.random.RandomState([2012, 9, 26]) zv = ((rng.randn(batch_size, n).astype(config.floatX) * 3.5) - 5.0) top_down_v = rng.randn(batch_size, (n / pool_size)).astype(config.floatX) z_th = T.matri...
null
null
null
Tests that the sample mean converges to the conditional expectation given by the function Tests that p really is the max of the samples tests that at most one h in a group is on
pcsd
@no debug mode def check sample correctishness channelwise f batch size = 27 pool size = 4 n = pool size * 21 rng = np random Random State [2012 9 26] zv = rng randn batch size n astype config float X * 3 5 - 5 0 top down v = rng randn batch size n / pool size astype config float X z th = T matrix z th tag test value =...
2010
@no_debug_mode def check_sample_correctishness_channelwise(f): batch_size = 27 pool_size = 4 n = (pool_size * 21) rng = np.random.RandomState([2012, 9, 26]) zv = ((rng.randn(batch_size, n).astype(config.floatX) * 3.5) - 5.0) top_down_v = rng.randn(batch_size, (n / pool_size)).astype(config.floatX) z_th = T.matri...
Tests that the sample mean converges to the conditional expectation given by the function Tests that p really is the max of the samples tests that at most one h in a group is on
tests that the sample mean converges to the conditional expectation given by the function tests that p really is the max of the samples tests that at most one h in a group is on
Question: What does this function do? Code: @no_debug_mode def check_sample_correctishness_channelwise(f): batch_size = 27 pool_size = 4 n = (pool_size * 21) rng = np.random.RandomState([2012, 9, 26]) zv = ((rng.randn(batch_size, n).astype(config.floatX) * 3.5) - 5.0) top_down_v = rng.randn(batch_size, (n / po...
null
null
null
What does this function do?
def extract_metadata(f): from headphones import logger results = [] count = 0 for (root, dirs, files) in os.walk(f): for file in files: extension = os.path.splitext(file)[1].lower()[1:] if (extension in headphones.MEDIA_FORMATS): count += 1 try: media_file = MediaFile(os.path.join(root, file)) ...
null
null
null
Scan all files in the given directory and decide on an artist, album and year based on the metadata. A decision is based on the number of different artists, albums and years found in the media files.
pcsd
def extract metadata f from headphones import logger results = [] count = 0 for root dirs files in os walk f for file in files extension = os path splitext file [1] lower [1 ] if extension in headphones MEDIA FORMATS count += 1 try media file = Media File os path join root file except File Type Error Unreadable File Er...
2013
def extract_metadata(f): from headphones import logger results = [] count = 0 for (root, dirs, files) in os.walk(f): for file in files: extension = os.path.splitext(file)[1].lower()[1:] if (extension in headphones.MEDIA_FORMATS): count += 1 try: media_file = MediaFile(os.path.join(root, file)) ...
Scan all files in the given directory and decide on an artist, album and year based on the metadata. A decision is based on the number of different artists, albums and years found in the media files.
scan all files in the given directory and decide on an artist , album and year based on the metadata .
Question: What does this function do? Code: def extract_metadata(f): from headphones import logger results = [] count = 0 for (root, dirs, files) in os.walk(f): for file in files: extension = os.path.splitext(file)[1].lower()[1:] if (extension in headphones.MEDIA_FORMATS): count += 1 try: medi...
null
null
null
What does this function do?
@utils.arg('server', metavar='<server>', help=_('Name or ID of server.')) @utils.arg('secgroup', metavar='<secgroup>', help=_('Name of Security Group.')) def do_remove_secgroup(cs, args): server = _find_server(cs, args.server) server.remove_security_group(args.secgroup)
null
null
null
Remove a Security Group from a server.
pcsd
@utils arg 'server' metavar='<server>' help= 'Name or ID of server ' @utils arg 'secgroup' metavar='<secgroup>' help= 'Name of Security Group ' def do remove secgroup cs args server = find server cs args server server remove security group args secgroup
2014
@utils.arg('server', metavar='<server>', help=_('Name or ID of server.')) @utils.arg('secgroup', metavar='<secgroup>', help=_('Name of Security Group.')) def do_remove_secgroup(cs, args): server = _find_server(cs, args.server) server.remove_security_group(args.secgroup)
Remove a Security Group from a server.
remove a security group from a server .
Question: What does this function do? Code: @utils.arg('server', metavar='<server>', help=_('Name or ID of server.')) @utils.arg('secgroup', metavar='<secgroup>', help=_('Name of Security Group.')) def do_remove_secgroup(cs, args): server = _find_server(cs, args.server) server.remove_security_group(args.secgroup)
null
null
null
What does this function do?
@pytest.fixture def template_name(): return 'cookiedozer'
null
null
null
Fixture to return a valid template_name.
pcsd
@pytest fixture def template name return 'cookiedozer'
2025
@pytest.fixture def template_name(): return 'cookiedozer'
Fixture to return a valid template_name.
fixture to return a valid template _ name .
Question: What does this function do? Code: @pytest.fixture def template_name(): return 'cookiedozer'
null
null
null
What does this function do?
def ingest_cifar10(out_dir, padded_size, overwrite=False): dataset = dict() cifar10 = CIFAR10(path=out_dir, normalize=False) (dataset['train'], dataset['val'], _) = cifar10.load_data() pad_size = (((padded_size - 32) // 2) if (padded_size > 32) else 0) pad_width = ((0, 0), (pad_size, pad_size), (pad_size, pad_size...
null
null
null
Save CIFAR-10 dataset as PNG files
pcsd
def ingest cifar10 out dir padded size overwrite=False dataset = dict cifar10 = CIFAR10 path=out dir normalize=False dataset['train'] dataset['val'] = cifar10 load data pad size = padded size - 32 // 2 if padded size > 32 else 0 pad width = 0 0 pad size pad size pad size pad size set names = 'train' 'val' manifest file...
2034
def ingest_cifar10(out_dir, padded_size, overwrite=False): dataset = dict() cifar10 = CIFAR10(path=out_dir, normalize=False) (dataset['train'], dataset['val'], _) = cifar10.load_data() pad_size = (((padded_size - 32) // 2) if (padded_size > 32) else 0) pad_width = ((0, 0), (pad_size, pad_size), (pad_size, pad_size...
Save CIFAR-10 dataset as PNG files
save cifar - 10 dataset as png files
Question: What does this function do? Code: def ingest_cifar10(out_dir, padded_size, overwrite=False): dataset = dict() cifar10 = CIFAR10(path=out_dir, normalize=False) (dataset['train'], dataset['val'], _) = cifar10.load_data() pad_size = (((padded_size - 32) // 2) if (padded_size > 32) else 0) pad_width = ((0...
null
null
null
What does this function do?
def num2strg(num): s = str(num) if s.endswith('.0'): s = s[:(-2)] return s
null
null
null
Attempt to emulate Excel\'s default conversion from number to string.
pcsd
def num2strg num s = str num if s endswith ' 0' s = s[ -2 ] return s
2037
def num2strg(num): s = str(num) if s.endswith('.0'): s = s[:(-2)] return s
Attempt to emulate Excel\'s default conversion from number to string.
attempt to emulate excels default conversion from number to string .
Question: What does this function do? Code: def num2strg(num): s = str(num) if s.endswith('.0'): s = s[:(-2)] return s
null
null
null
What does this function do?
@task @timed def i18n_validate_transifex_config(): home = path('~').expanduser() config = (home / '.transifexrc') if ((not config.isfile) or (config.getsize == 0)): msg = colorize('red', 'Cannot connect to Transifex, config file is missing or empty: {config} \nSee http://help.transifex.com/features/client/#transif...
null
null
null
Make sure config file with username/password exists
pcsd
@task @timed def i18n validate transifex config home = path '~' expanduser config = home / ' transifexrc' if not config isfile or config getsize == 0 msg = colorize 'red' 'Cannot connect to Transifex config file is missing or empty {config} See http //help transifex com/features/client/#transifexrc ' format config=conf...
2040
@task @timed def i18n_validate_transifex_config(): home = path('~').expanduser() config = (home / '.transifexrc') if ((not config.isfile) or (config.getsize == 0)): msg = colorize('red', 'Cannot connect to Transifex, config file is missing or empty: {config} \nSee http://help.transifex.com/features/client/#transif...
Make sure config file with username/password exists
make sure config file with username / password exists
Question: What does this function do? Code: @task @timed def i18n_validate_transifex_config(): home = path('~').expanduser() config = (home / '.transifexrc') if ((not config.isfile) or (config.getsize == 0)): msg = colorize('red', 'Cannot connect to Transifex, config file is missing or empty: {config} \nSee htt...
null
null
null
What does this function do?
def asset_get_current_log(asset_id): table = current.s3db.asset_log query = (((table.asset_id == asset_id) & (table.cancel == False)) & (table.deleted == False)) asset_log = current.db(query).select(table.id, table.status, table.datetime, table.cond, table.person_id, table.organisation_id, table.site_id, orderby=(~ ...
null
null
null
Get the current log entry for this asset
pcsd
def asset get current log asset id table = current s3db asset log query = table asset id == asset id & table cancel == False & table deleted == False asset log = current db query select table id table status table datetime table cond table person id table organisation id table site id orderby= ~ table datetime limitby=...
2044
def asset_get_current_log(asset_id): table = current.s3db.asset_log query = (((table.asset_id == asset_id) & (table.cancel == False)) & (table.deleted == False)) asset_log = current.db(query).select(table.id, table.status, table.datetime, table.cond, table.person_id, table.organisation_id, table.site_id, orderby=(~ ...
Get the current log entry for this asset
get the current log entry for this asset
Question: What does this function do? Code: def asset_get_current_log(asset_id): table = current.s3db.asset_log query = (((table.asset_id == asset_id) & (table.cancel == False)) & (table.deleted == False)) asset_log = current.db(query).select(table.id, table.status, table.datetime, table.cond, table.person_id, ta...
null
null
null
What does this function do?
def normalize_path(path): return os.path.normcase(os.path.realpath(path))
null
null
null
Convert a path to its canonical, case-normalized, absolute version.
pcsd
def normalize path path return os path normcase os path realpath path
2051
def normalize_path(path): return os.path.normcase(os.path.realpath(path))
Convert a path to its canonical, case-normalized, absolute version.
convert a path to its canonical , case - normalized , absolute version .
Question: What does this function do? Code: def normalize_path(path): return os.path.normcase(os.path.realpath(path))
null
null
null
What does this function do?
def clean_orphan_obj_perms(): from guardian.models import UserObjectPermission from guardian.models import GroupObjectPermission deleted = 0 for perm in chain(UserObjectPermission.objects.all().iterator(), GroupObjectPermission.objects.all().iterator()): if (perm.content_object is None): logger.debug((u'Removi...
null
null
null
Seeks and removes all object permissions entries pointing at non-existing targets. Returns number of removed objects.
pcsd
def clean orphan obj perms from guardian models import User Object Permission from guardian models import Group Object Permission deleted = 0 for perm in chain User Object Permission objects all iterator Group Object Permission objects all iterator if perm content object is None logger debug u'Removing %s pk=%d ' % per...
2058
def clean_orphan_obj_perms(): from guardian.models import UserObjectPermission from guardian.models import GroupObjectPermission deleted = 0 for perm in chain(UserObjectPermission.objects.all().iterator(), GroupObjectPermission.objects.all().iterator()): if (perm.content_object is None): logger.debug((u'Removi...
Seeks and removes all object permissions entries pointing at non-existing targets. Returns number of removed objects.
seeks and removes all object permissions entries pointing at non - existing targets .
Question: What does this function do? Code: def clean_orphan_obj_perms(): from guardian.models import UserObjectPermission from guardian.models import GroupObjectPermission deleted = 0 for perm in chain(UserObjectPermission.objects.all().iterator(), GroupObjectPermission.objects.all().iterator()): if (perm.con...
null
null
null
What does this function do?
def repeat(stmt='pass', setup='pass', timer=default_timer, repeat=default_repeat, number=default_number): return Timer(stmt, setup, timer).repeat(repeat, number)
null
null
null
Convenience function to create Timer object and call repeat method.
pcsd
def repeat stmt='pass' setup='pass' timer=default timer repeat=default repeat number=default number return Timer stmt setup timer repeat repeat number
2063
def repeat(stmt='pass', setup='pass', timer=default_timer, repeat=default_repeat, number=default_number): return Timer(stmt, setup, timer).repeat(repeat, number)
Convenience function to create Timer object and call repeat method.
convenience function to create timer object and call repeat method .
Question: What does this function do? Code: def repeat(stmt='pass', setup='pass', timer=default_timer, repeat=default_repeat, number=default_number): return Timer(stmt, setup, timer).repeat(repeat, number)
null
null
null
What does this function do?
def squeeze_2x2(input_): return squeeze_nxn(input_, n_factor=2)
null
null
null
Squeezing operation: reshape to convert space to channels.
pcsd
def squeeze 2x2 input return squeeze nxn input n factor=2
2092
def squeeze_2x2(input_): return squeeze_nxn(input_, n_factor=2)
Squeezing operation: reshape to convert space to channels.
squeezing operation : reshape to convert space to channels .
Question: What does this function do? Code: def squeeze_2x2(input_): return squeeze_nxn(input_, n_factor=2)
null
null
null
What does this function do?
def assert_not_none(actual, msg=None): assert (actual is not None), msg
null
null
null
verify that item is None
pcsd
def assert not none actual msg=None assert actual is not None msg
2098
def assert_not_none(actual, msg=None): assert (actual is not None), msg
verify that item is None
verify that item is none
Question: What does this function do? Code: def assert_not_none(actual, msg=None): assert (actual is not None), msg
null
null
null
What does this function do?
def verify_files(files, user): if salt.utils.is_windows(): return True import pwd try: pwnam = pwd.getpwnam(user) uid = pwnam[2] except KeyError: err = 'Failed to prepare the Salt environment for user {0}. The user is not available.\n'.format(user) sys.stderr.write(err) sys.exit(salt.defaults.exitcodes....
null
null
null
Verify that the named files exist and are owned by the named user
pcsd
def verify files files user if salt utils is windows return True import pwd try pwnam = pwd getpwnam user uid = pwnam[2] except Key Error err = 'Failed to prepare the Salt environment for user {0} The user is not available ' format user sys stderr write err sys exit salt defaults exitcodes EX NOUSER for fn in files dir...
2102
def verify_files(files, user): if salt.utils.is_windows(): return True import pwd try: pwnam = pwd.getpwnam(user) uid = pwnam[2] except KeyError: err = 'Failed to prepare the Salt environment for user {0}. The user is not available.\n'.format(user) sys.stderr.write(err) sys.exit(salt.defaults.exitcodes....
Verify that the named files exist and are owned by the named user
verify that the named files exist and are owned by the named user
Question: What does this function do? Code: def verify_files(files, user): if salt.utils.is_windows(): return True import pwd try: pwnam = pwd.getpwnam(user) uid = pwnam[2] except KeyError: err = 'Failed to prepare the Salt environment for user {0}. The user is not available.\n'.format(user) sys.stderr...
null
null
null
What does this function do?
def _needs_update(subnet, module, cloud): _can_update(subnet, module, cloud) enable_dhcp = module.params['enable_dhcp'] subnet_name = module.params['name'] pool_start = module.params['allocation_pool_start'] pool_end = module.params['allocation_pool_end'] gateway_ip = module.params['gateway_ip'] no_gateway_ip = ...
null
null
null
Check for differences in the updatable values.
pcsd
def needs update subnet module cloud can update subnet module cloud enable dhcp = module params['enable dhcp'] subnet name = module params['name'] pool start = module params['allocation pool start'] pool end = module params['allocation pool end'] gateway ip = module params['gateway ip'] no gateway ip = module params['n...
2105
def _needs_update(subnet, module, cloud): _can_update(subnet, module, cloud) enable_dhcp = module.params['enable_dhcp'] subnet_name = module.params['name'] pool_start = module.params['allocation_pool_start'] pool_end = module.params['allocation_pool_end'] gateway_ip = module.params['gateway_ip'] no_gateway_ip = ...
Check for differences in the updatable values.
check for differences in the updatable values .
Question: What does this function do? Code: def _needs_update(subnet, module, cloud): _can_update(subnet, module, cloud) enable_dhcp = module.params['enable_dhcp'] subnet_name = module.params['name'] pool_start = module.params['allocation_pool_start'] pool_end = module.params['allocation_pool_end'] gateway_ip ...
null
null
null
What does this function do?
def _validate_center_shape(X, n_centers, centers): if (len(centers) != n_centers): raise ValueError(('The shape of the initial centers (%s) does not match the number of clusters %i' % (centers.shape, n_centers))) if (centers.shape[1] != X.shape[1]): raise ValueError(('The number of features of the initial centers...
null
null
null
Check if centers is compatible with X and n_centers
pcsd
def validate center shape X n centers centers if len centers != n centers raise Value Error 'The shape of the initial centers %s does not match the number of clusters %i' % centers shape n centers if centers shape[1] != X shape[1] raise Value Error 'The number of features of the initial centers %s does not match the nu...
2112
def _validate_center_shape(X, n_centers, centers): if (len(centers) != n_centers): raise ValueError(('The shape of the initial centers (%s) does not match the number of clusters %i' % (centers.shape, n_centers))) if (centers.shape[1] != X.shape[1]): raise ValueError(('The number of features of the initial centers...
Check if centers is compatible with X and n_centers
check if centers is compatible with x and n _ centers
Question: What does this function do? Code: def _validate_center_shape(X, n_centers, centers): if (len(centers) != n_centers): raise ValueError(('The shape of the initial centers (%s) does not match the number of clusters %i' % (centers.shape, n_centers))) if (centers.shape[1] != X.shape[1]): raise ValueError(...
null
null
null
What does this function do?
@pytest.mark.parametrize('value, typ', [(None, None), (42, int)]) def test_conv_default_param(value, typ): def func(foo=value): pass param = inspect.signature(func).parameters['foo'] assert (argparser.type_conv(param, typ, value, str_choices=['val']) == value)
null
null
null
The default value should always be a valid choice.
pcsd
@pytest mark parametrize 'value typ' [ None None 42 int ] def test conv default param value typ def func foo=value pass param = inspect signature func parameters['foo'] assert argparser type conv param typ value str choices=['val'] == value
2115
@pytest.mark.parametrize('value, typ', [(None, None), (42, int)]) def test_conv_default_param(value, typ): def func(foo=value): pass param = inspect.signature(func).parameters['foo'] assert (argparser.type_conv(param, typ, value, str_choices=['val']) == value)
The default value should always be a valid choice.
the default value should always be a valid choice .
Question: What does this function do? Code: @pytest.mark.parametrize('value, typ', [(None, None), (42, int)]) def test_conv_default_param(value, typ): def func(foo=value): pass param = inspect.signature(func).parameters['foo'] assert (argparser.type_conv(param, typ, value, str_choices=['val']) == value)
null
null
null
What does this function do?
@testing.requires_testing_data def test_io_complex(): rng = np.random.RandomState(0) tempdir = _TempDir() dtypes = [np.complex64, np.complex128] raw = _test_raw_reader(partial(read_raw_fif), fname=fif_fname) picks = np.arange(5) (start, stop) = raw.time_as_index([0, 5]) (data_orig, _) = raw[picks, start:stop] f...
null
null
null
Test IO with complex data types.
pcsd
@testing requires testing data def test io complex rng = np random Random State 0 tempdir = Temp Dir dtypes = [np complex64 np complex128] raw = test raw reader partial read raw fif fname=fif fname picks = np arange 5 start stop = raw time as index [0 5] data orig = raw[picks start stop] for di dtype in enumerate dtype...
2126
@testing.requires_testing_data def test_io_complex(): rng = np.random.RandomState(0) tempdir = _TempDir() dtypes = [np.complex64, np.complex128] raw = _test_raw_reader(partial(read_raw_fif), fname=fif_fname) picks = np.arange(5) (start, stop) = raw.time_as_index([0, 5]) (data_orig, _) = raw[picks, start:stop] f...
Test IO with complex data types.
test io with complex data types .
Question: What does this function do? Code: @testing.requires_testing_data def test_io_complex(): rng = np.random.RandomState(0) tempdir = _TempDir() dtypes = [np.complex64, np.complex128] raw = _test_raw_reader(partial(read_raw_fif), fname=fif_fname) picks = np.arange(5) (start, stop) = raw.time_as_index([0, ...
null
null
null
What does this function do?
def p_expression_name(t): try: t[0] = names[t[1]] except LookupError: print (u"Undefined name '%s'" % t[1]) t[0] = 0
null
null
null
expression : NAME
pcsd
def p expression name t try t[0] = names[t[1]] except Lookup Error print u"Undefined name '%s'" % t[1] t[0] = 0
2132
def p_expression_name(t): try: t[0] = names[t[1]] except LookupError: print (u"Undefined name '%s'" % t[1]) t[0] = 0
expression : NAME
expression : name
Question: What does this function do? Code: def p_expression_name(t): try: t[0] = names[t[1]] except LookupError: print (u"Undefined name '%s'" % t[1]) t[0] = 0
null
null
null
What does this function do?
def get_temp_dir(): temp = get_environ_variable('TMP') if (temp == None): temp = get_environ_variable('TEMP') if (((temp == None) or (' ' in temp)) and (os.name == 'nt')): temp = 'C:\\temp' if (((temp == None) or (' ' in temp)) and (os.name == 'posix')): temp = '/tmp' return temp
null
null
null
Returns a temporary directory.
pcsd
def get temp dir temp = get environ variable 'TMP' if temp == None temp = get environ variable 'TEMP' if temp == None or ' ' in temp and os name == 'nt' temp = 'C \ emp' if temp == None or ' ' in temp and os name == 'posix' temp = '/tmp' return temp
2138
def get_temp_dir(): temp = get_environ_variable('TMP') if (temp == None): temp = get_environ_variable('TEMP') if (((temp == None) or (' ' in temp)) and (os.name == 'nt')): temp = 'C:\\temp' if (((temp == None) or (' ' in temp)) and (os.name == 'posix')): temp = '/tmp' return temp
Returns a temporary directory.
returns a temporary directory .
Question: What does this function do? Code: def get_temp_dir(): temp = get_environ_variable('TMP') if (temp == None): temp = get_environ_variable('TEMP') if (((temp == None) or (' ' in temp)) and (os.name == 'nt')): temp = 'C:\\temp' if (((temp == None) or (' ' in temp)) and (os.name == 'posix')): temp = '...
null
null
null
What does this function do?
def delete_instance_type_info(metadata, *prefixes): for key in system_metadata_instance_type_props.keys(): for prefix in prefixes: to_key = ('%sinstance_type_%s' % (prefix, key)) del metadata[to_key] return metadata
null
null
null
Delete instance_type information from instance\'s system_metadata by prefix.
pcsd
def delete instance type info metadata *prefixes for key in system metadata instance type props keys for prefix in prefixes to key = '%sinstance type %s' % prefix key del metadata[to key] return metadata
2140
def delete_instance_type_info(metadata, *prefixes): for key in system_metadata_instance_type_props.keys(): for prefix in prefixes: to_key = ('%sinstance_type_%s' % (prefix, key)) del metadata[to_key] return metadata
Delete instance_type information from instance\'s system_metadata by prefix.
delete instance _ type information from instances system _ metadata by prefix .
Question: What does this function do? Code: def delete_instance_type_info(metadata, *prefixes): for key in system_metadata_instance_type_props.keys(): for prefix in prefixes: to_key = ('%sinstance_type_%s' % (prefix, key)) del metadata[to_key] return metadata
null
null
null
What does this function do?
def list_compatible(): workflows = get_compatible() feedback = alfred.Feedback() for w in workflows: subtitle = ((('v' + unicode(w.version)) + ' ') + w.description) feedback.addItem(title=w.name, subtitle=subtitle, icon=w.icon, valid='no') if feedback.isEmpty(): feedback.addItem(title='No compatible workflows...
null
null
null
Displays all Alleyoop compatible workflows
pcsd
def list compatible workflows = get compatible feedback = alfred Feedback for w in workflows subtitle = 'v' + unicode w version + ' ' + w description feedback add Item title=w name subtitle=subtitle icon=w icon valid='no' if feedback is Empty feedback add Item title='No compatible workflows found' valid='no' autocomple...
2152
def list_compatible(): workflows = get_compatible() feedback = alfred.Feedback() for w in workflows: subtitle = ((('v' + unicode(w.version)) + ' ') + w.description) feedback.addItem(title=w.name, subtitle=subtitle, icon=w.icon, valid='no') if feedback.isEmpty(): feedback.addItem(title='No compatible workflows...
Displays all Alleyoop compatible workflows
displays all alleyoop compatible workflows
Question: What does this function do? Code: def list_compatible(): workflows = get_compatible() feedback = alfred.Feedback() for w in workflows: subtitle = ((('v' + unicode(w.version)) + ' ') + w.description) feedback.addItem(title=w.name, subtitle=subtitle, icon=w.icon, valid='no') if feedback.isEmpty(): ...
null
null
null
What does this function do?
def get_template_request_context(request=None): if (request is None): request = get_current_request() if (request is None): return None request_cache_dict = request_cache.get_cache('edxmako') cache_key = 'request_context' if (cache_key in request_cache_dict): return request_cache_dict[cache_key] context = R...
null
null
null
Returns the template processing context to use for the current request, or returns None if there is not a current request.
pcsd
def get template request context request=None if request is None request = get current request if request is None return None request cache dict = request cache get cache 'edxmako' cache key = 'request context' if cache key in request cache dict return request cache dict[cache key] context = Request Context request con...
2156
def get_template_request_context(request=None): if (request is None): request = get_current_request() if (request is None): return None request_cache_dict = request_cache.get_cache('edxmako') cache_key = 'request_context' if (cache_key in request_cache_dict): return request_cache_dict[cache_key] context = R...
Returns the template processing context to use for the current request, or returns None if there is not a current request.
returns the template processing context to use for the current request , or returns none if there is not a current request .
Question: What does this function do? Code: def get_template_request_context(request=None): if (request is None): request = get_current_request() if (request is None): return None request_cache_dict = request_cache.get_cache('edxmako') cache_key = 'request_context' if (cache_key in request_cache_dict): re...
null
null
null
What does this function do?
def backwards(apps, schema_editor): certificate_html_view_configuration_model = apps.get_model(u'certificates', u'CertificateHtmlViewConfiguration') certificate_html_view_configuration_model.objects.all().delete()
null
null
null
Rolling back to zero-state, so remove all currently-defined configurations
pcsd
def backwards apps schema editor certificate html view configuration model = apps get model u'certificates' u'Certificate Html View Configuration' certificate html view configuration model objects all delete
2160
def backwards(apps, schema_editor): certificate_html_view_configuration_model = apps.get_model(u'certificates', u'CertificateHtmlViewConfiguration') certificate_html_view_configuration_model.objects.all().delete()
Rolling back to zero-state, so remove all currently-defined configurations
rolling back to zero - state , so remove all currently - defined configurations
Question: What does this function do? Code: def backwards(apps, schema_editor): certificate_html_view_configuration_model = apps.get_model(u'certificates', u'CertificateHtmlViewConfiguration') certificate_html_view_configuration_model.objects.all().delete()
null
null
null
What does this function do?
@requires_auth('home') def schema_collection_endpoint(): schemas = {} for (resource_name, resource_config) in app.config['DOMAIN'].items(): if resource_name.endswith(config.VERSIONS): continue internal = resource_config.get('internal_resource', False) if internal: continue auth = resource_auth(resource_...
null
null
null
This endpoint is active when SCHEMA_ENDPOINT != None. It returns the schema definition for all public or request authenticated resources in JSON format.
pcsd
@requires auth 'home' def schema collection endpoint schemas = {} for resource name resource config in app config['DOMAIN'] items if resource name endswith config VERSIONS continue internal = resource config get 'internal resource' False if internal continue auth = resource auth resource name if auth and request method...
2167
@requires_auth('home') def schema_collection_endpoint(): schemas = {} for (resource_name, resource_config) in app.config['DOMAIN'].items(): if resource_name.endswith(config.VERSIONS): continue internal = resource_config.get('internal_resource', False) if internal: continue auth = resource_auth(resource_...
This endpoint is active when SCHEMA_ENDPOINT != None. It returns the schema definition for all public or request authenticated resources in JSON format.
this endpoint is active when schema _ endpoint ! = none .
Question: What does this function do? Code: @requires_auth('home') def schema_collection_endpoint(): schemas = {} for (resource_name, resource_config) in app.config['DOMAIN'].items(): if resource_name.endswith(config.VERSIONS): continue internal = resource_config.get('internal_resource', False) if interna...
null
null
null
What does this function do?
def authenhandler(req, **kwargs): os.environ.update(req.subprocess_env) req.get_basic_auth_pw() _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('DjangoRequireStaffStat...
null
null
null
Authentication handler that checks against Django\'s auth database.
pcsd
def authenhandler req **kwargs os environ update req subprocess env req get basic auth pw 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 =...
2173
def authenhandler(req, **kwargs): os.environ.update(req.subprocess_env) req.get_basic_auth_pw() _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('DjangoRequireStaffStat...
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) req.get_basic_auth_pw() _str_to_bool = (lambda s: (s.lower() in ('1', 'true', 'on', 'yes'))) options = req.get_options() permission_name = options.get('DjangoPermissionName', None) staff_only = _...
null
null
null
What does this function do?
@coroutine def component1(reactor, session): (yield session.expose(api))
null
null
null
A first component, which gets called "setup-like". When it returns, this signals that the component is ready for work.
pcsd
@coroutine def component1 reactor session yield session expose api
2179
@coroutine def component1(reactor, session): (yield session.expose(api))
A first component, which gets called "setup-like". When it returns, this signals that the component is ready for work.
a first component , which gets called " setup - like " .
Question: What does this function do? Code: @coroutine def component1(reactor, session): (yield session.expose(api))
null
null
null
What does this function do?
def getWinDrives(): assert (os.name == 'nt') drives = [] bitmask = windll.kernel32.GetLogicalDrives() for letter in string.uppercase: if (bitmask & 1): drives.append(letter) bitmask >>= 1 return drives
null
null
null
Return list of detected drives
pcsd
def get Win Drives assert os name == 'nt' drives = [] bitmask = windll kernel32 Get Logical Drives for letter in string uppercase if bitmask & 1 drives append letter bitmask >>= 1 return drives
2183
def getWinDrives(): assert (os.name == 'nt') drives = [] bitmask = windll.kernel32.GetLogicalDrives() for letter in string.uppercase: if (bitmask & 1): drives.append(letter) bitmask >>= 1 return drives
Return list of detected drives
return list of detected drives
Question: What does this function do? Code: def getWinDrives(): assert (os.name == 'nt') drives = [] bitmask = windll.kernel32.GetLogicalDrives() for letter in string.uppercase: if (bitmask & 1): drives.append(letter) bitmask >>= 1 return drives
null
null
null
What does this function do?
def notificationResponse(): a = TpPd(pd=6) b = MessageType(mesType=38) c = MobileStationClassmark2() d = MobileId() e = DescriptiveGroupOrBroadcastCallReference() packet = ((((a / b) / c) / d) / e) return packet
null
null
null
NOTIFICATION RESPONSE Section 9.1.21d
pcsd
def notification Response a = Tp Pd pd=6 b = Message Type mes Type=38 c = Mobile Station Classmark2 d = Mobile Id e = Descriptive Group Or Broadcast Call Reference packet = a / b / c / d / e return packet
2184
def notificationResponse(): a = TpPd(pd=6) b = MessageType(mesType=38) c = MobileStationClassmark2() d = MobileId() e = DescriptiveGroupOrBroadcastCallReference() packet = ((((a / b) / c) / d) / e) return packet
NOTIFICATION RESPONSE Section 9.1.21d
notification response section 9 . 1 . 21d
Question: What does this function do? Code: def notificationResponse(): a = TpPd(pd=6) b = MessageType(mesType=38) c = MobileStationClassmark2() d = MobileId() e = DescriptiveGroupOrBroadcastCallReference() packet = ((((a / b) / c) / d) / e) return packet
null
null
null
What does this function do?
def log_info(message, **kwargs): if (not __QUIET__): if kwargs: message = message.format(**kwargs) print(message, file=sys.stderr)
null
null
null
For non-critical informative/status output to stderr.
pcsd
def log info message **kwargs if not QUIET if kwargs message = message format **kwargs print message file=sys stderr
2195
def log_info(message, **kwargs): if (not __QUIET__): if kwargs: message = message.format(**kwargs) print(message, file=sys.stderr)
For non-critical informative/status output to stderr.
for non - critical informative / status output to stderr .
Question: What does this function do? Code: def log_info(message, **kwargs): if (not __QUIET__): if kwargs: message = message.format(**kwargs) print(message, file=sys.stderr)
null
null
null
What does this function do?
def get_jobs(when=None, only_scheduled=False): import sys try: cpath = os.path.dirname(os.path.realpath(sys.argv[0])) ppath = os.path.dirname(cpath) if (ppath not in sys.path): sys.path.append(ppath) except: pass _jobs = {} if True: from django.conf import settings for app_name in settings.INSTALLED...
null
null
null
Returns a dictionary mapping of job names together with their respective application class.
pcsd
def get jobs when=None only scheduled=False import sys try cpath = os path dirname os path realpath sys argv[0] ppath = os path dirname cpath if ppath not in sys path sys path append ppath except pass jobs = {} if True from django conf import settings for app name in settings INSTALLED APPS scandirs = None 'minutely' '...
2197
def get_jobs(when=None, only_scheduled=False): import sys try: cpath = os.path.dirname(os.path.realpath(sys.argv[0])) ppath = os.path.dirname(cpath) if (ppath not in sys.path): sys.path.append(ppath) except: pass _jobs = {} if True: from django.conf import settings for app_name in settings.INSTALLED...
Returns a dictionary mapping of job names together with their respective application class.
returns a dictionary mapping of job names together with their respective application class .
Question: What does this function do? Code: def get_jobs(when=None, only_scheduled=False): import sys try: cpath = os.path.dirname(os.path.realpath(sys.argv[0])) ppath = os.path.dirname(cpath) if (ppath not in sys.path): sys.path.append(ppath) except: pass _jobs = {} if True: from django.conf impor...
null
null
null
What does this function do?
def fingerprint(key): key = base64.b64decode(key.strip().split()[1].encode('ascii')) fp_plain = hashlib.md5(key).hexdigest() return ':'.join(((a + b) for (a, b) in zip(fp_plain[::2], fp_plain[1::2])))
null
null
null
Return the fingerprint for an SSH Public Key
pcsd
def fingerprint key key = base64 b64decode key strip split [1] encode 'ascii' fp plain = hashlib md5 key hexdigest return ' ' join a + b for a b in zip fp plain[ 2] fp plain[1 2]
2198
def fingerprint(key): key = base64.b64decode(key.strip().split()[1].encode('ascii')) fp_plain = hashlib.md5(key).hexdigest() return ':'.join(((a + b) for (a, b) in zip(fp_plain[::2], fp_plain[1::2])))
Return the fingerprint for an SSH Public Key
return the fingerprint for an ssh public key
Question: What does this function do? Code: def fingerprint(key): key = base64.b64decode(key.strip().split()[1].encode('ascii')) fp_plain = hashlib.md5(key).hexdigest() return ':'.join(((a + b) for (a, b) in zip(fp_plain[::2], fp_plain[1::2])))
null
null
null
What does this function do?
def _envs(branch, repo_location): gitpil = _LegacyGitPillar(branch, repo_location, __opts__) return gitpil.envs()
null
null
null
Return a list of refs that can be used as environments
pcsd
def envs branch repo location gitpil = Legacy Git Pillar branch repo location opts return gitpil envs
2200
def _envs(branch, repo_location): gitpil = _LegacyGitPillar(branch, repo_location, __opts__) return gitpil.envs()
Return a list of refs that can be used as environments
return a list of refs that can be used as environments
Question: What does this function do? Code: def _envs(branch, repo_location): gitpil = _LegacyGitPillar(branch, repo_location, __opts__) return gitpil.envs()
null
null
null
What does this function do?
def mc2mnc(mc): n = len(mc) mean = mc[0] mc = ([1] + list(mc)) mc[1] = 0 mnc = [1, mean] for (nn, m) in enumerate(mc[2:]): n = (nn + 2) mnc.append(0) for k in range((n + 1)): mnc[n] += ((comb(n, k, exact=1) * mc[k]) * (mean ** (n - k))) return mnc[1:]
null
null
null
convert central to non-central moments, uses recursive formula optionally adjusts first moment to return mean
pcsd
def mc2mnc mc n = len mc mean = mc[0] mc = [1] + list mc mc[1] = 0 mnc = [1 mean] for nn m in enumerate mc[2 ] n = nn + 2 mnc append 0 for k in range n + 1 mnc[n] += comb n k exact=1 * mc[k] * mean ** n - k return mnc[1 ]
2218
def mc2mnc(mc): n = len(mc) mean = mc[0] mc = ([1] + list(mc)) mc[1] = 0 mnc = [1, mean] for (nn, m) in enumerate(mc[2:]): n = (nn + 2) mnc.append(0) for k in range((n + 1)): mnc[n] += ((comb(n, k, exact=1) * mc[k]) * (mean ** (n - k))) return mnc[1:]
convert central to non-central moments, uses recursive formula optionally adjusts first moment to return mean
convert central to non - central moments , uses recursive formula optionally adjusts first moment to return mean
Question: What does this function do? Code: def mc2mnc(mc): n = len(mc) mean = mc[0] mc = ([1] + list(mc)) mc[1] = 0 mnc = [1, mean] for (nn, m) in enumerate(mc[2:]): n = (nn + 2) mnc.append(0) for k in range((n + 1)): mnc[n] += ((comb(n, k, exact=1) * mc[k]) * (mean ** (n - k))) return mnc[1:]
null
null
null
What does this function do?
def get_version(version=None): if (version is None): from gfirefly import VERSION as version else: assert (len(version) == 5) assert (version[3] in (u'alpha', u'beta', u'rc', u'final')) parts = (2 if (version[2] == 0) else 3) main = u'.'.join((str(x) for x in version[:parts])) sub = u'' if ((version[3] == u...
null
null
null
Returns a PEP 386-compliant version number from VERSION.
pcsd
def get version version=None if version is None from gfirefly import VERSION as version else assert len version == 5 assert version[3] in u'alpha' u'beta' u'rc' u'final' parts = 2 if version[2] == 0 else 3 main = u' ' join str x for x in version[ parts] sub = u'' if version[3] == u'alpha' and version[4] == 0 git change...
2219
def get_version(version=None): if (version is None): from gfirefly import VERSION as version else: assert (len(version) == 5) assert (version[3] in (u'alpha', u'beta', u'rc', u'final')) parts = (2 if (version[2] == 0) else 3) main = u'.'.join((str(x) for x in version[:parts])) sub = u'' if ((version[3] == u...
Returns a PEP 386-compliant version number from VERSION.
returns a pep 386 - compliant version number from version .
Question: What does this function do? Code: def get_version(version=None): if (version is None): from gfirefly import VERSION as version else: assert (len(version) == 5) assert (version[3] in (u'alpha', u'beta', u'rc', u'final')) parts = (2 if (version[2] == 0) else 3) main = u'.'.join((str(x) for x in ver...
null
null
null
What does this function do?
def getKeyM(row, column, prefix=''): return ('%sm%s%s' % (prefix, (row + 1), (column + 1)))
null
null
null
Get the m format key string from row & column, counting from one.
pcsd
def get Key M row column prefix='' return '%sm%s%s' % prefix row + 1 column + 1
2223
def getKeyM(row, column, prefix=''): return ('%sm%s%s' % (prefix, (row + 1), (column + 1)))
Get the m format key string from row & column, counting from one.
get the m format key string from row & column , counting from one .
Question: What does this function do? Code: def getKeyM(row, column, prefix=''): return ('%sm%s%s' % (prefix, (row + 1), (column + 1)))
null
null
null
What does this function do?
def getFloat(floatString): try: return float(floatString) except: return float(floatString.replace(',', '.'))
null
null
null
Get the float, replacing commas if necessary because an inferior program is using a comma instead of a point for the decimal point.
pcsd
def get Float float String try return float float String except return float float String replace ' ' ' '
2237
def getFloat(floatString): try: return float(floatString) except: return float(floatString.replace(',', '.'))
Get the float, replacing commas if necessary because an inferior program is using a comma instead of a point for the decimal point.
get the float , replacing commas if necessary because an inferior program is using a comma instead of a point for the decimal point .
Question: What does this function do? Code: def getFloat(floatString): try: return float(floatString) except: return float(floatString.replace(',', '.'))
null
null
null
What does this function do?
def body(request): return HttpResponse(request.body)
null
null
null
A view that is requested with GET and accesses request.body. Refs #14753.
pcsd
def body request return Http Response request body
2247
def body(request): return HttpResponse(request.body)
A view that is requested with GET and accesses request.body. Refs #14753.
a view that is requested with get and accesses request . body .
Question: What does this function do? Code: def body(request): return HttpResponse(request.body)
null
null
null
What does this function do?
def init_model(engine): meta.Session.remove() meta.Session.configure(bind=engine) meta.create_local_session.configure(bind=engine) meta.engine = engine meta.metadata.bind = engine import sqlalchemy.exc try: global version_table version_table = Table('migrate_version', meta.metadata, autoload=True) except sq...
null
null
null
Call me before using any of the tables or classes in the model
pcsd
def init model engine meta Session remove meta Session configure bind=engine meta create local session configure bind=engine meta engine = engine meta metadata bind = engine import sqlalchemy exc try global version table version table = Table 'migrate version' meta metadata autoload=True except sqlalchemy exc No Such T...
2249
def init_model(engine): meta.Session.remove() meta.Session.configure(bind=engine) meta.create_local_session.configure(bind=engine) meta.engine = engine meta.metadata.bind = engine import sqlalchemy.exc try: global version_table version_table = Table('migrate_version', meta.metadata, autoload=True) except sq...
Call me before using any of the tables or classes in the model
call me before using any of the tables or classes in the model
Question: What does this function do? Code: def init_model(engine): meta.Session.remove() meta.Session.configure(bind=engine) meta.create_local_session.configure(bind=engine) meta.engine = engine meta.metadata.bind = engine import sqlalchemy.exc try: global version_table version_table = Table('migrate_ver...
null
null
null
What does this function do?
def __virtual__(): on_freebsd = (__grains__['kernel'] == 'FreeBSD') on_linux = (__grains__['kernel'] == 'Linux') on_solaris = ((__grains__['kernel'] == 'SunOS') and (__grains__['kernelrelease'] == '5.11')) cmd = '' if on_freebsd: cmd = 'kldstat -q -m zfs' elif on_linux: modinfo = salt.utils.which('modinfo') ...
null
null
null
Makes sure that ZFS kernel module is loaded.
pcsd
def virtual on freebsd = grains ['kernel'] == 'Free BSD' on linux = grains ['kernel'] == 'Linux' on solaris = grains ['kernel'] == 'Sun OS' and grains ['kernelrelease'] == '5 11' cmd = '' if on freebsd cmd = 'kldstat -q -m zfs' elif on linux modinfo = salt utils which 'modinfo' if modinfo cmd = '{0} zfs' format modinfo...
2256
def __virtual__(): on_freebsd = (__grains__['kernel'] == 'FreeBSD') on_linux = (__grains__['kernel'] == 'Linux') on_solaris = ((__grains__['kernel'] == 'SunOS') and (__grains__['kernelrelease'] == '5.11')) cmd = '' if on_freebsd: cmd = 'kldstat -q -m zfs' elif on_linux: modinfo = salt.utils.which('modinfo') ...
Makes sure that ZFS kernel module is loaded.
makes sure that zfs kernel module is loaded .
Question: What does this function do? Code: def __virtual__(): on_freebsd = (__grains__['kernel'] == 'FreeBSD') on_linux = (__grains__['kernel'] == 'Linux') on_solaris = ((__grains__['kernel'] == 'SunOS') and (__grains__['kernelrelease'] == '5.11')) cmd = '' if on_freebsd: cmd = 'kldstat -q -m zfs' elif on_l...
null
null
null
What does this function do?
def import_workflow(trans, repository, workflow_name): status = 'done' message = '' changeset_revision = repository.changeset_revision metadata = repository.metadata workflows = metadata.get('workflows', []) tools_metadata = metadata.get('tools', []) workflow_dict = None for workflow_data_tuple in workflows: ...
null
null
null
Import a workflow contained in an installed tool shed repository into Galaxy (this method is called only from Galaxy).
pcsd
def import workflow trans repository workflow name status = 'done' message = '' changeset revision = repository changeset revision metadata = repository metadata workflows = metadata get 'workflows' [] tools metadata = metadata get 'tools' [] workflow dict = None for workflow data tuple in workflows relative path to wo...
2260
def import_workflow(trans, repository, workflow_name): status = 'done' message = '' changeset_revision = repository.changeset_revision metadata = repository.metadata workflows = metadata.get('workflows', []) tools_metadata = metadata.get('tools', []) workflow_dict = None for workflow_data_tuple in workflows: ...
Import a workflow contained in an installed tool shed repository into Galaxy (this method is called only from Galaxy).
import a workflow contained in an installed tool shed repository into galaxy .
Question: What does this function do? Code: def import_workflow(trans, repository, workflow_name): status = 'done' message = '' changeset_revision = repository.changeset_revision metadata = repository.metadata workflows = metadata.get('workflows', []) tools_metadata = metadata.get('tools', []) workflow_dict =...
null
null
null
What does this function do?
def continuation_tokens(cli, width): return [(Token, ((u'.' * (width - 1)) + u' '))]
null
null
null
The continuation: display dots before all the following lines.
pcsd
def continuation tokens cli width return [ Token u' ' * width - 1 + u' ' ]
2261
def continuation_tokens(cli, width): return [(Token, ((u'.' * (width - 1)) + u' '))]
The continuation: display dots before all the following lines.
the continuation : display dots before all the following lines .
Question: What does this function do? Code: def continuation_tokens(cli, width): return [(Token, ((u'.' * (width - 1)) + u' '))]
null
null
null
What does this function do?
@declared def critical(obj, output): set_value(obj, output, None, 2)
null
null
null
Set a service in CRITICAL state
pcsd
@declared def critical obj output set value obj output None 2
2269
@declared def critical(obj, output): set_value(obj, output, None, 2)
Set a service in CRITICAL state
set a service in critical state
Question: What does this function do? Code: @declared def critical(obj, output): set_value(obj, output, None, 2)
null
null
null
What does this function do?
def bind_unused_port(): [sock] = netutil.bind_sockets(None, 'localhost', family=socket.AF_INET) port = sock.getsockname()[1] return (sock, port)
null
null
null
Binds a server socket to an available port on localhost. Returns a tuple (socket, port).
pcsd
def bind unused port [sock] = netutil bind sockets None 'localhost' family=socket AF INET port = sock getsockname [1] return sock port
2282
def bind_unused_port(): [sock] = netutil.bind_sockets(None, 'localhost', family=socket.AF_INET) port = sock.getsockname()[1] return (sock, port)
Binds a server socket to an available port on localhost. Returns a tuple (socket, port).
binds a server socket to an available port on localhost .
Question: What does this function do? Code: def bind_unused_port(): [sock] = netutil.bind_sockets(None, 'localhost', family=socket.AF_INET) port = sock.getsockname()[1] return (sock, port)
null
null
null
What does this function do?
def process_sms_outbox(): msg.process_outbox(contact_method='SMS')
null
null
null
Send Pending SMS Messages
pcsd
def process sms outbox msg process outbox contact method='SMS'
2285
def process_sms_outbox(): msg.process_outbox(contact_method='SMS')
Send Pending SMS Messages
send pending sms messages
Question: What does this function do? Code: def process_sms_outbox(): msg.process_outbox(contact_method='SMS')
null
null
null
What does this function do?
def from_files(container): toc = TOC() for (i, spinepath) in enumerate(container.spine_items): name = container.abspath_to_name(spinepath) root = container.parsed(name) body = XPath(u'//h:body')(root) if (not body): continue text = find_text(body[0]) if (not text): text = name.rpartition(u'/')[(-1)]...
null
null
null
Generate a Table of Contents from files in the book.
pcsd
def from files container toc = TOC for i spinepath in enumerate container spine items name = container abspath to name spinepath root = container parsed name body = X Path u'//h body' root if not body continue text = find text body[0] if not text text = name rpartition u'/' [ -1 ] if i == 0 and text rpartition u' ' [0]...
2291
def from_files(container): toc = TOC() for (i, spinepath) in enumerate(container.spine_items): name = container.abspath_to_name(spinepath) root = container.parsed(name) body = XPath(u'//h:body')(root) if (not body): continue text = find_text(body[0]) if (not text): text = name.rpartition(u'/')[(-1)]...
Generate a Table of Contents from files in the book.
generate a table of contents from files in the book .
Question: What does this function do? Code: def from_files(container): toc = TOC() for (i, spinepath) in enumerate(container.spine_items): name = container.abspath_to_name(spinepath) root = container.parsed(name) body = XPath(u'//h:body')(root) if (not body): continue text = find_text(body[0]) if (n...
null
null
null
What does this function do?
def get_color(value, alpha): color = QColor() for typ in COLORS: if isinstance(value, typ): color = QColor(COLORS[typ]) color.setAlphaF(alpha) return color
null
null
null
Return color depending on value type
pcsd
def get color value alpha color = Q Color for typ in COLORS if isinstance value typ color = Q Color COLORS[typ] color set Alpha F alpha return color
2294
def get_color(value, alpha): color = QColor() for typ in COLORS: if isinstance(value, typ): color = QColor(COLORS[typ]) color.setAlphaF(alpha) return color
Return color depending on value type
return color depending on value type
Question: What does this function do? Code: def get_color(value, alpha): color = QColor() for typ in COLORS: if isinstance(value, typ): color = QColor(COLORS[typ]) color.setAlphaF(alpha) return color
null
null
null
What does this function do?
def getAddIndexedGrid(grid, vertexes, z): indexedGrid = [] for row in grid: indexedRow = [] indexedGrid.append(indexedRow) for pointComplex in row: vector3index = Vector3Index(len(vertexes), pointComplex.real, pointComplex.imag, z) indexedRow.append(vector3index) vertexes.append(vector3index) return i...
null
null
null
Get and add an indexed grid.
pcsd
def get Add Indexed Grid grid vertexes z indexed Grid = [] for row in grid indexed Row = [] indexed Grid append indexed Row for point Complex in row vector3index = Vector3Index len vertexes point Complex real point Complex imag z indexed Row append vector3index vertexes append vector3index return indexed Grid
2295
def getAddIndexedGrid(grid, vertexes, z): indexedGrid = [] for row in grid: indexedRow = [] indexedGrid.append(indexedRow) for pointComplex in row: vector3index = Vector3Index(len(vertexes), pointComplex.real, pointComplex.imag, z) indexedRow.append(vector3index) vertexes.append(vector3index) return i...
Get and add an indexed grid.
get and add an indexed grid .
Question: What does this function do? Code: def getAddIndexedGrid(grid, vertexes, z): indexedGrid = [] for row in grid: indexedRow = [] indexedGrid.append(indexedRow) for pointComplex in row: vector3index = Vector3Index(len(vertexes), pointComplex.real, pointComplex.imag, z) indexedRow.append(vector3in...
null
null
null
What does this function do?
@register.function @jinja2.contextfunction def get_doc_path(context, path, extension): lang = getattr(context['request'], 'LANG', 'en-US') if (lang in settings.AMO_LANGUAGES): try: localized_file_path = ('%s/%s.%s' % (path, lang, extension)) with open(localized_file_path): return localized_file_path exc...
null
null
null
Gets the path to a localizable document in the current language with fallback to en-US.
pcsd
@register function @jinja2 contextfunction def get doc path context path extension lang = getattr context['request'] 'LANG' 'en-US' if lang in settings AMO LANGUAGES try localized file path = '%s/%s %s' % path lang extension with open localized file path return localized file path except IO Error return '%s/en-US %s' %...
2299
@register.function @jinja2.contextfunction def get_doc_path(context, path, extension): lang = getattr(context['request'], 'LANG', 'en-US') if (lang in settings.AMO_LANGUAGES): try: localized_file_path = ('%s/%s.%s' % (path, lang, extension)) with open(localized_file_path): return localized_file_path exc...
Gets the path to a localizable document in the current language with fallback to en-US.
gets the path to a localizable document in the current language with fallback to en - us .
Question: What does this function do? Code: @register.function @jinja2.contextfunction def get_doc_path(context, path, extension): lang = getattr(context['request'], 'LANG', 'en-US') if (lang in settings.AMO_LANGUAGES): try: localized_file_path = ('%s/%s.%s' % (path, lang, extension)) with open(localized_f...
null
null
null
What does this function do?
def load_model(): print 'Loading dictionary...' with open(path_to_dictionary, 'rb') as f: worddict = pkl.load(f) print 'Creating inverted dictionary...' word_idict = dict() for (kk, vv) in worddict.iteritems(): word_idict[vv] = kk word_idict[0] = '<eos>' word_idict[1] = 'UNK' print 'Loading model options......
null
null
null
Load a trained model for decoding
pcsd
def load model print 'Loading dictionary ' with open path to dictionary 'rb' as f worddict = pkl load f print 'Creating inverted dictionary ' word idict = dict for kk vv in worddict iteritems word idict[vv] = kk word idict[0] = '<eos>' word idict[1] = 'UNK' print 'Loading model options ' with open '%s pkl' % path to mo...
2300
def load_model(): print 'Loading dictionary...' with open(path_to_dictionary, 'rb') as f: worddict = pkl.load(f) print 'Creating inverted dictionary...' word_idict = dict() for (kk, vv) in worddict.iteritems(): word_idict[vv] = kk word_idict[0] = '<eos>' word_idict[1] = 'UNK' print 'Loading model options......
Load a trained model for decoding
load a trained model for decoding
Question: What does this function do? Code: def load_model(): print 'Loading dictionary...' with open(path_to_dictionary, 'rb') as f: worddict = pkl.load(f) print 'Creating inverted dictionary...' word_idict = dict() for (kk, vv) in worddict.iteritems(): word_idict[vv] = kk word_idict[0] = '<eos>' word_id...
null
null
null
What does this function do?
def GetMachineKey(): return platform.node()
null
null
null
Gets the machine key to be used for Metrics uploaded from this process.
pcsd
def Get Machine Key return platform node
2306
def GetMachineKey(): return platform.node()
Gets the machine key to be used for Metrics uploaded from this process.
gets the machine key to be used for metrics uploaded from this process .
Question: What does this function do? Code: def GetMachineKey(): return platform.node()
null
null
null
What does this function do?
def create_element(tag, attributes=None, sub_elements=None): if tag: elem = XmlET.Element(tag) if attributes: for (k, v) in attributes.items(): elem.set(k, v) if sub_elements: for (k, v) in sub_elements.items(): if v: if (k == 'packages'): for v_tuple in v: sub_elem = XmlET.SubEle...
null
null
null
Create a new element whose tag is the value of the received tag, and whose attributes are all key / value pairs in the received attributes and sub_elements.
pcsd
def create element tag attributes=None sub elements=None if tag elem = Xml ET Element tag if attributes for k v in attributes items elem set k v if sub elements for k v in sub elements items if v if k == 'packages' for v tuple in v sub elem = Xml ET Sub Element elem 'package' sub elem name sub elem version = v tuple su...
2307
def create_element(tag, attributes=None, sub_elements=None): if tag: elem = XmlET.Element(tag) if attributes: for (k, v) in attributes.items(): elem.set(k, v) if sub_elements: for (k, v) in sub_elements.items(): if v: if (k == 'packages'): for v_tuple in v: sub_elem = XmlET.SubEle...
Create a new element whose tag is the value of the received tag, and whose attributes are all key / value pairs in the received attributes and sub_elements.
create a new element whose tag is the value of the received tag , and whose attributes are all key / value pairs in the received attributes and sub _ elements .
Question: What does this function do? Code: def create_element(tag, attributes=None, sub_elements=None): if tag: elem = XmlET.Element(tag) if attributes: for (k, v) in attributes.items(): elem.set(k, v) if sub_elements: for (k, v) in sub_elements.items(): if v: if (k == 'packages'): f...
null
null
null
What does this function do?
def _euler_step(xf_traj, yf_traj, dmap, f): (ny, nx) = dmap.grid.shape xi = xf_traj[(-1)] yi = yf_traj[(-1)] (cx, cy) = f(xi, yi) if (cx == 0): dsx = np.inf elif (cx < 0): dsx = (xi / (- cx)) else: dsx = (((nx - 1) - xi) / cx) if (cy == 0): dsy = np.inf elif (cy < 0): dsy = (yi / (- cy)) else: dsy...
null
null
null
Simple Euler integration step that extends streamline to boundary.
pcsd
def euler step xf traj yf traj dmap f ny nx = dmap grid shape xi = xf traj[ -1 ] yi = yf traj[ -1 ] cx cy = f xi yi if cx == 0 dsx = np inf elif cx < 0 dsx = xi / - cx else dsx = nx - 1 - xi / cx if cy == 0 dsy = np inf elif cy < 0 dsy = yi / - cy else dsy = ny - 1 - yi / cy ds = min dsx dsy xf traj append xi + cx * ds...
2309
def _euler_step(xf_traj, yf_traj, dmap, f): (ny, nx) = dmap.grid.shape xi = xf_traj[(-1)] yi = yf_traj[(-1)] (cx, cy) = f(xi, yi) if (cx == 0): dsx = np.inf elif (cx < 0): dsx = (xi / (- cx)) else: dsx = (((nx - 1) - xi) / cx) if (cy == 0): dsy = np.inf elif (cy < 0): dsy = (yi / (- cy)) else: dsy...
Simple Euler integration step that extends streamline to boundary.
simple euler integration step that extends streamline to boundary .
Question: What does this function do? Code: def _euler_step(xf_traj, yf_traj, dmap, f): (ny, nx) = dmap.grid.shape xi = xf_traj[(-1)] yi = yf_traj[(-1)] (cx, cy) = f(xi, yi) if (cx == 0): dsx = np.inf elif (cx < 0): dsx = (xi / (- cx)) else: dsx = (((nx - 1) - xi) / cx) if (cy == 0): dsy = np.inf el...
null
null
null
What does this function do?
def _getPropertyValue(schema, propertyName, options): if (propertyName not in options): paramsSchema = schema['properties'][propertyName] if ('default' in paramsSchema): options[propertyName] = paramsSchema['default'] else: options[propertyName] = None
null
null
null
Checks to see if property is specified in \'options\'. If not, reads the default value from the schema
pcsd
def get Property Value schema property Name options if property Name not in options params Schema = schema['properties'][property Name] if 'default' in params Schema options[property Name] = params Schema['default'] else options[property Name] = None
2316
def _getPropertyValue(schema, propertyName, options): if (propertyName not in options): paramsSchema = schema['properties'][propertyName] if ('default' in paramsSchema): options[propertyName] = paramsSchema['default'] else: options[propertyName] = None
Checks to see if property is specified in \'options\'. If not, reads the default value from the schema
checks to see if property is specified in options .
Question: What does this function do? Code: def _getPropertyValue(schema, propertyName, options): if (propertyName not in options): paramsSchema = schema['properties'][propertyName] if ('default' in paramsSchema): options[propertyName] = paramsSchema['default'] else: options[propertyName] = None
null
null
null
What does this function do?
def campaign_keyword(): return s3_rest_controller()
null
null
null
RESTful CRUD controller
pcsd
def campaign keyword return s3 rest controller
2317
def campaign_keyword(): return s3_rest_controller()
RESTful CRUD controller
restful crud controller
Question: What does this function do? Code: def campaign_keyword(): return s3_rest_controller()
null
null
null
What does this function do?
def _reassign(check, clusters, base, num): check[(check == num)] = base clusters[(base - 1)] = np.concatenate((clusters[(base - 1)], clusters[(num - 1)])) clusters[(num - 1)] = np.array([], dtype=int)
null
null
null
Reassign cluster numbers.
pcsd
def reassign check clusters base num check[ check == num ] = base clusters[ base - 1 ] = np concatenate clusters[ base - 1 ] clusters[ num - 1 ] clusters[ num - 1 ] = np array [] dtype=int
2323
def _reassign(check, clusters, base, num): check[(check == num)] = base clusters[(base - 1)] = np.concatenate((clusters[(base - 1)], clusters[(num - 1)])) clusters[(num - 1)] = np.array([], dtype=int)
Reassign cluster numbers.
reassign cluster numbers .
Question: What does this function do? Code: def _reassign(check, clusters, base, num): check[(check == num)] = base clusters[(base - 1)] = np.concatenate((clusters[(base - 1)], clusters[(num - 1)])) clusters[(num - 1)] = np.array([], dtype=int)
null
null
null
What does this function do?
def factors(n): for p in genprimes(): while ((n != 1) and ((n % p) == 0)): (yield p) n /= p if (n == 1): break if ((p * p) > n): (yield n) break
null
null
null
Yields the prime factors of the integer n.
pcsd
def factors n for p in genprimes while n != 1 and n % p == 0 yield p n /= p if n == 1 break if p * p > n yield n break
2325
def factors(n): for p in genprimes(): while ((n != 1) and ((n % p) == 0)): (yield p) n /= p if (n == 1): break if ((p * p) > n): (yield n) break
Yields the prime factors of the integer n.
yields the prime factors of the integer n .
Question: What does this function do? Code: def factors(n): for p in genprimes(): while ((n != 1) and ((n % p) == 0)): (yield p) n /= p if (n == 1): break if ((p * p) > n): (yield n) break
null
null
null
What does this function do?
@snippet def topic_create(client, to_delete): TOPIC_NAME = ('topic_create-%d' % (_millis(),)) topic = client.topic(TOPIC_NAME) topic.create() to_delete.append(topic)
null
null
null
Create a topic.
pcsd
@snippet def topic create client to delete TOPIC NAME = 'topic create-%d' % millis topic = client topic TOPIC NAME topic create to delete append topic
2334
@snippet def topic_create(client, to_delete): TOPIC_NAME = ('topic_create-%d' % (_millis(),)) topic = client.topic(TOPIC_NAME) topic.create() to_delete.append(topic)
Create a topic.
create a topic .
Question: What does this function do? Code: @snippet def topic_create(client, to_delete): TOPIC_NAME = ('topic_create-%d' % (_millis(),)) topic = client.topic(TOPIC_NAME) topic.create() to_delete.append(topic)
null
null
null
What does this function do?
def detect(stream): try: json.loads(stream) return True except ValueError: return False
null
null
null
Returns True if given stream is valid JSON.
pcsd
def detect stream try json loads stream return True except Value Error return False
2340
def detect(stream): try: json.loads(stream) return True except ValueError: return False
Returns True if given stream is valid JSON.
returns true if given stream is valid json .
Question: What does this function do? Code: def detect(stream): try: json.loads(stream) return True except ValueError: return False
null
null
null
What does this function do?
@no_emulator @with_device def reboot_bootloader(): log.info(('Rebooting %s to bootloader' % context.device)) with AdbClient() as c: c.reboot_bootloader()
null
null
null
Reboots the device to the bootloader.
pcsd
@no emulator @with device def reboot bootloader log info 'Rebooting %s to bootloader' % context device with Adb Client as c c reboot bootloader
2352
@no_emulator @with_device def reboot_bootloader(): log.info(('Rebooting %s to bootloader' % context.device)) with AdbClient() as c: c.reboot_bootloader()
Reboots the device to the bootloader.
reboots the device to the bootloader .
Question: What does this function do? Code: @no_emulator @with_device def reboot_bootloader(): log.info(('Rebooting %s to bootloader' % context.device)) with AdbClient() as c: c.reboot_bootloader()
null
null
null
What does this function do?
def textDiff(a, b): out = [] (a, b) = (html2list(a), html2list(b)) s = difflib.SequenceMatcher(None, a, b) for e in s.get_opcodes(): if (e[0] == 'replace'): out.append((((('<del>' + ''.join(a[e[1]:e[2]])) + '</del><ins>') + ''.join(b[e[3]:e[4]])) + '</ins>')) elif (e[0] == 'delete'): out.append((('<del >'...
null
null
null
Takes in strings a and b and returns a human-readable HTML diff.
pcsd
def text Diff a b out = [] a b = html2list a html2list b s = difflib Sequence Matcher None a b for e in s get opcodes if e[0] == 'replace' out append '<del>' + '' join a[e[1] e[2]] + '</del><ins>' + '' join b[e[3] e[4]] + '</ins>' elif e[0] == 'delete' out append '<del >' + '' join a[e[1] e[2]] + '</del>' elif e[0] == ...
2357
def textDiff(a, b): out = [] (a, b) = (html2list(a), html2list(b)) s = difflib.SequenceMatcher(None, a, b) for e in s.get_opcodes(): if (e[0] == 'replace'): out.append((((('<del>' + ''.join(a[e[1]:e[2]])) + '</del><ins>') + ''.join(b[e[3]:e[4]])) + '</ins>')) elif (e[0] == 'delete'): out.append((('<del >'...
Takes in strings a and b and returns a human-readable HTML diff.
takes in strings a and b and returns a human - readable html diff .
Question: What does this function do? Code: def textDiff(a, b): out = [] (a, b) = (html2list(a), html2list(b)) s = difflib.SequenceMatcher(None, a, b) for e in s.get_opcodes(): if (e[0] == 'replace'): out.append((((('<del>' + ''.join(a[e[1]:e[2]])) + '</del><ins>') + ''.join(b[e[3]:e[4]])) + '</ins>')) el...
null
null
null
What does this function do?
@api_versions.wraps('2.26') @utils.arg('server', metavar='<server>', help=_('Name or ID of server.')) @utils.arg('tag', metavar='<tag>', nargs='+', help=_('Tag(s) to add.')) def do_server_tag_add(cs, args): server = _find_server(cs, args.server) utils.do_action_on_many((lambda t: server.add_tag(t)), args.tag, _('Requ...
null
null
null
Add one or more tags to a server.
pcsd
@api versions wraps '2 26' @utils arg 'server' metavar='<server>' help= 'Name or ID of server ' @utils arg 'tag' metavar='<tag>' nargs='+' help= 'Tag s to add ' def do server tag add cs args server = find server cs args server utils do action on many lambda t server add tag t args tag 'Request to add tag %s to specifie...
2375
@api_versions.wraps('2.26') @utils.arg('server', metavar='<server>', help=_('Name or ID of server.')) @utils.arg('tag', metavar='<tag>', nargs='+', help=_('Tag(s) to add.')) def do_server_tag_add(cs, args): server = _find_server(cs, args.server) utils.do_action_on_many((lambda t: server.add_tag(t)), args.tag, _('Requ...
Add one or more tags to a server.
add one or more tags to a server .
Question: What does this function do? Code: @api_versions.wraps('2.26') @utils.arg('server', metavar='<server>', help=_('Name or ID of server.')) @utils.arg('tag', metavar='<tag>', nargs='+', help=_('Tag(s) to add.')) def do_server_tag_add(cs, args): server = _find_server(cs, args.server) utils.do_action_on_many((...
null
null
null
What does this function do?
def get_view_builder(req): base_url = req.application_url return ViewBuilder(base_url)
null
null
null
get view builder
pcsd
def get view builder req base url = req application url return View Builder base url
2383
def get_view_builder(req): base_url = req.application_url return ViewBuilder(base_url)
get view builder
get view builder
Question: What does this function do? Code: def get_view_builder(req): base_url = req.application_url return ViewBuilder(base_url)
null
null
null
What does this function do?
def _clear_search_indexes_storage(search_index_path): if os.path.lexists(search_index_path): try: os.remove(search_index_path) except OSError as e: logging.warning('Failed to remove search indexes file %r: %s', search_index_path, e)
null
null
null
Delete the search indexes storage file at the given path.
pcsd
def clear search indexes storage search index path if os path lexists search index path try os remove search index path except OS Error as e logging warning 'Failed to remove search indexes file %r %s' search index path e
2407
def _clear_search_indexes_storage(search_index_path): if os.path.lexists(search_index_path): try: os.remove(search_index_path) except OSError as e: logging.warning('Failed to remove search indexes file %r: %s', search_index_path, e)
Delete the search indexes storage file at the given path.
delete the search indexes storage file at the given path .
Question: What does this function do? Code: def _clear_search_indexes_storage(search_index_path): if os.path.lexists(search_index_path): try: os.remove(search_index_path) except OSError as e: logging.warning('Failed to remove search indexes file %r: %s', search_index_path, e)
null
null
null
What does this function do?
def _is_valid_slug(slug): VALID_SLUG_RE = re.compile('^[a-z0-9\\-]+$') return VALID_SLUG_RE.match(slug)
null
null
null
Returns true if slug is valid.
pcsd
def is valid slug slug VALID SLUG RE = re compile '^[a-z0-9\\-]+$' return VALID SLUG RE match slug
2413
def _is_valid_slug(slug): VALID_SLUG_RE = re.compile('^[a-z0-9\\-]+$') return VALID_SLUG_RE.match(slug)
Returns true if slug is valid.
returns true if slug is valid .
Question: What does this function do? Code: def _is_valid_slug(slug): VALID_SLUG_RE = re.compile('^[a-z0-9\\-]+$') return VALID_SLUG_RE.match(slug)
null
null
null
What does this function do?
@login_required def get_favorites(req): return render_to_response('favorite/favorite_list.html', RequestContext(req, {'favorites': models.Favorite.objects.favorites_for_user(req.user)}))
null
null
null
Display the request user\'s favorites.
pcsd
@login required def get favorites req return render to response 'favorite/favorite list html' Request Context req {'favorites' models Favorite objects favorites for user req user }
2417
@login_required def get_favorites(req): return render_to_response('favorite/favorite_list.html', RequestContext(req, {'favorites': models.Favorite.objects.favorites_for_user(req.user)}))
Display the request user\'s favorites.
display the request users favorites .
Question: What does this function do? Code: @login_required def get_favorites(req): return render_to_response('favorite/favorite_list.html', RequestContext(req, {'favorites': models.Favorite.objects.favorites_for_user(req.user)}))
null
null
null
What does this function do?
def deep_update(source, overrides): if (sys.version_info >= (3, 0)): items = overrides.items() else: items = overrides.iteritems() for (key, value) in items: if (isinstance(value, collections.Mapping) and value): returned = deep_update(source.get(key, {}), value) source[key] = returned else: source[...
null
null
null
Update a nested dictionary or similar mapping. Modify ``source`` in place.
pcsd
def deep update source overrides if sys version info >= 3 0 items = overrides items else items = overrides iteritems for key value in items if isinstance value collections Mapping and value returned = deep update source get key {} value source[key] = returned else source[key] = overrides[key] return source
2423
def deep_update(source, overrides): if (sys.version_info >= (3, 0)): items = overrides.items() else: items = overrides.iteritems() for (key, value) in items: if (isinstance(value, collections.Mapping) and value): returned = deep_update(source.get(key, {}), value) source[key] = returned else: source[...
Update a nested dictionary or similar mapping. Modify ``source`` in place.
update a nested dictionary or similar mapping .
Question: What does this function do? Code: def deep_update(source, overrides): if (sys.version_info >= (3, 0)): items = overrides.items() else: items = overrides.iteritems() for (key, value) in items: if (isinstance(value, collections.Mapping) and value): returned = deep_update(source.get(key, {}), valu...
null
null
null
What does this function do?
def copy_doc(doc, ignore_no_copy=True): import copy def remove_no_copy_fields(d): for df in d.meta.get(u'fields', {u'no_copy': 1}): if hasattr(d, df.fieldname): d.set(df.fieldname, None) fields_to_clear = [u'name', u'owner', u'creation', u'modified', u'modified_by'] if (not local.flags.in_test): fields_t...
null
null
null
No_copy fields also get copied.
pcsd
def copy doc doc ignore no copy=True import copy def remove no copy fields d for df in d meta get u'fields' {u'no copy' 1} if hasattr d df fieldname d set df fieldname None fields to clear = [u'name' u'owner' u'creation' u'modified' u'modified by'] if not local flags in test fields to clear append u'docstatus' if not i...
2430
def copy_doc(doc, ignore_no_copy=True): import copy def remove_no_copy_fields(d): for df in d.meta.get(u'fields', {u'no_copy': 1}): if hasattr(d, df.fieldname): d.set(df.fieldname, None) fields_to_clear = [u'name', u'owner', u'creation', u'modified', u'modified_by'] if (not local.flags.in_test): fields_t...
No_copy fields also get copied.
no _ copy fields also get copied .
Question: What does this function do? Code: def copy_doc(doc, ignore_no_copy=True): import copy def remove_no_copy_fields(d): for df in d.meta.get(u'fields', {u'no_copy': 1}): if hasattr(d, df.fieldname): d.set(df.fieldname, None) fields_to_clear = [u'name', u'owner', u'creation', u'modified', u'modified...
null
null
null
What does this function do?
def instances(query, cursor, context): context.runid = _new_runid() filtered = query._has_mapper_entities single_entity = ((len(query._entities) == 1) and query._entities[0].supports_single_entity) if filtered: if single_entity: filter_fn = id else: def filter_fn(row): return tuple(((id(item) if ent.u...
null
null
null
Return an ORM result as an iterator.
pcsd
def instances query cursor context context runid = new runid filtered = query has mapper entities single entity = len query entities == 1 and query entities[0] supports single entity if filtered if single entity filter fn = id else def filter fn row return tuple id item if ent use id for hash else item for ent item in ...
2434
def instances(query, cursor, context): context.runid = _new_runid() filtered = query._has_mapper_entities single_entity = ((len(query._entities) == 1) and query._entities[0].supports_single_entity) if filtered: if single_entity: filter_fn = id else: def filter_fn(row): return tuple(((id(item) if ent.u...
Return an ORM result as an iterator.
return an orm result as an iterator .
Question: What does this function do? Code: def instances(query, cursor, context): context.runid = _new_runid() filtered = query._has_mapper_entities single_entity = ((len(query._entities) == 1) and query._entities[0].supports_single_entity) if filtered: if single_entity: filter_fn = id else: def filte...
null
null
null
What does this function do?
def expand_ip_block(block): addresses = [] ip_r = block.base_ip.split('.') last_quad = int(ip_r[3]) address_root = ('%s.%s.%s.' % (ip_r[0], ip_r[1], ip_r[2])) for i in range(int(block.size)): addresses.append((address_root + str((last_quad + i)))) return addresses
null
null
null
Expand public IP block to show all addresses
pcsd
def expand ip block block addresses = [] ip r = block base ip split ' ' last quad = int ip r[3] address root = '%s %s %s ' % ip r[0] ip r[1] ip r[2] for i in range int block size addresses append address root + str last quad + i return addresses
2435
def expand_ip_block(block): addresses = [] ip_r = block.base_ip.split('.') last_quad = int(ip_r[3]) address_root = ('%s.%s.%s.' % (ip_r[0], ip_r[1], ip_r[2])) for i in range(int(block.size)): addresses.append((address_root + str((last_quad + i)))) return addresses
Expand public IP block to show all addresses
expand public ip block to show all addresses
Question: What does this function do? Code: def expand_ip_block(block): addresses = [] ip_r = block.base_ip.split('.') last_quad = int(ip_r[3]) address_root = ('%s.%s.%s.' % (ip_r[0], ip_r[1], ip_r[2])) for i in range(int(block.size)): addresses.append((address_root + str((last_quad + i)))) return addresses
null
null
null
What does this function do?
@register('role') def _check_role(brain, match_kind, match, target_dict, cred_dict): return (match.lower() in [x.lower() for x in cred_dict['roles']])
null
null
null
Check that there is a matching role in the cred dict.
pcsd
@register 'role' def check role brain match kind match target dict cred dict return match lower in [x lower for x in cred dict['roles']]
2442
@register('role') def _check_role(brain, match_kind, match, target_dict, cred_dict): return (match.lower() in [x.lower() for x in cred_dict['roles']])
Check that there is a matching role in the cred dict.
check that there is a matching role in the cred dict .
Question: What does this function do? Code: @register('role') def _check_role(brain, match_kind, match, target_dict, cred_dict): return (match.lower() in [x.lower() for x in cred_dict['roles']])
null
null
null
What does this function do?
def increment_index(builder, val): one = val.type(1) return builder.add(val, one, flags=['nsw'])
null
null
null
Increment an index *val*.
pcsd
def increment index builder val one = val type 1 return builder add val one flags=['nsw']
2445
def increment_index(builder, val): one = val.type(1) return builder.add(val, one, flags=['nsw'])
Increment an index *val*.
increment an index * val * .
Question: What does this function do? Code: def increment_index(builder, val): one = val.type(1) return builder.add(val, one, flags=['nsw'])
null
null
null
What does this function do?
def _process_requirements(requirements, cmd, cwd, saltenv, user): cleanup_requirements = [] if (requirements is not None): if isinstance(requirements, string_types): requirements = [r.strip() for r in requirements.split(',')] elif (not isinstance(requirements, list)): raise TypeError('requirements must be a...
null
null
null
Process the requirements argument
pcsd
def process requirements requirements cmd cwd saltenv user cleanup requirements = [] if requirements is not None if isinstance requirements string types requirements = [r strip for r in requirements split ' ' ] elif not isinstance requirements list raise Type Error 'requirements must be a string or list' treq = None fo...
2447
def _process_requirements(requirements, cmd, cwd, saltenv, user): cleanup_requirements = [] if (requirements is not None): if isinstance(requirements, string_types): requirements = [r.strip() for r in requirements.split(',')] elif (not isinstance(requirements, list)): raise TypeError('requirements must be a...
Process the requirements argument
process the requirements argument
Question: What does this function do? Code: def _process_requirements(requirements, cmd, cwd, saltenv, user): cleanup_requirements = [] if (requirements is not None): if isinstance(requirements, string_types): requirements = [r.strip() for r in requirements.split(',')] elif (not isinstance(requirements, lis...
null
null
null
What does this function do?
def load_vi_open_in_editor_bindings(): registry = Registry() navigation_mode = (ViMode() & ViNavigationMode()) registry.add_binding(u'v')(get_by_name(u'edit-and-execute-command')) return registry
null
null
null
Pressing \'v\' in navigation mode will open the buffer in an external editor.
pcsd
def load vi open in editor bindings registry = Registry navigation mode = Vi Mode & Vi Navigation Mode registry add binding u'v' get by name u'edit-and-execute-command' return registry
2448
def load_vi_open_in_editor_bindings(): registry = Registry() navigation_mode = (ViMode() & ViNavigationMode()) registry.add_binding(u'v')(get_by_name(u'edit-and-execute-command')) return registry
Pressing \'v\' in navigation mode will open the buffer in an external editor.
pressing v in navigation mode will open the buffer in an external editor .
Question: What does this function do? Code: def load_vi_open_in_editor_bindings(): registry = Registry() navigation_mode = (ViMode() & ViNavigationMode()) registry.add_binding(u'v')(get_by_name(u'edit-and-execute-command')) return registry
null
null
null
What does this function do?
def TagByteSize(field_number): return _VarUInt64ByteSizeNoTag(PackTag(field_number, 0))
null
null
null
Returns the bytes required to serialize a tag with this field number.
pcsd
def Tag Byte Size field number return Var U Int64Byte Size No Tag Pack Tag field number 0
2451
def TagByteSize(field_number): return _VarUInt64ByteSizeNoTag(PackTag(field_number, 0))
Returns the bytes required to serialize a tag with this field number.
returns the bytes required to serialize a tag with this field number .
Question: What does this function do? Code: def TagByteSize(field_number): return _VarUInt64ByteSizeNoTag(PackTag(field_number, 0))
null
null
null
What does this function do?
def _execute(*args, **kargs): cmd = (args[1:(-3)] if (args[0] == 'raidcom') else args) result = EXECUTE_TABLE.get(cmd, CMD_SUCCEED) return result
null
null
null
Return predefined results for command execution.
pcsd
def execute *args **kargs cmd = args[1 -3 ] if args[0] == 'raidcom' else args result = EXECUTE TABLE get cmd CMD SUCCEED return result
2453
def _execute(*args, **kargs): cmd = (args[1:(-3)] if (args[0] == 'raidcom') else args) result = EXECUTE_TABLE.get(cmd, CMD_SUCCEED) return result
Return predefined results for command execution.
return predefined results for command execution .
Question: What does this function do? Code: def _execute(*args, **kargs): cmd = (args[1:(-3)] if (args[0] == 'raidcom') else args) result = EXECUTE_TABLE.get(cmd, CMD_SUCCEED) return result
null
null
null
What does this function do?
def _get_gl_version(_lib): try: return _lib.glGetString(7938).decode('utf-8') except Exception: return 'unknown'
null
null
null
Helper to get the GL version string
pcsd
def get gl version lib try return lib gl Get String 7938 decode 'utf-8' except Exception return 'unknown'
2462
def _get_gl_version(_lib): try: return _lib.glGetString(7938).decode('utf-8') except Exception: return 'unknown'
Helper to get the GL version string
helper to get the gl version string
Question: What does this function do? Code: def _get_gl_version(_lib): try: return _lib.glGetString(7938).decode('utf-8') except Exception: return 'unknown'
null
null
null
What does this function do?
def OBV(ds1, volumeDs, count): data1 = value_ds_to_numpy(ds1, count) if (data1 is None): return None data2 = value_ds_to_numpy(volumeDs, count) if (data2 is None): return None return talib.OBV(data1, data2)
null
null
null
On Balance Volume
pcsd
def OBV ds1 volume Ds count data1 = value ds to numpy ds1 count if data1 is None return None data2 = value ds to numpy volume Ds count if data2 is None return None return talib OBV data1 data2
2466
def OBV(ds1, volumeDs, count): data1 = value_ds_to_numpy(ds1, count) if (data1 is None): return None data2 = value_ds_to_numpy(volumeDs, count) if (data2 is None): return None return talib.OBV(data1, data2)
On Balance Volume
on balance volume
Question: What does this function do? Code: def OBV(ds1, volumeDs, count): data1 = value_ds_to_numpy(ds1, count) if (data1 is None): return None data2 = value_ds_to_numpy(volumeDs, count) if (data2 is None): return None return talib.OBV(data1, data2)
null
null
null
What does this function do?
def asrun(pl, ascript): return run_cmd(pl, [u'osascript', u'-'], ascript)
null
null
null
Run the given AppleScript and return the standard output and error.
pcsd
def asrun pl ascript return run cmd pl [u'osascript' u'-'] ascript
2482
def asrun(pl, ascript): return run_cmd(pl, [u'osascript', u'-'], ascript)
Run the given AppleScript and return the standard output and error.
run the given applescript and return the standard output and error .
Question: What does this function do? Code: def asrun(pl, ascript): return run_cmd(pl, [u'osascript', u'-'], ascript)
null
null
null
What does this function do?
def basic_indexing(context, builder, aryty, ary, index_types, indices): zero = context.get_constant(types.intp, 0) shapes = cgutils.unpack_tuple(builder, ary.shape, aryty.ndim) strides = cgutils.unpack_tuple(builder, ary.strides, aryty.ndim) output_indices = [] output_shapes = [] output_strides = [] ax = 0 for ...
null
null
null
Perform basic indexing on the given array. A (data pointer, shapes, strides) tuple is returned describing the corresponding view.
pcsd
def basic indexing context builder aryty ary index types indices zero = context get constant types intp 0 shapes = cgutils unpack tuple builder ary shape aryty ndim strides = cgutils unpack tuple builder ary strides aryty ndim output indices = [] output shapes = [] output strides = [] ax = 0 for indexval idxty in zip i...
2483
def basic_indexing(context, builder, aryty, ary, index_types, indices): zero = context.get_constant(types.intp, 0) shapes = cgutils.unpack_tuple(builder, ary.shape, aryty.ndim) strides = cgutils.unpack_tuple(builder, ary.strides, aryty.ndim) output_indices = [] output_shapes = [] output_strides = [] ax = 0 for ...
Perform basic indexing on the given array. A (data pointer, shapes, strides) tuple is returned describing the corresponding view.
perform basic indexing on the given array .
Question: What does this function do? Code: def basic_indexing(context, builder, aryty, ary, index_types, indices): zero = context.get_constant(types.intp, 0) shapes = cgutils.unpack_tuple(builder, ary.shape, aryty.ndim) strides = cgutils.unpack_tuple(builder, ary.strides, aryty.ndim) output_indices = [] output...
null
null
null
What does this function do?
def disable_signing(**kwargs): return botocore.UNSIGNED
null
null
null
This handler disables request signing by setting the signer name to a special sentinel value.
pcsd
def disable signing **kwargs return botocore UNSIGNED
2488
def disable_signing(**kwargs): return botocore.UNSIGNED
This handler disables request signing by setting the signer name to a special sentinel value.
this handler disables request signing by setting the signer name to a special sentinel value .
Question: What does this function do? Code: def disable_signing(**kwargs): return botocore.UNSIGNED
null
null
null
What does this function do?
def setup_axes1(fig, rect): tr = Affine2D().scale(2, 1).rotate_deg(30) grid_helper = floating_axes.GridHelperCurveLinear(tr, extremes=((-0.5), 3.5, 0, 4)) ax1 = floating_axes.FloatingSubplot(fig, rect, grid_helper=grid_helper) fig.add_subplot(ax1) aux_ax = ax1.get_aux_axes(tr) grid_helper.grid_finder.grid_locator...
null
null
null
A simple one.
pcsd
def setup axes1 fig rect tr = Affine2D scale 2 1 rotate deg 30 grid helper = floating axes Grid Helper Curve Linear tr extremes= -0 5 3 5 0 4 ax1 = floating axes Floating Subplot fig rect grid helper=grid helper fig add subplot ax1 aux ax = ax1 get aux axes tr grid helper grid finder grid locator1 nbins = 4 grid helper...
2491
def setup_axes1(fig, rect): tr = Affine2D().scale(2, 1).rotate_deg(30) grid_helper = floating_axes.GridHelperCurveLinear(tr, extremes=((-0.5), 3.5, 0, 4)) ax1 = floating_axes.FloatingSubplot(fig, rect, grid_helper=grid_helper) fig.add_subplot(ax1) aux_ax = ax1.get_aux_axes(tr) grid_helper.grid_finder.grid_locator...
A simple one.
a simple one .
Question: What does this function do? Code: def setup_axes1(fig, rect): tr = Affine2D().scale(2, 1).rotate_deg(30) grid_helper = floating_axes.GridHelperCurveLinear(tr, extremes=((-0.5), 3.5, 0, 4)) ax1 = floating_axes.FloatingSubplot(fig, rect, grid_helper=grid_helper) fig.add_subplot(ax1) aux_ax = ax1.get_aux...
null
null
null
What does this function do?
def jsonrpc_server_call(target, jsonrpc_request, json_decoder=None): if (json_decoder is None): json_decoder = ScrapyJSONDecoder() try: req = json_decoder.decode(jsonrpc_request) except Exception as e: return jsonrpc_error(None, jsonrpc_errors.PARSE_ERROR, 'Parse error', traceback.format_exc()) try: (id, me...
null
null
null
Execute the given JSON-RPC request (as JSON-encoded string) on the given target object and return the JSON-RPC response, as a dict
pcsd
def jsonrpc server call target jsonrpc request json decoder=None if json decoder is None json decoder = Scrapy JSON Decoder try req = json decoder decode jsonrpc request except Exception as e return jsonrpc error None jsonrpc errors PARSE ERROR 'Parse error' traceback format exc try id methname = req['id'] req['method'...
2494
def jsonrpc_server_call(target, jsonrpc_request, json_decoder=None): if (json_decoder is None): json_decoder = ScrapyJSONDecoder() try: req = json_decoder.decode(jsonrpc_request) except Exception as e: return jsonrpc_error(None, jsonrpc_errors.PARSE_ERROR, 'Parse error', traceback.format_exc()) try: (id, me...
Execute the given JSON-RPC request (as JSON-encoded string) on the given target object and return the JSON-RPC response, as a dict
execute the given json - rpc request on the given target object and return the json - rpc response , as a dict
Question: What does this function do? Code: def jsonrpc_server_call(target, jsonrpc_request, json_decoder=None): if (json_decoder is None): json_decoder = ScrapyJSONDecoder() try: req = json_decoder.decode(jsonrpc_request) except Exception as e: return jsonrpc_error(None, jsonrpc_errors.PARSE_ERROR, 'Parse ...
null
null
null
What does this function do?
def debug(msg): msg = as_unicode(msg) with open(DUMP_FILENAME, 'ab') as dump_file: dump_file.write((msg + '\n').encode('utf-8'))
null
null
null
Dumb \'msg\' into the debug file.
pcsd
def debug msg msg = as unicode msg with open DUMP FILENAME 'ab' as dump file dump file write msg + ' ' encode 'utf-8'
2506
def debug(msg): msg = as_unicode(msg) with open(DUMP_FILENAME, 'ab') as dump_file: dump_file.write((msg + '\n').encode('utf-8'))
Dumb \'msg\' into the debug file.
dumb msg into the debug file .
Question: What does this function do? Code: def debug(msg): msg = as_unicode(msg) with open(DUMP_FILENAME, 'ab') as dump_file: dump_file.write((msg + '\n').encode('utf-8'))
null
null
null
What does this function do?
def LocalPathToCanonicalPath(path): return path
null
null
null
OSX uses a normal path.
pcsd
def Local Path To Canonical Path path return path
2517
def LocalPathToCanonicalPath(path): return path
OSX uses a normal path.
osx uses a normal path .
Question: What does this function do? Code: def LocalPathToCanonicalPath(path): return path
null
null
null
What does this function do?
def process_multipart(entity): ib = u'' if (u'boundary' in entity.content_type.params): ib = entity.content_type.params['boundary'].strip(u'"') if (not re.match(u'^[ -~]{0,200}[!-~]$', ib)): raise ValueError((u'Invalid boundary in multipart form: %r' % (ib,))) ib = (u'--' + ib).encode('ascii') while True: b ...
null
null
null
Read all multipart parts into entity.parts.
pcsd
def process multipart entity ib = u'' if u'boundary' in entity content type params ib = entity content type params['boundary'] strip u'"' if not re match u'^[ -~]{0 200}[!-~]$' ib raise Value Error u'Invalid boundary in multipart form %r' % ib ib = u'--' + ib encode 'ascii' while True b = entity readline if not b retur...
2536
def process_multipart(entity): ib = u'' if (u'boundary' in entity.content_type.params): ib = entity.content_type.params['boundary'].strip(u'"') if (not re.match(u'^[ -~]{0,200}[!-~]$', ib)): raise ValueError((u'Invalid boundary in multipart form: %r' % (ib,))) ib = (u'--' + ib).encode('ascii') while True: b ...
Read all multipart parts into entity.parts.
read all multipart parts into entity . parts .
Question: What does this function do? Code: def process_multipart(entity): ib = u'' if (u'boundary' in entity.content_type.params): ib = entity.content_type.params['boundary'].strip(u'"') if (not re.match(u'^[ -~]{0,200}[!-~]$', ib)): raise ValueError((u'Invalid boundary in multipart form: %r' % (ib,))) ib =...
null
null
null
What does this function do?
def get_projects_with_bugs(): projects = mysite.search.models.Project.objects.annotate(bug_count=Count('bug')).filter(bug_count__gt=0).order_by(u'display_name') return projects
null
null
null
Return a sorted list of all the Projects for which we\'ve indexed bugs.
pcsd
def get projects with bugs projects = mysite search models Project objects annotate bug count=Count 'bug' filter bug count gt=0 order by u'display name' return projects
2537
def get_projects_with_bugs(): projects = mysite.search.models.Project.objects.annotate(bug_count=Count('bug')).filter(bug_count__gt=0).order_by(u'display_name') return projects
Return a sorted list of all the Projects for which we\'ve indexed bugs.
return a sorted list of all the projects for which weve indexed bugs .
Question: What does this function do? Code: def get_projects_with_bugs(): projects = mysite.search.models.Project.objects.annotate(bug_count=Count('bug')).filter(bug_count__gt=0).order_by(u'display_name') return projects
null
null
null
What does this function do?
def DEFINE_list(name, default, help, flag_values=FLAGS, **args): parser = ListParser() serializer = ListSerializer(',') DEFINE(parser, name, default, help, flag_values, serializer, **args)
null
null
null
Registers a flag whose value is a comma-separated list of strings.
pcsd
def DEFINE list name default help flag values=FLAGS **args parser = List Parser serializer = List Serializer ' ' DEFINE parser name default help flag values serializer **args
2541
def DEFINE_list(name, default, help, flag_values=FLAGS, **args): parser = ListParser() serializer = ListSerializer(',') DEFINE(parser, name, default, help, flag_values, serializer, **args)
Registers a flag whose value is a comma-separated list of strings.
registers a flag whose value is a comma - separated list of strings .
Question: What does this function do? Code: def DEFINE_list(name, default, help, flag_values=FLAGS, **args): parser = ListParser() serializer = ListSerializer(',') DEFINE(parser, name, default, help, flag_values, serializer, **args)
null
null
null
What does this function do?
@never_cache @csrf_exempt @psa('{0}:complete'.format(NAMESPACE)) def complete(request, backend, *args, **kwargs): return do_complete(request.backend, _do_login, request.user, redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)
null
null
null
Authentication complete view
pcsd
@never cache @csrf exempt @psa '{0} complete' format NAMESPACE def complete request backend *args **kwargs return do complete request backend do login request user redirect name=REDIRECT FIELD NAME *args **kwargs
2543
@never_cache @csrf_exempt @psa('{0}:complete'.format(NAMESPACE)) def complete(request, backend, *args, **kwargs): return do_complete(request.backend, _do_login, request.user, redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)
Authentication complete view
authentication complete view
Question: What does this function do? Code: @never_cache @csrf_exempt @psa('{0}:complete'.format(NAMESPACE)) def complete(request, backend, *args, **kwargs): return do_complete(request.backend, _do_login, request.user, redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)
null
null
null
What does this function do?
def sortedEpisodes(m, season=None): episodes = [] seasons = season if (season is None): seasons = sortedSeasons(m) elif (not isinstance(season, (tuple, list))): seasons = [season] for s in seasons: eps_indx = m.get('episodes', {}).get(s, {}).keys() eps_indx.sort() for e in eps_indx: episodes.append(m[...
null
null
null
Return a sorted list of episodes of the given series, considering only the specified season(s) (every season, if None).
pcsd
def sorted Episodes m season=None episodes = [] seasons = season if season is None seasons = sorted Seasons m elif not isinstance season tuple list seasons = [season] for s in seasons eps indx = m get 'episodes' {} get s {} keys eps indx sort for e in eps indx episodes append m['episodes'][s][e] return episodes
2547
def sortedEpisodes(m, season=None): episodes = [] seasons = season if (season is None): seasons = sortedSeasons(m) elif (not isinstance(season, (tuple, list))): seasons = [season] for s in seasons: eps_indx = m.get('episodes', {}).get(s, {}).keys() eps_indx.sort() for e in eps_indx: episodes.append(m[...
Return a sorted list of episodes of the given series, considering only the specified season(s) (every season, if None).
return a sorted list of episodes of the given series , considering only the specified season ( s ) .
Question: What does this function do? Code: def sortedEpisodes(m, season=None): episodes = [] seasons = season if (season is None): seasons = sortedSeasons(m) elif (not isinstance(season, (tuple, list))): seasons = [season] for s in seasons: eps_indx = m.get('episodes', {}).get(s, {}).keys() eps_indx.so...
null
null
null
What does this function do?
def create_attach_volumes(name, kwargs, call=None, wait_to_finish=True): if (call != 'action'): raise SaltCloudSystemExit('The create_attach_volumes action must be called with -a or --action.') if ('instance_id' not in kwargs): kwargs['instance_id'] = _get_node(name)['instanceId'] if isinstance(kwargs['volumes']...
null
null
null
Create and attach volumes to created node
pcsd
def create attach volumes name kwargs call=None wait to finish=True if call != 'action' raise Salt Cloud System Exit 'The create attach volumes action must be called with -a or --action ' if 'instance id' not in kwargs kwargs['instance id'] = get node name ['instance Id'] if isinstance kwargs['volumes'] str volumes = y...
2549
def create_attach_volumes(name, kwargs, call=None, wait_to_finish=True): if (call != 'action'): raise SaltCloudSystemExit('The create_attach_volumes action must be called with -a or --action.') if ('instance_id' not in kwargs): kwargs['instance_id'] = _get_node(name)['instanceId'] if isinstance(kwargs['volumes']...
Create and attach volumes to created node
create and attach volumes to created node
Question: What does this function do? Code: def create_attach_volumes(name, kwargs, call=None, wait_to_finish=True): if (call != 'action'): raise SaltCloudSystemExit('The create_attach_volumes action must be called with -a or --action.') if ('instance_id' not in kwargs): kwargs['instance_id'] = _get_node(name)...
null
null
null
What does this function do?
def in6_getnsmac(a): a = struct.unpack('16B', a)[(-4):] mac = '33:33:' mac += ':'.join(map((lambda x: ('%.2x' % x)), a)) return mac
null
null
null
Return the multicast mac address associated with provided IPv6 address. Passed address must be in network format.
pcsd
def in6 getnsmac a a = struct unpack '16B' a [ -4 ] mac = '33 33 ' mac += ' ' join map lambda x '% 2x' % x a return mac
2550
def in6_getnsmac(a): a = struct.unpack('16B', a)[(-4):] mac = '33:33:' mac += ':'.join(map((lambda x: ('%.2x' % x)), a)) return mac
Return the multicast mac address associated with provided IPv6 address. Passed address must be in network format.
return the multicast mac address associated with provided
Question: What does this function do? Code: def in6_getnsmac(a): a = struct.unpack('16B', a)[(-4):] mac = '33:33:' mac += ':'.join(map((lambda x: ('%.2x' % x)), a)) return mac
null
null
null
What does this function do?
def user_has_permission(user_db, permission_type): if (not cfg.CONF.rbac.enable): return True resolver = resolvers.get_resolver_for_permission_type(permission_type=permission_type) result = resolver.user_has_permission(user_db=user_db, permission_type=permission_type) return result
null
null
null
Check that the provided user has specified permission.
pcsd
def user has permission user db permission type if not cfg CONF rbac enable return True resolver = resolvers get resolver for permission type permission type=permission type result = resolver user has permission user db=user db permission type=permission type return result
2555
def user_has_permission(user_db, permission_type): if (not cfg.CONF.rbac.enable): return True resolver = resolvers.get_resolver_for_permission_type(permission_type=permission_type) result = resolver.user_has_permission(user_db=user_db, permission_type=permission_type) return result
Check that the provided user has specified permission.
check that the provided user has specified permission .
Question: What does this function do? Code: def user_has_permission(user_db, permission_type): if (not cfg.CONF.rbac.enable): return True resolver = resolvers.get_resolver_for_permission_type(permission_type=permission_type) result = resolver.user_has_permission(user_db=user_db, permission_type=permission_type)...
null
null
null
What does this function do?
@register.filter def friends(user): try: return Relationship.objects.get_friends_for_user(user) except AttributeError: return []
null
null
null
Returns people user is following sans people blocking user.
pcsd
@register filter def friends user try return Relationship objects get friends for user user except Attribute Error return []
2557
@register.filter def friends(user): try: return Relationship.objects.get_friends_for_user(user) except AttributeError: return []
Returns people user is following sans people blocking user.
returns people user is following sans people blocking user .
Question: What does this function do? Code: @register.filter def friends(user): try: return Relationship.objects.get_friends_for_user(user) except AttributeError: return []