repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
coldfix/udiskie | udiskie/notify.py | Notify.device_removed | def device_removed(self, device):
"""Show removal notification for specified device object."""
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_notifi... | python | def device_removed(self, device):
"""Show removal notification for specified device object."""
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_notifi... | [
"def",
"device_removed",
"(",
"self",
",",
"device",
")",
":",
"if",
"not",
"self",
".",
"_mounter",
".",
"is_handleable",
"(",
"device",
")",
":",
"return",
"device_file",
"=",
"device",
".",
"device_presentation",
"if",
"(",
"device",
".",
"is_drive",
"o... | Show removal notification for specified device object. | [
"Show",
"removal",
"notification",
"for",
"specified",
"device",
"object",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/notify.py#L146-L156 | train |
coldfix/udiskie | udiskie/notify.py | Notify.job_failed | def job_failed(self, device, action, message):
"""Show 'Job failed' notification with 'Retry' button."""
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}... | python | def job_failed(self, device, action, message):
"""Show 'Job failed' notification with 'Retry' button."""
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}... | [
"def",
"job_failed",
"(",
"self",
",",
"device",
",",
"action",
",",
"message",
")",
":",
"if",
"not",
"self",
".",
"_mounter",
".",
"is_handleable",
"(",
"device",
")",
":",
"return",
"device_file",
"=",
"device",
".",
"device_presentation",
"or",
"device... | Show 'Job failed' notification with 'Retry' button. | [
"Show",
"Job",
"failed",
"notification",
"with",
"Retry",
"button",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/notify.py#L158-L177 | train |
coldfix/udiskie | udiskie/notify.py | Notify._show_notification | def _show_notification(self,
event, summary, message, icon,
*actions):
"""
Show a notification.
:param str event: event name
:param str summary: notification title
:param str message: notification body
:param str icon... | python | def _show_notification(self,
event, summary, message, icon,
*actions):
"""
Show a notification.
:param str event: event name
:param str summary: notification title
:param str message: notification body
:param str icon... | [
"def",
"_show_notification",
"(",
"self",
",",
"event",
",",
"summary",
",",
"message",
",",
"icon",
",",
"*",
"actions",
")",
":",
"notification",
"=",
"self",
".",
"_notify",
"(",
"summary",
",",
"message",
",",
"icon",
")",
"timeout",
"=",
"self",
"... | Show a notification.
:param str event: event name
:param str summary: notification title
:param str message: notification body
:param str icon: icon name
:param actions: each item is a tuple with parameters for _add_action | [
"Show",
"a",
"notification",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/notify.py#L179-L207 | train |
coldfix/udiskie | udiskie/notify.py | Notify._add_action | def _add_action(self, notification, action, label, callback, *args):
"""
Show an action button button in mount notifications.
Note, this only works with some libnotify services.
"""
on_action_click = run_bg(lambda *_: callback(*args))
try:
# this is the corre... | python | def _add_action(self, notification, action, label, callback, *args):
"""
Show an action button button in mount notifications.
Note, this only works with some libnotify services.
"""
on_action_click = run_bg(lambda *_: callback(*args))
try:
# this is the corre... | [
"def",
"_add_action",
"(",
"self",
",",
"notification",
",",
"action",
",",
"label",
",",
"callback",
",",
"*",
"args",
")",
":",
"on_action_click",
"=",
"run_bg",
"(",
"lambda",
"*",
"_",
":",
"callback",
"(",
"*",
"args",
")",
")",
"try",
":",
"# t... | Show an action button button in mount notifications.
Note, this only works with some libnotify services. | [
"Show",
"an",
"action",
"button",
"button",
"in",
"mount",
"notifications",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/notify.py#L209-L230 | train |
coldfix/udiskie | udiskie/notify.py | Notify._action_enabled | def _action_enabled(self, event, action):
"""Check if an action for a notification is enabled."""
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 | python | def _action_enabled(self, event, action):
"""Check if an action for a notification is enabled."""
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 | [
"def",
"_action_enabled",
"(",
"self",
",",
"event",
",",
"action",
")",
":",
"event_actions",
"=",
"self",
".",
"_aconfig",
".",
"get",
"(",
"event",
")",
"if",
"event_actions",
"is",
"None",
":",
"return",
"True",
"if",
"event_actions",
"is",
"False",
... | Check if an action for a notification is enabled. | [
"Check",
"if",
"an",
"action",
"for",
"a",
"notification",
"is",
"enabled",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/notify.py#L240-L247 | train |
coldfix/udiskie | udiskie/notify.py | Notify._has_actions | def _has_actions(self, event):
"""Check if a notification type has any enabled actions."""
event_actions = self._aconfig.get(event)
return event_actions is None or bool(event_actions) | python | def _has_actions(self, event):
"""Check if a notification type has any enabled actions."""
event_actions = self._aconfig.get(event)
return event_actions is None or bool(event_actions) | [
"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. | [
"Check",
"if",
"a",
"notification",
"type",
"has",
"any",
"enabled",
"actions",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/notify.py#L249-L252 | train |
coldfix/udiskie | udiskie/config.py | DeviceFilter.match | def match(self, device):
"""Check if the device object matches this filter."""
return all(match_value(getattr(device, k), v)
for k, v in self._match.items()) | python | def match(self, device):
"""Check if the device object matches this filter."""
return all(match_value(getattr(device, k), v)
for k, v in self._match.items()) | [
"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. | [
"Check",
"if",
"the",
"device",
"object",
"matches",
"this",
"filter",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/config.py#L118-L121 | train |
coldfix/udiskie | udiskie/config.py | DeviceFilter.value | def value(self, kind, device):
"""
Get the value for the device object associated with this filter.
If :meth:`match` is False for the device, the return value of this
method is undefined.
"""
self._log.debug(_('{0}(match={1!r}, {2}={3!r}) used for {4}',
... | python | def value(self, kind, device):
"""
Get the value for the device object associated with this filter.
If :meth:`match` is False for the device, the return value of this
method is undefined.
"""
self._log.debug(_('{0}(match={1!r}, {2}={3!r}) used for {4}',
... | [
"def",
"value",
"(",
"self",
",",
"kind",
",",
"device",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"_",
"(",
"'{0}(match={1!r}, {2}={3!r}) used for {4}'",
",",
"self",
".",
"__class__",
".",
"__name__",
",",
"self",
".",
"_match",
",",
"kind",
",... | Get the value for the device object associated with this filter.
If :meth:`match` is False for the device, the return value of this
method is undefined. | [
"Get",
"the",
"value",
"for",
"the",
"device",
"object",
"associated",
"with",
"this",
"filter",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/config.py#L126-L138 | train |
coldfix/udiskie | udiskie/config.py | Config.default_pathes | def default_pathes(cls):
"""Return the default config file pathes as a list."""
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... | python | def default_pathes(cls):
"""Return the default config file pathes as a list."""
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... | [
"def",
"default_pathes",
"(",
"cls",
")",
":",
"try",
":",
"from",
"xdg",
".",
"BaseDirectory",
"import",
"xdg_config_home",
"as",
"config_home",
"except",
"ImportError",
":",
"config_home",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.config'",
")",
... | Return the default config file pathes as a list. | [
"Return",
"the",
"default",
"config",
"file",
"pathes",
"as",
"a",
"list",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/config.py#L186-L193 | train |
coldfix/udiskie | udiskie/config.py | Config.from_file | def from_file(cls, path=None):
"""
Read YAML config file. Returns Config object.
:raises IOError: if the path does not exist
"""
# None => use default
if path is None:
for path in cls.default_pathes():
try:
return cls.from_... | python | def from_file(cls, path=None):
"""
Read YAML config file. Returns Config object.
:raises IOError: if the path does not exist
"""
# None => use default
if path is None:
for path in cls.default_pathes():
try:
return cls.from_... | [
"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",
... | Read YAML config file. Returns Config object.
:raises IOError: if the path does not exist | [
"Read",
"YAML",
"config",
"file",
".",
"Returns",
"Config",
"object",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/config.py#L196-L222 | train |
coldfix/udiskie | udiskie/tray.py | Icons.get_icon_name | def get_icon_name(self, icon_id: str) -> str:
"""Lookup the system icon name from udisie-internal id."""
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' | python | def get_icon_name(self, icon_id: str) -> str:
"""Lookup the system icon name from udisie-internal id."""
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' | [
"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_the... | Lookup the system icon name from udisie-internal id. | [
"Lookup",
"the",
"system",
"icon",
"name",
"from",
"udisie",
"-",
"internal",
"id",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L73-L79 | train |
coldfix/udiskie | udiskie/tray.py | Icons.get_icon | def get_icon(self, icon_id: str, size: "Gtk.IconSize") -> "Gtk.Image":
"""Load Gtk.Image from udiskie-internal id."""
return Gtk.Image.new_from_gicon(self.get_gicon(icon_id), size) | python | def get_icon(self, icon_id: str, size: "Gtk.IconSize") -> "Gtk.Image":
"""Load Gtk.Image from udiskie-internal id."""
return Gtk.Image.new_from_gicon(self.get_gicon(icon_id), size) | [
"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. | [
"Load",
"Gtk",
".",
"Image",
"from",
"udiskie",
"-",
"internal",
"id",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L81-L83 | train |
coldfix/udiskie | udiskie/tray.py | Icons.get_gicon | def get_gicon(self, icon_id: str) -> "Gio.Icon":
"""Lookup Gio.Icon from udiskie-internal id."""
return Gio.ThemedIcon.new_from_names(self._icon_names[icon_id]) | python | def get_gicon(self, icon_id: str) -> "Gio.Icon":
"""Lookup Gio.Icon from udiskie-internal id."""
return Gio.ThemedIcon.new_from_names(self._icon_names[icon_id]) | [
"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. | [
"Lookup",
"Gio",
".",
"Icon",
"from",
"udiskie",
"-",
"internal",
"id",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L85-L87 | train |
coldfix/udiskie | udiskie/tray.py | UdiskieMenu._insert_options | def _insert_options(self, menu):
"""Add configuration options to 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())
))
... | python | def _insert_options(self, menu):
"""Add configuration options to 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())
))
... | [
"def",
"_insert_options",
"(",
"self",
",",
"menu",
")",
":",
"menu",
".",
"append",
"(",
"Gtk",
".",
"SeparatorMenuItem",
"(",
")",
")",
"menu",
".",
"append",
"(",
"self",
".",
"_menuitem",
"(",
"_",
"(",
"'Mount disc image'",
")",
",",
"self",
".",
... | Add configuration options to menu. | [
"Add",
"configuration",
"options",
"to",
"menu",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L155-L183 | train |
coldfix/udiskie | udiskie/tray.py | UdiskieMenu.detect | def detect(self):
"""Detect all currently known devices. Returns the root device."""
root = self._actions.detect()
prune_empty_node(root, set())
return root | python | def detect(self):
"""Detect all currently known devices. Returns the root device."""
root = self._actions.detect()
prune_empty_node(root, set())
return root | [
"def",
"detect",
"(",
"self",
")",
":",
"root",
"=",
"self",
".",
"_actions",
".",
"detect",
"(",
")",
"prune_empty_node",
"(",
"root",
",",
"set",
"(",
")",
")",
"return",
"root"
] | Detect all currently known devices. Returns the root device. | [
"Detect",
"all",
"currently",
"known",
"devices",
".",
"Returns",
"the",
"root",
"device",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L196-L200 | train |
coldfix/udiskie | udiskie/tray.py | UdiskieMenu._create_menu | def _create_menu(self, items):
"""
Create a menu from the given node.
:param list items: list of menu items
:returns: a new Gtk.Menu object holding all items of the node
"""
menu = Gtk.Menu()
self._create_menu_items(menu, items)
return menu | python | def _create_menu(self, items):
"""
Create a menu from the given node.
:param list items: list of menu items
:returns: a new Gtk.Menu object holding all items of the node
"""
menu = Gtk.Menu()
self._create_menu_items(menu, items)
return menu | [
"def",
"_create_menu",
"(",
"self",
",",
"items",
")",
":",
"menu",
"=",
"Gtk",
".",
"Menu",
"(",
")",
"self",
".",
"_create_menu_items",
"(",
"menu",
",",
"items",
")",
"return",
"menu"
] | Create a menu from the given node.
:param list items: list of menu items
:returns: a new Gtk.Menu object holding all items of the node | [
"Create",
"a",
"menu",
"from",
"the",
"given",
"node",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L202-L211 | train |
coldfix/udiskie | udiskie/tray.py | UdiskieMenu._menuitem | def _menuitem(self, label, icon, onclick, checked=None):
"""
Create a generic menu item.
:param str label: text
:param Gtk.Image icon: icon (may be ``None``)
:param onclick: onclick handler, either a callable or Gtk.Menu
:returns: the menu item object
:rtype: Gtk... | python | def _menuitem(self, label, icon, onclick, checked=None):
"""
Create a generic menu item.
:param str label: text
:param Gtk.Image icon: icon (may be ``None``)
:param onclick: onclick handler, either a callable or Gtk.Menu
:returns: the menu item object
:rtype: Gtk... | [
"def",
"_menuitem",
"(",
"self",
",",
"label",
",",
"icon",
",",
"onclick",
",",
"checked",
"=",
"None",
")",
":",
"if",
"checked",
"is",
"not",
"None",
":",
"item",
"=",
"Gtk",
".",
"CheckMenuItem",
"(",
")",
"item",
".",
"set_active",
"(",
"checked... | Create a generic menu item.
:param str label: text
:param Gtk.Image icon: icon (may be ``None``)
:param onclick: onclick handler, either a callable or Gtk.Menu
:returns: the menu item object
:rtype: Gtk.MenuItem | [
"Create",
"a",
"generic",
"menu",
"item",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L245-L272 | train |
coldfix/udiskie | udiskie/tray.py | UdiskieMenu._prepare_menu | def _prepare_menu(self, node, flat=None):
"""
Prepare the menu hierarchy from the given device tree.
:param Device node: root node of device hierarchy
:returns: menu hierarchy as list
"""
if flat is None:
flat = self.flat
ItemGroup = MenuSection if fl... | python | def _prepare_menu(self, node, flat=None):
"""
Prepare the menu hierarchy from the given device tree.
:param Device node: root node of device hierarchy
:returns: menu hierarchy as list
"""
if flat is None:
flat = self.flat
ItemGroup = MenuSection if fl... | [
"def",
"_prepare_menu",
"(",
"self",
",",
"node",
",",
"flat",
"=",
"None",
")",
":",
"if",
"flat",
"is",
"None",
":",
"flat",
"=",
"self",
".",
"flat",
"ItemGroup",
"=",
"MenuSection",
"if",
"flat",
"else",
"SubMenu",
"return",
"[",
"ItemGroup",
"(",
... | Prepare the menu hierarchy from the given device tree.
:param Device node: root node of device hierarchy
:returns: menu hierarchy as list | [
"Prepare",
"the",
"menu",
"hierarchy",
"from",
"the",
"given",
"device",
"tree",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L274-L288 | train |
coldfix/udiskie | udiskie/tray.py | UdiskieMenu._collapse_device | def _collapse_device(self, node, flat):
"""Collapse device hierarchy into a flat folder."""
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... | python | def _collapse_device(self, node, flat):
"""Collapse device hierarchy into a flat folder."""
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... | [
"def",
"_collapse_device",
"(",
"self",
",",
"node",
",",
"flat",
")",
":",
"items",
"=",
"[",
"item",
"for",
"branch",
"in",
"node",
".",
"branches",
"for",
"item",
"in",
"self",
".",
"_collapse_device",
"(",
"branch",
",",
"flat",
")",
"if",
"item",
... | Collapse device hierarchy into a flat folder. | [
"Collapse",
"device",
"hierarchy",
"into",
"a",
"flat",
"folder",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L290-L306 | train |
coldfix/udiskie | udiskie/tray.py | TrayIcon._create_statusicon | def _create_statusicon(self):
"""Return a new Gtk.StatusIcon."""
statusicon = Gtk.StatusIcon()
statusicon.set_from_gicon(self._icons.get_gicon('media'))
statusicon.set_tooltip_text(_("udiskie"))
return statusicon | python | def _create_statusicon(self):
"""Return a new Gtk.StatusIcon."""
statusicon = Gtk.StatusIcon()
statusicon.set_from_gicon(self._icons.get_gicon('media'))
statusicon.set_tooltip_text(_("udiskie"))
return statusicon | [
"def",
"_create_statusicon",
"(",
"self",
")",
":",
"statusicon",
"=",
"Gtk",
".",
"StatusIcon",
"(",
")",
"statusicon",
".",
"set_from_gicon",
"(",
"self",
".",
"_icons",
".",
"get_gicon",
"(",
"'media'",
")",
")",
"statusicon",
".",
"set_tooltip_text",
"("... | Return a new Gtk.StatusIcon. | [
"Return",
"a",
"new",
"Gtk",
".",
"StatusIcon",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L337-L342 | train |
coldfix/udiskie | udiskie/tray.py | TrayIcon.show | def show(self, show=True):
"""Show or hide the tray icon."""
if show and not self.visible:
self._show()
if not show and self.visible:
self._hide() | python | def show(self, show=True):
"""Show or hide the tray icon."""
if show and not self.visible:
self._show()
if not show and self.visible:
self._hide() | [
"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. | [
"Show",
"or",
"hide",
"the",
"tray",
"icon",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L349-L354 | train |
coldfix/udiskie | udiskie/tray.py | TrayIcon._show | def _show(self):
"""Show the tray icon."""
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("popup-menu", self.... | python | def _show(self):
"""Show the tray icon."""
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("popup-menu", self.... | [
"def",
"_show",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_icon",
":",
"self",
".",
"_icon",
"=",
"self",
".",
"_create_statusicon",
"(",
")",
"widget",
"=",
"self",
".",
"_icon",
"widget",
".",
"set_visible",
"(",
"True",
")",
"self",
".",
... | Show the tray icon. | [
"Show",
"the",
"tray",
"icon",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L356-L363 | train |
coldfix/udiskie | udiskie/tray.py | TrayIcon._hide | def _hide(self):
"""Hide the tray icon."""
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 | python | def _hide(self):
"""Hide the tray icon."""
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 | [
"def",
"_hide",
"(",
"self",
")",
":",
"self",
".",
"_icon",
".",
"set_visible",
"(",
"False",
")",
"self",
".",
"_icon",
".",
"disconnect",
"(",
"self",
".",
"_conn_left",
")",
"self",
".",
"_icon",
".",
"disconnect",
"(",
"self",
".",
"_conn_right",
... | Hide the tray icon. | [
"Hide",
"the",
"tray",
"icon",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L365-L371 | train |
coldfix/udiskie | udiskie/tray.py | TrayIcon.create_context_menu | def create_context_menu(self, extended):
"""Create the context menu."""
menu = Gtk.Menu()
self._menu(menu, extended)
return menu | python | def create_context_menu(self, extended):
"""Create the context menu."""
menu = Gtk.Menu()
self._menu(menu, extended)
return menu | [
"def",
"create_context_menu",
"(",
"self",
",",
"extended",
")",
":",
"menu",
"=",
"Gtk",
".",
"Menu",
"(",
")",
"self",
".",
"_menu",
"(",
"menu",
",",
"extended",
")",
"return",
"menu"
] | Create the context menu. | [
"Create",
"the",
"context",
"menu",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/tray.py#L373-L377 | train |
coldfix/udiskie | udiskie/prompt.py | password_dialog | async def password_dialog(key, title, message, options):
"""
Show a Gtk password dialog.
:returns: the password or ``None`` if the user aborted the operation
:raises RuntimeError: if Gtk can not be properly initialized
"""
with PasswordDialog.create(key, title, message, options) as dialog:
... | python | async def password_dialog(key, title, message, options):
"""
Show a Gtk password dialog.
:returns: the password or ``None`` if the user aborted the operation
:raises RuntimeError: if Gtk can not be properly initialized
"""
with PasswordDialog.create(key, title, message, options) as dialog:
... | [
"async",
"def",
"password_dialog",
"(",
"key",
",",
"title",
",",
"message",
",",
"options",
")",
":",
"with",
"PasswordDialog",
".",
"create",
"(",
"key",
",",
"title",
",",
"message",
",",
"options",
")",
"as",
"dialog",
":",
"response",
"=",
"await",
... | Show a Gtk password dialog.
:returns: the password or ``None`` if the user aborted the operation
:raises RuntimeError: if Gtk can not be properly initialized | [
"Show",
"a",
"Gtk",
"password",
"dialog",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/prompt.py#L136-L148 | train |
coldfix/udiskie | udiskie/prompt.py | get_password_gui | def get_password_gui(device, options):
"""Get the password to unlock a device from GUI."""
text = _('Enter password for {0.device_presentation}: ', device)
try:
return password_dialog(device.id_uuid, 'udiskie', text, options)
except RuntimeError:
return None | python | def get_password_gui(device, options):
"""Get the password to unlock a device from GUI."""
text = _('Enter password for {0.device_presentation}: ', device)
try:
return password_dialog(device.id_uuid, 'udiskie', text, options)
except RuntimeError:
return None | [
"def",
"get_password_gui",
"(",
"device",
",",
"options",
")",
":",
"text",
"=",
"_",
"(",
"'Enter password for {0.device_presentation}: '",
",",
"device",
")",
"try",
":",
"return",
"password_dialog",
"(",
"device",
".",
"id_uuid",
",",
"'udiskie'",
",",
"text"... | Get the password to unlock a device from GUI. | [
"Get",
"the",
"password",
"to",
"unlock",
"a",
"device",
"from",
"GUI",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/prompt.py#L151-L157 | train |
coldfix/udiskie | udiskie/prompt.py | get_password_tty | async def get_password_tty(device, options):
"""Get the password to unlock a device from terminal."""
# TODO: make this a TRUE async
text = _('Enter password for {0.device_presentation}: ', device)
try:
return getpass.getpass(text)
except EOFError:
print("")
return None | python | async def get_password_tty(device, options):
"""Get the password to unlock a device from terminal."""
# TODO: make this a TRUE async
text = _('Enter password for {0.device_presentation}: ', device)
try:
return getpass.getpass(text)
except EOFError:
print("")
return None | [
"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",
... | Get the password to unlock a device from terminal. | [
"Get",
"the",
"password",
"to",
"unlock",
"a",
"device",
"from",
"terminal",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/prompt.py#L160-L168 | train |
coldfix/udiskie | udiskie/prompt.py | password | def password(password_command):
"""Create a password prompt function."""
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 tty()... | python | def password(password_command):
"""Create a password prompt function."""
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 tty()... | [
"def",
"password",
"(",
"password_command",
")",
":",
"gui",
"=",
"lambda",
":",
"has_Gtk",
"(",
")",
"and",
"get_password_gui",
"tty",
"=",
"lambda",
":",
"sys",
".",
"stdin",
".",
"isatty",
"(",
")",
"and",
"get_password_tty",
"if",
"password_command",
"... | Create a password prompt function. | [
"Create",
"a",
"password",
"prompt",
"function",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/prompt.py#L219-L230 | train |
coldfix/udiskie | udiskie/prompt.py | browser | def browser(browser_name='xdg-open'):
"""Create a browse-directory function."""
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
#... | python | def browser(browser_name='xdg-open'):
"""Create a browse-directory function."""
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
#... | [
"def",
"browser",
"(",
"browser_name",
"=",
"'xdg-open'",
")",
":",
"if",
"not",
"browser_name",
":",
"return",
"None",
"argv",
"=",
"shlex",
".",
"split",
"(",
"browser_name",
")",
"executable",
"=",
"find_executable",
"(",
"argv",
"[",
"0",
"]",
")",
"... | Create a browse-directory function. | [
"Create",
"a",
"browse",
"-",
"directory",
"function",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/prompt.py#L233-L253 | train |
coldfix/udiskie | udiskie/prompt.py | notify_command | def notify_command(command_format, mounter):
"""
Command notification tool.
This works similar to Notify, but will issue command instead of showing
the notifications on the desktop. This can then be used to react to events
from shell scripts.
The command can contain modern pythonic format plac... | python | def notify_command(command_format, mounter):
"""
Command notification tool.
This works similar to Notify, but will issue command instead of showing
the notifications on the desktop. This can then be used to react to events
from shell scripts.
The command can contain modern pythonic format plac... | [
"def",
"notify_command",
"(",
"command_format",
",",
"mounter",
")",
":",
"udisks",
"=",
"mounter",
".",
"udisks",
"for",
"event",
"in",
"[",
"'device_mounted'",
",",
"'device_unmounted'",
",",
"'device_locked'",
",",
"'device_unlocked'",
",",
"'device_added'",
",... | Command notification tool.
This works similar to Notify, but will issue command instead of showing
the notifications on the desktop. This can then be used to react to events
from shell scripts.
The command can contain modern pythonic format placeholders like:
{device_file}. The following placehold... | [
"Command",
"notification",
"tool",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/prompt.py#L256-L277 | train |
coldfix/udiskie | udiskie/async_.py | exec_subprocess | async def exec_subprocess(argv):
"""
An Future task that represents a subprocess. If successful, the task's
result is set to the collected STDOUT of the subprocess.
:raises subprocess.CalledProcessError: if the subprocess returns a non-zero
exit code
"""
... | python | async def exec_subprocess(argv):
"""
An Future task that represents a subprocess. If successful, the task's
result is set to the collected STDOUT of the subprocess.
:raises subprocess.CalledProcessError: if the subprocess returns a non-zero
exit code
"""
... | [
"async",
"def",
"exec_subprocess",
"(",
"argv",
")",
":",
"future",
"=",
"Future",
"(",
")",
"process",
"=",
"Gio",
".",
"Subprocess",
".",
"new",
"(",
"argv",
",",
"Gio",
".",
"SubprocessFlags",
".",
"STDOUT_PIPE",
"|",
"Gio",
".",
"SubprocessFlags",
".... | An Future task that represents a subprocess. If successful, the task's
result is set to the collected STDOUT of the subprocess.
:raises subprocess.CalledProcessError: if the subprocess returns a non-zero
exit code | [
"An",
"Future",
"task",
"that",
"represents",
"a",
"subprocess",
".",
"If",
"successful",
"the",
"task",
"s",
"result",
"is",
"set",
"to",
"the",
"collected",
"STDOUT",
"of",
"the",
"subprocess",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/async_.py#L206-L233 | train |
coldfix/udiskie | udiskie/async_.py | Future.set_exception | def set_exception(self, exception):
"""Signal unsuccessful completion."""
was_handled = self._finish(self.errbacks, exception)
if not was_handled:
traceback.print_exception(
type(exception), exception, exception.__traceback__) | python | def set_exception(self, exception):
"""Signal unsuccessful completion."""
was_handled = self._finish(self.errbacks, exception)
if not was_handled:
traceback.print_exception(
type(exception), exception, exception.__traceback__) | [
"def",
"set_exception",
"(",
"self",
",",
"exception",
")",
":",
"was_handled",
"=",
"self",
".",
"_finish",
"(",
"self",
".",
"errbacks",
",",
"exception",
")",
"if",
"not",
"was_handled",
":",
"traceback",
".",
"print_exception",
"(",
"type",
"(",
"excep... | Signal unsuccessful completion. | [
"Signal",
"unsuccessful",
"completion",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/async_.py#L82-L87 | train |
coldfix/udiskie | udiskie/async_.py | gather._subtask_result | def _subtask_result(self, idx, value):
"""Receive a result from a single subtask."""
self._results[idx] = value
if len(self._results) == self._num_tasks:
self.set_result([
self._results[i]
for i in range(self._num_tasks)
]) | python | def _subtask_result(self, idx, value):
"""Receive a result from a single subtask."""
self._results[idx] = value
if len(self._results) == self._num_tasks:
self.set_result([
self._results[i]
for i in range(self._num_tasks)
]) | [
"def",
"_subtask_result",
"(",
"self",
",",
"idx",
",",
"value",
")",
":",
"self",
".",
"_results",
"[",
"idx",
"]",
"=",
"value",
"if",
"len",
"(",
"self",
".",
"_results",
")",
"==",
"self",
".",
"_num_tasks",
":",
"self",
".",
"set_result",
"(",
... | Receive a result from a single subtask. | [
"Receive",
"a",
"result",
"from",
"a",
"single",
"subtask",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/async_.py#L132-L139 | train |
coldfix/udiskie | udiskie/async_.py | gather._subtask_error | def _subtask_error(self, idx, error):
"""Receive an error from a single subtask."""
self.set_exception(error)
self.errbacks.clear() | python | def _subtask_error(self, idx, error):
"""Receive an error from a single subtask."""
self.set_exception(error)
self.errbacks.clear() | [
"def",
"_subtask_error",
"(",
"self",
",",
"idx",
",",
"error",
")",
":",
"self",
".",
"set_exception",
"(",
"error",
")",
"self",
".",
"errbacks",
".",
"clear",
"(",
")"
] | Receive an error from a single subtask. | [
"Receive",
"an",
"error",
"from",
"a",
"single",
"subtask",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/async_.py#L141-L144 | train |
coldfix/udiskie | udiskie/async_.py | Task._resume | def _resume(self, func, *args):
"""Resume the coroutine by throwing a value or returning a value from
the ``await`` and handle further awaits."""
try:
value = func(*args)
except StopIteration:
self._generator.close()
self.set_result(None)
excep... | python | def _resume(self, func, *args):
"""Resume the coroutine by throwing a value or returning a value from
the ``await`` and handle further awaits."""
try:
value = func(*args)
except StopIteration:
self._generator.close()
self.set_result(None)
excep... | [
"def",
"_resume",
"(",
"self",
",",
"func",
",",
"*",
"args",
")",
":",
"try",
":",
"value",
"=",
"func",
"(",
"*",
"args",
")",
"except",
"StopIteration",
":",
"self",
".",
"_generator",
".",
"close",
"(",
")",
"self",
".",
"set_result",
"(",
"Non... | Resume the coroutine by throwing a value or returning a value from
the ``await`` and handle further awaits. | [
"Resume",
"the",
"coroutine",
"by",
"throwing",
"a",
"value",
"or",
"returning",
"a",
"value",
"from",
"the",
"await",
"and",
"handle",
"further",
"awaits",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/async_.py#L185-L199 | train |
relekang/python-semantic-release | semantic_release/history/parser_tag.py | parse_commit_message | def parse_commit_message(message: str) -> Tuple[int, str, Optional[str], Tuple[str, str, str]]:
"""
Parses a commit message according to the 1.0 version of python-semantic-release. It expects
a tag of some sort in the commit message and will use the rest of the first line as changelog
content.
:par... | python | def parse_commit_message(message: str) -> Tuple[int, str, Optional[str], Tuple[str, str, str]]:
"""
Parses a commit message according to the 1.0 version of python-semantic-release. It expects
a tag of some sort in the commit message and will use the rest of the first line as changelog
content.
:par... | [
"def",
"parse_commit_message",
"(",
"message",
":",
"str",
")",
"->",
"Tuple",
"[",
"int",
",",
"str",
",",
"Optional",
"[",
"str",
"]",
",",
"Tuple",
"[",
"str",
",",
"str",
",",
"str",
"]",
"]",
":",
"parsed",
"=",
"re_parser",
".",
"match",
"(",... | Parses a commit message according to the 1.0 version of python-semantic-release. It expects
a tag of some sort in the commit message and will use the rest of the first line as changelog
content.
:param message: A string of a commit message.
:raises UnknownCommitMessageStyleError: If it does not recogni... | [
"Parses",
"a",
"commit",
"message",
"according",
"to",
"the",
"1",
".",
"0",
"version",
"of",
"python",
"-",
"semantic",
"-",
"release",
".",
"It",
"expects",
"a",
"tag",
"of",
"some",
"sort",
"in",
"the",
"commit",
"message",
"and",
"will",
"use",
"th... | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/history/parser_tag.py#L17-L60 | train |
relekang/python-semantic-release | semantic_release/ci_checks.py | checker | def checker(func: Callable) -> Callable:
"""
A decorator that will convert AssertionErrors into
CiVerificationError.
:param func: A function that will raise AssertionError
:return: The given function wrapped to raise a CiVerificationError on AssertionError
"""
def func_wrapper(*args, **kwa... | python | def checker(func: Callable) -> Callable:
"""
A decorator that will convert AssertionErrors into
CiVerificationError.
:param func: A function that will raise AssertionError
:return: The given function wrapped to raise a CiVerificationError on AssertionError
"""
def func_wrapper(*args, **kwa... | [
"def",
"checker",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"def",
"func_wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"True",
"except",
... | A decorator that will convert AssertionErrors into
CiVerificationError.
:param func: A function that will raise AssertionError
:return: The given function wrapped to raise a CiVerificationError on AssertionError | [
"A",
"decorator",
"that",
"will",
"convert",
"AssertionErrors",
"into",
"CiVerificationError",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/ci_checks.py#L9-L27 | train |
relekang/python-semantic-release | semantic_release/ci_checks.py | travis | def travis(branch: str):
"""
Performs necessary checks to ensure that the travis build is one
that should create releases.
:param branch: The branch the environment should be running against.
"""
assert os.environ.get('TRAVIS_BRANCH') == branch
assert os.environ.get('TRAVIS_PULL_REQUEST') =... | python | def travis(branch: str):
"""
Performs necessary checks to ensure that the travis build is one
that should create releases.
:param branch: The branch the environment should be running against.
"""
assert os.environ.get('TRAVIS_BRANCH') == branch
assert os.environ.get('TRAVIS_PULL_REQUEST') =... | [
"def",
"travis",
"(",
"branch",
":",
"str",
")",
":",
"assert",
"os",
".",
"environ",
".",
"get",
"(",
"'TRAVIS_BRANCH'",
")",
"==",
"branch",
"assert",
"os",
".",
"environ",
".",
"get",
"(",
"'TRAVIS_PULL_REQUEST'",
")",
"==",
"'false'"
] | Performs necessary checks to ensure that the travis build is one
that should create releases.
:param branch: The branch the environment should be running against. | [
"Performs",
"necessary",
"checks",
"to",
"ensure",
"that",
"the",
"travis",
"build",
"is",
"one",
"that",
"should",
"create",
"releases",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/ci_checks.py#L31-L39 | train |
relekang/python-semantic-release | semantic_release/ci_checks.py | semaphore | def semaphore(branch: str):
"""
Performs necessary checks to ensure that the semaphore build is successful,
on the correct branch and not a pull-request.
:param branch: The branch the environment should be running against.
"""
assert os.environ.get('BRANCH_NAME') == branch
assert os.enviro... | python | def semaphore(branch: str):
"""
Performs necessary checks to ensure that the semaphore build is successful,
on the correct branch and not a pull-request.
:param branch: The branch the environment should be running against.
"""
assert os.environ.get('BRANCH_NAME') == branch
assert os.enviro... | [
"def",
"semaphore",
"(",
"branch",
":",
"str",
")",
":",
"assert",
"os",
".",
"environ",
".",
"get",
"(",
"'BRANCH_NAME'",
")",
"==",
"branch",
"assert",
"os",
".",
"environ",
".",
"get",
"(",
"'PULL_REQUEST_NUMBER'",
")",
"is",
"None",
"assert",
"os",
... | Performs necessary checks to ensure that the semaphore build is successful,
on the correct branch and not a pull-request.
:param branch: The branch the environment should be running against. | [
"Performs",
"necessary",
"checks",
"to",
"ensure",
"that",
"the",
"semaphore",
"build",
"is",
"successful",
"on",
"the",
"correct",
"branch",
"and",
"not",
"a",
"pull",
"-",
"request",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/ci_checks.py#L43-L52 | train |
relekang/python-semantic-release | semantic_release/ci_checks.py | frigg | def frigg(branch: str):
"""
Performs necessary checks to ensure that the frigg build is one
that should create releases.
:param branch: The branch the environment should be running against.
"""
assert os.environ.get('FRIGG_BUILD_BRANCH') == branch
assert not os.environ.get('FRIGG_PULL_REQUE... | python | def frigg(branch: str):
"""
Performs necessary checks to ensure that the frigg build is one
that should create releases.
:param branch: The branch the environment should be running against.
"""
assert os.environ.get('FRIGG_BUILD_BRANCH') == branch
assert not os.environ.get('FRIGG_PULL_REQUE... | [
"def",
"frigg",
"(",
"branch",
":",
"str",
")",
":",
"assert",
"os",
".",
"environ",
".",
"get",
"(",
"'FRIGG_BUILD_BRANCH'",
")",
"==",
"branch",
"assert",
"not",
"os",
".",
"environ",
".",
"get",
"(",
"'FRIGG_PULL_REQUEST'",
")"
] | Performs necessary checks to ensure that the frigg build is one
that should create releases.
:param branch: The branch the environment should be running against. | [
"Performs",
"necessary",
"checks",
"to",
"ensure",
"that",
"the",
"frigg",
"build",
"is",
"one",
"that",
"should",
"create",
"releases",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/ci_checks.py#L56-L64 | train |
relekang/python-semantic-release | semantic_release/ci_checks.py | circle | def circle(branch: str):
"""
Performs necessary checks to ensure that the circle build is one
that should create releases.
:param branch: The branch the environment should be running against.
"""
assert os.environ.get('CIRCLE_BRANCH') == branch
assert not os.environ.get('CI_PULL_REQUEST') | python | def circle(branch: str):
"""
Performs necessary checks to ensure that the circle build is one
that should create releases.
:param branch: The branch the environment should be running against.
"""
assert os.environ.get('CIRCLE_BRANCH') == branch
assert not os.environ.get('CI_PULL_REQUEST') | [
"def",
"circle",
"(",
"branch",
":",
"str",
")",
":",
"assert",
"os",
".",
"environ",
".",
"get",
"(",
"'CIRCLE_BRANCH'",
")",
"==",
"branch",
"assert",
"not",
"os",
".",
"environ",
".",
"get",
"(",
"'CI_PULL_REQUEST'",
")"
] | Performs necessary checks to ensure that the circle build is one
that should create releases.
:param branch: The branch the environment should be running against. | [
"Performs",
"necessary",
"checks",
"to",
"ensure",
"that",
"the",
"circle",
"build",
"is",
"one",
"that",
"should",
"create",
"releases",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/ci_checks.py#L68-L76 | train |
relekang/python-semantic-release | semantic_release/ci_checks.py | bitbucket | def bitbucket(branch: str):
"""
Performs necessary checks to ensure that the bitbucket build is one
that should create releases.
:param branch: The branch the environment should be running against.
"""
assert os.environ.get('BITBUCKET_BRANCH') == branch
assert not os.environ.get('BITBUCKET_... | python | def bitbucket(branch: str):
"""
Performs necessary checks to ensure that the bitbucket build is one
that should create releases.
:param branch: The branch the environment should be running against.
"""
assert os.environ.get('BITBUCKET_BRANCH') == branch
assert not os.environ.get('BITBUCKET_... | [
"def",
"bitbucket",
"(",
"branch",
":",
"str",
")",
":",
"assert",
"os",
".",
"environ",
".",
"get",
"(",
"'BITBUCKET_BRANCH'",
")",
"==",
"branch",
"assert",
"not",
"os",
".",
"environ",
".",
"get",
"(",
"'BITBUCKET_PR_ID'",
")"
] | Performs necessary checks to ensure that the bitbucket build is one
that should create releases.
:param branch: The branch the environment should be running against. | [
"Performs",
"necessary",
"checks",
"to",
"ensure",
"that",
"the",
"bitbucket",
"build",
"is",
"one",
"that",
"should",
"create",
"releases",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/ci_checks.py#L92-L100 | train |
relekang/python-semantic-release | semantic_release/ci_checks.py | check | def check(branch: str = 'master'):
"""
Detects the current CI environment, if any, and performs necessary
environment checks.
:param branch: The branch that should be the current branch.
"""
if os.environ.get('TRAVIS') == 'true':
travis(branch)
elif os.environ.get('SEMAPHORE') == 't... | python | def check(branch: str = 'master'):
"""
Detects the current CI environment, if any, and performs necessary
environment checks.
:param branch: The branch that should be the current branch.
"""
if os.environ.get('TRAVIS') == 'true':
travis(branch)
elif os.environ.get('SEMAPHORE') == 't... | [
"def",
"check",
"(",
"branch",
":",
"str",
"=",
"'master'",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'TRAVIS'",
")",
"==",
"'true'",
":",
"travis",
"(",
"branch",
")",
"elif",
"os",
".",
"environ",
".",
"get",
"(",
"'SEMAPHORE'",
")"... | Detects the current CI environment, if any, and performs necessary
environment checks.
:param branch: The branch that should be the current branch. | [
"Detects",
"the",
"current",
"CI",
"environment",
"if",
"any",
"and",
"performs",
"necessary",
"environment",
"checks",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/ci_checks.py#L103-L121 | train |
relekang/python-semantic-release | semantic_release/history/parser_angular.py | parse_commit_message | def parse_commit_message(message: str) -> Tuple[int, str, str, Tuple[str, str, str]]:
"""
Parses a commit message according to the angular commit guidelines specification.
:param message: A string of a commit message.
:return: A tuple of (level to bump, type of change, scope of change, a tuple with des... | python | def parse_commit_message(message: str) -> Tuple[int, str, str, Tuple[str, str, str]]:
"""
Parses a commit message according to the angular commit guidelines specification.
:param message: A string of a commit message.
:return: A tuple of (level to bump, type of change, scope of change, a tuple with des... | [
"def",
"parse_commit_message",
"(",
"message",
":",
"str",
")",
"->",
"Tuple",
"[",
"int",
",",
"str",
",",
"str",
",",
"Tuple",
"[",
"str",
",",
"str",
",",
"str",
"]",
"]",
":",
"parsed",
"=",
"re_parser",
".",
"match",
"(",
"message",
")",
"if",... | Parses a commit message according to the angular commit guidelines specification.
:param message: A string of a commit message.
:return: A tuple of (level to bump, type of change, scope of change, a tuple with descriptions)
:raises UnknownCommitMessageStyleError: if regular expression matching fails | [
"Parses",
"a",
"commit",
"message",
"according",
"to",
"the",
"angular",
"commit",
"guidelines",
"specification",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/history/parser_angular.py#L32-L69 | train |
relekang/python-semantic-release | semantic_release/history/parser_helpers.py | parse_text_block | def parse_text_block(text: str) -> Tuple[str, str]:
"""
This will take a text block and return a tuple with body and footer,
where footer is defined as the last paragraph.
:param text: The text string to be divided.
:return: A tuple with body and footer,
where footer is defined as the last para... | python | def parse_text_block(text: str) -> Tuple[str, str]:
"""
This will take a text block and return a tuple with body and footer,
where footer is defined as the last paragraph.
:param text: The text string to be divided.
:return: A tuple with body and footer,
where footer is defined as the last para... | [
"def",
"parse_text_block",
"(",
"text",
":",
"str",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"body",
",",
"footer",
"=",
"''",
",",
"''",
"if",
"text",
":",
"body",
"=",
"text",
".",
"split",
"(",
"'\\n\\n'",
")",
"[",
"0",
"]",
"i... | This will take a text block and return a tuple with body and footer,
where footer is defined as the last paragraph.
:param text: The text string to be divided.
:return: A tuple with body and footer,
where footer is defined as the last paragraph. | [
"This",
"will",
"take",
"a",
"text",
"block",
"and",
"return",
"a",
"tuple",
"with",
"body",
"and",
"footer",
"where",
"footer",
"is",
"defined",
"as",
"the",
"last",
"paragraph",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/history/parser_helpers.py#L6-L21 | train |
relekang/python-semantic-release | semantic_release/pypi.py | upload_to_pypi | def upload_to_pypi(
dists: str = 'sdist bdist_wheel',
username: str = None,
password: str = None,
skip_existing: bool = False
):
"""Creates the wheel and uploads to pypi with twine.
:param dists: The dists string passed to setup.py. Default: 'bdist_wheel'
:param username: Py... | python | def upload_to_pypi(
dists: str = 'sdist bdist_wheel',
username: str = None,
password: str = None,
skip_existing: bool = False
):
"""Creates the wheel and uploads to pypi with twine.
:param dists: The dists string passed to setup.py. Default: 'bdist_wheel'
:param username: Py... | [
"def",
"upload_to_pypi",
"(",
"dists",
":",
"str",
"=",
"'sdist bdist_wheel'",
",",
"username",
":",
"str",
"=",
"None",
",",
"password",
":",
"str",
"=",
"None",
",",
"skip_existing",
":",
"bool",
"=",
"False",
")",
":",
"if",
"username",
"is",
"None",
... | Creates the wheel and uploads to pypi with twine.
:param dists: The dists string passed to setup.py. Default: 'bdist_wheel'
:param username: PyPI account username string
:param password: PyPI account password string
:param skip_existing: Continue uploading files if one already exists. (Only valid when
... | [
"Creates",
"the",
"wheel",
"and",
"uploads",
"to",
"pypi",
"with",
"twine",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/pypi.py#L8-L34 | train |
relekang/python-semantic-release | semantic_release/vcs_helpers.py | get_commit_log | def get_commit_log(from_rev=None):
"""
Yields all commit messages from last to first.
"""
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) | python | def get_commit_log(from_rev=None):
"""
Yields all commit messages from last to first.
"""
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) | [
"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",
".",
... | Yields all commit messages from last to first. | [
"Yields",
"all",
"commit",
"messages",
"from",
"last",
"to",
"first",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/vcs_helpers.py#L25-L35 | train |
relekang/python-semantic-release | semantic_release/vcs_helpers.py | get_last_version | def get_last_version(skip_tags=None) -> Optional[str]:
"""
Return last version from repo tags.
:return: A string contains version number.
"""
debug('get_last_version skip_tags=', skip_tags)
check_repo()
skip_tags = skip_tags or []
def version_finder(tag):
if isinstance(tag.com... | python | def get_last_version(skip_tags=None) -> Optional[str]:
"""
Return last version from repo tags.
:return: A string contains version number.
"""
debug('get_last_version skip_tags=', skip_tags)
check_repo()
skip_tags = skip_tags or []
def version_finder(tag):
if isinstance(tag.com... | [
"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",
"versio... | Return last version from repo tags.
:return: A string contains version number. | [
"Return",
"last",
"version",
"from",
"repo",
"tags",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/vcs_helpers.py#L38-L59 | train |
relekang/python-semantic-release | semantic_release/vcs_helpers.py | get_version_from_tag | def get_version_from_tag(tag_name: str) -> Optional[str]:
"""Get git hash from tag
:param tag_name: Name of the git tag (i.e. 'v1.0.0')
:return: sha1 hash of the commit
"""
debug('get_version_from_tag({})'.format(tag_name))
check_repo()
for i in repo.tags:
if i.name == tag_name:
... | python | def get_version_from_tag(tag_name: str) -> Optional[str]:
"""Get git hash from tag
:param tag_name: Name of the git tag (i.e. 'v1.0.0')
:return: sha1 hash of the commit
"""
debug('get_version_from_tag({})'.format(tag_name))
check_repo()
for i in repo.tags:
if i.name == tag_name:
... | [
"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",
... | Get git hash from tag
:param tag_name: Name of the git tag (i.e. 'v1.0.0')
:return: sha1 hash of the commit | [
"Get",
"git",
"hash",
"from",
"tag"
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/vcs_helpers.py#L62-L74 | train |
relekang/python-semantic-release | semantic_release/vcs_helpers.py | get_repository_owner_and_name | def get_repository_owner_and_name() -> Tuple[str, str]:
"""
Checks the origin remote to get the owner and name of the remote repository.
:return: A tuple of the owner and name.
"""
check_repo()
url = repo.remote('origin').url
parts = re.search(r'([^/:]+)/([^/]+).git$', url)
if not part... | python | def get_repository_owner_and_name() -> Tuple[str, str]:
"""
Checks the origin remote to get the owner and name of the remote repository.
:return: A tuple of the owner and name.
"""
check_repo()
url = repo.remote('origin').url
parts = re.search(r'([^/:]+)/([^/]+).git$', url)
if not part... | [
"def",
"get_repository_owner_and_name",
"(",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"check_repo",
"(",
")",
"url",
"=",
"repo",
".",
"remote",
"(",
"'origin'",
")",
".",
"url",
"parts",
"=",
"re",
".",
"search",
"(",
"r'([^/:]+)/([^/]+).gi... | Checks the origin remote to get the owner and name of the remote repository.
:return: A tuple of the owner and name. | [
"Checks",
"the",
"origin",
"remote",
"to",
"get",
"the",
"owner",
"and",
"name",
"of",
"the",
"remote",
"repository",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/vcs_helpers.py#L77-L90 | train |
relekang/python-semantic-release | semantic_release/vcs_helpers.py | commit_new_version | def commit_new_version(version: str):
"""
Commits the file containing the version number variable with the version number as the commit
message.
:param version: The version number to be used in the commit message.
"""
check_repo()
commit_message = config.get('semantic_release', 'commit_mes... | python | def commit_new_version(version: str):
"""
Commits the file containing the version number variable with the version number as the commit
message.
:param version: The version number to be used in the commit message.
"""
check_repo()
commit_message = config.get('semantic_release', 'commit_mes... | [
"def",
"commit_new_version",
"(",
"version",
":",
"str",
")",
":",
"check_repo",
"(",
")",
"commit_message",
"=",
"config",
".",
"get",
"(",
"'semantic_release'",
",",
"'commit_message'",
")",
"message",
"=",
"'{0}\\n\\n{1}'",
".",
"format",
"(",
"version",
",... | Commits the file containing the version number variable with the version number as the commit
message.
:param version: The version number to be used in the commit message. | [
"Commits",
"the",
"file",
"containing",
"the",
"version",
"number",
"variable",
"with",
"the",
"version",
"number",
"as",
"the",
"commit",
"message",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/vcs_helpers.py#L104-L116 | train |
relekang/python-semantic-release | semantic_release/vcs_helpers.py | tag_new_version | def tag_new_version(version: str):
"""
Creates a new tag with the version number prefixed with v.
:param version: The version number used in the tag as a string.
"""
check_repo()
return repo.git.tag('-a', 'v{0}'.format(version), m='v{0}'.format(version)) | python | def tag_new_version(version: str):
"""
Creates a new tag with the version number prefixed with v.
:param version: The version number used in the tag as a string.
"""
check_repo()
return repo.git.tag('-a', 'v{0}'.format(version), m='v{0}'.format(version)) | [
"def",
"tag_new_version",
"(",
"version",
":",
"str",
")",
":",
"check_repo",
"(",
")",
"return",
"repo",
".",
"git",
".",
"tag",
"(",
"'-a'",
",",
"'v{0}'",
".",
"format",
"(",
"version",
")",
",",
"m",
"=",
"'v{0}'",
".",
"format",
"(",
"version",
... | Creates a new tag with the version number prefixed with v.
:param version: The version number used in the tag as a string. | [
"Creates",
"a",
"new",
"tag",
"with",
"the",
"version",
"number",
"prefixed",
"with",
"v",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/vcs_helpers.py#L119-L127 | train |
relekang/python-semantic-release | semantic_release/settings.py | current_commit_parser | def current_commit_parser() -> Callable:
"""Current commit parser
:raises ImproperConfigurationError: if ImportError or AttributeError is raised
"""
try:
parts = config.get('semantic_release', 'commit_parser').split('.')
module = '.'.join(parts[:-1])
return getattr(importlib.im... | python | def current_commit_parser() -> Callable:
"""Current commit parser
:raises ImproperConfigurationError: if ImportError or AttributeError is raised
"""
try:
parts = config.get('semantic_release', 'commit_parser').split('.')
module = '.'.join(parts[:-1])
return getattr(importlib.im... | [
"def",
"current_commit_parser",
"(",
")",
"->",
"Callable",
":",
"try",
":",
"parts",
"=",
"config",
".",
"get",
"(",
"'semantic_release'",
",",
"'commit_parser'",
")",
".",
"split",
"(",
"'.'",
")",
"module",
"=",
"'.'",
".",
"join",
"(",
"parts",
"[",
... | Current commit parser
:raises ImproperConfigurationError: if ImportError or AttributeError is raised | [
"Current",
"commit",
"parser"
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/settings.py#L24-L35 | train |
relekang/python-semantic-release | semantic_release/history/__init__.py | get_current_version_by_config_file | def get_current_version_by_config_file() -> str:
"""
Get current version from the version variable defined in the configuration
:return: A string with the current version number
:raises ImproperConfigurationError: if version variable cannot be parsed
"""
debug('get_current_version_by_config_fil... | python | def get_current_version_by_config_file() -> str:
"""
Get current version from the version variable defined in the configuration
:return: A string with the current version number
:raises ImproperConfigurationError: if version variable cannot be parsed
"""
debug('get_current_version_by_config_fil... | [
"def",
"get_current_version_by_config_file",
"(",
")",
"->",
"str",
":",
"debug",
"(",
"'get_current_version_by_config_file'",
")",
"filename",
",",
"variable",
"=",
"config",
".",
"get",
"(",
"'semantic_release'",
",",
"'version_variable'",
")",
".",
"split",
"(",
... | Get current version from the version variable defined in the configuration
:return: A string with the current version number
:raises ImproperConfigurationError: if version variable cannot be parsed | [
"Get",
"current",
"version",
"from",
"the",
"version",
"variable",
"defined",
"in",
"the",
"configuration"
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/history/__init__.py#L34-L55 | train |
relekang/python-semantic-release | semantic_release/history/__init__.py | get_new_version | def get_new_version(current_version: str, level_bump: str) -> str:
"""
Calculates the next version based on the given bump level with semver.
:param current_version: The version the package has now.
:param level_bump: The level of the version number that should be bumped. Should be a `'major'`,
... | python | def get_new_version(current_version: str, level_bump: str) -> str:
"""
Calculates the next version based on the given bump level with semver.
:param current_version: The version the package has now.
:param level_bump: The level of the version number that should be bumped. Should be a `'major'`,
... | [
"def",
"get_new_version",
"(",
"current_version",
":",
"str",
",",
"level_bump",
":",
"str",
")",
"->",
"str",
":",
"debug",
"(",
"'get_new_version(\"{}\", \"{}\")'",
".",
"format",
"(",
"current_version",
",",
"level_bump",
")",
")",
"if",
"not",
"level_bump",
... | Calculates the next version based on the given bump level with semver.
:param current_version: The version the package has now.
:param level_bump: The level of the version number that should be bumped. Should be a `'major'`,
`'minor'` or `'patch'`.
:return: A string with the next ver... | [
"Calculates",
"the",
"next",
"version",
"based",
"on",
"the",
"given",
"bump",
"level",
"with",
"semver",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/history/__init__.py#L69-L81 | train |
relekang/python-semantic-release | semantic_release/history/__init__.py | get_previous_version | def get_previous_version(version: str) -> Optional[str]:
"""
Returns the version prior to the given version.
:param version: A string with the version number.
:return: A string with the previous version number
"""
debug('get_previous_version')
found_version = False
for commit_hash, comm... | python | def get_previous_version(version: str) -> Optional[str]:
"""
Returns the version prior to the given version.
:param version: A string with the version number.
:return: A string with the previous version number
"""
debug('get_previous_version')
found_version = False
for commit_hash, comm... | [
"def",
"get_previous_version",
"(",
"version",
":",
"str",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"debug",
"(",
"'get_previous_version'",
")",
"found_version",
"=",
"False",
"for",
"commit_hash",
",",
"commit_message",
"in",
"get_commit_log",
"(",
")",
"... | Returns the version prior to the given version.
:param version: A string with the version number.
:return: A string with the previous version number | [
"Returns",
"the",
"version",
"prior",
"to",
"the",
"given",
"version",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/history/__init__.py#L84-L106 | train |
relekang/python-semantic-release | semantic_release/history/__init__.py | replace_version_string | def replace_version_string(content, variable, new_version):
"""
Given the content of a file, finds the version string and updates it.
:param content: The file contents
:param variable: The version variable name as a string
:param new_version: The new version number as a string
:return: A string... | python | def replace_version_string(content, variable, new_version):
"""
Given the content of a file, finds the version string and updates it.
:param content: The file contents
:param variable: The version variable name as a string
:param new_version: The new version number as a string
:return: A string... | [
"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",
"(... | Given the content of a file, finds the version string and updates it.
:param content: The file contents
:param variable: The version variable name as a string
:param new_version: The new version number as a string
:return: A string with the updated version number | [
"Given",
"the",
"content",
"of",
"a",
"file",
"finds",
"the",
"version",
"string",
"and",
"updates",
"it",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/history/__init__.py#L109-L122 | train |
relekang/python-semantic-release | semantic_release/history/__init__.py | set_new_version | def set_new_version(new_version: str) -> bool:
"""
Replaces the version number in the correct place and writes the changed file to disk.
:param new_version: The new version number as a string.
:return: `True` if it succeeded.
"""
filename, variable = config.get(
'semantic_release', 'ver... | python | def set_new_version(new_version: str) -> bool:
"""
Replaces the version number in the correct place and writes the changed file to disk.
:param new_version: The new version number as a string.
:return: `True` if it succeeded.
"""
filename, variable = config.get(
'semantic_release', 'ver... | [
"def",
"set_new_version",
"(",
"new_version",
":",
"str",
")",
"->",
"bool",
":",
"filename",
",",
"variable",
"=",
"config",
".",
"get",
"(",
"'semantic_release'",
",",
"'version_variable'",
")",
".",
"split",
"(",
"':'",
")",
"variable",
"=",
"variable",
... | Replaces the version number in the correct place and writes the changed file to disk.
:param new_version: The new version number as a string.
:return: `True` if it succeeded. | [
"Replaces",
"the",
"version",
"number",
"in",
"the",
"correct",
"place",
"and",
"writes",
"the",
"changed",
"file",
"to",
"disk",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/history/__init__.py#L125-L142 | train |
relekang/python-semantic-release | semantic_release/history/logs.py | evaluate_version_bump | def evaluate_version_bump(current_version: str, force: str = None) -> Optional[str]:
"""
Reads git log since last release to find out if should be a major, minor or patch release.
:param current_version: A string with the current version number.
:param force: A string with the bump level that should be... | python | def evaluate_version_bump(current_version: str, force: str = None) -> Optional[str]:
"""
Reads git log since last release to find out if should be a major, minor or patch release.
:param current_version: A string with the current version number.
:param force: A string with the bump level that should be... | [
"def",
"evaluate_version_bump",
"(",
"current_version",
":",
"str",
",",
"force",
":",
"str",
"=",
"None",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"debug",
"(",
"'evaluate_version_bump(\"{}\", \"{}\")'",
".",
"format",
"(",
"current_version",
",",
"force",
... | Reads git log since last release to find out if should be a major, minor or patch release.
:param current_version: A string with the current version number.
:param force: A string with the bump level that should be forced.
:return: A string with either major, minor or patch if there should be a release. If... | [
"Reads",
"git",
"log",
"since",
"last",
"release",
"to",
"find",
"out",
"if",
"should",
"be",
"a",
"major",
"minor",
"or",
"patch",
"release",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/history/logs.py#L25-L63 | train |
relekang/python-semantic-release | semantic_release/history/logs.py | generate_changelog | def generate_changelog(from_version: str, to_version: str = None) -> dict:
"""
Generates a changelog for the given version.
:param from_version: The last version not in the changelog. The changelog
will be generated from the commit after this one.
:param to_version: The last ve... | python | def generate_changelog(from_version: str, to_version: str = None) -> dict:
"""
Generates a changelog for the given version.
:param from_version: The last version not in the changelog. The changelog
will be generated from the commit after this one.
:param to_version: The last ve... | [
"def",
"generate_changelog",
"(",
"from_version",
":",
"str",
",",
"to_version",
":",
"str",
"=",
"None",
")",
"->",
"dict",
":",
"debug",
"(",
"'generate_changelog(\"{}\", \"{}\")'",
".",
"format",
"(",
"from_version",
",",
"to_version",
")",
")",
"changes",
... | Generates a changelog for the given version.
:param from_version: The last version not in the changelog. The changelog
will be generated from the commit after this one.
:param to_version: The last version in the changelog.
:return: a dict with different changelog sections | [
"Generates",
"a",
"changelog",
"for",
"the",
"given",
"version",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/history/logs.py#L66-L116 | train |
relekang/python-semantic-release | semantic_release/history/logs.py | markdown_changelog | def markdown_changelog(version: str, changelog: dict, header: bool = False) -> str:
"""
Generates a markdown version of the changelog. Takes a parsed changelog dict from
generate_changelog.
:param version: A string with the version number.
:param changelog: A dict from generate_changelog.
:para... | python | def markdown_changelog(version: str, changelog: dict, header: bool = False) -> str:
"""
Generates a markdown version of the changelog. Takes a parsed changelog dict from
generate_changelog.
:param version: A string with the version number.
:param changelog: A dict from generate_changelog.
:para... | [
"def",
"markdown_changelog",
"(",
"version",
":",
"str",
",",
"changelog",
":",
"dict",
",",
"header",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"debug",
"(",
"'markdown_changelog(version=\"{}\", header={}, changelog=...)'",
".",
"format",
"(",
"version",
... | Generates a markdown version of the changelog. Takes a parsed changelog dict from
generate_changelog.
:param version: A string with the version number.
:param changelog: A dict from generate_changelog.
:param header: A boolean that decides whether a header should be included or not.
:return: The ma... | [
"Generates",
"a",
"markdown",
"version",
"of",
"the",
"changelog",
".",
"Takes",
"a",
"parsed",
"changelog",
"dict",
"from",
"generate_changelog",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/history/logs.py#L119-L142 | train |
relekang/python-semantic-release | semantic_release/hvcs.py | get_hvcs | def get_hvcs() -> Base:
"""Get HVCS helper class
:raises ImproperConfigurationError: if the hvcs option provided is not valid
"""
hvcs = config.get('semantic_release', 'hvcs')
debug('get_hvcs: hvcs=', hvcs)
try:
return globals()[hvcs.capitalize()]
except KeyError:
raise Impr... | python | def get_hvcs() -> Base:
"""Get HVCS helper class
:raises ImproperConfigurationError: if the hvcs option provided is not valid
"""
hvcs = config.get('semantic_release', 'hvcs')
debug('get_hvcs: hvcs=', hvcs)
try:
return globals()[hvcs.capitalize()]
except KeyError:
raise Impr... | [
"def",
"get_hvcs",
"(",
")",
"->",
"Base",
":",
"hvcs",
"=",
"config",
".",
"get",
"(",
"'semantic_release'",
",",
"'hvcs'",
")",
"debug",
"(",
"'get_hvcs: hvcs='",
",",
"hvcs",
")",
"try",
":",
"return",
"globals",
"(",
")",
"[",
"hvcs",
".",
"capital... | Get HVCS helper class
:raises ImproperConfigurationError: if the hvcs option provided is not valid | [
"Get",
"HVCS",
"helper",
"class"
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/hvcs.py#L121-L131 | train |
relekang/python-semantic-release | semantic_release/hvcs.py | check_build_status | def check_build_status(owner: str, repository: str, ref: str) -> bool:
"""
Checks the build status of a commit on the api from your hosted version control provider.
:param owner: The owner of the repository
:param repository: The repository name
:param ref: Commit or branch reference
:return: A... | python | def check_build_status(owner: str, repository: str, ref: str) -> bool:
"""
Checks the build status of a commit on the api from your hosted version control provider.
:param owner: The owner of the repository
:param repository: The repository name
:param ref: Commit or branch reference
:return: A... | [
"def",
"check_build_status",
"(",
"owner",
":",
"str",
",",
"repository",
":",
"str",
",",
"ref",
":",
"str",
")",
"->",
"bool",
":",
"debug",
"(",
"'check_build_status'",
")",
"return",
"get_hvcs",
"(",
")",
".",
"check_build_status",
"(",
"owner",
",",
... | Checks the build status of a commit on the api from your hosted version control provider.
:param owner: The owner of the repository
:param repository: The repository name
:param ref: Commit or branch reference
:return: A boolean with the build status | [
"Checks",
"the",
"build",
"status",
"of",
"a",
"commit",
"on",
"the",
"api",
"from",
"your",
"hosted",
"version",
"control",
"provider",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/hvcs.py#L134-L144 | train |
relekang/python-semantic-release | semantic_release/hvcs.py | post_changelog | def post_changelog(owner: str, repository: str, version: str, changelog: str) -> Tuple[bool, dict]:
"""
Posts the changelog to the current hvcs release API
:param owner: The owner of the repository
:param repository: The repository name
:param version: A string with the new version
:param chang... | python | def post_changelog(owner: str, repository: str, version: str, changelog: str) -> Tuple[bool, dict]:
"""
Posts the changelog to the current hvcs release API
:param owner: The owner of the repository
:param repository: The repository name
:param version: A string with the new version
:param chang... | [
"def",
"post_changelog",
"(",
"owner",
":",
"str",
",",
"repository",
":",
"str",
",",
"version",
":",
"str",
",",
"changelog",
":",
"str",
")",
"->",
"Tuple",
"[",
"bool",
",",
"dict",
"]",
":",
"debug",
"(",
"'post_changelog(owner={}, repository={}, versio... | Posts the changelog to the current hvcs release API
:param owner: The owner of the repository
:param repository: The repository name
:param version: A string with the new version
:param changelog: A string with the changelog in correct format
:return: a tuple with success status and payload from hv... | [
"Posts",
"the",
"changelog",
"to",
"the",
"current",
"hvcs",
"release",
"API"
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/hvcs.py#L147-L158 | train |
relekang/python-semantic-release | semantic_release/cli.py | version | def version(**kwargs):
"""
Detects the new version according to git log and semver. Writes the new version
number and commits it, unless the noop-option is True.
"""
retry = kwargs.get("retry")
if retry:
click.echo('Retrying publication of the same version...')
else:
click.ec... | python | def version(**kwargs):
"""
Detects the new version according to git log and semver. Writes the new version
number and commits it, unless the noop-option is True.
"""
retry = kwargs.get("retry")
if retry:
click.echo('Retrying publication of the same version...')
else:
click.ec... | [
"def",
"version",
"(",
"*",
"*",
"kwargs",
")",
":",
"retry",
"=",
"kwargs",
".",
"get",
"(",
"\"retry\"",
")",
"if",
"retry",
":",
"click",
".",
"echo",
"(",
"'Retrying publication of the same version...'",
")",
"else",
":",
"click",
".",
"echo",
"(",
"... | Detects the new version according to git log and semver. Writes the new version
number and commits it, unless the noop-option is True. | [
"Detects",
"the",
"new",
"version",
"according",
"to",
"git",
"log",
"and",
"semver",
".",
"Writes",
"the",
"new",
"version",
"number",
"and",
"commits",
"it",
"unless",
"the",
"noop",
"-",
"option",
"is",
"True",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/cli.py#L43-L93 | train |
relekang/python-semantic-release | semantic_release/cli.py | publish | def publish(**kwargs):
"""
Runs the version task before pushing to git and uploading to pypi.
"""
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" ... | python | def publish(**kwargs):
"""
Runs the version task before pushing to git and uploading to pypi.
"""
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" ... | [
"def",
"publish",
"(",
"*",
"*",
"kwargs",
")",
":",
"current_version",
"=",
"get_current_version",
"(",
")",
"click",
".",
"echo",
"(",
"'Current version: {0}'",
".",
"format",
"(",
"current_version",
")",
")",
"retry",
"=",
"kwargs",
".",
"get",
"(",
"\"... | Runs the version task before pushing to git and uploading to pypi. | [
"Runs",
"the",
"version",
"task",
"before",
"pushing",
"to",
"git",
"and",
"uploading",
"to",
"pypi",
"."
] | 76123f410180599a19e7c48da413880185bbea20 | https://github.com/relekang/python-semantic-release/blob/76123f410180599a19e7c48da413880185bbea20/semantic_release/cli.py#L132-L188 | train |
aljosa/django-tinymce | tinymce/views.py | flatpages_link_list | def flatpages_link_list(request):
"""
Returns a HttpResponse whose content is a Javascript file representing a
list of links to flatpages.
"""
from django.contrib.flatpages.models import FlatPage
link_list = [(page.title, page.url) for page in FlatPage.objects.all()]
return render_to_link_li... | python | def flatpages_link_list(request):
"""
Returns a HttpResponse whose content is a Javascript file representing a
list of links to flatpages.
"""
from django.contrib.flatpages.models import FlatPage
link_list = [(page.title, page.url) for page in FlatPage.objects.all()]
return render_to_link_li... | [
"def",
"flatpages_link_list",
"(",
"request",
")",
":",
"from",
"django",
".",
"contrib",
".",
"flatpages",
".",
"models",
"import",
"FlatPage",
"link_list",
"=",
"[",
"(",
"page",
".",
"title",
",",
"page",
".",
"url",
")",
"for",
"page",
"in",
"FlatPag... | Returns a HttpResponse whose content is a Javascript file representing a
list of links to flatpages. | [
"Returns",
"a",
"HttpResponse",
"whose",
"content",
"is",
"a",
"Javascript",
"file",
"representing",
"a",
"list",
"of",
"links",
"to",
"flatpages",
"."
] | a509fdbc6c623ddac6552199da89712c0f026c91 | https://github.com/aljosa/django-tinymce/blob/a509fdbc6c623ddac6552199da89712c0f026c91/tinymce/views.py#L72-L79 | train |
aio-libs/aiomonitor | aiomonitor/monitor.py | Monitor._interactive_loop | def _interactive_loop(self, sin: IO[str], sout: IO[str]) -> None:
"""Main interactive loop of the monitor"""
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, s=s... | python | def _interactive_loop(self, sin: IO[str], sout: IO[str]) -> None:
"""Main interactive loop of the monitor"""
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, s=s... | [
"def",
"_interactive_loop",
"(",
"self",
",",
"sin",
":",
"IO",
"[",
"str",
"]",
",",
"sout",
":",
"IO",
"[",
"str",
"]",
")",
"->",
"None",
":",
"self",
".",
"_sin",
"=",
"sin",
"self",
".",
"_sout",
"=",
"sout",
"tasknum",
"=",
"len",
"(",
"a... | Main interactive loop of the monitor | [
"Main",
"interactive",
"loop",
"of",
"the",
"monitor"
] | fe5f9caa0b117861afef13b64bce5dce3a415b80 | https://github.com/aio-libs/aiomonitor/blob/fe5f9caa0b117861afef13b64bce5dce3a415b80/aiomonitor/monitor.py#L156-L184 | train |
aio-libs/aiomonitor | aiomonitor/monitor.py | Monitor.do_help | def do_help(self, *cmd_names: str) -> None:
"""Show help for command name
Any number of command names may be given to help, and the long help
text for all of them will be shown.
"""
def _h(cmd: str, template: str) -> None:
try:
func = getattr(self, cm... | python | def do_help(self, *cmd_names: str) -> None:
"""Show help for command name
Any number of command names may be given to help, and the long help
text for all of them will be shown.
"""
def _h(cmd: str, template: str) -> None:
try:
func = getattr(self, cm... | [
"def",
"do_help",
"(",
"self",
",",
"*",
"cmd_names",
":",
"str",
")",
"->",
"None",
":",
"def",
"_h",
"(",
"cmd",
":",
"str",
",",
"template",
":",
"str",
")",
"->",
"None",
":",
"try",
":",
"func",
"=",
"getattr",
"(",
"self",
",",
"cmd",
")"... | Show help for command name
Any number of command names may be given to help, and the long help
text for all of them will be shown. | [
"Show",
"help",
"for",
"command",
"name"
] | fe5f9caa0b117861afef13b64bce5dce3a415b80 | https://github.com/aio-libs/aiomonitor/blob/fe5f9caa0b117861afef13b64bce5dce3a415b80/aiomonitor/monitor.py#L299-L334 | train |
aio-libs/aiomonitor | aiomonitor/monitor.py | Monitor.do_ps | def do_ps(self) -> None:
"""Show task table"""
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), 80))
... | python | def do_ps(self) -> None:
"""Show task table"""
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), 80))
... | [
"def",
"do_ps",
"(",
"self",
")",
"->",
"None",
":",
"headers",
"=",
"(",
"'Task ID'",
",",
"'State'",
",",
"'Task'",
")",
"table_data",
"=",
"[",
"headers",
"]",
"for",
"task",
"in",
"sorted",
"(",
"all_tasks",
"(",
"loop",
"=",
"self",
".",
"_loop"... | Show task table | [
"Show",
"task",
"table"
] | fe5f9caa0b117861afef13b64bce5dce3a415b80 | https://github.com/aio-libs/aiomonitor/blob/fe5f9caa0b117861afef13b64bce5dce3a415b80/aiomonitor/monitor.py#L337-L349 | train |
aio-libs/aiomonitor | aiomonitor/monitor.py | Monitor.do_where | def do_where(self, taskid: int) -> None:
"""Show stack frames for a task"""
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) | python | def do_where(self, taskid: int) -> None:
"""Show stack frames for a task"""
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) | [
"def",
"do_where",
"(",
"self",
",",
"taskid",
":",
"int",
")",
"->",
"None",
":",
"task",
"=",
"task_by_id",
"(",
"taskid",
",",
"self",
".",
"_loop",
")",
"if",
"task",
":",
"self",
".",
"_sout",
".",
"write",
"(",
"_format_stack",
"(",
"task",
"... | Show stack frames for a task | [
"Show",
"stack",
"frames",
"for",
"a",
"task"
] | fe5f9caa0b117861afef13b64bce5dce3a415b80 | https://github.com/aio-libs/aiomonitor/blob/fe5f9caa0b117861afef13b64bce5dce3a415b80/aiomonitor/monitor.py#L352-L359 | train |
aio-libs/aiomonitor | aiomonitor/monitor.py | Monitor.do_signal | def do_signal(self, signame: str) -> None:
"""Send a Unix signal"""
if hasattr(signal, signame):
os.kill(os.getpid(), getattr(signal, signame))
else:
self._sout.write('Unknown signal %s\n' % signame) | python | def do_signal(self, signame: str) -> None:
"""Send a Unix signal"""
if hasattr(signal, signame):
os.kill(os.getpid(), getattr(signal, signame))
else:
self._sout.write('Unknown signal %s\n' % signame) | [
"def",
"do_signal",
"(",
"self",
",",
"signame",
":",
"str",
")",
"->",
"None",
":",
"if",
"hasattr",
"(",
"signal",
",",
"signame",
")",
":",
"os",
".",
"kill",
"(",
"os",
".",
"getpid",
"(",
")",
",",
"getattr",
"(",
"signal",
",",
"signame",
"... | Send a Unix signal | [
"Send",
"a",
"Unix",
"signal"
] | fe5f9caa0b117861afef13b64bce5dce3a415b80 | https://github.com/aio-libs/aiomonitor/blob/fe5f9caa0b117861afef13b64bce5dce3a415b80/aiomonitor/monitor.py#L361-L366 | train |
aio-libs/aiomonitor | aiomonitor/monitor.py | Monitor.do_stacktrace | def do_stacktrace(self) -> None:
"""Print a stack trace from the event loop thread"""
frame = sys._current_frames()[self._event_loop_thread_id]
traceback.print_stack(frame, file=self._sout) | python | def do_stacktrace(self) -> None:
"""Print a stack trace from the event loop thread"""
frame = sys._current_frames()[self._event_loop_thread_id]
traceback.print_stack(frame, file=self._sout) | [
"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 | [
"Print",
"a",
"stack",
"trace",
"from",
"the",
"event",
"loop",
"thread"
] | fe5f9caa0b117861afef13b64bce5dce3a415b80 | https://github.com/aio-libs/aiomonitor/blob/fe5f9caa0b117861afef13b64bce5dce3a415b80/aiomonitor/monitor.py#L369-L372 | train |
aio-libs/aiomonitor | aiomonitor/monitor.py | Monitor.do_cancel | def do_cancel(self, taskid: int) -> None:
"""Cancel an indicated task"""
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.write('Cancel t... | python | def do_cancel(self, taskid: int) -> None:
"""Cancel an indicated task"""
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.write('Cancel t... | [
"def",
"do_cancel",
"(",
"self",
",",
"taskid",
":",
"int",
")",
"->",
"None",
":",
"task",
"=",
"task_by_id",
"(",
"taskid",
",",
"self",
".",
"_loop",
")",
"if",
"task",
":",
"fut",
"=",
"asyncio",
".",
"run_coroutine_threadsafe",
"(",
"cancel_task",
... | Cancel an indicated task | [
"Cancel",
"an",
"indicated",
"task"
] | fe5f9caa0b117861afef13b64bce5dce3a415b80 | https://github.com/aio-libs/aiomonitor/blob/fe5f9caa0b117861afef13b64bce5dce3a415b80/aiomonitor/monitor.py#L374-L383 | train |
aio-libs/aiomonitor | aiomonitor/monitor.py | Monitor.do_console | def do_console(self) -> None:
"""Switch to async Python REPL"""
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('Starting console at... | python | def do_console(self) -> None:
"""Switch to async Python REPL"""
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('Starting console at... | [
"def",
"do_console",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_console_enabled",
":",
"self",
".",
"_sout",
".",
"write",
"(",
"'Python console disabled for this sessiong\\n'",
")",
"self",
".",
"_sout",
".",
"flush",
"(",
")",
"return... | Switch to async Python REPL | [
"Switch",
"to",
"async",
"Python",
"REPL"
] | fe5f9caa0b117861afef13b64bce5dce3a415b80 | https://github.com/aio-libs/aiomonitor/blob/fe5f9caa0b117861afef13b64bce5dce3a415b80/aiomonitor/monitor.py#L391-L409 | train |
aio-libs/aiomonitor | aiomonitor/utils.py | alt_names | def alt_names(names: str) -> Callable[..., Any]:
"""Add alternative names to you custom commands.
`names` is a single string with a space separated list of aliases for the
decorated command.
"""
names_split = names.split()
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
... | python | def alt_names(names: str) -> Callable[..., Any]:
"""Add alternative names to you custom commands.
`names` is a single string with a space separated list of aliases for the
decorated command.
"""
names_split = names.split()
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
... | [
"def",
"alt_names",
"(",
"names",
":",
"str",
")",
"->",
"Callable",
"[",
"...",
",",
"Any",
"]",
":",
"names_split",
"=",
"names",
".",
"split",
"(",
")",
"def",
"decorator",
"(",
"func",
":",
"Callable",
"[",
"...",
",",
"Any",
"]",
")",
"->",
... | Add alternative names to you custom commands.
`names` is a single string with a space separated list of aliases for the
decorated command. | [
"Add",
"alternative",
"names",
"to",
"you",
"custom",
"commands",
"."
] | fe5f9caa0b117861afef13b64bce5dce3a415b80 | https://github.com/aio-libs/aiomonitor/blob/fe5f9caa0b117861afef13b64bce5dce3a415b80/aiomonitor/utils.py#L115-L126 | train |
vxgmichel/aioconsole | aioconsole/events.py | set_interactive_policy | def set_interactive_policy(*, locals=None, banner=None, serve=None,
prompt_control=None):
"""Use an interactive event loop by default."""
policy = InteractiveEventLoopPolicy(
locals=locals,
banner=banner,
serve=serve,
prompt_control=prompt_control)
... | python | def set_interactive_policy(*, locals=None, banner=None, serve=None,
prompt_control=None):
"""Use an interactive event loop by default."""
policy = InteractiveEventLoopPolicy(
locals=locals,
banner=banner,
serve=serve,
prompt_control=prompt_control)
... | [
"def",
"set_interactive_policy",
"(",
"*",
",",
"locals",
"=",
"None",
",",
"banner",
"=",
"None",
",",
"serve",
"=",
"None",
",",
"prompt_control",
"=",
"None",
")",
":",
"policy",
"=",
"InteractiveEventLoopPolicy",
"(",
"locals",
"=",
"locals",
",",
"ban... | Use an interactive event loop by default. | [
"Use",
"an",
"interactive",
"event",
"loop",
"by",
"default",
"."
] | 8223435723d616fd4db398431d6a6182a6015e3f | https://github.com/vxgmichel/aioconsole/blob/8223435723d616fd4db398431d6a6182a6015e3f/aioconsole/events.py#L71-L79 | train |
vxgmichel/aioconsole | aioconsole/events.py | run_console | def run_console(*, locals=None, banner=None, serve=None, prompt_control=None):
"""Run the interactive event loop."""
loop = InteractiveEventLoop(
locals=locals,
banner=banner,
serve=serve,
prompt_control=prompt_control)
asyncio.set_event_loop(loop)
try:
loop.run_f... | python | def run_console(*, locals=None, banner=None, serve=None, prompt_control=None):
"""Run the interactive event loop."""
loop = InteractiveEventLoop(
locals=locals,
banner=banner,
serve=serve,
prompt_control=prompt_control)
asyncio.set_event_loop(loop)
try:
loop.run_f... | [
"def",
"run_console",
"(",
"*",
",",
"locals",
"=",
"None",
",",
"banner",
"=",
"None",
",",
"serve",
"=",
"None",
",",
"prompt_control",
"=",
"None",
")",
":",
"loop",
"=",
"InteractiveEventLoop",
"(",
"locals",
"=",
"locals",
",",
"banner",
"=",
"ban... | Run the interactive event loop. | [
"Run",
"the",
"interactive",
"event",
"loop",
"."
] | 8223435723d616fd4db398431d6a6182a6015e3f | https://github.com/vxgmichel/aioconsole/blob/8223435723d616fd4db398431d6a6182a6015e3f/aioconsole/events.py#L82-L93 | train |
vxgmichel/aioconsole | aioconsole/execute.py | make_arg | def make_arg(key, annotation=None):
"""Make an ast function argument."""
arg = ast.arg(key, annotation)
arg.lineno, arg.col_offset = 0, 0
return arg | python | def make_arg(key, annotation=None):
"""Make an ast function argument."""
arg = ast.arg(key, annotation)
arg.lineno, arg.col_offset = 0, 0
return arg | [
"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. | [
"Make",
"an",
"ast",
"function",
"argument",
"."
] | 8223435723d616fd4db398431d6a6182a6015e3f | https://github.com/vxgmichel/aioconsole/blob/8223435723d616fd4db398431d6a6182a6015e3f/aioconsole/execute.py#L16-L20 | train |
vxgmichel/aioconsole | aioconsole/execute.py | make_coroutine_from_tree | def make_coroutine_from_tree(tree, filename="<aexec>", symbol="single",
local={}):
"""Make a coroutine from a tree structure."""
dct = {}
tree.body[0].args.args = list(map(make_arg, local))
exec(compile(tree, filename, symbol), dct)
return asyncio.coroutine(dct[CORO_NAME... | python | def make_coroutine_from_tree(tree, filename="<aexec>", symbol="single",
local={}):
"""Make a coroutine from a tree structure."""
dct = {}
tree.body[0].args.args = list(map(make_arg, local))
exec(compile(tree, filename, symbol), dct)
return asyncio.coroutine(dct[CORO_NAME... | [
"def",
"make_coroutine_from_tree",
"(",
"tree",
",",
"filename",
"=",
"\"<aexec>\"",
",",
"symbol",
"=",
"\"single\"",
",",
"local",
"=",
"{",
"}",
")",
":",
"dct",
"=",
"{",
"}",
"tree",
".",
"body",
"[",
"0",
"]",
".",
"args",
".",
"args",
"=",
"... | Make a coroutine from a tree structure. | [
"Make",
"a",
"coroutine",
"from",
"a",
"tree",
"structure",
"."
] | 8223435723d616fd4db398431d6a6182a6015e3f | https://github.com/vxgmichel/aioconsole/blob/8223435723d616fd4db398431d6a6182a6015e3f/aioconsole/execute.py#L50-L56 | train |
libfuse/python-fuse | fuse.py | feature_needs | def feature_needs(*feas):
"""
Get info about the FUSE API version needed for the support of some features.
This function takes a variable number of feature patterns.
A feature pattern is either:
- an integer (directly referring to a FUSE API version number)
- a built-in feature specifier st... | python | def feature_needs(*feas):
"""
Get info about the FUSE API version needed for the support of some features.
This function takes a variable number of feature patterns.
A feature pattern is either:
- an integer (directly referring to a FUSE API version number)
- a built-in feature specifier st... | [
"def",
"feature_needs",
"(",
"*",
"feas",
")",
":",
"fmap",
"=",
"{",
"'stateful_files'",
":",
"22",
",",
"'stateful_dirs'",
":",
"23",
",",
"'stateful_io'",
":",
"(",
"'stateful_files'",
",",
"'stateful_dirs'",
")",
",",
"'stateful_files_keep_cache'",
":",
"2... | Get info about the FUSE API version needed for the support of some features.
This function takes a variable number of feature patterns.
A feature pattern is either:
- an integer (directly referring to a FUSE API version number)
- a built-in feature specifier string (meaning defined by dictionary)
... | [
"Get",
"info",
"about",
"the",
"FUSE",
"API",
"version",
"needed",
"for",
"the",
"support",
"of",
"some",
"features",
"."
] | 2c088b657ad71faca6975b456f80b7d2c2cea2a7 | https://github.com/libfuse/python-fuse/blob/2c088b657ad71faca6975b456f80b7d2c2cea2a7/fuse.py#L502-L593 | train |
libfuse/python-fuse | fuse.py | FuseArgs.assemble | def assemble(self):
"""Mangle self into an argument array"""
self.canonify()
args = [sys.argv and sys.argv[0] or "python"]
if self.mountpoint:
args.append(self.mountpoint)
for m, v in self.modifiers.items():
if v:
args.append(self.fuse_mod... | python | def assemble(self):
"""Mangle self into an argument array"""
self.canonify()
args = [sys.argv and sys.argv[0] or "python"]
if self.mountpoint:
args.append(self.mountpoint)
for m, v in self.modifiers.items():
if v:
args.append(self.fuse_mod... | [
"def",
"assemble",
"(",
"self",
")",
":",
"self",
".",
"canonify",
"(",
")",
"args",
"=",
"[",
"sys",
".",
"argv",
"and",
"sys",
".",
"argv",
"[",
"0",
"]",
"or",
"\"python\"",
"]",
"if",
"self",
".",
"mountpoint",
":",
"args",
".",
"append",
"("... | Mangle self into an argument array | [
"Mangle",
"self",
"into",
"an",
"argument",
"array"
] | 2c088b657ad71faca6975b456f80b7d2c2cea2a7 | https://github.com/libfuse/python-fuse/blob/2c088b657ad71faca6975b456f80b7d2c2cea2a7/fuse.py#L129-L148 | train |
libfuse/python-fuse | fuse.py | Fuse.parse | def parse(self, *args, **kw):
"""Parse command line, fill `fuse_args` attribute."""
ev = 'errex' in kw and kw.pop('errex')
if ev and not isinstance(ev, int):
raise TypeError("error exit value should be an integer")
try:
self.cmdline = self.parser.parse_args(*arg... | python | def parse(self, *args, **kw):
"""Parse command line, fill `fuse_args` attribute."""
ev = 'errex' in kw and kw.pop('errex')
if ev and not isinstance(ev, int):
raise TypeError("error exit value should be an integer")
try:
self.cmdline = self.parser.parse_args(*arg... | [
"def",
"parse",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"ev",
"=",
"'errex'",
"in",
"kw",
"and",
"kw",
".",
"pop",
"(",
"'errex'",
")",
"if",
"ev",
"and",
"not",
"isinstance",
"(",
"ev",
",",
"int",
")",
":",
"raise",
"T... | Parse command line, fill `fuse_args` attribute. | [
"Parse",
"command",
"line",
"fill",
"fuse_args",
"attribute",
"."
] | 2c088b657ad71faca6975b456f80b7d2c2cea2a7 | https://github.com/libfuse/python-fuse/blob/2c088b657ad71faca6975b456f80b7d2c2cea2a7/fuse.py#L714-L728 | train |
libfuse/python-fuse | fuse.py | Fuse.main | def main(self, args=None):
"""Enter filesystem service loop."""
if get_compat_0_1():
args = self.main_0_1_preamble()
d = {'multithreaded': self.multithreaded and 1 or 0}
d['fuse_args'] = args or self.fuse_args.assemble()
for t in 'file_class', 'dir_class':
... | python | def main(self, args=None):
"""Enter filesystem service loop."""
if get_compat_0_1():
args = self.main_0_1_preamble()
d = {'multithreaded': self.multithreaded and 1 or 0}
d['fuse_args'] = args or self.fuse_args.assemble()
for t in 'file_class', 'dir_class':
... | [
"def",
"main",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"if",
"get_compat_0_1",
"(",
")",
":",
"args",
"=",
"self",
".",
"main_0_1_preamble",
"(",
")",
"d",
"=",
"{",
"'multithreaded'",
":",
"self",
".",
"multithreaded",
"and",
"1",
"or",
"0"... | Enter filesystem service loop. | [
"Enter",
"filesystem",
"service",
"loop",
"."
] | 2c088b657ad71faca6975b456f80b7d2c2cea2a7 | https://github.com/libfuse/python-fuse/blob/2c088b657ad71faca6975b456f80b7d2c2cea2a7/fuse.py#L730-L757 | train |
libfuse/python-fuse | fuse.py | Fuse.fuseoptref | def fuseoptref(cls):
"""
Find out which options are recognized by the library.
Result is a `FuseArgs` instance with the list of supported
options, suitable for passing on to the `filter` method of
another `FuseArgs` instance.
"""
import os, re
pr, pw = o... | python | def fuseoptref(cls):
"""
Find out which options are recognized by the library.
Result is a `FuseArgs` instance with the list of supported
options, suitable for passing on to the `filter` method of
another `FuseArgs` instance.
"""
import os, re
pr, pw = o... | [
"def",
"fuseoptref",
"(",
"cls",
")",
":",
"import",
"os",
",",
"re",
"pr",
",",
"pw",
"=",
"os",
".",
"pipe",
"(",
")",
"pid",
"=",
"os",
".",
"fork",
"(",
")",
"if",
"pid",
"==",
"0",
":",
"os",
".",
"dup2",
"(",
"pw",
",",
"2",
")",
"o... | Find out which options are recognized by the library.
Result is a `FuseArgs` instance with the list of supported
options, suitable for passing on to the `filter` method of
another `FuseArgs` instance. | [
"Find",
"out",
"which",
"options",
"are",
"recognized",
"by",
"the",
"library",
".",
"Result",
"is",
"a",
"FuseArgs",
"instance",
"with",
"the",
"list",
"of",
"supported",
"options",
"suitable",
"for",
"passing",
"on",
"to",
"the",
"filter",
"method",
"of",
... | 2c088b657ad71faca6975b456f80b7d2c2cea2a7 | https://github.com/libfuse/python-fuse/blob/2c088b657ad71faca6975b456f80b7d2c2cea2a7/fuse.py#L796-L840 | train |
libfuse/python-fuse | fuseparts/subbedopts.py | SubOptsHive.filter | def filter(self, other):
"""
Throw away those options which are not in the other one.
Returns a new instance with the rejected options.
"""
self.canonify()
other.canonify()
rej = self.__class__()
rej.optlist = self.optlist.difference(other.optlist)
... | python | def filter(self, other):
"""
Throw away those options which are not in the other one.
Returns a new instance with the rejected options.
"""
self.canonify()
other.canonify()
rej = self.__class__()
rej.optlist = self.optlist.difference(other.optlist)
... | [
"def",
"filter",
"(",
"self",
",",
"other",
")",
":",
"self",
".",
"canonify",
"(",
")",
"other",
".",
"canonify",
"(",
")",
"rej",
"=",
"self",
".",
"__class__",
"(",
")",
"rej",
".",
"optlist",
"=",
"self",
".",
"optlist",
".",
"difference",
"(",... | Throw away those options which are not in the other one.
Returns a new instance with the rejected options. | [
"Throw",
"away",
"those",
"options",
"which",
"are",
"not",
"in",
"the",
"other",
"one",
".",
"Returns",
"a",
"new",
"instance",
"with",
"the",
"rejected",
"options",
"."
] | 2c088b657ad71faca6975b456f80b7d2c2cea2a7 | https://github.com/libfuse/python-fuse/blob/2c088b657ad71faca6975b456f80b7d2c2cea2a7/fuseparts/subbedopts.py#L59-L76 | train |
libfuse/python-fuse | fuseparts/subbedopts.py | SubOptsHive.add | def add(self, opt, val=None):
"""Add a suboption."""
ov = opt.split('=', 1)
o = ov[0]
v = len(ov) > 1 and ov[1] or None
if (v):
if val != None:
raise AttributeError("ambiguous option value")
val = v
if val == False:
r... | python | def add(self, opt, val=None):
"""Add a suboption."""
ov = opt.split('=', 1)
o = ov[0]
v = len(ov) > 1 and ov[1] or None
if (v):
if val != None:
raise AttributeError("ambiguous option value")
val = v
if val == False:
r... | [
"def",
"add",
"(",
"self",
",",
"opt",
",",
"val",
"=",
"None",
")",
":",
"ov",
"=",
"opt",
".",
"split",
"(",
"'='",
",",
"1",
")",
"o",
"=",
"ov",
"[",
"0",
"]",
"v",
"=",
"len",
"(",
"ov",
")",
">",
"1",
"and",
"ov",
"[",
"1",
"]",
... | Add a suboption. | [
"Add",
"a",
"suboption",
"."
] | 2c088b657ad71faca6975b456f80b7d2c2cea2a7 | https://github.com/libfuse/python-fuse/blob/2c088b657ad71faca6975b456f80b7d2c2cea2a7/fuseparts/subbedopts.py#L78-L96 | train |
libfuse/python-fuse | fuseparts/subbedopts.py | SubbedOpt.register_sub | def register_sub(self, o):
"""Register argument a suboption for `self`."""
if o.subopt in self.subopt_map:
raise OptionConflictError(
"conflicting suboption handlers for `%s'" % o.subopt,
o)
self.subopt_map[o.subopt] = o | python | def register_sub(self, o):
"""Register argument a suboption for `self`."""
if o.subopt in self.subopt_map:
raise OptionConflictError(
"conflicting suboption handlers for `%s'" % o.subopt,
o)
self.subopt_map[o.subopt] = o | [
"def",
"register_sub",
"(",
"self",
",",
"o",
")",
":",
"if",
"o",
".",
"subopt",
"in",
"self",
".",
"subopt_map",
":",
"raise",
"OptionConflictError",
"(",
"\"conflicting suboption handlers for `%s'\"",
"%",
"o",
".",
"subopt",
",",
"o",
")",
"self",
".",
... | Register argument a suboption for `self`. | [
"Register",
"argument",
"a",
"suboption",
"for",
"self",
"."
] | 2c088b657ad71faca6975b456f80b7d2c2cea2a7 | https://github.com/libfuse/python-fuse/blob/2c088b657ad71faca6975b456f80b7d2c2cea2a7/fuseparts/subbedopts.py#L170-L177 | train |
tasdikrahman/vocabulary | vocabulary/vocabulary.py | Vocabulary.__parse_content | def __parse_content(tuc_content, content_to_be_parsed):
"""
parses the passed "tuc_content" for
- meanings
- synonym
received by querying the glosbe API
Called by
- meaning()
- synonym()
:param tuc_content: passed on the calling Function. A l... | python | def __parse_content(tuc_content, content_to_be_parsed):
"""
parses the passed "tuc_content" for
- meanings
- synonym
received by querying the glosbe API
Called by
- meaning()
- synonym()
:param tuc_content: passed on the calling Function. A l... | [
"def",
"__parse_content",
"(",
"tuc_content",
",",
"content_to_be_parsed",
")",
":",
"initial_parsed_content",
"=",
"{",
"}",
"i",
"=",
"0",
"for",
"content_dict",
"in",
"tuc_content",
":",
"if",
"content_to_be_parsed",
"in",
"content_dict",
".",
"keys",
"(",
")... | parses the passed "tuc_content" for
- meanings
- synonym
received by querying the glosbe API
Called by
- meaning()
- synonym()
:param tuc_content: passed on the calling Function. A list object
:param content_to_be_parsed: data to be parsed from. Whet... | [
"parses",
"the",
"passed",
"tuc_content",
"for",
"-",
"meanings",
"-",
"synonym",
"received",
"by",
"querying",
"the",
"glosbe",
"API"
] | 54403c5981af25dc3457796b57048ae27f09e9be | https://github.com/tasdikrahman/vocabulary/blob/54403c5981af25dc3457796b57048ae27f09e9be/vocabulary/vocabulary.py#L96-L136 | train |
tasdikrahman/vocabulary | vocabulary/vocabulary.py | Vocabulary.meaning | def meaning(phrase, source_lang="en", dest_lang="en", format="json"):
"""
make calls to the glosbe API
:param phrase: word for which meaning is to be found
:param source_lang: Defaults to : "en"
:param dest_lang: Defaults to : "en" For eg: "fr" for french
:param format: ... | python | def meaning(phrase, source_lang="en", dest_lang="en", format="json"):
"""
make calls to the glosbe API
:param phrase: word for which meaning is to be found
:param source_lang: Defaults to : "en"
:param dest_lang: Defaults to : "en" For eg: "fr" for french
:param format: ... | [
"def",
"meaning",
"(",
"phrase",
",",
"source_lang",
"=",
"\"en\"",
",",
"dest_lang",
"=",
"\"en\"",
",",
"format",
"=",
"\"json\"",
")",
":",
"base_url",
"=",
"Vocabulary",
".",
"__get_api_link",
"(",
"\"glosbe\"",
")",
"url",
"=",
"base_url",
".",
"forma... | make calls to the glosbe API
:param phrase: word for which meaning is to be found
:param source_lang: Defaults to : "en"
:param dest_lang: Defaults to : "en" For eg: "fr" for french
:param format: response structure type. Defaults to: "json"
:returns: returns a json object as st... | [
"make",
"calls",
"to",
"the",
"glosbe",
"API"
] | 54403c5981af25dc3457796b57048ae27f09e9be | https://github.com/tasdikrahman/vocabulary/blob/54403c5981af25dc3457796b57048ae27f09e9be/vocabulary/vocabulary.py#L161-L186 | train |
tasdikrahman/vocabulary | vocabulary/vocabulary.py | Vocabulary.part_of_speech | def part_of_speech(phrase, format='json'):
"""
querrying Wordnik's API for knowing whether the word is a noun, adjective and the like
:params phrase: word for which part_of_speech is to be found
:param format: response structure type. Defaults to: "json"
:returns: returns a json... | python | def part_of_speech(phrase, format='json'):
"""
querrying Wordnik's API for knowing whether the word is a noun, adjective and the like
:params phrase: word for which part_of_speech is to be found
:param format: response structure type. Defaults to: "json"
:returns: returns a json... | [
"def",
"part_of_speech",
"(",
"phrase",
",",
"format",
"=",
"'json'",
")",
":",
"# We get a list object as a return value from the Wordnik API",
"base_url",
"=",
"Vocabulary",
".",
"__get_api_link",
"(",
"\"wordnik\"",
")",
"url",
"=",
"base_url",
".",
"format",
"(",
... | querrying Wordnik's API for knowing whether the word is a noun, adjective and the like
:params phrase: word for which part_of_speech is to be found
:param format: response structure type. Defaults to: "json"
:returns: returns a json object as str, False if invalid phrase | [
"querrying",
"Wordnik",
"s",
"API",
"for",
"knowing",
"whether",
"the",
"word",
"is",
"a",
"noun",
"adjective",
"and",
"the",
"like"
] | 54403c5981af25dc3457796b57048ae27f09e9be | https://github.com/tasdikrahman/vocabulary/blob/54403c5981af25dc3457796b57048ae27f09e9be/vocabulary/vocabulary.py#L304-L326 | train |
tasdikrahman/vocabulary | vocabulary/vocabulary.py | Vocabulary.usage_example | def usage_example(phrase, format='json'):
"""Takes the source phrase and queries it to the urbandictionary API
:params phrase: word for which usage_example is to be found
:param format: response structure type. Defaults to: "json"
:returns: returns a json object as str, False if invalid... | python | def usage_example(phrase, format='json'):
"""Takes the source phrase and queries it to the urbandictionary API
:params phrase: word for which usage_example is to be found
:param format: response structure type. Defaults to: "json"
:returns: returns a json object as str, False if invalid... | [
"def",
"usage_example",
"(",
"phrase",
",",
"format",
"=",
"'json'",
")",
":",
"base_url",
"=",
"Vocabulary",
".",
"__get_api_link",
"(",
"\"urbandict\"",
")",
"url",
"=",
"base_url",
".",
"format",
"(",
"action",
"=",
"\"define\"",
",",
"word",
"=",
"phra... | Takes the source phrase and queries it to the urbandictionary API
:params phrase: word for which usage_example is to be found
:param format: response structure type. Defaults to: "json"
:returns: returns a json object as str, False if invalid phrase | [
"Takes",
"the",
"source",
"phrase",
"and",
"queries",
"it",
"to",
"the",
"urbandictionary",
"API"
] | 54403c5981af25dc3457796b57048ae27f09e9be | https://github.com/tasdikrahman/vocabulary/blob/54403c5981af25dc3457796b57048ae27f09e9be/vocabulary/vocabulary.py#L329-L353 | train |
tasdikrahman/vocabulary | vocabulary/vocabulary.py | Vocabulary.pronunciation | def pronunciation(phrase, format='json'):
"""
Gets the pronunciation from the Wordnik API
:params phrase: word for which pronunciation is to be found
:param format: response structure type. Defaults to: "json"
:returns: returns a list object, False if invalid phrase
"""
... | python | def pronunciation(phrase, format='json'):
"""
Gets the pronunciation from the Wordnik API
:params phrase: word for which pronunciation is to be found
:param format: response structure type. Defaults to: "json"
:returns: returns a list object, False if invalid phrase
"""
... | [
"def",
"pronunciation",
"(",
"phrase",
",",
"format",
"=",
"'json'",
")",
":",
"base_url",
"=",
"Vocabulary",
".",
"__get_api_link",
"(",
"\"wordnik\"",
")",
"url",
"=",
"base_url",
".",
"format",
"(",
"word",
"=",
"phrase",
".",
"lower",
"(",
")",
",",
... | Gets the pronunciation from the Wordnik API
:params phrase: word for which pronunciation is to be found
:param format: response structure type. Defaults to: "json"
:returns: returns a list object, False if invalid phrase | [
"Gets",
"the",
"pronunciation",
"from",
"the",
"Wordnik",
"API"
] | 54403c5981af25dc3457796b57048ae27f09e9be | https://github.com/tasdikrahman/vocabulary/blob/54403c5981af25dc3457796b57048ae27f09e9be/vocabulary/vocabulary.py#L356-L383 | train |
tasdikrahman/vocabulary | vocabulary/vocabulary.py | Vocabulary.hyphenation | def hyphenation(phrase, format='json'):
"""
Returns back the stress points in the "phrase" passed
:param phrase: word for which hyphenation is to be found
:param format: response structure type. Defaults to: "json"
:returns: returns a json object as str, False if invalid phrase
... | python | def hyphenation(phrase, format='json'):
"""
Returns back the stress points in the "phrase" passed
:param phrase: word for which hyphenation is to be found
:param format: response structure type. Defaults to: "json"
:returns: returns a json object as str, False if invalid phrase
... | [
"def",
"hyphenation",
"(",
"phrase",
",",
"format",
"=",
"'json'",
")",
":",
"base_url",
"=",
"Vocabulary",
".",
"__get_api_link",
"(",
"\"wordnik\"",
")",
"url",
"=",
"base_url",
".",
"format",
"(",
"word",
"=",
"phrase",
".",
"lower",
"(",
")",
",",
... | Returns back the stress points in the "phrase" passed
:param phrase: word for which hyphenation is to be found
:param format: response structure type. Defaults to: "json"
:returns: returns a json object as str, False if invalid phrase | [
"Returns",
"back",
"the",
"stress",
"points",
"in",
"the",
"phrase",
"passed"
] | 54403c5981af25dc3457796b57048ae27f09e9be | https://github.com/tasdikrahman/vocabulary/blob/54403c5981af25dc3457796b57048ae27f09e9be/vocabulary/vocabulary.py#L386-L402 | train |
tasdikrahman/vocabulary | vocabulary/responselib.py | Response.__respond_with_dict | def __respond_with_dict(self, data):
"""
Builds a python dictionary from a json object
:param data: the json object
:returns: a nested dictionary
"""
response = {}
if isinstance(data, list):
temp_data, data = data, {}
for key, value in enu... | python | def __respond_with_dict(self, data):
"""
Builds a python dictionary from a json object
:param data: the json object
:returns: a nested dictionary
"""
response = {}
if isinstance(data, list):
temp_data, data = data, {}
for key, value in enu... | [
"def",
"__respond_with_dict",
"(",
"self",
",",
"data",
")",
":",
"response",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"data",
",",
"list",
")",
":",
"temp_data",
",",
"data",
"=",
"data",
",",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"enumerate",
... | Builds a python dictionary from a json object
:param data: the json object
:returns: a nested dictionary | [
"Builds",
"a",
"python",
"dictionary",
"from",
"a",
"json",
"object"
] | 54403c5981af25dc3457796b57048ae27f09e9be | https://github.com/tasdikrahman/vocabulary/blob/54403c5981af25dc3457796b57048ae27f09e9be/vocabulary/responselib.py#L39-L62 | train |
tasdikrahman/vocabulary | vocabulary/responselib.py | Response.__respond_with_list | def __respond_with_list(self, data):
"""
Builds a python list from a json object
:param data: the json object
:returns: a nested list
"""
response = []
if isinstance(data, dict):
data.pop('seq', None)
data = list(data.values())
fo... | python | def __respond_with_list(self, data):
"""
Builds a python list from a json object
:param data: the json object
:returns: a nested list
"""
response = []
if isinstance(data, dict):
data.pop('seq', None)
data = list(data.values())
fo... | [
"def",
"__respond_with_list",
"(",
"self",
",",
"data",
")",
":",
"response",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"data",
".",
"pop",
"(",
"'seq'",
",",
"None",
")",
"data",
"=",
"list",
"(",
"data",
".",
"values"... | Builds a python list from a json object
:param data: the json object
:returns: a nested list | [
"Builds",
"a",
"python",
"list",
"from",
"a",
"json",
"object"
] | 54403c5981af25dc3457796b57048ae27f09e9be | https://github.com/tasdikrahman/vocabulary/blob/54403c5981af25dc3457796b57048ae27f09e9be/vocabulary/responselib.py#L64-L86 | train |
tasdikrahman/vocabulary | vocabulary/responselib.py | Response.respond | def respond(self, data, format='json'):
"""
Converts a json object to a python datastructure based on
specified format
:param data: the json object
:param format: python datastructure type. Defaults to: "json"
:returns: a python specified object
"""
dispa... | python | def respond(self, data, format='json'):
"""
Converts a json object to a python datastructure based on
specified format
:param data: the json object
:param format: python datastructure type. Defaults to: "json"
:returns: a python specified object
"""
dispa... | [
"def",
"respond",
"(",
"self",
",",
"data",
",",
"format",
"=",
"'json'",
")",
":",
"dispatchers",
"=",
"{",
"\"dict\"",
":",
"self",
".",
"__respond_with_dict",
",",
"\"list\"",
":",
"self",
".",
"__respond_with_list",
"}",
"if",
"not",
"dispatchers",
"."... | Converts a json object to a python datastructure based on
specified format
:param data: the json object
:param format: python datastructure type. Defaults to: "json"
:returns: a python specified object | [
"Converts",
"a",
"json",
"object",
"to",
"a",
"python",
"datastructure",
"based",
"on",
"specified",
"format"
] | 54403c5981af25dc3457796b57048ae27f09e9be | https://github.com/tasdikrahman/vocabulary/blob/54403c5981af25dc3457796b57048ae27f09e9be/vocabulary/responselib.py#L88-L105 | train |
bram85/topydo | topydo/lib/MultiCommand.py | MultiCommand.get_todos | def get_todos(self):
""" Gets todo objects from supplied todo IDs. """
if self.is_expression:
self.get_todos_from_expr()
else:
if self.last_argument:
numbers = self.args[:-1]
else:
numbers = self.args
for number in ... | python | def get_todos(self):
""" Gets todo objects from supplied todo IDs. """
if self.is_expression:
self.get_todos_from_expr()
else:
if self.last_argument:
numbers = self.args[:-1]
else:
numbers = self.args
for number in ... | [
"def",
"get_todos",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_expression",
":",
"self",
".",
"get_todos_from_expr",
"(",
")",
"else",
":",
"if",
"self",
".",
"last_argument",
":",
"numbers",
"=",
"self",
".",
"args",
"[",
":",
"-",
"1",
"]",
"els... | Gets todo objects from supplied todo IDs. | [
"Gets",
"todo",
"objects",
"from",
"supplied",
"todo",
"IDs",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/MultiCommand.py#L64-L78 | train |
bram85/topydo | topydo/ui/columns/TodoWidget.py | _markup | def _markup(p_todo, p_focus):
"""
Returns an attribute spec for the colors that correspond to the given todo
item.
"""
pri = p_todo.priority()
pri = 'pri_' + pri if pri else PaletteItem.DEFAULT
if not p_focus:
attr_dict = {None: pri}
else:
# use '_focus' palette entries ... | python | def _markup(p_todo, p_focus):
"""
Returns an attribute spec for the colors that correspond to the given todo
item.
"""
pri = p_todo.priority()
pri = 'pri_' + pri if pri else PaletteItem.DEFAULT
if not p_focus:
attr_dict = {None: pri}
else:
# use '_focus' palette entries ... | [
"def",
"_markup",
"(",
"p_todo",
",",
"p_focus",
")",
":",
"pri",
"=",
"p_todo",
".",
"priority",
"(",
")",
"pri",
"=",
"'pri_'",
"+",
"pri",
"if",
"pri",
"else",
"PaletteItem",
".",
"DEFAULT",
"if",
"not",
"p_focus",
":",
"attr_dict",
"=",
"{",
"Non... | Returns an attribute spec for the colors that correspond to the given todo
item. | [
"Returns",
"an",
"attribute",
"spec",
"for",
"the",
"colors",
"that",
"correspond",
"to",
"the",
"given",
"todo",
"item",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/ui/columns/TodoWidget.py#L35-L53 | train |
bram85/topydo | topydo/ui/columns/TodoWidget.py | TodoWidget.create | def create(p_class, p_todo, p_id_width=4):
"""
Creates a TodoWidget instance for the given todo. Widgets are
cached, the same object is returned for the same todo item.
"""
def parent_progress_may_have_changed(p_todo):
"""
Returns True when a todo's progr... | python | def create(p_class, p_todo, p_id_width=4):
"""
Creates a TodoWidget instance for the given todo. Widgets are
cached, the same object is returned for the same todo item.
"""
def parent_progress_may_have_changed(p_todo):
"""
Returns True when a todo's progr... | [
"def",
"create",
"(",
"p_class",
",",
"p_todo",
",",
"p_id_width",
"=",
"4",
")",
":",
"def",
"parent_progress_may_have_changed",
"(",
"p_todo",
")",
":",
"\"\"\"\n Returns True when a todo's progress should be updated because it is\n dependent on the parent... | Creates a TodoWidget instance for the given todo. Widgets are
cached, the same object is returned for the same todo item. | [
"Creates",
"a",
"TodoWidget",
"instance",
"for",
"the",
"given",
"todo",
".",
"Widgets",
"are",
"cached",
"the",
"same",
"object",
"is",
"returned",
"for",
"the",
"same",
"todo",
"item",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/ui/columns/TodoWidget.py#L164-L195 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.