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 _list_items(queue): with _conn() as cur: cmd = 'SELECT data FROM {0}'.format(queue) log.debug('SQL Query: {0}'.format(cmd)) cur.execute(cmd) contents = cur.fetchall() return contents
null
null
null
Private function to list contents of a queue
pcsd
def list items queue with conn as cur cmd = 'SELECT data FROM {0}' format queue log debug 'SQL Query {0}' format cmd cur execute cmd contents = cur fetchall return contents
14254
def _list_items(queue): with _conn() as cur: cmd = 'SELECT data FROM {0}'.format(queue) log.debug('SQL Query: {0}'.format(cmd)) cur.execute(cmd) contents = cur.fetchall() return contents
Private function to list contents of a queue
private function to list contents of a queue
Question: What does this function do? Code: def _list_items(queue): with _conn() as cur: cmd = 'SELECT data FROM {0}'.format(queue) log.debug('SQL Query: {0}'.format(cmd)) cur.execute(cmd) contents = cur.fetchall() return contents
null
null
null
What does this function do?
def get_static_web_help_page(): return '\n<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n<html>\n <!-- Natural Language Toolkit: Wordnet Interface: Graphical Wordnet Browser\n Copyright (C) 2001-2017 NLTK Project\n Author: Jussi Salmela <jtsalmela@...
null
null
null
Return the static web help page.
pcsd
def get static web help page return ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4 01//EN" "http //www w3 org/TR/html4/strict dtd"> <html> <!-- Natural Language Toolkit Wordnet Interface Graphical Wordnet Browser Copyright C 2001-2017 NLTK Project Author Jussi Salmela <jtsalmela@users sourceforge net> URL <http //nltk org...
14258
def get_static_web_help_page(): return '\n<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n<html>\n <!-- Natural Language Toolkit: Wordnet Interface: Graphical Wordnet Browser\n Copyright (C) 2001-2017 NLTK Project\n Author: Jussi Salmela <jtsalmela@...
Return the static web help page.
return the static web help page .
Question: What does this function do? Code: def get_static_web_help_page(): return '\n<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n<html>\n <!-- Natural Language Toolkit: Wordnet Interface: Graphical Wordnet Browser\n Copyright (C) 2001-2017 NLTK Project...
null
null
null
What does this function do?
def create_panels_join(cls, panels): panels = [a for a in panels if (a is not None)] if (len(panels) == 0): return None elif (len(panels) == 1): return panels[0] elif ((len(panels) == 2) and (panels[0] == panels[1])): return panels[0] d = dict() (minor, major, items) = (set(), set(), set()) for panel in pa...
null
null
null
given an array of panels\'s, create a single panel
pcsd
def create panels join cls panels panels = [a for a in panels if a is not None ] if len panels == 0 return None elif len panels == 1 return panels[0] elif len panels == 2 and panels[0] == panels[1] return panels[0] d = dict minor major items = set set set for panel in panels items update panel items major update panel ...
14263
def create_panels_join(cls, panels): panels = [a for a in panels if (a is not None)] if (len(panels) == 0): return None elif (len(panels) == 1): return panels[0] elif ((len(panels) == 2) and (panels[0] == panels[1])): return panels[0] d = dict() (minor, major, items) = (set(), set(), set()) for panel in pa...
given an array of panels\'s, create a single panel
given an array of panelss , create a single panel
Question: What does this function do? Code: def create_panels_join(cls, panels): panels = [a for a in panels if (a is not None)] if (len(panels) == 0): return None elif (len(panels) == 1): return panels[0] elif ((len(panels) == 2) and (panels[0] == panels[1])): return panels[0] d = dict() (minor, major, ...
null
null
null
What does this function do?
def send_notification(title, msg, gtype): if ((sabnzbd.DARWIN_VERSION > 7) and sabnzbd.cfg.ncenter_enable()): if check_classes(gtype, 'ncenter'): send_notification_center(title, msg, gtype) if (sabnzbd.WIN32 and sabnzbd.cfg.acenter_enable()): if check_classes(gtype, 'acenter'): send_windows(title, msg, gtyp...
null
null
null
Send Notification message
pcsd
def send notification title msg gtype if sabnzbd DARWIN VERSION > 7 and sabnzbd cfg ncenter enable if check classes gtype 'ncenter' send notification center title msg gtype if sabnzbd WIN32 and sabnzbd cfg acenter enable if check classes gtype 'acenter' send windows title msg gtype if sabnzbd cfg growl enable and check...
14266
def send_notification(title, msg, gtype): if ((sabnzbd.DARWIN_VERSION > 7) and sabnzbd.cfg.ncenter_enable()): if check_classes(gtype, 'ncenter'): send_notification_center(title, msg, gtype) if (sabnzbd.WIN32 and sabnzbd.cfg.acenter_enable()): if check_classes(gtype, 'acenter'): send_windows(title, msg, gtyp...
Send Notification message
send notification message
Question: What does this function do? Code: def send_notification(title, msg, gtype): if ((sabnzbd.DARWIN_VERSION > 7) and sabnzbd.cfg.ncenter_enable()): if check_classes(gtype, 'ncenter'): send_notification_center(title, msg, gtype) if (sabnzbd.WIN32 and sabnzbd.cfg.acenter_enable()): if check_classes(gtyp...
null
null
null
What does this function do?
def find_resource(manager, name_or_id): try: if (isinstance(name_or_id, int) or name_or_id.isdigit()): return manager.get(int(name_or_id)) except exceptions.NotFound: pass try: uuid.UUID(strutils.safe_decode(name_or_id)) return manager.get(name_or_id) except (ValueError, exceptions.NotFound): pass try...
null
null
null
Helper for the _find_* methods.
pcsd
def find resource manager name or id try if isinstance name or id int or name or id isdigit return manager get int name or id except exceptions Not Found pass try uuid UUID strutils safe decode name or id return manager get name or id except Value Error exceptions Not Found pass try try return manager find human id=nam...
14271
def find_resource(manager, name_or_id): try: if (isinstance(name_or_id, int) or name_or_id.isdigit()): return manager.get(int(name_or_id)) except exceptions.NotFound: pass try: uuid.UUID(strutils.safe_decode(name_or_id)) return manager.get(name_or_id) except (ValueError, exceptions.NotFound): pass try...
Helper for the _find_* methods.
helper for the _ find _ * methods .
Question: What does this function do? Code: def find_resource(manager, name_or_id): try: if (isinstance(name_or_id, int) or name_or_id.isdigit()): return manager.get(int(name_or_id)) except exceptions.NotFound: pass try: uuid.UUID(strutils.safe_decode(name_or_id)) return manager.get(name_or_id) except...
null
null
null
What does this function do?
def get_size(vm_): sizes = avail_sizes() vm_size = str(config.get_cloud_config_value('size', vm_, __opts__, search_global=False)) for size in sizes: if (vm_size.lower() == sizes[size]['slug']): return sizes[size]['slug'] raise SaltCloudNotFound("The specified size, '{0}', could not be found.".format(vm_size))
null
null
null
Return the VM\'s size. Used by create_node().
pcsd
def get size vm sizes = avail sizes vm size = str config get cloud config value 'size' vm opts search global=False for size in sizes if vm size lower == sizes[size]['slug'] return sizes[size]['slug'] raise Salt Cloud Not Found "The specified size '{0}' could not be found " format vm size
14280
def get_size(vm_): sizes = avail_sizes() vm_size = str(config.get_cloud_config_value('size', vm_, __opts__, search_global=False)) for size in sizes: if (vm_size.lower() == sizes[size]['slug']): return sizes[size]['slug'] raise SaltCloudNotFound("The specified size, '{0}', could not be found.".format(vm_size))
Return the VM\'s size. Used by create_node().
return the vms size .
Question: What does this function do? Code: def get_size(vm_): sizes = avail_sizes() vm_size = str(config.get_cloud_config_value('size', vm_, __opts__, search_global=False)) for size in sizes: if (vm_size.lower() == sizes[size]['slug']): return sizes[size]['slug'] raise SaltCloudNotFound("The specified size...
null
null
null
What does this function do?
def is_kernel_thread(proc): try: return (os.getpgid(proc.pid) == 0) except OSError: return False
null
null
null
Return True if proc is a kernel thread, False instead.
pcsd
def is kernel thread proc try return os getpgid proc pid == 0 except OS Error return False
14284
def is_kernel_thread(proc): try: return (os.getpgid(proc.pid) == 0) except OSError: return False
Return True if proc is a kernel thread, False instead.
return true if proc is a kernel thread , false instead .
Question: What does this function do? Code: def is_kernel_thread(proc): try: return (os.getpgid(proc.pid) == 0) except OSError: return False
null
null
null
What does this function do?
def is_old_code(): code_exists = exists('~/viewfinder') if (not code_exists): return False with settings(warn_only=True): is_link = run('readlink ~/viewfinder') if (is_link.return_code == 0): return False return True
null
null
null
Return True if ~/viewfinder is old-style (plain directory) or False if new style (symlink). No ~/viewfinder returns False.
pcsd
def is old code code exists = exists '~/viewfinder' if not code exists return False with settings warn only=True is link = run 'readlink ~/viewfinder' if is link return code == 0 return False return True
14285
def is_old_code(): code_exists = exists('~/viewfinder') if (not code_exists): return False with settings(warn_only=True): is_link = run('readlink ~/viewfinder') if (is_link.return_code == 0): return False return True
Return True if ~/viewfinder is old-style (plain directory) or False if new style (symlink). No ~/viewfinder returns False.
return true if ~ / viewfinder is old - style or false if new style .
Question: What does this function do? Code: def is_old_code(): code_exists = exists('~/viewfinder') if (not code_exists): return False with settings(warn_only=True): is_link = run('readlink ~/viewfinder') if (is_link.return_code == 0): return False return True
null
null
null
What does this function do?
def instance_uri(request, resource_name, **params): return strip_uri_prefix(request.route_path(('%s-record' % resource_name), **params))
null
null
null
Return the URI for the given resource.
pcsd
def instance uri request resource name **params return strip uri prefix request route path '%s-record' % resource name **params
14288
def instance_uri(request, resource_name, **params): return strip_uri_prefix(request.route_path(('%s-record' % resource_name), **params))
Return the URI for the given resource.
return the uri for the given resource .
Question: What does this function do? Code: def instance_uri(request, resource_name, **params): return strip_uri_prefix(request.route_path(('%s-record' % resource_name), **params))
null
null
null
What does this function do?
def warn_cxx(val): if ((sys.platform == 'darwin') and ('clang++' not in val)): _logger.warning('Only clang++ is supported. With g++, we end up with strange g++/OSX bugs.') return True
null
null
null
We only support clang++ as otherwise we hit strange g++/OSX bugs.
pcsd
def warn cxx val if sys platform == 'darwin' and 'clang++' not in val logger warning 'Only clang++ is supported With g++ we end up with strange g++/OSX bugs ' return True
14290
def warn_cxx(val): if ((sys.platform == 'darwin') and ('clang++' not in val)): _logger.warning('Only clang++ is supported. With g++, we end up with strange g++/OSX bugs.') return True
We only support clang++ as otherwise we hit strange g++/OSX bugs.
we only support clang + + as otherwise we hit strange g + + / osx bugs .
Question: What does this function do? Code: def warn_cxx(val): if ((sys.platform == 'darwin') and ('clang++' not in val)): _logger.warning('Only clang++ is supported. With g++, we end up with strange g++/OSX bugs.') return True
null
null
null
What does this function do?
def check_cat_sidebar(url, addon): cache.clear() for type_ in [amo.ADDON_EXTENSION, amo.ADDON_THEME, amo.ADDON_SEARCH]: addon.update(type=type_) r = Client().get(url) assert (pq(r.content)('#side-nav').attr('data-addontype') == str(type_))
null
null
null
Ensures that the sidebar shows the categories for the correct type.
pcsd
def check cat sidebar url addon cache clear for type in [amo ADDON EXTENSION amo ADDON THEME amo ADDON SEARCH] addon update type=type r = Client get url assert pq r content '#side-nav' attr 'data-addontype' == str type
14301
def check_cat_sidebar(url, addon): cache.clear() for type_ in [amo.ADDON_EXTENSION, amo.ADDON_THEME, amo.ADDON_SEARCH]: addon.update(type=type_) r = Client().get(url) assert (pq(r.content)('#side-nav').attr('data-addontype') == str(type_))
Ensures that the sidebar shows the categories for the correct type.
ensures that the sidebar shows the categories for the correct type .
Question: What does this function do? Code: def check_cat_sidebar(url, addon): cache.clear() for type_ in [amo.ADDON_EXTENSION, amo.ADDON_THEME, amo.ADDON_SEARCH]: addon.update(type=type_) r = Client().get(url) assert (pq(r.content)('#side-nav').attr('data-addontype') == str(type_))
null
null
null
What does this function do?
def show_message(title, message): script = '\n on run argv\n tell application "Alfred 2"\n activate\n set alfredPath to (path to application "Alfred 2")\n set alfredIcon to path to resource "appicon.icns" in bundle \xc2\xac\n (alfredPath as alias)\n...
null
null
null
Display a message dialog
pcsd
def show message title message script = ' on run argv tell application "Alfred 2" activate set alfred Path to path to application "Alfred 2" set alfred Icon to path to resource "appicon icns" in bundle \xc2\xac alfred Path as alias set dlg Title to item 1 of argv set dlg Message to item 2 of argv display dialog dlg Mes...
14305
def show_message(title, message): script = '\n on run argv\n tell application "Alfred 2"\n activate\n set alfredPath to (path to application "Alfred 2")\n set alfredIcon to path to resource "appicon.icns" in bundle \xc2\xac\n (alfredPath as alias)\n...
Display a message dialog
display a message dialog
Question: What does this function do? Code: def show_message(title, message): script = '\n on run argv\n tell application "Alfred 2"\n activate\n set alfredPath to (path to application "Alfred 2")\n set alfredIcon to path to resource "appicon.icns" in bundle \x...
null
null
null
What does this function do?
def get_users(): return User.find(Q('is_registered', 'eq', True))
null
null
null
Get all users who will be subscribed to the OSF General mailing list.
pcsd
def get users return User find Q 'is registered' 'eq' True
14306
def get_users(): return User.find(Q('is_registered', 'eq', True))
Get all users who will be subscribed to the OSF General mailing list.
get all users who will be subscribed to the osf general mailing list .
Question: What does this function do? Code: def get_users(): return User.find(Q('is_registered', 'eq', True))
null
null
null
What does this function do?
def _align_32(f): pos = f.tell() if ((pos % 4) != 0): f.seek(((pos + 4) - (pos % 4))) return
null
null
null
Align to the next 32-bit position in a file
pcsd
def align 32 f pos = f tell if pos % 4 != 0 f seek pos + 4 - pos % 4 return
14310
def _align_32(f): pos = f.tell() if ((pos % 4) != 0): f.seek(((pos + 4) - (pos % 4))) return
Align to the next 32-bit position in a file
align to the next 32 - bit position in a file
Question: What does this function do? Code: def _align_32(f): pos = f.tell() if ((pos % 4) != 0): f.seek(((pos + 4) - (pos % 4))) return
null
null
null
What does this function do?
def getInsetLoopsFromLoop(inset, loop, thresholdRatio=0.9): isInset = (inset > 0) insetLoops = [] isLoopWiddershins = euclidean.isWiddershins(loop) arounds = getAroundsFromLoop(loop, inset, thresholdRatio) for around in arounds: leftPoint = euclidean.getLeftPoint(around) shouldBeWithin = (isInset == isLoopWidd...
null
null
null
Get the inset loops, which might overlap.
pcsd
def get Inset Loops From Loop inset loop threshold Ratio=0 9 is Inset = inset > 0 inset Loops = [] is Loop Widdershins = euclidean is Widdershins loop arounds = get Arounds From Loop loop inset threshold Ratio for around in arounds left Point = euclidean get Left Point around should Be Within = is Inset == is Loop Widd...
14311
def getInsetLoopsFromLoop(inset, loop, thresholdRatio=0.9): isInset = (inset > 0) insetLoops = [] isLoopWiddershins = euclidean.isWiddershins(loop) arounds = getAroundsFromLoop(loop, inset, thresholdRatio) for around in arounds: leftPoint = euclidean.getLeftPoint(around) shouldBeWithin = (isInset == isLoopWidd...
Get the inset loops, which might overlap.
get the inset loops , which might overlap .
Question: What does this function do? Code: def getInsetLoopsFromLoop(inset, loop, thresholdRatio=0.9): isInset = (inset > 0) insetLoops = [] isLoopWiddershins = euclidean.isWiddershins(loop) arounds = getAroundsFromLoop(loop, inset, thresholdRatio) for around in arounds: leftPoint = euclidean.getLeftPoint(ar...
null
null
null
What does this function do?
def _combine_details(detailses): result = {} for details in detailses: gather_details(details, result) return pmap(result)
null
null
null
Take a sequence of details dictionaries and combine them into one.
pcsd
def combine details detailses result = {} for details in detailses gather details details result return pmap result
14324
def _combine_details(detailses): result = {} for details in detailses: gather_details(details, result) return pmap(result)
Take a sequence of details dictionaries and combine them into one.
take a sequence of details dictionaries and combine them into one .
Question: What does this function do? Code: def _combine_details(detailses): result = {} for details in detailses: gather_details(details, result) return pmap(result)
null
null
null
What does this function do?
def increment_lineno(node, n=1): for child in walk(node): if ('lineno' in child._attributes): child.lineno = (getattr(child, 'lineno', 0) + n) return node
null
null
null
Increment the line number of each node in the tree starting at *node* by *n*. This is useful to "move code" to a different location in a file.
pcsd
def increment lineno node n=1 for child in walk node if 'lineno' in child attributes child lineno = getattr child 'lineno' 0 + n return node
14326
def increment_lineno(node, n=1): for child in walk(node): if ('lineno' in child._attributes): child.lineno = (getattr(child, 'lineno', 0) + n) return node
Increment the line number of each node in the tree starting at *node* by *n*. This is useful to "move code" to a different location in a file.
increment the line number of each node in the tree starting at * node * by * n * .
Question: What does this function do? Code: def increment_lineno(node, n=1): for child in walk(node): if ('lineno' in child._attributes): child.lineno = (getattr(child, 'lineno', 0) + n) return node
null
null
null
What does this function do?
def clear_bad_addresses(store): bad_tx = ['a288fec5559c3f73fd3d93db8e8460562ebfe2fcf04a5114e8d0f2920a6270dc', '2a0597e665ac3d1cabeede95cedf907934db7f639e477b3c77b242140d8cf728', 'e411dbebd2f7d64dafeef9b14b5c59ec60c36779d43f850e5e347abee1e1a455'] for tx_hash in bad_tx: row = store.selectrow('\n SELECT tx_...
null
null
null
Set address=Unknown for the bogus outputs in Bitcoin 71036.
pcsd
def clear bad addresses store bad tx = ['a288fec5559c3f73fd3d93db8e8460562ebfe2fcf04a5114e8d0f2920a6270dc' '2a0597e665ac3d1cabeede95cedf907934db7f639e477b3c77b242140d8cf728' 'e411dbebd2f7d64dafeef9b14b5c59ec60c36779d43f850e5e347abee1e1a455'] for tx hash in bad tx row = store selectrow ' SELECT tx id FROM tx WHERE tx ha...
14330
def clear_bad_addresses(store): bad_tx = ['a288fec5559c3f73fd3d93db8e8460562ebfe2fcf04a5114e8d0f2920a6270dc', '2a0597e665ac3d1cabeede95cedf907934db7f639e477b3c77b242140d8cf728', 'e411dbebd2f7d64dafeef9b14b5c59ec60c36779d43f850e5e347abee1e1a455'] for tx_hash in bad_tx: row = store.selectrow('\n SELECT tx_...
Set address=Unknown for the bogus outputs in Bitcoin 71036.
set address = unknown for the bogus outputs in bitcoin 71036 .
Question: What does this function do? Code: def clear_bad_addresses(store): bad_tx = ['a288fec5559c3f73fd3d93db8e8460562ebfe2fcf04a5114e8d0f2920a6270dc', '2a0597e665ac3d1cabeede95cedf907934db7f639e477b3c77b242140d8cf728', 'e411dbebd2f7d64dafeef9b14b5c59ec60c36779d43f850e5e347abee1e1a455'] for tx_hash in bad_tx: ...
null
null
null
What does this function do?
@contextmanager def augment_usage_errors(ctx, param=None): try: (yield) except BadParameter as e: if (e.ctx is None): e.ctx = ctx if ((param is not None) and (e.param is None)): e.param = param raise except UsageError as e: if (e.ctx is None): e.ctx = ctx raise
null
null
null
Context manager that attaches extra information to exceptions that fly.
pcsd
@contextmanager def augment usage errors ctx param=None try yield except Bad Parameter as e if e ctx is None e ctx = ctx if param is not None and e param is None e param = param raise except Usage Error as e if e ctx is None e ctx = ctx raise
14332
@contextmanager def augment_usage_errors(ctx, param=None): try: (yield) except BadParameter as e: if (e.ctx is None): e.ctx = ctx if ((param is not None) and (e.param is None)): e.param = param raise except UsageError as e: if (e.ctx is None): e.ctx = ctx raise
Context manager that attaches extra information to exceptions that fly.
context manager that attaches extra information to exceptions that fly .
Question: What does this function do? Code: @contextmanager def augment_usage_errors(ctx, param=None): try: (yield) except BadParameter as e: if (e.ctx is None): e.ctx = ctx if ((param is not None) and (e.param is None)): e.param = param raise except UsageError as e: if (e.ctx is None): e.ctx =...
null
null
null
What does this function do?
def get_pasted_lines(sentinel, l_input=py3compat.input, quiet=False): if (not quiet): print ("Pasting code; enter '%s' alone on the line to stop or use Ctrl-D." % sentinel) prompt = ':' else: prompt = '' while True: try: l = l_input(prompt) if (l == sentinel): return else: (yield l) except...
null
null
null
Yield pasted lines until the user enters the given sentinel value.
pcsd
def get pasted lines sentinel l input=py3compat input quiet=False if not quiet print "Pasting code enter '%s' alone on the line to stop or use Ctrl-D " % sentinel prompt = ' ' else prompt = '' while True try l = l input prompt if l == sentinel return else yield l except EOF Error print '<EOF>' return
14338
def get_pasted_lines(sentinel, l_input=py3compat.input, quiet=False): if (not quiet): print ("Pasting code; enter '%s' alone on the line to stop or use Ctrl-D." % sentinel) prompt = ':' else: prompt = '' while True: try: l = l_input(prompt) if (l == sentinel): return else: (yield l) except...
Yield pasted lines until the user enters the given sentinel value.
yield pasted lines until the user enters the given sentinel value .
Question: What does this function do? Code: def get_pasted_lines(sentinel, l_input=py3compat.input, quiet=False): if (not quiet): print ("Pasting code; enter '%s' alone on the line to stop or use Ctrl-D." % sentinel) prompt = ':' else: prompt = '' while True: try: l = l_input(prompt) if (l == sentin...
null
null
null
What does this function do?
@task def docker_init(ctx): import platform print 'You will be asked for your sudo password to continue...' if (platform.system() == 'Darwin'): ctx.run('sudo ifconfig lo0 alias 192.168.168.167') else: print 'Your system is not recognized, you will have to setup docker manually'
null
null
null
Initial docker setup
pcsd
@task def docker init ctx import platform print 'You will be asked for your sudo password to continue ' if platform system == 'Darwin' ctx run 'sudo ifconfig lo0 alias 192 168 168 167' else print 'Your system is not recognized you will have to setup docker manually'
14340
@task def docker_init(ctx): import platform print 'You will be asked for your sudo password to continue...' if (platform.system() == 'Darwin'): ctx.run('sudo ifconfig lo0 alias 192.168.168.167') else: print 'Your system is not recognized, you will have to setup docker manually'
Initial docker setup
initial docker setup
Question: What does this function do? Code: @task def docker_init(ctx): import platform print 'You will be asked for your sudo password to continue...' if (platform.system() == 'Darwin'): ctx.run('sudo ifconfig lo0 alias 192.168.168.167') else: print 'Your system is not recognized, you will have to setup doc...
null
null
null
What does this function do?
def counter(counter=itertools.count()): return next(counter)
null
null
null
Each time we\'re called, return the next integer in the natural numbers.
pcsd
def counter counter=itertools count return next counter
14350
def counter(counter=itertools.count()): return next(counter)
Each time we\'re called, return the next integer in the natural numbers.
each time were called , return the next integer in the natural numbers .
Question: What does this function do? Code: def counter(counter=itertools.count()): return next(counter)
null
null
null
What does this function do?
@pytest.mark.skipif(u'not HAS_SCIPY') def test_units(): cosmo = core.FlatLambdaCDM(H0=70, Om0=0.27, Tcmb0=2.0) assert (cosmo.comoving_distance(1.0).unit == u.Mpc) assert (cosmo._comoving_distance_z1z2(1.0, 2.0).unit == u.Mpc) assert (cosmo.comoving_transverse_distance(1.0).unit == u.Mpc) assert (cosmo._comoving_tr...
null
null
null
Test if the right units are being returned
pcsd
@pytest mark skipif u'not HAS SCIPY' def test units cosmo = core Flat Lambda CDM H0=70 Om0=0 27 Tcmb0=2 0 assert cosmo comoving distance 1 0 unit == u Mpc assert cosmo comoving distance z1z2 1 0 2 0 unit == u Mpc assert cosmo comoving transverse distance 1 0 unit == u Mpc assert cosmo comoving transverse distance z1z2 ...
14353
@pytest.mark.skipif(u'not HAS_SCIPY') def test_units(): cosmo = core.FlatLambdaCDM(H0=70, Om0=0.27, Tcmb0=2.0) assert (cosmo.comoving_distance(1.0).unit == u.Mpc) assert (cosmo._comoving_distance_z1z2(1.0, 2.0).unit == u.Mpc) assert (cosmo.comoving_transverse_distance(1.0).unit == u.Mpc) assert (cosmo._comoving_tr...
Test if the right units are being returned
test if the right units are being returned
Question: What does this function do? Code: @pytest.mark.skipif(u'not HAS_SCIPY') def test_units(): cosmo = core.FlatLambdaCDM(H0=70, Om0=0.27, Tcmb0=2.0) assert (cosmo.comoving_distance(1.0).unit == u.Mpc) assert (cosmo._comoving_distance_z1z2(1.0, 2.0).unit == u.Mpc) assert (cosmo.comoving_transverse_distance(...
null
null
null
What does this function do?
def agent_build_get_all(context, hypervisor=None): return IMPL.agent_build_get_all(context, hypervisor)
null
null
null
Get all agent builds.
pcsd
def agent build get all context hypervisor=None return IMPL agent build get all context hypervisor
14355
def agent_build_get_all(context, hypervisor=None): return IMPL.agent_build_get_all(context, hypervisor)
Get all agent builds.
get all agent builds .
Question: What does this function do? Code: def agent_build_get_all(context, hypervisor=None): return IMPL.agent_build_get_all(context, hypervisor)
null
null
null
What does this function do?
def compile_template_str(template, renderers, default, blacklist, whitelist): fn_ = salt.utils.files.mkstemp() with salt.utils.fopen(fn_, 'wb') as ofile: ofile.write(SLS_ENCODER(template)[0]) return compile_template(fn_, renderers, default, blacklist, whitelist)
null
null
null
Take template as a string and return the high data structure derived from the template.
pcsd
def compile template str template renderers default blacklist whitelist fn = salt utils files mkstemp with salt utils fopen fn 'wb' as ofile ofile write SLS ENCODER template [0] return compile template fn renderers default blacklist whitelist
14367
def compile_template_str(template, renderers, default, blacklist, whitelist): fn_ = salt.utils.files.mkstemp() with salt.utils.fopen(fn_, 'wb') as ofile: ofile.write(SLS_ENCODER(template)[0]) return compile_template(fn_, renderers, default, blacklist, whitelist)
Take template as a string and return the high data structure derived from the template.
take template as a string and return the high data structure derived from the template .
Question: What does this function do? Code: def compile_template_str(template, renderers, default, blacklist, whitelist): fn_ = salt.utils.files.mkstemp() with salt.utils.fopen(fn_, 'wb') as ofile: ofile.write(SLS_ENCODER(template)[0]) return compile_template(fn_, renderers, default, blacklist, whitelist)
null
null
null
What does this function do?
@manager.command() @click.argument('name') @click.option('--org', 'organization', default='default', help="The organization the user belongs to (leave blank for 'default').") def test(name, organization='default'): try: org = models.Organization.get_by_slug(organization) data_source = models.DataSource.query.filte...
null
null
null
Test connection to data source by issuing a trivial query.
pcsd
@manager command @click argument 'name' @click option '--org' 'organization' default='default' help="The organization the user belongs to leave blank for 'default' " def test name organization='default' try org = models Organization get by slug organization data source = models Data Source query filter models Data Sour...
14383
@manager.command() @click.argument('name') @click.option('--org', 'organization', default='default', help="The organization the user belongs to (leave blank for 'default').") def test(name, organization='default'): try: org = models.Organization.get_by_slug(organization) data_source = models.DataSource.query.filte...
Test connection to data source by issuing a trivial query.
test connection to data source by issuing a trivial query .
Question: What does this function do? Code: @manager.command() @click.argument('name') @click.option('--org', 'organization', default='default', help="The organization the user belongs to (leave blank for 'default').") def test(name, organization='default'): try: org = models.Organization.get_by_slug(organization...
null
null
null
What does this function do?
def pathsplit(p): l = p.split('/') l = ([(i + '/') for i in l[:(-1)]] + l[(-1):]) if (l[(-1)] == ''): l.pop() return l
null
null
null
Split a path into a list of elements of the file system hierarchy.
pcsd
def pathsplit p l = p split '/' l = [ i + '/' for i in l[ -1 ]] + l[ -1 ] if l[ -1 ] == '' l pop return l
14386
def pathsplit(p): l = p.split('/') l = ([(i + '/') for i in l[:(-1)]] + l[(-1):]) if (l[(-1)] == ''): l.pop() return l
Split a path into a list of elements of the file system hierarchy.
split a path into a list of elements of the file system hierarchy .
Question: What does this function do? Code: def pathsplit(p): l = p.split('/') l = ([(i + '/') for i in l[:(-1)]] + l[(-1):]) if (l[(-1)] == ''): l.pop() return l
null
null
null
What does this function do?
def update_items(lib, query, album, move, pretend): with lib.transaction(): (items, _) = _do_query(lib, query, album) affected_albums = set() for item in items: if (not os.path.exists(syspath(item.path))): ui.print_obj(item, lib) ui.print_(ui.colorize('red', u' deleted')) if (not pretend): i...
null
null
null
For all the items matched by the query, update the library to reflect the item\'s embedded tags.
pcsd
def update items lib query album move pretend with lib transaction items = do query lib query album affected albums = set for item in items if not os path exists syspath item path ui print obj item lib ui print ui colorize 'red' u' deleted' if not pretend item remove True affected albums add item album id continue if i...
14397
def update_items(lib, query, album, move, pretend): with lib.transaction(): (items, _) = _do_query(lib, query, album) affected_albums = set() for item in items: if (not os.path.exists(syspath(item.path))): ui.print_obj(item, lib) ui.print_(ui.colorize('red', u' deleted')) if (not pretend): i...
For all the items matched by the query, update the library to reflect the item\'s embedded tags.
for all the items matched by the query , update the library to reflect the items embedded tags .
Question: What does this function do? Code: def update_items(lib, query, album, move, pretend): with lib.transaction(): (items, _) = _do_query(lib, query, album) affected_albums = set() for item in items: if (not os.path.exists(syspath(item.path))): ui.print_obj(item, lib) ui.print_(ui.colorize('re...
null
null
null
What does this function do?
def is_raising(body): for node in body: if isinstance(node, astroid.Raise): return True return False
null
null
null
return true if the given statement node raise an exception
pcsd
def is raising body for node in body if isinstance node astroid Raise return True return False
14400
def is_raising(body): for node in body: if isinstance(node, astroid.Raise): return True return False
return true if the given statement node raise an exception
return true if the given statement node raise an exception
Question: What does this function do? Code: def is_raising(body): for node in body: if isinstance(node, astroid.Raise): return True return False
null
null
null
What does this function do?
@treeio_login_required def widget_index_assigned(request, response_format='html'): context = _get_default_context(request) agent = context['agent'] if agent: tickets = Object.filter_by_request(request, Ticket.objects.filter(assigned=agent, status__hidden=False)) else: return user_denied(request, 'You are not a ...
null
null
null
Tickets assigned to current user
pcsd
@treeio login required def widget index assigned request response format='html' context = get default context request agent = context['agent'] if agent tickets = Object filter by request request Ticket objects filter assigned=agent status hidden=False else return user denied request 'You are not a Service Support Agent...
14405
@treeio_login_required def widget_index_assigned(request, response_format='html'): context = _get_default_context(request) agent = context['agent'] if agent: tickets = Object.filter_by_request(request, Ticket.objects.filter(assigned=agent, status__hidden=False)) else: return user_denied(request, 'You are not a ...
Tickets assigned to current user
tickets assigned to current user
Question: What does this function do? Code: @treeio_login_required def widget_index_assigned(request, response_format='html'): context = _get_default_context(request) agent = context['agent'] if agent: tickets = Object.filter_by_request(request, Ticket.objects.filter(assigned=agent, status__hidden=False)) else...
null
null
null
What does this function do?
def _get_info(info, name): try: idx = info[name] except: idx = info[name] = dict() return idx
null
null
null
get/create the info for this name
pcsd
def get info info name try idx = info[name] except idx = info[name] = dict return idx
14410
def _get_info(info, name): try: idx = info[name] except: idx = info[name] = dict() return idx
get/create the info for this name
get / create the info for this name
Question: What does this function do? Code: def _get_info(info, name): try: idx = info[name] except: idx = info[name] = dict() return idx
null
null
null
What does this function do?
@contextmanager def swap_stdout(): old_stdout = sys.stdout if PY3: fake_stream = StringIO() else: fake_stream = BytesIO() sys.stdout = fake_stream (yield fake_stream) sys.stdout = old_stdout
null
null
null
context manager that temporarily replaces stdout for tests that need to verify output
pcsd
@contextmanager def swap stdout old stdout = sys stdout if PY3 fake stream = String IO else fake stream = Bytes IO sys stdout = fake stream yield fake stream sys stdout = old stdout
14417
@contextmanager def swap_stdout(): old_stdout = sys.stdout if PY3: fake_stream = StringIO() else: fake_stream = BytesIO() sys.stdout = fake_stream (yield fake_stream) sys.stdout = old_stdout
context manager that temporarily replaces stdout for tests that need to verify output
context manager that temporarily replaces stdout for tests that need to verify output
Question: What does this function do? Code: @contextmanager def swap_stdout(): old_stdout = sys.stdout if PY3: fake_stream = StringIO() else: fake_stream = BytesIO() sys.stdout = fake_stream (yield fake_stream) sys.stdout = old_stdout
null
null
null
What does this function do?
def __virtual__(): if HAS_LIBS: return __virtualname__ else: return (False, 'The "{0}" module could not be loaded: "requests" is not installed.'.format(__virtualname__))
null
null
null
Only load if requests is installed
pcsd
def virtual if HAS LIBS return virtualname else return False 'The "{0}" module could not be loaded "requests" is not installed ' format virtualname
14418
def __virtual__(): if HAS_LIBS: return __virtualname__ else: return (False, 'The "{0}" module could not be loaded: "requests" is not installed.'.format(__virtualname__))
Only load if requests is installed
only load if requests is installed
Question: What does this function do? Code: def __virtual__(): if HAS_LIBS: return __virtualname__ else: return (False, 'The "{0}" module could not be loaded: "requests" is not installed.'.format(__virtualname__))
null
null
null
What does this function do?
@requires_pandas def test_to_data_frame(): (raw, events, picks) = _get_data() epochs = Epochs(raw, events, {'a': 1, 'b': 2}, tmin, tmax, picks=picks) assert_raises(ValueError, epochs.to_data_frame, index=['foo', 'bar']) assert_raises(ValueError, epochs.to_data_frame, index='qux') assert_raises(ValueError, epochs.t...
null
null
null
Test epochs Pandas exporter.
pcsd
@requires pandas def test to data frame raw events picks = get data epochs = Epochs raw events {'a' 1 'b' 2} tmin tmax picks=picks assert raises Value Error epochs to data frame index=['foo' 'bar'] assert raises Value Error epochs to data frame index='qux' assert raises Value Error epochs to data frame np arange 400 df...
14422
@requires_pandas def test_to_data_frame(): (raw, events, picks) = _get_data() epochs = Epochs(raw, events, {'a': 1, 'b': 2}, tmin, tmax, picks=picks) assert_raises(ValueError, epochs.to_data_frame, index=['foo', 'bar']) assert_raises(ValueError, epochs.to_data_frame, index='qux') assert_raises(ValueError, epochs.t...
Test epochs Pandas exporter.
test epochs pandas exporter .
Question: What does this function do? Code: @requires_pandas def test_to_data_frame(): (raw, events, picks) = _get_data() epochs = Epochs(raw, events, {'a': 1, 'b': 2}, tmin, tmax, picks=picks) assert_raises(ValueError, epochs.to_data_frame, index=['foo', 'bar']) assert_raises(ValueError, epochs.to_data_frame, i...
null
null
null
What does this function do?
def get_prop_spec(client_factory, spec_type, properties): prop_spec = client_factory.create('ns0:PropertySpec') prop_spec.type = spec_type prop_spec.pathSet = properties return prop_spec
null
null
null
Builds the Property Spec Object.
pcsd
def get prop spec client factory spec type properties prop spec = client factory create 'ns0 Property Spec' prop spec type = spec type prop spec path Set = properties return prop spec
14423
def get_prop_spec(client_factory, spec_type, properties): prop_spec = client_factory.create('ns0:PropertySpec') prop_spec.type = spec_type prop_spec.pathSet = properties return prop_spec
Builds the Property Spec Object.
builds the property spec object .
Question: What does this function do? Code: def get_prop_spec(client_factory, spec_type, properties): prop_spec = client_factory.create('ns0:PropertySpec') prop_spec.type = spec_type prop_spec.pathSet = properties return prop_spec
null
null
null
What does this function do?
def get_host_name_for_vm(session, instance): host_ref = get_host_ref_for_vm(session, instance) return session._call_method(vutil, 'get_object_property', host_ref, 'name')
null
null
null
Get the hostname of the ESXi host currently running an instance.
pcsd
def get host name for vm session instance host ref = get host ref for vm session instance return session call method vutil 'get object property' host ref 'name'
14424
def get_host_name_for_vm(session, instance): host_ref = get_host_ref_for_vm(session, instance) return session._call_method(vutil, 'get_object_property', host_ref, 'name')
Get the hostname of the ESXi host currently running an instance.
get the hostname of the esxi host currently running an instance .
Question: What does this function do? Code: def get_host_name_for_vm(session, instance): host_ref = get_host_ref_for_vm(session, instance) return session._call_method(vutil, 'get_object_property', host_ref, 'name')
null
null
null
What does this function do?
def add_caching_to_response(response, request=None, etag=None): if (not etag): if ('Cache-Control' not in response.headers): response.headers['Cache-Control'] = 'no-cache' return assert (request is not None) if (response.code not in (200, 304)): return response.headers['Etag'] = etag if ('Access-Control-A...
null
null
null
Set caching headers.
pcsd
def add caching to response response request=None etag=None if not etag if 'Cache-Control' not in response headers response headers['Cache-Control'] = 'no-cache' return assert request is not None if response code not in 200 304 return response headers['Etag'] = etag if 'Access-Control-Allow-Origin' not in response head...
14431
def add_caching_to_response(response, request=None, etag=None): if (not etag): if ('Cache-Control' not in response.headers): response.headers['Cache-Control'] = 'no-cache' return assert (request is not None) if (response.code not in (200, 304)): return response.headers['Etag'] = etag if ('Access-Control-A...
Set caching headers.
set caching headers .
Question: What does this function do? Code: def add_caching_to_response(response, request=None, etag=None): if (not etag): if ('Cache-Control' not in response.headers): response.headers['Cache-Control'] = 'no-cache' return assert (request is not None) if (response.code not in (200, 304)): return respons...
null
null
null
What does this function do?
def is_eligible_node(node): if ((node._id == POPULAR_LINKS_NODE) or (node._id == NEW_AND_NOTEWORTHY_LINKS_NODE)): return False for contrib in node.contributors: if (contrib._id in NEW_AND_NOTEWORTHY_CONTRIBUTOR_BLACKLIST): logger.info('Node {} skipped because a contributor, {}, is blacklisted.'.format(node._id...
null
null
null
Check to ensure that node is not the POPULAR or NEW_AND_NOTEWORTHY LINKS_NODE. Ensures no blacklisted contributor nodes are shown (for example, a test project created by QA)
pcsd
def is eligible node node if node id == POPULAR LINKS NODE or node id == NEW AND NOTEWORTHY LINKS NODE return False for contrib in node contributors if contrib id in NEW AND NOTEWORTHY CONTRIBUTOR BLACKLIST logger info 'Node {} skipped because a contributor {} is blacklisted ' format node id contrib id return False ret...
14437
def is_eligible_node(node): if ((node._id == POPULAR_LINKS_NODE) or (node._id == NEW_AND_NOTEWORTHY_LINKS_NODE)): return False for contrib in node.contributors: if (contrib._id in NEW_AND_NOTEWORTHY_CONTRIBUTOR_BLACKLIST): logger.info('Node {} skipped because a contributor, {}, is blacklisted.'.format(node._id...
Check to ensure that node is not the POPULAR or NEW_AND_NOTEWORTHY LINKS_NODE. Ensures no blacklisted contributor nodes are shown (for example, a test project created by QA)
check to ensure that node is not the popular or new _ and _ noteworthy links _ node .
Question: What does this function do? Code: def is_eligible_node(node): if ((node._id == POPULAR_LINKS_NODE) or (node._id == NEW_AND_NOTEWORTHY_LINKS_NODE)): return False for contrib in node.contributors: if (contrib._id in NEW_AND_NOTEWORTHY_CONTRIBUTOR_BLACKLIST): logger.info('Node {} skipped because a co...
null
null
null
What does this function do?
def _get_terminal_size_linux(): def ioctl_GWINSZ(fd): ' ioctl_GWINSZ. ' try: import fcntl import termios cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234')) return cr except: pass cr = (ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)) if ((not cr) or (cr == (0, 0))): tr...
null
null
null
Get terminal size Linux.
pcsd
def get terminal size linux def ioctl GWINSZ fd ' ioctl GWINSZ ' try import fcntl import termios cr = struct unpack 'hh' fcntl ioctl fd termios TIOCGWINSZ '1234' return cr except pass cr = ioctl GWINSZ 0 or ioctl GWINSZ 1 or ioctl GWINSZ 2 if not cr or cr == 0 0 try fd = os open os ctermid os O RDONLY cr = ioctl GWINSZ...
14439
def _get_terminal_size_linux(): def ioctl_GWINSZ(fd): ' ioctl_GWINSZ. ' try: import fcntl import termios cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234')) return cr except: pass cr = (ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)) if ((not cr) or (cr == (0, 0))): tr...
Get terminal size Linux.
get terminal size linux .
Question: What does this function do? Code: def _get_terminal_size_linux(): def ioctl_GWINSZ(fd): ' ioctl_GWINSZ. ' try: import fcntl import termios cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234')) return cr except: pass cr = (ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GW...
null
null
null
What does this function do?
def say_text(text, priority='important'): mpstate.console.writeln(text)
null
null
null
text output - default function for say()
pcsd
def say text text priority='important' mpstate console writeln text
14445
def say_text(text, priority='important'): mpstate.console.writeln(text)
text output - default function for say()
text output - default function for say ( )
Question: What does this function do? Code: def say_text(text, priority='important'): mpstate.console.writeln(text)
null
null
null
What does this function do?
def get_login_pass(body): user = None passwd = None userfields = ['log', 'login', 'wpname', 'ahd_username', 'unickname', 'nickname', 'user', 'user_name', 'alias', 'pseudo', 'email', 'username', '_username', 'userid', 'form_loginname', 'loginname', 'login_id', 'loginid', 'session_key', 'sessionkey', 'pop_login', 'uid...
null
null
null
Regex out logins and passwords from a string
pcsd
def get login pass body user = None passwd = None userfields = ['log' 'login' 'wpname' 'ahd username' 'unickname' 'nickname' 'user' 'user name' 'alias' 'pseudo' 'email' 'username' ' username' 'userid' 'form loginname' 'loginname' 'login id' 'loginid' 'session key' 'sessionkey' 'pop login' 'uid' 'id' 'user id' 'screenam...
14449
def get_login_pass(body): user = None passwd = None userfields = ['log', 'login', 'wpname', 'ahd_username', 'unickname', 'nickname', 'user', 'user_name', 'alias', 'pseudo', 'email', 'username', '_username', 'userid', 'form_loginname', 'loginname', 'login_id', 'loginid', 'session_key', 'sessionkey', 'pop_login', 'uid...
Regex out logins and passwords from a string
regex out logins and passwords from a string
Question: What does this function do? Code: def get_login_pass(body): user = None passwd = None userfields = ['log', 'login', 'wpname', 'ahd_username', 'unickname', 'nickname', 'user', 'user_name', 'alias', 'pseudo', 'email', 'username', '_username', 'userid', 'form_loginname', 'loginname', 'login_id', 'loginid',...
null
null
null
What does this function do?
def _symlink(src, dest): try: os.symlink(src, dest) except OSError: warn(('Could not create symbolic link %s. Check that your partition handles symbolic links. The file will be copied instead.' % dest)) shutil.copy(src, dest)
null
null
null
Create a symlink.
pcsd
def symlink src dest try os symlink src dest except OS Error warn 'Could not create symbolic link %s Check that your partition handles symbolic links The file will be copied instead ' % dest shutil copy src dest
14450
def _symlink(src, dest): try: os.symlink(src, dest) except OSError: warn(('Could not create symbolic link %s. Check that your partition handles symbolic links. The file will be copied instead.' % dest)) shutil.copy(src, dest)
Create a symlink.
create a symlink .
Question: What does this function do? Code: def _symlink(src, dest): try: os.symlink(src, dest) except OSError: warn(('Could not create symbolic link %s. Check that your partition handles symbolic links. The file will be copied instead.' % dest)) shutil.copy(src, dest)
null
null
null
What does this function do?
def get_diff(fs, key, val, convert=1): global stats, last_val if (key in last_val[fs]): logging.debug((((((((' get_diff for ' + fs) + '_') + key) + ': ') + str(val)) + ' last_val: ') + str(last_val[fs][key]))) else: logging.debug((((((' get_diff for ' + fs) + '_') + key) + ': ') + str(val))) if (key in last_val...
null
null
null
return difference between cur_val - last_val, update last_val
pcsd
def get diff fs key val convert=1 global stats last val if key in last val[fs] logging debug ' get diff for ' + fs + ' ' + key + ' ' + str val + ' last val ' + str last val[fs][key] else logging debug ' get diff for ' + fs + ' ' + key + ' ' + str val if key in last val[fs] stats[fs][key] = val - last val[fs][key] * flo...
14452
def get_diff(fs, key, val, convert=1): global stats, last_val if (key in last_val[fs]): logging.debug((((((((' get_diff for ' + fs) + '_') + key) + ': ') + str(val)) + ' last_val: ') + str(last_val[fs][key]))) else: logging.debug((((((' get_diff for ' + fs) + '_') + key) + ': ') + str(val))) if (key in last_val...
return difference between cur_val - last_val, update last_val
return difference between cur _ val - last _ val , update last _ val
Question: What does this function do? Code: def get_diff(fs, key, val, convert=1): global stats, last_val if (key in last_val[fs]): logging.debug((((((((' get_diff for ' + fs) + '_') + key) + ': ') + str(val)) + ' last_val: ') + str(last_val[fs][key]))) else: logging.debug((((((' get_diff for ' + fs) + '_') +...
null
null
null
What does this function do?
def get_num_con_cat(con_by_sample, cat_by_sample): num_con_cat = defaultdict(float) num_con = 0 for (sample, connects) in con_by_sample.items(): sample_categories = cat_by_sample[sample] for s_con in connects: if (s_con not in cat_by_sample.keys()): continue for (s_cat, con_cat) in zip(sample_categorie...
null
null
null
finds the number of samples connected to the same OTU split by metadata
pcsd
def get num con cat con by sample cat by sample num con cat = defaultdict float num con = 0 for sample connects in con by sample items sample categories = cat by sample[sample] for s con in connects if s con not in cat by sample keys continue for s cat con cat in zip sample categories cat by sample[s con] if s cat == c...
14454
def get_num_con_cat(con_by_sample, cat_by_sample): num_con_cat = defaultdict(float) num_con = 0 for (sample, connects) in con_by_sample.items(): sample_categories = cat_by_sample[sample] for s_con in connects: if (s_con not in cat_by_sample.keys()): continue for (s_cat, con_cat) in zip(sample_categorie...
finds the number of samples connected to the same OTU split by metadata
finds the number of samples connected to the same otu split by metadata
Question: What does this function do? Code: def get_num_con_cat(con_by_sample, cat_by_sample): num_con_cat = defaultdict(float) num_con = 0 for (sample, connects) in con_by_sample.items(): sample_categories = cat_by_sample[sample] for s_con in connects: if (s_con not in cat_by_sample.keys()): continue ...
null
null
null
What does this function do?
def create(vm_): try: if (vm_['profile'] and (config.is_profile_configured(__opts__, (__active_provider_name__ or 'openstack'), vm_['profile'], vm_=vm_) is False)): return False except AttributeError: pass deploy = config.get_cloud_config_value('deploy', vm_, __opts__) key_filename = config.get_cloud_config_...
null
null
null
Create a single VM from a data dict
pcsd
def create vm try if vm ['profile'] and config is profile configured opts active provider name or 'openstack' vm ['profile'] vm =vm is False return False except Attribute Error pass deploy = config get cloud config value 'deploy' vm opts key filename = config get cloud config value 'ssh key file' vm opts search global=...
14458
def create(vm_): try: if (vm_['profile'] and (config.is_profile_configured(__opts__, (__active_provider_name__ or 'openstack'), vm_['profile'], vm_=vm_) is False)): return False except AttributeError: pass deploy = config.get_cloud_config_value('deploy', vm_, __opts__) key_filename = config.get_cloud_config_...
Create a single VM from a data dict
create a single vm from a data dict
Question: What does this function do? Code: def create(vm_): try: if (vm_['profile'] and (config.is_profile_configured(__opts__, (__active_provider_name__ or 'openstack'), vm_['profile'], vm_=vm_) is False)): return False except AttributeError: pass deploy = config.get_cloud_config_value('deploy', vm_, __o...
null
null
null
What does this function do?
def truncate(s, maxlen=128, suffix=u'...'): if (maxlen and (len(s) >= maxlen)): return (s[:maxlen].rsplit(u' ', 1)[0] + suffix) return s
null
null
null
Truncate text to a maximum number of characters.
pcsd
def truncate s maxlen=128 suffix=u' ' if maxlen and len s >= maxlen return s[ maxlen] rsplit u' ' 1 [0] + suffix return s
14459
def truncate(s, maxlen=128, suffix=u'...'): if (maxlen and (len(s) >= maxlen)): return (s[:maxlen].rsplit(u' ', 1)[0] + suffix) return s
Truncate text to a maximum number of characters.
truncate text to a maximum number of characters .
Question: What does this function do? Code: def truncate(s, maxlen=128, suffix=u'...'): if (maxlen and (len(s) >= maxlen)): return (s[:maxlen].rsplit(u' ', 1)[0] + suffix) return s
null
null
null
What does this function do?
def login_redirect(): method = (((web.ctx.method == 'POST') and 'post') or 'get') data = web.input(_method=method) value = data.get('next') return {'REDIRECT_FIELD_NAME': 'next', 'REDIRECT_FIELD_VALUE': value, 'REDIRECT_QUERYSTRING': ((value and ('next=' + value)) or '')}
null
null
null
Load current redirect to context.
pcsd
def login redirect method = web ctx method == 'POST' and 'post' or 'get' data = web input method=method value = data get 'next' return {'REDIRECT FIELD NAME' 'next' 'REDIRECT FIELD VALUE' value 'REDIRECT QUERYSTRING' value and 'next=' + value or '' }
14465
def login_redirect(): method = (((web.ctx.method == 'POST') and 'post') or 'get') data = web.input(_method=method) value = data.get('next') return {'REDIRECT_FIELD_NAME': 'next', 'REDIRECT_FIELD_VALUE': value, 'REDIRECT_QUERYSTRING': ((value and ('next=' + value)) or '')}
Load current redirect to context.
load current redirect to context .
Question: What does this function do? Code: def login_redirect(): method = (((web.ctx.method == 'POST') and 'post') or 'get') data = web.input(_method=method) value = data.get('next') return {'REDIRECT_FIELD_NAME': 'next', 'REDIRECT_FIELD_VALUE': value, 'REDIRECT_QUERYSTRING': ((value and ('next=' + value)) or '...
null
null
null
What does this function do?
def getAllPaths(paths, xmlObject): for archivableObject in xmlObject.archivableObjects: paths += archivableObject.getPaths() return paths
null
null
null
Get all paths.
pcsd
def get All Paths paths xml Object for archivable Object in xml Object archivable Objects paths += archivable Object get Paths return paths
14470
def getAllPaths(paths, xmlObject): for archivableObject in xmlObject.archivableObjects: paths += archivableObject.getPaths() return paths
Get all paths.
get all paths .
Question: What does this function do? Code: def getAllPaths(paths, xmlObject): for archivableObject in xmlObject.archivableObjects: paths += archivableObject.getPaths() return paths
null
null
null
What does this function do?
def Value(typecode_or_type, *args, **kwds): from multiprocessing.sharedctypes import Value return Value(typecode_or_type, *args, **kwds)
null
null
null
Returns a synchronized shared object
pcsd
def Value typecode or type *args **kwds from multiprocessing sharedctypes import Value return Value typecode or type *args **kwds
14475
def Value(typecode_or_type, *args, **kwds): from multiprocessing.sharedctypes import Value return Value(typecode_or_type, *args, **kwds)
Returns a synchronized shared object
returns a synchronized shared object
Question: What does this function do? Code: def Value(typecode_or_type, *args, **kwds): from multiprocessing.sharedctypes import Value return Value(typecode_or_type, *args, **kwds)
null
null
null
What does this function do?
def rand_char(bad='', chars=allchars): return rand_base(1, bad, chars)
null
null
null
generate a random char with chars collection
pcsd
def rand char bad='' chars=allchars return rand base 1 bad chars
14488
def rand_char(bad='', chars=allchars): return rand_base(1, bad, chars)
generate a random char with chars collection
generate a random char with chars collection
Question: What does this function do? Code: def rand_char(bad='', chars=allchars): return rand_base(1, bad, chars)
null
null
null
What does this function do?
def _concatenate_coils(coils): rmags = np.concatenate([coil['rmag'] for coil in coils]) cosmags = np.concatenate([coil['cosmag'] for coil in coils]) ws = np.concatenate([coil['w'] for coil in coils]) n_int = np.array([len(coil['rmag']) for coil in coils]) if (n_int[(-1)] == 0): raise RuntimeError('not supported'...
null
null
null
Helper to concatenate MEG coil parameters.
pcsd
def concatenate coils coils rmags = np concatenate [coil['rmag'] for coil in coils] cosmags = np concatenate [coil['cosmag'] for coil in coils] ws = np concatenate [coil['w'] for coil in coils] n int = np array [len coil['rmag'] for coil in coils] if n int[ -1 ] == 0 raise Runtime Error 'not supported' bins = np repeat...
14507
def _concatenate_coils(coils): rmags = np.concatenate([coil['rmag'] for coil in coils]) cosmags = np.concatenate([coil['cosmag'] for coil in coils]) ws = np.concatenate([coil['w'] for coil in coils]) n_int = np.array([len(coil['rmag']) for coil in coils]) if (n_int[(-1)] == 0): raise RuntimeError('not supported'...
Helper to concatenate MEG coil parameters.
helper to concatenate meg coil parameters .
Question: What does this function do? Code: def _concatenate_coils(coils): rmags = np.concatenate([coil['rmag'] for coil in coils]) cosmags = np.concatenate([coil['cosmag'] for coil in coils]) ws = np.concatenate([coil['w'] for coil in coils]) n_int = np.array([len(coil['rmag']) for coil in coils]) if (n_int[(-...
null
null
null
What does this function do?
def isSidePointAdded(pixelTable, closestPath, closestPathIndex, closestPointIndex, layerInfillWidth, removedEndpointPoint, width): if ((closestPointIndex <= 0) or (closestPointIndex >= len(closestPath))): return False pointBegin = closestPath[(closestPointIndex - 1)] pointEnd = closestPath[closestPointIndex] remo...
null
null
null
Add side point along with the closest removed endpoint to the path, with minimal twisting.
pcsd
def is Side Point Added pixel Table closest Path closest Path Index closest Point Index layer Infill Width removed Endpoint Point width if closest Point Index <= 0 or closest Point Index >= len closest Path return False point Begin = closest Path[ closest Point Index - 1 ] point End = closest Path[closest Point Index] ...
14509
def isSidePointAdded(pixelTable, closestPath, closestPathIndex, closestPointIndex, layerInfillWidth, removedEndpointPoint, width): if ((closestPointIndex <= 0) or (closestPointIndex >= len(closestPath))): return False pointBegin = closestPath[(closestPointIndex - 1)] pointEnd = closestPath[closestPointIndex] remo...
Add side point along with the closest removed endpoint to the path, with minimal twisting.
add side point along with the closest removed endpoint to the path , with minimal twisting .
Question: What does this function do? Code: def isSidePointAdded(pixelTable, closestPath, closestPathIndex, closestPointIndex, layerInfillWidth, removedEndpointPoint, width): if ((closestPointIndex <= 0) or (closestPointIndex >= len(closestPath))): return False pointBegin = closestPath[(closestPointIndex - 1)] ...
null
null
null
What does this function do?
def MakeFreshResponse(): reference = json.loads(kVerifyResponseRenewedExpired) new = {'status': 0, 'receipt': reference['receipt']} new['receipt']['expires_date'] = (1000.0 * (time.time() + datetime.timedelta(days=28).total_seconds())) return json.dumps(new)
null
null
null
Returns a response for a subscription which has an expiration date in the future. Note that the metadata here may be inconsistent, since only the expiration date is changed from an old receipt template.
pcsd
def Make Fresh Response reference = json loads k Verify Response Renewed Expired new = {'status' 0 'receipt' reference['receipt']} new['receipt']['expires date'] = 1000 0 * time time + datetime timedelta days=28 total seconds return json dumps new
14511
def MakeFreshResponse(): reference = json.loads(kVerifyResponseRenewedExpired) new = {'status': 0, 'receipt': reference['receipt']} new['receipt']['expires_date'] = (1000.0 * (time.time() + datetime.timedelta(days=28).total_seconds())) return json.dumps(new)
Returns a response for a subscription which has an expiration date in the future. Note that the metadata here may be inconsistent, since only the expiration date is changed from an old receipt template.
returns a response for a subscription which has an expiration date in the future .
Question: What does this function do? Code: def MakeFreshResponse(): reference = json.loads(kVerifyResponseRenewedExpired) new = {'status': 0, 'receipt': reference['receipt']} new['receipt']['expires_date'] = (1000.0 * (time.time() + datetime.timedelta(days=28).total_seconds())) return json.dumps(new)
null
null
null
What does this function do?
def job_clear(context, data_dict): return {'success': False}
null
null
null
Clear background jobs. Only sysadmins.
pcsd
def job clear context data dict return {'success' False}
14512
def job_clear(context, data_dict): return {'success': False}
Clear background jobs. Only sysadmins.
clear background jobs .
Question: What does this function do? Code: def job_clear(context, data_dict): return {'success': False}
null
null
null
What does this function do?
@handle_response_format @treeio_login_required def equity_view(request, equity_id, response_format='html'): equity = get_object_or_404(Equity, pk=equity_id) return render_to_response('finance/equity_view', {'equity': equity}, context_instance=RequestContext(request), response_format=response_format)
null
null
null
Single transaction view page
pcsd
@handle response format @treeio login required def equity view request equity id response format='html' equity = get object or 404 Equity pk=equity id return render to response 'finance/equity view' {'equity' equity} context instance=Request Context request response format=response format
14516
@handle_response_format @treeio_login_required def equity_view(request, equity_id, response_format='html'): equity = get_object_or_404(Equity, pk=equity_id) return render_to_response('finance/equity_view', {'equity': equity}, context_instance=RequestContext(request), response_format=response_format)
Single transaction view page
single transaction view page
Question: What does this function do? Code: @handle_response_format @treeio_login_required def equity_view(request, equity_id, response_format='html'): equity = get_object_or_404(Equity, pk=equity_id) return render_to_response('finance/equity_view', {'equity': equity}, context_instance=RequestContext(request), res...
null
null
null
What does this function do?
def decorate_numtips(tree): for n in tree.postorder(include_self=True): if n.istip(): n.Score = 1 else: n.Score = len(n.tips()) return tree
null
null
null
This function maps the number of children (tips) for each node
pcsd
def decorate numtips tree for n in tree postorder include self=True if n istip n Score = 1 else n Score = len n tips return tree
14524
def decorate_numtips(tree): for n in tree.postorder(include_self=True): if n.istip(): n.Score = 1 else: n.Score = len(n.tips()) return tree
This function maps the number of children (tips) for each node
this function maps the number of children for each node
Question: What does this function do? Code: def decorate_numtips(tree): for n in tree.postorder(include_self=True): if n.istip(): n.Score = 1 else: n.Score = len(n.tips()) return tree
null
null
null
What does this function do?
@synchronized(DIR_LOCK) def get_unique_path(dirpath, n=0, create_dir=True): if (not check_mount(dirpath)): return dirpath path = dirpath if n: path = ('%s.%s' % (dirpath, n)) if (not os.path.exists(path)): if create_dir: return create_dirs(path) else: return path else: return get_unique_path(dirpat...
null
null
null
Determine a unique folder or filename
pcsd
@synchronized DIR LOCK def get unique path dirpath n=0 create dir=True if not check mount dirpath return dirpath path = dirpath if n path = '%s %s' % dirpath n if not os path exists path if create dir return create dirs path else return path else return get unique path dirpath n= n + 1 create dir=create dir
14530
@synchronized(DIR_LOCK) def get_unique_path(dirpath, n=0, create_dir=True): if (not check_mount(dirpath)): return dirpath path = dirpath if n: path = ('%s.%s' % (dirpath, n)) if (not os.path.exists(path)): if create_dir: return create_dirs(path) else: return path else: return get_unique_path(dirpat...
Determine a unique folder or filename
determine a unique folder or filename
Question: What does this function do? Code: @synchronized(DIR_LOCK) def get_unique_path(dirpath, n=0, create_dir=True): if (not check_mount(dirpath)): return dirpath path = dirpath if n: path = ('%s.%s' % (dirpath, n)) if (not os.path.exists(path)): if create_dir: return create_dirs(path) else: ret...
null
null
null
What does this function do?
def load_module_sections(trans): module_sections = {} module_sections['inputs'] = {'name': 'inputs', 'title': 'Inputs', 'modules': [{'name': 'data_input', 'title': 'Input Dataset', 'description': 'Input dataset'}, {'name': 'data_collection_input', 'title': 'Input Dataset Collection', 'description': 'Input dataset col...
null
null
null
Get abstract description of the workflow modules this Galaxy instance is configured with.
pcsd
def load module sections trans module sections = {} module sections['inputs'] = {'name' 'inputs' 'title' 'Inputs' 'modules' [{'name' 'data input' 'title' 'Input Dataset' 'description' 'Input dataset'} {'name' 'data collection input' 'title' 'Input Dataset Collection' 'description' 'Input dataset collection'}]} if trans...
14541
def load_module_sections(trans): module_sections = {} module_sections['inputs'] = {'name': 'inputs', 'title': 'Inputs', 'modules': [{'name': 'data_input', 'title': 'Input Dataset', 'description': 'Input dataset'}, {'name': 'data_collection_input', 'title': 'Input Dataset Collection', 'description': 'Input dataset col...
Get abstract description of the workflow modules this Galaxy instance is configured with.
get abstract description of the workflow modules this galaxy instance is configured with .
Question: What does this function do? Code: def load_module_sections(trans): module_sections = {} module_sections['inputs'] = {'name': 'inputs', 'title': 'Inputs', 'modules': [{'name': 'data_input', 'title': 'Input Dataset', 'description': 'Input dataset'}, {'name': 'data_collection_input', 'title': 'Input Dataset...
null
null
null
What does this function do?
def purge(): _cache.clear() _cache_repl.clear()
null
null
null
Clear the regular expression caches
pcsd
def purge cache clear cache repl clear
14545
def purge(): _cache.clear() _cache_repl.clear()
Clear the regular expression caches
clear the regular expression caches
Question: What does this function do? Code: def purge(): _cache.clear() _cache_repl.clear()
null
null
null
What does this function do?
def network_entry(is_metal, interface, bridge=None, net_type=None, net_mtu=None): if is_metal: _network = dict() else: _network = {'interface': interface} if bridge: _network['bridge'] = bridge if net_type: _network['type'] = net_type if net_mtu: _network['mtu'] = net_mtu return _network
null
null
null
Return a network entry for a container.
pcsd
def network entry is metal interface bridge=None net type=None net mtu=None if is metal network = dict else network = {'interface' interface} if bridge network['bridge'] = bridge if net type network['type'] = net type if net mtu network['mtu'] = net mtu return network
14553
def network_entry(is_metal, interface, bridge=None, net_type=None, net_mtu=None): if is_metal: _network = dict() else: _network = {'interface': interface} if bridge: _network['bridge'] = bridge if net_type: _network['type'] = net_type if net_mtu: _network['mtu'] = net_mtu return _network
Return a network entry for a container.
return a network entry for a container .
Question: What does this function do? Code: def network_entry(is_metal, interface, bridge=None, net_type=None, net_mtu=None): if is_metal: _network = dict() else: _network = {'interface': interface} if bridge: _network['bridge'] = bridge if net_type: _network['type'] = net_type if net_mtu: _network['m...
null
null
null
What does this function do?
def validate_runner_parameter_attribute_override(action_ref, param_name, attr_name, runner_param_attr_value, action_param_attr_value): param_values_are_the_same = (action_param_attr_value == runner_param_attr_value) if ((attr_name not in RUNNER_PARAM_OVERRIDABLE_ATTRS) and (not param_values_are_the_same)): raise In...
null
null
null
Validate that the provided parameter from the action schema can override the runner parameter.
pcsd
def validate runner parameter attribute override action ref param name attr name runner param attr value action param attr value param values are the same = action param attr value == runner param attr value if attr name not in RUNNER PARAM OVERRIDABLE ATTRS and not param values are the same raise Invalid Action Parame...
14555
def validate_runner_parameter_attribute_override(action_ref, param_name, attr_name, runner_param_attr_value, action_param_attr_value): param_values_are_the_same = (action_param_attr_value == runner_param_attr_value) if ((attr_name not in RUNNER_PARAM_OVERRIDABLE_ATTRS) and (not param_values_are_the_same)): raise In...
Validate that the provided parameter from the action schema can override the runner parameter.
validate that the provided parameter from the action schema can override the runner parameter .
Question: What does this function do? Code: def validate_runner_parameter_attribute_override(action_ref, param_name, attr_name, runner_param_attr_value, action_param_attr_value): param_values_are_the_same = (action_param_attr_value == runner_param_attr_value) if ((attr_name not in RUNNER_PARAM_OVERRIDABLE_ATTRS) a...
null
null
null
What does this function do?
def register_models(engine): models = (MetadefNamespace, MetadefObject, MetadefProperty, MetadefTag, MetadefResourceType, MetadefNamespaceResourceType) for model in models: model.metadata.create_all(engine)
null
null
null
Create database tables for all models with the given engine.
pcsd
def register models engine models = Metadef Namespace Metadef Object Metadef Property Metadef Tag Metadef Resource Type Metadef Namespace Resource Type for model in models model metadata create all engine
14570
def register_models(engine): models = (MetadefNamespace, MetadefObject, MetadefProperty, MetadefTag, MetadefResourceType, MetadefNamespaceResourceType) for model in models: model.metadata.create_all(engine)
Create database tables for all models with the given engine.
create database tables for all models with the given engine .
Question: What does this function do? Code: def register_models(engine): models = (MetadefNamespace, MetadefObject, MetadefProperty, MetadefTag, MetadefResourceType, MetadefNamespaceResourceType) for model in models: model.metadata.create_all(engine)
null
null
null
What does this function do?
def register(mgr): mgr.set_lang_info(lang, silvercity_lexer=XULLexer(), buf_class=XULBuffer, import_handler_class=None, cile_driver_class=XULCILEDriver, is_cpln_lang=True)
null
null
null
Register language support with the Manager.
pcsd
def register mgr mgr set lang info lang silvercity lexer=XUL Lexer buf class=XUL Buffer import handler class=None cile driver class=XULCILE Driver is cpln lang=True
14574
def register(mgr): mgr.set_lang_info(lang, silvercity_lexer=XULLexer(), buf_class=XULBuffer, import_handler_class=None, cile_driver_class=XULCILEDriver, is_cpln_lang=True)
Register language support with the Manager.
register language support with the manager .
Question: What does this function do? Code: def register(mgr): mgr.set_lang_info(lang, silvercity_lexer=XULLexer(), buf_class=XULBuffer, import_handler_class=None, cile_driver_class=XULCILEDriver, is_cpln_lang=True)
null
null
null
What does this function do?
def enable_pretty_logging(logger, level='info'): logger.setLevel(getattr(logging, level.upper())) if (not logger.handlers): color = False if (curses and sys.stderr.isatty()): try: curses.setupterm() if (curses.tigetnum('colors') > 0): color = True except: pass channel = logging.StreamHand...
null
null
null
Turns on formatted logging output as configured.
pcsd
def enable pretty logging logger level='info' logger set Level getattr logging level upper if not logger handlers color = False if curses and sys stderr isatty try curses setupterm if curses tigetnum 'colors' > 0 color = True except pass channel = logging Stream Handler channel set Formatter Log Formatter color=color l...
14575
def enable_pretty_logging(logger, level='info'): logger.setLevel(getattr(logging, level.upper())) if (not logger.handlers): color = False if (curses and sys.stderr.isatty()): try: curses.setupterm() if (curses.tigetnum('colors') > 0): color = True except: pass channel = logging.StreamHand...
Turns on formatted logging output as configured.
turns on formatted logging output as configured .
Question: What does this function do? Code: def enable_pretty_logging(logger, level='info'): logger.setLevel(getattr(logging, level.upper())) if (not logger.handlers): color = False if (curses and sys.stderr.isatty()): try: curses.setupterm() if (curses.tigetnum('colors') > 0): color = True ...
null
null
null
What does this function do?
def auth_decorator(check_auth): def decorator(method): def decorated(self, *args, **kwargs): check_auth(self) return method(self, *args, **kwargs) decorated.__name__ = method.__name__ decorated.__doc__ = method.__doc__ return decorated decorator.__name__ = check_auth.__name__ decorator.__doc__ = check_...
null
null
null
Make an authentication decorator I heard you like decorators, so I put a decorator in your decorator, so you can decorate while you decorate.
pcsd
def auth decorator check auth def decorator method def decorated self *args **kwargs check auth self return method self *args **kwargs decorated name = method name decorated doc = method doc return decorated decorator name = check auth name decorator doc = check auth doc return decorator
14577
def auth_decorator(check_auth): def decorator(method): def decorated(self, *args, **kwargs): check_auth(self) return method(self, *args, **kwargs) decorated.__name__ = method.__name__ decorated.__doc__ = method.__doc__ return decorated decorator.__name__ = check_auth.__name__ decorator.__doc__ = check_...
Make an authentication decorator I heard you like decorators, so I put a decorator in your decorator, so you can decorate while you decorate.
make an authentication decorator
Question: What does this function do? Code: def auth_decorator(check_auth): def decorator(method): def decorated(self, *args, **kwargs): check_auth(self) return method(self, *args, **kwargs) decorated.__name__ = method.__name__ decorated.__doc__ = method.__doc__ return decorated decorator.__name__ = ...
null
null
null
What does this function do?
def _unmount(path, idempotent=False): try: run_process(['umount', '-l', path.path]) except CalledProcessError as e: if (idempotent and (e.returncode in (1, 32))): pass else: raise UnmountError(blockdevice=path.path, source_message=e.output)
null
null
null
Unmount the path (directory or device path).
pcsd
def unmount path idempotent=False try run process ['umount' '-l' path path] except Called Process Error as e if idempotent and e returncode in 1 32 pass else raise Unmount Error blockdevice=path path source message=e output
14605
def _unmount(path, idempotent=False): try: run_process(['umount', '-l', path.path]) except CalledProcessError as e: if (idempotent and (e.returncode in (1, 32))): pass else: raise UnmountError(blockdevice=path.path, source_message=e.output)
Unmount the path (directory or device path).
unmount the path .
Question: What does this function do? Code: def _unmount(path, idempotent=False): try: run_process(['umount', '-l', path.path]) except CalledProcessError as e: if (idempotent and (e.returncode in (1, 32))): pass else: raise UnmountError(blockdevice=path.path, source_message=e.output)
null
null
null
What does this function do?
def write_error_summary(error): fullpath = request.environ.get('FULLPATH', request.path) uid = (c.user._id if c.user_is_loggedin else '-') g.log.error('E: %s U: %s FP: %s', error, uid, fullpath)
null
null
null
Log a single-line summary of the error for easy log grepping.
pcsd
def write error summary error fullpath = request environ get 'FULLPATH' request path uid = c user id if c user is loggedin else '-' g log error 'E %s U %s FP %s' error uid fullpath
14609
def write_error_summary(error): fullpath = request.environ.get('FULLPATH', request.path) uid = (c.user._id if c.user_is_loggedin else '-') g.log.error('E: %s U: %s FP: %s', error, uid, fullpath)
Log a single-line summary of the error for easy log grepping.
log a single - line summary of the error for easy log grepping .
Question: What does this function do? Code: def write_error_summary(error): fullpath = request.environ.get('FULLPATH', request.path) uid = (c.user._id if c.user_is_loggedin else '-') g.log.error('E: %s U: %s FP: %s', error, uid, fullpath)
null
null
null
What does this function do?
@register.inclusion_tag(u'generic/includes/comments.html', takes_context=True) def comments_for(context, obj): form_class = import_dotted_path(settings.COMMENT_FORM_CLASS) form = form_class(context[u'request'], obj) context_form = context.get(u'posted_comment_form', form) context.update({u'posted_comment_form': (co...
null
null
null
Provides a generic context variable name for the object that comments are being rendered for.
pcsd
@register inclusion tag u'generic/includes/comments html' takes context=True def comments for context obj form class = import dotted path settings COMMENT FORM CLASS form = form class context[u'request'] obj context form = context get u'posted comment form' form context update {u'posted comment form' context form if co...
14611
@register.inclusion_tag(u'generic/includes/comments.html', takes_context=True) def comments_for(context, obj): form_class = import_dotted_path(settings.COMMENT_FORM_CLASS) form = form_class(context[u'request'], obj) context_form = context.get(u'posted_comment_form', form) context.update({u'posted_comment_form': (co...
Provides a generic context variable name for the object that comments are being rendered for.
provides a generic context variable name for the object that comments are being rendered for .
Question: What does this function do? Code: @register.inclusion_tag(u'generic/includes/comments.html', takes_context=True) def comments_for(context, obj): form_class = import_dotted_path(settings.COMMENT_FORM_CLASS) form = form_class(context[u'request'], obj) context_form = context.get(u'posted_comment_form', for...
null
null
null
What does this function do?
def x509_verify(cacert, cert, binary=False): ca = x509_parse_cert(cacert) crt = x509_parse_cert(cert, binary) return crt.verify(ca.get_pubkey())
null
null
null
Validate the certificate\'s authenticity using a certification authority
pcsd
def x509 verify cacert cert binary=False ca = x509 parse cert cacert crt = x509 parse cert cert binary return crt verify ca get pubkey
14612
def x509_verify(cacert, cert, binary=False): ca = x509_parse_cert(cacert) crt = x509_parse_cert(cert, binary) return crt.verify(ca.get_pubkey())
Validate the certificate\'s authenticity using a certification authority
validate the certificates authenticity using a certification authority
Question: What does this function do? Code: def x509_verify(cacert, cert, binary=False): ca = x509_parse_cert(cacert) crt = x509_parse_cert(cert, binary) return crt.verify(ca.get_pubkey())
null
null
null
What does this function do?
def update(context, values, session): name = values['name'] metadef_utils.drop_protected_attrs(models.MetadefResourceType, values) db_rec = get(context, name, session) db_rec.update(values.copy()) db_rec.save(session=session) return db_rec.to_dict()
null
null
null
Update a resource type, raise if not found
pcsd
def update context values session name = values['name'] metadef utils drop protected attrs models Metadef Resource Type values db rec = get context name session db rec update values copy db rec save session=session return db rec to dict
14618
def update(context, values, session): name = values['name'] metadef_utils.drop_protected_attrs(models.MetadefResourceType, values) db_rec = get(context, name, session) db_rec.update(values.copy()) db_rec.save(session=session) return db_rec.to_dict()
Update a resource type, raise if not found
update a resource type , raise if not found
Question: What does this function do? Code: def update(context, values, session): name = values['name'] metadef_utils.drop_protected_attrs(models.MetadefResourceType, values) db_rec = get(context, name, session) db_rec.update(values.copy()) db_rec.save(session=session) return db_rec.to_dict()
null
null
null
What does this function do?
def fetch(bank, key, cachedir): key_file = os.path.join(cachedir, os.path.normpath(bank), '{0}.p'.format(key)) if (not os.path.isfile(key_file)): log.debug('Cache file "%s" does not exist', key_file) return None try: with salt.utils.fopen(key_file, 'rb') as fh_: return __context__['serial'].load(fh_) excep...
null
null
null
Fetch information from a file.
pcsd
def fetch bank key cachedir key file = os path join cachedir os path normpath bank '{0} p' format key if not os path isfile key file log debug 'Cache file "%s" does not exist' key file return None try with salt utils fopen key file 'rb' as fh return context ['serial'] load fh except IO Error as exc raise Salt Cache Err...
14624
def fetch(bank, key, cachedir): key_file = os.path.join(cachedir, os.path.normpath(bank), '{0}.p'.format(key)) if (not os.path.isfile(key_file)): log.debug('Cache file "%s" does not exist', key_file) return None try: with salt.utils.fopen(key_file, 'rb') as fh_: return __context__['serial'].load(fh_) excep...
Fetch information from a file.
fetch information from a file .
Question: What does this function do? Code: def fetch(bank, key, cachedir): key_file = os.path.join(cachedir, os.path.normpath(bank), '{0}.p'.format(key)) if (not os.path.isfile(key_file)): log.debug('Cache file "%s" does not exist', key_file) return None try: with salt.utils.fopen(key_file, 'rb') as fh_: ...
null
null
null
What does this function do?
def port_standard(standard_annotations, sel, sample, extractors): new_annotations = [] for annotation in standard_annotations: if (not annotation.get('tagid')): continue element = find_element(annotation, sel) if (element is None): continue selector = find_generalized_css_selector(element, sel) if (no...
null
null
null
Add accept selectors for existing annotations.
pcsd
def port standard standard annotations sel sample extractors new annotations = [] for annotation in standard annotations if not annotation get 'tagid' continue element = find element annotation sel if element is None continue selector = find generalized css selector element sel if not selector continue annotation['acce...
14629
def port_standard(standard_annotations, sel, sample, extractors): new_annotations = [] for annotation in standard_annotations: if (not annotation.get('tagid')): continue element = find_element(annotation, sel) if (element is None): continue selector = find_generalized_css_selector(element, sel) if (no...
Add accept selectors for existing annotations.
add accept selectors for existing annotations .
Question: What does this function do? Code: def port_standard(standard_annotations, sel, sample, extractors): new_annotations = [] for annotation in standard_annotations: if (not annotation.get('tagid')): continue element = find_element(annotation, sel) if (element is None): continue selector = find_...
null
null
null
What does this function do?
def cut_levels(nodes, from_level, to_level, extra_inactive, extra_active): final = [] removed = [] selected = None for node in nodes: if (not hasattr(node, 'level')): remove(node, removed) continue if (node.level == from_level): final.append(node) node.parent = None if ((not node.ancestor) and (no...
null
null
null
cutting nodes away from menus
pcsd
def cut levels nodes from level to level extra inactive extra active final = [] removed = [] selected = None for node in nodes if not hasattr node 'level' remove node removed continue if node level == from level final append node node parent = None if not node ancestor and not node selected and not node descendant cut ...
14632
def cut_levels(nodes, from_level, to_level, extra_inactive, extra_active): final = [] removed = [] selected = None for node in nodes: if (not hasattr(node, 'level')): remove(node, removed) continue if (node.level == from_level): final.append(node) node.parent = None if ((not node.ancestor) and (no...
cutting nodes away from menus
cutting nodes away from menus
Question: What does this function do? Code: def cut_levels(nodes, from_level, to_level, extra_inactive, extra_active): final = [] removed = [] selected = None for node in nodes: if (not hasattr(node, 'level')): remove(node, removed) continue if (node.level == from_level): final.append(node) node....
null
null
null
What does this function do?
def version(): return _PIP_VERSION
null
null
null
Returns a string specifying the bundled version of pip.
pcsd
def version return PIP VERSION
14638
def version(): return _PIP_VERSION
Returns a string specifying the bundled version of pip.
returns a string specifying the bundled version of pip .
Question: What does this function do? Code: def version(): return _PIP_VERSION
null
null
null
What does this function do?
def getTranslatedComplexPath(path, translateComplex): translatedComplexPath = [] for point in path: translatedComplexPath.append((point + translateComplex)) return translatedComplexPath
null
null
null
Get the translated complex path.
pcsd
def get Translated Complex Path path translate Complex translated Complex Path = [] for point in path translated Complex Path append point + translate Complex return translated Complex Path
14648
def getTranslatedComplexPath(path, translateComplex): translatedComplexPath = [] for point in path: translatedComplexPath.append((point + translateComplex)) return translatedComplexPath
Get the translated complex path.
get the translated complex path .
Question: What does this function do? Code: def getTranslatedComplexPath(path, translateComplex): translatedComplexPath = [] for point in path: translatedComplexPath.append((point + translateComplex)) return translatedComplexPath
null
null
null
What does this function do?
def setCacheCapacity(capacity=DEFAULT_CACHE_CAPACITY): enableCache() _entityCache.setCapacity(capacity)
null
null
null
Set the capacity of the entity cache.
pcsd
def set Cache Capacity capacity=DEFAULT CACHE CAPACITY enable Cache entity Cache set Capacity capacity
14653
def setCacheCapacity(capacity=DEFAULT_CACHE_CAPACITY): enableCache() _entityCache.setCapacity(capacity)
Set the capacity of the entity cache.
set the capacity of the entity cache .
Question: What does this function do? Code: def setCacheCapacity(capacity=DEFAULT_CACHE_CAPACITY): enableCache() _entityCache.setCapacity(capacity)
null
null
null
What does this function do?
def upgrade(migrate_engine): if (migrate_engine.name != 'mysql'): if (not utils.index_exists(migrate_engine, SYS_META_TABLE_NAME, INDEX_NAME)): utils.add_index(migrate_engine, SYS_META_TABLE_NAME, INDEX_NAME, INDEX_COLUMNS)
null
null
null
Add instance_system_metadata indexes missing on PostgreSQL and other DB.
pcsd
def upgrade migrate engine if migrate engine name != 'mysql' if not utils index exists migrate engine SYS META TABLE NAME INDEX NAME utils add index migrate engine SYS META TABLE NAME INDEX NAME INDEX COLUMNS
14654
def upgrade(migrate_engine): if (migrate_engine.name != 'mysql'): if (not utils.index_exists(migrate_engine, SYS_META_TABLE_NAME, INDEX_NAME)): utils.add_index(migrate_engine, SYS_META_TABLE_NAME, INDEX_NAME, INDEX_COLUMNS)
Add instance_system_metadata indexes missing on PostgreSQL and other DB.
add instance _ system _ metadata indexes missing on postgresql and other db .
Question: What does this function do? Code: def upgrade(migrate_engine): if (migrate_engine.name != 'mysql'): if (not utils.index_exists(migrate_engine, SYS_META_TABLE_NAME, INDEX_NAME)): utils.add_index(migrate_engine, SYS_META_TABLE_NAME, INDEX_NAME, INDEX_COLUMNS)
null
null
null
What does this function do?
def parse_grid_id_args(grid, grid_url): if (grid is not None): id_from_grid = grid.id else: id_from_grid = None args = [id_from_grid, grid_url] arg_names = ('grid', 'grid_url') supplied_arg_names = [arg_name for (arg_name, arg) in zip(arg_names, args) if (arg is not None)] if (not supplied_arg_names): raise...
null
null
null
Return the grid_id from the non-None input argument. Raise an error if more than one argument was supplied.
pcsd
def parse grid id args grid grid url if grid is not None id from grid = grid id else id from grid = None args = [id from grid grid url] arg names = 'grid' 'grid url' supplied arg names = [arg name for arg name arg in zip arg names args if arg is not None ] if not supplied arg names raise exceptions Input Error "One of ...
14655
def parse_grid_id_args(grid, grid_url): if (grid is not None): id_from_grid = grid.id else: id_from_grid = None args = [id_from_grid, grid_url] arg_names = ('grid', 'grid_url') supplied_arg_names = [arg_name for (arg_name, arg) in zip(arg_names, args) if (arg is not None)] if (not supplied_arg_names): raise...
Return the grid_id from the non-None input argument. Raise an error if more than one argument was supplied.
return the grid _ id from the non - none input argument .
Question: What does this function do? Code: def parse_grid_id_args(grid, grid_url): if (grid is not None): id_from_grid = grid.id else: id_from_grid = None args = [id_from_grid, grid_url] arg_names = ('grid', 'grid_url') supplied_arg_names = [arg_name for (arg_name, arg) in zip(arg_names, args) if (arg is n...
null
null
null
What does this function do?
def main_loop(): while True: syslog.syslog(syslog.LOG_WARNING, 'In main') time.sleep(5)
null
null
null
A loop that never exits.
pcsd
def main loop while True syslog syslog syslog LOG WARNING 'In main' time sleep 5
14656
def main_loop(): while True: syslog.syslog(syslog.LOG_WARNING, 'In main') time.sleep(5)
A loop that never exits.
a loop that never exits .
Question: What does this function do? Code: def main_loop(): while True: syslog.syslog(syslog.LOG_WARNING, 'In main') time.sleep(5)
null
null
null
What does this function do?
def make_channel(host, port): (credentials, _) = google.auth.default(scopes=[SPEECH_SCOPE]) http_request = google.auth.transport.requests.Request() target = '{}:{}'.format(host, port) return google.auth.transport.grpc.secure_authorized_channel(credentials, http_request, target)
null
null
null
Creates a secure channel with auth credentials from the environment.
pcsd
def make channel host port credentials = google auth default scopes=[SPEECH SCOPE] http request = google auth transport requests Request target = '{} {}' format host port return google auth transport grpc secure authorized channel credentials http request target
14660
def make_channel(host, port): (credentials, _) = google.auth.default(scopes=[SPEECH_SCOPE]) http_request = google.auth.transport.requests.Request() target = '{}:{}'.format(host, port) return google.auth.transport.grpc.secure_authorized_channel(credentials, http_request, target)
Creates a secure channel with auth credentials from the environment.
creates a secure channel with auth credentials from the environment .
Question: What does this function do? Code: def make_channel(host, port): (credentials, _) = google.auth.default(scopes=[SPEECH_SCOPE]) http_request = google.auth.transport.requests.Request() target = '{}:{}'.format(host, port) return google.auth.transport.grpc.secure_authorized_channel(credentials, http_request...
null
null
null
What does this function do?
def EC2Token_filter_factory(global_conf, **local_conf): conf = global_conf.copy() conf.update(local_conf) def filter(app): return EC2Token(app, conf) return filter
null
null
null
Factory method for paste.deploy.
pcsd
def EC2Token filter factory global conf **local conf conf = global conf copy conf update local conf def filter app return EC2Token app conf return filter
14668
def EC2Token_filter_factory(global_conf, **local_conf): conf = global_conf.copy() conf.update(local_conf) def filter(app): return EC2Token(app, conf) return filter
Factory method for paste.deploy.
factory method for paste . deploy .
Question: What does this function do? Code: def EC2Token_filter_factory(global_conf, **local_conf): conf = global_conf.copy() conf.update(local_conf) def filter(app): return EC2Token(app, conf) return filter
null
null
null
What does this function do?
def addMenuEntitiesToMenu(menu, menuEntities): for menuEntity in menuEntities: menuEntity.addToMenu(menu)
null
null
null
Add the menu entities to the menu.
pcsd
def add Menu Entities To Menu menu menu Entities for menu Entity in menu Entities menu Entity add To Menu menu
14670
def addMenuEntitiesToMenu(menu, menuEntities): for menuEntity in menuEntities: menuEntity.addToMenu(menu)
Add the menu entities to the menu.
add the menu entities to the menu .
Question: What does this function do? Code: def addMenuEntitiesToMenu(menu, menuEntities): for menuEntity in menuEntities: menuEntity.addToMenu(menu)
null
null
null
What does this function do?
def ext_pillar(minion_id, pillar, bucket, key=None, keyid=None, verify_ssl=True, location=None, multiple_env=False, environment='base', prefix='', service_url=None, kms_keyid=None, s3_cache_expire=30, s3_sync_on_update=True, path_style=False, https_enable=True): s3_creds = S3Credentials(key, keyid, bucket, service_url...
null
null
null
Execute a command and read the output as YAML
pcsd
def ext pillar minion id pillar bucket key=None keyid=None verify ssl=True location=None multiple env=False environment='base' prefix='' service url=None kms keyid=None s3 cache expire=30 s3 sync on update=True path style=False https enable=True s3 creds = S3Credentials key keyid bucket service url verify ssl kms keyid...
14671
def ext_pillar(minion_id, pillar, bucket, key=None, keyid=None, verify_ssl=True, location=None, multiple_env=False, environment='base', prefix='', service_url=None, kms_keyid=None, s3_cache_expire=30, s3_sync_on_update=True, path_style=False, https_enable=True): s3_creds = S3Credentials(key, keyid, bucket, service_url...
Execute a command and read the output as YAML
execute a command and read the output as yaml
Question: What does this function do? Code: def ext_pillar(minion_id, pillar, bucket, key=None, keyid=None, verify_ssl=True, location=None, multiple_env=False, environment='base', prefix='', service_url=None, kms_keyid=None, s3_cache_expire=30, s3_sync_on_update=True, path_style=False, https_enable=True): s3_creds ...
null
null
null
What does this function do?
def get_dir_time_suffix(): dirfmt = '%4d-%02d-%02d_%02d%02d%02d' now = time.localtime()[0:6] dirname = (dirfmt % now) return dirname
null
null
null
Returns the name of a folder with the \'now\' time as suffix
pcsd
def get dir time suffix dirfmt = '%4d-%02d-%02d %02d%02d%02d' now = time localtime [0 6] dirname = dirfmt % now return dirname
14673
def get_dir_time_suffix(): dirfmt = '%4d-%02d-%02d_%02d%02d%02d' now = time.localtime()[0:6] dirname = (dirfmt % now) return dirname
Returns the name of a folder with the \'now\' time as suffix
returns the name of a folder with the now time as suffix
Question: What does this function do? Code: def get_dir_time_suffix(): dirfmt = '%4d-%02d-%02d_%02d%02d%02d' now = time.localtime()[0:6] dirname = (dirfmt % now) return dirname
null
null
null
What does this function do?
def setNonBlocking(fd): flags = fcntl.fcntl(fd, fcntl.F_GETFL) flags = (flags | os.O_NONBLOCK) fcntl.fcntl(fd, fcntl.F_SETFL, flags)
null
null
null
Make a file descriptor non-blocking.
pcsd
def set Non Blocking fd flags = fcntl fcntl fd fcntl F GETFL flags = flags | os O NONBLOCK fcntl fcntl fd fcntl F SETFL flags
14686
def setNonBlocking(fd): flags = fcntl.fcntl(fd, fcntl.F_GETFL) flags = (flags | os.O_NONBLOCK) fcntl.fcntl(fd, fcntl.F_SETFL, flags)
Make a file descriptor non-blocking.
make a file descriptor non - blocking .
Question: What does this function do? Code: def setNonBlocking(fd): flags = fcntl.fcntl(fd, fcntl.F_GETFL) flags = (flags | os.O_NONBLOCK) fcntl.fcntl(fd, fcntl.F_SETFL, flags)
null
null
null
What does this function do?
def getNearestPointOnSegment(segmentBegin, segmentEnd, point): segmentDifference = (segmentEnd - segmentBegin) if (abs(segmentDifference) <= 0.0): return segmentBegin pointMinusSegmentBegin = (point - segmentBegin) beginPlaneDot = getDotProduct(pointMinusSegmentBegin, segmentDifference) differencePlaneDot = getD...
null
null
null
Get the nearest point on the segment.
pcsd
def get Nearest Point On Segment segment Begin segment End point segment Difference = segment End - segment Begin if abs segment Difference <= 0 0 return segment Begin point Minus Segment Begin = point - segment Begin begin Plane Dot = get Dot Product point Minus Segment Begin segment Difference difference Plane Dot = ...
14688
def getNearestPointOnSegment(segmentBegin, segmentEnd, point): segmentDifference = (segmentEnd - segmentBegin) if (abs(segmentDifference) <= 0.0): return segmentBegin pointMinusSegmentBegin = (point - segmentBegin) beginPlaneDot = getDotProduct(pointMinusSegmentBegin, segmentDifference) differencePlaneDot = getD...
Get the nearest point on the segment.
get the nearest point on the segment .
Question: What does this function do? Code: def getNearestPointOnSegment(segmentBegin, segmentEnd, point): segmentDifference = (segmentEnd - segmentBegin) if (abs(segmentDifference) <= 0.0): return segmentBegin pointMinusSegmentBegin = (point - segmentBegin) beginPlaneDot = getDotProduct(pointMinusSegmentBegin...
null
null
null
What does this function do?
def index(): module_name = T('Synchronization') response.title = module_name return dict(module_name=module_name)
null
null
null
Module\'s Home Page
pcsd
def index module name = T 'Synchronization' response title = module name return dict module name=module name
14702
def index(): module_name = T('Synchronization') response.title = module_name return dict(module_name=module_name)
Module\'s Home Page
modules home page
Question: What does this function do? Code: def index(): module_name = T('Synchronization') response.title = module_name return dict(module_name=module_name)
null
null
null
What does this function do?
@utils.arg('backup', metavar='<backup>', help='ID of the backup.') @utils.service_type('monitor') def do_backup_show(cs, args): backup = _find_backup(cs, args.backup) info = dict() info.update(backup._info) if ('links' in info): info.pop('links') utils.print_dict(info)
null
null
null
Show details about a backup.
pcsd
@utils arg 'backup' metavar='<backup>' help='ID of the backup ' @utils service type 'monitor' def do backup show cs args backup = find backup cs args backup info = dict info update backup info if 'links' in info info pop 'links' utils print dict info
14706
@utils.arg('backup', metavar='<backup>', help='ID of the backup.') @utils.service_type('monitor') def do_backup_show(cs, args): backup = _find_backup(cs, args.backup) info = dict() info.update(backup._info) if ('links' in info): info.pop('links') utils.print_dict(info)
Show details about a backup.
show details about a backup .
Question: What does this function do? Code: @utils.arg('backup', metavar='<backup>', help='ID of the backup.') @utils.service_type('monitor') def do_backup_show(cs, args): backup = _find_backup(cs, args.backup) info = dict() info.update(backup._info) if ('links' in info): info.pop('links') utils.print_dict(in...
null
null
null
What does this function do?
def cue_split(albumpath): count = 0 cue_count = 0 cue_dirs = [] for (root, dirs, files) in os.walk(albumpath): for _file in files: extension = os.path.splitext(_file)[1].lower()[1:] if (extension in headphones.MEDIA_FORMATS): count += 1 elif (extension == 'cue'): cue_count += 1 if (root not i...
null
null
null
Attempts to check and split audio files by a cue for the given directory.
pcsd
def cue split albumpath count = 0 cue count = 0 cue dirs = [] for root dirs files in os walk albumpath for file in files extension = os path splitext file [1] lower [1 ] if extension in headphones MEDIA FORMATS count += 1 elif extension == 'cue' cue count += 1 if root not in cue dirs cue dirs append root if cue count a...
14715
def cue_split(albumpath): count = 0 cue_count = 0 cue_dirs = [] for (root, dirs, files) in os.walk(albumpath): for _file in files: extension = os.path.splitext(_file)[1].lower()[1:] if (extension in headphones.MEDIA_FORMATS): count += 1 elif (extension == 'cue'): cue_count += 1 if (root not i...
Attempts to check and split audio files by a cue for the given directory.
attempts to check and split audio files by a cue for the given directory .
Question: What does this function do? Code: def cue_split(albumpath): count = 0 cue_count = 0 cue_dirs = [] for (root, dirs, files) in os.walk(albumpath): for _file in files: extension = os.path.splitext(_file)[1].lower()[1:] if (extension in headphones.MEDIA_FORMATS): count += 1 elif (extension =...
null
null
null
What does this function do?
@utils.arg('--all-tenants', action='store_const', const=1, default=0, help=_('Stop server(s) in another tenant by name (Admin only).')) @utils.arg('server', metavar='<server>', nargs='+', help=_('Name or ID of server(s).')) def do_stop(cs, args): find_args = {'all_tenants': args.all_tenants} utils.do_action_on_many((...
null
null
null
Stop the server(s).
pcsd
@utils arg '--all-tenants' action='store const' const=1 default=0 help= 'Stop server s in another tenant by name Admin only ' @utils arg 'server' metavar='<server>' nargs='+' help= 'Name or ID of server s ' def do stop cs args find args = {'all tenants' args all tenants} utils do action on many lambda s find server cs ...
14725
@utils.arg('--all-tenants', action='store_const', const=1, default=0, help=_('Stop server(s) in another tenant by name (Admin only).')) @utils.arg('server', metavar='<server>', nargs='+', help=_('Name or ID of server(s).')) def do_stop(cs, args): find_args = {'all_tenants': args.all_tenants} utils.do_action_on_many((...
Stop the server(s).
stop the server ( s ) .
Question: What does this function do? Code: @utils.arg('--all-tenants', action='store_const', const=1, default=0, help=_('Stop server(s) in another tenant by name (Admin only).')) @utils.arg('server', metavar='<server>', nargs='+', help=_('Name or ID of server(s).')) def do_stop(cs, args): find_args = {'all_tenants...
null
null
null
What does this function do?
def find_lexer_class(name): if (name in _lexer_cache): return _lexer_cache[name] for (module_name, lname, aliases, _, _) in LEXERS.itervalues(): if (name == lname): _load_lexers(module_name) return _lexer_cache[name] for cls in find_plugin_lexers(): if (cls.name == name): return cls
null
null
null
Lookup a lexer class by name. Return None if not found.
pcsd
def find lexer class name if name in lexer cache return lexer cache[name] for module name lname aliases in LEXERS itervalues if name == lname load lexers module name return lexer cache[name] for cls in find plugin lexers if cls name == name return cls
14730
def find_lexer_class(name): if (name in _lexer_cache): return _lexer_cache[name] for (module_name, lname, aliases, _, _) in LEXERS.itervalues(): if (name == lname): _load_lexers(module_name) return _lexer_cache[name] for cls in find_plugin_lexers(): if (cls.name == name): return cls
Lookup a lexer class by name. Return None if not found.
lookup a lexer class by name .
Question: What does this function do? Code: def find_lexer_class(name): if (name in _lexer_cache): return _lexer_cache[name] for (module_name, lname, aliases, _, _) in LEXERS.itervalues(): if (name == lname): _load_lexers(module_name) return _lexer_cache[name] for cls in find_plugin_lexers(): if (cls....
null
null
null
What does this function do?
@pytest.mark.skipif((sys.version_info[:2] <= (3, 3)), reason='Python 3.4+ shows chained exceptions on multiprocess') def test_exception_handling_no_traceback(testdir): p1 = testdir.makepyfile('\n from multiprocessing import Pool\n\n def process_task(n):\n assert n == 10\n\n def multitas...
null
null
null
Handle chain exceptions in tasks submitted by the multiprocess module (#1984).
pcsd
@pytest mark skipif sys version info[ 2] <= 3 3 reason='Python 3 4+ shows chained exceptions on multiprocess' def test exception handling no traceback testdir p1 = testdir makepyfile ' from multiprocessing import Pool def process task n assert n == 10 def multitask job tasks = [1] with Pool processes=1 as pool pool map...
14734
@pytest.mark.skipif((sys.version_info[:2] <= (3, 3)), reason='Python 3.4+ shows chained exceptions on multiprocess') def test_exception_handling_no_traceback(testdir): p1 = testdir.makepyfile('\n from multiprocessing import Pool\n\n def process_task(n):\n assert n == 10\n\n def multitas...
Handle chain exceptions in tasks submitted by the multiprocess module (#1984).
handle chain exceptions in tasks submitted by the multiprocess module .
Question: What does this function do? Code: @pytest.mark.skipif((sys.version_info[:2] <= (3, 3)), reason='Python 3.4+ shows chained exceptions on multiprocess') def test_exception_handling_no_traceback(testdir): p1 = testdir.makepyfile('\n from multiprocessing import Pool\n\n def process_task(n):\n ...
null
null
null
What does this function do?
def condense_hex_colors(css): regex = re.compile('([^\\"\'=\\s])(\\s*)#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])') match = regex.search(css) while match: first = ((match.group(3) + match.group(5)) + match.group(7)) second = ((match.group(4) + match.group(6)) + match.group(8))...
null
null
null
Shorten colors from #AABBCC to #ABC where possible.
pcsd
def condense hex colors css regex = re compile ' [^\\"\'=\\s] \\s* # [0-9a-f A-F] [0-9a-f A-F] [0-9a-f A-F] [0-9a-f A-F] [0-9a-f A-F] [0-9a-f A-F] ' match = regex search css while match first = match group 3 + match group 5 + match group 7 second = match group 4 + match group 6 + match group 8 if first lower == second ...
14747
def condense_hex_colors(css): regex = re.compile('([^\\"\'=\\s])(\\s*)#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])') match = regex.search(css) while match: first = ((match.group(3) + match.group(5)) + match.group(7)) second = ((match.group(4) + match.group(6)) + match.group(8))...
Shorten colors from #AABBCC to #ABC where possible.
shorten colors from # aabbcc to # abc where possible .
Question: What does this function do? Code: def condense_hex_colors(css): regex = re.compile('([^\\"\'=\\s])(\\s*)#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])') match = regex.search(css) while match: first = ((match.group(3) + match.group(5)) + match.group(7)) second = ((mat...
null
null
null
What does this function do?
def _recursive_escape(value, esc=conditional_escape): if isinstance(value, dict): return type(value)(((esc(k), _recursive_escape(v)) for (k, v) in value.iteritems())) elif isinstance(value, (list, tuple)): return type(value)((_recursive_escape(v) for v in value)) elif isinstance(value, basestring): return esc(...
null
null
null
Recursively escapes strings in an object. Traverses dict, list and tuples. These are the data structures supported by the JSON encoder.
pcsd
def recursive escape value esc=conditional escape if isinstance value dict return type value esc k recursive escape v for k v in value iteritems elif isinstance value list tuple return type value recursive escape v for v in value elif isinstance value basestring return esc value elif isinstance value int long float or ...
14753
def _recursive_escape(value, esc=conditional_escape): if isinstance(value, dict): return type(value)(((esc(k), _recursive_escape(v)) for (k, v) in value.iteritems())) elif isinstance(value, (list, tuple)): return type(value)((_recursive_escape(v) for v in value)) elif isinstance(value, basestring): return esc(...
Recursively escapes strings in an object. Traverses dict, list and tuples. These are the data structures supported by the JSON encoder.
recursively escapes strings in an object .
Question: What does this function do? Code: def _recursive_escape(value, esc=conditional_escape): if isinstance(value, dict): return type(value)(((esc(k), _recursive_escape(v)) for (k, v) in value.iteritems())) elif isinstance(value, (list, tuple)): return type(value)((_recursive_escape(v) for v in value)) el...
null
null
null
What does this function do?
def execute_patch(patchmodule, method=None, methodargs=None): block_user(True) frappe.db.begin() try: log(u'Executing {patch} in {site} ({db})'.format(patch=(patchmodule or str(methodargs)), site=frappe.local.site, db=frappe.db.cur_db_name)) if patchmodule: if patchmodule.startswith(u'finally:'): frappe.f...
null
null
null
execute the patch
pcsd
def execute patch patchmodule method=None methodargs=None block user True frappe db begin try log u'Executing {patch} in {site} {db} ' format patch= patchmodule or str methodargs site=frappe local site db=frappe db cur db name if patchmodule if patchmodule startswith u'finally ' frappe flags final patches append patchm...
14761
def execute_patch(patchmodule, method=None, methodargs=None): block_user(True) frappe.db.begin() try: log(u'Executing {patch} in {site} ({db})'.format(patch=(patchmodule or str(methodargs)), site=frappe.local.site, db=frappe.db.cur_db_name)) if patchmodule: if patchmodule.startswith(u'finally:'): frappe.f...
execute the patch
execute the patch
Question: What does this function do? Code: def execute_patch(patchmodule, method=None, methodargs=None): block_user(True) frappe.db.begin() try: log(u'Executing {patch} in {site} ({db})'.format(patch=(patchmodule or str(methodargs)), site=frappe.local.site, db=frappe.db.cur_db_name)) if patchmodule: if pa...
null
null
null
What does this function do?
@_docstring('recording') def get_recording_by_id(id, includes=[], release_status=[], release_type=[]): params = _check_filter_and_make_params('recording', includes, release_status, release_type) return _do_mb_query('recording', id, includes, params)
null
null
null
Get the recording with the MusicBrainz `id` as a dict with a \'recording\' key. *Available includes*: {includes}
pcsd
@ docstring 'recording' def get recording by id id includes=[] release status=[] release type=[] params = check filter and make params 'recording' includes release status release type return do mb query 'recording' id includes params
14764
@_docstring('recording') def get_recording_by_id(id, includes=[], release_status=[], release_type=[]): params = _check_filter_and_make_params('recording', includes, release_status, release_type) return _do_mb_query('recording', id, includes, params)
Get the recording with the MusicBrainz `id` as a dict with a \'recording\' key. *Available includes*: {includes}
get the recording with the musicbrainz id as a dict with a recording key .
Question: What does this function do? Code: @_docstring('recording') def get_recording_by_id(id, includes=[], release_status=[], release_type=[]): params = _check_filter_and_make_params('recording', includes, release_status, release_type) return _do_mb_query('recording', id, includes, params)
null
null
null
What does this function do?
@register.inclusion_tag('utilities/render_custom_fields.html') def render_custom_fields(form): return {'form': form}
null
null
null
Render all custom fields in a form
pcsd
@register inclusion tag 'utilities/render custom fields html' def render custom fields form return {'form' form}
14765
@register.inclusion_tag('utilities/render_custom_fields.html') def render_custom_fields(form): return {'form': form}
Render all custom fields in a form
render all custom fields in a form
Question: What does this function do? Code: @register.inclusion_tag('utilities/render_custom_fields.html') def render_custom_fields(form): return {'form': form}
null
null
null
What does this function do?
def tree_selection_items(tree_item): selected = [] for idx in range(tree_item.childCount()): child = tree_item.child(idx) if child.isSelected(): selected.append(child) return selected
null
null
null
Returns selected widget items
pcsd
def tree selection items tree item selected = [] for idx in range tree item child Count child = tree item child idx if child is Selected selected append child return selected
14779
def tree_selection_items(tree_item): selected = [] for idx in range(tree_item.childCount()): child = tree_item.child(idx) if child.isSelected(): selected.append(child) return selected
Returns selected widget items
returns selected widget items
Question: What does this function do? Code: def tree_selection_items(tree_item): selected = [] for idx in range(tree_item.childCount()): child = tree_item.child(idx) if child.isSelected(): selected.append(child) return selected
null
null
null
What does this function do?
def register(linter): linter.register_checker(ModelineChecker(linter))
null
null
null
Register the checker.
pcsd
def register linter linter register checker Modeline Checker linter
14781
def register(linter): linter.register_checker(ModelineChecker(linter))
Register the checker.
register the checker .
Question: What does this function do? Code: def register(linter): linter.register_checker(ModelineChecker(linter))
null
null
null
What does this function do?
def action_peek_xml(body): dom = utils.safe_minidom_parse_string(body) action_node = dom.childNodes[0] return action_node.tagName
null
null
null
Determine action to invoke.
pcsd
def action peek xml body dom = utils safe minidom parse string body action node = dom child Nodes[0] return action node tag Name
14782
def action_peek_xml(body): dom = utils.safe_minidom_parse_string(body) action_node = dom.childNodes[0] return action_node.tagName
Determine action to invoke.
determine action to invoke .
Question: What does this function do? Code: def action_peek_xml(body): dom = utils.safe_minidom_parse_string(body) action_node = dom.childNodes[0] return action_node.tagName