id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
249,600 | etcher-be/elib_run | elib_run/_run/_capture_output.py | capture_output_from_running_process | def capture_output_from_running_process(context: RunContext) -> None:
"""
Parses output from a running sub-process
Decodes and filters the process output line by line, buffering it
If "mute" is False, sends the output back in real time
:param context: run context
:type context: _RunContext
... | python | def capture_output_from_running_process(context: RunContext) -> None:
"""
Parses output from a running sub-process
Decodes and filters the process output line by line, buffering it
If "mute" is False, sends the output back in real time
:param context: run context
:type context: _RunContext
... | [
"def",
"capture_output_from_running_process",
"(",
"context",
":",
"RunContext",
")",
"->",
"None",
":",
"# Get the raw output one line at a time",
"_output",
"=",
"context",
".",
"capture",
".",
"readline",
"(",
"block",
"=",
"False",
")",
"if",
"_output",
":",
"... | Parses output from a running sub-process
Decodes and filters the process output line by line, buffering it
If "mute" is False, sends the output back in real time
:param context: run context
:type context: _RunContext | [
"Parses",
"output",
"from",
"a",
"running",
"sub",
"-",
"process"
] | c9d8ba9f067ab90c5baa27375a92b23f1b97cdde | https://github.com/etcher-be/elib_run/blob/c9d8ba9f067ab90c5baa27375a92b23f1b97cdde/elib_run/_run/_capture_output.py#L54-L84 |
249,601 | awacha/credolib | credolib/atsas.py | autorg | def autorg(filename, mininterval=None, qminrg=None, qmaxrg=None, noprint=True):
"""Execute autorg.
Inputs:
filename: either a name of an ascii file, or an instance of Curve.
mininterval: the minimum number of points in the Guinier range
qminrg: the maximum value of qmin*Rg. Default of a... | python | def autorg(filename, mininterval=None, qminrg=None, qmaxrg=None, noprint=True):
"""Execute autorg.
Inputs:
filename: either a name of an ascii file, or an instance of Curve.
mininterval: the minimum number of points in the Guinier range
qminrg: the maximum value of qmin*Rg. Default of a... | [
"def",
"autorg",
"(",
"filename",
",",
"mininterval",
"=",
"None",
",",
"qminrg",
"=",
"None",
",",
"qmaxrg",
"=",
"None",
",",
"noprint",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"Curve",
")",
":",
"curve",
"=",
"filename",
"... | Execute autorg.
Inputs:
filename: either a name of an ascii file, or an instance of Curve.
mininterval: the minimum number of points in the Guinier range
qminrg: the maximum value of qmin*Rg. Default of autorg is 1.0
qmaxrg: the maximum value of qmax*Rg. Default of autorg is 1.3
... | [
"Execute",
"autorg",
"."
] | 11c0be3eea7257d3d6e13697d3e76ce538f2f1b2 | https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/atsas.py#L156-L197 |
249,602 | awacha/credolib | credolib/atsas.py | datcmp | def datcmp(*curves, alpha=None, adjust=None, test='CORMAP'):
"""Run datcmp on the scattering curves.
Inputs:
*curves: scattering curves as positional arguments
alpha: confidence parameter
adjust: adjustment type (string), see the help of datcmp for details
test: test (string), s... | python | def datcmp(*curves, alpha=None, adjust=None, test='CORMAP'):
"""Run datcmp on the scattering curves.
Inputs:
*curves: scattering curves as positional arguments
alpha: confidence parameter
adjust: adjustment type (string), see the help of datcmp for details
test: test (string), s... | [
"def",
"datcmp",
"(",
"*",
"curves",
",",
"alpha",
"=",
"None",
",",
"adjust",
"=",
"None",
",",
"test",
"=",
"'CORMAP'",
")",
":",
"if",
"len",
"(",
"{",
"len",
"(",
"c",
")",
"for",
"c",
"in",
"curves",
"}",
")",
"!=",
"1",
":",
"raise",
"V... | Run datcmp on the scattering curves.
Inputs:
*curves: scattering curves as positional arguments
alpha: confidence parameter
adjust: adjustment type (string), see the help of datcmp for details
test: test (string), see the help of datcmp for details
Outputs:
matC: the C ... | [
"Run",
"datcmp",
"on",
"the",
"scattering",
"curves",
"."
] | 11c0be3eea7257d3d6e13697d3e76ce538f2f1b2 | https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/atsas.py#L371-L428 |
249,603 | awacha/credolib | credolib/atsas.py | datporod | def datporod(gnomoutfile):
"""Run datporod and return the estimated Porod volume.
Returns:
Radius of gyration found in the input file
I0 found in the input file
Vporod: the estimated Porod volume
"""
results = subprocess.check_output(['datporod', gnomoutfile]).decode('utf-8')... | python | def datporod(gnomoutfile):
"""Run datporod and return the estimated Porod volume.
Returns:
Radius of gyration found in the input file
I0 found in the input file
Vporod: the estimated Porod volume
"""
results = subprocess.check_output(['datporod', gnomoutfile]).decode('utf-8')... | [
"def",
"datporod",
"(",
"gnomoutfile",
")",
":",
"results",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'datporod'",
",",
"gnomoutfile",
"]",
")",
".",
"decode",
"(",
"'utf-8'",
")",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"return",
"flo... | Run datporod and return the estimated Porod volume.
Returns:
Radius of gyration found in the input file
I0 found in the input file
Vporod: the estimated Porod volume | [
"Run",
"datporod",
"and",
"return",
"the",
"estimated",
"Porod",
"volume",
"."
] | 11c0be3eea7257d3d6e13697d3e76ce538f2f1b2 | https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/atsas.py#L431-L440 |
249,604 | awacha/credolib | credolib/atsas.py | gnom | def gnom(curve, Rmax, outputfilename=None, Npoints_realspace=None, initial_alpha=None):
"""Run GNOM on the dataset.
Inputs:
curve: an instance of sastool.classes2.Curve or anything which has a
save() method, saving the scattering curve to a given .dat file,
in q=4*pi*sin(theta)/... | python | def gnom(curve, Rmax, outputfilename=None, Npoints_realspace=None, initial_alpha=None):
"""Run GNOM on the dataset.
Inputs:
curve: an instance of sastool.classes2.Curve or anything which has a
save() method, saving the scattering curve to a given .dat file,
in q=4*pi*sin(theta)/... | [
"def",
"gnom",
"(",
"curve",
",",
"Rmax",
",",
"outputfilename",
"=",
"None",
",",
"Npoints_realspace",
"=",
"None",
",",
"initial_alpha",
"=",
"None",
")",
":",
"with",
"tempfile",
".",
"TemporaryDirectory",
"(",
"prefix",
"=",
"'credolib_gnom'",
")",
"as",... | Run GNOM on the dataset.
Inputs:
curve: an instance of sastool.classes2.Curve or anything which has a
save() method, saving the scattering curve to a given .dat file,
in q=4*pi*sin(theta)/lambda [1/nm] units
Rmax: the estimated maximum extent of the scattering object, in nm.... | [
"Run",
"GNOM",
"on",
"the",
"dataset",
"."
] | 11c0be3eea7257d3d6e13697d3e76ce538f2f1b2 | https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/atsas.py#L443-L518 |
249,605 | uw-it-aca/uw-restclients-libraries | uw_libraries/mylib.py | get_account | def get_account(netid, timestamp=None):
"""
The Libraries object has a method for getting information
about a user's library account
"""
response = _get_account(netid, timestamp=timestamp)
return _account_from_json(response) | python | def get_account(netid, timestamp=None):
"""
The Libraries object has a method for getting information
about a user's library account
"""
response = _get_account(netid, timestamp=timestamp)
return _account_from_json(response) | [
"def",
"get_account",
"(",
"netid",
",",
"timestamp",
"=",
"None",
")",
":",
"response",
"=",
"_get_account",
"(",
"netid",
",",
"timestamp",
"=",
"timestamp",
")",
"return",
"_account_from_json",
"(",
"response",
")"
] | The Libraries object has a method for getting information
about a user's library account | [
"The",
"Libraries",
"object",
"has",
"a",
"method",
"for",
"getting",
"information",
"about",
"a",
"user",
"s",
"library",
"account"
] | 2fa2e38be4516d7853c2802e2f23b17fbf4bac3d | https://github.com/uw-it-aca/uw-restclients-libraries/blob/2fa2e38be4516d7853c2802e2f23b17fbf4bac3d/uw_libraries/mylib.py#L45-L51 |
249,606 | fred49/linshare-api | linshareapi/user/contactslistcontact.py | ContactsListContact.delete | def delete(self, list_uuid, uuid):
""" Delete one list."""
res = self.get(list_uuid, uuid)
url = "%(base)s/%(list_uuid)s/contacts/%(uuid)s" % {
'base': self.local_base_url,
'list_uuid': list_uuid,
'uuid': uuid
}
self.core.delete(url)
re... | python | def delete(self, list_uuid, uuid):
""" Delete one list."""
res = self.get(list_uuid, uuid)
url = "%(base)s/%(list_uuid)s/contacts/%(uuid)s" % {
'base': self.local_base_url,
'list_uuid': list_uuid,
'uuid': uuid
}
self.core.delete(url)
re... | [
"def",
"delete",
"(",
"self",
",",
"list_uuid",
",",
"uuid",
")",
":",
"res",
"=",
"self",
".",
"get",
"(",
"list_uuid",
",",
"uuid",
")",
"url",
"=",
"\"%(base)s/%(list_uuid)s/contacts/%(uuid)s\"",
"%",
"{",
"'base'",
":",
"self",
".",
"local_base_url",
"... | Delete one list. | [
"Delete",
"one",
"list",
"."
] | be646c25aa8ba3718abb6869c620b157d53d6e41 | https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/user/contactslistcontact.py#L99-L108 |
249,607 | ramrod-project/database-brain | schema/brain/controller/plugins.py | find_plugin | def find_plugin(value,
key=DEFAULT_LOOKUP_KEY,
conn=None):
"""
get's the plugin matching the key and value
example: find_plugin("plugin1", "ServiceName") => list of 0 or 1 item
example: find_plugin("plugin1", "Name") => list of 0-to-many items
:param value:
:par... | python | def find_plugin(value,
key=DEFAULT_LOOKUP_KEY,
conn=None):
"""
get's the plugin matching the key and value
example: find_plugin("plugin1", "ServiceName") => list of 0 or 1 item
example: find_plugin("plugin1", "Name") => list of 0-to-many items
:param value:
:par... | [
"def",
"find_plugin",
"(",
"value",
",",
"key",
"=",
"DEFAULT_LOOKUP_KEY",
",",
"conn",
"=",
"None",
")",
":",
"# cast to list to hide rethink internals from caller",
"result",
"=",
"list",
"(",
"RPC",
".",
"filter",
"(",
"{",
"key",
":",
"value",
"}",
")",
... | get's the plugin matching the key and value
example: find_plugin("plugin1", "ServiceName") => list of 0 or 1 item
example: find_plugin("plugin1", "Name") => list of 0-to-many items
:param value:
:param key: <str> (default "Name")
:param conn:
:return: | [
"get",
"s",
"the",
"plugin",
"matching",
"the",
"key",
"and",
"value"
] | b024cb44f34cabb9d80af38271ddb65c25767083 | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/controller/plugins.py#L57-L75 |
249,608 | OpenVolunteeringPlatform/django-ovp-projects | ovp_projects/emails.py | ApplyMail.sendAppliedToOwner | def sendAppliedToOwner(self, context={}):
"""
Sent to project owner when user applies to a project
"""
super(ApplyMail, self).__init__(self.apply.project.owner.email, self.async, self.apply.project.owner.locale)
return self.sendEmail('volunteerApplied-ToOwner', 'New volunteer', context) | python | def sendAppliedToOwner(self, context={}):
"""
Sent to project owner when user applies to a project
"""
super(ApplyMail, self).__init__(self.apply.project.owner.email, self.async, self.apply.project.owner.locale)
return self.sendEmail('volunteerApplied-ToOwner', 'New volunteer', context) | [
"def",
"sendAppliedToOwner",
"(",
"self",
",",
"context",
"=",
"{",
"}",
")",
":",
"super",
"(",
"ApplyMail",
",",
"self",
")",
".",
"__init__",
"(",
"self",
".",
"apply",
".",
"project",
".",
"owner",
".",
"email",
",",
"self",
".",
"async",
",",
... | Sent to project owner when user applies to a project | [
"Sent",
"to",
"project",
"owner",
"when",
"user",
"applies",
"to",
"a",
"project"
] | 239e27027ca99c7b44ee4f30bf55d06439d49251 | https://github.com/OpenVolunteeringPlatform/django-ovp-projects/blob/239e27027ca99c7b44ee4f30bf55d06439d49251/ovp_projects/emails.py#L53-L58 |
249,609 | mbarakaja/braulio | braulio/git.py | Git.add | def add(self, *files):
"""Add one or more files to the index running git-add."""
try:
_run_command(("git", "add") + files)
except CalledProcessError:
# Only if the command fails we check if the files
# exist, because git-add most of the time fails when
... | python | def add(self, *files):
"""Add one or more files to the index running git-add."""
try:
_run_command(("git", "add") + files)
except CalledProcessError:
# Only if the command fails we check if the files
# exist, because git-add most of the time fails when
... | [
"def",
"add",
"(",
"self",
",",
"*",
"files",
")",
":",
"try",
":",
"_run_command",
"(",
"(",
"\"git\"",
",",
"\"add\"",
")",
"+",
"files",
")",
"except",
"CalledProcessError",
":",
"# Only if the command fails we check if the files",
"# exist, because git-add most ... | Add one or more files to the index running git-add. | [
"Add",
"one",
"or",
"more",
"files",
"to",
"the",
"index",
"running",
"git",
"-",
"add",
"."
] | 70ab6f0dd631ef78c4da1b39d1c6fb6f9a995d2b | https://github.com/mbarakaja/braulio/blob/70ab6f0dd631ef78c4da1b39d1c6fb6f9a995d2b/braulio/git.py#L71-L82 |
249,610 | mbarakaja/braulio | braulio/git.py | Git.commit | def commit(self, message, files=None):
"""Run git-commit."""
if files:
self.add(*files)
return _run_command(["git", "commit", "-m", f'"{message}"']) | python | def commit(self, message, files=None):
"""Run git-commit."""
if files:
self.add(*files)
return _run_command(["git", "commit", "-m", f'"{message}"']) | [
"def",
"commit",
"(",
"self",
",",
"message",
",",
"files",
"=",
"None",
")",
":",
"if",
"files",
":",
"self",
".",
"add",
"(",
"*",
"files",
")",
"return",
"_run_command",
"(",
"[",
"\"git\"",
",",
"\"commit\"",
",",
"\"-m\"",
",",
"f'\"{message}\"'",... | Run git-commit. | [
"Run",
"git",
"-",
"commit",
"."
] | 70ab6f0dd631ef78c4da1b39d1c6fb6f9a995d2b | https://github.com/mbarakaja/braulio/blob/70ab6f0dd631ef78c4da1b39d1c6fb6f9a995d2b/braulio/git.py#L84-L90 |
249,611 | mbarakaja/braulio | braulio/git.py | Git.log | def log(self, _from=None, to=None):
"""Run git-log."""
command = ["git", "log"]
if _from:
to = "HEAD" if not to else to
revision_range = f"{_from}..{to}"
command.append(revision_range)
git_log_text = _run_command(command)
commit_text_lst = _... | python | def log(self, _from=None, to=None):
"""Run git-log."""
command = ["git", "log"]
if _from:
to = "HEAD" if not to else to
revision_range = f"{_from}..{to}"
command.append(revision_range)
git_log_text = _run_command(command)
commit_text_lst = _... | [
"def",
"log",
"(",
"self",
",",
"_from",
"=",
"None",
",",
"to",
"=",
"None",
")",
":",
"command",
"=",
"[",
"\"git\"",
",",
"\"log\"",
"]",
"if",
"_from",
":",
"to",
"=",
"\"HEAD\"",
"if",
"not",
"to",
"else",
"to",
"revision_range",
"=",
"f\"{_fr... | Run git-log. | [
"Run",
"git",
"-",
"log",
"."
] | 70ab6f0dd631ef78c4da1b39d1c6fb6f9a995d2b | https://github.com/mbarakaja/braulio/blob/70ab6f0dd631ef78c4da1b39d1c6fb6f9a995d2b/braulio/git.py#L92-L105 |
249,612 | mbarakaja/braulio | braulio/git.py | Git.tag | def tag(self, name=None):
"""Create and list tag objects running git-tag command"""
command = ["git", "tag"]
if not name:
command.extend(
[
"-l",
"--sort=creatordate",
"--format=%(creatordate:short)%09%(ref... | python | def tag(self, name=None):
"""Create and list tag objects running git-tag command"""
command = ["git", "tag"]
if not name:
command.extend(
[
"-l",
"--sort=creatordate",
"--format=%(creatordate:short)%09%(ref... | [
"def",
"tag",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"command",
"=",
"[",
"\"git\"",
",",
"\"tag\"",
"]",
"if",
"not",
"name",
":",
"command",
".",
"extend",
"(",
"[",
"\"-l\"",
",",
"\"--sort=creatordate\"",
",",
"\"--format=%(creatordate:short)... | Create and list tag objects running git-tag command | [
"Create",
"and",
"list",
"tag",
"objects",
"running",
"git",
"-",
"tag",
"command"
] | 70ab6f0dd631ef78c4da1b39d1c6fb6f9a995d2b | https://github.com/mbarakaja/braulio/blob/70ab6f0dd631ef78c4da1b39d1c6fb6f9a995d2b/braulio/git.py#L107-L132 |
249,613 | devricks/soft_drf | soft_drf/api/routers/__init__.py | DefaultRouter.register | def register(self, prefix, viewset, base_name=None, router_class=None):
"""
Append the given viewset to the proper registry.
"""
if base_name is None:
base_name = self.get_default_base_name(viewset)
if router_class is not None:
kwargs = {'trailing_slash':... | python | def register(self, prefix, viewset, base_name=None, router_class=None):
"""
Append the given viewset to the proper registry.
"""
if base_name is None:
base_name = self.get_default_base_name(viewset)
if router_class is not None:
kwargs = {'trailing_slash':... | [
"def",
"register",
"(",
"self",
",",
"prefix",
",",
"viewset",
",",
"base_name",
"=",
"None",
",",
"router_class",
"=",
"None",
")",
":",
"if",
"base_name",
"is",
"None",
":",
"base_name",
"=",
"self",
".",
"get_default_base_name",
"(",
"viewset",
")",
"... | Append the given viewset to the proper registry. | [
"Append",
"the",
"given",
"viewset",
"to",
"the",
"proper",
"registry",
"."
] | 1869b13f9341bfcebd931059e93de2bc38570da3 | https://github.com/devricks/soft_drf/blob/1869b13f9341bfcebd931059e93de2bc38570da3/soft_drf/api/routers/__init__.py#L16-L34 |
249,614 | devricks/soft_drf | soft_drf/api/routers/__init__.py | DefaultRouter.register_nested | def register_nested(
self, parent_prefix, prefix, viewset,
base_name=None, parent_lookup_name=None,
depth_level=1
):
"""
Register a nested viewset wihtout worrying of instantiate a nested
router for registry.
"""
kwargs = {
'trailing_slash'... | python | def register_nested(
self, parent_prefix, prefix, viewset,
base_name=None, parent_lookup_name=None,
depth_level=1
):
"""
Register a nested viewset wihtout worrying of instantiate a nested
router for registry.
"""
kwargs = {
'trailing_slash'... | [
"def",
"register_nested",
"(",
"self",
",",
"parent_prefix",
",",
"prefix",
",",
"viewset",
",",
"base_name",
"=",
"None",
",",
"parent_lookup_name",
"=",
"None",
",",
"depth_level",
"=",
"1",
")",
":",
"kwargs",
"=",
"{",
"'trailing_slash'",
":",
"bool",
... | Register a nested viewset wihtout worrying of instantiate a nested
router for registry. | [
"Register",
"a",
"nested",
"viewset",
"wihtout",
"worrying",
"of",
"instantiate",
"a",
"nested",
"router",
"for",
"registry",
"."
] | 1869b13f9341bfcebd931059e93de2bc38570da3 | https://github.com/devricks/soft_drf/blob/1869b13f9341bfcebd931059e93de2bc38570da3/soft_drf/api/routers/__init__.py#L36-L78 |
249,615 | devricks/soft_drf | soft_drf/api/routers/__init__.py | DefaultRouter.get_urls | def get_urls(self):
"""
Generate the list of URL patterns including the registered single
object routers urls.
"""
base_urls = super(SimpleRouter, self).get_urls()
single_urls = sum([r.urls for r in self._single_object_registry], [])
nested_urls = sum([r.urls for ... | python | def get_urls(self):
"""
Generate the list of URL patterns including the registered single
object routers urls.
"""
base_urls = super(SimpleRouter, self).get_urls()
single_urls = sum([r.urls for r in self._single_object_registry], [])
nested_urls = sum([r.urls for ... | [
"def",
"get_urls",
"(",
"self",
")",
":",
"base_urls",
"=",
"super",
"(",
"SimpleRouter",
",",
"self",
")",
".",
"get_urls",
"(",
")",
"single_urls",
"=",
"sum",
"(",
"[",
"r",
".",
"urls",
"for",
"r",
"in",
"self",
".",
"_single_object_registry",
"]",... | Generate the list of URL patterns including the registered single
object routers urls. | [
"Generate",
"the",
"list",
"of",
"URL",
"patterns",
"including",
"the",
"registered",
"single",
"object",
"routers",
"urls",
"."
] | 1869b13f9341bfcebd931059e93de2bc38570da3 | https://github.com/devricks/soft_drf/blob/1869b13f9341bfcebd931059e93de2bc38570da3/soft_drf/api/routers/__init__.py#L80-L89 |
249,616 | DoWhileGeek/authentise-services | authentise_services/config.py | Config.parse_config | def parse_config(path):
"""parse either the config file we found, or use some canned defaults"""
config = configparser.ConfigParser()
if path: # if user has config with user creds in it, this will grab it
config.read(path)
try:
return {k: v for k, v in config["... | python | def parse_config(path):
"""parse either the config file we found, or use some canned defaults"""
config = configparser.ConfigParser()
if path: # if user has config with user creds in it, this will grab it
config.read(path)
try:
return {k: v for k, v in config["... | [
"def",
"parse_config",
"(",
"path",
")",
":",
"config",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"if",
"path",
":",
"# if user has config with user creds in it, this will grab it",
"config",
".",
"read",
"(",
"path",
")",
"try",
":",
"return",
"{",
"k... | parse either the config file we found, or use some canned defaults | [
"parse",
"either",
"the",
"config",
"file",
"we",
"found",
"or",
"use",
"some",
"canned",
"defaults"
] | ee32bd7f7de15d3fb24c0a6374640d3a1ec8096d | https://github.com/DoWhileGeek/authentise-services/blob/ee32bd7f7de15d3fb24c0a6374640d3a1ec8096d/authentise_services/config.py#L25-L35 |
249,617 | b3j0f/utils | b3j0f/utils/path.py | lookup | def lookup(path, cache=True, scope=None, safe=False):
"""Get element reference from input element.
The element can be a builtin/globals/scope object or is resolved from the
current execution stack.
:limitations: it does not resolve class methods or static values such as
True, False, numbers, s... | python | def lookup(path, cache=True, scope=None, safe=False):
"""Get element reference from input element.
The element can be a builtin/globals/scope object or is resolved from the
current execution stack.
:limitations: it does not resolve class methods or static values such as
True, False, numbers, s... | [
"def",
"lookup",
"(",
"path",
",",
"cache",
"=",
"True",
",",
"scope",
"=",
"None",
",",
"safe",
"=",
"False",
")",
":",
"result",
"=",
"None",
"found",
"=",
"path",
"and",
"cache",
"and",
"path",
"in",
"__LOOKUP_CACHE",
"if",
"found",
":",
"result",... | Get element reference from input element.
The element can be a builtin/globals/scope object or is resolved from the
current execution stack.
:limitations: it does not resolve class methods or static values such as
True, False, numbers, string and keywords.
:param str path: full path to a pytho... | [
"Get",
"element",
"reference",
"from",
"input",
"element",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/path.py#L100-L211 |
249,618 | b3j0f/utils | b3j0f/utils/path.py | getpath | def getpath(element):
"""Get full path of a given element such as the opposite of the
resolve_path behaviour.
:param element: must be directly defined into a module or a package and has
the attribute '__name__'.
:return: element absolute path.
:rtype: str
:raises AttributeError: if el... | python | def getpath(element):
"""Get full path of a given element such as the opposite of the
resolve_path behaviour.
:param element: must be directly defined into a module or a package and has
the attribute '__name__'.
:return: element absolute path.
:rtype: str
:raises AttributeError: if el... | [
"def",
"getpath",
"(",
"element",
")",
":",
"if",
"not",
"hasattr",
"(",
"element",
",",
"'__name__'",
")",
":",
"raise",
"AttributeError",
"(",
"'element {0} must have the attribute __name__'",
".",
"format",
"(",
"element",
")",
")",
"result",
"=",
"element",
... | Get full path of a given element such as the opposite of the
resolve_path behaviour.
:param element: must be directly defined into a module or a package and has
the attribute '__name__'.
:return: element absolute path.
:rtype: str
:raises AttributeError: if element has not the attribute _... | [
"Get",
"full",
"path",
"of",
"a",
"given",
"element",
"such",
"as",
"the",
"opposite",
"of",
"the",
"resolve_path",
"behaviour",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/path.py#L214-L240 |
249,619 | bbiskup/purkinje-messages | purkinje_messages/message.py | register_eventclass | def register_eventclass(event_id):
"""Decorator for registering event classes for parsing
"""
def register(cls):
if not issubclass(cls, Event):
raise MessageException(('Cannot register a class that'
' is not a subclass of Event'))
EVENT_REGISTR... | python | def register_eventclass(event_id):
"""Decorator for registering event classes for parsing
"""
def register(cls):
if not issubclass(cls, Event):
raise MessageException(('Cannot register a class that'
' is not a subclass of Event'))
EVENT_REGISTR... | [
"def",
"register_eventclass",
"(",
"event_id",
")",
":",
"def",
"register",
"(",
"cls",
")",
":",
"if",
"not",
"issubclass",
"(",
"cls",
",",
"Event",
")",
":",
"raise",
"MessageException",
"(",
"(",
"'Cannot register a class that'",
"' is not a subclass of Event'... | Decorator for registering event classes for parsing | [
"Decorator",
"for",
"registering",
"event",
"classes",
"for",
"parsing"
] | ba4217d993a86fd882bcf73d206d2910e65316dd | https://github.com/bbiskup/purkinje-messages/blob/ba4217d993a86fd882bcf73d206d2910e65316dd/purkinje_messages/message.py#L141-L152 |
249,620 | stevepeak/inquiry | inquiry/helpers.py | json_minify | def json_minify(string, strip_space=True): # pragma: no cover
"""Removes whitespace from json strings, returning the string
"""
in_string = False
in_multi = False
in_single = False
new_str = []
index = 0
for match in re.finditer(TOKENIZER, string):
if not (in_multi or in_singl... | python | def json_minify(string, strip_space=True): # pragma: no cover
"""Removes whitespace from json strings, returning the string
"""
in_string = False
in_multi = False
in_single = False
new_str = []
index = 0
for match in re.finditer(TOKENIZER, string):
if not (in_multi or in_singl... | [
"def",
"json_minify",
"(",
"string",
",",
"strip_space",
"=",
"True",
")",
":",
"# pragma: no cover",
"in_string",
"=",
"False",
"in_multi",
"=",
"False",
"in_single",
"=",
"False",
"new_str",
"=",
"[",
"]",
"index",
"=",
"0",
"for",
"match",
"in",
"re",
... | Removes whitespace from json strings, returning the string | [
"Removes",
"whitespace",
"from",
"json",
"strings",
"returning",
"the",
"string"
] | f6ea435c302560ba19985b5d4ce2c97e2f321508 | https://github.com/stevepeak/inquiry/blob/f6ea435c302560ba19985b5d4ce2c97e2f321508/inquiry/helpers.py#L110-L152 |
249,621 | alexlovelltroy/django-classy-mail | classy_mail/mixins/base.py | resolve_template | def resolve_template(template):
"Accepts a template object, path-to-template or list of paths"
if isinstance(template, (list, tuple)):
return loader.select_template(template)
elif isinstance(template, basestring):
try:
return loader.get_template(template)
except TemplateD... | python | def resolve_template(template):
"Accepts a template object, path-to-template or list of paths"
if isinstance(template, (list, tuple)):
return loader.select_template(template)
elif isinstance(template, basestring):
try:
return loader.get_template(template)
except TemplateD... | [
"def",
"resolve_template",
"(",
"template",
")",
":",
"if",
"isinstance",
"(",
"template",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"loader",
".",
"select_template",
"(",
"template",
")",
"elif",
"isinstance",
"(",
"template",
",",
"basestr... | Accepts a template object, path-to-template or list of paths | [
"Accepts",
"a",
"template",
"object",
"path",
"-",
"to",
"-",
"template",
"or",
"list",
"of",
"paths"
] | 1f225555bce44d8dbc4c695a4b7ffc71ac500168 | https://github.com/alexlovelltroy/django-classy-mail/blob/1f225555bce44d8dbc4c695a4b7ffc71ac500168/classy_mail/mixins/base.py#L6-L16 |
249,622 | brentpayne/kennyg | kennyg/element.py | DateValue.value | def value(self, value, *args, **kwargs):
"""
Takes a string value and returns the Date based on the format
"""
from datetime import datetime
value = self.obj.value(value, *args, **kwargs)
try:
rv = datetime.strptime(value, self.format)
except ValueErro... | python | def value(self, value, *args, **kwargs):
"""
Takes a string value and returns the Date based on the format
"""
from datetime import datetime
value = self.obj.value(value, *args, **kwargs)
try:
rv = datetime.strptime(value, self.format)
except ValueErro... | [
"def",
"value",
"(",
"self",
",",
"value",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"datetime",
"import",
"datetime",
"value",
"=",
"self",
".",
"obj",
".",
"value",
"(",
"value",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"... | Takes a string value and returns the Date based on the format | [
"Takes",
"a",
"string",
"value",
"and",
"returns",
"the",
"Date",
"based",
"on",
"the",
"format"
] | c688dd6d270bb7dcdcce7f08c54eafb1bf3232f2 | https://github.com/brentpayne/kennyg/blob/c688dd6d270bb7dcdcce7f08c54eafb1bf3232f2/kennyg/element.py#L123-L133 |
249,623 | klmitch/framer | framer/transport.py | FramerAdaptor._interpret_framer | def _interpret_framer(self, args, kwargs):
"""
Interprets positional and keyword arguments related to
framers.
:param args: A tuple of positional arguments. The first such
argument will be interpreted as a framer object,
and the second will be ... | python | def _interpret_framer(self, args, kwargs):
"""
Interprets positional and keyword arguments related to
framers.
:param args: A tuple of positional arguments. The first such
argument will be interpreted as a framer object,
and the second will be ... | [
"def",
"_interpret_framer",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"# Cannot specify both positional and keyword arguments, but",
"# must provide one or the other",
"if",
"not",
"args",
"and",
"not",
"kwargs",
":",
"raise",
"exc",
".",
"InvalidFramerSpecificat... | Interprets positional and keyword arguments related to
framers.
:param args: A tuple of positional arguments. The first such
argument will be interpreted as a framer object,
and the second will be interpreted as a framer
state.
:pa... | [
"Interprets",
"positional",
"and",
"keyword",
"arguments",
"related",
"to",
"framers",
"."
] | bd34cee9737793dab61d1d8973930b64bd08acb4 | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/transport.py#L131-L210 |
249,624 | klmitch/framer | framer/transport.py | FramerAdaptor.connection_made | def connection_made(self, transport):
"""
Called by the underlying transport when a connection is made.
:param transport: The transport representing the connection.
"""
# Save the underlying transport
self._transport = transport
# Call connection_made() on the ... | python | def connection_made(self, transport):
"""
Called by the underlying transport when a connection is made.
:param transport: The transport representing the connection.
"""
# Save the underlying transport
self._transport = transport
# Call connection_made() on the ... | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
")",
":",
"# Save the underlying transport",
"self",
".",
"_transport",
"=",
"transport",
"# Call connection_made() on the client protocol, passing",
"# ourself as the transport",
"self",
".",
"_client",
".",
"connectio... | Called by the underlying transport when a connection is made.
:param transport: The transport representing the connection. | [
"Called",
"by",
"the",
"underlying",
"transport",
"when",
"a",
"connection",
"is",
"made",
"."
] | bd34cee9737793dab61d1d8973930b64bd08acb4 | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/transport.py#L212-L224 |
249,625 | klmitch/framer | framer/transport.py | FramerAdaptor.data_received | def data_received(self, data):
"""
Called by the underlying transport when data is received.
:param data: The data received on the connection.
"""
# First, add the data to the receive buffer
self._recv_buf += data
# Now, pass all frames we can find to the clien... | python | def data_received(self, data):
"""
Called by the underlying transport when data is received.
:param data: The data received on the connection.
"""
# First, add the data to the receive buffer
self._recv_buf += data
# Now, pass all frames we can find to the clien... | [
"def",
"data_received",
"(",
"self",
",",
"data",
")",
":",
"# First, add the data to the receive buffer",
"self",
".",
"_recv_buf",
"+=",
"data",
"# Now, pass all frames we can find to the client protocol",
"while",
"self",
".",
"_recv_buf",
"and",
"not",
"self",
".",
... | Called by the underlying transport when data is received.
:param data: The data received on the connection. | [
"Called",
"by",
"the",
"underlying",
"transport",
"when",
"data",
"is",
"received",
"."
] | bd34cee9737793dab61d1d8973930b64bd08acb4 | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/transport.py#L257-L278 |
249,626 | klmitch/framer | framer/transport.py | FramerAdaptor.get_extra_info | def get_extra_info(self, name, default=None):
"""
Called by the client protocol to return optional transport
information. Information requests not recognized by the
``FramerProtocol`` are passed on to the underlying transport.
The values of ``name`` recognized directly by
... | python | def get_extra_info(self, name, default=None):
"""
Called by the client protocol to return optional transport
information. Information requests not recognized by the
``FramerProtocol`` are passed on to the underlying transport.
The values of ``name`` recognized directly by
... | [
"def",
"get_extra_info",
"(",
"self",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"# Handle data we know about",
"if",
"name",
"in",
"self",
".",
"_handlers",
":",
"return",
"self",
".",
"_handlers",
"[",
"name",
"]",
"(",
"self",
")",
"# Call get_... | Called by the client protocol to return optional transport
information. Information requests not recognized by the
``FramerProtocol`` are passed on to the underlying transport.
The values of ``name`` recognized directly by
``FramerProtocol`` are:
=============== =============... | [
"Called",
"by",
"the",
"client",
"protocol",
"to",
"return",
"optional",
"transport",
"information",
".",
"Information",
"requests",
"not",
"recognized",
"by",
"the",
"FramerProtocol",
"are",
"passed",
"on",
"to",
"the",
"underlying",
"transport",
"."
] | bd34cee9737793dab61d1d8973930b64bd08acb4 | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/transport.py#L307-L342 |
249,627 | klmitch/framer | framer/transport.py | FramerAdaptor.set_write_buffer_limits | def set_write_buffer_limits(self, high=None, low=None):
"""
Called by the client protocol to set the high- and low-water
limits for write flow control.
These two values control when call the protocol's
``pause_writing()`` and ``resume_writing()`` methods are
called.
... | python | def set_write_buffer_limits(self, high=None, low=None):
"""
Called by the client protocol to set the high- and low-water
limits for write flow control.
These two values control when call the protocol's
``pause_writing()`` and ``resume_writing()`` methods are
called.
... | [
"def",
"set_write_buffer_limits",
"(",
"self",
",",
"high",
"=",
"None",
",",
"low",
"=",
"None",
")",
":",
"# Call set_write_buffer_limits() on the transport",
"self",
".",
"_transport",
".",
"set_write_buffer_limits",
"(",
"high",
"=",
"high",
",",
"low",
"=",
... | Called by the client protocol to set the high- and low-water
limits for write flow control.
These two values control when call the protocol's
``pause_writing()`` and ``resume_writing()`` methods are
called.
:param high: The high-water limit. Must be a non-negative
... | [
"Called",
"by",
"the",
"client",
"protocol",
"to",
"set",
"the",
"high",
"-",
"and",
"low",
"-",
"water",
"limits",
"for",
"write",
"flow",
"control",
"."
] | bd34cee9737793dab61d1d8973930b64bd08acb4 | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/transport.py#L413-L433 |
249,628 | klmitch/framer | framer/transport.py | FramerAdaptor.send_frame | def send_frame(self, frame):
"""
Called by the client protocol to send a frame to the remote
peer. This method does not block; it buffers the data and
arranges for it to be sent out asynchronously.
:param frame: The frame to send to the peer. Must be in the
... | python | def send_frame(self, frame):
"""
Called by the client protocol to send a frame to the remote
peer. This method does not block; it buffers the data and
arranges for it to be sent out asynchronously.
:param frame: The frame to send to the peer. Must be in the
... | [
"def",
"send_frame",
"(",
"self",
",",
"frame",
")",
":",
"# Convert the frame to bytes and write them to the connection",
"data",
"=",
"self",
".",
"_send_framer",
".",
"to_bytes",
"(",
"frame",
",",
"self",
".",
"_send_state",
")",
"self",
".",
"_transport",
"."... | Called by the client protocol to send a frame to the remote
peer. This method does not block; it buffers the data and
arranges for it to be sent out asynchronously.
:param frame: The frame to send to the peer. Must be in the
format expected by the currently active send
... | [
"Called",
"by",
"the",
"client",
"protocol",
"to",
"send",
"a",
"frame",
"to",
"the",
"remote",
"peer",
".",
"This",
"method",
"does",
"not",
"block",
";",
"it",
"buffers",
"the",
"data",
"and",
"arranges",
"for",
"it",
"to",
"be",
"sent",
"out",
"asyn... | bd34cee9737793dab61d1d8973930b64bd08acb4 | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/transport.py#L447-L460 |
249,629 | exekias/droplet | droplet/web/menus.py | menu | def menu():
"""
Return global menu composed from all modules menu.
This method will compose the global menu by calling menu() function for
module, it should be located under module_path.menu module
"""
root = MenuItem('')
for mod in droplet.modules():
if mod.installed:
... | python | def menu():
"""
Return global menu composed from all modules menu.
This method will compose the global menu by calling menu() function for
module, it should be located under module_path.menu module
"""
root = MenuItem('')
for mod in droplet.modules():
if mod.installed:
... | [
"def",
"menu",
"(",
")",
":",
"root",
"=",
"MenuItem",
"(",
"''",
")",
"for",
"mod",
"in",
"droplet",
".",
"modules",
"(",
")",
":",
"if",
"mod",
".",
"installed",
":",
"module_path",
"=",
"mod",
".",
"__class__",
".",
"__module__",
".",
"rsplit",
... | Return global menu composed from all modules menu.
This method will compose the global menu by calling menu() function for
module, it should be located under module_path.menu module | [
"Return",
"global",
"menu",
"composed",
"from",
"all",
"modules",
"menu",
"."
] | aeac573a2c1c4b774e99d5414a1c79b1bb734941 | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/web/menus.py#L56-L72 |
249,630 | exekias/droplet | droplet/web/menus.py | MenuItem.append | def append(self, item):
"""
Add the given item as children
"""
if self.url:
raise TypeError('Menu items with URL cannot have childrens')
# Look for already present common node
if not item.is_leaf():
for current_item in self.items:
... | python | def append(self, item):
"""
Add the given item as children
"""
if self.url:
raise TypeError('Menu items with URL cannot have childrens')
# Look for already present common node
if not item.is_leaf():
for current_item in self.items:
... | [
"def",
"append",
"(",
"self",
",",
"item",
")",
":",
"if",
"self",
".",
"url",
":",
"raise",
"TypeError",
"(",
"'Menu items with URL cannot have childrens'",
")",
"# Look for already present common node",
"if",
"not",
"item",
".",
"is_leaf",
"(",
")",
":",
"for"... | Add the given item as children | [
"Add",
"the",
"given",
"item",
"as",
"children"
] | aeac573a2c1c4b774e99d5414a1c79b1bb734941 | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/web/menus.py#L34-L50 |
249,631 | ardydedase/pycouchbase | pycouchbase/document.py | Document.doc_id | def doc_id(self):
"""Returns the couchbase document's id, object property.
:returns: The document id (that is created from :attr:'doc_type' and
:attr:'__key_field__' value, or auto-hashed document id at first
saving).
:rtype: unicode
"""
if self.id:
... | python | def doc_id(self):
"""Returns the couchbase document's id, object property.
:returns: The document id (that is created from :attr:'doc_type' and
:attr:'__key_field__' value, or auto-hashed document id at first
saving).
:rtype: unicode
"""
if self.id:
... | [
"def",
"doc_id",
"(",
"self",
")",
":",
"if",
"self",
".",
"id",
":",
"return",
"'%s_%s'",
"%",
"(",
"self",
".",
"doc_type",
",",
"self",
".",
"id",
".",
"lower",
"(",
")",
")",
"return",
"self",
".",
"_hashed_key"
] | Returns the couchbase document's id, object property.
:returns: The document id (that is created from :attr:'doc_type' and
:attr:'__key_field__' value, or auto-hashed document id at first
saving).
:rtype: unicode | [
"Returns",
"the",
"couchbase",
"document",
"s",
"id",
"object",
"property",
"."
] | 6f010b4d2ef41aead2366878d0cf0b1284c0db0e | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/pycouchbase/document.py#L97-L107 |
249,632 | ardydedase/pycouchbase | pycouchbase/document.py | Document.touch | def touch(self, expiration):
"""Updates the current document's expiration value.
:param expiration: Expiration in seconds for the document to be removed by
couchbase server, defaults to 0 - will never expire.
:type expiration: int
:returns: Response from CouchbaseClient.
... | python | def touch(self, expiration):
"""Updates the current document's expiration value.
:param expiration: Expiration in seconds for the document to be removed by
couchbase server, defaults to 0 - will never expire.
:type expiration: int
:returns: Response from CouchbaseClient.
... | [
"def",
"touch",
"(",
"self",
",",
"expiration",
")",
":",
"if",
"not",
"self",
".",
"cas_value",
"or",
"not",
"self",
".",
"doc_id",
":",
"raise",
"self",
".",
"DoesNotExist",
"(",
"self",
")",
"return",
"self",
".",
"bucket",
".",
"touch",
"(",
"sel... | Updates the current document's expiration value.
:param expiration: Expiration in seconds for the document to be removed by
couchbase server, defaults to 0 - will never expire.
:type expiration: int
:returns: Response from CouchbaseClient.
:rtype: unicode
:raises: :e... | [
"Updates",
"the",
"current",
"document",
"s",
"expiration",
"value",
"."
] | 6f010b4d2ef41aead2366878d0cf0b1284c0db0e | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/pycouchbase/document.py#L245-L258 |
249,633 | vecnet/vecnet.simulation | vecnet/simulation/sim_status.py | get_description | def get_description(status_code):
"""
Get the description for a status code.
"""
description = _descriptions.get(status_code)
if description is None:
description = 'code = %s (no description)' % str(status_code)
return description | python | def get_description(status_code):
"""
Get the description for a status code.
"""
description = _descriptions.get(status_code)
if description is None:
description = 'code = %s (no description)' % str(status_code)
return description | [
"def",
"get_description",
"(",
"status_code",
")",
":",
"description",
"=",
"_descriptions",
".",
"get",
"(",
"status_code",
")",
"if",
"description",
"is",
"None",
":",
"description",
"=",
"'code = %s (no description)'",
"%",
"str",
"(",
"status_code",
")",
"re... | Get the description for a status code. | [
"Get",
"the",
"description",
"for",
"a",
"status",
"code",
"."
] | 3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e | https://github.com/vecnet/vecnet.simulation/blob/3a4b3df7b12418c6fa8a7d9cd49656a1c031fc0e/vecnet/simulation/sim_status.py#L47-L54 |
249,634 | emilssolmanis/tapes | tapes/meta.py | metered_meta | def metered_meta(metrics, base=type):
"""Creates a metaclass that will add the specified metrics at a path parametrized on the dynamic class name.
Prime use case is for base classes if all subclasses need separate metrics and / or the metrics need to be
used in base class methods, e.g., Tornado's ``Request... | python | def metered_meta(metrics, base=type):
"""Creates a metaclass that will add the specified metrics at a path parametrized on the dynamic class name.
Prime use case is for base classes if all subclasses need separate metrics and / or the metrics need to be
used in base class methods, e.g., Tornado's ``Request... | [
"def",
"metered_meta",
"(",
"metrics",
",",
"base",
"=",
"type",
")",
":",
"class",
"_MeteredMeta",
"(",
"base",
")",
":",
"def",
"__new__",
"(",
"meta",
",",
"name",
",",
"bases",
",",
"dict_",
")",
":",
"new_dict",
"=",
"dict",
"(",
"*",
"*",
"di... | Creates a metaclass that will add the specified metrics at a path parametrized on the dynamic class name.
Prime use case is for base classes if all subclasses need separate metrics and / or the metrics need to be
used in base class methods, e.g., Tornado's ``RequestHandler`` like::
import tapes
... | [
"Creates",
"a",
"metaclass",
"that",
"will",
"add",
"the",
"specified",
"metrics",
"at",
"a",
"path",
"parametrized",
"on",
"the",
"dynamic",
"class",
"name",
"."
] | 7797fc9ebcb359cb1ba5085570e3cab5ebcd1d3c | https://github.com/emilssolmanis/tapes/blob/7797fc9ebcb359cb1ba5085570e3cab5ebcd1d3c/tapes/meta.py#L1-L57 |
249,635 | KnowledgeLinks/rdfframework | rdfframework/search/elasticsearchbase.py | EsBase.make_action_list | def make_action_list(self, item_list, **kwargs):
''' Generates a list of actions for sending to Elasticsearch '''
action_list = []
es_index = get2(kwargs, "es_index", self.es_index)
action_type = kwargs.get("action_type","index")
action_settings = {'_op_type': action_type,... | python | def make_action_list(self, item_list, **kwargs):
''' Generates a list of actions for sending to Elasticsearch '''
action_list = []
es_index = get2(kwargs, "es_index", self.es_index)
action_type = kwargs.get("action_type","index")
action_settings = {'_op_type': action_type,... | [
"def",
"make_action_list",
"(",
"self",
",",
"item_list",
",",
"*",
"*",
"kwargs",
")",
":",
"action_list",
"=",
"[",
"]",
"es_index",
"=",
"get2",
"(",
"kwargs",
",",
"\"es_index\"",
",",
"self",
".",
"es_index",
")",
"action_type",
"=",
"kwargs",
".",
... | Generates a list of actions for sending to Elasticsearch | [
"Generates",
"a",
"list",
"of",
"actions",
"for",
"sending",
"to",
"Elasticsearch"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/elasticsearchbase.py#L45-L63 |
249,636 | KnowledgeLinks/rdfframework | rdfframework/search/elasticsearchbase.py | EsBase.bulk_save | def bulk_save(self, action_list, **kwargs):
''' sends a passed in action_list to elasticsearch '''
lg = logging.getLogger("%s.%s" % (self.ln, inspect.stack()[0][3]))
lg.setLevel(self.log_level)
err_log = logging.getLogger("index.errors")
es = self.es
es_index = ge... | python | def bulk_save(self, action_list, **kwargs):
''' sends a passed in action_list to elasticsearch '''
lg = logging.getLogger("%s.%s" % (self.ln, inspect.stack()[0][3]))
lg.setLevel(self.log_level)
err_log = logging.getLogger("index.errors")
es = self.es
es_index = ge... | [
"def",
"bulk_save",
"(",
"self",
",",
"action_list",
",",
"*",
"*",
"kwargs",
")",
":",
"lg",
"=",
"logging",
".",
"getLogger",
"(",
"\"%s.%s\"",
"%",
"(",
"self",
".",
"ln",
",",
"inspect",
".",
"stack",
"(",
")",
"[",
"0",
"]",
"[",
"3",
"]",
... | sends a passed in action_list to elasticsearch | [
"sends",
"a",
"passed",
"in",
"action_list",
"to",
"elasticsearch"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/elasticsearchbase.py#L65-L101 |
249,637 | KnowledgeLinks/rdfframework | rdfframework/search/elasticsearchbase.py | EsBase.get_list | def get_list(self, method="list", **kwargs):
""" returns a key value list of items based on the specfied criteria
"""
lg = logging.getLogger("%s.%s" % (self.ln, inspect.stack()[0][3]))
lg.setLevel(self.log_level)
args = inspect.getargvalues(inspect.currentframe())[3]
... | python | def get_list(self, method="list", **kwargs):
""" returns a key value list of items based on the specfied criteria
"""
lg = logging.getLogger("%s.%s" % (self.ln, inspect.stack()[0][3]))
lg.setLevel(self.log_level)
args = inspect.getargvalues(inspect.currentframe())[3]
... | [
"def",
"get_list",
"(",
"self",
",",
"method",
"=",
"\"list\"",
",",
"*",
"*",
"kwargs",
")",
":",
"lg",
"=",
"logging",
".",
"getLogger",
"(",
"\"%s.%s\"",
"%",
"(",
"self",
".",
"ln",
",",
"inspect",
".",
"stack",
"(",
")",
"[",
"0",
"]",
"[",
... | returns a key value list of items based on the specfied criteria | [
"returns",
"a",
"key",
"value",
"list",
"of",
"items",
"based",
"on",
"the",
"specfied",
"criteria"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/elasticsearchbase.py#L227-L311 |
249,638 | cirruscluster/cirruscluster | cirruscluster/cluster/ec2cluster.py | Ec2Cluster.authorize_role | def authorize_role(self, role, protocol, from_port, to_port, cidr_ip):
"""
Authorize access to machines in a given role from a given network.
"""
if (protocol != 'tcp' and protocol != 'udp'):
raise RuntimeError('error: expected protocol to be tcp or udp '\
'but got %s' % (... | python | def authorize_role(self, role, protocol, from_port, to_port, cidr_ip):
"""
Authorize access to machines in a given role from a given network.
"""
if (protocol != 'tcp' and protocol != 'udp'):
raise RuntimeError('error: expected protocol to be tcp or udp '\
'but got %s' % (... | [
"def",
"authorize_role",
"(",
"self",
",",
"role",
",",
"protocol",
",",
"from_port",
",",
"to_port",
",",
"cidr_ip",
")",
":",
"if",
"(",
"protocol",
"!=",
"'tcp'",
"and",
"protocol",
"!=",
"'udp'",
")",
":",
"raise",
"RuntimeError",
"(",
"'error: expecte... | Authorize access to machines in a given role from a given network. | [
"Authorize",
"access",
"to",
"machines",
"in",
"a",
"given",
"role",
"from",
"a",
"given",
"network",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/ec2cluster.py#L83-L102 |
249,639 | cirruscluster/cirruscluster | cirruscluster/cluster/ec2cluster.py | Ec2Cluster.check_running | def check_running(self, role, number):
"""
Check that a certain number of instances in a role are running.
"""
instances = self.get_instances_in_role(role, "running")
if len(instances) != number:
print "Expected %s instances in role %s, but was %s %s" % \
(number, role, len(instances),... | python | def check_running(self, role, number):
"""
Check that a certain number of instances in a role are running.
"""
instances = self.get_instances_in_role(role, "running")
if len(instances) != number:
print "Expected %s instances in role %s, but was %s %s" % \
(number, role, len(instances),... | [
"def",
"check_running",
"(",
"self",
",",
"role",
",",
"number",
")",
":",
"instances",
"=",
"self",
".",
"get_instances_in_role",
"(",
"role",
",",
"\"running\"",
")",
"if",
"len",
"(",
"instances",
")",
"!=",
"number",
":",
"print",
"\"Expected %s instance... | Check that a certain number of instances in a role are running. | [
"Check",
"that",
"a",
"certain",
"number",
"of",
"instances",
"in",
"a",
"role",
"are",
"running",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/ec2cluster.py#L104-L114 |
249,640 | cirruscluster/cirruscluster | cirruscluster/cluster/ec2cluster.py | Ec2Cluster.get_instances_in_role | def get_instances_in_role(self, role, state_filter=None):
"""
Get all the instances in a role, filtered by state.
@param role: the name of the role
@param state_filter: the state that the instance should be in
(e.g. "running"), or None for all states
"""
self._check_role_name(role)
in... | python | def get_instances_in_role(self, role, state_filter=None):
"""
Get all the instances in a role, filtered by state.
@param role: the name of the role
@param state_filter: the state that the instance should be in
(e.g. "running"), or None for all states
"""
self._check_role_name(role)
in... | [
"def",
"get_instances_in_role",
"(",
"self",
",",
"role",
",",
"state_filter",
"=",
"None",
")",
":",
"self",
".",
"_check_role_name",
"(",
"role",
")",
"instances",
"=",
"[",
"]",
"for",
"instance",
"in",
"self",
".",
"_get_instances",
"(",
"self",
".",
... | Get all the instances in a role, filtered by state.
@param role: the name of the role
@param state_filter: the state that the instance should be in
(e.g. "running"), or None for all states | [
"Get",
"all",
"the",
"instances",
"in",
"a",
"role",
"filtered",
"by",
"state",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/ec2cluster.py#L116-L133 |
249,641 | cirruscluster/cirruscluster | cirruscluster/cluster/ec2cluster.py | Ec2Cluster.get_instances | def get_instances(self, state_filter=None):
"""
Get all the instances filtered by state.
@param state_filter: the state that the instance should be in
(e.g. "running"), or None for all states
"""
instances = []
for instance in self._get_instances(self._get_cluster_group_name(),
... | python | def get_instances(self, state_filter=None):
"""
Get all the instances filtered by state.
@param state_filter: the state that the instance should be in
(e.g. "running"), or None for all states
"""
instances = []
for instance in self._get_instances(self._get_cluster_group_name(),
... | [
"def",
"get_instances",
"(",
"self",
",",
"state_filter",
"=",
"None",
")",
":",
"instances",
"=",
"[",
"]",
"for",
"instance",
"in",
"self",
".",
"_get_instances",
"(",
"self",
".",
"_get_cluster_group_name",
"(",
")",
",",
"state_filter",
")",
":",
"inst... | Get all the instances filtered by state.
@param state_filter: the state that the instance should be in
(e.g. "running"), or None for all states | [
"Get",
"all",
"the",
"instances",
"filtered",
"by",
"state",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/ec2cluster.py#L135-L149 |
249,642 | cirruscluster/cirruscluster | cirruscluster/cluster/ec2cluster.py | Ec2Cluster.print_status | def print_status(self, roles=None, state_filter="running"):
"""
Print the status of instances in the given roles, filtered by state.
"""
if not roles:
for instance in self._get_instances(self._get_cluster_group_name(),
state_filter):
self._print_in... | python | def print_status(self, roles=None, state_filter="running"):
"""
Print the status of instances in the given roles, filtered by state.
"""
if not roles:
for instance in self._get_instances(self._get_cluster_group_name(),
state_filter):
self._print_in... | [
"def",
"print_status",
"(",
"self",
",",
"roles",
"=",
"None",
",",
"state_filter",
"=",
"\"running\"",
")",
":",
"if",
"not",
"roles",
":",
"for",
"instance",
"in",
"self",
".",
"_get_instances",
"(",
"self",
".",
"_get_cluster_group_name",
"(",
")",
",",... | Print the status of instances in the given roles, filtered by state. | [
"Print",
"the",
"status",
"of",
"instances",
"in",
"the",
"given",
"roles",
"filtered",
"by",
"state",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/ec2cluster.py#L151-L163 |
249,643 | cirruscluster/cirruscluster | cirruscluster/cluster/ec2cluster.py | Ec2Cluster.CreateBlockDeviceMap | def CreateBlockDeviceMap(self, image_id, instance_type):
"""
If you launch without specifying a manual device block mapping, you may
not get all the ephemeral devices available to the given instance type.
This will build one that ensures all available ephemeral devices are
mapped.
... | python | def CreateBlockDeviceMap(self, image_id, instance_type):
"""
If you launch without specifying a manual device block mapping, you may
not get all the ephemeral devices available to the given instance type.
This will build one that ensures all available ephemeral devices are
mapped.
... | [
"def",
"CreateBlockDeviceMap",
"(",
"self",
",",
"image_id",
",",
"instance_type",
")",
":",
"# get the block device mapping stored with the image",
"image",
"=",
"self",
".",
"ec2",
".",
"get_image",
"(",
"image_id",
")",
"block_device_map",
"=",
"image",
".",
"blo... | If you launch without specifying a manual device block mapping, you may
not get all the ephemeral devices available to the given instance type.
This will build one that ensures all available ephemeral devices are
mapped. | [
"If",
"you",
"launch",
"without",
"specifying",
"a",
"manual",
"device",
"block",
"mapping",
"you",
"may",
"not",
"get",
"all",
"the",
"ephemeral",
"devices",
"available",
"to",
"the",
"given",
"instance",
"type",
".",
"This",
"will",
"build",
"one",
"that",... | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/ec2cluster.py#L213-L233 |
249,644 | cirruscluster/cirruscluster | cirruscluster/cluster/ec2cluster.py | Ec2Cluster._create_security_groups | def _create_security_groups(self, role):
"""
Create the security groups for a given role, including a group for the
cluster if it doesn't exist.
"""
self._check_role_name(role)
security_group_names = self._get_all_group_names()
cluster_group_name = self._get_cluster_group_name()
if not ... | python | def _create_security_groups(self, role):
"""
Create the security groups for a given role, including a group for the
cluster if it doesn't exist.
"""
self._check_role_name(role)
security_group_names = self._get_all_group_names()
cluster_group_name = self._get_cluster_group_name()
if not ... | [
"def",
"_create_security_groups",
"(",
"self",
",",
"role",
")",
":",
"self",
".",
"_check_role_name",
"(",
"role",
")",
"security_group_names",
"=",
"self",
".",
"_get_all_group_names",
"(",
")",
"cluster_group_name",
"=",
"self",
".",
"_get_cluster_group_name",
... | Create the security groups for a given role, including a group for the
cluster if it doesn't exist. | [
"Create",
"the",
"security",
"groups",
"for",
"a",
"given",
"role",
"including",
"a",
"group",
"for",
"the",
"cluster",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/ec2cluster.py#L468-L492 |
249,645 | cirruscluster/cirruscluster | cirruscluster/cluster/ec2cluster.py | Ec2Cluster._delete_security_groups | def _delete_security_groups(self):
"""
Delete the security groups for each role in the cluster, and the group for
the cluster.
"""
group_names = self._get_all_group_names_for_cluster()
for group in group_names:
self.ec2.delete_security_group(group) | python | def _delete_security_groups(self):
"""
Delete the security groups for each role in the cluster, and the group for
the cluster.
"""
group_names = self._get_all_group_names_for_cluster()
for group in group_names:
self.ec2.delete_security_group(group) | [
"def",
"_delete_security_groups",
"(",
"self",
")",
":",
"group_names",
"=",
"self",
".",
"_get_all_group_names_for_cluster",
"(",
")",
"for",
"group",
"in",
"group_names",
":",
"self",
".",
"ec2",
".",
"delete_security_group",
"(",
"group",
")"
] | Delete the security groups for each role in the cluster, and the group for
the cluster. | [
"Delete",
"the",
"security",
"groups",
"for",
"each",
"role",
"in",
"the",
"cluster",
"and",
"the",
"group",
"for",
"the",
"cluster",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/cluster/ec2cluster.py#L494-L501 |
249,646 | b3j0f/conf | b3j0f/conf/parser/core.py | serialize | def serialize(expr):
"""Serialize input expr into a parsable value.
:rtype: str"""
result = None
if isinstance(expr, string_types):
result = expr
elif expr is not None:
result = '=py:{0}'.format(expr)
return result | python | def serialize(expr):
"""Serialize input expr into a parsable value.
:rtype: str"""
result = None
if isinstance(expr, string_types):
result = expr
elif expr is not None:
result = '=py:{0}'.format(expr)
return result | [
"def",
"serialize",
"(",
"expr",
")",
":",
"result",
"=",
"None",
"if",
"isinstance",
"(",
"expr",
",",
"string_types",
")",
":",
"result",
"=",
"expr",
"elif",
"expr",
"is",
"not",
"None",
":",
"result",
"=",
"'=py:{0}'",
".",
"format",
"(",
"expr",
... | Serialize input expr into a parsable value.
:rtype: str | [
"Serialize",
"input",
"expr",
"into",
"a",
"parsable",
"value",
"."
] | 18dd6d5d6560f9b202793739e2330a2181163511 | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/core.py#L198-L211 |
249,647 | b3j0f/conf | b3j0f/conf/parser/core.py | parse | def parse(
svalue, conf=None, configurable=None, ptype=None,
scope=DEFAULT_SCOPE, safe=DEFAULT_SAFE, besteffort=DEFAULT_BESTEFFORT
):
"""Parser which delegates parsing to expression or format parser."""
result = None
if ptype is None:
ptype = object
compilation = REGEX_EXPR.ma... | python | def parse(
svalue, conf=None, configurable=None, ptype=None,
scope=DEFAULT_SCOPE, safe=DEFAULT_SAFE, besteffort=DEFAULT_BESTEFFORT
):
"""Parser which delegates parsing to expression or format parser."""
result = None
if ptype is None:
ptype = object
compilation = REGEX_EXPR.ma... | [
"def",
"parse",
"(",
"svalue",
",",
"conf",
"=",
"None",
",",
"configurable",
"=",
"None",
",",
"ptype",
"=",
"None",
",",
"scope",
"=",
"DEFAULT_SCOPE",
",",
"safe",
"=",
"DEFAULT_SAFE",
",",
"besteffort",
"=",
"DEFAULT_BESTEFFORT",
")",
":",
"result",
... | Parser which delegates parsing to expression or format parser. | [
"Parser",
"which",
"delegates",
"parsing",
"to",
"expression",
"or",
"format",
"parser",
"."
] | 18dd6d5d6560f9b202793739e2330a2181163511 | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/core.py#L214-L252 |
249,648 | b3j0f/conf | b3j0f/conf/parser/core.py | _exprparser | def _exprparser(
expr, scope, lang=None, conf=None, configurable=None,
safe=DEFAULT_SAFE, besteffort=DEFAULT_BESTEFFORT, tostr=False
):
"""In charge of parsing an expression and return a python object."""
if scope is None:
scope = {}
scope.update({
'configurable': configura... | python | def _exprparser(
expr, scope, lang=None, conf=None, configurable=None,
safe=DEFAULT_SAFE, besteffort=DEFAULT_BESTEFFORT, tostr=False
):
"""In charge of parsing an expression and return a python object."""
if scope is None:
scope = {}
scope.update({
'configurable': configura... | [
"def",
"_exprparser",
"(",
"expr",
",",
"scope",
",",
"lang",
"=",
"None",
",",
"conf",
"=",
"None",
",",
"configurable",
"=",
"None",
",",
"safe",
"=",
"DEFAULT_SAFE",
",",
"besteffort",
"=",
"DEFAULT_BESTEFFORT",
",",
"tostr",
"=",
"False",
")",
":",
... | In charge of parsing an expression and return a python object. | [
"In",
"charge",
"of",
"parsing",
"an",
"expression",
"and",
"return",
"a",
"python",
"object",
"."
] | 18dd6d5d6560f9b202793739e2330a2181163511 | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/core.py#L255-L281 |
249,649 | b3j0f/conf | b3j0f/conf/parser/core.py | _ref | def _ref(
pname, conf=None, configurable=None, cname=None, path=None, history=0
):
"""Resolve a parameter value.
:param Configuration conf: configuration to use.
:param str pname: parameter name.
:param Configurable configurable: configurable.
:param str cname: category name.
:param str... | python | def _ref(
pname, conf=None, configurable=None, cname=None, path=None, history=0
):
"""Resolve a parameter value.
:param Configuration conf: configuration to use.
:param str pname: parameter name.
:param Configurable configurable: configurable.
:param str cname: category name.
:param str... | [
"def",
"_ref",
"(",
"pname",
",",
"conf",
"=",
"None",
",",
"configurable",
"=",
"None",
",",
"cname",
"=",
"None",
",",
"path",
"=",
"None",
",",
"history",
"=",
"0",
")",
":",
"result",
"=",
"None",
"if",
"configurable",
"is",
"not",
"None",
":",... | Resolve a parameter value.
:param Configuration conf: configuration to use.
:param str pname: parameter name.
:param Configurable configurable: configurable.
:param str cname: category name.
:param str path: conf path.
:param int history: parameter history research.
:return: parameter.
... | [
"Resolve",
"a",
"parameter",
"value",
"."
] | 18dd6d5d6560f9b202793739e2330a2181163511 | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/core.py#L385-L422 |
249,650 | dev-platypus/platyutil | python/platyutil/system.py | mount | def mount(dev, mountpoint, flags='', log=None):
'''Mount the given dev to the given mountpoint by using the given flags'''
ensureDirectory(mountpoint)
systemCall('mount %s %s %s' % (flags, dev, mountpoint),
log=log) | python | def mount(dev, mountpoint, flags='', log=None):
'''Mount the given dev to the given mountpoint by using the given flags'''
ensureDirectory(mountpoint)
systemCall('mount %s %s %s' % (flags, dev, mountpoint),
log=log) | [
"def",
"mount",
"(",
"dev",
",",
"mountpoint",
",",
"flags",
"=",
"''",
",",
"log",
"=",
"None",
")",
":",
"ensureDirectory",
"(",
"mountpoint",
")",
"systemCall",
"(",
"'mount %s %s %s'",
"%",
"(",
"flags",
",",
"dev",
",",
"mountpoint",
")",
",",
"lo... | Mount the given dev to the given mountpoint by using the given flags | [
"Mount",
"the",
"given",
"dev",
"to",
"the",
"given",
"mountpoint",
"by",
"using",
"the",
"given",
"flags"
] | 5f3dadbdc2445e71755fb09d6020641c77d13c47 | https://github.com/dev-platypus/platyutil/blob/5f3dadbdc2445e71755fb09d6020641c77d13c47/python/platyutil/system.py#L37-L41 |
249,651 | dev-platypus/platyutil | python/platyutil/system.py | systemCall | def systemCall(cmd, sh=True, log=None):
'''Fancy magic version of os.system'''
if log is None:
log = logging
log.debug('System call [sh:%s]: %s' \
% (sh, cmd))
out = []
proc = None
poller = None
outBuf = ['']
errBuf = ['']
def pollOutput():
'''
... | python | def systemCall(cmd, sh=True, log=None):
'''Fancy magic version of os.system'''
if log is None:
log = logging
log.debug('System call [sh:%s]: %s' \
% (sh, cmd))
out = []
proc = None
poller = None
outBuf = ['']
errBuf = ['']
def pollOutput():
'''
... | [
"def",
"systemCall",
"(",
"cmd",
",",
"sh",
"=",
"True",
",",
"log",
"=",
"None",
")",
":",
"if",
"log",
"is",
"None",
":",
"log",
"=",
"logging",
"log",
".",
"debug",
"(",
"'System call [sh:%s]: %s'",
"%",
"(",
"sh",
",",
"cmd",
")",
")",
"out",
... | Fancy magic version of os.system | [
"Fancy",
"magic",
"version",
"of",
"os",
".",
"system"
] | 5f3dadbdc2445e71755fb09d6020641c77d13c47 | https://github.com/dev-platypus/platyutil/blob/5f3dadbdc2445e71755fb09d6020641c77d13c47/python/platyutil/system.py#L50-L135 |
249,652 | dev-platypus/platyutil | python/platyutil/system.py | chrootedSystemCall | def chrootedSystemCall(chrootDir, cmd, sh=True, mountPseudoFs=True, log=None):
'''Chrooted version of systemCall. Manages necessary pseudo filesystems.'''
if log is None:
log = conduct.app.log
# determine mount points for pseudo fs
proc = path.join(chrootDir, 'proc')
sys = path.join(chrootD... | python | def chrootedSystemCall(chrootDir, cmd, sh=True, mountPseudoFs=True, log=None):
'''Chrooted version of systemCall. Manages necessary pseudo filesystems.'''
if log is None:
log = conduct.app.log
# determine mount points for pseudo fs
proc = path.join(chrootDir, 'proc')
sys = path.join(chrootD... | [
"def",
"chrootedSystemCall",
"(",
"chrootDir",
",",
"cmd",
",",
"sh",
"=",
"True",
",",
"mountPseudoFs",
"=",
"True",
",",
"log",
"=",
"None",
")",
":",
"if",
"log",
"is",
"None",
":",
"log",
"=",
"conduct",
".",
"app",
".",
"log",
"# determine mount p... | Chrooted version of systemCall. Manages necessary pseudo filesystems. | [
"Chrooted",
"version",
"of",
"systemCall",
".",
"Manages",
"necessary",
"pseudo",
"filesystems",
"."
] | 5f3dadbdc2445e71755fb09d6020641c77d13c47 | https://github.com/dev-platypus/platyutil/blob/5f3dadbdc2445e71755fb09d6020641c77d13c47/python/platyutil/system.py#L138-L169 |
249,653 | cogniteev/docido-python-sdk | docido_sdk/core.py | ExtensionPoint.extensions | def extensions(self, component):
"""Return a list of components that declare to implement the
extension point interface.
"""
classes = ComponentMeta._registry.get(self.interface, ())
components = [component.compmgr[cls] for cls in classes]
return [c for c in components if... | python | def extensions(self, component):
"""Return a list of components that declare to implement the
extension point interface.
"""
classes = ComponentMeta._registry.get(self.interface, ())
components = [component.compmgr[cls] for cls in classes]
return [c for c in components if... | [
"def",
"extensions",
"(",
"self",
",",
"component",
")",
":",
"classes",
"=",
"ComponentMeta",
".",
"_registry",
".",
"get",
"(",
"self",
".",
"interface",
",",
"(",
")",
")",
"components",
"=",
"[",
"component",
".",
"compmgr",
"[",
"cls",
"]",
"for",... | Return a list of components that declare to implement the
extension point interface. | [
"Return",
"a",
"list",
"of",
"components",
"that",
"declare",
"to",
"implement",
"the",
"extension",
"point",
"interface",
"."
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/core.py#L30-L36 |
249,654 | cogniteev/docido-python-sdk | docido_sdk/core.py | Component.implements | def implements(*interfaces):
"""Can be used in the class definition of `Component`
subclasses to declare the extension points that are extended.
"""
import sys
frame = sys._getframe(1)
locals_ = frame.f_locals
# Some sanity checks
msg = 'implements() can... | python | def implements(*interfaces):
"""Can be used in the class definition of `Component`
subclasses to declare the extension points that are extended.
"""
import sys
frame = sys._getframe(1)
locals_ = frame.f_locals
# Some sanity checks
msg = 'implements() can... | [
"def",
"implements",
"(",
"*",
"interfaces",
")",
":",
"import",
"sys",
"frame",
"=",
"sys",
".",
"_getframe",
"(",
"1",
")",
"locals_",
"=",
"frame",
".",
"f_locals",
"# Some sanity checks",
"msg",
"=",
"'implements() can only be used in a class definition'",
"as... | Can be used in the class definition of `Component`
subclasses to declare the extension points that are extended. | [
"Can",
"be",
"used",
"in",
"the",
"class",
"definition",
"of",
"Component",
"subclasses",
"to",
"declare",
"the",
"extension",
"points",
"that",
"are",
"extended",
"."
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/core.py#L144-L157 |
249,655 | cogniteev/docido-python-sdk | docido_sdk/core.py | ComponentManager.is_enabled | def is_enabled(self, cls):
"""Return whether the given component class is enabled."""
if cls not in self.enabled:
self.enabled[cls] = self.is_component_enabled(cls)
return self.enabled[cls] | python | def is_enabled(self, cls):
"""Return whether the given component class is enabled."""
if cls not in self.enabled:
self.enabled[cls] = self.is_component_enabled(cls)
return self.enabled[cls] | [
"def",
"is_enabled",
"(",
"self",
",",
"cls",
")",
":",
"if",
"cls",
"not",
"in",
"self",
".",
"enabled",
":",
"self",
".",
"enabled",
"[",
"cls",
"]",
"=",
"self",
".",
"is_component_enabled",
"(",
"cls",
")",
"return",
"self",
".",
"enabled",
"[",
... | Return whether the given component class is enabled. | [
"Return",
"whether",
"the",
"given",
"component",
"class",
"is",
"enabled",
"."
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/core.py#L206-L210 |
249,656 | cogniteev/docido-python-sdk | docido_sdk/core.py | ComponentManager.disable_component | def disable_component(self, component):
"""Force a component to be disabled.
:param component: can be a class or an instance.
"""
if not isinstance(component, type):
component = component.__class__
self.enabled[component] = False
self.components[component] = ... | python | def disable_component(self, component):
"""Force a component to be disabled.
:param component: can be a class or an instance.
"""
if not isinstance(component, type):
component = component.__class__
self.enabled[component] = False
self.components[component] = ... | [
"def",
"disable_component",
"(",
"self",
",",
"component",
")",
":",
"if",
"not",
"isinstance",
"(",
"component",
",",
"type",
")",
":",
"component",
"=",
"component",
".",
"__class__",
"self",
".",
"enabled",
"[",
"component",
"]",
"=",
"False",
"self",
... | Force a component to be disabled.
:param component: can be a class or an instance. | [
"Force",
"a",
"component",
"to",
"be",
"disabled",
"."
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/core.py#L212-L220 |
249,657 | btrevizan/pystrct | pystrct/pystrct.py | StructFile.size | def size(self):
"""Calculate and return the file size in bytes."""
old = self.__file.tell() # old position
self.__file.seek(0, 2) # end of file
n_bytes = self.__file.tell() # file size in bytes
self.__file.seek(old) # back to old position
r... | python | def size(self):
"""Calculate and return the file size in bytes."""
old = self.__file.tell() # old position
self.__file.seek(0, 2) # end of file
n_bytes = self.__file.tell() # file size in bytes
self.__file.seek(old) # back to old position
r... | [
"def",
"size",
"(",
"self",
")",
":",
"old",
"=",
"self",
".",
"__file",
".",
"tell",
"(",
")",
"# old position",
"self",
".",
"__file",
".",
"seek",
"(",
"0",
",",
"2",
")",
"# end of file",
"n_bytes",
"=",
"self",
".",
"__file",
".",
"tell",
"(",... | Calculate and return the file size in bytes. | [
"Calculate",
"and",
"return",
"the",
"file",
"size",
"in",
"bytes",
"."
] | 80e7edaacfbcb191a26ac449f049bbce878c67a3 | https://github.com/btrevizan/pystrct/blob/80e7edaacfbcb191a26ac449f049bbce878c67a3/pystrct/pystrct.py#L33-L42 |
249,658 | btrevizan/pystrct | pystrct/pystrct.py | StructFile.prev | def prev(self, n=1):
"""Get the previous n data from file.
Keyword argument:
n -- number of structs to be retrieved (default 1)
Must be greater than 0.
Return:
A data in the format of obj_fmt, if n = 1. A list of
structs, otherwise.
... | python | def prev(self, n=1):
"""Get the previous n data from file.
Keyword argument:
n -- number of structs to be retrieved (default 1)
Must be greater than 0.
Return:
A data in the format of obj_fmt, if n = 1. A list of
structs, otherwise.
... | [
"def",
"prev",
"(",
"self",
",",
"n",
"=",
"1",
")",
":",
"# Current position - #data",
"i",
"=",
"abs",
"(",
"self",
".",
"tell",
"-",
"n",
")",
"# Get the next n data starting from i",
"return",
"self",
".",
"get",
"(",
"i",
",",
"n",
")"
] | Get the previous n data from file.
Keyword argument:
n -- number of structs to be retrieved (default 1)
Must be greater than 0.
Return:
A data in the format of obj_fmt, if n = 1. A list of
structs, otherwise. | [
"Get",
"the",
"previous",
"n",
"data",
"from",
"file",
"."
] | 80e7edaacfbcb191a26ac449f049bbce878c67a3 | https://github.com/btrevizan/pystrct/blob/80e7edaacfbcb191a26ac449f049bbce878c67a3/pystrct/pystrct.py#L70-L85 |
249,659 | btrevizan/pystrct | pystrct/pystrct.py | StructFile.get | def get(self, i, n=1):
"""Get the n data starting from the ith.
Keyword argument:
i -- position in file
n -- number of structs to be retrieved (default 1)
Must be greater than 0.
Return:
A data in the format of obj_fmt, if n = 1. A list of
... | python | def get(self, i, n=1):
"""Get the n data starting from the ith.
Keyword argument:
i -- position in file
n -- number of structs to be retrieved (default 1)
Must be greater than 0.
Return:
A data in the format of obj_fmt, if n = 1. A list of
... | [
"def",
"get",
"(",
"self",
",",
"i",
",",
"n",
"=",
"1",
")",
":",
"# If there is nothing to get...",
"if",
"self",
".",
"size",
"==",
"0",
":",
"return",
"None",
"if",
"n",
"<",
"1",
":",
"return",
"[",
"]",
"# Current byte position - (n * data_size)",
... | Get the n data starting from the ith.
Keyword argument:
i -- position in file
n -- number of structs to be retrieved (default 1)
Must be greater than 0.
Return:
A data in the format of obj_fmt, if n = 1. A list of
structs, otherwise.
... | [
"Get",
"the",
"n",
"data",
"starting",
"from",
"the",
"ith",
"."
] | 80e7edaacfbcb191a26ac449f049bbce878c67a3 | https://github.com/btrevizan/pystrct/blob/80e7edaacfbcb191a26ac449f049bbce878c67a3/pystrct/pystrct.py#L87-L121 |
249,660 | btrevizan/pystrct | pystrct/pystrct.py | StructFile.last | def last(self):
"""Get the last object in file."""
# End of file
self.__file.seek(0, 2)
# Get the last struct
data = self.get(self.length - 1)
return data | python | def last(self):
"""Get the last object in file."""
# End of file
self.__file.seek(0, 2)
# Get the last struct
data = self.get(self.length - 1)
return data | [
"def",
"last",
"(",
"self",
")",
":",
"# End of file",
"self",
".",
"__file",
".",
"seek",
"(",
"0",
",",
"2",
")",
"# Get the last struct",
"data",
"=",
"self",
".",
"get",
"(",
"self",
".",
"length",
"-",
"1",
")",
"return",
"data"
] | Get the last object in file. | [
"Get",
"the",
"last",
"object",
"in",
"file",
"."
] | 80e7edaacfbcb191a26ac449f049bbce878c67a3 | https://github.com/btrevizan/pystrct/blob/80e7edaacfbcb191a26ac449f049bbce878c67a3/pystrct/pystrct.py#L123-L131 |
249,661 | btrevizan/pystrct | pystrct/pystrct.py | StructFile.append | def append(self, value):
"""Write the value into the file.
Keyword arguments:
value -- value to be writen (tuple)
"""
# Pack value
data = self.pack(value)
# End of file
self.__file.seek(0, 2)
# Write packed value
self.__file.write(da... | python | def append(self, value):
"""Write the value into the file.
Keyword arguments:
value -- value to be writen (tuple)
"""
# Pack value
data = self.pack(value)
# End of file
self.__file.seek(0, 2)
# Write packed value
self.__file.write(da... | [
"def",
"append",
"(",
"self",
",",
"value",
")",
":",
"# Pack value",
"data",
"=",
"self",
".",
"pack",
"(",
"value",
")",
"# End of file",
"self",
".",
"__file",
".",
"seek",
"(",
"0",
",",
"2",
")",
"# Write packed value",
"self",
".",
"__file",
".",... | Write the value into the file.
Keyword arguments:
value -- value to be writen (tuple) | [
"Write",
"the",
"value",
"into",
"the",
"file",
"."
] | 80e7edaacfbcb191a26ac449f049bbce878c67a3 | https://github.com/btrevizan/pystrct/blob/80e7edaacfbcb191a26ac449f049bbce878c67a3/pystrct/pystrct.py#L175-L188 |
249,662 | btrevizan/pystrct | pystrct/pystrct.py | StructFile.write | def write(self, i, value):
"""Write value in ith position in file.
Keyword arguments:
i -- position in file
value -- value to be packed (tuple)
"""
# Current byte position - (n * data_size)
offset = i * self.__strct.size
# Set file pointer to -(#... | python | def write(self, i, value):
"""Write value in ith position in file.
Keyword arguments:
i -- position in file
value -- value to be packed (tuple)
"""
# Current byte position - (n * data_size)
offset = i * self.__strct.size
# Set file pointer to -(#... | [
"def",
"write",
"(",
"self",
",",
"i",
",",
"value",
")",
":",
"# Current byte position - (n * data_size)",
"offset",
"=",
"i",
"*",
"self",
".",
"__strct",
".",
"size",
"# Set file pointer to -(#data)",
"self",
".",
"__file",
".",
"seek",
"(",
"offset",
")",
... | Write value in ith position in file.
Keyword arguments:
i -- position in file
value -- value to be packed (tuple) | [
"Write",
"value",
"in",
"ith",
"position",
"in",
"file",
"."
] | 80e7edaacfbcb191a26ac449f049bbce878c67a3 | https://github.com/btrevizan/pystrct/blob/80e7edaacfbcb191a26ac449f049bbce878c67a3/pystrct/pystrct.py#L190-L207 |
249,663 | radjkarl/appBase | appbase/Session.py | Session._inspectArguments | def _inspectArguments(self, args):
"""inspect the command-line-args and give them to appBase"""
if args:
self.exec_path = PathStr(args[0])
else:
self.exec_path = None
session_name = None
args = args[1:]
openSession = False
for ... | python | def _inspectArguments(self, args):
"""inspect the command-line-args and give them to appBase"""
if args:
self.exec_path = PathStr(args[0])
else:
self.exec_path = None
session_name = None
args = args[1:]
openSession = False
for ... | [
"def",
"_inspectArguments",
"(",
"self",
",",
"args",
")",
":",
"if",
"args",
":",
"self",
".",
"exec_path",
"=",
"PathStr",
"(",
"args",
"[",
"0",
"]",
")",
"else",
":",
"self",
".",
"exec_path",
"=",
"None",
"session_name",
"=",
"None",
"args",
"="... | inspect the command-line-args and give them to appBase | [
"inspect",
"the",
"command",
"-",
"line",
"-",
"args",
"and",
"give",
"them",
"to",
"appBase"
] | 72b514e6dee7c083f01a2d0b2cc93d46df55bdcb | https://github.com/radjkarl/appBase/blob/72b514e6dee7c083f01a2d0b2cc93d46df55bdcb/appbase/Session.py#L327-L356 |
249,664 | radjkarl/appBase | appbase/Session.py | Session.save | def save(self):
"""save the current session
override, if session was saved earlier"""
if self.path:
self._saveState(self.path)
else:
self.saveAs() | python | def save(self):
"""save the current session
override, if session was saved earlier"""
if self.path:
self._saveState(self.path)
else:
self.saveAs() | [
"def",
"save",
"(",
"self",
")",
":",
"if",
"self",
".",
"path",
":",
"self",
".",
"_saveState",
"(",
"self",
".",
"path",
")",
"else",
":",
"self",
".",
"saveAs",
"(",
")"
] | save the current session
override, if session was saved earlier | [
"save",
"the",
"current",
"session",
"override",
"if",
"session",
"was",
"saved",
"earlier"
] | 72b514e6dee7c083f01a2d0b2cc93d46df55bdcb | https://github.com/radjkarl/appBase/blob/72b514e6dee7c083f01a2d0b2cc93d46df55bdcb/appbase/Session.py#L368-L374 |
249,665 | radjkarl/appBase | appbase/Session.py | Session.open | def open(self):
"""open a session to define in a dialog in an extra window"""
filename = self.dialogs.getOpenFileName(filter="*.%s" % self.FTYPE)
if filename:
self.new(filename) | python | def open(self):
"""open a session to define in a dialog in an extra window"""
filename = self.dialogs.getOpenFileName(filter="*.%s" % self.FTYPE)
if filename:
self.new(filename) | [
"def",
"open",
"(",
"self",
")",
":",
"filename",
"=",
"self",
".",
"dialogs",
".",
"getOpenFileName",
"(",
"filter",
"=",
"\"*.%s\"",
"%",
"self",
".",
"FTYPE",
")",
"if",
"filename",
":",
"self",
".",
"new",
"(",
"filename",
")"
] | open a session to define in a dialog in an extra window | [
"open",
"a",
"session",
"to",
"define",
"in",
"a",
"dialog",
"in",
"an",
"extra",
"window"
] | 72b514e6dee7c083f01a2d0b2cc93d46df55bdcb | https://github.com/radjkarl/appBase/blob/72b514e6dee7c083f01a2d0b2cc93d46df55bdcb/appbase/Session.py#L397-L401 |
249,666 | radjkarl/appBase | appbase/Session.py | Session.new | def new(self, filename=None):
"""start a session an independent process"""
path = (self.exec_path,)
if self.exec_path.filetype() in ('py', 'pyw', 'pyz', self.FTYPE):
# get the absolute path to the python-executable
p = find_executable("python")
path = (p... | python | def new(self, filename=None):
"""start a session an independent process"""
path = (self.exec_path,)
if self.exec_path.filetype() in ('py', 'pyw', 'pyz', self.FTYPE):
# get the absolute path to the python-executable
p = find_executable("python")
path = (p... | [
"def",
"new",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"path",
"=",
"(",
"self",
".",
"exec_path",
",",
")",
"if",
"self",
".",
"exec_path",
".",
"filetype",
"(",
")",
"in",
"(",
"'py'",
",",
"'pyw'",
",",
"'pyz'",
",",
"self",
".",
... | start a session an independent process | [
"start",
"a",
"session",
"an",
"independent",
"process"
] | 72b514e6dee7c083f01a2d0b2cc93d46df55bdcb | https://github.com/radjkarl/appBase/blob/72b514e6dee7c083f01a2d0b2cc93d46df55bdcb/appbase/Session.py#L403-L416 |
249,667 | radjkarl/appBase | appbase/Session.py | Session._saveState | def _saveState(self, path):
"""save current state and add a new state"""
self.addSession() # next session
self._save(str(self.n_sessions), path) | python | def _saveState(self, path):
"""save current state and add a new state"""
self.addSession() # next session
self._save(str(self.n_sessions), path) | [
"def",
"_saveState",
"(",
"self",
",",
"path",
")",
":",
"self",
".",
"addSession",
"(",
")",
"# next session\r",
"self",
".",
"_save",
"(",
"str",
"(",
"self",
".",
"n_sessions",
")",
",",
"path",
")"
] | save current state and add a new state | [
"save",
"current",
"state",
"and",
"add",
"a",
"new",
"state"
] | 72b514e6dee7c083f01a2d0b2cc93d46df55bdcb | https://github.com/radjkarl/appBase/blob/72b514e6dee7c083f01a2d0b2cc93d46df55bdcb/appbase/Session.py#L456-L459 |
249,668 | radjkarl/appBase | appbase/Session.py | Session._autoSave | def _autoSave(self):
"""save state into 'autosave' """
a = 'autoSave'
path = self.path
if not path:
path = self.dir.join('%s.%s' % (a, self.FTYPE))
self._createdAutosaveFile = path
self.tmp_dir_save_session = self.tmp_dir_session.join(a).mkdir()
... | python | def _autoSave(self):
"""save state into 'autosave' """
a = 'autoSave'
path = self.path
if not path:
path = self.dir.join('%s.%s' % (a, self.FTYPE))
self._createdAutosaveFile = path
self.tmp_dir_save_session = self.tmp_dir_session.join(a).mkdir()
... | [
"def",
"_autoSave",
"(",
"self",
")",
":",
"a",
"=",
"'autoSave'",
"path",
"=",
"self",
".",
"path",
"if",
"not",
"path",
":",
"path",
"=",
"self",
".",
"dir",
".",
"join",
"(",
"'%s.%s'",
"%",
"(",
"a",
",",
"self",
".",
"FTYPE",
")",
")",
"se... | save state into 'autosave' | [
"save",
"state",
"into",
"autosave"
] | 72b514e6dee7c083f01a2d0b2cc93d46df55bdcb | https://github.com/radjkarl/appBase/blob/72b514e6dee7c083f01a2d0b2cc93d46df55bdcb/appbase/Session.py#L461-L469 |
249,669 | radjkarl/appBase | appbase/Session.py | Session.blockingSave | def blockingSave(self, path):
"""
saved session to file - returns after finish
only called by interactiveTutorial-save at the moment
"""
self.tmp_dir_save_session = self.tmp_dir_session.join('block').mkdir()
state = {'session': dict(self.opts),
'di... | python | def blockingSave(self, path):
"""
saved session to file - returns after finish
only called by interactiveTutorial-save at the moment
"""
self.tmp_dir_save_session = self.tmp_dir_session.join('block').mkdir()
state = {'session': dict(self.opts),
'di... | [
"def",
"blockingSave",
"(",
"self",
",",
"path",
")",
":",
"self",
".",
"tmp_dir_save_session",
"=",
"self",
".",
"tmp_dir_session",
".",
"join",
"(",
"'block'",
")",
".",
"mkdir",
"(",
")",
"state",
"=",
"{",
"'session'",
":",
"dict",
"(",
"self",
"."... | saved session to file - returns after finish
only called by interactiveTutorial-save at the moment | [
"saved",
"session",
"to",
"file",
"-",
"returns",
"after",
"finish",
"only",
"called",
"by",
"interactiveTutorial",
"-",
"save",
"at",
"the",
"moment"
] | 72b514e6dee7c083f01a2d0b2cc93d46df55bdcb | https://github.com/radjkarl/appBase/blob/72b514e6dee7c083f01a2d0b2cc93d46df55bdcb/appbase/Session.py#L471-L481 |
249,670 | radjkarl/appBase | appbase/Session.py | Session._save | def _save(self, stateName, path):
"""save into 'stateName' to pyz-path"""
print('saving...')
state = {'session': dict(self.opts),
'dialogs': self.dialogs.saveState()}
self.sigSave.emit(state)
self.saveThread.prepare(stateName, path, self.tmp_dir_session... | python | def _save(self, stateName, path):
"""save into 'stateName' to pyz-path"""
print('saving...')
state = {'session': dict(self.opts),
'dialogs': self.dialogs.saveState()}
self.sigSave.emit(state)
self.saveThread.prepare(stateName, path, self.tmp_dir_session... | [
"def",
"_save",
"(",
"self",
",",
"stateName",
",",
"path",
")",
":",
"print",
"(",
"'saving...'",
")",
"state",
"=",
"{",
"'session'",
":",
"dict",
"(",
"self",
".",
"opts",
")",
",",
"'dialogs'",
":",
"self",
".",
"dialogs",
".",
"saveState",
"(",
... | save into 'stateName' to pyz-path | [
"save",
"into",
"stateName",
"to",
"pyz",
"-",
"path"
] | 72b514e6dee7c083f01a2d0b2cc93d46df55bdcb | https://github.com/radjkarl/appBase/blob/72b514e6dee7c083f01a2d0b2cc93d46df55bdcb/appbase/Session.py#L483-L503 |
249,671 | radjkarl/appBase | appbase/Session.py | _SaveThread._recusiveReplaceArrayWithPlaceholder | def _recusiveReplaceArrayWithPlaceholder(self, state):
"""
replace all numpy.array within the state dict
with a placeholder
this allows to save the arrays extra using numpy.save_compressed
"""
arrays = {}
def recursive(state):
for key, val in... | python | def _recusiveReplaceArrayWithPlaceholder(self, state):
"""
replace all numpy.array within the state dict
with a placeholder
this allows to save the arrays extra using numpy.save_compressed
"""
arrays = {}
def recursive(state):
for key, val in... | [
"def",
"_recusiveReplaceArrayWithPlaceholder",
"(",
"self",
",",
"state",
")",
":",
"arrays",
"=",
"{",
"}",
"def",
"recursive",
"(",
"state",
")",
":",
"for",
"key",
",",
"val",
"in",
"state",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"val... | replace all numpy.array within the state dict
with a placeholder
this allows to save the arrays extra using numpy.save_compressed | [
"replace",
"all",
"numpy",
".",
"array",
"within",
"the",
"state",
"dict",
"with",
"a",
"placeholder",
"this",
"allows",
"to",
"save",
"the",
"arrays",
"extra",
"using",
"numpy",
".",
"save_compressed"
] | 72b514e6dee7c083f01a2d0b2cc93d46df55bdcb | https://github.com/radjkarl/appBase/blob/72b514e6dee7c083f01a2d0b2cc93d46df55bdcb/appbase/Session.py#L516-L536 |
249,672 | eeshangarg/nukefilewalker | nukefilewalker/indexer.py | FileIndexer.start_indexing | def start_indexing(self):
"""
Read all the files and tokenize their text into words and
accumulate all the words in a list.
"""
for filepath in self.filepaths:
with open(filepath) as fp:
blob = fp.read()
self.words.extend(self.tokenize(... | python | def start_indexing(self):
"""
Read all the files and tokenize their text into words and
accumulate all the words in a list.
"""
for filepath in self.filepaths:
with open(filepath) as fp:
blob = fp.read()
self.words.extend(self.tokenize(... | [
"def",
"start_indexing",
"(",
"self",
")",
":",
"for",
"filepath",
"in",
"self",
".",
"filepaths",
":",
"with",
"open",
"(",
"filepath",
")",
"as",
"fp",
":",
"blob",
"=",
"fp",
".",
"read",
"(",
")",
"self",
".",
"words",
".",
"extend",
"(",
"self... | Read all the files and tokenize their text into words and
accumulate all the words in a list. | [
"Read",
"all",
"the",
"files",
"and",
"tokenize",
"their",
"text",
"into",
"words",
"and",
"accumulate",
"all",
"the",
"words",
"in",
"a",
"list",
"."
] | 8538d8b70a95691b8d2d01248cd69eae18558d11 | https://github.com/eeshangarg/nukefilewalker/blob/8538d8b70a95691b8d2d01248cd69eae18558d11/nukefilewalker/indexer.py#L61-L69 |
249,673 | pudo/mqlparser | mqlparser/util.py | parse_name | def parse_name(name):
""" Split a query name into field name, operator and whether it is
inverted. """
inverted, op = False, OP_EQ
if name is not None:
for op_ in (OP_NIN, OP_IN, OP_NOT, OP_LIKE):
if name.endswith(op_):
op = op_
name = name[:len(name) ... | python | def parse_name(name):
""" Split a query name into field name, operator and whether it is
inverted. """
inverted, op = False, OP_EQ
if name is not None:
for op_ in (OP_NIN, OP_IN, OP_NOT, OP_LIKE):
if name.endswith(op_):
op = op_
name = name[:len(name) ... | [
"def",
"parse_name",
"(",
"name",
")",
":",
"inverted",
",",
"op",
"=",
"False",
",",
"OP_EQ",
"if",
"name",
"is",
"not",
"None",
":",
"for",
"op_",
"in",
"(",
"OP_NIN",
",",
"OP_IN",
",",
"OP_NOT",
",",
"OP_LIKE",
")",
":",
"if",
"name",
".",
"e... | Split a query name into field name, operator and whether it is
inverted. | [
"Split",
"a",
"query",
"name",
"into",
"field",
"name",
"operator",
"and",
"whether",
"it",
"is",
"inverted",
"."
] | 80f2e8c837a31ff1f5d0b8fb89dba9f3b2fef4bf | https://github.com/pudo/mqlparser/blob/80f2e8c837a31ff1f5d0b8fb89dba9f3b2fef4bf/mqlparser/util.py#L9-L22 |
249,674 | ECESeniorDesign/lazy_record | lazy_record/__init__.py | connect_db | def connect_db(database_name=":memory:"):
"""
Connect lazy_record to the database at the path specified in
+database_name+.
"""
db = repo.Repo.connect_db(database_name)
base.Repo.db = db
query.Repo.db = db | python | def connect_db(database_name=":memory:"):
"""
Connect lazy_record to the database at the path specified in
+database_name+.
"""
db = repo.Repo.connect_db(database_name)
base.Repo.db = db
query.Repo.db = db | [
"def",
"connect_db",
"(",
"database_name",
"=",
"\":memory:\"",
")",
":",
"db",
"=",
"repo",
".",
"Repo",
".",
"connect_db",
"(",
"database_name",
")",
"base",
".",
"Repo",
".",
"db",
"=",
"db",
"query",
".",
"Repo",
".",
"db",
"=",
"db"
] | Connect lazy_record to the database at the path specified in
+database_name+. | [
"Connect",
"lazy_record",
"to",
"the",
"database",
"at",
"the",
"path",
"specified",
"in",
"+",
"database_name",
"+",
"."
] | 929d3cc7c2538b0f792365c0d2b0e0d41084c2dd | https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/__init__.py#L10-L17 |
249,675 | ECESeniorDesign/lazy_record | lazy_record/__init__.py | close_db | def close_db():
"""
Close the connection to the database opened in `connect_db`
"""
db = repo.Repo.db
if db is not None:
db.close()
repo.Repo.db = None
base.Repo.db = None
query.Repo.db = None | python | def close_db():
"""
Close the connection to the database opened in `connect_db`
"""
db = repo.Repo.db
if db is not None:
db.close()
repo.Repo.db = None
base.Repo.db = None
query.Repo.db = None | [
"def",
"close_db",
"(",
")",
":",
"db",
"=",
"repo",
".",
"Repo",
".",
"db",
"if",
"db",
"is",
"not",
"None",
":",
"db",
".",
"close",
"(",
")",
"repo",
".",
"Repo",
".",
"db",
"=",
"None",
"base",
".",
"Repo",
".",
"db",
"=",
"None",
"query"... | Close the connection to the database opened in `connect_db` | [
"Close",
"the",
"connection",
"to",
"the",
"database",
"opened",
"in",
"connect_db"
] | 929d3cc7c2538b0f792365c0d2b0e0d41084c2dd | https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/__init__.py#L20-L29 |
249,676 | ECESeniorDesign/lazy_record | lazy_record/__init__.py | load_schema | def load_schema(schema):
"""
Load a schema file with path +schema+ into the database. Assumes that
there exists an active database connection.
"""
with repo.Repo.db:
repo.Repo.db.executescript(schema) | python | def load_schema(schema):
"""
Load a schema file with path +schema+ into the database. Assumes that
there exists an active database connection.
"""
with repo.Repo.db:
repo.Repo.db.executescript(schema) | [
"def",
"load_schema",
"(",
"schema",
")",
":",
"with",
"repo",
".",
"Repo",
".",
"db",
":",
"repo",
".",
"Repo",
".",
"db",
".",
"executescript",
"(",
"schema",
")"
] | Load a schema file with path +schema+ into the database. Assumes that
there exists an active database connection. | [
"Load",
"a",
"schema",
"file",
"with",
"path",
"+",
"schema",
"+",
"into",
"the",
"database",
".",
"Assumes",
"that",
"there",
"exists",
"an",
"active",
"database",
"connection",
"."
] | 929d3cc7c2538b0f792365c0d2b0e0d41084c2dd | https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/__init__.py#L31-L37 |
249,677 | mverleg/package_versions | package_versions/versions.py | VersionRange.update_values | def update_values(self, min=None, max=None, conflict='warning'):
"""
Update the boundaries, handling possible conflicts.
:param conflict: What to do in case of failure: 'silent', 'warning' or 'error'.
"""
conflict_txt = None
if min is not None:
if min > self.min:
if min > self.max:
self.max = s... | python | def update_values(self, min=None, max=None, conflict='warning'):
"""
Update the boundaries, handling possible conflicts.
:param conflict: What to do in case of failure: 'silent', 'warning' or 'error'.
"""
conflict_txt = None
if min is not None:
if min > self.min:
if min > self.max:
self.max = s... | [
"def",
"update_values",
"(",
"self",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
",",
"conflict",
"=",
"'warning'",
")",
":",
"conflict_txt",
"=",
"None",
"if",
"min",
"is",
"not",
"None",
":",
"if",
"min",
">",
"self",
".",
"min",
":",
"if",... | Update the boundaries, handling possible conflicts.
:param conflict: What to do in case of failure: 'silent', 'warning' or 'error'. | [
"Update",
"the",
"boundaries",
"handling",
"possible",
"conflicts",
"."
] | 187c6ff709199e6abc2765d64e0851bca5906088 | https://github.com/mverleg/package_versions/blob/187c6ff709199e6abc2765d64e0851bca5906088/package_versions/versions.py#L70-L92 |
249,678 | mverleg/package_versions | package_versions/versions.py | VersionRange.add_selection | def add_selection(self, selection, conflict = 'warning'):
"""
Restrict the range given a selection string
:param selection: A single selection (without comma), like '>=1.3'.
:param conflict: What to do in case of failure: 'silent', 'warning' or 'error'.
"""
selection = selection.replace(' ', '').replace('=... | python | def add_selection(self, selection, conflict = 'warning'):
"""
Restrict the range given a selection string
:param selection: A single selection (without comma), like '>=1.3'.
:param conflict: What to do in case of failure: 'silent', 'warning' or 'error'.
"""
selection = selection.replace(' ', '').replace('=... | [
"def",
"add_selection",
"(",
"self",
",",
"selection",
",",
"conflict",
"=",
"'warning'",
")",
":",
"selection",
"=",
"selection",
".",
"replace",
"(",
"' '",
",",
"''",
")",
".",
"replace",
"(",
"'=.'",
",",
"'=0.'",
")",
"if",
"not",
"selection",
":"... | Restrict the range given a selection string
:param selection: A single selection (without comma), like '>=1.3'.
:param conflict: What to do in case of failure: 'silent', 'warning' or 'error'. | [
"Restrict",
"the",
"range",
"given",
"a",
"selection",
"string"
] | 187c6ff709199e6abc2765d64e0851bca5906088 | https://github.com/mverleg/package_versions/blob/187c6ff709199e6abc2765d64e0851bca5906088/package_versions/versions.py#L101-L149 |
249,679 | mverleg/package_versions | package_versions/versions.py | VersionRange.choose | def choose(self, versions, conflict='silent'):
"""
Choose the highest version in the range.
:param versions: Iterable of available versions.
"""
assert conflict in ('silent', 'warning', 'error')
if not versions:
raise VersionRangeMismatch('No versions to choose from')
version_map = {}
for version in... | python | def choose(self, versions, conflict='silent'):
"""
Choose the highest version in the range.
:param versions: Iterable of available versions.
"""
assert conflict in ('silent', 'warning', 'error')
if not versions:
raise VersionRangeMismatch('No versions to choose from')
version_map = {}
for version in... | [
"def",
"choose",
"(",
"self",
",",
"versions",
",",
"conflict",
"=",
"'silent'",
")",
":",
"assert",
"conflict",
"in",
"(",
"'silent'",
",",
"'warning'",
",",
"'error'",
")",
"if",
"not",
"versions",
":",
"raise",
"VersionRangeMismatch",
"(",
"'No versions t... | Choose the highest version in the range.
:param versions: Iterable of available versions. | [
"Choose",
"the",
"highest",
"version",
"in",
"the",
"range",
"."
] | 187c6ff709199e6abc2765d64e0851bca5906088 | https://github.com/mverleg/package_versions/blob/187c6ff709199e6abc2765d64e0851bca5906088/package_versions/versions.py#L151-L188 |
249,680 | OpenGov/python_data_wrap | datawrap/listwrap.py | is_slice_or_dim_range_request | def is_slice_or_dim_range_request(key, depth=0):
'''
Checks if a particular key is a slice, DimensionRange or
list of those types
'''
# Slice, DimensionRange, or list of those elements
return (is_slice_or_dim_range(key) or
# Don't check more than the first depth
(depth ==... | python | def is_slice_or_dim_range_request(key, depth=0):
'''
Checks if a particular key is a slice, DimensionRange or
list of those types
'''
# Slice, DimensionRange, or list of those elements
return (is_slice_or_dim_range(key) or
# Don't check more than the first depth
(depth ==... | [
"def",
"is_slice_or_dim_range_request",
"(",
"key",
",",
"depth",
"=",
"0",
")",
":",
"# Slice, DimensionRange, or list of those elements",
"return",
"(",
"is_slice_or_dim_range",
"(",
"key",
")",
"or",
"# Don't check more than the first depth",
"(",
"depth",
"==",
"0",
... | Checks if a particular key is a slice, DimensionRange or
list of those types | [
"Checks",
"if",
"a",
"particular",
"key",
"is",
"a",
"slice",
"DimensionRange",
"or",
"list",
"of",
"those",
"types"
] | 7de38bb30d7a500adc336a4a7999528d753e5600 | https://github.com/OpenGov/python_data_wrap/blob/7de38bb30d7a500adc336a4a7999528d753e5600/datawrap/listwrap.py#L52-L61 |
249,681 | OpenGov/python_data_wrap | datawrap/listwrap.py | get_restricted_index | def get_restricted_index(index, length, length_index_allowed=True):
'''
Converts negative indices to positive ones and indices above length to length or
length-1 depending on lengthAllowed.
'''
if index and index >= length:
index = length if length_index_allowed else length-1
return get_... | python | def get_restricted_index(index, length, length_index_allowed=True):
'''
Converts negative indices to positive ones and indices above length to length or
length-1 depending on lengthAllowed.
'''
if index and index >= length:
index = length if length_index_allowed else length-1
return get_... | [
"def",
"get_restricted_index",
"(",
"index",
",",
"length",
",",
"length_index_allowed",
"=",
"True",
")",
":",
"if",
"index",
"and",
"index",
">=",
"length",
":",
"index",
"=",
"length",
"if",
"length_index_allowed",
"else",
"length",
"-",
"1",
"return",
"g... | Converts negative indices to positive ones and indices above length to length or
length-1 depending on lengthAllowed. | [
"Converts",
"negative",
"indices",
"to",
"positive",
"ones",
"and",
"indices",
"above",
"length",
"to",
"length",
"or",
"length",
"-",
"1",
"depending",
"on",
"lengthAllowed",
"."
] | 7de38bb30d7a500adc336a4a7999528d753e5600 | https://github.com/OpenGov/python_data_wrap/blob/7de38bb30d7a500adc336a4a7999528d753e5600/datawrap/listwrap.py#L63-L70 |
249,682 | OpenGov/python_data_wrap | datawrap/listwrap.py | DimensionRange.slice_on_length | def slice_on_length(self, data_len, *addSlices):
'''
Returns a slice representing the dimension range
restrictions applied to a list of length data_len.
If addSlices contains additional slice requirements,
they are processed in the order they are given.
'''
if le... | python | def slice_on_length(self, data_len, *addSlices):
'''
Returns a slice representing the dimension range
restrictions applied to a list of length data_len.
If addSlices contains additional slice requirements,
they are processed in the order they are given.
'''
if le... | [
"def",
"slice_on_length",
"(",
"self",
",",
"data_len",
",",
"*",
"addSlices",
")",
":",
"if",
"len",
"(",
"self",
".",
"ordered_ranges",
")",
"+",
"len",
"(",
"addSlices",
")",
"==",
"0",
":",
"return",
"slice",
"(",
"None",
",",
"None",
",",
"None"... | Returns a slice representing the dimension range
restrictions applied to a list of length data_len.
If addSlices contains additional slice requirements,
they are processed in the order they are given. | [
"Returns",
"a",
"slice",
"representing",
"the",
"dimension",
"range",
"restrictions",
"applied",
"to",
"a",
"list",
"of",
"length",
"data_len",
"."
] | 7de38bb30d7a500adc336a4a7999528d753e5600 | https://github.com/OpenGov/python_data_wrap/blob/7de38bb30d7a500adc336a4a7999528d753e5600/datawrap/listwrap.py#L142-L155 |
249,683 | OpenGov/python_data_wrap | datawrap/listwrap.py | DimensionRange._combine_ranges_on_length | def _combine_ranges_on_length(self, data_len, first, second):
'''
Combines a first range with a second range, where the second
range is considered within the scope of the first.
'''
first = get_true_slice(first, data_len)
second = get_true_slice(second, data_len)
... | python | def _combine_ranges_on_length(self, data_len, first, second):
'''
Combines a first range with a second range, where the second
range is considered within the scope of the first.
'''
first = get_true_slice(first, data_len)
second = get_true_slice(second, data_len)
... | [
"def",
"_combine_ranges_on_length",
"(",
"self",
",",
"data_len",
",",
"first",
",",
"second",
")",
":",
"first",
"=",
"get_true_slice",
"(",
"first",
",",
"data_len",
")",
"second",
"=",
"get_true_slice",
"(",
"second",
",",
"data_len",
")",
"final_start",
... | Combines a first range with a second range, where the second
range is considered within the scope of the first. | [
"Combines",
"a",
"first",
"range",
"with",
"a",
"second",
"range",
"where",
"the",
"second",
"range",
"is",
"considered",
"within",
"the",
"scope",
"of",
"the",
"first",
"."
] | 7de38bb30d7a500adc336a4a7999528d753e5600 | https://github.com/OpenGov/python_data_wrap/blob/7de38bb30d7a500adc336a4a7999528d753e5600/datawrap/listwrap.py#L157-L190 |
249,684 | OpenGov/python_data_wrap | datawrap/listwrap.py | DimensionRange._combine_lists_of_ranges_on_length | def _combine_lists_of_ranges_on_length(self, data_len, first, *range_list):
'''
Combines an arbitrary length list of ranges into a single slice.
'''
current_range = first
for next_range in range_list:
current_range = self._combine_ranges_on_length(data_len, current_ra... | python | def _combine_lists_of_ranges_on_length(self, data_len, first, *range_list):
'''
Combines an arbitrary length list of ranges into a single slice.
'''
current_range = first
for next_range in range_list:
current_range = self._combine_ranges_on_length(data_len, current_ra... | [
"def",
"_combine_lists_of_ranges_on_length",
"(",
"self",
",",
"data_len",
",",
"first",
",",
"*",
"range_list",
")",
":",
"current_range",
"=",
"first",
"for",
"next_range",
"in",
"range_list",
":",
"current_range",
"=",
"self",
".",
"_combine_ranges_on_length",
... | Combines an arbitrary length list of ranges into a single slice. | [
"Combines",
"an",
"arbitrary",
"length",
"list",
"of",
"ranges",
"into",
"a",
"single",
"slice",
"."
] | 7de38bb30d7a500adc336a4a7999528d753e5600 | https://github.com/OpenGov/python_data_wrap/blob/7de38bb30d7a500adc336a4a7999528d753e5600/datawrap/listwrap.py#L192-L199 |
249,685 | OpenGov/python_data_wrap | datawrap/listwrap.py | FixedListSubset._get_single_depth | def _get_single_depth(self, multi_index):
'''
Helper method for determining how many single index entries there
are in a particular multi-index
'''
single_depth = 0
for subind in multi_index:
if is_slice_or_dim_range(subind):
break
... | python | def _get_single_depth(self, multi_index):
'''
Helper method for determining how many single index entries there
are in a particular multi-index
'''
single_depth = 0
for subind in multi_index:
if is_slice_or_dim_range(subind):
break
... | [
"def",
"_get_single_depth",
"(",
"self",
",",
"multi_index",
")",
":",
"single_depth",
"=",
"0",
"for",
"subind",
"in",
"multi_index",
":",
"if",
"is_slice_or_dim_range",
"(",
"subind",
")",
":",
"break",
"single_depth",
"+=",
"1",
"return",
"single_depth"
] | Helper method for determining how many single index entries there
are in a particular multi-index | [
"Helper",
"method",
"for",
"determining",
"how",
"many",
"single",
"index",
"entries",
"there",
"are",
"in",
"a",
"particular",
"multi",
"-",
"index"
] | 7de38bb30d7a500adc336a4a7999528d753e5600 | https://github.com/OpenGov/python_data_wrap/blob/7de38bb30d7a500adc336a4a7999528d753e5600/datawrap/listwrap.py#L354-L364 |
249,686 | OpenGov/python_data_wrap | datawrap/listwrap.py | ZeroList._generate_splice | def _generate_splice(self, slice_ind):
'''
Creates a splice size version of the ZeroList
'''
step_size = slice_ind.step if slice_ind.step else 1
# Check for each of the four possible scenarios
if slice_ind.start != None:
if slice_ind.stop != None:
... | python | def _generate_splice(self, slice_ind):
'''
Creates a splice size version of the ZeroList
'''
step_size = slice_ind.step if slice_ind.step else 1
# Check for each of the four possible scenarios
if slice_ind.start != None:
if slice_ind.stop != None:
... | [
"def",
"_generate_splice",
"(",
"self",
",",
"slice_ind",
")",
":",
"step_size",
"=",
"slice_ind",
".",
"step",
"if",
"slice_ind",
".",
"step",
"else",
"1",
"# Check for each of the four possible scenarios",
"if",
"slice_ind",
".",
"start",
"!=",
"None",
":",
"i... | Creates a splice size version of the ZeroList | [
"Creates",
"a",
"splice",
"size",
"version",
"of",
"the",
"ZeroList"
] | 7de38bb30d7a500adc336a4a7999528d753e5600 | https://github.com/OpenGov/python_data_wrap/blob/7de38bb30d7a500adc336a4a7999528d753e5600/datawrap/listwrap.py#L547-L566 |
249,687 | minhhoit/yacms | yacms/core/models.py | SiteRelated.save | def save(self, update_site=False, *args, **kwargs):
"""
Set the site to the current site when the record is first
created, or the ``update_site`` argument is explicitly set
to ``True``.
"""
if update_site or (self.id is None and self.site_id is None):
self.sit... | python | def save(self, update_site=False, *args, **kwargs):
"""
Set the site to the current site when the record is first
created, or the ``update_site`` argument is explicitly set
to ``True``.
"""
if update_site or (self.id is None and self.site_id is None):
self.sit... | [
"def",
"save",
"(",
"self",
",",
"update_site",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"update_site",
"or",
"(",
"self",
".",
"id",
"is",
"None",
"and",
"self",
".",
"site_id",
"is",
"None",
")",
":",
"self",
"."... | Set the site to the current site when the record is first
created, or the ``update_site`` argument is explicitly set
to ``True``. | [
"Set",
"the",
"site",
"to",
"the",
"current",
"site",
"when",
"the",
"record",
"is",
"first",
"created",
"or",
"the",
"update_site",
"argument",
"is",
"explicitly",
"set",
"to",
"True",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L51-L59 |
249,688 | minhhoit/yacms | yacms/core/models.py | MetaData.save | def save(self, *args, **kwargs):
"""
Set the description field on save.
"""
if self.gen_description:
self.description = strip_tags(self.description_from_content())
super(MetaData, self).save(*args, **kwargs) | python | def save(self, *args, **kwargs):
"""
Set the description field on save.
"""
if self.gen_description:
self.description = strip_tags(self.description_from_content())
super(MetaData, self).save(*args, **kwargs) | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"gen_description",
":",
"self",
".",
"description",
"=",
"strip_tags",
"(",
"self",
".",
"description_from_content",
"(",
")",
")",
"super",
"(",
"MetaD... | Set the description field on save. | [
"Set",
"the",
"description",
"field",
"on",
"save",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L137-L143 |
249,689 | minhhoit/yacms | yacms/core/models.py | MetaData.description_from_content | def description_from_content(self):
"""
Returns the first block or sentence of the first content-like
field.
"""
description = ""
# Use the first RichTextField, or TextField if none found.
for field_type in (RichTextField, models.TextField):
if not des... | python | def description_from_content(self):
"""
Returns the first block or sentence of the first content-like
field.
"""
description = ""
# Use the first RichTextField, or TextField if none found.
for field_type in (RichTextField, models.TextField):
if not des... | [
"def",
"description_from_content",
"(",
"self",
")",
":",
"description",
"=",
"\"\"",
"# Use the first RichTextField, or TextField if none found.",
"for",
"field_type",
"in",
"(",
"RichTextField",
",",
"models",
".",
"TextField",
")",
":",
"if",
"not",
"description",
... | Returns the first block or sentence of the first content-like
field. | [
"Returns",
"the",
"first",
"block",
"or",
"sentence",
"of",
"the",
"first",
"content",
"-",
"like",
"field",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L152-L187 |
249,690 | minhhoit/yacms | yacms/core/models.py | Displayable.save | def save(self, *args, **kwargs):
"""
Set default for ``publish_date``. We can't use ``auto_now_add`` on
the field as it will be blank when a blog post is created from
the quick blog form in the admin dashboard.
"""
if self.publish_date is None:
self.publish_da... | python | def save(self, *args, **kwargs):
"""
Set default for ``publish_date``. We can't use ``auto_now_add`` on
the field as it will be blank when a blog post is created from
the quick blog form in the admin dashboard.
"""
if self.publish_date is None:
self.publish_da... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"publish_date",
"is",
"None",
":",
"self",
".",
"publish_date",
"=",
"now",
"(",
")",
"super",
"(",
"Displayable",
",",
"self",
")",
".",
"save",
... | Set default for ``publish_date``. We can't use ``auto_now_add`` on
the field as it will be blank when a blog post is created from
the quick blog form in the admin dashboard. | [
"Set",
"default",
"for",
"publish_date",
".",
"We",
"can",
"t",
"use",
"auto_now_add",
"on",
"the",
"field",
"as",
"it",
"will",
"be",
"blank",
"when",
"a",
"blog",
"post",
"is",
"created",
"from",
"the",
"quick",
"blog",
"form",
"in",
"the",
"admin",
... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L245-L253 |
249,691 | minhhoit/yacms | yacms/core/models.py | Displayable.set_short_url | def set_short_url(self):
"""
Generates the ``short_url`` attribute if the model does not
already have one. Used by the ``set_short_url_for`` template
tag and ``TweetableAdmin``.
If no sharing service is defined (bitly is the one implemented,
but others could be by overri... | python | def set_short_url(self):
"""
Generates the ``short_url`` attribute if the model does not
already have one. Used by the ``set_short_url_for`` template
tag and ``TweetableAdmin``.
If no sharing service is defined (bitly is the one implemented,
but others could be by overri... | [
"def",
"set_short_url",
"(",
"self",
")",
":",
"if",
"self",
".",
"short_url",
"==",
"SHORT_URL_UNSET",
":",
"self",
".",
"short_url",
"=",
"self",
".",
"get_absolute_url_with_host",
"(",
")",
"elif",
"not",
"self",
".",
"short_url",
":",
"self",
".",
"sho... | Generates the ``short_url`` attribute if the model does not
already have one. Used by the ``set_short_url_for`` template
tag and ``TweetableAdmin``.
If no sharing service is defined (bitly is the one implemented,
but others could be by overriding ``generate_short_url``), the
``S... | [
"Generates",
"the",
"short_url",
"attribute",
"if",
"the",
"model",
"does",
"not",
"already",
"have",
"one",
".",
"Used",
"by",
"the",
"set_short_url_for",
"template",
"tag",
"and",
"TweetableAdmin",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L289-L307 |
249,692 | minhhoit/yacms | yacms/core/models.py | Displayable.generate_short_url | def generate_short_url(self):
"""
Returns a new short URL generated using bit.ly if credentials for the
service have been specified.
"""
from yacms.conf import settings
if settings.BITLY_ACCESS_TOKEN:
url = "https://api-ssl.bit.ly/v3/shorten?%s" % urlencode({
... | python | def generate_short_url(self):
"""
Returns a new short URL generated using bit.ly if credentials for the
service have been specified.
"""
from yacms.conf import settings
if settings.BITLY_ACCESS_TOKEN:
url = "https://api-ssl.bit.ly/v3/shorten?%s" % urlencode({
... | [
"def",
"generate_short_url",
"(",
"self",
")",
":",
"from",
"yacms",
".",
"conf",
"import",
"settings",
"if",
"settings",
".",
"BITLY_ACCESS_TOKEN",
":",
"url",
"=",
"\"https://api-ssl.bit.ly/v3/shorten?%s\"",
"%",
"urlencode",
"(",
"{",
"\"access_token\"",
":",
"... | Returns a new short URL generated using bit.ly if credentials for the
service have been specified. | [
"Returns",
"a",
"new",
"short",
"URL",
"generated",
"using",
"bit",
".",
"ly",
"if",
"credentials",
"for",
"the",
"service",
"have",
"been",
"specified",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L309-L323 |
249,693 | minhhoit/yacms | yacms/core/models.py | Displayable._get_next_or_previous_by_publish_date | def _get_next_or_previous_by_publish_date(self, is_next, **kwargs):
"""
Retrieves next or previous object by publish date. We implement
our own version instead of Django's so we can hook into the
published manager and concrete subclasses.
"""
arg = "publish_date__gt" if i... | python | def _get_next_or_previous_by_publish_date(self, is_next, **kwargs):
"""
Retrieves next or previous object by publish date. We implement
our own version instead of Django's so we can hook into the
published manager and concrete subclasses.
"""
arg = "publish_date__gt" if i... | [
"def",
"_get_next_or_previous_by_publish_date",
"(",
"self",
",",
"is_next",
",",
"*",
"*",
"kwargs",
")",
":",
"arg",
"=",
"\"publish_date__gt\"",
"if",
"is_next",
"else",
"\"publish_date__lt\"",
"order",
"=",
"\"publish_date\"",
"if",
"is_next",
"else",
"\"-publis... | Retrieves next or previous object by publish date. We implement
our own version instead of Django's so we can hook into the
published manager and concrete subclasses. | [
"Retrieves",
"next",
"or",
"previous",
"object",
"by",
"publish",
"date",
".",
"We",
"implement",
"our",
"own",
"version",
"instead",
"of",
"Django",
"s",
"so",
"we",
"can",
"hook",
"into",
"the",
"published",
"manager",
"and",
"concrete",
"subclasses",
"."
... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L325-L342 |
249,694 | minhhoit/yacms | yacms/core/models.py | Orderable.with_respect_to | def with_respect_to(self):
"""
Returns a dict to use as a filter for ordering operations
containing the original ``Meta.order_with_respect_to`` value
if provided. If the field is a Generic Relation, the dict
returned contains names and values for looking up the
relation's... | python | def with_respect_to(self):
"""
Returns a dict to use as a filter for ordering operations
containing the original ``Meta.order_with_respect_to`` value
if provided. If the field is a Generic Relation, the dict
returned contains names and values for looking up the
relation's... | [
"def",
"with_respect_to",
"(",
"self",
")",
":",
"try",
":",
"name",
"=",
"self",
".",
"order_with_respect_to",
"value",
"=",
"getattr",
"(",
"self",
",",
"name",
")",
"except",
"AttributeError",
":",
"# No ``order_with_respect_to`` specified on the model.",
"return... | Returns a dict to use as a filter for ordering operations
containing the original ``Meta.order_with_respect_to`` value
if provided. If the field is a Generic Relation, the dict
returned contains names and values for looking up the
relation's ``ct_field`` and ``fk_field`` attributes. | [
"Returns",
"a",
"dict",
"to",
"use",
"as",
"a",
"filter",
"for",
"ordering",
"operations",
"containing",
"the",
"original",
"Meta",
".",
"order_with_respect_to",
"value",
"if",
"provided",
".",
"If",
"the",
"field",
"is",
"a",
"Generic",
"Relation",
"the",
"... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L408-L427 |
249,695 | minhhoit/yacms | yacms/core/models.py | Orderable.save | def save(self, *args, **kwargs):
"""
Set the initial ordering value.
"""
if self._order is None:
lookup = self.with_respect_to()
lookup["_order__isnull"] = False
concrete_model = base_concrete_model(Orderable, self)
self._order = concrete_m... | python | def save(self, *args, **kwargs):
"""
Set the initial ordering value.
"""
if self._order is None:
lookup = self.with_respect_to()
lookup["_order__isnull"] = False
concrete_model = base_concrete_model(Orderable, self)
self._order = concrete_m... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_order",
"is",
"None",
":",
"lookup",
"=",
"self",
".",
"with_respect_to",
"(",
")",
"lookup",
"[",
"\"_order__isnull\"",
"]",
"=",
"False",
"concret... | Set the initial ordering value. | [
"Set",
"the",
"initial",
"ordering",
"value",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L429-L438 |
249,696 | minhhoit/yacms | yacms/core/models.py | Orderable.delete | def delete(self, *args, **kwargs):
"""
Update the ordering values for siblings.
"""
lookup = self.with_respect_to()
lookup["_order__gte"] = self._order
concrete_model = base_concrete_model(Orderable, self)
after = concrete_model.objects.filter(**lookup)
af... | python | def delete(self, *args, **kwargs):
"""
Update the ordering values for siblings.
"""
lookup = self.with_respect_to()
lookup["_order__gte"] = self._order
concrete_model = base_concrete_model(Orderable, self)
after = concrete_model.objects.filter(**lookup)
af... | [
"def",
"delete",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"lookup",
"=",
"self",
".",
"with_respect_to",
"(",
")",
"lookup",
"[",
"\"_order__gte\"",
"]",
"=",
"self",
".",
"_order",
"concrete_model",
"=",
"base_concrete_model",
"... | Update the ordering values for siblings. | [
"Update",
"the",
"ordering",
"values",
"for",
"siblings",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L440-L449 |
249,697 | minhhoit/yacms | yacms/core/models.py | Orderable._get_next_or_previous_by_order | def _get_next_or_previous_by_order(self, is_next, **kwargs):
"""
Retrieves next or previous object by order. We implement our
own version instead of Django's so we can hook into the
published manager, concrete subclasses and our custom
``with_respect_to`` method.
"""
... | python | def _get_next_or_previous_by_order(self, is_next, **kwargs):
"""
Retrieves next or previous object by order. We implement our
own version instead of Django's so we can hook into the
published manager, concrete subclasses and our custom
``with_respect_to`` method.
"""
... | [
"def",
"_get_next_or_previous_by_order",
"(",
"self",
",",
"is_next",
",",
"*",
"*",
"kwargs",
")",
":",
"lookup",
"=",
"self",
".",
"with_respect_to",
"(",
")",
"lookup",
"[",
"\"_order\"",
"]",
"=",
"self",
".",
"_order",
"+",
"(",
"1",
"if",
"is_next"... | Retrieves next or previous object by order. We implement our
own version instead of Django's so we can hook into the
published manager, concrete subclasses and our custom
``with_respect_to`` method. | [
"Retrieves",
"next",
"or",
"previous",
"object",
"by",
"order",
".",
"We",
"implement",
"our",
"own",
"version",
"instead",
"of",
"Django",
"s",
"so",
"we",
"can",
"hook",
"into",
"the",
"published",
"manager",
"concrete",
"subclasses",
"and",
"our",
"custom... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L451-L468 |
249,698 | minhhoit/yacms | yacms/core/models.py | Ownable.is_editable | def is_editable(self, request):
"""
Restrict in-line editing to the objects's owner and superusers.
"""
return request.user.is_superuser or request.user.id == self.user_id | python | def is_editable(self, request):
"""
Restrict in-line editing to the objects's owner and superusers.
"""
return request.user.is_superuser or request.user.id == self.user_id | [
"def",
"is_editable",
"(",
"self",
",",
"request",
")",
":",
"return",
"request",
".",
"user",
".",
"is_superuser",
"or",
"request",
".",
"user",
".",
"id",
"==",
"self",
".",
"user_id"
] | Restrict in-line editing to the objects's owner and superusers. | [
"Restrict",
"in",
"-",
"line",
"editing",
"to",
"the",
"objects",
"s",
"owner",
"and",
"superusers",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L494-L498 |
249,699 | minhhoit/yacms | yacms/core/models.py | ContentTyped.get_content_models | def get_content_models(cls):
""" Return all subclasses of the concrete model. """
concrete_model = base_concrete_model(ContentTyped, cls)
return [m for m in apps.get_models()
if m is not concrete_model and issubclass(m, concrete_model)] | python | def get_content_models(cls):
""" Return all subclasses of the concrete model. """
concrete_model = base_concrete_model(ContentTyped, cls)
return [m for m in apps.get_models()
if m is not concrete_model and issubclass(m, concrete_model)] | [
"def",
"get_content_models",
"(",
"cls",
")",
":",
"concrete_model",
"=",
"base_concrete_model",
"(",
"ContentTyped",
",",
"cls",
")",
"return",
"[",
"m",
"for",
"m",
"in",
"apps",
".",
"get_models",
"(",
")",
"if",
"m",
"is",
"not",
"concrete_model",
"and... | Return all subclasses of the concrete model. | [
"Return",
"all",
"subclasses",
"of",
"the",
"concrete",
"model",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/core/models.py#L526-L530 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.