repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
mrallen1/pygett | pygett/request.py | BaseRequest.put | def put(self, endpoint, d, *args, **kwargs):
"""
**put**
Make a PUT call to a remove endpoint
Input:
* An absolute endpoint
* A data stream
Output:
* A :py:mod:`pygett.request.GettResponse` object
"""
return self._make_reque... | python | def put(self, endpoint, d, *args, **kwargs):
"""
**put**
Make a PUT call to a remove endpoint
Input:
* An absolute endpoint
* A data stream
Output:
* A :py:mod:`pygett.request.GettResponse` object
"""
return self._make_reque... | [
"def",
"put",
"(",
"self",
",",
"endpoint",
",",
"d",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_make_request",
"(",
"endpoint",
",",
"type",
"=",
"'PUT'",
",",
"data",
"=",
"d",
")"
] | **put**
Make a PUT call to a remove endpoint
Input:
* An absolute endpoint
* A data stream
Output:
* A :py:mod:`pygett.request.GettResponse` object | [
"**",
"put",
"**"
] | train | https://github.com/mrallen1/pygett/blob/1e21f8674a3634a901af054226670174b5ce2d87/pygett/request.py#L82-L96 |
akatrevorjay/uninhibited | uninhibited/events.py | Event.remove_handlers_bound_to_instance | def remove_handlers_bound_to_instance(self, obj):
"""
Remove all handlers bound to given object instance.
This is useful to remove all handler methods that are part of an instance.
:param object obj: Remove handlers that are methods of this instance
"""
for handler in se... | python | def remove_handlers_bound_to_instance(self, obj):
"""
Remove all handlers bound to given object instance.
This is useful to remove all handler methods that are part of an instance.
:param object obj: Remove handlers that are methods of this instance
"""
for handler in se... | [
"def",
"remove_handlers_bound_to_instance",
"(",
"self",
",",
"obj",
")",
":",
"for",
"handler",
"in",
"self",
".",
"handlers",
":",
"if",
"handler",
".",
"im_self",
"==",
"obj",
":",
"self",
"-=",
"handler"
] | Remove all handlers bound to given object instance.
This is useful to remove all handler methods that are part of an instance.
:param object obj: Remove handlers that are methods of this instance | [
"Remove",
"all",
"handlers",
"bound",
"to",
"given",
"object",
"instance",
".",
"This",
"is",
"useful",
"to",
"remove",
"all",
"handler",
"methods",
"that",
"are",
"part",
"of",
"an",
"instance",
"."
] | train | https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/events.py#L100-L109 |
akatrevorjay/uninhibited | uninhibited/events.py | PriorityEvent.add | def add(self, handler, priority=10):
"""
Add handler.
:param callable handler: callable handler
:return callable: The handler you added is given back so this can be used as a decorator.
"""
self.container.add_handler(handler, priority=priority)
return handler | python | def add(self, handler, priority=10):
"""
Add handler.
:param callable handler: callable handler
:return callable: The handler you added is given back so this can be used as a decorator.
"""
self.container.add_handler(handler, priority=priority)
return handler | [
"def",
"add",
"(",
"self",
",",
"handler",
",",
"priority",
"=",
"10",
")",
":",
"self",
".",
"container",
".",
"add_handler",
"(",
"handler",
",",
"priority",
"=",
"priority",
")",
"return",
"handler"
] | Add handler.
:param callable handler: callable handler
:return callable: The handler you added is given back so this can be used as a decorator. | [
"Add",
"handler",
"."
] | train | https://github.com/akatrevorjay/uninhibited/blob/f23079fe61cf831fa274d3c60bda8076c571d3f1/uninhibited/events.py#L165-L173 |
pjuren/pyokit | src/pyokit/interface/cli.py | CLI.usage | def usage(self):
"""Print usage description for this program. Output is to standard out."""
print self.programName + " [options]",
if self.maxArgs == -1 or self.maxArgs - self.minArgs > 1:
print "[files..]"
elif self.maxArgs - self.minArgs == 1:
print "[file]"
print
print self.short... | python | def usage(self):
"""Print usage description for this program. Output is to standard out."""
print self.programName + " [options]",
if self.maxArgs == -1 or self.maxArgs - self.minArgs > 1:
print "[files..]"
elif self.maxArgs - self.minArgs == 1:
print "[file]"
print
print self.short... | [
"def",
"usage",
"(",
"self",
")",
":",
"print",
"self",
".",
"programName",
"+",
"\" [options]\"",
",",
"if",
"self",
".",
"maxArgs",
"==",
"-",
"1",
"or",
"self",
".",
"maxArgs",
"-",
"self",
".",
"minArgs",
">",
"1",
":",
"print",
"\"[files..]\"",
... | Print usage description for this program. Output is to standard out. | [
"Print",
"usage",
"description",
"for",
"this",
"program",
".",
"Output",
"is",
"to",
"standard",
"out",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/interface/cli.py#L155-L169 |
pjuren/pyokit | src/pyokit/interface/cli.py | CLI.parseCommandLine | def parseCommandLine(self, line):
"""
Parse the given command line and populate self with the values found.
If the command line doesn't conform to the specification defined
by this CLI object, this function prints a message to stdout indicating
what was wrong, prints the program usage instructions ... | python | def parseCommandLine(self, line):
"""
Parse the given command line and populate self with the values found.
If the command line doesn't conform to the specification defined
by this CLI object, this function prints a message to stdout indicating
what was wrong, prints the program usage instructions ... | [
"def",
"parseCommandLine",
"(",
"self",
",",
"line",
")",
":",
"# separate arguments and options",
"try",
":",
"optlist",
",",
"args",
"=",
"getopt",
".",
"getopt",
"(",
"line",
",",
"self",
".",
"_optlist",
"(",
")",
",",
"self",
".",
"_longoptl",
"(",
... | Parse the given command line and populate self with the values found.
If the command line doesn't conform to the specification defined
by this CLI object, this function prints a message to stdout indicating
what was wrong, prints the program usage instructions and then exists
the program
:param li... | [
"Parse",
"the",
"given",
"command",
"line",
"and",
"populate",
"self",
"with",
"the",
"values",
"found",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/interface/cli.py#L171-L229 |
pjuren/pyokit | src/pyokit/interface/cli.py | CLI.getOption | def getOption(self, name):
"""
Get the the Option object associated with the given name.
:param name: the name of the option to retrieve; can be short or long name.
:raise InterfaceException: if the named option doesn't exist.
"""
name = name.strip()
for o in self.options:
if o.short ... | python | def getOption(self, name):
"""
Get the the Option object associated with the given name.
:param name: the name of the option to retrieve; can be short or long name.
:raise InterfaceException: if the named option doesn't exist.
"""
name = name.strip()
for o in self.options:
if o.short ... | [
"def",
"getOption",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"name",
".",
"strip",
"(",
")",
"for",
"o",
"in",
"self",
".",
"options",
":",
"if",
"o",
".",
"short",
"==",
"name",
"or",
"o",
".",
"long",
"==",
"name",
":",
"return",
"o",... | Get the the Option object associated with the given name.
:param name: the name of the option to retrieve; can be short or long name.
:raise InterfaceException: if the named option doesn't exist. | [
"Get",
"the",
"the",
"Option",
"object",
"associated",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/interface/cli.py#L231-L242 |
pjuren/pyokit | src/pyokit/interface/cli.py | CLI.hasOption | def hasOption(self, name):
"""
Check whether this CLI has an option with a given name.
:param name: the name of the option to check; can be short or long name.
:return: true if an option exists in the UI for the given name
"""
name = name.strip()
for o in self.options:
if o.short == n... | python | def hasOption(self, name):
"""
Check whether this CLI has an option with a given name.
:param name: the name of the option to check; can be short or long name.
:return: true if an option exists in the UI for the given name
"""
name = name.strip()
for o in self.options:
if o.short == n... | [
"def",
"hasOption",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"name",
".",
"strip",
"(",
")",
"for",
"o",
"in",
"self",
".",
"options",
":",
"if",
"o",
".",
"short",
"==",
"name",
"or",
"o",
".",
"long",
"==",
"name",
":",
"return",
"Tru... | Check whether this CLI has an option with a given name.
:param name: the name of the option to check; can be short or long name.
:return: true if an option exists in the UI for the given name | [
"Check",
"whether",
"this",
"CLI",
"has",
"an",
"option",
"with",
"a",
"given",
"name",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/interface/cli.py#L253-L264 |
pjuren/pyokit | src/pyokit/interface/cli.py | CLI.addOption | def addOption(self, o):
"""
Add a new Option to this CLI.
:param o: the option to add
:raise InterfaceException: if an option with that name already exists.
"""
if self.hasOption(o.short):
raise InterfaceException("Failed adding option - already have " + str(o))
self.options.append(o) | python | def addOption(self, o):
"""
Add a new Option to this CLI.
:param o: the option to add
:raise InterfaceException: if an option with that name already exists.
"""
if self.hasOption(o.short):
raise InterfaceException("Failed adding option - already have " + str(o))
self.options.append(o) | [
"def",
"addOption",
"(",
"self",
",",
"o",
")",
":",
"if",
"self",
".",
"hasOption",
"(",
"o",
".",
"short",
")",
":",
"raise",
"InterfaceException",
"(",
"\"Failed adding option - already have \"",
"+",
"str",
"(",
"o",
")",
")",
"self",
".",
"options",
... | Add a new Option to this CLI.
:param o: the option to add
:raise InterfaceException: if an option with that name already exists. | [
"Add",
"a",
"new",
"Option",
"to",
"this",
"CLI",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/interface/cli.py#L266-L275 |
pjuren/pyokit | src/pyokit/interface/cli.py | CLI.optionIsSet | def optionIsSet(self, name):
"""
Check whether an option with a given name exists and has been set.
:param name: the name of the option to check; can be short or long name.
:return: true if an option matching the given name exists and it has had
it's value set by the user
"""
name ... | python | def optionIsSet(self, name):
"""
Check whether an option with a given name exists and has been set.
:param name: the name of the option to check; can be short or long name.
:return: true if an option matching the given name exists and it has had
it's value set by the user
"""
name ... | [
"def",
"optionIsSet",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"name",
".",
"strip",
"(",
")",
"if",
"not",
"self",
".",
"hasOption",
"(",
"name",
")",
":",
"return",
"False",
"return",
"self",
".",
"getOption",
"(",
"name",
")",
".",
"isSe... | Check whether an option with a given name exists and has been set.
:param name: the name of the option to check; can be short or long name.
:return: true if an option matching the given name exists and it has had
it's value set by the user | [
"Check",
"whether",
"an",
"option",
"with",
"a",
"given",
"name",
"exists",
"and",
"has",
"been",
"set",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/interface/cli.py#L277-L288 |
pjuren/pyokit | src/pyokit/interface/cli.py | CLI.getArgument | def getArgument(self, num):
"""
Get the num^th argument.
:param num: Which argument to get; indexing here is from 0.
:return: The num^th agument; arguments are always parsed as strings, so this
will be a string.
:raise InterfaceException: if there are fewer than num + 1 arguments.
... | python | def getArgument(self, num):
"""
Get the num^th argument.
:param num: Which argument to get; indexing here is from 0.
:return: The num^th agument; arguments are always parsed as strings, so this
will be a string.
:raise InterfaceException: if there are fewer than num + 1 arguments.
... | [
"def",
"getArgument",
"(",
"self",
",",
"num",
")",
":",
"if",
"not",
"self",
".",
"hasArgument",
"(",
"num",
")",
":",
"raise",
"InterfaceException",
"(",
"\"Failed to retrieve argument \"",
"+",
"str",
"(",
"num",
")",
"+",
"\" -- not enough arguments provided... | Get the num^th argument.
:param num: Which argument to get; indexing here is from 0.
:return: The num^th agument; arguments are always parsed as strings, so this
will be a string.
:raise InterfaceException: if there are fewer than num + 1 arguments. | [
"Get",
"the",
"num^th",
"argument",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/interface/cli.py#L301-L313 |
pjuren/pyokit | src/pyokit/interface/cli.py | CLI._optlist | def _optlist(self):
"""Get a string representation of the options in short format."""
res = ""
for o in self.options:
res += o.short
if o.argName is not None:
res += ":"
return res | python | def _optlist(self):
"""Get a string representation of the options in short format."""
res = ""
for o in self.options:
res += o.short
if o.argName is not None:
res += ":"
return res | [
"def",
"_optlist",
"(",
"self",
")",
":",
"res",
"=",
"\"\"",
"for",
"o",
"in",
"self",
".",
"options",
":",
"res",
"+=",
"o",
".",
"short",
"if",
"o",
".",
"argName",
"is",
"not",
"None",
":",
"res",
"+=",
"\":\"",
"return",
"res"
] | Get a string representation of the options in short format. | [
"Get",
"a",
"string",
"representation",
"of",
"the",
"options",
"in",
"short",
"format",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/interface/cli.py#L324-L331 |
pjuren/pyokit | src/pyokit/interface/cli.py | CLI._longoptl | def _longoptl(self):
"""Get a list of string representations of the options in long format."""
res = []
for o in self.options:
nm = o.long
if o.argName is not None:
nm += "="
res.append(nm)
return res | python | def _longoptl(self):
"""Get a list of string representations of the options in long format."""
res = []
for o in self.options:
nm = o.long
if o.argName is not None:
nm += "="
res.append(nm)
return res | [
"def",
"_longoptl",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"for",
"o",
"in",
"self",
".",
"options",
":",
"nm",
"=",
"o",
".",
"long",
"if",
"o",
".",
"argName",
"is",
"not",
"None",
":",
"nm",
"+=",
"\"=\"",
"res",
".",
"append",
"(",
... | Get a list of string representations of the options in long format. | [
"Get",
"a",
"list",
"of",
"string",
"representations",
"of",
"the",
"options",
"in",
"long",
"format",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/interface/cli.py#L333-L341 |
Tinche/django-bower-cache | registry/models.py | ClonedRepo.pull | def pull(self):
"""Pull from the origin."""
repo_root = settings.REPO_ROOT
pull_from_origin(join(repo_root, self.name)) | python | def pull(self):
"""Pull from the origin."""
repo_root = settings.REPO_ROOT
pull_from_origin(join(repo_root, self.name)) | [
"def",
"pull",
"(",
"self",
")",
":",
"repo_root",
"=",
"settings",
".",
"REPO_ROOT",
"pull_from_origin",
"(",
"join",
"(",
"repo_root",
",",
"self",
".",
"name",
")",
")"
] | Pull from the origin. | [
"Pull",
"from",
"the",
"origin",
"."
] | train | https://github.com/Tinche/django-bower-cache/blob/5245b2ee80c33c09d85ce0bf8f047825d9df2118/registry/models.py#L40-L43 |
Tinche/django-bower-cache | registry/models.py | ClonedRepo.to_package | def to_package(self, repo_url):
"""Return the package representation of this repo."""
return Package(name=self.name, url=repo_url + self.name) | python | def to_package(self, repo_url):
"""Return the package representation of this repo."""
return Package(name=self.name, url=repo_url + self.name) | [
"def",
"to_package",
"(",
"self",
",",
"repo_url",
")",
":",
"return",
"Package",
"(",
"name",
"=",
"self",
".",
"name",
",",
"url",
"=",
"repo_url",
"+",
"self",
".",
"name",
")"
] | Return the package representation of this repo. | [
"Return",
"the",
"package",
"representation",
"of",
"this",
"repo",
"."
] | train | https://github.com/Tinche/django-bower-cache/blob/5245b2ee80c33c09d85ce0bf8f047825d9df2118/registry/models.py#L45-L47 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/utils.py | get_storage | def get_storage(clear=False):
"""helper function to get annotation storage on the portal
:param clear: If true is passed in, annotations will be cleared
:returns: portal annotations
:rtype: IAnnotations
"""
portal = getUtility(ISiteRoot)
annotations = IAnnotations(portal)
if ANNOTATION... | python | def get_storage(clear=False):
"""helper function to get annotation storage on the portal
:param clear: If true is passed in, annotations will be cleared
:returns: portal annotations
:rtype: IAnnotations
"""
portal = getUtility(ISiteRoot)
annotations = IAnnotations(portal)
if ANNOTATION... | [
"def",
"get_storage",
"(",
"clear",
"=",
"False",
")",
":",
"portal",
"=",
"getUtility",
"(",
"ISiteRoot",
")",
"annotations",
"=",
"IAnnotations",
"(",
"portal",
")",
"if",
"ANNOTATION_KEY",
"not",
"in",
"annotations",
"or",
"clear",
":",
"annotations",
"["... | helper function to get annotation storage on the portal
:param clear: If true is passed in, annotations will be cleared
:returns: portal annotations
:rtype: IAnnotations | [
"helper",
"function",
"to",
"get",
"annotation",
"storage",
"on",
"the",
"portal"
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/utils.py#L33-L45 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/utils.py | send_email | def send_email(recipient,
subject,
message,
sender="ploneintranet@netsight.co.uk"):
"""helper function to send an email with the sender preset
"""
try:
api.portal.send_email(
recipient=recipient,
sender=sender,
subject... | python | def send_email(recipient,
subject,
message,
sender="ploneintranet@netsight.co.uk"):
"""helper function to send an email with the sender preset
"""
try:
api.portal.send_email(
recipient=recipient,
sender=sender,
subject... | [
"def",
"send_email",
"(",
"recipient",
",",
"subject",
",",
"message",
",",
"sender",
"=",
"\"ploneintranet@netsight.co.uk\"",
")",
":",
"try",
":",
"api",
".",
"portal",
".",
"send_email",
"(",
"recipient",
"=",
"recipient",
",",
"sender",
"=",
"sender",
",... | helper function to send an email with the sender preset | [
"helper",
"function",
"to",
"send",
"an",
"email",
"with",
"the",
"sender",
"preset"
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/utils.py#L48-L62 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/utils.py | parent_workspace | def parent_workspace(context):
""" Return containing workspace
Returns None if not found.
"""
if IWorkspaceFolder.providedBy(context):
return context
for parent in aq_chain(context):
if IWorkspaceFolder.providedBy(parent):
return parent | python | def parent_workspace(context):
""" Return containing workspace
Returns None if not found.
"""
if IWorkspaceFolder.providedBy(context):
return context
for parent in aq_chain(context):
if IWorkspaceFolder.providedBy(parent):
return parent | [
"def",
"parent_workspace",
"(",
"context",
")",
":",
"if",
"IWorkspaceFolder",
".",
"providedBy",
"(",
"context",
")",
":",
"return",
"context",
"for",
"parent",
"in",
"aq_chain",
"(",
"context",
")",
":",
"if",
"IWorkspaceFolder",
".",
"providedBy",
"(",
"p... | Return containing workspace
Returns None if not found. | [
"Return",
"containing",
"workspace",
"Returns",
"None",
"if",
"not",
"found",
"."
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/utils.py#L65-L73 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/utils.py | get_workspace_activities | def get_workspace_activities(brain, limit=1):
""" Return the workspace activities sorted by reverse chronological
order
Regarding the time value:
- the datetime value contains the time in international format
(machine readable)
- the title value contains the absolute date and time of the p... | python | def get_workspace_activities(brain, limit=1):
""" Return the workspace activities sorted by reverse chronological
order
Regarding the time value:
- the datetime value contains the time in international format
(machine readable)
- the title value contains the absolute date and time of the p... | [
"def",
"get_workspace_activities",
"(",
"brain",
",",
"limit",
"=",
"1",
")",
":",
"mb",
"=",
"queryUtility",
"(",
"IMicroblogTool",
")",
"items",
"=",
"mb",
".",
"context_values",
"(",
"brain",
".",
"getObject",
"(",
")",
",",
"limit",
"=",
"limit",
")"... | Return the workspace activities sorted by reverse chronological
order
Regarding the time value:
- the datetime value contains the time in international format
(machine readable)
- the title value contains the absolute date and time of the post | [
"Return",
"the",
"workspace",
"activities",
"sorted",
"by",
"reverse",
"chronological",
"order"
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/utils.py#L89-L110 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/utils.py | my_workspaces | def my_workspaces(context):
""" The list of my workspaces
"""
pc = api.portal.get_tool('portal_catalog')
brains = pc(
portal_type="ploneintranet.workspace.workspacefolder",
sort_on="modified",
sort_order="reversed",
)
workspaces = [
{
'id': brain.getId... | python | def my_workspaces(context):
""" The list of my workspaces
"""
pc = api.portal.get_tool('portal_catalog')
brains = pc(
portal_type="ploneintranet.workspace.workspacefolder",
sort_on="modified",
sort_order="reversed",
)
workspaces = [
{
'id': brain.getId... | [
"def",
"my_workspaces",
"(",
"context",
")",
":",
"pc",
"=",
"api",
".",
"portal",
".",
"get_tool",
"(",
"'portal_catalog'",
")",
"brains",
"=",
"pc",
"(",
"portal_type",
"=",
"\"ploneintranet.workspace.workspacefolder\"",
",",
"sort_on",
"=",
"\"modified\"",
",... | The list of my workspaces | [
"The",
"list",
"of",
"my",
"workspaces"
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/utils.py#L113-L132 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/utils.py | existing_users | def existing_users(context):
"""
Look up the full user details for current workspace members
"""
members = IWorkspace(context).members
info = []
for userid, details in members.items():
user = api.user.get(userid)
if user is None:
continue
user = user.getUser()... | python | def existing_users(context):
"""
Look up the full user details for current workspace members
"""
members = IWorkspace(context).members
info = []
for userid, details in members.items():
user = api.user.get(userid)
if user is None:
continue
user = user.getUser()... | [
"def",
"existing_users",
"(",
"context",
")",
":",
"members",
"=",
"IWorkspace",
"(",
"context",
")",
".",
"members",
"info",
"=",
"[",
"]",
"for",
"userid",
",",
"details",
"in",
"members",
".",
"items",
"(",
")",
":",
"user",
"=",
"api",
".",
"user... | Look up the full user details for current workspace members | [
"Look",
"up",
"the",
"full",
"user",
"details",
"for",
"current",
"workspace",
"members"
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/utils.py#L135-L165 |
sbusard/wagoner | wagoner/utils.py | random_weighted_choice | def random_weighted_choice(choices):
"""
Return a random key of choices, weighted by their value.
:param choices: a dictionary of keys and positive integer pairs;
:return: a random key of choices.
"""
choices, weights = zip(*choices.items())
cumdist = list(accumulate(weights))
x = rando... | python | def random_weighted_choice(choices):
"""
Return a random key of choices, weighted by their value.
:param choices: a dictionary of keys and positive integer pairs;
:return: a random key of choices.
"""
choices, weights = zip(*choices.items())
cumdist = list(accumulate(weights))
x = rando... | [
"def",
"random_weighted_choice",
"(",
"choices",
")",
":",
"choices",
",",
"weights",
"=",
"zip",
"(",
"*",
"choices",
".",
"items",
"(",
")",
")",
"cumdist",
"=",
"list",
"(",
"accumulate",
"(",
"weights",
")",
")",
"x",
"=",
"random",
".",
"random",
... | Return a random key of choices, weighted by their value.
:param choices: a dictionary of keys and positive integer pairs;
:return: a random key of choices. | [
"Return",
"a",
"random",
"key",
"of",
"choices",
"weighted",
"by",
"their",
"value",
"."
] | train | https://github.com/sbusard/wagoner/blob/7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b/wagoner/utils.py#L62-L73 |
sbusard/wagoner | wagoner/utils.py | extract_words | def extract_words(lines):
"""
Extract from the given iterable of lines the list of words.
:param lines: an iterable of lines;
:return: a generator of words of lines.
"""
for line in lines:
for word in re.findall(r"\w+", line):
yield word | python | def extract_words(lines):
"""
Extract from the given iterable of lines the list of words.
:param lines: an iterable of lines;
:return: a generator of words of lines.
"""
for line in lines:
for word in re.findall(r"\w+", line):
yield word | [
"def",
"extract_words",
"(",
"lines",
")",
":",
"for",
"line",
"in",
"lines",
":",
"for",
"word",
"in",
"re",
".",
"findall",
"(",
"r\"\\w+\"",
",",
"line",
")",
":",
"yield",
"word"
] | Extract from the given iterable of lines the list of words.
:param lines: an iterable of lines;
:return: a generator of words of lines. | [
"Extract",
"from",
"the",
"given",
"iterable",
"of",
"lines",
"the",
"list",
"of",
"words",
"."
] | train | https://github.com/sbusard/wagoner/blob/7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b/wagoner/utils.py#L76-L85 |
minhhoit/yacms | yacms/utils/html.py | absolute_urls | def absolute_urls(html):
"""
Converts relative URLs into absolute URLs. Used for RSS feeds to
provide more complete HTML for item descriptions, but could also
be used as a general richtext filter.
"""
from bs4 import BeautifulSoup
from yacms.core.request import current_request
request ... | python | def absolute_urls(html):
"""
Converts relative URLs into absolute URLs. Used for RSS feeds to
provide more complete HTML for item descriptions, but could also
be used as a general richtext filter.
"""
from bs4 import BeautifulSoup
from yacms.core.request import current_request
request ... | [
"def",
"absolute_urls",
"(",
"html",
")",
":",
"from",
"bs4",
"import",
"BeautifulSoup",
"from",
"yacms",
".",
"core",
".",
"request",
"import",
"current_request",
"request",
"=",
"current_request",
"(",
")",
"if",
"request",
"is",
"not",
"None",
":",
"dom",... | Converts relative URLs into absolute URLs. Used for RSS feeds to
provide more complete HTML for item descriptions, but could also
be used as a general richtext filter. | [
"Converts",
"relative",
"URLs",
"into",
"absolute",
"URLs",
".",
"Used",
"for",
"RSS",
"feeds",
"to",
"provide",
"more",
"complete",
"HTML",
"for",
"item",
"descriptions",
"but",
"could",
"also",
"be",
"used",
"as",
"a",
"general",
"richtext",
"filter",
"."
... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/html.py#L40-L59 |
minhhoit/yacms | yacms/utils/html.py | decode_entities | def decode_entities(html):
"""
Remove HTML entities from a string.
Adapted from http://effbot.org/zone/re-sub.htm#unescape-html
"""
def decode(m):
html = m.group(0)
if html[:2] == "&#":
try:
if html[:3] == "&#x":
return chr(int(html[3:-... | python | def decode_entities(html):
"""
Remove HTML entities from a string.
Adapted from http://effbot.org/zone/re-sub.htm#unescape-html
"""
def decode(m):
html = m.group(0)
if html[:2] == "&#":
try:
if html[:3] == "&#x":
return chr(int(html[3:-... | [
"def",
"decode_entities",
"(",
"html",
")",
":",
"def",
"decode",
"(",
"m",
")",
":",
"html",
"=",
"m",
".",
"group",
"(",
"0",
")",
"if",
"html",
"[",
":",
"2",
"]",
"==",
"\"&#\"",
":",
"try",
":",
"if",
"html",
"[",
":",
"3",
"]",
"==",
... | Remove HTML entities from a string.
Adapted from http://effbot.org/zone/re-sub.htm#unescape-html | [
"Remove",
"HTML",
"entities",
"from",
"a",
"string",
".",
"Adapted",
"from",
"http",
":",
"//",
"effbot",
".",
"org",
"/",
"zone",
"/",
"re",
"-",
"sub",
".",
"htm#unescape",
"-",
"html"
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/html.py#L62-L83 |
minhhoit/yacms | yacms/utils/html.py | escape | def escape(html):
"""
Escapes HTML according to the rules defined by the settings
``RICHTEXT_FILTER_LEVEL``, ``RICHTEXT_ALLOWED_TAGS``,
``RICHTEXT_ALLOWED_ATTRIBUTES``, ``RICHTEXT_ALLOWED_STYLES``.
"""
from yacms.conf import settings
from yacms.core import defaults
if settings.RICHTEXT_F... | python | def escape(html):
"""
Escapes HTML according to the rules defined by the settings
``RICHTEXT_FILTER_LEVEL``, ``RICHTEXT_ALLOWED_TAGS``,
``RICHTEXT_ALLOWED_ATTRIBUTES``, ``RICHTEXT_ALLOWED_STYLES``.
"""
from yacms.conf import settings
from yacms.core import defaults
if settings.RICHTEXT_F... | [
"def",
"escape",
"(",
"html",
")",
":",
"from",
"yacms",
".",
"conf",
"import",
"settings",
"from",
"yacms",
".",
"core",
"import",
"defaults",
"if",
"settings",
".",
"RICHTEXT_FILTER_LEVEL",
"==",
"defaults",
".",
"RICHTEXT_FILTER_LEVEL_NONE",
":",
"return",
... | Escapes HTML according to the rules defined by the settings
``RICHTEXT_FILTER_LEVEL``, ``RICHTEXT_ALLOWED_TAGS``,
``RICHTEXT_ALLOWED_ATTRIBUTES``, ``RICHTEXT_ALLOWED_STYLES``. | [
"Escapes",
"HTML",
"according",
"to",
"the",
"rules",
"defined",
"by",
"the",
"settings",
"RICHTEXT_FILTER_LEVEL",
"RICHTEXT_ALLOWED_TAGS",
"RICHTEXT_ALLOWED_ATTRIBUTES",
"RICHTEXT_ALLOWED_STYLES",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/html.py#L86-L103 |
minhhoit/yacms | yacms/utils/html.py | thumbnails | def thumbnails(html):
"""
Given a HTML string, converts paths in img tags to thumbnail
paths, using yacms's ``thumbnail`` template tag. Used as
one of the default values in the ``RICHTEXT_FILTERS`` setting.
"""
from django.conf import settings
from bs4 import BeautifulSoup
from yacms.cor... | python | def thumbnails(html):
"""
Given a HTML string, converts paths in img tags to thumbnail
paths, using yacms's ``thumbnail`` template tag. Used as
one of the default values in the ``RICHTEXT_FILTERS`` setting.
"""
from django.conf import settings
from bs4 import BeautifulSoup
from yacms.cor... | [
"def",
"thumbnails",
"(",
"html",
")",
":",
"from",
"django",
".",
"conf",
"import",
"settings",
"from",
"bs4",
"import",
"BeautifulSoup",
"from",
"yacms",
".",
"core",
".",
"templatetags",
".",
"yacms_tags",
"import",
"thumbnail",
"# If MEDIA_URL isn't in the HTM... | Given a HTML string, converts paths in img tags to thumbnail
paths, using yacms's ``thumbnail`` template tag. Used as
one of the default values in the ``RICHTEXT_FILTERS`` setting. | [
"Given",
"a",
"HTML",
"string",
"converts",
"paths",
"in",
"img",
"tags",
"to",
"thumbnail",
"paths",
"using",
"yacms",
"s",
"thumbnail",
"template",
"tag",
".",
"Used",
"as",
"one",
"of",
"the",
"default",
"values",
"in",
"the",
"RICHTEXT_FILTERS",
"setting... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/html.py#L106-L130 |
rackerlabs/rackspace-python-neutronclient | neutronclient/client.py | HTTPClient.request | def request(self, url, method, body=None, headers=None, **kwargs):
"""Request without authentication."""
content_type = kwargs.pop('content_type', None) or 'application/json'
headers = headers or {}
headers.setdefault('Accept', content_type)
if body:
headers.setdefa... | python | def request(self, url, method, body=None, headers=None, **kwargs):
"""Request without authentication."""
content_type = kwargs.pop('content_type', None) or 'application/json'
headers = headers or {}
headers.setdefault('Accept', content_type)
if body:
headers.setdefa... | [
"def",
"request",
"(",
"self",
",",
"url",
",",
"method",
",",
"body",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"content_type",
"=",
"kwargs",
".",
"pop",
"(",
"'content_type'",
",",
"None",
")",
"or",
"'applicatio... | Request without authentication. | [
"Request",
"without",
"authentication",
"."
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/client.py#L133-L154 |
rackerlabs/rackspace-python-neutronclient | neutronclient/client.py | HTTPClient._extract_service_catalog | def _extract_service_catalog(self, body):
"""Set the client's service catalog from the response data."""
self.auth_ref = access.create(body=body)
self.service_catalog = self.auth_ref.service_catalog
self.auth_token = self.auth_ref.auth_token
self.auth_tenant_id = self.auth_ref.te... | python | def _extract_service_catalog(self, body):
"""Set the client's service catalog from the response data."""
self.auth_ref = access.create(body=body)
self.service_catalog = self.auth_ref.service_catalog
self.auth_token = self.auth_ref.auth_token
self.auth_tenant_id = self.auth_ref.te... | [
"def",
"_extract_service_catalog",
"(",
"self",
",",
"body",
")",
":",
"self",
".",
"auth_ref",
"=",
"access",
".",
"create",
"(",
"body",
"=",
"body",
")",
"self",
".",
"service_catalog",
"=",
"self",
".",
"auth_ref",
".",
"service_catalog",
"self",
".",
... | Set the client's service catalog from the response data. | [
"Set",
"the",
"client",
"s",
"service",
"catalog",
"from",
"the",
"response",
"data",
"."
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/client.py#L190-L202 |
usc-isi-i2/dig-sparkutil | digSparkUtil/rddUtil.py | show_partitioning | def show_partitioning(rdd, show=True):
"""Seems to be significantly more expensive on cluster than locally"""
if show:
partitionCount = rdd.getNumPartitions()
try:
valueCount = rdd.countApprox(1000, confidence=0.50)
except:
valueCount = -1
try:
... | python | def show_partitioning(rdd, show=True):
"""Seems to be significantly more expensive on cluster than locally"""
if show:
partitionCount = rdd.getNumPartitions()
try:
valueCount = rdd.countApprox(1000, confidence=0.50)
except:
valueCount = -1
try:
... | [
"def",
"show_partitioning",
"(",
"rdd",
",",
"show",
"=",
"True",
")",
":",
"if",
"show",
":",
"partitionCount",
"=",
"rdd",
".",
"getNumPartitions",
"(",
")",
"try",
":",
"valueCount",
"=",
"rdd",
".",
"countApprox",
"(",
"1000",
",",
"confidence",
"=",... | Seems to be significantly more expensive on cluster than locally | [
"Seems",
"to",
"be",
"significantly",
"more",
"expensive",
"on",
"cluster",
"than",
"locally"
] | train | https://github.com/usc-isi-i2/dig-sparkutil/blob/d39c6cf957025c170753b0e02e477fea20ee3f2a/digSparkUtil/rddUtil.py#L26-L40 |
tehmaze-labs/wright | wright/util.py | normal_case | def normal_case(name):
"""Converts "CamelCaseHere" to "camel case here"."""
s1 = re.sub(r'(.)([A-Z][a-z]+)', r'\1 \2', name)
return re.sub(r'([a-z0-9])([A-Z])', r'\1 \2', s1).lower() | python | def normal_case(name):
"""Converts "CamelCaseHere" to "camel case here"."""
s1 = re.sub(r'(.)([A-Z][a-z]+)', r'\1 \2', name)
return re.sub(r'([a-z0-9])([A-Z])', r'\1 \2', s1).lower() | [
"def",
"normal_case",
"(",
"name",
")",
":",
"s1",
"=",
"re",
".",
"sub",
"(",
"r'(.)([A-Z][a-z]+)'",
",",
"r'\\1 \\2'",
",",
"name",
")",
"return",
"re",
".",
"sub",
"(",
"r'([a-z0-9])([A-Z])'",
",",
"r'\\1 \\2'",
",",
"s1",
")",
".",
"lower",
"(",
")... | Converts "CamelCaseHere" to "camel case here". | [
"Converts",
"CamelCaseHere",
"to",
"camel",
"case",
"here",
"."
] | train | https://github.com/tehmaze-labs/wright/blob/79b2d816f541e69d5fb7f36a3c39fa0d432157a6/wright/util.py#L123-L126 |
tehmaze-labs/wright | wright/util.py | parse_flags | def parse_flags(*flags, **kwargs):
"""Parse compile flags."""
parsed = {
'ASFLAGS': OrderedSet(),
'CFLAGS': OrderedSet(),
'DEFINES': OrderedSet(),
'INCLUDES': OrderedSet(),
'FRAMEWORKS': OrderedSet(),
'FRAMEWORKPATH': OrderedSet(),
... | python | def parse_flags(*flags, **kwargs):
"""Parse compile flags."""
parsed = {
'ASFLAGS': OrderedSet(),
'CFLAGS': OrderedSet(),
'DEFINES': OrderedSet(),
'INCLUDES': OrderedSet(),
'FRAMEWORKS': OrderedSet(),
'FRAMEWORKPATH': OrderedSet(),
... | [
"def",
"parse_flags",
"(",
"*",
"flags",
",",
"*",
"*",
"kwargs",
")",
":",
"parsed",
"=",
"{",
"'ASFLAGS'",
":",
"OrderedSet",
"(",
")",
",",
"'CFLAGS'",
":",
"OrderedSet",
"(",
")",
",",
"'DEFINES'",
":",
"OrderedSet",
"(",
")",
",",
"'INCLUDES'",
... | Parse compile flags. | [
"Parse",
"compile",
"flags",
"."
] | train | https://github.com/tehmaze-labs/wright/blob/79b2d816f541e69d5fb7f36a3c39fa0d432157a6/wright/util.py#L162-L284 |
tehmaze-labs/wright | wright/util.py | Environment.merge | def merge(self, other):
"""Merge other (dict or OrderedSet) into this environment.
Only works for basic types: str, list, tuple, dict and OrderedSet.
"""
for key, value in other.items():
if not key in self:
self[key] = value
elif isinstance(value,... | python | def merge(self, other):
"""Merge other (dict or OrderedSet) into this environment.
Only works for basic types: str, list, tuple, dict and OrderedSet.
"""
for key, value in other.items():
if not key in self:
self[key] = value
elif isinstance(value,... | [
"def",
"merge",
"(",
"self",
",",
"other",
")",
":",
"for",
"key",
",",
"value",
"in",
"other",
".",
"items",
"(",
")",
":",
"if",
"not",
"key",
"in",
"self",
":",
"self",
"[",
"key",
"]",
"=",
"value",
"elif",
"isinstance",
"(",
"value",
",",
... | Merge other (dict or OrderedSet) into this environment.
Only works for basic types: str, list, tuple, dict and OrderedSet. | [
"Merge",
"other",
"(",
"dict",
"or",
"OrderedSet",
")",
"into",
"this",
"environment",
"."
] | train | https://github.com/tehmaze-labs/wright/blob/79b2d816f541e69d5fb7f36a3c39fa0d432157a6/wright/util.py#L97-L115 |
bird-house/birdhousebuilder.recipe.supervisor | birdhousebuilder/recipe/supervisor/__init__.py | Recipe.install_config | def install_config(self):
"""
install supervisor main config file
"""
text = templ_config.render(**self.options)
config = Configuration(self.buildout, 'supervisord.conf', {
'deployment': self.deployment_name,
'text': text})
return [config.install()... | python | def install_config(self):
"""
install supervisor main config file
"""
text = templ_config.render(**self.options)
config = Configuration(self.buildout, 'supervisord.conf', {
'deployment': self.deployment_name,
'text': text})
return [config.install()... | [
"def",
"install_config",
"(",
"self",
")",
":",
"text",
"=",
"templ_config",
".",
"render",
"(",
"*",
"*",
"self",
".",
"options",
")",
"config",
"=",
"Configuration",
"(",
"self",
".",
"buildout",
",",
"'supervisord.conf'",
",",
"{",
"'deployment'",
":",
... | install supervisor main config file | [
"install",
"supervisor",
"main",
"config",
"file"
] | train | https://github.com/bird-house/birdhousebuilder.recipe.supervisor/blob/bbd5531466f5f84b2ab7757f674dcdb5ae751d7f/birdhousebuilder/recipe/supervisor/__init__.py#L127-L135 |
bird-house/birdhousebuilder.recipe.supervisor | birdhousebuilder/recipe/supervisor/__init__.py | Recipe.install_program | def install_program(self):
"""
install supervisor program config file
"""
text = templ_program.render(**self.options)
config = Configuration(self.buildout, self.program + '.conf', {
'deployment': self.deployment_name,
'directory': os.path.join(self.options... | python | def install_program(self):
"""
install supervisor program config file
"""
text = templ_program.render(**self.options)
config = Configuration(self.buildout, self.program + '.conf', {
'deployment': self.deployment_name,
'directory': os.path.join(self.options... | [
"def",
"install_program",
"(",
"self",
")",
":",
"text",
"=",
"templ_program",
".",
"render",
"(",
"*",
"*",
"self",
".",
"options",
")",
"config",
"=",
"Configuration",
"(",
"self",
".",
"buildout",
",",
"self",
".",
"program",
"+",
"'.conf'",
",",
"{... | install supervisor program config file | [
"install",
"supervisor",
"program",
"config",
"file"
] | train | https://github.com/bird-house/birdhousebuilder.recipe.supervisor/blob/bbd5531466f5f84b2ab7757f674dcdb5ae751d7f/birdhousebuilder/recipe/supervisor/__init__.py#L137-L146 |
ulf1/oxyba | oxyba/linreg_ols_lu.py | linreg_ols_lu | def linreg_ols_lu(y, X):
"""Linear Regression, OLS, by solving linear equations and LU decomposition
Properties
----------
* based on LAPACK's _gesv what applies LU decomposition
* avoids using python's inverse functions
* should be stable
* no overhead or other computations
Example:
... | python | def linreg_ols_lu(y, X):
"""Linear Regression, OLS, by solving linear equations and LU decomposition
Properties
----------
* based on LAPACK's _gesv what applies LU decomposition
* avoids using python's inverse functions
* should be stable
* no overhead or other computations
Example:
... | [
"def",
"linreg_ols_lu",
"(",
"y",
",",
"X",
")",
":",
"import",
"numpy",
"as",
"np",
"try",
":",
"# solve OLS formula",
"return",
"np",
".",
"linalg",
".",
"solve",
"(",
"np",
".",
"dot",
"(",
"X",
".",
"T",
",",
"X",
")",
",",
"np",
".",
"dot",
... | Linear Regression, OLS, by solving linear equations and LU decomposition
Properties
----------
* based on LAPACK's _gesv what applies LU decomposition
* avoids using python's inverse functions
* should be stable
* no overhead or other computations
Example:
--------
beta = linre... | [
"Linear",
"Regression",
"OLS",
"by",
"solving",
"linear",
"equations",
"and",
"LU",
"decomposition"
] | train | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/linreg_ols_lu.py#L2-L26 |
natemara/jumprunpro-python | jumprun/__init__.py | JumprunProApi._time_to_minutes | def _time_to_minutes(self, time_str):
"""
Convert a time string to the equivalent number in minutes as an int.
Return 0 if the time_str is not a valid amount of time.
>>> jump = JumprunProApi('skydive-warren-county')
>>> jump._time_to_minutes('34 minutes')
34
>>> jump._time_to_minutes('1 hour, 30 minutes... | python | def _time_to_minutes(self, time_str):
"""
Convert a time string to the equivalent number in minutes as an int.
Return 0 if the time_str is not a valid amount of time.
>>> jump = JumprunProApi('skydive-warren-county')
>>> jump._time_to_minutes('34 minutes')
34
>>> jump._time_to_minutes('1 hour, 30 minutes... | [
"def",
"_time_to_minutes",
"(",
"self",
",",
"time_str",
")",
":",
"minutes",
"=",
"0",
"try",
":",
"call_time_obj",
"=",
"parser",
".",
"parse",
"(",
"time_str",
")",
"minutes",
"=",
"call_time_obj",
".",
"minute",
"minutes",
"+=",
"call_time_obj",
".",
"... | Convert a time string to the equivalent number in minutes as an int.
Return 0 if the time_str is not a valid amount of time.
>>> jump = JumprunProApi('skydive-warren-county')
>>> jump._time_to_minutes('34 minutes')
34
>>> jump._time_to_minutes('1 hour, 30 minutes')
90
>>> jump._time_to_minutes('jfksadjfk... | [
"Convert",
"a",
"time",
"string",
"to",
"the",
"equivalent",
"number",
"in",
"minutes",
"as",
"an",
"int",
".",
"Return",
"0",
"if",
"the",
"time_str",
"is",
"not",
"a",
"valid",
"amount",
"of",
"time",
"."
] | train | https://github.com/natemara/jumprunpro-python/blob/016fb86955a87d2c6a4c776959031a44180b37f3/jumprun/__init__.py#L31-L53 |
natemara/jumprunpro-python | jumprun/__init__.py | JumprunProApi.jumping | def jumping(self, _loads=None):
"""
Return True if this dropzone is still making new loads, False otherwise.
:param _loads: The output of the `departing_loads` function. This
should be left alone except for debugging purposes.
"""
if _loads is None:
_loads = self.departing_loads()
if len(_loads) < 1:... | python | def jumping(self, _loads=None):
"""
Return True if this dropzone is still making new loads, False otherwise.
:param _loads: The output of the `departing_loads` function. This
should be left alone except for debugging purposes.
"""
if _loads is None:
_loads = self.departing_loads()
if len(_loads) < 1:... | [
"def",
"jumping",
"(",
"self",
",",
"_loads",
"=",
"None",
")",
":",
"if",
"_loads",
"is",
"None",
":",
"_loads",
"=",
"self",
".",
"departing_loads",
"(",
")",
"if",
"len",
"(",
"_loads",
")",
"<",
"1",
":",
"return",
"False",
"last_load",
"=",
"_... | Return True if this dropzone is still making new loads, False otherwise.
:param _loads: The output of the `departing_loads` function. This
should be left alone except for debugging purposes. | [
"Return",
"True",
"if",
"this",
"dropzone",
"is",
"still",
"making",
"new",
"loads",
"False",
"otherwise",
"."
] | train | https://github.com/natemara/jumprunpro-python/blob/016fb86955a87d2c6a4c776959031a44180b37f3/jumprun/__init__.py#L90-L107 |
Othernet-Project/hwd | hwd/udev.py | devices_by_subsystem | def devices_by_subsystem(subsys, only=lambda x: True):
"""
Iterator that yields devices that belong to specified subsystem. Returned
values are ``pydev.Device`` instances.
The ``only`` argument can be used to further filter devices. It should be
a function that takes a ``pyudev.Device`` object, and... | python | def devices_by_subsystem(subsys, only=lambda x: True):
"""
Iterator that yields devices that belong to specified subsystem. Returned
values are ``pydev.Device`` instances.
The ``only`` argument can be used to further filter devices. It should be
a function that takes a ``pyudev.Device`` object, and... | [
"def",
"devices_by_subsystem",
"(",
"subsys",
",",
"only",
"=",
"lambda",
"x",
":",
"True",
")",
":",
"ctx",
"=",
"pyudev",
".",
"Context",
"(",
")",
"for",
"d",
"in",
"ctx",
".",
"list_devices",
"(",
")",
":",
"if",
"d",
".",
"subsystem",
"!=",
"s... | Iterator that yields devices that belong to specified subsystem. Returned
values are ``pydev.Device`` instances.
The ``only`` argument can be used to further filter devices. It should be
a function that takes a ``pyudev.Device`` object, and returns ``True`` or
``False`` to indicate whether device shoul... | [
"Iterator",
"that",
"yields",
"devices",
"that",
"belong",
"to",
"specified",
"subsystem",
".",
"Returned",
"values",
"are",
"pydev",
".",
"Device",
"instances",
"."
] | train | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/udev.py#L4-L25 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | check_infile | def check_infile(filename):
"""Check text file exisitense.
Argument:
filename: text file of bulk updating
"""
if os.path.isfile(filename):
domain = os.path.basename(filename).split('.txt')[0]
return domain
else:
sys.stderr.write("ERROR: %s : No such file\n" % filena... | python | def check_infile(filename):
"""Check text file exisitense.
Argument:
filename: text file of bulk updating
"""
if os.path.isfile(filename):
domain = os.path.basename(filename).split('.txt')[0]
return domain
else:
sys.stderr.write("ERROR: %s : No such file\n" % filena... | [
"def",
"check_infile",
"(",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"domain",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")",
".",
"split",
"(",
"'.txt'",
")",
"[",
"0",
"]",
"return",... | Check text file exisitense.
Argument:
filename: text file of bulk updating | [
"Check",
"text",
"file",
"exisitense",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L35-L47 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | set_json | def set_json(domain, action, filename=False, record=False):
"""Convert text file to JSON.
Arguments:
domain: domain name of updating target
action: True ; for PUT/POST HTTP method
False; for DELETE HTTP method
filename: text file of bulk updating (default is False... | python | def set_json(domain, action, filename=False, record=False):
"""Convert text file to JSON.
Arguments:
domain: domain name of updating target
action: True ; for PUT/POST HTTP method
False; for DELETE HTTP method
filename: text file of bulk updating (default is False... | [
"def",
"set_json",
"(",
"domain",
",",
"action",
",",
"filename",
"=",
"False",
",",
"record",
"=",
"False",
")",
":",
"o",
"=",
"JSONConverter",
"(",
"domain",
")",
"if",
"filename",
":",
"# for 'bulk_create/bulk_delete'",
"with",
"open",
"(",
"filename",
... | Convert text file to JSON.
Arguments:
domain: domain name of updating target
action: True ; for PUT/POST HTTP method
False; for DELETE HTTP method
filename: text file of bulk updating (default is False)
record: json record of updating single record (default ... | [
"Convert",
"text",
"file",
"to",
"JSON",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L50-L76 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | get_password | def get_password(args):
"""Get password
Argument:
args: arguments object
Return: password string
"""
password = ''
if args.__dict__.get('password'):
# Specify password as argument (for -p option)
password = args.password
elif args.__dict__.get('P'):
# Ent... | python | def get_password(args):
"""Get password
Argument:
args: arguments object
Return: password string
"""
password = ''
if args.__dict__.get('password'):
# Specify password as argument (for -p option)
password = args.password
elif args.__dict__.get('P'):
# Ent... | [
"def",
"get_password",
"(",
"args",
")",
":",
"password",
"=",
"''",
"if",
"args",
".",
"__dict__",
".",
"get",
"(",
"'password'",
")",
":",
"# Specify password as argument (for -p option)",
"password",
"=",
"args",
".",
"password",
"elif",
"args",
".",
"__dic... | Get password
Argument:
args: arguments object
Return: password string | [
"Get",
"password"
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L79-L106 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | get_record_params | def get_record_params(args):
"""Get record parameters from command options.
Argument:
args: arguments object
"""
name, rtype, content, ttl, priority = (
args.name, args.rtype, args.content, args.ttl, args.priority)
return name, rtype, content, ttl, priority | python | def get_record_params(args):
"""Get record parameters from command options.
Argument:
args: arguments object
"""
name, rtype, content, ttl, priority = (
args.name, args.rtype, args.content, args.ttl, args.priority)
return name, rtype, content, ttl, priority | [
"def",
"get_record_params",
"(",
"args",
")",
":",
"name",
",",
"rtype",
",",
"content",
",",
"ttl",
",",
"priority",
"=",
"(",
"args",
".",
"name",
",",
"args",
".",
"rtype",
",",
"args",
".",
"content",
",",
"args",
".",
"ttl",
",",
"args",
".",
... | Get record parameters from command options.
Argument:
args: arguments object | [
"Get",
"record",
"parameters",
"from",
"command",
"options",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L109-L118 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | show | def show(args):
"""Convert and print JSON.
Argument:
args: arguments object
"""
domain = check_infile(args.infile)
action = True
try:
print(json.dumps(set_json(domain, action, filename=args.infile),
sort_keys=True, indent=2))
except UnicodeDecodeErr... | python | def show(args):
"""Convert and print JSON.
Argument:
args: arguments object
"""
domain = check_infile(args.infile)
action = True
try:
print(json.dumps(set_json(domain, action, filename=args.infile),
sort_keys=True, indent=2))
except UnicodeDecodeErr... | [
"def",
"show",
"(",
"args",
")",
":",
"domain",
"=",
"check_infile",
"(",
"args",
".",
"infile",
")",
"action",
"=",
"True",
"try",
":",
"print",
"(",
"json",
".",
"dumps",
"(",
"set_json",
"(",
"domain",
",",
"action",
",",
"filename",
"=",
"args",
... | Convert and print JSON.
Argument:
args: arguments object | [
"Convert",
"and",
"print",
"JSON",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L121-L136 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | get | def get(args):
"""Retrieve records.
Argument:
args: arguments object
"""
password = get_password(args)
token = connect.get_token(args.username, password, args.server)
if args.__dict__.get('search'):
# When using '--search' option
keyword = args.search
else:
... | python | def get(args):
"""Retrieve records.
Argument:
args: arguments object
"""
password = get_password(args)
token = connect.get_token(args.username, password, args.server)
if args.__dict__.get('search'):
# When using '--search' option
keyword = args.search
else:
... | [
"def",
"get",
"(",
"args",
")",
":",
"password",
"=",
"get_password",
"(",
"args",
")",
"token",
"=",
"connect",
".",
"get_token",
"(",
"args",
".",
"username",
",",
"password",
",",
"args",
".",
"server",
")",
"if",
"args",
".",
"__dict__",
".",
"ge... | Retrieve records.
Argument:
args: arguments object | [
"Retrieve",
"records",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L139-L170 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | create | def create(args):
"""Create records.
Argument:
args: arguments object
"""
# for PUT HTTP method
action = True
if ((args.__dict__.get('domain') and args.__dict__.get('name')
and args.__dict__.get('rtype') and args.__dict__.get('content'))):
# for create sub-command
... | python | def create(args):
"""Create records.
Argument:
args: arguments object
"""
# for PUT HTTP method
action = True
if ((args.__dict__.get('domain') and args.__dict__.get('name')
and args.__dict__.get('rtype') and args.__dict__.get('content'))):
# for create sub-command
... | [
"def",
"create",
"(",
"args",
")",
":",
"# for PUT HTTP method",
"action",
"=",
"True",
"if",
"(",
"(",
"args",
".",
"__dict__",
".",
"get",
"(",
"'domain'",
")",
"and",
"args",
".",
"__dict__",
".",
"get",
"(",
"'name'",
")",
"and",
"args",
".",
"__... | Create records.
Argument:
args: arguments object | [
"Create",
"records",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L173-L208 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | update | def update(args):
"""Update a record.
Argument:
args: arguments object
Firstly call delete(), then create().
"""
# Check specifying some new values
if ((not args.__dict__.get('new_type') and
not args.__dict__.get('new_content') and
not args.__dict__.get('new_ttl') an... | python | def update(args):
"""Update a record.
Argument:
args: arguments object
Firstly call delete(), then create().
"""
# Check specifying some new values
if ((not args.__dict__.get('new_type') and
not args.__dict__.get('new_content') and
not args.__dict__.get('new_ttl') an... | [
"def",
"update",
"(",
"args",
")",
":",
"# Check specifying some new values",
"if",
"(",
"(",
"not",
"args",
".",
"__dict__",
".",
"get",
"(",
"'new_type'",
")",
"and",
"not",
"args",
".",
"__dict__",
".",
"get",
"(",
"'new_content'",
")",
"and",
"not",
... | Update a record.
Argument:
args: arguments object
Firstly call delete(), then create(). | [
"Update",
"a",
"record",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L249-L299 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | retrieve_tmpl | def retrieve_tmpl(args):
"""Retrieve template.
Argument:
args: arguments object
"""
password = get_password(args)
token = connect.get_token(args.username, password, args.server)
if args.__dict__.get('template'):
# When specified template identifier
template = args.temp... | python | def retrieve_tmpl(args):
"""Retrieve template.
Argument:
args: arguments object
"""
password = get_password(args)
token = connect.get_token(args.username, password, args.server)
if args.__dict__.get('template'):
# When specified template identifier
template = args.temp... | [
"def",
"retrieve_tmpl",
"(",
"args",
")",
":",
"password",
"=",
"get_password",
"(",
"args",
")",
"token",
"=",
"connect",
".",
"get_token",
"(",
"args",
".",
"username",
",",
"password",
",",
"args",
".",
"server",
")",
"if",
"args",
".",
"__dict__",
... | Retrieve template.
Argument:
args: arguments object | [
"Retrieve",
"template",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L302-L319 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | delete_tmpl | def delete_tmpl(args):
"""Delete template.
Argument:
args: arguments object
"""
if args.__dict__.get('template'):
template = args.template
password = get_password(args)
token = connect.get_token(args.username, password, args.server)
processing.delete_template(args.server, ... | python | def delete_tmpl(args):
"""Delete template.
Argument:
args: arguments object
"""
if args.__dict__.get('template'):
template = args.template
password = get_password(args)
token = connect.get_token(args.username, password, args.server)
processing.delete_template(args.server, ... | [
"def",
"delete_tmpl",
"(",
"args",
")",
":",
"if",
"args",
".",
"__dict__",
".",
"get",
"(",
"'template'",
")",
":",
"template",
"=",
"args",
".",
"template",
"password",
"=",
"get_password",
"(",
"args",
")",
"token",
"=",
"connect",
".",
"get_token",
... | Delete template.
Argument:
args: arguments object | [
"Delete",
"template",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L322-L334 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | update_soa_serial | def update_soa_serial(args):
"""Update SOA serial.
Argument:
args: arguments object
"""
password = get_password(args)
token = connect.get_token(args.username, password, args.server)
soa_content = dict(domain=args.domain)
if args.__dict__.get('mname'):
soa_content['mname'] =... | python | def update_soa_serial(args):
"""Update SOA serial.
Argument:
args: arguments object
"""
password = get_password(args)
token = connect.get_token(args.username, password, args.server)
soa_content = dict(domain=args.domain)
if args.__dict__.get('mname'):
soa_content['mname'] =... | [
"def",
"update_soa_serial",
"(",
"args",
")",
":",
"password",
"=",
"get_password",
"(",
"args",
")",
"token",
"=",
"connect",
".",
"get_token",
"(",
"args",
".",
"username",
",",
"password",
",",
"args",
".",
"server",
")",
"soa_content",
"=",
"dict",
"... | Update SOA serial.
Argument:
args: arguments object | [
"Update",
"SOA",
"serial",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L337-L359 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | create_zone | def create_zone(args):
"""Create zone.
Argument:
args: arguments object
"""
action = True
password = get_password(args)
token = connect.get_token(args.username, password, args.server)
domain = args.domain
template = args.domain.replace('.', '_')
master = None
dnsaddr... | python | def create_zone(args):
"""Create zone.
Argument:
args: arguments object
"""
action = True
password = get_password(args)
token = connect.get_token(args.username, password, args.server)
domain = args.domain
template = args.domain.replace('.', '_')
master = None
dnsaddr... | [
"def",
"create_zone",
"(",
"args",
")",
":",
"action",
"=",
"True",
"password",
"=",
"get_password",
"(",
"args",
")",
"token",
"=",
"connect",
".",
"get_token",
"(",
"args",
".",
"username",
",",
"password",
",",
"args",
".",
"server",
")",
"domain",
... | Create zone.
Argument:
args: arguments object | [
"Create",
"zone",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L362-L398 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | delete_zone | def delete_zone(args):
"""Delete zone.
Argument:
args: arguments object
"""
if args.__dict__.get('domain'):
domain = args.domain
password = get_password(args)
token = connect.get_token(args.username, password, args.server)
processing.delete_zone(args.server, token, domain) | python | def delete_zone(args):
"""Delete zone.
Argument:
args: arguments object
"""
if args.__dict__.get('domain'):
domain = args.domain
password = get_password(args)
token = connect.get_token(args.username, password, args.server)
processing.delete_zone(args.server, token, domain) | [
"def",
"delete_zone",
"(",
"args",
")",
":",
"if",
"args",
".",
"__dict__",
".",
"get",
"(",
"'domain'",
")",
":",
"domain",
"=",
"args",
".",
"domain",
"password",
"=",
"get_password",
"(",
"args",
")",
"token",
"=",
"connect",
".",
"get_token",
"(",
... | Delete zone.
Argument:
args: arguments object | [
"Delete",
"zone",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L401-L413 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | set_option | def set_option(prs, keyword, required=False):
"""Set options of command line.
Arguments:
prs: parser object of argparse
keyword: processing keyword
required: True is required option (default is False)
"""
if keyword == 'server':
prs.add_argument(
'-s',... | python | def set_option(prs, keyword, required=False):
"""Set options of command line.
Arguments:
prs: parser object of argparse
keyword: processing keyword
required: True is required option (default is False)
"""
if keyword == 'server':
prs.add_argument(
'-s',... | [
"def",
"set_option",
"(",
"prs",
",",
"keyword",
",",
"required",
"=",
"False",
")",
":",
"if",
"keyword",
"==",
"'server'",
":",
"prs",
".",
"add_argument",
"(",
"'-s'",
",",
"dest",
"=",
"'server'",
",",
"required",
"=",
"True",
",",
"help",
"=",
"... | Set options of command line.
Arguments:
prs: parser object of argparse
keyword: processing keyword
required: True is required option (default is False) | [
"Set",
"options",
"of",
"command",
"line",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L416-L482 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | conn_options | def conn_options(prs, conn):
"""Set options of connecting to TonicDNS API server
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
if conn.get('server') and conn.get('username') and conn.get('password'):
prs.set_defaults(server=conn.get('... | python | def conn_options(prs, conn):
"""Set options of connecting to TonicDNS API server
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
if conn.get('server') and conn.get('username') and conn.get('password'):
prs.set_defaults(server=conn.get('... | [
"def",
"conn_options",
"(",
"prs",
",",
"conn",
")",
":",
"if",
"conn",
".",
"get",
"(",
"'server'",
")",
"and",
"conn",
".",
"get",
"(",
"'username'",
")",
"and",
"conn",
".",
"get",
"(",
"'password'",
")",
":",
"prs",
".",
"set_defaults",
"(",
"s... | Set options of connecting to TonicDNS API server
Arguments:
prs: parser object of argparse
conn: dictionary of connection information | [
"Set",
"options",
"of",
"connecting",
"to",
"TonicDNS",
"API",
"server"
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L485-L512 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_options | def parse_options():
"""Define sub-commands and command line options."""
server, username, password, auto_update_soa = False, False, False, False
prs = argparse.ArgumentParser(description='usage')
prs.add_argument('-v', '--version', action='version',
version=__version__)
if os... | python | def parse_options():
"""Define sub-commands and command line options."""
server, username, password, auto_update_soa = False, False, False, False
prs = argparse.ArgumentParser(description='usage')
prs.add_argument('-v', '--version', action='version',
version=__version__)
if os... | [
"def",
"parse_options",
"(",
")",
":",
"server",
",",
"username",
",",
"password",
",",
"auto_update_soa",
"=",
"False",
",",
"False",
",",
"False",
",",
"False",
"prs",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'usage'",
")",
"prs"... | Define sub-commands and command line options. | [
"Define",
"sub",
"-",
"commands",
"and",
"command",
"line",
"options",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L515-L571 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_show | def parse_show(prs):
"""Convert and print JSON.
Argument:
prs: parser object of argparse
"""
prs_show = prs.add_parser('show',
help='show converted JSON')
set_option(prs_show, 'infile')
prs_show.set_defaults(func=show) | python | def parse_show(prs):
"""Convert and print JSON.
Argument:
prs: parser object of argparse
"""
prs_show = prs.add_parser('show',
help='show converted JSON')
set_option(prs_show, 'infile')
prs_show.set_defaults(func=show) | [
"def",
"parse_show",
"(",
"prs",
")",
":",
"prs_show",
"=",
"prs",
".",
"add_parser",
"(",
"'show'",
",",
"help",
"=",
"'show converted JSON'",
")",
"set_option",
"(",
"prs_show",
",",
"'infile'",
")",
"prs_show",
".",
"set_defaults",
"(",
"func",
"=",
"sh... | Convert and print JSON.
Argument:
prs: parser object of argparse | [
"Convert",
"and",
"print",
"JSON",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L574-L584 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_get | def parse_get(prs, conn):
"""Retrieve records.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_get = prs.add_parser(
'get', help='retrieve all zones or records with a specific zone')
prs_get.add_argument('--domain', action='stor... | python | def parse_get(prs, conn):
"""Retrieve records.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_get = prs.add_parser(
'get', help='retrieve all zones or records with a specific zone')
prs_get.add_argument('--domain', action='stor... | [
"def",
"parse_get",
"(",
"prs",
",",
"conn",
")",
":",
"prs_get",
"=",
"prs",
".",
"add_parser",
"(",
"'get'",
",",
"help",
"=",
"'retrieve all zones or records with a specific zone'",
")",
"prs_get",
".",
"add_argument",
"(",
"'--domain'",
",",
"action",
"=",
... | Retrieve records.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information | [
"Retrieve",
"records",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L587-L601 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_create | def parse_create(prs, conn):
"""Create record.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_create = prs.add_parser(
'create', help='create record of specific zone')
set_option(prs_create, 'domain')
conn_options(prs_creat... | python | def parse_create(prs, conn):
"""Create record.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_create = prs.add_parser(
'create', help='create record of specific zone')
set_option(prs_create, 'domain')
conn_options(prs_creat... | [
"def",
"parse_create",
"(",
"prs",
",",
"conn",
")",
":",
"prs_create",
"=",
"prs",
".",
"add_parser",
"(",
"'create'",
",",
"help",
"=",
"'create record of specific zone'",
")",
"set_option",
"(",
"prs_create",
",",
"'domain'",
")",
"conn_options",
"(",
"prs_... | Create record.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information | [
"Create",
"record",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L604-L616 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_bulk_create | def parse_bulk_create(prs, conn):
"""Create bulk_records.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_create = prs.add_parser(
'bulk_create', help='create bulk records of specific zone')
set_option(prs_create, 'infile')
... | python | def parse_bulk_create(prs, conn):
"""Create bulk_records.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_create = prs.add_parser(
'bulk_create', help='create bulk records of specific zone')
set_option(prs_create, 'infile')
... | [
"def",
"parse_bulk_create",
"(",
"prs",
",",
"conn",
")",
":",
"prs_create",
"=",
"prs",
".",
"add_parser",
"(",
"'bulk_create'",
",",
"help",
"=",
"'create bulk records of specific zone'",
")",
"set_option",
"(",
"prs_create",
",",
"'infile'",
")",
"conn_options"... | Create bulk_records.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information | [
"Create",
"bulk_records",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L619-L633 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_delete | def parse_delete(prs, conn):
"""Delete record.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_delete = prs.add_parser(
'delete', help='delete a record of specific zone')
set_option(prs_delete, 'domain')
conn_options(prs_del... | python | def parse_delete(prs, conn):
"""Delete record.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_delete = prs.add_parser(
'delete', help='delete a record of specific zone')
set_option(prs_delete, 'domain')
conn_options(prs_del... | [
"def",
"parse_delete",
"(",
"prs",
",",
"conn",
")",
":",
"prs_delete",
"=",
"prs",
".",
"add_parser",
"(",
"'delete'",
",",
"help",
"=",
"'delete a record of specific zone'",
")",
"set_option",
"(",
"prs_delete",
",",
"'domain'",
")",
"conn_options",
"(",
"pr... | Delete record.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information | [
"Delete",
"record",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L636-L648 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_bulk_delete | def parse_bulk_delete(prs, conn):
"""Delete bulk_records.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_delete = prs.add_parser(
'bulk_delete', help='delete bulk records of specific zone')
set_option(prs_delete, 'infile')
... | python | def parse_bulk_delete(prs, conn):
"""Delete bulk_records.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_delete = prs.add_parser(
'bulk_delete', help='delete bulk records of specific zone')
set_option(prs_delete, 'infile')
... | [
"def",
"parse_bulk_delete",
"(",
"prs",
",",
"conn",
")",
":",
"prs_delete",
"=",
"prs",
".",
"add_parser",
"(",
"'bulk_delete'",
",",
"help",
"=",
"'delete bulk records of specific zone'",
")",
"set_option",
"(",
"prs_delete",
",",
"'infile'",
")",
"conn_options"... | Delete bulk_records.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information | [
"Delete",
"bulk_records",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L651-L665 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_update | def parse_update(prs, conn):
"""Update a record.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_update = prs.add_parser(
'update', help='update record of specific zone')
set_option(prs_update, 'domain')
set_option(prs_upda... | python | def parse_update(prs, conn):
"""Update a record.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_update = prs.add_parser(
'update', help='update record of specific zone')
set_option(prs_update, 'domain')
set_option(prs_upda... | [
"def",
"parse_update",
"(",
"prs",
",",
"conn",
")",
":",
"prs_update",
"=",
"prs",
".",
"add_parser",
"(",
"'update'",
",",
"help",
"=",
"'update record of specific zone'",
")",
"set_option",
"(",
"prs_update",
",",
"'domain'",
")",
"set_option",
"(",
"prs_up... | Update a record.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information | [
"Update",
"a",
"record",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L668-L682 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_get_tmpl | def parse_get_tmpl(prs, conn):
"""Retrieve template.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_tmpl_get = prs.add_parser(
'tmpl_get', help='retrieve templates')
set_option(prs_tmpl_get, 'template')
conn_options(prs_tmp... | python | def parse_get_tmpl(prs, conn):
"""Retrieve template.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_tmpl_get = prs.add_parser(
'tmpl_get', help='retrieve templates')
set_option(prs_tmpl_get, 'template')
conn_options(prs_tmp... | [
"def",
"parse_get_tmpl",
"(",
"prs",
",",
"conn",
")",
":",
"prs_tmpl_get",
"=",
"prs",
".",
"add_parser",
"(",
"'tmpl_get'",
",",
"help",
"=",
"'retrieve templates'",
")",
"set_option",
"(",
"prs_tmpl_get",
",",
"'template'",
")",
"conn_options",
"(",
"prs_tm... | Retrieve template.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information | [
"Retrieve",
"template",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L685-L697 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_delete_tmpl | def parse_delete_tmpl(prs, conn):
"""Delete template.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_tmpl_delete = prs.add_parser(
'tmpl_delete', help='delete template')
set_option(prs_tmpl_delete, 'template', required=True)
... | python | def parse_delete_tmpl(prs, conn):
"""Delete template.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_tmpl_delete = prs.add_parser(
'tmpl_delete', help='delete template')
set_option(prs_tmpl_delete, 'template', required=True)
... | [
"def",
"parse_delete_tmpl",
"(",
"prs",
",",
"conn",
")",
":",
"prs_tmpl_delete",
"=",
"prs",
".",
"add_parser",
"(",
"'tmpl_delete'",
",",
"help",
"=",
"'delete template'",
")",
"set_option",
"(",
"prs_tmpl_delete",
",",
"'template'",
",",
"required",
"=",
"T... | Delete template.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information | [
"Delete",
"template",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L700-L712 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_update_soa | def parse_update_soa(prs, conn):
"""Update SOA serial.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_soa = prs.add_parser('soa', help='update SOA record')
prs_soa.add_argument('--domain', action='store', required=True,
... | python | def parse_update_soa(prs, conn):
"""Update SOA serial.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_soa = prs.add_parser('soa', help='update SOA record')
prs_soa.add_argument('--domain', action='store', required=True,
... | [
"def",
"parse_update_soa",
"(",
"prs",
",",
"conn",
")",
":",
"prs_soa",
"=",
"prs",
".",
"add_parser",
"(",
"'soa'",
",",
"help",
"=",
"'update SOA record'",
")",
"prs_soa",
".",
"add_argument",
"(",
"'--domain'",
",",
"action",
"=",
"'store'",
",",
"requ... | Update SOA serial.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information | [
"Update",
"SOA",
"serial",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L715-L739 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_create_zone | def parse_create_zone(prs, conn):
"""Create zone.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_zone_create = prs.add_parser('zone_create', help='create zone')
prs_zone_create.add_argument(
'--domain', action='store', required... | python | def parse_create_zone(prs, conn):
"""Create zone.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_zone_create = prs.add_parser('zone_create', help='create zone')
prs_zone_create.add_argument(
'--domain', action='store', required... | [
"def",
"parse_create_zone",
"(",
"prs",
",",
"conn",
")",
":",
"prs_zone_create",
"=",
"prs",
".",
"add_parser",
"(",
"'zone_create'",
",",
"help",
"=",
"'create zone'",
")",
"prs_zone_create",
".",
"add_argument",
"(",
"'--domain'",
",",
"action",
"=",
"'stor... | Create zone.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information | [
"Create",
"zone",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L742-L761 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | parse_delete_zone | def parse_delete_zone(prs, conn):
"""Delete zone.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_zone_delete = prs.add_parser('zone_delete', help='delete zone')
prs_zone_delete.add_argument('--domain', action='store', required=True,
... | python | def parse_delete_zone(prs, conn):
"""Delete zone.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information
"""
prs_zone_delete = prs.add_parser('zone_delete', help='delete zone')
prs_zone_delete.add_argument('--domain', action='store', required=True,
... | [
"def",
"parse_delete_zone",
"(",
"prs",
",",
"conn",
")",
":",
"prs_zone_delete",
"=",
"prs",
".",
"add_parser",
"(",
"'zone_delete'",
",",
"help",
"=",
"'delete zone'",
")",
"prs_zone_delete",
".",
"add_argument",
"(",
"'--domain'",
",",
"action",
"=",
"'stor... | Delete zone.
Arguments:
prs: parser object of argparse
conn: dictionary of connection information | [
"Delete",
"zone",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L764-L776 |
mkouhei/tonicdnscli | src/tonicdnscli/command.py | check_config | def check_config(filename):
"""Check configuration file of TonicDNS CLI.
Argument:
filename: config file name (default is ~/.tdclirc)
"""
conf = configparser.SafeConfigParser(allow_no_value=False)
conf.read(filename)
try:
server = conf.get('global', 'server')
except configp... | python | def check_config(filename):
"""Check configuration file of TonicDNS CLI.
Argument:
filename: config file name (default is ~/.tdclirc)
"""
conf = configparser.SafeConfigParser(allow_no_value=False)
conf.read(filename)
try:
server = conf.get('global', 'server')
except configp... | [
"def",
"check_config",
"(",
"filename",
")",
":",
"conf",
"=",
"configparser",
".",
"SafeConfigParser",
"(",
"allow_no_value",
"=",
"False",
")",
"conf",
".",
"read",
"(",
"filename",
")",
"try",
":",
"server",
"=",
"conf",
".",
"get",
"(",
"'global'",
"... | Check configuration file of TonicDNS CLI.
Argument:
filename: config file name (default is ~/.tdclirc) | [
"Check",
"configuration",
"file",
"of",
"TonicDNS",
"CLI",
"."
] | train | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/command.py#L779-L813 |
etcher-be/elib_config | elib_config/_file/_config_example.py | _aggregate_config_values | def _aggregate_config_values(config_values: typing.List[ConfigValue]) -> dict:
"""
Returns a (sorted)
:param config_values:
:type config_values:
:return:
:rtype:
"""
_keys: defaultdict = _nested_default_dict()
_sorted_values = sorted(config_values, key=lambda x: x.name)
for valu... | python | def _aggregate_config_values(config_values: typing.List[ConfigValue]) -> dict:
"""
Returns a (sorted)
:param config_values:
:type config_values:
:return:
:rtype:
"""
_keys: defaultdict = _nested_default_dict()
_sorted_values = sorted(config_values, key=lambda x: x.name)
for valu... | [
"def",
"_aggregate_config_values",
"(",
"config_values",
":",
"typing",
".",
"List",
"[",
"ConfigValue",
"]",
")",
"->",
"dict",
":",
"_keys",
":",
"defaultdict",
"=",
"_nested_default_dict",
"(",
")",
"_sorted_values",
"=",
"sorted",
"(",
"config_values",
",",
... | Returns a (sorted)
:param config_values:
:type config_values:
:return:
:rtype: | [
"Returns",
"a",
"(",
"sorted",
")"
] | train | https://github.com/etcher-be/elib_config/blob/5d8c839e84d70126620ab0186dc1f717e5868bd0/elib_config/_file/_config_example.py#L41-L58 |
etcher-be/elib_config | elib_config/_file/_config_example.py | write_example_config | def write_example_config(example_file_path: str):
"""
Writes an example config file using the config values declared so far
:param example_file_path: path to write to
"""
document = tomlkit.document()
for header_line in _get_header():
document.add(tomlkit.comment(header_line))
confi... | python | def write_example_config(example_file_path: str):
"""
Writes an example config file using the config values declared so far
:param example_file_path: path to write to
"""
document = tomlkit.document()
for header_line in _get_header():
document.add(tomlkit.comment(header_line))
confi... | [
"def",
"write_example_config",
"(",
"example_file_path",
":",
"str",
")",
":",
"document",
"=",
"tomlkit",
".",
"document",
"(",
")",
"for",
"header_line",
"in",
"_get_header",
"(",
")",
":",
"document",
".",
"add",
"(",
"tomlkit",
".",
"comment",
"(",
"he... | Writes an example config file using the config values declared so far
:param example_file_path: path to write to | [
"Writes",
"an",
"example",
"config",
"file",
"using",
"the",
"config",
"values",
"declared",
"so",
"far"
] | train | https://github.com/etcher-be/elib_config/blob/5d8c839e84d70126620ab0186dc1f717e5868bd0/elib_config/_file/_config_example.py#L71-L84 |
20c/xbahn | xbahn/api.py | Comm.prepare_message | def prepare_message(self, message):
"""
Prepares the message before sending it out
Returns:
- message.Message: the message
"""
message.meta.update(path=self.path)
for handler in self.handlers:
handler.outgoing(message, self)
return mess... | python | def prepare_message(self, message):
"""
Prepares the message before sending it out
Returns:
- message.Message: the message
"""
message.meta.update(path=self.path)
for handler in self.handlers:
handler.outgoing(message, self)
return mess... | [
"def",
"prepare_message",
"(",
"self",
",",
"message",
")",
":",
"message",
".",
"meta",
".",
"update",
"(",
"path",
"=",
"self",
".",
"path",
")",
"for",
"handler",
"in",
"self",
".",
"handlers",
":",
"handler",
".",
"outgoing",
"(",
"message",
",",
... | Prepares the message before sending it out
Returns:
- message.Message: the message | [
"Prepares",
"the",
"message",
"before",
"sending",
"it",
"out"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/api.py#L288-L301 |
20c/xbahn | xbahn/api.py | Comm.on_receive | def on_receive(self, message=None, wire=None, event_origin=None):
"""
event handler bound to the receive event of the
link the server is wired too.
Arguments:
- message (message.Message): incoming message
Keyword arguments:
- event_origin (connection.Li... | python | def on_receive(self, message=None, wire=None, event_origin=None):
"""
event handler bound to the receive event of the
link the server is wired too.
Arguments:
- message (message.Message): incoming message
Keyword arguments:
- event_origin (connection.Li... | [
"def",
"on_receive",
"(",
"self",
",",
"message",
"=",
"None",
",",
"wire",
"=",
"None",
",",
"event_origin",
"=",
"None",
")",
":",
"self",
".",
"trigger",
"(",
"\"before_call\"",
",",
"message",
")",
"fn_name",
"=",
"message",
".",
"data",
"pmsg",
"=... | event handler bound to the receive event of the
link the server is wired too.
Arguments:
- message (message.Message): incoming message
Keyword arguments:
- event_origin (connection.Link) | [
"event",
"handler",
"bound",
"to",
"the",
"receive",
"event",
"of",
"the",
"link",
"the",
"server",
"is",
"wired",
"too",
"."
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/api.py#L304-L350 |
20c/xbahn | xbahn/api.py | ClientAwareServer.cleanup | def cleanup(self):
"""
removes inactive clients (will be run in its own thread, about once
every second)
"""
while self.inactive_timeout > 0:
self.time = time.time()
keys = []
for key, client in self.clients.items.items():
t ... | python | def cleanup(self):
"""
removes inactive clients (will be run in its own thread, about once
every second)
"""
while self.inactive_timeout > 0:
self.time = time.time()
keys = []
for key, client in self.clients.items.items():
t ... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"while",
"self",
".",
"inactive_timeout",
">",
"0",
":",
"self",
".",
"time",
"=",
"time",
".",
"time",
"(",
")",
"keys",
"=",
"[",
"]",
"for",
"key",
",",
"client",
"in",
"self",
".",
"clients",
".",
"ite... | removes inactive clients (will be run in its own thread, about once
every second) | [
"removes",
"inactive",
"clients",
"(",
"will",
"be",
"run",
"in",
"its",
"own",
"thread",
"about",
"once",
"every",
"second",
")"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/api.py#L483-L504 |
20c/xbahn | xbahn/api.py | WidgetAwareServer.detach_remote | def detach_remote(self, id, name):
"""
destroy remote instance of widget
Arguments:
- id (str): widget id
- name (str): widget type name
"""
if name in self.widgets:
if id in self.widgets[name]:
del self.widgets[name] | python | def detach_remote(self, id, name):
"""
destroy remote instance of widget
Arguments:
- id (str): widget id
- name (str): widget type name
"""
if name in self.widgets:
if id in self.widgets[name]:
del self.widgets[name] | [
"def",
"detach_remote",
"(",
"self",
",",
"id",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"widgets",
":",
"if",
"id",
"in",
"self",
".",
"widgets",
"[",
"name",
"]",
":",
"del",
"self",
".",
"widgets",
"[",
"name",
"]"
] | destroy remote instance of widget
Arguments:
- id (str): widget id
- name (str): widget type name | [
"destroy",
"remote",
"instance",
"of",
"widget"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/api.py#L559-L570 |
20c/xbahn | xbahn/api.py | WidgetAwareServer.attach_remote | def attach_remote(self, id, name, **kwargs):
"""
create remote instance of widget
Arguments:
- id (str): widget id
- name (str): widget type name
Keyword Arguments:
- any further arguments you wish to pass
to the widget constructor
... | python | def attach_remote(self, id, name, **kwargs):
"""
create remote instance of widget
Arguments:
- id (str): widget id
- name (str): widget type name
Keyword Arguments:
- any further arguments you wish to pass
to the widget constructor
... | [
"def",
"attach_remote",
"(",
"self",
",",
"id",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"client_id",
"=",
"id",
".",
"split",
"(",
"\".\"",
")",
"[",
"0",
"]",
"widget",
"=",
"self",
".",
"make_widget",
"(",
"id",
",",
"name",
",",
"dispa... | create remote instance of widget
Arguments:
- id (str): widget id
- name (str): widget type name
Keyword Arguments:
- any further arguments you wish to pass
to the widget constructor | [
"create",
"remote",
"instance",
"of",
"widget"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/api.py#L574-L600 |
20c/xbahn | xbahn/api.py | Widget.on_api_error | def on_api_error(self, error_status=None, message=None, event_origin=None):
"""
API error handling
"""
if message.meta["error"].find("Widget instance not found on server") > -1:
# widget is missing on the other side, try to re-attach
# then try again
... | python | def on_api_error(self, error_status=None, message=None, event_origin=None):
"""
API error handling
"""
if message.meta["error"].find("Widget instance not found on server") > -1:
# widget is missing on the other side, try to re-attach
# then try again
... | [
"def",
"on_api_error",
"(",
"self",
",",
"error_status",
"=",
"None",
",",
"message",
"=",
"None",
",",
"event_origin",
"=",
"None",
")",
":",
"if",
"message",
".",
"meta",
"[",
"\"error\"",
"]",
".",
"find",
"(",
"\"Widget instance not found on server\"",
"... | API error handling | [
"API",
"error",
"handling"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/api.py#L724-L738 |
eeue56/PyChat.js | pychatjs/server/connections.py | ChatConnection.write_message | def write_message(self, message):
""" Writes a message to this chat connection's handler """
logging.debug("Sending message {mes} to {usr}".format(mes=message, usr=self.id))
self.handler.write_message(message) | python | def write_message(self, message):
""" Writes a message to this chat connection's handler """
logging.debug("Sending message {mes} to {usr}".format(mes=message, usr=self.id))
self.handler.write_message(message) | [
"def",
"write_message",
"(",
"self",
",",
"message",
")",
":",
"logging",
".",
"debug",
"(",
"\"Sending message {mes} to {usr}\"",
".",
"format",
"(",
"mes",
"=",
"message",
",",
"usr",
"=",
"self",
".",
"id",
")",
")",
"self",
".",
"handler",
".",
"writ... | Writes a message to this chat connection's handler | [
"Writes",
"a",
"message",
"to",
"this",
"chat",
"connection",
"s",
"handler"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/connections.py#L21-L24 |
eeue56/PyChat.js | pychatjs/server/connections.py | ChatConnection.join_room | def join_room(self, room_name):
""" Connects to a given room
If it does not exist it is created"""
logging.debug('Joining room {ro}'.format(ro=room_name))
for room in self.rooms:
if room.name == room_name:
room.add_user(self)
... | python | def join_room(self, room_name):
""" Connects to a given room
If it does not exist it is created"""
logging.debug('Joining room {ro}'.format(ro=room_name))
for room in self.rooms:
if room.name == room_name:
room.add_user(self)
... | [
"def",
"join_room",
"(",
"self",
",",
"room_name",
")",
":",
"logging",
".",
"debug",
"(",
"'Joining room {ro}'",
".",
"format",
"(",
"ro",
"=",
"room_name",
")",
")",
"for",
"room",
"in",
"self",
".",
"rooms",
":",
"if",
"room",
".",
"name",
"==",
"... | Connects to a given room
If it does not exist it is created | [
"Connects",
"to",
"a",
"given",
"room",
"If",
"it",
"does",
"not",
"exist",
"it",
"is",
"created"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/connections.py#L26-L41 |
eeue56/PyChat.js | pychatjs/server/connections.py | ChatConnection.send_to_room | def send_to_room(self, message, room_name):
""" Sends a given message to a given room """
room = self.get_room(room_name)
if room is not None:
room.send_message(message) | python | def send_to_room(self, message, room_name):
""" Sends a given message to a given room """
room = self.get_room(room_name)
if room is not None:
room.send_message(message) | [
"def",
"send_to_room",
"(",
"self",
",",
"message",
",",
"room_name",
")",
":",
"room",
"=",
"self",
".",
"get_room",
"(",
"room_name",
")",
"if",
"room",
"is",
"not",
"None",
":",
"room",
".",
"send_message",
"(",
"message",
")"
] | Sends a given message to a given room | [
"Sends",
"a",
"given",
"message",
"to",
"a",
"given",
"room"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/connections.py#L43-L48 |
eeue56/PyChat.js | pychatjs/server/connections.py | ChatConnection._send_to_all_rooms | def _send_to_all_rooms(self, message):
""" Send a message to all connected rooms """
for room in self._rooms.values():
room.send_message(message) | python | def _send_to_all_rooms(self, message):
""" Send a message to all connected rooms """
for room in self._rooms.values():
room.send_message(message) | [
"def",
"_send_to_all_rooms",
"(",
"self",
",",
"message",
")",
":",
"for",
"room",
"in",
"self",
".",
"_rooms",
".",
"values",
"(",
")",
":",
"room",
".",
"send_message",
"(",
"message",
")"
] | Send a message to all connected rooms | [
"Send",
"a",
"message",
"to",
"all",
"connected",
"rooms"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/connections.py#L50-L53 |
eeue56/PyChat.js | pychatjs/server/connections.py | ChatConnection.close | def close(self):
""" Closes the connection by removing the user from all rooms """
logging.debug('Closing for user {user}'.format(user=self.id.name))
self.id.release_name()
for room in self._rooms.values():
room.disconnect(self) | python | def close(self):
""" Closes the connection by removing the user from all rooms """
logging.debug('Closing for user {user}'.format(user=self.id.name))
self.id.release_name()
for room in self._rooms.values():
room.disconnect(self) | [
"def",
"close",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"'Closing for user {user}'",
".",
"format",
"(",
"user",
"=",
"self",
".",
"id",
".",
"name",
")",
")",
"self",
".",
"id",
".",
"release_name",
"(",
")",
"for",
"room",
"in",
"self"... | Closes the connection by removing the user from all rooms | [
"Closes",
"the",
"connection",
"by",
"removing",
"the",
"user",
"from",
"all",
"rooms"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/connections.py#L55-L60 |
Ffisegydd/whatis | whatis/_type.py | get_type | def get_type(obj, **kwargs):
"""Return the type of an object. Do some regex to remove the "<class..." bit."""
t = type(obj)
s = extract_type(str(t))
return 'Type: {}'.format(s) | python | def get_type(obj, **kwargs):
"""Return the type of an object. Do some regex to remove the "<class..." bit."""
t = type(obj)
s = extract_type(str(t))
return 'Type: {}'.format(s) | [
"def",
"get_type",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"t",
"=",
"type",
"(",
"obj",
")",
"s",
"=",
"extract_type",
"(",
"str",
"(",
"t",
")",
")",
"return",
"'Type: {}'",
".",
"format",
"(",
"s",
")"
] | Return the type of an object. Do some regex to remove the "<class..." bit. | [
"Return",
"the",
"type",
"of",
"an",
"object",
".",
"Do",
"some",
"regex",
"to",
"remove",
"the",
"<class",
"...",
"bit",
"."
] | train | https://github.com/Ffisegydd/whatis/blob/eef780ced61aae6d001aeeef7574e5e27e613583/whatis/_type.py#L8-L14 |
Ffisegydd/whatis | whatis/_type.py | get_parents | def get_parents(obj, **kwargs):
"""Return the MRO of an object. Do regex on each element to remove the "<class..." bit."""
num_of_mro = kwargs.get("num_of_mro", 5)
mro = getmro(obj.__class__)
mro_string = ', '.join([extract_type(str(t)) for t in mro[:num_of_mro]])
return "Hierarchy: {}".format(mro... | python | def get_parents(obj, **kwargs):
"""Return the MRO of an object. Do regex on each element to remove the "<class..." bit."""
num_of_mro = kwargs.get("num_of_mro", 5)
mro = getmro(obj.__class__)
mro_string = ', '.join([extract_type(str(t)) for t in mro[:num_of_mro]])
return "Hierarchy: {}".format(mro... | [
"def",
"get_parents",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"num_of_mro",
"=",
"kwargs",
".",
"get",
"(",
"\"num_of_mro\"",
",",
"5",
")",
"mro",
"=",
"getmro",
"(",
"obj",
".",
"__class__",
")",
"mro_string",
"=",
"', '",
".",
"join",
"(",
... | Return the MRO of an object. Do regex on each element to remove the "<class..." bit. | [
"Return",
"the",
"MRO",
"of",
"an",
"object",
".",
"Do",
"regex",
"on",
"each",
"element",
"to",
"remove",
"the",
"<class",
"...",
"bit",
"."
] | train | https://github.com/Ffisegydd/whatis/blob/eef780ced61aae6d001aeeef7574e5e27e613583/whatis/_type.py#L17-L24 |
c0ntrol-x/p4rr0t007 | p4rr0t007/lib/core.py | colorize_logger | def colorize_logger(logger, stream=None, level=logging.DEBUG):
"""resets the handlers and formatters in a given logger, and sets it up with Colorful() logs
"""
logger.handlers = []
logger.filters = []
stream = stream or sys.stderr
handler = logging.StreamHandler(stream=stream)
handler.setLev... | python | def colorize_logger(logger, stream=None, level=logging.DEBUG):
"""resets the handlers and formatters in a given logger, and sets it up with Colorful() logs
"""
logger.handlers = []
logger.filters = []
stream = stream or sys.stderr
handler = logging.StreamHandler(stream=stream)
handler.setLev... | [
"def",
"colorize_logger",
"(",
"logger",
",",
"stream",
"=",
"None",
",",
"level",
"=",
"logging",
".",
"DEBUG",
")",
":",
"logger",
".",
"handlers",
"=",
"[",
"]",
"logger",
".",
"filters",
"=",
"[",
"]",
"stream",
"=",
"stream",
"or",
"sys",
".",
... | resets the handlers and formatters in a given logger, and sets it up with Colorful() logs | [
"resets",
"the",
"handlers",
"and",
"formatters",
"in",
"a",
"given",
"logger",
"and",
"sets",
"it",
"up",
"with",
"Colorful",
"()",
"logs"
] | train | https://github.com/c0ntrol-x/p4rr0t007/blob/6fe88ec1231a778b9f1d13bc61332581715d646e/p4rr0t007/lib/core.py#L27-L37 |
c0ntrol-x/p4rr0t007 | p4rr0t007/lib/core.py | get_logger | def get_logger(name=None, level=logging.DEBUG, stream=None):
"""returns a colorized logger. This function can be used just like
:py:func:`logging.getLogger` except you can set the level right
away."""
logger = logging.getLogger(name)
colored = colorize_logger(logger, stream=stream, level=level)
... | python | def get_logger(name=None, level=logging.DEBUG, stream=None):
"""returns a colorized logger. This function can be used just like
:py:func:`logging.getLogger` except you can set the level right
away."""
logger = logging.getLogger(name)
colored = colorize_logger(logger, stream=stream, level=level)
... | [
"def",
"get_logger",
"(",
"name",
"=",
"None",
",",
"level",
"=",
"logging",
".",
"DEBUG",
",",
"stream",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"colored",
"=",
"colorize_logger",
"(",
"logger",
",",
"strea... | returns a colorized logger. This function can be used just like
:py:func:`logging.getLogger` except you can set the level right
away. | [
"returns",
"a",
"colorized",
"logger",
".",
"This",
"function",
"can",
"be",
"used",
"just",
"like",
":",
"py",
":",
"func",
":",
"logging",
".",
"getLogger",
"except",
"you",
"can",
"set",
"the",
"level",
"right",
"away",
"."
] | train | https://github.com/c0ntrol-x/p4rr0t007/blob/6fe88ec1231a778b9f1d13bc61332581715d646e/p4rr0t007/lib/core.py#L40-L46 |
c0ntrol-x/p4rr0t007 | p4rr0t007/lib/core.py | python_object_name | def python_object_name(item, module=True):
"""takes a python object and returns its import path.
:param item: the source object
:param module: bool - defaults to ``True`` - whether the object name should be prefixed by its module name.
"""
if not isinstance(item, type):
return python_object_... | python | def python_object_name(item, module=True):
"""takes a python object and returns its import path.
:param item: the source object
:param module: bool - defaults to ``True`` - whether the object name should be prefixed by its module name.
"""
if not isinstance(item, type):
return python_object_... | [
"def",
"python_object_name",
"(",
"item",
",",
"module",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"item",
",",
"type",
")",
":",
"return",
"python_object_name",
"(",
"type",
"(",
"item",
")",
")",
"return",
"br'.'",
".",
"join",
"(",
"fil... | takes a python object and returns its import path.
:param item: the source object
:param module: bool - defaults to ``True`` - whether the object name should be prefixed by its module name. | [
"takes",
"a",
"python",
"object",
"and",
"returns",
"its",
"import",
"path",
".",
":",
"param",
"item",
":",
"the",
"source",
"object",
":",
"param",
"module",
":",
"bool",
"-",
"defaults",
"to",
"True",
"-",
"whether",
"the",
"object",
"name",
"should",... | train | https://github.com/c0ntrol-x/p4rr0t007/blob/6fe88ec1231a778b9f1d13bc61332581715d646e/p4rr0t007/lib/core.py#L62-L70 |
c0ntrol-x/p4rr0t007 | p4rr0t007/lib/core.py | lpad | def lpad(s, N, char='\0'):
"""pads a string to the left with null-bytes or any other given character.
..note:: This is used by the :py:func:`xor` function.
:param s: the string
:param N: an integer of how much padding should be done
:returns: the original bytes
"""
assert isinstance(char, ... | python | def lpad(s, N, char='\0'):
"""pads a string to the left with null-bytes or any other given character.
..note:: This is used by the :py:func:`xor` function.
:param s: the string
:param N: an integer of how much padding should be done
:returns: the original bytes
"""
assert isinstance(char, ... | [
"def",
"lpad",
"(",
"s",
",",
"N",
",",
"char",
"=",
"'\\0'",
")",
":",
"assert",
"isinstance",
"(",
"char",
",",
"bytes",
")",
"and",
"len",
"(",
"char",
")",
"==",
"1",
",",
"'char should be a string with length 1'",
"return",
"s",
".",
"rjust",
"(",... | pads a string to the left with null-bytes or any other given character.
..note:: This is used by the :py:func:`xor` function.
:param s: the string
:param N: an integer of how much padding should be done
:returns: the original bytes | [
"pads",
"a",
"string",
"to",
"the",
"left",
"with",
"null",
"-",
"bytes",
"or",
"any",
"other",
"given",
"character",
"."
] | train | https://github.com/c0ntrol-x/p4rr0t007/blob/6fe88ec1231a778b9f1d13bc61332581715d646e/p4rr0t007/lib/core.py#L89-L99 |
c0ntrol-x/p4rr0t007 | p4rr0t007/lib/core.py | rpad | def rpad(s, N, char='\0'):
"""pads a string to the right with null-bytes or any other given character.
..note:: This is used by the :py:func:`xor` function.
:param s: the string
:param N: an integer of how much padding should be done
:returns: the original bytes
"""
assert isinstance(char,... | python | def rpad(s, N, char='\0'):
"""pads a string to the right with null-bytes or any other given character.
..note:: This is used by the :py:func:`xor` function.
:param s: the string
:param N: an integer of how much padding should be done
:returns: the original bytes
"""
assert isinstance(char,... | [
"def",
"rpad",
"(",
"s",
",",
"N",
",",
"char",
"=",
"'\\0'",
")",
":",
"assert",
"isinstance",
"(",
"char",
",",
"bytes",
")",
"and",
"len",
"(",
"char",
")",
"==",
"1",
",",
"'char should be a string with length 1'",
"return",
"s",
".",
"ljust",
"(",... | pads a string to the right with null-bytes or any other given character.
..note:: This is used by the :py:func:`xor` function.
:param s: the string
:param N: an integer of how much padding should be done
:returns: the original bytes | [
"pads",
"a",
"string",
"to",
"the",
"right",
"with",
"null",
"-",
"bytes",
"or",
"any",
"other",
"given",
"character",
"."
] | train | https://github.com/c0ntrol-x/p4rr0t007/blob/6fe88ec1231a778b9f1d13bc61332581715d646e/p4rr0t007/lib/core.py#L102-L112 |
c0ntrol-x/p4rr0t007 | p4rr0t007/lib/core.py | xor | def xor(left, right):
"""xor 2 strings. They can be shorter than each other, in which case
the shortest will be padded with null bytes at its right.
:param left: a string to be the left side of the xor
:param right: a string to be the left side of the xor
"""
maxlength = max(map(len, (left, rig... | python | def xor(left, right):
"""xor 2 strings. They can be shorter than each other, in which case
the shortest will be padded with null bytes at its right.
:param left: a string to be the left side of the xor
:param right: a string to be the left side of the xor
"""
maxlength = max(map(len, (left, rig... | [
"def",
"xor",
"(",
"left",
",",
"right",
")",
":",
"maxlength",
"=",
"max",
"(",
"map",
"(",
"len",
",",
"(",
"left",
",",
"right",
")",
")",
")",
"ileft",
"=",
"string_to_int",
"(",
"rpad",
"(",
"left",
",",
"maxlength",
")",
")",
"iright",
"=",... | xor 2 strings. They can be shorter than each other, in which case
the shortest will be padded with null bytes at its right.
:param left: a string to be the left side of the xor
:param right: a string to be the left side of the xor | [
"xor",
"2",
"strings",
".",
"They",
"can",
"be",
"shorter",
"than",
"each",
"other",
"in",
"which",
"case",
"the",
"shortest",
"will",
"be",
"padded",
"with",
"null",
"bytes",
"at",
"its",
"right",
"."
] | train | https://github.com/c0ntrol-x/p4rr0t007/blob/6fe88ec1231a778b9f1d13bc61332581715d646e/p4rr0t007/lib/core.py#L124-L136 |
c0ntrol-x/p4rr0t007 | p4rr0t007/lib/core.py | slugify | def slugify(string, repchar='_'):
"""replaces all non-alphanumeric chars in the string with the given repchar.
:param string: the source string
:param repchar:
"""
slug_regex = re.compile(r'(^[{0}._-]+|[^a-z-A-Z0-9_.-]+|[{0}._-]+$)'.format(repchar))
strip_regex = re.compile(r'[{0}._-]+'.format(... | python | def slugify(string, repchar='_'):
"""replaces all non-alphanumeric chars in the string with the given repchar.
:param string: the source string
:param repchar:
"""
slug_regex = re.compile(r'(^[{0}._-]+|[^a-z-A-Z0-9_.-]+|[{0}._-]+$)'.format(repchar))
strip_regex = re.compile(r'[{0}._-]+'.format(... | [
"def",
"slugify",
"(",
"string",
",",
"repchar",
"=",
"'_'",
")",
":",
"slug_regex",
"=",
"re",
".",
"compile",
"(",
"r'(^[{0}._-]+|[^a-z-A-Z0-9_.-]+|[{0}._-]+$)'",
".",
"format",
"(",
"repchar",
")",
")",
"strip_regex",
"=",
"re",
".",
"compile",
"(",
"r'[{... | replaces all non-alphanumeric chars in the string with the given repchar.
:param string: the source string
:param repchar: | [
"replaces",
"all",
"non",
"-",
"alphanumeric",
"chars",
"in",
"the",
"string",
"with",
"the",
"given",
"repchar",
"."
] | train | https://github.com/c0ntrol-x/p4rr0t007/blob/6fe88ec1231a778b9f1d13bc61332581715d646e/p4rr0t007/lib/core.py#L304-L323 |
rackerlabs/rackspace-python-neutronclient | neutronclient/common/serializer.py | ActionDispatcher.dispatch | def dispatch(self, *args, **kwargs):
"""Find and call local method."""
action = kwargs.pop('action', 'default')
action_method = getattr(self, str(action), self.default)
return action_method(*args, **kwargs) | python | def dispatch(self, *args, **kwargs):
"""Find and call local method."""
action = kwargs.pop('action', 'default')
action_method = getattr(self, str(action), self.default)
return action_method(*args, **kwargs) | [
"def",
"dispatch",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"action",
"=",
"kwargs",
".",
"pop",
"(",
"'action'",
",",
"'default'",
")",
"action_method",
"=",
"getattr",
"(",
"self",
",",
"str",
"(",
"action",
")",
",",
"se... | Find and call local method. | [
"Find",
"and",
"call",
"local",
"method",
"."
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/common/serializer.py#L33-L37 |
treycucco/bidon | bidon/configuration.py | Configuration.update | def update(self, **kwargs):
"""Creates or updates a property for the instance for each parameter."""
for key, value in kwargs.items():
setattr(self, key, value) | python | def update(self, **kwargs):
"""Creates or updates a property for the instance for each parameter."""
for key, value in kwargs.items():
setattr(self, key, value) | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"key",
",",
"value",
")"
] | Creates or updates a property for the instance for each parameter. | [
"Creates",
"or",
"updates",
"a",
"property",
"for",
"the",
"instance",
"for",
"each",
"parameter",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/configuration.py#L17-L20 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/template.py | _varFindLimitSpace | def _varFindLimitSpace(basedir, vars, space, part, lookup_fatal, depth):
''' limits the search space of space to part
basically does space.get(part, None), but with
templating for part and a few more things
'''
# Previous part couldn't be found, nothing to limit to
if space is None:
... | python | def _varFindLimitSpace(basedir, vars, space, part, lookup_fatal, depth):
''' limits the search space of space to part
basically does space.get(part, None), but with
templating for part and a few more things
'''
# Previous part couldn't be found, nothing to limit to
if space is None:
... | [
"def",
"_varFindLimitSpace",
"(",
"basedir",
",",
"vars",
",",
"space",
",",
"part",
",",
"lookup_fatal",
",",
"depth",
")",
":",
"# Previous part couldn't be found, nothing to limit to",
"if",
"space",
"is",
"None",
":",
"return",
"space",
"# A part with escaped .s i... | limits the search space of space to part
basically does space.get(part, None), but with
templating for part and a few more things | [
"limits",
"the",
"search",
"space",
"of",
"space",
"to",
"part",
"basically",
"does",
"space",
".",
"get",
"(",
"part",
"None",
")",
"but",
"with",
"templating",
"for",
"part",
"and",
"a",
"few",
"more",
"things"
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/template.py#L36-L71 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/template.py | _varFind | def _varFind(basedir, text, vars, lookup_fatal, depth=0):
''' Searches for a variable in text and finds its replacement in vars
The variables can have two formats;
- simple, $ followed by alphanumerics and/or underscores
- complex, ${ followed by alphanumerics, underscores, periods, braces and brackets... | python | def _varFind(basedir, text, vars, lookup_fatal, depth=0):
''' Searches for a variable in text and finds its replacement in vars
The variables can have two formats;
- simple, $ followed by alphanumerics and/or underscores
- complex, ${ followed by alphanumerics, underscores, periods, braces and brackets... | [
"def",
"_varFind",
"(",
"basedir",
",",
"text",
",",
"vars",
",",
"lookup_fatal",
",",
"depth",
"=",
"0",
")",
":",
"start",
"=",
"text",
".",
"find",
"(",
"\"$\"",
")",
"if",
"start",
"==",
"-",
"1",
":",
"return",
"None",
"# $ as last character",
"... | Searches for a variable in text and finds its replacement in vars
The variables can have two formats;
- simple, $ followed by alphanumerics and/or underscores
- complex, ${ followed by alphanumerics, underscores, periods, braces and brackets, ended by a }
Examples:
- $variable: simple variable tha... | [
"Searches",
"for",
"a",
"variable",
"in",
"text",
"and",
"finds",
"its",
"replacement",
"in",
"vars"
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/template.py#L73-L184 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/template.py | varReplace | def varReplace(basedir, raw, vars, lookup_fatal=True, depth=0, expand_lists=False):
''' Perform variable replacement of $variables in string raw using vars dictionary '''
# this code originally from yum
if (depth > 20):
raise errors.AnsibleError("template recursion depth exceeded")
done = [] #... | python | def varReplace(basedir, raw, vars, lookup_fatal=True, depth=0, expand_lists=False):
''' Perform variable replacement of $variables in string raw using vars dictionary '''
# this code originally from yum
if (depth > 20):
raise errors.AnsibleError("template recursion depth exceeded")
done = [] #... | [
"def",
"varReplace",
"(",
"basedir",
",",
"raw",
",",
"vars",
",",
"lookup_fatal",
"=",
"True",
",",
"depth",
"=",
"0",
",",
"expand_lists",
"=",
"False",
")",
":",
"# this code originally from yum",
"if",
"(",
"depth",
">",
"20",
")",
":",
"raise",
"err... | Perform variable replacement of $variables in string raw using vars dictionary | [
"Perform",
"variable",
"replacement",
"of",
"$variables",
"in",
"string",
"raw",
"using",
"vars",
"dictionary"
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/template.py#L186-L217 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/template.py | template_ds | def template_ds(basedir, varname, vars, lookup_fatal=True, depth=0):
''' templates a data structure by traversing it and substituting for other data structures '''
if isinstance(varname, basestring):
m = _varFind(basedir, varname, vars, lookup_fatal, depth)
if not m:
return varname
... | python | def template_ds(basedir, varname, vars, lookup_fatal=True, depth=0):
''' templates a data structure by traversing it and substituting for other data structures '''
if isinstance(varname, basestring):
m = _varFind(basedir, varname, vars, lookup_fatal, depth)
if not m:
return varname
... | [
"def",
"template_ds",
"(",
"basedir",
",",
"varname",
",",
"vars",
",",
"lookup_fatal",
"=",
"True",
",",
"depth",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"varname",
",",
"basestring",
")",
":",
"m",
"=",
"_varFind",
"(",
"basedir",
",",
"varname"... | templates a data structure by traversing it and substituting for other data structures | [
"templates",
"a",
"data",
"structure",
"by",
"traversing",
"it",
"and",
"substituting",
"for",
"other",
"data",
"structures"
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/template.py#L219-L241 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/template.py | template | def template(basedir, text, vars, lookup_fatal=True, expand_lists=False):
''' run a text buffer through the templating engine until it no longer changes '''
try:
text = text.decode('utf-8')
except UnicodeEncodeError:
pass # already unicode
text = varReplace(basedir, unicode(text), vars,... | python | def template(basedir, text, vars, lookup_fatal=True, expand_lists=False):
''' run a text buffer through the templating engine until it no longer changes '''
try:
text = text.decode('utf-8')
except UnicodeEncodeError:
pass # already unicode
text = varReplace(basedir, unicode(text), vars,... | [
"def",
"template",
"(",
"basedir",
",",
"text",
",",
"vars",
",",
"lookup_fatal",
"=",
"True",
",",
"expand_lists",
"=",
"False",
")",
":",
"try",
":",
"text",
"=",
"text",
".",
"decode",
"(",
"'utf-8'",
")",
"except",
"UnicodeEncodeError",
":",
"pass",
... | run a text buffer through the templating engine until it no longer changes | [
"run",
"a",
"text",
"buffer",
"through",
"the",
"templating",
"engine",
"until",
"it",
"no",
"longer",
"changes"
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/template.py#L243-L251 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/template.py | template_from_file | def template_from_file(basedir, path, vars):
''' run a file through the templating engine '''
from cirruscluster.ext.ansible import utils
realpath = utils.path_dwim(basedir, path)
loader=jinja2.FileSystemLoader([basedir,os.path.dirname(realpath)])
environment = jinja2.Environment(loader=loader, tri... | python | def template_from_file(basedir, path, vars):
''' run a file through the templating engine '''
from cirruscluster.ext.ansible import utils
realpath = utils.path_dwim(basedir, path)
loader=jinja2.FileSystemLoader([basedir,os.path.dirname(realpath)])
environment = jinja2.Environment(loader=loader, tri... | [
"def",
"template_from_file",
"(",
"basedir",
",",
"path",
",",
"vars",
")",
":",
"from",
"cirruscluster",
".",
"ext",
".",
"ansible",
"import",
"utils",
"realpath",
"=",
"utils",
".",
"path_dwim",
"(",
"basedir",
",",
"path",
")",
"loader",
"=",
"jinja2",
... | run a file through the templating engine | [
"run",
"a",
"file",
"through",
"the",
"templating",
"engine"
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/template.py#L311-L369 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/template.py | _jinja2_vars.add_locals | def add_locals(self, locals):
'''
If locals are provided, create a copy of self containing those
locals in addition to what is already in this variable proxy.
'''
if locals is None:
return self
return _jinja2_vars(self.basedir, self.vars, self.globals, locals,... | python | def add_locals(self, locals):
'''
If locals are provided, create a copy of self containing those
locals in addition to what is already in this variable proxy.
'''
if locals is None:
return self
return _jinja2_vars(self.basedir, self.vars, self.globals, locals,... | [
"def",
"add_locals",
"(",
"self",
",",
"locals",
")",
":",
"if",
"locals",
"is",
"None",
":",
"return",
"self",
"return",
"_jinja2_vars",
"(",
"self",
".",
"basedir",
",",
"self",
".",
"vars",
",",
"self",
".",
"globals",
",",
"locals",
",",
"*",
"se... | If locals are provided, create a copy of self containing those
locals in addition to what is already in this variable proxy. | [
"If",
"locals",
"are",
"provided",
"create",
"a",
"copy",
"of",
"self",
"containing",
"those",
"locals",
"in",
"addition",
"to",
"what",
"is",
"already",
"in",
"this",
"variable",
"proxy",
"."
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/template.py#L292-L299 |
a1ezzz/wasp-launcher | wasp_launcher/apps/web/wasp.py | WErrorPresenter.error_code | def error_code(self, code):
"""
:param code:
:return:
"""
context = {
'error_title': "Damn error page %i" % code,
'error_header': "What has happened?",
'error_footer': "WHY!?!?!",
'error_messages': {
('Error %i' % code): self.__message__(code)
}
}
return WWebTemplateResponse(WTemplateT... | python | def error_code(self, code):
"""
:param code:
:return:
"""
context = {
'error_title': "Damn error page %i" % code,
'error_header': "What has happened?",
'error_footer': "WHY!?!?!",
'error_messages': {
('Error %i' % code): self.__message__(code)
}
}
return WWebTemplateResponse(WTemplateT... | [
"def",
"error_code",
"(",
"self",
",",
"code",
")",
":",
"context",
"=",
"{",
"'error_title'",
":",
"\"Damn error page %i\"",
"%",
"code",
",",
"'error_header'",
":",
"\"What has happened?\"",
",",
"'error_footer'",
":",
"\"WHY!?!?!\"",
",",
"'error_messages'",
":... | :param code:
:return: | [
":",
"param",
"code",
":",
":",
"return",
":"
] | train | https://github.com/a1ezzz/wasp-launcher/blob/38b476286fb422830207031935d3af1fe8da316d/wasp_launcher/apps/web/wasp.py#L213-L227 |
alexhayes/django-toolkit | django_toolkit/templatetags/cache_helpers.py | expire_cache | def expire_cache(fragment_name, *args):
"""
Expire a cache item.
@param url: The url object
@param product_names: A list of product names
@param start: The date from which the reporting should start.
@param stop: The date at which the reporting should stop.
"""
cache_key = make_temp... | python | def expire_cache(fragment_name, *args):
"""
Expire a cache item.
@param url: The url object
@param product_names: A list of product names
@param start: The date from which the reporting should start.
@param stop: The date at which the reporting should stop.
"""
cache_key = make_temp... | [
"def",
"expire_cache",
"(",
"fragment_name",
",",
"*",
"args",
")",
":",
"cache_key",
"=",
"make_template_fragment_key",
"(",
"fragment_name",
",",
"args",
")",
"cache",
".",
"delete",
"(",
"cache_key",
")"
] | Expire a cache item.
@param url: The url object
@param product_names: A list of product names
@param start: The date from which the reporting should start.
@param stop: The date at which the reporting should stop. | [
"Expire",
"a",
"cache",
"item",
"."
] | train | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/templatetags/cache_helpers.py#L8-L18 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.