Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def device_added(self, device):
if not self._mounter.is_handleable(device):
return
if self._has_actions('device_added'):
# wait for partitions etc to be reported to udiskie, otherwise we
# can't discover the action... | [
"Show discovery notification for specified device object."
] |
Please provide a description of the function:def device_removed(self, device):
if not self._mounter.is_handleable(device):
return
device_file = device.device_presentation
if (device.is_drive or device.is_toplevel) and device_file:
self._show_notification(
... | [
"Show removal notification for specified device object."
] |
Please provide a description of the function:def job_failed(self, device, action, message):
if not self._mounter.is_handleable(device):
return
device_file = device.device_presentation or device.object_path
if message:
text = _('failed to {0} {1}:\n{2}', action, d... | [
"Show 'Job failed' notification with 'Retry' button."
] |
Please provide a description of the function:def _show_notification(self,
event, summary, message, icon,
*actions):
notification = self._notify(summary, message, icon)
timeout = self._get_timeout(event)
if timeout != -1:
... | [
"\n Show a notification.\n\n :param str event: event name\n :param str summary: notification title\n :param str message: notification body\n :param str icon: icon name\n :param actions: each item is a tuple with parameters for _add_action\n "
] |
Please provide a description of the function:def _add_action(self, notification, action, label, callback, *args):
on_action_click = run_bg(lambda *_: callback(*args))
try:
# this is the correct signature for Notify-0.7, the last argument
# being 'user_data':
... | [
"\n Show an action button button in mount notifications.\n\n Note, this only works with some libnotify services.\n "
] |
Please provide a description of the function:def _action_enabled(self, event, action):
event_actions = self._aconfig.get(event)
if event_actions is None:
return True
if event_actions is False:
return False
return action in event_actions | [
"Check if an action for a notification is enabled."
] |
Please provide a description of the function:def _has_actions(self, event):
event_actions = self._aconfig.get(event)
return event_actions is None or bool(event_actions) | [
"Check if a notification type has any enabled actions."
] |
Please provide a description of the function:def match_config(filters, device, kind, default):
if device is None:
return default
matches = (f.value(kind, device)
for f in filters
if f.has_value(kind) and f.match(device))
return next(matches, default) | [
"\n Matches devices against multiple :class:`DeviceFilter`s.\n\n :param list filters: device filters\n :param Device device: device to be mounted\n :param str kind: value kind\n :param default: default value\n :returns: value of the first matching filter\n "
] |
Please provide a description of the function:def match(self, device):
return all(match_value(getattr(device, k), v)
for k, v in self._match.items()) | [
"Check if the device object matches this filter."
] |
Please provide a description of the function:def value(self, kind, device):
self._log.debug(_('{0}(match={1!r}, {2}={3!r}) used for {4}',
self.__class__.__name__,
self._match,
kind, self._values[kind],
... | [
"\n Get the value for the device object associated with this filter.\n\n If :meth:`match` is False for the device, the return value of this\n method is undefined.\n "
] |
Please provide a description of the function:def default_pathes(cls):
try:
from xdg.BaseDirectory import xdg_config_home as config_home
except ImportError:
config_home = os.path.expanduser('~/.config')
return [os.path.join(config_home, 'udiskie', 'config.yml'),
... | [
"Return the default config file pathes as a list."
] |
Please provide a description of the function:def from_file(cls, path=None):
# None => use default
if path is None:
for path in cls.default_pathes():
try:
return cls.from_file(path)
except IOError as e:
logging.g... | [
"\n Read YAML config file. Returns Config object.\n\n :raises IOError: if the path does not exist\n "
] |
Please provide a description of the function:def get_icon_name(self, icon_id: str) -> str:
icon_theme = Gtk.IconTheme.get_default()
for name in self._icon_names[icon_id]:
if icon_theme.has_icon(name):
return name
return 'not-available' | [
"Lookup the system icon name from udisie-internal id."
] |
Please provide a description of the function:def get_icon(self, icon_id: str, size: "Gtk.IconSize") -> "Gtk.Image":
return Gtk.Image.new_from_gicon(self.get_gicon(icon_id), size) | [
"Load Gtk.Image from udiskie-internal id."
] |
Please provide a description of the function:def get_gicon(self, icon_id: str) -> "Gio.Icon":
return Gio.ThemedIcon.new_from_names(self._icon_names[icon_id]) | [
"Lookup Gio.Icon from udiskie-internal id."
] |
Please provide a description of the function:def _insert_options(self, menu):
menu.append(Gtk.SeparatorMenuItem())
menu.append(self._menuitem(
_('Mount disc image'),
self._icons.get_icon('losetup', Gtk.IconSize.MENU),
run_bg(lambda _: self._losetup())
... | [
"Add configuration options to menu."
] |
Please provide a description of the function:def detect(self):
root = self._actions.detect()
prune_empty_node(root, set())
return root | [
"Detect all currently known devices. Returns the root device."
] |
Please provide a description of the function:def _create_menu(self, items):
menu = Gtk.Menu()
self._create_menu_items(menu, items)
return menu | [
"\n Create a menu from the given node.\n\n :param list items: list of menu items\n :returns: a new Gtk.Menu object holding all items of the node\n "
] |
Please provide a description of the function:def _menuitem(self, label, icon, onclick, checked=None):
if checked is not None:
item = Gtk.CheckMenuItem()
item.set_active(checked)
elif icon is None:
item = Gtk.MenuItem()
else:
item = Gtk.Ima... | [
"\n Create a generic menu item.\n\n :param str label: text\n :param Gtk.Image icon: icon (may be ``None``)\n :param onclick: onclick handler, either a callable or Gtk.Menu\n :returns: the menu item object\n :rtype: Gtk.MenuItem\n "
] |
Please provide a description of the function:def _prepare_menu(self, node, flat=None):
if flat is None:
flat = self.flat
ItemGroup = MenuSection if flat else SubMenu
return [
ItemGroup(branch.label, self._collapse_device(branch, flat))
for branch in n... | [
"\n Prepare the menu hierarchy from the given device tree.\n\n :param Device node: root node of device hierarchy\n :returns: menu hierarchy as list\n "
] |
Please provide a description of the function:def _collapse_device(self, node, flat):
items = [item
for branch in node.branches
for item in self._collapse_device(branch, flat)
if item]
show_all = not flat or self._quickmenu_actions == 'all'
... | [
"Collapse device hierarchy into a flat folder."
] |
Please provide a description of the function:def _create_statusicon(self):
statusicon = Gtk.StatusIcon()
statusicon.set_from_gicon(self._icons.get_gicon('media'))
statusicon.set_tooltip_text(_("udiskie"))
return statusicon | [
"Return a new Gtk.StatusIcon."
] |
Please provide a description of the function:def show(self, show=True):
if show and not self.visible:
self._show()
if not show and self.visible:
self._hide() | [
"Show or hide the tray icon."
] |
Please provide a description of the function:def _show(self):
if not self._icon:
self._icon = self._create_statusicon()
widget = self._icon
widget.set_visible(True)
self._conn_left = widget.connect("activate", self._activate)
self._conn_right = widget.connect... | [
"Show the tray icon."
] |
Please provide a description of the function:def _hide(self):
self._icon.set_visible(False)
self._icon.disconnect(self._conn_left)
self._icon.disconnect(self._conn_right)
self._conn_left = None
self._conn_right = None | [
"Hide the tray icon."
] |
Please provide a description of the function:def create_context_menu(self, extended):
menu = Gtk.Menu()
self._menu(menu, extended)
return menu | [
"Create the context menu."
] |
Please provide a description of the function:def _activate(self, icon):
self._popup_menu(icon, button=0, time=Gtk.get_current_event_time(),
extended=False) | [
"Handle a left click event (show the menu)."
] |
Please provide a description of the function:def _popup_menu(self, icon, button, time, extended=True):
m = self.create_context_menu(extended)
m.show_all()
m.popup(parent_menu_shell=None,
parent_menu_item=None,
func=icon.position_menu,
data... | [
"Handle a right click event (show the menu)."
] |
Please provide a description of the function:def update(self, *args):
if self.smart:
self._icon.show(self.has_menu())
else:
self._icon.show(True) | [
"Show/hide icon depending on whether there are devices."
] |
Please provide a description of the function:async def password_dialog(key, title, message, options):
with PasswordDialog.create(key, title, message, options) as dialog:
response = await dialog
if response == Gtk.ResponseType.OK:
return PasswordResult(dialog.get_text(),
... | [
"\n Show a Gtk password dialog.\n\n :returns: the password or ``None`` if the user aborted the operation\n :raises RuntimeError: if Gtk can not be properly initialized\n "
] |
Please provide a description of the function:def get_password_gui(device, options):
text = _('Enter password for {0.device_presentation}: ', device)
try:
return password_dialog(device.id_uuid, 'udiskie', text, options)
except RuntimeError:
return None | [
"Get the password to unlock a device from GUI."
] |
Please provide a description of the function:async def get_password_tty(device, options):
# TODO: make this a TRUE async
text = _('Enter password for {0.device_presentation}: ', device)
try:
return getpass.getpass(text)
except EOFError:
print("")
return None | [
"Get the password to unlock a device from terminal."
] |
Please provide a description of the function:def password(password_command):
gui = lambda: has_Gtk() and get_password_gui
tty = lambda: sys.stdin.isatty() and get_password_tty
if password_command == 'builtin:gui':
return gui() or tty()
elif password_command == 'builtin:tty':
return ... | [
"Create a password prompt function."
] |
Please provide a description of the function:def browser(browser_name='xdg-open'):
if not browser_name:
return None
argv = shlex.split(browser_name)
executable = find_executable(argv[0])
if executable is None:
# Why not raise an exception? -I think it is more convenient (for
... | [
"Create a browse-directory function."
] |
Please provide a description of the function:def notify_command(command_format, mounter):
udisks = mounter.udisks
for event in ['device_mounted', 'device_unmounted',
'device_locked', 'device_unlocked',
'device_added', 'device_removed',
'job_failed']:
... | [
"\n Command notification tool.\n\n This works similar to Notify, but will issue command instead of showing\n the notifications on the desktop. This can then be used to react to events\n from shell scripts.\n\n The command can contain modern pythonic format placeholders like:\n {device_file}. The f... |
Please provide a description of the function:def make_mo(self, po_filename, mo_filename):
try:
call(['msgfmt', po_filename, '-o', mo_filename])
except OSError as e:
# ignore failures since i18n support is optional:
logging.warning(e) | [
"Create a machine object (.mo) from a portable object (.po) file."
] |
Please provide a description of the function:def run(self):
orig_install.run(self)
try:
call(['gtk-update-icon-cache', 'share/icons/hicolor'])
except OSError as e:
# ignore failures since the tray icon is an optional component:
logging.warning(e) | [
"\n Perform old-style (distutils) install, then update GTK icon cache.\n\n Extends ``distutils.command.install.install.run``.\n "
] |
Please provide a description of the function:async def exec_subprocess(argv):
future = Future()
process = Gio.Subprocess.new(
argv,
Gio.SubprocessFlags.STDOUT_PIPE |
Gio.SubprocessFlags.STDIN_INHERIT)
stdin_buf = None
cancellable = None
process.communicate_utf8_async(
... | [
"\n An Future task that represents a subprocess. If successful, the task's\n result is set to the collected STDOUT of the subprocess.\n\n :raises subprocess.CalledProcessError: if the subprocess returns a non-zero\n exit code\n "
] |
Please provide a description of the function:def set_exception(self, exception):
was_handled = self._finish(self.errbacks, exception)
if not was_handled:
traceback.print_exception(
type(exception), exception, exception.__traceback__) | [
"Signal unsuccessful completion."
] |
Please provide a description of the function:def _subtask_result(self, idx, value):
self._results[idx] = value
if len(self._results) == self._num_tasks:
self.set_result([
self._results[i]
for i in range(self._num_tasks)
]) | [
"Receive a result from a single subtask."
] |
Please provide a description of the function:def _subtask_error(self, idx, error):
self.set_exception(error)
self.errbacks.clear() | [
"Receive an error from a single subtask."
] |
Please provide a description of the function:def _resume(self, func, *args):
try:
value = func(*args)
except StopIteration:
self._generator.close()
self.set_result(None)
except Exception as e:
self._generator.close()
self.set_e... | [
"Resume the coroutine by throwing a value or returning a value from\n the ``await`` and handle further awaits."
] |
Please provide a description of the function:def parse_commit_message(message: str) -> Tuple[int, str, Optional[str], Tuple[str, str, str]]:
parsed = re_parser.match(message)
if not parsed:
raise UnknownCommitMessageStyleError(
'Unable to parse the given commit message: {0}'.format(me... | [
"\n Parses a commit message according to the 1.0 version of python-semantic-release. It expects\n a tag of some sort in the commit message and will use the rest of the first line as changelog\n content.\n\n :param message: A string of a commit message.\n :raises UnknownCommitMessageStyleError: If it ... |
Please provide a description of the function:def checker(func: Callable) -> Callable:
def func_wrapper(*args, **kwargs):
try:
func(*args, **kwargs)
return True
except AssertionError:
raise CiVerificationError(
'The verification check for the ... | [
"\n A decorator that will convert AssertionErrors into\n CiVerificationError.\n\n :param func: A function that will raise AssertionError\n :return: The given function wrapped to raise a CiVerificationError on AssertionError\n "
] |
Please provide a description of the function:def travis(branch: str):
assert os.environ.get('TRAVIS_BRANCH') == branch
assert os.environ.get('TRAVIS_PULL_REQUEST') == 'false' | [
"\n Performs necessary checks to ensure that the travis build is one\n that should create releases.\n\n :param branch: The branch the environment should be running against.\n "
] |
Please provide a description of the function:def semaphore(branch: str):
assert os.environ.get('BRANCH_NAME') == branch
assert os.environ.get('PULL_REQUEST_NUMBER') is None
assert os.environ.get('SEMAPHORE_THREAD_RESULT') != 'failed' | [
"\n Performs necessary checks to ensure that the semaphore build is successful,\n on the correct branch and not a pull-request.\n\n :param branch: The branch the environment should be running against.\n "
] |
Please provide a description of the function:def frigg(branch: str):
assert os.environ.get('FRIGG_BUILD_BRANCH') == branch
assert not os.environ.get('FRIGG_PULL_REQUEST') | [
"\n Performs necessary checks to ensure that the frigg build is one\n that should create releases.\n\n :param branch: The branch the environment should be running against.\n "
] |
Please provide a description of the function:def circle(branch: str):
assert os.environ.get('CIRCLE_BRANCH') == branch
assert not os.environ.get('CI_PULL_REQUEST') | [
"\n Performs necessary checks to ensure that the circle build is one\n that should create releases.\n\n :param branch: The branch the environment should be running against.\n "
] |
Please provide a description of the function:def bitbucket(branch: str):
assert os.environ.get('BITBUCKET_BRANCH') == branch
assert not os.environ.get('BITBUCKET_PR_ID') | [
"\n Performs necessary checks to ensure that the bitbucket build is one\n that should create releases.\n\n :param branch: The branch the environment should be running against.\n "
] |
Please provide a description of the function:def check(branch: str = 'master'):
if os.environ.get('TRAVIS') == 'true':
travis(branch)
elif os.environ.get('SEMAPHORE') == 'true':
semaphore(branch)
elif os.environ.get('FRIGG') == 'true':
frigg(branch)
elif os.environ.get('CIRC... | [
"\n Detects the current CI environment, if any, and performs necessary\n environment checks.\n\n :param branch: The branch that should be the current branch.\n "
] |
Please provide a description of the function:def parse_commit_message(message: str) -> Tuple[int, str, str, Tuple[str, str, str]]:
parsed = re_parser.match(message)
if not parsed:
raise UnknownCommitMessageStyleError(
'Unable to parse the given commit message: {}'.format(message)
... | [
"\n Parses a commit message according to the angular commit guidelines specification.\n\n :param message: A string of a commit message.\n :return: A tuple of (level to bump, type of change, scope of change, a tuple with descriptions)\n :raises UnknownCommitMessageStyleError: if regular expression matchi... |
Please provide a description of the function:def parse_text_block(text: str) -> Tuple[str, str]:
body, footer = '', ''
if text:
body = text.split('\n\n')[0]
if len(text.split('\n\n')) == 2:
footer = text.split('\n\n')[1]
return body.replace('\n', ' '), footer.replace('\n', ... | [
"\n This will take a text block and return a tuple with body and footer,\n where footer is defined as the last paragraph.\n\n :param text: The text string to be divided.\n :return: A tuple with body and footer,\n where footer is defined as the last paragraph.\n "
] |
Please provide a description of the function:def upload_to_pypi(
dists: str = 'sdist bdist_wheel',
username: str = None,
password: str = None,
skip_existing: bool = False
):
if username is None or password is None or username == "" or password == "":
raise ImproperConfig... | [
"Creates the wheel and uploads to pypi with twine.\n\n :param dists: The dists string passed to setup.py. Default: 'bdist_wheel'\n :param username: PyPI account username string\n :param password: PyPI account password string\n :param skip_existing: Continue uploading files if one already exists. (Only v... |
Please provide a description of the function:def get_commit_log(from_rev=None):
check_repo()
rev = None
if from_rev:
rev = '...{from_rev}'.format(from_rev=from_rev)
for commit in repo.iter_commits(rev):
yield (commit.hexsha, commit.message) | [
"\n Yields all commit messages from last to first.\n "
] |
Please provide a description of the function:def get_last_version(skip_tags=None) -> Optional[str]:
debug('get_last_version skip_tags=', skip_tags)
check_repo()
skip_tags = skip_tags or []
def version_finder(tag):
if isinstance(tag.commit, TagObject):
return tag.tag.tagged_dat... | [
"\n Return last version from repo tags.\n\n :return: A string contains version number.\n "
] |
Please provide a description of the function:def get_version_from_tag(tag_name: str) -> Optional[str]:
debug('get_version_from_tag({})'.format(tag_name))
check_repo()
for i in repo.tags:
if i.name == tag_name:
return i.commit.hexsha
return None | [
"Get git hash from tag\n\n :param tag_name: Name of the git tag (i.e. 'v1.0.0')\n :return: sha1 hash of the commit\n "
] |
Please provide a description of the function:def get_repository_owner_and_name() -> Tuple[str, str]:
check_repo()
url = repo.remote('origin').url
parts = re.search(r'([^/:]+)/([^/]+).git$', url)
if not parts:
raise HvcsRepoParseError
debug('get_repository_owner_and_name', parts)
re... | [
"\n Checks the origin remote to get the owner and name of the remote repository.\n\n :return: A tuple of the owner and name.\n "
] |
Please provide a description of the function:def commit_new_version(version: str):
check_repo()
commit_message = config.get('semantic_release', 'commit_message')
message = '{0}\n\n{1}'.format(version, commit_message)
repo.git.add(config.get('semantic_release', 'version_variable').split(':')[0])
... | [
"\n Commits the file containing the version number variable with the version number as the commit\n message.\n\n :param version: The version number to be used in the commit message.\n "
] |
Please provide a description of the function:def tag_new_version(version: str):
check_repo()
return repo.git.tag('-a', 'v{0}'.format(version), m='v{0}'.format(version)) | [
"\n Creates a new tag with the version number prefixed with v.\n\n :param version: The version number used in the tag as a string.\n "
] |
Please provide a description of the function:def push_new_version(gh_token: str = None, owner: str = None, name: str = None):
check_repo()
server = 'origin'
if gh_token:
server = 'https://{token}@{repo}'.format(
token=gh_token,
repo='github.com/{owner}/{name}.git'.forma... | [
"\n Runs git push and git push --tags.\n\n :param gh_token: Github token used to push.\n :param owner: Organisation or user that owns the repository.\n :param name: Name of repository.\n :raises GitError: if GitCommandError is raised\n "
] |
Please provide a description of the function:def current_commit_parser() -> Callable:
try:
parts = config.get('semantic_release', 'commit_parser').split('.')
module = '.'.join(parts[:-1])
return getattr(importlib.import_module(module), parts[-1])
except (ImportError, AttributeError... | [
"Current commit parser\n\n :raises ImproperConfigurationError: if ImportError or AttributeError is raised\n "
] |
Please provide a description of the function:def get_current_version_by_config_file() -> str:
debug('get_current_version_by_config_file')
filename, variable = config.get('semantic_release',
'version_variable').split(':')
variable = variable.strip()
debug(filename... | [
"\n Get current version from the version variable defined in the configuration\n\n :return: A string with the current version number\n :raises ImproperConfigurationError: if version variable cannot be parsed\n "
] |
Please provide a description of the function:def get_new_version(current_version: str, level_bump: str) -> str:
debug('get_new_version("{}", "{}")'.format(current_version, level_bump))
if not level_bump:
return current_version
return getattr(semver, 'bump_{0}'.format(level_bump))(current_versio... | [
"\n Calculates the next version based on the given bump level with semver.\n\n :param current_version: The version the package has now.\n :param level_bump: The level of the version number that should be bumped. Should be a `'major'`,\n `'minor'` or `'patch'`.\n :return: A string w... |
Please provide a description of the function:def get_previous_version(version: str) -> Optional[str]:
debug('get_previous_version')
found_version = False
for commit_hash, commit_message in get_commit_log():
debug('checking commit {}'.format(commit_hash))
if version in commit_message:
... | [
"\n Returns the version prior to the given version.\n\n :param version: A string with the version number.\n :return: A string with the previous version number\n "
] |
Please provide a description of the function:def replace_version_string(content, variable, new_version):
return re.sub(
r'({0} ?= ?["\'])\d+\.\d+(?:\.\d+)?(["\'])'.format(variable),
r'\g<1>{0}\g<2>'.format(new_version),
content
) | [
"\n Given the content of a file, finds the version string and updates it.\n\n :param content: The file contents\n :param variable: The version variable name as a string\n :param new_version: The new version number as a string\n :return: A string with the updated version number\n "
] |
Please provide a description of the function:def set_new_version(new_version: str) -> bool:
filename, variable = config.get(
'semantic_release', 'version_variable').split(':')
variable = variable.strip()
with open(filename, mode='r') as fr:
content = fr.read()
content = replace_ver... | [
"\n Replaces the version number in the correct place and writes the changed file to disk.\n\n :param new_version: The new version number as a string.\n :return: `True` if it succeeded.\n "
] |
Please provide a description of the function:def evaluate_version_bump(current_version: str, force: str = None) -> Optional[str]:
debug('evaluate_version_bump("{}", "{}")'.format(current_version, force))
if force:
return force
bump = None
changes = []
commit_count = 0
for _hash, ... | [
"\n Reads git log since last release to find out if should be a major, minor or patch release.\n\n :param current_version: A string with the current version number.\n :param force: A string with the bump level that should be forced.\n :return: A string with either major, minor or patch if there should b... |
Please provide a description of the function:def generate_changelog(from_version: str, to_version: str = None) -> dict:
debug('generate_changelog("{}", "{}")'.format(from_version, to_version))
changes: dict = {'feature': [], 'fix': [],
'documentation': [], 'refactor': [], 'breaking': [... | [
"\n Generates a changelog for the given version.\n\n :param from_version: The last version not in the changelog. The changelog\n will be generated from the commit after this one.\n :param to_version: The last version in the changelog.\n :return: a dict with different changelog se... |
Please provide a description of the function:def markdown_changelog(version: str, changelog: dict, header: bool = False) -> str:
debug('markdown_changelog(version="{}", header={}, changelog=...)'.format(version, header))
output = ''
if header:
output += '## v{0}\n'.format(version)
for sect... | [
"\n Generates a markdown version of the changelog. Takes a parsed changelog dict from\n generate_changelog.\n\n :param version: A string with the version number.\n :param changelog: A dict from generate_changelog.\n :param header: A boolean that decides whether a header should be included or not.\n ... |
Please provide a description of the function:def get_hvcs() -> Base:
hvcs = config.get('semantic_release', 'hvcs')
debug('get_hvcs: hvcs=', hvcs)
try:
return globals()[hvcs.capitalize()]
except KeyError:
raise ImproperConfigurationError('"{0}" is not a valid option for hvcs.') | [
"Get HVCS helper class\n\n :raises ImproperConfigurationError: if the hvcs option provided is not valid\n "
] |
Please provide a description of the function:def check_build_status(owner: str, repository: str, ref: str) -> bool:
debug('check_build_status')
return get_hvcs().check_build_status(owner, repository, ref) | [
"\n Checks the build status of a commit on the api from your hosted version control provider.\n\n :param owner: The owner of the repository\n :param repository: The repository name\n :param ref: Commit or branch reference\n :return: A boolean with the build status\n "
] |
Please provide a description of the function:def post_changelog(owner: str, repository: str, version: str, changelog: str) -> Tuple[bool, dict]:
debug('post_changelog(owner={}, repository={}, version={})'.format(owner, repository, version))
return get_hvcs().post_release_changelog(owner, repository, versio... | [
"\n Posts the changelog to the current hvcs release API\n\n :param owner: The owner of the repository\n :param repository: The repository name\n :param version: A string with the new version\n :param changelog: A string with the changelog in correct format\n :return: a tuple with success status an... |
Please provide a description of the function:def check_build_status(owner: str, repo: str, ref: str) -> bool:
url = '{domain}/repos/{owner}/{repo}/commits/{ref}/status'
response = requests.get(
url.format(domain=Github.DOMAIN, owner=owner, repo=repo, ref=ref)
)
if de... | [
"Check build status\n\n :param owner: The owner namespace of the repository\n :param repo: The repository name\n :param ref: The sha1 hash of the commit ref\n\n :return: Was the build status success?\n "
] |
Please provide a description of the function:def post_release_changelog(
cls, owner: str, repo: str, version: str, changelog: str) -> Tuple[bool, dict]:
url = '{domain}/repos/{owner}/{repo}/releases?access_token={token}'
tag = 'v{0}'.format(version)
debug_gh('listing release... | [
"Check build status\n\n :param owner: The owner namespace of the repository\n :param repo: The repository name\n :param version: The version number\n :param changelog: The release notes for this version\n\n :return: The status of the request and the response json\n "
] |
Please provide a description of the function:def version(**kwargs):
retry = kwargs.get("retry")
if retry:
click.echo('Retrying publication of the same version...')
else:
click.echo('Creating new version..')
try:
current_version = get_current_version()
except GitError as... | [
"\n Detects the new version according to git log and semver. Writes the new version\n number and commits it, unless the noop-option is True.\n "
] |
Please provide a description of the function:def changelog(**kwargs):
current_version = get_current_version()
debug('changelog got current_version', current_version)
if current_version is None:
raise ImproperConfigurationError(
"Unable to get the current version. "
"Mak... | [
"\n Generates the changelog since the last release.\n :raises ImproperConfigurationError: if there is no current version\n "
] |
Please provide a description of the function:def publish(**kwargs):
current_version = get_current_version()
click.echo('Current version: {0}'.format(current_version))
retry = kwargs.get("retry")
debug('publish: retry=', retry)
if retry:
# The "new" version will actually be the current ... | [
"\n Runs the version task before pushing to git and uploading to pypi.\n "
] |
Please provide a description of the function:def spell_check(request):
try:
if not enchant:
raise RuntimeError("install pyenchant for spellchecker functionality")
raw = force_text(request.body)
input = json.loads(raw)
id = input['id']
method = input['method'... | [
"\n Returns a HttpResponse that implements the TinyMCE spellchecker protocol.\n "
] |
Please provide a description of the function:def flatpages_link_list(request):
from django.contrib.flatpages.models import FlatPage
link_list = [(page.title, page.url) for page in FlatPage.objects.all()]
return render_to_link_list(link_list) | [
"\n Returns a HttpResponse whose content is a Javascript file representing a\n list of links to flatpages.\n "
] |
Please provide a description of the function:def _interactive_loop(self, sin: IO[str], sout: IO[str]) -> None:
self._sin = sin
self._sout = sout
tasknum = len(all_tasks(loop=self._loop))
s = '' if tasknum == 1 else 's'
self._sout.write(self.intro.format(tasknum=tasknum, ... | [
"Main interactive loop of the monitor"
] |
Please provide a description of the function:def do_help(self, *cmd_names: str) -> None:
def _h(cmd: str, template: str) -> None:
try:
func = getattr(self, cmd)
except AttributeError:
self._sout.write('No such command: {}\n'.format(cmd))
... | [
"Show help for command name\n\n Any number of command names may be given to help, and the long help\n text for all of them will be shown.\n "
] |
Please provide a description of the function:def do_ps(self) -> None:
headers = ('Task ID', 'State', 'Task')
table_data = [headers]
for task in sorted(all_tasks(loop=self._loop), key=id):
taskid = str(id(task))
if task:
t = '\n'.join(wrap(str(task... | [
"Show task table"
] |
Please provide a description of the function:def do_where(self, taskid: int) -> None:
task = task_by_id(taskid, self._loop)
if task:
self._sout.write(_format_stack(task))
self._sout.write('\n')
else:
self._sout.write('No task %d\n' % taskid) | [
"Show stack frames for a task"
] |
Please provide a description of the function:def do_signal(self, signame: str) -> None:
if hasattr(signal, signame):
os.kill(os.getpid(), getattr(signal, signame))
else:
self._sout.write('Unknown signal %s\n' % signame) | [
"Send a Unix signal"
] |
Please provide a description of the function:def do_stacktrace(self) -> None:
frame = sys._current_frames()[self._event_loop_thread_id]
traceback.print_stack(frame, file=self._sout) | [
"Print a stack trace from the event loop thread"
] |
Please provide a description of the function:def do_cancel(self, taskid: int) -> None:
task = task_by_id(taskid, self._loop)
if task:
fut = asyncio.run_coroutine_threadsafe(
cancel_task(task), loop=self._loop)
fut.result(timeout=3)
self._sout.... | [
"Cancel an indicated task"
] |
Please provide a description of the function:def do_console(self) -> None:
if not self._console_enabled:
self._sout.write('Python console disabled for this sessiong\n')
self._sout.flush()
return
h, p = self._host, self._console_port
log.info('Startin... | [
"Switch to async Python REPL"
] |
Please provide a description of the function:def do_hello(self, sin, sout, name=None):
name = '' if name is None else '/' + name
r = requests.get('http://localhost:8090/hello' + name)
sout.write(r.text + '\n') | [
"Using the /hello GET interface\n\n There is one optional argument, \"name\". This name argument must be\n provided with proper URL excape codes, like %20 for spaces.\n "
] |
Please provide a description of the function:def alt_names(names: str) -> Callable[..., Any]:
names_split = names.split()
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
func.alt_names = names_split # type: ignore
return func
return decorator | [
"Add alternative names to you custom commands.\n\n `names` is a single string with a space separated list of aliases for the\n decorated command.\n "
] |
Please provide a description of the function:def set_interactive_policy(*, locals=None, banner=None, serve=None,
prompt_control=None):
policy = InteractiveEventLoopPolicy(
locals=locals,
banner=banner,
serve=serve,
prompt_control=prompt_control)
as... | [
"Use an interactive event loop by default."
] |
Please provide a description of the function:def run_console(*, locals=None, banner=None, serve=None, prompt_control=None):
loop = InteractiveEventLoop(
locals=locals,
banner=banner,
serve=serve,
prompt_control=prompt_control)
asyncio.set_event_loop(loop)
try:
lo... | [
"Run the interactive event loop."
] |
Please provide a description of the function:def make_arg(key, annotation=None):
arg = ast.arg(key, annotation)
arg.lineno, arg.col_offset = 0, 0
return arg | [
"Make an ast function argument."
] |
Please provide a description of the function:def exec_result(obj, local, stream):
local['_'] = obj
if obj is not None:
print(repr(obj), file=stream) | [
"Reproduce default exec behavior (print and builtins._)"
] |
Please provide a description of the function:def make_tree(statement, filename="<aexec>", symbol="single", local={}):
# Create tree
tree = ast.parse(CORO_CODE, filename, symbol)
# Check expression statement
if isinstance(statement, ast.Expr):
tree.body[0].body[0].value.elts[0] = statement.v... | [
"Helper for *aexec*."
] |
Please provide a description of the function:def make_coroutine_from_tree(tree, filename="<aexec>", symbol="single",
local={}):
dct = {}
tree.body[0].args.args = list(map(make_arg, local))
exec(compile(tree, filename, symbol), dct)
return asyncio.coroutine(dct[CORO_NAME... | [
"Make a coroutine from a tree structure."
] |
Please provide a description of the function:def compile_for_aexec(source, filename="<aexec>", mode="single",
dont_imply_dedent=False, local={}):
flags = ast.PyCF_ONLY_AST
if dont_imply_dedent:
flags |= codeop.PyCF_DONT_IMPLY_DEDENT
if compat.PY35:
# Avoid a syntax... | [
"Return a list of (coroutine object, abstract base tree)."
] |
Please provide a description of the function:def aexec(source, local=None, stream=None):
if local is None:
local = {}
if isinstance(source, str):
source = compile_for_aexec(source)
for tree in source:
coro = make_coroutine_from_tree(tree, local=local)
result, new_local =... | [
"Asynchronous equivalent to *exec*.\n\n Support the *yield from* syntax.\n "
] |
Please provide a description of the function:def ainput(prompt='', *, streams=None, use_stderr=False, loop=None):
# Get standard streams
if streams is None:
streams = yield from get_standard_streams(
use_stderr=use_stderr, loop=loop)
reader, writer = streams
# Write prompt
w... | [
"Asynchronous equivalent to *input*."
] |
Please provide a description of the function:def aprint(*values, sep=None, end='\n', flush=False, streams=None, use_stderr=False, loop=None):
# Get standard streams
if streams is None:
streams = yield from get_standard_streams(
use_stderr=use_stderr, loop=loop)
_, writer = streams
... | [
"Asynchronous equivalent to *print*."
] |
Please provide a description of the function:def feature_needs(*feas):
fmap = {'stateful_files': 22,
'stateful_dirs': 23,
'stateful_io': ('stateful_files', 'stateful_dirs'),
'stateful_files_keep_cache': 23,
'stateful_files_direct_io': 23,
'keep_c... | [
"\n Get info about the FUSE API version needed for the support of some features.\n\n This function takes a variable number of feature patterns.\n\n A feature pattern is either:\n\n - an integer (directly referring to a FUSE API version number)\n - a built-in feature specifier string (meaning define... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.