repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
20c/twentyc.rpc | twentyc/rpc/client.py | RestClient.update | def update(self, typ, id, **kwargs):
"""
update just fields sent by keyword args
"""
return self._load(self._request(typ, id=id, method='PUT', data=kwargs)) | python | def update(self, typ, id, **kwargs):
"""
update just fields sent by keyword args
"""
return self._load(self._request(typ, id=id, method='PUT', data=kwargs)) | [
"def",
"update",
"(",
"self",
",",
"typ",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_load",
"(",
"self",
".",
"_request",
"(",
"typ",
",",
"id",
"=",
"id",
",",
"method",
"=",
"'PUT'",
",",
"data",
"=",
"kwargs",
")"... | update just fields sent by keyword args | [
"update",
"just",
"fields",
"sent",
"by",
"keyword",
"args"
] | train | https://github.com/20c/twentyc.rpc/blob/23ff07be55eaf21cc2e1a13c2879710b5bc7f933/twentyc/rpc/client.py#L145-L149 |
20c/twentyc.rpc | twentyc/rpc/client.py | RestClient.save | def save(self, typ, data):
"""
Save the dataset pointed to by data (create or update)
"""
if 'id' in data:
return self._load(self._request(typ, id=data['id'], method='PUT', data=data))
return self.create(typ, data) | python | def save(self, typ, data):
"""
Save the dataset pointed to by data (create or update)
"""
if 'id' in data:
return self._load(self._request(typ, id=data['id'], method='PUT', data=data))
return self.create(typ, data) | [
"def",
"save",
"(",
"self",
",",
"typ",
",",
"data",
")",
":",
"if",
"'id'",
"in",
"data",
":",
"return",
"self",
".",
"_load",
"(",
"self",
".",
"_request",
"(",
"typ",
",",
"id",
"=",
"data",
"[",
"'id'",
"]",
",",
"method",
"=",
"'PUT'",
","... | Save the dataset pointed to by data (create or update) | [
"Save",
"the",
"dataset",
"pointed",
"to",
"by",
"data",
"(",
"create",
"or",
"update",
")"
] | train | https://github.com/20c/twentyc.rpc/blob/23ff07be55eaf21cc2e1a13c2879710b5bc7f933/twentyc/rpc/client.py#L151-L158 |
20c/twentyc.rpc | twentyc/rpc/client.py | RestClient.rm | def rm(self, typ, id):
"""
remove typ by id
"""
return self._load(self._request(typ, id=id, method='DELETE')) | python | def rm(self, typ, id):
"""
remove typ by id
"""
return self._load(self._request(typ, id=id, method='DELETE')) | [
"def",
"rm",
"(",
"self",
",",
"typ",
",",
"id",
")",
":",
"return",
"self",
".",
"_load",
"(",
"self",
".",
"_request",
"(",
"typ",
",",
"id",
"=",
"id",
",",
"method",
"=",
"'DELETE'",
")",
")"
] | remove typ by id | [
"remove",
"typ",
"by",
"id"
] | train | https://github.com/20c/twentyc.rpc/blob/23ff07be55eaf21cc2e1a13c2879710b5bc7f933/twentyc/rpc/client.py#L160-L164 |
renalreg/cornflake | cornflake/serializers.py | _merge_fields | def _merge_fields(a, b):
"""Merge two lists of fields.
Fields in `b` override fields in `a`. Fields in `a` are output first.
"""
a_names = set(x[0] for x in a)
b_names = set(x[0] for x in b)
a_keep = a_names - b_names
fields = []
for name, field in a:
if name in a_keep:
... | python | def _merge_fields(a, b):
"""Merge two lists of fields.
Fields in `b` override fields in `a`. Fields in `a` are output first.
"""
a_names = set(x[0] for x in a)
b_names = set(x[0] for x in b)
a_keep = a_names - b_names
fields = []
for name, field in a:
if name in a_keep:
... | [
"def",
"_merge_fields",
"(",
"a",
",",
"b",
")",
":",
"a_names",
"=",
"set",
"(",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"a",
")",
"b_names",
"=",
"set",
"(",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"b",
")",
"a_keep",
"=",
"a_names",
"-",
"b_... | Merge two lists of fields.
Fields in `b` override fields in `a`. Fields in `a` are output first. | [
"Merge",
"two",
"lists",
"of",
"fields",
"."
] | train | https://github.com/renalreg/cornflake/blob/ce0c0b260c95e84046f108d05773f1f130ae886c/cornflake/serializers.py#L95-L113 |
dariosky/wfcli | wfcli/__main__.py | main | def main(args=None):
"""The main routine."""
# example './cli.py install redis --app-name tambeta'
parser = get_cli_parser()
if args is None:
args = sys.argv[1:]
args = parser.parse_args(args)
# set the credential in the environment
if args.webfaction_user:
os.environ['WEBFA... | python | def main(args=None):
"""The main routine."""
# example './cli.py install redis --app-name tambeta'
parser = get_cli_parser()
if args is None:
args = sys.argv[1:]
args = parser.parse_args(args)
# set the credential in the environment
if args.webfaction_user:
os.environ['WEBFA... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"# example './cli.py install redis --app-name tambeta'",
"parser",
"=",
"get_cli_parser",
"(",
")",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"args",
"=",
"parse... | The main routine. | [
"The",
"main",
"routine",
"."
] | train | https://github.com/dariosky/wfcli/blob/87a9ed30dbd456f801135a55099f0541b0614ccb/wfcli/__main__.py#L44-L78 |
hvishwanath/libpaas | libpaas/paascli/config.py | Config.getInstance | def getInstance(cls, *args):
'''
Returns a singleton instance of the class
'''
if not cls.__singleton:
cls.__singleton = Config(*args)
return cls.__singleton | python | def getInstance(cls, *args):
'''
Returns a singleton instance of the class
'''
if not cls.__singleton:
cls.__singleton = Config(*args)
return cls.__singleton | [
"def",
"getInstance",
"(",
"cls",
",",
"*",
"args",
")",
":",
"if",
"not",
"cls",
".",
"__singleton",
":",
"cls",
".",
"__singleton",
"=",
"Config",
"(",
"*",
"args",
")",
"return",
"cls",
".",
"__singleton"
] | Returns a singleton instance of the class | [
"Returns",
"a",
"singleton",
"instance",
"of",
"the",
"class"
] | train | https://github.com/hvishwanath/libpaas/blob/3df07adca59c003ee754c4e919cf506c13953be1/libpaas/paascli/config.py#L19-L25 |
ludeeus/pyruter | pyruter/common.py | CommonFunctions.api_call | async def api_call(self, endpoint):
"""Call the API."""
data = None
if self.session is None:
self.session = aiohttp.ClientSession()
try:
async with async_timeout.timeout(5, loop=self.loop):
response = await self.session.get(endpoint, headers=HEADER... | python | async def api_call(self, endpoint):
"""Call the API."""
data = None
if self.session is None:
self.session = aiohttp.ClientSession()
try:
async with async_timeout.timeout(5, loop=self.loop):
response = await self.session.get(endpoint, headers=HEADER... | [
"async",
"def",
"api_call",
"(",
"self",
",",
"endpoint",
")",
":",
"data",
"=",
"None",
"if",
"self",
".",
"session",
"is",
"None",
":",
"self",
".",
"session",
"=",
"aiohttp",
".",
"ClientSession",
"(",
")",
"try",
":",
"async",
"with",
"async_timeou... | Call the API. | [
"Call",
"the",
"API",
"."
] | train | https://github.com/ludeeus/pyruter/blob/415d8b9c8bfd48caa82c1a1201bfd3beb670a117/pyruter/common.py#L20-L33 |
minhhoit/yacms | yacms/conf/__init__.py | register_setting | def register_setting(name=None, label=None, editable=False, description=None,
default=None, choices=None, append=False,
translatable=False):
"""
Registers a setting that can be edited via the admin. This mostly
equates to storing the given args as a dict in the ``re... | python | def register_setting(name=None, label=None, editable=False, description=None,
default=None, choices=None, append=False,
translatable=False):
"""
Registers a setting that can be edited via the admin. This mostly
equates to storing the given args as a dict in the ``re... | [
"def",
"register_setting",
"(",
"name",
"=",
"None",
",",
"label",
"=",
"None",
",",
"editable",
"=",
"False",
",",
"description",
"=",
"None",
",",
"default",
"=",
"None",
",",
"choices",
"=",
"None",
",",
"append",
"=",
"False",
",",
"translatable",
... | Registers a setting that can be edited via the admin. This mostly
equates to storing the given args as a dict in the ``registry``
dict by name. | [
"Registers",
"a",
"setting",
"that",
"can",
"be",
"edited",
"via",
"the",
"admin",
".",
"This",
"mostly",
"equates",
"to",
"storing",
"the",
"given",
"args",
"as",
"a",
"dict",
"in",
"the",
"registry",
"dict",
"by",
"name",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/conf/__init__.py#L25-L76 |
minhhoit/yacms | yacms/conf/__init__.py | Settings._get_editable | def _get_editable(self, request):
"""
Get the dictionary of editable settings for a given request. Settings
are fetched from the database once per request and then stored in
``_editable_caches``, a WeakKeyDictionary that will automatically
discard each entry when no more referenc... | python | def _get_editable(self, request):
"""
Get the dictionary of editable settings for a given request. Settings
are fetched from the database once per request and then stored in
``_editable_caches``, a WeakKeyDictionary that will automatically
discard each entry when no more referenc... | [
"def",
"_get_editable",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"editable_settings",
"=",
"self",
".",
"_editable_caches",
"[",
"request",
"]",
"except",
"KeyError",
":",
"editable_settings",
"=",
"self",
".",
"_editable_caches",
"[",
"request",
"]"... | Get the dictionary of editable settings for a given request. Settings
are fetched from the database once per request and then stored in
``_editable_caches``, a WeakKeyDictionary that will automatically
discard each entry when no more references to the request exist. | [
"Get",
"the",
"dictionary",
"of",
"editable",
"settings",
"for",
"a",
"given",
"request",
".",
"Settings",
"are",
"fetched",
"from",
"the",
"database",
"once",
"per",
"request",
"and",
"then",
"stored",
"in",
"_editable_caches",
"a",
"WeakKeyDictionary",
"that",... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/conf/__init__.py#L142-L153 |
minhhoit/yacms | yacms/conf/__init__.py | Settings._to_python | def _to_python(cls, setting, raw_value):
"""
Convert a value stored in the database for a particular setting
to its correct type, as determined by ``register_setting()``.
"""
type_fn = cls.TYPE_FUNCTIONS.get(setting["type"], setting["type"])
try:
value = typ... | python | def _to_python(cls, setting, raw_value):
"""
Convert a value stored in the database for a particular setting
to its correct type, as determined by ``register_setting()``.
"""
type_fn = cls.TYPE_FUNCTIONS.get(setting["type"], setting["type"])
try:
value = typ... | [
"def",
"_to_python",
"(",
"cls",
",",
"setting",
",",
"raw_value",
")",
":",
"type_fn",
"=",
"cls",
".",
"TYPE_FUNCTIONS",
".",
"get",
"(",
"setting",
"[",
"\"type\"",
"]",
",",
"setting",
"[",
"\"type\"",
"]",
")",
"try",
":",
"value",
"=",
"type_fn",... | Convert a value stored in the database for a particular setting
to its correct type, as determined by ``register_setting()``. | [
"Convert",
"a",
"value",
"stored",
"in",
"the",
"database",
"for",
"a",
"particular",
"setting",
"to",
"its",
"correct",
"type",
"as",
"determined",
"by",
"register_setting",
"()",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/conf/__init__.py#L156-L176 |
minhhoit/yacms | yacms/conf/__init__.py | Settings._load | def _load(self):
"""
Load editable settings from the database and return them as a dict.
Delete any settings from the database that are no longer registered,
and emit a warning if there are settings that are defined in both
settings.py and the database.
"""
from y... | python | def _load(self):
"""
Load editable settings from the database and return them as a dict.
Delete any settings from the database that are no longer registered,
and emit a warning if there are settings that are defined in both
settings.py and the database.
"""
from y... | [
"def",
"_load",
"(",
"self",
")",
":",
"from",
"yacms",
".",
"conf",
".",
"models",
"import",
"Setting",
"removed_settings",
"=",
"[",
"]",
"conflicting_settings",
"=",
"[",
"]",
"new_cache",
"=",
"{",
"}",
"for",
"setting_obj",
"in",
"Setting",
".",
"ob... | Load editable settings from the database and return them as a dict.
Delete any settings from the database that are no longer registered,
and emit a warning if there are settings that are defined in both
settings.py and the database. | [
"Load",
"editable",
"settings",
"from",
"the",
"database",
"and",
"return",
"them",
"as",
"a",
"dict",
".",
"Delete",
"any",
"settings",
"from",
"the",
"database",
"that",
"are",
"no",
"longer",
"registered",
"and",
"emit",
"a",
"warning",
"if",
"there",
"... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/conf/__init__.py#L178-L223 |
yougov/vr.runners | vr/runners/base.py | untar | def untar(tarpath, outfolder, owners=None, overwrite=True, fixperms=True):
"""
Unpack tarpath to outfolder. Make a guess about the compression based on
file extension (.gz or .bz2).
The unpacking of the tarfile is done in a temp directory and moved into
place atomically at the end (assuming /tmp i... | python | def untar(tarpath, outfolder, owners=None, overwrite=True, fixperms=True):
"""
Unpack tarpath to outfolder. Make a guess about the compression based on
file extension (.gz or .bz2).
The unpacking of the tarfile is done in a temp directory and moved into
place atomically at the end (assuming /tmp i... | [
"def",
"untar",
"(",
"tarpath",
",",
"outfolder",
",",
"owners",
"=",
"None",
",",
"overwrite",
"=",
"True",
",",
"fixperms",
"=",
"True",
")",
":",
"# We don't use fixperms at all",
"_ignored",
"=",
"fixperms",
"# noqa",
"# make a folder to untar to",
"with",
"... | Unpack tarpath to outfolder. Make a guess about the compression based on
file extension (.gz or .bz2).
The unpacking of the tarfile is done in a temp directory and moved into
place atomically at the end (assuming /tmp is on the same filesystem as
outfolder).
If 'owners' is provided, it should be ... | [
"Unpack",
"tarpath",
"to",
"outfolder",
".",
"Make",
"a",
"guess",
"about",
"the",
"compression",
"based",
"on",
"file",
"extension",
"(",
".",
"gz",
"or",
".",
"bz2",
")",
"."
] | train | https://github.com/yougov/vr.runners/blob/f43ba50a64b17ee4f07596fe225bcb38ca6652ad/vr/runners/base.py#L368-L424 |
yougov/vr.runners | vr/runners/base.py | ensure_file | def ensure_file(url, path, md5sum=None):
"""
If file is not already at 'path', then download from 'url' and put it
there.
If md5sum is provided, and 'path' exists, check that file matches the
md5sum. If not, re-download.
"""
if not os.path.isfile(path) or (md5sum and md5sum != file_md5(pa... | python | def ensure_file(url, path, md5sum=None):
"""
If file is not already at 'path', then download from 'url' and put it
there.
If md5sum is provided, and 'path' exists, check that file matches the
md5sum. If not, re-download.
"""
if not os.path.isfile(path) or (md5sum and md5sum != file_md5(pa... | [
"def",
"ensure_file",
"(",
"url",
",",
"path",
",",
"md5sum",
"=",
"None",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
"or",
"(",
"md5sum",
"and",
"md5sum",
"!=",
"file_md5",
"(",
"path",
")",
")",
":",
"download_file... | If file is not already at 'path', then download from 'url' and put it
there.
If md5sum is provided, and 'path' exists, check that file matches the
md5sum. If not, re-download. | [
"If",
"file",
"is",
"not",
"already",
"at",
"path",
"then",
"download",
"from",
"url",
"and",
"put",
"it",
"there",
"."
] | train | https://github.com/yougov/vr.runners/blob/f43ba50a64b17ee4f07596fe225bcb38ca6652ad/vr/runners/base.py#L427-L437 |
yougov/vr.runners | vr/runners/base.py | get_template | def get_template(name):
"""
Look for 'name' in the vr.runners.templates folder. Return its contents.
"""
path = pkg_resources.resource_filename('vr.runners', 'templates/' + name)
with open(path, 'r') as f:
return f.read() | python | def get_template(name):
"""
Look for 'name' in the vr.runners.templates folder. Return its contents.
"""
path = pkg_resources.resource_filename('vr.runners', 'templates/' + name)
with open(path, 'r') as f:
return f.read() | [
"def",
"get_template",
"(",
"name",
")",
":",
"path",
"=",
"pkg_resources",
".",
"resource_filename",
"(",
"'vr.runners'",
",",
"'templates/'",
"+",
"name",
")",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"f",
":",
"return",
"f",
".",
"read",
... | Look for 'name' in the vr.runners.templates folder. Return its contents. | [
"Look",
"for",
"name",
"in",
"the",
"vr",
".",
"runners",
".",
"templates",
"folder",
".",
"Return",
"its",
"contents",
"."
] | train | https://github.com/yougov/vr.runners/blob/f43ba50a64b17ee4f07596fe225bcb38ca6652ad/vr/runners/base.py#L451-L457 |
yougov/vr.runners | vr/runners/base.py | BaseRunner.write_proc_sh | def write_proc_sh(self):
"""
Write the script that is the first thing called inside the
container. It sets env vars and then calls the real program.
"""
print("Writing proc.sh")
context = {
'tmp': '/tmp',
'home': '/app',
'settings': '/... | python | def write_proc_sh(self):
"""
Write the script that is the first thing called inside the
container. It sets env vars and then calls the real program.
"""
print("Writing proc.sh")
context = {
'tmp': '/tmp',
'home': '/app',
'settings': '/... | [
"def",
"write_proc_sh",
"(",
"self",
")",
":",
"print",
"(",
"\"Writing proc.sh\"",
")",
"context",
"=",
"{",
"'tmp'",
":",
"'/tmp'",
",",
"'home'",
":",
"'/app'",
",",
"'settings'",
":",
"'/settings.yaml'",
",",
"'envsh'",
":",
"'/env.sh'",
",",
"'port'",
... | Write the script that is the first thing called inside the
container. It sets env vars and then calls the real program. | [
"Write",
"the",
"script",
"that",
"is",
"the",
"first",
"thing",
"called",
"inside",
"the",
"container",
".",
"It",
"sets",
"env",
"vars",
"and",
"then",
"calls",
"the",
"real",
"program",
"."
] | train | https://github.com/yougov/vr.runners/blob/f43ba50a64b17ee4f07596fe225bcb38ca6652ad/vr/runners/base.py#L107-L127 |
yougov/vr.runners | vr/runners/base.py | BaseRunner.get_cmd | def get_cmd(self):
"""
If self.config.cmd is not None, return that.
Otherwise, read the Procfile inside the build code, parse it
(as yaml), and pull out the command for self.config.proc_name.
"""
if self.config.cmd is not None:
return self.config.cmd
... | python | def get_cmd(self):
"""
If self.config.cmd is not None, return that.
Otherwise, read the Procfile inside the build code, parse it
(as yaml), and pull out the command for self.config.proc_name.
"""
if self.config.cmd is not None:
return self.config.cmd
... | [
"def",
"get_cmd",
"(",
"self",
")",
":",
"if",
"self",
".",
"config",
".",
"cmd",
"is",
"not",
"None",
":",
"return",
"self",
".",
"config",
".",
"cmd",
"procfile_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"get_app_path",
"(",
"self",
".",
"c... | If self.config.cmd is not None, return that.
Otherwise, read the Procfile inside the build code, parse it
(as yaml), and pull out the command for self.config.proc_name. | [
"If",
"self",
".",
"config",
".",
"cmd",
"is",
"not",
"None",
"return",
"that",
"."
] | train | https://github.com/yougov/vr.runners/blob/f43ba50a64b17ee4f07596fe225bcb38ca6652ad/vr/runners/base.py#L147-L160 |
yougov/vr.runners | vr/runners/base.py | BaseRunner.ensure_container | def ensure_container(self, name=None):
"""Make sure container exists. It's only needed on newer
versions of LXC."""
if get_lxc_version() < pkg_resources.parse_version('2.0.0'):
# Nothing to do for old versions of LXC
return
if name is None:
name = sel... | python | def ensure_container(self, name=None):
"""Make sure container exists. It's only needed on newer
versions of LXC."""
if get_lxc_version() < pkg_resources.parse_version('2.0.0'):
# Nothing to do for old versions of LXC
return
if name is None:
name = sel... | [
"def",
"ensure_container",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"get_lxc_version",
"(",
")",
"<",
"pkg_resources",
".",
"parse_version",
"(",
"'2.0.0'",
")",
":",
"# Nothing to do for old versions of LXC",
"return",
"if",
"name",
"is",
"None",
... | Make sure container exists. It's only needed on newer
versions of LXC. | [
"Make",
"sure",
"container",
"exists",
".",
"It",
"s",
"only",
"needed",
"on",
"newer",
"versions",
"of",
"LXC",
"."
] | train | https://github.com/yougov/vr.runners/blob/f43ba50a64b17ee4f07596fe225bcb38ca6652ad/vr/runners/base.py#L162-L178 |
yougov/vr.runners | vr/runners/base.py | BaseRunner.ensure_build | def ensure_build(self):
"""
If self.config.build_url is set, ensure it's been downloaded to the
builds folder.
"""
if self.config.build_url:
path = get_buildfile_path(self.config)
# Ensure that builds_root has been created.
mkdir(BUILDS_ROOT)
... | python | def ensure_build(self):
"""
If self.config.build_url is set, ensure it's been downloaded to the
builds folder.
"""
if self.config.build_url:
path = get_buildfile_path(self.config)
# Ensure that builds_root has been created.
mkdir(BUILDS_ROOT)
... | [
"def",
"ensure_build",
"(",
"self",
")",
":",
"if",
"self",
".",
"config",
".",
"build_url",
":",
"path",
"=",
"get_buildfile_path",
"(",
"self",
".",
"config",
")",
"# Ensure that builds_root has been created.",
"mkdir",
"(",
"BUILDS_ROOT",
")",
"build_md5",
"=... | If self.config.build_url is set, ensure it's been downloaded to the
builds folder. | [
"If",
"self",
".",
"config",
".",
"build_url",
"is",
"set",
"ensure",
"it",
"s",
"been",
"downloaded",
"to",
"the",
"builds",
"folder",
"."
] | train | https://github.com/yougov/vr.runners/blob/f43ba50a64b17ee4f07596fe225bcb38ca6652ad/vr/runners/base.py#L180-L194 |
yougov/vr.runners | vr/runners/base.py | BaseRunner.teardown | def teardown(self):
"""
Delete the proc path where everything has been put.
The build will be cleaned up elsewhere.
"""
proc_path = get_proc_path(self.config)
if os.path.isdir(proc_path):
shutil.rmtree(proc_path) | python | def teardown(self):
"""
Delete the proc path where everything has been put.
The build will be cleaned up elsewhere.
"""
proc_path = get_proc_path(self.config)
if os.path.isdir(proc_path):
shutil.rmtree(proc_path) | [
"def",
"teardown",
"(",
"self",
")",
":",
"proc_path",
"=",
"get_proc_path",
"(",
"self",
".",
"config",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"proc_path",
")",
":",
"shutil",
".",
"rmtree",
"(",
"proc_path",
")"
] | Delete the proc path where everything has been put.
The build will be cleaned up elsewhere. | [
"Delete",
"the",
"proc",
"path",
"where",
"everything",
"has",
"been",
"put",
".",
"The",
"build",
"will",
"be",
"cleaned",
"up",
"elsewhere",
"."
] | train | https://github.com/yougov/vr.runners/blob/f43ba50a64b17ee4f07596fe225bcb38ca6652ad/vr/runners/base.py#L305-L312 |
miquelo/resort | packages/resort/engine/execution.py | Context.resolve | def resolve(self, value):
"""
Resolve contextual value.
:param value:
Contextual value.
:return:
If value is a function with a single parameter, which is a read-only
dictionary, the return value of the function called with context
properties as its parameter. If not, the value itself.
"... | python | def resolve(self, value):
"""
Resolve contextual value.
:param value:
Contextual value.
:return:
If value is a function with a single parameter, which is a read-only
dictionary, the return value of the function called with context
properties as its parameter. If not, the value itself.
"... | [
"def",
"resolve",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"collections",
".",
"Callable",
")",
":",
"return",
"value",
"(",
"{",
"\"base_dir\"",
":",
"self",
".",
"__base_dir",
",",
"\"profile_dir\"",
":",
"self",
".",... | Resolve contextual value.
:param value:
Contextual value.
:return:
If value is a function with a single parameter, which is a read-only
dictionary, the return value of the function called with context
properties as its parameter. If not, the value itself. | [
"Resolve",
"contextual",
"value",
"."
] | train | https://github.com/miquelo/resort/blob/097a25d3257c91a75c194fd44c2797ab356f85dd/packages/resort/engine/execution.py#L43-L62 |
townsenddw/jhubctl | jhubctl/hubs/hubs.py | HubList.get_hubs | def get_hubs(self):
"""Get a list of hubs names.
Returns
-------
hubs : list
List of hub names
"""
# Use helm to get a list of hubs.
output = helm(
'list',
'-q'
)
# Check if an error occurred.
if... | python | def get_hubs(self):
"""Get a list of hubs names.
Returns
-------
hubs : list
List of hub names
"""
# Use helm to get a list of hubs.
output = helm(
'list',
'-q'
)
# Check if an error occurred.
if... | [
"def",
"get_hubs",
"(",
"self",
")",
":",
"# Use helm to get a list of hubs.",
"output",
"=",
"helm",
"(",
"'list'",
",",
"'-q'",
")",
"# Check if an error occurred.",
"if",
"output",
".",
"returncode",
"!=",
"0",
":",
"print",
"(",
"\"Something went wrong!\"",
")... | Get a list of hubs names.
Returns
-------
hubs : list
List of hub names | [
"Get",
"a",
"list",
"of",
"hubs",
"names",
".",
"Returns",
"-------",
"hubs",
":",
"list",
"List",
"of",
"hub",
"names"
] | train | https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/hubs/hubs.py#L22-L41 |
townsenddw/jhubctl | jhubctl/hubs/hubs.py | HubList.get | def get(self, name=None):
"""Print a list of all jupyterHubs."""
# Print a list of hubs.
if name is None:
hubs = self.get_hubs()
print("Running Jupyterhub Deployments (by name):")
for hub_name in hubs:
hub = Hub(namespace=hub_name)
... | python | def get(self, name=None):
"""Print a list of all jupyterHubs."""
# Print a list of hubs.
if name is None:
hubs = self.get_hubs()
print("Running Jupyterhub Deployments (by name):")
for hub_name in hubs:
hub = Hub(namespace=hub_name)
... | [
"def",
"get",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"# Print a list of hubs.",
"if",
"name",
"is",
"None",
":",
"hubs",
"=",
"self",
".",
"get_hubs",
"(",
")",
"print",
"(",
"\"Running Jupyterhub Deployments (by name):\"",
")",
"for",
"hub_name",
... | Print a list of all jupyterHubs. | [
"Print",
"a",
"list",
"of",
"all",
"jupyterHubs",
"."
] | train | https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/hubs/hubs.py#L43-L57 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/runner/action_plugins/copy.py | ActionModule.run | def run(self, conn, tmp, module_name, module_args, inject):
''' handler for file transfer operations '''
# load up options
options = utils.parse_kv(module_args)
source = options.get('src', None)
dest = options.get('dest', None)
if dest.endswith("/"):
bas... | python | def run(self, conn, tmp, module_name, module_args, inject):
''' handler for file transfer operations '''
# load up options
options = utils.parse_kv(module_args)
source = options.get('src', None)
dest = options.get('dest', None)
if dest.endswith("/"):
bas... | [
"def",
"run",
"(",
"self",
",",
"conn",
",",
"tmp",
",",
"module_name",
",",
"module_args",
",",
"inject",
")",
":",
"# load up options",
"options",
"=",
"utils",
".",
"parse_kv",
"(",
"module_args",
")",
"source",
"=",
"options",
".",
"get",
"(",
"'src'... | handler for file transfer operations | [
"handler",
"for",
"file",
"transfer",
"operations"
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/action_plugins/copy.py#L29-L89 |
pjuren/pyokit | src/pyokit/scripts/regionCollapse.py | main | def main(args, prog_name):
"""
main entry point for the script.
:param args: the arguments for this script, as a list of string. Should
already have had things like the script name stripped. That
is, if there are no args provided, this should be an empty
list.
"""
... | python | def main(args, prog_name):
"""
main entry point for the script.
:param args: the arguments for this script, as a list of string. Should
already have had things like the script name stripped. That
is, if there are no args provided, this should be an empty
list.
"""
... | [
"def",
"main",
"(",
"args",
",",
"prog_name",
")",
":",
"# get options and arguments",
"ui",
"=",
"getUI",
"(",
"args",
",",
"prog_name",
")",
"if",
"ui",
".",
"optionIsSet",
"(",
"\"test\"",
")",
":",
"# just run unit tests",
"unittest",
".",
"main",
"(",
... | main entry point for the script.
:param args: the arguments for this script, as a list of string. Should
already have had things like the script name stripped. That
is, if there are no args provided, this should be an empty
list. | [
"main",
"entry",
"point",
"for",
"the",
"script",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/scripts/regionCollapse.py#L101-L147 |
arindampradhan/cheesy | cheesy/ch.py | _pull_all | def _pull_all(command):
"""Website scraper for the info from table content"""
page = requests.get(BASE_URL,verify=False)
soup = BeautifulSoup(page.text,"lxml")
table = soup.find('table',{'class':'list'})
rows = table.findAll("tr")
rows = rows[1:-1]
l = []
name_max = 0
for row in rows:
elements = row.findAll... | python | def _pull_all(command):
"""Website scraper for the info from table content"""
page = requests.get(BASE_URL,verify=False)
soup = BeautifulSoup(page.text,"lxml")
table = soup.find('table',{'class':'list'})
rows = table.findAll("tr")
rows = rows[1:-1]
l = []
name_max = 0
for row in rows:
elements = row.findAll... | [
"def",
"_pull_all",
"(",
"command",
")",
":",
"page",
"=",
"requests",
".",
"get",
"(",
"BASE_URL",
",",
"verify",
"=",
"False",
")",
"soup",
"=",
"BeautifulSoup",
"(",
"page",
".",
"text",
",",
"\"lxml\"",
")",
"table",
"=",
"soup",
".",
"find",
"("... | Website scraper for the info from table content | [
"Website",
"scraper",
"for",
"the",
"info",
"from",
"table",
"content"
] | train | https://github.com/arindampradhan/cheesy/blob/a7dbc90bba551a562644b1563c595d4ac38f15ed/cheesy/ch.py#L43-L78 |
arindampradhan/cheesy | cheesy/ch.py | _release_info | def _release_info(jsn,VERSION):
"""Gives information about a particular package version."""
try:
release_point = jsn['releases'][VERSION][0]
except KeyError:
print "\033[91m\033[1mError: Release not found."
exit(1)
python_version = release_point['python_version']
filename = release_point['filename']
md5 = r... | python | def _release_info(jsn,VERSION):
"""Gives information about a particular package version."""
try:
release_point = jsn['releases'][VERSION][0]
except KeyError:
print "\033[91m\033[1mError: Release not found."
exit(1)
python_version = release_point['python_version']
filename = release_point['filename']
md5 = r... | [
"def",
"_release_info",
"(",
"jsn",
",",
"VERSION",
")",
":",
"try",
":",
"release_point",
"=",
"jsn",
"[",
"'releases'",
"]",
"[",
"VERSION",
"]",
"[",
"0",
"]",
"except",
"KeyError",
":",
"print",
"\"\\033[91m\\033[1mError: Release not found.\"",
"exit",
"("... | Gives information about a particular package version. | [
"Gives",
"information",
"about",
"a",
"particular",
"package",
"version",
"."
] | train | https://github.com/arindampradhan/cheesy/blob/a7dbc90bba551a562644b1563c595d4ac38f15ed/cheesy/ch.py#L97-L120 |
arindampradhan/cheesy | cheesy/ch.py | _construct | def _construct(PACKAGE,VERSION):
"""Construct the information part from the API."""
jsn = _get_info(PACKAGE)
package_url = jsn['info']['package_url']
author = jsn['info']['author']
author_email = jsn['info']['author_email']
description = jsn['info']['description']
last_month = jsn['info']['downloads']['last_mo... | python | def _construct(PACKAGE,VERSION):
"""Construct the information part from the API."""
jsn = _get_info(PACKAGE)
package_url = jsn['info']['package_url']
author = jsn['info']['author']
author_email = jsn['info']['author_email']
description = jsn['info']['description']
last_month = jsn['info']['downloads']['last_mo... | [
"def",
"_construct",
"(",
"PACKAGE",
",",
"VERSION",
")",
":",
"jsn",
"=",
"_get_info",
"(",
"PACKAGE",
")",
"package_url",
"=",
"jsn",
"[",
"'info'",
"]",
"[",
"'package_url'",
"]",
"author",
"=",
"jsn",
"[",
"'info'",
"]",
"[",
"'author'",
"]",
"auth... | Construct the information part from the API. | [
"Construct",
"the",
"information",
"part",
"from",
"the",
"API",
"."
] | train | https://github.com/arindampradhan/cheesy/blob/a7dbc90bba551a562644b1563c595d4ac38f15ed/cheesy/ch.py#L122-L167 |
arindampradhan/cheesy | cheesy/ch.py | main | def main():
'''cheesy gives you the news for today's cheese pipy factory from command line'''
arguments = docopt(__doc__, version=__version__)
if arguments['ls']:
_pull_all('ls')
elif arguments['list']:
_pull_all('list')
elif arguments['<PACKAGE>']:
try:
if arguments['<VERSION>'... | python | def main():
'''cheesy gives you the news for today's cheese pipy factory from command line'''
arguments = docopt(__doc__, version=__version__)
if arguments['ls']:
_pull_all('ls')
elif arguments['list']:
_pull_all('list')
elif arguments['<PACKAGE>']:
try:
if arguments['<VERSION>'... | [
"def",
"main",
"(",
")",
":",
"arguments",
"=",
"docopt",
"(",
"__doc__",
",",
"version",
"=",
"__version__",
")",
"if",
"arguments",
"[",
"'ls'",
"]",
":",
"_pull_all",
"(",
"'ls'",
")",
"elif",
"arguments",
"[",
"'list'",
"]",
":",
"_pull_all",
"(",
... | cheesy gives you the news for today's cheese pipy factory from command line | [
"cheesy",
"gives",
"you",
"the",
"news",
"for",
"today",
"s",
"cheese",
"pipy",
"factory",
"from",
"command",
"line"
] | train | https://github.com/arindampradhan/cheesy/blob/a7dbc90bba551a562644b1563c595d4ac38f15ed/cheesy/ch.py#L170-L186 |
fstab50/metal | metal/chk_standalone.py | compile_binary | def compile_binary(source):
"""
Prepare chkrootkit binary
$ tar xzvf chkrootkit.tar.gz
$ cd chkrootkit-0.52
$ make sense
sudo mv chkrootkit-0.52 /usr/local/chkrootkit
sudo ln -s
"""
cmd = 'make sense'
src = '/usr/local/bin/chkrootkit'
dst = '/usr/local/chkrootkit/chkrootkit'
... | python | def compile_binary(source):
"""
Prepare chkrootkit binary
$ tar xzvf chkrootkit.tar.gz
$ cd chkrootkit-0.52
$ make sense
sudo mv chkrootkit-0.52 /usr/local/chkrootkit
sudo ln -s
"""
cmd = 'make sense'
src = '/usr/local/bin/chkrootkit'
dst = '/usr/local/chkrootkit/chkrootkit'
... | [
"def",
"compile_binary",
"(",
"source",
")",
":",
"cmd",
"=",
"'make sense'",
"src",
"=",
"'/usr/local/bin/chkrootkit'",
"dst",
"=",
"'/usr/local/chkrootkit/chkrootkit'",
"# Tar Extraction",
"t",
"=",
"tarfile",
".",
"open",
"(",
"source",
",",
"'r'",
")",
"t",
... | Prepare chkrootkit binary
$ tar xzvf chkrootkit.tar.gz
$ cd chkrootkit-0.52
$ make sense
sudo mv chkrootkit-0.52 /usr/local/chkrootkit
sudo ln -s | [
"Prepare",
"chkrootkit",
"binary",
"$",
"tar",
"xzvf",
"chkrootkit",
".",
"tar",
".",
"gz",
"$",
"cd",
"chkrootkit",
"-",
"0",
".",
"52",
"$",
"make",
"sense",
"sudo",
"mv",
"chkrootkit",
"-",
"0",
".",
"52",
"/",
"usr",
"/",
"local",
"/",
"chkrootki... | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/chk_standalone.py#L45-L70 |
fstab50/metal | metal/chk_standalone.py | os_packages | def os_packages(metadata):
""" Installs operating system dependent packages """
family = metadata[0]
release = metadata[1]
#
if 'Amazon' in family and '2' not in release:
stdout_message('Identified Amazon Linux 1 os distro')
commands = [
'sudo yum -y update', 'sudo yum -y... | python | def os_packages(metadata):
""" Installs operating system dependent packages """
family = metadata[0]
release = metadata[1]
#
if 'Amazon' in family and '2' not in release:
stdout_message('Identified Amazon Linux 1 os distro')
commands = [
'sudo yum -y update', 'sudo yum -y... | [
"def",
"os_packages",
"(",
"metadata",
")",
":",
"family",
"=",
"metadata",
"[",
"0",
"]",
"release",
"=",
"metadata",
"[",
"1",
"]",
"#",
"if",
"'Amazon'",
"in",
"family",
"and",
"'2'",
"not",
"in",
"release",
":",
"stdout_message",
"(",
"'Identified Am... | Installs operating system dependent packages | [
"Installs",
"operating",
"system",
"dependent",
"packages"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/chk_standalone.py#L166-L203 |
fstab50/metal | metal/chk_standalone.py | stdout_message | def stdout_message(message, prefix='INFO', quiet=False,
multiline=False, tabspaces=4, severity=''):
""" Prints message to cli stdout while indicating type and severity
Args:
:message (str): text characters to be printed to stdout
:prefix (str): 4-letter stri... | python | def stdout_message(message, prefix='INFO', quiet=False,
multiline=False, tabspaces=4, severity=''):
""" Prints message to cli stdout while indicating type and severity
Args:
:message (str): text characters to be printed to stdout
:prefix (str): 4-letter stri... | [
"def",
"stdout_message",
"(",
"message",
",",
"prefix",
"=",
"'INFO'",
",",
"quiet",
"=",
"False",
",",
"multiline",
"=",
"False",
",",
"tabspaces",
"=",
"4",
",",
"severity",
"=",
"''",
")",
":",
"prefix",
"=",
"prefix",
".",
"upper",
"(",
")",
"tab... | Prints message to cli stdout while indicating type and severity
Args:
:message (str): text characters to be printed to stdout
:prefix (str): 4-letter string message type identifier.
:quiet (bool): Flag to suppress all output
:multiline (bool): indicates multiline message; removes ... | [
"Prints",
"message",
"to",
"cli",
"stdout",
"while",
"indicating",
"type",
"and",
"severity"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/chk_standalone.py#L206-L253 |
fstab50/metal | metal/chk_standalone.py | main | def main():
"""
Check Dependencies, download files, integrity check
"""
# vars
tar_file = TMPDIR + '/' + BINARY_URL.split('/')[-1]
chksum = TMPDIR + '/' + MD5_URL.split('/')[-1]
# pre-run validation + execution
if precheck() and os_packages(distro.linux_distribution()):
stdout_me... | python | def main():
"""
Check Dependencies, download files, integrity check
"""
# vars
tar_file = TMPDIR + '/' + BINARY_URL.split('/')[-1]
chksum = TMPDIR + '/' + MD5_URL.split('/')[-1]
# pre-run validation + execution
if precheck() and os_packages(distro.linux_distribution()):
stdout_me... | [
"def",
"main",
"(",
")",
":",
"# vars",
"tar_file",
"=",
"TMPDIR",
"+",
"'/'",
"+",
"BINARY_URL",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"chksum",
"=",
"TMPDIR",
"+",
"'/'",
"+",
"MD5_URL",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"... | Check Dependencies, download files, integrity check | [
"Check",
"Dependencies",
"download",
"files",
"integrity",
"check"
] | train | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/chk_standalone.py#L256-L271 |
naphatkrit/easyci | easyci/commands/gc.py | gc | def gc(ctx):
"""Runs housekeeping tasks to free up space.
For now, this only removes saved but unused (unreachable) test results.
"""
vcs = ctx.obj['vcs']
count = 0
with locking.lock(vcs, locking.Lock.tests_history):
known_signatures = set(get_committed_signatures(vcs) + get_staged_sign... | python | def gc(ctx):
"""Runs housekeeping tasks to free up space.
For now, this only removes saved but unused (unreachable) test results.
"""
vcs = ctx.obj['vcs']
count = 0
with locking.lock(vcs, locking.Lock.tests_history):
known_signatures = set(get_committed_signatures(vcs) + get_staged_sign... | [
"def",
"gc",
"(",
"ctx",
")",
":",
"vcs",
"=",
"ctx",
".",
"obj",
"[",
"'vcs'",
"]",
"count",
"=",
"0",
"with",
"locking",
".",
"lock",
"(",
"vcs",
",",
"locking",
".",
"Lock",
".",
"tests_history",
")",
":",
"known_signatures",
"=",
"set",
"(",
... | Runs housekeeping tasks to free up space.
For now, this only removes saved but unused (unreachable) test results. | [
"Runs",
"housekeeping",
"tasks",
"to",
"free",
"up",
"space",
"."
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/commands/gc.py#L12-L25 |
Tinche/django-bower-cache | registry/tasks.py | clone_repo | def clone_repo(pkg_name, repo_url):
"""Create a new cloned repo with the given parameters."""
new_repo = ClonedRepo(name=pkg_name, origin=repo_url)
new_repo.save()
return new_repo | python | def clone_repo(pkg_name, repo_url):
"""Create a new cloned repo with the given parameters."""
new_repo = ClonedRepo(name=pkg_name, origin=repo_url)
new_repo.save()
return new_repo | [
"def",
"clone_repo",
"(",
"pkg_name",
",",
"repo_url",
")",
":",
"new_repo",
"=",
"ClonedRepo",
"(",
"name",
"=",
"pkg_name",
",",
"origin",
"=",
"repo_url",
")",
"new_repo",
".",
"save",
"(",
")",
"return",
"new_repo"
] | Create a new cloned repo with the given parameters. | [
"Create",
"a",
"new",
"cloned",
"repo",
"with",
"the",
"given",
"parameters",
"."
] | train | https://github.com/Tinche/django-bower-cache/blob/5245b2ee80c33c09d85ce0bf8f047825d9df2118/registry/tasks.py#L10-L14 |
Tinche/django-bower-cache | registry/tasks.py | pull_repo | def pull_repo(repo_name):
"""Pull from origin for repo_name."""
repo = ClonedRepo.objects.get(pk=repo_name)
repo.pull() | python | def pull_repo(repo_name):
"""Pull from origin for repo_name."""
repo = ClonedRepo.objects.get(pk=repo_name)
repo.pull() | [
"def",
"pull_repo",
"(",
"repo_name",
")",
":",
"repo",
"=",
"ClonedRepo",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"repo_name",
")",
"repo",
".",
"pull",
"(",
")"
] | Pull from origin for repo_name. | [
"Pull",
"from",
"origin",
"for",
"repo_name",
"."
] | train | https://github.com/Tinche/django-bower-cache/blob/5245b2ee80c33c09d85ce0bf8f047825d9df2118/registry/tasks.py#L18-L21 |
Tinche/django-bower-cache | registry/tasks.py | pull_all_repos | def pull_all_repos():
"""Pull origin updates for all repos with origins."""
repos = ClonedRepo.objects.all()
for repo in repos:
if repo.origin is not None:
pull_repo.delay(repo_name=repo.name) | python | def pull_all_repos():
"""Pull origin updates for all repos with origins."""
repos = ClonedRepo.objects.all()
for repo in repos:
if repo.origin is not None:
pull_repo.delay(repo_name=repo.name) | [
"def",
"pull_all_repos",
"(",
")",
":",
"repos",
"=",
"ClonedRepo",
".",
"objects",
".",
"all",
"(",
")",
"for",
"repo",
"in",
"repos",
":",
"if",
"repo",
".",
"origin",
"is",
"not",
"None",
":",
"pull_repo",
".",
"delay",
"(",
"repo_name",
"=",
"rep... | Pull origin updates for all repos with origins. | [
"Pull",
"origin",
"updates",
"for",
"all",
"repos",
"with",
"origins",
"."
] | train | https://github.com/Tinche/django-bower-cache/blob/5245b2ee80c33c09d85ce0bf8f047825d9df2118/registry/tasks.py#L25-L30 |
Othernet-Project/hwd | hwd/network.py | NetIface._get_ipv4_addrs | def _get_ipv4_addrs(self):
"""
Returns the IPv4 addresses associated with this NIC. If no IPv4
addresses are used, then empty dictionary is returned.
"""
addrs = self._get_addrs()
ipv4addrs = addrs.get(netifaces.AF_INET)
if not ipv4addrs:
return {}
... | python | def _get_ipv4_addrs(self):
"""
Returns the IPv4 addresses associated with this NIC. If no IPv4
addresses are used, then empty dictionary is returned.
"""
addrs = self._get_addrs()
ipv4addrs = addrs.get(netifaces.AF_INET)
if not ipv4addrs:
return {}
... | [
"def",
"_get_ipv4_addrs",
"(",
"self",
")",
":",
"addrs",
"=",
"self",
".",
"_get_addrs",
"(",
")",
"ipv4addrs",
"=",
"addrs",
".",
"get",
"(",
"netifaces",
".",
"AF_INET",
")",
"if",
"not",
"ipv4addrs",
":",
"return",
"{",
"}",
"return",
"ipv4addrs",
... | Returns the IPv4 addresses associated with this NIC. If no IPv4
addresses are used, then empty dictionary is returned. | [
"Returns",
"the",
"IPv4",
"addresses",
"associated",
"with",
"this",
"NIC",
".",
"If",
"no",
"IPv4",
"addresses",
"are",
"used",
"then",
"empty",
"dictionary",
"is",
"returned",
"."
] | train | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/network.py#L47-L56 |
Othernet-Project/hwd | hwd/network.py | NetIface._get_ipv6addrs | def _get_ipv6addrs(self):
"""
Returns the IPv6 addresses associated with this NIC. If no IPv6
addresses are used, empty dict is returned.
"""
addrs = self._get_addrs()
ipv6addrs = addrs.get(netifaces.AF_INET6)
if not ipv6addrs:
return {}
return... | python | def _get_ipv6addrs(self):
"""
Returns the IPv6 addresses associated with this NIC. If no IPv6
addresses are used, empty dict is returned.
"""
addrs = self._get_addrs()
ipv6addrs = addrs.get(netifaces.AF_INET6)
if not ipv6addrs:
return {}
return... | [
"def",
"_get_ipv6addrs",
"(",
"self",
")",
":",
"addrs",
"=",
"self",
".",
"_get_addrs",
"(",
")",
"ipv6addrs",
"=",
"addrs",
".",
"get",
"(",
"netifaces",
".",
"AF_INET6",
")",
"if",
"not",
"ipv6addrs",
":",
"return",
"{",
"}",
"return",
"ipv6addrs",
... | Returns the IPv6 addresses associated with this NIC. If no IPv6
addresses are used, empty dict is returned. | [
"Returns",
"the",
"IPv6",
"addresses",
"associated",
"with",
"this",
"NIC",
".",
"If",
"no",
"IPv6",
"addresses",
"are",
"used",
"empty",
"dict",
"is",
"returned",
"."
] | train | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/network.py#L58-L67 |
Othernet-Project/hwd | hwd/network.py | NetIface._get_default_gateway | def _get_default_gateway(self, ip=4):
"""
Returns the default gateway for given IP version. The ``ip`` argument
is used to specify the IP version, and can be either 4 or 6.
"""
net_type = netifaces.AF_INET if ip == 4 else netifaces.AF_INET6
gw = netifaces.gateways()['defa... | python | def _get_default_gateway(self, ip=4):
"""
Returns the default gateway for given IP version. The ``ip`` argument
is used to specify the IP version, and can be either 4 or 6.
"""
net_type = netifaces.AF_INET if ip == 4 else netifaces.AF_INET6
gw = netifaces.gateways()['defa... | [
"def",
"_get_default_gateway",
"(",
"self",
",",
"ip",
"=",
"4",
")",
":",
"net_type",
"=",
"netifaces",
".",
"AF_INET",
"if",
"ip",
"==",
"4",
"else",
"netifaces",
".",
"AF_INET6",
"gw",
"=",
"netifaces",
".",
"gateways",
"(",
")",
"[",
"'default'",
"... | Returns the default gateway for given IP version. The ``ip`` argument
is used to specify the IP version, and can be either 4 or 6. | [
"Returns",
"the",
"default",
"gateway",
"for",
"given",
"IP",
"version",
".",
"The",
"ip",
"argument",
"is",
"used",
"to",
"specify",
"the",
"IP",
"version",
"and",
"can",
"be",
"either",
"4",
"or",
"6",
"."
] | train | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/network.py#L69-L77 |
ArabellaTech/ydcommon | ydcommon/fab.py | switch | def switch(stage):
"""
Switch to given stage (dev/qa/production) + pull
"""
stage = stage.lower()
local("git pull")
if stage in ['dev', 'devel', 'develop']:
branch_name = 'develop'
elif stage in ['qa', 'release']:
branches = local('git branch -r', capture=True)
po... | python | def switch(stage):
"""
Switch to given stage (dev/qa/production) + pull
"""
stage = stage.lower()
local("git pull")
if stage in ['dev', 'devel', 'develop']:
branch_name = 'develop'
elif stage in ['qa', 'release']:
branches = local('git branch -r', capture=True)
po... | [
"def",
"switch",
"(",
"stage",
")",
":",
"stage",
"=",
"stage",
".",
"lower",
"(",
")",
"local",
"(",
"\"git pull\"",
")",
"if",
"stage",
"in",
"[",
"'dev'",
",",
"'devel'",
",",
"'develop'",
"]",
":",
"branch_name",
"=",
"'develop'",
"elif",
"stage",
... | Switch to given stage (dev/qa/production) + pull | [
"Switch",
"to",
"given",
"stage",
"(",
"dev",
"/",
"qa",
"/",
"production",
")",
"+",
"pull"
] | train | https://github.com/ArabellaTech/ydcommon/blob/4aa105e7b33f379e8f09111497c0e427b189c36c/ydcommon/fab.py#L36-L60 |
ArabellaTech/ydcommon | ydcommon/fab.py | release_qa | def release_qa(quietly=False):
"""
Release code to QA server
"""
name = prompt(red('Sprint name?'), default='Sprint 1').lower().replace(' ', "_")
release_date = prompt(red('Sprint start date (Y-m-d)?'), default='2013-01-20').replace('-', '')
release_name = '%s_%s' % (release_date, name)
... | python | def release_qa(quietly=False):
"""
Release code to QA server
"""
name = prompt(red('Sprint name?'), default='Sprint 1').lower().replace(' ', "_")
release_date = prompt(red('Sprint start date (Y-m-d)?'), default='2013-01-20').replace('-', '')
release_name = '%s_%s' % (release_date, name)
... | [
"def",
"release_qa",
"(",
"quietly",
"=",
"False",
")",
":",
"name",
"=",
"prompt",
"(",
"red",
"(",
"'Sprint name?'",
")",
",",
"default",
"=",
"'Sprint 1'",
")",
".",
"lower",
"(",
")",
".",
"replace",
"(",
"' '",
",",
"\"_\"",
")",
"release_date",
... | Release code to QA server | [
"Release",
"code",
"to",
"QA",
"server"
] | train | https://github.com/ArabellaTech/ydcommon/blob/4aa105e7b33f379e8f09111497c0e427b189c36c/ydcommon/fab.py#L63-L73 |
ArabellaTech/ydcommon | ydcommon/fab.py | update_qa | def update_qa(quietly=False):
"""
Merge code from develop to qa
"""
switch('dev')
switch('qa')
local('git merge --no-edit develop')
local('git push')
if not quietly:
print(red('PLEASE DEPLOY CODE: fab deploy:all')) | python | def update_qa(quietly=False):
"""
Merge code from develop to qa
"""
switch('dev')
switch('qa')
local('git merge --no-edit develop')
local('git push')
if not quietly:
print(red('PLEASE DEPLOY CODE: fab deploy:all')) | [
"def",
"update_qa",
"(",
"quietly",
"=",
"False",
")",
":",
"switch",
"(",
"'dev'",
")",
"switch",
"(",
"'qa'",
")",
"local",
"(",
"'git merge --no-edit develop'",
")",
"local",
"(",
"'git push'",
")",
"if",
"not",
"quietly",
":",
"print",
"(",
"red",
"(... | Merge code from develop to qa | [
"Merge",
"code",
"from",
"develop",
"to",
"qa"
] | train | https://github.com/ArabellaTech/ydcommon/blob/4aa105e7b33f379e8f09111497c0e427b189c36c/ydcommon/fab.py#L76-L85 |
ArabellaTech/ydcommon | ydcommon/fab.py | backup_db | def backup_db():
"""
Backup local database
"""
if not os.path.exists('backups'):
os.makedirs('backups')
local('python manage.py dump_database | gzip > backups/' + _sql_paths('local', datetime.now())) | python | def backup_db():
"""
Backup local database
"""
if not os.path.exists('backups'):
os.makedirs('backups')
local('python manage.py dump_database | gzip > backups/' + _sql_paths('local', datetime.now())) | [
"def",
"backup_db",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"'backups'",
")",
":",
"os",
".",
"makedirs",
"(",
"'backups'",
")",
"local",
"(",
"'python manage.py dump_database | gzip > backups/'",
"+",
"_sql_paths",
"(",
"'local'",
... | Backup local database | [
"Backup",
"local",
"database"
] | train | https://github.com/ArabellaTech/ydcommon/blob/4aa105e7b33f379e8f09111497c0e427b189c36c/ydcommon/fab.py#L123-L129 |
ArabellaTech/ydcommon | ydcommon/fab.py | _get_db | def _get_db():
"""
Get database from server
"""
with cd(env.remote_path):
file_path = '/tmp/' + _sql_paths('remote', str(base64.urlsafe_b64encode(uuid.uuid4().bytes)).replace('=', ''))
run(env.python + ' manage.py dump_database | gzip > ' + file_path)
local_file_path = './bac... | python | def _get_db():
"""
Get database from server
"""
with cd(env.remote_path):
file_path = '/tmp/' + _sql_paths('remote', str(base64.urlsafe_b64encode(uuid.uuid4().bytes)).replace('=', ''))
run(env.python + ' manage.py dump_database | gzip > ' + file_path)
local_file_path = './bac... | [
"def",
"_get_db",
"(",
")",
":",
"with",
"cd",
"(",
"env",
".",
"remote_path",
")",
":",
"file_path",
"=",
"'/tmp/'",
"+",
"_sql_paths",
"(",
"'remote'",
",",
"str",
"(",
"base64",
".",
"urlsafe_b64encode",
"(",
"uuid",
".",
"uuid4",
"(",
")",
".",
"... | Get database from server | [
"Get",
"database",
"from",
"server"
] | train | https://github.com/ArabellaTech/ydcommon/blob/4aa105e7b33f379e8f09111497c0e427b189c36c/ydcommon/fab.py#L132-L142 |
ArabellaTech/ydcommon | ydcommon/fab.py | command | def command(command):
"""
Run custom Django management command
"""
with cd(env.remote_path):
sudo(env.python + ' manage.py %s' % command, user=env.remote_user) | python | def command(command):
"""
Run custom Django management command
"""
with cd(env.remote_path):
sudo(env.python + ' manage.py %s' % command, user=env.remote_user) | [
"def",
"command",
"(",
"command",
")",
":",
"with",
"cd",
"(",
"env",
".",
"remote_path",
")",
":",
"sudo",
"(",
"env",
".",
"python",
"+",
"' manage.py %s'",
"%",
"command",
",",
"user",
"=",
"env",
".",
"remote_user",
")"
] | Run custom Django management command | [
"Run",
"custom",
"Django",
"management",
"command"
] | train | https://github.com/ArabellaTech/ydcommon/blob/4aa105e7b33f379e8f09111497c0e427b189c36c/ydcommon/fab.py#L173-L178 |
ArabellaTech/ydcommon | ydcommon/fab.py | setup_server | def setup_server(clear_old=False, repo="github", python="/usr/bin/python3.6"):
"""
Setup server
"""
if repo == 'github':
url_keys = 'https://github.com/ArabellaTech/%s/settings/keys' % env.repo_name
url_clone = 'git@github.com:ArabellaTech/%s.git' % env.repo_name
elif repo == 'b... | python | def setup_server(clear_old=False, repo="github", python="/usr/bin/python3.6"):
"""
Setup server
"""
if repo == 'github':
url_keys = 'https://github.com/ArabellaTech/%s/settings/keys' % env.repo_name
url_clone = 'git@github.com:ArabellaTech/%s.git' % env.repo_name
elif repo == 'b... | [
"def",
"setup_server",
"(",
"clear_old",
"=",
"False",
",",
"repo",
"=",
"\"github\"",
",",
"python",
"=",
"\"/usr/bin/python3.6\"",
")",
":",
"if",
"repo",
"==",
"'github'",
":",
"url_keys",
"=",
"'https://github.com/ArabellaTech/%s/settings/keys'",
"%",
"env",
"... | Setup server | [
"Setup",
"server"
] | train | https://github.com/ArabellaTech/ydcommon/blob/4aa105e7b33f379e8f09111497c0e427b189c36c/ydcommon/fab.py#L188-L252 |
ArabellaTech/ydcommon | ydcommon/fab.py | copy_db | def copy_db(source_env, destination_env):
"""
Copies Db betweem servers, ie develop to qa.
Should be called by function from function defined in project fabfile.
Example usage:
def copy_db_between_servers(source_server, destination_server):
source_env = {}
d... | python | def copy_db(source_env, destination_env):
"""
Copies Db betweem servers, ie develop to qa.
Should be called by function from function defined in project fabfile.
Example usage:
def copy_db_between_servers(source_server, destination_server):
source_env = {}
d... | [
"def",
"copy_db",
"(",
"source_env",
",",
"destination_env",
")",
":",
"env",
".",
"update",
"(",
"source_env",
")",
"local_file_path",
"=",
"_get_db",
"(",
")",
"# put the file on external file system",
"# clean external db",
"# load database into external file system",
... | Copies Db betweem servers, ie develop to qa.
Should be called by function from function defined in project fabfile.
Example usage:
def copy_db_between_servers(source_server, destination_server):
source_env = {}
destination_env = {}
def populate_env_dict(ser... | [
"Copies",
"Db",
"betweem",
"servers",
"ie",
"develop",
"to",
"qa",
".",
"Should",
"be",
"called",
"by",
"function",
"from",
"function",
"defined",
"in",
"project",
"fabfile",
".",
"Example",
"usage",
":"
] | train | https://github.com/ArabellaTech/ydcommon/blob/4aa105e7b33f379e8f09111497c0e427b189c36c/ydcommon/fab.py#L255-L321 |
ArabellaTech/ydcommon | ydcommon/fab.py | copy_s3_bucket | def copy_s3_bucket(src_bucket_name, src_bucket_secret_key, src_bucket_access_key,
dst_bucket_name, dst_bucket_secret_key, dst_bucket_access_key):
""" Copy S3 bucket directory with CMS data between environments. Operations are done on server. """
with cd(env.remote_path):
tmp_dir = "s3... | python | def copy_s3_bucket(src_bucket_name, src_bucket_secret_key, src_bucket_access_key,
dst_bucket_name, dst_bucket_secret_key, dst_bucket_access_key):
""" Copy S3 bucket directory with CMS data between environments. Operations are done on server. """
with cd(env.remote_path):
tmp_dir = "s3... | [
"def",
"copy_s3_bucket",
"(",
"src_bucket_name",
",",
"src_bucket_secret_key",
",",
"src_bucket_access_key",
",",
"dst_bucket_name",
",",
"dst_bucket_secret_key",
",",
"dst_bucket_access_key",
")",
":",
"with",
"cd",
"(",
"env",
".",
"remote_path",
")",
":",
"tmp_dir"... | Copy S3 bucket directory with CMS data between environments. Operations are done on server. | [
"Copy",
"S3",
"bucket",
"directory",
"with",
"CMS",
"data",
"between",
"environments",
".",
"Operations",
"are",
"done",
"on",
"server",
"."
] | train | https://github.com/ArabellaTech/ydcommon/blob/4aa105e7b33f379e8f09111497c0e427b189c36c/ydcommon/fab.py#L324-L342 |
theonion/influxer | influxer/wsgi.py | send_point_data | def send_point_data(events, additional):
"""creates data point payloads and sends them to influxdb
"""
bodies = {}
for (site, content_id), count in events.items():
if not len(site) or not len(content_id):
continue
# influxdb will take an array of arrays of values, cutting do... | python | def send_point_data(events, additional):
"""creates data point payloads and sends them to influxdb
"""
bodies = {}
for (site, content_id), count in events.items():
if not len(site) or not len(content_id):
continue
# influxdb will take an array of arrays of values, cutting do... | [
"def",
"send_point_data",
"(",
"events",
",",
"additional",
")",
":",
"bodies",
"=",
"{",
"}",
"for",
"(",
"site",
",",
"content_id",
")",
",",
"count",
"in",
"events",
".",
"items",
"(",
")",
":",
"if",
"not",
"len",
"(",
"site",
")",
"or",
"not",... | creates data point payloads and sends them to influxdb | [
"creates",
"data",
"point",
"payloads",
"and",
"sends",
"them",
"to",
"influxdb"
] | train | https://github.com/theonion/influxer/blob/bdc6e4770d1e37c21a785881c9c50f4c767b34cc/influxer/wsgi.py#L74-L102 |
theonion/influxer | influxer/wsgi.py | send_trending_data | def send_trending_data(events):
"""creates data point payloads for trending data to influxdb
"""
bodies = {}
# sort the values
top_hits = sorted(
[(key, count) for key, count in events.items()],
key=lambda x: x[1],
reverse=True
)[:100]
# build up points to be writte... | python | def send_trending_data(events):
"""creates data point payloads for trending data to influxdb
"""
bodies = {}
# sort the values
top_hits = sorted(
[(key, count) for key, count in events.items()],
key=lambda x: x[1],
reverse=True
)[:100]
# build up points to be writte... | [
"def",
"send_trending_data",
"(",
"events",
")",
":",
"bodies",
"=",
"{",
"}",
"# sort the values",
"top_hits",
"=",
"sorted",
"(",
"[",
"(",
"key",
",",
"count",
")",
"for",
"key",
",",
"count",
"in",
"events",
".",
"items",
"(",
")",
"]",
",",
"key... | creates data point payloads for trending data to influxdb | [
"creates",
"data",
"point",
"payloads",
"for",
"trending",
"data",
"to",
"influxdb"
] | train | https://github.com/theonion/influxer/blob/bdc6e4770d1e37c21a785881c9c50f4c767b34cc/influxer/wsgi.py#L105-L138 |
theonion/influxer | influxer/wsgi.py | count_events | def count_events():
"""pulls data from the queue, tabulates it and spawns a send event
"""
# wait loop
while 1:
# sleep and let the queue build up
gevent.sleep(FLUSH_INTERVAL)
# init the data points containers
events = Counter()
additional = {}
# flush t... | python | def count_events():
"""pulls data from the queue, tabulates it and spawns a send event
"""
# wait loop
while 1:
# sleep and let the queue build up
gevent.sleep(FLUSH_INTERVAL)
# init the data points containers
events = Counter()
additional = {}
# flush t... | [
"def",
"count_events",
"(",
")",
":",
"# wait loop",
"while",
"1",
":",
"# sleep and let the queue build up",
"gevent",
".",
"sleep",
"(",
"FLUSH_INTERVAL",
")",
"# init the data points containers",
"events",
"=",
"Counter",
"(",
")",
"additional",
"=",
"{",
"}",
... | pulls data from the queue, tabulates it and spawns a send event | [
"pulls",
"data",
"from",
"the",
"queue",
"tabulates",
"it",
"and",
"spawns",
"a",
"send",
"event"
] | train | https://github.com/theonion/influxer/blob/bdc6e4770d1e37c21a785881c9c50f4c767b34cc/influxer/wsgi.py#L141-L169 |
theonion/influxer | influxer/wsgi.py | pageviews | def pageviews(params):
"""takes a couple (optional) query parameters and queries influxdb and sends a modified response
"""
# set up default values
default_from, default_to, yesterday, _ = make_default_times()
# get params
try:
series = params.get("site", [DEFAULT_SERIES])[0]
fr... | python | def pageviews(params):
"""takes a couple (optional) query parameters and queries influxdb and sends a modified response
"""
# set up default values
default_from, default_to, yesterday, _ = make_default_times()
# get params
try:
series = params.get("site", [DEFAULT_SERIES])[0]
fr... | [
"def",
"pageviews",
"(",
"params",
")",
":",
"# set up default values",
"default_from",
",",
"default_to",
",",
"yesterday",
",",
"_",
"=",
"make_default_times",
"(",
")",
"# get params",
"try",
":",
"series",
"=",
"params",
".",
"get",
"(",
"\"site\"",
",",
... | takes a couple (optional) query parameters and queries influxdb and sends a modified response | [
"takes",
"a",
"couple",
"(",
"optional",
")",
"query",
"parameters",
"and",
"queries",
"influxdb",
"and",
"sends",
"a",
"modified",
"response"
] | train | https://github.com/theonion/influxer/blob/bdc6e4770d1e37c21a785881c9c50f4c767b34cc/influxer/wsgi.py#L235-L321 |
theonion/influxer | influxer/wsgi.py | content_ids | def content_ids(params):
"""does the same this as `pageviews`, except it includes content ids and then optionally filters
the response by a list of content ids passed as query params - note, this load can be a little
heavy and could take a minute
"""
# set up default values
default_from, default... | python | def content_ids(params):
"""does the same this as `pageviews`, except it includes content ids and then optionally filters
the response by a list of content ids passed as query params - note, this load can be a little
heavy and could take a minute
"""
# set up default values
default_from, default... | [
"def",
"content_ids",
"(",
"params",
")",
":",
"# set up default values",
"default_from",
",",
"default_to",
",",
"yesterday",
",",
"_",
"=",
"make_default_times",
"(",
")",
"# get params",
"try",
":",
"series",
"=",
"params",
".",
"get",
"(",
"\"site\"",
",",... | does the same this as `pageviews`, except it includes content ids and then optionally filters
the response by a list of content ids passed as query params - note, this load can be a little
heavy and could take a minute | [
"does",
"the",
"same",
"this",
"as",
"pageviews",
"except",
"it",
"includes",
"content",
"ids",
"and",
"then",
"optionally",
"filters",
"the",
"response",
"by",
"a",
"list",
"of",
"content",
"ids",
"passed",
"as",
"query",
"params",
"-",
"note",
"this",
"l... | train | https://github.com/theonion/influxer/blob/bdc6e4770d1e37c21a785881c9c50f4c767b34cc/influxer/wsgi.py#L412-L499 |
theonion/influxer | influxer/wsgi.py | trending | def trending(params):
"""gets trending content values
"""
# get params
try:
series = params.get("site", [DEFAULT_SERIES])[0]
offset = params.get("offset", [DEFAULT_GROUP_BY])[0]
limit = params.get("limit", [20])[0]
except Exception as e:
LOGGER.exception(e)
re... | python | def trending(params):
"""gets trending content values
"""
# get params
try:
series = params.get("site", [DEFAULT_SERIES])[0]
offset = params.get("offset", [DEFAULT_GROUP_BY])[0]
limit = params.get("limit", [20])[0]
except Exception as e:
LOGGER.exception(e)
re... | [
"def",
"trending",
"(",
"params",
")",
":",
"# get params",
"try",
":",
"series",
"=",
"params",
".",
"get",
"(",
"\"site\"",
",",
"[",
"DEFAULT_SERIES",
"]",
")",
"[",
"0",
"]",
"offset",
"=",
"params",
".",
"get",
"(",
"\"offset\"",
",",
"[",
"DEFA... | gets trending content values | [
"gets",
"trending",
"content",
"values"
] | train | https://github.com/theonion/influxer/blob/bdc6e4770d1e37c21a785881c9c50f4c767b34cc/influxer/wsgi.py#L502-L569 |
theonion/influxer | influxer/wsgi.py | application | def application(env, start_response):
"""wsgi application
"""
path = env["PATH_INFO"]
if path == "/influx.gif":
# send response
start_response("200 OK", [("Content-Type", "image/gif")])
yield GIF
# parse the query params and stick them in the queue
params = parse... | python | def application(env, start_response):
"""wsgi application
"""
path = env["PATH_INFO"]
if path == "/influx.gif":
# send response
start_response("200 OK", [("Content-Type", "image/gif")])
yield GIF
# parse the query params and stick them in the queue
params = parse... | [
"def",
"application",
"(",
"env",
",",
"start_response",
")",
":",
"path",
"=",
"env",
"[",
"\"PATH_INFO\"",
"]",
"if",
"path",
"==",
"\"/influx.gif\"",
":",
"# send response",
"start_response",
"(",
"\"200 OK\"",
",",
"[",
"(",
"\"Content-Type\"",
",",
"\"ima... | wsgi application | [
"wsgi",
"application"
] | train | https://github.com/theonion/influxer/blob/bdc6e4770d1e37c21a785881c9c50f4c767b34cc/influxer/wsgi.py#L753-L811 |
KnowledgeLinks/rdfframework | rdfframework/connections/rdflibconn.py | RdflibTriplestore.create_namespace | def create_namespace(self, name, ignore_errors=False):
"""creates a namespace if it does not exist
args:
name: the name of the namespace
ignore_errors(bool): Will ignore if a namespace already exists or
there is an error creating the namespace
... | python | def create_namespace(self, name, ignore_errors=False):
"""creates a namespace if it does not exist
args:
name: the name of the namespace
ignore_errors(bool): Will ignore if a namespace already exists or
there is an error creating the namespace
... | [
"def",
"create_namespace",
"(",
"self",
",",
"name",
",",
"ignore_errors",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"has_namespace",
"(",
"name",
")",
":",
"self",
".",
"namespaces",
"[",
"name",
"]",
"=",
"ConjunctiveGraph",
"(",
")",
"return",... | creates a namespace if it does not exist
args:
name: the name of the namespace
ignore_errors(bool): Will ignore if a namespace already exists or
there is an error creating the namespace
returns:
True if created
False if not c... | [
"creates",
"a",
"namespace",
"if",
"it",
"does",
"not",
"exist",
"args",
":",
"name",
":",
"the",
"name",
"of",
"the",
"namespace",
"ignore_errors",
"(",
"bool",
")",
":",
"Will",
"ignore",
"if",
"a",
"namespace",
"already",
"exists",
"or",
"there",
"is"... | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/rdflibconn.py#L59-L78 |
KnowledgeLinks/rdfframework | rdfframework/connections/rdflibconn.py | RdflibTriplestore.delete_namespace | def delete_namespace(self, name, ignore_errors=False):
""" deletes a namespace
args:
name: the name of the namespace
ignore_errors(bool): Will ignore if a namespace doesn not exist or
there is an error deleting the namespace
returns:
... | python | def delete_namespace(self, name, ignore_errors=False):
""" deletes a namespace
args:
name: the name of the namespace
ignore_errors(bool): Will ignore if a namespace doesn not exist or
there is an error deleting the namespace
returns:
... | [
"def",
"delete_namespace",
"(",
"self",
",",
"name",
",",
"ignore_errors",
"=",
"False",
")",
":",
"if",
"self",
".",
"has_namespace",
"(",
"name",
")",
":",
"del",
"self",
".",
"namespaces",
"[",
"name",
"]",
"return",
"True",
"elif",
"ignore_errors",
"... | deletes a namespace
args:
name: the name of the namespace
ignore_errors(bool): Will ignore if a namespace doesn not exist or
there is an error deleting the namespace
returns:
True if deleted
False if not deleted
... | [
"deletes",
"a",
"namespace",
"args",
":",
"name",
":",
"the",
"name",
"of",
"the",
"namespace",
"ignore_errors",
"(",
"bool",
")",
":",
"Will",
"ignore",
"if",
"a",
"namespace",
"doesn",
"not",
"exist",
"or",
"there",
"is",
"an",
"error",
"deleting",
"th... | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/rdflibconn.py#L80-L99 |
KnowledgeLinks/rdfframework | rdfframework/connections/rdflibconn.py | RdflibConn.query | def query(self,
sparql,
mode="get",
namespace=None,
rtn_format="json",
**kwargs):
""" runs a sparql query and returns the results
args:
sparql: the sparql query to run
namespace: the name... | python | def query(self,
sparql,
mode="get",
namespace=None,
rtn_format="json",
**kwargs):
""" runs a sparql query and returns the results
args:
sparql: the sparql query to run
namespace: the name... | [
"def",
"query",
"(",
"self",
",",
"sparql",
",",
"mode",
"=",
"\"get\"",
",",
"namespace",
"=",
"None",
",",
"rtn_format",
"=",
"\"json\"",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"\"debug\"",
")",
":",
"log",
".",
"setL... | runs a sparql query and returns the results
args:
sparql: the sparql query to run
namespace: the namespace to run the sparql query against
mode: ['get'(default), 'update'] the type of sparql query
rtn_format: ['json'(default), 'xml'] for... | [
"runs",
"a",
"sparql",
"query",
"and",
"returns",
"the",
"results",
"args",
":",
"sparql",
":",
"the",
"sparql",
"query",
"to",
"run",
"namespace",
":",
"the",
"namespace",
"to",
"run",
"the",
"sparql",
"query",
"against",
"mode",
":",
"[",
"get",
"(",
... | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/rdflibconn.py#L161-L209 |
KnowledgeLinks/rdfframework | rdfframework/connections/rdflibconn.py | RdflibConn.update_query | def update_query(self, sparql, namespace=None, **kwargs):
""" runs a sparql update query and returns the results
args:
sparql: the sparql query to run
namespace: the namespace to run the sparql query against
"""
return self.query(sparql, "updat... | python | def update_query(self, sparql, namespace=None, **kwargs):
""" runs a sparql update query and returns the results
args:
sparql: the sparql query to run
namespace: the namespace to run the sparql query against
"""
return self.query(sparql, "updat... | [
"def",
"update_query",
"(",
"self",
",",
"sparql",
",",
"namespace",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"query",
"(",
"sparql",
",",
"\"update\"",
",",
"namespace",
",",
"*",
"*",
"kwargs",
")"
] | runs a sparql update query and returns the results
args:
sparql: the sparql query to run
namespace: the namespace to run the sparql query against | [
"runs",
"a",
"sparql",
"update",
"query",
"and",
"returns",
"the",
"results",
"args",
":",
"sparql",
":",
"the",
"sparql",
"query",
"to",
"run",
"namespace",
":",
"the",
"namespace",
"to",
"run",
"the",
"sparql",
"query",
"against"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/rdflibconn.py#L211-L218 |
KnowledgeLinks/rdfframework | rdfframework/connections/rdflibconn.py | RdflibConn.load_data | def load_data(self,
data,
datatype="ttl",
namespace=None,
graph=None,
is_file=False,
**kwargs):
""" loads data via file stream from python to triplestore
Args:
data: The data ... | python | def load_data(self,
data,
datatype="ttl",
namespace=None,
graph=None,
is_file=False,
**kwargs):
""" loads data via file stream from python to triplestore
Args:
data: The data ... | [
"def",
"load_data",
"(",
"self",
",",
"data",
",",
"datatype",
"=",
"\"ttl\"",
",",
"namespace",
"=",
"None",
",",
"graph",
"=",
"None",
",",
"is_file",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"'debug'",
")... | loads data via file stream from python to triplestore
Args:
data: The data or filepath to load
datatype(['ttl', 'xml', 'rdf']): the type of data to load
namespace: the namespace to use
graph: the graph to load the data to.
is_file(False): If true python ... | [
"loads",
"data",
"via",
"file",
"stream",
"from",
"python",
"to",
"triplestore",
"Args",
":",
"data",
":",
"The",
"data",
"or",
"filepath",
"to",
"load",
"datatype",
"(",
"[",
"ttl",
"xml",
"rdf",
"]",
")",
":",
"the",
"type",
"of",
"data",
"to",
"lo... | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/rdflibconn.py#L220-L281 |
KnowledgeLinks/rdfframework | rdfframework/connections/rdflibconn.py | RdflibConn.load_directory | def load_directory(self, method='data_stream', **kwargs):
""" Uploads data to the Blazegraph Triplestore that is stored in files
that are in a local directory
kwargs:
method['local', 'data_stream']: 'local' uses the container dir
'data_strea... | python | def load_directory(self, method='data_stream', **kwargs):
""" Uploads data to the Blazegraph Triplestore that is stored in files
that are in a local directory
kwargs:
method['local', 'data_stream']: 'local' uses the container dir
'data_strea... | [
"def",
"load_directory",
"(",
"self",
",",
"method",
"=",
"'data_stream'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"'reset'",
")",
"==",
"True",
":",
"self",
".",
"reset_namespace",
"(",
")",
"namespace",
"=",
"kwargs",
".",... | Uploads data to the Blazegraph Triplestore that is stored in files
that are in a local directory
kwargs:
method['local', 'data_stream']: 'local' uses the container dir
'data_stream': reads the file and sends it as part of
htt... | [
"Uploads",
"data",
"to",
"the",
"Blazegraph",
"Triplestore",
"that",
"is",
"stored",
"in",
"files",
"that",
"are",
"in",
"a",
"local",
"directory",
"kwargs",
":",
"method",
"[",
"local",
"data_stream",
"]",
":",
"local",
"uses",
"the",
"container",
"dir",
... | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/rdflibconn.py#L283-L376 |
KnowledgeLinks/rdfframework | rdfframework/connections/rdflibconn.py | RdflibConn.load_local_file | def load_local_file(self, file_path, namespace=None, graph=None, **kwargs):
""" Uploads data to the Blazegraph Triplestore that is stored in files
in a local directory
args:
file_path: full path to the file
namespace: the Blazegraph namespace to lo... | python | def load_local_file(self, file_path, namespace=None, graph=None, **kwargs):
""" Uploads data to the Blazegraph Triplestore that is stored in files
in a local directory
args:
file_path: full path to the file
namespace: the Blazegraph namespace to lo... | [
"def",
"load_local_file",
"(",
"self",
",",
"file_path",
",",
"namespace",
"=",
"None",
",",
"graph",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"load_data",
"(",
"file_path",
",",
"namespace",
"=",
"namespace",
",",
"graph",
... | Uploads data to the Blazegraph Triplestore that is stored in files
in a local directory
args:
file_path: full path to the file
namespace: the Blazegraph namespace to load the data
graph: uri of the graph to load the data. Default is None | [
"Uploads",
"data",
"to",
"the",
"Blazegraph",
"Triplestore",
"that",
"is",
"stored",
"in",
"files",
"in",
"a",
"local",
"directory",
"args",
":",
"file_path",
":",
"full",
"path",
"to",
"the",
"file",
"namespace",
":",
"the",
"Blazegraph",
"namespace",
"to",... | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/rdflibconn.py#L378-L391 |
KnowledgeLinks/rdfframework | rdfframework/connections/rdflibconn.py | RdflibConn.reset_namespace | def reset_namespace(self, namespace=None, params=None):
""" Will delete and recreate specified namespace
args:
namespace(str): Namespace to reset
params(dict): params used to reset the namespace
"""
namespace = pick(namespace, self.namespace)
para... | python | def reset_namespace(self, namespace=None, params=None):
""" Will delete and recreate specified namespace
args:
namespace(str): Namespace to reset
params(dict): params used to reset the namespace
"""
namespace = pick(namespace, self.namespace)
para... | [
"def",
"reset_namespace",
"(",
"self",
",",
"namespace",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"namespace",
"=",
"pick",
"(",
"namespace",
",",
"self",
".",
"namespace",
")",
"params",
"=",
"pick",
"(",
"params",
",",
"self",
".",
"namespa... | Will delete and recreate specified namespace
args:
namespace(str): Namespace to reset
params(dict): params used to reset the namespace | [
"Will",
"delete",
"and",
"recreate",
"specified",
"namespace",
"args",
":",
"namespace",
"(",
"str",
")",
":",
"Namespace",
"to",
"reset",
"params",
"(",
"dict",
")",
":",
"params",
"used",
"to",
"reset",
"the",
"namespace"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/rdflibconn.py#L429-L445 |
jmgilman/Neolib | neolib/config/Configuration.py | Configuration.initialize | def initialize():
""" Attempts to load default configuration from Configuration.path, returns status
Loads the contents of the file referenced in Configuration.path and
parses it's JSON contents. Iterates over the contents of the resulting
dictionary and converts the contents in... | python | def initialize():
""" Attempts to load default configuration from Configuration.path, returns status
Loads the contents of the file referenced in Configuration.path and
parses it's JSON contents. Iterates over the contents of the resulting
dictionary and converts the contents in... | [
"def",
"initialize",
"(",
")",
":",
"try",
":",
"f",
"=",
"open",
"(",
"Configuration",
".",
"path",
",",
"'r'",
")",
"data",
"=",
"f",
".",
"read",
"(",
")",
"f",
".",
"close",
"(",
")",
"except",
"Exception",
":",
"Configuration",
".",
"_createDe... | Attempts to load default configuration from Configuration.path, returns status
Loads the contents of the file referenced in Configuration.path and
parses it's JSON contents. Iterates over the contents of the resulting
dictionary and converts the contents into a tiered instance of
... | [
"Attempts",
"to",
"load",
"default",
"configuration",
"from",
"Configuration",
".",
"path",
"returns",
"status",
"Loads",
"the",
"contents",
"of",
"the",
"file",
"referenced",
"in",
"Configuration",
".",
"path",
"and",
"parses",
"it",
"s",
"JSON",
"contents",
... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/config/Configuration.py#L97-L125 |
MrKriss/vigilance | vigilance/conditions.py | maha_dist | def maha_dist(df):
"""Compute the squared Mahalanobis Distance for each row in the dataframe
Given a list of rows `x`, each with `p` elements, a vector :math:\mu of the
row means of length `p`, and the :math:pxp covarence matrix of the columns :math:\Sigma,
The returned value for each row is:
... | python | def maha_dist(df):
"""Compute the squared Mahalanobis Distance for each row in the dataframe
Given a list of rows `x`, each with `p` elements, a vector :math:\mu of the
row means of length `p`, and the :math:pxp covarence matrix of the columns :math:\Sigma,
The returned value for each row is:
... | [
"def",
"maha_dist",
"(",
"df",
")",
":",
"mean",
"=",
"df",
".",
"mean",
"(",
")",
"S_1",
"=",
"np",
".",
"linalg",
".",
"inv",
"(",
"df",
".",
"cov",
"(",
")",
")",
"def",
"fun",
"(",
"row",
")",
":",
"A",
"=",
"np",
".",
"dot",
"(",
"("... | Compute the squared Mahalanobis Distance for each row in the dataframe
Given a list of rows `x`, each with `p` elements, a vector :math:\mu of the
row means of length `p`, and the :math:pxp covarence matrix of the columns :math:\Sigma,
The returned value for each row is:
.. math::
D^{2} ... | [
"Compute",
"the",
"squared",
"Mahalanobis",
"Distance",
"for",
"each",
"row",
"in",
"the",
"dataframe"
] | train | https://github.com/MrKriss/vigilance/blob/2946b09f524c042c12d796f111f287866e7a3c67/vigilance/conditions.py#L12-L44 |
MrKriss/vigilance | vigilance/conditions.py | within_n_sds | def within_n_sds(n, series):
"""Return true if all values in sequence are within n SDs"""
z_score = (series - series.mean()) / series.std()
return (z_score.abs() <= n).all() | python | def within_n_sds(n, series):
"""Return true if all values in sequence are within n SDs"""
z_score = (series - series.mean()) / series.std()
return (z_score.abs() <= n).all() | [
"def",
"within_n_sds",
"(",
"n",
",",
"series",
")",
":",
"z_score",
"=",
"(",
"series",
"-",
"series",
".",
"mean",
"(",
")",
")",
"/",
"series",
".",
"std",
"(",
")",
"return",
"(",
"z_score",
".",
"abs",
"(",
")",
"<=",
"n",
")",
".",
"all",... | Return true if all values in sequence are within n SDs | [
"Return",
"true",
"if",
"all",
"values",
"in",
"sequence",
"are",
"within",
"n",
"SDs"
] | train | https://github.com/MrKriss/vigilance/blob/2946b09f524c042c12d796f111f287866e7a3c67/vigilance/conditions.py#L47-L50 |
MrKriss/vigilance | vigilance/conditions.py | within_n_mads | def within_n_mads(n, series):
"""Return true if all values in sequence are within n MADs"""
mad_score = (series - series.mean()) / series.mad()
return (mad_score.abs() <= n).all() | python | def within_n_mads(n, series):
"""Return true if all values in sequence are within n MADs"""
mad_score = (series - series.mean()) / series.mad()
return (mad_score.abs() <= n).all() | [
"def",
"within_n_mads",
"(",
"n",
",",
"series",
")",
":",
"mad_score",
"=",
"(",
"series",
"-",
"series",
".",
"mean",
"(",
")",
")",
"/",
"series",
".",
"mad",
"(",
")",
"return",
"(",
"mad_score",
".",
"abs",
"(",
")",
"<=",
"n",
")",
".",
"... | Return true if all values in sequence are within n MADs | [
"Return",
"true",
"if",
"all",
"values",
"in",
"sequence",
"are",
"within",
"n",
"MADs"
] | train | https://github.com/MrKriss/vigilance/blob/2946b09f524c042c12d796f111f287866e7a3c67/vigilance/conditions.py#L53-L56 |
tsroten/ticktock | ticktock.py | open | def open(filename, flag='c', protocol=None, writeback=False,
maxsize=DEFAULT_MAXSIZE, timeout=DEFAULT_TIMEOUT):
"""Open a database file as a persistent dictionary.
The persistent dictionary file is opened using :func:`dbm.open`, so
performance will depend on which :mod:`dbm` modules are installed.... | python | def open(filename, flag='c', protocol=None, writeback=False,
maxsize=DEFAULT_MAXSIZE, timeout=DEFAULT_TIMEOUT):
"""Open a database file as a persistent dictionary.
The persistent dictionary file is opened using :func:`dbm.open`, so
performance will depend on which :mod:`dbm` modules are installed.... | [
"def",
"open",
"(",
"filename",
",",
"flag",
"=",
"'c'",
",",
"protocol",
"=",
"None",
",",
"writeback",
"=",
"False",
",",
"maxsize",
"=",
"DEFAULT_MAXSIZE",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
")",
":",
"import",
"dbm",
"dict",
"=",
"dbm",
".",
"... | Open a database file as a persistent dictionary.
The persistent dictionary file is opened using :func:`dbm.open`, so
performance will depend on which :mod:`dbm` modules are installed.
:func:`open` chooses to open a :class:`Shelf <shelve.Shelf>`,
:class:`LRUShelf`, :class:`TimeoutShelf`, or :class:`LRU... | [
"Open",
"a",
"database",
"file",
"as",
"a",
"persistent",
"dictionary",
"."
] | train | https://github.com/tsroten/ticktock/blob/3c5431fff24d6f266f3f5ee31ade8696826943bd/ticktock.py#L372-L415 |
tsroten/ticktock | ticktock.py | _LRUMixin._remove_add_key | def _remove_add_key(self, key):
"""Move a key to the end of the linked list and discard old entries."""
if not hasattr(self, '_queue'):
return # haven't initialized yet, so don't bother
if key in self._queue:
self._queue.remove(key)
self._queue.append(key)
... | python | def _remove_add_key(self, key):
"""Move a key to the end of the linked list and discard old entries."""
if not hasattr(self, '_queue'):
return # haven't initialized yet, so don't bother
if key in self._queue:
self._queue.remove(key)
self._queue.append(key)
... | [
"def",
"_remove_add_key",
"(",
"self",
",",
"key",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_queue'",
")",
":",
"return",
"# haven't initialized yet, so don't bother",
"if",
"key",
"in",
"self",
".",
"_queue",
":",
"self",
".",
"_queue",
".",
... | Move a key to the end of the linked list and discard old entries. | [
"Move",
"a",
"key",
"to",
"the",
"end",
"of",
"the",
"linked",
"list",
"and",
"discard",
"old",
"entries",
"."
] | train | https://github.com/tsroten/ticktock/blob/3c5431fff24d6f266f3f5ee31ade8696826943bd/ticktock.py#L66-L76 |
tsroten/ticktock | ticktock.py | _TimeoutMixin._is_expired | def _is_expired(self, key):
"""Check if a key is expired. If so, delete the key."""
if not hasattr(self, '_index'):
return False # haven't initalized yet, so don't bother
try:
timeout = self._index[key]
except KeyError:
if self.timeout:
... | python | def _is_expired(self, key):
"""Check if a key is expired. If so, delete the key."""
if not hasattr(self, '_index'):
return False # haven't initalized yet, so don't bother
try:
timeout = self._index[key]
except KeyError:
if self.timeout:
... | [
"def",
"_is_expired",
"(",
"self",
",",
"key",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_index'",
")",
":",
"return",
"False",
"# haven't initalized yet, so don't bother",
"try",
":",
"timeout",
"=",
"self",
".",
"_index",
"[",
"key",
"]",
"ex... | Check if a key is expired. If so, delete the key. | [
"Check",
"if",
"a",
"key",
"is",
"expired",
".",
"If",
"so",
"delete",
"the",
"key",
"."
] | train | https://github.com/tsroten/ticktock/blob/3c5431fff24d6f266f3f5ee31ade8696826943bd/ticktock.py#L153-L168 |
tsroten/ticktock | ticktock.py | _TimeoutMixin.set | def set(self, key, func, *args, **kwargs):
"""Return key's value if it exists, otherwise call given function.
:param key: The key to lookup/set.
:param func: A function to use if the key doesn't exist.
All other arguments and keyword arguments are passed to *func*.
"""
... | python | def set(self, key, func, *args, **kwargs):
"""Return key's value if it exists, otherwise call given function.
:param key: The key to lookup/set.
:param func: A function to use if the key doesn't exist.
All other arguments and keyword arguments are passed to *func*.
"""
... | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"key",
"in",
"self",
":",
"return",
"self",
"[",
"key",
"]",
"self",
"[",
"key",
"]",
"=",
"value",
"=",
"func",
"(",
"*",
"args",
... | Return key's value if it exists, otherwise call given function.
:param key: The key to lookup/set.
:param func: A function to use if the key doesn't exist.
All other arguments and keyword arguments are passed to *func*. | [
"Return",
"key",
"s",
"value",
"if",
"it",
"exists",
"otherwise",
"call",
"given",
"function",
"."
] | train | https://github.com/tsroten/ticktock/blob/3c5431fff24d6f266f3f5ee31ade8696826943bd/ticktock.py#L180-L192 |
tsroten/ticktock | ticktock.py | _TimeoutMixin.settimeout | def settimeout(self, key, value, timeout):
"""Set a key with a timeout value (in seconds).
:meth:`settimeout` is used to override the shelf's timeout value.
:param timeout: The timeout value in seconds for the given key.
``0`` means that the key will never expire.
:type tim... | python | def settimeout(self, key, value, timeout):
"""Set a key with a timeout value (in seconds).
:meth:`settimeout` is used to override the shelf's timeout value.
:param timeout: The timeout value in seconds for the given key.
``0`` means that the key will never expire.
:type tim... | [
"def",
"settimeout",
"(",
"self",
",",
"key",
",",
"value",
",",
"timeout",
")",
":",
"self",
"[",
"key",
"]",
"=",
"value",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_index'",
")",
":",
"return",
"# don't update index if __init__ hasn't completed",
"self"... | Set a key with a timeout value (in seconds).
:meth:`settimeout` is used to override the shelf's timeout value.
:param timeout: The timeout value in seconds for the given key.
``0`` means that the key will never expire.
:type timeout: integer | [
"Set",
"a",
"key",
"with",
"a",
"timeout",
"value",
"(",
"in",
"seconds",
")",
"."
] | train | https://github.com/tsroten/ticktock/blob/3c5431fff24d6f266f3f5ee31ade8696826943bd/ticktock.py#L194-L207 |
tsroten/ticktock | ticktock.py | _TimeoutMixin.sync | def sync(self):
"""Sync the timeout index entry with the shelf."""
if self.writeback and self.cache:
super(_TimeoutMixin, self).__delitem__(self._INDEX)
super(_TimeoutMixin, self).sync()
self.writeback = False
super(_TimeoutMixin, self).__setitem__(self._I... | python | def sync(self):
"""Sync the timeout index entry with the shelf."""
if self.writeback and self.cache:
super(_TimeoutMixin, self).__delitem__(self._INDEX)
super(_TimeoutMixin, self).sync()
self.writeback = False
super(_TimeoutMixin, self).__setitem__(self._I... | [
"def",
"sync",
"(",
"self",
")",
":",
"if",
"self",
".",
"writeback",
"and",
"self",
".",
"cache",
":",
"super",
"(",
"_TimeoutMixin",
",",
"self",
")",
".",
"__delitem__",
"(",
"self",
".",
"_INDEX",
")",
"super",
"(",
"_TimeoutMixin",
",",
"self",
... | Sync the timeout index entry with the shelf. | [
"Sync",
"the",
"timeout",
"index",
"entry",
"with",
"the",
"shelf",
"."
] | train | https://github.com/tsroten/ticktock/blob/3c5431fff24d6f266f3f5ee31ade8696826943bd/ticktock.py#L251-L260 |
minhhoit/yacms | yacms/core/admin.py | DisplayableAdmin.save_model | def save_model(self, request, obj, form, change):
"""
Save model for every language so that field auto-population
is done for every each of it.
"""
super(DisplayableAdmin, self).save_model(request, obj, form, change)
if settings.USE_MODELTRANSLATION:
lang = ge... | python | def save_model(self, request, obj, form, change):
"""
Save model for every language so that field auto-population
is done for every each of it.
"""
super(DisplayableAdmin, self).save_model(request, obj, form, change)
if settings.USE_MODELTRANSLATION:
lang = ge... | [
"def",
"save_model",
"(",
"self",
",",
"request",
",",
"obj",
",",
"form",
",",
"change",
")",
":",
"super",
"(",
"DisplayableAdmin",
",",
"self",
")",
".",
"save_model",
"(",
"request",
",",
"obj",
",",
"form",
",",
"change",
")",
"if",
"settings",
... | Save model for every language so that field auto-population
is done for every each of it. | [
"Save",
"model",
"for",
"every",
"language",
"so",
"that",
"field",
"auto",
"-",
"population",
"is",
"done",
"for",
"every",
"each",
"of",
"it",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/admin.py#L116-L132 |
minhhoit/yacms | yacms/core/admin.py | BaseDynamicInlineAdmin.get_fields | def get_fields(self, request, obj=None):
"""
For subclasses of ``Orderable``, the ``_order`` field must
always be present and be the last field.
"""
fields = super(BaseDynamicInlineAdmin, self).get_fields(request, obj)
if issubclass(self.model, Orderable):
fie... | python | def get_fields(self, request, obj=None):
"""
For subclasses of ``Orderable``, the ``_order`` field must
always be present and be the last field.
"""
fields = super(BaseDynamicInlineAdmin, self).get_fields(request, obj)
if issubclass(self.model, Orderable):
fie... | [
"def",
"get_fields",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"fields",
"=",
"super",
"(",
"BaseDynamicInlineAdmin",
",",
"self",
")",
".",
"get_fields",
"(",
"request",
",",
"obj",
")",
"if",
"issubclass",
"(",
"self",
".",
"mod... | For subclasses of ``Orderable``, the ``_order`` field must
always be present and be the last field. | [
"For",
"subclasses",
"of",
"Orderable",
"the",
"_order",
"field",
"must",
"always",
"be",
"present",
"and",
"be",
"the",
"last",
"field",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/admin.py#L146-L159 |
minhhoit/yacms | yacms/core/admin.py | BaseDynamicInlineAdmin.get_fieldsets | def get_fieldsets(self, request, obj=None):
"""
Same as above, but for fieldsets.
"""
fieldsets = super(BaseDynamicInlineAdmin, self).get_fieldsets(
request, obj)
if issubclass(self.model, Orderable):
for fie... | python | def get_fieldsets(self, request, obj=None):
"""
Same as above, but for fieldsets.
"""
fieldsets = super(BaseDynamicInlineAdmin, self).get_fieldsets(
request, obj)
if issubclass(self.model, Orderable):
for fie... | [
"def",
"get_fieldsets",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"fieldsets",
"=",
"super",
"(",
"BaseDynamicInlineAdmin",
",",
"self",
")",
".",
"get_fieldsets",
"(",
"request",
",",
"obj",
")",
"if",
"issubclass",
"(",
"self",
".... | Same as above, but for fieldsets. | [
"Same",
"as",
"above",
"but",
"for",
"fieldsets",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/admin.py#L161-L177 |
minhhoit/yacms | yacms/core/admin.py | OwnableAdmin.save_form | def save_form(self, request, form, change):
"""
Set the object's owner as the logged in user.
"""
obj = form.save(commit=False)
if obj.user_id is None:
obj.user = request.user
return super(OwnableAdmin, self).save_form(request, form, change) | python | def save_form(self, request, form, change):
"""
Set the object's owner as the logged in user.
"""
obj = form.save(commit=False)
if obj.user_id is None:
obj.user = request.user
return super(OwnableAdmin, self).save_form(request, form, change) | [
"def",
"save_form",
"(",
"self",
",",
"request",
",",
"form",
",",
"change",
")",
":",
"obj",
"=",
"form",
".",
"save",
"(",
"commit",
"=",
"False",
")",
"if",
"obj",
".",
"user_id",
"is",
"None",
":",
"obj",
".",
"user",
"=",
"request",
".",
"us... | Set the object's owner as the logged in user. | [
"Set",
"the",
"object",
"s",
"owner",
"as",
"the",
"logged",
"in",
"user",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/admin.py#L229-L236 |
minhhoit/yacms | yacms/core/admin.py | OwnableAdmin.get_queryset | def get_queryset(self, request):
"""
Filter the change list by currently logged in user if not a
superuser. We also skip filtering if the model for this admin
class has been added to the sequence in the setting
``OWNABLE_MODELS_ALL_EDITABLE``, which contains models in the
... | python | def get_queryset(self, request):
"""
Filter the change list by currently logged in user if not a
superuser. We also skip filtering if the model for this admin
class has been added to the sequence in the setting
``OWNABLE_MODELS_ALL_EDITABLE``, which contains models in the
... | [
"def",
"get_queryset",
"(",
"self",
",",
"request",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"model_name",
"=",
"(",
"\"%s.%s\"",
"%",
"(",
"opts",
".",
"app_label",
",",
"opts",
".",
"object_name",
")",
")",
".",
"lower",
"(",
")",... | Filter the change list by currently logged in user if not a
superuser. We also skip filtering if the model for this admin
class has been added to the sequence in the setting
``OWNABLE_MODELS_ALL_EDITABLE``, which contains models in the
format ``app_label.object_name``, and allows models ... | [
"Filter",
"the",
"change",
"list",
"by",
"currently",
"logged",
"in",
"user",
"if",
"not",
"a",
"superuser",
".",
"We",
"also",
"skip",
"filtering",
"if",
"the",
"model",
"for",
"this",
"admin",
"class",
"has",
"been",
"added",
"to",
"the",
"sequence",
"... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/admin.py#L238-L255 |
minhhoit/yacms | yacms/core/admin.py | ContentTypedAdmin.base_concrete_modeladmin | def base_concrete_modeladmin(self):
""" The class inheriting directly from ContentModelAdmin. """
candidates = [self.__class__]
while candidates:
candidate = candidates.pop()
if ContentTypedAdmin in candidate.__bases__:
return candidate
candida... | python | def base_concrete_modeladmin(self):
""" The class inheriting directly from ContentModelAdmin. """
candidates = [self.__class__]
while candidates:
candidate = candidates.pop()
if ContentTypedAdmin in candidate.__bases__:
return candidate
candida... | [
"def",
"base_concrete_modeladmin",
"(",
"self",
")",
":",
"candidates",
"=",
"[",
"self",
".",
"__class__",
"]",
"while",
"candidates",
":",
"candidate",
"=",
"candidates",
".",
"pop",
"(",
")",
"if",
"ContentTypedAdmin",
"in",
"candidate",
".",
"__bases__",
... | The class inheriting directly from ContentModelAdmin. | [
"The",
"class",
"inheriting",
"directly",
"from",
"ContentModelAdmin",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/admin.py#L305-L314 |
minhhoit/yacms | yacms/core/admin.py | ContentTypedAdmin.change_view | def change_view(self, request, object_id, **kwargs):
"""
For the concrete model, check ``get_content_model()``
for a subclass and redirect to its admin change view.
"""
instance = get_object_or_404(self.concrete_model, pk=object_id)
content_model = instance.get_content_mo... | python | def change_view(self, request, object_id, **kwargs):
"""
For the concrete model, check ``get_content_model()``
for a subclass and redirect to its admin change view.
"""
instance = get_object_or_404(self.concrete_model, pk=object_id)
content_model = instance.get_content_mo... | [
"def",
"change_view",
"(",
"self",
",",
"request",
",",
"object_id",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"get_object_or_404",
"(",
"self",
".",
"concrete_model",
",",
"pk",
"=",
"object_id",
")",
"content_model",
"=",
"instance",
".",
"get_... | For the concrete model, check ``get_content_model()``
for a subclass and redirect to its admin change view. | [
"For",
"the",
"concrete",
"model",
"check",
"get_content_model",
"()",
"for",
"a",
"subclass",
"and",
"redirect",
"to",
"its",
"admin",
"change",
"view",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/admin.py#L322-L338 |
minhhoit/yacms | yacms/core/admin.py | ContentTypedAdmin.changelist_view | def changelist_view(self, request, extra_context=None):
""" Redirect to the changelist view for subclasses. """
if self.model is not self.concrete_model:
return HttpResponseRedirect(
admin_url(self.concrete_model, "changelist"))
extra_context = extra_context or {}
... | python | def changelist_view(self, request, extra_context=None):
""" Redirect to the changelist view for subclasses. """
if self.model is not self.concrete_model:
return HttpResponseRedirect(
admin_url(self.concrete_model, "changelist"))
extra_context = extra_context or {}
... | [
"def",
"changelist_view",
"(",
"self",
",",
"request",
",",
"extra_context",
"=",
"None",
")",
":",
"if",
"self",
".",
"model",
"is",
"not",
"self",
".",
"concrete_model",
":",
"return",
"HttpResponseRedirect",
"(",
"admin_url",
"(",
"self",
".",
"concrete_m... | Redirect to the changelist view for subclasses. | [
"Redirect",
"to",
"the",
"changelist",
"view",
"for",
"subclasses",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/admin.py#L340-L350 |
minhhoit/yacms | yacms/core/admin.py | ContentTypedAdmin.get_content_models | def get_content_models(self):
""" Return all subclasses that are admin registered. """
models = []
for model in self.concrete_model.get_content_models():
try:
admin_url(model, "add")
except NoReverseMatch:
continue
else:
... | python | def get_content_models(self):
""" Return all subclasses that are admin registered. """
models = []
for model in self.concrete_model.get_content_models():
try:
admin_url(model, "add")
except NoReverseMatch:
continue
else:
... | [
"def",
"get_content_models",
"(",
"self",
")",
":",
"models",
"=",
"[",
"]",
"for",
"model",
"in",
"self",
".",
"concrete_model",
".",
"get_content_models",
"(",
")",
":",
"try",
":",
"admin_url",
"(",
"model",
",",
"\"add\"",
")",
"except",
"NoReverseMatc... | Return all subclasses that are admin registered. | [
"Return",
"all",
"subclasses",
"that",
"are",
"admin",
"registered",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/admin.py#L352-L366 |
minhhoit/yacms | yacms/core/admin.py | SitePermissionUserAdmin.save_model | def save_model(self, request, obj, form, change):
"""
Provides a warning if the user is an active admin with no admin access.
"""
super(SitePermissionUserAdmin, self).save_model(
request, obj, form, change)
user = self.model.objects.get(id=obj.id)
has_perms = ... | python | def save_model(self, request, obj, form, change):
"""
Provides a warning if the user is an active admin with no admin access.
"""
super(SitePermissionUserAdmin, self).save_model(
request, obj, form, change)
user = self.model.objects.get(id=obj.id)
has_perms = ... | [
"def",
"save_model",
"(",
"self",
",",
"request",
",",
"obj",
",",
"form",
",",
"change",
")",
":",
"super",
"(",
"SitePermissionUserAdmin",
",",
"self",
")",
".",
"save_model",
"(",
"request",
",",
"obj",
",",
"form",
",",
"change",
")",
"user",
"=",
... | Provides a warning if the user is an active admin with no admin access. | [
"Provides",
"a",
"warning",
"if",
"the",
"user",
"is",
"an",
"active",
"admin",
"with",
"no",
"admin",
"access",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/admin.py#L383-L396 |
zyga/call | call/__init__.py | _PythonCall.bind | def bind(self, args, kwargs):
"""
Bind arguments and keyword arguments to the encapsulated function.
Returns a dictionary of parameters (named according to function
parameters) with the values that were bound to each name.
"""
spec = self._spec
resolution = self.... | python | def bind(self, args, kwargs):
"""
Bind arguments and keyword arguments to the encapsulated function.
Returns a dictionary of parameters (named according to function
parameters) with the values that were bound to each name.
"""
spec = self._spec
resolution = self.... | [
"def",
"bind",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"spec",
"=",
"self",
".",
"_spec",
"resolution",
"=",
"self",
".",
"resolve",
"(",
"args",
",",
"kwargs",
")",
"params",
"=",
"dict",
"(",
"zip",
"(",
"spec",
".",
"args",
",",
"re... | Bind arguments and keyword arguments to the encapsulated function.
Returns a dictionary of parameters (named according to function
parameters) with the values that were bound to each name. | [
"Bind",
"arguments",
"and",
"keyword",
"arguments",
"to",
"the",
"encapsulated",
"function",
"."
] | train | https://github.com/zyga/call/blob/dcef9a5aac7f9085bd4829dd6bcedc5fc2945d87/call/__init__.py#L46-L62 |
zyga/call | call/__init__.py | _PythonCall.apply | def apply(self, args, kwargs):
"""
Replicate a call to the encapsulated function.
Unlike func(*args, **kwargs) the call is deterministic in the order
kwargs are being checked by python. In other words, it behaves exactly
the same as if typed into the repl prompt.
This i... | python | def apply(self, args, kwargs):
"""
Replicate a call to the encapsulated function.
Unlike func(*args, **kwargs) the call is deterministic in the order
kwargs are being checked by python. In other words, it behaves exactly
the same as if typed into the repl prompt.
This i... | [
"def",
"apply",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"# Construct helper locals that only contain the function to call as",
"# 'func', all positional arguments as 'argX' and all keyword arguments",
"# as 'kwX'",
"_locals",
"=",
"{",
"'func'",
":",
"self",
".",
"... | Replicate a call to the encapsulated function.
Unlike func(*args, **kwargs) the call is deterministic in the order
kwargs are being checked by python. In other words, it behaves exactly
the same as if typed into the repl prompt.
This is usually only a problem when a function is given t... | [
"Replicate",
"a",
"call",
"to",
"the",
"encapsulated",
"function",
"."
] | train | https://github.com/zyga/call/blob/dcef9a5aac7f9085bd4829dd6bcedc5fc2945d87/call/__init__.py#L103-L150 |
mrallen1/pygett | pygett/shares.py | GettShare.update | def update(self, **kwargs):
"""
Add, remove or modify a share's title.
Input:
* ``title`` The share title, if any (optional)
**NOTE**: Passing ``None`` or calling this method with an empty argument list will remove the share's title.
Output:
* None
... | python | def update(self, **kwargs):
"""
Add, remove or modify a share's title.
Input:
* ``title`` The share title, if any (optional)
**NOTE**: Passing ``None`` or calling this method with an empty argument list will remove the share's title.
Output:
* None
... | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'title'",
"in",
"kwargs",
":",
"params",
"=",
"{",
"\"title\"",
":",
"kwargs",
"[",
"'title'",
"]",
"}",
"else",
":",
"params",
"=",
"{",
"\"title\"",
":",
"None",
"}",
"respon... | Add, remove or modify a share's title.
Input:
* ``title`` The share title, if any (optional)
**NOTE**: Passing ``None`` or calling this method with an empty argument list will remove the share's title.
Output:
* None
Example::
share = client.get_s... | [
"Add",
"remove",
"or",
"modify",
"a",
"share",
"s",
"title",
"."
] | train | https://github.com/mrallen1/pygett/blob/1e21f8674a3634a901af054226670174b5ce2d87/pygett/shares.py#L38-L64 |
mrallen1/pygett | pygett/shares.py | GettShare.destroy | def destroy(self):
"""
This method removes this share and all of its associated files. There is no way to recover a share or its contents
once this method has been called.
Input:
* None
Output:
* ``True``
Example::
client.get_share(... | python | def destroy(self):
"""
This method removes this share and all of its associated files. There is no way to recover a share or its contents
once this method has been called.
Input:
* None
Output:
* ``True``
Example::
client.get_share(... | [
"def",
"destroy",
"(",
"self",
")",
":",
"response",
"=",
"GettRequest",
"(",
")",
".",
"post",
"(",
"\"/shares/%s/destroy?accesstoken=%s\"",
"%",
"(",
"self",
".",
"sharename",
",",
"self",
".",
"user",
".",
"access_token",
"(",
")",
")",
",",
"None",
"... | This method removes this share and all of its associated files. There is no way to recover a share or its contents
once this method has been called.
Input:
* None
Output:
* ``True``
Example::
client.get_share("4ddfds").destroy() | [
"This",
"method",
"removes",
"this",
"share",
"and",
"all",
"of",
"its",
"associated",
"files",
".",
"There",
"is",
"no",
"way",
"to",
"recover",
"a",
"share",
"or",
"its",
"contents",
"once",
"this",
"method",
"has",
"been",
"called",
"."
] | train | https://github.com/mrallen1/pygett/blob/1e21f8674a3634a901af054226670174b5ce2d87/pygett/shares.py#L66-L84 |
mrallen1/pygett | pygett/shares.py | GettShare.refresh | def refresh(self):
"""
This method refreshes the object with current metadata from the Gett service.
Input:
* None
Output:
* None
Example::
share = client.get_share("4ddfds")
print share.files[0].filename # prints 'foobar'
... | python | def refresh(self):
"""
This method refreshes the object with current metadata from the Gett service.
Input:
* None
Output:
* None
Example::
share = client.get_share("4ddfds")
print share.files[0].filename # prints 'foobar'
... | [
"def",
"refresh",
"(",
"self",
")",
":",
"response",
"=",
"GettRequest",
"(",
")",
".",
"get",
"(",
"\"/shares/%s\"",
"%",
"self",
".",
"sharename",
")",
"if",
"response",
".",
"http_status",
"==",
"200",
":",
"self",
".",
"__init__",
"(",
"self",
".",... | This method refreshes the object with current metadata from the Gett service.
Input:
* None
Output:
* None
Example::
share = client.get_share("4ddfds")
print share.files[0].filename # prints 'foobar'
if share.files[0].destroy()... | [
"This",
"method",
"refreshes",
"the",
"object",
"with",
"current",
"metadata",
"from",
"the",
"Gett",
"service",
"."
] | train | https://github.com/mrallen1/pygett/blob/1e21f8674a3634a901af054226670174b5ce2d87/pygett/shares.py#L86-L107 |
klen/muffin-debugtoolbar | muffin_debugtoolbar/tbtools/tbtools.py | get_current_traceback | def get_current_traceback(*, ignore_system_exceptions=False,
show_hidden_frames=False, skip=0, exc):
"""Get the current exception info as `Traceback` object. Per default
calling this method will reraise system exceptions such as generator exit,
system exit or others. This behavio... | python | def get_current_traceback(*, ignore_system_exceptions=False,
show_hidden_frames=False, skip=0, exc):
"""Get the current exception info as `Traceback` object. Per default
calling this method will reraise system exceptions such as generator exit,
system exit or others. This behavio... | [
"def",
"get_current_traceback",
"(",
"*",
",",
"ignore_system_exceptions",
"=",
"False",
",",
"show_hidden_frames",
"=",
"False",
",",
"skip",
"=",
"0",
",",
"exc",
")",
":",
"info",
"=",
"sys",
".",
"exc_info",
"(",
")",
"return",
"get_traceback",
"(",
"i... | Get the current exception info as `Traceback` object. Per default
calling this method will reraise system exceptions such as generator exit,
system exit or others. This behavior can be disabled by passing `False`
to the function as first parameter. | [
"Get",
"the",
"current",
"exception",
"info",
"as",
"Traceback",
"object",
".",
"Per",
"default",
"calling",
"this",
"method",
"will",
"reraise",
"system",
"exceptions",
"such",
"as",
"generator",
"exit",
"system",
"exit",
"or",
"others",
".",
"This",
"behavio... | train | https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/tbtools/tbtools.py#L55-L66 |
klen/muffin-debugtoolbar | muffin_debugtoolbar/tbtools/tbtools.py | Traceback.render_summary | def render_summary(self, include_title=True, request=None):
"""Render the traceback for the interactive console."""
title = ''
frames = []
classes = ['traceback']
if not self.frames:
classes.append('noframe-traceback')
if include_title:
if self.is... | python | def render_summary(self, include_title=True, request=None):
"""Render the traceback for the interactive console."""
title = ''
frames = []
classes = ['traceback']
if not self.frames:
classes.append('noframe-traceback')
if include_title:
if self.is... | [
"def",
"render_summary",
"(",
"self",
",",
"include_title",
"=",
"True",
",",
"request",
"=",
"None",
")",
":",
"title",
"=",
"''",
"frames",
"=",
"[",
"]",
"classes",
"=",
"[",
"'traceback'",
"]",
"if",
"not",
"self",
".",
"frames",
":",
"classes",
... | Render the traceback for the interactive console. | [
"Render",
"the",
"traceback",
"for",
"the",
"interactive",
"console",
"."
] | train | https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/tbtools/tbtools.py#L192-L229 |
klen/muffin-debugtoolbar | muffin_debugtoolbar/tbtools/tbtools.py | Traceback.render_full | def render_full(self, request, lodgeit_url=None):
"""Render the Full HTML page with the traceback info."""
app = request.app
root_path = request.app.ps.debugtoolbar.cfg.prefix
exc = escape(self.exception)
summary = self.render_summary(include_title=False, request=request)
... | python | def render_full(self, request, lodgeit_url=None):
"""Render the Full HTML page with the traceback info."""
app = request.app
root_path = request.app.ps.debugtoolbar.cfg.prefix
exc = escape(self.exception)
summary = self.render_summary(include_title=False, request=request)
... | [
"def",
"render_full",
"(",
"self",
",",
"request",
",",
"lodgeit_url",
"=",
"None",
")",
":",
"app",
"=",
"request",
".",
"app",
"root_path",
"=",
"request",
".",
"app",
".",
"ps",
".",
"debugtoolbar",
".",
"cfg",
".",
"prefix",
"exc",
"=",
"escape",
... | Render the Full HTML page with the traceback info. | [
"Render",
"the",
"Full",
"HTML",
"page",
"with",
"the",
"traceback",
"info",
"."
] | train | https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/tbtools/tbtools.py#L231-L256 |
klen/muffin-debugtoolbar | muffin_debugtoolbar/tbtools/tbtools.py | Frame.sourcelines | def sourcelines(self):
"""The sourcecode of the file as list of unicode strings."""
# get sourcecode from loader or file
source = None
if self.loader is not None:
try:
if hasattr(self.loader, 'get_source'):
source = self.loader.get_source(s... | python | def sourcelines(self):
"""The sourcecode of the file as list of unicode strings."""
# get sourcecode from loader or file
source = None
if self.loader is not None:
try:
if hasattr(self.loader, 'get_source'):
source = self.loader.get_source(s... | [
"def",
"sourcelines",
"(",
"self",
")",
":",
"# get sourcecode from loader or file",
"source",
"=",
"None",
"if",
"self",
".",
"loader",
"is",
"not",
"None",
":",
"try",
":",
"if",
"hasattr",
"(",
"self",
".",
"loader",
",",
"'get_source'",
")",
":",
"sour... | The sourcecode of the file as list of unicode strings. | [
"The",
"sourcecode",
"of",
"the",
"file",
"as",
"list",
"of",
"unicode",
"strings",
"."
] | train | https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/tbtools/tbtools.py#L360-L385 |
KnowledgeLinks/rdfframework | rdfframework/utilities/codetimer.py | code_timer | def code_timer(reset=False):
'''Sets a global variable for tracking the timer accross multiple
files '''
global CODE_TIMER
if reset:
CODE_TIMER = CodeTimer()
else:
if CODE_TIMER is None:
return CodeTimer()
else:
return CODE_TIMER | python | def code_timer(reset=False):
'''Sets a global variable for tracking the timer accross multiple
files '''
global CODE_TIMER
if reset:
CODE_TIMER = CodeTimer()
else:
if CODE_TIMER is None:
return CodeTimer()
else:
return CODE_TIMER | [
"def",
"code_timer",
"(",
"reset",
"=",
"False",
")",
":",
"global",
"CODE_TIMER",
"if",
"reset",
":",
"CODE_TIMER",
"=",
"CodeTimer",
"(",
")",
"else",
":",
"if",
"CODE_TIMER",
"is",
"None",
":",
"return",
"CodeTimer",
"(",
")",
"else",
":",
"return",
... | Sets a global variable for tracking the timer accross multiple
files | [
"Sets",
"a",
"global",
"variable",
"for",
"tracking",
"the",
"timer",
"accross",
"multiple",
"files"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/codetimer.py#L55-L66 |
KnowledgeLinks/rdfframework | rdfframework/utilities/codetimer.py | CodeTimer.log | def log(self, timer_name, node):
''' logs a event in the timer '''
timestamp = time.time()
if hasattr(self, timer_name):
getattr(self, timer_name).append({
"node":node,
"time":timestamp})
else:
setattr(self, timer_name, [{"node":nod... | python | def log(self, timer_name, node):
''' logs a event in the timer '''
timestamp = time.time()
if hasattr(self, timer_name):
getattr(self, timer_name).append({
"node":node,
"time":timestamp})
else:
setattr(self, timer_name, [{"node":nod... | [
"def",
"log",
"(",
"self",
",",
"timer_name",
",",
"node",
")",
":",
"timestamp",
"=",
"time",
".",
"time",
"(",
")",
"if",
"hasattr",
"(",
"self",
",",
"timer_name",
")",
":",
"getattr",
"(",
"self",
",",
"timer_name",
")",
".",
"append",
"(",
"{"... | logs a event in the timer | [
"logs",
"a",
"event",
"in",
"the",
"timer"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/codetimer.py#L16-L24 |
KnowledgeLinks/rdfframework | rdfframework/utilities/codetimer.py | CodeTimer.print_timer | def print_timer(self, timer_name, **kwargs):
''' prints the timer to the terminal
keyword args:
delete -> True/False -deletes the timer after printing
'''
if hasattr(self, timer_name):
_delete_timer = kwargs.get("delete", False)
print("|-----... | python | def print_timer(self, timer_name, **kwargs):
''' prints the timer to the terminal
keyword args:
delete -> True/False -deletes the timer after printing
'''
if hasattr(self, timer_name):
_delete_timer = kwargs.get("delete", False)
print("|-----... | [
"def",
"print_timer",
"(",
"self",
",",
"timer_name",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"timer_name",
")",
":",
"_delete_timer",
"=",
"kwargs",
".",
"get",
"(",
"\"delete\"",
",",
"False",
")",
"print",
"(",
"\"|----... | prints the timer to the terminal
keyword args:
delete -> True/False -deletes the timer after printing | [
"prints",
"the",
"timer",
"to",
"the",
"terminal"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/codetimer.py#L25-L48 |
townsenddw/jhubctl | jhubctl/clusters/clusters.py | ClusterList.check_cluster_exists | def check_cluster_exists(self, name):
"""Check if cluster exists. If it does not, raise exception."""
self.kubeconf.open()
clusters = self.kubeconf.get_clusters()
names = [c['name'] for c in clusters]
if name in names:
return True
return False | python | def check_cluster_exists(self, name):
"""Check if cluster exists. If it does not, raise exception."""
self.kubeconf.open()
clusters = self.kubeconf.get_clusters()
names = [c['name'] for c in clusters]
if name in names:
return True
return False | [
"def",
"check_cluster_exists",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"kubeconf",
".",
"open",
"(",
")",
"clusters",
"=",
"self",
".",
"kubeconf",
".",
"get_clusters",
"(",
")",
"names",
"=",
"[",
"c",
"[",
"'name'",
"]",
"for",
"c",
"in",
... | Check if cluster exists. If it does not, raise exception. | [
"Check",
"if",
"cluster",
"exists",
".",
"If",
"it",
"does",
"not",
"raise",
"exception",
"."
] | train | https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/clusters.py#L14-L21 |
townsenddw/jhubctl | jhubctl/clusters/clusters.py | ClusterList.get | def get(self, name=None, provider='AwsEKS', print_output=True):
"""List all cluster.
"""
# Create cluster object
Cluster = getattr(providers, provider)
cluster = Cluster(name)
self.kubeconf.open()
if name is None:
clusters = self.kubeconf.get_clusters... | python | def get(self, name=None, provider='AwsEKS', print_output=True):
"""List all cluster.
"""
# Create cluster object
Cluster = getattr(providers, provider)
cluster = Cluster(name)
self.kubeconf.open()
if name is None:
clusters = self.kubeconf.get_clusters... | [
"def",
"get",
"(",
"self",
",",
"name",
"=",
"None",
",",
"provider",
"=",
"'AwsEKS'",
",",
"print_output",
"=",
"True",
")",
":",
"# Create cluster object",
"Cluster",
"=",
"getattr",
"(",
"providers",
",",
"provider",
")",
"cluster",
"=",
"Cluster",
"(",... | List all cluster. | [
"List",
"all",
"cluster",
"."
] | train | https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/clusters.py#L23-L42 |
townsenddw/jhubctl | jhubctl/clusters/clusters.py | ClusterList.create | def create(self, name, provider='AwsEKS'):
"""Create a Kubernetes cluster on a given provider.
"""
# ----- Create K8s cluster on provider -------
# Create cluster object
Cluster = getattr(providers, provider)
cluster = Cluster(name=name, ssh_key_name='zsailer')
cl... | python | def create(self, name, provider='AwsEKS'):
"""Create a Kubernetes cluster on a given provider.
"""
# ----- Create K8s cluster on provider -------
# Create cluster object
Cluster = getattr(providers, provider)
cluster = Cluster(name=name, ssh_key_name='zsailer')
cl... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"provider",
"=",
"'AwsEKS'",
")",
":",
"# ----- Create K8s cluster on provider -------",
"# Create cluster object",
"Cluster",
"=",
"getattr",
"(",
"providers",
",",
"provider",
")",
"cluster",
"=",
"Cluster",
"(",
"... | Create a Kubernetes cluster on a given provider. | [
"Create",
"a",
"Kubernetes",
"cluster",
"on",
"a",
"given",
"provider",
"."
] | train | https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/clusters.py#L44-L124 |
townsenddw/jhubctl | jhubctl/clusters/clusters.py | ClusterList.delete | def delete(self, name, provider='AwsEKS'):
"""Delete a Kubernetes cluster.
"""
# if self.check_cluster_exists(name) is False:
# raise JhubctlError("Cluster name not found in availabe clusters.")
# Create cluster object
Cluster = getattr(providers, provider)
c... | python | def delete(self, name, provider='AwsEKS'):
"""Delete a Kubernetes cluster.
"""
# if self.check_cluster_exists(name) is False:
# raise JhubctlError("Cluster name not found in availabe clusters.")
# Create cluster object
Cluster = getattr(providers, provider)
c... | [
"def",
"delete",
"(",
"self",
",",
"name",
",",
"provider",
"=",
"'AwsEKS'",
")",
":",
"# if self.check_cluster_exists(name) is False:",
"# raise JhubctlError(\"Cluster name not found in availabe clusters.\")",
"# Create cluster object",
"Cluster",
"=",
"getattr",
"(",
"pro... | Delete a Kubernetes cluster. | [
"Delete",
"a",
"Kubernetes",
"cluster",
"."
] | train | https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/clusters.py#L126-L142 |
uw-it-aca/uw-restclients-iasystem | uw_iasystem/__init__.py | __get_resource | def __get_resource(dao, url):
"""
Issue a GET request to IASystem with the given url
and return a response in Collection+json format.
:returns: http response with content in json
"""
headers = {"Accept": "application/vnd.collection+json"}
response = dao.getURL(url, headers)
status = resp... | python | def __get_resource(dao, url):
"""
Issue a GET request to IASystem with the given url
and return a response in Collection+json format.
:returns: http response with content in json
"""
headers = {"Accept": "application/vnd.collection+json"}
response = dao.getURL(url, headers)
status = resp... | [
"def",
"__get_resource",
"(",
"dao",
",",
"url",
")",
":",
"headers",
"=",
"{",
"\"Accept\"",
":",
"\"application/vnd.collection+json\"",
"}",
"response",
"=",
"dao",
".",
"getURL",
"(",
"url",
",",
"headers",
")",
"status",
"=",
"response",
".",
"status",
... | Issue a GET request to IASystem with the given url
and return a response in Collection+json format.
:returns: http response with content in json | [
"Issue",
"a",
"GET",
"request",
"to",
"IASystem",
"with",
"the",
"given",
"url",
"and",
"return",
"a",
"response",
"in",
"Collection",
"+",
"json",
"format",
".",
":",
"returns",
":",
"http",
"response",
"with",
"content",
"in",
"json"
] | train | https://github.com/uw-it-aca/uw-restclients-iasystem/blob/f65f169d54b0d39e2d732cba529ccd8b6cb49f8a/uw_iasystem/__init__.py#L33-L57 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.