_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q262300 | BaseAXUIElement._performAction | validation | def _performAction(self, action):
"""Perform the specified action."""
try:
_a11y.AXUIElement._performAction(self, 'AX%s' % action)
except _a11y.ErrorUnsupported as e:
sierra_ver = '10.12'
if mac_ver()[0] < sierra_ver:
raise e
else:
... | python | {
"resource": ""
} |
q262301 | BaseAXUIElement._generateChildren | validation | def _generateChildren(self):
"""Generator which yields all AXChildren of the object."""
try:
children = self.AXChildren
except _a11y.Error:
return
if children:
for child in children:
yield child | python | {
"resource": ""
} |
q262302 | BaseAXUIElement._generateChildrenR | validation | def _generateChildrenR(self, target=None):
"""Generator which recursively yields all AXChildren of the object."""
if target is None:
target = self
try:
children = target.AXChildren
except _a11y.Error:
return
if children:
for child i... | python | {
"resource": ""
} |
q262303 | BaseAXUIElement._match | validation | def _match(self, **kwargs):
"""Method which indicates if the object matches specified criteria.
Match accepts criteria as kwargs and looks them up on attributes.
Actual matching is performed with fnmatch, so shell-like wildcards
work within match strings. Examples:
obj._match(A... | python | {
"resource": ""
} |
q262304 | BaseAXUIElement._matchOther | validation | def _matchOther(self, obj, **kwargs):
"""Perform _match but on another object, not self."""
if obj is not None:
# Need to check that the returned UI element wasn't destroyed first:
if self._findFirstR(**kwargs):
return obj._match(**kwargs)
return False | python | {
"resource": ""
} |
q262305 | BaseAXUIElement._generateFind | validation | def _generateFind(self, **kwargs):
"""Generator which yields matches on AXChildren."""
for needle in self._generateChildren():
if needle._match(**kwargs):
yield needle | python | {
"resource": ""
} |
q262306 | BaseAXUIElement._generateFindR | validation | def _generateFindR(self, **kwargs):
"""Generator which yields matches on AXChildren and their children."""
for needle in self._generateChildrenR():
if needle._match(**kwargs):
yield needle | python | {
"resource": ""
} |
q262307 | BaseAXUIElement._findAll | validation | def _findAll(self, **kwargs):
"""Return a list of all children that match the specified criteria."""
result = []
for item in self._generateFind(**kwargs):
result.append(item)
return result | python | {
"resource": ""
} |
q262308 | BaseAXUIElement._getApplication | validation | def _getApplication(self):
"""Get the base application UIElement.
If the UIElement is a child of the application, it will try
to get the AXParent until it reaches the top application level
element.
"""
app = self
while True:
try:
app =... | python | {
"resource": ""
} |
q262309 | BaseAXUIElement._getBundleId | validation | def _getBundleId(self):
"""Return the bundle ID of the application."""
ra = AppKit.NSRunningApplication
app = ra.runningApplicationWithProcessIdentifier_(
self._getPid())
return app.bundleIdentifier() | python | {
"resource": ""
} |
q262310 | NativeUIElement.popUpItem | validation | def popUpItem(self, *args):
"""Return the specified item in a pop up menu."""
self.Press()
time.sleep(.5)
return self._menuItem(self, *args) | python | {
"resource": ""
} |
q262311 | NativeUIElement.dragMouseButtonLeft | validation | def dragMouseButtonLeft(self, coord, dest_coord, interval=0.5):
"""Drag the left mouse button without modifiers pressed.
Parameters: coordinates to click on screen (tuple (x, y))
dest coordinates to drag to (tuple (x, y))
interval to send event of btn down, drag ... | python | {
"resource": ""
} |
q262312 | NativeUIElement.doubleClickDragMouseButtonLeft | validation | def doubleClickDragMouseButtonLeft(self, coord, dest_coord, interval=0.5):
"""Double-click and drag the left mouse button without modifiers
pressed.
Parameters: coordinates to double-click on screen (tuple (x, y))
dest coordinates to drag to (tuple (x, y))
... | python | {
"resource": ""
} |
q262313 | NativeUIElement.clickMouseButtonLeft | validation | def clickMouseButtonLeft(self, coord, interval=None):
"""Click the left mouse button without modifiers pressed.
Parameters: coordinates to click on screen (tuple (x, y))
Returns: None
"""
modFlags = 0
self._queueMouseButton(coord, Quartz.kCGMouseButtonLeft, modFlags)
... | python | {
"resource": ""
} |
q262314 | NativeUIElement.clickMouseButtonRight | validation | def clickMouseButtonRight(self, coord):
"""Click the right mouse button without modifiers pressed.
Parameters: coordinates to click on scren (tuple (x, y))
Returns: None
"""
modFlags = 0
self._queueMouseButton(coord, Quartz.kCGMouseButtonRight, modFlags)
self._po... | python | {
"resource": ""
} |
q262315 | NativeUIElement.clickMouseButtonRightWithMods | validation | def clickMouseButtonRightWithMods(self, coord, modifiers):
"""Click the right mouse button with modifiers pressed.
Parameters: coordinates to click; modifiers (list)
Returns: None
"""
modFlags = self._pressModifiers(modifiers)
self._queueMouseButton(coord, Quartz.kCGMous... | python | {
"resource": ""
} |
q262316 | NativeUIElement.leftMouseDragged | validation | def leftMouseDragged(self, stopCoord, strCoord=(0, 0), speed=1):
"""Click the left mouse button and drag object.
Parameters: stopCoord, the position of dragging stopped
strCoord, the position of dragging started
(0,0) will get current position
... | python | {
"resource": ""
} |
q262317 | NativeUIElement.doubleClickMouse | validation | def doubleClickMouse(self, coord):
"""Double-click primary mouse button.
Parameters: coordinates to click (assume primary is left button)
Returns: None
"""
modFlags = 0
self._queueMouseButton(coord, Quartz.kCGMouseButtonLeft, modFlags)
# This is a kludge:
... | python | {
"resource": ""
} |
q262318 | NativeUIElement.tripleClickMouse | validation | def tripleClickMouse(self, coord):
"""Triple-click primary mouse button.
Parameters: coordinates to click (assume primary is left button)
Returns: None
"""
# Note above re: double-clicks applies to triple-clicks
modFlags = 0
for i in range(2):
self._q... | python | {
"resource": ""
} |
q262319 | NativeUIElement.waitFor | validation | def waitFor(self, timeout, notification, **kwargs):
"""Generic wait for a UI event that matches the specified
criteria to occur.
For customization of the callback, use keyword args labeled
'callback', 'args', and 'kwargs' for the callback fn, callback args,
and callback kwargs, ... | python | {
"resource": ""
} |
q262320 | NativeUIElement.waitForCreation | validation | def waitForCreation(self, timeout=10, notification='AXCreated'):
"""Convenience method to wait for creation of some UI element.
Returns: The element created
"""
callback = AXCallbacks.returnElemCallback
retelem = None
args = (retelem,)
return self.waitFor(timeou... | python | {
"resource": ""
} |
q262321 | NativeUIElement.waitForWindowToDisappear | validation | def waitForWindowToDisappear(self, winName, timeout=10):
"""Convenience method to wait for a window with the given name to
disappear.
Returns: Boolean
"""
callback = AXCallbacks.elemDisappearedCallback
retelem = None
args = (retelem, self)
# For some rea... | python | {
"resource": ""
} |
q262322 | NativeUIElement.waitForValueToChange | validation | def waitForValueToChange(self, timeout=10):
"""Convenience method to wait for value attribute of given element to
change.
Some types of elements (e.g. menu items) have their titles change,
so this will not work for those. This seems to work best if you set
the notification at t... | python | {
"resource": ""
} |
q262323 | NativeUIElement.waitForFocusedWindowToChange | validation | def waitForFocusedWindowToChange(self, nextWinName, timeout=10):
"""Convenience method to wait for focused window to change
Returns: Boolean
"""
callback = AXCallbacks.returnElemCallback
retelem = None
return self.waitFor(timeout, 'AXFocusedWindowChanged',
... | python | {
"resource": ""
} |
q262324 | removecallback | validation | def removecallback(window_name):
"""
Remove registered callback on window create
@param window_name: Window name to look for, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@return: 1 if registration was successful, 0 if not.
@rtype: integer
"""
... | python | {
"resource": ""
} |
q262325 | stopEventLoop | validation | def stopEventLoop():
"""
Stop the current event loop if possible
returns True if it expects that it was successful, False otherwise
"""
stopper = PyObjCAppHelperRunLoopStopper_wrap.currentRunLoopStopper()
if stopper is None:
if NSApp() is not None:
NSApp().terminate_(None)
... | python | {
"resource": ""
} |
q262326 | main | validation | def main(port=4118, parentpid=None):
"""Main entry point. Parse command line options and start up a server."""
if "LDTP_DEBUG" in os.environ:
_ldtp_debug = True
else:
_ldtp_debug = False
_ldtp_debug_file = os.environ.get('LDTP_DEBUG_FILE', None)
if _ldtp_debug:
print("Parent ... | python | {
"resource": ""
} |
q262327 | LDTPServer.server_bind | validation | def server_bind(self, *args, **kwargs):
'''Server Bind. Forces reuse of port.'''
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# Can't use super() here since SimpleXMLRPCServer is an old-style class
SimpleXMLRPCServer.server_bind(self, *args, **kwargs) | python | {
"resource": ""
} |
q262328 | ooldtp.log | validation | def log(self, message, level=logging.DEBUG):
"""
Logs the message in the root logger with the log level
@param message: Message to be logged
@type message: string
@param level: Log level, defaul DEBUG
@type level: integer
@return: 1 on success and 0 on error
... | python | {
"resource": ""
} |
q262329 | ooldtp.stoplog | validation | def stoplog(self):
""" Stop logging.
@return: 1 on success and 0 on error
@rtype: integer
"""
if self._file_logger:
self.logger.removeHandler(_file_logger)
self._file_logger = None
return 1 | python | {
"resource": ""
} |
q262330 | ooldtp.imagecapture | validation | def imagecapture(self, window_name=None, out_file=None, x=0, y=0,
width=None, height=None):
"""
Captures screenshot of the whole desktop or given window
@param window_name: Window name to look for, either full name,
LDTP's name convention, or a Unix glob.
@t... | python | {
"resource": ""
} |
q262331 | ooldtp.onwindowcreate | validation | def onwindowcreate(self, window_name, fn_name, *args):
"""
On window create, call the function with given arguments
@param window_name: Window name to look for, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param fn_name: Callback f... | python | {
"resource": ""
} |
q262332 | ooldtp.registerevent | validation | def registerevent(self, event_name, fn_name, *args):
"""
Register at-spi event
@param event_name: Event name in at-spi format.
@type event_name: string
@param fn_name: Callback function
@type fn_name: function
@param *args: arguments to be passed to the callback ... | python | {
"resource": ""
} |
q262333 | ooldtp.registerkbevent | validation | def registerkbevent(self, keys, modifiers, fn_name, *args):
"""
Register keystroke events
@param keys: key to listen
@type keys: string
@param modifiers: control / alt combination using gtk MODIFIERS
@type modifiers: int
@param fn_name: Callback function
... | python | {
"resource": ""
} |
q262334 | ooldtp.windowuptime | validation | def windowuptime(self, window_name):
"""
Get window uptime
@param window_name: Window name to look for, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@return: "starttime, endtime" as datetime python object
"""
tm... | python | {
"resource": ""
} |
q262335 | Value.verifyscrollbarvertical | validation | def verifyscrollbarvertical(self, window_name, object_name):
"""
Verify scrollbar is vertical
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, eithe... | python | {
"resource": ""
} |
q262336 | Value.verifyscrollbarhorizontal | validation | def verifyscrollbarhorizontal(self, window_name, object_name):
"""
Verify scrollbar is horizontal
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, e... | python | {
"resource": ""
} |
q262337 | Value.setmax | validation | def setmax(self, window_name, object_name):
"""
Set max value
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, either full name,
LDTP's name... | python | {
"resource": ""
} |
q262338 | Value.setmin | validation | def setmin(self, window_name, object_name):
"""
Set min value
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, either full name,
LDTP's name... | python | {
"resource": ""
} |
q262339 | Value.onedown | validation | def onedown(self, window_name, object_name, iterations):
"""
Press scrollbar down with number of iterations
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to ... | python | {
"resource": ""
} |
q262340 | Value.oneup | validation | def oneup(self, window_name, object_name, iterations):
"""
Press scrollbar up with number of iterations
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type... | python | {
"resource": ""
} |
q262341 | Value.oneright | validation | def oneright(self, window_name, object_name, iterations):
"""
Press scrollbar right with number of iterations
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name t... | python | {
"resource": ""
} |
q262342 | Value.oneleft | validation | def oneleft(self, window_name, object_name, iterations):
"""
Press scrollbar left with number of iterations
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to ... | python | {
"resource": ""
} |
q262343 | ComboBox.getallitem | validation | def getallitem(self, window_name, object_name):
"""
Get all combo box item
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, either full name,
... | python | {
"resource": ""
} |
q262344 | MobileClientWrapper.login | validation | def login(self, username=None, password=None, android_id=None):
"""Authenticate the gmusicapi Mobileclient instance.
Parameters:
username (Optional[str]): Your Google Music username. Will be prompted if not given.
password (Optional[str]): Your Google Music password. Will be prompted if not given.
andro... | python | {
"resource": ""
} |
q262345 | MobileClientWrapper.get_google_playlist | validation | def get_google_playlist(self, playlist):
"""Get playlist information of a user-generated Google Music playlist.
Parameters:
playlist (str): Name or ID of Google Music playlist. Names are case-sensitive.
Google allows multiple playlists with the same name.
If multiple playlists have the same name, the fi... | python | {
"resource": ""
} |
q262346 | MobileClientWrapper.get_google_playlist_songs | validation | def get_google_playlist_songs(self, playlist, include_filters=None, exclude_filters=None, all_includes=False, all_excludes=False):
"""Create song list from a user-generated Google Music playlist.
Parameters:
playlist (str): Name or ID of Google Music playlist. Names are case-sensitive.
Google allows multipl... | python | {
"resource": ""
} |
q262347 | cast_to_list | validation | def cast_to_list(position):
"""Cast the positional argument at given position into a list if not already a list."""
@wrapt.decorator
def wrapper(function, instance, args, kwargs):
if not isinstance(args[position], list):
args = list(args)
args[position] = [args[position]]
args = tuple(args)
return fun... | python | {
"resource": ""
} |
q262348 | _pybossa_req | validation | def _pybossa_req(method, domain, id=None, payload=None, params={},
headers={'content-type': 'application/json'},
files=None):
"""
Send a JSON request.
Returns True if everything went well, otherwise it returns the status
code of the response.
"""
url = _opts['e... | python | {
"resource": ""
} |
q262349 | get_projects | validation | def get_projects(limit=100, offset=0, last_id=None):
"""Return a list of registered projects.
:param limit: Number of returned items, default 100
:type limit: integer
:param offset: Offset for the query, default 0
:type offset: integer
:param last_id: id of the last project, used for pagination... | python | {
"resource": ""
} |
q262350 | get_project | validation | def get_project(project_id):
"""Return a PYBOSSA Project for the project_id.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:rtype: PYBOSSA Project
:returns: A PYBOSSA Project object
"""
try:
res = _pybossa_req('get', 'project', project_id)
if res.get('id')... | python | {
"resource": ""
} |
q262351 | find_project | validation | def find_project(**kwargs):
"""Return a list with matching project arguments.
:param kwargs: PYBOSSA Project members
:rtype: list
:returns: A list of projects that match the kwargs
"""
try:
res = _pybossa_req('get', 'project', params=kwargs)
if type(res).__name__ == 'list':
... | python | {
"resource": ""
} |
q262352 | create_project | validation | def create_project(name, short_name, description):
"""Create a project.
:param name: PYBOSSA Project Name
:type name: string
:param short_name: PYBOSSA Project short name or slug
:type short_name: string
:param description: PYBOSSA Project description
:type decription: string
:returns: ... | python | {
"resource": ""
} |
q262353 | update_project | validation | def update_project(project):
"""Update a project instance.
:param project: PYBOSSA project
:type project: PYBOSSA Project
:returns: True -- the response status code
"""
try:
project_id = project.id
project = _forbidden_attributes(project)
res = _pybossa_req('put', 'proj... | python | {
"resource": ""
} |
q262354 | delete_project | validation | def delete_project(project_id):
"""Delete a Project with id = project_id.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:returns: True -- the response status code
"""
try:
res = _pybossa_req('delete', 'project', project_id)
if type(res).__name__ == 'bool':
... | python | {
"resource": ""
} |
q262355 | get_categories | validation | def get_categories(limit=20, offset=0, last_id=None):
"""Return a list of registered categories.
:param limit: Number of returned items, default 20
:type limit: integer
:param offset: Offset for the query, default 0
:type offset: integer
:param last_id: id of the last category, used for paginat... | python | {
"resource": ""
} |
q262356 | get_category | validation | def get_category(category_id):
"""Return a PYBOSSA Category for the category_id.
:param category_id: PYBOSSA Category ID
:type category_id: integer
:rtype: PYBOSSA Category
:returns: A PYBOSSA Category object
"""
try:
res = _pybossa_req('get', 'category', category_id)
if re... | python | {
"resource": ""
} |
q262357 | find_category | validation | def find_category(**kwargs):
"""Return a list with matching Category arguments.
:param kwargs: PYBOSSA Category members
:rtype: list
:returns: A list of project that match the kwargs
"""
try:
res = _pybossa_req('get', 'category', params=kwargs)
if type(res).__name__ == 'list':
... | python | {
"resource": ""
} |
q262358 | create_category | validation | def create_category(name, description):
"""Create a Category.
:param name: PYBOSSA Category Name
:type name: string
:param description: PYBOSSA Category description
:type decription: string
:returns: True -- the response status code
"""
try:
category = dict(name=name, short_name... | python | {
"resource": ""
} |
q262359 | update_category | validation | def update_category(category):
"""Update a Category instance.
:param category: PYBOSSA Category
:type category: PYBOSSA Category
:returns: True -- the response status code
"""
try:
res = _pybossa_req('put', 'category',
category.id, payload=category.data)
... | python | {
"resource": ""
} |
q262360 | delete_category | validation | def delete_category(category_id):
"""Delete a Category with id = category_id.
:param category_id: PYBOSSA Category ID
:type category_id: integer
:returns: True -- the response status code
"""
try:
res = _pybossa_req('delete', 'category', category_id)
if type(res).__name__ == 'b... | python | {
"resource": ""
} |
q262361 | get_tasks | validation | def get_tasks(project_id, limit=100, offset=0, last_id=None):
"""Return a list of tasks for a given project ID.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:param limit: Number of returned items, default 100
:type limit: integer
:param offset: Offset for the query, default 0... | python | {
"resource": ""
} |
q262362 | find_tasks | validation | def find_tasks(project_id, **kwargs):
"""Return a list of matched tasks for a given project ID.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:param kwargs: PYBOSSA Task members
:type info: dict
:rtype: list
:returns: A list of tasks that match the kwargs
"""
try:... | python | {
"resource": ""
} |
q262363 | create_task | validation | def create_task(project_id, info, n_answers=30, priority_0=0, quorum=0):
"""Create a task for a given project ID.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:param info: PYBOSSA Project info JSON field
:type info: dict
:param n_answers: Number of answers or TaskRuns per tas... | python | {
"resource": ""
} |
q262364 | update_task | validation | def update_task(task):
"""Update a task for a given task ID.
:param task: PYBOSSA task
"""
try:
task_id = task.id
task = _forbidden_attributes(task)
res = _pybossa_req('put', 'task', task_id, payload=task.data)
if res.get('id'):
return Task(res)
else... | python | {
"resource": ""
} |
q262365 | delete_task | validation | def delete_task(task_id):
"""Delete a task for a given task ID.
:param task: PYBOSSA task
"""
#: :arg task: A task
try:
res = _pybossa_req('delete', 'task', task_id)
if type(res).__name__ == 'bool':
return True
else:
return res
except: # pragma:... | python | {
"resource": ""
} |
q262366 | get_taskruns | validation | def get_taskruns(project_id, limit=100, offset=0, last_id=None):
"""Return a list of task runs for a given project ID.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:param limit: Number of returned items, default 100
:type limit: integer
:param offset: Offset for the query, de... | python | {
"resource": ""
} |
q262367 | find_taskruns | validation | def find_taskruns(project_id, **kwargs):
"""Return a list of matched task runs for a given project ID.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:param kwargs: PYBOSSA Task Run members
:rtype: list
:returns: A List of task runs that match the query members
"""
try... | python | {
"resource": ""
} |
q262368 | delete_taskrun | validation | def delete_taskrun(taskrun_id):
"""Delete the given taskrun.
:param task: PYBOSSA task
"""
try:
res = _pybossa_req('delete', 'taskrun', taskrun_id)
if type(res).__name__ == 'bool':
return True
else:
return res
except: # pragma: no cover
raise | python | {
"resource": ""
} |
q262369 | get_results | validation | def get_results(project_id, limit=100, offset=0, last_id=None):
"""Return a list of results for a given project ID.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:param limit: Number of returned items, default 100
:type limit: integer
:param offset: Offset for the query, defau... | python | {
"resource": ""
} |
q262370 | find_results | validation | def find_results(project_id, **kwargs):
"""Return a list of matched results for a given project ID.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:param kwargs: PYBOSSA Results members
:type info: dict
:rtype: list
:returns: A list of results that match the kwargs
"""... | python | {
"resource": ""
} |
q262371 | update_result | validation | def update_result(result):
"""Update a result for a given result ID.
:param result: PYBOSSA result
"""
try:
result_id = result.id
result = _forbidden_attributes(result)
res = _pybossa_req('put', 'result', result_id, payload=result.data)
if res.get('id'):
ret... | python | {
"resource": ""
} |
q262372 | _forbidden_attributes | validation | def _forbidden_attributes(obj):
"""Return the object without the forbidden attributes."""
for key in list(obj.data.keys()):
if key in list(obj.reserved_keys.keys()):
obj.data.pop(key)
return obj | python | {
"resource": ""
} |
q262373 | create_helpingmaterial | validation | def create_helpingmaterial(project_id, info, media_url=None, file_path=None):
"""Create a helping material for a given project ID.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:param info: PYBOSSA Helping Material info JSON field
:type info: dict
:param media_url: URL for a m... | python | {
"resource": ""
} |
q262374 | get_helping_materials | validation | def get_helping_materials(project_id, limit=100, offset=0, last_id=None):
"""Return a list of helping materials for a given project ID.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:param limit: Number of returned items, default 100
:type limit: integer
:param offset: Offset ... | python | {
"resource": ""
} |
q262375 | find_helping_materials | validation | def find_helping_materials(project_id, **kwargs):
"""Return a list of matched helping materials for a given project ID.
:param project_id: PYBOSSA Project ID
:type project_id: integer
:param kwargs: PYBOSSA HelpingMaterial members
:type info: dict
:rtype: list
:returns: A list of helping ma... | python | {
"resource": ""
} |
q262376 | update_helping_material | validation | def update_helping_material(helpingmaterial):
"""Update a helping material for a given helping material ID.
:param helpingmaterial: PYBOSSA helping material
"""
try:
helpingmaterial_id = helpingmaterial.id
helpingmaterial = _forbidden_attributes(helpingmaterial)
res = _pybossa_... | python | {
"resource": ""
} |
q262377 | MusicManagerWrapper.login | validation | def login(self, oauth_filename="oauth", uploader_id=None):
"""Authenticate the gmusicapi Musicmanager instance.
Parameters:
oauth_filename (str): The filename of the oauth credentials file to use/create for login.
Default: ``oauth``
uploader_id (str): A unique id as a MAC address (e.g. ``'00:11:22:33:AA... | python | {
"resource": ""
} |
q262378 | MusicManagerWrapper.download | validation | def download(self, songs, template=None):
"""Download Google Music songs.
Parameters:
songs (list or dict): Google Music song dict(s).
template (str): A filepath which can include template patterns.
Returns:
A list of result dictionaries.
::
[
{'result': 'downloaded', 'id': song_id, 'file... | python | {
"resource": ""
} |
q262379 | convert_cygwin_path | validation | def convert_cygwin_path(path):
"""Convert Unix path from Cygwin to Windows path."""
try:
win_path = subprocess.check_output(["cygpath", "-aw", path], universal_newlines=True).strip()
except (FileNotFoundError, subprocess.CalledProcessError):
logger.exception("Call to cygpath failed.")
raise
return win_path | python | {
"resource": ""
} |
q262380 | _get_mutagen_metadata | validation | def _get_mutagen_metadata(filepath):
"""Get mutagen metadata dict from a file."""
try:
metadata = mutagen.File(filepath, easy=True)
except mutagen.MutagenError:
logger.warning("Can't load {} as music file.".format(filepath))
raise
return metadata | python | {
"resource": ""
} |
q262381 | _mutagen_fields_to_single_value | validation | def _mutagen_fields_to_single_value(metadata):
"""Replace mutagen metadata field list values in mutagen tags with the first list value."""
return dict((k, v[0]) for k, v in metadata.items() if v) | python | {
"resource": ""
} |
q262382 | _normalize_metadata | validation | def _normalize_metadata(metadata):
"""Normalize metadata to improve match accuracy."""
metadata = str(metadata)
metadata = metadata.lower()
metadata = re.sub(r'\/\s*\d+', '', metadata) # Remove "/<totaltracks>" from track number.
metadata = re.sub(r'^0+([0-9]+)', r'\1', metadata) # Remove leading zero(s) from ... | python | {
"resource": ""
} |
q262383 | compare_song_collections | validation | def compare_song_collections(src_songs, dst_songs):
"""Compare two song collections to find missing songs.
Parameters:
src_songs (list): Google Music song dicts or filepaths of local songs.
dest_songs (list): Google Music song dicts or filepaths of local songs.
Returns:
A list of Google Music song dicts or ... | python | {
"resource": ""
} |
q262384 | get_supported_filepaths | validation | def get_supported_filepaths(filepaths, supported_extensions, max_depth=float('inf')):
"""Get filepaths with supported extensions from given filepaths.
Parameters:
filepaths (list or str): Filepath(s) to check.
supported_extensions (tuple or str): Supported file extensions or a single file extension.
max_dept... | python | {
"resource": ""
} |
q262385 | exclude_filepaths | validation | def exclude_filepaths(filepaths, exclude_patterns=None):
"""Exclude file paths based on regex patterns.
Parameters:
filepaths (list or str): Filepath(s) to check.
exclude_patterns (list): Python regex patterns to check filepaths against.
Returns:
A list of filepaths to include and a list of filepaths to exc... | python | {
"resource": ""
} |
q262386 | _check_field_value | validation | def _check_field_value(field_value, pattern):
"""Check a song metadata field value for a pattern."""
if isinstance(field_value, list):
return any(re.search(pattern, str(value), re.I) for value in field_value)
else:
return re.search(pattern, str(field_value), re.I) | python | {
"resource": ""
} |
q262387 | _check_filters | validation | def _check_filters(song, include_filters=None, exclude_filters=None, all_includes=False, all_excludes=False):
"""Check a song metadata dict against a set of metadata filters."""
include = True
if include_filters:
if all_includes:
if not all(field in song and _check_field_value(song[field], pattern) for field,... | python | {
"resource": ""
} |
q262388 | filter_google_songs | validation | def filter_google_songs(songs, include_filters=None, exclude_filters=None, all_includes=False, all_excludes=False):
"""Match a Google Music song dict against a set of metadata filters.
Parameters:
songs (list): Google Music song dicts to filter.
include_filters (list): A list of ``(field, pattern)`` tuples.
... | python | {
"resource": ""
} |
q262389 | filter_local_songs | validation | def filter_local_songs(filepaths, include_filters=None, exclude_filters=None, all_includes=False, all_excludes=False):
"""Match a local file against a set of metadata filters.
Parameters:
filepaths (list): Filepaths to filter.
include_filters (list): A list of ``(field, pattern)`` tuples.
Fields are any vali... | python | {
"resource": ""
} |
q262390 | get_suggested_filename | validation | def get_suggested_filename(metadata):
"""Generate a filename for a song based on metadata.
Parameters:
metadata (dict): A metadata dict.
Returns:
A filename.
"""
if metadata.get('title') and metadata.get('track_number'):
suggested_filename = '{track_number:0>2} {title}'.format(**metadata)
elif metadata.g... | python | {
"resource": ""
} |
q262391 | template_to_filepath | validation | def template_to_filepath(template, metadata, template_patterns=None):
"""Create directory structure and file name based on metadata template.
Parameters:
template (str): A filepath which can include template patterns as defined by :param template_patterns:.
metadata (dict): A metadata dict.
template_patterns... | python | {
"resource": ""
} |
q262392 | walk_depth | validation | def walk_depth(path, max_depth=float('inf')):
"""Walk a directory tree with configurable depth.
Parameters:
path (str): A directory path to walk.
max_depth (int): The depth in the directory tree to walk.
A depth of '0' limits the walk to the top directory.
Default: No limit.
"""
start_level = os.path.a... | python | {
"resource": ""
} |
q262393 | _BaseWrapper.get_local_songs | validation | def get_local_songs(
filepaths, include_filters=None, exclude_filters=None, all_includes=False, all_excludes=False,
exclude_patterns=None, max_depth=float('inf')):
"""Load songs from local filepaths.
Parameters:
filepaths (list or str): Filepath(s) to search for music files.
include_filters (list): A ... | python | {
"resource": ""
} |
q262394 | _BaseWrapper.get_local_playlists | validation | def get_local_playlists(filepaths, exclude_patterns=None, max_depth=float('inf')):
"""Load playlists from local filepaths.
Parameters:
filepaths (list or str): Filepath(s) to search for music files.
exclude_patterns (list or str): Pattern(s) to exclude.
Patterns are Python regex patterns.
Filepaths ... | python | {
"resource": ""
} |
q262395 | _BaseWrapper.get_local_playlist_songs | validation | def get_local_playlist_songs(
playlist, include_filters=None, exclude_filters=None,
all_includes=False, all_excludes=False, exclude_patterns=None):
"""Load songs from local playlist.
Parameters:
playlist (str): An M3U(8) playlist filepath.
include_filters (list): A list of ``(field, pattern)`` tuples.
... | python | {
"resource": ""
} |
q262396 | Material._create_element_list_ | validation | def _create_element_list_(self):
"""
Extract an alphabetically sorted list of elements from the compounds of
the material.
:returns: An alphabetically sorted list of elements.
"""
element_set = stoich.elements(self.compounds)
return sorted(list(element_set)) | python | {
"resource": ""
} |
q262397 | MaterialPackage.get_assay | validation | def get_assay(self):
"""
Determine the assay of self.
:returns: [mass fractions] An array containing the assay of self.
"""
masses_sum = sum(self.compound_masses)
return [m / masses_sum for m in self.compound_masses] | python | {
"resource": ""
} |
q262398 | MaterialPackage.get_element_masses | validation | def get_element_masses(self):
"""
Get the masses of elements in the package.
:returns: [kg] An array of element masses. The sequence of the elements
in the result corresponds with the sequence of elements in the
element list of the material.
"""
result = [0]... | python | {
"resource": ""
} |
q262399 | MaterialPackage.add_to | validation | def add_to(self, other):
"""
Add another chem material package to this material package.
:param other: The other material package.
"""
# Add another package.
if type(other) is MaterialPackage:
# Packages of the same material.
if self.material ==... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.