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 |
|---|---|---|---|---|---|---|---|---|---|---|
tBaxter/tango-comments | build/lib/tango_comments/moderation.py | CommentModerator.allow | def allow(self, comment, content_object, request):
"""
Determine whether a given comment is allowed to be posted on
a given object.
Return ``True`` if the comment should be allowed, ``False
otherwise.
"""
if self.enable_field:
if not getattr(content_... | python | def allow(self, comment, content_object, request):
"""
Determine whether a given comment is allowed to be posted on
a given object.
Return ``True`` if the comment should be allowed, ``False
otherwise.
"""
if self.enable_field:
if not getattr(content_... | [
"def",
"allow",
"(",
"self",
",",
"comment",
",",
"content_object",
",",
"request",
")",
":",
"if",
"self",
".",
"enable_field",
":",
"if",
"not",
"getattr",
"(",
"content_object",
",",
"self",
".",
"enable_field",
")",
":",
"return",
"False",
"if",
"sel... | Determine whether a given comment is allowed to be posted on
a given object.
Return ``True`` if the comment should be allowed, ``False
otherwise. | [
"Determine",
"whether",
"a",
"given",
"comment",
"is",
"allowed",
"to",
"be",
"posted",
"on",
"a",
"given",
"object",
"."
] | train | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/moderation.py#L199-L215 |
tBaxter/tango-comments | build/lib/tango_comments/moderation.py | CommentModerator.moderate | def moderate(self, comment, content_object, request):
"""
Determine whether a given comment on a given object should be
allowed to show up immediately, or should be marked non-public
and await approval.
Return ``True`` if the comment should be moderated (marked
non-publi... | python | def moderate(self, comment, content_object, request):
"""
Determine whether a given comment on a given object should be
allowed to show up immediately, or should be marked non-public
and await approval.
Return ``True`` if the comment should be moderated (marked
non-publi... | [
"def",
"moderate",
"(",
"self",
",",
"comment",
",",
"content_object",
",",
"request",
")",
":",
"if",
"self",
".",
"auto_moderate_field",
"and",
"self",
".",
"moderate_after",
"is",
"not",
"None",
":",
"moderate_after_date",
"=",
"getattr",
"(",
"content_obje... | Determine whether a given comment on a given object should be
allowed to show up immediately, or should be marked non-public
and await approval.
Return ``True`` if the comment should be moderated (marked
non-public), ``False`` otherwise. | [
"Determine",
"whether",
"a",
"given",
"comment",
"on",
"a",
"given",
"object",
"should",
"be",
"allowed",
"to",
"show",
"up",
"immediately",
"or",
"should",
"be",
"marked",
"non",
"-",
"public",
"and",
"await",
"approval",
"."
] | train | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/moderation.py#L217-L231 |
tBaxter/tango-comments | build/lib/tango_comments/moderation.py | CommentModerator.email | def email(self, comment, content_object, request):
"""
Send email notification of a new comment to site staff when email
notifications have been requested.
"""
if not self.email_notification:
return
recipient_list = [manager_tuple[1] for manager_tuple in sett... | python | def email(self, comment, content_object, request):
"""
Send email notification of a new comment to site staff when email
notifications have been requested.
"""
if not self.email_notification:
return
recipient_list = [manager_tuple[1] for manager_tuple in sett... | [
"def",
"email",
"(",
"self",
",",
"comment",
",",
"content_object",
",",
"request",
")",
":",
"if",
"not",
"self",
".",
"email_notification",
":",
"return",
"recipient_list",
"=",
"[",
"manager_tuple",
"[",
"1",
"]",
"for",
"manager_tuple",
"in",
"settings",... | Send email notification of a new comment to site staff when email
notifications have been requested. | [
"Send",
"email",
"notification",
"of",
"a",
"new",
"comment",
"to",
"site",
"staff",
"when",
"email",
"notifications",
"have",
"been",
"requested",
"."
] | train | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/moderation.py#L233-L248 |
tBaxter/tango-comments | build/lib/tango_comments/moderation.py | Moderator.connect | def connect(self):
"""
Hook up the moderation methods to pre- and post-save signals
from the comment models.
"""
signals.comment_will_be_posted.connect(self.pre_save_moderation, sender=comments.get_model())
signals.comment_was_posted.connect(self.post_save_moderation, se... | python | def connect(self):
"""
Hook up the moderation methods to pre- and post-save signals
from the comment models.
"""
signals.comment_will_be_posted.connect(self.pre_save_moderation, sender=comments.get_model())
signals.comment_was_posted.connect(self.post_save_moderation, se... | [
"def",
"connect",
"(",
"self",
")",
":",
"signals",
".",
"comment_will_be_posted",
".",
"connect",
"(",
"self",
".",
"pre_save_moderation",
",",
"sender",
"=",
"comments",
".",
"get_model",
"(",
")",
")",
"signals",
".",
"comment_was_posted",
".",
"connect",
... | Hook up the moderation methods to pre- and post-save signals
from the comment models. | [
"Hook",
"up",
"the",
"moderation",
"methods",
"to",
"pre",
"-",
"and",
"post",
"-",
"save",
"signals",
"from",
"the",
"comment",
"models",
"."
] | train | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/moderation.py#L285-L292 |
tBaxter/tango-comments | build/lib/tango_comments/moderation.py | Moderator.register | def register(self, model_or_iterable, moderation_class):
"""
Register a model or a list of models for comment moderation,
using a particular moderation class.
Raise ``AlreadyModerated`` if any of the models are already
registered.
"""
if isinstance(model_or_iter... | python | def register(self, model_or_iterable, moderation_class):
"""
Register a model or a list of models for comment moderation,
using a particular moderation class.
Raise ``AlreadyModerated`` if any of the models are already
registered.
"""
if isinstance(model_or_iter... | [
"def",
"register",
"(",
"self",
",",
"model_or_iterable",
",",
"moderation_class",
")",
":",
"if",
"isinstance",
"(",
"model_or_iterable",
",",
"ModelBase",
")",
":",
"model_or_iterable",
"=",
"[",
"model_or_iterable",
"]",
"for",
"model",
"in",
"model_or_iterable... | Register a model or a list of models for comment moderation,
using a particular moderation class.
Raise ``AlreadyModerated`` if any of the models are already
registered. | [
"Register",
"a",
"model",
"or",
"a",
"list",
"of",
"models",
"for",
"comment",
"moderation",
"using",
"a",
"particular",
"moderation",
"class",
"."
] | train | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/moderation.py#L294-L310 |
tBaxter/tango-comments | build/lib/tango_comments/moderation.py | Moderator.unregister | def unregister(self, model_or_iterable):
"""
Remove a model or a list of models from the list of models
whose comments will be moderated.
Raise ``NotModerated`` if any of the models are not currently
registered for moderation.
"""
if isinstance(model_or_iterable... | python | def unregister(self, model_or_iterable):
"""
Remove a model or a list of models from the list of models
whose comments will be moderated.
Raise ``NotModerated`` if any of the models are not currently
registered for moderation.
"""
if isinstance(model_or_iterable... | [
"def",
"unregister",
"(",
"self",
",",
"model_or_iterable",
")",
":",
"if",
"isinstance",
"(",
"model_or_iterable",
",",
"ModelBase",
")",
":",
"model_or_iterable",
"=",
"[",
"model_or_iterable",
"]",
"for",
"model",
"in",
"model_or_iterable",
":",
"if",
"model"... | Remove a model or a list of models from the list of models
whose comments will be moderated.
Raise ``NotModerated`` if any of the models are not currently
registered for moderation. | [
"Remove",
"a",
"model",
"or",
"a",
"list",
"of",
"models",
"from",
"the",
"list",
"of",
"models",
"whose",
"comments",
"will",
"be",
"moderated",
"."
] | train | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/moderation.py#L312-L326 |
tBaxter/tango-comments | build/lib/tango_comments/moderation.py | Moderator.pre_save_moderation | def pre_save_moderation(self, sender, comment, request, **kwargs):
"""
Apply any necessary pre-save moderation steps to new
comments.
"""
model = comment.content_type.model_class()
if model not in self._registry:
return
content_object = comment.conten... | python | def pre_save_moderation(self, sender, comment, request, **kwargs):
"""
Apply any necessary pre-save moderation steps to new
comments.
"""
model = comment.content_type.model_class()
if model not in self._registry:
return
content_object = comment.conten... | [
"def",
"pre_save_moderation",
"(",
"self",
",",
"sender",
",",
"comment",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"model",
"=",
"comment",
".",
"content_type",
".",
"model_class",
"(",
")",
"if",
"model",
"not",
"in",
"self",
".",
"_registry",... | Apply any necessary pre-save moderation steps to new
comments. | [
"Apply",
"any",
"necessary",
"pre",
"-",
"save",
"moderation",
"steps",
"to",
"new",
"comments",
"."
] | train | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/moderation.py#L328-L345 |
tBaxter/tango-comments | build/lib/tango_comments/moderation.py | Moderator.post_save_moderation | def post_save_moderation(self, sender, comment, request, **kwargs):
"""
Apply any necessary post-save moderation steps to new
comments.
"""
model = comment.content_type.model_class()
if model not in self._registry:
return
self._registry[model].email(c... | python | def post_save_moderation(self, sender, comment, request, **kwargs):
"""
Apply any necessary post-save moderation steps to new
comments.
"""
model = comment.content_type.model_class()
if model not in self._registry:
return
self._registry[model].email(c... | [
"def",
"post_save_moderation",
"(",
"self",
",",
"sender",
",",
"comment",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"model",
"=",
"comment",
".",
"content_type",
".",
"model_class",
"(",
")",
"if",
"model",
"not",
"in",
"self",
".",
"_registry"... | Apply any necessary post-save moderation steps to new
comments. | [
"Apply",
"any",
"necessary",
"post",
"-",
"save",
"moderation",
"steps",
"to",
"new",
"comments",
"."
] | train | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/moderation.py#L347-L356 |
hapylestat/apputils | examples/progressBar_Sample.py | do_status_progress | def do_status_progress(p, hide=False):
"""
:type p ProgressBar
:type hide bool
"""
p.start(10)
for i in range(1, 60):
p.progress_inc(new_status="count %s" % i)
time.sleep(0.1)
p.stop(hide_progress=hide, new_status="done") | python | def do_status_progress(p, hide=False):
"""
:type p ProgressBar
:type hide bool
"""
p.start(10)
for i in range(1, 60):
p.progress_inc(new_status="count %s" % i)
time.sleep(0.1)
p.stop(hide_progress=hide, new_status="done") | [
"def",
"do_status_progress",
"(",
"p",
",",
"hide",
"=",
"False",
")",
":",
"p",
".",
"start",
"(",
"10",
")",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"60",
")",
":",
"p",
".",
"progress_inc",
"(",
"new_status",
"=",
"\"count %s\"",
"%",
"i",
"... | :type p ProgressBar
:type hide bool | [
":",
"type",
"p",
"ProgressBar",
":",
"type",
"hide",
"bool"
] | train | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/examples/progressBar_Sample.py#L13-L24 |
pjuren/pyokit | src/pyokit/scripts/fdr.py | main | def main(args):
"""
main entry point for the FDR script.
:param args: the arguments for this script, as a list of string. Should
already have had things like the script name stripped. That
is, if there are no args provided, this should be an empty
list.
"""
# get ... | python | def main(args):
"""
main entry point for the FDR script.
:param args: the arguments for this script, as a list of string. Should
already have had things like the script name stripped. That
is, if there are no args provided, this should be an empty
list.
"""
# get ... | [
"def",
"main",
"(",
"args",
")",
":",
"# get options and arguments",
"ui",
"=",
"getUI",
"(",
"args",
")",
"if",
"ui",
".",
"optionIsSet",
"(",
"\"test\"",
")",
":",
"# just run unit tests",
"unittest",
".",
"main",
"(",
"argv",
"=",
"[",
"sys",
".",
"ar... | main entry point for the FDR script.
:param args: the arguments for this script, as a list of string. Should
already have had things like the script name stripped. That
is, if there are no args provided, this should be an empty
list. | [
"main",
"entry",
"point",
"for",
"the",
"FDR",
"script",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/scripts/fdr.py#L182-L226 |
pjuren/pyokit | src/pyokit/scripts/fdr.py | DataTable.load | def load(self, in_fh, header=False, delimit=None, verbose=False):
"""
Load this data_table from a stream or file.
Blank lines in the file are skipped. Any existing values in this dataTable
object are cleared before loading the new ones.
:param in_fh: load from this stream. Can also be a string,... | python | def load(self, in_fh, header=False, delimit=None, verbose=False):
"""
Load this data_table from a stream or file.
Blank lines in the file are skipped. Any existing values in this dataTable
object are cleared before loading the new ones.
:param in_fh: load from this stream. Can also be a string,... | [
"def",
"load",
"(",
"self",
",",
"in_fh",
",",
"header",
"=",
"False",
",",
"delimit",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"self",
".",
"clear",
"(",
")",
"if",
"verbose",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"getting in... | Load this data_table from a stream or file.
Blank lines in the file are skipped. Any existing values in this dataTable
object are cleared before loading the new ones.
:param in_fh: load from this stream. Can also be a string, in which case
we treat it as a filename and attempt to l... | [
"Load",
"this",
"data_table",
"from",
"a",
"stream",
"or",
"file",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/scripts/fdr.py#L66-L103 |
pjuren/pyokit | src/pyokit/scripts/fdr.py | DataTable.write | def write(self, strm, delim, verbose=False):
"""
Write this data frame to a stream or file.
:param strm: stream to write to; can also be a string, in which case we
treat it as a filename and to open that file for writing
to.
:param delim: delimiter to us... | python | def write(self, strm, delim, verbose=False):
"""
Write this data frame to a stream or file.
:param strm: stream to write to; can also be a string, in which case we
treat it as a filename and to open that file for writing
to.
:param delim: delimiter to us... | [
"def",
"write",
"(",
"self",
",",
"strm",
",",
"delim",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"verbose",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"outputing...\\n\"",
")",
"# figure out whether we need to open a file or not",
"out_strm",
"=",
"s... | Write this data frame to a stream or file.
:param strm: stream to write to; can also be a string, in which case we
treat it as a filename and to open that file for writing
to.
:param delim: delimiter to use between columns.
:param verbose: if True, output p... | [
"Write",
"this",
"data",
"frame",
"to",
"a",
"stream",
"or",
"file",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/scripts/fdr.py#L105-L131 |
solocompt/plugs-filter | plugs_filter/filtersets.py | Meta.attach_core_filters | def attach_core_filters(cls):
"""
Attach core filters to filterset
"""
opts = cls._meta
base_filters = cls.base_filters.copy()
cls.base_filters.clear()
for name, filter_ in six.iteritems(base_filters):
if isinstance(filter_, AutoFilters):
... | python | def attach_core_filters(cls):
"""
Attach core filters to filterset
"""
opts = cls._meta
base_filters = cls.base_filters.copy()
cls.base_filters.clear()
for name, filter_ in six.iteritems(base_filters):
if isinstance(filter_, AutoFilters):
... | [
"def",
"attach_core_filters",
"(",
"cls",
")",
":",
"opts",
"=",
"cls",
".",
"_meta",
"base_filters",
"=",
"cls",
".",
"base_filters",
".",
"copy",
"(",
")",
"cls",
".",
"base_filters",
".",
"clear",
"(",
")",
"for",
"name",
",",
"filter_",
"in",
"six"... | Attach core filters to filterset | [
"Attach",
"core",
"filters",
"to",
"filterset"
] | train | https://github.com/solocompt/plugs-filter/blob/cb34c7d662d3f96c07c10b3ed0a34bafef78b52c/plugs_filter/filtersets.py#L35-L54 |
zerc/django-vest | django_vest/decorators.py | themeble | def themeble(name, themes=None, global_context=None):
""" Decorator for registering objects (i.e. functions, classes) for
different themes.
Params:
* name - type of string. New global name for object
* themes - for this themes ``obj`` will be have alias with given name
* global_con... | python | def themeble(name, themes=None, global_context=None):
""" Decorator for registering objects (i.e. functions, classes) for
different themes.
Params:
* name - type of string. New global name for object
* themes - for this themes ``obj`` will be have alias with given name
* global_con... | [
"def",
"themeble",
"(",
"name",
",",
"themes",
"=",
"None",
",",
"global_context",
"=",
"None",
")",
":",
"def",
"wrap",
"(",
"obj",
")",
":",
"context",
"=",
"global_context",
"or",
"inspect",
".",
"stack",
"(",
")",
"[",
"1",
"]",
"[",
"0",
"]",
... | Decorator for registering objects (i.e. functions, classes) for
different themes.
Params:
* name - type of string. New global name for object
* themes - for this themes ``obj`` will be have alias with given name
* global_context - current decorator's global context
Example:
.... | [
"Decorator",
"for",
"registering",
"objects",
"(",
"i",
".",
"e",
".",
"functions",
"classes",
")",
"for",
"different",
"themes",
"."
] | train | https://github.com/zerc/django-vest/blob/39dbd0cd4de59ad8f5d06d1cc4d5fbcd210ab764/django_vest/decorators.py#L14-L67 |
zerc/django-vest | django_vest/decorators.py | only_for | def only_for(theme, redirect_to='/', raise_error=None):
""" Decorator for restrict access to views according by list of themes.
Params:
* ``theme`` - string or list of themes where decorated view must be
* ``redirect_to`` - url or name of url pattern for redirect
if CURRENT_THEME n... | python | def only_for(theme, redirect_to='/', raise_error=None):
""" Decorator for restrict access to views according by list of themes.
Params:
* ``theme`` - string or list of themes where decorated view must be
* ``redirect_to`` - url or name of url pattern for redirect
if CURRENT_THEME n... | [
"def",
"only_for",
"(",
"theme",
",",
"redirect_to",
"=",
"'/'",
",",
"raise_error",
"=",
"None",
")",
":",
"def",
"check_theme",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"theme",
",",
"six",
".",
"string_types",
... | Decorator for restrict access to views according by list of themes.
Params:
* ``theme`` - string or list of themes where decorated view must be
* ``redirect_to`` - url or name of url pattern for redirect
if CURRENT_THEME not in themes
* ``raise_error`` - error class for raising... | [
"Decorator",
"for",
"restrict",
"access",
"to",
"views",
"according",
"by",
"list",
"of",
"themes",
"."
] | train | https://github.com/zerc/django-vest/blob/39dbd0cd4de59ad8f5d06d1cc4d5fbcd210ab764/django_vest/decorators.py#L70-L108 |
heikomuller/sco-datastore | scodata/experiment.py | DefaultExperimentManager.create_object | def create_object(self, subject_id, image_group_id, properties, fmri_data_id=None):
"""Create an experiment object for the subject and image group. Objects
are referenced by their identifier. The reference to a functional data
object is optional.
Raises ValueError if no valid experiment... | python | def create_object(self, subject_id, image_group_id, properties, fmri_data_id=None):
"""Create an experiment object for the subject and image group. Objects
are referenced by their identifier. The reference to a functional data
object is optional.
Raises ValueError if no valid experiment... | [
"def",
"create_object",
"(",
"self",
",",
"subject_id",
",",
"image_group_id",
",",
"properties",
",",
"fmri_data_id",
"=",
"None",
")",
":",
"# Ensure that experiment name is given in property list.",
"if",
"not",
"datastore",
".",
"PROPERTY_NAME",
"in",
"properties",
... | Create an experiment object for the subject and image group. Objects
are referenced by their identifier. The reference to a functional data
object is optional.
Raises ValueError if no valid experiment name is given in property list.
Parameters
----------
subject_id : st... | [
"Create",
"an",
"experiment",
"object",
"for",
"the",
"subject",
"and",
"image",
"group",
".",
"Objects",
"are",
"referenced",
"by",
"their",
"identifier",
".",
"The",
"reference",
"to",
"a",
"functional",
"data",
"object",
"is",
"optional",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/experiment.py#L111-L151 |
heikomuller/sco-datastore | scodata/experiment.py | DefaultExperimentManager.from_dict | def from_dict(self, document):
"""Create experiment object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ExperimentHandle
Handle for experiment object
"... | python | def from_dict(self, document):
"""Create experiment object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ExperimentHandle
Handle for experiment object
"... | [
"def",
"from_dict",
"(",
"self",
",",
"document",
")",
":",
"identifier",
"=",
"str",
"(",
"document",
"[",
"'_id'",
"]",
")",
"active",
"=",
"document",
"[",
"'active'",
"]",
"timestamp",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"document... | Create experiment object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ExperimentHandle
Handle for experiment object | [
"Create",
"experiment",
"object",
"from",
"JSON",
"document",
"retrieved",
"from",
"database",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/experiment.py#L153-L181 |
heikomuller/sco-datastore | scodata/experiment.py | DefaultExperimentManager.list_objects | def list_objects(self, query=None, limit=-1, offset=-1):
"""List of all experiments in the database. Overrides the super class
method to allow the returned object's property lists to be extended
with the run count.
Parameters
----------
query : Dictionary
Fil... | python | def list_objects(self, query=None, limit=-1, offset=-1):
"""List of all experiments in the database. Overrides the super class
method to allow the returned object's property lists to be extended
with the run count.
Parameters
----------
query : Dictionary
Fil... | [
"def",
"list_objects",
"(",
"self",
",",
"query",
"=",
"None",
",",
"limit",
"=",
"-",
"1",
",",
"offset",
"=",
"-",
"1",
")",
":",
"# Call super class method to get the object listing",
"result",
"=",
"super",
"(",
"DefaultExperimentManager",
",",
"self",
")"... | List of all experiments in the database. Overrides the super class
method to allow the returned object's property lists to be extended
with the run count.
Parameters
----------
query : Dictionary
Filter objects by property-value pairs defined by dictionary.
l... | [
"List",
"of",
"all",
"experiments",
"in",
"the",
"database",
".",
"Overrides",
"the",
"super",
"class",
"method",
"to",
"allow",
"the",
"returned",
"object",
"s",
"property",
"lists",
"to",
"be",
"extended",
"with",
"the",
"run",
"count",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/experiment.py#L183-L224 |
heikomuller/sco-datastore | scodata/experiment.py | DefaultExperimentManager.to_dict | def to_dict(self, experiment):
"""Create a Json-like object for an experiment. Extends the basic
object with subject, image group, and (optional) functional data
identifiers.
Parameters
----------
experiment : ExperimentHandle
Returns
-------
Jso... | python | def to_dict(self, experiment):
"""Create a Json-like object for an experiment. Extends the basic
object with subject, image group, and (optional) functional data
identifiers.
Parameters
----------
experiment : ExperimentHandle
Returns
-------
Jso... | [
"def",
"to_dict",
"(",
"self",
",",
"experiment",
")",
":",
"# Get the basic Json object from the super class",
"json_obj",
"=",
"super",
"(",
"DefaultExperimentManager",
",",
"self",
")",
".",
"to_dict",
"(",
"experiment",
")",
"# Add associated object references",
"js... | Create a Json-like object for an experiment. Extends the basic
object with subject, image group, and (optional) functional data
identifiers.
Parameters
----------
experiment : ExperimentHandle
Returns
-------
Json Object
Json-like object, i.e... | [
"Create",
"a",
"Json",
"-",
"like",
"object",
"for",
"an",
"experiment",
".",
"Extends",
"the",
"basic",
"object",
"with",
"subject",
"image",
"group",
"and",
"(",
"optional",
")",
"functional",
"data",
"identifiers",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/experiment.py#L226-L247 |
heikomuller/sco-datastore | scodata/experiment.py | DefaultExperimentManager.update_fmri_data | def update_fmri_data(self, identifier, fmri_data_id):
"""Associate the fMRI object with the identified experiment.
Parameters
----------
identifier : string
Unique experiment object identifier
fmri_data_id : string
Unique fMRI data object identifier
... | python | def update_fmri_data(self, identifier, fmri_data_id):
"""Associate the fMRI object with the identified experiment.
Parameters
----------
identifier : string
Unique experiment object identifier
fmri_data_id : string
Unique fMRI data object identifier
... | [
"def",
"update_fmri_data",
"(",
"self",
",",
"identifier",
",",
"fmri_data_id",
")",
":",
"# Get experiment to ensure that it exists",
"experiment",
"=",
"self",
".",
"get_object",
"(",
"identifier",
")",
"if",
"experiment",
"is",
"None",
":",
"return",
"None",
"#... | Associate the fMRI object with the identified experiment.
Parameters
----------
identifier : string
Unique experiment object identifier
fmri_data_id : string
Unique fMRI data object identifier
Returns
-------
ExperimentHandle
... | [
"Associate",
"the",
"fMRI",
"object",
"with",
"the",
"identified",
"experiment",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/experiment.py#L249-L273 |
FujiMakoto/IPS-Vagrant | ips_vagrant/common/__init__.py | config | def config():
"""
Load system configuration
@rtype: ConfigParser
"""
cfg = ConfigParser()
cfg.read(os.path.join(os.path.dirname(os.path.realpath(ips_vagrant.__file__)), 'config/ipsv.conf'))
return cfg | python | def config():
"""
Load system configuration
@rtype: ConfigParser
"""
cfg = ConfigParser()
cfg.read(os.path.join(os.path.dirname(os.path.realpath(ips_vagrant.__file__)), 'config/ipsv.conf'))
return cfg | [
"def",
"config",
"(",
")",
":",
"cfg",
"=",
"ConfigParser",
"(",
")",
"cfg",
".",
"read",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"ips_vagrant",
".",
"__file__",
"... | Load system configuration
@rtype: ConfigParser | [
"Load",
"system",
"configuration"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/__init__.py#L12-L19 |
FujiMakoto/IPS-Vagrant | ips_vagrant/common/__init__.py | choice | def choice(opts, default=1, text='Please make a choice.'):
"""
Prompt the user to select an option
@param opts: List of tuples containing options in (key, value) format - value is optional
@type opts: list of tuple
@param text: Prompt text
@type text: str
"""
opts_len = len... | python | def choice(opts, default=1, text='Please make a choice.'):
"""
Prompt the user to select an option
@param opts: List of tuples containing options in (key, value) format - value is optional
@type opts: list of tuple
@param text: Prompt text
@type text: str
"""
opts_len = len... | [
"def",
"choice",
"(",
"opts",
",",
"default",
"=",
"1",
",",
"text",
"=",
"'Please make a choice.'",
")",
":",
"opts_len",
"=",
"len",
"(",
"opts",
")",
"opts_enum",
"=",
"enumerate",
"(",
"opts",
",",
"1",
")",
"opts",
"=",
"list",
"(",
"opts",
")",... | Prompt the user to select an option
@param opts: List of tuples containing options in (key, value) format - value is optional
@type opts: list of tuple
@param text: Prompt text
@type text: str | [
"Prompt",
"the",
"user",
"to",
"select",
"an",
"option"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/__init__.py#L22-L40 |
FujiMakoto/IPS-Vagrant | ips_vagrant/common/__init__.py | styled_status | def styled_status(enabled, bold=True):
"""
Generate a styled status string
@param enabled: Enabled / Disabled boolean
@type enabled: bool
@param bold: Display status in bold format
@type bold: bool
@rtype: str
"""
return click.style('Enabled' if enabled else '... | python | def styled_status(enabled, bold=True):
"""
Generate a styled status string
@param enabled: Enabled / Disabled boolean
@type enabled: bool
@param bold: Display status in bold format
@type bold: bool
@rtype: str
"""
return click.style('Enabled' if enabled else '... | [
"def",
"styled_status",
"(",
"enabled",
",",
"bold",
"=",
"True",
")",
":",
"return",
"click",
".",
"style",
"(",
"'Enabled'",
"if",
"enabled",
"else",
"'Disabled'",
",",
"'green'",
"if",
"enabled",
"else",
"'red'",
",",
"bold",
"=",
"bold",
")"
] | Generate a styled status string
@param enabled: Enabled / Disabled boolean
@type enabled: bool
@param bold: Display status in bold format
@type bold: bool
@rtype: str | [
"Generate",
"a",
"styled",
"status",
"string"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/__init__.py#L43-L52 |
FujiMakoto/IPS-Vagrant | ips_vagrant/common/__init__.py | domain_parse | def domain_parse(url):
"""
urlparse wrapper for user input
@type url: str
@rtype: urlparse.ParseResult
"""
url = url.lower()
if not url.startswith('http://') and not url.startswith('https://'):
url = '{schema}{host}'.format(schema='http://', host=url)
url = urlparse(url)
... | python | def domain_parse(url):
"""
urlparse wrapper for user input
@type url: str
@rtype: urlparse.ParseResult
"""
url = url.lower()
if not url.startswith('http://') and not url.startswith('https://'):
url = '{schema}{host}'.format(schema='http://', host=url)
url = urlparse(url)
... | [
"def",
"domain_parse",
"(",
"url",
")",
":",
"url",
"=",
"url",
".",
"lower",
"(",
")",
"if",
"not",
"url",
".",
"startswith",
"(",
"'http://'",
")",
"and",
"not",
"url",
".",
"startswith",
"(",
"'https://'",
")",
":",
"url",
"=",
"'{schema}{host}'",
... | urlparse wrapper for user input
@type url: str
@rtype: urlparse.ParseResult | [
"urlparse",
"wrapper",
"for",
"user",
"input"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/__init__.py#L55-L70 |
FujiMakoto/IPS-Vagrant | ips_vagrant/common/__init__.py | http_session | def http_session(cookies=None):
"""
Generate a Requests session
@param cookies: Cookies to load. None loads the app default CookieJar. False disables cookie loading.
@type cookies: dict, cookielib.LWPCookieJar, None or False
@rtype requests.Session
"""
session = requests.Session()
... | python | def http_session(cookies=None):
"""
Generate a Requests session
@param cookies: Cookies to load. None loads the app default CookieJar. False disables cookie loading.
@type cookies: dict, cookielib.LWPCookieJar, None or False
@rtype requests.Session
"""
session = requests.Session()
... | [
"def",
"http_session",
"(",
"cookies",
"=",
"None",
")",
":",
"session",
"=",
"requests",
".",
"Session",
"(",
")",
"if",
"cookies",
"is",
"not",
"False",
":",
"session",
".",
"cookies",
".",
"update",
"(",
"cookies",
"or",
"cookiejar",
"(",
")",
")",
... | Generate a Requests session
@param cookies: Cookies to load. None loads the app default CookieJar. False disables cookie loading.
@type cookies: dict, cookielib.LWPCookieJar, None or False
@rtype requests.Session | [
"Generate",
"a",
"Requests",
"session"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/__init__.py#L73-L85 |
FujiMakoto/IPS-Vagrant | ips_vagrant/common/__init__.py | cookiejar | def cookiejar(name='session'):
"""
Ready the CookieJar, loading a saved session if available
@rtype: cookielib.LWPCookieJar
"""
log = logging.getLogger('ipsv.common.cookiejar')
spath = os.path.join(config().get('Paths', 'Data'), '{n}.txt'.format(n=name))
cj = cookielib.LWPCookieJar(spath)
... | python | def cookiejar(name='session'):
"""
Ready the CookieJar, loading a saved session if available
@rtype: cookielib.LWPCookieJar
"""
log = logging.getLogger('ipsv.common.cookiejar')
spath = os.path.join(config().get('Paths', 'Data'), '{n}.txt'.format(n=name))
cj = cookielib.LWPCookieJar(spath)
... | [
"def",
"cookiejar",
"(",
"name",
"=",
"'session'",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"'ipsv.common.cookiejar'",
")",
"spath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"config",
"(",
")",
".",
"get",
"(",
"'Paths'",
",",
"'Data'",... | Ready the CookieJar, loading a saved session if available
@rtype: cookielib.LWPCookieJar | [
"Ready",
"the",
"CookieJar",
"loading",
"a",
"saved",
"session",
"if",
"available"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/__init__.py#L88-L104 |
FujiMakoto/IPS-Vagrant | ips_vagrant/common/__init__.py | parse_version | def parse_version(vstring):
"""
StrictVersion / LooseVersion decorator method
@type vstring: str
@return: StrictVersion if possible, otherwise LooseVersion
@rtype: StrictVersion or LooseVersion
"""
try:
version = StrictVersion(vstring)
except ValueError:
loggi... | python | def parse_version(vstring):
"""
StrictVersion / LooseVersion decorator method
@type vstring: str
@return: StrictVersion if possible, otherwise LooseVersion
@rtype: StrictVersion or LooseVersion
"""
try:
version = StrictVersion(vstring)
except ValueError:
loggi... | [
"def",
"parse_version",
"(",
"vstring",
")",
":",
"try",
":",
"version",
"=",
"StrictVersion",
"(",
"vstring",
")",
"except",
"ValueError",
":",
"logging",
".",
"getLogger",
"(",
"'ipvs.common.debug'",
")",
".",
"info",
"(",
"'Strict parsing failed, falling back t... | StrictVersion / LooseVersion decorator method
@type vstring: str
@return: StrictVersion if possible, otherwise LooseVersion
@rtype: StrictVersion or LooseVersion | [
"StrictVersion",
"/",
"LooseVersion",
"decorator",
"method"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/__init__.py#L107-L121 |
OpenVolunteeringPlatform/django-ovp-organizations | ovp_organizations/emails.py | OrganizationMail.sendUserInvitationRevoked | def sendUserInvitationRevoked(self, context={}):
"""
Sent when user is invitation is revoked
"""
organization, invited, invitator = context['invite'].organization, context['invite'].invited, context['invite'].invitator
# invited user email
self.__init__(organization, async_mail=self.async_mail, ... | python | def sendUserInvitationRevoked(self, context={}):
"""
Sent when user is invitation is revoked
"""
organization, invited, invitator = context['invite'].organization, context['invite'].invited, context['invite'].invitator
# invited user email
self.__init__(organization, async_mail=self.async_mail, ... | [
"def",
"sendUserInvitationRevoked",
"(",
"self",
",",
"context",
"=",
"{",
"}",
")",
":",
"organization",
",",
"invited",
",",
"invitator",
"=",
"context",
"[",
"'invite'",
"]",
".",
"organization",
",",
"context",
"[",
"'invite'",
"]",
".",
"invited",
","... | Sent when user is invitation is revoked | [
"Sent",
"when",
"user",
"is",
"invitation",
"is",
"revoked"
] | train | https://github.com/OpenVolunteeringPlatform/django-ovp-organizations/blob/7c60024684024b604eb19a02d119adab547ed0d1/ovp_organizations/emails.py#L50-L67 |
OpenVolunteeringPlatform/django-ovp-organizations | ovp_organizations/emails.py | OrganizationMail.sendUserLeft | def sendUserLeft(self, context={}):
"""
Sent when user leaves organization
"""
self.__init__(context['organization'], async_mail=self.async_mail, override_receiver=context['user'].email, locale=context['user'].locale)
self.sendEmail('userLeft-toUser', 'You have left an organization', context)
s... | python | def sendUserLeft(self, context={}):
"""
Sent when user leaves organization
"""
self.__init__(context['organization'], async_mail=self.async_mail, override_receiver=context['user'].email, locale=context['user'].locale)
self.sendEmail('userLeft-toUser', 'You have left an organization', context)
s... | [
"def",
"sendUserLeft",
"(",
"self",
",",
"context",
"=",
"{",
"}",
")",
":",
"self",
".",
"__init__",
"(",
"context",
"[",
"'organization'",
"]",
",",
"async_mail",
"=",
"self",
".",
"async_mail",
",",
"override_receiver",
"=",
"context",
"[",
"'user'",
... | Sent when user leaves organization | [
"Sent",
"when",
"user",
"leaves",
"organization"
] | train | https://github.com/OpenVolunteeringPlatform/django-ovp-organizations/blob/7c60024684024b604eb19a02d119adab547ed0d1/ovp_organizations/emails.py#L70-L78 |
caspervg/pylex | src/pylex/user.py | UserRoute.all | def all(self, start=0, amount=10):
"""
Return a list of all users
:rtype: list
"""
return self._get_json('user/all', start=start, amount=amount) | python | def all(self, start=0, amount=10):
"""
Return a list of all users
:rtype: list
"""
return self._get_json('user/all', start=start, amount=amount) | [
"def",
"all",
"(",
"self",
",",
"start",
"=",
"0",
",",
"amount",
"=",
"10",
")",
":",
"return",
"self",
".",
"_get_json",
"(",
"'user/all'",
",",
"start",
"=",
"start",
",",
"amount",
"=",
"amount",
")"
] | Return a list of all users
:rtype: list | [
"Return",
"a",
"list",
"of",
"all",
"users",
":",
"rtype",
":",
"list"
] | train | https://github.com/caspervg/pylex/blob/bae00c705b5331b0f784d42b27e19dc3541e1b5a/src/pylex/user.py#L21-L26 |
caspervg/pylex | src/pylex/user.py | UserRoute.register | def register(self, username, password, email, full_name):
"""
Registers a new user on the LEX
:rtype: None
"""
if all([username, password, email, full_name]):
r = requests.post(self._base + 'user/register', params={
'username': username,
... | python | def register(self, username, password, email, full_name):
"""
Registers a new user on the LEX
:rtype: None
"""
if all([username, password, email, full_name]):
r = requests.post(self._base + 'user/register', params={
'username': username,
... | [
"def",
"register",
"(",
"self",
",",
"username",
",",
"password",
",",
"email",
",",
"full_name",
")",
":",
"if",
"all",
"(",
"[",
"username",
",",
"password",
",",
"email",
",",
"full_name",
"]",
")",
":",
"r",
"=",
"requests",
".",
"post",
"(",
"... | Registers a new user on the LEX
:rtype: None | [
"Registers",
"a",
"new",
"user",
"on",
"the",
"LEX",
":",
"rtype",
":",
"None"
] | train | https://github.com/caspervg/pylex/blob/bae00c705b5331b0f784d42b27e19dc3541e1b5a/src/pylex/user.py#L42-L57 |
caspervg/pylex | src/pylex/user.py | UserRoute.activate | def activate(self, key):
"""
Activates a new registree on the LEX with given activation key
:rtype: None
"""
url = self._base + 'user/activate'
r = requests.get(url, params={
'activation_key': key
})
r.raise_for_status() | python | def activate(self, key):
"""
Activates a new registree on the LEX with given activation key
:rtype: None
"""
url = self._base + 'user/activate'
r = requests.get(url, params={
'activation_key': key
})
r.raise_for_status() | [
"def",
"activate",
"(",
"self",
",",
"key",
")",
":",
"url",
"=",
"self",
".",
"_base",
"+",
"'user/activate'",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"params",
"=",
"{",
"'activation_key'",
":",
"key",
"}",
")",
"r",
".",
"raise_for_stat... | Activates a new registree on the LEX with given activation key
:rtype: None | [
"Activates",
"a",
"new",
"registree",
"on",
"the",
"LEX",
"with",
"given",
"activation",
"key",
":",
"rtype",
":",
"None"
] | train | https://github.com/caspervg/pylex/blob/bae00c705b5331b0f784d42b27e19dc3541e1b5a/src/pylex/user.py#L59-L68 |
cfobel/clutter-webcam-viewer | clutter_webcam_viewer/__init__.py | RecordView.refresh_config | def refresh_config(self):
'''
__NB__ This *must* be called from a *different* thread than the GUI/Gtk thread.
'''
from gi.repository import Clutter, Gst, GstVideo, ClutterGst
from path_helpers import path
from .warp import bounding_box_from_allocation
if self.con... | python | def refresh_config(self):
'''
__NB__ This *must* be called from a *different* thread than the GUI/Gtk thread.
'''
from gi.repository import Clutter, Gst, GstVideo, ClutterGst
from path_helpers import path
from .warp import bounding_box_from_allocation
if self.con... | [
"def",
"refresh_config",
"(",
"self",
")",
":",
"from",
"gi",
".",
"repository",
"import",
"Clutter",
",",
"Gst",
",",
"GstVideo",
",",
"ClutterGst",
"from",
"path_helpers",
"import",
"path",
"from",
".",
"warp",
"import",
"bounding_box_from_allocation",
"if",
... | __NB__ This *must* be called from a *different* thread than the GUI/Gtk thread. | [
"__NB__",
"This",
"*",
"must",
"*",
"be",
"called",
"from",
"a",
"*",
"different",
"*",
"thread",
"than",
"the",
"GUI",
"/",
"Gtk",
"thread",
"."
] | train | https://github.com/cfobel/clutter-webcam-viewer/blob/b227d2ae02d750194e65c13bcf178550755c3afc/clutter_webcam_viewer/__init__.py#L78-L119 |
AshleySetter/qplots | qplots/qplots/qplots.py | joint_plot | def joint_plot(x, y, marginalBins=50, gridsize=50, plotlimits=None, logscale_cmap=False, logscale_marginals=False, alpha_hexbin=0.75, alpha_marginals=0.75, cmap="inferno_r", marginalCol=None, figsize=(8, 8), fontsize=8, *args, **kwargs):
"""
Plots some x and y data using hexbins along with a colorbar
and ma... | python | def joint_plot(x, y, marginalBins=50, gridsize=50, plotlimits=None, logscale_cmap=False, logscale_marginals=False, alpha_hexbin=0.75, alpha_marginals=0.75, cmap="inferno_r", marginalCol=None, figsize=(8, 8), fontsize=8, *args, **kwargs):
"""
Plots some x and y data using hexbins along with a colorbar
and ma... | [
"def",
"joint_plot",
"(",
"x",
",",
"y",
",",
"marginalBins",
"=",
"50",
",",
"gridsize",
"=",
"50",
",",
"plotlimits",
"=",
"None",
",",
"logscale_cmap",
"=",
"False",
",",
"logscale_marginals",
"=",
"False",
",",
"alpha_hexbin",
"=",
"0.75",
",",
"alph... | Plots some x and y data using hexbins along with a colorbar
and marginal distributions (X and Y histograms).
Parameters
----------
x : ndarray
The x data
y : ndarray
The y data
marginalBins : int, optional
The number of bins to use in calculating the marginal
his... | [
"Plots",
"some",
"x",
"and",
"y",
"data",
"using",
"hexbins",
"along",
"with",
"a",
"colorbar",
"and",
"marginal",
"distributions",
"(",
"X",
"and",
"Y",
"histograms",
")",
"."
] | train | https://github.com/AshleySetter/qplots/blob/780ca98e6c08bee612d2c3db37e27e38be5ddec3/qplots/qplots/qplots.py#L11-L158 |
AshleySetter/qplots | qplots/qplots/qplots.py | dynamic_zoom_plot | def dynamic_zoom_plot(x, y, N, RegionStartSize=1000):
"""
plots 2 time traces, the top is the downsampled time trace
the bottom is the full time trace.
"""
x_lowres = x[::N]
y_lowres = y[::N]
ax1 = _plt.subplot2grid((2, 1), (0, 0), colspan=1)
ax2 = _plt.subplot2grid((2, 1), (1... | python | def dynamic_zoom_plot(x, y, N, RegionStartSize=1000):
"""
plots 2 time traces, the top is the downsampled time trace
the bottom is the full time trace.
"""
x_lowres = x[::N]
y_lowres = y[::N]
ax1 = _plt.subplot2grid((2, 1), (0, 0), colspan=1)
ax2 = _plt.subplot2grid((2, 1), (1... | [
"def",
"dynamic_zoom_plot",
"(",
"x",
",",
"y",
",",
"N",
",",
"RegionStartSize",
"=",
"1000",
")",
":",
"x_lowres",
"=",
"x",
"[",
":",
":",
"N",
"]",
"y_lowres",
"=",
"y",
"[",
":",
":",
"N",
"]",
"ax1",
"=",
"_plt",
".",
"subplot2grid",
"(",
... | plots 2 time traces, the top is the downsampled time trace
the bottom is the full time trace. | [
"plots",
"2",
"time",
"traces",
"the",
"top",
"is",
"the",
"downsampled",
"time",
"trace",
"the",
"bottom",
"is",
"the",
"full",
"time",
"trace",
"."
] | train | https://github.com/AshleySetter/qplots/blob/780ca98e6c08bee612d2c3db37e27e38be5ddec3/qplots/qplots/qplots.py#L211-L272 |
ionrock/rdo | rdo/config.py | find_config | def find_config(fname='.rdo.conf', start=None):
"""Go up until you find an rdo config.
"""
start = start or os.getcwd()
config_file = os.path.join(start, fname)
if os.path.isfile(config_file):
return config_file
parent, _ = os.path.split(start)
if parent == start:
raise Exce... | python | def find_config(fname='.rdo.conf', start=None):
"""Go up until you find an rdo config.
"""
start = start or os.getcwd()
config_file = os.path.join(start, fname)
if os.path.isfile(config_file):
return config_file
parent, _ = os.path.split(start)
if parent == start:
raise Exce... | [
"def",
"find_config",
"(",
"fname",
"=",
"'.rdo.conf'",
",",
"start",
"=",
"None",
")",
":",
"start",
"=",
"start",
"or",
"os",
".",
"getcwd",
"(",
")",
"config_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"start",
",",
"fname",
")",
"if",
"os"... | Go up until you find an rdo config. | [
"Go",
"up",
"until",
"you",
"find",
"an",
"rdo",
"config",
"."
] | train | https://github.com/ionrock/rdo/blob/1c58abdf67d69e832cadc8088b62093d2b8ca75f/rdo/config.py#L13-L25 |
ludeeus/pyruter | pyruter/cli.py | departure | def departure(stop, destination):
"""Get departure information."""
from pyruter.api import Departures
async def get_departures():
"""Get departure information."""
async with aiohttp.ClientSession() as session:
data = Departures(LOOP, stop, destination, session)
await... | python | def departure(stop, destination):
"""Get departure information."""
from pyruter.api import Departures
async def get_departures():
"""Get departure information."""
async with aiohttp.ClientSession() as session:
data = Departures(LOOP, stop, destination, session)
await... | [
"def",
"departure",
"(",
"stop",
",",
"destination",
")",
":",
"from",
"pyruter",
".",
"api",
"import",
"Departures",
"async",
"def",
"get_departures",
"(",
")",
":",
"\"\"\"Get departure information.\"\"\"",
"async",
"with",
"aiohttp",
".",
"ClientSession",
"(",
... | Get departure information. | [
"Get",
"departure",
"information",
"."
] | train | https://github.com/ludeeus/pyruter/blob/415d8b9c8bfd48caa82c1a1201bfd3beb670a117/pyruter/cli.py#L18-L28 |
ludeeus/pyruter | pyruter/cli.py | destinations | def destinations(stop):
"""Get destination information."""
from pyruter.api import Departures
async def get_destinations():
"""Get departure information."""
async with aiohttp.ClientSession() as session:
data = Departures(LOOP, stop, session=session)
result = await d... | python | def destinations(stop):
"""Get destination information."""
from pyruter.api import Departures
async def get_destinations():
"""Get departure information."""
async with aiohttp.ClientSession() as session:
data = Departures(LOOP, stop, session=session)
result = await d... | [
"def",
"destinations",
"(",
"stop",
")",
":",
"from",
"pyruter",
".",
"api",
"import",
"Departures",
"async",
"def",
"get_destinations",
"(",
")",
":",
"\"\"\"Get departure information.\"\"\"",
"async",
"with",
"aiohttp",
".",
"ClientSession",
"(",
")",
"as",
"s... | Get destination information. | [
"Get",
"destination",
"information",
"."
] | train | https://github.com/ludeeus/pyruter/blob/415d8b9c8bfd48caa82c1a1201bfd3beb670a117/pyruter/cli.py#L34-L45 |
dansackett/django-toolset | django_toolset/decorators.py | authenticated_redirect | def authenticated_redirect(view_func=None, path=None):
"""
Decorator for an already authenticated user that we don't want to serve a
view to. Instead we send them to the dashboard by default or a specified
path.
Usage:
@authenticated_redirect
@authenticated_redirect()
@auth... | python | def authenticated_redirect(view_func=None, path=None):
"""
Decorator for an already authenticated user that we don't want to serve a
view to. Instead we send them to the dashboard by default or a specified
path.
Usage:
@authenticated_redirect
@authenticated_redirect()
@auth... | [
"def",
"authenticated_redirect",
"(",
"view_func",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"default_path",
"=",
"getattr",
"(",
"settings",
",",
"'DEFAULT_AUTHENTICATED_PATH'",
",",
"'dashboard'",
")",
"if",
"view_func",
"is",
"None",
":",
"return",
"... | Decorator for an already authenticated user that we don't want to serve a
view to. Instead we send them to the dashboard by default or a specified
path.
Usage:
@authenticated_redirect
@authenticated_redirect()
@authenticated_redirect(path='home') | [
"Decorator",
"for",
"an",
"already",
"authenticated",
"user",
"that",
"we",
"don",
"t",
"want",
"to",
"serve",
"a",
"view",
"to",
".",
"Instead",
"we",
"send",
"them",
"to",
"the",
"dashboard",
"by",
"default",
"or",
"a",
"specified",
"path",
"."
] | train | https://github.com/dansackett/django-toolset/blob/a28cc19e32cf41130e848c268d26c1858a7cf26a/django_toolset/decorators.py#L7-L35 |
andsor/pyggcq | ggcq/ggcq.py | Queue.process | def process(self, job_id):
"""
Process a job by the queue
"""
self._logger.info(
'{:.2f}: Process job {}'.format(self._env.now, job_id)
)
# log time of commencement of service
self._observer.notify_service(time=self._env.now, job_id=job_id)
... | python | def process(self, job_id):
"""
Process a job by the queue
"""
self._logger.info(
'{:.2f}: Process job {}'.format(self._env.now, job_id)
)
# log time of commencement of service
self._observer.notify_service(time=self._env.now, job_id=job_id)
... | [
"def",
"process",
"(",
"self",
",",
"job_id",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"'{:.2f}: Process job {}'",
".",
"format",
"(",
"self",
".",
"_env",
".",
"now",
",",
"job_id",
")",
")",
"# log time of commencement of service",
"self",
".",
... | Process a job by the queue | [
"Process",
"a",
"job",
"by",
"the",
"queue"
] | train | https://github.com/andsor/pyggcq/blob/672b10bdeaa79d82cb4a1bf50169196334b162de/ggcq/ggcq.py#L141-L206 |
andsor/pyggcq | ggcq/ggcq.py | Source.generate | def generate(self):
"""
Source generates jobs according to the interarrival time distribution
"""
inter_arrival_time = 0.0
while True:
# wait for next job to arrive
try:
yield self._env.timeout(inter_arrival_time)
except TypeEr... | python | def generate(self):
"""
Source generates jobs according to the interarrival time distribution
"""
inter_arrival_time = 0.0
while True:
# wait for next job to arrive
try:
yield self._env.timeout(inter_arrival_time)
except TypeEr... | [
"def",
"generate",
"(",
"self",
")",
":",
"inter_arrival_time",
"=",
"0.0",
"while",
"True",
":",
"# wait for next job to arrive",
"try",
":",
"yield",
"self",
".",
"_env",
".",
"timeout",
"(",
"inter_arrival_time",
")",
"except",
"TypeError",
":",
"# error: arr... | Source generates jobs according to the interarrival time distribution | [
"Source",
"generates",
"jobs",
"according",
"to",
"the",
"interarrival",
"time",
"distribution"
] | train | https://github.com/andsor/pyggcq/blob/672b10bdeaa79d82cb4a1bf50169196334b162de/ggcq/ggcq.py#L227-L280 |
awsroadhouse/roadhouse | roadhouse/parser.py | Rule.parse | def parse(cls, rule_string):
"""
returns a list of rules
a single line may yield multiple rules
"""
result = parser.parseString(rule_string)
rules = []
# breakout port ranges into multple rules
kwargs = {}
kwargs['address'] = result.ip_and_mask o... | python | def parse(cls, rule_string):
"""
returns a list of rules
a single line may yield multiple rules
"""
result = parser.parseString(rule_string)
rules = []
# breakout port ranges into multple rules
kwargs = {}
kwargs['address'] = result.ip_and_mask o... | [
"def",
"parse",
"(",
"cls",
",",
"rule_string",
")",
":",
"result",
"=",
"parser",
".",
"parseString",
"(",
"rule_string",
")",
"rules",
"=",
"[",
"]",
"# breakout port ranges into multple rules",
"kwargs",
"=",
"{",
"}",
"kwargs",
"[",
"'address'",
"]",
"="... | returns a list of rules
a single line may yield multiple rules | [
"returns",
"a",
"list",
"of",
"rules",
"a",
"single",
"line",
"may",
"yield",
"multiple",
"rules"
] | train | https://github.com/awsroadhouse/roadhouse/blob/d7c2c316fc20a04b8cae3357996c0ce4f51d44ea/roadhouse/parser.py#L64-L82 |
stuaxo/mnd | mnd/handler.py | bind_function | def bind_function(f, dispatcher, *accept_args, **accept_kwargs):
"""
Bind a function to a dispatcher.
Takes accept_args, and accept_kwargs and creates and ArgSpec instance,
adding that to the MNDFunction which annotates the function
:param f: function to wrap
:param accept_args:
:param a... | python | def bind_function(f, dispatcher, *accept_args, **accept_kwargs):
"""
Bind a function to a dispatcher.
Takes accept_args, and accept_kwargs and creates and ArgSpec instance,
adding that to the MNDFunction which annotates the function
:param f: function to wrap
:param accept_args:
:param a... | [
"def",
"bind_function",
"(",
"f",
",",
"dispatcher",
",",
"*",
"accept_args",
",",
"*",
"*",
"accept_kwargs",
")",
":",
"argspec",
"=",
"ArgSpec",
"(",
"None",
",",
"*",
"accept_args",
",",
"*",
"*",
"accept_kwargs",
")",
"mnd",
"=",
"MNDFunction",
"(",
... | Bind a function to a dispatcher.
Takes accept_args, and accept_kwargs and creates and ArgSpec instance,
adding that to the MNDFunction which annotates the function
:param f: function to wrap
:param accept_args:
:param accept_kwargs:
:return: | [
"Bind",
"a",
"function",
"to",
"a",
"dispatcher",
"."
] | train | https://github.com/stuaxo/mnd/blob/0eb30155d310fa1e550cb9efd6486816b9231d27/mnd/handler.py#L180-L196 |
stuaxo/mnd | mnd/handler.py | bind_instancemethod | def bind_instancemethod(m, dispatcher, *accept_args, **accept_kwargs):
"""
Bind a function to a dispatcher.
Takes accept_args, and accept_kwargs and creates and ArgSpec instance,
adding that to the MNDFunction which annotates the function
:param f: function to wrap
:param accept_args:
:p... | python | def bind_instancemethod(m, dispatcher, *accept_args, **accept_kwargs):
"""
Bind a function to a dispatcher.
Takes accept_args, and accept_kwargs and creates and ArgSpec instance,
adding that to the MNDFunction which annotates the function
:param f: function to wrap
:param accept_args:
:p... | [
"def",
"bind_instancemethod",
"(",
"m",
",",
"dispatcher",
",",
"*",
"accept_args",
",",
"*",
"*",
"accept_kwargs",
")",
":",
"argspec",
"=",
"ArgSpec",
"(",
"None",
",",
"*",
"accept_args",
",",
"*",
"*",
"accept_kwargs",
")",
"mnd",
"=",
"MNDMethod",
"... | Bind a function to a dispatcher.
Takes accept_args, and accept_kwargs and creates and ArgSpec instance,
adding that to the MNDFunction which annotates the function
:param f: function to wrap
:param accept_args:
:param accept_kwargs:
:return: | [
"Bind",
"a",
"function",
"to",
"a",
"dispatcher",
"."
] | train | https://github.com/stuaxo/mnd/blob/0eb30155d310fa1e550cb9efd6486816b9231d27/mnd/handler.py#L199-L215 |
stuaxo/mnd | mnd/handler.py | handle | def handle(dispatcher, *accept_args, **accept_kwargs):
"""
:param dispatcher: dispatcher to recieve events from
:param accept_args: args to match on
:param accept_kwargs: kwargs to match on
Creates an MNDFunction instance which containing the
argspec and adds the function to the dispatcher.
... | python | def handle(dispatcher, *accept_args, **accept_kwargs):
"""
:param dispatcher: dispatcher to recieve events from
:param accept_args: args to match on
:param accept_kwargs: kwargs to match on
Creates an MNDFunction instance which containing the
argspec and adds the function to the dispatcher.
... | [
"def",
"handle",
"(",
"dispatcher",
",",
"*",
"accept_args",
",",
"*",
"*",
"accept_kwargs",
")",
":",
"def",
"bind_function_later",
"(",
"f",
")",
":",
"bind_function",
"(",
"f",
",",
"dispatcher",
",",
"*",
"accept_args",
",",
"*",
"*",
"accept_kwargs",
... | :param dispatcher: dispatcher to recieve events from
:param accept_args: args to match on
:param accept_kwargs: kwargs to match on
Creates an MNDFunction instance which containing the
argspec and adds the function to the dispatcher. | [
":",
"param",
"dispatcher",
":",
"dispatcher",
"to",
"recieve",
"events",
"from",
":",
"param",
"accept_args",
":",
"args",
"to",
"match",
"on",
":",
"param",
"accept_kwargs",
":",
"kwargs",
"to",
"match",
"on"
] | train | https://github.com/stuaxo/mnd/blob/0eb30155d310fa1e550cb9efd6486816b9231d27/mnd/handler.py#L218-L230 |
stuaxo/mnd | mnd/handler.py | MNDFunction.bind_to | def bind_to(self, argspec, dispatcher):
"""
Add our function to dispatcher
"""
self.bound_to[argspec.key].add((argspec, dispatcher))
dispatcher.bind(self.f, argspec) | python | def bind_to(self, argspec, dispatcher):
"""
Add our function to dispatcher
"""
self.bound_to[argspec.key].add((argspec, dispatcher))
dispatcher.bind(self.f, argspec) | [
"def",
"bind_to",
"(",
"self",
",",
"argspec",
",",
"dispatcher",
")",
":",
"self",
".",
"bound_to",
"[",
"argspec",
".",
"key",
"]",
".",
"add",
"(",
"(",
"argspec",
",",
"dispatcher",
")",
")",
"dispatcher",
".",
"bind",
"(",
"self",
".",
"f",
",... | Add our function to dispatcher | [
"Add",
"our",
"function",
"to",
"dispatcher"
] | train | https://github.com/stuaxo/mnd/blob/0eb30155d310fa1e550cb9efd6486816b9231d27/mnd/handler.py#L72-L77 |
stuaxo/mnd | mnd/handler.py | MNDFunction.unbind | def unbind(self):
"""
Unbind from dispatchers and target function.
:return: set of tuples containing [argspec, dispatcher]
"""
args_dispatchers = set()
f = self._wf()
if f is not None:
for ad_list in self.bound_to.values():
args_dispat... | python | def unbind(self):
"""
Unbind from dispatchers and target function.
:return: set of tuples containing [argspec, dispatcher]
"""
args_dispatchers = set()
f = self._wf()
if f is not None:
for ad_list in self.bound_to.values():
args_dispat... | [
"def",
"unbind",
"(",
"self",
")",
":",
"args_dispatchers",
"=",
"set",
"(",
")",
"f",
"=",
"self",
".",
"_wf",
"(",
")",
"if",
"f",
"is",
"not",
"None",
":",
"for",
"ad_list",
"in",
"self",
".",
"bound_to",
".",
"values",
"(",
")",
":",
"args_di... | Unbind from dispatchers and target function.
:return: set of tuples containing [argspec, dispatcher] | [
"Unbind",
"from",
"dispatchers",
"and",
"target",
"function",
"."
] | train | https://github.com/stuaxo/mnd/blob/0eb30155d310fa1e550cb9efd6486816b9231d27/mnd/handler.py#L83-L98 |
carlosp420/primer-designer | primer_designer/designer.py | PrimerDesigner.insert_taxon_in_new_fasta_file | def insert_taxon_in_new_fasta_file(self, aln):
"""primer4clades infers the codon usage table from the taxon names in the
sequences.
These names need to be enclosed by square brackets and be
present in the description of the FASTA sequence. The position is not
important. I will i... | python | def insert_taxon_in_new_fasta_file(self, aln):
"""primer4clades infers the codon usage table from the taxon names in the
sequences.
These names need to be enclosed by square brackets and be
present in the description of the FASTA sequence. The position is not
important. I will i... | [
"def",
"insert_taxon_in_new_fasta_file",
"(",
"self",
",",
"aln",
")",
":",
"new_seq_records",
"=",
"[",
"]",
"for",
"seq_record",
"in",
"SeqIO",
".",
"parse",
"(",
"aln",
",",
"'fasta'",
")",
":",
"new_seq_record_id",
"=",
"\"[{0}] {1}\"",
".",
"format",
"(... | primer4clades infers the codon usage table from the taxon names in the
sequences.
These names need to be enclosed by square brackets and be
present in the description of the FASTA sequence. The position is not
important. I will insert the names in the description in a new FASTA
... | [
"primer4clades",
"infers",
"the",
"codon",
"usage",
"table",
"from",
"the",
"taxon",
"names",
"in",
"the",
"sequences",
"."
] | train | https://github.com/carlosp420/primer-designer/blob/586cb7fecf41fedbffe6563c8b79a3156c6066ae/primer_designer/designer.py#L155-L176 |
carlosp420/primer-designer | primer_designer/designer.py | PrimerDesigner.make_report_from_html_file | def make_report_from_html_file(self, response_body, this_file):
"""Processes the results from primer4clades (a html file).
Makes a report based on the best possible primer pair (with highest
quality and longest amplicon).
"""
amplicon_tuples = self.get_amplicon_data_as_tuples(re... | python | def make_report_from_html_file(self, response_body, this_file):
"""Processes the results from primer4clades (a html file).
Makes a report based on the best possible primer pair (with highest
quality and longest amplicon).
"""
amplicon_tuples = self.get_amplicon_data_as_tuples(re... | [
"def",
"make_report_from_html_file",
"(",
"self",
",",
"response_body",
",",
"this_file",
")",
":",
"amplicon_tuples",
"=",
"self",
".",
"get_amplicon_data_as_tuples",
"(",
"response_body",
")",
"best_amplicon",
"=",
"self",
".",
"choose_best_amplicon",
"(",
"amplicon... | Processes the results from primer4clades (a html file).
Makes a report based on the best possible primer pair (with highest
quality and longest amplicon). | [
"Processes",
"the",
"results",
"from",
"primer4clades",
"(",
"a",
"html",
"file",
")",
"."
] | train | https://github.com/carlosp420/primer-designer/blob/586cb7fecf41fedbffe6563c8b79a3156c6066ae/primer_designer/designer.py#L190-L205 |
carlosp420/primer-designer | primer_designer/designer.py | PrimerDesigner.group_primers | def group_primers(self, my_list):
"""Group elements in list by certain number 'n'"""
new_list = []
n = 2
for i in range(0, len(my_list), n):
grouped_primers = my_list[i:i + n]
forward_primer = grouped_primers[0].split(" ")
reverse_primer = grouped_prim... | python | def group_primers(self, my_list):
"""Group elements in list by certain number 'n'"""
new_list = []
n = 2
for i in range(0, len(my_list), n):
grouped_primers = my_list[i:i + n]
forward_primer = grouped_primers[0].split(" ")
reverse_primer = grouped_prim... | [
"def",
"group_primers",
"(",
"self",
",",
"my_list",
")",
":",
"new_list",
"=",
"[",
"]",
"n",
"=",
"2",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"my_list",
")",
",",
"n",
")",
":",
"grouped_primers",
"=",
"my_list",
"[",
"i",
":",
... | Group elements in list by certain number 'n | [
"Group",
"elements",
"in",
"list",
"by",
"certain",
"number",
"n"
] | train | https://github.com/carlosp420/primer-designer/blob/586cb7fecf41fedbffe6563c8b79a3156c6066ae/primer_designer/designer.py#L241-L252 |
carlosp420/primer-designer | primer_designer/designer.py | PrimerDesigner.choose_best_amplicon | def choose_best_amplicon(self, amplicon_tuples):
"""Iterates over amplicon tuples and returns the one with highest quality
and amplicon length.
"""
quality = 0
amplicon_length = 0
best_amplicon = None
for amplicon in amplicon_tuples:
if int(amplicon[4... | python | def choose_best_amplicon(self, amplicon_tuples):
"""Iterates over amplicon tuples and returns the one with highest quality
and amplicon length.
"""
quality = 0
amplicon_length = 0
best_amplicon = None
for amplicon in amplicon_tuples:
if int(amplicon[4... | [
"def",
"choose_best_amplicon",
"(",
"self",
",",
"amplicon_tuples",
")",
":",
"quality",
"=",
"0",
"amplicon_length",
"=",
"0",
"best_amplicon",
"=",
"None",
"for",
"amplicon",
"in",
"amplicon_tuples",
":",
"if",
"int",
"(",
"amplicon",
"[",
"4",
"]",
")",
... | Iterates over amplicon tuples and returns the one with highest quality
and amplicon length. | [
"Iterates",
"over",
"amplicon",
"tuples",
"and",
"returns",
"the",
"one",
"with",
"highest",
"quality",
"and",
"amplicon",
"length",
"."
] | train | https://github.com/carlosp420/primer-designer/blob/586cb7fecf41fedbffe6563c8b79a3156c6066ae/primer_designer/designer.py#L254-L268 |
jaraco/jaraco.context | jaraco/context.py | run | def run():
"""
Run a command in the context of the system dependencies.
"""
parser = argparse.ArgumentParser()
parser.add_argument(
'--deps-def',
default=data_lines_from_file("system deps.txt")
+ data_lines_from_file("build deps.txt"),
help="A file specifying the dependencies (one per line)",
type=data_l... | python | def run():
"""
Run a command in the context of the system dependencies.
"""
parser = argparse.ArgumentParser()
parser.add_argument(
'--deps-def',
default=data_lines_from_file("system deps.txt")
+ data_lines_from_file("build deps.txt"),
help="A file specifying the dependencies (one per line)",
type=data_l... | [
"def",
"run",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'--deps-def'",
",",
"default",
"=",
"data_lines_from_file",
"(",
"\"system deps.txt\"",
")",
"+",
"data_lines_from_file",
"(",
"\"build ... | Run a command in the context of the system dependencies. | [
"Run",
"a",
"command",
"in",
"the",
"context",
"of",
"the",
"system",
"dependencies",
"."
] | train | https://github.com/jaraco/jaraco.context/blob/105f81a6204d3a9fbb848675d62be4ef185f36f2/jaraco/context.py#L61-L98 |
jaraco/jaraco.context | jaraco/context.py | dependency_context | def dependency_context(package_names, aggressively_remove=False):
"""
Install the supplied packages and yield. Finally, remove all packages
that were installed.
Currently assumes 'aptitude' is available.
"""
installed_packages = []
log = logging.getLogger(__name__)
try:
if not package_names:
logging.debug(... | python | def dependency_context(package_names, aggressively_remove=False):
"""
Install the supplied packages and yield. Finally, remove all packages
that were installed.
Currently assumes 'aptitude' is available.
"""
installed_packages = []
log = logging.getLogger(__name__)
try:
if not package_names:
logging.debug(... | [
"def",
"dependency_context",
"(",
"package_names",
",",
"aggressively_remove",
"=",
"False",
")",
":",
"installed_packages",
"=",
"[",
"]",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"try",
":",
"if",
"not",
"package_names",
":",
"logging",... | Install the supplied packages and yield. Finally, remove all packages
that were installed.
Currently assumes 'aptitude' is available. | [
"Install",
"the",
"supplied",
"packages",
"and",
"yield",
".",
"Finally",
"remove",
"all",
"packages",
"that",
"were",
"installed",
".",
"Currently",
"assumes",
"aptitude",
"is",
"available",
"."
] | train | https://github.com/jaraco/jaraco.context/blob/105f81a6204d3a9fbb848675d62be4ef185f36f2/jaraco/context.py#L109-L149 |
jaraco/jaraco.context | jaraco/context.py | tarball_context | def tarball_context(url, target_dir=None, runner=None, pushd=pushd):
"""
Get a tarball, extract it, change to that directory, yield, then
clean up.
`runner` is the function to invoke commands.
`pushd` is a context manager for changing the directory.
"""
if target_dir is None:
target_dir = os.path.basename(url)... | python | def tarball_context(url, target_dir=None, runner=None, pushd=pushd):
"""
Get a tarball, extract it, change to that directory, yield, then
clean up.
`runner` is the function to invoke commands.
`pushd` is a context manager for changing the directory.
"""
if target_dir is None:
target_dir = os.path.basename(url)... | [
"def",
"tarball_context",
"(",
"url",
",",
"target_dir",
"=",
"None",
",",
"runner",
"=",
"None",
",",
"pushd",
"=",
"pushd",
")",
":",
"if",
"target_dir",
"is",
"None",
":",
"target_dir",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"url",
")",
"."... | Get a tarball, extract it, change to that directory, yield, then
clean up.
`runner` is the function to invoke commands.
`pushd` is a context manager for changing the directory. | [
"Get",
"a",
"tarball",
"extract",
"it",
"change",
"to",
"that",
"directory",
"yield",
"then",
"clean",
"up",
".",
"runner",
"is",
"the",
"function",
"to",
"invoke",
"commands",
".",
"pushd",
"is",
"a",
"context",
"manager",
"for",
"changing",
"the",
"direc... | train | https://github.com/jaraco/jaraco.context/blob/105f81a6204d3a9fbb848675d62be4ef185f36f2/jaraco/context.py#L163-L188 |
jaraco/jaraco.context | jaraco/context.py | infer_compression | def infer_compression(url):
"""
Given a URL or filename, infer the compression code for tar.
"""
# cheat and just assume it's the last two characters
compression_indicator = url[-2:]
mapping = dict(
gz='z',
bz='j',
xz='J',
)
# Assume 'z' (gzip) if no match
return mapping.get(compression_indicator, 'z') | python | def infer_compression(url):
"""
Given a URL or filename, infer the compression code for tar.
"""
# cheat and just assume it's the last two characters
compression_indicator = url[-2:]
mapping = dict(
gz='z',
bz='j',
xz='J',
)
# Assume 'z' (gzip) if no match
return mapping.get(compression_indicator, 'z') | [
"def",
"infer_compression",
"(",
"url",
")",
":",
"# cheat and just assume it's the last two characters",
"compression_indicator",
"=",
"url",
"[",
"-",
"2",
":",
"]",
"mapping",
"=",
"dict",
"(",
"gz",
"=",
"'z'",
",",
"bz",
"=",
"'j'",
",",
"xz",
"=",
"'J'... | Given a URL or filename, infer the compression code for tar. | [
"Given",
"a",
"URL",
"or",
"filename",
"infer",
"the",
"compression",
"code",
"for",
"tar",
"."
] | train | https://github.com/jaraco/jaraco.context/blob/105f81a6204d3a9fbb848675d62be4ef185f36f2/jaraco/context.py#L191-L203 |
jaraco/jaraco.context | jaraco/context.py | temp_dir | def temp_dir(remover=shutil.rmtree):
"""
Create a temporary directory context. Pass a custom remover
to override the removal behavior.
"""
temp_dir = tempfile.mkdtemp()
try:
yield temp_dir
finally:
remover(temp_dir) | python | def temp_dir(remover=shutil.rmtree):
"""
Create a temporary directory context. Pass a custom remover
to override the removal behavior.
"""
temp_dir = tempfile.mkdtemp()
try:
yield temp_dir
finally:
remover(temp_dir) | [
"def",
"temp_dir",
"(",
"remover",
"=",
"shutil",
".",
"rmtree",
")",
":",
"temp_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"try",
":",
"yield",
"temp_dir",
"finally",
":",
"remover",
"(",
"temp_dir",
")"
] | Create a temporary directory context. Pass a custom remover
to override the removal behavior. | [
"Create",
"a",
"temporary",
"directory",
"context",
".",
"Pass",
"a",
"custom",
"remover",
"to",
"override",
"the",
"removal",
"behavior",
"."
] | train | https://github.com/jaraco/jaraco.context/blob/105f81a6204d3a9fbb848675d62be4ef185f36f2/jaraco/context.py#L207-L216 |
jaraco/jaraco.context | jaraco/context.py | repo_context | def repo_context(url, branch=None, quiet=True, dest_ctx=temp_dir):
"""
Check out the repo indicated by url.
If dest_ctx is supplied, it should be a context manager
to yield the target directory for the check out.
"""
exe = 'git' if 'git' in url else 'hg'
with dest_ctx() as repo_dir:
cmd = [exe, 'clone', url, ... | python | def repo_context(url, branch=None, quiet=True, dest_ctx=temp_dir):
"""
Check out the repo indicated by url.
If dest_ctx is supplied, it should be a context manager
to yield the target directory for the check out.
"""
exe = 'git' if 'git' in url else 'hg'
with dest_ctx() as repo_dir:
cmd = [exe, 'clone', url, ... | [
"def",
"repo_context",
"(",
"url",
",",
"branch",
"=",
"None",
",",
"quiet",
"=",
"True",
",",
"dest_ctx",
"=",
"temp_dir",
")",
":",
"exe",
"=",
"'git'",
"if",
"'git'",
"in",
"url",
"else",
"'hg'",
"with",
"dest_ctx",
"(",
")",
"as",
"repo_dir",
":"... | Check out the repo indicated by url.
If dest_ctx is supplied, it should be a context manager
to yield the target directory for the check out. | [
"Check",
"out",
"the",
"repo",
"indicated",
"by",
"url",
"."
] | train | https://github.com/jaraco/jaraco.context/blob/105f81a6204d3a9fbb848675d62be4ef185f36f2/jaraco/context.py#L220-L235 |
minhhoit/yacms | yacms/utils/device.py | device_from_request | def device_from_request(request):
"""
Determine's the device name from the request by first looking for an
overridding cookie, and if not found then matching the user agent.
Used at both the template level for choosing the template to load and
also at the cache level as a cache key prefix.
"""
... | python | def device_from_request(request):
"""
Determine's the device name from the request by first looking for an
overridding cookie, and if not found then matching the user agent.
Used at both the template level for choosing the template to load and
also at the cache level as a cache key prefix.
"""
... | [
"def",
"device_from_request",
"(",
"request",
")",
":",
"from",
"yacms",
".",
"conf",
"import",
"settings",
"try",
":",
"# If a device was set via cookie, match available devices.",
"for",
"(",
"device",
",",
"_",
")",
"in",
"settings",
".",
"DEVICE_USER_AGENTS",
":... | Determine's the device name from the request by first looking for an
overridding cookie, and if not found then matching the user agent.
Used at both the template level for choosing the template to load and
also at the cache level as a cache key prefix. | [
"Determine",
"s",
"the",
"device",
"name",
"from",
"the",
"request",
"by",
"first",
"looking",
"for",
"an",
"overridding",
"cookie",
"and",
"if",
"not",
"found",
"then",
"matching",
"the",
"user",
"agent",
".",
"Used",
"at",
"both",
"the",
"template",
"lev... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/device.py#L4-L32 |
minhhoit/yacms | yacms/utils/device.py | templates_for_device | def templates_for_device(request, templates):
"""
Given a template name (or list of them), returns the template names
as a list, with each name prefixed with the device directory
inserted before it's associate default in the list.
"""
from yacms.conf import settings
if not isinstance(templat... | python | def templates_for_device(request, templates):
"""
Given a template name (or list of them), returns the template names
as a list, with each name prefixed with the device directory
inserted before it's associate default in the list.
"""
from yacms.conf import settings
if not isinstance(templat... | [
"def",
"templates_for_device",
"(",
"request",
",",
"templates",
")",
":",
"from",
"yacms",
".",
"conf",
"import",
"settings",
"if",
"not",
"isinstance",
"(",
"templates",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"templates",
"=",
"[",
"templates",
... | Given a template name (or list of them), returns the template names
as a list, with each name prefixed with the device directory
inserted before it's associate default in the list. | [
"Given",
"a",
"template",
"name",
"(",
"or",
"list",
"of",
"them",
")",
"returns",
"the",
"template",
"names",
"as",
"a",
"list",
"with",
"each",
"name",
"prefixed",
"with",
"the",
"device",
"directory",
"inserted",
"before",
"it",
"s",
"associate",
"defau... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/device.py#L35-L53 |
tomokinakamaru/mapletree | mapletree/defaults/request/request.py | Request.body | def body(self):
""" String from `wsgi.input`.
"""
if self._body is None:
if self._fieldstorage is not None:
raise ReadBodyTwiceError()
clength = int(self.environ('CONTENT_LENGTH') or 0)
self._body = self._environ['wsgi.input'].read(clength)
... | python | def body(self):
""" String from `wsgi.input`.
"""
if self._body is None:
if self._fieldstorage is not None:
raise ReadBodyTwiceError()
clength = int(self.environ('CONTENT_LENGTH') or 0)
self._body = self._environ['wsgi.input'].read(clength)
... | [
"def",
"body",
"(",
"self",
")",
":",
"if",
"self",
".",
"_body",
"is",
"None",
":",
"if",
"self",
".",
"_fieldstorage",
"is",
"not",
"None",
":",
"raise",
"ReadBodyTwiceError",
"(",
")",
"clength",
"=",
"int",
"(",
"self",
".",
"environ",
"(",
"'CON... | String from `wsgi.input`. | [
"String",
"from",
"wsgi",
".",
"input",
"."
] | train | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/request/request.py#L43-L55 |
tomokinakamaru/mapletree | mapletree/defaults/request/request.py | Request.fieldstorage | def fieldstorage(self):
""" `cgi.FieldStorage` from `wsgi.input`.
"""
if self._fieldstorage is None:
if self._body is not None:
raise ReadBodyTwiceError()
self._fieldstorage = cgi.FieldStorage(
environ=self._environ,
fp=sel... | python | def fieldstorage(self):
""" `cgi.FieldStorage` from `wsgi.input`.
"""
if self._fieldstorage is None:
if self._body is not None:
raise ReadBodyTwiceError()
self._fieldstorage = cgi.FieldStorage(
environ=self._environ,
fp=sel... | [
"def",
"fieldstorage",
"(",
"self",
")",
":",
"if",
"self",
".",
"_fieldstorage",
"is",
"None",
":",
"if",
"self",
".",
"_body",
"is",
"not",
"None",
":",
"raise",
"ReadBodyTwiceError",
"(",
")",
"self",
".",
"_fieldstorage",
"=",
"cgi",
".",
"FieldStora... | `cgi.FieldStorage` from `wsgi.input`. | [
"cgi",
".",
"FieldStorage",
"from",
"wsgi",
".",
"input",
"."
] | train | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/request/request.py#L58-L70 |
tomokinakamaru/mapletree | mapletree/defaults/request/request.py | Request.params | def params(self):
""" Parsed query string.
"""
if self._params is None:
self._params = self.arg_container()
data = compat.parse_qs(self.environ('QUERY_STRING') or '')
for k, v in data.items():
self._params[k] = v[0]
return self._param... | python | def params(self):
""" Parsed query string.
"""
if self._params is None:
self._params = self.arg_container()
data = compat.parse_qs(self.environ('QUERY_STRING') or '')
for k, v in data.items():
self._params[k] = v[0]
return self._param... | [
"def",
"params",
"(",
"self",
")",
":",
"if",
"self",
".",
"_params",
"is",
"None",
":",
"self",
".",
"_params",
"=",
"self",
".",
"arg_container",
"(",
")",
"data",
"=",
"compat",
".",
"parse_qs",
"(",
"self",
".",
"environ",
"(",
"'QUERY_STRING'",
... | Parsed query string. | [
"Parsed",
"query",
"string",
"."
] | train | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/request/request.py#L73-L83 |
tomokinakamaru/mapletree | mapletree/defaults/request/request.py | Request.cookie | def cookie(self):
""" Cookie values.
"""
if self._cookie is None:
self._cookie = self.arg_container()
data = compat.parse_qs(self.http_header('cookie') or '')
for k, v in data.items():
self._cookie[k.strip()] = v[0]
return self._cooki... | python | def cookie(self):
""" Cookie values.
"""
if self._cookie is None:
self._cookie = self.arg_container()
data = compat.parse_qs(self.http_header('cookie') or '')
for k, v in data.items():
self._cookie[k.strip()] = v[0]
return self._cooki... | [
"def",
"cookie",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cookie",
"is",
"None",
":",
"self",
".",
"_cookie",
"=",
"self",
".",
"arg_container",
"(",
")",
"data",
"=",
"compat",
".",
"parse_qs",
"(",
"self",
".",
"http_header",
"(",
"'cookie'",
")... | Cookie values. | [
"Cookie",
"values",
"."
] | train | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/request/request.py#L92-L102 |
tomokinakamaru/mapletree | mapletree/defaults/request/request.py | Request.data | def data(self):
""" Values in request body.
"""
if self._data is None:
self._data = self.arg_container()
if isinstance(self.fieldstorage.value, list):
for k in self.fieldstorage.keys():
fname = self.fieldstorage[k].filename
... | python | def data(self):
""" Values in request body.
"""
if self._data is None:
self._data = self.arg_container()
if isinstance(self.fieldstorage.value, list):
for k in self.fieldstorage.keys():
fname = self.fieldstorage[k].filename
... | [
"def",
"data",
"(",
"self",
")",
":",
"if",
"self",
".",
"_data",
"is",
"None",
":",
"self",
".",
"_data",
"=",
"self",
".",
"arg_container",
"(",
")",
"if",
"isinstance",
"(",
"self",
".",
"fieldstorage",
".",
"value",
",",
"list",
")",
":",
"for"... | Values in request body. | [
"Values",
"in",
"request",
"body",
"."
] | train | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/request/request.py#L105-L120 |
smetj/wishbone-input-namedpipe | wishbone_input_namedpipe/namedpipein.py | NamedPipeIn.drain | def drain(self, p):
'''Reads the named pipe.'''
self.logging.info('Started.')
fd = os.open(p, os.O_RDWR | os.O_NONBLOCK)
gevent_os.make_nonblocking(fd)
while self.loop():
try:
lines = gevent_os.nb_read(fd, 4096).splitlines()
if len(li... | python | def drain(self, p):
'''Reads the named pipe.'''
self.logging.info('Started.')
fd = os.open(p, os.O_RDWR | os.O_NONBLOCK)
gevent_os.make_nonblocking(fd)
while self.loop():
try:
lines = gevent_os.nb_read(fd, 4096).splitlines()
if len(li... | [
"def",
"drain",
"(",
"self",
",",
"p",
")",
":",
"self",
".",
"logging",
".",
"info",
"(",
"'Started.'",
")",
"fd",
"=",
"os",
".",
"open",
"(",
"p",
",",
"os",
".",
"O_RDWR",
"|",
"os",
".",
"O_NONBLOCK",
")",
"gevent_os",
".",
"make_nonblocking",... | Reads the named pipe. | [
"Reads",
"the",
"named",
"pipe",
"."
] | train | https://github.com/smetj/wishbone-input-namedpipe/blob/01c3d03aeaa482b4893b38f78a66606e213ef144/wishbone_input_namedpipe/namedpipein.py#L67-L82 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/datastructures/eperiodical.py | EPeriodical.from_xml | def from_xml(xml):
"""
Convert :class:`.MARCXMLRecord` object to :class:`.EPublication`
namedtuple.
Args:
xml (str/MARCXMLRecord): MARC XML which will be converted to
EPublication. In case of str, ``<record>`` tag is required.
Returns:
st... | python | def from_xml(xml):
"""
Convert :class:`.MARCXMLRecord` object to :class:`.EPublication`
namedtuple.
Args:
xml (str/MARCXMLRecord): MARC XML which will be converted to
EPublication. In case of str, ``<record>`` tag is required.
Returns:
st... | [
"def",
"from_xml",
"(",
"xml",
")",
":",
"parsed",
"=",
"xml",
"if",
"not",
"isinstance",
"(",
"xml",
",",
"MARCXMLRecord",
")",
":",
"parsed",
"=",
"MARCXMLRecord",
"(",
"str",
"(",
"xml",
")",
")",
"# check whether the document was deleted",
"if",
"\"DEL\"... | Convert :class:`.MARCXMLRecord` object to :class:`.EPublication`
namedtuple.
Args:
xml (str/MARCXMLRecord): MARC XML which will be converted to
EPublication. In case of str, ``<record>`` tag is required.
Returns:
structure: :class:`.EPublication` namedtu... | [
"Convert",
":",
"class",
":",
".",
"MARCXMLRecord",
"object",
"to",
":",
"class",
":",
".",
"EPublication",
"namedtuple",
"."
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/datastructures/eperiodical.py#L53-L89 |
dhain/potpy | potpy/router.py | Route.add | def add(self, handler, name=None, exception_handlers=()):
"""Add a handler to the route.
:param handler: The "handler" callable to add.
:param name: Optional. When specified, the return value of this
handler will be added to the context under ``name``.
:param exception_handl... | python | def add(self, handler, name=None, exception_handlers=()):
"""Add a handler to the route.
:param handler: The "handler" callable to add.
:param name: Optional. When specified, the return value of this
handler will be added to the context under ``name``.
:param exception_handl... | [
"def",
"add",
"(",
"self",
",",
"handler",
",",
"name",
"=",
"None",
",",
"exception_handlers",
"=",
"(",
")",
")",
":",
"self",
".",
"route",
".",
"append",
"(",
"(",
"name",
",",
"handler",
",",
"exception_handlers",
")",
")"
] | Add a handler to the route.
:param handler: The "handler" callable to add.
:param name: Optional. When specified, the return value of this
handler will be added to the context under ``name``.
:param exception_handlers: Optional. A list of ``(types, handler)``
tuples, whe... | [
"Add",
"a",
"handler",
"to",
"the",
"route",
"."
] | train | https://github.com/dhain/potpy/blob/e39a5a84f763fbf144b07a620afb02a5ff3741c9/potpy/router.py#L124-L184 |
dhain/potpy | potpy/router.py | Router.add | def add(self, match, handler):
"""Register a handler with the Router.
:param match: The first argument passed to the :meth:`match` method
when checking against this handler.
:param handler: A callable or :class:`Route` instance that will handle
matching calls. If not a R... | python | def add(self, match, handler):
"""Register a handler with the Router.
:param match: The first argument passed to the :meth:`match` method
when checking against this handler.
:param handler: A callable or :class:`Route` instance that will handle
matching calls. If not a R... | [
"def",
"add",
"(",
"self",
",",
"match",
",",
"handler",
")",
":",
"self",
".",
"routes",
".",
"append",
"(",
"(",
"match",
",",
"(",
"Route",
"(",
"handler",
")",
"if",
"not",
"isinstance",
"(",
"handler",
",",
"Route",
")",
"else",
"handler",
")"... | Register a handler with the Router.
:param match: The first argument passed to the :meth:`match` method
when checking against this handler.
:param handler: A callable or :class:`Route` instance that will handle
matching calls. If not a Route instance, will be wrapped in one. | [
"Register",
"a",
"handler",
"with",
"the",
"Router",
"."
] | train | https://github.com/dhain/potpy/blob/e39a5a84f763fbf144b07a620afb02a5ff3741c9/potpy/router.py#L250-L261 |
shaunduncan/helga-reviewboard | helga_reviewboard.py | reviewboard | def reviewboard(client, channel, nick, message, matches):
"""
Automatically responds to reviewboard urls if a user mentions a pattern
like cr####. Requires REVIEWBOARD_URL to exist in settings with formattable
substring '{review}'
"""
url_fmt = getattr(settings, 'REVIEWBOARD_URL', 'http://localh... | python | def reviewboard(client, channel, nick, message, matches):
"""
Automatically responds to reviewboard urls if a user mentions a pattern
like cr####. Requires REVIEWBOARD_URL to exist in settings with formattable
substring '{review}'
"""
url_fmt = getattr(settings, 'REVIEWBOARD_URL', 'http://localh... | [
"def",
"reviewboard",
"(",
"client",
",",
"channel",
",",
"nick",
",",
"message",
",",
"matches",
")",
":",
"url_fmt",
"=",
"getattr",
"(",
"settings",
",",
"'REVIEWBOARD_URL'",
",",
"'http://localhost/{review}'",
")",
"reviews",
"=",
"[",
"url_fmt",
".",
"f... | Automatically responds to reviewboard urls if a user mentions a pattern
like cr####. Requires REVIEWBOARD_URL to exist in settings with formattable
substring '{review}' | [
"Automatically",
"responds",
"to",
"reviewboard",
"urls",
"if",
"a",
"user",
"mentions",
"a",
"pattern",
"like",
"cr####",
".",
"Requires",
"REVIEWBOARD_URL",
"to",
"exist",
"in",
"settings",
"with",
"formattable",
"substring",
"{",
"review",
"}"
] | train | https://github.com/shaunduncan/helga-reviewboard/blob/72b5a03ab4a6e89e0e3609572ef07b59fa3586f5/helga_reviewboard.py#L7-L15 |
nicktgr15/sac | sac/util.py | Util.get_annotated_data_x_y | def get_annotated_data_x_y(timestamps, data, lbls):
"""
DOESN'T work with OVERLAPPING labels
:param timestamps:
:param data:
:param lbls:
:return:
"""
timestamps = np.array(timestamps)
timestamp_step = timestamps[3]-timestamps[2]
current... | python | def get_annotated_data_x_y(timestamps, data, lbls):
"""
DOESN'T work with OVERLAPPING labels
:param timestamps:
:param data:
:param lbls:
:return:
"""
timestamps = np.array(timestamps)
timestamp_step = timestamps[3]-timestamps[2]
current... | [
"def",
"get_annotated_data_x_y",
"(",
"timestamps",
",",
"data",
",",
"lbls",
")",
":",
"timestamps",
"=",
"np",
".",
"array",
"(",
"timestamps",
")",
"timestamp_step",
"=",
"timestamps",
"[",
"3",
"]",
"-",
"timestamps",
"[",
"2",
"]",
"current_new_timestam... | DOESN'T work with OVERLAPPING labels
:param timestamps:
:param data:
:param lbls:
:return: | [
"DOESN",
"T",
"work",
"with",
"OVERLAPPING",
"labels"
] | train | https://github.com/nicktgr15/sac/blob/4b1d5d8e6ca2c437972db34ddc72990860865159/sac/util.py#L172-L207 |
nicktgr15/sac | sac/util.py | Util.generate_labels_from_classifications | def generate_labels_from_classifications(classifications, timestamps):
"""
This is to generate continuous segments out of classified small windows
:param classifications:
:param timestamps:
:return:
"""
window_length = timestamps[1] - timestamps[0]
combo_l... | python | def generate_labels_from_classifications(classifications, timestamps):
"""
This is to generate continuous segments out of classified small windows
:param classifications:
:param timestamps:
:return:
"""
window_length = timestamps[1] - timestamps[0]
combo_l... | [
"def",
"generate_labels_from_classifications",
"(",
"classifications",
",",
"timestamps",
")",
":",
"window_length",
"=",
"timestamps",
"[",
"1",
"]",
"-",
"timestamps",
"[",
"0",
"]",
"combo_list",
"=",
"[",
"(",
"classifications",
"[",
"k",
"]",
",",
"timest... | This is to generate continuous segments out of classified small windows
:param classifications:
:param timestamps:
:return: | [
"This",
"is",
"to",
"generate",
"continuous",
"segments",
"out",
"of",
"classified",
"small",
"windows",
":",
"param",
"classifications",
":",
":",
"param",
"timestamps",
":",
":",
"return",
":"
] | train | https://github.com/nicktgr15/sac/blob/4b1d5d8e6ca2c437972db34ddc72990860865159/sac/util.py#L258-L274 |
nicktgr15/sac | sac/util.py | Util.write_audacity_labels | def write_audacity_labels(audacity_labels, filename):
"""
:param audacity_labels: list containing audacity label objects
:return:
"""
with open(filename, "w") as f:
for label in audacity_labels:
f.write("%s\t%s\t%s\n" % (label.start_seconds, label.end_... | python | def write_audacity_labels(audacity_labels, filename):
"""
:param audacity_labels: list containing audacity label objects
:return:
"""
with open(filename, "w") as f:
for label in audacity_labels:
f.write("%s\t%s\t%s\n" % (label.start_seconds, label.end_... | [
"def",
"write_audacity_labels",
"(",
"audacity_labels",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"\"w\"",
")",
"as",
"f",
":",
"for",
"label",
"in",
"audacity_labels",
":",
"f",
".",
"write",
"(",
"\"%s\\t%s\\t%s\\n\"",
"%",
"(",
"l... | :param audacity_labels: list containing audacity label objects
:return: | [
":",
"param",
"audacity_labels",
":",
"list",
"containing",
"audacity",
"label",
"objects",
":",
"return",
":"
] | train | https://github.com/nicktgr15/sac/blob/4b1d5d8e6ca2c437972db34ddc72990860865159/sac/util.py#L431-L438 |
bluec0re/python-helperlib | helperlib/logging.py | load_config | def load_config(filename="logging.ini", *args, **kwargs):
"""
Load logger config from file
Keyword arguments:
filename -- configuration filename (Default: "logging.ini")
*args -- options passed to fileConfig
**kwargs -- options passed to fileConfigg
"""
logging.config.fileConfi... | python | def load_config(filename="logging.ini", *args, **kwargs):
"""
Load logger config from file
Keyword arguments:
filename -- configuration filename (Default: "logging.ini")
*args -- options passed to fileConfig
**kwargs -- options passed to fileConfigg
"""
logging.config.fileConfi... | [
"def",
"load_config",
"(",
"filename",
"=",
"\"logging.ini\"",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"config",
".",
"fileConfig",
"(",
"filename",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Load logger config from file
Keyword arguments:
filename -- configuration filename (Default: "logging.ini")
*args -- options passed to fileConfig
**kwargs -- options passed to fileConfigg | [
"Load",
"logger",
"config",
"from",
"file",
"Keyword",
"arguments",
":",
"filename",
"--",
"configuration",
"filename",
"(",
"Default",
":",
"logging",
".",
"ini",
")",
"*",
"args",
"--",
"options",
"passed",
"to",
"fileConfig",
"**",
"kwargs",
"--",
"option... | train | https://github.com/bluec0re/python-helperlib/blob/a2ac429668a6b86d3dc5e686978965c938f07d2c/helperlib/logging.py#L60-L70 |
bluec0re/python-helperlib | helperlib/logging.py | default_config | def default_config(level=logging.INFO, auto_init=True, new_formatter=False, **kwargs):
"""
Returns the default config dictionary and inits the logging system if requested
Keyword arguments:
level -- loglevel of the console handler (Default: logging.INFO)
auto_init -- initialize the logging syst... | python | def default_config(level=logging.INFO, auto_init=True, new_formatter=False, **kwargs):
"""
Returns the default config dictionary and inits the logging system if requested
Keyword arguments:
level -- loglevel of the console handler (Default: logging.INFO)
auto_init -- initialize the logging syst... | [
"def",
"default_config",
"(",
"level",
"=",
"logging",
".",
"INFO",
",",
"auto_init",
"=",
"True",
",",
"new_formatter",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"formatters",
"=",
"{",
"'color'",
":",
"{",
"'()'",
":",
"__name__",
"+",
"'.Colo... | Returns the default config dictionary and inits the logging system if requested
Keyword arguments:
level -- loglevel of the console handler (Default: logging.INFO)
auto_init -- initialize the logging system with the provided config (Default: True)
**kwargs -- additional options for the logging syst... | [
"Returns",
"the",
"default",
"config",
"dictionary",
"and",
"inits",
"the",
"logging",
"system",
"if",
"requested",
"Keyword",
"arguments",
":",
"level",
"--",
"loglevel",
"of",
"the",
"console",
"handler",
"(",
"Default",
":",
"logging",
".",
"INFO",
")",
"... | train | https://github.com/bluec0re/python-helperlib/blob/a2ac429668a6b86d3dc5e686978965c938f07d2c/helperlib/logging.py#L73-L124 |
bluec0re/python-helperlib | helperlib/logging.py | scope_logger | def scope_logger(cls):
"""
Class decorator for adding a class local logger
Example:
>>> @scope_logger
>>> class Test:
>>> def __init__(self):
>>> self.log.info("class instantiated")
>>> t = Test()
"""
cls.log = logging.getLogger('{0}.{1}'.format(cls.__module__, ... | python | def scope_logger(cls):
"""
Class decorator for adding a class local logger
Example:
>>> @scope_logger
>>> class Test:
>>> def __init__(self):
>>> self.log.info("class instantiated")
>>> t = Test()
"""
cls.log = logging.getLogger('{0}.{1}'.format(cls.__module__, ... | [
"def",
"scope_logger",
"(",
"cls",
")",
":",
"cls",
".",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"'{0}.{1}'",
".",
"format",
"(",
"cls",
".",
"__module__",
",",
"cls",
".",
"__name__",
")",
")",
"return",
"cls"
] | Class decorator for adding a class local logger
Example:
>>> @scope_logger
>>> class Test:
>>> def __init__(self):
>>> self.log.info("class instantiated")
>>> t = Test() | [
"Class",
"decorator",
"for",
"adding",
"a",
"class",
"local",
"logger"
] | train | https://github.com/bluec0re/python-helperlib/blob/a2ac429668a6b86d3dc5e686978965c938f07d2c/helperlib/logging.py#L127-L140 |
bluec0re/python-helperlib | helperlib/logging.py | LogPipe.run | def run(self):
"""Run the thread, logging everything.
"""
self._finished.clear()
for line in iter(self.pipeReader.readline, ''):
logging.log(self.level, line.strip('\n'))
self.pipeReader.close()
self._finished.set() | python | def run(self):
"""Run the thread, logging everything.
"""
self._finished.clear()
for line in iter(self.pipeReader.readline, ''):
logging.log(self.level, line.strip('\n'))
self.pipeReader.close()
self._finished.set() | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"_finished",
".",
"clear",
"(",
")",
"for",
"line",
"in",
"iter",
"(",
"self",
".",
"pipeReader",
".",
"readline",
",",
"''",
")",
":",
"logging",
".",
"log",
"(",
"self",
".",
"level",
",",
"line... | Run the thread, logging everything. | [
"Run",
"the",
"thread",
"logging",
"everything",
"."
] | train | https://github.com/bluec0re/python-helperlib/blob/a2ac429668a6b86d3dc5e686978965c938f07d2c/helperlib/logging.py#L162-L170 |
sveetch/py-css-styleguide | py_css_styleguide/model.py | Manifest.load | def load(self, source, filepath=None):
"""
Load source as manifest attributes
Arguments:
source (string or file-object): CSS source to parse and serialize
to find metas and rules. It can be either a string or a
file-like object (aka with a ``read()`` ... | python | def load(self, source, filepath=None):
"""
Load source as manifest attributes
Arguments:
source (string or file-object): CSS source to parse and serialize
to find metas and rules. It can be either a string or a
file-like object (aka with a ``read()`` ... | [
"def",
"load",
"(",
"self",
",",
"source",
",",
"filepath",
"=",
"None",
")",
":",
"# Set _path if source is a file-like object",
"try",
":",
"self",
".",
"_path",
"=",
"source",
".",
"name",
"except",
"AttributeError",
":",
"self",
".",
"_path",
"=",
"filep... | Load source as manifest attributes
Arguments:
source (string or file-object): CSS source to parse and serialize
to find metas and rules. It can be either a string or a
file-like object (aka with a ``read()`` method which return
string).
Keywo... | [
"Load",
"source",
"as",
"manifest",
"attributes"
] | train | https://github.com/sveetch/py-css-styleguide/blob/5acc693f71b2fa7d944d7fed561ae0a7699ccd0f/py_css_styleguide/model.py#L41-L87 |
sveetch/py-css-styleguide | py_css_styleguide/model.py | Manifest.set_rule | def set_rule(self, name, properties):
"""
Set a rules as object attribute.
Arguments:
name (string): Rule name to set as attribute name.
properties (dict): Dictionnary of properties.
"""
self._rule_attrs.append(name)
setattr(self, name, properties... | python | def set_rule(self, name, properties):
"""
Set a rules as object attribute.
Arguments:
name (string): Rule name to set as attribute name.
properties (dict): Dictionnary of properties.
"""
self._rule_attrs.append(name)
setattr(self, name, properties... | [
"def",
"set_rule",
"(",
"self",
",",
"name",
",",
"properties",
")",
":",
"self",
".",
"_rule_attrs",
".",
"append",
"(",
"name",
")",
"setattr",
"(",
"self",
",",
"name",
",",
"properties",
")"
] | Set a rules as object attribute.
Arguments:
name (string): Rule name to set as attribute name.
properties (dict): Dictionnary of properties. | [
"Set",
"a",
"rules",
"as",
"object",
"attribute",
"."
] | train | https://github.com/sveetch/py-css-styleguide/blob/5acc693f71b2fa7d944d7fed561ae0a7699ccd0f/py_css_styleguide/model.py#L89-L98 |
sveetch/py-css-styleguide | py_css_styleguide/model.py | Manifest.remove_rule | def remove_rule(self, name):
"""
Remove a rule from attributes.
Arguments:
name (string): Rule name to remove.
"""
self._rule_attrs.remove(name)
delattr(self, name) | python | def remove_rule(self, name):
"""
Remove a rule from attributes.
Arguments:
name (string): Rule name to remove.
"""
self._rule_attrs.remove(name)
delattr(self, name) | [
"def",
"remove_rule",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_rule_attrs",
".",
"remove",
"(",
"name",
")",
"delattr",
"(",
"self",
",",
"name",
")"
] | Remove a rule from attributes.
Arguments:
name (string): Rule name to remove. | [
"Remove",
"a",
"rule",
"from",
"attributes",
"."
] | train | https://github.com/sveetch/py-css-styleguide/blob/5acc693f71b2fa7d944d7fed561ae0a7699ccd0f/py_css_styleguide/model.py#L100-L108 |
sveetch/py-css-styleguide | py_css_styleguide/model.py | Manifest.to_json | def to_json(self, indent=4):
"""
Serialize metas and reference attributes to a JSON string.
Keyword Arguments:
indent (int): Space indentation, default to ``4``.
Returns:
string: JSON datas.
"""
agregate = {
'metas': self.metas,
... | python | def to_json(self, indent=4):
"""
Serialize metas and reference attributes to a JSON string.
Keyword Arguments:
indent (int): Space indentation, default to ``4``.
Returns:
string: JSON datas.
"""
agregate = {
'metas': self.metas,
... | [
"def",
"to_json",
"(",
"self",
",",
"indent",
"=",
"4",
")",
":",
"agregate",
"=",
"{",
"'metas'",
":",
"self",
".",
"metas",
",",
"}",
"agregate",
".",
"update",
"(",
"{",
"k",
":",
"getattr",
"(",
"self",
",",
"k",
")",
"for",
"k",
"in",
"sel... | Serialize metas and reference attributes to a JSON string.
Keyword Arguments:
indent (int): Space indentation, default to ``4``.
Returns:
string: JSON datas. | [
"Serialize",
"metas",
"and",
"reference",
"attributes",
"to",
"a",
"JSON",
"string",
"."
] | train | https://github.com/sveetch/py-css-styleguide/blob/5acc693f71b2fa7d944d7fed561ae0a7699ccd0f/py_css_styleguide/model.py#L110-L126 |
elkan1788/ppytools | ppytools/emailclient.py | EmailClient.send | def send(self, to, cc, subject, body, atts=None, delete=False):
"""Send an email action.
:param to: receivers list
:param cc: copy user list
:param subject: email title
:param body: email content body
:param atts: email attachments
:param delete: whether delete a... | python | def send(self, to, cc, subject, body, atts=None, delete=False):
"""Send an email action.
:param to: receivers list
:param cc: copy user list
:param subject: email title
:param body: email content body
:param atts: email attachments
:param delete: whether delete a... | [
"def",
"send",
"(",
"self",
",",
"to",
",",
"cc",
",",
"subject",
",",
"body",
",",
"atts",
"=",
"None",
",",
"delete",
"=",
"False",
")",
":",
"email_cnt",
"=",
"MIMEMultipart",
"(",
")",
"email_cnt",
"[",
"'From'",
"]",
"=",
"Header",
"(",
"self"... | Send an email action.
:param to: receivers list
:param cc: copy user list
:param subject: email title
:param body: email content body
:param atts: email attachments
:param delete: whether delete att
:return: True or False | [
"Send",
"an",
"email",
"action",
"."
] | train | https://github.com/elkan1788/ppytools/blob/117aeed9f669ae46e0dd6cb11c5687a5f797816c/ppytools/emailclient.py#L118-L157 |
klmitch/bark | bark/proxy.py | _parse_ip | def _parse_ip(addr):
"""
Helper function to convert an address into an IPAddress object.
Canonicalizes IPv6-mapped (or compatible) IPv4 addresses into IPv4
addresses. Returns None if the address cannot be parsed.
"""
# Parse the IP address
try:
address = netaddr.IPAddress(addr.stri... | python | def _parse_ip(addr):
"""
Helper function to convert an address into an IPAddress object.
Canonicalizes IPv6-mapped (or compatible) IPv4 addresses into IPv4
addresses. Returns None if the address cannot be parsed.
"""
# Parse the IP address
try:
address = netaddr.IPAddress(addr.stri... | [
"def",
"_parse_ip",
"(",
"addr",
")",
":",
"# Parse the IP address",
"try",
":",
"address",
"=",
"netaddr",
".",
"IPAddress",
"(",
"addr",
".",
"strip",
"(",
")",
")",
"except",
"(",
"ValueError",
",",
"netaddr",
".",
"AddrFormatError",
")",
":",
"return",... | Helper function to convert an address into an IPAddress object.
Canonicalizes IPv6-mapped (or compatible) IPv4 addresses into IPv4
addresses. Returns None if the address cannot be parsed. | [
"Helper",
"function",
"to",
"convert",
"an",
"address",
"into",
"an",
"IPAddress",
"object",
".",
"Canonicalizes",
"IPv6",
"-",
"mapped",
"(",
"or",
"compatible",
")",
"IPv4",
"addresses",
"into",
"IPv4",
"addresses",
".",
"Returns",
"None",
"if",
"the",
"ad... | train | https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/proxy.py#L37-L57 |
klmitch/bark | bark/proxy.py | Proxy.restrict | def restrict(self, addr):
"""
Drop an address from the set of addresses this proxy is
permitted to introduce.
:param addr: The address to remove.
"""
# Remove the address from the set
ip_addr = _parse_ip(addr)
if ip_addr is None:
LOG.warn("Ca... | python | def restrict(self, addr):
"""
Drop an address from the set of addresses this proxy is
permitted to introduce.
:param addr: The address to remove.
"""
# Remove the address from the set
ip_addr = _parse_ip(addr)
if ip_addr is None:
LOG.warn("Ca... | [
"def",
"restrict",
"(",
"self",
",",
"addr",
")",
":",
"# Remove the address from the set",
"ip_addr",
"=",
"_parse_ip",
"(",
"addr",
")",
"if",
"ip_addr",
"is",
"None",
":",
"LOG",
".",
"warn",
"(",
"\"Cannot restrict address %r from proxy %s: \"",
"\"invalid addre... | Drop an address from the set of addresses this proxy is
permitted to introduce.
:param addr: The address to remove. | [
"Drop",
"an",
"address",
"from",
"the",
"set",
"of",
"addresses",
"this",
"proxy",
"is",
"permitted",
"to",
"introduce",
"."
] | train | https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/proxy.py#L111-L125 |
klmitch/bark | bark/proxy.py | Proxy.accept | def accept(self, addr):
"""
Add an address to the set of addresses this proxy is permitted
to introduce.
:param addr: The address to add.
"""
# Add the address to the set
ip_addr = _parse_ip(addr)
if ip_addr is None:
LOG.warn("Cannot add addr... | python | def accept(self, addr):
"""
Add an address to the set of addresses this proxy is permitted
to introduce.
:param addr: The address to add.
"""
# Add the address to the set
ip_addr = _parse_ip(addr)
if ip_addr is None:
LOG.warn("Cannot add addr... | [
"def",
"accept",
"(",
"self",
",",
"addr",
")",
":",
"# Add the address to the set",
"ip_addr",
"=",
"_parse_ip",
"(",
"addr",
")",
"if",
"ip_addr",
"is",
"None",
":",
"LOG",
".",
"warn",
"(",
"\"Cannot add address %r to proxy %s: \"",
"\"invalid address\"",
"%",
... | Add an address to the set of addresses this proxy is permitted
to introduce.
:param addr: The address to add. | [
"Add",
"an",
"address",
"to",
"the",
"set",
"of",
"addresses",
"this",
"proxy",
"is",
"permitted",
"to",
"introduce",
"."
] | train | https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/proxy.py#L127-L141 |
klmitch/bark | bark/proxy.py | ProxyConfig.validate | def validate(self, proxy_ip, client_ip):
"""
Looks up the proxy identified by its IP, then verifies that
the given client IP may be introduced by that proxy.
:param proxy_ip: The IP address of the proxy.
:param client_ip: The IP address of the supposed client.
:returns:... | python | def validate(self, proxy_ip, client_ip):
"""
Looks up the proxy identified by its IP, then verifies that
the given client IP may be introduced by that proxy.
:param proxy_ip: The IP address of the proxy.
:param client_ip: The IP address of the supposed client.
:returns:... | [
"def",
"validate",
"(",
"self",
",",
"proxy_ip",
",",
"client_ip",
")",
":",
"# First, look up the proxy",
"if",
"self",
".",
"pseudo_proxy",
":",
"proxy",
"=",
"self",
".",
"pseudo_proxy",
"elif",
"proxy_ip",
"not",
"in",
"self",
".",
"proxies",
":",
"retur... | Looks up the proxy identified by its IP, then verifies that
the given client IP may be introduced by that proxy.
:param proxy_ip: The IP address of the proxy.
:param client_ip: The IP address of the supposed client.
:returns: True if the proxy is permitted to introduce the
... | [
"Looks",
"up",
"the",
"proxy",
"identified",
"by",
"its",
"IP",
"then",
"verifies",
"that",
"the",
"given",
"client",
"IP",
"may",
"be",
"introduced",
"by",
"that",
"proxy",
"."
] | train | https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/proxy.py#L282-L304 |
shad7/tvdbapi_client | tvdbapi_client/api.py | requires_auth | def requires_auth(func):
"""Handle authentication checks.
.. py:decorator:: requires_auth
Checks if the token has expired and performs authentication if needed.
"""
@six.wraps(func)
def wrapper(self, *args, **kwargs):
if self.token_expired:
self.authenticate()
r... | python | def requires_auth(func):
"""Handle authentication checks.
.. py:decorator:: requires_auth
Checks if the token has expired and performs authentication if needed.
"""
@six.wraps(func)
def wrapper(self, *args, **kwargs):
if self.token_expired:
self.authenticate()
r... | [
"def",
"requires_auth",
"(",
"func",
")",
":",
"@",
"six",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"token_expired",
":",
"self",
".",
"authenticate",
"("... | Handle authentication checks.
.. py:decorator:: requires_auth
Checks if the token has expired and performs authentication if needed. | [
"Handle",
"authentication",
"checks",
"."
] | train | https://github.com/shad7/tvdbapi_client/blob/edf1771184122f4db42af7fc087407a3e6a4e377/tvdbapi_client/api.py#L40-L52 |
shad7/tvdbapi_client | tvdbapi_client/api.py | TVDBClient.headers | def headers(self):
"""Provide access to updated headers."""
self._headers.update(**{'Accept-Language': self.language})
if self.__token:
self._headers.update(
**{'Authorization': 'Bearer %s' % self.__token})
return self._headers | python | def headers(self):
"""Provide access to updated headers."""
self._headers.update(**{'Accept-Language': self.language})
if self.__token:
self._headers.update(
**{'Authorization': 'Bearer %s' % self.__token})
return self._headers | [
"def",
"headers",
"(",
"self",
")",
":",
"self",
".",
"_headers",
".",
"update",
"(",
"*",
"*",
"{",
"'Accept-Language'",
":",
"self",
".",
"language",
"}",
")",
"if",
"self",
".",
"__token",
":",
"self",
".",
"_headers",
".",
"update",
"(",
"*",
"... | Provide access to updated headers. | [
"Provide",
"access",
"to",
"updated",
"headers",
"."
] | train | https://github.com/shad7/tvdbapi_client/blob/edf1771184122f4db42af7fc087407a3e6a4e377/tvdbapi_client/api.py#L77-L83 |
shad7/tvdbapi_client | tvdbapi_client/api.py | TVDBClient.token_expired | def token_expired(self):
"""Provide access to flag indicating if token has expired."""
if self._token_timer is None:
return True
return timeutil.is_newer_than(self._token_timer, timeutil.ONE_HOUR) | python | def token_expired(self):
"""Provide access to flag indicating if token has expired."""
if self._token_timer is None:
return True
return timeutil.is_newer_than(self._token_timer, timeutil.ONE_HOUR) | [
"def",
"token_expired",
"(",
"self",
")",
":",
"if",
"self",
".",
"_token_timer",
"is",
"None",
":",
"return",
"True",
"return",
"timeutil",
".",
"is_newer_than",
"(",
"self",
".",
"_token_timer",
",",
"timeutil",
".",
"ONE_HOUR",
")"
] | Provide access to flag indicating if token has expired. | [
"Provide",
"access",
"to",
"flag",
"indicating",
"if",
"token",
"has",
"expired",
"."
] | train | https://github.com/shad7/tvdbapi_client/blob/edf1771184122f4db42af7fc087407a3e6a4e377/tvdbapi_client/api.py#L96-L100 |
shad7/tvdbapi_client | tvdbapi_client/api.py | TVDBClient.session | def session(self):
"""Provide access to request session with local cache enabled."""
if self._session is None:
self._session = cachecontrol.CacheControl(
requests.Session(),
cache=caches.FileCache('.tvdb_cache'))
return self._session | python | def session(self):
"""Provide access to request session with local cache enabled."""
if self._session is None:
self._session = cachecontrol.CacheControl(
requests.Session(),
cache=caches.FileCache('.tvdb_cache'))
return self._session | [
"def",
"session",
"(",
"self",
")",
":",
"if",
"self",
".",
"_session",
"is",
"None",
":",
"self",
".",
"_session",
"=",
"cachecontrol",
".",
"CacheControl",
"(",
"requests",
".",
"Session",
"(",
")",
",",
"cache",
"=",
"caches",
".",
"FileCache",
"(",... | Provide access to request session with local cache enabled. | [
"Provide",
"access",
"to",
"request",
"session",
"with",
"local",
"cache",
"enabled",
"."
] | train | https://github.com/shad7/tvdbapi_client/blob/edf1771184122f4db42af7fc087407a3e6a4e377/tvdbapi_client/api.py#L103-L109 |
shad7/tvdbapi_client | tvdbapi_client/api.py | TVDBClient._exec_request | def _exec_request(self, service, method=None, path_args=None, data=None,
params=None):
"""Execute request."""
if path_args is None:
path_args = []
req = {
'method': method or 'get',
'url': '/'.join(str(a).strip('/') for a in [
... | python | def _exec_request(self, service, method=None, path_args=None, data=None,
params=None):
"""Execute request."""
if path_args is None:
path_args = []
req = {
'method': method or 'get',
'url': '/'.join(str(a).strip('/') for a in [
... | [
"def",
"_exec_request",
"(",
"self",
",",
"service",
",",
"method",
"=",
"None",
",",
"path_args",
"=",
"None",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"path_args",
"is",
"None",
":",
"path_args",
"=",
"[",
"]",
"req",
... | Execute request. | [
"Execute",
"request",
"."
] | train | https://github.com/shad7/tvdbapi_client/blob/edf1771184122f4db42af7fc087407a3e6a4e377/tvdbapi_client/api.py#L112-L132 |
shad7/tvdbapi_client | tvdbapi_client/api.py | TVDBClient.authenticate | def authenticate(self):
"""Aquire authorization token for using thetvdb apis."""
if self.__token:
try:
resp = self._refresh_token()
except exceptions.TVDBRequestException as err:
# if a 401 is the cause try to login
if getattr(err.r... | python | def authenticate(self):
"""Aquire authorization token for using thetvdb apis."""
if self.__token:
try:
resp = self._refresh_token()
except exceptions.TVDBRequestException as err:
# if a 401 is the cause try to login
if getattr(err.r... | [
"def",
"authenticate",
"(",
"self",
")",
":",
"if",
"self",
".",
"__token",
":",
"try",
":",
"resp",
"=",
"self",
".",
"_refresh_token",
"(",
")",
"except",
"exceptions",
".",
"TVDBRequestException",
"as",
"err",
":",
"# if a 401 is the cause try to login",
"i... | Aquire authorization token for using thetvdb apis. | [
"Aquire",
"authorization",
"token",
"for",
"using",
"thetvdb",
"apis",
"."
] | train | https://github.com/shad7/tvdbapi_client/blob/edf1771184122f4db42af7fc087407a3e6a4e377/tvdbapi_client/api.py#L144-L159 |
shad7/tvdbapi_client | tvdbapi_client/api.py | TVDBClient.search_series | def search_series(self, **kwargs):
"""Provide the ability to search for a series.
.. warning::
authorization token required
The following search arguments currently supported:
* name
* imdbId
* zap2itId
:param kwargs: keyword arguments... | python | def search_series(self, **kwargs):
"""Provide the ability to search for a series.
.. warning::
authorization token required
The following search arguments currently supported:
* name
* imdbId
* zap2itId
:param kwargs: keyword arguments... | [
"def",
"search_series",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"}",
"for",
"arg",
",",
"val",
"in",
"six",
".",
"iteritems",
"(",
"kwargs",
")",
":",
"if",
"arg",
"in",
"SERIES_BY",
":",
"params",
"[",
"arg",
"]",
"="... | Provide the ability to search for a series.
.. warning::
authorization token required
The following search arguments currently supported:
* name
* imdbId
* zap2itId
:param kwargs: keyword arguments to search for series
:returns: series... | [
"Provide",
"the",
"ability",
"to",
"search",
"for",
"a",
"series",
"."
] | train | https://github.com/shad7/tvdbapi_client/blob/edf1771184122f4db42af7fc087407a3e6a4e377/tvdbapi_client/api.py#L162-L187 |
shad7/tvdbapi_client | tvdbapi_client/api.py | TVDBClient.get_episodes | def get_episodes(self, series_id, **kwargs):
"""All episodes for a given series.
Paginated with 100 results per page.
.. warning::
authorization token required
The following search arguments currently supported:
* airedSeason
* airedEpisode
... | python | def get_episodes(self, series_id, **kwargs):
"""All episodes for a given series.
Paginated with 100 results per page.
.. warning::
authorization token required
The following search arguments currently supported:
* airedSeason
* airedEpisode
... | [
"def",
"get_episodes",
"(",
"self",
",",
"series_id",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"'page'",
":",
"1",
"}",
"for",
"arg",
",",
"val",
"in",
"six",
".",
"iteritems",
"(",
"kwargs",
")",
":",
"if",
"arg",
"in",
"EPISODES_BY"... | All episodes for a given series.
Paginated with 100 results per page.
.. warning::
authorization token required
The following search arguments currently supported:
* airedSeason
* airedEpisode
* imdbId
* dvdSeason
* dvd... | [
"All",
"episodes",
"for",
"a",
"given",
"series",
"."
] | train | https://github.com/shad7/tvdbapi_client/blob/edf1771184122f4db42af7fc087407a3e6a4e377/tvdbapi_client/api.py#L204-L234 |
pjuren/pyokit | src/pyokit/datastruct/intervalTree.py | IntervalTree.intersectingPoint | def intersectingPoint(self, p):
"""
given a point, get intervals in the tree that are intersected.
:param p: intersection point
:return: the list of intersected intervals
"""
# perfect match
if p == self.data.mid:
return self.data.ends
if p > self.data.mid:
# we know all in... | python | def intersectingPoint(self, p):
"""
given a point, get intervals in the tree that are intersected.
:param p: intersection point
:return: the list of intersected intervals
"""
# perfect match
if p == self.data.mid:
return self.data.ends
if p > self.data.mid:
# we know all in... | [
"def",
"intersectingPoint",
"(",
"self",
",",
"p",
")",
":",
"# perfect match",
"if",
"p",
"==",
"self",
".",
"data",
".",
"mid",
":",
"return",
"self",
".",
"data",
".",
"ends",
"if",
"p",
">",
"self",
".",
"data",
".",
"mid",
":",
"# we know all in... | given a point, get intervals in the tree that are intersected.
:param p: intersection point
:return: the list of intersected intervals | [
"given",
"a",
"point",
"get",
"intervals",
"in",
"the",
"tree",
"that",
"are",
"intersected",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/intervalTree.py#L133-L162 |
pjuren/pyokit | src/pyokit/datastruct/intervalTree.py | IntervalTree.intersectingInterval | def intersectingInterval(self, start, end):
"""
given an interval, get intervals in the tree that are intersected.
:param start: start of the intersecting interval
:param end: end of the intersecting interval
:return: the list of intersected intervals
"""
# find all intervals in this... | python | def intersectingInterval(self, start, end):
"""
given an interval, get intervals in the tree that are intersected.
:param start: start of the intersecting interval
:param end: end of the intersecting interval
:return: the list of intersected intervals
"""
# find all intervals in this... | [
"def",
"intersectingInterval",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"# find all intervals in this node that intersect start and end",
"l",
"=",
"[",
"]",
"for",
"x",
"in",
"self",
".",
"data",
".",
"starts",
":",
"xStartsAfterInterval",
"=",
"(",
"x"... | given an interval, get intervals in the tree that are intersected.
:param start: start of the intersecting interval
:param end: end of the intersecting interval
:return: the list of intersected intervals | [
"given",
"an",
"interval",
"get",
"intervals",
"in",
"the",
"tree",
"that",
"are",
"intersected",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/intervalTree.py#L164-L192 |
pjuren/pyokit | src/pyokit/datastruct/intervalTree.py | IntervalTree.intersectingIntervalIterator | def intersectingIntervalIterator(self, start, end):
"""
Get an iterator which will iterate over those objects in the tree which
intersect the given interval - sorted in order of start index
:param start: find intervals in the tree that intersect an interval with
with this start index ... | python | def intersectingIntervalIterator(self, start, end):
"""
Get an iterator which will iterate over those objects in the tree which
intersect the given interval - sorted in order of start index
:param start: find intervals in the tree that intersect an interval with
with this start index ... | [
"def",
"intersectingIntervalIterator",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"items",
"=",
"self",
".",
"intersectingInterval",
"(",
"start",
",",
"end",
")",
"items",
".",
"sort",
"(",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"start",
")",... | Get an iterator which will iterate over those objects in the tree which
intersect the given interval - sorted in order of start index
:param start: find intervals in the tree that intersect an interval with
with this start index (inclusive)
:param end: find intervals in the tree that in... | [
"Get",
"an",
"iterator",
"which",
"will",
"iterate",
"over",
"those",
"objects",
"in",
"the",
"tree",
"which",
"intersect",
"the",
"given",
"interval",
"-",
"sorted",
"in",
"order",
"of",
"start",
"index"
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/intervalTree.py#L194-L208 |
aganezov/gos | gos/manager.py | Manager.initiate_tasks | def initiate_tasks(self):
""" Loads all tasks using `TaskLoader` from respective configuration option """
self.tasks_classes = TaskLoader().load_tasks(
paths=self.configuration[Configuration.ALGORITHM][Configuration.TASKS][Configuration.PATHS]) | python | def initiate_tasks(self):
""" Loads all tasks using `TaskLoader` from respective configuration option """
self.tasks_classes = TaskLoader().load_tasks(
paths=self.configuration[Configuration.ALGORITHM][Configuration.TASKS][Configuration.PATHS]) | [
"def",
"initiate_tasks",
"(",
"self",
")",
":",
"self",
".",
"tasks_classes",
"=",
"TaskLoader",
"(",
")",
".",
"load_tasks",
"(",
"paths",
"=",
"self",
".",
"configuration",
"[",
"Configuration",
".",
"ALGORITHM",
"]",
"[",
"Configuration",
".",
"TASKS",
... | Loads all tasks using `TaskLoader` from respective configuration option | [
"Loads",
"all",
"tasks",
"using",
"TaskLoader",
"from",
"respective",
"configuration",
"option"
] | train | https://github.com/aganezov/gos/blob/fb4d210284f3037c5321250cb95f3901754feb6b/gos/manager.py#L16-L19 |
aganezov/gos | gos/manager.py | Manager.instantiate_tasks | def instantiate_tasks(self):
""" All loaded tasks are initialized. Depending on configuration fails in such instantiations may be silent """
self.tasks_instances = {}
for task_name, task_class in self.tasks_classes.items():
try:
self.tasks_instances[task_name] = task_... | python | def instantiate_tasks(self):
""" All loaded tasks are initialized. Depending on configuration fails in such instantiations may be silent """
self.tasks_instances = {}
for task_name, task_class in self.tasks_classes.items():
try:
self.tasks_instances[task_name] = task_... | [
"def",
"instantiate_tasks",
"(",
"self",
")",
":",
"self",
".",
"tasks_instances",
"=",
"{",
"}",
"for",
"task_name",
",",
"task_class",
"in",
"self",
".",
"tasks_classes",
".",
"items",
"(",
")",
":",
"try",
":",
"self",
".",
"tasks_instances",
"[",
"ta... | All loaded tasks are initialized. Depending on configuration fails in such instantiations may be silent | [
"All",
"loaded",
"tasks",
"are",
"initialized",
".",
"Depending",
"on",
"configuration",
"fails",
"in",
"such",
"instantiations",
"may",
"be",
"silent"
] | train | https://github.com/aganezov/gos/blob/fb4d210284f3037c5321250cb95f3901754feb6b/gos/manager.py#L21-L30 |
fedora-infra/fmn.rules | setup.py | get_requirements | def get_requirements(filename='requirements.txt'):
"""
Get the contents of a file listing the requirements.
:param filename: path to a requirements file
:type filename: str
:returns: the list of requirements
:return type: list
"""
with open(filename) as f:
return [
... | python | def get_requirements(filename='requirements.txt'):
"""
Get the contents of a file listing the requirements.
:param filename: path to a requirements file
:type filename: str
:returns: the list of requirements
:return type: list
"""
with open(filename) as f:
return [
... | [
"def",
"get_requirements",
"(",
"filename",
"=",
"'requirements.txt'",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"return",
"[",
"line",
".",
"rstrip",
"(",
")",
".",
"split",
"(",
"'#'",
")",
"[",
"0",
"]",
"for",
"line",
"in",
... | Get the contents of a file listing the requirements.
:param filename: path to a requirements file
:type filename: str
:returns: the list of requirements
:return type: list | [
"Get",
"the",
"contents",
"of",
"a",
"file",
"listing",
"the",
"requirements",
"."
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/setup.py#L23-L38 |
tehmaze-labs/wright | wright/stage/env.py | Generate._have | def _have(self, name=None):
"""Check if a configure flag is set.
If called without argument, it returns all HAVE_* items.
Example:
{% if have('netinet/ip.h') %}...{% endif %}
"""
if name is None:
return (
(k, v) for k, v in self.env.ite... | python | def _have(self, name=None):
"""Check if a configure flag is set.
If called without argument, it returns all HAVE_* items.
Example:
{% if have('netinet/ip.h') %}...{% endif %}
"""
if name is None:
return (
(k, v) for k, v in self.env.ite... | [
"def",
"_have",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"return",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"env",
".",
"items",
"(",
")",
"if",
"k",
".",
"startswith",
... | Check if a configure flag is set.
If called without argument, it returns all HAVE_* items.
Example:
{% if have('netinet/ip.h') %}...{% endif %} | [
"Check",
"if",
"a",
"configure",
"flag",
"is",
"set",
"."
] | train | https://github.com/tehmaze-labs/wright/blob/79b2d816f541e69d5fb7f36a3c39fa0d432157a6/wright/stage/env.py#L32-L46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.