labNo float64 1 10 ⌀ | taskNo float64 0 4 ⌀ | questioner stringclasses 2
values | question stringlengths 9 201 | code stringlengths 18 30.3k | startLine float64 0 192 ⌀ | endLine float64 0 196 ⌀ | questionType stringclasses 4
values | answer stringlengths 2 905 | src stringclasses 3
values | code_processed stringlengths 12 28.3k ⌀ | id stringlengths 2 5 ⌀ | raw_code stringlengths 20 30.3k ⌀ | raw_comment stringlengths 10 242 ⌀ | comment stringlengths 9 207 ⌀ | q_code stringlengths 66 30.3k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
null | null | null | What does this function do? | def run_cmd(cmd, attempts=1):
try:
for i in range(attempts):
proc = subprocess.Popen(cmd, stdin=open(os.devnull, 'r'))
proc.wait()
if (not (proc.returncode == 0)):
print('Command ', str(cmd), ' failed')
else:
print('Command ', str(cmd), ' succeeded.')
return True
time.sleep(3)
return Fal... | null | null | null | Runs a command attempts times, logging its output. Returns True if it
succeeds once, or False if it never does. | pcsd | def run cmd cmd attempts=1 try for i in range attempts proc = subprocess Popen cmd stdin=open os devnull 'r' proc wait if not proc returncode == 0 print 'Command ' str cmd ' failed' else print 'Command ' str cmd ' succeeded ' return True time sleep 3 return False except OS Error as e print 'Error while attempting to ru... | 12541 | def run_cmd(cmd, attempts=1):
try:
for i in range(attempts):
proc = subprocess.Popen(cmd, stdin=open(os.devnull, 'r'))
proc.wait()
if (not (proc.returncode == 0)):
print('Command ', str(cmd), ' failed')
else:
print('Command ', str(cmd), ' succeeded.')
return True
time.sleep(3)
return Fal... | Runs a command attempts times, logging its output. Returns True if it
succeeds once, or False if it never does. | runs a command attempts times , logging its output . | Question:
What does this function do?
Code:
def run_cmd(cmd, attempts=1):
try:
for i in range(attempts):
proc = subprocess.Popen(cmd, stdin=open(os.devnull, 'r'))
proc.wait()
if (not (proc.returncode == 0)):
print('Command ', str(cmd), ' failed')
else:
print('Command ', str(cmd), ' succeeded.'... |
null | null | null | What does this function do? | def _resolve_name(name, package, level):
if (not hasattr(package, 'rindex')):
raise ValueError("'package' not set to a string")
dot = len(package)
for x in range(level, 1, (-1)):
try:
dot = package.rindex('.', 0, dot)
except ValueError:
raise ValueError('attempted relative import beyond top-level package... | null | null | null | Return the absolute name of the module to be imported. | pcsd | def resolve name name package level if not hasattr package 'rindex' raise Value Error "'package' not set to a string" dot = len package for x in range level 1 -1 try dot = package rindex ' ' 0 dot except Value Error raise Value Error 'attempted relative import beyond top-level package' return '%s %s' % package[ dot] na... | 12545 | def _resolve_name(name, package, level):
if (not hasattr(package, 'rindex')):
raise ValueError("'package' not set to a string")
dot = len(package)
for x in range(level, 1, (-1)):
try:
dot = package.rindex('.', 0, dot)
except ValueError:
raise ValueError('attempted relative import beyond top-level package... | Return the absolute name of the module to be imported. | return the absolute name of the module to be imported . | Question:
What does this function do?
Code:
def _resolve_name(name, package, level):
if (not hasattr(package, 'rindex')):
raise ValueError("'package' not set to a string")
dot = len(package)
for x in range(level, 1, (-1)):
try:
dot = package.rindex('.', 0, dot)
except ValueError:
raise ValueError('att... |
null | null | null | What does this function do? | @with_open_mode('r')
@with_sizes('medium')
def read_bytewise(f):
f.seek(0)
while f.read(1):
pass
| null | null | null | read one unit at a time | pcsd | @with open mode 'r' @with sizes 'medium' def read bytewise f f seek 0 while f read 1 pass | 12546 | @with_open_mode('r')
@with_sizes('medium')
def read_bytewise(f):
f.seek(0)
while f.read(1):
pass
| read one unit at a time | read one unit at a time | Question:
What does this function do?
Code:
@with_open_mode('r')
@with_sizes('medium')
def read_bytewise(f):
f.seek(0)
while f.read(1):
pass
|
null | null | null | What does this function do? | def display(url, api_key=None, return_formatted=True):
try:
r = get(url, api_key=api_key)
except urllib2.HTTPError as e:
print e
print e.read(1024)
sys.exit(1)
if (type(r) == unicode):
print ('error: %s' % r)
return None
if (not return_formatted):
return r
elif (type(r) == list):
print 'Collection ... | null | null | null | Sends an API GET request and acts as a generic formatter for the JSON response. | pcsd | def display url api key=None return formatted=True try r = get url api key=api key except urllib2 HTTP Error as e print e print e read 1024 sys exit 1 if type r == unicode print 'error %s' % r return None if not return formatted return r elif type r == list print 'Collection Members' print '------------------' for n i ... | 12557 | def display(url, api_key=None, return_formatted=True):
try:
r = get(url, api_key=api_key)
except urllib2.HTTPError as e:
print e
print e.read(1024)
sys.exit(1)
if (type(r) == unicode):
print ('error: %s' % r)
return None
if (not return_formatted):
return r
elif (type(r) == list):
print 'Collection ... | Sends an API GET request and acts as a generic formatter for the JSON response. | sends an api get request and acts as a generic formatter for the json response . | Question:
What does this function do?
Code:
def display(url, api_key=None, return_formatted=True):
try:
r = get(url, api_key=api_key)
except urllib2.HTTPError as e:
print e
print e.read(1024)
sys.exit(1)
if (type(r) == unicode):
print ('error: %s' % r)
return None
if (not return_formatted):
return ... |
null | null | null | What does this function do? | def mono_check(plugin, fmt='png'):
img = img_as_ubyte(data.moon())
r1 = roundtrip(img, plugin, fmt)
testing.assert_allclose(img, r1)
img2 = (img > 128)
r2 = roundtrip(img2, plugin, fmt)
testing.assert_allclose(img2.astype(np.uint8), r2)
img3 = img_as_float(img)
with expected_warnings(['precision|\\A\\Z']):
r3... | null | null | null | Check the roundtrip behavior for images that support most types.
All major input types should be handled. | pcsd | def mono check plugin fmt='png' img = img as ubyte data moon r1 = roundtrip img plugin fmt testing assert allclose img r1 img2 = img > 128 r2 = roundtrip img2 plugin fmt testing assert allclose img2 astype np uint8 r2 img3 = img as float img with expected warnings ['precision|\\A\\Z'] r3 = roundtrip img3 plugin fmt if ... | 12563 | def mono_check(plugin, fmt='png'):
img = img_as_ubyte(data.moon())
r1 = roundtrip(img, plugin, fmt)
testing.assert_allclose(img, r1)
img2 = (img > 128)
r2 = roundtrip(img2, plugin, fmt)
testing.assert_allclose(img2.astype(np.uint8), r2)
img3 = img_as_float(img)
with expected_warnings(['precision|\\A\\Z']):
r3... | Check the roundtrip behavior for images that support most types.
All major input types should be handled. | check the roundtrip behavior for images that support most types . | Question:
What does this function do?
Code:
def mono_check(plugin, fmt='png'):
img = img_as_ubyte(data.moon())
r1 = roundtrip(img, plugin, fmt)
testing.assert_allclose(img, r1)
img2 = (img > 128)
r2 = roundtrip(img2, plugin, fmt)
testing.assert_allclose(img2.astype(np.uint8), r2)
img3 = img_as_float(img)
wit... |
null | null | null | What does this function do? | def matchStrength(x, y):
return sum(((xi == yi) for (xi, yi) in zip(x, y)))
| null | null | null | Compute the match strength for the individual *x* on the string *y*. | pcsd | def match Strength x y return sum xi == yi for xi yi in zip x y | 12564 | def matchStrength(x, y):
return sum(((xi == yi) for (xi, yi) in zip(x, y)))
| Compute the match strength for the individual *x* on the string *y*. | compute the match strength for the individual * x * on the string * y * . | Question:
What does this function do?
Code:
def matchStrength(x, y):
return sum(((xi == yi) for (xi, yi) in zip(x, y)))
|
null | null | null | What does this function do? | @utils.service_type('monitor')
def do_type_list(cs, args):
vtypes = cs.monitor_types.list()
_print_monitor_type_list(vtypes)
| null | null | null | Print a list of available \'monitor types\'. | pcsd | @utils service type 'monitor' def do type list cs args vtypes = cs monitor types list print monitor type list vtypes | 12574 | @utils.service_type('monitor')
def do_type_list(cs, args):
vtypes = cs.monitor_types.list()
_print_monitor_type_list(vtypes)
| Print a list of available \'monitor types\'. | print a list of available monitor types . | Question:
What does this function do?
Code:
@utils.service_type('monitor')
def do_type_list(cs, args):
vtypes = cs.monitor_types.list()
_print_monitor_type_list(vtypes)
|
null | null | null | What does this function do? | def _key2bin(s):
kl = map((lambda x: bord(x)), s)
kl = map((lambda x: (binary[(x >> 4)] + binary[(x & 15)])), kl)
return ''.join(kl)
| null | null | null | Convert a key into a string of binary digits | pcsd | def key2bin s kl = map lambda x bord x s kl = map lambda x binary[ x >> 4 ] + binary[ x & 15 ] kl return '' join kl | 12576 | def _key2bin(s):
kl = map((lambda x: bord(x)), s)
kl = map((lambda x: (binary[(x >> 4)] + binary[(x & 15)])), kl)
return ''.join(kl)
| Convert a key into a string of binary digits | convert a key into a string of binary digits | Question:
What does this function do?
Code:
def _key2bin(s):
kl = map((lambda x: bord(x)), s)
kl = map((lambda x: (binary[(x >> 4)] + binary[(x & 15)])), kl)
return ''.join(kl)
|
null | null | null | What does this function do? | @receiver(pre_save, sender=CourseEnrollment)
def pre_save_callback(sender, instance, **kwargs):
try:
old_instance = sender.objects.get(pk=instance.pk)
instance._old_mode = old_instance.mode
except CourseEnrollment.DoesNotExist:
instance._old_mode = None
| null | null | null | Extend to store previous mode. | pcsd | @receiver pre save sender=Course Enrollment def pre save callback sender instance **kwargs try old instance = sender objects get pk=instance pk instance old mode = old instance mode except Course Enrollment Does Not Exist instance old mode = None | 12583 | @receiver(pre_save, sender=CourseEnrollment)
def pre_save_callback(sender, instance, **kwargs):
try:
old_instance = sender.objects.get(pk=instance.pk)
instance._old_mode = old_instance.mode
except CourseEnrollment.DoesNotExist:
instance._old_mode = None
| Extend to store previous mode. | extend to store previous mode . | Question:
What does this function do?
Code:
@receiver(pre_save, sender=CourseEnrollment)
def pre_save_callback(sender, instance, **kwargs):
try:
old_instance = sender.objects.get(pk=instance.pk)
instance._old_mode = old_instance.mode
except CourseEnrollment.DoesNotExist:
instance._old_mode = None
|
null | null | null | What does this function do? | def SetFilesProperty(output, variable, property_name, values, sep):
output.write('set_source_files_properties(')
WriteVariable(output, variable)
output.write(' PROPERTIES ')
output.write(property_name)
output.write(' "')
for value in values:
output.write(CMakeStringEscape(value))
output.write(sep)
output.wri... | null | null | null | Given a set of source files, sets the given property on them. | pcsd | def Set Files Property output variable property name values sep output write 'set source files properties ' Write Variable output variable output write ' PROPERTIES ' output write property name output write ' "' for value in values output write C Make String Escape value output write sep output write '" ' | 12589 | def SetFilesProperty(output, variable, property_name, values, sep):
output.write('set_source_files_properties(')
WriteVariable(output, variable)
output.write(' PROPERTIES ')
output.write(property_name)
output.write(' "')
for value in values:
output.write(CMakeStringEscape(value))
output.write(sep)
output.wri... | Given a set of source files, sets the given property on them. | given a set of source files , sets the given property on them . | Question:
What does this function do?
Code:
def SetFilesProperty(output, variable, property_name, values, sep):
output.write('set_source_files_properties(')
WriteVariable(output, variable)
output.write(' PROPERTIES ')
output.write(property_name)
output.write(' "')
for value in values:
output.write(CMakeStrin... |
null | null | null | What does this function do? | def profile(fn):
if ENABLE_PROFILING:
@wraps(fn)
def wrapper(self, *a, **k):
if PROFILER:
return PROFILER.runcall(partial(fn, self, *a, **k))
else:
print ('Can not profile (%s), it is probably reloaded' % fn.__name__)
return fn(*a, **k)
return wrapper
else:
return fn
| null | null | null | Decorator to mark a function to be profiled. Only mark top level functions | pcsd | def profile fn if ENABLE PROFILING @wraps fn def wrapper self *a **k if PROFILER return PROFILER runcall partial fn self *a **k else print 'Can not profile %s it is probably reloaded' % fn name return fn *a **k return wrapper else return fn | 12590 | def profile(fn):
if ENABLE_PROFILING:
@wraps(fn)
def wrapper(self, *a, **k):
if PROFILER:
return PROFILER.runcall(partial(fn, self, *a, **k))
else:
print ('Can not profile (%s), it is probably reloaded' % fn.__name__)
return fn(*a, **k)
return wrapper
else:
return fn
| Decorator to mark a function to be profiled. Only mark top level functions | decorator to mark a function to be profiled . | Question:
What does this function do?
Code:
def profile(fn):
if ENABLE_PROFILING:
@wraps(fn)
def wrapper(self, *a, **k):
if PROFILER:
return PROFILER.runcall(partial(fn, self, *a, **k))
else:
print ('Can not profile (%s), it is probably reloaded' % fn.__name__)
return fn(*a, **k)
return wrap... |
null | null | null | What does this function do? | def fixup_link(link, target_blank=True):
if target_blank:
link.set('target', '_blank')
link.set('title', url_filename(link.get('href')))
| null | null | null | Set certain attributes we want on every link. | pcsd | def fixup link link target blank=True if target blank link set 'target' ' blank' link set 'title' url filename link get 'href' | 12591 | def fixup_link(link, target_blank=True):
if target_blank:
link.set('target', '_blank')
link.set('title', url_filename(link.get('href')))
| Set certain attributes we want on every link. | set certain attributes we want on every link . | Question:
What does this function do?
Code:
def fixup_link(link, target_blank=True):
if target_blank:
link.set('target', '_blank')
link.set('title', url_filename(link.get('href')))
|
null | null | null | What does this function do? | def _mouse_click(event, params):
if (event.button != 1):
return
if (event.inaxes is None):
if (params['n_channels'] > 100):
return
ax = params['ax']
ylim = ax.get_ylim()
pos = ax.transData.inverted().transform((event.x, event.y))
if ((pos[0] > params['t_start']) or (pos[1] < 0) or (pos[1] > ylim[0])):
... | null | null | null | Vertical select callback. | pcsd | def mouse click event params if event button != 1 return if event inaxes is None if params['n channels'] > 100 return ax = params['ax'] ylim = ax get ylim pos = ax trans Data inverted transform event x event y if pos[0] > params['t start'] or pos[1] < 0 or pos[1] > ylim[0] return params['label click fun'] pos if event ... | 12592 | def _mouse_click(event, params):
if (event.button != 1):
return
if (event.inaxes is None):
if (params['n_channels'] > 100):
return
ax = params['ax']
ylim = ax.get_ylim()
pos = ax.transData.inverted().transform((event.x, event.y))
if ((pos[0] > params['t_start']) or (pos[1] < 0) or (pos[1] > ylim[0])):
... | Vertical select callback. | vertical select callback . | Question:
What does this function do?
Code:
def _mouse_click(event, params):
if (event.button != 1):
return
if (event.inaxes is None):
if (params['n_channels'] > 100):
return
ax = params['ax']
ylim = ax.get_ylim()
pos = ax.transData.inverted().transform((event.x, event.y))
if ((pos[0] > params['t_st... |
null | null | null | What does this function do? | def leftordered(M):
l = list(M.T)
l.sort(key=tuple)
return array(l)[::(-1)].T
| null | null | null | Returns the given matrix in left-ordered-form. | pcsd | def leftordered M l = list M T l sort key=tuple return array l [ -1 ] T | 12611 | def leftordered(M):
l = list(M.T)
l.sort(key=tuple)
return array(l)[::(-1)].T
| Returns the given matrix in left-ordered-form. | returns the given matrix in left - ordered - form . | Question:
What does this function do?
Code:
def leftordered(M):
l = list(M.T)
l.sort(key=tuple)
return array(l)[::(-1)].T
|
null | null | null | What does this function do? | def _sign_app(src, dest, ids, reviewer, tempname, local=False):
active_endpoint = _get_endpoint(reviewer)
timeout = settings.SIGNED_APPS_SERVER_TIMEOUT
if (not active_endpoint):
_no_sign(src, dest)
return
try:
jar = JarExtractor(src, tempname, ids, omit_signature_sections=settings.SIGNED_APPS_OMIT_PER_FILE_SI... | null | null | null | Generate a manifest and signature and send signature to signing server to
be signed. | pcsd | def sign app src dest ids reviewer tempname local=False active endpoint = get endpoint reviewer timeout = settings SIGNED APPS SERVER TIMEOUT if not active endpoint no sign src dest return try jar = Jar Extractor src tempname ids omit signature sections=settings SIGNED APPS OMIT PER FILE SIGS except log error 'Archive ... | 12619 | def _sign_app(src, dest, ids, reviewer, tempname, local=False):
active_endpoint = _get_endpoint(reviewer)
timeout = settings.SIGNED_APPS_SERVER_TIMEOUT
if (not active_endpoint):
_no_sign(src, dest)
return
try:
jar = JarExtractor(src, tempname, ids, omit_signature_sections=settings.SIGNED_APPS_OMIT_PER_FILE_SI... | Generate a manifest and signature and send signature to signing server to
be signed. | generate a manifest and signature and send signature to signing server to be signed . | Question:
What does this function do?
Code:
def _sign_app(src, dest, ids, reviewer, tempname, local=False):
active_endpoint = _get_endpoint(reviewer)
timeout = settings.SIGNED_APPS_SERVER_TIMEOUT
if (not active_endpoint):
_no_sign(src, dest)
return
try:
jar = JarExtractor(src, tempname, ids, omit_signature... |
null | null | null | What does this function do? | @contextfunction
def identities_group_list(context, groups, skip_group=False):
request = context['request']
response_format = 'html'
if ('response_format' in context):
response_format = context['response_format']
return Markup(render_to_string('identities/tags/group_list', {'groups': groups, 'skip_group': skip_gr... | null | null | null | Print a list of groups | pcsd | @contextfunction def identities group list context groups skip group=False request = context['request'] response format = 'html' if 'response format' in context response format = context['response format'] return Markup render to string 'identities/tags/group list' {'groups' groups 'skip group' skip group} context inst... | 12627 | @contextfunction
def identities_group_list(context, groups, skip_group=False):
request = context['request']
response_format = 'html'
if ('response_format' in context):
response_format = context['response_format']
return Markup(render_to_string('identities/tags/group_list', {'groups': groups, 'skip_group': skip_gr... | Print a list of groups | print a list of groups | Question:
What does this function do?
Code:
@contextfunction
def identities_group_list(context, groups, skip_group=False):
request = context['request']
response_format = 'html'
if ('response_format' in context):
response_format = context['response_format']
return Markup(render_to_string('identities/tags/group_... |
null | null | null | What does this function do? | def CheckSection(CFG, sec):
try:
CFG[sec]
return True
except:
CFG[sec] = {}
return False
| null | null | null | Check if INI section exists, if not create it | pcsd | def Check Section CFG sec try CFG[sec] return True except CFG[sec] = {} return False | 12633 | def CheckSection(CFG, sec):
try:
CFG[sec]
return True
except:
CFG[sec] = {}
return False
| Check if INI section exists, if not create it | check if ini section exists , if not create it | Question:
What does this function do?
Code:
def CheckSection(CFG, sec):
try:
CFG[sec]
return True
except:
CFG[sec] = {}
return False
|
null | null | null | What does this function do? | def getid(obj):
try:
return obj.id
except AttributeError:
return obj
| null | null | null | Get object\'s ID or object.
Abstracts the common pattern of allowing both an object or an object\'s ID
as a parameter when dealing with relationships. | pcsd | def getid obj try return obj id except Attribute Error return obj | 12640 | def getid(obj):
try:
return obj.id
except AttributeError:
return obj
| Get object\'s ID or object.
Abstracts the common pattern of allowing both an object or an object\'s ID
as a parameter when dealing with relationships. | get objects id or object . | Question:
What does this function do?
Code:
def getid(obj):
try:
return obj.id
except AttributeError:
return obj
|
null | null | null | What does this function do? | def module_list(path):
if (path == ''):
path = '.'
pjoin = os.path.join
if os.path.isdir(path):
files = []
for (root, dirs, nondirs) in os.walk(path):
subdir = root[(len(path) + 1):]
if subdir:
files.extend((pjoin(subdir, f) for f in nondirs))
dirs[:] = []
else:
files.extend(nondirs)
else... | null | null | null | Return the list containing the names of the modules available in the given
folder. | pcsd | def module list path if path == '' path = ' ' pjoin = os path join if os path isdir path files = [] for root dirs nondirs in os walk path subdir = root[ len path + 1 ] if subdir files extend pjoin subdir f for f in nondirs dirs[ ] = [] else files extend nondirs else try files = list zipimporter path files keys except f... | 12659 | def module_list(path):
if (path == ''):
path = '.'
pjoin = os.path.join
if os.path.isdir(path):
files = []
for (root, dirs, nondirs) in os.walk(path):
subdir = root[(len(path) + 1):]
if subdir:
files.extend((pjoin(subdir, f) for f in nondirs))
dirs[:] = []
else:
files.extend(nondirs)
else... | Return the list containing the names of the modules available in the given
folder. | return the list containing the names of the modules available in the given folder . | Question:
What does this function do?
Code:
def module_list(path):
if (path == ''):
path = '.'
pjoin = os.path.join
if os.path.isdir(path):
files = []
for (root, dirs, nondirs) in os.walk(path):
subdir = root[(len(path) + 1):]
if subdir:
files.extend((pjoin(subdir, f) for f in nondirs))
dirs[:... |
null | null | null | What does this function do? | def flatten_blocks(lines, num_indents=(-1)):
INDENTATION = (' ' * 4)
if (not lines):
return ''
if isinstance(lines, basestring):
return ((INDENTATION * num_indents) + lines)
return '\n'.join([flatten_blocks(line, (num_indents + 1)) for line in lines])
| null | null | null | Takes a list (block) or string (statement) and flattens it into a string
with indentation. | pcsd | def flatten blocks lines num indents= -1 INDENTATION = ' ' * 4 if not lines return '' if isinstance lines basestring return INDENTATION * num indents + lines return ' ' join [flatten blocks line num indents + 1 for line in lines] | 12660 | def flatten_blocks(lines, num_indents=(-1)):
INDENTATION = (' ' * 4)
if (not lines):
return ''
if isinstance(lines, basestring):
return ((INDENTATION * num_indents) + lines)
return '\n'.join([flatten_blocks(line, (num_indents + 1)) for line in lines])
| Takes a list (block) or string (statement) and flattens it into a string
with indentation. | takes a list or string and flattens it into a string with indentation . | Question:
What does this function do?
Code:
def flatten_blocks(lines, num_indents=(-1)):
INDENTATION = (' ' * 4)
if (not lines):
return ''
if isinstance(lines, basestring):
return ((INDENTATION * num_indents) + lines)
return '\n'.join([flatten_blocks(line, (num_indents + 1)) for line in lines])
|
null | null | null | What does this function do? | def register_home(route):
global _home
_home = route
| null | null | null | Registers UI home page | pcsd | def register home route global home home = route | 12664 | def register_home(route):
global _home
_home = route
| Registers UI home page | registers ui home page | Question:
What does this function do?
Code:
def register_home(route):
global _home
_home = route
|
null | null | null | What does this function do? | def _replacestrings(source):
match = re.search('var *(_\\w+)\\=\\["(.*?)"\\];', source, re.DOTALL)
if match:
(varname, strings) = match.groups()
startpoint = len(match.group(0))
lookup = strings.split('","')
variable = ('%s[%%d]' % varname)
for (index, value) in enumerate(lookup):
source = source.replace... | null | null | null | Strip string lookup table (list) and replace values in source. | pcsd | def replacestrings source match = re search 'var * \\w+ \\=\\[" *? "\\] ' source re DOTALL if match varname strings = match groups startpoint = len match group 0 lookup = strings split '" "' variable = '%s[%%d]' % varname for index value in enumerate lookup source = source replace variable % index '"%s"' % value return... | 12676 | def _replacestrings(source):
match = re.search('var *(_\\w+)\\=\\["(.*?)"\\];', source, re.DOTALL)
if match:
(varname, strings) = match.groups()
startpoint = len(match.group(0))
lookup = strings.split('","')
variable = ('%s[%%d]' % varname)
for (index, value) in enumerate(lookup):
source = source.replace... | Strip string lookup table (list) and replace values in source. | strip string lookup table and replace values in source . | Question:
What does this function do?
Code:
def _replacestrings(source):
match = re.search('var *(_\\w+)\\=\\["(.*?)"\\];', source, re.DOTALL)
if match:
(varname, strings) = match.groups()
startpoint = len(match.group(0))
lookup = strings.split('","')
variable = ('%s[%%d]' % varname)
for (index, value) i... |
null | null | null | What does this function do? | def _emit_insert_statements(base_mapper, uowtransaction, cached_connections, mapper, table, insert):
statement = base_mapper._memo(('insert', table), table.insert)
for ((connection, pkeys, hasvalue, has_all_pks, has_all_defaults), records) in groupby(insert, (lambda rec: (rec[4], list(rec[2].keys()), bool(rec[5]), re... | null | null | null | Emit INSERT statements corresponding to value lists collected
by _collect_insert_commands(). | pcsd | def emit insert statements base mapper uowtransaction cached connections mapper table insert statement = base mapper memo 'insert' table table insert for connection pkeys hasvalue has all pks has all defaults records in groupby insert lambda rec rec[4] list rec[2] keys bool rec[5] rec[6] rec[7] if has all defaults or n... | 12677 | def _emit_insert_statements(base_mapper, uowtransaction, cached_connections, mapper, table, insert):
statement = base_mapper._memo(('insert', table), table.insert)
for ((connection, pkeys, hasvalue, has_all_pks, has_all_defaults), records) in groupby(insert, (lambda rec: (rec[4], list(rec[2].keys()), bool(rec[5]), re... | Emit INSERT statements corresponding to value lists collected
by _collect_insert_commands(). | emit insert statements corresponding to value lists collected by _ collect _ insert _ commands ( ) . | Question:
What does this function do?
Code:
def _emit_insert_statements(base_mapper, uowtransaction, cached_connections, mapper, table, insert):
statement = base_mapper._memo(('insert', table), table.insert)
for ((connection, pkeys, hasvalue, has_all_pks, has_all_defaults), records) in groupby(insert, (lambda rec:... |
null | null | null | What does this function do? | def has_mixed_eol_chars(text):
eol_chars = get_eol_chars(text)
if (eol_chars is None):
return False
correct_text = eol_chars.join((text + eol_chars).splitlines())
return (repr(correct_text) != repr(text))
| null | null | null | Detect if text has mixed EOL characters | pcsd | def has mixed eol chars text eol chars = get eol chars text if eol chars is None return False correct text = eol chars join text + eol chars splitlines return repr correct text != repr text | 12690 | def has_mixed_eol_chars(text):
eol_chars = get_eol_chars(text)
if (eol_chars is None):
return False
correct_text = eol_chars.join((text + eol_chars).splitlines())
return (repr(correct_text) != repr(text))
| Detect if text has mixed EOL characters | detect if text has mixed eol characters | Question:
What does this function do?
Code:
def has_mixed_eol_chars(text):
eol_chars = get_eol_chars(text)
if (eol_chars is None):
return False
correct_text = eol_chars.join((text + eol_chars).splitlines())
return (repr(correct_text) != repr(text))
|
null | null | null | What does this function do? | def retry_argument_spec(spec=None):
arg_spec = dict(retries=dict(type='int'), retry_pause=dict(type='float', default=1))
if spec:
arg_spec.update(spec)
return arg_spec
| null | null | null | Creates an argument spec for working with retrying | pcsd | def retry argument spec spec=None arg spec = dict retries=dict type='int' retry pause=dict type='float' default=1 if spec arg spec update spec return arg spec | 12707 | def retry_argument_spec(spec=None):
arg_spec = dict(retries=dict(type='int'), retry_pause=dict(type='float', default=1))
if spec:
arg_spec.update(spec)
return arg_spec
| Creates an argument spec for working with retrying | creates an argument spec for working with retrying | Question:
What does this function do?
Code:
def retry_argument_spec(spec=None):
arg_spec = dict(retries=dict(type='int'), retry_pause=dict(type='float', default=1))
if spec:
arg_spec.update(spec)
return arg_spec
|
null | null | null | What does this function do? | def filter_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)
return (lambda app: TempURL(app, conf))
| null | null | null | Returns the WSGI filter for use with paste.deploy. | pcsd | def filter factory global conf **local conf conf = global conf copy conf update local conf return lambda app Temp URL app conf | 12714 | def filter_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)
return (lambda app: TempURL(app, conf))
| Returns the WSGI filter for use with paste.deploy. | returns the wsgi filter for use with paste . deploy . | Question:
What does this function do?
Code:
def filter_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)
return (lambda app: TempURL(app, conf))
|
null | null | null | What does this function do? | def query_package(module, name, state='present'):
if (state == 'present'):
lcmd = ('pear info %s' % name)
(lrc, lstdout, lstderr) = module.run_command(lcmd, check_rc=False)
if (lrc != 0):
return (False, False)
rcmd = ('pear remote-info %s' % name)
(rrc, rstdout, rstderr) = module.run_command(rcmd, check_r... | null | null | null | Query the package status in both the local system and the repository.
Returns a boolean to indicate if the package is installed,
and a second boolean to indicate if the package is up-to-date. | pcsd | def query package module name state='present' if state == 'present' lcmd = 'pear info %s' % name lrc lstdout lstderr = module run command lcmd check rc=False if lrc != 0 return False False rcmd = 'pear remote-info %s' % name rrc rstdout rstderr = module run command rcmd check rc=False lversion = get local version rstdo... | 12718 | def query_package(module, name, state='present'):
if (state == 'present'):
lcmd = ('pear info %s' % name)
(lrc, lstdout, lstderr) = module.run_command(lcmd, check_rc=False)
if (lrc != 0):
return (False, False)
rcmd = ('pear remote-info %s' % name)
(rrc, rstdout, rstderr) = module.run_command(rcmd, check_r... | Query the package status in both the local system and the repository.
Returns a boolean to indicate if the package is installed,
and a second boolean to indicate if the package is up-to-date. | query the package status in both the local system and the repository . | Question:
What does this function do?
Code:
def query_package(module, name, state='present'):
if (state == 'present'):
lcmd = ('pear info %s' % name)
(lrc, lstdout, lstderr) = module.run_command(lcmd, check_rc=False)
if (lrc != 0):
return (False, False)
rcmd = ('pear remote-info %s' % name)
(rrc, rstdo... |
null | null | null | What does this function do? | def get_translation(request, project, subproject, lang, skip_acl=False):
translation = get_object_or_404(Translation.objects.prefetch(), language__code=lang, subproject__slug=subproject, subproject__project__slug=project, enabled=True)
if (not skip_acl):
translation.check_acl(request)
return translation
| null | null | null | Returns translation matching parameters. | pcsd | def get translation request project subproject lang skip acl=False translation = get object or 404 Translation objects prefetch language code=lang subproject slug=subproject subproject project slug=project enabled=True if not skip acl translation check acl request return translation | 12724 | def get_translation(request, project, subproject, lang, skip_acl=False):
translation = get_object_or_404(Translation.objects.prefetch(), language__code=lang, subproject__slug=subproject, subproject__project__slug=project, enabled=True)
if (not skip_acl):
translation.check_acl(request)
return translation
| Returns translation matching parameters. | returns translation matching parameters . | Question:
What does this function do?
Code:
def get_translation(request, project, subproject, lang, skip_acl=False):
translation = get_object_or_404(Translation.objects.prefetch(), language__code=lang, subproject__slug=subproject, subproject__project__slug=project, enabled=True)
if (not skip_acl):
translation.ch... |
null | null | null | What does this function do? | def join(coro):
return JoinEvent(coro)
| null | null | null | Suspend the thread until another, previously `spawn`ed thread
completes. | pcsd | def join coro return Join Event coro | 12735 | def join(coro):
return JoinEvent(coro)
| Suspend the thread until another, previously `spawn`ed thread
completes. | suspend the thread until another , previously spawned thread completes . | Question:
What does this function do?
Code:
def join(coro):
return JoinEvent(coro)
|
null | null | null | What does this function do? | def writeOutput(fileName):
repository = getNewRepository()
repository.fileNameInput.value = fileName
repository.execute()
settings.startMainLoopFromConstructor(repository)
| null | null | null | Craft a file, display dialog. | pcsd | def write Output file Name repository = get New Repository repository file Name Input value = file Name repository execute settings start Main Loop From Constructor repository | 12750 | def writeOutput(fileName):
repository = getNewRepository()
repository.fileNameInput.value = fileName
repository.execute()
settings.startMainLoopFromConstructor(repository)
| Craft a file, display dialog. | craft a file , display dialog . | Question:
What does this function do?
Code:
def writeOutput(fileName):
repository = getNewRepository()
repository.fileNameInput.value = fileName
repository.execute()
settings.startMainLoopFromConstructor(repository)
|
null | null | null | What does this function do? | def unregister_file(path, pkg=None, conn=None):
if (conn is None):
conn = init()
conn.execute('DELETE FROM files WHERE path=?', (path,))
| null | null | null | Unregister a file from the package database | pcsd | def unregister file path pkg=None conn=None if conn is None conn = init conn execute 'DELETE FROM files WHERE path=?' path | 12751 | def unregister_file(path, pkg=None, conn=None):
if (conn is None):
conn = init()
conn.execute('DELETE FROM files WHERE path=?', (path,))
| Unregister a file from the package database | unregister a file from the package database | Question:
What does this function do?
Code:
def unregister_file(path, pkg=None, conn=None):
if (conn is None):
conn = init()
conn.execute('DELETE FROM files WHERE path=?', (path,))
|
null | null | null | What does this function do? | def master_compile(master_opts, minion_opts, grains, id_, saltenv):
st_ = MasterHighState(master_opts, minion_opts, grains, id_, saltenv)
return st_.compile_highstate()
| null | null | null | Compile the master side low state data, and build the hidden state file | pcsd | def master compile master opts minion opts grains id saltenv st = Master High State master opts minion opts grains id saltenv return st compile highstate | 12759 | def master_compile(master_opts, minion_opts, grains, id_, saltenv):
st_ = MasterHighState(master_opts, minion_opts, grains, id_, saltenv)
return st_.compile_highstate()
| Compile the master side low state data, and build the hidden state file | compile the master side low state data , and build the hidden state file | Question:
What does this function do?
Code:
def master_compile(master_opts, minion_opts, grains, id_, saltenv):
st_ = MasterHighState(master_opts, minion_opts, grains, id_, saltenv)
return st_.compile_highstate()
|
null | null | null | What does this function do? | def pagingRequestType3():
a = L2PseudoLength(l2pLength=19)
b = TpPd(pd=6)
c = MessageType(mesType=36)
d = PageModeAndChannelNeeded()
e = TmsiPTmsi()
f = TmsiPTmsi()
g = TmsiPTmsi()
h = TmsiPTmsi()
i = P3RestOctets()
packet = ((((((((a / b) / c) / d) / e) / f) / g) / h) / i)
return packet
| null | null | null | PAGING REQUEST TYPE 3 Section 9.1.24 | pcsd | def paging Request Type3 a = L2Pseudo Length l2p Length=19 b = Tp Pd pd=6 c = Message Type mes Type=36 d = Page Mode And Channel Needed e = Tmsi P Tmsi f = Tmsi P Tmsi g = Tmsi P Tmsi h = Tmsi P Tmsi i = P3Rest Octets packet = a / b / c / d / e / f / g / h / i return packet | 12774 | def pagingRequestType3():
a = L2PseudoLength(l2pLength=19)
b = TpPd(pd=6)
c = MessageType(mesType=36)
d = PageModeAndChannelNeeded()
e = TmsiPTmsi()
f = TmsiPTmsi()
g = TmsiPTmsi()
h = TmsiPTmsi()
i = P3RestOctets()
packet = ((((((((a / b) / c) / d) / e) / f) / g) / h) / i)
return packet
| PAGING REQUEST TYPE 3 Section 9.1.24 | paging request type 3 section 9 . 1 . 24 | Question:
What does this function do?
Code:
def pagingRequestType3():
a = L2PseudoLength(l2pLength=19)
b = TpPd(pd=6)
c = MessageType(mesType=36)
d = PageModeAndChannelNeeded()
e = TmsiPTmsi()
f = TmsiPTmsi()
g = TmsiPTmsi()
h = TmsiPTmsi()
i = P3RestOctets()
packet = ((((((((a / b) / c) / d) / e) / f) / g... |
null | null | null | What does this function do? | def do_pickle(data):
return to_str(dumps(data, protocol=PICKLE_PROTOCOL))
| null | null | null | Perform pickle to string | pcsd | def do pickle data return to str dumps data protocol=PICKLE PROTOCOL | 12779 | def do_pickle(data):
return to_str(dumps(data, protocol=PICKLE_PROTOCOL))
| Perform pickle to string | perform pickle to string | Question:
What does this function do?
Code:
def do_pickle(data):
return to_str(dumps(data, protocol=PICKLE_PROTOCOL))
|
null | null | null | What does this function do? | def keywords(s, top=10, **kwargs):
return parser.find_keywords(s, **dict({'frequency': parser.frequency, 'top': top, 'pos': ('NN',), 'ignore': ('rt',)}, **kwargs))
| null | null | null | Returns a sorted list of keywords in the given string. | pcsd | def keywords s top=10 **kwargs return parser find keywords s **dict {'frequency' parser frequency 'top' top 'pos' 'NN' 'ignore' 'rt' } **kwargs | 12782 | def keywords(s, top=10, **kwargs):
return parser.find_keywords(s, **dict({'frequency': parser.frequency, 'top': top, 'pos': ('NN',), 'ignore': ('rt',)}, **kwargs))
| Returns a sorted list of keywords in the given string. | returns a sorted list of keywords in the given string . | Question:
What does this function do?
Code:
def keywords(s, top=10, **kwargs):
return parser.find_keywords(s, **dict({'frequency': parser.frequency, 'top': top, 'pos': ('NN',), 'ignore': ('rt',)}, **kwargs))
|
null | null | null | What does this function do? | def _delete_resource(resource, name=None, resource_id=None, region=None, key=None, keyid=None, profile=None, **kwargs):
if (not _exactly_one((name, resource_id))):
raise SaltInvocationError('One (but not both) of name or id must be provided.')
try:
conn = _get_conn(region=region, key=key, keyid=keyid, profile=pro... | null | null | null | Delete a VPC resource. Returns True if successful, otherwise False. | pcsd | def delete resource resource name=None resource id=None region=None key=None keyid=None profile=None **kwargs if not exactly one name resource id raise Salt Invocation Error 'One but not both of name or id must be provided ' try conn = get conn region=region key=key keyid=keyid profile=profile try delete resource = get... | 12783 | def _delete_resource(resource, name=None, resource_id=None, region=None, key=None, keyid=None, profile=None, **kwargs):
if (not _exactly_one((name, resource_id))):
raise SaltInvocationError('One (but not both) of name or id must be provided.')
try:
conn = _get_conn(region=region, key=key, keyid=keyid, profile=pro... | Delete a VPC resource. Returns True if successful, otherwise False. | delete a vpc resource . | Question:
What does this function do?
Code:
def _delete_resource(resource, name=None, resource_id=None, region=None, key=None, keyid=None, profile=None, **kwargs):
if (not _exactly_one((name, resource_id))):
raise SaltInvocationError('One (but not both) of name or id must be provided.')
try:
conn = _get_conn(r... |
null | null | null | What does this function do? | def warning(msg):
sys.stderr.write((('\nWARNING: ' + msg) + '\n'))
| null | null | null | Prints warning messages to stderr | pcsd | def warning msg sys stderr write ' WARNING ' + msg + ' ' | 12788 | def warning(msg):
sys.stderr.write((('\nWARNING: ' + msg) + '\n'))
| Prints warning messages to stderr | prints warning messages to stderr | Question:
What does this function do?
Code:
def warning(msg):
sys.stderr.write((('\nWARNING: ' + msg) + '\n'))
|
null | null | null | What does this function do? | def topic_subscription_push(client, to_delete):
TOPIC_NAME = ('topic_subscription_push-%d' % (_millis(),))
SUB_PUSH = ('topic_subscription_push-sub-%d' % (_millis(),))
PUSH_URL = 'https://api.example.com/push-endpoint'
topic = client.topic(TOPIC_NAME)
topic.create()
to_delete.append(topic)
subscription = topic.s... | null | null | null | Create subscriptions to a topic. | pcsd | def topic subscription push client to delete TOPIC NAME = 'topic subscription push-%d' % millis SUB PUSH = 'topic subscription push-sub-%d' % millis PUSH URL = 'https //api example com/push-endpoint' topic = client topic TOPIC NAME topic create to delete append topic subscription = topic subscription SUB PUSH push endp... | 12797 | def topic_subscription_push(client, to_delete):
TOPIC_NAME = ('topic_subscription_push-%d' % (_millis(),))
SUB_PUSH = ('topic_subscription_push-sub-%d' % (_millis(),))
PUSH_URL = 'https://api.example.com/push-endpoint'
topic = client.topic(TOPIC_NAME)
topic.create()
to_delete.append(topic)
subscription = topic.s... | Create subscriptions to a topic. | create subscriptions to a topic . | Question:
What does this function do?
Code:
def topic_subscription_push(client, to_delete):
TOPIC_NAME = ('topic_subscription_push-%d' % (_millis(),))
SUB_PUSH = ('topic_subscription_push-sub-%d' % (_millis(),))
PUSH_URL = 'https://api.example.com/push-endpoint'
topic = client.topic(TOPIC_NAME)
topic.create()
... |
null | null | null | What does this function do? | def assert_bool(dist, attr, value):
if (bool(value) != value):
raise DistutilsSetupError(('%r must be a boolean value (got %r)' % (attr, value)))
| null | null | null | Verify that value is True, False, 0, or 1 | pcsd | def assert bool dist attr value if bool value != value raise Distutils Setup Error '%r must be a boolean value got %r ' % attr value | 12800 | def assert_bool(dist, attr, value):
if (bool(value) != value):
raise DistutilsSetupError(('%r must be a boolean value (got %r)' % (attr, value)))
| Verify that value is True, False, 0, or 1 | verify that value is true , false , 0 , or 1 | Question:
What does this function do?
Code:
def assert_bool(dist, attr, value):
if (bool(value) != value):
raise DistutilsSetupError(('%r must be a boolean value (got %r)' % (attr, value)))
|
null | null | null | What does this function do? | def do_include(parser, token):
bits = token.split_contents()
if (len(bits) != 2):
raise TemplateSyntaxError(('%r tag takes one argument: the name of the template to be included' % bits[0]))
path = bits[1]
if ((path[0] in ('"', "'")) and (path[(-1)] == path[0])):
return ConstantIncludeNode(path[1:(-1)])
return ... | null | null | null | Loads a template and renders it with the current context.
Example::
{% include "foo/some_include" %} | pcsd | def do include parser token bits = token split contents if len bits != 2 raise Template Syntax Error '%r tag takes one argument the name of the template to be included' % bits[0] path = bits[1] if path[0] in '"' "'" and path[ -1 ] == path[0] return Constant Include Node path[1 -1 ] return Include Node bits[1] | 12802 | def do_include(parser, token):
bits = token.split_contents()
if (len(bits) != 2):
raise TemplateSyntaxError(('%r tag takes one argument: the name of the template to be included' % bits[0]))
path = bits[1]
if ((path[0] in ('"', "'")) and (path[(-1)] == path[0])):
return ConstantIncludeNode(path[1:(-1)])
return ... | Loads a template and renders it with the current context.
Example::
{% include "foo/some_include" %} | loads a template and renders it with the current context . | Question:
What does this function do?
Code:
def do_include(parser, token):
bits = token.split_contents()
if (len(bits) != 2):
raise TemplateSyntaxError(('%r tag takes one argument: the name of the template to be included' % bits[0]))
path = bits[1]
if ((path[0] in ('"', "'")) and (path[(-1)] == path[0])):
re... |
null | null | null | What does this function do? | def AddRoundKey(algInstance, keyBlock):
for column in range(algInstance.Nb):
for row in range(4):
algInstance.state[column][row] ^= keyBlock[column][row]
| null | null | null | XOR the algorithm state with a block of key material | pcsd | def Add Round Key alg Instance key Block for column in range alg Instance Nb for row in range 4 alg Instance state[column][row] ^= key Block[column][row] | 12803 | def AddRoundKey(algInstance, keyBlock):
for column in range(algInstance.Nb):
for row in range(4):
algInstance.state[column][row] ^= keyBlock[column][row]
| XOR the algorithm state with a block of key material | xor the algorithm state with a block of key material | Question:
What does this function do?
Code:
def AddRoundKey(algInstance, keyBlock):
for column in range(algInstance.Nb):
for row in range(4):
algInstance.state[column][row] ^= keyBlock[column][row]
|
null | null | null | What does this function do? | def _quota_reservations_query(context, reservations):
return model_query(context, models.Reservation, read_deleted='no').filter(models.Reservation.uuid.in_(reservations)).with_lockmode('update')
| null | null | null | Return the relevant reservations. | pcsd | def quota reservations query context reservations return model query context models Reservation read deleted='no' filter models Reservation uuid in reservations with lockmode 'update' | 12813 | def _quota_reservations_query(context, reservations):
return model_query(context, models.Reservation, read_deleted='no').filter(models.Reservation.uuid.in_(reservations)).with_lockmode('update')
| Return the relevant reservations. | return the relevant reservations . | Question:
What does this function do?
Code:
def _quota_reservations_query(context, reservations):
return model_query(context, models.Reservation, read_deleted='no').filter(models.Reservation.uuid.in_(reservations)).with_lockmode('update')
|
null | null | null | What does this function do? | def create_job_common(name, priority, control_type, control_file=None, hosts=[], profiles=[], meta_hosts=[], meta_host_profiles=[], one_time_hosts=[], atomic_group_name=None, synch_count=None, is_template=False, timeout=None, max_runtime_hrs=None, run_verify=True, email_list='', dependencies=(), reboot_before=None, reb... | null | null | null | Common code between creating "standard" jobs and creating parameterized jobs | pcsd | def create job common name priority control type control file=None hosts=[] profiles=[] meta hosts=[] meta host profiles=[] one time hosts=[] atomic group name=None synch count=None is template=False timeout=None max runtime hrs=None run verify=True email list='' dependencies= reboot before=None reboot after=None parse... | 12836 | def create_job_common(name, priority, control_type, control_file=None, hosts=[], profiles=[], meta_hosts=[], meta_host_profiles=[], one_time_hosts=[], atomic_group_name=None, synch_count=None, is_template=False, timeout=None, max_runtime_hrs=None, run_verify=True, email_list='', dependencies=(), reboot_before=None, reb... | Common code between creating "standard" jobs and creating parameterized jobs | common code between creating " standard " jobs and creating parameterized jobs | Question:
What does this function do?
Code:
def create_job_common(name, priority, control_type, control_file=None, hosts=[], profiles=[], meta_hosts=[], meta_host_profiles=[], one_time_hosts=[], atomic_group_name=None, synch_count=None, is_template=False, timeout=None, max_runtime_hrs=None, run_verify=True, email_li... |
null | null | null | What does this function do? | def dump_processes():
output_file = (PROFILING_OUTPUT_FMT % get_filename_fmt())
data = {}
for child in multiprocessing.active_children():
pid = child._popen.pid
child_data = {'name': child.name, 'daemon': child.daemon, 'exitcode': child.exitcode, 'target': child._target.__name__, 'args': [], 'kwargs': {}}
for ... | null | null | null | Dumps sub-process information to a file | pcsd | def dump processes output file = PROFILING OUTPUT FMT % get filename fmt data = {} for child in multiprocessing active children pid = child popen pid child data = {'name' child name 'daemon' child daemon 'exitcode' child exitcode 'target' child target name 'args' [] 'kwargs' {}} for arg in child args try json dumps arg... | 12841 | def dump_processes():
output_file = (PROFILING_OUTPUT_FMT % get_filename_fmt())
data = {}
for child in multiprocessing.active_children():
pid = child._popen.pid
child_data = {'name': child.name, 'daemon': child.daemon, 'exitcode': child.exitcode, 'target': child._target.__name__, 'args': [], 'kwargs': {}}
for ... | Dumps sub-process information to a file | dumps sub - process information to a file | Question:
What does this function do?
Code:
def dump_processes():
output_file = (PROFILING_OUTPUT_FMT % get_filename_fmt())
data = {}
for child in multiprocessing.active_children():
pid = child._popen.pid
child_data = {'name': child.name, 'daemon': child.daemon, 'exitcode': child.exitcode, 'target': child._ta... |
null | null | null | What does this function do? | def float_to_rational(flt):
int_part = int(flt)
error = (flt - int_part)
if (abs(error) < 0.0001):
return (int_part, 1)
(den, num) = float_to_rational((1.0 / error))
return (((int_part * den) + num), den)
| null | null | null | Converts a float to a rational pair. | pcsd | def float to rational flt int part = int flt error = flt - int part if abs error < 0 0001 return int part 1 den num = float to rational 1 0 / error return int part * den + num den | 12849 | def float_to_rational(flt):
int_part = int(flt)
error = (flt - int_part)
if (abs(error) < 0.0001):
return (int_part, 1)
(den, num) = float_to_rational((1.0 / error))
return (((int_part * den) + num), den)
| Converts a float to a rational pair. | converts a float to a rational pair . | Question:
What does this function do?
Code:
def float_to_rational(flt):
int_part = int(flt)
error = (flt - int_part)
if (abs(error) < 0.0001):
return (int_part, 1)
(den, num) = float_to_rational((1.0 / error))
return (((int_part * den) + num), den)
|
null | null | null | What does this function do? | def dset_sheet(dataset, ws, freeze_panes=True):
_package = dataset._package(dicts=False)
for (i, sep) in enumerate(dataset._separators):
_offset = i
_package.insert((sep[0] + _offset), (sep[1],))
for (i, row) in enumerate(_package):
row_number = (i + 1)
for (j, col) in enumerate(row):
col_idx = get_column... | null | null | null | Completes given worksheet from given Dataset. | pcsd | def dset sheet dataset ws freeze panes=True package = dataset package dicts=False for i sep in enumerate dataset separators offset = i package insert sep[0] + offset sep[1] for i row in enumerate package row number = i + 1 for j col in enumerate row col idx = get column letter j + 1 if row number == 1 and dataset heade... | 12850 | def dset_sheet(dataset, ws, freeze_panes=True):
_package = dataset._package(dicts=False)
for (i, sep) in enumerate(dataset._separators):
_offset = i
_package.insert((sep[0] + _offset), (sep[1],))
for (i, row) in enumerate(_package):
row_number = (i + 1)
for (j, col) in enumerate(row):
col_idx = get_column... | Completes given worksheet from given Dataset. | completes given worksheet from given dataset . | Question:
What does this function do?
Code:
def dset_sheet(dataset, ws, freeze_panes=True):
_package = dataset._package(dicts=False)
for (i, sep) in enumerate(dataset._separators):
_offset = i
_package.insert((sep[0] + _offset), (sep[1],))
for (i, row) in enumerate(_package):
row_number = (i + 1)
for (j, ... |
null | null | null | What does this function do? | def job_title():
mode = session.s3.hrm.mode
def prep(r):
if (mode is not None):
auth.permission.fail()
elif (r.representation == 'xls'):
current.messages['NONE'] = ''
table = s3db.hrm_job_title
table.organisation_id.represent = s3db.org_OrganisationRepresent(acronym=False, parent=False)
table.organ... | null | null | null | Job Titles Controller | pcsd | def job title mode = session s3 hrm mode def prep r if mode is not None auth permission fail elif r representation == 'xls' current messages['NONE'] = '' table = s3db hrm job title table organisation id represent = s3db org Organisation Represent acronym=False parent=False table organisation id label = None table type ... | 12854 | def job_title():
mode = session.s3.hrm.mode
def prep(r):
if (mode is not None):
auth.permission.fail()
elif (r.representation == 'xls'):
current.messages['NONE'] = ''
table = s3db.hrm_job_title
table.organisation_id.represent = s3db.org_OrganisationRepresent(acronym=False, parent=False)
table.organ... | Job Titles Controller | job titles controller | Question:
What does this function do?
Code:
def job_title():
mode = session.s3.hrm.mode
def prep(r):
if (mode is not None):
auth.permission.fail()
elif (r.representation == 'xls'):
current.messages['NONE'] = ''
table = s3db.hrm_job_title
table.organisation_id.represent = s3db.org_OrganisationRepres... |
null | null | null | What does this function do? | def incorrect_policy_index(info, remote_info):
if ('storage_policy_index' not in remote_info):
return False
if (remote_info['storage_policy_index'] == info['storage_policy_index']):
return False
return (info['storage_policy_index'] != sorted([info, remote_info], cmp=cmp_policy_info)[0]['storage_policy_index'])
| null | null | null | Compare remote_info to info and decide if the remote storage policy index
should be used instead of ours. | pcsd | def incorrect policy index info remote info if 'storage policy index' not in remote info return False if remote info['storage policy index'] == info['storage policy index'] return False return info['storage policy index'] != sorted [info remote info] cmp=cmp policy info [0]['storage policy index'] | 12859 | def incorrect_policy_index(info, remote_info):
if ('storage_policy_index' not in remote_info):
return False
if (remote_info['storage_policy_index'] == info['storage_policy_index']):
return False
return (info['storage_policy_index'] != sorted([info, remote_info], cmp=cmp_policy_info)[0]['storage_policy_index'])
| Compare remote_info to info and decide if the remote storage policy index
should be used instead of ours. | compare remote _ info to info and decide if the remote storage policy index should be used instead of ours . | Question:
What does this function do?
Code:
def incorrect_policy_index(info, remote_info):
if ('storage_policy_index' not in remote_info):
return False
if (remote_info['storage_policy_index'] == info['storage_policy_index']):
return False
return (info['storage_policy_index'] != sorted([info, remote_info], cmp... |
null | null | null | What does this function do? | @utils.arg('--extra-specs', dest='extra_specs', action='store_true', default=False, help=_('Get extra-specs of each flavor.'))
@utils.arg('--all', dest='all', action='store_true', default=False, help=_('Display all flavors (Admin only).'))
@utils.arg('--marker', dest='marker', metavar='<marker>', default=None, help=_('... | null | null | null | Print a list of available \'flavors\' (sizes of servers). | pcsd | @utils arg '--extra-specs' dest='extra specs' action='store true' default=False help= 'Get extra-specs of each flavor ' @utils arg '--all' dest='all' action='store true' default=False help= 'Display all flavors Admin only ' @utils arg '--marker' dest='marker' metavar='<marker>' default=None help= 'The last flavor ID of... | 12864 | @utils.arg('--extra-specs', dest='extra_specs', action='store_true', default=False, help=_('Get extra-specs of each flavor.'))
@utils.arg('--all', dest='all', action='store_true', default=False, help=_('Display all flavors (Admin only).'))
@utils.arg('--marker', dest='marker', metavar='<marker>', default=None, help=_('... | Print a list of available \'flavors\' (sizes of servers). | print a list of available flavors . | Question:
What does this function do?
Code:
@utils.arg('--extra-specs', dest='extra_specs', action='store_true', default=False, help=_('Get extra-specs of each flavor.'))
@utils.arg('--all', dest='all', action='store_true', default=False, help=_('Display all flavors (Admin only).'))
@utils.arg('--marker', dest='mark... |
null | null | null | What does this function do? | def _save_modified_value(_config_vars, cv, newvalue):
oldvalue = _config_vars.get(cv, '')
if ((oldvalue != newvalue) and ((_INITPRE + cv) not in _config_vars)):
_config_vars[(_INITPRE + cv)] = oldvalue
_config_vars[cv] = newvalue
| null | null | null | Save modified and original unmodified value of configuration var | pcsd | def save modified value config vars cv newvalue oldvalue = config vars get cv '' if oldvalue != newvalue and INITPRE + cv not in config vars config vars[ INITPRE + cv ] = oldvalue config vars[cv] = newvalue | 12865 | def _save_modified_value(_config_vars, cv, newvalue):
oldvalue = _config_vars.get(cv, '')
if ((oldvalue != newvalue) and ((_INITPRE + cv) not in _config_vars)):
_config_vars[(_INITPRE + cv)] = oldvalue
_config_vars[cv] = newvalue
| Save modified and original unmodified value of configuration var | save modified and original unmodified value of configuration var | Question:
What does this function do?
Code:
def _save_modified_value(_config_vars, cv, newvalue):
oldvalue = _config_vars.get(cv, '')
if ((oldvalue != newvalue) and ((_INITPRE + cv) not in _config_vars)):
_config_vars[(_INITPRE + cv)] = oldvalue
_config_vars[cv] = newvalue
|
null | null | null | What does this function do? | def parse_bootstrap_support(lines):
bootstraps = {}
for line in lines:
if (line[0] == '#'):
continue
wordlist = line.strip().split()
bootstraps[wordlist[0]] = float(wordlist[1])
return bootstraps
| null | null | null | Parser for a bootstrap/jackknife support in tab delimited text | pcsd | def parse bootstrap support lines bootstraps = {} for line in lines if line[0] == '#' continue wordlist = line strip split bootstraps[wordlist[0]] = float wordlist[1] return bootstraps | 12866 | def parse_bootstrap_support(lines):
bootstraps = {}
for line in lines:
if (line[0] == '#'):
continue
wordlist = line.strip().split()
bootstraps[wordlist[0]] = float(wordlist[1])
return bootstraps
| Parser for a bootstrap/jackknife support in tab delimited text | parser for a bootstrap / jackknife support in tab delimited text | Question:
What does this function do?
Code:
def parse_bootstrap_support(lines):
bootstraps = {}
for line in lines:
if (line[0] == '#'):
continue
wordlist = line.strip().split()
bootstraps[wordlist[0]] = float(wordlist[1])
return bootstraps
|
null | null | null | What does this function do? | def line_shortening_rank(candidate, indent_word, max_line_length, experimental=False):
if (not candidate.strip()):
return 0
rank = 0
lines = candidate.rstrip().split(u'\n')
offset = 0
if ((not lines[0].lstrip().startswith(u'#')) and (lines[0].rstrip()[(-1)] not in u'([{')):
for (opening, closing) in (u'()', u'... | null | null | null | Return rank of candidate.
This is for sorting candidates. | pcsd | def line shortening rank candidate indent word max line length experimental=False if not candidate strip return 0 rank = 0 lines = candidate rstrip split u' ' offset = 0 if not lines[0] lstrip startswith u'#' and lines[0] rstrip [ -1 ] not in u' [{' for opening closing in u' ' u'[]' u'{}' opening loc = lines[0] find op... | 12868 | def line_shortening_rank(candidate, indent_word, max_line_length, experimental=False):
if (not candidate.strip()):
return 0
rank = 0
lines = candidate.rstrip().split(u'\n')
offset = 0
if ((not lines[0].lstrip().startswith(u'#')) and (lines[0].rstrip()[(-1)] not in u'([{')):
for (opening, closing) in (u'()', u'... | Return rank of candidate.
This is for sorting candidates. | return rank of candidate . | Question:
What does this function do?
Code:
def line_shortening_rank(candidate, indent_word, max_line_length, experimental=False):
if (not candidate.strip()):
return 0
rank = 0
lines = candidate.rstrip().split(u'\n')
offset = 0
if ((not lines[0].lstrip().startswith(u'#')) and (lines[0].rstrip()[(-1)] not in u... |
null | null | null | What does this function do? | def _get_evoked_node(fname):
(f, tree, _) = fiff_open(fname)
with f as fid:
(_, meas) = read_meas_info(fid, tree, verbose=False)
evoked_node = dir_tree_find(meas, FIFF.FIFFB_EVOKED)
return evoked_node
| null | null | null | Get info in evoked file. | pcsd | def get evoked node fname f tree = fiff open fname with f as fid meas = read meas info fid tree verbose=False evoked node = dir tree find meas FIFF FIFFB EVOKED return evoked node | 12869 | def _get_evoked_node(fname):
(f, tree, _) = fiff_open(fname)
with f as fid:
(_, meas) = read_meas_info(fid, tree, verbose=False)
evoked_node = dir_tree_find(meas, FIFF.FIFFB_EVOKED)
return evoked_node
| Get info in evoked file. | get info in evoked file . | Question:
What does this function do?
Code:
def _get_evoked_node(fname):
(f, tree, _) = fiff_open(fname)
with f as fid:
(_, meas) = read_meas_info(fid, tree, verbose=False)
evoked_node = dir_tree_find(meas, FIFF.FIFFB_EVOKED)
return evoked_node
|
null | null | null | What does this function do? | def hash_password(password):
password_utf8 = trunc_password(password).encode('utf-8')
if passlib.hash.sha512_crypt.identify(password_utf8):
return password_utf8
h = passlib.hash.sha512_crypt.encrypt(password_utf8, rounds=CONF.crypt_strength)
return h
| null | null | null | Hash a password. Hard. | pcsd | def hash password password password utf8 = trunc password password encode 'utf-8' if passlib hash sha512 crypt identify password utf8 return password utf8 h = passlib hash sha512 crypt encrypt password utf8 rounds=CONF crypt strength return h | 12870 | def hash_password(password):
password_utf8 = trunc_password(password).encode('utf-8')
if passlib.hash.sha512_crypt.identify(password_utf8):
return password_utf8
h = passlib.hash.sha512_crypt.encrypt(password_utf8, rounds=CONF.crypt_strength)
return h
| Hash a password. Hard. | hash a password . | Question:
What does this function do?
Code:
def hash_password(password):
password_utf8 = trunc_password(password).encode('utf-8')
if passlib.hash.sha512_crypt.identify(password_utf8):
return password_utf8
h = passlib.hash.sha512_crypt.encrypt(password_utf8, rounds=CONF.crypt_strength)
return h
|
null | null | null | What does this function do? | @command('reverse all')
def reverse_playlist():
if ((g.last_search_query == (None, None)) or ('func' not in g.last_search_query[1])):
g.content = content.logo()
g.message = 'No playlist loaded'
return
songs_list_or_func = g.last_search_query[1]['func']
if callable(songs_list_or_func):
songs = reversed(songs_... | null | null | null | Reverse order of entire loaded playlist. | pcsd | @command 'reverse all' def reverse playlist if g last search query == None None or 'func' not in g last search query[1] g content = content logo g message = 'No playlist loaded' return songs list or func = g last search query[1]['func'] if callable songs list or func songs = reversed songs list or func 0 None else song... | 12878 | @command('reverse all')
def reverse_playlist():
if ((g.last_search_query == (None, None)) or ('func' not in g.last_search_query[1])):
g.content = content.logo()
g.message = 'No playlist loaded'
return
songs_list_or_func = g.last_search_query[1]['func']
if callable(songs_list_or_func):
songs = reversed(songs_... | Reverse order of entire loaded playlist. | reverse order of entire loaded playlist . | Question:
What does this function do?
Code:
@command('reverse all')
def reverse_playlist():
if ((g.last_search_query == (None, None)) or ('func' not in g.last_search_query[1])):
g.content = content.logo()
g.message = 'No playlist loaded'
return
songs_list_or_func = g.last_search_query[1]['func']
if callable... |
null | null | null | What does this function do? | def mangle_identifier(ident):
splitted = (''.join(map(_encode, x)) for x in ident.split('.'))
parts = [('%d%s' % (len(x), x)) for x in splitted]
if (len(parts) > 1):
return ('N%sE' % ''.join(parts))
else:
return parts[0]
| null | null | null | Mangle the identifier
This treats \'.\' as \'::\' in C++ | pcsd | def mangle identifier ident splitted = '' join map encode x for x in ident split ' ' parts = [ '%d%s' % len x x for x in splitted] if len parts > 1 return 'N%s E' % '' join parts else return parts[0] | 12880 | def mangle_identifier(ident):
splitted = (''.join(map(_encode, x)) for x in ident.split('.'))
parts = [('%d%s' % (len(x), x)) for x in splitted]
if (len(parts) > 1):
return ('N%sE' % ''.join(parts))
else:
return parts[0]
| Mangle the identifier
This treats \'.\' as \'::\' in C++ | mangle the identifier | Question:
What does this function do?
Code:
def mangle_identifier(ident):
splitted = (''.join(map(_encode, x)) for x in ident.split('.'))
parts = [('%d%s' % (len(x), x)) for x in splitted]
if (len(parts) > 1):
return ('N%sE' % ''.join(parts))
else:
return parts[0]
|
null | null | null | What does this function do? | def yield_translation_csv_messages(file, no_header=False):
csvreader = csv.reader(file, lineterminator='\n')
if (not no_header):
columns = next(csvreader)
assert (columns == 'language_id,table,id,column,source_crc,string'.split(','))
for (language_id, table, id, column, source_crc, string) in csvreader:
if isi... | null | null | null | Yield messages from a translation CSV file | pcsd | def yield translation csv messages file no header=False csvreader = csv reader file lineterminator=' ' if not no header columns = next csvreader assert columns == 'language id table id column source crc string' split ' ' for language id table id column source crc string in csvreader if isinstance string bytes string = ... | 12892 | def yield_translation_csv_messages(file, no_header=False):
csvreader = csv.reader(file, lineterminator='\n')
if (not no_header):
columns = next(csvreader)
assert (columns == 'language_id,table,id,column,source_crc,string'.split(','))
for (language_id, table, id, column, source_crc, string) in csvreader:
if isi... | Yield messages from a translation CSV file | yield messages from a translation csv file | Question:
What does this function do?
Code:
def yield_translation_csv_messages(file, no_header=False):
csvreader = csv.reader(file, lineterminator='\n')
if (not no_header):
columns = next(csvreader)
assert (columns == 'language_id,table,id,column,source_crc,string'.split(','))
for (language_id, table, id, col... |
null | null | null | What does this function do? | def compile_controllers(folder):
path = pjoin(folder, 'controllers')
for fname in listdir(path, '.+\\.py$'):
data = read_file(pjoin(path, fname))
exposed = find_exposed_functions(data)
for function in exposed:
command = (data + ('\nresponse._vars=response._caller(%s)\n' % function))
filename = pjoin(folde... | null | null | null | Compiles all the controllers in the application specified by `folder` | pcsd | def compile controllers folder path = pjoin folder 'controllers' for fname in listdir path ' +\\ py$' data = read file pjoin path fname exposed = find exposed functions data for function in exposed command = data + ' response vars=response caller %s ' % function filename = pjoin folder 'compiled' 'controllers %s %s py'... | 12896 | def compile_controllers(folder):
path = pjoin(folder, 'controllers')
for fname in listdir(path, '.+\\.py$'):
data = read_file(pjoin(path, fname))
exposed = find_exposed_functions(data)
for function in exposed:
command = (data + ('\nresponse._vars=response._caller(%s)\n' % function))
filename = pjoin(folde... | Compiles all the controllers in the application specified by `folder` | compiles all the controllers in the application specified by folder | Question:
What does this function do?
Code:
def compile_controllers(folder):
path = pjoin(folder, 'controllers')
for fname in listdir(path, '.+\\.py$'):
data = read_file(pjoin(path, fname))
exposed = find_exposed_functions(data)
for function in exposed:
command = (data + ('\nresponse._vars=response._calle... |
null | null | null | What does this function do? | def _reciprocity_iter(G, nodes):
n = G.nbunch_iter(nodes)
for node in n:
pred = set(G.predecessors(node))
succ = set(G.successors(node))
overlap = (pred & succ)
n_total = (len(pred) + len(succ))
if (n_total == 0):
(yield (node, None))
else:
reciprocity = ((2.0 * float(len(overlap))) / float(n_total)... | null | null | null | Return an iterator of (node, reciprocity). | pcsd | def reciprocity iter G nodes n = G nbunch iter nodes for node in n pred = set G predecessors node succ = set G successors node overlap = pred & succ n total = len pred + len succ if n total == 0 yield node None else reciprocity = 2 0 * float len overlap / float n total yield node reciprocity | 12897 | def _reciprocity_iter(G, nodes):
n = G.nbunch_iter(nodes)
for node in n:
pred = set(G.predecessors(node))
succ = set(G.successors(node))
overlap = (pred & succ)
n_total = (len(pred) + len(succ))
if (n_total == 0):
(yield (node, None))
else:
reciprocity = ((2.0 * float(len(overlap))) / float(n_total)... | Return an iterator of (node, reciprocity). | return an iterator of . | Question:
What does this function do?
Code:
def _reciprocity_iter(G, nodes):
n = G.nbunch_iter(nodes)
for node in n:
pred = set(G.predecessors(node))
succ = set(G.successors(node))
overlap = (pred & succ)
n_total = (len(pred) + len(succ))
if (n_total == 0):
(yield (node, None))
else:
reciprocity ... |
null | null | null | What does this function do? | def file_upload_echo(request):
r = dict([(k, f.name) for (k, f) in request.FILES.items()])
return HttpResponse(simplejson.dumps(r))
| null | null | null | Simple view to echo back info about uploaded files for tests. | pcsd | def file upload echo request r = dict [ k f name for k f in request FILES items ] return Http Response simplejson dumps r | 12898 | def file_upload_echo(request):
r = dict([(k, f.name) for (k, f) in request.FILES.items()])
return HttpResponse(simplejson.dumps(r))
| Simple view to echo back info about uploaded files for tests. | simple view to echo back info about uploaded files for tests . | Question:
What does this function do?
Code:
def file_upload_echo(request):
r = dict([(k, f.name) for (k, f) in request.FILES.items()])
return HttpResponse(simplejson.dumps(r))
|
null | null | null | What does this function do? | @register.filter
def to_js(value):
return mark_safe(('JSON.parse("%s")' % escapejs(jsonify(value))))
| null | null | null | Returns a string which leaves the value readily available for JS
consumption. | pcsd | @register filter def to js value return mark safe 'JSON parse "%s" ' % escapejs jsonify value | 12899 | @register.filter
def to_js(value):
return mark_safe(('JSON.parse("%s")' % escapejs(jsonify(value))))
| Returns a string which leaves the value readily available for JS
consumption. | returns a string which leaves the value readily available for js consumption . | Question:
What does this function do?
Code:
@register.filter
def to_js(value):
return mark_safe(('JSON.parse("%s")' % escapejs(jsonify(value))))
|
null | null | null | What does this function do? | @library.global_function
def now_in_timezone(timezone_name):
zone = timezone(timezone_name)
return zone.normalize(aware_utcnow().astimezone(zone))
| null | null | null | Return the current time, expressed in the named timezone | pcsd | @library global function def now in timezone timezone name zone = timezone timezone name return zone normalize aware utcnow astimezone zone | 12906 | @library.global_function
def now_in_timezone(timezone_name):
zone = timezone(timezone_name)
return zone.normalize(aware_utcnow().astimezone(zone))
| Return the current time, expressed in the named timezone | return the current time , expressed in the named timezone | Question:
What does this function do?
Code:
@library.global_function
def now_in_timezone(timezone_name):
zone = timezone(timezone_name)
return zone.normalize(aware_utcnow().astimezone(zone))
|
null | null | null | What does this function do? | def heappop(heap):
lastelt = heap.pop()
if heap:
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)
else:
returnitem = lastelt
return returnitem
| null | null | null | Pop the smallest item off the heap, maintaining the heap invariant. | pcsd | def heappop heap lastelt = heap pop if heap returnitem = heap[0] heap[0] = lastelt siftup heap 0 else returnitem = lastelt return returnitem | 12916 | def heappop(heap):
lastelt = heap.pop()
if heap:
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)
else:
returnitem = lastelt
return returnitem
| Pop the smallest item off the heap, maintaining the heap invariant. | pop the smallest item off the heap , maintaining the heap invariant . | Question:
What does this function do?
Code:
def heappop(heap):
lastelt = heap.pop()
if heap:
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)
else:
returnitem = lastelt
return returnitem
|
null | null | null | What does this function do? | def _service_path(name):
if (not SERVICE_DIR):
raise CommandExecutionError('Could not find service directory.')
return os.path.join(SERVICE_DIR, name)
| null | null | null | Return SERVICE_DIR+name if possible
name
the service\'s name to work on | pcsd | def service path name if not SERVICE DIR raise Command Execution Error 'Could not find service directory ' return os path join SERVICE DIR name | 12918 | def _service_path(name):
if (not SERVICE_DIR):
raise CommandExecutionError('Could not find service directory.')
return os.path.join(SERVICE_DIR, name)
| Return SERVICE_DIR+name if possible
name
the service\'s name to work on | return service _ dir + name if possible name the services name to work on | Question:
What does this function do?
Code:
def _service_path(name):
if (not SERVICE_DIR):
raise CommandExecutionError('Could not find service directory.')
return os.path.join(SERVICE_DIR, name)
|
null | null | null | What does this function do? | def singularize(word, pos=NOUN, custom={}):
if (word in custom):
return custom[word]
w = word.lower()
if (pos == 'DT'):
if (w in ('i', 'gli')):
return 'il'
if (w == 'el'):
return 'la'
return w
if (len(w) < 3):
return w
if (w in singular_irregular):
return singular_irregular[w]
for (a, b) in sing... | null | null | null | Returns the singular of a given word. | pcsd | def singularize word pos=NOUN custom={} if word in custom return custom[word] w = word lower if pos == 'DT' if w in 'i' 'gli' return 'il' if w == 'el' return 'la' return w if len w < 3 return w if w in singular irregular return singular irregular[w] for a b in singular majority vote if w endswith a return w[ - len a ] ... | 12919 | def singularize(word, pos=NOUN, custom={}):
if (word in custom):
return custom[word]
w = word.lower()
if (pos == 'DT'):
if (w in ('i', 'gli')):
return 'il'
if (w == 'el'):
return 'la'
return w
if (len(w) < 3):
return w
if (w in singular_irregular):
return singular_irregular[w]
for (a, b) in sing... | Returns the singular of a given word. | returns the singular of a given word . | Question:
What does this function do?
Code:
def singularize(word, pos=NOUN, custom={}):
if (word in custom):
return custom[word]
w = word.lower()
if (pos == 'DT'):
if (w in ('i', 'gli')):
return 'il'
if (w == 'el'):
return 'la'
return w
if (len(w) < 3):
return w
if (w in singular_irregular):
r... |
null | null | null | What does this function do? | def dump_data(app_labels, format='json', indent=None):
from django.db.models import get_app, get_apps, get_models
from django.core import serializers
if (len(app_labels) == 0):
app_list = get_apps()
else:
app_list = [get_app(app_label) for app_label in app_labels]
try:
serializers.get_serializer(format)
exc... | null | null | null | Output the current contents of the database as a fixture of the given format | pcsd | def dump data app labels format='json' indent=None from django db models import get app get apps get models from django core import serializers if len app labels == 0 app list = get apps else app list = [get app app label for app label in app labels] try serializers get serializer format except Key Error sys stderr wri... | 12926 | def dump_data(app_labels, format='json', indent=None):
from django.db.models import get_app, get_apps, get_models
from django.core import serializers
if (len(app_labels) == 0):
app_list = get_apps()
else:
app_list = [get_app(app_label) for app_label in app_labels]
try:
serializers.get_serializer(format)
exc... | Output the current contents of the database as a fixture of the given format | output the current contents of the database as a fixture of the given format | Question:
What does this function do?
Code:
def dump_data(app_labels, format='json', indent=None):
from django.db.models import get_app, get_apps, get_models
from django.core import serializers
if (len(app_labels) == 0):
app_list = get_apps()
else:
app_list = [get_app(app_label) for app_label in app_labels]
... |
null | null | null | What does this function do? | @testing.requires_testing_data
def test_maxwell_filter_additional():
data_path = op.join(testing.data_path(download=False))
file_name = 'test_move_anon'
raw_fname = op.join(data_path, 'SSS', (file_name + '_raw.fif'))
raw = read_crop(raw_fname, (0.0, 2.0))
raw.load_data()
raw.pick_types(meg=True, eeg=False)
int_o... | null | null | null | Test processing of Maxwell filtered data. | pcsd | @testing requires testing data def test maxwell filter additional data path = op join testing data path download=False file name = 'test move anon' raw fname = op join data path 'SSS' file name + ' raw fif' raw = read crop raw fname 0 0 2 0 raw load data raw pick types meg=True eeg=False int order = 8 raw sss = maxwell... | 12928 | @testing.requires_testing_data
def test_maxwell_filter_additional():
data_path = op.join(testing.data_path(download=False))
file_name = 'test_move_anon'
raw_fname = op.join(data_path, 'SSS', (file_name + '_raw.fif'))
raw = read_crop(raw_fname, (0.0, 2.0))
raw.load_data()
raw.pick_types(meg=True, eeg=False)
int_o... | Test processing of Maxwell filtered data. | test processing of maxwell filtered data . | Question:
What does this function do?
Code:
@testing.requires_testing_data
def test_maxwell_filter_additional():
data_path = op.join(testing.data_path(download=False))
file_name = 'test_move_anon'
raw_fname = op.join(data_path, 'SSS', (file_name + '_raw.fif'))
raw = read_crop(raw_fname, (0.0, 2.0))
raw.load_dat... |
null | null | null | What does this function do? | def approx_fprime(x, f, eps=None, *args):
if (eps is None):
eps = np.sqrt(np.finfo(ca.float_).eps)
grad = np.zeros_like(x)
step = np.zeros_like(x)
for idx in np.ndindex(x.shape):
step[idx] = (eps * max(abs(x[idx]), 1.0))
grad[idx] = ((f(*(((x + step),) + args)) - f(*(((x - step),) + args))) / (2 * step[idx]))... | null | null | null | Central difference approximation of the gradient of a scalar function. | pcsd | def approx fprime x f eps=None *args if eps is None eps = np sqrt np finfo ca float eps grad = np zeros like x step = np zeros like x for idx in np ndindex x shape step[idx] = eps * max abs x[idx] 1 0 grad[idx] = f * x + step + args - f * x - step + args / 2 * step[idx] step[idx] = 0 0 return grad | 12931 | def approx_fprime(x, f, eps=None, *args):
if (eps is None):
eps = np.sqrt(np.finfo(ca.float_).eps)
grad = np.zeros_like(x)
step = np.zeros_like(x)
for idx in np.ndindex(x.shape):
step[idx] = (eps * max(abs(x[idx]), 1.0))
grad[idx] = ((f(*(((x + step),) + args)) - f(*(((x - step),) + args))) / (2 * step[idx]))... | Central difference approximation of the gradient of a scalar function. | central difference approximation of the gradient of a scalar function . | Question:
What does this function do?
Code:
def approx_fprime(x, f, eps=None, *args):
if (eps is None):
eps = np.sqrt(np.finfo(ca.float_).eps)
grad = np.zeros_like(x)
step = np.zeros_like(x)
for idx in np.ndindex(x.shape):
step[idx] = (eps * max(abs(x[idx]), 1.0))
grad[idx] = ((f(*(((x + step),) + args)) -... |
null | null | null | What does this function do? | def rss_mail(feed, jobs):
parm = {'amount': len(jobs), 'feed': feed, 'jobs': jobs}
return send_with_template('rss', parm)
| null | null | null | Send notification email containing list of files | pcsd | def rss mail feed jobs parm = {'amount' len jobs 'feed' feed 'jobs' jobs} return send with template 'rss' parm | 12941 | def rss_mail(feed, jobs):
parm = {'amount': len(jobs), 'feed': feed, 'jobs': jobs}
return send_with_template('rss', parm)
| Send notification email containing list of files | send notification email containing list of files | Question:
What does this function do?
Code:
def rss_mail(feed, jobs):
parm = {'amount': len(jobs), 'feed': feed, 'jobs': jobs}
return send_with_template('rss', parm)
|
null | null | null | What does this function do? | def _end_of_life_tween_factory(handler, registry):
deprecation_msg = 'The service you are trying to connect no longer exists at this location.'
def eos_tween(request):
eos_date = registry.settings['eos']
eos_url = registry.settings['eos_url']
eos_message = registry.settings['eos_message']
if (not eos_date):
... | null | null | null | Pyramid tween to handle service end of life. | pcsd | def end of life tween factory handler registry deprecation msg = 'The service you are trying to connect no longer exists at this location ' def eos tween request eos date = registry settings['eos'] eos url = registry settings['eos url'] eos message = registry settings['eos message'] if not eos date return handler reque... | 12976 | def _end_of_life_tween_factory(handler, registry):
deprecation_msg = 'The service you are trying to connect no longer exists at this location.'
def eos_tween(request):
eos_date = registry.settings['eos']
eos_url = registry.settings['eos_url']
eos_message = registry.settings['eos_message']
if (not eos_date):
... | Pyramid tween to handle service end of life. | pyramid tween to handle service end of life . | Question:
What does this function do?
Code:
def _end_of_life_tween_factory(handler, registry):
deprecation_msg = 'The service you are trying to connect no longer exists at this location.'
def eos_tween(request):
eos_date = registry.settings['eos']
eos_url = registry.settings['eos_url']
eos_message = registry... |
null | null | null | What does this function do? | def run():
games = Webapp.category('games')
if games:
apps = Webapp.objects.filter(categories=games.id)
for app in apps:
AER.objects.get_or_create(addon=app, region=mkt.regions.BR.id)
| null | null | null | Exclude Games in Brazil. | pcsd | def run games = Webapp category 'games' if games apps = Webapp objects filter categories=games id for app in apps AER objects get or create addon=app region=mkt regions BR id | 12984 | def run():
games = Webapp.category('games')
if games:
apps = Webapp.objects.filter(categories=games.id)
for app in apps:
AER.objects.get_or_create(addon=app, region=mkt.regions.BR.id)
| Exclude Games in Brazil. | exclude games in brazil . | Question:
What does this function do?
Code:
def run():
games = Webapp.category('games')
if games:
apps = Webapp.objects.filter(categories=games.id)
for app in apps:
AER.objects.get_or_create(addon=app, region=mkt.regions.BR.id)
|
null | null | null | What does this function do? | def _atq(**kwargs):
jobs = []
runas = kwargs.get('runas', None)
tag = kwargs.get('tag', None)
hour = kwargs.get('hour', None)
minute = kwargs.get('minute', None)
day = kwargs.get('day', None)
month = kwargs.get('month', None)
year = kwargs.get('year', None)
if (year and (len(str(year)) == 2)):
year = '20{0}'... | null | null | null | Return match jobs list | pcsd | def atq **kwargs jobs = [] runas = kwargs get 'runas' None tag = kwargs get 'tag' None hour = kwargs get 'hour' None minute = kwargs get 'minute' None day = kwargs get 'day' None month = kwargs get 'month' None year = kwargs get 'year' None if year and len str year == 2 year = '20{0}' format year jobinfo = atq ['jobs']... | 12990 | def _atq(**kwargs):
jobs = []
runas = kwargs.get('runas', None)
tag = kwargs.get('tag', None)
hour = kwargs.get('hour', None)
minute = kwargs.get('minute', None)
day = kwargs.get('day', None)
month = kwargs.get('month', None)
year = kwargs.get('year', None)
if (year and (len(str(year)) == 2)):
year = '20{0}'... | Return match jobs list | return match jobs list | Question:
What does this function do?
Code:
def _atq(**kwargs):
jobs = []
runas = kwargs.get('runas', None)
tag = kwargs.get('tag', None)
hour = kwargs.get('hour', None)
minute = kwargs.get('minute', None)
day = kwargs.get('day', None)
month = kwargs.get('month', None)
year = kwargs.get('year', None)
if (ye... |
null | null | null | What does this function do? | def saveMeshes(filename, objects):
ext = os.path.splitext(filename)[1].lower()
if (ext == '.stl'):
stl.saveScene(filename, objects)
return
if (ext == '.amf'):
amf.saveScene(filename, objects)
return
print ('Error: Unknown model extension: %s' % ext)
| null | null | null | Save a list of objects into the file given by the filename. Use the filename extension to find out the file format. | pcsd | def save Meshes filename objects ext = os path splitext filename [1] lower if ext == ' stl' stl save Scene filename objects return if ext == ' amf' amf save Scene filename objects return print 'Error Unknown model extension %s' % ext | 12996 | def saveMeshes(filename, objects):
ext = os.path.splitext(filename)[1].lower()
if (ext == '.stl'):
stl.saveScene(filename, objects)
return
if (ext == '.amf'):
amf.saveScene(filename, objects)
return
print ('Error: Unknown model extension: %s' % ext)
| Save a list of objects into the file given by the filename. Use the filename extension to find out the file format. | save a list of objects into the file given by the filename . | Question:
What does this function do?
Code:
def saveMeshes(filename, objects):
ext = os.path.splitext(filename)[1].lower()
if (ext == '.stl'):
stl.saveScene(filename, objects)
return
if (ext == '.amf'):
amf.saveScene(filename, objects)
return
print ('Error: Unknown model extension: %s' % ext)
|
null | null | null | What does this function do? | @manager.command
def drop_db():
db.drop_all()
| null | null | null | Drops the database. | pcsd | @manager command def drop db db drop all | 12999 | @manager.command
def drop_db():
db.drop_all()
| Drops the database. | drops the database . | Question:
What does this function do?
Code:
@manager.command
def drop_db():
db.drop_all()
|
null | null | null | What does this function do? | @verbose
def make_dir_tree(fid, directory, start=0, indent=0, verbose=None):
FIFF_BLOCK_START = 104
FIFF_BLOCK_END = 105
FIFF_FILE_ID = 100
FIFF_BLOCK_ID = 103
FIFF_PARENT_BLOCK_ID = 110
if (directory[start].kind == FIFF_BLOCK_START):
tag = read_tag(fid, directory[start].pos)
block = tag.data
else:
block =... | null | null | null | Create the directory tree structure. | pcsd | @verbose def make dir tree fid directory start=0 indent=0 verbose=None FIFF BLOCK START = 104 FIFF BLOCK END = 105 FIFF FILE ID = 100 FIFF BLOCK ID = 103 FIFF PARENT BLOCK ID = 110 if directory[start] kind == FIFF BLOCK START tag = read tag fid directory[start] pos block = tag data else block = 0 logger debug ' ' * ind... | 13002 | @verbose
def make_dir_tree(fid, directory, start=0, indent=0, verbose=None):
FIFF_BLOCK_START = 104
FIFF_BLOCK_END = 105
FIFF_FILE_ID = 100
FIFF_BLOCK_ID = 103
FIFF_PARENT_BLOCK_ID = 110
if (directory[start].kind == FIFF_BLOCK_START):
tag = read_tag(fid, directory[start].pos)
block = tag.data
else:
block =... | Create the directory tree structure. | create the directory tree structure . | Question:
What does this function do?
Code:
@verbose
def make_dir_tree(fid, directory, start=0, indent=0, verbose=None):
FIFF_BLOCK_START = 104
FIFF_BLOCK_END = 105
FIFF_FILE_ID = 100
FIFF_BLOCK_ID = 103
FIFF_PARENT_BLOCK_ID = 110
if (directory[start].kind == FIFF_BLOCK_START):
tag = read_tag(fid, directory[... |
null | null | null | What does this function do? | def _compute_style_grad(F, G, G_style, layer):
(Fl, Gl) = (F[layer], G[layer])
c = ((Fl.shape[0] ** (-2)) * (Fl.shape[1] ** (-2)))
El = (Gl - G_style[layer])
loss = ((c / 4) * (El ** 2).sum())
grad = ((c * sgemm(1.0, El, Fl)) * (Fl > 0))
return (loss, grad)
| null | null | null | Computes style gradient and loss from activation features. | pcsd | def compute style grad F G G style layer Fl Gl = F[layer] G[layer] c = Fl shape[0] ** -2 * Fl shape[1] ** -2 El = Gl - G style[layer] loss = c / 4 * El ** 2 sum grad = c * sgemm 1 0 El Fl * Fl > 0 return loss grad | 13004 | def _compute_style_grad(F, G, G_style, layer):
(Fl, Gl) = (F[layer], G[layer])
c = ((Fl.shape[0] ** (-2)) * (Fl.shape[1] ** (-2)))
El = (Gl - G_style[layer])
loss = ((c / 4) * (El ** 2).sum())
grad = ((c * sgemm(1.0, El, Fl)) * (Fl > 0))
return (loss, grad)
| Computes style gradient and loss from activation features. | computes style gradient and loss from activation features . | Question:
What does this function do?
Code:
def _compute_style_grad(F, G, G_style, layer):
(Fl, Gl) = (F[layer], G[layer])
c = ((Fl.shape[0] ** (-2)) * (Fl.shape[1] ** (-2)))
El = (Gl - G_style[layer])
loss = ((c / 4) * (El ** 2).sum())
grad = ((c * sgemm(1.0, El, Fl)) * (Fl > 0))
return (loss, grad)
|
null | null | null | What does this function do? | def assert_alerts(ea_inst, calls):
assert (ea_inst.rules[0]['alert'][0].alert.call_count == len(calls))
for (call_num, call_args) in enumerate(ea_inst.rules[0]['alert'][0].alert.call_args_list):
assert (not any([(match['@timestamp'] not in calls[call_num]) for match in call_args[0][0]]))
assert (len(call_args[0][... | null | null | null | Takes a list of lists of timestamps. Asserts that an alert was called for each list, containing those timestamps. | pcsd | def assert alerts ea inst calls assert ea inst rules[0]['alert'][0] alert call count == len calls for call num call args in enumerate ea inst rules[0]['alert'][0] alert call args list assert not any [ match['@timestamp'] not in calls[call num] for match in call args[0][0]] assert len call args[0][0] == len calls[call n... | 13006 | def assert_alerts(ea_inst, calls):
assert (ea_inst.rules[0]['alert'][0].alert.call_count == len(calls))
for (call_num, call_args) in enumerate(ea_inst.rules[0]['alert'][0].alert.call_args_list):
assert (not any([(match['@timestamp'] not in calls[call_num]) for match in call_args[0][0]]))
assert (len(call_args[0][... | Takes a list of lists of timestamps. Asserts that an alert was called for each list, containing those timestamps. | takes a list of lists of timestamps . | Question:
What does this function do?
Code:
def assert_alerts(ea_inst, calls):
assert (ea_inst.rules[0]['alert'][0].alert.call_count == len(calls))
for (call_num, call_args) in enumerate(ea_inst.rules[0]['alert'][0].alert.call_args_list):
assert (not any([(match['@timestamp'] not in calls[call_num]) for match in... |
null | null | null | What does this function do? | def _footer_css_urls(request, package_name):
package = settings.PIPELINE_CSS.get(package_name, {})
paths = ([package['output_filename']] if (not settings.DEBUG) else package['source_filenames'])
return [_footer_static_url(request, path) for path in paths]
| null | null | null | Construct absolute URLs to CSS assets in a package. | pcsd | def footer css urls request package name package = settings PIPELINE CSS get package name {} paths = [package['output filename']] if not settings DEBUG else package['source filenames'] return [ footer static url request path for path in paths] | 13009 | def _footer_css_urls(request, package_name):
package = settings.PIPELINE_CSS.get(package_name, {})
paths = ([package['output_filename']] if (not settings.DEBUG) else package['source_filenames'])
return [_footer_static_url(request, path) for path in paths]
| Construct absolute URLs to CSS assets in a package. | construct absolute urls to css assets in a package . | Question:
What does this function do?
Code:
def _footer_css_urls(request, package_name):
package = settings.PIPELINE_CSS.get(package_name, {})
paths = ([package['output_filename']] if (not settings.DEBUG) else package['source_filenames'])
return [_footer_static_url(request, path) for path in paths]
|
null | null | null | What does this function do? | def _zpkbilinear(z, p, k, fs):
degree = _relative_degree(z, p)
fs2 = (2 * fs)
z_z = [((fs2 + z1) / (fs2 - z1)) for z1 in z]
p_z = [((fs2 + p1) / (fs2 - p1)) for p1 in p]
z_z.extend(([(-1)] * degree))
numer = _prod(((fs2 - z1) for z1 in z))
denom = _prod(((fs2 - p1) for p1 in p))
k_z = ((k * numer) / denom)
ret... | null | null | null | Bilinear transformation to convert a filter from analog to digital. | pcsd | def zpkbilinear z p k fs degree = relative degree z p fs2 = 2 * fs z z = [ fs2 + z1 / fs2 - z1 for z1 in z] p z = [ fs2 + p1 / fs2 - p1 for p1 in p] z z extend [ -1 ] * degree numer = prod fs2 - z1 for z1 in z denom = prod fs2 - p1 for p1 in p k z = k * numer / denom return z z p z k z real | 13013 | def _zpkbilinear(z, p, k, fs):
degree = _relative_degree(z, p)
fs2 = (2 * fs)
z_z = [((fs2 + z1) / (fs2 - z1)) for z1 in z]
p_z = [((fs2 + p1) / (fs2 - p1)) for p1 in p]
z_z.extend(([(-1)] * degree))
numer = _prod(((fs2 - z1) for z1 in z))
denom = _prod(((fs2 - p1) for p1 in p))
k_z = ((k * numer) / denom)
ret... | Bilinear transformation to convert a filter from analog to digital. | bilinear transformation to convert a filter from analog to digital . | Question:
What does this function do?
Code:
def _zpkbilinear(z, p, k, fs):
degree = _relative_degree(z, p)
fs2 = (2 * fs)
z_z = [((fs2 + z1) / (fs2 - z1)) for z1 in z]
p_z = [((fs2 + p1) / (fs2 - p1)) for p1 in p]
z_z.extend(([(-1)] * degree))
numer = _prod(((fs2 - z1) for z1 in z))
denom = _prod(((fs2 - p1) ... |
null | null | null | What does this function do? | @pytest.mark.skipif('not HAS_YAML')
def test_write_full():
t = T_DTYPES[('bool', 'int64', 'float64', 'str')]
lines = ['# %ECSV 0.9', '# ---', '# datatype:', '# - name: bool', '# unit: m / s', '# datatype: bool', '# description: descr_bool', '# meta: {meta bool: 1}', '# - name: int64', '# unit: m / s', '# ... | null | null | null | Write a full-featured table with common types and explicitly checkout output | pcsd | @pytest mark skipif 'not HAS YAML' def test write full t = T DTYPES[ 'bool' 'int64' 'float64' 'str' ] lines = ['# %ECSV 0 9' '# ---' '# datatype ' '# - name bool' '# unit m / s' '# datatype bool' '# description descr bool' '# meta {meta bool 1}' '# - name int64' '# unit m / s' '# datatype int64' '# description descr in... | 13017 | @pytest.mark.skipif('not HAS_YAML')
def test_write_full():
t = T_DTYPES[('bool', 'int64', 'float64', 'str')]
lines = ['# %ECSV 0.9', '# ---', '# datatype:', '# - name: bool', '# unit: m / s', '# datatype: bool', '# description: descr_bool', '# meta: {meta bool: 1}', '# - name: int64', '# unit: m / s', '# ... | Write a full-featured table with common types and explicitly checkout output | write a full - featured table with common types and explicitly checkout output | Question:
What does this function do?
Code:
@pytest.mark.skipif('not HAS_YAML')
def test_write_full():
t = T_DTYPES[('bool', 'int64', 'float64', 'str')]
lines = ['# %ECSV 0.9', '# ---', '# datatype:', '# - name: bool', '# unit: m / s', '# datatype: bool', '# description: descr_bool', '# meta: {meta bool: 1... |
null | null | null | What does this function do? | def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
instances = Table('instances', meta, autoload=True)
for index in instances.indexes:
if ([c.name for c in index.columns] == ['project_id', 'deleted']):
LOG.info(_LI('Skipped adding instances_project_id_deleted_idx because an equivalent index alrea... | null | null | null | Change instances (project_id) index to cover (project_id, deleted). | pcsd | def upgrade migrate engine meta = Meta Data bind=migrate engine instances = Table 'instances' meta autoload=True for index in instances indexes if [c name for c in index columns] == ['project id' 'deleted'] LOG info LI 'Skipped adding instances project id deleted idx because an equivalent index already exists ' break e... | 13018 | def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
instances = Table('instances', meta, autoload=True)
for index in instances.indexes:
if ([c.name for c in index.columns] == ['project_id', 'deleted']):
LOG.info(_LI('Skipped adding instances_project_id_deleted_idx because an equivalent index alrea... | Change instances (project_id) index to cover (project_id, deleted). | change instances index to cover . | Question:
What does this function do?
Code:
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
instances = Table('instances', meta, autoload=True)
for index in instances.indexes:
if ([c.name for c in index.columns] == ['project_id', 'deleted']):
LOG.info(_LI('Skipped adding instances_project_i... |
null | null | null | What does this function do? | def _getAccessibleAttribute(attributeName):
if (attributeName in globalAccessibleAttributeDictionary):
return globalAccessibleAttributeDictionary[attributeName]
return None
| null | null | null | Get the accessible attribute. | pcsd | def get Accessible Attribute attribute Name if attribute Name in global Accessible Attribute Dictionary return global Accessible Attribute Dictionary[attribute Name] return None | 13028 | def _getAccessibleAttribute(attributeName):
if (attributeName in globalAccessibleAttributeDictionary):
return globalAccessibleAttributeDictionary[attributeName]
return None
| Get the accessible attribute. | get the accessible attribute . | Question:
What does this function do?
Code:
def _getAccessibleAttribute(attributeName):
if (attributeName in globalAccessibleAttributeDictionary):
return globalAccessibleAttributeDictionary[attributeName]
return None
|
null | null | null | What does this function do? | def setup_platform(hass, config, add_devices, discovery_info=None):
netatmo = get_component('netatmo')
home = config.get(CONF_HOME)
import lnetatmo
try:
data = CameraData(netatmo.NETATMO_AUTH, home)
for camera_name in data.get_camera_names():
camera_type = data.get_camera_type(camera=camera_name, home=home)
... | null | null | null | Setup access to Netatmo cameras. | pcsd | def setup platform hass config add devices discovery info=None netatmo = get component 'netatmo' home = config get CONF HOME import lnetatmo try data = Camera Data netatmo NETATMO AUTH home for camera name in data get camera names camera type = data get camera type camera=camera name home=home if CONF CAMERAS in config... | 13029 | def setup_platform(hass, config, add_devices, discovery_info=None):
netatmo = get_component('netatmo')
home = config.get(CONF_HOME)
import lnetatmo
try:
data = CameraData(netatmo.NETATMO_AUTH, home)
for camera_name in data.get_camera_names():
camera_type = data.get_camera_type(camera=camera_name, home=home)
... | Setup access to Netatmo cameras. | setup access to netatmo cameras . | Question:
What does this function do?
Code:
def setup_platform(hass, config, add_devices, discovery_info=None):
netatmo = get_component('netatmo')
home = config.get(CONF_HOME)
import lnetatmo
try:
data = CameraData(netatmo.NETATMO_AUTH, home)
for camera_name in data.get_camera_names():
camera_type = data.... |
null | null | null | What does this function do? | def setSVGCarvingCorners(cornerMaximum, cornerMinimum, layerThickness, loopLayers):
for loopLayer in loopLayers:
for loop in loopLayer.loops:
for point in loop:
pointVector3 = Vector3(point.real, point.imag, loopLayer.z)
cornerMaximum.maximize(pointVector3)
cornerMinimum.minimize(pointVector3)
halfLa... | null | null | null | Parse SVG text and store the layers. | pcsd | def set SVG Carving Corners corner Maximum corner Minimum layer Thickness loop Layers for loop Layer in loop Layers for loop in loop Layer loops for point in loop point Vector3 = Vector3 point real point imag loop Layer z corner Maximum maximize point Vector3 corner Minimum minimize point Vector3 half Layer Thickness =... | 13036 | def setSVGCarvingCorners(cornerMaximum, cornerMinimum, layerThickness, loopLayers):
for loopLayer in loopLayers:
for loop in loopLayer.loops:
for point in loop:
pointVector3 = Vector3(point.real, point.imag, loopLayer.z)
cornerMaximum.maximize(pointVector3)
cornerMinimum.minimize(pointVector3)
halfLa... | Parse SVG text and store the layers. | parse svg text and store the layers . | Question:
What does this function do?
Code:
def setSVGCarvingCorners(cornerMaximum, cornerMinimum, layerThickness, loopLayers):
for loopLayer in loopLayers:
for loop in loopLayer.loops:
for point in loop:
pointVector3 = Vector3(point.real, point.imag, loopLayer.z)
cornerMaximum.maximize(pointVector3)
... |
null | null | null | What does this function do? | def _service_bus_error_handler(http_error):
return _general_error_handler(http_error)
| null | null | null | Simple error handler for service bus service. | pcsd | def service bus error handler http error return general error handler http error | 13044 | def _service_bus_error_handler(http_error):
return _general_error_handler(http_error)
| Simple error handler for service bus service. | simple error handler for service bus service . | Question:
What does this function do?
Code:
def _service_bus_error_handler(http_error):
return _general_error_handler(http_error)
|
null | null | null | What does this function do? | def reset_config_files():
print('*** Reset Spyder settings to defaults ***', file=STDERR)
for fname in SAVED_CONFIG_FILES:
cfg_fname = get_conf_path(fname)
if (osp.isfile(cfg_fname) or osp.islink(cfg_fname)):
os.remove(cfg_fname)
elif osp.isdir(cfg_fname):
shutil.rmtree(cfg_fname)
else:
continue
pr... | null | null | null | Remove all config files | pcsd | def reset config files print '*** Reset Spyder settings to defaults ***' file=STDERR for fname in SAVED CONFIG FILES cfg fname = get conf path fname if osp isfile cfg fname or osp islink cfg fname os remove cfg fname elif osp isdir cfg fname shutil rmtree cfg fname else continue print 'removing ' cfg fname file=STDERR | 13045 | def reset_config_files():
print('*** Reset Spyder settings to defaults ***', file=STDERR)
for fname in SAVED_CONFIG_FILES:
cfg_fname = get_conf_path(fname)
if (osp.isfile(cfg_fname) or osp.islink(cfg_fname)):
os.remove(cfg_fname)
elif osp.isdir(cfg_fname):
shutil.rmtree(cfg_fname)
else:
continue
pr... | Remove all config files | remove all config files | Question:
What does this function do?
Code:
def reset_config_files():
print('*** Reset Spyder settings to defaults ***', file=STDERR)
for fname in SAVED_CONFIG_FILES:
cfg_fname = get_conf_path(fname)
if (osp.isfile(cfg_fname) or osp.islink(cfg_fname)):
os.remove(cfg_fname)
elif osp.isdir(cfg_fname):
sh... |
null | null | null | What does this function do? | def _validate(dns_proto, dns_servers, ip_proto, ip_addrs, gateway):
errors = []
if (dns_proto == 'dhcp'):
if (dns_servers is not None):
errors.append("The dns_servers param cannot be set if unless dns_proto is set to 'static'.")
elif (not dns_servers):
errors.append('The dns_servers param is required to set s... | null | null | null | Ensure that the configuration passed is formatted correctly and contains
valid IP addresses, etc. | pcsd | def validate dns proto dns servers ip proto ip addrs gateway errors = [] if dns proto == 'dhcp' if dns servers is not None errors append "The dns servers param cannot be set if unless dns proto is set to 'static' " elif not dns servers errors append 'The dns servers param is required to set static DNS servers ' elif no... | 13046 | def _validate(dns_proto, dns_servers, ip_proto, ip_addrs, gateway):
errors = []
if (dns_proto == 'dhcp'):
if (dns_servers is not None):
errors.append("The dns_servers param cannot be set if unless dns_proto is set to 'static'.")
elif (not dns_servers):
errors.append('The dns_servers param is required to set s... | Ensure that the configuration passed is formatted correctly and contains
valid IP addresses, etc. | ensure that the configuration passed is formatted correctly and contains valid ip addresses , etc . | Question:
What does this function do?
Code:
def _validate(dns_proto, dns_servers, ip_proto, ip_addrs, gateway):
errors = []
if (dns_proto == 'dhcp'):
if (dns_servers is not None):
errors.append("The dns_servers param cannot be set if unless dns_proto is set to 'static'.")
elif (not dns_servers):
errors.app... |
null | null | null | What does this function do? | def get_text_style(text):
style = {}
style['alpha'] = text.get_alpha()
if (style['alpha'] is None):
style['alpha'] = 1
style['fontsize'] = text.get_size()
style['color'] = color_to_hex(text.get_color())
style['halign'] = text.get_horizontalalignment()
style['valign'] = text.get_verticalalignment()
style['rota... | null | null | null | Return the text style dict for a text instance | pcsd | def get text style text style = {} style['alpha'] = text get alpha if style['alpha'] is None style['alpha'] = 1 style['fontsize'] = text get size style['color'] = color to hex text get color style['halign'] = text get horizontalalignment style['valign'] = text get verticalalignment style['rotation'] = text get rotation... | 13048 | def get_text_style(text):
style = {}
style['alpha'] = text.get_alpha()
if (style['alpha'] is None):
style['alpha'] = 1
style['fontsize'] = text.get_size()
style['color'] = color_to_hex(text.get_color())
style['halign'] = text.get_horizontalalignment()
style['valign'] = text.get_verticalalignment()
style['rota... | Return the text style dict for a text instance | return the text style dict for a text instance | Question:
What does this function do?
Code:
def get_text_style(text):
style = {}
style['alpha'] = text.get_alpha()
if (style['alpha'] is None):
style['alpha'] = 1
style['fontsize'] = text.get_size()
style['color'] = color_to_hex(text.get_color())
style['halign'] = text.get_horizontalalignment()
style['valig... |
null | null | null | What does this function do? | def split(path, result=None):
if (result is None):
result = []
(head, tail) = os.path.split(path)
if (head == ''):
return ([tail] + result)
if (head == path):
return result
return split(head, ([tail] + result))
| null | null | null | Split a path into components in a platform-neutral way. | pcsd | def split path result=None if result is None result = [] head tail = os path split path if head == '' return [tail] + result if head == path return result return split head [tail] + result | 13052 | def split(path, result=None):
if (result is None):
result = []
(head, tail) = os.path.split(path)
if (head == ''):
return ([tail] + result)
if (head == path):
return result
return split(head, ([tail] + result))
| Split a path into components in a platform-neutral way. | split a path into components in a platform - neutral way . | Question:
What does this function do?
Code:
def split(path, result=None):
if (result is None):
result = []
(head, tail) = os.path.split(path)
if (head == ''):
return ([tail] + result)
if (head == path):
return result
return split(head, ([tail] + result))
|
null | null | null | What does this function do? | def wait_for(callback, value, timeout=EFSConnection.DEFAULT_WAIT_TIMEOUT_SECONDS):
wait_start = timestamp()
while True:
if (callback() != value):
if ((timeout != 0) and ((timestamp() - wait_start) > timeout)):
raise RuntimeError((('Wait timeout exceeded (' + str(timeout)) + ' sec)'))
else:
sleep(5)
... | null | null | null | Helper method to wait for desired value returned by callback method | pcsd | def wait for callback value timeout=EFS Connection DEFAULT WAIT TIMEOUT SECONDS wait start = timestamp while True if callback != value if timeout != 0 and timestamp - wait start > timeout raise Runtime Error 'Wait timeout exceeded ' + str timeout + ' sec ' else sleep 5 continue break | 13054 | def wait_for(callback, value, timeout=EFSConnection.DEFAULT_WAIT_TIMEOUT_SECONDS):
wait_start = timestamp()
while True:
if (callback() != value):
if ((timeout != 0) and ((timestamp() - wait_start) > timeout)):
raise RuntimeError((('Wait timeout exceeded (' + str(timeout)) + ' sec)'))
else:
sleep(5)
... | Helper method to wait for desired value returned by callback method | helper method to wait for desired value returned by callback method | Question:
What does this function do?
Code:
def wait_for(callback, value, timeout=EFSConnection.DEFAULT_WAIT_TIMEOUT_SECONDS):
wait_start = timestamp()
while True:
if (callback() != value):
if ((timeout != 0) and ((timestamp() - wait_start) > timeout)):
raise RuntimeError((('Wait timeout exceeded (' + str... |
null | null | null | What does this function do? | @task
@timed
def i18n_clean():
sh('git clean -fdX conf/locale')
| null | null | null | Clean the i18n directory of artifacts | pcsd | @task @timed def i18n clean sh 'git clean -fd X conf/locale' | 13061 | @task
@timed
def i18n_clean():
sh('git clean -fdX conf/locale')
| Clean the i18n directory of artifacts | clean the i18n directory of artifacts | Question:
What does this function do?
Code:
@task
@timed
def i18n_clean():
sh('git clean -fdX conf/locale')
|
null | null | null | What does this function do? | def runMultiLink():
topo = simpleMultiLinkTopo(n=2)
net = Mininet(topo=topo)
net.start()
CLI(net)
net.stop()
| null | null | null | Create and run multiple link network | pcsd | def run Multi Link topo = simple Multi Link Topo n=2 net = Mininet topo=topo net start CLI net net stop | 13100 | def runMultiLink():
topo = simpleMultiLinkTopo(n=2)
net = Mininet(topo=topo)
net.start()
CLI(net)
net.stop()
| Create and run multiple link network | create and run multiple link network | Question:
What does this function do?
Code:
def runMultiLink():
topo = simpleMultiLinkTopo(n=2)
net = Mininet(topo=topo)
net.start()
CLI(net)
net.stop()
|
null | null | null | What does this function do? | def _external_login_or_signup(request, external_id, external_domain, credentials, email, fullname, retfun=None):
try:
eamap = ExternalAuthMap.objects.get(external_id=external_id, external_domain=external_domain)
log.debug(u'Found eamap=%s', eamap)
except ExternalAuthMap.DoesNotExist:
eamap = ExternalAuthMap(ext... | null | null | null | Generic external auth login or signup | pcsd | def external login or signup request external id external domain credentials email fullname retfun=None try eamap = External Auth Map objects get external id=external id external domain=external domain log debug u'Found eamap=%s' eamap except External Auth Map Does Not Exist eamap = External Auth Map external id=extern... | 13101 | def _external_login_or_signup(request, external_id, external_domain, credentials, email, fullname, retfun=None):
try:
eamap = ExternalAuthMap.objects.get(external_id=external_id, external_domain=external_domain)
log.debug(u'Found eamap=%s', eamap)
except ExternalAuthMap.DoesNotExist:
eamap = ExternalAuthMap(ext... | Generic external auth login or signup | generic external auth login or signup | Question:
What does this function do?
Code:
def _external_login_or_signup(request, external_id, external_domain, credentials, email, fullname, retfun=None):
try:
eamap = ExternalAuthMap.objects.get(external_id=external_id, external_domain=external_domain)
log.debug(u'Found eamap=%s', eamap)
except ExternalAuth... |
null | null | null | What does this function do? | def get_entity(service):
entity = None
try:
entity = service.get()
except sdk.Error:
pass
return entity
| null | null | null | Ignore SDK Error in case of getting an entity from service. | pcsd | def get entity service entity = None try entity = service get except sdk Error pass return entity | 13112 | def get_entity(service):
entity = None
try:
entity = service.get()
except sdk.Error:
pass
return entity
| Ignore SDK Error in case of getting an entity from service. | ignore sdk error in case of getting an entity from service . | Question:
What does this function do?
Code:
def get_entity(service):
entity = None
try:
entity = service.get()
except sdk.Error:
pass
return entity
|
null | null | null | What does this function do? | def _create_gpg(user=None, gnupghome=None):
if (not gnupghome):
gnupghome = _get_user_gnupghome(user)
if GPG_1_3_1:
gpg = gnupg.GPG(homedir=gnupghome)
else:
gpg = gnupg.GPG(gnupghome=gnupghome)
return gpg
| null | null | null | Create the GPG object | pcsd | def create gpg user=None gnupghome=None if not gnupghome gnupghome = get user gnupghome user if GPG 1 3 1 gpg = gnupg GPG homedir=gnupghome else gpg = gnupg GPG gnupghome=gnupghome return gpg | 13119 | def _create_gpg(user=None, gnupghome=None):
if (not gnupghome):
gnupghome = _get_user_gnupghome(user)
if GPG_1_3_1:
gpg = gnupg.GPG(homedir=gnupghome)
else:
gpg = gnupg.GPG(gnupghome=gnupghome)
return gpg
| Create the GPG object | create the gpg object | Question:
What does this function do?
Code:
def _create_gpg(user=None, gnupghome=None):
if (not gnupghome):
gnupghome = _get_user_gnupghome(user)
if GPG_1_3_1:
gpg = gnupg.GPG(homedir=gnupghome)
else:
gpg = gnupg.GPG(gnupghome=gnupghome)
return gpg
|
null | null | null | What does this function do? | def _iter_lexerclasses():
for key in sorted(LEXERS):
(module_name, name) = LEXERS[key][:2]
if (name not in _lexer_cache):
_load_lexers(module_name)
(yield _lexer_cache[name])
for lexer in find_plugin_lexers():
(yield lexer)
| null | null | null | Return an iterator over all lexer classes. | pcsd | def iter lexerclasses for key in sorted LEXERS module name name = LEXERS[key][ 2] if name not in lexer cache load lexers module name yield lexer cache[name] for lexer in find plugin lexers yield lexer | 13123 | def _iter_lexerclasses():
for key in sorted(LEXERS):
(module_name, name) = LEXERS[key][:2]
if (name not in _lexer_cache):
_load_lexers(module_name)
(yield _lexer_cache[name])
for lexer in find_plugin_lexers():
(yield lexer)
| Return an iterator over all lexer classes. | return an iterator over all lexer classes . | Question:
What does this function do?
Code:
def _iter_lexerclasses():
for key in sorted(LEXERS):
(module_name, name) = LEXERS[key][:2]
if (name not in _lexer_cache):
_load_lexers(module_name)
(yield _lexer_cache[name])
for lexer in find_plugin_lexers():
(yield lexer)
|
null | null | null | What does this function do? | def replace_query_param(url, key, val):
(scheme, netloc, path, query, fragment) = urlparse.urlsplit(url)
query_dict = QueryDict(query).copy()
query_dict[key] = val
query = query_dict.urlencode()
return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
| null | null | null | Given a URL and a key/val pair, set or replace an item in the query
parameters of the URL, and return the new URL. | pcsd | def replace query param url key val scheme netloc path query fragment = urlparse urlsplit url query dict = Query Dict query copy query dict[key] = val query = query dict urlencode return urlparse urlunsplit scheme netloc path query fragment | 13131 | def replace_query_param(url, key, val):
(scheme, netloc, path, query, fragment) = urlparse.urlsplit(url)
query_dict = QueryDict(query).copy()
query_dict[key] = val
query = query_dict.urlencode()
return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
| Given a URL and a key/val pair, set or replace an item in the query
parameters of the URL, and return the new URL. | given a url and a key / val pair , set or replace an item in the query parameters of the url , and return the new url . | Question:
What does this function do?
Code:
def replace_query_param(url, key, val):
(scheme, netloc, path, query, fragment) = urlparse.urlsplit(url)
query_dict = QueryDict(query).copy()
query_dict[key] = val
query = query_dict.urlencode()
return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
|
null | null | null | What does this function do? | def treepositions_no_leaves(tree):
treepositions = tree.treepositions()
prefixes = set()
for pos in treepositions:
for length in range(len(pos)):
prefixes.add(pos[:length])
return [pos for pos in treepositions if (pos in prefixes)]
| null | null | null | Returns all the tree positions in the given tree which are not
leaf nodes. | pcsd | def treepositions no leaves tree treepositions = tree treepositions prefixes = set for pos in treepositions for length in range len pos prefixes add pos[ length] return [pos for pos in treepositions if pos in prefixes ] | 13137 | def treepositions_no_leaves(tree):
treepositions = tree.treepositions()
prefixes = set()
for pos in treepositions:
for length in range(len(pos)):
prefixes.add(pos[:length])
return [pos for pos in treepositions if (pos in prefixes)]
| Returns all the tree positions in the given tree which are not
leaf nodes. | returns all the tree positions in the given tree which are not leaf nodes . | Question:
What does this function do?
Code:
def treepositions_no_leaves(tree):
treepositions = tree.treepositions()
prefixes = set()
for pos in treepositions:
for length in range(len(pos)):
prefixes.add(pos[:length])
return [pos for pos in treepositions if (pos in prefixes)]
|
null | null | null | What does this function do? | def print_sentiment(filename):
credentials = GoogleCredentials.get_application_default()
service = discovery.build('language', 'v1', credentials=credentials)
with io.open(filename, 'r') as review_file:
review_file_contents = review_file.read()
service_request = service.documents().analyzeSentiment(body={'document... | null | null | null | Prints sentiment analysis on a given file contents. | pcsd | def print sentiment filename credentials = Google Credentials get application default service = discovery build 'language' 'v1' credentials=credentials with io open filename 'r' as review file review file contents = review file read service request = service documents analyze Sentiment body={'document' {'type' 'PLAIN T... | 13138 | def print_sentiment(filename):
credentials = GoogleCredentials.get_application_default()
service = discovery.build('language', 'v1', credentials=credentials)
with io.open(filename, 'r') as review_file:
review_file_contents = review_file.read()
service_request = service.documents().analyzeSentiment(body={'document... | Prints sentiment analysis on a given file contents. | prints sentiment analysis on a given file contents . | Question:
What does this function do?
Code:
def print_sentiment(filename):
credentials = GoogleCredentials.get_application_default()
service = discovery.build('language', 'v1', credentials=credentials)
with io.open(filename, 'r') as review_file:
review_file_contents = review_file.read()
service_request = servi... |
null | null | null | What does this function do? | def ismount(path):
(unc, rest) = splitunc(path)
if unc:
return (rest in ('', '/', '\\'))
p = splitdrive(path)[1]
return ((len(p) == 1) and (p[0] in '/\\'))
| null | null | null | Test whether a path is a mount point (defined as root of drive) | pcsd | def ismount path unc rest = splitunc path if unc return rest in '' '/' '\\' p = splitdrive path [1] return len p == 1 and p[0] in '/\\' | 13144 | def ismount(path):
(unc, rest) = splitunc(path)
if unc:
return (rest in ('', '/', '\\'))
p = splitdrive(path)[1]
return ((len(p) == 1) and (p[0] in '/\\'))
| Test whether a path is a mount point (defined as root of drive) | test whether a path is a mount point | Question:
What does this function do?
Code:
def ismount(path):
(unc, rest) = splitunc(path)
if unc:
return (rest in ('', '/', '\\'))
p = splitdrive(path)[1]
return ((len(p) == 1) and (p[0] in '/\\'))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.