repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Xion/taipan | taipan/objective/modifiers.py | abstract | def abstract(class_):
"""Mark the class as _abstract_ base class, forbidding its instantiation.
.. note::
Unlike other modifiers, ``@abstract`` can be applied
to all Python classes, not just subclasses of :class:`Object`.
.. versionadded:: 0.0.3
"""
if not inspect.isclass(class_):... | python | def abstract(class_):
"""Mark the class as _abstract_ base class, forbidding its instantiation.
.. note::
Unlike other modifiers, ``@abstract`` can be applied
to all Python classes, not just subclasses of :class:`Object`.
.. versionadded:: 0.0.3
"""
if not inspect.isclass(class_):... | [
"def",
"abstract",
"(",
"class_",
")",
":",
"if",
"not",
"inspect",
".",
"isclass",
"(",
"class_",
")",
":",
"raise",
"TypeError",
"(",
"\"@abstract can only be applied to classes\"",
")",
"abc_meta",
"=",
"None",
"class_meta",
"=",
"type",
"(",
"class_",
")",... | Mark the class as _abstract_ base class, forbidding its instantiation.
.. note::
Unlike other modifiers, ``@abstract`` can be applied
to all Python classes, not just subclasses of :class:`Object`.
.. versionadded:: 0.0.3 | [
"Mark",
"the",
"class",
"as",
"_abstract_",
"base",
"class",
"forbidding",
"its",
"instantiation",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/objective/modifiers.py#L50-L80 | train |
Xion/taipan | taipan/objective/modifiers.py | final | def final(arg):
"""Mark a class or method as _final_.
Final classes are those that end the inheritance chain, i.e. forbid
further subclassing. A final class can thus be only instantiated,
not inherited from.
Similarly, methods marked as final in a superclass cannot be overridden
in any of the ... | python | def final(arg):
"""Mark a class or method as _final_.
Final classes are those that end the inheritance chain, i.e. forbid
further subclassing. A final class can thus be only instantiated,
not inherited from.
Similarly, methods marked as final in a superclass cannot be overridden
in any of the ... | [
"def",
"final",
"(",
"arg",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"arg",
")",
":",
"if",
"not",
"isinstance",
"(",
"arg",
",",
"ObjectMetaclass",
")",
":",
"raise",
"ValueError",
"(",
"\"@final can only be applied to a class \"",
"\"that is a subclass ... | Mark a class or method as _final_.
Final classes are those that end the inheritance chain, i.e. forbid
further subclassing. A final class can thus be only instantiated,
not inherited from.
Similarly, methods marked as final in a superclass cannot be overridden
in any of the subclasses.
.. not... | [
"Mark",
"a",
"class",
"or",
"method",
"as",
"_final_",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/objective/modifiers.py#L93-L129 | train |
Xion/taipan | taipan/objective/modifiers.py | override | def override(base=ABSENT):
"""Mark a method as overriding a corresponding method from superclass.
:param base:
Optional base class from which this method is being overridden.
If provided, it can be a class itself, or its (qualified) name.
.. note::
When overriding a :class:`class... | python | def override(base=ABSENT):
"""Mark a method as overriding a corresponding method from superclass.
:param base:
Optional base class from which this method is being overridden.
If provided, it can be a class itself, or its (qualified) name.
.. note::
When overriding a :class:`class... | [
"def",
"override",
"(",
"base",
"=",
"ABSENT",
")",
":",
"arg",
"=",
"base",
"if",
"inspect",
".",
"isfunction",
"(",
"arg",
")",
"or",
"isinstance",
"(",
"arg",
",",
"NonInstanceMethod",
")",
":",
"_OverrideDecorator",
".",
"maybe_signal_classmethod",
"(",
... | Mark a method as overriding a corresponding method from superclass.
:param base:
Optional base class from which this method is being overridden.
If provided, it can be a class itself, or its (qualified) name.
.. note::
When overriding a :class:`classmethod`, remember to place ``@over... | [
"Mark",
"a",
"method",
"as",
"overriding",
"a",
"corresponding",
"method",
"from",
"superclass",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/objective/modifiers.py#L134-L170 | train |
Xion/taipan | taipan/collections/lists.py | find | def find(*args, **kwargs):
"""Find the first matching element in a list and return it.
Usage::
find(element, list_)
find(of=element, in_=list_)
find(where=predicate, in_=list_)
:param element, of: Element to search for (by equality comparison)
:param where: Predicate defining ... | python | def find(*args, **kwargs):
"""Find the first matching element in a list and return it.
Usage::
find(element, list_)
find(of=element, in_=list_)
find(where=predicate, in_=list_)
:param element, of: Element to search for (by equality comparison)
:param where: Predicate defining ... | [
"def",
"find",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"list_",
",",
"idx",
"=",
"_index",
"(",
"*",
"args",
",",
"start",
"=",
"0",
",",
"step",
"=",
"1",
",",
"**",
"kwargs",
")",
"if",
"idx",
"<",
"0",
":",
"raise",
"IndexError",
... | Find the first matching element in a list and return it.
Usage::
find(element, list_)
find(of=element, in_=list_)
find(where=predicate, in_=list_)
:param element, of: Element to search for (by equality comparison)
:param where: Predicate defining an element to search for.
... | [
"Find",
"the",
"first",
"matching",
"element",
"in",
"a",
"list",
"and",
"return",
"it",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/collections/lists.py#L50-L73 | train |
Xion/taipan | taipan/collections/lists.py | findlast | def findlast(*args, **kwargs):
"""Find the last matching element in a list and return it.
Usage::
findlast(element, list_)
findlast(of=element, in_=list_)
findlast(where=predicate, in_=list_)
:param element, of: Element to search for (by equality comparison)
:param where: Pred... | python | def findlast(*args, **kwargs):
"""Find the last matching element in a list and return it.
Usage::
findlast(element, list_)
findlast(of=element, in_=list_)
findlast(where=predicate, in_=list_)
:param element, of: Element to search for (by equality comparison)
:param where: Pred... | [
"def",
"findlast",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"list_",
",",
"idx",
"=",
"_index",
"(",
"*",
"args",
",",
"start",
"=",
"sys",
".",
"maxsize",
",",
"step",
"=",
"-",
"1",
",",
"**",
"kwargs",
")",
"if",
"idx",
"<",
"0",
"... | Find the last matching element in a list and return it.
Usage::
findlast(element, list_)
findlast(of=element, in_=list_)
findlast(where=predicate, in_=list_)
:param element, of: Element to search for (by equality comparison)
:param where: Predicate defining an element to search fo... | [
"Find",
"the",
"last",
"matching",
"element",
"in",
"a",
"list",
"and",
"return",
"it",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/collections/lists.py#L76-L99 | train |
Xion/taipan | taipan/collections/lists.py | index | def index(*args, **kwargs):
"""Search a list for an exact element, or element satisfying a predicate.
Usage::
index(element, list_)
index(of=element, in_=list_)
index(where=predicate, in_=list_)
:param element, of: Element to search for (by equality comparison)
:param where: P... | python | def index(*args, **kwargs):
"""Search a list for an exact element, or element satisfying a predicate.
Usage::
index(element, list_)
index(of=element, in_=list_)
index(where=predicate, in_=list_)
:param element, of: Element to search for (by equality comparison)
:param where: P... | [
"def",
"index",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"_",
",",
"idx",
"=",
"_index",
"(",
"*",
"args",
",",
"start",
"=",
"0",
",",
"step",
"=",
"1",
",",
"**",
"kwargs",
")",
"return",
"idx"
] | Search a list for an exact element, or element satisfying a predicate.
Usage::
index(element, list_)
index(of=element, in_=list_)
index(where=predicate, in_=list_)
:param element, of: Element to search for (by equality comparison)
:param where: Predicate defining an element to sea... | [
"Search",
"a",
"list",
"for",
"an",
"exact",
"element",
"or",
"element",
"satisfying",
"a",
"predicate",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/collections/lists.py#L102-L122 | train |
Xion/taipan | taipan/collections/lists.py | lastindex | def lastindex(*args, **kwargs):
"""Search a list backwards for an exact element,
or element satisfying a predicate.
Usage::
lastindex(element, list_)
lastindex(of=element, in_=list_)
lastindex(where=predicate, in_=list_)
:param element, of: Element to search for (by equality c... | python | def lastindex(*args, **kwargs):
"""Search a list backwards for an exact element,
or element satisfying a predicate.
Usage::
lastindex(element, list_)
lastindex(of=element, in_=list_)
lastindex(where=predicate, in_=list_)
:param element, of: Element to search for (by equality c... | [
"def",
"lastindex",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"_",
",",
"idx",
"=",
"_index",
"(",
"*",
"args",
",",
"start",
"=",
"sys",
".",
"maxsize",
",",
"step",
"=",
"-",
"1",
",",
"**",
"kwargs",
")",
"return",
"idx"
] | Search a list backwards for an exact element,
or element satisfying a predicate.
Usage::
lastindex(element, list_)
lastindex(of=element, in_=list_)
lastindex(where=predicate, in_=list_)
:param element, of: Element to search for (by equality comparison)
:param where: Predicate ... | [
"Search",
"a",
"list",
"backwards",
"for",
"an",
"exact",
"element",
"or",
"element",
"satisfying",
"a",
"predicate",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/collections/lists.py#L125-L146 | train |
Xion/taipan | taipan/collections/lists.py | _index | def _index(*args, **kwargs):
"""Implementation of list searching.
:param of: Element to search for
:param where: Predicate to search for
:param in_: List to search in
:param start: Start index for the lookup
:param step: Counter step (i.e. in/decrement) for each iteration
:return: Pair of ... | python | def _index(*args, **kwargs):
"""Implementation of list searching.
:param of: Element to search for
:param where: Predicate to search for
:param in_: List to search in
:param start: Start index for the lookup
:param step: Counter step (i.e. in/decrement) for each iteration
:return: Pair of ... | [
"def",
"_index",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"start",
"=",
"kwargs",
".",
"pop",
"(",
"'start'",
",",
"0",
")",
"step",
"=",
"kwargs",
".",
"pop",
"(",
"'step'",
",",
"1",
")",
"if",
"len",
"(",
"args",
")",
"==",
"2",
":... | Implementation of list searching.
:param of: Element to search for
:param where: Predicate to search for
:param in_: List to search in
:param start: Start index for the lookup
:param step: Counter step (i.e. in/decrement) for each iteration
:return: Pair of ``(list, index)``,
wher... | [
"Implementation",
"of",
"list",
"searching",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/collections/lists.py#L149-L194 | train |
Xion/taipan | taipan/collections/lists.py | intercalate | def intercalate(elems, list_):
"""Insert given elements between existing elements of a list.
:param elems: List of elements to insert between elements of ``list_`
:param list_: List to insert the elements to
:return: A new list where items from ``elems`` are inserted
between every two ele... | python | def intercalate(elems, list_):
"""Insert given elements between existing elements of a list.
:param elems: List of elements to insert between elements of ``list_`
:param list_: List to insert the elements to
:return: A new list where items from ``elems`` are inserted
between every two ele... | [
"def",
"intercalate",
"(",
"elems",
",",
"list_",
")",
":",
"ensure_sequence",
"(",
"elems",
")",
"ensure_sequence",
"(",
"list_",
")",
"if",
"len",
"(",
"list_",
")",
"<=",
"1",
":",
"return",
"list_",
"return",
"sum",
"(",
"(",
"elems",
"+",
"list_",... | Insert given elements between existing elements of a list.
:param elems: List of elements to insert between elements of ``list_`
:param list_: List to insert the elements to
:return: A new list where items from ``elems`` are inserted
between every two elements of ``list_`` | [
"Insert",
"given",
"elements",
"between",
"existing",
"elements",
"of",
"a",
"list",
"."
] | f333f0287c8bd0915182c7d5308e5f05ef0cca78 | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/collections/lists.py#L208-L225 | train |
tjcsl/cslbot | cslbot/hooks/caps.py | handle | def handle(_, msg, args):
"""Check for capslock abuse.
Check if a line is more than THRESHOLD percent uppercase. If this is
the second line in a row, kick the user.
"""
# SHUT CAPS LOCK OFF, MORON
if args['config']['feature'].getboolean('capskick'):
nick = args['nick']
thresho... | python | def handle(_, msg, args):
"""Check for capslock abuse.
Check if a line is more than THRESHOLD percent uppercase. If this is
the second line in a row, kick the user.
"""
# SHUT CAPS LOCK OFF, MORON
if args['config']['feature'].getboolean('capskick'):
nick = args['nick']
thresho... | [
"def",
"handle",
"(",
"_",
",",
"msg",
",",
"args",
")",
":",
"if",
"args",
"[",
"'config'",
"]",
"[",
"'feature'",
"]",
".",
"getboolean",
"(",
"'capskick'",
")",
":",
"nick",
"=",
"args",
"[",
"'nick'",
"]",
"threshold",
"=",
"0.65",
"text",
"=",... | Check for capslock abuse.
Check if a line is more than THRESHOLD percent uppercase. If this is
the second line in a row, kick the user. | [
"Check",
"for",
"capslock",
"abuse",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/hooks/caps.py#L29-L55 | train |
tjcsl/cslbot | cslbot/commands/fullwidth.py | cmd | def cmd(send, msg, args):
"""Converts text to fullwidth characters.
Syntax: {command} [text]
"""
if not msg:
msg = gen_word()
send(gen_fullwidth(msg.upper())) | python | def cmd(send, msg, args):
"""Converts text to fullwidth characters.
Syntax: {command} [text]
"""
if not msg:
msg = gen_word()
send(gen_fullwidth(msg.upper())) | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"if",
"not",
"msg",
":",
"msg",
"=",
"gen_word",
"(",
")",
"send",
"(",
"gen_fullwidth",
"(",
"msg",
".",
"upper",
"(",
")",
")",
")"
] | Converts text to fullwidth characters.
Syntax: {command} [text] | [
"Converts",
"text",
"to",
"fullwidth",
"characters",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/fullwidth.py#L23-L31 | train |
ktdreyer/txkoji | examples/estimate-container.py | task_estimates | def task_estimates(channel, states):
"""
Estimate remaining time for all tasks in this channel.
:param channel: txkoji.channel.Channel
:param list states: list of task_states ints, eg [task_states.OPEN]
:returns: deferred that when fired returns a list of
(task, est_remaining) tuples
... | python | def task_estimates(channel, states):
"""
Estimate remaining time for all tasks in this channel.
:param channel: txkoji.channel.Channel
:param list states: list of task_states ints, eg [task_states.OPEN]
:returns: deferred that when fired returns a list of
(task, est_remaining) tuples
... | [
"def",
"task_estimates",
"(",
"channel",
",",
"states",
")",
":",
"for",
"state",
"in",
"states",
":",
"if",
"state",
"!=",
"task_states",
".",
"OPEN",
":",
"raise",
"NotImplementedError",
"(",
"'only estimate OPEN tasks'",
")",
"tasks",
"=",
"yield",
"channel... | Estimate remaining time for all tasks in this channel.
:param channel: txkoji.channel.Channel
:param list states: list of task_states ints, eg [task_states.OPEN]
:returns: deferred that when fired returns a list of
(task, est_remaining) tuples | [
"Estimate",
"remaining",
"time",
"for",
"all",
"tasks",
"in",
"this",
"channel",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/examples/estimate-container.py#L80-L109 | train |
ktdreyer/txkoji | examples/estimate-container.py | describe_delta | def describe_delta(delta):
"""
Describe this timedelta in human-readable terms.
:param delta: datetime.timedelta object
:returns: str, describing this delta
"""
s = delta.total_seconds()
s = abs(s)
hours, remainder = divmod(s, 3600)
minutes, seconds = divmod(remainder, 60)
if ho... | python | def describe_delta(delta):
"""
Describe this timedelta in human-readable terms.
:param delta: datetime.timedelta object
:returns: str, describing this delta
"""
s = delta.total_seconds()
s = abs(s)
hours, remainder = divmod(s, 3600)
minutes, seconds = divmod(remainder, 60)
if ho... | [
"def",
"describe_delta",
"(",
"delta",
")",
":",
"s",
"=",
"delta",
".",
"total_seconds",
"(",
")",
"s",
"=",
"abs",
"(",
"s",
")",
"hours",
",",
"remainder",
"=",
"divmod",
"(",
"s",
",",
"3600",
")",
"minutes",
",",
"seconds",
"=",
"divmod",
"(",... | Describe this timedelta in human-readable terms.
:param delta: datetime.timedelta object
:returns: str, describing this delta | [
"Describe",
"this",
"timedelta",
"in",
"human",
"-",
"readable",
"terms",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/examples/estimate-container.py#L112-L127 | train |
ktdreyer/txkoji | examples/estimate-container.py | log_est_complete | def log_est_complete(est_complete):
"""
Log the relative time remaining for this est_complete datetime object.
"""
if not est_complete:
print('could not determine an estimated completion time')
return
remaining = est_complete - datetime.utcnow()
message = 'this task should be com... | python | def log_est_complete(est_complete):
"""
Log the relative time remaining for this est_complete datetime object.
"""
if not est_complete:
print('could not determine an estimated completion time')
return
remaining = est_complete - datetime.utcnow()
message = 'this task should be com... | [
"def",
"log_est_complete",
"(",
"est_complete",
")",
":",
"if",
"not",
"est_complete",
":",
"print",
"(",
"'could not determine an estimated completion time'",
")",
"return",
"remaining",
"=",
"est_complete",
"-",
"datetime",
".",
"utcnow",
"(",
")",
"message",
"=",... | Log the relative time remaining for this est_complete datetime object. | [
"Log",
"the",
"relative",
"time",
"remaining",
"for",
"this",
"est_complete",
"datetime",
"object",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/examples/estimate-container.py#L130-L141 | train |
davisagli/eye | eye/patch.py | patched_normalizeargs | def patched_normalizeargs(sequence, output = None):
"""Normalize declaration arguments
Normalization arguments might contain Declarions, tuples, or single
interfaces.
Anything but individial interfaces or implements specs will be expanded.
"""
if output is None:
output = []
if Bro... | python | def patched_normalizeargs(sequence, output = None):
"""Normalize declaration arguments
Normalization arguments might contain Declarions, tuples, or single
interfaces.
Anything but individial interfaces or implements specs will be expanded.
"""
if output is None:
output = []
if Bro... | [
"def",
"patched_normalizeargs",
"(",
"sequence",
",",
"output",
"=",
"None",
")",
":",
"if",
"output",
"is",
"None",
":",
"output",
"=",
"[",
"]",
"if",
"Broken",
"in",
"getattr",
"(",
"sequence",
",",
"'__bases__'",
",",
"(",
")",
")",
":",
"return",
... | Normalize declaration arguments
Normalization arguments might contain Declarions, tuples, or single
interfaces.
Anything but individial interfaces or implements specs will be expanded. | [
"Normalize",
"declaration",
"arguments"
] | 4007b6b490ac667c8423c6cc789b303e93f9d03d | https://github.com/davisagli/eye/blob/4007b6b490ac667c8423c6cc789b303e93f9d03d/eye/patch.py#L12-L33 | train |
ktdreyer/txkoji | txkoji/connection.py | profiles | def profiles():
"""
List of all the connection profile files, ordered by preference.
:returns: list of all Koji client config files. Example:
['/home/kdreyer/.koji/config.d/kojidev.conf',
'/etc/koji.conf.d/stg.conf',
'/etc/koji.conf.d/fedora.conf']
"""
pa... | python | def profiles():
"""
List of all the connection profile files, ordered by preference.
:returns: list of all Koji client config files. Example:
['/home/kdreyer/.koji/config.d/kojidev.conf',
'/etc/koji.conf.d/stg.conf',
'/etc/koji.conf.d/fedora.conf']
"""
pa... | [
"def",
"profiles",
"(",
")",
":",
"paths",
"=",
"[",
"]",
"for",
"pattern",
"in",
"PROFILES",
":",
"pattern",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"pattern",
")",
"paths",
"+=",
"glob",
"(",
"pattern",
")",
"return",
"paths"
] | List of all the connection profile files, ordered by preference.
:returns: list of all Koji client config files. Example:
['/home/kdreyer/.koji/config.d/kojidev.conf',
'/etc/koji.conf.d/stg.conf',
'/etc/koji.conf.d/fedora.conf'] | [
"List",
"of",
"all",
"the",
"connection",
"profile",
"files",
"ordered",
"by",
"preference",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L38-L51 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.lookup | def lookup(self, profile, setting):
""" Check koji.conf.d files for this profile's setting.
:param setting: ``str`` like "server" (for kojihub) or "weburl"
:returns: ``str``, value for this setting
"""
for path in profiles():
cfg = SafeConfigParser()
cfg.... | python | def lookup(self, profile, setting):
""" Check koji.conf.d files for this profile's setting.
:param setting: ``str`` like "server" (for kojihub) or "weburl"
:returns: ``str``, value for this setting
"""
for path in profiles():
cfg = SafeConfigParser()
cfg.... | [
"def",
"lookup",
"(",
"self",
",",
"profile",
",",
"setting",
")",
":",
"for",
"path",
"in",
"profiles",
"(",
")",
":",
"cfg",
"=",
"SafeConfigParser",
"(",
")",
"cfg",
".",
"read",
"(",
"path",
")",
"if",
"profile",
"not",
"in",
"cfg",
".",
"secti... | Check koji.conf.d files for this profile's setting.
:param setting: ``str`` like "server" (for kojihub) or "weburl"
:returns: ``str``, value for this setting | [
"Check",
"koji",
".",
"conf",
".",
"d",
"files",
"for",
"this",
"profile",
"s",
"setting",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L71-L84 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.connect_from_web | def connect_from_web(klass, url):
"""
Find a connection that matches this kojiweb URL.
Check all koji.conf.d files' kojiweb URLs and load the profile that
matches the url we pass in here.
For example, if a user pastes a kojiweb URL into chat, we want to
discover the cor... | python | def connect_from_web(klass, url):
"""
Find a connection that matches this kojiweb URL.
Check all koji.conf.d files' kojiweb URLs and load the profile that
matches the url we pass in here.
For example, if a user pastes a kojiweb URL into chat, we want to
discover the cor... | [
"def",
"connect_from_web",
"(",
"klass",
",",
"url",
")",
":",
"if",
"re",
".",
"search",
"(",
"r'\\s'",
",",
"url",
")",
":",
"return",
"url",
"=",
"url",
".",
"split",
"(",
"' '",
",",
"1",
")",
"[",
"0",
"]",
"for",
"path",
"in",
"profiles",
... | Find a connection that matches this kojiweb URL.
Check all koji.conf.d files' kojiweb URLs and load the profile that
matches the url we pass in here.
For example, if a user pastes a kojiweb URL into chat, we want to
discover the corresponding Koji instance hub automatically.
S... | [
"Find",
"a",
"connection",
"that",
"matches",
"this",
"kojiweb",
"URL",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L87-L115 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.from_web | def from_web(self, url):
"""
Reverse-engineer a kojiweb URL into an equivalent API response.
Only a few kojiweb URL endpoints work here.
See also connect_from_web().
:param url: ``str``, for example
"http://cbs.centos.org/koji/buildinfo?buildID=21155"
... | python | def from_web(self, url):
"""
Reverse-engineer a kojiweb URL into an equivalent API response.
Only a few kojiweb URL endpoints work here.
See also connect_from_web().
:param url: ``str``, for example
"http://cbs.centos.org/koji/buildinfo?buildID=21155"
... | [
"def",
"from_web",
"(",
"self",
",",
"url",
")",
":",
"if",
"re",
".",
"search",
"(",
"r'\\s'",
",",
"url",
")",
":",
"return",
"defer",
".",
"succeed",
"(",
"None",
")",
"o",
"=",
"urlparse",
"(",
"url",
")",
"endpoint",
"=",
"os",
".",
"path",
... | Reverse-engineer a kojiweb URL into an equivalent API response.
Only a few kojiweb URL endpoints work here.
See also connect_from_web().
:param url: ``str``, for example
"http://cbs.centos.org/koji/buildinfo?buildID=21155"
:returns: deferred that when fired returns... | [
"Reverse",
"-",
"engineer",
"a",
"kojiweb",
"URL",
"into",
"an",
"equivalent",
"API",
"response",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L117-L158 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.call | def call(self, method, *args, **kwargs):
"""
Make an XML-RPC call to the server.
If this client is logged in (with login()), this call will be
authenticated.
Koji has its own custom implementation of XML-RPC that supports named
args (kwargs). For example, to use the "qu... | python | def call(self, method, *args, **kwargs):
"""
Make an XML-RPC call to the server.
If this client is logged in (with login()), this call will be
authenticated.
Koji has its own custom implementation of XML-RPC that supports named
args (kwargs). For example, to use the "qu... | [
"def",
"call",
"(",
"self",
",",
"method",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"kwargs",
":",
"kwargs",
"[",
"'__starstar'",
"]",
"=",
"True",
"args",
"=",
"args",
"+",
"(",
"kwargs",
",",
")",
"if",
"self",
".",
"session_id",
... | Make an XML-RPC call to the server.
If this client is logged in (with login()), this call will be
authenticated.
Koji has its own custom implementation of XML-RPC that supports named
args (kwargs). For example, to use the "queryOpts" kwarg:
d = client.call('listBuilds', pack... | [
"Make",
"an",
"XML",
"-",
"RPC",
"call",
"to",
"the",
"server",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L160-L190 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection._authenticated_path | def _authenticated_path(self):
"""
Get the path of our XML-RPC endpoint with session auth params added.
For example:
/kojihub?session-id=123456&session-key=1234-asdf&callnum=0
If we're making an authenticated request, we must add these session
parameters to the hub's ... | python | def _authenticated_path(self):
"""
Get the path of our XML-RPC endpoint with session auth params added.
For example:
/kojihub?session-id=123456&session-key=1234-asdf&callnum=0
If we're making an authenticated request, we must add these session
parameters to the hub's ... | [
"def",
"_authenticated_path",
"(",
"self",
")",
":",
"basepath",
"=",
"self",
".",
"proxy",
".",
"path",
".",
"decode",
"(",
")",
".",
"split",
"(",
"'?'",
")",
"[",
"0",
"]",
"params",
"=",
"urlencode",
"(",
"{",
"'session-id'",
":",
"self",
".",
... | Get the path of our XML-RPC endpoint with session auth params added.
For example:
/kojihub?session-id=123456&session-key=1234-asdf&callnum=0
If we're making an authenticated request, we must add these session
parameters to the hub's XML-RPC endpoint.
:return: a path suitable... | [
"Get",
"the",
"path",
"of",
"our",
"XML",
"-",
"RPC",
"endpoint",
"with",
"session",
"auth",
"params",
"added",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L192-L209 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.getAverageBuildDuration | def getAverageBuildDuration(self, package, **kwargs):
"""
Return a timedelta that Koji considers to be average for this package.
Calls "getAverageBuildDuration" XML-RPC.
:param package: ``str``, for example "ceph"
:returns: deferred that when fired returns a datetime object for... | python | def getAverageBuildDuration(self, package, **kwargs):
"""
Return a timedelta that Koji considers to be average for this package.
Calls "getAverageBuildDuration" XML-RPC.
:param package: ``str``, for example "ceph"
:returns: deferred that when fired returns a datetime object for... | [
"def",
"getAverageBuildDuration",
"(",
"self",
",",
"package",
",",
"**",
"kwargs",
")",
":",
"seconds",
"=",
"yield",
"self",
".",
"call",
"(",
"'getAverageBuildDuration'",
",",
"package",
",",
"**",
"kwargs",
")",
"if",
"seconds",
"is",
"None",
":",
"def... | Return a timedelta that Koji considers to be average for this package.
Calls "getAverageBuildDuration" XML-RPC.
:param package: ``str``, for example "ceph"
:returns: deferred that when fired returns a datetime object for the
estimated duration, or None if we could find no est... | [
"Return",
"a",
"timedelta",
"that",
"Koji",
"considers",
"to",
"be",
"average",
"for",
"this",
"package",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L215-L229 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.getBuild | def getBuild(self, build_id, **kwargs):
"""
Load all information about a build and return a custom Build class.
Calls "getBuild" XML-RPC.
:param build_id: ``int``, for example 12345
:returns: deferred that when fired returns a Build (Munch, dict-like)
object r... | python | def getBuild(self, build_id, **kwargs):
"""
Load all information about a build and return a custom Build class.
Calls "getBuild" XML-RPC.
:param build_id: ``int``, for example 12345
:returns: deferred that when fired returns a Build (Munch, dict-like)
object r... | [
"def",
"getBuild",
"(",
"self",
",",
"build_id",
",",
"**",
"kwargs",
")",
":",
"buildinfo",
"=",
"yield",
"self",
".",
"call",
"(",
"'getBuild'",
",",
"build_id",
",",
"**",
"kwargs",
")",
"build",
"=",
"Build",
".",
"fromDict",
"(",
"buildinfo",
")",... | Load all information about a build and return a custom Build class.
Calls "getBuild" XML-RPC.
:param build_id: ``int``, for example 12345
:returns: deferred that when fired returns a Build (Munch, dict-like)
object representing this Koji build, or None if no build was
... | [
"Load",
"all",
"information",
"about",
"a",
"build",
"and",
"return",
"a",
"custom",
"Build",
"class",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L232-L247 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.getChannel | def getChannel(self, channel_id, **kwargs):
"""
Load all information about a channel and return a custom Channel class.
Calls "getChannel" XML-RPC.
:param channel_id: ``int``, for example 12345, or ``str`` for name.
:returns: deferred that when fired returns a Channel (Munch, d... | python | def getChannel(self, channel_id, **kwargs):
"""
Load all information about a channel and return a custom Channel class.
Calls "getChannel" XML-RPC.
:param channel_id: ``int``, for example 12345, or ``str`` for name.
:returns: deferred that when fired returns a Channel (Munch, d... | [
"def",
"getChannel",
"(",
"self",
",",
"channel_id",
",",
"**",
"kwargs",
")",
":",
"channelinfo",
"=",
"yield",
"self",
".",
"call",
"(",
"'getChannel'",
",",
"channel_id",
",",
"**",
"kwargs",
")",
"channel",
"=",
"Channel",
".",
"fromDict",
"(",
"chan... | Load all information about a channel and return a custom Channel class.
Calls "getChannel" XML-RPC.
:param channel_id: ``int``, for example 12345, or ``str`` for name.
:returns: deferred that when fired returns a Channel (Munch, dict-like)
object representing this Koji channe... | [
"Load",
"all",
"information",
"about",
"a",
"channel",
"and",
"return",
"a",
"custom",
"Channel",
"class",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L250-L265 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.getPackage | def getPackage(self, name, **kwargs):
"""
Load information about a package and return a custom Package class.
Calls "getPackage" XML-RPC.
:param package_id: ``int``, for example 12345
:returns: deferred that when fired returns a Package (Munch, dict-like)
obje... | python | def getPackage(self, name, **kwargs):
"""
Load information about a package and return a custom Package class.
Calls "getPackage" XML-RPC.
:param package_id: ``int``, for example 12345
:returns: deferred that when fired returns a Package (Munch, dict-like)
obje... | [
"def",
"getPackage",
"(",
"self",
",",
"name",
",",
"**",
"kwargs",
")",
":",
"packageinfo",
"=",
"yield",
"self",
".",
"call",
"(",
"'getPackage'",
",",
"name",
",",
"**",
"kwargs",
")",
"package",
"=",
"Package",
".",
"fromDict",
"(",
"packageinfo",
... | Load information about a package and return a custom Package class.
Calls "getPackage" XML-RPC.
:param package_id: ``int``, for example 12345
:returns: deferred that when fired returns a Package (Munch, dict-like)
object representing this Koji package, or None if no build
... | [
"Load",
"information",
"about",
"a",
"package",
"and",
"return",
"a",
"custom",
"Package",
"class",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L268-L283 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.getTaskDescendents | def getTaskDescendents(self, task_id, **kwargs):
"""
Load all information about a task's descendents into Task classes.
Calls "getTaskDescendents" XML-RPC (with request=True to get the full
information.)
:param task_id: ``int``, for example 12345, parent task ID
:return... | python | def getTaskDescendents(self, task_id, **kwargs):
"""
Load all information about a task's descendents into Task classes.
Calls "getTaskDescendents" XML-RPC (with request=True to get the full
information.)
:param task_id: ``int``, for example 12345, parent task ID
:return... | [
"def",
"getTaskDescendents",
"(",
"self",
",",
"task_id",
",",
"**",
"kwargs",
")",
":",
"kwargs",
"[",
"'request'",
"]",
"=",
"True",
"data",
"=",
"yield",
"self",
".",
"call",
"(",
"'getTaskDescendents'",
",",
"task_id",
",",
"**",
"kwargs",
")",
"task... | Load all information about a task's descendents into Task classes.
Calls "getTaskDescendents" XML-RPC (with request=True to get the full
information.)
:param task_id: ``int``, for example 12345, parent task ID
:returns: deferred that when fired returns a list of Task (Munch,
... | [
"Load",
"all",
"information",
"about",
"a",
"task",
"s",
"descendents",
"into",
"Task",
"classes",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L286-L304 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.getTaskInfo | def getTaskInfo(self, task_id, **kwargs):
"""
Load all information about a task and return a custom Task class.
Calls "getTaskInfo" XML-RPC (with request=True to get the full
information.)
:param task_id: ``int``, for example 12345
:returns: deferred that when fired ret... | python | def getTaskInfo(self, task_id, **kwargs):
"""
Load all information about a task and return a custom Task class.
Calls "getTaskInfo" XML-RPC (with request=True to get the full
information.)
:param task_id: ``int``, for example 12345
:returns: deferred that when fired ret... | [
"def",
"getTaskInfo",
"(",
"self",
",",
"task_id",
",",
"**",
"kwargs",
")",
":",
"kwargs",
"[",
"'request'",
"]",
"=",
"True",
"taskinfo",
"=",
"yield",
"self",
".",
"call",
"(",
"'getTaskInfo'",
",",
"task_id",
",",
"**",
"kwargs",
")",
"task",
"=",
... | Load all information about a task and return a custom Task class.
Calls "getTaskInfo" XML-RPC (with request=True to get the full
information.)
:param task_id: ``int``, for example 12345
:returns: deferred that when fired returns a Task (Munch, dict-like)
object repres... | [
"Load",
"all",
"information",
"about",
"a",
"task",
"and",
"return",
"a",
"custom",
"Task",
"class",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L307-L324 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.listBuilds | def listBuilds(self, package, **kwargs):
"""
Get information about all builds of a package.
Calls "listBuilds" XML-RPC, with an enhancement: you can also pass a
string here for the package name instead of the package ID number.
See https://pagure.io/koji/issue/1209 for implement... | python | def listBuilds(self, package, **kwargs):
"""
Get information about all builds of a package.
Calls "listBuilds" XML-RPC, with an enhancement: you can also pass a
string here for the package name instead of the package ID number.
See https://pagure.io/koji/issue/1209 for implement... | [
"def",
"listBuilds",
"(",
"self",
",",
"package",
",",
"**",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"package",
",",
"int",
")",
":",
"package_id",
"=",
"package",
"else",
":",
"package_data",
"=",
"yield",
"self",
".",
"getPackage",
"(",
"package",... | Get information about all builds of a package.
Calls "listBuilds" XML-RPC, with an enhancement: you can also pass a
string here for the package name instead of the package ID number.
See https://pagure.io/koji/issue/1209 for implementing this
server-side.
:param package: ``int`... | [
"Get",
"information",
"about",
"all",
"builds",
"of",
"a",
"package",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L327-L353 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.listTagged | def listTagged(self, *args, **kwargs):
"""
List builds tagged with a tag.
Calls "listTagged" XML-RPC.
:returns: deferred that when fired returns a list of Build objects.
"""
data = yield self.call('listTagged', *args, **kwargs)
builds = []
for bdata in d... | python | def listTagged(self, *args, **kwargs):
"""
List builds tagged with a tag.
Calls "listTagged" XML-RPC.
:returns: deferred that when fired returns a list of Build objects.
"""
data = yield self.call('listTagged', *args, **kwargs)
builds = []
for bdata in d... | [
"def",
"listTagged",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"data",
"=",
"yield",
"self",
".",
"call",
"(",
"'listTagged'",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
"builds",
"=",
"[",
"]",
"for",
"bdata",
"in",
"data",
... | List builds tagged with a tag.
Calls "listTagged" XML-RPC.
:returns: deferred that when fired returns a list of Build objects. | [
"List",
"builds",
"tagged",
"with",
"a",
"tag",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L356-L370 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.listTasks | def listTasks(self, opts={}, queryOpts={}):
"""
Get information about all Koji tasks.
Calls "listTasks" XML-RPC.
:param dict opts: Eg. {'state': [task_states.OPEN]}
:param dict queryOpts: Eg. {'order' : 'priority,create_time'}
:returns: deferred that when fired returns ... | python | def listTasks(self, opts={}, queryOpts={}):
"""
Get information about all Koji tasks.
Calls "listTasks" XML-RPC.
:param dict opts: Eg. {'state': [task_states.OPEN]}
:param dict queryOpts: Eg. {'order' : 'priority,create_time'}
:returns: deferred that when fired returns ... | [
"def",
"listTasks",
"(",
"self",
",",
"opts",
"=",
"{",
"}",
",",
"queryOpts",
"=",
"{",
"}",
")",
":",
"opts",
"[",
"'decode'",
"]",
"=",
"True",
"data",
"=",
"yield",
"self",
".",
"call",
"(",
"'listTasks'",
",",
"opts",
",",
"queryOpts",
")",
... | Get information about all Koji tasks.
Calls "listTasks" XML-RPC.
:param dict opts: Eg. {'state': [task_states.OPEN]}
:param dict queryOpts: Eg. {'order' : 'priority,create_time'}
:returns: deferred that when fired returns a list of Task objects. | [
"Get",
"information",
"about",
"all",
"Koji",
"tasks",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L373-L390 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.listChannels | def listChannels(self, **kwargs):
"""
Get information about all Koji channels.
:param **kwargs: keyword args to pass through to listChannels RPC.
:returns: deferred that when fired returns a list of Channel objects.
"""
data = yield self.call('listChannels', **kwargs)
... | python | def listChannels(self, **kwargs):
"""
Get information about all Koji channels.
:param **kwargs: keyword args to pass through to listChannels RPC.
:returns: deferred that when fired returns a list of Channel objects.
"""
data = yield self.call('listChannels', **kwargs)
... | [
"def",
"listChannels",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"data",
"=",
"yield",
"self",
".",
"call",
"(",
"'listChannels'",
",",
"**",
"kwargs",
")",
"channels",
"=",
"[",
"]",
"for",
"cdata",
"in",
"data",
":",
"channel",
"=",
"Channel",
".... | Get information about all Koji channels.
:param **kwargs: keyword args to pass through to listChannels RPC.
:returns: deferred that when fired returns a list of Channel objects. | [
"Get",
"information",
"about",
"all",
"Koji",
"channels",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L393-L406 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection.login | def login(self):
"""
Return True if we successfully logged into this Koji hub.
We support GSSAPI and SSL Client authentication (not the old-style
krb-over-xmlrpc krbLogin method).
:returns: deferred that when fired returns True
"""
authtype = self.lookup(self.pr... | python | def login(self):
"""
Return True if we successfully logged into this Koji hub.
We support GSSAPI and SSL Client authentication (not the old-style
krb-over-xmlrpc krbLogin method).
:returns: deferred that when fired returns True
"""
authtype = self.lookup(self.pr... | [
"def",
"login",
"(",
"self",
")",
":",
"authtype",
"=",
"self",
".",
"lookup",
"(",
"self",
".",
"profile",
",",
"'authtype'",
")",
"if",
"authtype",
"is",
"None",
":",
"cert",
"=",
"self",
".",
"lookup",
"(",
"self",
".",
"profile",
",",
"'cert'",
... | Return True if we successfully logged into this Koji hub.
We support GSSAPI and SSL Client authentication (not the old-style
krb-over-xmlrpc krbLogin method).
:returns: deferred that when fired returns True | [
"Return",
"True",
"if",
"we",
"successfully",
"logged",
"into",
"this",
"Koji",
"hub",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L412-L439 | train |
ktdreyer/txkoji | txkoji/connection.py | Connection._ssl_agent | def _ssl_agent(self):
"""
Get a Twisted Agent that performs Client SSL authentication for Koji.
"""
# Load "cert" into a PrivateCertificate.
certfile = self.lookup(self.profile, 'cert')
certfile = os.path.expanduser(certfile)
with open(certfile) as certfp:
... | python | def _ssl_agent(self):
"""
Get a Twisted Agent that performs Client SSL authentication for Koji.
"""
# Load "cert" into a PrivateCertificate.
certfile = self.lookup(self.profile, 'cert')
certfile = os.path.expanduser(certfile)
with open(certfile) as certfp:
... | [
"def",
"_ssl_agent",
"(",
"self",
")",
":",
"certfile",
"=",
"self",
".",
"lookup",
"(",
"self",
".",
"profile",
",",
"'cert'",
")",
"certfile",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"certfile",
")",
"with",
"open",
"(",
"certfile",
")",
"a... | Get a Twisted Agent that performs Client SSL authentication for Koji. | [
"Get",
"a",
"Twisted",
"Agent",
"that",
"performs",
"Client",
"SSL",
"authentication",
"for",
"Koji",
"."
] | a7de380f29f745bf11730b27217208f6d4da7733 | https://github.com/ktdreyer/txkoji/blob/a7de380f29f745bf11730b27217208f6d4da7733/txkoji/connection.py#L451-L470 | train |
shapiromatron/bmds | bmds/logic/recommender.py | Recommender._get_bmdl_ratio | def _get_bmdl_ratio(self, models):
"""Return BMDL ratio in list of models."""
bmdls = [model.output["BMDL"] for model in models if model.output["BMDL"] > 0]
return max(bmdls) / min(bmdls) if len(bmdls) > 0 else 0 | python | def _get_bmdl_ratio(self, models):
"""Return BMDL ratio in list of models."""
bmdls = [model.output["BMDL"] for model in models if model.output["BMDL"] > 0]
return max(bmdls) / min(bmdls) if len(bmdls) > 0 else 0 | [
"def",
"_get_bmdl_ratio",
"(",
"self",
",",
"models",
")",
":",
"bmdls",
"=",
"[",
"model",
".",
"output",
"[",
"\"BMDL\"",
"]",
"for",
"model",
"in",
"models",
"if",
"model",
".",
"output",
"[",
"\"BMDL\"",
"]",
">",
"0",
"]",
"return",
"max",
"(",
... | Return BMDL ratio in list of models. | [
"Return",
"BMDL",
"ratio",
"in",
"list",
"of",
"models",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/logic/recommender.py#L129-L133 | train |
shapiromatron/bmds | bmds/logic/recommender.py | Recommender._get_parsimonious_model | def _get_parsimonious_model(models):
"""
Return the most parsimonious model of all available models. The most
parsimonious model is defined as the model with the fewest number of
parameters.
"""
params = [len(model.output["parameters"]) for model in models]
idx = ... | python | def _get_parsimonious_model(models):
"""
Return the most parsimonious model of all available models. The most
parsimonious model is defined as the model with the fewest number of
parameters.
"""
params = [len(model.output["parameters"]) for model in models]
idx = ... | [
"def",
"_get_parsimonious_model",
"(",
"models",
")",
":",
"params",
"=",
"[",
"len",
"(",
"model",
".",
"output",
"[",
"\"parameters\"",
"]",
")",
"for",
"model",
"in",
"models",
"]",
"idx",
"=",
"params",
".",
"index",
"(",
"min",
"(",
"params",
")",... | Return the most parsimonious model of all available models. The most
parsimonious model is defined as the model with the fewest number of
parameters. | [
"Return",
"the",
"most",
"parsimonious",
"model",
"of",
"all",
"available",
"models",
".",
"The",
"most",
"parsimonious",
"model",
"is",
"defined",
"as",
"the",
"model",
"with",
"the",
"fewest",
"number",
"of",
"parameters",
"."
] | 395c6ce84ad82876fd9fa4a89a3497fb61616de0 | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/logic/recommender.py#L145-L153 | train |
rraadd88/rohan | rohan/dandage/io_strs.py | make_pathable_string | def make_pathable_string(s,replacewith='_'):
"""
Removes symbols from a string to be compatible with directory structure.
:param s: string
"""
import re
return re.sub(r'[^\w+/.]',replacewith, s.lower()) | python | def make_pathable_string(s,replacewith='_'):
"""
Removes symbols from a string to be compatible with directory structure.
:param s: string
"""
import re
return re.sub(r'[^\w+/.]',replacewith, s.lower()) | [
"def",
"make_pathable_string",
"(",
"s",
",",
"replacewith",
"=",
"'_'",
")",
":",
"import",
"re",
"return",
"re",
".",
"sub",
"(",
"r'[^\\w+/.]'",
",",
"replacewith",
",",
"s",
".",
"lower",
"(",
")",
")"
] | Removes symbols from a string to be compatible with directory structure.
:param s: string | [
"Removes",
"symbols",
"from",
"a",
"string",
"to",
"be",
"compatible",
"with",
"directory",
"structure",
"."
] | b0643a3582a2fffc0165ace69fb80880d92bfb10 | https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/io_strs.py#L120-L127 | train |
rraadd88/rohan | rohan/dandage/io_strs.py | get_time | def get_time():
"""
Gets current time in a form of a formated string. Used in logger function.
"""
import datetime
time=make_pathable_string('%s' % datetime.datetime.now())
return time.replace('-','_').replace(':','_').replace('.','_') | python | def get_time():
"""
Gets current time in a form of a formated string. Used in logger function.
"""
import datetime
time=make_pathable_string('%s' % datetime.datetime.now())
return time.replace('-','_').replace(':','_').replace('.','_') | [
"def",
"get_time",
"(",
")",
":",
"import",
"datetime",
"time",
"=",
"make_pathable_string",
"(",
"'%s'",
"%",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
")",
"return",
"time",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
".",
"replace",
"(",
... | Gets current time in a form of a formated string. Used in logger function. | [
"Gets",
"current",
"time",
"in",
"a",
"form",
"of",
"a",
"formated",
"string",
".",
"Used",
"in",
"logger",
"function",
"."
] | b0643a3582a2fffc0165ace69fb80880d92bfb10 | https://github.com/rraadd88/rohan/blob/b0643a3582a2fffc0165ace69fb80880d92bfb10/rohan/dandage/io_strs.py#L174-L181 | train |
The-Politico/politico-civic-election-night | electionnight/management/commands/methods/bootstrap/general_election.py | GeneralElection.bootstrap_general_election | def bootstrap_general_election(self, election):
"""
Create a general election page type
"""
election_day = election.election_day
page_type, created = PageType.objects.get_or_create(
model_type=ContentType.objects.get(
app_label="election", model="elect... | python | def bootstrap_general_election(self, election):
"""
Create a general election page type
"""
election_day = election.election_day
page_type, created = PageType.objects.get_or_create(
model_type=ContentType.objects.get(
app_label="election", model="elect... | [
"def",
"bootstrap_general_election",
"(",
"self",
",",
"election",
")",
":",
"election_day",
"=",
"election",
".",
"election_day",
"page_type",
",",
"created",
"=",
"PageType",
".",
"objects",
".",
"get_or_create",
"(",
"model_type",
"=",
"ContentType",
".",
"ob... | Create a general election page type | [
"Create",
"a",
"general",
"election",
"page",
"type"
] | a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6 | https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/management/commands/methods/bootstrap/general_election.py#L6-L21 | train |
tjcsl/cslbot | cslbot/commands/wtf.py | cmd | def cmd(send, msg, _):
"""Tells you what acronyms mean.
Syntax: {command} <term>
"""
try:
answer = subprocess.check_output(['wtf', msg], stderr=subprocess.STDOUT)
send(answer.decode().strip().replace('\n', ' or ').replace('fuck', 'fsck'))
except subprocess.CalledProcessError as ex:... | python | def cmd(send, msg, _):
"""Tells you what acronyms mean.
Syntax: {command} <term>
"""
try:
answer = subprocess.check_output(['wtf', msg], stderr=subprocess.STDOUT)
send(answer.decode().strip().replace('\n', ' or ').replace('fuck', 'fsck'))
except subprocess.CalledProcessError as ex:... | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"_",
")",
":",
"try",
":",
"answer",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'wtf'",
",",
"msg",
"]",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
")",
"send",
"(",
"answer",
".",
"decode",... | Tells you what acronyms mean.
Syntax: {command} <term> | [
"Tells",
"you",
"what",
"acronyms",
"mean",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/wtf.py#L24-L34 | train |
kodethon/KoDrive | kodrive/cli.py | sys | def sys(**kwargs):
''' Manage system configuration. '''
output, err = cli_syncthing_adapter.sys(**kwargs)
if output:
click.echo("%s" % output, err=err)
else:
if not kwargs['init']:
click.echo(click.get_current_context().get_help()) | python | def sys(**kwargs):
''' Manage system configuration. '''
output, err = cli_syncthing_adapter.sys(**kwargs)
if output:
click.echo("%s" % output, err=err)
else:
if not kwargs['init']:
click.echo(click.get_current_context().get_help()) | [
"def",
"sys",
"(",
"**",
"kwargs",
")",
":",
"output",
",",
"err",
"=",
"cli_syncthing_adapter",
".",
"sys",
"(",
"**",
"kwargs",
")",
"if",
"output",
":",
"click",
".",
"echo",
"(",
"\"%s\"",
"%",
"output",
",",
"err",
"=",
"err",
")",
"else",
":"... | Manage system configuration. | [
"Manage",
"system",
"configuration",
"."
] | 325fe5e5870b7d4eb121dcc7e93be64aa16e7988 | https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/cli.py#L32-L41 | train |
kodethon/KoDrive | kodrive/cli.py | ls | def ls():
''' List all synchronized directories. '''
heading, body = cli_syncthing_adapter.ls()
if heading:
click.echo(heading)
if body:
click.echo(body.strip()) | python | def ls():
''' List all synchronized directories. '''
heading, body = cli_syncthing_adapter.ls()
if heading:
click.echo(heading)
if body:
click.echo(body.strip()) | [
"def",
"ls",
"(",
")",
":",
"heading",
",",
"body",
"=",
"cli_syncthing_adapter",
".",
"ls",
"(",
")",
"if",
"heading",
":",
"click",
".",
"echo",
"(",
"heading",
")",
"if",
"body",
":",
"click",
".",
"echo",
"(",
"body",
".",
"strip",
"(",
")",
... | List all synchronized directories. | [
"List",
"all",
"synchronized",
"directories",
"."
] | 325fe5e5870b7d4eb121dcc7e93be64aa16e7988 | https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/cli.py#L45-L54 | train |
kodethon/KoDrive | kodrive/cli.py | auth | def auth(**kwargs):
''' Authorize device synchronization. '''
"""
kodrive auth <path> <device_id (client)>
1. make sure path has been added to config.xml, server
2. make sure path is not shared by someone
3. add device_id to folder in config.xml, server
4. add device to devices in config.xml, ... | python | def auth(**kwargs):
''' Authorize device synchronization. '''
"""
kodrive auth <path> <device_id (client)>
1. make sure path has been added to config.xml, server
2. make sure path is not shared by someone
3. add device_id to folder in config.xml, server
4. add device to devices in config.xml, ... | [
"def",
"auth",
"(",
"**",
"kwargs",
")",
":",
"option",
"=",
"'add'",
"path",
"=",
"kwargs",
"[",
"'path'",
"]",
"key",
"=",
"kwargs",
"[",
"'key'",
"]",
"if",
"kwargs",
"[",
"'remove'",
"]",
":",
"option",
"=",
"'remove'",
"if",
"kwargs",
"[",
"'y... | Authorize device synchronization. | [
"Authorize",
"device",
"synchronization",
"."
] | 325fe5e5870b7d4eb121dcc7e93be64aa16e7988 | https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/cli.py#L132-L161 | train |
kodethon/KoDrive | kodrive/cli.py | mv | def mv(source, target):
''' Move synchronized directory. '''
if os.path.isfile(target) and len(source) == 1:
if click.confirm("Are you sure you want to overwrite %s?" % target):
err_msg = cli_syncthing_adapter.mv_edge_case(source, target)
# Edge case: to match Bash 'mv' behavior and overwrite file... | python | def mv(source, target):
''' Move synchronized directory. '''
if os.path.isfile(target) and len(source) == 1:
if click.confirm("Are you sure you want to overwrite %s?" % target):
err_msg = cli_syncthing_adapter.mv_edge_case(source, target)
# Edge case: to match Bash 'mv' behavior and overwrite file... | [
"def",
"mv",
"(",
"source",
",",
"target",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"target",
")",
"and",
"len",
"(",
"source",
")",
"==",
"1",
":",
"if",
"click",
".",
"confirm",
"(",
"\"Are you sure you want to overwrite %s?\"",
"%",
"t... | Move synchronized directory. | [
"Move",
"synchronized",
"directory",
"."
] | 325fe5e5870b7d4eb121dcc7e93be64aa16e7988 | https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/cli.py#L178-L200 | train |
kodethon/KoDrive | kodrive/cli.py | push | def push(**kwargs):
''' Force synchronization of directory. '''
output, err = cli_syncthing_adapter.refresh(**kwargs)
if output:
click.echo("%s" % output, err=err)
if kwargs['verbose'] and not err:
with click.progressbar(
iterable=None,
length=100,
label='Synchronizing') as bar:
... | python | def push(**kwargs):
''' Force synchronization of directory. '''
output, err = cli_syncthing_adapter.refresh(**kwargs)
if output:
click.echo("%s" % output, err=err)
if kwargs['verbose'] and not err:
with click.progressbar(
iterable=None,
length=100,
label='Synchronizing') as bar:
... | [
"def",
"push",
"(",
"**",
"kwargs",
")",
":",
"output",
",",
"err",
"=",
"cli_syncthing_adapter",
".",
"refresh",
"(",
"**",
"kwargs",
")",
"if",
"output",
":",
"click",
".",
"echo",
"(",
"\"%s\"",
"%",
"output",
",",
"err",
"=",
"err",
")",
"if",
... | Force synchronization of directory. | [
"Force",
"synchronization",
"of",
"directory",
"."
] | 325fe5e5870b7d4eb121dcc7e93be64aa16e7988 | https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/cli.py#L212-L246 | train |
kodethon/KoDrive | kodrive/cli.py | tag | def tag(path, name):
''' Change tag associated with directory. '''
output, err = cli_syncthing_adapter.tag(path, name)
click.echo("%s" % output, err=err) | python | def tag(path, name):
''' Change tag associated with directory. '''
output, err = cli_syncthing_adapter.tag(path, name)
click.echo("%s" % output, err=err) | [
"def",
"tag",
"(",
"path",
",",
"name",
")",
":",
"output",
",",
"err",
"=",
"cli_syncthing_adapter",
".",
"tag",
"(",
"path",
",",
"name",
")",
"click",
".",
"echo",
"(",
"\"%s\"",
"%",
"output",
",",
"err",
"=",
"err",
")"
] | Change tag associated with directory. | [
"Change",
"tag",
"associated",
"with",
"directory",
"."
] | 325fe5e5870b7d4eb121dcc7e93be64aa16e7988 | https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/cli.py#L256-L260 | train |
kodethon/KoDrive | kodrive/cli.py | free | def free(**kwargs):
''' Stop synchronization of directory. '''
output, err = cli_syncthing_adapter.free(kwargs['path'])
click.echo("%s" % output, err=err) | python | def free(**kwargs):
''' Stop synchronization of directory. '''
output, err = cli_syncthing_adapter.free(kwargs['path'])
click.echo("%s" % output, err=err) | [
"def",
"free",
"(",
"**",
"kwargs",
")",
":",
"output",
",",
"err",
"=",
"cli_syncthing_adapter",
".",
"free",
"(",
"kwargs",
"[",
"'path'",
"]",
")",
"click",
".",
"echo",
"(",
"\"%s\"",
"%",
"output",
",",
"err",
"=",
"err",
")"
] | Stop synchronization of directory. | [
"Stop",
"synchronization",
"of",
"directory",
"."
] | 325fe5e5870b7d4eb121dcc7e93be64aa16e7988 | https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/cli.py#L269-L273 | train |
kodethon/KoDrive | kodrive/cli.py | add | def add(**kwargs):
''' Make a directory shareable. '''
output, err = cli_syncthing_adapter.add(**kwargs)
click.echo("%s" % output, err=err) | python | def add(**kwargs):
''' Make a directory shareable. '''
output, err = cli_syncthing_adapter.add(**kwargs)
click.echo("%s" % output, err=err) | [
"def",
"add",
"(",
"**",
"kwargs",
")",
":",
"output",
",",
"err",
"=",
"cli_syncthing_adapter",
".",
"add",
"(",
"**",
"kwargs",
")",
"click",
".",
"echo",
"(",
"\"%s\"",
"%",
"output",
",",
"err",
"=",
"err",
")"
] | Make a directory shareable. | [
"Make",
"a",
"directory",
"shareable",
"."
] | 325fe5e5870b7d4eb121dcc7e93be64aa16e7988 | https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/cli.py#L292-L296 | train |
kodethon/KoDrive | kodrive/cli.py | info | def info(path):
''' Display synchronization information. '''
output, err = cli_syncthing_adapter.info(folder=path)
if err:
click.echo(output, err=err)
else:
stat = output['status']
click.echo("State: %s" % stat['state'])
click.echo("\nTotal Files: %s" % stat['localFiles'])
click.echo("File... | python | def info(path):
''' Display synchronization information. '''
output, err = cli_syncthing_adapter.info(folder=path)
if err:
click.echo(output, err=err)
else:
stat = output['status']
click.echo("State: %s" % stat['state'])
click.echo("\nTotal Files: %s" % stat['localFiles'])
click.echo("File... | [
"def",
"info",
"(",
"path",
")",
":",
"output",
",",
"err",
"=",
"cli_syncthing_adapter",
".",
"info",
"(",
"folder",
"=",
"path",
")",
"if",
"err",
":",
"click",
".",
"echo",
"(",
"output",
",",
"err",
"=",
"err",
")",
"else",
":",
"stat",
"=",
... | Display synchronization information. | [
"Display",
"synchronization",
"information",
"."
] | 325fe5e5870b7d4eb121dcc7e93be64aa16e7988 | https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/cli.py#L304-L335 | train |
kodethon/KoDrive | kodrive/cli.py | key | def key(**kwargs):
''' Display system key. '''
output, err = cli_syncthing_adapter.key(device=True)
click.echo("%s" % output, err=err) | python | def key(**kwargs):
''' Display system key. '''
output, err = cli_syncthing_adapter.key(device=True)
click.echo("%s" % output, err=err) | [
"def",
"key",
"(",
"**",
"kwargs",
")",
":",
"output",
",",
"err",
"=",
"cli_syncthing_adapter",
".",
"key",
"(",
"device",
"=",
"True",
")",
"click",
".",
"echo",
"(",
"\"%s\"",
"%",
"output",
",",
"err",
"=",
"err",
")"
] | Display system key. | [
"Display",
"system",
"key",
"."
] | 325fe5e5870b7d4eb121dcc7e93be64aa16e7988 | https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/cli.py#L381-L385 | train |
kodethon/KoDrive | kodrive/cli.py | start | def start(**kwargs):
''' Start KodeDrive daemon. '''
output, err = cli_syncthing_adapter.start(**kwargs)
click.echo("%s" % output, err=err) | python | def start(**kwargs):
''' Start KodeDrive daemon. '''
output, err = cli_syncthing_adapter.start(**kwargs)
click.echo("%s" % output, err=err) | [
"def",
"start",
"(",
"**",
"kwargs",
")",
":",
"output",
",",
"err",
"=",
"cli_syncthing_adapter",
".",
"start",
"(",
"**",
"kwargs",
")",
"click",
".",
"echo",
"(",
"\"%s\"",
"%",
"output",
",",
"err",
"=",
"err",
")"
] | Start KodeDrive daemon. | [
"Start",
"KodeDrive",
"daemon",
"."
] | 325fe5e5870b7d4eb121dcc7e93be64aa16e7988 | https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/cli.py#L406-L410 | train |
kodethon/KoDrive | kodrive/cli.py | stop | def stop():
''' Stop KodeDrive daemon. '''
output, err = cli_syncthing_adapter.sys(exit=True)
click.echo("%s" % output, err=err) | python | def stop():
''' Stop KodeDrive daemon. '''
output, err = cli_syncthing_adapter.sys(exit=True)
click.echo("%s" % output, err=err) | [
"def",
"stop",
"(",
")",
":",
"output",
",",
"err",
"=",
"cli_syncthing_adapter",
".",
"sys",
"(",
"exit",
"=",
"True",
")",
"click",
".",
"echo",
"(",
"\"%s\"",
"%",
"output",
",",
"err",
"=",
"err",
")"
] | Stop KodeDrive daemon. | [
"Stop",
"KodeDrive",
"daemon",
"."
] | 325fe5e5870b7d4eb121dcc7e93be64aa16e7988 | https://github.com/kodethon/KoDrive/blob/325fe5e5870b7d4eb121dcc7e93be64aa16e7988/kodrive/cli.py#L414-L418 | train |
tjcsl/cslbot | cslbot/commands/vote.py | start_poll | def start_poll(args):
"""Starts a poll."""
if args.type == 'privmsg':
return "We don't have secret ballots in this benevolent dictatorship!"
if not args.msg:
return "Polls need a question."
ctrlchan = args.config['core']['ctrlchan']
poll = Polls(question=args.msg, submitter=args.nick... | python | def start_poll(args):
"""Starts a poll."""
if args.type == 'privmsg':
return "We don't have secret ballots in this benevolent dictatorship!"
if not args.msg:
return "Polls need a question."
ctrlchan = args.config['core']['ctrlchan']
poll = Polls(question=args.msg, submitter=args.nick... | [
"def",
"start_poll",
"(",
"args",
")",
":",
"if",
"args",
".",
"type",
"==",
"'privmsg'",
":",
"return",
"\"We don't have secret ballots in this benevolent dictatorship!\"",
"if",
"not",
"args",
".",
"msg",
":",
"return",
"\"Polls need a question.\"",
"ctrlchan",
"=",... | Starts a poll. | [
"Starts",
"a",
"poll",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/vote.py#L25-L41 | train |
tjcsl/cslbot | cslbot/commands/vote.py | delete_poll | def delete_poll(args):
"""Deletes a poll."""
if not args.isadmin:
return "Nope, not gonna do it."
if not args.msg:
return "Syntax: !poll delete <pollnum>"
if not args.msg.isdigit():
return "Not A Valid Positive Integer."
poll = args.session.query(Polls).filter(Polls.accepted ... | python | def delete_poll(args):
"""Deletes a poll."""
if not args.isadmin:
return "Nope, not gonna do it."
if not args.msg:
return "Syntax: !poll delete <pollnum>"
if not args.msg.isdigit():
return "Not A Valid Positive Integer."
poll = args.session.query(Polls).filter(Polls.accepted ... | [
"def",
"delete_poll",
"(",
"args",
")",
":",
"if",
"not",
"args",
".",
"isadmin",
":",
"return",
"\"Nope, not gonna do it.\"",
"if",
"not",
"args",
".",
"msg",
":",
"return",
"\"Syntax: !poll delete <pollnum>\"",
"if",
"not",
"args",
".",
"msg",
".",
"isdigit"... | Deletes a poll. | [
"Deletes",
"a",
"poll",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/vote.py#L44-L60 | train |
tjcsl/cslbot | cslbot/commands/vote.py | edit_poll | def edit_poll(args):
"""Edits a poll."""
if not args.isadmin:
return "Nope, not gonna do it."
msg = args.msg.split(maxsplit=1)
if len(msg) < 2:
return "Syntax: !vote edit <pollnum> <question>"
if not msg[0].isdigit():
return "Not A Valid Positive Integer."
pid = int(msg[0... | python | def edit_poll(args):
"""Edits a poll."""
if not args.isadmin:
return "Nope, not gonna do it."
msg = args.msg.split(maxsplit=1)
if len(msg) < 2:
return "Syntax: !vote edit <pollnum> <question>"
if not msg[0].isdigit():
return "Not A Valid Positive Integer."
pid = int(msg[0... | [
"def",
"edit_poll",
"(",
"args",
")",
":",
"if",
"not",
"args",
".",
"isadmin",
":",
"return",
"\"Nope, not gonna do it.\"",
"msg",
"=",
"args",
".",
"msg",
".",
"split",
"(",
"maxsplit",
"=",
"1",
")",
"if",
"len",
"(",
"msg",
")",
"<",
"2",
":",
... | Edits a poll. | [
"Edits",
"a",
"poll",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/vote.py#L67-L81 | train |
tjcsl/cslbot | cslbot/commands/vote.py | reopen | def reopen(args):
"""reopens a closed poll."""
if not args.isadmin:
return "Nope, not gonna do it."
msg = args.msg.split()
if not msg:
return "Syntax: !poll reopen <pollnum>"
if not msg[0].isdigit():
return "Not a valid positve integer."
pid = int(msg[0])
poll = get_o... | python | def reopen(args):
"""reopens a closed poll."""
if not args.isadmin:
return "Nope, not gonna do it."
msg = args.msg.split()
if not msg:
return "Syntax: !poll reopen <pollnum>"
if not msg[0].isdigit():
return "Not a valid positve integer."
pid = int(msg[0])
poll = get_o... | [
"def",
"reopen",
"(",
"args",
")",
":",
"if",
"not",
"args",
".",
"isadmin",
":",
"return",
"\"Nope, not gonna do it.\"",
"msg",
"=",
"args",
".",
"msg",
".",
"split",
"(",
")",
"if",
"not",
"msg",
":",
"return",
"\"Syntax: !poll reopen <pollnum>\"",
"if",
... | reopens a closed poll. | [
"reopens",
"a",
"closed",
"poll",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/vote.py#L84-L98 | train |
tjcsl/cslbot | cslbot/commands/vote.py | end_poll | def end_poll(args):
"""Ends a poll."""
if not args.isadmin:
return "Nope, not gonna do it."
if not args.msg:
return "Syntax: !vote end <pollnum>"
if not args.msg.isdigit():
return "Not A Valid Positive Integer."
poll = get_open_poll(args.session, int(args.msg))
if poll is... | python | def end_poll(args):
"""Ends a poll."""
if not args.isadmin:
return "Nope, not gonna do it."
if not args.msg:
return "Syntax: !vote end <pollnum>"
if not args.msg.isdigit():
return "Not A Valid Positive Integer."
poll = get_open_poll(args.session, int(args.msg))
if poll is... | [
"def",
"end_poll",
"(",
"args",
")",
":",
"if",
"not",
"args",
".",
"isadmin",
":",
"return",
"\"Nope, not gonna do it.\"",
"if",
"not",
"args",
".",
"msg",
":",
"return",
"\"Syntax: !vote end <pollnum>\"",
"if",
"not",
"args",
".",
"msg",
".",
"isdigit",
"(... | Ends a poll. | [
"Ends",
"a",
"poll",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/vote.py#L101-L115 | train |
tjcsl/cslbot | cslbot/commands/vote.py | tally_poll | def tally_poll(args):
"""Shows the results of poll."""
if not args.msg:
return "Syntax: !vote tally <pollnum>"
if not args.msg.isdigit():
return "Not A Valid Positive Integer."
pid = int(args.msg)
poll = get_open_poll(args.session, pid)
if poll is None:
return "That poll ... | python | def tally_poll(args):
"""Shows the results of poll."""
if not args.msg:
return "Syntax: !vote tally <pollnum>"
if not args.msg.isdigit():
return "Not A Valid Positive Integer."
pid = int(args.msg)
poll = get_open_poll(args.session, pid)
if poll is None:
return "That poll ... | [
"def",
"tally_poll",
"(",
"args",
")",
":",
"if",
"not",
"args",
".",
"msg",
":",
"return",
"\"Syntax: !vote tally <pollnum>\"",
"if",
"not",
"args",
".",
"msg",
".",
"isdigit",
"(",
")",
":",
"return",
"\"Not A Valid Positive Integer.\"",
"pid",
"=",
"int",
... | Shows the results of poll. | [
"Shows",
"the",
"results",
"of",
"poll",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/vote.py#L118-L149 | train |
tjcsl/cslbot | cslbot/commands/vote.py | vote | def vote(session, nick, pid, response):
"""Votes on a poll."""
if not response:
return "You have to vote something!"
if response == "n" or response == "nay":
response = "no"
elif response == "y" or response == "aye":
response = "yes"
poll = get_open_poll(session, pid)
if ... | python | def vote(session, nick, pid, response):
"""Votes on a poll."""
if not response:
return "You have to vote something!"
if response == "n" or response == "nay":
response = "no"
elif response == "y" or response == "aye":
response = "yes"
poll = get_open_poll(session, pid)
if ... | [
"def",
"vote",
"(",
"session",
",",
"nick",
",",
"pid",
",",
"response",
")",
":",
"if",
"not",
"response",
":",
"return",
"\"You have to vote something!\"",
"if",
"response",
"==",
"\"n\"",
"or",
"response",
"==",
"\"nay\"",
":",
"response",
"=",
"\"no\"",
... | Votes on a poll. | [
"Votes",
"on",
"a",
"poll",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/vote.py#L156-L177 | train |
tjcsl/cslbot | cslbot/commands/vote.py | retract | def retract(args):
"""Deletes a vote for a poll."""
if not args.msg:
return "Syntax: !vote retract <pollnum>"
if not args.msg.isdigit():
return "Not A Valid Positive Integer."
response = get_response(args.session, args.msg, args.nick)
if response is None:
return "You haven't ... | python | def retract(args):
"""Deletes a vote for a poll."""
if not args.msg:
return "Syntax: !vote retract <pollnum>"
if not args.msg.isdigit():
return "Not A Valid Positive Integer."
response = get_response(args.session, args.msg, args.nick)
if response is None:
return "You haven't ... | [
"def",
"retract",
"(",
"args",
")",
":",
"if",
"not",
"args",
".",
"msg",
":",
"return",
"\"Syntax: !vote retract <pollnum>\"",
"if",
"not",
"args",
".",
"msg",
".",
"isdigit",
"(",
")",
":",
"return",
"\"Not A Valid Positive Integer.\"",
"response",
"=",
"get... | Deletes a vote for a poll. | [
"Deletes",
"a",
"vote",
"for",
"a",
"poll",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/vote.py#L180-L190 | train |
tjcsl/cslbot | cslbot/commands/vote.py | cmd | def cmd(send, msg, args):
"""Handles voting.
Syntax: {command} <start|end|list|tally|edit|delete|retract|reopen|(num) vote>
"""
command = msg.split()
msg = " ".join(command[1:])
if not command:
send("Which poll?")
return
else:
command = command[0]
# FIXME: integ... | python | def cmd(send, msg, args):
"""Handles voting.
Syntax: {command} <start|end|list|tally|edit|delete|retract|reopen|(num) vote>
"""
command = msg.split()
msg = " ".join(command[1:])
if not command:
send("Which poll?")
return
else:
command = command[0]
# FIXME: integ... | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"command",
"=",
"msg",
".",
"split",
"(",
")",
"msg",
"=",
"\" \"",
".",
"join",
"(",
"command",
"[",
"1",
":",
"]",
")",
"if",
"not",
"command",
":",
"send",
"(",
"\"Which poll?\"",
... | Handles voting.
Syntax: {command} <start|end|list|tally|edit|delete|retract|reopen|(num) vote> | [
"Handles",
"voting",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/vote.py#L199-L244 | train |
tjcsl/cslbot | cslbot/commands/stats.py | cmd | def cmd(send, msg, args):
"""Gets stats.
Syntax: {command} <--high|--low|--userhigh|--nick <nick>|command>
"""
parser = arguments.ArgParser(args['config'])
group = parser.add_mutually_exclusive_group()
group.add_argument('--high', action='store_true')
group.add_argument('--low', action='st... | python | def cmd(send, msg, args):
"""Gets stats.
Syntax: {command} <--high|--low|--userhigh|--nick <nick>|command>
"""
parser = arguments.ArgParser(args['config'])
group = parser.add_mutually_exclusive_group()
group.add_argument('--high', action='store_true')
group.add_argument('--low', action='st... | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"parser",
"=",
"arguments",
".",
"ArgParser",
"(",
"args",
"[",
"'config'",
"]",
")",
"group",
"=",
"parser",
".",
"add_mutually_exclusive_group",
"(",
")",
"group",
".",
"add_argument",
"(",
... | Gets stats.
Syntax: {command} <--high|--low|--userhigh|--nick <nick>|command> | [
"Gets",
"stats",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/stats.py#L59-L108 | train |
nephila/djangocms-apphook-setup | djangocms_apphook_setup/base.py | AutoCMSAppMixin._create_page | def _create_page(cls, page, lang, auto_title, cms_app=None, parent=None, namespace=None,
site=None, set_home=False):
"""
Create a single page or titles
:param page: Page instance
:param lang: language code
:param auto_title: title text for the newly created ... | python | def _create_page(cls, page, lang, auto_title, cms_app=None, parent=None, namespace=None,
site=None, set_home=False):
"""
Create a single page or titles
:param page: Page instance
:param lang: language code
:param auto_title: title text for the newly created ... | [
"def",
"_create_page",
"(",
"cls",
",",
"page",
",",
"lang",
",",
"auto_title",
",",
"cms_app",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"site",
"=",
"None",
",",
"set_home",
"=",
"False",
")",
":",
"from",
"cms",
... | Create a single page or titles
:param page: Page instance
:param lang: language code
:param auto_title: title text for the newly created title
:param cms_app: Apphook Class to be attached to the page
:param parent: parent page (None when creating the home page)
:param na... | [
"Create",
"a",
"single",
"page",
"or",
"titles"
] | e82c0afdf966f859fe13dc80fcd417b44080f460 | https://github.com/nephila/djangocms-apphook-setup/blob/e82c0afdf966f859fe13dc80fcd417b44080f460/djangocms_apphook_setup/base.py#L22-L57 | train |
nephila/djangocms-apphook-setup | djangocms_apphook_setup/base.py | AutoCMSAppMixin._create_config | def _create_config(cls):
"""
Creates an ApphookConfig instance
``AutoCMSAppMixin.auto_setup['config_fields']`` is used to fill in the data
of the instance.
:return: ApphookConfig instance
"""
return cls.app_config.objects.create(
namespace=cls.auto_s... | python | def _create_config(cls):
"""
Creates an ApphookConfig instance
``AutoCMSAppMixin.auto_setup['config_fields']`` is used to fill in the data
of the instance.
:return: ApphookConfig instance
"""
return cls.app_config.objects.create(
namespace=cls.auto_s... | [
"def",
"_create_config",
"(",
"cls",
")",
":",
"return",
"cls",
".",
"app_config",
".",
"objects",
".",
"create",
"(",
"namespace",
"=",
"cls",
".",
"auto_setup",
"[",
"'namespace'",
"]",
",",
"**",
"cls",
".",
"auto_setup",
"[",
"'config_fields'",
"]",
... | Creates an ApphookConfig instance
``AutoCMSAppMixin.auto_setup['config_fields']`` is used to fill in the data
of the instance.
:return: ApphookConfig instance | [
"Creates",
"an",
"ApphookConfig",
"instance"
] | e82c0afdf966f859fe13dc80fcd417b44080f460 | https://github.com/nephila/djangocms-apphook-setup/blob/e82c0afdf966f859fe13dc80fcd417b44080f460/djangocms_apphook_setup/base.py#L60-L71 | train |
nephila/djangocms-apphook-setup | djangocms_apphook_setup/base.py | AutoCMSAppMixin._create_config_translation | def _create_config_translation(cls, config, lang):
"""
Creates a translation for the given ApphookConfig
Only django-parler kind of models are currently supported.
``AutoCMSAppMixin.auto_setup['config_translated_fields']`` is used to fill in the data
of the instance for all the... | python | def _create_config_translation(cls, config, lang):
"""
Creates a translation for the given ApphookConfig
Only django-parler kind of models are currently supported.
``AutoCMSAppMixin.auto_setup['config_translated_fields']`` is used to fill in the data
of the instance for all the... | [
"def",
"_create_config_translation",
"(",
"cls",
",",
"config",
",",
"lang",
")",
":",
"config",
".",
"set_current_language",
"(",
"lang",
",",
"initialize",
"=",
"True",
")",
"for",
"field",
",",
"data",
"in",
"cls",
".",
"auto_setup",
"[",
"'config_transla... | Creates a translation for the given ApphookConfig
Only django-parler kind of models are currently supported.
``AutoCMSAppMixin.auto_setup['config_translated_fields']`` is used to fill in the data
of the instance for all the languages.
:param config: ApphookConfig instance
:par... | [
"Creates",
"a",
"translation",
"for",
"the",
"given",
"ApphookConfig"
] | e82c0afdf966f859fe13dc80fcd417b44080f460 | https://github.com/nephila/djangocms-apphook-setup/blob/e82c0afdf966f859fe13dc80fcd417b44080f460/djangocms_apphook_setup/base.py#L74-L89 | train |
nephila/djangocms-apphook-setup | djangocms_apphook_setup/base.py | AutoCMSAppMixin._setup_pages | def _setup_pages(cls, config):
"""
Create the page structure.
It created a home page (if not exists) and a sub-page, and attach the Apphook to the
sub-page.
Pages titles are provided by ``AutoCMSAppMixin.auto_setup``
:param setup_config: boolean to control whether creat... | python | def _setup_pages(cls, config):
"""
Create the page structure.
It created a home page (if not exists) and a sub-page, and attach the Apphook to the
sub-page.
Pages titles are provided by ``AutoCMSAppMixin.auto_setup``
:param setup_config: boolean to control whether creat... | [
"def",
"_setup_pages",
"(",
"cls",
",",
"config",
")",
":",
"from",
"cms",
".",
"exceptions",
"import",
"NoHomeFound",
"from",
"cms",
".",
"models",
"import",
"Page",
"from",
"cms",
".",
"utils",
"import",
"get_language_list",
"from",
"django",
".",
"conf",
... | Create the page structure.
It created a home page (if not exists) and a sub-page, and attach the Apphook to the
sub-page.
Pages titles are provided by ``AutoCMSAppMixin.auto_setup``
:param setup_config: boolean to control whether creating the ApphookConfig instance | [
"Create",
"the",
"page",
"structure",
"."
] | e82c0afdf966f859fe13dc80fcd417b44080f460 | https://github.com/nephila/djangocms-apphook-setup/blob/e82c0afdf966f859fe13dc80fcd417b44080f460/djangocms_apphook_setup/base.py#L92-L153 | train |
nephila/djangocms-apphook-setup | djangocms_apphook_setup/base.py | AutoCMSAppMixin.setup | def setup(cls):
"""
Main method to auto setup Apphook
It must be called after the Apphook registration::
apphook_pool.register(MyApp)
MyApp.setup()
"""
try:
if cls.auto_setup and cls.auto_setup.get('enabled', False):
if not cl... | python | def setup(cls):
"""
Main method to auto setup Apphook
It must be called after the Apphook registration::
apphook_pool.register(MyApp)
MyApp.setup()
"""
try:
if cls.auto_setup and cls.auto_setup.get('enabled', False):
if not cl... | [
"def",
"setup",
"(",
"cls",
")",
":",
"try",
":",
"if",
"cls",
".",
"auto_setup",
"and",
"cls",
".",
"auto_setup",
".",
"get",
"(",
"'enabled'",
",",
"False",
")",
":",
"if",
"not",
"cls",
".",
"auto_setup",
".",
"get",
"(",
"'home title'",
",",
"F... | Main method to auto setup Apphook
It must be called after the Apphook registration::
apphook_pool.register(MyApp)
MyApp.setup() | [
"Main",
"method",
"to",
"auto",
"setup",
"Apphook"
] | e82c0afdf966f859fe13dc80fcd417b44080f460 | https://github.com/nephila/djangocms-apphook-setup/blob/e82c0afdf966f859fe13dc80fcd417b44080f460/djangocms_apphook_setup/base.py#L156-L187 | train |
Genida/archan | src/archan/analysis.py | Analysis.run | def run(self, verbose=True):
"""
Run the analysis.
Generate data from each provider, then check these data with every
checker, and store the analysis results.
Args:
verbose (bool): whether to immediately print the results or not.
"""
self.results.cle... | python | def run(self, verbose=True):
"""
Run the analysis.
Generate data from each provider, then check these data with every
checker, and store the analysis results.
Args:
verbose (bool): whether to immediately print the results or not.
"""
self.results.cle... | [
"def",
"run",
"(",
"self",
",",
"verbose",
"=",
"True",
")",
":",
"self",
".",
"results",
".",
"clear",
"(",
")",
"for",
"analysis_group",
"in",
"self",
".",
"config",
".",
"analysis_groups",
":",
"if",
"analysis_group",
".",
"providers",
":",
"for",
"... | Run the analysis.
Generate data from each provider, then check these data with every
checker, and store the analysis results.
Args:
verbose (bool): whether to immediately print the results or not. | [
"Run",
"the",
"analysis",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/analysis.py#L41-L72 | train |
Genida/archan | src/archan/analysis.py | Analysis.output_tap | def output_tap(self):
"""Output analysis results in TAP format."""
tracker = Tracker(streaming=True, stream=sys.stdout)
for group in self.config.analysis_groups:
n_providers = len(group.providers)
n_checkers = len(group.checkers)
if not group.providers and gro... | python | def output_tap(self):
"""Output analysis results in TAP format."""
tracker = Tracker(streaming=True, stream=sys.stdout)
for group in self.config.analysis_groups:
n_providers = len(group.providers)
n_checkers = len(group.checkers)
if not group.providers and gro... | [
"def",
"output_tap",
"(",
"self",
")",
":",
"tracker",
"=",
"Tracker",
"(",
"streaming",
"=",
"True",
",",
"stream",
"=",
"sys",
".",
"stdout",
")",
"for",
"group",
"in",
"self",
".",
"config",
".",
"analysis_groups",
":",
"n_providers",
"=",
"len",
"(... | Output analysis results in TAP format. | [
"Output",
"analysis",
"results",
"in",
"TAP",
"format",
"."
] | a026d3105c7e86f30e6c9507b93ceb736684bfdc | https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/analysis.py#L79-L114 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | find_latex_font_serif | def find_latex_font_serif():
r'''
Find an available font to mimic LaTeX, and return its name.
'''
import os, re
import matplotlib.font_manager
name = lambda font: os.path.splitext(os.path.split(font)[-1])[0].split(' - ')[0]
fonts = matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')
... | python | def find_latex_font_serif():
r'''
Find an available font to mimic LaTeX, and return its name.
'''
import os, re
import matplotlib.font_manager
name = lambda font: os.path.splitext(os.path.split(font)[-1])[0].split(' - ')[0]
fonts = matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')
... | [
"def",
"find_latex_font_serif",
"(",
")",
":",
"r",
"import",
"os",
",",
"re",
"import",
"matplotlib",
".",
"font_manager",
"name",
"=",
"lambda",
"font",
":",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"split",
"(",
"font",
")",
... | r'''
Find an available font to mimic LaTeX, and return its name. | [
"r",
"Find",
"an",
"available",
"font",
"to",
"mimic",
"LaTeX",
"and",
"return",
"its",
"name",
"."
] | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L25-L51 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | copy_style | def copy_style():
r'''
Write all goose-styles to the relevant matplotlib configuration directory.
'''
import os
import matplotlib
# style definitions
# -----------------
styles = {}
styles['goose.mplstyle'] = '''
figure.figsize : 8,6
font.weight : normal
font.size : 16
axes... | python | def copy_style():
r'''
Write all goose-styles to the relevant matplotlib configuration directory.
'''
import os
import matplotlib
# style definitions
# -----------------
styles = {}
styles['goose.mplstyle'] = '''
figure.figsize : 8,6
font.weight : normal
font.size : 16
axes... | [
"def",
"copy_style",
"(",
")",
":",
"r",
"import",
"os",
"import",
"matplotlib",
"styles",
"=",
"{",
"}",
"styles",
"[",
"'goose.mplstyle'",
"]",
"=",
"styles",
"[",
"'goose-tick-in.mplstyle'",
"]",
"=",
"styles",
"[",
"'goose-tick-lower.mplstyle'",
"]",
"=",
... | r'''
Write all goose-styles to the relevant matplotlib configuration directory. | [
"r",
"Write",
"all",
"goose",
"-",
"styles",
"to",
"the",
"relevant",
"matplotlib",
"configuration",
"directory",
"."
] | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L55-L137 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | scale_lim | def scale_lim(lim,factor=1.05):
r'''
Scale limits to be 5% wider, to have a nice plot.
:arguments:
**lim** (``<list>`` | ``<str>``)
The limits. May be a string "[...,...]", which is converted to a list.
:options:
**factor** ([``1.05``] | ``<float>``)
Scale factor.
'''
# convert string "[...,...]"... | python | def scale_lim(lim,factor=1.05):
r'''
Scale limits to be 5% wider, to have a nice plot.
:arguments:
**lim** (``<list>`` | ``<str>``)
The limits. May be a string "[...,...]", which is converted to a list.
:options:
**factor** ([``1.05``] | ``<float>``)
Scale factor.
'''
# convert string "[...,...]"... | [
"def",
"scale_lim",
"(",
"lim",
",",
"factor",
"=",
"1.05",
")",
":",
"r",
"if",
"type",
"(",
"lim",
")",
"==",
"str",
":",
"lim",
"=",
"eval",
"(",
"lim",
")",
"D",
"=",
"lim",
"[",
"1",
"]",
"-",
"lim",
"[",
"0",
"]",
"lim",
"[",
"0",
"... | r'''
Scale limits to be 5% wider, to have a nice plot.
:arguments:
**lim** (``<list>`` | ``<str>``)
The limits. May be a string "[...,...]", which is converted to a list.
:options:
**factor** ([``1.05``] | ``<float>``)
Scale factor. | [
"r",
"Scale",
"limits",
"to",
"be",
"5%",
"wider",
"to",
"have",
"a",
"nice",
"plot",
"."
] | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L180-L203 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | abs2rel_y | def abs2rel_y(y, axis=None):
r'''
Transform absolute y-coordinates to relative y-coordinates. Relative coordinates correspond to a
fraction of the relevant axis. Be sure to set the limits and scale before calling this function!
:arguments:
**y** (``float``, ``list``)
Absolute coordinates.
:options:
**axis... | python | def abs2rel_y(y, axis=None):
r'''
Transform absolute y-coordinates to relative y-coordinates. Relative coordinates correspond to a
fraction of the relevant axis. Be sure to set the limits and scale before calling this function!
:arguments:
**y** (``float``, ``list``)
Absolute coordinates.
:options:
**axis... | [
"def",
"abs2rel_y",
"(",
"y",
",",
"axis",
"=",
"None",
")",
":",
"r",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"plt",
".",
"gca",
"(",
")",
"ymin",
",",
"ymax",
"=",
"axis",
".",
"get_ylim",
"(",
")",
"if",
"axis",
".",
"get_xscale",
"(",... | r'''
Transform absolute y-coordinates to relative y-coordinates. Relative coordinates correspond to a
fraction of the relevant axis. Be sure to set the limits and scale before calling this function!
:arguments:
**y** (``float``, ``list``)
Absolute coordinates.
:options:
**axis** ([``plt.gca()``] | ...)
... | [
"r",
"Transform",
"absolute",
"y",
"-",
"coordinates",
"to",
"relative",
"y",
"-",
"coordinates",
".",
"Relative",
"coordinates",
"correspond",
"to",
"a",
"fraction",
"of",
"the",
"relevant",
"axis",
".",
"Be",
"sure",
"to",
"set",
"the",
"limits",
"and",
... | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L247-L283 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | rel2abs_x | def rel2abs_x(x, axis=None):
r'''
Transform relative x-coordinates to absolute x-coordinates. Relative coordinates correspond to a
fraction of the relevant axis. Be sure to set the limits and scale before calling this function!
:arguments:
**x** (``float``, ``list``)
Relative coordinates.
:options:
**axis... | python | def rel2abs_x(x, axis=None):
r'''
Transform relative x-coordinates to absolute x-coordinates. Relative coordinates correspond to a
fraction of the relevant axis. Be sure to set the limits and scale before calling this function!
:arguments:
**x** (``float``, ``list``)
Relative coordinates.
:options:
**axis... | [
"def",
"rel2abs_x",
"(",
"x",
",",
"axis",
"=",
"None",
")",
":",
"r",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"plt",
".",
"gca",
"(",
")",
"xmin",
",",
"xmax",
"=",
"axis",
".",
"get_xlim",
"(",
")",
"if",
"axis",
".",
"get_xscale",
"(",... | r'''
Transform relative x-coordinates to absolute x-coordinates. Relative coordinates correspond to a
fraction of the relevant axis. Be sure to set the limits and scale before calling this function!
:arguments:
**x** (``float``, ``list``)
Relative coordinates.
:options:
**axis** ([``plt.gca()``] | ...)
... | [
"r",
"Transform",
"relative",
"x",
"-",
"coordinates",
"to",
"absolute",
"x",
"-",
"coordinates",
".",
"Relative",
"coordinates",
"correspond",
"to",
"a",
"fraction",
"of",
"the",
"relevant",
"axis",
".",
"Be",
"sure",
"to",
"set",
"the",
"limits",
"and",
... | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L287-L323 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | subplots | def subplots(scale_x=None, scale_y=None, scale=None, **kwargs):
r'''
Run ``matplotlib.pyplot.subplots`` with ``figsize`` set to the correct multiple of the default.
:additional options:
**scale, scale_x, scale_y** (``<float>``)
Scale the figure-size (along one of the dimensions).
'''
if 'figsize' in kwar... | python | def subplots(scale_x=None, scale_y=None, scale=None, **kwargs):
r'''
Run ``matplotlib.pyplot.subplots`` with ``figsize`` set to the correct multiple of the default.
:additional options:
**scale, scale_x, scale_y** (``<float>``)
Scale the figure-size (along one of the dimensions).
'''
if 'figsize' in kwar... | [
"def",
"subplots",
"(",
"scale_x",
"=",
"None",
",",
"scale_y",
"=",
"None",
",",
"scale",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"r",
"if",
"'figsize'",
"in",
"kwargs",
":",
"return",
"plt",
".",
"subplots",
"(",
"**",
"kwargs",
")",
"width",
... | r'''
Run ``matplotlib.pyplot.subplots`` with ``figsize`` set to the correct multiple of the default.
:additional options:
**scale, scale_x, scale_y** (``<float>``)
Scale the figure-size (along one of the dimensions). | [
"r",
"Run",
"matplotlib",
".",
"pyplot",
".",
"subplots",
"with",
"figsize",
"set",
"to",
"the",
"correct",
"multiple",
"of",
"the",
"default",
"."
] | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L367-L397 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | plot | def plot(x, y, units='absolute', axis=None, **kwargs):
r'''
Plot.
:arguments:
**x, y** (``list``)
Coordinates.
:options:
**units** ([``'absolute'``] | ``'relative'``)
The type of units in which the coordinates are specified. Relative coordinates correspond to a
fraction of the relevant axis. If yo... | python | def plot(x, y, units='absolute', axis=None, **kwargs):
r'''
Plot.
:arguments:
**x, y** (``list``)
Coordinates.
:options:
**units** ([``'absolute'``] | ``'relative'``)
The type of units in which the coordinates are specified. Relative coordinates correspond to a
fraction of the relevant axis. If yo... | [
"def",
"plot",
"(",
"x",
",",
"y",
",",
"units",
"=",
"'absolute'",
",",
"axis",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"r",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"plt",
".",
"gca",
"(",
")",
"if",
"units",
".",
"lower",
"(",
")"... | r'''
Plot.
:arguments:
**x, y** (``list``)
Coordinates.
:options:
**units** ([``'absolute'``] | ``'relative'``)
The type of units in which the coordinates are specified. Relative coordinates correspond to a
fraction of the relevant axis. If you use relative coordinates, be sure to set the limits and... | [
"r",
"Plot",
"."
] | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L401-L435 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | plot_powerlaw | def plot_powerlaw(exp, startx, starty, width=None, **kwargs):
r'''
Plot a power-law.
:arguments:
**exp** (``float``)
The power-law exponent.
**startx, starty** (``float``)
Start coordinates.
:options:
**width, height, endx, endy** (``float``)
Definition of the end coordinate (only on of these o... | python | def plot_powerlaw(exp, startx, starty, width=None, **kwargs):
r'''
Plot a power-law.
:arguments:
**exp** (``float``)
The power-law exponent.
**startx, starty** (``float``)
Start coordinates.
:options:
**width, height, endx, endy** (``float``)
Definition of the end coordinate (only on of these o... | [
"def",
"plot_powerlaw",
"(",
"exp",
",",
"startx",
",",
"starty",
",",
"width",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"r",
"endx",
"=",
"kwargs",
".",
"pop",
"(",
"'endx'",
",",
"None",
")",
"endy",
"=",
"kwargs",
".",
"pop",
"(",
"'endy'",
... | r'''
Plot a power-law.
:arguments:
**exp** (``float``)
The power-law exponent.
**startx, starty** (``float``)
Start coordinates.
:options:
**width, height, endx, endy** (``float``)
Definition of the end coordinate (only on of these options is needed).
**units** ([``'relative'``] | ``'absolute'... | [
"r",
"Plot",
"a",
"power",
"-",
"law",
"."
] | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L630-L701 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | histogram_bin_edges_minwidth | def histogram_bin_edges_minwidth(min_width, bins):
r'''
Merge bins with right-neighbour until each bin has a minimum width.
:arguments:
**bins** (``<array_like>``)
The bin-edges.
**min_width** (``<float>``)
The minimum bin width.
'''
# escape
if min_width is None : return bins
if min_width is ... | python | def histogram_bin_edges_minwidth(min_width, bins):
r'''
Merge bins with right-neighbour until each bin has a minimum width.
:arguments:
**bins** (``<array_like>``)
The bin-edges.
**min_width** (``<float>``)
The minimum bin width.
'''
# escape
if min_width is None : return bins
if min_width is ... | [
"def",
"histogram_bin_edges_minwidth",
"(",
"min_width",
",",
"bins",
")",
":",
"r",
"if",
"min_width",
"is",
"None",
":",
"return",
"bins",
"if",
"min_width",
"is",
"False",
":",
"return",
"bins",
"while",
"True",
":",
"idx",
"=",
"np",
".",
"where",
"(... | r'''
Merge bins with right-neighbour until each bin has a minimum width.
:arguments:
**bins** (``<array_like>``)
The bin-edges.
**min_width** (``<float>``)
The minimum bin width. | [
"r",
"Merge",
"bins",
"with",
"right",
"-",
"neighbour",
"until",
"each",
"bin",
"has",
"a",
"minimum",
"width",
"."
] | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L840-L867 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | histogram_bin_edges_mincount | def histogram_bin_edges_mincount(data, min_count, bins):
r'''
Merge bins with right-neighbour until each bin has a minimum number of data-points.
:arguments:
**data** (``<array_like>``)
Input data. The histogram is computed over the flattened array.
**bins** (``<array_like>`` | ``<int>``)
The bin-edges... | python | def histogram_bin_edges_mincount(data, min_count, bins):
r'''
Merge bins with right-neighbour until each bin has a minimum number of data-points.
:arguments:
**data** (``<array_like>``)
Input data. The histogram is computed over the flattened array.
**bins** (``<array_like>`` | ``<int>``)
The bin-edges... | [
"def",
"histogram_bin_edges_mincount",
"(",
"data",
",",
"min_count",
",",
"bins",
")",
":",
"r",
"if",
"min_count",
"is",
"None",
":",
"return",
"bins",
"if",
"min_count",
"is",
"False",
":",
"return",
"bins",
"if",
"type",
"(",
"min_count",
")",
"!=",
... | r'''
Merge bins with right-neighbour until each bin has a minimum number of data-points.
:arguments:
**data** (``<array_like>``)
Input data. The histogram is computed over the flattened array.
**bins** (``<array_like>`` | ``<int>``)
The bin-edges (or the number of bins, automatically converted to equal-s... | [
"r",
"Merge",
"bins",
"with",
"right",
"-",
"neighbour",
"until",
"each",
"bin",
"has",
"a",
"minimum",
"number",
"of",
"data",
"-",
"points",
"."
] | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L871-L906 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | histogram_bin_edges | def histogram_bin_edges(data, bins=10, mode='equal', min_count=None, integer=False, remove_empty_edges=True, min_width=None):
r'''
Determine bin-edges.
:arguments:
**data** (``<array_like>``)
Input data. The histogram is computed over the flattened array.
:options:
**bins** ([``10``] | ``<int>``)
The ... | python | def histogram_bin_edges(data, bins=10, mode='equal', min_count=None, integer=False, remove_empty_edges=True, min_width=None):
r'''
Determine bin-edges.
:arguments:
**data** (``<array_like>``)
Input data. The histogram is computed over the flattened array.
:options:
**bins** ([``10``] | ``<int>``)
The ... | [
"def",
"histogram_bin_edges",
"(",
"data",
",",
"bins",
"=",
"10",
",",
"mode",
"=",
"'equal'",
",",
"min_count",
"=",
"None",
",",
"integer",
"=",
"False",
",",
"remove_empty_edges",
"=",
"True",
",",
"min_width",
"=",
"None",
")",
":",
"r",
"if",
"mo... | r'''
Determine bin-edges.
:arguments:
**data** (``<array_like>``)
Input data. The histogram is computed over the flattened array.
:options:
**bins** ([``10``] | ``<int>``)
The number of bins.
**mode** ([``'equal'`` | ``<str>``)
Mode with which to compute the bin-edges:
* ``'equal'``: each bin... | [
"r",
"Determine",
"bin",
"-",
"edges",
"."
] | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L910-L1020 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | hist | def hist(P, edges, **kwargs):
r'''
Plot histogram.
'''
from matplotlib.collections import PatchCollection
from matplotlib.patches import Polygon
# extract local options
axis = kwargs.pop( 'axis' , plt.gca() )
cindex = kwargs.pop( 'cindex' , None )
autoscale = kwargs.pop( 'auto... | python | def hist(P, edges, **kwargs):
r'''
Plot histogram.
'''
from matplotlib.collections import PatchCollection
from matplotlib.patches import Polygon
# extract local options
axis = kwargs.pop( 'axis' , plt.gca() )
cindex = kwargs.pop( 'cindex' , None )
autoscale = kwargs.pop( 'auto... | [
"def",
"hist",
"(",
"P",
",",
"edges",
",",
"**",
"kwargs",
")",
":",
"r",
"from",
"matplotlib",
".",
"collections",
"import",
"PatchCollection",
"from",
"matplotlib",
".",
"patches",
"import",
"Polygon",
"axis",
"=",
"kwargs",
".",
"pop",
"(",
"'axis'",
... | r'''
Plot histogram. | [
"r",
"Plot",
"histogram",
"."
] | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L1080-L1129 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | cdf | def cdf(data,mode='continuous',**kwargs):
'''
Return cumulative density.
:arguments:
**data** (``<numpy.ndarray>``)
Input data, to plot the distribution for.
:returns:
**P** (``<numpy.ndarray>``)
Cumulative probability.
**x** (``<numpy.ndarray>``)
Data points.
'''
return ( np.linspace(0.0,... | python | def cdf(data,mode='continuous',**kwargs):
'''
Return cumulative density.
:arguments:
**data** (``<numpy.ndarray>``)
Input data, to plot the distribution for.
:returns:
**P** (``<numpy.ndarray>``)
Cumulative probability.
**x** (``<numpy.ndarray>``)
Data points.
'''
return ( np.linspace(0.0,... | [
"def",
"cdf",
"(",
"data",
",",
"mode",
"=",
"'continuous'",
",",
"**",
"kwargs",
")",
":",
"return",
"(",
"np",
".",
"linspace",
"(",
"0.0",
",",
"1.0",
",",
"len",
"(",
"data",
")",
")",
",",
"np",
".",
"sort",
"(",
"data",
")",
")"
] | Return cumulative density.
:arguments:
**data** (``<numpy.ndarray>``)
Input data, to plot the distribution for.
:returns:
**P** (``<numpy.ndarray>``)
Cumulative probability.
**x** (``<numpy.ndarray>``)
Data points. | [
"Return",
"cumulative",
"density",
"."
] | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L1133-L1151 | train |
tdegeus/GooseMPL | GooseMPL/__init__.py | patch | def patch(*args,**kwargs):
'''
Add patches to plot. The color of the patches is indexed according to a specified color-index.
:example:
Plot a finite element mesh: the outline of the undeformed configuration, and the deformed
configuration for which the elements get a color e.g. based on stress::
import ma... | python | def patch(*args,**kwargs):
'''
Add patches to plot. The color of the patches is indexed according to a specified color-index.
:example:
Plot a finite element mesh: the outline of the undeformed configuration, and the deformed
configuration for which the elements get a color e.g. based on stress::
import ma... | [
"def",
"patch",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"from",
"matplotlib",
".",
"collections",
"import",
"PatchCollection",
"from",
"matplotlib",
".",
"patches",
"import",
"Polygon",
"if",
"(",
"'coor'",
"not",
"in",
"kwargs",
"or",
"'conn'",
"... | Add patches to plot. The color of the patches is indexed according to a specified color-index.
:example:
Plot a finite element mesh: the outline of the undeformed configuration, and the deformed
configuration for which the elements get a color e.g. based on stress::
import matplotlib.pyplot as plt
import... | [
"Add",
"patches",
"to",
"plot",
".",
"The",
"color",
"of",
"the",
"patches",
"is",
"indexed",
"according",
"to",
"a",
"specified",
"color",
"-",
"index",
"."
] | 16e1e06cbcf7131ac98c03ca7251ce83734ef905 | https://github.com/tdegeus/GooseMPL/blob/16e1e06cbcf7131ac98c03ca7251ce83734ef905/GooseMPL/__init__.py#L1155-L1271 | train |
tjcsl/cslbot | cslbot/commands/filter.py | cmd | def cmd(send, msg, args):
"""Changes the output filter.
Syntax: {command} [--channel channel] <filter|--show|--list|--reset|--chain filter,[filter2,...]>
"""
if args['type'] == 'privmsg':
send('Filters must be set in channels, not via private message.')
return
isadmin = args['is_ad... | python | def cmd(send, msg, args):
"""Changes the output filter.
Syntax: {command} [--channel channel] <filter|--show|--list|--reset|--chain filter,[filter2,...]>
"""
if args['type'] == 'privmsg':
send('Filters must be set in channels, not via private message.')
return
isadmin = args['is_ad... | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"if",
"args",
"[",
"'type'",
"]",
"==",
"'privmsg'",
":",
"send",
"(",
"'Filters must be set in channels, not via private message.'",
")",
"return",
"isadmin",
"=",
"args",
"[",
"'is_admin'",
"]",
... | Changes the output filter.
Syntax: {command} [--channel channel] <filter|--show|--list|--reset|--chain filter,[filter2,...]> | [
"Changes",
"the",
"output",
"filter",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/filter.py#L31-L80 | train |
JIC-CSB/jicimagelib | jicimagelib/region.py | Region.inner | def inner(self):
"""Region formed by taking non-border elements.
:returns: :class:`jicimagelib.region.Region`
"""
inner_array = nd.morphology.binary_erosion(self.bitmap)
return Region(inner_array) | python | def inner(self):
"""Region formed by taking non-border elements.
:returns: :class:`jicimagelib.region.Region`
"""
inner_array = nd.morphology.binary_erosion(self.bitmap)
return Region(inner_array) | [
"def",
"inner",
"(",
"self",
")",
":",
"inner_array",
"=",
"nd",
".",
"morphology",
".",
"binary_erosion",
"(",
"self",
".",
"bitmap",
")",
"return",
"Region",
"(",
"inner_array",
")"
] | Region formed by taking non-border elements.
:returns: :class:`jicimagelib.region.Region` | [
"Region",
"formed",
"by",
"taking",
"non",
"-",
"border",
"elements",
"."
] | fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44 | https://github.com/JIC-CSB/jicimagelib/blob/fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44/jicimagelib/region.py#L107-L114 | train |
JIC-CSB/jicimagelib | jicimagelib/region.py | Region.border | def border(self):
"""Region formed by taking border elements.
:returns: :class:`jicimagelib.region.Region`
"""
border_array = self.bitmap - self.inner.bitmap
return Region(border_array) | python | def border(self):
"""Region formed by taking border elements.
:returns: :class:`jicimagelib.region.Region`
"""
border_array = self.bitmap - self.inner.bitmap
return Region(border_array) | [
"def",
"border",
"(",
"self",
")",
":",
"border_array",
"=",
"self",
".",
"bitmap",
"-",
"self",
".",
"inner",
".",
"bitmap",
"return",
"Region",
"(",
"border_array",
")"
] | Region formed by taking border elements.
:returns: :class:`jicimagelib.region.Region` | [
"Region",
"formed",
"by",
"taking",
"border",
"elements",
"."
] | fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44 | https://github.com/JIC-CSB/jicimagelib/blob/fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44/jicimagelib/region.py#L117-L124 | train |
JIC-CSB/jicimagelib | jicimagelib/region.py | Region.convex_hull | def convex_hull(self):
"""Region representing the convex hull.
:returns: :class:`jicimagelib.region.Region`
"""
hull_array = skimage.morphology.convex_hull_image(self.bitmap)
return Region(hull_array) | python | def convex_hull(self):
"""Region representing the convex hull.
:returns: :class:`jicimagelib.region.Region`
"""
hull_array = skimage.morphology.convex_hull_image(self.bitmap)
return Region(hull_array) | [
"def",
"convex_hull",
"(",
"self",
")",
":",
"hull_array",
"=",
"skimage",
".",
"morphology",
".",
"convex_hull_image",
"(",
"self",
".",
"bitmap",
")",
"return",
"Region",
"(",
"hull_array",
")"
] | Region representing the convex hull.
:returns: :class:`jicimagelib.region.Region` | [
"Region",
"representing",
"the",
"convex",
"hull",
"."
] | fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44 | https://github.com/JIC-CSB/jicimagelib/blob/fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44/jicimagelib/region.py#L127-L133 | train |
JIC-CSB/jicimagelib | jicimagelib/region.py | Region.dilate | def dilate(self, iterations=1):
"""Return a dilated region.
:param iterations: number of iterations to use in dilation
:returns: :class:`jicimagelib.region.Region`
"""
dilated_array = nd.morphology.binary_dilation(self.bitmap,
... | python | def dilate(self, iterations=1):
"""Return a dilated region.
:param iterations: number of iterations to use in dilation
:returns: :class:`jicimagelib.region.Region`
"""
dilated_array = nd.morphology.binary_dilation(self.bitmap,
... | [
"def",
"dilate",
"(",
"self",
",",
"iterations",
"=",
"1",
")",
":",
"dilated_array",
"=",
"nd",
".",
"morphology",
".",
"binary_dilation",
"(",
"self",
".",
"bitmap",
",",
"iterations",
"=",
"iterations",
")",
"return",
"Region",
"(",
"dilated_array",
")"... | Return a dilated region.
:param iterations: number of iterations to use in dilation
:returns: :class:`jicimagelib.region.Region` | [
"Return",
"a",
"dilated",
"region",
"."
] | fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44 | https://github.com/JIC-CSB/jicimagelib/blob/fbd67accb2e6d55969c6d4ed7e8b4bb4ab65cd44/jicimagelib/region.py#L162-L170 | train |
tjcsl/cslbot | cslbot/commands/guarded.py | cmd | def cmd(send, _, args):
"""Shows the currently guarded nicks.
Syntax: {command}
"""
guarded = args['handler'].guarded
if not guarded:
send("Nobody is guarded.")
else:
send(", ".join(guarded)) | python | def cmd(send, _, args):
"""Shows the currently guarded nicks.
Syntax: {command}
"""
guarded = args['handler'].guarded
if not guarded:
send("Nobody is guarded.")
else:
send(", ".join(guarded)) | [
"def",
"cmd",
"(",
"send",
",",
"_",
",",
"args",
")",
":",
"guarded",
"=",
"args",
"[",
"'handler'",
"]",
".",
"guarded",
"if",
"not",
"guarded",
":",
"send",
"(",
"\"Nobody is guarded.\"",
")",
"else",
":",
"send",
"(",
"\", \"",
".",
"join",
"(",
... | Shows the currently guarded nicks.
Syntax: {command} | [
"Shows",
"the",
"currently",
"guarded",
"nicks",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/guarded.py#L22-L32 | train |
CI-WATER/mapkit | mapkit/ColorRampGenerator.py | ColorRampGenerator.mapColorRampToValues | def mapColorRampToValues(cls, colorRamp, minValue, maxValue, alpha=1.0):
"""
Creates color ramp based on min and max values of all the raster pixels from all rasters. If pixel value is one
of the no data values it will be excluded in the color ramp interpolation. Returns colorRamp, slope, interc... | python | def mapColorRampToValues(cls, colorRamp, minValue, maxValue, alpha=1.0):
"""
Creates color ramp based on min and max values of all the raster pixels from all rasters. If pixel value is one
of the no data values it will be excluded in the color ramp interpolation. Returns colorRamp, slope, interc... | [
"def",
"mapColorRampToValues",
"(",
"cls",
",",
"colorRamp",
",",
"minValue",
",",
"maxValue",
",",
"alpha",
"=",
"1.0",
")",
":",
"minRampIndex",
"=",
"0",
"maxRampIndex",
"=",
"float",
"(",
"len",
"(",
"colorRamp",
")",
"-",
"1",
")",
"if",
"minValue",... | Creates color ramp based on min and max values of all the raster pixels from all rasters. If pixel value is one
of the no data values it will be excluded in the color ramp interpolation. Returns colorRamp, slope, intercept
:param colorRamp: A list of RGB tuples representing a color ramp (e.g.: results ... | [
"Creates",
"color",
"ramp",
"based",
"on",
"min",
"and",
"max",
"values",
"of",
"all",
"the",
"raster",
"pixels",
"from",
"all",
"rasters",
".",
"If",
"pixel",
"value",
"is",
"one",
"of",
"the",
"no",
"data",
"values",
"it",
"will",
"be",
"excluded",
"... | ce5fbded6af7adabdf1eec85631c6811ef8ecc34 | https://github.com/CI-WATER/mapkit/blob/ce5fbded6af7adabdf1eec85631c6811ef8ecc34/mapkit/ColorRampGenerator.py#L273-L305 | train |
tjcsl/cslbot | cslbot/commands/blame.py | cmd | def cmd(send, msg, args):
"""Blames a random user for something.
Syntax: {command} [reason]
"""
user = choice(get_users(args))
if msg:
msg = " for " + msg
msg = "blames " + user + msg
send(msg, 'action') | python | def cmd(send, msg, args):
"""Blames a random user for something.
Syntax: {command} [reason]
"""
user = choice(get_users(args))
if msg:
msg = " for " + msg
msg = "blames " + user + msg
send(msg, 'action') | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"args",
")",
":",
"user",
"=",
"choice",
"(",
"get_users",
"(",
"args",
")",
")",
"if",
"msg",
":",
"msg",
"=",
"\" for \"",
"+",
"msg",
"msg",
"=",
"\"blames \"",
"+",
"user",
"+",
"msg",
"send",
"(",
... | Blames a random user for something.
Syntax: {command} [reason] | [
"Blames",
"a",
"random",
"user",
"for",
"something",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/blame.py#L25-L35 | train |
tjcsl/cslbot | cslbot/commands/weather.py | set_default | def set_default(nick, location, session, send, apikey):
"""Sets nick's default location to location."""
if valid_location(location, apikey):
send("Setting default location")
default = session.query(Weather_prefs).filter(Weather_prefs.nick == nick).first()
if default is None:
... | python | def set_default(nick, location, session, send, apikey):
"""Sets nick's default location to location."""
if valid_location(location, apikey):
send("Setting default location")
default = session.query(Weather_prefs).filter(Weather_prefs.nick == nick).first()
if default is None:
... | [
"def",
"set_default",
"(",
"nick",
",",
"location",
",",
"session",
",",
"send",
",",
"apikey",
")",
":",
"if",
"valid_location",
"(",
"location",
",",
"apikey",
")",
":",
"send",
"(",
"\"Setting default location\"",
")",
"default",
"=",
"session",
".",
"q... | Sets nick's default location to location. | [
"Sets",
"nick",
"s",
"default",
"location",
"to",
"location",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/weather.py#L73-L84 | train |
tjcsl/cslbot | cslbot/commands/slogan.py | cmd | def cmd(send, msg, _):
"""Gets a slogan.
Syntax: {command} [text]
"""
if not msg:
msg = textutils.gen_word()
send(textutils.gen_slogan(msg)) | python | def cmd(send, msg, _):
"""Gets a slogan.
Syntax: {command} [text]
"""
if not msg:
msg = textutils.gen_word()
send(textutils.gen_slogan(msg)) | [
"def",
"cmd",
"(",
"send",
",",
"msg",
",",
"_",
")",
":",
"if",
"not",
"msg",
":",
"msg",
"=",
"textutils",
".",
"gen_word",
"(",
")",
"send",
"(",
"textutils",
".",
"gen_slogan",
"(",
"msg",
")",
")"
] | Gets a slogan.
Syntax: {command} [text] | [
"Gets",
"a",
"slogan",
"."
] | aebe07be47141f61d7c180706bddfb707f19b2b5 | https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/commands/slogan.py#L23-L31 | train |
acutesoftware/virtual-AI-simulator | vais/planet.py | Planet.evolve | def evolve(self, years):
"""
run the evolution of the planet to see how it looks
after 'years'
"""
world_file = fldr + os.sep + self.name + '.txt'
self.build_base()
self.world.add_mountains()
self.add_life()
self.world.grd.save(world_file)
... | python | def evolve(self, years):
"""
run the evolution of the planet to see how it looks
after 'years'
"""
world_file = fldr + os.sep + self.name + '.txt'
self.build_base()
self.world.add_mountains()
self.add_life()
self.world.grd.save(world_file)
... | [
"def",
"evolve",
"(",
"self",
",",
"years",
")",
":",
"world_file",
"=",
"fldr",
"+",
"os",
".",
"sep",
"+",
"self",
".",
"name",
"+",
"'.txt'",
"self",
".",
"build_base",
"(",
")",
"self",
".",
"world",
".",
"add_mountains",
"(",
")",
"self",
".",... | run the evolution of the planet to see how it looks
after 'years' | [
"run",
"the",
"evolution",
"of",
"the",
"planet",
"to",
"see",
"how",
"it",
"looks",
"after",
"years"
] | 57de679a5b1a58c38fefe6aea58af1f3a7e79c58 | https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/planet.py#L53-L64 | train |
acutesoftware/virtual-AI-simulator | vais/planet.py | Planet.build_base | def build_base(self):
"""
create a base random land structure using the AIKIF world model
"""
#print('Planet ' + self.name + ' has formed!')
self.world = my_world.World( self.grid_height, self.grid_width, [' ','x','#'])
perc_land = (self.lava + (self.wind/10) + ... | python | def build_base(self):
"""
create a base random land structure using the AIKIF world model
"""
#print('Planet ' + self.name + ' has formed!')
self.world = my_world.World( self.grid_height, self.grid_width, [' ','x','#'])
perc_land = (self.lava + (self.wind/10) + ... | [
"def",
"build_base",
"(",
"self",
")",
":",
"self",
".",
"world",
"=",
"my_world",
".",
"World",
"(",
"self",
".",
"grid_height",
",",
"self",
".",
"grid_width",
",",
"[",
"' '",
",",
"'x'",
",",
"'#'",
"]",
")",
"perc_land",
"=",
"(",
"self",
".",... | create a base random land structure using the AIKIF world model | [
"create",
"a",
"base",
"random",
"land",
"structure",
"using",
"the",
"AIKIF",
"world",
"model"
] | 57de679a5b1a58c38fefe6aea58af1f3a7e79c58 | https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/planet.py#L68-L80 | train |
tylerbutler/engineer | engineer/models.py | Post.url | def url(self):
"""The site-relative URL to the post."""
url = u'{home_url}{permalink}'.format(home_url=settings.HOME_URL,
permalink=self._permalink)
url = re.sub(r'/{2,}', r'/', url)
return url | python | def url(self):
"""The site-relative URL to the post."""
url = u'{home_url}{permalink}'.format(home_url=settings.HOME_URL,
permalink=self._permalink)
url = re.sub(r'/{2,}', r'/', url)
return url | [
"def",
"url",
"(",
"self",
")",
":",
"url",
"=",
"u'{home_url}{permalink}'",
".",
"format",
"(",
"home_url",
"=",
"settings",
".",
"HOME_URL",
",",
"permalink",
"=",
"self",
".",
"_permalink",
")",
"url",
"=",
"re",
".",
"sub",
"(",
"r'/{2,}'",
",",
"r... | The site-relative URL to the post. | [
"The",
"site",
"-",
"relative",
"URL",
"to",
"the",
"post",
"."
] | 8884f587297f37646c40e5553174852b444a4024 | https://github.com/tylerbutler/engineer/blob/8884f587297f37646c40e5553174852b444a4024/engineer/models.py#L157-L162 | train |
tylerbutler/engineer | engineer/models.py | Post.content | def content(self):
"""The post's content in HTML format."""
content_list = wrap_list(self._content_preprocessed)
content_list.extend(self._content_stash)
content_to_render = '\n'.join(content_list)
return typogrify(self.content_renderer.render(content_to_render, self.format)) | python | def content(self):
"""The post's content in HTML format."""
content_list = wrap_list(self._content_preprocessed)
content_list.extend(self._content_stash)
content_to_render = '\n'.join(content_list)
return typogrify(self.content_renderer.render(content_to_render, self.format)) | [
"def",
"content",
"(",
"self",
")",
":",
"content_list",
"=",
"wrap_list",
"(",
"self",
".",
"_content_preprocessed",
")",
"content_list",
".",
"extend",
"(",
"self",
".",
"_content_stash",
")",
"content_to_render",
"=",
"'\\n'",
".",
"join",
"(",
"content_lis... | The post's content in HTML format. | [
"The",
"post",
"s",
"content",
"in",
"HTML",
"format",
"."
] | 8884f587297f37646c40e5553174852b444a4024 | https://github.com/tylerbutler/engineer/blob/8884f587297f37646c40e5553174852b444a4024/engineer/models.py#L188-L193 | train |
tylerbutler/engineer | engineer/models.py | Post.is_published | def is_published(self):
"""``True`` if the post is published, ``False`` otherwise."""
return self.status == Status.published and self.timestamp <= arrow.now() | python | def is_published(self):
"""``True`` if the post is published, ``False`` otherwise."""
return self.status == Status.published and self.timestamp <= arrow.now() | [
"def",
"is_published",
"(",
"self",
")",
":",
"return",
"self",
".",
"status",
"==",
"Status",
".",
"published",
"and",
"self",
".",
"timestamp",
"<=",
"arrow",
".",
"now",
"(",
")"
] | ``True`` if the post is published, ``False`` otherwise. | [
"True",
"if",
"the",
"post",
"is",
"published",
"False",
"otherwise",
"."
] | 8884f587297f37646c40e5553174852b444a4024 | https://github.com/tylerbutler/engineer/blob/8884f587297f37646c40e5553174852b444a4024/engineer/models.py#L243-L245 | train |
tylerbutler/engineer | engineer/models.py | Post.is_pending | def is_pending(self):
"""``True`` if the post is marked as published but has a timestamp set in the future."""
return self.status == Status.published and self.timestamp >= arrow.now() | python | def is_pending(self):
"""``True`` if the post is marked as published but has a timestamp set in the future."""
return self.status == Status.published and self.timestamp >= arrow.now() | [
"def",
"is_pending",
"(",
"self",
")",
":",
"return",
"self",
".",
"status",
"==",
"Status",
".",
"published",
"and",
"self",
".",
"timestamp",
">=",
"arrow",
".",
"now",
"(",
")"
] | ``True`` if the post is marked as published but has a timestamp set in the future. | [
"True",
"if",
"the",
"post",
"is",
"marked",
"as",
"published",
"but",
"has",
"a",
"timestamp",
"set",
"in",
"the",
"future",
"."
] | 8884f587297f37646c40e5553174852b444a4024 | https://github.com/tylerbutler/engineer/blob/8884f587297f37646c40e5553174852b444a4024/engineer/models.py#L248-L250 | train |
tylerbutler/engineer | engineer/models.py | Post.set_finalized_content | def set_finalized_content(self, content, caller_class):
"""
Plugins can call this method to modify post content that is written back to source post files.
This method can be called at any time by anyone, but it has no effect if the caller is not granted the
``MODIFY_RAW_POST`` permission... | python | def set_finalized_content(self, content, caller_class):
"""
Plugins can call this method to modify post content that is written back to source post files.
This method can be called at any time by anyone, but it has no effect if the caller is not granted the
``MODIFY_RAW_POST`` permission... | [
"def",
"set_finalized_content",
"(",
"self",
",",
"content",
",",
"caller_class",
")",
":",
"caller",
"=",
"caller_class",
".",
"get_name",
"(",
")",
"if",
"hasattr",
"(",
"caller_class",
",",
"'get_name'",
")",
"else",
"unicode",
"(",
"caller_class",
")",
"... | Plugins can call this method to modify post content that is written back to source post files.
This method can be called at any time by anyone, but it has no effect if the caller is not granted the
``MODIFY_RAW_POST`` permission in the Engineer configuration.
The :attr:`~engineer.conf.EngineerC... | [
"Plugins",
"can",
"call",
"this",
"method",
"to",
"modify",
"post",
"content",
"that",
"is",
"written",
"back",
"to",
"source",
"post",
"files",
".",
"This",
"method",
"can",
"be",
"called",
"at",
"any",
"time",
"by",
"anyone",
"but",
"it",
"has",
"no",
... | 8884f587297f37646c40e5553174852b444a4024 | https://github.com/tylerbutler/engineer/blob/8884f587297f37646c40e5553174852b444a4024/engineer/models.py#L344-L371 | train |
tylerbutler/engineer | engineer/models.py | PostCollection.all_tags | def all_tags(self):
"""Returns a list of all the unique tags, as strings, that posts in the collection have."""
tags = set()
for post in self:
tags.update(post.tags)
return list(tags) | python | def all_tags(self):
"""Returns a list of all the unique tags, as strings, that posts in the collection have."""
tags = set()
for post in self:
tags.update(post.tags)
return list(tags) | [
"def",
"all_tags",
"(",
"self",
")",
":",
"tags",
"=",
"set",
"(",
")",
"for",
"post",
"in",
"self",
":",
"tags",
".",
"update",
"(",
"post",
".",
"tags",
")",
"return",
"list",
"(",
"tags",
")"
] | Returns a list of all the unique tags, as strings, that posts in the collection have. | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"unique",
"tags",
"as",
"strings",
"that",
"posts",
"in",
"the",
"collection",
"have",
"."
] | 8884f587297f37646c40e5553174852b444a4024 | https://github.com/tylerbutler/engineer/blob/8884f587297f37646c40e5553174852b444a4024/engineer/models.py#L428-L433 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.