id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
11,200 | Gandi/gandi.cli | gandi/cli/commands/config.py | get | def get(gandi, g, key):
"""Display value of a given config key."""
val = gandi.get(key=key, global_=g)
if not val:
gandi.echo("No value found.")
sys.exit(1)
gandi.echo(val) | python | def get(gandi, g, key):
"""Display value of a given config key."""
val = gandi.get(key=key, global_=g)
if not val:
gandi.echo("No value found.")
sys.exit(1)
gandi.echo(val) | [
"def",
"get",
"(",
"gandi",
",",
"g",
",",
"key",
")",
":",
"val",
"=",
"gandi",
".",
"get",
"(",
"key",
"=",
"key",
",",
"global_",
"=",
"g",
")",
"if",
"not",
"val",
":",
"gandi",
".",
"echo",
"(",
"\"No value found.\"",
")",
"sys",
".",
"exi... | Display value of a given config key. | [
"Display",
"value",
"of",
"a",
"given",
"config",
"key",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/config.py#L26-L32 |
11,201 | Gandi/gandi.cli | gandi/cli/commands/config.py | edit | def edit(gandi, g):
"""Edit config file with prefered text editor"""
config_file = gandi.home_config if g else gandi.local_config
path = os.path.expanduser(config_file)
editor = gandi.get('editor')
if not editor:
try:
editor = click.prompt("Please enter the path of your prefered ... | python | def edit(gandi, g):
"""Edit config file with prefered text editor"""
config_file = gandi.home_config if g else gandi.local_config
path = os.path.expanduser(config_file)
editor = gandi.get('editor')
if not editor:
try:
editor = click.prompt("Please enter the path of your prefered ... | [
"def",
"edit",
"(",
"gandi",
",",
"g",
")",
":",
"config_file",
"=",
"gandi",
".",
"home_config",
"if",
"g",
"else",
"gandi",
".",
"local_config",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"config_file",
")",
"editor",
"=",
"gandi",
".",
... | Edit config file with prefered text editor | [
"Edit",
"config",
"file",
"with",
"prefered",
"text",
"editor"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/config.py#L50-L66 |
11,202 | Gandi/gandi.cli | gandi/cli/modules/webacc.py | Webacc.delete | def delete(cls, name):
""" Delete a webaccelerator """
result = cls.call('hosting.rproxy.delete', cls.usable_id(name))
cls.echo('Deleting your webaccelerator named %s' % name)
cls.display_progress(result)
cls.echo('Webaccelerator have been deleted')
return result | python | def delete(cls, name):
""" Delete a webaccelerator """
result = cls.call('hosting.rproxy.delete', cls.usable_id(name))
cls.echo('Deleting your webaccelerator named %s' % name)
cls.display_progress(result)
cls.echo('Webaccelerator have been deleted')
return result | [
"def",
"delete",
"(",
"cls",
",",
"name",
")",
":",
"result",
"=",
"cls",
".",
"call",
"(",
"'hosting.rproxy.delete'",
",",
"cls",
".",
"usable_id",
"(",
"name",
")",
")",
"cls",
".",
"echo",
"(",
"'Deleting your webaccelerator named %s'",
"%",
"name",
")"... | Delete a webaccelerator | [
"Delete",
"a",
"webaccelerator"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L104-L110 |
11,203 | Gandi/gandi.cli | gandi/cli/modules/webacc.py | Webacc.backend_add | def backend_add(cls, name, backend):
""" Add a backend into a webaccelerator """
oper = cls.call(
'hosting.rproxy.server.create', cls.usable_id(name), backend)
cls.echo('Adding backend %s:%s into webaccelerator' %
(backend['ip'], backend['port']))
cls.display... | python | def backend_add(cls, name, backend):
""" Add a backend into a webaccelerator """
oper = cls.call(
'hosting.rproxy.server.create', cls.usable_id(name), backend)
cls.echo('Adding backend %s:%s into webaccelerator' %
(backend['ip'], backend['port']))
cls.display... | [
"def",
"backend_add",
"(",
"cls",
",",
"name",
",",
"backend",
")",
":",
"oper",
"=",
"cls",
".",
"call",
"(",
"'hosting.rproxy.server.create'",
",",
"cls",
".",
"usable_id",
"(",
"name",
")",
",",
"backend",
")",
"cls",
".",
"echo",
"(",
"'Adding backen... | Add a backend into a webaccelerator | [
"Add",
"a",
"backend",
"into",
"a",
"webaccelerator"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L118-L126 |
11,204 | Gandi/gandi.cli | gandi/cli/modules/webacc.py | Webacc.backend_disable | def backend_disable(cls, backend):
""" Disable a backend for a server """
server = cls.backend_list(backend)
oper = cls.call('hosting.rproxy.server.disable',
server[0]['id'])
cls.echo('Desactivating backend on server %s' %
server[0]['ip'])
... | python | def backend_disable(cls, backend):
""" Disable a backend for a server """
server = cls.backend_list(backend)
oper = cls.call('hosting.rproxy.server.disable',
server[0]['id'])
cls.echo('Desactivating backend on server %s' %
server[0]['ip'])
... | [
"def",
"backend_disable",
"(",
"cls",
",",
"backend",
")",
":",
"server",
"=",
"cls",
".",
"backend_list",
"(",
"backend",
")",
"oper",
"=",
"cls",
".",
"call",
"(",
"'hosting.rproxy.server.disable'",
",",
"server",
"[",
"0",
"]",
"[",
"'id'",
"]",
")",
... | Disable a backend for a server | [
"Disable",
"a",
"backend",
"for",
"a",
"server"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L156-L165 |
11,205 | Gandi/gandi.cli | gandi/cli/modules/webacc.py | Webacc.vhost_add | def vhost_add(cls, resource, params):
""" Add a vhost into a webaccelerator """
try:
oper = cls.call(
'hosting.rproxy.vhost.create', cls.usable_id(resource), params)
cls.echo('Adding your virtual host (%s) into %s' %
(params['vhost'], resource... | python | def vhost_add(cls, resource, params):
""" Add a vhost into a webaccelerator """
try:
oper = cls.call(
'hosting.rproxy.vhost.create', cls.usable_id(resource), params)
cls.echo('Adding your virtual host (%s) into %s' %
(params['vhost'], resource... | [
"def",
"vhost_add",
"(",
"cls",
",",
"resource",
",",
"params",
")",
":",
"try",
":",
"oper",
"=",
"cls",
".",
"call",
"(",
"'hosting.rproxy.vhost.create'",
",",
"cls",
".",
"usable_id",
"(",
"resource",
")",
",",
"params",
")",
"cls",
".",
"echo",
"("... | Add a vhost into a webaccelerator | [
"Add",
"a",
"vhost",
"into",
"a",
"webaccelerator"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L173-L208 |
11,206 | Gandi/gandi.cli | gandi/cli/modules/webacc.py | Webacc.vhost_remove | def vhost_remove(cls, name):
""" Delete a vhost in a webaccelerator """
oper = cls.call('hosting.rproxy.vhost.delete', name)
cls.echo('Deleting your virtual host %s' % name)
cls.display_progress(oper)
cls.echo('Your virtual host have been removed')
return oper | python | def vhost_remove(cls, name):
""" Delete a vhost in a webaccelerator """
oper = cls.call('hosting.rproxy.vhost.delete', name)
cls.echo('Deleting your virtual host %s' % name)
cls.display_progress(oper)
cls.echo('Your virtual host have been removed')
return oper | [
"def",
"vhost_remove",
"(",
"cls",
",",
"name",
")",
":",
"oper",
"=",
"cls",
".",
"call",
"(",
"'hosting.rproxy.vhost.delete'",
",",
"name",
")",
"cls",
".",
"echo",
"(",
"'Deleting your virtual host %s'",
"%",
"name",
")",
"cls",
".",
"display_progress",
"... | Delete a vhost in a webaccelerator | [
"Delete",
"a",
"vhost",
"in",
"a",
"webaccelerator"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L211-L217 |
11,207 | Gandi/gandi.cli | gandi/cli/modules/webacc.py | Webacc.probe | def probe(cls, resource, enable, disable, test, host, interval,
http_method, http_response, threshold, timeout, url, window):
""" Set a probe for a webaccelerator """
params = {
'host': host,
'interval': interval,
'method': http_method,
'resp... | python | def probe(cls, resource, enable, disable, test, host, interval,
http_method, http_response, threshold, timeout, url, window):
""" Set a probe for a webaccelerator """
params = {
'host': host,
'interval': interval,
'method': http_method,
'resp... | [
"def",
"probe",
"(",
"cls",
",",
"resource",
",",
"enable",
",",
"disable",
",",
"test",
",",
"host",
",",
"interval",
",",
"http_method",
",",
"http_response",
",",
"threshold",
",",
"timeout",
",",
"url",
",",
"window",
")",
":",
"params",
"=",
"{",
... | Set a probe for a webaccelerator | [
"Set",
"a",
"probe",
"for",
"a",
"webaccelerator"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L220-L244 |
11,208 | Gandi/gandi.cli | gandi/cli/modules/webacc.py | Webacc.probe_enable | def probe_enable(cls, resource):
""" Activate a probe on a webaccelerator """
oper = cls.call('hosting.rproxy.probe.enable', cls.usable_id(resource))
cls.echo('Activating probe on %s' % resource)
cls.display_progress(oper)
cls.echo('The probe have been activated')
return ... | python | def probe_enable(cls, resource):
""" Activate a probe on a webaccelerator """
oper = cls.call('hosting.rproxy.probe.enable', cls.usable_id(resource))
cls.echo('Activating probe on %s' % resource)
cls.display_progress(oper)
cls.echo('The probe have been activated')
return ... | [
"def",
"probe_enable",
"(",
"cls",
",",
"resource",
")",
":",
"oper",
"=",
"cls",
".",
"call",
"(",
"'hosting.rproxy.probe.enable'",
",",
"cls",
".",
"usable_id",
"(",
"resource",
")",
")",
"cls",
".",
"echo",
"(",
"'Activating probe on %s'",
"%",
"resource"... | Activate a probe on a webaccelerator | [
"Activate",
"a",
"probe",
"on",
"a",
"webaccelerator"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L247-L253 |
11,209 | Gandi/gandi.cli | gandi/cli/modules/webacc.py | Webacc.probe_disable | def probe_disable(cls, resource):
""" Disable a probe on a webaccelerator """
oper = cls.call('hosting.rproxy.probe.disable',
cls.usable_id(resource))
cls.echo('Desactivating probe on %s' % resource)
cls.display_progress(oper)
cls.echo('The probe have been... | python | def probe_disable(cls, resource):
""" Disable a probe on a webaccelerator """
oper = cls.call('hosting.rproxy.probe.disable',
cls.usable_id(resource))
cls.echo('Desactivating probe on %s' % resource)
cls.display_progress(oper)
cls.echo('The probe have been... | [
"def",
"probe_disable",
"(",
"cls",
",",
"resource",
")",
":",
"oper",
"=",
"cls",
".",
"call",
"(",
"'hosting.rproxy.probe.disable'",
",",
"cls",
".",
"usable_id",
"(",
"resource",
")",
")",
"cls",
".",
"echo",
"(",
"'Desactivating probe on %s'",
"%",
"reso... | Disable a probe on a webaccelerator | [
"Disable",
"a",
"probe",
"on",
"a",
"webaccelerator"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L256-L263 |
11,210 | Gandi/gandi.cli | gandi/cli/modules/webacc.py | Webacc.usable_id | def usable_id(cls, id):
""" Retrieve id from input which can be hostname, vhost, id. """
try:
# id is maybe a hostname
qry_id = cls.from_name(id)
if not qry_id:
# id is maybe an ip
qry_id = cls.from_ip(id)
if not qry_id:
... | python | def usable_id(cls, id):
""" Retrieve id from input which can be hostname, vhost, id. """
try:
# id is maybe a hostname
qry_id = cls.from_name(id)
if not qry_id:
# id is maybe an ip
qry_id = cls.from_ip(id)
if not qry_id:
... | [
"def",
"usable_id",
"(",
"cls",
",",
"id",
")",
":",
"try",
":",
"# id is maybe a hostname",
"qry_id",
"=",
"cls",
".",
"from_name",
"(",
"id",
")",
"if",
"not",
"qry_id",
":",
"# id is maybe an ip",
"qry_id",
"=",
"cls",
".",
"from_ip",
"(",
"id",
")",
... | Retrieve id from input which can be hostname, vhost, id. | [
"Retrieve",
"id",
"from",
"input",
"which",
"can",
"be",
"hostname",
"vhost",
"id",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L266-L283 |
11,211 | Gandi/gandi.cli | gandi/cli/modules/webacc.py | Webacc.from_name | def from_name(cls, name):
"""Retrieve webacc id associated to a webacc name."""
result = cls.list({'items_per_page': 500})
webaccs = {}
for webacc in result:
webaccs[webacc['name']] = webacc['id']
return webaccs.get(name) | python | def from_name(cls, name):
"""Retrieve webacc id associated to a webacc name."""
result = cls.list({'items_per_page': 500})
webaccs = {}
for webacc in result:
webaccs[webacc['name']] = webacc['id']
return webaccs.get(name) | [
"def",
"from_name",
"(",
"cls",
",",
"name",
")",
":",
"result",
"=",
"cls",
".",
"list",
"(",
"{",
"'items_per_page'",
":",
"500",
"}",
")",
"webaccs",
"=",
"{",
"}",
"for",
"webacc",
"in",
"result",
":",
"webaccs",
"[",
"webacc",
"[",
"'name'",
"... | Retrieve webacc id associated to a webacc name. | [
"Retrieve",
"webacc",
"id",
"associated",
"to",
"a",
"webacc",
"name",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L286-L292 |
11,212 | Gandi/gandi.cli | gandi/cli/modules/webacc.py | Webacc.from_ip | def from_ip(cls, ip):
"""Retrieve webacc id associated to a webacc ip"""
result = cls.list({'items_per_page': 500})
webaccs = {}
for webacc in result:
for server in webacc['servers']:
webaccs[server['ip']] = webacc['id']
return webaccs.get(ip) | python | def from_ip(cls, ip):
"""Retrieve webacc id associated to a webacc ip"""
result = cls.list({'items_per_page': 500})
webaccs = {}
for webacc in result:
for server in webacc['servers']:
webaccs[server['ip']] = webacc['id']
return webaccs.get(ip) | [
"def",
"from_ip",
"(",
"cls",
",",
"ip",
")",
":",
"result",
"=",
"cls",
".",
"list",
"(",
"{",
"'items_per_page'",
":",
"500",
"}",
")",
"webaccs",
"=",
"{",
"}",
"for",
"webacc",
"in",
"result",
":",
"for",
"server",
"in",
"webacc",
"[",
"'server... | Retrieve webacc id associated to a webacc ip | [
"Retrieve",
"webacc",
"id",
"associated",
"to",
"a",
"webacc",
"ip"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L295-L302 |
11,213 | Gandi/gandi.cli | gandi/cli/modules/webacc.py | Webacc.from_vhost | def from_vhost(cls, vhost):
"""Retrieve webbacc id associated to a webacc vhost"""
result = cls.list({'items_per_page': 500})
webaccs = {}
for webacc in result:
for vhost in webacc['vhosts']:
webaccs[vhost['name']] = webacc['id']
return webaccs.get(vho... | python | def from_vhost(cls, vhost):
"""Retrieve webbacc id associated to a webacc vhost"""
result = cls.list({'items_per_page': 500})
webaccs = {}
for webacc in result:
for vhost in webacc['vhosts']:
webaccs[vhost['name']] = webacc['id']
return webaccs.get(vho... | [
"def",
"from_vhost",
"(",
"cls",
",",
"vhost",
")",
":",
"result",
"=",
"cls",
".",
"list",
"(",
"{",
"'items_per_page'",
":",
"500",
"}",
")",
"webaccs",
"=",
"{",
"}",
"for",
"webacc",
"in",
"result",
":",
"for",
"vhost",
"in",
"webacc",
"[",
"'v... | Retrieve webbacc id associated to a webacc vhost | [
"Retrieve",
"webbacc",
"id",
"associated",
"to",
"a",
"webacc",
"vhost"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L305-L312 |
11,214 | Gandi/gandi.cli | gandi/cli/modules/status.py | Status.descriptions | def descriptions(cls):
""" Retrieve status descriptions from status.gandi.net. """
schema = cls.json_get('%s/status/schema' % cls.api_url, empty_key=True,
send_key=False)
descs = {}
for val in schema['fields']['status']['value']:
descs.update(val... | python | def descriptions(cls):
""" Retrieve status descriptions from status.gandi.net. """
schema = cls.json_get('%s/status/schema' % cls.api_url, empty_key=True,
send_key=False)
descs = {}
for val in schema['fields']['status']['value']:
descs.update(val... | [
"def",
"descriptions",
"(",
"cls",
")",
":",
"schema",
"=",
"cls",
".",
"json_get",
"(",
"'%s/status/schema'",
"%",
"cls",
".",
"api_url",
",",
"empty_key",
"=",
"True",
",",
"send_key",
"=",
"False",
")",
"descs",
"=",
"{",
"}",
"for",
"val",
"in",
... | Retrieve status descriptions from status.gandi.net. | [
"Retrieve",
"status",
"descriptions",
"from",
"status",
".",
"gandi",
".",
"net",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/status.py#L23-L30 |
11,215 | Gandi/gandi.cli | gandi/cli/modules/status.py | Status.services | def services(cls):
"""Retrieve services statuses from status.gandi.net."""
return cls.json_get('%s/services' % cls.api_url, empty_key=True,
send_key=False) | python | def services(cls):
"""Retrieve services statuses from status.gandi.net."""
return cls.json_get('%s/services' % cls.api_url, empty_key=True,
send_key=False) | [
"def",
"services",
"(",
"cls",
")",
":",
"return",
"cls",
".",
"json_get",
"(",
"'%s/services'",
"%",
"cls",
".",
"api_url",
",",
"empty_key",
"=",
"True",
",",
"send_key",
"=",
"False",
")"
] | Retrieve services statuses from status.gandi.net. | [
"Retrieve",
"services",
"statuses",
"from",
"status",
".",
"gandi",
".",
"net",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/status.py#L33-L36 |
11,216 | Gandi/gandi.cli | gandi/cli/modules/status.py | Status.status | def status(cls):
"""Retrieve global status from status.gandi.net."""
return cls.json_get('%s/status' % cls.api_url, empty_key=True,
send_key=False) | python | def status(cls):
"""Retrieve global status from status.gandi.net."""
return cls.json_get('%s/status' % cls.api_url, empty_key=True,
send_key=False) | [
"def",
"status",
"(",
"cls",
")",
":",
"return",
"cls",
".",
"json_get",
"(",
"'%s/status'",
"%",
"cls",
".",
"api_url",
",",
"empty_key",
"=",
"True",
",",
"send_key",
"=",
"False",
")"
] | Retrieve global status from status.gandi.net. | [
"Retrieve",
"global",
"status",
"from",
"status",
".",
"gandi",
".",
"net",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/status.py#L39-L42 |
11,217 | Gandi/gandi.cli | gandi/cli/modules/status.py | Status.events | def events(cls, filters):
"""Retrieve events details from status.gandi.net."""
current = filters.pop('current', False)
current_params = []
if current:
current_params = [('current', 'true')]
filter_url = uparse.urlencode(sorted(list(filters.items())) + current_params)... | python | def events(cls, filters):
"""Retrieve events details from status.gandi.net."""
current = filters.pop('current', False)
current_params = []
if current:
current_params = [('current', 'true')]
filter_url = uparse.urlencode(sorted(list(filters.items())) + current_params)... | [
"def",
"events",
"(",
"cls",
",",
"filters",
")",
":",
"current",
"=",
"filters",
".",
"pop",
"(",
"'current'",
",",
"False",
")",
"current_params",
"=",
"[",
"]",
"if",
"current",
":",
"current_params",
"=",
"[",
"(",
"'current'",
",",
"'true'",
")",
... | Retrieve events details from status.gandi.net. | [
"Retrieve",
"events",
"details",
"from",
"status",
".",
"gandi",
".",
"net",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/status.py#L45-L55 |
11,218 | Gandi/gandi.cli | gandi/cli/commands/paas.py | list | def list(gandi, state, id, vhosts, type, limit):
"""List PaaS instances."""
options = {
'items_per_page': limit,
}
if state:
options['state'] = state
output_keys = ['name', 'state']
if id:
output_keys.append('id')
if vhosts:
output_keys.append('vhost')
if... | python | def list(gandi, state, id, vhosts, type, limit):
"""List PaaS instances."""
options = {
'items_per_page': limit,
}
if state:
options['state'] = state
output_keys = ['name', 'state']
if id:
output_keys.append('id')
if vhosts:
output_keys.append('vhost')
if... | [
"def",
"list",
"(",
"gandi",
",",
"state",
",",
"id",
",",
"vhosts",
",",
"type",
",",
"limit",
")",
":",
"options",
"=",
"{",
"'items_per_page'",
":",
"limit",
",",
"}",
"if",
"state",
":",
"options",
"[",
"'state'",
"]",
"=",
"state",
"output_keys"... | List PaaS instances. | [
"List",
"PaaS",
"instances",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/paas.py#L30-L60 |
11,219 | Gandi/gandi.cli | gandi/cli/commands/paas.py | info | def info(gandi, resource, stat):
"""Display information about a PaaS instance.
Resource can be a vhost, a hostname, or an ID
Cache statistics are based on 24 hours data.
"""
output_keys = ['name', 'type', 'size', 'memory', 'console', 'vhost',
'dc', 'sftp_server', 'git_server', 's... | python | def info(gandi, resource, stat):
"""Display information about a PaaS instance.
Resource can be a vhost, a hostname, or an ID
Cache statistics are based on 24 hours data.
"""
output_keys = ['name', 'type', 'size', 'memory', 'console', 'vhost',
'dc', 'sftp_server', 'git_server', 's... | [
"def",
"info",
"(",
"gandi",
",",
"resource",
",",
"stat",
")",
":",
"output_keys",
"=",
"[",
"'name'",
",",
"'type'",
",",
"'size'",
",",
"'memory'",
",",
"'console'",
",",
"'vhost'",
",",
"'dc'",
",",
"'sftp_server'",
",",
"'git_server'",
",",
"'snapsh... | Display information about a PaaS instance.
Resource can be a vhost, a hostname, or an ID
Cache statistics are based on 24 hours data. | [
"Display",
"information",
"about",
"a",
"PaaS",
"instance",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/paas.py#L68-L93 |
11,220 | Gandi/gandi.cli | gandi/cli/commands/paas.py | clone | def clone(gandi, name, vhost, directory, origin):
"""Clone a remote vhost in a local git repository."""
if vhost != 'default':
directory = vhost
else:
directory = name if not directory else directory
return gandi.paas.clone(name, vhost, directory, origin) | python | def clone(gandi, name, vhost, directory, origin):
"""Clone a remote vhost in a local git repository."""
if vhost != 'default':
directory = vhost
else:
directory = name if not directory else directory
return gandi.paas.clone(name, vhost, directory, origin) | [
"def",
"clone",
"(",
"gandi",
",",
"name",
",",
"vhost",
",",
"directory",
",",
"origin",
")",
":",
"if",
"vhost",
"!=",
"'default'",
":",
"directory",
"=",
"vhost",
"else",
":",
"directory",
"=",
"name",
"if",
"not",
"directory",
"else",
"directory",
... | Clone a remote vhost in a local git repository. | [
"Clone",
"a",
"remote",
"vhost",
"in",
"a",
"local",
"git",
"repository",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/paas.py#L102-L109 |
11,221 | Gandi/gandi.cli | gandi/cli/commands/paas.py | attach | def attach(gandi, name, vhost, remote):
"""Add remote for an instance's default vhost to the local git repository.
"""
return gandi.paas.attach(name, vhost, remote) | python | def attach(gandi, name, vhost, remote):
"""Add remote for an instance's default vhost to the local git repository.
"""
return gandi.paas.attach(name, vhost, remote) | [
"def",
"attach",
"(",
"gandi",
",",
"name",
",",
"vhost",
",",
"remote",
")",
":",
"return",
"gandi",
".",
"paas",
".",
"attach",
"(",
"name",
",",
"vhost",
",",
"remote",
")"
] | Add remote for an instance's default vhost to the local git repository. | [
"Add",
"remote",
"for",
"an",
"instance",
"s",
"default",
"vhost",
"to",
"the",
"local",
"git",
"repository",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/paas.py#L119-L122 |
11,222 | Gandi/gandi.cli | gandi/cli/commands/paas.py | create | def create(gandi, name, size, type, quantity, duration, datacenter, vhosts,
password, snapshotprofile, background, sshkey, ssl, private_key,
poll_cert):
"""Create a new PaaS instance and initialize associated git repository.
you can specify a configuration entry named 'sshkey' containing
... | python | def create(gandi, name, size, type, quantity, duration, datacenter, vhosts,
password, snapshotprofile, background, sshkey, ssl, private_key,
poll_cert):
"""Create a new PaaS instance and initialize associated git repository.
you can specify a configuration entry named 'sshkey' containing
... | [
"def",
"create",
"(",
"gandi",
",",
"name",
",",
"size",
",",
"type",
",",
"quantity",
",",
"duration",
",",
"datacenter",
",",
"vhosts",
",",
"password",
",",
"snapshotprofile",
",",
"background",
",",
"sshkey",
",",
"ssl",
",",
"private_key",
",",
"pol... | Create a new PaaS instance and initialize associated git repository.
you can specify a configuration entry named 'sshkey' containing
path to your sshkey file
$ gandi config set [-g] sshkey ~/.ssh/id_rsa.pub
or getting the sshkey "my_key" from your gandi ssh keyring
$ gandi config set [-g] sshkey... | [
"Create",
"a",
"new",
"PaaS",
"instance",
"and",
"initialize",
"associated",
"git",
"repository",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/paas.py#L207-L249 |
11,223 | Gandi/gandi.cli | gandi/cli/commands/paas.py | restart | def restart(gandi, resource, background, force):
"""Restart a PaaS instance.
Resource can be a vhost, a hostname, or an ID
"""
output_keys = ['id', 'type', 'step']
possible_resources = gandi.paas.resource_list()
for item in resource:
if item not in possible_resources:
gandi... | python | def restart(gandi, resource, background, force):
"""Restart a PaaS instance.
Resource can be a vhost, a hostname, or an ID
"""
output_keys = ['id', 'type', 'step']
possible_resources = gandi.paas.resource_list()
for item in resource:
if item not in possible_resources:
gandi... | [
"def",
"restart",
"(",
"gandi",
",",
"resource",
",",
"background",
",",
"force",
")",
":",
"output_keys",
"=",
"[",
"'id'",
",",
"'type'",
",",
"'step'",
"]",
"possible_resources",
"=",
"gandi",
".",
"paas",
".",
"resource_list",
"(",
")",
"for",
"item"... | Restart a PaaS instance.
Resource can be a vhost, a hostname, or an ID | [
"Restart",
"a",
"PaaS",
"instance",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/paas.py#L315-L343 |
11,224 | Gandi/gandi.cli | gandi/cli/commands/paas.py | types | def types(gandi):
"""List types PaaS instances."""
options = {}
types = gandi.paas.type_list(options)
for type_ in types:
gandi.echo(type_['name'])
return types | python | def types(gandi):
"""List types PaaS instances."""
options = {}
types = gandi.paas.type_list(options)
for type_ in types:
gandi.echo(type_['name'])
return types | [
"def",
"types",
"(",
"gandi",
")",
":",
"options",
"=",
"{",
"}",
"types",
"=",
"gandi",
".",
"paas",
".",
"type_list",
"(",
"options",
")",
"for",
"type_",
"in",
"types",
":",
"gandi",
".",
"echo",
"(",
"type_",
"[",
"'name'",
"]",
")",
"return",
... | List types PaaS instances. | [
"List",
"types",
"PaaS",
"instances",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/paas.py#L348-L355 |
11,225 | Gandi/gandi.cli | gandi/cli/commands/sshkey.py | info | def info(gandi, resource, id, value):
"""Display information about an SSH key.
Resource can be a name or an ID
"""
output_keys = ['name', 'fingerprint']
if id:
output_keys.append('id')
if value:
output_keys.append('value')
ret = []
for item in resource:
sshkey ... | python | def info(gandi, resource, id, value):
"""Display information about an SSH key.
Resource can be a name or an ID
"""
output_keys = ['name', 'fingerprint']
if id:
output_keys.append('id')
if value:
output_keys.append('value')
ret = []
for item in resource:
sshkey ... | [
"def",
"info",
"(",
"gandi",
",",
"resource",
",",
"id",
",",
"value",
")",
":",
"output_keys",
"=",
"[",
"'name'",
",",
"'fingerprint'",
"]",
"if",
"id",
":",
"output_keys",
".",
"append",
"(",
"'id'",
")",
"if",
"value",
":",
"output_keys",
".",
"a... | Display information about an SSH key.
Resource can be a name or an ID | [
"Display",
"information",
"about",
"an",
"SSH",
"key",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/sshkey.py#L47-L64 |
11,226 | Gandi/gandi.cli | gandi/cli/commands/sshkey.py | create | def create(gandi, name, value=None, filename=None):
""" Create a new SSH key. """
if not value and not filename:
raise UsageError('You must set value OR filename.')
if value and filename:
raise UsageError('You must not set value AND filename.')
if filename:
value = filename.rea... | python | def create(gandi, name, value=None, filename=None):
""" Create a new SSH key. """
if not value and not filename:
raise UsageError('You must set value OR filename.')
if value and filename:
raise UsageError('You must not set value AND filename.')
if filename:
value = filename.rea... | [
"def",
"create",
"(",
"gandi",
",",
"name",
",",
"value",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"if",
"not",
"value",
"and",
"not",
"filename",
":",
"raise",
"UsageError",
"(",
"'You must set value OR filename.'",
")",
"if",
"value",
"and",
... | Create a new SSH key. | [
"Create",
"a",
"new",
"SSH",
"key",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/sshkey.py#L72-L86 |
11,227 | Gandi/gandi.cli | gandi/cli/modules/account.py | Account.creditusage | def creditusage(cls):
"""Get credit usage per hour"""
rating = cls.call('hosting.rating.list')
if not rating:
return 0
rating = rating.pop()
usage = [sum(resource.values())
for resource in rating.values()
if isinstance(resource, dict... | python | def creditusage(cls):
"""Get credit usage per hour"""
rating = cls.call('hosting.rating.list')
if not rating:
return 0
rating = rating.pop()
usage = [sum(resource.values())
for resource in rating.values()
if isinstance(resource, dict... | [
"def",
"creditusage",
"(",
"cls",
")",
":",
"rating",
"=",
"cls",
".",
"call",
"(",
"'hosting.rating.list'",
")",
"if",
"not",
"rating",
":",
"return",
"0",
"rating",
"=",
"rating",
".",
"pop",
"(",
")",
"usage",
"=",
"[",
"sum",
"(",
"resource",
"."... | Get credit usage per hour | [
"Get",
"credit",
"usage",
"per",
"hour"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/account.py#L20-L30 |
11,228 | Gandi/gandi.cli | gandi/cli/modules/account.py | Account.all | def all(cls):
""" Get all informations about this account """
account = cls.info()
creditusage = cls.creditusage()
if not creditusage:
return account
left = account['credits'] / creditusage
years, hours = divmod(left, 365 * 24)
months, hours = divmod... | python | def all(cls):
""" Get all informations about this account """
account = cls.info()
creditusage = cls.creditusage()
if not creditusage:
return account
left = account['credits'] / creditusage
years, hours = divmod(left, 365 * 24)
months, hours = divmod... | [
"def",
"all",
"(",
"cls",
")",
":",
"account",
"=",
"cls",
".",
"info",
"(",
")",
"creditusage",
"=",
"cls",
".",
"creditusage",
"(",
")",
"if",
"not",
"creditusage",
":",
"return",
"account",
"left",
"=",
"account",
"[",
"'credits'",
"]",
"/",
"cred... | Get all informations about this account | [
"Get",
"all",
"informations",
"about",
"this",
"account"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/account.py#L33-L49 |
11,229 | Gandi/gandi.cli | gandi/cli/commands/snapshotprofile.py | list | def list(gandi, only_paas, only_vm):
""" List snapshot profiles. """
target = None
if only_paas and not only_vm:
target = 'paas'
if only_vm and not only_paas:
target = 'vm'
output_keys = ['id', 'name', 'kept_total', 'target']
result = gandi.snapshotprofile.list({}, target=target... | python | def list(gandi, only_paas, only_vm):
""" List snapshot profiles. """
target = None
if only_paas and not only_vm:
target = 'paas'
if only_vm and not only_paas:
target = 'vm'
output_keys = ['id', 'name', 'kept_total', 'target']
result = gandi.snapshotprofile.list({}, target=target... | [
"def",
"list",
"(",
"gandi",
",",
"only_paas",
",",
"only_vm",
")",
":",
"target",
"=",
"None",
"if",
"only_paas",
"and",
"not",
"only_vm",
":",
"target",
"=",
"'paas'",
"if",
"only_vm",
"and",
"not",
"only_paas",
":",
"target",
"=",
"'vm'",
"output_keys... | List snapshot profiles. | [
"List",
"snapshot",
"profiles",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/snapshotprofile.py#L20-L36 |
11,230 | Gandi/gandi.cli | gandi/cli/commands/certificate.py | list | def list(gandi, id, altnames, csr, cert, all_status, status, dates, limit):
""" List certificates. """
options = {'items_per_page': limit}
if not all_status:
options['status'] = ['valid', 'pending']
output_keys = ['cn', 'plan']
if id:
output_keys.append('id')
if status:
... | python | def list(gandi, id, altnames, csr, cert, all_status, status, dates, limit):
""" List certificates. """
options = {'items_per_page': limit}
if not all_status:
options['status'] = ['valid', 'pending']
output_keys = ['cn', 'plan']
if id:
output_keys.append('id')
if status:
... | [
"def",
"list",
"(",
"gandi",
",",
"id",
",",
"altnames",
",",
"csr",
",",
"cert",
",",
"all_status",
",",
"status",
",",
"dates",
",",
"limit",
")",
":",
"options",
"=",
"{",
"'items_per_page'",
":",
"limit",
"}",
"if",
"not",
"all_status",
":",
"opt... | List certificates. | [
"List",
"certificates",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/certificate.py#L114-L148 |
11,231 | Gandi/gandi.cli | gandi/cli/commands/certificate.py | info | def info(gandi, resource, id, altnames, csr, cert, all_status):
""" Display information about a certificate.
Resource can be a CN or an ID
"""
output_keys = ['cn', 'date_created', 'date_end', 'plan', 'status']
if id:
output_keys.append('id')
if altnames:
output_keys.append('al... | python | def info(gandi, resource, id, altnames, csr, cert, all_status):
""" Display information about a certificate.
Resource can be a CN or an ID
"""
output_keys = ['cn', 'date_created', 'date_end', 'plan', 'status']
if id:
output_keys.append('id')
if altnames:
output_keys.append('al... | [
"def",
"info",
"(",
"gandi",
",",
"resource",
",",
"id",
",",
"altnames",
",",
"csr",
",",
"cert",
",",
"all_status",
")",
":",
"output_keys",
"=",
"[",
"'cn'",
",",
"'date_created'",
",",
"'date_end'",
",",
"'plan'",
",",
"'status'",
"]",
"if",
"id",
... | Display information about a certificate.
Resource can be a CN or an ID | [
"Display",
"information",
"about",
"a",
"certificate",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/certificate.py#L159-L193 |
11,232 | Gandi/gandi.cli | gandi/cli/commands/certificate.py | update | def update(gandi, resource, csr, private_key, country, state, city,
organisation, branch, altnames, dcv_method):
""" Update a certificate CSR.
Resource can be a CN or an ID
"""
ids = gandi.certificate.usable_ids(resource)
if len(ids) > 1:
gandi.echo('Will not update, %s is not p... | python | def update(gandi, resource, csr, private_key, country, state, city,
organisation, branch, altnames, dcv_method):
""" Update a certificate CSR.
Resource can be a CN or an ID
"""
ids = gandi.certificate.usable_ids(resource)
if len(ids) > 1:
gandi.echo('Will not update, %s is not p... | [
"def",
"update",
"(",
"gandi",
",",
"resource",
",",
"csr",
",",
"private_key",
",",
"country",
",",
"state",
",",
"city",
",",
"organisation",
",",
"branch",
",",
"altnames",
",",
"dcv_method",
")",
":",
"ids",
"=",
"gandi",
".",
"certificate",
".",
"... | Update a certificate CSR.
Resource can be a CN or an ID | [
"Update",
"a",
"certificate",
"CSR",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/certificate.py#L389-L416 |
11,233 | Gandi/gandi.cli | gandi/cli/commands/certificate.py | follow | def follow(gandi, resource):
""" Get the operation status
Resource is an operation ID
"""
oper = gandi.oper.info(int(resource))
assert(oper['type'].startswith('certificate_'))
output_cert_oper(gandi, oper)
return oper | python | def follow(gandi, resource):
""" Get the operation status
Resource is an operation ID
"""
oper = gandi.oper.info(int(resource))
assert(oper['type'].startswith('certificate_'))
output_cert_oper(gandi, oper)
return oper | [
"def",
"follow",
"(",
"gandi",
",",
"resource",
")",
":",
"oper",
"=",
"gandi",
".",
"oper",
".",
"info",
"(",
"int",
"(",
"resource",
")",
")",
"assert",
"(",
"oper",
"[",
"'type'",
"]",
".",
"startswith",
"(",
"'certificate_'",
")",
")",
"output_ce... | Get the operation status
Resource is an operation ID | [
"Get",
"the",
"operation",
"status"
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/certificate.py#L422-L430 |
11,234 | Gandi/gandi.cli | gandi/cli/commands/certificate.py | change_dcv | def change_dcv(gandi, resource, dcv_method):
""" Change the DCV for a running certificate operation.
Resource can be a CN or an ID
"""
ids = gandi.certificate.usable_ids(resource)
if len(ids) > 1:
gandi.echo('Will not update, %s is not precise enough.' % resource)
gandi.echo(' * c... | python | def change_dcv(gandi, resource, dcv_method):
""" Change the DCV for a running certificate operation.
Resource can be a CN or an ID
"""
ids = gandi.certificate.usable_ids(resource)
if len(ids) > 1:
gandi.echo('Will not update, %s is not precise enough.' % resource)
gandi.echo(' * c... | [
"def",
"change_dcv",
"(",
"gandi",
",",
"resource",
",",
"dcv_method",
")",
":",
"ids",
"=",
"gandi",
".",
"certificate",
".",
"usable_ids",
"(",
"resource",
")",
"if",
"len",
"(",
"ids",
")",
">",
"1",
":",
"gandi",
".",
"echo",
"(",
"'Will not update... | Change the DCV for a running certificate operation.
Resource can be a CN or an ID | [
"Change",
"the",
"DCV",
"for",
"a",
"running",
"certificate",
"operation",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/certificate.py#L438-L472 |
11,235 | Gandi/gandi.cli | gandi/cli/commands/certificate.py | resend_dcv | def resend_dcv(gandi, resource):
""" Resend the DCV mail.
Resource can be a CN or an ID
"""
ids = gandi.certificate.usable_ids(resource)
if len(ids) > 1:
gandi.echo('Will not update, %s is not precise enough.' % resource)
gandi.echo(' * cert : ' +
'\n * cert : ... | python | def resend_dcv(gandi, resource):
""" Resend the DCV mail.
Resource can be a CN or an ID
"""
ids = gandi.certificate.usable_ids(resource)
if len(ids) > 1:
gandi.echo('Will not update, %s is not precise enough.' % resource)
gandi.echo(' * cert : ' +
'\n * cert : ... | [
"def",
"resend_dcv",
"(",
"gandi",
",",
"resource",
")",
":",
"ids",
"=",
"gandi",
".",
"certificate",
".",
"usable_ids",
"(",
"resource",
")",
"if",
"len",
"(",
"ids",
")",
">",
"1",
":",
"gandi",
".",
"echo",
"(",
"'Will not update, %s is not precise eno... | Resend the DCV mail.
Resource can be a CN or an ID | [
"Resend",
"the",
"DCV",
"mail",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/certificate.py#L478-L509 |
11,236 | Gandi/gandi.cli | gandi/cli/commands/certificate.py | delete | def delete(gandi, resource, background, force):
""" Revoke the certificate.
Resource can be a CN or an ID
"""
ids = gandi.certificate.usable_ids(resource)
if len(ids) > 1:
gandi.echo('Will not delete, %s is not precise enough.' % resource)
gandi.echo(' * cert : ' +
... | python | def delete(gandi, resource, background, force):
""" Revoke the certificate.
Resource can be a CN or an ID
"""
ids = gandi.certificate.usable_ids(resource)
if len(ids) > 1:
gandi.echo('Will not delete, %s is not precise enough.' % resource)
gandi.echo(' * cert : ' +
... | [
"def",
"delete",
"(",
"gandi",
",",
"resource",
",",
"background",
",",
"force",
")",
":",
"ids",
"=",
"gandi",
".",
"certificate",
".",
"usable_ids",
"(",
"resource",
")",
"if",
"len",
"(",
"ids",
")",
">",
"1",
":",
"gandi",
".",
"echo",
"(",
"'W... | Revoke the certificate.
Resource can be a CN or an ID | [
"Revoke",
"the",
"certificate",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/certificate.py#L520-L540 |
11,237 | Gandi/gandi.cli | gandi/cli/commands/certstore.py | list | def list(gandi, id, vhosts, dates, fqdns, limit):
""" List hosted certificates. """
justify = 10
options = {'items_per_page': limit, 'state': 'created'}
output_keys = []
if id:
output_keys.append('id')
output_keys.append('subject')
if dates:
output_keys.extend(['date_crea... | python | def list(gandi, id, vhosts, dates, fqdns, limit):
""" List hosted certificates. """
justify = 10
options = {'items_per_page': limit, 'state': 'created'}
output_keys = []
if id:
output_keys.append('id')
output_keys.append('subject')
if dates:
output_keys.extend(['date_crea... | [
"def",
"list",
"(",
"gandi",
",",
"id",
",",
"vhosts",
",",
"dates",
",",
"fqdns",
",",
"limit",
")",
":",
"justify",
"=",
"10",
"options",
"=",
"{",
"'items_per_page'",
":",
"limit",
",",
"'state'",
":",
"'created'",
"}",
"output_keys",
"=",
"[",
"]... | List hosted certificates. | [
"List",
"hosted",
"certificates",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/certstore.py#L33-L66 |
11,238 | Gandi/gandi.cli | gandi/cli/commands/certstore.py | info | def info(gandi, resource):
""" Display information about a hosted certificate.
Resource can be a FQDN or an ID
"""
output_keys = ['id', 'subject', 'date_created', 'date_expire',
'fqdns', 'vhosts']
result = gandi.hostedcert.infos(resource)
for num, hcert in enumerate(result):... | python | def info(gandi, resource):
""" Display information about a hosted certificate.
Resource can be a FQDN or an ID
"""
output_keys = ['id', 'subject', 'date_created', 'date_expire',
'fqdns', 'vhosts']
result = gandi.hostedcert.infos(resource)
for num, hcert in enumerate(result):... | [
"def",
"info",
"(",
"gandi",
",",
"resource",
")",
":",
"output_keys",
"=",
"[",
"'id'",
",",
"'subject'",
",",
"'date_created'",
",",
"'date_expire'",
",",
"'fqdns'",
",",
"'vhosts'",
"]",
"result",
"=",
"gandi",
".",
"hostedcert",
".",
"infos",
"(",
"r... | Display information about a hosted certificate.
Resource can be a FQDN or an ID | [
"Display",
"information",
"about",
"a",
"hosted",
"certificate",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/certstore.py#L72-L86 |
11,239 | Gandi/gandi.cli | gandi/cli/commands/certstore.py | create | def create(gandi, private_key, certificate, certificate_id):
""" Create a new hosted certificate. """
if not certificate and not certificate_id:
gandi.echo('One of --certificate or --certificate-id is needed.')
return
if certificate and certificate_id:
gandi.echo('Only one of --certi... | python | def create(gandi, private_key, certificate, certificate_id):
""" Create a new hosted certificate. """
if not certificate and not certificate_id:
gandi.echo('One of --certificate or --certificate-id is needed.')
return
if certificate and certificate_id:
gandi.echo('Only one of --certi... | [
"def",
"create",
"(",
"gandi",
",",
"private_key",
",",
"certificate",
",",
"certificate_id",
")",
":",
"if",
"not",
"certificate",
"and",
"not",
"certificate_id",
":",
"gandi",
".",
"echo",
"(",
"'One of --certificate or --certificate-id is needed.'",
")",
"return"... | Create a new hosted certificate. | [
"Create",
"a",
"new",
"hosted",
"certificate",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/certstore.py#L97-L124 |
11,240 | Gandi/gandi.cli | gandi/cli/commands/certstore.py | delete | def delete(gandi, resource, force):
""" Delete a hosted certificate.
Resource can be a FQDN or an ID
"""
infos = gandi.hostedcert.infos(resource)
if not infos:
return
if not force:
proceed = click.confirm('Are you sure to delete the following hosted '
... | python | def delete(gandi, resource, force):
""" Delete a hosted certificate.
Resource can be a FQDN or an ID
"""
infos = gandi.hostedcert.infos(resource)
if not infos:
return
if not force:
proceed = click.confirm('Are you sure to delete the following hosted '
... | [
"def",
"delete",
"(",
"gandi",
",",
"resource",
",",
"force",
")",
":",
"infos",
"=",
"gandi",
".",
"hostedcert",
".",
"infos",
"(",
"resource",
")",
"if",
"not",
"infos",
":",
"return",
"if",
"not",
"force",
":",
"proceed",
"=",
"click",
".",
"confi... | Delete a hosted certificate.
Resource can be a FQDN or an ID | [
"Delete",
"a",
"hosted",
"certificate",
"."
] | 6ee5b8fc8ec44b0a6c232043ca610606ad8f693d | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/certstore.py#L133-L152 |
11,241 | aykut/django-bulk-update | django_bulk_update/helper.py | flatten | def flatten(l, types=(list, float)):
"""
Flat nested list of lists into a single list.
"""
l = [item if isinstance(item, types) else [item] for item in l]
return [item for sublist in l for item in sublist] | python | def flatten(l, types=(list, float)):
"""
Flat nested list of lists into a single list.
"""
l = [item if isinstance(item, types) else [item] for item in l]
return [item for sublist in l for item in sublist] | [
"def",
"flatten",
"(",
"l",
",",
"types",
"=",
"(",
"list",
",",
"float",
")",
")",
":",
"l",
"=",
"[",
"item",
"if",
"isinstance",
"(",
"item",
",",
"types",
")",
"else",
"[",
"item",
"]",
"for",
"item",
"in",
"l",
"]",
"return",
"[",
"item",
... | Flat nested list of lists into a single list. | [
"Flat",
"nested",
"list",
"of",
"lists",
"into",
"a",
"single",
"list",
"."
] | 399e64d820133a79f910682c1cf247938c5c4784 | https://github.com/aykut/django-bulk-update/blob/399e64d820133a79f910682c1cf247938c5c4784/django_bulk_update/helper.py#L41-L46 |
11,242 | aitjcize/cppman | cppman/util.py | get_width | def get_width():
"""Get terminal width"""
# Get terminal size
ws = struct.pack("HHHH", 0, 0, 0, 0)
ws = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, ws)
lines, columns, x, y = struct.unpack("HHHH", ws)
width = min(columns * 39 // 40, columns - 2)
return width | python | def get_width():
"""Get terminal width"""
# Get terminal size
ws = struct.pack("HHHH", 0, 0, 0, 0)
ws = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, ws)
lines, columns, x, y = struct.unpack("HHHH", ws)
width = min(columns * 39 // 40, columns - 2)
return width | [
"def",
"get_width",
"(",
")",
":",
"# Get terminal size",
"ws",
"=",
"struct",
".",
"pack",
"(",
"\"HHHH\"",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
"ws",
"=",
"fcntl",
".",
"ioctl",
"(",
"sys",
".",
"stdout",
".",
"fileno",
"(",
")",
",",
... | Get terminal width | [
"Get",
"terminal",
"width"
] | 7b48e81b2cd3baa912d73dfe977ecbaff945a93c | https://github.com/aitjcize/cppman/blob/7b48e81b2cd3baa912d73dfe977ecbaff945a93c/cppman/util.py#L83-L90 |
11,243 | aitjcize/cppman | cppman/util.py | groff2man | def groff2man(data):
"""Read groff-formatted text and output man pages."""
width = get_width()
cmd = 'groff -t -Tascii -m man -rLL=%dn -rLT=%dn' % (width, width)
handle = subprocess.Popen(
cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
man_te... | python | def groff2man(data):
"""Read groff-formatted text and output man pages."""
width = get_width()
cmd = 'groff -t -Tascii -m man -rLL=%dn -rLT=%dn' % (width, width)
handle = subprocess.Popen(
cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
man_te... | [
"def",
"groff2man",
"(",
"data",
")",
":",
"width",
"=",
"get_width",
"(",
")",
"cmd",
"=",
"'groff -t -Tascii -m man -rLL=%dn -rLT=%dn'",
"%",
"(",
"width",
",",
"width",
")",
"handle",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"shell",
"=",
"True... | Read groff-formatted text and output man pages. | [
"Read",
"groff",
"-",
"formatted",
"text",
"and",
"output",
"man",
"pages",
"."
] | 7b48e81b2cd3baa912d73dfe977ecbaff945a93c | https://github.com/aitjcize/cppman/blob/7b48e81b2cd3baa912d73dfe977ecbaff945a93c/cppman/util.py#L93-L102 |
11,244 | aitjcize/cppman | cppman/main.py | Cppman.extract_name | def extract_name(self, data):
"""Extract man page name from web page."""
name = re.search('<h1[^>]*>(.+?)</h1>', data).group(1)
name = re.sub(r'<([^>]+)>', r'', name)
name = re.sub(r'>', r'>', name)
name = re.sub(r'<', r'<', name)
return name | python | def extract_name(self, data):
"""Extract man page name from web page."""
name = re.search('<h1[^>]*>(.+?)</h1>', data).group(1)
name = re.sub(r'<([^>]+)>', r'', name)
name = re.sub(r'>', r'>', name)
name = re.sub(r'<', r'<', name)
return name | [
"def",
"extract_name",
"(",
"self",
",",
"data",
")",
":",
"name",
"=",
"re",
".",
"search",
"(",
"'<h1[^>]*>(.+?)</h1>'",
",",
"data",
")",
".",
"group",
"(",
"1",
")",
"name",
"=",
"re",
".",
"sub",
"(",
"r'<([^>]+)>'",
",",
"r''",
",",
"name",
"... | Extract man page name from web page. | [
"Extract",
"man",
"page",
"name",
"from",
"web",
"page",
"."
] | 7b48e81b2cd3baa912d73dfe977ecbaff945a93c | https://github.com/aitjcize/cppman/blob/7b48e81b2cd3baa912d73dfe977ecbaff945a93c/cppman/main.py#L56-L62 |
11,245 | aitjcize/cppman | cppman/main.py | Cppman.cache_all | def cache_all(self):
"""Cache all available man pages"""
respond = input(
'By default, cppman fetches pages on-the-fly if corresponding '
'page is not found in the cache. The "cache-all" option is only '
'useful if you want to view man pages offline. '
... | python | def cache_all(self):
"""Cache all available man pages"""
respond = input(
'By default, cppman fetches pages on-the-fly if corresponding '
'page is not found in the cache. The "cache-all" option is only '
'useful if you want to view man pages offline. '
... | [
"def",
"cache_all",
"(",
"self",
")",
":",
"respond",
"=",
"input",
"(",
"'By default, cppman fetches pages on-the-fly if corresponding '",
"'page is not found in the cache. The \"cache-all\" option is only '",
"'useful if you want to view man pages offline. '",
"'Caching all contents will... | Cache all available man pages | [
"Cache",
"all",
"available",
"man",
"pages"
] | 7b48e81b2cd3baa912d73dfe977ecbaff945a93c | https://github.com/aitjcize/cppman/blob/7b48e81b2cd3baa912d73dfe977ecbaff945a93c/cppman/main.py#L204-L254 |
11,246 | aitjcize/cppman | cppman/main.py | Cppman.cache_man_page | def cache_man_page(self, source, url, name):
"""callback to cache new man page"""
# Skip if already exists, override if forced flag is true
outname = self.get_page_path(source, name)
if os.path.exists(outname) and not self.forced:
return
try:
os.makedirs(... | python | def cache_man_page(self, source, url, name):
"""callback to cache new man page"""
# Skip if already exists, override if forced flag is true
outname = self.get_page_path(source, name)
if os.path.exists(outname) and not self.forced:
return
try:
os.makedirs(... | [
"def",
"cache_man_page",
"(",
"self",
",",
"source",
",",
"url",
",",
"name",
")",
":",
"# Skip if already exists, override if forced flag is true",
"outname",
"=",
"self",
".",
"get_page_path",
"(",
"source",
",",
"name",
")",
"if",
"os",
".",
"path",
".",
"e... | callback to cache new man page | [
"callback",
"to",
"cache",
"new",
"man",
"page"
] | 7b48e81b2cd3baa912d73dfe977ecbaff945a93c | https://github.com/aitjcize/cppman/blob/7b48e81b2cd3baa912d73dfe977ecbaff945a93c/cppman/main.py#L256-L276 |
11,247 | aitjcize/cppman | cppman/main.py | Cppman.man | def man(self, pattern):
"""Call viewer.sh to view man page"""
try:
avail = os.listdir(os.path.join(environ.cache_dir, environ.source))
except OSError:
avail = []
if not os.path.exists(environ.index_db):
raise RuntimeError("can't find index.db")
... | python | def man(self, pattern):
"""Call viewer.sh to view man page"""
try:
avail = os.listdir(os.path.join(environ.cache_dir, environ.source))
except OSError:
avail = []
if not os.path.exists(environ.index_db):
raise RuntimeError("can't find index.db")
... | [
"def",
"man",
"(",
"self",
",",
"pattern",
")",
":",
"try",
":",
"avail",
"=",
"os",
".",
"listdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"environ",
".",
"cache_dir",
",",
"environ",
".",
"source",
")",
")",
"except",
"OSError",
":",
"avail",
... | Call viewer.sh to view man page | [
"Call",
"viewer",
".",
"sh",
"to",
"view",
"man",
"page"
] | 7b48e81b2cd3baa912d73dfe977ecbaff945a93c | https://github.com/aitjcize/cppman/blob/7b48e81b2cd3baa912d73dfe977ecbaff945a93c/cppman/main.py#L282-L333 |
11,248 | aitjcize/cppman | cppman/main.py | Cppman.find | def find(self, pattern):
"""Find pages in database."""
if not os.path.exists(environ.index_db):
raise RuntimeError("can't find index.db")
conn = sqlite3.connect(environ.index_db)
cursor = conn.cursor()
selected = cursor.execute(
'SELECT * FROM "%s" WHERE... | python | def find(self, pattern):
"""Find pages in database."""
if not os.path.exists(environ.index_db):
raise RuntimeError("can't find index.db")
conn = sqlite3.connect(environ.index_db)
cursor = conn.cursor()
selected = cursor.execute(
'SELECT * FROM "%s" WHERE... | [
"def",
"find",
"(",
"self",
",",
"pattern",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"environ",
".",
"index_db",
")",
":",
"raise",
"RuntimeError",
"(",
"\"can't find index.db\"",
")",
"conn",
"=",
"sqlite3",
".",
"connect",
"(",
"... | Find pages in database. | [
"Find",
"pages",
"in",
"database",
"."
] | 7b48e81b2cd3baa912d73dfe977ecbaff945a93c | https://github.com/aitjcize/cppman/blob/7b48e81b2cd3baa912d73dfe977ecbaff945a93c/cppman/main.py#L335-L358 |
11,249 | aitjcize/cppman | cppman/main.py | Cppman.update_mandb | def update_mandb(self, quiet=True):
"""Update mandb."""
if not environ.config.UpdateManPath:
return
print('\nrunning mandb...')
cmd = 'mandb %s' % (' -q' if quiet else '')
subprocess.Popen(cmd, shell=True).wait() | python | def update_mandb(self, quiet=True):
"""Update mandb."""
if not environ.config.UpdateManPath:
return
print('\nrunning mandb...')
cmd = 'mandb %s' % (' -q' if quiet else '')
subprocess.Popen(cmd, shell=True).wait() | [
"def",
"update_mandb",
"(",
"self",
",",
"quiet",
"=",
"True",
")",
":",
"if",
"not",
"environ",
".",
"config",
".",
"UpdateManPath",
":",
"return",
"print",
"(",
"'\\nrunning mandb...'",
")",
"cmd",
"=",
"'mandb %s'",
"%",
"(",
"' -q'",
"if",
"quiet",
"... | Update mandb. | [
"Update",
"mandb",
"."
] | 7b48e81b2cd3baa912d73dfe977ecbaff945a93c | https://github.com/aitjcize/cppman/blob/7b48e81b2cd3baa912d73dfe977ecbaff945a93c/cppman/main.py#L360-L366 |
11,250 | aitjcize/cppman | cppman/config.py | Config.set_default | def set_default(self):
"""Set config to default."""
try:
os.makedirs(os.path.dirname(self._configfile))
except:
pass
self._config = configparser.RawConfigParser()
self._config.add_section('Settings')
for key, val in self.DEFAULTS.items():
... | python | def set_default(self):
"""Set config to default."""
try:
os.makedirs(os.path.dirname(self._configfile))
except:
pass
self._config = configparser.RawConfigParser()
self._config.add_section('Settings')
for key, val in self.DEFAULTS.items():
... | [
"def",
"set_default",
"(",
"self",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"_configfile",
")",
")",
"except",
":",
"pass",
"self",
".",
"_config",
"=",
"configparser",
".",
"RawConfigParser... | Set config to default. | [
"Set",
"config",
"to",
"default",
"."
] | 7b48e81b2cd3baa912d73dfe977ecbaff945a93c | https://github.com/aitjcize/cppman/blob/7b48e81b2cd3baa912d73dfe977ecbaff945a93c/cppman/config.py#L64-L78 |
11,251 | aitjcize/cppman | cppman/config.py | Config.save | def save(self):
"""Store config back to file."""
try:
os.makedirs(os.path.dirname(self._configfile))
except:
pass
with open(self._configfile, 'w') as f:
self._config.write(f) | python | def save(self):
"""Store config back to file."""
try:
os.makedirs(os.path.dirname(self._configfile))
except:
pass
with open(self._configfile, 'w') as f:
self._config.write(f) | [
"def",
"save",
"(",
"self",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"_configfile",
")",
")",
"except",
":",
"pass",
"with",
"open",
"(",
"self",
".",
"_configfile",
",",
"'w'",
")",
"... | Store config back to file. | [
"Store",
"config",
"back",
"to",
"file",
"."
] | 7b48e81b2cd3baa912d73dfe977ecbaff945a93c | https://github.com/aitjcize/cppman/blob/7b48e81b2cd3baa912d73dfe977ecbaff945a93c/cppman/config.py#L80-L88 |
11,252 | fbcotter/py3nvml | py3nvml/utils.py | get_free_gpus | def get_free_gpus(max_procs=0):
"""
Checks the number of processes running on your GPUs.
Parameters
----------
max_procs : int
Maximum number of procs allowed to run on a gpu for it to be considered
'available'
Returns
-------
availabilities : list(bool)
List of... | python | def get_free_gpus(max_procs=0):
"""
Checks the number of processes running on your GPUs.
Parameters
----------
max_procs : int
Maximum number of procs allowed to run on a gpu for it to be considered
'available'
Returns
-------
availabilities : list(bool)
List of... | [
"def",
"get_free_gpus",
"(",
"max_procs",
"=",
"0",
")",
":",
"# Try connect with NVIDIA drivers",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"try",
":",
"py3nvml",
".",
"nvmlInit",
"(",
")",
"except",
":",
"str_",
"=",
"\"\"\"Couldn't c... | Checks the number of processes running on your GPUs.
Parameters
----------
max_procs : int
Maximum number of procs allowed to run on a gpu for it to be considered
'available'
Returns
-------
availabilities : list(bool)
List of length N for an N-gpu system. The nth value... | [
"Checks",
"the",
"number",
"of",
"processes",
"running",
"on",
"your",
"GPUs",
"."
] | 47f0f2c0eee56dec4e4beebec26b734e01d357b7 | https://github.com/fbcotter/py3nvml/blob/47f0f2c0eee56dec4e4beebec26b734e01d357b7/py3nvml/utils.py#L170-L216 |
11,253 | fbcotter/py3nvml | py3nvml/utils.py | get_num_procs | def get_num_procs():
""" Gets the number of processes running on each gpu
Returns
-------
num_procs : list(int)
Number of processes running on each gpu
Note
----
If function can't query the driver will return an empty list rather than raise an
Exception.
Note
----
... | python | def get_num_procs():
""" Gets the number of processes running on each gpu
Returns
-------
num_procs : list(int)
Number of processes running on each gpu
Note
----
If function can't query the driver will return an empty list rather than raise an
Exception.
Note
----
... | [
"def",
"get_num_procs",
"(",
")",
":",
"# Try connect with NVIDIA drivers",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"try",
":",
"py3nvml",
".",
"nvmlInit",
"(",
")",
"except",
":",
"str_",
"=",
"\"\"\"Couldn't connect to nvml drivers. Check... | Gets the number of processes running on each gpu
Returns
-------
num_procs : list(int)
Number of processes running on each gpu
Note
----
If function can't query the driver will return an empty list rather than raise an
Exception.
Note
----
If function can't get the inf... | [
"Gets",
"the",
"number",
"of",
"processes",
"running",
"on",
"each",
"gpu"
] | 47f0f2c0eee56dec4e4beebec26b734e01d357b7 | https://github.com/fbcotter/py3nvml/blob/47f0f2c0eee56dec4e4beebec26b734e01d357b7/py3nvml/utils.py#L219-L258 |
11,254 | fbcotter/py3nvml | py3nvml/py3nvml.py | _extractNVMLErrorsAsClasses | def _extractNVMLErrorsAsClasses():
"""
Generates a hierarchy of classes on top of NVMLError class.
Each NVML Error gets a new NVMLError subclass. This way try,except blocks
can filter appropriate exceptions more easily.
NVMLError is a parent class. Each NVML_ERROR_* gets it's own subclass. e.g.
... | python | def _extractNVMLErrorsAsClasses():
"""
Generates a hierarchy of classes on top of NVMLError class.
Each NVML Error gets a new NVMLError subclass. This way try,except blocks
can filter appropriate exceptions more easily.
NVMLError is a parent class. Each NVML_ERROR_* gets it's own subclass. e.g.
... | [
"def",
"_extractNVMLErrorsAsClasses",
"(",
")",
":",
"this_module",
"=",
"sys",
".",
"modules",
"[",
"__name__",
"]",
"nvmlErrorsNames",
"=",
"[",
"x",
"for",
"x",
"in",
"dir",
"(",
"this_module",
")",
"if",
"x",
".",
"startswith",
"(",
"\"NVML_ERROR_\"",
... | Generates a hierarchy of classes on top of NVMLError class.
Each NVML Error gets a new NVMLError subclass. This way try,except blocks
can filter appropriate exceptions more easily.
NVMLError is a parent class. Each NVML_ERROR_* gets it's own subclass. e.g.
NVML_ERROR_ALREADY_INITIALIZED will be turne... | [
"Generates",
"a",
"hierarchy",
"of",
"classes",
"on",
"top",
"of",
"NVMLError",
"class",
"."
] | 47f0f2c0eee56dec4e4beebec26b734e01d357b7 | https://github.com/fbcotter/py3nvml/blob/47f0f2c0eee56dec4e4beebec26b734e01d357b7/py3nvml/py3nvml.py#L686-L711 |
11,255 | fbcotter/py3nvml | py3nvml/py3nvml.py | _LoadNvmlLibrary | def _LoadNvmlLibrary():
"""
Load the library if it isn't loaded already
"""
global nvmlLib
if (nvmlLib is None):
# lock to ensure only one caller loads the library
libLoadLock.acquire()
try:
# ensure the library still isn't loaded
if (nvmlLib is None... | python | def _LoadNvmlLibrary():
"""
Load the library if it isn't loaded already
"""
global nvmlLib
if (nvmlLib is None):
# lock to ensure only one caller loads the library
libLoadLock.acquire()
try:
# ensure the library still isn't loaded
if (nvmlLib is None... | [
"def",
"_LoadNvmlLibrary",
"(",
")",
":",
"global",
"nvmlLib",
"if",
"(",
"nvmlLib",
"is",
"None",
")",
":",
"# lock to ensure only one caller loads the library",
"libLoadLock",
".",
"acquire",
"(",
")",
"try",
":",
"# ensure the library still isn't loaded",
"if",
"("... | Load the library if it isn't loaded already | [
"Load",
"the",
"library",
"if",
"it",
"isn",
"t",
"loaded",
"already"
] | 47f0f2c0eee56dec4e4beebec26b734e01d357b7 | https://github.com/fbcotter/py3nvml/blob/47f0f2c0eee56dec4e4beebec26b734e01d357b7/py3nvml/py3nvml.py#L1104-L1138 |
11,256 | samuraisam/pyapns | pyapns/server.py | encode_notifications | def encode_notifications(tokens, notifications):
""" Returns the encoded bytes of tokens and notifications
tokens a list of tokens or a string of only one token
notifications a list of notifications or a dictionary of only one
"""
fmt = "!BH32sH%ds"
structify = lambda t, p: stru... | python | def encode_notifications(tokens, notifications):
""" Returns the encoded bytes of tokens and notifications
tokens a list of tokens or a string of only one token
notifications a list of notifications or a dictionary of only one
"""
fmt = "!BH32sH%ds"
structify = lambda t, p: stru... | [
"def",
"encode_notifications",
"(",
"tokens",
",",
"notifications",
")",
":",
"fmt",
"=",
"\"!BH32sH%ds\"",
"structify",
"=",
"lambda",
"t",
",",
"p",
":",
"struct",
".",
"pack",
"(",
"fmt",
"%",
"len",
"(",
"p",
")",
",",
"0",
",",
"32",
",",
"t",
... | Returns the encoded bytes of tokens and notifications
tokens a list of tokens or a string of only one token
notifications a list of notifications or a dictionary of only one | [
"Returns",
"the",
"encoded",
"bytes",
"of",
"tokens",
"and",
"notifications",
"tokens",
"a",
"list",
"of",
"tokens",
"or",
"a",
"string",
"of",
"only",
"one",
"token",
"notifications",
"a",
"list",
"of",
"notifications",
"or",
"a",
"dictionary",
"of",
"only"... | 78c1875f28f8af51c7dd7f60d4436a8b282b0394 | https://github.com/samuraisam/pyapns/blob/78c1875f28f8af51c7dd7f60d4436a8b282b0394/pyapns/server.py#L317-L331 |
11,257 | samuraisam/pyapns | pyapns/server.py | APNSService.write | def write(self, notifications):
"Connect to the APNS service and send notifications"
if not self.factory:
log.msg('APNSService write (connecting)')
server, port = ((APNS_SERVER_SANDBOX_HOSTNAME
if self.environment == 'sandbox'
else APNS_SERVER_HOSTNAME), ... | python | def write(self, notifications):
"Connect to the APNS service and send notifications"
if not self.factory:
log.msg('APNSService write (connecting)')
server, port = ((APNS_SERVER_SANDBOX_HOSTNAME
if self.environment == 'sandbox'
else APNS_SERVER_HOSTNAME), ... | [
"def",
"write",
"(",
"self",
",",
"notifications",
")",
":",
"if",
"not",
"self",
".",
"factory",
":",
"log",
".",
"msg",
"(",
"'APNSService write (connecting)'",
")",
"server",
",",
"port",
"=",
"(",
"(",
"APNS_SERVER_SANDBOX_HOSTNAME",
"if",
"self",
".",
... | Connect to the APNS service and send notifications | [
"Connect",
"to",
"the",
"APNS",
"service",
"and",
"send",
"notifications"
] | 78c1875f28f8af51c7dd7f60d4436a8b282b0394 | https://github.com/samuraisam/pyapns/blob/78c1875f28f8af51c7dd7f60d4436a8b282b0394/pyapns/server.py#L186-L213 |
11,258 | samuraisam/pyapns | pyapns/server.py | APNSService.read | def read(self):
"Connect to the feedback service and read all data."
log.msg('APNSService read (connecting)')
try:
server, port = ((FEEDBACK_SERVER_SANDBOX_HOSTNAME
if self.environment == 'sandbox'
else FEEDBACK_SERVER_HOSTNAME), FEEDBACK_SERVER_PORT)
... | python | def read(self):
"Connect to the feedback service and read all data."
log.msg('APNSService read (connecting)')
try:
server, port = ((FEEDBACK_SERVER_SANDBOX_HOSTNAME
if self.environment == 'sandbox'
else FEEDBACK_SERVER_HOSTNAME), FEEDBACK_SERVER_PORT)
... | [
"def",
"read",
"(",
"self",
")",
":",
"log",
".",
"msg",
"(",
"'APNSService read (connecting)'",
")",
"try",
":",
"server",
",",
"port",
"=",
"(",
"(",
"FEEDBACK_SERVER_SANDBOX_HOSTNAME",
"if",
"self",
".",
"environment",
"==",
"'sandbox'",
"else",
"FEEDBACK_S... | Connect to the feedback service and read all data. | [
"Connect",
"to",
"the",
"feedback",
"service",
"and",
"read",
"all",
"data",
"."
] | 78c1875f28f8af51c7dd7f60d4436a8b282b0394 | https://github.com/samuraisam/pyapns/blob/78c1875f28f8af51c7dd7f60d4436a8b282b0394/pyapns/server.py#L215-L239 |
11,259 | samuraisam/pyapns | pyapns/client.py | reprovision_and_retry | def reprovision_and_retry(func):
"""
Wraps the `errback` callback of the API functions, automatically trying to
re-provision if the app ID can not be found during the operation. If that's
unsuccessful, it will raise the UnknownAppID error.
"""
@functools.wraps(func)
def wrapper(*a, **kw):
errback = kw... | python | def reprovision_and_retry(func):
"""
Wraps the `errback` callback of the API functions, automatically trying to
re-provision if the app ID can not be found during the operation. If that's
unsuccessful, it will raise the UnknownAppID error.
"""
@functools.wraps(func)
def wrapper(*a, **kw):
errback = kw... | [
"def",
"reprovision_and_retry",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"errback",
"=",
"kw",
".",
"get",
"(",
"'errback'",
",",
"None",
")",
"if",
"... | Wraps the `errback` callback of the API functions, automatically trying to
re-provision if the app ID can not be found during the operation. If that's
unsuccessful, it will raise the UnknownAppID error. | [
"Wraps",
"the",
"errback",
"callback",
"of",
"the",
"API",
"functions",
"automatically",
"trying",
"to",
"re",
"-",
"provision",
"if",
"the",
"app",
"ID",
"can",
"not",
"be",
"found",
"during",
"the",
"operation",
".",
"If",
"that",
"s",
"unsuccessful",
"i... | 78c1875f28f8af51c7dd7f60d4436a8b282b0394 | https://github.com/samuraisam/pyapns/blob/78c1875f28f8af51c7dd7f60d4436a8b282b0394/pyapns/client.py#L44-L68 |
11,260 | timothycrosley/jiphy | jiphy/parser.py | Parser.pop | def pop(self):
"""removes the current character then moves to the next one, returning the current character"""
char = self.code[self.index]
self.index += 1
return char | python | def pop(self):
"""removes the current character then moves to the next one, returning the current character"""
char = self.code[self.index]
self.index += 1
return char | [
"def",
"pop",
"(",
"self",
")",
":",
"char",
"=",
"self",
".",
"code",
"[",
"self",
".",
"index",
"]",
"self",
".",
"index",
"+=",
"1",
"return",
"char"
] | removes the current character then moves to the next one, returning the current character | [
"removes",
"the",
"current",
"character",
"then",
"moves",
"to",
"the",
"next",
"one",
"returning",
"the",
"current",
"character"
] | 6e09be9c3496ca40901df70fc9b14d2ca3ec2e04 | https://github.com/timothycrosley/jiphy/blob/6e09be9c3496ca40901df70fc9b14d2ca3ec2e04/jiphy/parser.py#L83-L87 |
11,261 | timothycrosley/jiphy | jiphy/parser.py | Parser.characters | def characters(self, numberOfCharacters):
"""Returns characters at index + number of characters"""
return self.code[self.index:self.index + numberOfCharacters] | python | def characters(self, numberOfCharacters):
"""Returns characters at index + number of characters"""
return self.code[self.index:self.index + numberOfCharacters] | [
"def",
"characters",
"(",
"self",
",",
"numberOfCharacters",
")",
":",
"return",
"self",
".",
"code",
"[",
"self",
".",
"index",
":",
"self",
".",
"index",
"+",
"numberOfCharacters",
"]"
] | Returns characters at index + number of characters | [
"Returns",
"characters",
"at",
"index",
"+",
"number",
"of",
"characters"
] | 6e09be9c3496ca40901df70fc9b14d2ca3ec2e04 | https://github.com/timothycrosley/jiphy/blob/6e09be9c3496ca40901df70fc9b14d2ca3ec2e04/jiphy/parser.py#L89-L91 |
11,262 | timothycrosley/jiphy | jiphy/parser.py | Parser.next_content | def next_content(self, start, amount=1):
"""Returns the next non-whitespace characters"""
while start < len(self.code) and self.code[start] in (' ', '\t', '\n'):
start += 1
return self.code[start: start + amount] | python | def next_content(self, start, amount=1):
"""Returns the next non-whitespace characters"""
while start < len(self.code) and self.code[start] in (' ', '\t', '\n'):
start += 1
return self.code[start: start + amount] | [
"def",
"next_content",
"(",
"self",
",",
"start",
",",
"amount",
"=",
"1",
")",
":",
"while",
"start",
"<",
"len",
"(",
"self",
".",
"code",
")",
"and",
"self",
".",
"code",
"[",
"start",
"]",
"in",
"(",
"' '",
",",
"'\\t'",
",",
"'\\n'",
")",
... | Returns the next non-whitespace characters | [
"Returns",
"the",
"next",
"non",
"-",
"whitespace",
"characters"
] | 6e09be9c3496ca40901df70fc9b14d2ca3ec2e04 | https://github.com/timothycrosley/jiphy/blob/6e09be9c3496ca40901df70fc9b14d2ca3ec2e04/jiphy/parser.py#L117-L122 |
11,263 | timothycrosley/jiphy | jiphy/parser.py | Parser.prev_content | def prev_content(self, start, amount=1):
"""Returns the prev non-whitespace characters"""
while start > 0 and self.code[start] in (' ', '\t', '\n'):
start -= 1
return self.code[(start or amount) - amount: start] | python | def prev_content(self, start, amount=1):
"""Returns the prev non-whitespace characters"""
while start > 0 and self.code[start] in (' ', '\t', '\n'):
start -= 1
return self.code[(start or amount) - amount: start] | [
"def",
"prev_content",
"(",
"self",
",",
"start",
",",
"amount",
"=",
"1",
")",
":",
"while",
"start",
">",
"0",
"and",
"self",
".",
"code",
"[",
"start",
"]",
"in",
"(",
"' '",
",",
"'\\t'",
",",
"'\\n'",
")",
":",
"start",
"-=",
"1",
"return",
... | Returns the prev non-whitespace characters | [
"Returns",
"the",
"prev",
"non",
"-",
"whitespace",
"characters"
] | 6e09be9c3496ca40901df70fc9b14d2ca3ec2e04 | https://github.com/timothycrosley/jiphy/blob/6e09be9c3496ca40901df70fc9b14d2ca3ec2e04/jiphy/parser.py#L124-L129 |
11,264 | languitar/pass-git-helper | passgithelper.py | parse_mapping | def parse_mapping(mapping_file: Optional[str]) -> configparser.ConfigParser:
"""
Parse the file containing the mappings from hosts to pass entries.
Args:
mapping_file:
Name of the file to parse. If ``None``, the default file from the
XDG location is used.
"""
LOGGER.... | python | def parse_mapping(mapping_file: Optional[str]) -> configparser.ConfigParser:
"""
Parse the file containing the mappings from hosts to pass entries.
Args:
mapping_file:
Name of the file to parse. If ``None``, the default file from the
XDG location is used.
"""
LOGGER.... | [
"def",
"parse_mapping",
"(",
"mapping_file",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"configparser",
".",
"ConfigParser",
":",
"LOGGER",
".",
"debug",
"(",
"'Parsing mapping file. Command line: %s'",
",",
"mapping_file",
")",
"def",
"parse",
"(",
"mapping_fil... | Parse the file containing the mappings from hosts to pass entries.
Args:
mapping_file:
Name of the file to parse. If ``None``, the default file from the
XDG location is used. | [
"Parse",
"the",
"file",
"containing",
"the",
"mappings",
"from",
"hosts",
"to",
"pass",
"entries",
"."
] | f84376d9ed6f7c47454a499da103da6fc2575a25 | https://github.com/languitar/pass-git-helper/blob/f84376d9ed6f7c47454a499da103da6fc2575a25/passgithelper.py#L73-L104 |
11,265 | languitar/pass-git-helper | passgithelper.py | parse_request | def parse_request() -> Dict[str, str]:
"""
Parse the request of the git credential API from stdin.
Returns:
A dictionary with all key-value pairs of the request
"""
in_lines = sys.stdin.readlines()
LOGGER.debug('Received request "%s"', in_lines)
request = {}
for line in in_line... | python | def parse_request() -> Dict[str, str]:
"""
Parse the request of the git credential API from stdin.
Returns:
A dictionary with all key-value pairs of the request
"""
in_lines = sys.stdin.readlines()
LOGGER.debug('Received request "%s"', in_lines)
request = {}
for line in in_line... | [
"def",
"parse_request",
"(",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"in_lines",
"=",
"sys",
".",
"stdin",
".",
"readlines",
"(",
")",
"LOGGER",
".",
"debug",
"(",
"'Received request \"%s\"'",
",",
"in_lines",
")",
"request",
"=",
"{",
"}"... | Parse the request of the git credential API from stdin.
Returns:
A dictionary with all key-value pairs of the request | [
"Parse",
"the",
"request",
"of",
"the",
"git",
"credential",
"API",
"from",
"stdin",
"."
] | f84376d9ed6f7c47454a499da103da6fc2575a25 | https://github.com/languitar/pass-git-helper/blob/f84376d9ed6f7c47454a499da103da6fc2575a25/passgithelper.py#L107-L127 |
11,266 | languitar/pass-git-helper | passgithelper.py | get_password | def get_password(request, mapping) -> None:
"""
Resolve the given credential request in the provided mapping definition.
The result is printed automatically.
Args:
request:
The credential request specified as a dict of key-value pairs.
mapping:
The mapping confi... | python | def get_password(request, mapping) -> None:
"""
Resolve the given credential request in the provided mapping definition.
The result is printed automatically.
Args:
request:
The credential request specified as a dict of key-value pairs.
mapping:
The mapping confi... | [
"def",
"get_password",
"(",
"request",
",",
"mapping",
")",
"->",
"None",
":",
"LOGGER",
".",
"debug",
"(",
"'Received request \"%s\"'",
",",
"request",
")",
"if",
"'host'",
"not",
"in",
"request",
":",
"LOGGER",
".",
"error",
"(",
"'host= entry missing in req... | Resolve the given credential request in the provided mapping definition.
The result is printed automatically.
Args:
request:
The credential request specified as a dict of key-value pairs.
mapping:
The mapping configuration as a ConfigParser instance. | [
"Resolve",
"the",
"given",
"credential",
"request",
"in",
"the",
"provided",
"mapping",
"definition",
"."
] | f84376d9ed6f7c47454a499da103da6fc2575a25 | https://github.com/languitar/pass-git-helper/blob/f84376d9ed6f7c47454a499da103da6fc2575a25/passgithelper.py#L324-L383 |
11,267 | languitar/pass-git-helper | passgithelper.py | main | def main(argv: Optional[Sequence[str]] = None) -> None:
"""
Start the pass-git-helper script.
Args:
argv:
If not ``None``, use the provided command line arguments for
parsing. Otherwise, extract them automatically.
"""
args = parse_arguments(argv=argv)
if args.l... | python | def main(argv: Optional[Sequence[str]] = None) -> None:
"""
Start the pass-git-helper script.
Args:
argv:
If not ``None``, use the provided command line arguments for
parsing. Otherwise, extract them automatically.
"""
args = parse_arguments(argv=argv)
if args.l... | [
"def",
"main",
"(",
"argv",
":",
"Optional",
"[",
"Sequence",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"None",
":",
"args",
"=",
"parse_arguments",
"(",
"argv",
"=",
"argv",
")",
"if",
"args",
".",
"logging",
":",
"logging",
".",
"basicConfig",
... | Start the pass-git-helper script.
Args:
argv:
If not ``None``, use the provided command line arguments for
parsing. Otherwise, extract them automatically. | [
"Start",
"the",
"pass",
"-",
"git",
"-",
"helper",
"script",
"."
] | f84376d9ed6f7c47454a499da103da6fc2575a25 | https://github.com/languitar/pass-git-helper/blob/f84376d9ed6f7c47454a499da103da6fc2575a25/passgithelper.py#L394-L429 |
11,268 | languitar/pass-git-helper | passgithelper.py | SkippingDataExtractor.configure | def configure(self, config):
"""Configure the amount of characters to skip."""
self._prefix_length = config.getint(
'skip{suffix}'.format(suffix=self._option_suffix),
fallback=self._prefix_length) | python | def configure(self, config):
"""Configure the amount of characters to skip."""
self._prefix_length = config.getint(
'skip{suffix}'.format(suffix=self._option_suffix),
fallback=self._prefix_length) | [
"def",
"configure",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"_prefix_length",
"=",
"config",
".",
"getint",
"(",
"'skip{suffix}'",
".",
"format",
"(",
"suffix",
"=",
"self",
".",
"_option_suffix",
")",
",",
"fallback",
"=",
"self",
".",
"_pref... | Configure the amount of characters to skip. | [
"Configure",
"the",
"amount",
"of",
"characters",
"to",
"skip",
"."
] | f84376d9ed6f7c47454a499da103da6fc2575a25 | https://github.com/languitar/pass-git-helper/blob/f84376d9ed6f7c47454a499da103da6fc2575a25/passgithelper.py#L194-L198 |
11,269 | asottile/git-code-debt | git_code_debt/write_logic.py | insert_metric_changes | def insert_metric_changes(db, metrics, metric_mapping, commit):
"""Insert into the metric_changes tables.
:param metrics: `list` of `Metric` objects
:param dict metric_mapping: Maps metric names to ids
:param Commit commit:
"""
values = [
[commit.sha, metric_mapping[metric.name], metric... | python | def insert_metric_changes(db, metrics, metric_mapping, commit):
"""Insert into the metric_changes tables.
:param metrics: `list` of `Metric` objects
:param dict metric_mapping: Maps metric names to ids
:param Commit commit:
"""
values = [
[commit.sha, metric_mapping[metric.name], metric... | [
"def",
"insert_metric_changes",
"(",
"db",
",",
"metrics",
",",
"metric_mapping",
",",
"commit",
")",
":",
"values",
"=",
"[",
"[",
"commit",
".",
"sha",
",",
"metric_mapping",
"[",
"metric",
".",
"name",
"]",
",",
"metric",
".",
"value",
"]",
"for",
"... | Insert into the metric_changes tables.
:param metrics: `list` of `Metric` objects
:param dict metric_mapping: Maps metric names to ids
:param Commit commit: | [
"Insert",
"into",
"the",
"metric_changes",
"tables",
"."
] | 31b41e2510063e9739de7987cdca95eaccaecbd6 | https://github.com/asottile/git-code-debt/blob/31b41e2510063e9739de7987cdca95eaccaecbd6/git_code_debt/write_logic.py#L18-L33 |
11,270 | asottile/git-code-debt | git_code_debt/repo_parser.py | RepoParser.get_commits | def get_commits(self, since_sha=None):
"""Returns a list of Commit objects.
Args:
since_sha - (optional) A sha to search from
"""
assert self.tempdir
cmd = ['git', 'log', '--first-parent', '--reverse', COMMIT_FORMAT]
if since_sha:
commits = [self.... | python | def get_commits(self, since_sha=None):
"""Returns a list of Commit objects.
Args:
since_sha - (optional) A sha to search from
"""
assert self.tempdir
cmd = ['git', 'log', '--first-parent', '--reverse', COMMIT_FORMAT]
if since_sha:
commits = [self.... | [
"def",
"get_commits",
"(",
"self",
",",
"since_sha",
"=",
"None",
")",
":",
"assert",
"self",
".",
"tempdir",
"cmd",
"=",
"[",
"'git'",
",",
"'log'",
",",
"'--first-parent'",
",",
"'--reverse'",
",",
"COMMIT_FORMAT",
"]",
"if",
"since_sha",
":",
"commits",... | Returns a list of Commit objects.
Args:
since_sha - (optional) A sha to search from | [
"Returns",
"a",
"list",
"of",
"Commit",
"objects",
"."
] | 31b41e2510063e9739de7987cdca95eaccaecbd6 | https://github.com/asottile/git-code-debt/blob/31b41e2510063e9739de7987cdca95eaccaecbd6/git_code_debt/repo_parser.py#L49-L70 |
11,271 | asottile/git-code-debt | git_code_debt/util/discovery.py | discover | def discover(package, cls_match_func):
"""Returns a set of classes in the directory matched by cls_match_func
Args:
path - A Python package
cls_match_func - Function taking a class and returning true if the
class is to be included in the output.
"""
matched_classes = set()
... | python | def discover(package, cls_match_func):
"""Returns a set of classes in the directory matched by cls_match_func
Args:
path - A Python package
cls_match_func - Function taking a class and returning true if the
class is to be included in the output.
"""
matched_classes = set()
... | [
"def",
"discover",
"(",
"package",
",",
"cls_match_func",
")",
":",
"matched_classes",
"=",
"set",
"(",
")",
"for",
"_",
",",
"module_name",
",",
"_",
"in",
"pkgutil",
".",
"walk_packages",
"(",
"package",
".",
"__path__",
",",
"prefix",
"=",
"package",
... | Returns a set of classes in the directory matched by cls_match_func
Args:
path - A Python package
cls_match_func - Function taking a class and returning true if the
class is to be included in the output. | [
"Returns",
"a",
"set",
"of",
"classes",
"in",
"the",
"directory",
"matched",
"by",
"cls_match_func"
] | 31b41e2510063e9739de7987cdca95eaccaecbd6 | https://github.com/asottile/git-code-debt/blob/31b41e2510063e9739de7987cdca95eaccaecbd6/git_code_debt/util/discovery.py#L8-L34 |
11,272 | asottile/git-code-debt | git_code_debt/util/iter.py | chunk_iter | def chunk_iter(iterable, n):
"""Yields an iterator in chunks
For example you can do
for a, b in chunk_iter([1, 2, 3, 4, 5, 6], 2):
print('{} {}'.format(a, b))
# Prints
# 1 2
# 3 4
# 5 6
Args:
iterable - Some iterable
n - Chunk size (must be greater than 0)
... | python | def chunk_iter(iterable, n):
"""Yields an iterator in chunks
For example you can do
for a, b in chunk_iter([1, 2, 3, 4, 5, 6], 2):
print('{} {}'.format(a, b))
# Prints
# 1 2
# 3 4
# 5 6
Args:
iterable - Some iterable
n - Chunk size (must be greater than 0)
... | [
"def",
"chunk_iter",
"(",
"iterable",
",",
"n",
")",
":",
"assert",
"n",
">",
"0",
"iterable",
"=",
"iter",
"(",
"iterable",
")",
"chunk",
"=",
"tuple",
"(",
"itertools",
".",
"islice",
"(",
"iterable",
",",
"n",
")",
")",
"while",
"chunk",
":",
"y... | Yields an iterator in chunks
For example you can do
for a, b in chunk_iter([1, 2, 3, 4, 5, 6], 2):
print('{} {}'.format(a, b))
# Prints
# 1 2
# 3 4
# 5 6
Args:
iterable - Some iterable
n - Chunk size (must be greater than 0) | [
"Yields",
"an",
"iterator",
"in",
"chunks"
] | 31b41e2510063e9739de7987cdca95eaccaecbd6 | https://github.com/asottile/git-code-debt/blob/31b41e2510063e9739de7987cdca95eaccaecbd6/git_code_debt/util/iter.py#L7-L30 |
11,273 | asottile/git-code-debt | git_code_debt/discovery.py | get_metric_parsers | def get_metric_parsers(metric_packages=tuple(), include_defaults=True):
"""Gets all of the metric parsers.
Args:
metric_packages - Defaults to no extra packages. An iterable of
metric containing packages. A metric inherits DiffParserBase
and does not have __metric__ = False
... | python | def get_metric_parsers(metric_packages=tuple(), include_defaults=True):
"""Gets all of the metric parsers.
Args:
metric_packages - Defaults to no extra packages. An iterable of
metric containing packages. A metric inherits DiffParserBase
and does not have __metric__ = False
... | [
"def",
"get_metric_parsers",
"(",
"metric_packages",
"=",
"tuple",
"(",
")",
",",
"include_defaults",
"=",
"True",
")",
":",
"metric_parsers",
"=",
"set",
"(",
")",
"if",
"include_defaults",
":",
"import",
"git_code_debt",
".",
"metrics",
"metric_parsers",
".",
... | Gets all of the metric parsers.
Args:
metric_packages - Defaults to no extra packages. An iterable of
metric containing packages. A metric inherits DiffParserBase
and does not have __metric__ = False
A metric package must be imported using import a.b.c
include_d... | [
"Gets",
"all",
"of",
"the",
"metric",
"parsers",
"."
] | 31b41e2510063e9739de7987cdca95eaccaecbd6 | https://github.com/asottile/git-code-debt/blob/31b41e2510063e9739de7987cdca95eaccaecbd6/git_code_debt/discovery.py#L22-L40 |
11,274 | hustcc/timeago | src/timeago/locales/__init__.py | timeago_template | def timeago_template(locale, index, ago_in):
'''
simple locale implement
'''
try:
LOCALE = __import__('timeago.locales.' + locale)
LOCALE = locale_module(LOCALE, locale)
except:
locale = setting.DEFAULT_LOCALE
LOCALE = __import__('timeago.locales.' + locale)
L... | python | def timeago_template(locale, index, ago_in):
'''
simple locale implement
'''
try:
LOCALE = __import__('timeago.locales.' + locale)
LOCALE = locale_module(LOCALE, locale)
except:
locale = setting.DEFAULT_LOCALE
LOCALE = __import__('timeago.locales.' + locale)
L... | [
"def",
"timeago_template",
"(",
"locale",
",",
"index",
",",
"ago_in",
")",
":",
"try",
":",
"LOCALE",
"=",
"__import__",
"(",
"'timeago.locales.'",
"+",
"locale",
")",
"LOCALE",
"=",
"locale_module",
"(",
"LOCALE",
",",
"locale",
")",
"except",
":",
"loca... | simple locale implement | [
"simple",
"locale",
"implement"
] | 819fc6efefeccea2a39e6c1cb2f20b5d2cc9f613 | https://github.com/hustcc/timeago/blob/819fc6efefeccea2a39e6c1cb2f20b5d2cc9f613/src/timeago/locales/__init__.py#L20-L35 |
11,275 | hustcc/timeago | src/timeago/parser.py | parse | def parse(input):
'''
parse input to datetime
'''
if isinstance(input, datetime):
return input
if isinstance(input, date):
return date_to_datetime(input)
if isinstance(input, time):
return time_to_datetime(input)
if isinstance(input, (int, float)):
return time... | python | def parse(input):
'''
parse input to datetime
'''
if isinstance(input, datetime):
return input
if isinstance(input, date):
return date_to_datetime(input)
if isinstance(input, time):
return time_to_datetime(input)
if isinstance(input, (int, float)):
return time... | [
"def",
"parse",
"(",
"input",
")",
":",
"if",
"isinstance",
"(",
"input",
",",
"datetime",
")",
":",
"return",
"input",
"if",
"isinstance",
"(",
"input",
",",
"date",
")",
":",
"return",
"date_to_datetime",
"(",
"input",
")",
"if",
"isinstance",
"(",
"... | parse input to datetime | [
"parse",
"input",
"to",
"datetime"
] | 819fc6efefeccea2a39e6c1cb2f20b5d2cc9f613 | https://github.com/hustcc/timeago/blob/819fc6efefeccea2a39e6c1cb2f20b5d2cc9f613/src/timeago/parser.py#L16-L30 |
11,276 | hustcc/timeago | src/timeago/__init__.py | format | def format(date, now=None, locale='en'):
'''
the entry method
'''
if not isinstance(date, timedelta):
if now is None:
now = datetime.now()
date = parser.parse(date)
now = parser.parse(now)
if date is None:
raise ParameterUnvalid('the parameter `da... | python | def format(date, now=None, locale='en'):
'''
the entry method
'''
if not isinstance(date, timedelta):
if now is None:
now = datetime.now()
date = parser.parse(date)
now = parser.parse(now)
if date is None:
raise ParameterUnvalid('the parameter `da... | [
"def",
"format",
"(",
"date",
",",
"now",
"=",
"None",
",",
"locale",
"=",
"'en'",
")",
":",
"if",
"not",
"isinstance",
"(",
"date",
",",
"timedelta",
")",
":",
"if",
"now",
"is",
"None",
":",
"now",
"=",
"datetime",
".",
"now",
"(",
")",
"date",... | the entry method | [
"the",
"entry",
"method"
] | 819fc6efefeccea2a39e6c1cb2f20b5d2cc9f613 | https://github.com/hustcc/timeago/blob/819fc6efefeccea2a39e6c1cb2f20b5d2cc9f613/src/timeago/__init__.py#L36-L83 |
11,277 | coldfix/udiskie | udiskie/mount.py | _is_parent_of | def _is_parent_of(parent, child):
"""Check whether the first device is the parent of the second device."""
if child.is_partition:
return child.partition_slave == parent
if child.is_toplevel:
return child.drive == parent and child != parent
return False | python | def _is_parent_of(parent, child):
"""Check whether the first device is the parent of the second device."""
if child.is_partition:
return child.partition_slave == parent
if child.is_toplevel:
return child.drive == parent and child != parent
return False | [
"def",
"_is_parent_of",
"(",
"parent",
",",
"child",
")",
":",
"if",
"child",
".",
"is_partition",
":",
"return",
"child",
".",
"partition_slave",
"==",
"parent",
"if",
"child",
".",
"is_toplevel",
":",
"return",
"child",
".",
"drive",
"==",
"parent",
"and... | Check whether the first device is the parent of the second device. | [
"Check",
"whether",
"the",
"first",
"device",
"is",
"the",
"parent",
"of",
"the",
"second",
"device",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L36-L42 |
11,278 | coldfix/udiskie | udiskie/mount.py | prune_empty_node | def prune_empty_node(node, seen):
"""
Recursively remove empty branches and return whether this makes the node
itself empty.
The ``seen`` parameter is used to avoid infinite recursion due to cycles
(you never know).
"""
if node.methods:
return False
if id(node) in seen:
... | python | def prune_empty_node(node, seen):
"""
Recursively remove empty branches and return whether this makes the node
itself empty.
The ``seen`` parameter is used to avoid infinite recursion due to cycles
(you never know).
"""
if node.methods:
return False
if id(node) in seen:
... | [
"def",
"prune_empty_node",
"(",
"node",
",",
"seen",
")",
":",
"if",
"node",
".",
"methods",
":",
"return",
"False",
"if",
"id",
"(",
"node",
")",
"in",
"seen",
":",
"return",
"True",
"seen",
"=",
"seen",
"|",
"{",
"id",
"(",
"node",
")",
"}",
"f... | Recursively remove empty branches and return whether this makes the node
itself empty.
The ``seen`` parameter is used to avoid infinite recursion due to cycles
(you never know). | [
"Recursively",
"remove",
"empty",
"branches",
"and",
"return",
"whether",
"this",
"makes",
"the",
"node",
"itself",
"empty",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L844-L862 |
11,279 | coldfix/udiskie | udiskie/mount.py | Mounter.browse | async def browse(self, device):
"""
Launch file manager on the mount path of the specified device.
:param device: device object, block device path or mount path
:returns: whether the program was successfully launched.
"""
device = self._find_device(device)
if not... | python | async def browse(self, device):
"""
Launch file manager on the mount path of the specified device.
:param device: device object, block device path or mount path
:returns: whether the program was successfully launched.
"""
device = self._find_device(device)
if not... | [
"async",
"def",
"browse",
"(",
"self",
",",
"device",
")",
":",
"device",
"=",
"self",
".",
"_find_device",
"(",
"device",
")",
"if",
"not",
"device",
".",
"is_mounted",
":",
"self",
".",
"_log",
".",
"error",
"(",
"_",
"(",
"\"not browsing {0}: not moun... | Launch file manager on the mount path of the specified device.
:param device: device object, block device path or mount path
:returns: whether the program was successfully launched. | [
"Launch",
"file",
"manager",
"on",
"the",
"mount",
"path",
"of",
"the",
"specified",
"device",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L109-L126 |
11,280 | coldfix/udiskie | udiskie/mount.py | Mounter.terminal | async def terminal(self, device):
"""
Launch terminal on the mount path of the specified device.
:param device: device object, block device path or mount path
:returns: whether the program was successfully launched.
"""
device = self._find_device(device)
if not d... | python | async def terminal(self, device):
"""
Launch terminal on the mount path of the specified device.
:param device: device object, block device path or mount path
:returns: whether the program was successfully launched.
"""
device = self._find_device(device)
if not d... | [
"async",
"def",
"terminal",
"(",
"self",
",",
"device",
")",
":",
"device",
"=",
"self",
".",
"_find_device",
"(",
"device",
")",
"if",
"not",
"device",
".",
"is_mounted",
":",
"self",
".",
"_log",
".",
"error",
"(",
"_",
"(",
"\"not opening terminal {0}... | Launch terminal on the mount path of the specified device.
:param device: device object, block device path or mount path
:returns: whether the program was successfully launched. | [
"Launch",
"terminal",
"on",
"the",
"mount",
"path",
"of",
"the",
"specified",
"device",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L129-L146 |
11,281 | coldfix/udiskie | udiskie/mount.py | Mounter.mount | async def mount(self, device):
"""
Mount the device if not already mounted.
:param device: device object, block device path or mount path
:returns: whether the device is mounted.
"""
device = self._find_device(device)
if not self.is_handleable(device) or not devi... | python | async def mount(self, device):
"""
Mount the device if not already mounted.
:param device: device object, block device path or mount path
:returns: whether the device is mounted.
"""
device = self._find_device(device)
if not self.is_handleable(device) or not devi... | [
"async",
"def",
"mount",
"(",
"self",
",",
"device",
")",
":",
"device",
"=",
"self",
".",
"_find_device",
"(",
"device",
")",
"if",
"not",
"self",
".",
"is_handleable",
"(",
"device",
")",
"or",
"not",
"device",
".",
"is_filesystem",
":",
"self",
".",... | Mount the device if not already mounted.
:param device: device object, block device path or mount path
:returns: whether the device is mounted. | [
"Mount",
"the",
"device",
"if",
"not",
"already",
"mounted",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L150-L170 |
11,282 | coldfix/udiskie | udiskie/mount.py | Mounter.unmount | async def unmount(self, device):
"""
Unmount a Device if mounted.
:param device: device object, block device path or mount path
:returns: whether the device is unmounted
"""
device = self._find_device(device)
if not self.is_handleable(device) or not device.is_fil... | python | async def unmount(self, device):
"""
Unmount a Device if mounted.
:param device: device object, block device path or mount path
:returns: whether the device is unmounted
"""
device = self._find_device(device)
if not self.is_handleable(device) or not device.is_fil... | [
"async",
"def",
"unmount",
"(",
"self",
",",
"device",
")",
":",
"device",
"=",
"self",
".",
"_find_device",
"(",
"device",
")",
"if",
"not",
"self",
".",
"is_handleable",
"(",
"device",
")",
"or",
"not",
"device",
".",
"is_filesystem",
":",
"self",
".... | Unmount a Device if mounted.
:param device: device object, block device path or mount path
:returns: whether the device is unmounted | [
"Unmount",
"a",
"Device",
"if",
"mounted",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L180-L197 |
11,283 | coldfix/udiskie | udiskie/mount.py | Mounter.unlock | async def unlock(self, device):
"""
Unlock the device if not already unlocked.
:param device: device object, block device path or mount path
:returns: whether the device is unlocked
"""
device = self._find_device(device)
if not self.is_handleable(device) or not d... | python | async def unlock(self, device):
"""
Unlock the device if not already unlocked.
:param device: device object, block device path or mount path
:returns: whether the device is unlocked
"""
device = self._find_device(device)
if not self.is_handleable(device) or not d... | [
"async",
"def",
"unlock",
"(",
"self",
",",
"device",
")",
":",
"device",
"=",
"self",
".",
"_find_device",
"(",
"device",
")",
"if",
"not",
"self",
".",
"is_handleable",
"(",
"device",
")",
"or",
"not",
"device",
".",
"is_crypto",
":",
"self",
".",
... | Unlock the device if not already unlocked.
:param device: device object, block device path or mount path
:returns: whether the device is unlocked | [
"Unlock",
"the",
"device",
"if",
"not",
"already",
"unlocked",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L201-L242 |
11,284 | coldfix/udiskie | udiskie/mount.py | Mounter.lock | async def lock(self, device):
"""
Lock device if unlocked.
:param device: device object, block device path or mount path
:returns: whether the device is locked
"""
device = self._find_device(device)
if not self.is_handleable(device) or not device.is_crypto:
... | python | async def lock(self, device):
"""
Lock device if unlocked.
:param device: device object, block device path or mount path
:returns: whether the device is locked
"""
device = self._find_device(device)
if not self.is_handleable(device) or not device.is_crypto:
... | [
"async",
"def",
"lock",
"(",
"self",
",",
"device",
")",
":",
"device",
"=",
"self",
".",
"_find_device",
"(",
"device",
")",
"if",
"not",
"self",
".",
"is_handleable",
"(",
"device",
")",
"or",
"not",
"device",
".",
"is_crypto",
":",
"self",
".",
"_... | Lock device if unlocked.
:param device: device object, block device path or mount path
:returns: whether the device is locked | [
"Lock",
"device",
"if",
"unlocked",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L299-L316 |
11,285 | coldfix/udiskie | udiskie/mount.py | Mounter.add | async def add(self, device, recursive=None):
"""
Mount or unlock the device depending on its type.
:param device: device object, block device path or mount path
:param bool recursive: recursively mount and unlock child devices
:returns: whether all attempted operations succeeded... | python | async def add(self, device, recursive=None):
"""
Mount or unlock the device depending on its type.
:param device: device object, block device path or mount path
:param bool recursive: recursively mount and unlock child devices
:returns: whether all attempted operations succeeded... | [
"async",
"def",
"add",
"(",
"self",
",",
"device",
",",
"recursive",
"=",
"None",
")",
":",
"device",
",",
"created",
"=",
"await",
"self",
".",
"_find_device_losetup",
"(",
"device",
")",
"if",
"created",
"and",
"recursive",
"is",
"False",
":",
"return"... | Mount or unlock the device depending on its type.
:param device: device object, block device path or mount path
:param bool recursive: recursively mount and unlock child devices
:returns: whether all attempted operations succeeded | [
"Mount",
"or",
"unlock",
"the",
"device",
"depending",
"on",
"its",
"type",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L320-L354 |
11,286 | coldfix/udiskie | udiskie/mount.py | Mounter.auto_add | async def auto_add(self, device, recursive=None, automount=True):
"""
Automatically attempt to mount or unlock a device, but be quiet if the
device is not supported.
:param device: device object, block device path or mount path
:param bool recursive: recursively mount and unlock... | python | async def auto_add(self, device, recursive=None, automount=True):
"""
Automatically attempt to mount or unlock a device, but be quiet if the
device is not supported.
:param device: device object, block device path or mount path
:param bool recursive: recursively mount and unlock... | [
"async",
"def",
"auto_add",
"(",
"self",
",",
"device",
",",
"recursive",
"=",
"None",
",",
"automount",
"=",
"True",
")",
":",
"device",
",",
"created",
"=",
"await",
"self",
".",
"_find_device_losetup",
"(",
"device",
")",
"if",
"created",
"and",
"recu... | Automatically attempt to mount or unlock a device, but be quiet if the
device is not supported.
:param device: device object, block device path or mount path
:param bool recursive: recursively mount and unlock child devices
:returns: whether all attempted operations succeeded | [
"Automatically",
"attempt",
"to",
"mount",
"or",
"unlock",
"a",
"device",
"but",
"be",
"quiet",
"if",
"the",
"device",
"is",
"not",
"supported",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L357-L396 |
11,287 | coldfix/udiskie | udiskie/mount.py | Mounter.remove | async def remove(self, device, force=False, detach=False, eject=False,
lock=False):
"""
Unmount or lock the device depending on device type.
:param device: device object, block device path or mount path
:param bool force: recursively remove all child devices
... | python | async def remove(self, device, force=False, detach=False, eject=False,
lock=False):
"""
Unmount or lock the device depending on device type.
:param device: device object, block device path or mount path
:param bool force: recursively remove all child devices
... | [
"async",
"def",
"remove",
"(",
"self",
",",
"device",
",",
"force",
"=",
"False",
",",
"detach",
"=",
"False",
",",
"eject",
"=",
"False",
",",
"lock",
"=",
"False",
")",
":",
"device",
"=",
"self",
".",
"_find_device",
"(",
"device",
")",
"if",
"d... | Unmount or lock the device depending on device type.
:param device: device object, block device path or mount path
:param bool force: recursively remove all child devices
:param bool detach: detach the root drive
:param bool eject: remove media from the root drive
:param bool lo... | [
"Unmount",
"or",
"lock",
"the",
"device",
"depending",
"on",
"device",
"type",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L399-L444 |
11,288 | coldfix/udiskie | udiskie/mount.py | Mounter.eject | async def eject(self, device, force=False):
"""
Eject a device after unmounting all its mounted filesystems.
:param device: device object, block device path or mount path
:param bool force: remove child devices before trying to eject
:returns: whether the operation succeeded
... | python | async def eject(self, device, force=False):
"""
Eject a device after unmounting all its mounted filesystems.
:param device: device object, block device path or mount path
:param bool force: remove child devices before trying to eject
:returns: whether the operation succeeded
... | [
"async",
"def",
"eject",
"(",
"self",
",",
"device",
",",
"force",
"=",
"False",
")",
":",
"device",
"=",
"self",
".",
"_find_device",
"(",
"device",
")",
"if",
"not",
"self",
".",
"is_handleable",
"(",
"device",
")",
":",
"self",
".",
"_log",
".",
... | Eject a device after unmounting all its mounted filesystems.
:param device: device object, block device path or mount path
:param bool force: remove child devices before trying to eject
:returns: whether the operation succeeded | [
"Eject",
"a",
"device",
"after",
"unmounting",
"all",
"its",
"mounted",
"filesystems",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L496-L519 |
11,289 | coldfix/udiskie | udiskie/mount.py | Mounter.detach | async def detach(self, device, force=False):
"""
Detach a device after unmounting all its mounted filesystems.
:param device: device object, block device path or mount path
:param bool force: remove child devices before trying to detach
:returns: whether the operation succeeded
... | python | async def detach(self, device, force=False):
"""
Detach a device after unmounting all its mounted filesystems.
:param device: device object, block device path or mount path
:param bool force: remove child devices before trying to detach
:returns: whether the operation succeeded
... | [
"async",
"def",
"detach",
"(",
"self",
",",
"device",
",",
"force",
"=",
"False",
")",
":",
"device",
"=",
"self",
".",
"_find_device",
"(",
"device",
")",
"if",
"not",
"self",
".",
"is_handleable",
"(",
"device",
")",
":",
"self",
".",
"_log",
".",
... | Detach a device after unmounting all its mounted filesystems.
:param device: device object, block device path or mount path
:param bool force: remove child devices before trying to detach
:returns: whether the operation succeeded | [
"Detach",
"a",
"device",
"after",
"unmounting",
"all",
"its",
"mounted",
"filesystems",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L522-L543 |
11,290 | coldfix/udiskie | udiskie/mount.py | Mounter.add_all | async def add_all(self, recursive=False):
"""
Add all handleable devices that available at start.
:param bool recursive: recursively mount and unlock child devices
:returns: whether all attempted operations succeeded
"""
tasks = [self.auto_add(device, recursive=recursive... | python | async def add_all(self, recursive=False):
"""
Add all handleable devices that available at start.
:param bool recursive: recursively mount and unlock child devices
:returns: whether all attempted operations succeeded
"""
tasks = [self.auto_add(device, recursive=recursive... | [
"async",
"def",
"add_all",
"(",
"self",
",",
"recursive",
"=",
"False",
")",
":",
"tasks",
"=",
"[",
"self",
".",
"auto_add",
"(",
"device",
",",
"recursive",
"=",
"recursive",
")",
"for",
"device",
"in",
"self",
".",
"get_all_handleable_leaves",
"(",
")... | Add all handleable devices that available at start.
:param bool recursive: recursively mount and unlock child devices
:returns: whether all attempted operations succeeded | [
"Add",
"all",
"handleable",
"devices",
"that",
"available",
"at",
"start",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L546-L557 |
11,291 | coldfix/udiskie | udiskie/mount.py | Mounter.remove_all | async def remove_all(self, detach=False, eject=False, lock=False):
"""
Remove all filesystems handleable by udiskie.
:param bool detach: detach the root drive
:param bool eject: remove media from the root drive
:param bool lock: lock the associated LUKS cleartext slave
:... | python | async def remove_all(self, detach=False, eject=False, lock=False):
"""
Remove all filesystems handleable by udiskie.
:param bool detach: detach the root drive
:param bool eject: remove media from the root drive
:param bool lock: lock the associated LUKS cleartext slave
:... | [
"async",
"def",
"remove_all",
"(",
"self",
",",
"detach",
"=",
"False",
",",
"eject",
"=",
"False",
",",
"lock",
"=",
"False",
")",
":",
"kw",
"=",
"dict",
"(",
"force",
"=",
"True",
",",
"detach",
"=",
"detach",
",",
"eject",
"=",
"eject",
",",
... | Remove all filesystems handleable by udiskie.
:param bool detach: detach the root drive
:param bool eject: remove media from the root drive
:param bool lock: lock the associated LUKS cleartext slave
:returns: whether all attempted operations succeeded | [
"Remove",
"all",
"filesystems",
"handleable",
"by",
"udiskie",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L559-L573 |
11,292 | coldfix/udiskie | udiskie/mount.py | Mounter.losetup | async def losetup(self, image, read_only=True, offset=None, size=None,
no_part_scan=None):
"""
Setup a loop device.
:param str image: path of the image file
:param bool read_only:
:param int offset:
:param int size:
:param bool no_part_scan:... | python | async def losetup(self, image, read_only=True, offset=None, size=None,
no_part_scan=None):
"""
Setup a loop device.
:param str image: path of the image file
:param bool read_only:
:param int offset:
:param int size:
:param bool no_part_scan:... | [
"async",
"def",
"losetup",
"(",
"self",
",",
"image",
",",
"read_only",
"=",
"True",
",",
"offset",
"=",
"None",
",",
"size",
"=",
"None",
",",
"no_part_scan",
"=",
"None",
")",
":",
"try",
":",
"device",
"=",
"self",
".",
"udisks",
".",
"find",
"(... | Setup a loop device.
:param str image: path of the image file
:param bool read_only:
:param int offset:
:param int size:
:param bool no_part_scan:
:returns: the device object for the loop device | [
"Setup",
"a",
"loop",
"device",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L576-L608 |
11,293 | coldfix/udiskie | udiskie/mount.py | Mounter.delete | async def delete(self, device, remove=True):
"""
Detach the loop device.
:param device: device object, block device path or mount path
:param bool remove: whether to unmount the partition etc.
:returns: whether the loop device is deleted
"""
device = self._find_d... | python | async def delete(self, device, remove=True):
"""
Detach the loop device.
:param device: device object, block device path or mount path
:param bool remove: whether to unmount the partition etc.
:returns: whether the loop device is deleted
"""
device = self._find_d... | [
"async",
"def",
"delete",
"(",
"self",
",",
"device",
",",
"remove",
"=",
"True",
")",
":",
"device",
"=",
"self",
".",
"_find_device",
"(",
"device",
")",
"if",
"not",
"self",
".",
"is_handleable",
"(",
"device",
")",
"or",
"not",
"device",
".",
"is... | Detach the loop device.
:param device: device object, block device path or mount path
:param bool remove: whether to unmount the partition etc.
:returns: whether the loop device is deleted | [
"Detach",
"the",
"loop",
"device",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L611-L628 |
11,294 | coldfix/udiskie | udiskie/mount.py | Mounter.is_handleable | def is_handleable(self, device):
# TODO: handle pathes in first argument
"""
Check whether this device should be handled by udiskie.
:param device: device object, block device path or mount path
:returns: handleability
Currently this just means that the device is remova... | python | def is_handleable(self, device):
# TODO: handle pathes in first argument
"""
Check whether this device should be handled by udiskie.
:param device: device object, block device path or mount path
:returns: handleability
Currently this just means that the device is remova... | [
"def",
"is_handleable",
"(",
"self",
",",
"device",
")",
":",
"# TODO: handle pathes in first argument",
"ignored",
"=",
"self",
".",
"_ignore_device",
"(",
"device",
")",
"# propagate handleability of parent devices:",
"if",
"ignored",
"is",
"None",
"and",
"device",
... | Check whether this device should be handled by udiskie.
:param device: device object, block device path or mount path
:returns: handleability
Currently this just means that the device is removable and holds a
filesystem or the device is a LUKS encrypted volume. | [
"Check",
"whether",
"this",
"device",
"should",
"be",
"handled",
"by",
"udiskie",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L631-L646 |
11,295 | coldfix/udiskie | udiskie/mount.py | Mounter.is_addable | def is_addable(self, device, automount=True):
"""Check if device can be added with ``auto_add``."""
if not self.is_automount(device, automount):
return False
if device.is_filesystem:
return not device.is_mounted
if device.is_crypto:
return self._prompt... | python | def is_addable(self, device, automount=True):
"""Check if device can be added with ``auto_add``."""
if not self.is_automount(device, automount):
return False
if device.is_filesystem:
return not device.is_mounted
if device.is_crypto:
return self._prompt... | [
"def",
"is_addable",
"(",
"self",
",",
"device",
",",
"automount",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"is_automount",
"(",
"device",
",",
"automount",
")",
":",
"return",
"False",
"if",
"device",
".",
"is_filesystem",
":",
"return",
"not",
... | Check if device can be added with ``auto_add``. | [
"Check",
"if",
"device",
"can",
"be",
"added",
"with",
"auto_add",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L656-L668 |
11,296 | coldfix/udiskie | udiskie/mount.py | Mounter.is_removable | def is_removable(self, device):
"""Check if device can be removed with ``auto_remove``."""
if not self.is_handleable(device):
return False
if device.is_filesystem:
return device.is_mounted
if device.is_crypto:
return device.is_unlocked
if devic... | python | def is_removable(self, device):
"""Check if device can be removed with ``auto_remove``."""
if not self.is_handleable(device):
return False
if device.is_filesystem:
return device.is_mounted
if device.is_crypto:
return device.is_unlocked
if devic... | [
"def",
"is_removable",
"(",
"self",
",",
"device",
")",
":",
"if",
"not",
"self",
".",
"is_handleable",
"(",
"device",
")",
":",
"return",
"False",
"if",
"device",
".",
"is_filesystem",
":",
"return",
"device",
".",
"is_mounted",
"if",
"device",
".",
"is... | Check if device can be removed with ``auto_remove``. | [
"Check",
"if",
"device",
"can",
"be",
"removed",
"with",
"auto_remove",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L670-L682 |
11,297 | coldfix/udiskie | udiskie/mount.py | Mounter.get_all_handleable | def get_all_handleable(self):
"""Get list of all known handleable devices."""
nodes = self.get_device_tree()
return [node.device
for node in sorted(nodes.values(), key=DevNode._sort_key)
if not node.ignored and node.device] | python | def get_all_handleable(self):
"""Get list of all known handleable devices."""
nodes = self.get_device_tree()
return [node.device
for node in sorted(nodes.values(), key=DevNode._sort_key)
if not node.ignored and node.device] | [
"def",
"get_all_handleable",
"(",
"self",
")",
":",
"nodes",
"=",
"self",
".",
"get_device_tree",
"(",
")",
"return",
"[",
"node",
".",
"device",
"for",
"node",
"in",
"sorted",
"(",
"nodes",
".",
"values",
"(",
")",
",",
"key",
"=",
"DevNode",
".",
"... | Get list of all known handleable devices. | [
"Get",
"list",
"of",
"all",
"known",
"handleable",
"devices",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L684-L689 |
11,298 | coldfix/udiskie | udiskie/mount.py | Mounter.get_all_handleable_roots | def get_all_handleable_roots(self):
"""
Get list of all handleable devices, return only those that represent
root nodes within the filtered device tree.
"""
nodes = self.get_device_tree()
return [node.device
for node in sorted(nodes.values(), key=DevNode._... | python | def get_all_handleable_roots(self):
"""
Get list of all handleable devices, return only those that represent
root nodes within the filtered device tree.
"""
nodes = self.get_device_tree()
return [node.device
for node in sorted(nodes.values(), key=DevNode._... | [
"def",
"get_all_handleable_roots",
"(",
"self",
")",
":",
"nodes",
"=",
"self",
".",
"get_device_tree",
"(",
")",
"return",
"[",
"node",
".",
"device",
"for",
"node",
"in",
"sorted",
"(",
"nodes",
".",
"values",
"(",
")",
",",
"key",
"=",
"DevNode",
".... | Get list of all handleable devices, return only those that represent
root nodes within the filtered device tree. | [
"Get",
"list",
"of",
"all",
"handleable",
"devices",
"return",
"only",
"those",
"that",
"represent",
"root",
"nodes",
"within",
"the",
"filtered",
"device",
"tree",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L691-L700 |
11,299 | coldfix/udiskie | udiskie/mount.py | Mounter.get_all_handleable_leaves | def get_all_handleable_leaves(self):
"""
Get list of all handleable devices, return only those that represent
leaf nodes within the filtered device tree.
"""
nodes = self.get_device_tree()
return [node.device
for node in sorted(nodes.values(), key=DevNode.... | python | def get_all_handleable_leaves(self):
"""
Get list of all handleable devices, return only those that represent
leaf nodes within the filtered device tree.
"""
nodes = self.get_device_tree()
return [node.device
for node in sorted(nodes.values(), key=DevNode.... | [
"def",
"get_all_handleable_leaves",
"(",
"self",
")",
":",
"nodes",
"=",
"self",
".",
"get_device_tree",
"(",
")",
"return",
"[",
"node",
".",
"device",
"for",
"node",
"in",
"sorted",
"(",
"nodes",
".",
"values",
"(",
")",
",",
"key",
"=",
"DevNode",
"... | Get list of all handleable devices, return only those that represent
leaf nodes within the filtered device tree. | [
"Get",
"list",
"of",
"all",
"handleable",
"devices",
"return",
"only",
"those",
"that",
"represent",
"leaf",
"nodes",
"within",
"the",
"filtered",
"device",
"tree",
"."
] | 804c9d27df6f7361fec3097c432398f2d702f911 | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L702-L711 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.