repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
jepegit/cellpy | cellpy/utils/ocv_rlx.py | MultiCycleOcvFit.plot_summary_translated | def plot_summary_translated(self):
"""Convenience function for plotting the summary of the
fit (translated)"""
fig2 = plt.figure()
ax1 = fig2.add_subplot(221)
ax1.set_title('OCV (V)')
ax2 = fig2.add_subplot(222)
ax2.set_title('IR (Ohm)')
ax3 = fig2.add_su... | python | def plot_summary_translated(self):
"""Convenience function for plotting the summary of the
fit (translated)"""
fig2 = plt.figure()
ax1 = fig2.add_subplot(221)
ax1.set_title('OCV (V)')
ax2 = fig2.add_subplot(222)
ax2.set_title('IR (Ohm)')
ax3 = fig2.add_su... | [
"def",
"plot_summary_translated",
"(",
"self",
")",
":",
"fig2",
"=",
"plt",
".",
"figure",
"(",
")",
"ax1",
"=",
"fig2",
".",
"add_subplot",
"(",
"221",
")",
"ax1",
".",
"set_title",
"(",
"'OCV (V)'",
")",
"ax2",
"=",
"fig2",
".",
"add_subplot",
"(",
... | Convenience function for plotting the summary of the
fit (translated) | [
"Convenience",
"function",
"for",
"plotting",
"the",
"summary",
"of",
"the",
"fit",
"(",
"translated",
")"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ocv_rlx.py#L372-L399 |
jepegit/cellpy | cellpy/utils/ocv_rlx.py | OcvFit.set_cellpydata | def set_cellpydata(self, cellpydata, cycle):
"""Performing fit of the OCV steps in the cycles set by set_cycles()
from the data set by set_data()
r is found by calculating v0 / i_start --> err(r)= err(v0) + err(i_start).
c is found from using tau / r --> err(c) = err(r) + err(tau)
... | python | def set_cellpydata(self, cellpydata, cycle):
"""Performing fit of the OCV steps in the cycles set by set_cycles()
from the data set by set_data()
r is found by calculating v0 / i_start --> err(r)= err(v0) + err(i_start).
c is found from using tau / r --> err(c) = err(r) + err(tau)
... | [
"def",
"set_cellpydata",
"(",
"self",
",",
"cellpydata",
",",
"cycle",
")",
":",
"self",
".",
"data",
"=",
"cellpydata",
"self",
".",
"step_table",
"=",
"self",
".",
"data",
".",
"dataset",
"# hope it works...",
"time_voltage",
"=",
"self",
".",
"data",
".... | Performing fit of the OCV steps in the cycles set by set_cycles()
from the data set by set_data()
r is found by calculating v0 / i_start --> err(r)= err(v0) + err(i_start).
c is found from using tau / r --> err(c) = err(r) + err(tau)
Args:
cellpydata (CellpyData): data obje... | [
"Performing",
"fit",
"of",
"the",
"OCV",
"steps",
"in",
"the",
"cycles",
"set",
"by",
"set_cycles",
"()",
"from",
"the",
"data",
"set",
"by",
"set_data",
"()"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ocv_rlx.py#L422-L445 |
jepegit/cellpy | cellpy/utils/ocv_rlx.py | OcvFit.run_fit | def run_fit(self):
"""Performing fit of the OCV steps in the cycles set by set_cycles()
from the data set by set_data()
r is found by calculating v0 / i_start --> err(r)= err(v0) + err(i_start).
c is found from using tau / r --> err(c) = err(r) + err(tau)
Returns:
... | python | def run_fit(self):
"""Performing fit of the OCV steps in the cycles set by set_cycles()
from the data set by set_data()
r is found by calculating v0 / i_start --> err(r)= err(v0) + err(i_start).
c is found from using tau / r --> err(c) = err(r) + err(tau)
Returns:
... | [
"def",
"run_fit",
"(",
"self",
")",
":",
"# Check if data is set",
"if",
"self",
".",
"time",
"is",
"[",
"]",
":",
"self",
".",
"result",
"=",
"[",
"]",
"return",
"try",
":",
"self",
".",
"fit_model",
"(",
")",
"except",
"ValueError",
"as",
"e",
":",... | Performing fit of the OCV steps in the cycles set by set_cycles()
from the data set by set_data()
r is found by calculating v0 / i_start --> err(r)= err(v0) + err(i_start).
c is found from using tau / r --> err(c) = err(r) + err(tau)
Returns:
None: Resulting best fit param... | [
"Performing",
"fit",
"of",
"the",
"OCV",
"steps",
"in",
"the",
"cycles",
"set",
"by",
"set_cycles",
"()",
"from",
"the",
"data",
"set",
"by",
"set_data",
"()"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/utils/ocv_rlx.py#L517-L540 |
openstax/cnx-epub | cnxepub/html_parsers.py | parse_navigation_html_to_tree | def parse_navigation_html_to_tree(html, id):
"""Parse the given ``html`` (an etree object) to a tree.
The ``id`` is required in order to assign the top-level tree id value.
"""
def xpath(x):
return html.xpath(x, namespaces=HTML_DOCUMENT_NAMESPACES)
try:
value = xpath('//*[@data-type=... | python | def parse_navigation_html_to_tree(html, id):
"""Parse the given ``html`` (an etree object) to a tree.
The ``id`` is required in order to assign the top-level tree id value.
"""
def xpath(x):
return html.xpath(x, namespaces=HTML_DOCUMENT_NAMESPACES)
try:
value = xpath('//*[@data-type=... | [
"def",
"parse_navigation_html_to_tree",
"(",
"html",
",",
"id",
")",
":",
"def",
"xpath",
"(",
"x",
")",
":",
"return",
"html",
".",
"xpath",
"(",
"x",
",",
"namespaces",
"=",
"HTML_DOCUMENT_NAMESPACES",
")",
"try",
":",
"value",
"=",
"xpath",
"(",
"'//*... | Parse the given ``html`` (an etree object) to a tree.
The ``id`` is required in order to assign the top-level tree id value. | [
"Parse",
"the",
"given",
"html",
"(",
"an",
"etree",
"object",
")",
"to",
"a",
"tree",
".",
"The",
"id",
"is",
"required",
"in",
"order",
"to",
"assign",
"the",
"top",
"-",
"level",
"tree",
"id",
"value",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/html_parsers.py#L22-L39 |
openstax/cnx-epub | cnxepub/html_parsers.py | _nav_to_tree | def _nav_to_tree(root):
"""Given an etree containing a navigation document structure
rooted from the 'nav' element, parse to a tree:
{'id': <id>|'subcol', 'title': <title>, 'contents': [<tree>, ...]}
"""
def expath(e, x):
return e.xpath(x, namespaces=HTML_DOCUMENT_NAMESPACES)
for li in e... | python | def _nav_to_tree(root):
"""Given an etree containing a navigation document structure
rooted from the 'nav' element, parse to a tree:
{'id': <id>|'subcol', 'title': <title>, 'contents': [<tree>, ...]}
"""
def expath(e, x):
return e.xpath(x, namespaces=HTML_DOCUMENT_NAMESPACES)
for li in e... | [
"def",
"_nav_to_tree",
"(",
"root",
")",
":",
"def",
"expath",
"(",
"e",
",",
"x",
")",
":",
"return",
"e",
".",
"xpath",
"(",
"x",
",",
"namespaces",
"=",
"HTML_DOCUMENT_NAMESPACES",
")",
"for",
"li",
"in",
"expath",
"(",
"root",
",",
"'xhtml:ol/xhtml... | Given an etree containing a navigation document structure
rooted from the 'nav' element, parse to a tree:
{'id': <id>|'subcol', 'title': <title>, 'contents': [<tree>, ...]} | [
"Given",
"an",
"etree",
"containing",
"a",
"navigation",
"document",
"structure",
"rooted",
"from",
"the",
"nav",
"element",
"parse",
"to",
"a",
"tree",
":",
"{",
"id",
":",
"<id",
">",
"|",
"subcol",
"title",
":",
"<title",
">",
"contents",
":",
"[",
... | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/html_parsers.py#L42-L68 |
openstax/cnx-epub | cnxepub/html_parsers.py | parse_resources | def parse_resources(html):
"""Return a list of resource names found in the html metadata section."""
xpath = '//*[@data-type="resources"]//xhtml:li/xhtml:a'
for resource in html.xpath(xpath, namespaces=HTML_DOCUMENT_NAMESPACES):
yield {
'id': resource.get('href'),
'filename':... | python | def parse_resources(html):
"""Return a list of resource names found in the html metadata section."""
xpath = '//*[@data-type="resources"]//xhtml:li/xhtml:a'
for resource in html.xpath(xpath, namespaces=HTML_DOCUMENT_NAMESPACES):
yield {
'id': resource.get('href'),
'filename':... | [
"def",
"parse_resources",
"(",
"html",
")",
":",
"xpath",
"=",
"'//*[@data-type=\"resources\"]//xhtml:li/xhtml:a'",
"for",
"resource",
"in",
"html",
".",
"xpath",
"(",
"xpath",
",",
"namespaces",
"=",
"HTML_DOCUMENT_NAMESPACES",
")",
":",
"yield",
"{",
"'id'",
":"... | Return a list of resource names found in the html metadata section. | [
"Return",
"a",
"list",
"of",
"resource",
"names",
"found",
"in",
"the",
"html",
"metadata",
"section",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/html_parsers.py#L77-L84 |
sci-bots/serial-device | serial_device/mqtt.py | SerialDeviceManager.on_connect | def on_connect(self, client, userdata, flags, rc):
'''
Callback for when the client receives a ``CONNACK`` response from the
broker.
Parameters
----------
client : paho.mqtt.client.Client
The client instance for this callback.
userdata : object
... | python | def on_connect(self, client, userdata, flags, rc):
'''
Callback for when the client receives a ``CONNACK`` response from the
broker.
Parameters
----------
client : paho.mqtt.client.Client
The client instance for this callback.
userdata : object
... | [
"def",
"on_connect",
"(",
"self",
",",
"client",
",",
"userdata",
",",
"flags",
",",
"rc",
")",
":",
"super",
"(",
"SerialDeviceManager",
",",
"self",
")",
".",
"on_connect",
"(",
"client",
",",
"userdata",
",",
"flags",
",",
"rc",
")",
"if",
"rc",
"... | Callback for when the client receives a ``CONNACK`` response from the
broker.
Parameters
----------
client : paho.mqtt.client.Client
The client instance for this callback.
userdata : object
The private user data as set in :class:`paho.mqtt.client.Client`
... | [
"Callback",
"for",
"when",
"the",
"client",
"receives",
"a",
"CONNACK",
"response",
"from",
"the",
"broker",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/mqtt.py#L57-L106 |
sci-bots/serial-device | serial_device/mqtt.py | SerialDeviceManager.on_message | def on_message(self, client, userdata, msg):
'''
Callback for when a ``PUBLISH`` message is received from the broker.
'''
if msg.topic == 'serial_device/refresh_comports':
self.refresh_comports()
return
match = CRE_MANAGER.match(msg.topic)
if matc... | python | def on_message(self, client, userdata, msg):
'''
Callback for when a ``PUBLISH`` message is received from the broker.
'''
if msg.topic == 'serial_device/refresh_comports':
self.refresh_comports()
return
match = CRE_MANAGER.match(msg.topic)
if matc... | [
"def",
"on_message",
"(",
"self",
",",
"client",
",",
"userdata",
",",
"msg",
")",
":",
"if",
"msg",
".",
"topic",
"==",
"'serial_device/refresh_comports'",
":",
"self",
".",
"refresh_comports",
"(",
")",
"return",
"match",
"=",
"CRE_MANAGER",
".",
"match",
... | Callback for when a ``PUBLISH`` message is received from the broker. | [
"Callback",
"for",
"when",
"a",
"PUBLISH",
"message",
"is",
"received",
"from",
"the",
"broker",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/mqtt.py#L108-L138 |
sci-bots/serial-device | serial_device/mqtt.py | SerialDeviceManager._publish_status | def _publish_status(self, port):
'''
Publish status for specified port.
Parameters
----------
port : str
Device name/port.
'''
if port not in self.open_devices:
status = {}
else:
device = self.open_devices[port].serial
... | python | def _publish_status(self, port):
'''
Publish status for specified port.
Parameters
----------
port : str
Device name/port.
'''
if port not in self.open_devices:
status = {}
else:
device = self.open_devices[port].serial
... | [
"def",
"_publish_status",
"(",
"self",
",",
"port",
")",
":",
"if",
"port",
"not",
"in",
"self",
".",
"open_devices",
":",
"status",
"=",
"{",
"}",
"else",
":",
"device",
"=",
"self",
".",
"open_devices",
"[",
"port",
"]",
".",
"serial",
"properties",
... | Publish status for specified port.
Parameters
----------
port : str
Device name/port. | [
"Publish",
"status",
"for",
"specified",
"port",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/mqtt.py#L142-L160 |
sci-bots/serial-device | serial_device/mqtt.py | SerialDeviceManager._serial_close | def _serial_close(self, port):
'''
Handle close request.
Parameters
----------
port : str
Device name/port.
'''
if port in self.open_devices:
try:
self.open_devices[port].close()
except Exception as exception:
... | python | def _serial_close(self, port):
'''
Handle close request.
Parameters
----------
port : str
Device name/port.
'''
if port in self.open_devices:
try:
self.open_devices[port].close()
except Exception as exception:
... | [
"def",
"_serial_close",
"(",
"self",
",",
"port",
")",
":",
"if",
"port",
"in",
"self",
".",
"open_devices",
":",
"try",
":",
"self",
".",
"open_devices",
"[",
"port",
"]",
".",
"close",
"(",
")",
"except",
"Exception",
"as",
"exception",
":",
"logger"... | Handle close request.
Parameters
----------
port : str
Device name/port. | [
"Handle",
"close",
"request",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/mqtt.py#L162-L180 |
sci-bots/serial-device | serial_device/mqtt.py | SerialDeviceManager._serial_connect | def _serial_connect(self, port, request):
'''
Handle connection request.
Parameters
----------
port : str
Device name/port.
request : dict
'''
# baudrate : int
# Baud rate such as 9600 or 115200 etc.
# bytesize ... | python | def _serial_connect(self, port, request):
'''
Handle connection request.
Parameters
----------
port : str
Device name/port.
request : dict
'''
# baudrate : int
# Baud rate such as 9600 or 115200 etc.
# bytesize ... | [
"def",
"_serial_connect",
"(",
"self",
",",
"port",
",",
"request",
")",
":",
"# baudrate : int",
"# Baud rate such as 9600 or 115200 etc.",
"# bytesize : str, optional",
"# Number of data bits.",
"#",
"# Possible values: ``'FIVEBITS'``, ``'SIXBITS'``, `... | Handle connection request.
Parameters
----------
port : str
Device name/port.
request : dict | [
"Handle",
"connection",
"request",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/mqtt.py#L182-L324 |
sci-bots/serial-device | serial_device/mqtt.py | SerialDeviceManager._serial_send | def _serial_send(self, port, payload):
'''
Send data to connected device.
Parameters
----------
port : str
Device name/port.
payload : bytes
Payload to send to device.
'''
if port not in self.open_devices:
# Not connect... | python | def _serial_send(self, port, payload):
'''
Send data to connected device.
Parameters
----------
port : str
Device name/port.
payload : bytes
Payload to send to device.
'''
if port not in self.open_devices:
# Not connect... | [
"def",
"_serial_send",
"(",
"self",
",",
"port",
",",
"payload",
")",
":",
"if",
"port",
"not",
"in",
"self",
".",
"open_devices",
":",
"# Not connected to device.",
"logger",
".",
"error",
"(",
"'Error sending data: `%s` not connected'",
",",
"port",
")",
"self... | Send data to connected device.
Parameters
----------
port : str
Device name/port.
payload : bytes
Payload to send to device. | [
"Send",
"data",
"to",
"connected",
"device",
"."
] | train | https://github.com/sci-bots/serial-device/blob/5de1c3fc447ae829b57d80073ec6ac4fba3283c6/serial_device/mqtt.py#L326-L347 |
jepegit/cellpy | dev_utils/parsing_binary.py | print_datetime_object | def print_datetime_object(dt):
"""prints a date-object"""
print(dt)
print('ctime :', dt.ctime())
print('tuple :', dt.timetuple())
print('ordinal:', dt.toordinal())
print('Year :', dt.year)
print('Mon :', dt.month)
print('Day :', dt.day) | python | def print_datetime_object(dt):
"""prints a date-object"""
print(dt)
print('ctime :', dt.ctime())
print('tuple :', dt.timetuple())
print('ordinal:', dt.toordinal())
print('Year :', dt.year)
print('Mon :', dt.month)
print('Day :', dt.day) | [
"def",
"print_datetime_object",
"(",
"dt",
")",
":",
"print",
"(",
"dt",
")",
"print",
"(",
"'ctime :'",
",",
"dt",
".",
"ctime",
"(",
")",
")",
"print",
"(",
"'tuple :'",
",",
"dt",
".",
"timetuple",
"(",
")",
")",
"print",
"(",
"'ordinal:'",
",",... | prints a date-object | [
"prints",
"a",
"date",
"-",
"object"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/dev_utils/parsing_binary.py#L21-L29 |
jepegit/cellpy | cellpy/readers/instruments/pec.py | PECLoader.get_raw_limits | def get_raw_limits(self):
"""Include the settings for how to decide what kind of step you are examining here.
The raw limits are 'epsilons' used to check if the current and/or voltage is stable (for example
for galvanostatic steps, one would expect that the current is stable (constant) and non-... | python | def get_raw_limits(self):
"""Include the settings for how to decide what kind of step you are examining here.
The raw limits are 'epsilons' used to check if the current and/or voltage is stable (for example
for galvanostatic steps, one would expect that the current is stable (constant) and non-... | [
"def",
"get_raw_limits",
"(",
"self",
")",
":",
"warnings",
".",
"warn",
"(",
"\"raw limits have not been subject for testing yet\"",
")",
"raw_limits",
"=",
"dict",
"(",
")",
"raw_limits",
"[",
"\"current_hard\"",
"]",
"=",
"0.1",
"# There is a bug in PEC",
"raw_limi... | Include the settings for how to decide what kind of step you are examining here.
The raw limits are 'epsilons' used to check if the current and/or voltage is stable (for example
for galvanostatic steps, one would expect that the current is stable (constant) and non-zero).
It is expected that di... | [
"Include",
"the",
"settings",
"for",
"how",
"to",
"decide",
"what",
"kind",
"of",
"step",
"you",
"are",
"examining",
"here",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/instruments/pec.py#L75-L97 |
jepegit/cellpy | cellpy/readers/core.py | check64bit | def check64bit(current_system="python"):
"""checks if you are on a 64 bit platform"""
if current_system == "python":
return sys.maxsize > 2147483647
elif current_system == "os":
import platform
pm = platform.machine()
if pm != ".." and pm.endswith('64'): # recent Python (not... | python | def check64bit(current_system="python"):
"""checks if you are on a 64 bit platform"""
if current_system == "python":
return sys.maxsize > 2147483647
elif current_system == "os":
import platform
pm = platform.machine()
if pm != ".." and pm.endswith('64'): # recent Python (not... | [
"def",
"check64bit",
"(",
"current_system",
"=",
"\"python\"",
")",
":",
"if",
"current_system",
"==",
"\"python\"",
":",
"return",
"sys",
".",
"maxsize",
">",
"2147483647",
"elif",
"current_system",
"==",
"\"os\"",
":",
"import",
"platform",
"pm",
"=",
"platf... | checks if you are on a 64 bit platform | [
"checks",
"if",
"you",
"are",
"on",
"a",
"64",
"bit",
"platform"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/core.py#L269-L292 |
jepegit/cellpy | cellpy/readers/core.py | humanize_bytes | def humanize_bytes(b, precision=1):
"""Return a humanized string representation of a number of b.
Assumes `from __future__ import division`.
>>> humanize_bytes(1)
'1 byte'
>>> humanize_bytes(1024)
'1.0 kB'
>>> humanize_bytes(1024*123)
'123.0 kB'
>>> humanize_bytes(1024*12342)
'... | python | def humanize_bytes(b, precision=1):
"""Return a humanized string representation of a number of b.
Assumes `from __future__ import division`.
>>> humanize_bytes(1)
'1 byte'
>>> humanize_bytes(1024)
'1.0 kB'
>>> humanize_bytes(1024*123)
'123.0 kB'
>>> humanize_bytes(1024*12342)
'... | [
"def",
"humanize_bytes",
"(",
"b",
",",
"precision",
"=",
"1",
")",
":",
"# abbrevs = (",
"# (1 << 50L, 'PB'),",
"# (1 << 40L, 'TB'),",
"# (1 << 30L, 'GB'),",
"# (1 << 20L, 'MB'),",
"# (1 << 10L, 'kB'),",
"# (1, 'b')",
"# )",
"abbrevs",
"=",
"(",
"("... | Return a humanized string representation of a number of b.
Assumes `from __future__ import division`.
>>> humanize_bytes(1)
'1 byte'
>>> humanize_bytes(1024)
'1.0 kB'
>>> humanize_bytes(1024*123)
'123.0 kB'
>>> humanize_bytes(1024*12342)
'12.1 MB'
>>> humanize_bytes(1024*12342,... | [
"Return",
"a",
"humanized",
"string",
"representation",
"of",
"a",
"number",
"of",
"b",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/core.py#L295-L339 |
jepegit/cellpy | cellpy/readers/core.py | xldate_as_datetime | def xldate_as_datetime(xldate, datemode=0, option="to_datetime"):
"""Converts a xls date stamp to a more sensible format.
Args:
xldate (str): date stamp in Excel format.
datemode (int): 0 for 1900-based, 1 for 1904-based.
option (str): option in ("to_datetime", "to_float", "to_string"),... | python | def xldate_as_datetime(xldate, datemode=0, option="to_datetime"):
"""Converts a xls date stamp to a more sensible format.
Args:
xldate (str): date stamp in Excel format.
datemode (int): 0 for 1900-based, 1 for 1904-based.
option (str): option in ("to_datetime", "to_float", "to_string"),... | [
"def",
"xldate_as_datetime",
"(",
"xldate",
",",
"datemode",
"=",
"0",
",",
"option",
"=",
"\"to_datetime\"",
")",
":",
"# This does not work for numpy-arrays",
"if",
"option",
"==",
"\"to_float\"",
":",
"d",
"=",
"(",
"xldate",
"-",
"25589",
")",
"*",
"86400.... | Converts a xls date stamp to a more sensible format.
Args:
xldate (str): date stamp in Excel format.
datemode (int): 0 for 1900-based, 1 for 1904-based.
option (str): option in ("to_datetime", "to_float", "to_string"),
return value
Returns:
datetime (datetime object... | [
"Converts",
"a",
"xls",
"date",
"stamp",
"to",
"a",
"more",
"sensible",
"format",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/core.py#L342-L372 |
jepegit/cellpy | cellpy/readers/core.py | FileID.populate | def populate(self, filename):
"""Finds the file-stats and populates the class with stat values.
Args:
filename (str): name of the file.
"""
if os.path.isfile(filename):
fid_st = os.stat(filename)
self.name = os.path.abspath(filename)
self... | python | def populate(self, filename):
"""Finds the file-stats and populates the class with stat values.
Args:
filename (str): name of the file.
"""
if os.path.isfile(filename):
fid_st = os.stat(filename)
self.name = os.path.abspath(filename)
self... | [
"def",
"populate",
"(",
"self",
",",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"fid_st",
"=",
"os",
".",
"stat",
"(",
"filename",
")",
"self",
".",
"name",
"=",
"os",
".",
"path",
".",
"abspath",
"("... | Finds the file-stats and populates the class with stat values.
Args:
filename (str): name of the file. | [
"Finds",
"the",
"file",
"-",
"stats",
"and",
"populates",
"the",
"class",
"with",
"stat",
"values",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/core.py#L81-L96 |
jepegit/cellpy | cellpy/readers/core.py | FileID.get_raw | def get_raw(self):
"""Get a list with information about the file.
The returned list contains name, size, last_modified and location.
"""
return [self.name, self.size, self.last_modified, self.location] | python | def get_raw(self):
"""Get a list with information about the file.
The returned list contains name, size, last_modified and location.
"""
return [self.name, self.size, self.last_modified, self.location] | [
"def",
"get_raw",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"name",
",",
"self",
".",
"size",
",",
"self",
".",
"last_modified",
",",
"self",
".",
"location",
"]"
] | Get a list with information about the file.
The returned list contains name, size, last_modified and location. | [
"Get",
"a",
"list",
"with",
"information",
"about",
"the",
"file",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/core.py#L98-L103 |
jepegit/cellpy | cellpy/readers/core.py | DataSet.dfsummary_made | def dfsummary_made(self):
"""check if the summary table exists"""
try:
empty = self.dfsummary.empty
except AttributeError:
empty = True
return not empty | python | def dfsummary_made(self):
"""check if the summary table exists"""
try:
empty = self.dfsummary.empty
except AttributeError:
empty = True
return not empty | [
"def",
"dfsummary_made",
"(",
"self",
")",
":",
"try",
":",
"empty",
"=",
"self",
".",
"dfsummary",
".",
"empty",
"except",
"AttributeError",
":",
"empty",
"=",
"True",
"return",
"not",
"empty"
] | check if the summary table exists | [
"check",
"if",
"the",
"summary",
"table",
"exists"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/core.py#L243-L249 |
jepegit/cellpy | cellpy/readers/core.py | DataSet.step_table_made | def step_table_made(self):
"""check if the step table exists"""
try:
empty = self.step_table.empty
except AttributeError:
empty = True
return not empty | python | def step_table_made(self):
"""check if the step table exists"""
try:
empty = self.step_table.empty
except AttributeError:
empty = True
return not empty | [
"def",
"step_table_made",
"(",
"self",
")",
":",
"try",
":",
"empty",
"=",
"self",
".",
"step_table",
".",
"empty",
"except",
"AttributeError",
":",
"empty",
"=",
"True",
"return",
"not",
"empty"
] | check if the step table exists | [
"check",
"if",
"the",
"step",
"table",
"exists"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/core.py#L252-L258 |
jepegit/cellpy | cellpy/readers/dbreader.py | Reader._open_sheet | def _open_sheet(self, dtypes_dict=None):
"""Opens sheets and returns it"""
table_name = self.db_sheet_table
header_row = self.db_header_row
nrows = self.nrows
if dtypes_dict is None:
dtypes_dict = self.dtypes_dict
rows_to_skip = self.skiprows
logging... | python | def _open_sheet(self, dtypes_dict=None):
"""Opens sheets and returns it"""
table_name = self.db_sheet_table
header_row = self.db_header_row
nrows = self.nrows
if dtypes_dict is None:
dtypes_dict = self.dtypes_dict
rows_to_skip = self.skiprows
logging... | [
"def",
"_open_sheet",
"(",
"self",
",",
"dtypes_dict",
"=",
"None",
")",
":",
"table_name",
"=",
"self",
".",
"db_sheet_table",
"header_row",
"=",
"self",
".",
"db_header_row",
"nrows",
"=",
"self",
".",
"nrows",
"if",
"dtypes_dict",
"is",
"None",
":",
"dt... | Opens sheets and returns it | [
"Opens",
"sheets",
"and",
"returns",
"it"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/dbreader.py#L122-L151 |
jepegit/cellpy | cellpy/readers/dbreader.py | Reader._validate | def _validate(self):
"""Checks that the db-file is ok
Returns:
True if OK, False if not.
"""
probably_good_to_go = True
sheet = self.table
identity = self.db_sheet_cols.id
# check if you have unique srnos
id_col = sheet.loc[:, identity]
... | python | def _validate(self):
"""Checks that the db-file is ok
Returns:
True if OK, False if not.
"""
probably_good_to_go = True
sheet = self.table
identity = self.db_sheet_cols.id
# check if you have unique srnos
id_col = sheet.loc[:, identity]
... | [
"def",
"_validate",
"(",
"self",
")",
":",
"probably_good_to_go",
"=",
"True",
"sheet",
"=",
"self",
".",
"table",
"identity",
"=",
"self",
".",
"db_sheet_cols",
".",
"id",
"# check if you have unique srnos",
"id_col",
"=",
"sheet",
".",
"loc",
"[",
":",
","... | Checks that the db-file is ok
Returns:
True if OK, False if not. | [
"Checks",
"that",
"the",
"db",
"-",
"file",
"is",
"ok"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/dbreader.py#L153-L172 |
jepegit/cellpy | cellpy/readers/dbreader.py | Reader.select_serial_number_row | def select_serial_number_row(self, serial_number):
"""Select row for identification number serial_number
Args:
serial_number: serial number
Returns:
pandas.DataFrame
"""
sheet = self.table
col = self.db_sheet_cols.id
rows = sheet.loc[:, c... | python | def select_serial_number_row(self, serial_number):
"""Select row for identification number serial_number
Args:
serial_number: serial number
Returns:
pandas.DataFrame
"""
sheet = self.table
col = self.db_sheet_cols.id
rows = sheet.loc[:, c... | [
"def",
"select_serial_number_row",
"(",
"self",
",",
"serial_number",
")",
":",
"sheet",
"=",
"self",
".",
"table",
"col",
"=",
"self",
".",
"db_sheet_cols",
".",
"id",
"rows",
"=",
"sheet",
".",
"loc",
"[",
":",
",",
"col",
"]",
"==",
"serial_number",
... | Select row for identification number serial_number
Args:
serial_number: serial number
Returns:
pandas.DataFrame | [
"Select",
"row",
"for",
"identification",
"number",
"serial_number"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/dbreader.py#L182-L194 |
jepegit/cellpy | cellpy/readers/dbreader.py | Reader.select_all | def select_all(self, serial_numbers):
"""Select rows for identification for a list of serial_number.
Args:
serial_numbers: list (or ndarray) of serial numbers
Returns:
pandas.DataFrame
"""
sheet = self.table
col = self.db_sheet_cols.id
ro... | python | def select_all(self, serial_numbers):
"""Select rows for identification for a list of serial_number.
Args:
serial_numbers: list (or ndarray) of serial numbers
Returns:
pandas.DataFrame
"""
sheet = self.table
col = self.db_sheet_cols.id
ro... | [
"def",
"select_all",
"(",
"self",
",",
"serial_numbers",
")",
":",
"sheet",
"=",
"self",
".",
"table",
"col",
"=",
"self",
".",
"db_sheet_cols",
".",
"id",
"rows",
"=",
"sheet",
".",
"loc",
"[",
":",
",",
"col",
"]",
".",
"isin",
"(",
"serial_numbers... | Select rows for identification for a list of serial_number.
Args:
serial_numbers: list (or ndarray) of serial numbers
Returns:
pandas.DataFrame | [
"Select",
"rows",
"for",
"identification",
"for",
"a",
"list",
"of",
"serial_number",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/dbreader.py#L196-L208 |
jepegit/cellpy | cellpy/readers/dbreader.py | Reader.print_serial_number_info | def print_serial_number_info(self, serial_number, print_to_screen=True):
"""Print information about the run.
Args:
serial_number: serial number.
print_to_screen: runs the print statement if True,
returns txt if not.
Returns:
txt if print_to_s... | python | def print_serial_number_info(self, serial_number, print_to_screen=True):
"""Print information about the run.
Args:
serial_number: serial number.
print_to_screen: runs the print statement if True,
returns txt if not.
Returns:
txt if print_to_s... | [
"def",
"print_serial_number_info",
"(",
"self",
",",
"serial_number",
",",
"print_to_screen",
"=",
"True",
")",
":",
"r",
"=",
"self",
".",
"select_serial_number_row",
"(",
"serial_number",
")",
"if",
"r",
".",
"empty",
":",
"warnings",
".",
"warn",
"(",
"\"... | Print information about the run.
Args:
serial_number: serial number.
print_to_screen: runs the print statement if True,
returns txt if not.
Returns:
txt if print_to_screen is False, else None. | [
"Print",
"information",
"about",
"the",
"run",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/dbreader.py#L210-L244 |
jepegit/cellpy | cellpy/readers/dbreader.py | Reader.filter_by_slurry | def filter_by_slurry(self, slurry, appender="_"):
"""Filters sheet/table by slurry name.
Input is slurry name or list of slurry names, for example 'es030' or
["es012","es033","es031"].
Args:
slurry (str or list of strings): slurry names.
appender (chr): char tha... | python | def filter_by_slurry(self, slurry, appender="_"):
"""Filters sheet/table by slurry name.
Input is slurry name or list of slurry names, for example 'es030' or
["es012","es033","es031"].
Args:
slurry (str or list of strings): slurry names.
appender (chr): char tha... | [
"def",
"filter_by_slurry",
"(",
"self",
",",
"slurry",
",",
"appender",
"=",
"\"_\"",
")",
":",
"sheet",
"=",
"self",
".",
"table",
"identity",
"=",
"self",
".",
"db_sheet_cols",
".",
"id",
"exists",
"=",
"self",
".",
"db_sheet_cols",
".",
"exists",
"cel... | Filters sheet/table by slurry name.
Input is slurry name or list of slurry names, for example 'es030' or
["es012","es033","es031"].
Args:
slurry (str or list of strings): slurry names.
appender (chr): char that surrounds slurry names.
Returns:
List ... | [
"Filters",
"sheet",
"/",
"table",
"by",
"slurry",
"name",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/dbreader.py#L361-L400 |
jepegit/cellpy | cellpy/readers/dbreader.py | Reader.filter_by_col | def filter_by_col(self, column_names):
"""filters sheet/table by columns (input is column header)
The routine returns the serial numbers with values>1 in the selected
columns.
Args:
column_names (list): the column headers.
Returns:
pandas.DataFrame
... | python | def filter_by_col(self, column_names):
"""filters sheet/table by columns (input is column header)
The routine returns the serial numbers with values>1 in the selected
columns.
Args:
column_names (list): the column headers.
Returns:
pandas.DataFrame
... | [
"def",
"filter_by_col",
"(",
"self",
",",
"column_names",
")",
":",
"if",
"not",
"isinstance",
"(",
"column_names",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"column_names",
"=",
"[",
"column_names",
",",
"]",
"sheet",
"=",
"self",
".",
"table",
"... | filters sheet/table by columns (input is column header)
The routine returns the serial numbers with values>1 in the selected
columns.
Args:
column_names (list): the column headers.
Returns:
pandas.DataFrame | [
"filters",
"sheet",
"/",
"table",
"by",
"columns",
"(",
"input",
"is",
"column",
"header",
")"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/dbreader.py#L402-L428 |
jepegit/cellpy | cellpy/readers/dbreader.py | Reader.filter_by_col_value | def filter_by_col_value(self, column_name,
min_val=None, max_val=None):
"""filters sheet/table by column.
The routine returns the serial-numbers with min_val <= values >= max_val
in the selected column.
Args:
column_name (str): column name.
... | python | def filter_by_col_value(self, column_name,
min_val=None, max_val=None):
"""filters sheet/table by column.
The routine returns the serial-numbers with min_val <= values >= max_val
in the selected column.
Args:
column_name (str): column name.
... | [
"def",
"filter_by_col_value",
"(",
"self",
",",
"column_name",
",",
"min_val",
"=",
"None",
",",
"max_val",
"=",
"None",
")",
":",
"sheet",
"=",
"self",
".",
"table",
"identity",
"=",
"self",
".",
"db_sheet_cols",
".",
"id",
"exists_col_number",
"=",
"self... | filters sheet/table by column.
The routine returns the serial-numbers with min_val <= values >= max_val
in the selected column.
Args:
column_name (str): column name.
min_val (int): minimum value of serial number.
max_val (int): maximum value of serial number... | [
"filters",
"sheet",
"/",
"table",
"by",
"column",
"."
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/dbreader.py#L430-L470 |
jepegit/cellpy | cellpy/readers/dbreader.py | Reader.select_batch | def select_batch(self, batch, batch_col_name=None):
"""selects the rows in column batch_col_number
(default: DbSheetCols.batch)"""
if not batch_col_name:
batch_col_name = self.db_sheet_cols.batch
logger.debug("selecting batch - %s" % batch)
sheet = self.table
... | python | def select_batch(self, batch, batch_col_name=None):
"""selects the rows in column batch_col_number
(default: DbSheetCols.batch)"""
if not batch_col_name:
batch_col_name = self.db_sheet_cols.batch
logger.debug("selecting batch - %s" % batch)
sheet = self.table
... | [
"def",
"select_batch",
"(",
"self",
",",
"batch",
",",
"batch_col_name",
"=",
"None",
")",
":",
"if",
"not",
"batch_col_name",
":",
"batch_col_name",
"=",
"self",
".",
"db_sheet_cols",
".",
"batch",
"logger",
".",
"debug",
"(",
"\"selecting batch - %s\"",
"%",... | selects the rows in column batch_col_number
(default: DbSheetCols.batch) | [
"selects",
"the",
"rows",
"in",
"column",
"batch_col_number",
"(",
"default",
":",
"DbSheetCols",
".",
"batch",
")"
] | train | https://github.com/jepegit/cellpy/blob/9f4a84cdd11f72cfa02cda8c2d7b5174abbb7370/cellpy/readers/dbreader.py#L472-L487 |
openstax/cnx-epub | cnxepub/scripts/collated_single_html/main.py | main | def main(argv=None):
"""Parse passed in cooked single HTML."""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('collated_html', type=argparse.FileType('r'),
help='Path to the collated html'
' file (use - for stdin)')
parser.a... | python | def main(argv=None):
"""Parse passed in cooked single HTML."""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('collated_html', type=argparse.FileType('r'),
help='Path to the collated html'
' file (use - for stdin)')
parser.a... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__doc__",
")",
"parser",
".",
"add_argument",
"(",
"'collated_html'",
",",
"type",
"=",
"argparse",
".",
"FileType",
"(",
"'r'",
... | Parse passed in cooked single HTML. | [
"Parse",
"passed",
"in",
"cooked",
"single",
"HTML",
"."
] | train | https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/scripts/collated_single_html/main.py#L28-L74 |
ModisWorks/modis | modis/discord_modis/modules/hex/ui_embed.py | success | def success(channel, image, hex_str):
"""
Creates an embed UI containing a hex color message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
image (str): The url of the image to add
hex_str (str): The hex value
Returns:
ui (ui_embed.UI): The em... | python | def success(channel, image, hex_str):
"""
Creates an embed UI containing a hex color message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
image (str): The url of the image to add
hex_str (str): The hex value
Returns:
ui (ui_embed.UI): The em... | [
"def",
"success",
"(",
"channel",
",",
"image",
",",
"hex_str",
")",
":",
"hex_number",
"=",
"int",
"(",
"hex_str",
",",
"16",
")",
"# Create embed UI object",
"gui",
"=",
"ui_embed",
".",
"UI",
"(",
"channel",
",",
"\"\"",
",",
"\"#{}\"",
".",
"format",... | Creates an embed UI containing a hex color message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
image (str): The url of the image to add
hex_str (str): The hex value
Returns:
ui (ui_embed.UI): The embed UI object that was created | [
"Creates",
"an",
"embed",
"UI",
"containing",
"a",
"hex",
"color",
"message"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/hex/ui_embed.py#L5-L30 |
ModisWorks/modis | GenerateReadme.py | add_md | def add_md(text, s, level=0):
"""Adds text to the readme at the given level"""
if level > 0:
if text != "":
text += "\n"
text += "#" * level
text += " "
text += s + "\n"
if level > 0:
text += "\n"
return text | python | def add_md(text, s, level=0):
"""Adds text to the readme at the given level"""
if level > 0:
if text != "":
text += "\n"
text += "#" * level
text += " "
text += s + "\n"
if level > 0:
text += "\n"
return text | [
"def",
"add_md",
"(",
"text",
",",
"s",
",",
"level",
"=",
"0",
")",
":",
"if",
"level",
">",
"0",
":",
"if",
"text",
"!=",
"\"\"",
":",
"text",
"+=",
"\"\\n\"",
"text",
"+=",
"\"#\"",
"*",
"level",
"text",
"+=",
"\" \"",
"text",
"+=",
"s",
"+"... | Adds text to the readme at the given level | [
"Adds",
"text",
"to",
"the",
"readme",
"at",
"the",
"given",
"level"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/GenerateReadme.py#L10-L23 |
ModisWorks/modis | GenerateReadme.py | add_ul | def add_ul(text, ul):
"""Adds an unordered list to the readme"""
text += "\n"
for li in ul:
text += "- " + li + "\n"
text += "\n"
return text | python | def add_ul(text, ul):
"""Adds an unordered list to the readme"""
text += "\n"
for li in ul:
text += "- " + li + "\n"
text += "\n"
return text | [
"def",
"add_ul",
"(",
"text",
",",
"ul",
")",
":",
"text",
"+=",
"\"\\n\"",
"for",
"li",
"in",
"ul",
":",
"text",
"+=",
"\"- \"",
"+",
"li",
"+",
"\"\\n\"",
"text",
"+=",
"\"\\n\"",
"return",
"text"
] | Adds an unordered list to the readme | [
"Adds",
"an",
"unordered",
"list",
"to",
"the",
"readme"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/GenerateReadme.py#L26-L33 |
freelawproject/reporters-db | reporters_db/make_csv.py | make_editions_dict | def make_editions_dict(editions):
"""Take a reporter editions dict and flatten it, returning a dict for
use in the DictWriter.
"""
d = {}
nums = ['1', '2', '3', '4', '5', '6']
num_counter = 0
for k, date_dict in editions.items():
d['edition%s' % nums[num_counter]] = k
if date... | python | def make_editions_dict(editions):
"""Take a reporter editions dict and flatten it, returning a dict for
use in the DictWriter.
"""
d = {}
nums = ['1', '2', '3', '4', '5', '6']
num_counter = 0
for k, date_dict in editions.items():
d['edition%s' % nums[num_counter]] = k
if date... | [
"def",
"make_editions_dict",
"(",
"editions",
")",
":",
"d",
"=",
"{",
"}",
"nums",
"=",
"[",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
"]",
"num_counter",
"=",
"0",
"for",
"k",
",",
"date_dict",
"in",
"editions",
".",
"i... | Take a reporter editions dict and flatten it, returning a dict for
use in the DictWriter. | [
"Take",
"a",
"reporter",
"editions",
"dict",
"and",
"flatten",
"it",
"returning",
"a",
"dict",
"for",
"use",
"in",
"the",
"DictWriter",
"."
] | train | https://github.com/freelawproject/reporters-db/blob/ee17ee38a4e39de8d83beb78d84d146cd7e8afbc/reporters_db/make_csv.py#L15-L31 |
ModisWorks/modis | modis/discord_modis/modules/rocketleague/on_message.py | on_message | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | python | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | [
"async",
"def",
"on_message",
"(",
"message",
")",
":",
"# Simplify message info",
"server",
"=",
"message",
".",
"server",
"author",
"=",
"message",
".",
"author",
"channel",
"=",
"message",
".",
"channel",
"content",
"=",
"message",
".",
"content",
"data",
... | The on_message event handler for this module
Args:
message (discord.Message): Input message | [
"The",
"on_message",
"event",
"handler",
"for",
"this",
"module"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/rocketleague/on_message.py#L6-L66 |
ModisWorks/modis | modis/discord_modis/modules/music/_ui.py | ModuleUIFrame.update_keys | def update_keys(self):
"""Updates the Google API key with the text value"""
from ...main import add_api_key
add_api_key("google_api_key", self.google_api_key.get())
add_api_key("soundcloud_client_id", self.soundcloud_client_id.get()) | python | def update_keys(self):
"""Updates the Google API key with the text value"""
from ...main import add_api_key
add_api_key("google_api_key", self.google_api_key.get())
add_api_key("soundcloud_client_id", self.soundcloud_client_id.get()) | [
"def",
"update_keys",
"(",
"self",
")",
":",
"from",
".",
".",
".",
"main",
"import",
"add_api_key",
"add_api_key",
"(",
"\"google_api_key\"",
",",
"self",
".",
"google_api_key",
".",
"get",
"(",
")",
")",
"add_api_key",
"(",
"\"soundcloud_client_id\"",
",",
... | Updates the Google API key with the text value | [
"Updates",
"the",
"Google",
"API",
"key",
"with",
"the",
"text",
"value"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_ui.py#L48-L52 |
ModisWorks/modis | modis/discord_modis/modules/manager/ui_embed.py | modify_module | def modify_module(channel, module_name, module_state):
"""
Creates an embed UI containing the module modified message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
module_name (str): The name of the module that was updated
module_state (bool): The current... | python | def modify_module(channel, module_name, module_state):
"""
Creates an embed UI containing the module modified message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
module_name (str): The name of the module that was updated
module_state (bool): The current... | [
"def",
"modify_module",
"(",
"channel",
",",
"module_name",
",",
"module_state",
")",
":",
"# Create embed UI object",
"gui",
"=",
"ui_embed",
".",
"UI",
"(",
"channel",
",",
"\"{} updated\"",
".",
"format",
"(",
"module_name",
")",
",",
"\"{} is now {}\"",
".",... | Creates an embed UI containing the module modified message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
module_name (str): The name of the module that was updated
module_state (bool): The current state of the module
Returns:
embed: The created embed | [
"Creates",
"an",
"embed",
"UI",
"containing",
"the",
"module",
"modified",
"message"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/manager/ui_embed.py#L7-L28 |
ModisWorks/modis | modis/discord_modis/modules/manager/ui_embed.py | modify_prefix | def modify_prefix(channel, new_prefix):
"""
Creates an embed UI containing the prefix modified message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
new_prefix (str): The value of the new prefix
Returns:
embed: The created embed
"""
# Create... | python | def modify_prefix(channel, new_prefix):
"""
Creates an embed UI containing the prefix modified message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
new_prefix (str): The value of the new prefix
Returns:
embed: The created embed
"""
# Create... | [
"def",
"modify_prefix",
"(",
"channel",
",",
"new_prefix",
")",
":",
"# Create embed UI object",
"gui",
"=",
"ui_embed",
".",
"UI",
"(",
"channel",
",",
"\"Prefix updated\"",
",",
"\"Modis prefix is now `{}`\"",
".",
"format",
"(",
"new_prefix",
")",
",",
"modulen... | Creates an embed UI containing the prefix modified message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
new_prefix (str): The value of the new prefix
Returns:
embed: The created embed | [
"Creates",
"an",
"embed",
"UI",
"containing",
"the",
"prefix",
"modified",
"message"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/manager/ui_embed.py#L31-L51 |
ModisWorks/modis | modis/discord_modis/modules/manager/ui_embed.py | user_warning | def user_warning(channel, user, warnings, max_warnings):
"""
Creates an embed UI containing an user warning message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
user (discord.User): The user to warn
warnings (str): The warnings for the user
max_w... | python | def user_warning(channel, user, warnings, max_warnings):
"""
Creates an embed UI containing an user warning message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
user (discord.User): The user to warn
warnings (str): The warnings for the user
max_w... | [
"def",
"user_warning",
"(",
"channel",
",",
"user",
",",
"warnings",
",",
"max_warnings",
")",
":",
"username",
"=",
"user",
".",
"name",
"if",
"isinstance",
"(",
"user",
",",
"discord",
".",
"Member",
")",
":",
"if",
"user",
".",
"nick",
"is",
"not",
... | Creates an embed UI containing an user warning message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
user (discord.User): The user to warn
warnings (str): The warnings for the user
max_warnings (str): The maximum warnings for the user
Returns:
... | [
"Creates",
"an",
"embed",
"UI",
"containing",
"an",
"user",
"warning",
"message"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/manager/ui_embed.py#L54-L87 |
ModisWorks/modis | modis/discord_modis/modules/manager/ui_embed.py | user_ban | def user_ban(channel, user):
"""
Creates an embed UI containing an user warning message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
user (discord.User): The user to ban
Returns:
ui (ui_embed.UI): The embed UI object
"""
username = user.nam... | python | def user_ban(channel, user):
"""
Creates an embed UI containing an user warning message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
user (discord.User): The user to ban
Returns:
ui (ui_embed.UI): The embed UI object
"""
username = user.nam... | [
"def",
"user_ban",
"(",
"channel",
",",
"user",
")",
":",
"username",
"=",
"user",
".",
"name",
"if",
"isinstance",
"(",
"user",
",",
"discord",
".",
"Member",
")",
":",
"if",
"user",
".",
"nick",
"is",
"not",
"None",
":",
"username",
"=",
"user",
... | Creates an embed UI containing an user warning message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
user (discord.User): The user to ban
Returns:
ui (ui_embed.UI): The embed UI object | [
"Creates",
"an",
"embed",
"UI",
"containing",
"an",
"user",
"warning",
"message"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/manager/ui_embed.py#L90-L115 |
ModisWorks/modis | modis/discord_modis/modules/manager/ui_embed.py | warning_max_changed | def warning_max_changed(channel, max_warnings):
"""
Creates an embed UI containing an error message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
max_warnings (int): The new maximum warnings
Returns:
ui (ui_embed.UI): The embed UI object
"""
... | python | def warning_max_changed(channel, max_warnings):
"""
Creates an embed UI containing an error message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
max_warnings (int): The new maximum warnings
Returns:
ui (ui_embed.UI): The embed UI object
"""
... | [
"def",
"warning_max_changed",
"(",
"channel",
",",
"max_warnings",
")",
":",
"# Create embed UI object",
"gui",
"=",
"ui_embed",
".",
"UI",
"(",
"channel",
",",
"\"Maximum Warnings Changed\"",
",",
"\"Users must now have {} warnings to be banned \"",
"\"(this won't ban existi... | Creates an embed UI containing an error message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
max_warnings (int): The new maximum warnings
Returns:
ui (ui_embed.UI): The embed UI object | [
"Creates",
"an",
"embed",
"UI",
"containing",
"an",
"error",
"message"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/manager/ui_embed.py#L118-L139 |
ModisWorks/modis | modis/discord_modis/modules/manager/ui_embed.py | error | def error(channel, title, description):
"""
Creates an embed UI containing an error message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
title (str): The title of the embed
description (str): The description for the error
Returns:
ui (ui_emb... | python | def error(channel, title, description):
"""
Creates an embed UI containing an error message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
title (str): The title of the embed
description (str): The description for the error
Returns:
ui (ui_emb... | [
"def",
"error",
"(",
"channel",
",",
"title",
",",
"description",
")",
":",
"# Create embed UI object",
"gui",
"=",
"ui_embed",
".",
"UI",
"(",
"channel",
",",
"title",
",",
"description",
",",
"modulename",
"=",
"modulename",
")",
"return",
"gui"
] | Creates an embed UI containing an error message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
title (str): The title of the embed
description (str): The description for the error
Returns:
ui (ui_embed.UI): The embed UI object | [
"Creates",
"an",
"embed",
"UI",
"containing",
"an",
"error",
"message"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/manager/ui_embed.py#L142-L163 |
ModisWorks/modis | modis/discord_modis/modules/!core/api_core.py | update_server_data | async def update_server_data(server):
"""
Updates the server info for the given server
Args:
server: The Discord server to update info for
"""
data = datatools.get_data()
# Add the server to server data if it doesn't yet exist
send_welcome_message = False
if server.id not in da... | python | async def update_server_data(server):
"""
Updates the server info for the given server
Args:
server: The Discord server to update info for
"""
data = datatools.get_data()
# Add the server to server data if it doesn't yet exist
send_welcome_message = False
if server.id not in da... | [
"async",
"def",
"update_server_data",
"(",
"server",
")",
":",
"data",
"=",
"datatools",
".",
"get_data",
"(",
")",
"# Add the server to server data if it doesn't yet exist",
"send_welcome_message",
"=",
"False",
"if",
"server",
".",
"id",
"not",
"in",
"data",
"[",
... | Updates the server info for the given server
Args:
server: The Discord server to update info for | [
"Updates",
"the",
"server",
"info",
"for",
"the",
"given",
"server"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/!core/api_core.py#L10-L76 |
ModisWorks/modis | modis/discord_modis/modules/!core/api_core.py | remove_server_data | def remove_server_data(server_id):
"""
Remove a server from the server data
Args:
server_id (int): The server to remove from the server data
"""
logger.debug("Removing server from serverdata")
# Remove the server from data
data = datatools.get_data()
if server_id in data["disco... | python | def remove_server_data(server_id):
"""
Remove a server from the server data
Args:
server_id (int): The server to remove from the server data
"""
logger.debug("Removing server from serverdata")
# Remove the server from data
data = datatools.get_data()
if server_id in data["disco... | [
"def",
"remove_server_data",
"(",
"server_id",
")",
":",
"logger",
".",
"debug",
"(",
"\"Removing server from serverdata\"",
")",
"# Remove the server from data",
"data",
"=",
"datatools",
".",
"get_data",
"(",
")",
"if",
"server_id",
"in",
"data",
"[",
"\"discord\"... | Remove a server from the server data
Args:
server_id (int): The server to remove from the server data | [
"Remove",
"a",
"server",
"from",
"the",
"server",
"data"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/!core/api_core.py#L79-L92 |
ModisWorks/modis | modis/discord_modis/modules/!core/api_core.py | check_all_servers | def check_all_servers():
"""Checks all servers, removing any that Modis isn't part of any more"""
data = datatools.get_data()
for server_id in data["discord"]["servers"]:
is_in_client = False
for client_server in client.servers:
if server_id == client_server.id:
i... | python | def check_all_servers():
"""Checks all servers, removing any that Modis isn't part of any more"""
data = datatools.get_data()
for server_id in data["discord"]["servers"]:
is_in_client = False
for client_server in client.servers:
if server_id == client_server.id:
i... | [
"def",
"check_all_servers",
"(",
")",
":",
"data",
"=",
"datatools",
".",
"get_data",
"(",
")",
"for",
"server_id",
"in",
"data",
"[",
"\"discord\"",
"]",
"[",
"\"servers\"",
"]",
":",
"is_in_client",
"=",
"False",
"for",
"client_server",
"in",
"client",
"... | Checks all servers, removing any that Modis isn't part of any more | [
"Checks",
"all",
"servers",
"removing",
"any",
"that",
"Modis",
"isn",
"t",
"part",
"of",
"any",
"more"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/!core/api_core.py#L95-L106 |
ModisWorks/modis | modis/discord_modis/gui.py | ModuleFrame.clear_modules | def clear_modules(self):
"""Clears all modules from the list"""
for child in self.module_selection.winfo_children():
child.destroy()
self.clear_ui()
tk.Label(self.module_ui, text="Start Modis and select a module").grid(
column=0, row=0, padx=0, pady=0, sticky="W... | python | def clear_modules(self):
"""Clears all modules from the list"""
for child in self.module_selection.winfo_children():
child.destroy()
self.clear_ui()
tk.Label(self.module_ui, text="Start Modis and select a module").grid(
column=0, row=0, padx=0, pady=0, sticky="W... | [
"def",
"clear_modules",
"(",
"self",
")",
":",
"for",
"child",
"in",
"self",
".",
"module_selection",
".",
"winfo_children",
"(",
")",
":",
"child",
".",
"destroy",
"(",
")",
"self",
".",
"clear_ui",
"(",
")",
"tk",
".",
"Label",
"(",
"self",
".",
"m... | Clears all modules from the list | [
"Clears",
"all",
"modules",
"from",
"the",
"list"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/gui.py#L137-L151 |
ModisWorks/modis | modis/discord_modis/gui.py | ModuleFrame.add_module | def add_module(self, module_name, module_ui):
"""
Adds a module to the list
Args:
module_name (str): The name of the module
module_ui: The function to call to create the module's UI
"""
m_button = tk.Label(self.module_selection, text=module_name, bg="whit... | python | def add_module(self, module_name, module_ui):
"""
Adds a module to the list
Args:
module_name (str): The name of the module
module_ui: The function to call to create the module's UI
"""
m_button = tk.Label(self.module_selection, text=module_name, bg="whit... | [
"def",
"add_module",
"(",
"self",
",",
"module_name",
",",
"module_ui",
")",
":",
"m_button",
"=",
"tk",
".",
"Label",
"(",
"self",
".",
"module_selection",
",",
"text",
"=",
"module_name",
",",
"bg",
"=",
"\"white\"",
",",
"anchor",
"=",
"\"w\"",
")",
... | Adds a module to the list
Args:
module_name (str): The name of the module
module_ui: The function to call to create the module's UI | [
"Adds",
"a",
"module",
"to",
"the",
"list"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/gui.py#L158-L170 |
ModisWorks/modis | modis/discord_modis/gui.py | ModuleFrame.module_selected | def module_selected(self, module_name, module_ui):
"""
Called when a module is selected
Args:
module_name (str): The name of the module
module_ui: The function to call to create the module's UI
"""
if self.current_button == self.module_buttons[module_name... | python | def module_selected(self, module_name, module_ui):
"""
Called when a module is selected
Args:
module_name (str): The name of the module
module_ui: The function to call to create the module's UI
"""
if self.current_button == self.module_buttons[module_name... | [
"def",
"module_selected",
"(",
"self",
",",
"module_name",
",",
"module_ui",
")",
":",
"if",
"self",
".",
"current_button",
"==",
"self",
".",
"module_buttons",
"[",
"module_name",
"]",
":",
"return",
"self",
".",
"module_buttons",
"[",
"module_name",
"]",
"... | Called when a module is selected
Args:
module_name (str): The name of the module
module_ui: The function to call to create the module's UI | [
"Called",
"when",
"a",
"module",
"is",
"selected"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/gui.py#L172-L199 |
ModisWorks/modis | modis/discord_modis/gui.py | BotControl.toggle | def toggle(self, discord_token, discord_client_id):
"""Toggles Modis on or off"""
if self.state == 'off':
self.start(discord_token, discord_client_id)
elif self.state == 'on':
self.stop() | python | def toggle(self, discord_token, discord_client_id):
"""Toggles Modis on or off"""
if self.state == 'off':
self.start(discord_token, discord_client_id)
elif self.state == 'on':
self.stop() | [
"def",
"toggle",
"(",
"self",
",",
"discord_token",
",",
"discord_client_id",
")",
":",
"if",
"self",
".",
"state",
"==",
"'off'",
":",
"self",
".",
"start",
"(",
"discord_token",
",",
"discord_client_id",
")",
"elif",
"self",
".",
"state",
"==",
"'on'",
... | Toggles Modis on or off | [
"Toggles",
"Modis",
"on",
"or",
"off"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/gui.py#L295-L300 |
ModisWorks/modis | modis/discord_modis/gui.py | BotControl.start | def start(self, discord_token, discord_client_id):
"""Start Modis and log it into Discord."""
self.button_toggle_text.set("Stop Modis")
self.state = "on"
self.status_bar.set_status(1)
logger.info("----------------STARTING DISCORD MODIS----------------")
# Clear the mod... | python | def start(self, discord_token, discord_client_id):
"""Start Modis and log it into Discord."""
self.button_toggle_text.set("Stop Modis")
self.state = "on"
self.status_bar.set_status(1)
logger.info("----------------STARTING DISCORD MODIS----------------")
# Clear the mod... | [
"def",
"start",
"(",
"self",
",",
"discord_token",
",",
"discord_client_id",
")",
":",
"self",
".",
"button_toggle_text",
".",
"set",
"(",
"\"Stop Modis\"",
")",
"self",
".",
"state",
"=",
"\"on\"",
"self",
".",
"status_bar",
".",
"set_status",
"(",
"1",
"... | Start Modis and log it into Discord. | [
"Start",
"Modis",
"and",
"log",
"it",
"into",
"Discord",
"."
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/gui.py#L302-L344 |
ModisWorks/modis | modis/discord_modis/gui.py | BotControl.stop | def stop(self):
"""Stop Modis and log it out of Discord."""
self.button_toggle_text.set("Start Modis")
self.state = "off"
logger.info("Stopping Discord Modis")
from ._client import client
asyncio.run_coroutine_threadsafe(client.logout(), client.loop)
self.status... | python | def stop(self):
"""Stop Modis and log it out of Discord."""
self.button_toggle_text.set("Start Modis")
self.state = "off"
logger.info("Stopping Discord Modis")
from ._client import client
asyncio.run_coroutine_threadsafe(client.logout(), client.loop)
self.status... | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"button_toggle_text",
".",
"set",
"(",
"\"Start Modis\"",
")",
"self",
".",
"state",
"=",
"\"off\"",
"logger",
".",
"info",
"(",
"\"Stopping Discord Modis\"",
")",
"from",
".",
"_client",
"import",
"client",... | Stop Modis and log it out of Discord. | [
"Stop",
"Modis",
"and",
"log",
"it",
"out",
"of",
"Discord",
"."
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/gui.py#L350-L359 |
ModisWorks/modis | modis/discord_modis/gui.py | BotControl.key_changed | def key_changed(self):
"""Checks if the key name and value fields have been set, and updates the add key button"""
if self.key_name.get() and self.key_val.get():
self.button_key_add.state(["!disabled"])
else:
self.button_key_add.state(["disabled"]) | python | def key_changed(self):
"""Checks if the key name and value fields have been set, and updates the add key button"""
if self.key_name.get() and self.key_val.get():
self.button_key_add.state(["!disabled"])
else:
self.button_key_add.state(["disabled"]) | [
"def",
"key_changed",
"(",
"self",
")",
":",
"if",
"self",
".",
"key_name",
".",
"get",
"(",
")",
"and",
"self",
".",
"key_val",
".",
"get",
"(",
")",
":",
"self",
".",
"button_key_add",
".",
"state",
"(",
"[",
"\"!disabled\"",
"]",
")",
"else",
":... | Checks if the key name and value fields have been set, and updates the add key button | [
"Checks",
"if",
"the",
"key",
"name",
"and",
"value",
"fields",
"have",
"been",
"set",
"and",
"updates",
"the",
"add",
"key",
"button"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/gui.py#L361-L366 |
ModisWorks/modis | modis/discord_modis/gui.py | BotControl.key_add | def key_add(self):
"""Adds the current API key to the bot's data"""
from .main import add_api_key
add_api_key(self.key_name.get(), self.key_val.get())
# Clear the text fields
self.key_name.set("")
self.key_val.set("") | python | def key_add(self):
"""Adds the current API key to the bot's data"""
from .main import add_api_key
add_api_key(self.key_name.get(), self.key_val.get())
# Clear the text fields
self.key_name.set("")
self.key_val.set("") | [
"def",
"key_add",
"(",
"self",
")",
":",
"from",
".",
"main",
"import",
"add_api_key",
"add_api_key",
"(",
"self",
".",
"key_name",
".",
"get",
"(",
")",
",",
"self",
".",
"key_val",
".",
"get",
"(",
")",
")",
"# Clear the text fields",
"self",
".",
"k... | Adds the current API key to the bot's data | [
"Adds",
"the",
"current",
"API",
"key",
"to",
"the",
"bot",
"s",
"data"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/gui.py#L368-L375 |
ModisWorks/modis | modis/discord_modis/gui.py | StatusBar.set_status | def set_status(self, status):
"""
Updates the status text
Args:
status (int): The offline/starting/online status of Modis
0: offline, 1: starting, 2: online
"""
text = ""
colour = "#FFFFFF"
if status == 0:
text = "OFFLINE"... | python | def set_status(self, status):
"""
Updates the status text
Args:
status (int): The offline/starting/online status of Modis
0: offline, 1: starting, 2: online
"""
text = ""
colour = "#FFFFFF"
if status == 0:
text = "OFFLINE"... | [
"def",
"set_status",
"(",
"self",
",",
"status",
")",
":",
"text",
"=",
"\"\"",
"colour",
"=",
"\"#FFFFFF\"",
"if",
"status",
"==",
"0",
":",
"text",
"=",
"\"OFFLINE\"",
"colour",
"=",
"\"#EF9A9A\"",
"elif",
"status",
"==",
"1",
":",
"text",
"=",
"\"ST... | Updates the status text
Args:
status (int): The offline/starting/online status of Modis
0: offline, 1: starting, 2: online | [
"Updates",
"the",
"status",
"text"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/gui.py#L485-L507 |
ModisWorks/modis | modis/helptools.py | get_help_data | def get_help_data(filepath):
"""
Get the json data from a help file
Args:
filepath (str): The file path for the help file
Returns:
data: The json data from a help file
"""
try:
with open(filepath, 'r') as file:
return _json.load(file, object_pairs_hook=Orde... | python | def get_help_data(filepath):
"""
Get the json data from a help file
Args:
filepath (str): The file path for the help file
Returns:
data: The json data from a help file
"""
try:
with open(filepath, 'r') as file:
return _json.load(file, object_pairs_hook=Orde... | [
"def",
"get_help_data",
"(",
"filepath",
")",
":",
"try",
":",
"with",
"open",
"(",
"filepath",
",",
"'r'",
")",
"as",
"file",
":",
"return",
"_json",
".",
"load",
"(",
"file",
",",
"object_pairs_hook",
"=",
"OrderedDict",
")",
"except",
"Exception",
"as... | Get the json data from a help file
Args:
filepath (str): The file path for the help file
Returns:
data: The json data from a help file | [
"Get",
"the",
"json",
"data",
"from",
"a",
"help",
"file"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/helptools.py#L9-L26 |
ModisWorks/modis | modis/helptools.py | get_help_datapacks | def get_help_datapacks(filepath, prefix="!"):
"""
Load help text from a file and give it as datapacks
Args:
filepath (str): The file to load help text from
prefix (str): The prefix to use for commands
Returns:
datapacks (list): The datapacks from the file
"""
help_cont... | python | def get_help_datapacks(filepath, prefix="!"):
"""
Load help text from a file and give it as datapacks
Args:
filepath (str): The file to load help text from
prefix (str): The prefix to use for commands
Returns:
datapacks (list): The datapacks from the file
"""
help_cont... | [
"def",
"get_help_datapacks",
"(",
"filepath",
",",
"prefix",
"=",
"\"!\"",
")",
":",
"help_contents",
"=",
"get_help_data",
"(",
"filepath",
")",
"datapacks",
"=",
"[",
"]",
"# Add the content",
"for",
"d",
"in",
"help_contents",
":",
"heading",
"=",
"d",
"c... | Load help text from a file and give it as datapacks
Args:
filepath (str): The file to load help text from
prefix (str): The prefix to use for commands
Returns:
datapacks (list): The datapacks from the file | [
"Load",
"help",
"text",
"from",
"a",
"file",
"and",
"give",
"it",
"as",
"datapacks"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/helptools.py#L29-L70 |
ModisWorks/modis | modis/helptools.py | add_help_text | def add_help_text(parent, filepath, prefix="!"):
"""
Load help text from a file and adds it to the parent
Args:
parent: A tk or ttk object
filepath (str): The file to load help text from
prefix (str): The prefix to use for commands
"""
import tkinter as tk
import tkinte... | python | def add_help_text(parent, filepath, prefix="!"):
"""
Load help text from a file and adds it to the parent
Args:
parent: A tk or ttk object
filepath (str): The file to load help text from
prefix (str): The prefix to use for commands
"""
import tkinter as tk
import tkinte... | [
"def",
"add_help_text",
"(",
"parent",
",",
"filepath",
",",
"prefix",
"=",
"\"!\"",
")",
":",
"import",
"tkinter",
"as",
"tk",
"import",
"tkinter",
".",
"ttk",
"as",
"ttk",
"help_contents",
"=",
"get_help_data",
"(",
"filepath",
")",
"text",
"=",
"tk",
... | Load help text from a file and adds it to the parent
Args:
parent: A tk or ttk object
filepath (str): The file to load help text from
prefix (str): The prefix to use for commands | [
"Load",
"help",
"text",
"from",
"a",
"file",
"and",
"adds",
"it",
"to",
"the",
"parent"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/helptools.py#L73-L126 |
ModisWorks/modis | modis/discord_modis/modules/music/on_reaction_add.py | on_reaction_add | async def on_reaction_add(reaction, user):
"""The on_message event handler for this module
Args:
reaction (discord.Reaction): Input reaction
user (discord.User): The user that added the reaction
"""
# Simplify reaction info
server = reaction.message.server
emoji = reaction.emoj... | python | async def on_reaction_add(reaction, user):
"""The on_message event handler for this module
Args:
reaction (discord.Reaction): Input reaction
user (discord.User): The user that added the reaction
"""
# Simplify reaction info
server = reaction.message.server
emoji = reaction.emoj... | [
"async",
"def",
"on_reaction_add",
"(",
"reaction",
",",
"user",
")",
":",
"# Simplify reaction info",
"server",
"=",
"reaction",
".",
"message",
".",
"server",
"emoji",
"=",
"reaction",
".",
"emoji",
"data",
"=",
"datatools",
".",
"get_data",
"(",
")",
"if"... | The on_message event handler for this module
Args:
reaction (discord.Reaction): Input reaction
user (discord.User): The user that added the reaction | [
"The",
"on_message",
"event",
"handler",
"for",
"this",
"module"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/on_reaction_add.py#L9-L59 |
ModisWorks/modis | modis/__init__.py | console | def console(discord_token, discord_client_id):
"""
Start Modis in console format.
Args:
discord_token (str): The bot token for your Discord application
discord_client_id: The bot's client ID
"""
state, response = datatools.get_compare_version()
logger.info("Starting Modis in c... | python | def console(discord_token, discord_client_id):
"""
Start Modis in console format.
Args:
discord_token (str): The bot token for your Discord application
discord_client_id: The bot's client ID
"""
state, response = datatools.get_compare_version()
logger.info("Starting Modis in c... | [
"def",
"console",
"(",
"discord_token",
",",
"discord_client_id",
")",
":",
"state",
",",
"response",
"=",
"datatools",
".",
"get_compare_version",
"(",
")",
"logger",
".",
"info",
"(",
"\"Starting Modis in console\"",
")",
"logger",
".",
"info",
"(",
"response"... | Start Modis in console format.
Args:
discord_token (str): The bot token for your Discord application
discord_client_id: The bot's client ID | [
"Start",
"Modis",
"in",
"console",
"format",
"."
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/__init__.py#L40-L79 |
ModisWorks/modis | modis/__init__.py | gui | def gui(discord_token, discord_client_id):
"""
Start Modis in gui format.
Args:
discord_token (str): The bot token for your Discord application
discord_client_id: The bot's client ID
"""
logger.info("Starting Modis in GUI")
import tkinter as tk
logger.debug("Loading packa... | python | def gui(discord_token, discord_client_id):
"""
Start Modis in gui format.
Args:
discord_token (str): The bot token for your Discord application
discord_client_id: The bot's client ID
"""
logger.info("Starting Modis in GUI")
import tkinter as tk
logger.debug("Loading packa... | [
"def",
"gui",
"(",
"discord_token",
",",
"discord_client_id",
")",
":",
"logger",
".",
"info",
"(",
"\"Starting Modis in GUI\"",
")",
"import",
"tkinter",
"as",
"tk",
"logger",
".",
"debug",
"(",
"\"Loading packages\"",
")",
"from",
"modis",
".",
"discord_modis"... | Start Modis in gui format.
Args:
discord_token (str): The bot token for your Discord application
discord_client_id: The bot's client ID | [
"Start",
"Modis",
"in",
"gui",
"format",
"."
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/__init__.py#L82-L138 |
ModisWorks/modis | modis/datatools.py | write_data | def write_data(data):
"""
Write the data to the data.json file
Args:
data (dict): The updated data dictionary for Modis
"""
sorted_dict = sort_recursive(data)
with open(_datafile, 'w') as file:
_json.dump(sorted_dict, file, indent=2) | python | def write_data(data):
"""
Write the data to the data.json file
Args:
data (dict): The updated data dictionary for Modis
"""
sorted_dict = sort_recursive(data)
with open(_datafile, 'w') as file:
_json.dump(sorted_dict, file, indent=2) | [
"def",
"write_data",
"(",
"data",
")",
":",
"sorted_dict",
"=",
"sort_recursive",
"(",
"data",
")",
"with",
"open",
"(",
"_datafile",
",",
"'w'",
")",
"as",
"file",
":",
"_json",
".",
"dump",
"(",
"sorted_dict",
",",
"file",
",",
"indent",
"=",
"2",
... | Write the data to the data.json file
Args:
data (dict): The updated data dictionary for Modis | [
"Write",
"the",
"data",
"to",
"the",
"data",
".",
"json",
"file"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/datatools.py#L51-L62 |
ModisWorks/modis | modis/datatools.py | sort_recursive | def sort_recursive(data):
"""
Recursively sorts all elements in a dictionary
Args:
data (dict): The dictionary to sort
Returns:
sorted_dict (OrderedDict): The sorted data dict
"""
newdict = {}
for i in data.items():
if type(i[1]) is dict:
newdict[i[0]]... | python | def sort_recursive(data):
"""
Recursively sorts all elements in a dictionary
Args:
data (dict): The dictionary to sort
Returns:
sorted_dict (OrderedDict): The sorted data dict
"""
newdict = {}
for i in data.items():
if type(i[1]) is dict:
newdict[i[0]]... | [
"def",
"sort_recursive",
"(",
"data",
")",
":",
"newdict",
"=",
"{",
"}",
"for",
"i",
"in",
"data",
".",
"items",
"(",
")",
":",
"if",
"type",
"(",
"i",
"[",
"1",
"]",
")",
"is",
"dict",
":",
"newdict",
"[",
"i",
"[",
"0",
"]",
"]",
"=",
"s... | Recursively sorts all elements in a dictionary
Args:
data (dict): The dictionary to sort
Returns:
sorted_dict (OrderedDict): The sorted data dict | [
"Recursively",
"sorts",
"all",
"elements",
"in",
"a",
"dictionary"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/datatools.py#L65-L84 |
ModisWorks/modis | modis/datatools.py | get_compare_version | def get_compare_version():
"""
Get the version comparison info.
Returns: (tuple)
state (int): -1 for lower version, 0 for same version, 1 for higher version than latest.
response (str): The response string.
"""
state, latest_version = compare_latest_version()
if state < 0:
... | python | def get_compare_version():
"""
Get the version comparison info.
Returns: (tuple)
state (int): -1 for lower version, 0 for same version, 1 for higher version than latest.
response (str): The response string.
"""
state, latest_version = compare_latest_version()
if state < 0:
... | [
"def",
"get_compare_version",
"(",
")",
":",
"state",
",",
"latest_version",
"=",
"compare_latest_version",
"(",
")",
"if",
"state",
"<",
"0",
":",
"return",
"-",
"1",
",",
"\"A new version of Modis is available (v{})\"",
".",
"format",
"(",
"latest_version",
")",... | Get the version comparison info.
Returns: (tuple)
state (int): -1 for lower version, 0 for same version, 1 for higher version than latest.
response (str): The response string. | [
"Get",
"the",
"version",
"comparison",
"info",
"."
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/datatools.py#L137-L152 |
ModisWorks/modis | modis/discord_modis/modules/rocketleague/ui_embed.py | success | def success(channel, stats, name, platform, dp):
"""Creates an embed UI containing the Rocket League stats
Args:
channel (discord.Channel): The Discord channel to bind the embed to
stats (tuple): Tuples of (field, value, percentile)
name (str): The name of the player
platform (s... | python | def success(channel, stats, name, platform, dp):
"""Creates an embed UI containing the Rocket League stats
Args:
channel (discord.Channel): The Discord channel to bind the embed to
stats (tuple): Tuples of (field, value, percentile)
name (str): The name of the player
platform (s... | [
"def",
"success",
"(",
"channel",
",",
"stats",
",",
"name",
",",
"platform",
",",
"dp",
")",
":",
"# Create datapacks",
"datapacks",
"=",
"[",
"(",
"\"Platform\"",
",",
"platform",
",",
"False",
")",
"]",
"for",
"stat",
"in",
"stats",
":",
"# Add stats"... | Creates an embed UI containing the Rocket League stats
Args:
channel (discord.Channel): The Discord channel to bind the embed to
stats (tuple): Tuples of (field, value, percentile)
name (str): The name of the player
platform (str): The playfor to search on, can be 'steam', 'ps', or ... | [
"Creates",
"an",
"embed",
"UI",
"containing",
"the",
"Rocket",
"League",
"stats"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/rocketleague/ui_embed.py#L5-L47 |
ModisWorks/modis | modis/discord_modis/modules/rocketleague/ui_embed.py | fail_steamid | def fail_steamid(channel):
"""Creates an embed UI for invalid SteamIDs
Args:
channel (discord.Channel): The Discord channel to bind the embed to
Returns:
ui (ui_embed.UI): The embed UI object
"""
gui = ui_embed.UI(
channel,
"That SteamID doesn't exist.",
"Y... | python | def fail_steamid(channel):
"""Creates an embed UI for invalid SteamIDs
Args:
channel (discord.Channel): The Discord channel to bind the embed to
Returns:
ui (ui_embed.UI): The embed UI object
"""
gui = ui_embed.UI(
channel,
"That SteamID doesn't exist.",
"Y... | [
"def",
"fail_steamid",
"(",
"channel",
")",
":",
"gui",
"=",
"ui_embed",
".",
"UI",
"(",
"channel",
",",
"\"That SteamID doesn't exist.\"",
",",
"\"You can get your SteamID by going to your profile page and looking at the url, \"",
"\"or you can set a custom ID by going to edit pro... | Creates an embed UI for invalid SteamIDs
Args:
channel (discord.Channel): The Discord channel to bind the embed to
Returns:
ui (ui_embed.UI): The embed UI object | [
"Creates",
"an",
"embed",
"UI",
"for",
"invalid",
"SteamIDs"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/rocketleague/ui_embed.py#L50-L69 |
ModisWorks/modis | modis/discord_modis/modules/rocketleague/ui_embed.py | fail_api | def fail_api(channel):
"""Creates an embed UI for when the API call didn't work
Args:
channel (discord.Channel): The Discord channel to bind the embed to
Returns:
ui (ui_embed.UI): The embed UI object
"""
gui = ui_embed.UI(
channel,
"Couldn't get stats off RLTracke... | python | def fail_api(channel):
"""Creates an embed UI for when the API call didn't work
Args:
channel (discord.Channel): The Discord channel to bind the embed to
Returns:
ui (ui_embed.UI): The embed UI object
"""
gui = ui_embed.UI(
channel,
"Couldn't get stats off RLTracke... | [
"def",
"fail_api",
"(",
"channel",
")",
":",
"gui",
"=",
"ui_embed",
".",
"UI",
"(",
"channel",
",",
"\"Couldn't get stats off RLTrackerNetwork.\"",
",",
"\"Maybe the API changed, please tell Infraxion.\"",
",",
"modulename",
"=",
"modulename",
",",
"colour",
"=",
"0x... | Creates an embed UI for when the API call didn't work
Args:
channel (discord.Channel): The Discord channel to bind the embed to
Returns:
ui (ui_embed.UI): The embed UI object | [
"Creates",
"an",
"embed",
"UI",
"for",
"when",
"the",
"API",
"call",
"didn",
"t",
"work"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/rocketleague/ui_embed.py#L72-L90 |
ModisWorks/modis | modis/discord_modis/modules/hex/on_message.py | on_message | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | python | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | [
"async",
"def",
"on_message",
"(",
"message",
")",
":",
"# Simplify message info",
"server",
"=",
"message",
".",
"server",
"author",
"=",
"message",
".",
"author",
"channel",
"=",
"message",
".",
"channel",
"content",
"=",
"message",
".",
"content",
"data",
... | The on_message event handler for this module
Args:
message (discord.Message): Input message | [
"The",
"on_message",
"event",
"handler",
"for",
"this",
"module"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/hex/on_message.py#L6-L59 |
ModisWorks/modis | modis/discord_modis/modules/gamedeals/on_message.py | on_message | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | python | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | [
"async",
"def",
"on_message",
"(",
"message",
")",
":",
"# Simplify message info",
"server",
"=",
"message",
".",
"server",
"author",
"=",
"message",
".",
"author",
"channel",
"=",
"message",
".",
"channel",
"content",
"=",
"message",
".",
"content",
"data",
... | The on_message event handler for this module
Args:
message (discord.Message): Input message | [
"The",
"on_message",
"event",
"handler",
"for",
"this",
"module"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/gamedeals/on_message.py#L6-L47 |
ModisWorks/modis | modis/discord_modis/modules/gamedeals/ui_embed.py | success | def success(channel, post):
"""Creates an embed UI containing the Reddit posts
Args:
channel (discord.Channel): The Discord channel to bind the embed to
post (tuple): Tuples of (field, value, percentile)
Returns:
"""
# Create datapacks
datapacks = [("Game", post[0], True), ("... | python | def success(channel, post):
"""Creates an embed UI containing the Reddit posts
Args:
channel (discord.Channel): The Discord channel to bind the embed to
post (tuple): Tuples of (field, value, percentile)
Returns:
"""
# Create datapacks
datapacks = [("Game", post[0], True), ("... | [
"def",
"success",
"(",
"channel",
",",
"post",
")",
":",
"# Create datapacks",
"datapacks",
"=",
"[",
"(",
"\"Game\"",
",",
"post",
"[",
"0",
"]",
",",
"True",
")",
",",
"(",
"\"Upvotes\"",
",",
"post",
"[",
"2",
"]",
",",
"True",
")",
"]",
"# Crea... | Creates an embed UI containing the Reddit posts
Args:
channel (discord.Channel): The Discord channel to bind the embed to
post (tuple): Tuples of (field, value, percentile)
Returns: | [
"Creates",
"an",
"embed",
"UI",
"containing",
"the",
"Reddit",
"posts"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/gamedeals/ui_embed.py#L5-L30 |
ModisWorks/modis | modis/discord_modis/modules/gamedeals/ui_embed.py | no_results | def no_results(channel):
"""Creates an embed UI for when there were no results
Args:
channel (discord.Channel): The Discord channel to bind the embed to
Returns:
ui (ui_embed.UI): The embed UI object
"""
gui = ui_embed.UI(
channel,
"No results",
":c",
... | python | def no_results(channel):
"""Creates an embed UI for when there were no results
Args:
channel (discord.Channel): The Discord channel to bind the embed to
Returns:
ui (ui_embed.UI): The embed UI object
"""
gui = ui_embed.UI(
channel,
"No results",
":c",
... | [
"def",
"no_results",
"(",
"channel",
")",
":",
"gui",
"=",
"ui_embed",
".",
"UI",
"(",
"channel",
",",
"\"No results\"",
",",
"\":c\"",
",",
"modulename",
"=",
"modulename",
",",
"colour",
"=",
"0xFF8800",
")",
"return",
"gui"
] | Creates an embed UI for when there were no results
Args:
channel (discord.Channel): The Discord channel to bind the embed to
Returns:
ui (ui_embed.UI): The embed UI object | [
"Creates",
"an",
"embed",
"UI",
"for",
"when",
"there",
"were",
"no",
"results"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/gamedeals/ui_embed.py#L33-L51 |
ModisWorks/modis | modis/discord_modis/modules/music/_timebar.py | make_timebar | def make_timebar(progress=0, duration=0):
"""
Makes a new time bar string
Args:
progress: How far through the current song we are (in seconds)
duration: The duration of the current song (in seconds)
Returns:
timebar (str): The time bar string
"""
duration_string = api_... | python | def make_timebar(progress=0, duration=0):
"""
Makes a new time bar string
Args:
progress: How far through the current song we are (in seconds)
duration: The duration of the current song (in seconds)
Returns:
timebar (str): The time bar string
"""
duration_string = api_... | [
"def",
"make_timebar",
"(",
"progress",
"=",
"0",
",",
"duration",
"=",
"0",
")",
":",
"duration_string",
"=",
"api_music",
".",
"duration_to_string",
"(",
"duration",
")",
"if",
"duration",
"<=",
"0",
":",
"return",
"\"---\"",
"time_counts",
"=",
"int",
"... | Makes a new time bar string
Args:
progress: How far through the current song we are (in seconds)
duration: The duration of the current song (in seconds)
Returns:
timebar (str): The time bar string | [
"Makes",
"a",
"new",
"time",
"bar",
"string"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_timebar.py#L9-L35 |
ModisWorks/modis | modis/discord_modis/modules/_chatbot/on_message.py | on_message | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | python | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | [
"async",
"def",
"on_message",
"(",
"message",
")",
":",
"# Simplify message info",
"server",
"=",
"message",
".",
"server",
"author",
"=",
"message",
".",
"author",
"channel",
"=",
"message",
".",
"channel",
"content",
"=",
"message",
".",
"content",
"data",
... | The on_message event handler for this module
Args:
message (discord.Message): Input message | [
"The",
"on_message",
"event",
"handler",
"for",
"this",
"module"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/_chatbot/on_message.py#L10-L58 |
ModisWorks/modis | modis/discord_modis/modules/_tools/ui_embed.py | UI.build | def build(self):
"""Builds Discord embed GUI
Returns:
discord.Embed: Built GUI
"""
if self.colour:
embed = discord.Embed(
title=self.title,
type='rich',
description=self.description,
colour=self.col... | python | def build(self):
"""Builds Discord embed GUI
Returns:
discord.Embed: Built GUI
"""
if self.colour:
embed = discord.Embed(
title=self.title,
type='rich',
description=self.description,
colour=self.col... | [
"def",
"build",
"(",
"self",
")",
":",
"if",
"self",
".",
"colour",
":",
"embed",
"=",
"discord",
".",
"Embed",
"(",
"title",
"=",
"self",
".",
"title",
",",
"type",
"=",
"'rich'",
",",
"description",
"=",
"self",
".",
"description",
",",
"colour",
... | Builds Discord embed GUI
Returns:
discord.Embed: Built GUI | [
"Builds",
"Discord",
"embed",
"GUI"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/_tools/ui_embed.py#L33-L70 |
ModisWorks/modis | modis/discord_modis/modules/_tools/ui_embed.py | UI.send | async def send(self):
"""Send new GUI"""
await client.send_typing(self.channel)
self.sent_embed = await client.send_message(self.channel, embed=self.built_embed) | python | async def send(self):
"""Send new GUI"""
await client.send_typing(self.channel)
self.sent_embed = await client.send_message(self.channel, embed=self.built_embed) | [
"async",
"def",
"send",
"(",
"self",
")",
":",
"await",
"client",
".",
"send_typing",
"(",
"self",
".",
"channel",
")",
"self",
".",
"sent_embed",
"=",
"await",
"client",
".",
"send_message",
"(",
"self",
".",
"channel",
",",
"embed",
"=",
"self",
".",... | Send new GUI | [
"Send",
"new",
"GUI"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/_tools/ui_embed.py#L72-L76 |
ModisWorks/modis | modis/discord_modis/modules/_tools/ui_embed.py | UI.update_data | def update_data(self, index, data):
"""Updates a particular datapack's data
Args:
index (int): The index of the datapack
data (str): The new value to set for this datapack
"""
datapack = self.built_embed.to_dict()["fields"][index]
self.built_embed.set_fi... | python | def update_data(self, index, data):
"""Updates a particular datapack's data
Args:
index (int): The index of the datapack
data (str): The new value to set for this datapack
"""
datapack = self.built_embed.to_dict()["fields"][index]
self.built_embed.set_fi... | [
"def",
"update_data",
"(",
"self",
",",
"index",
",",
"data",
")",
":",
"datapack",
"=",
"self",
".",
"built_embed",
".",
"to_dict",
"(",
")",
"[",
"\"fields\"",
"]",
"[",
"index",
"]",
"self",
".",
"built_embed",
".",
"set_field_at",
"(",
"index",
","... | Updates a particular datapack's data
Args:
index (int): The index of the datapack
data (str): The new value to set for this datapack | [
"Updates",
"a",
"particular",
"datapack",
"s",
"data"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/_tools/ui_embed.py#L96-L105 |
freelawproject/reporters-db | reporters_db/utils.py | suck_out_variations_only | def suck_out_variations_only(reporters):
"""Builds a dictionary of variations to canonical reporters.
The dictionary takes the form of:
{
"A. 2d": ["A.2d"],
...
"P.R.": ["Pen. & W.", "P.R.R.", "P."],
}
In other words, it's a dictionary that maps each variation to... | python | def suck_out_variations_only(reporters):
"""Builds a dictionary of variations to canonical reporters.
The dictionary takes the form of:
{
"A. 2d": ["A.2d"],
...
"P.R.": ["Pen. & W.", "P.R.R.", "P."],
}
In other words, it's a dictionary that maps each variation to... | [
"def",
"suck_out_variations_only",
"(",
"reporters",
")",
":",
"variations_out",
"=",
"{",
"}",
"for",
"reporter_key",
",",
"data_list",
"in",
"reporters",
".",
"items",
"(",
")",
":",
"# For each reporter key...",
"for",
"data",
"in",
"data_list",
":",
"# For e... | Builds a dictionary of variations to canonical reporters.
The dictionary takes the form of:
{
"A. 2d": ["A.2d"],
...
"P.R.": ["Pen. & W.", "P.R.R.", "P."],
}
In other words, it's a dictionary that maps each variation to a list of
reporters that it could be possib... | [
"Builds",
"a",
"dictionary",
"of",
"variations",
"to",
"canonical",
"reporters",
"."
] | train | https://github.com/freelawproject/reporters-db/blob/ee17ee38a4e39de8d83beb78d84d146cd7e8afbc/reporters_db/utils.py#L7-L34 |
freelawproject/reporters-db | reporters_db/utils.py | suck_out_editions | def suck_out_editions(reporters):
"""Builds a dictionary mapping edition keys to their root name.
The dictionary takes the form of:
{
"A.": "A.",
"A.2d": "A.",
"A.3d": "A.",
"A.D.": "A.D.",
...
}
In other words, this lets you go from an editio... | python | def suck_out_editions(reporters):
"""Builds a dictionary mapping edition keys to their root name.
The dictionary takes the form of:
{
"A.": "A.",
"A.2d": "A.",
"A.3d": "A.",
"A.D.": "A.D.",
...
}
In other words, this lets you go from an editio... | [
"def",
"suck_out_editions",
"(",
"reporters",
")",
":",
"editions_out",
"=",
"{",
"}",
"for",
"reporter_key",
",",
"data_list",
"in",
"reporters",
".",
"items",
"(",
")",
":",
"# For each reporter key...",
"for",
"data",
"in",
"data_list",
":",
"# For each book ... | Builds a dictionary mapping edition keys to their root name.
The dictionary takes the form of:
{
"A.": "A.",
"A.2d": "A.",
"A.3d": "A.",
"A.D.": "A.D.",
...
}
In other words, this lets you go from an edition match to its parent key. | [
"Builds",
"a",
"dictionary",
"mapping",
"edition",
"keys",
"to",
"their",
"root",
"name",
"."
] | train | https://github.com/freelawproject/reporters-db/blob/ee17ee38a4e39de8d83beb78d84d146cd7e8afbc/reporters_db/utils.py#L37-L62 |
freelawproject/reporters-db | reporters_db/utils.py | names_to_abbreviations | def names_to_abbreviations(reporters):
"""Build a dict mapping names to their variations
Something like:
{
"Atlantic Reporter": ['A.', 'A.2d'],
}
Note that the abbreviations are sorted by start date.
"""
names = {}
for reporter_key, data_list in reporters.items():
... | python | def names_to_abbreviations(reporters):
"""Build a dict mapping names to their variations
Something like:
{
"Atlantic Reporter": ['A.', 'A.2d'],
}
Note that the abbreviations are sorted by start date.
"""
names = {}
for reporter_key, data_list in reporters.items():
... | [
"def",
"names_to_abbreviations",
"(",
"reporters",
")",
":",
"names",
"=",
"{",
"}",
"for",
"reporter_key",
",",
"data_list",
"in",
"reporters",
".",
"items",
"(",
")",
":",
"for",
"data",
"in",
"data_list",
":",
"abbrevs",
"=",
"data",
"[",
"'editions'",
... | Build a dict mapping names to their variations
Something like:
{
"Atlantic Reporter": ['A.', 'A.2d'],
}
Note that the abbreviations are sorted by start date. | [
"Build",
"a",
"dict",
"mapping",
"names",
"to",
"their",
"variations"
] | train | https://github.com/freelawproject/reporters-db/blob/ee17ee38a4e39de8d83beb78d84d146cd7e8afbc/reporters_db/utils.py#L65-L85 |
ModisWorks/modis | modis/discord_modis/modules/rocketleague/api_rocketleaguestats.py | check_rank | def check_rank(player, platform="steam"):
"""Gets the Rocket League stats and name and dp of a UserID
Args:
player (str): The UserID of the player we want to rank check
platform (str): The platform to check for, can be 'steam', 'ps', or 'xbox'
Returns:
success (bool): Whether the r... | python | def check_rank(player, platform="steam"):
"""Gets the Rocket League stats and name and dp of a UserID
Args:
player (str): The UserID of the player we want to rank check
platform (str): The platform to check for, can be 'steam', 'ps', or 'xbox'
Returns:
success (bool): Whether the r... | [
"def",
"check_rank",
"(",
"player",
",",
"platform",
"=",
"\"steam\"",
")",
":",
"# Get player ID and name Rocket League Tracker Network",
"webpage",
"=",
"requests",
".",
"get",
"(",
"\"https://rocketleague.tracker.network/profile/{}/{}\"",
".",
"format",
"(",
"platform",
... | Gets the Rocket League stats and name and dp of a UserID
Args:
player (str): The UserID of the player we want to rank check
platform (str): The platform to check for, can be 'steam', 'ps', or 'xbox'
Returns:
success (bool): Whether the rank check was successful
package (tuple):... | [
"Gets",
"the",
"Rocket",
"League",
"stats",
"and",
"name",
"and",
"dp",
"of",
"a",
"UserID"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/rocketleague/api_rocketleaguestats.py#L5-L66 |
ModisWorks/modis | modis/discord_modis/modules/bethebot/_ui.py | send_message | def send_message(channel_id, message):
"""
Send a message to a channel
Args:
channel_id (str): The id of the channel to send the message to
message (str): The message to send to the channel
"""
channel = client.get_channel(channel_id)
if channel is None:
logger.info("{... | python | def send_message(channel_id, message):
"""
Send a message to a channel
Args:
channel_id (str): The id of the channel to send the message to
message (str): The message to send to the channel
"""
channel = client.get_channel(channel_id)
if channel is None:
logger.info("{... | [
"def",
"send_message",
"(",
"channel_id",
",",
"message",
")",
":",
"channel",
"=",
"client",
".",
"get_channel",
"(",
"channel_id",
")",
"if",
"channel",
"is",
"None",
":",
"logger",
".",
"info",
"(",
"\"{} is not a channel\"",
".",
"format",
"(",
"channel_... | Send a message to a channel
Args:
channel_id (str): The id of the channel to send the message to
message (str): The message to send to the channel | [
"Send",
"a",
"message",
"to",
"a",
"channel"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/bethebot/_ui.py#L72-L95 |
ModisWorks/modis | modis/discord_modis/modules/bethebot/_ui.py | runcoro | def runcoro(async_function):
"""
Runs an asynchronous function without needing to use await - useful for lambda
Args:
async_function (Coroutine): The asynchronous function to run
"""
future = _asyncio.run_coroutine_threadsafe(async_function, client.loop)
result = future.result()
re... | python | def runcoro(async_function):
"""
Runs an asynchronous function without needing to use await - useful for lambda
Args:
async_function (Coroutine): The asynchronous function to run
"""
future = _asyncio.run_coroutine_threadsafe(async_function, client.loop)
result = future.result()
re... | [
"def",
"runcoro",
"(",
"async_function",
")",
":",
"future",
"=",
"_asyncio",
".",
"run_coroutine_threadsafe",
"(",
"async_function",
",",
"client",
".",
"loop",
")",
"result",
"=",
"future",
".",
"result",
"(",
")",
"return",
"result"
] | Runs an asynchronous function without needing to use await - useful for lambda
Args:
async_function (Coroutine): The asynchronous function to run | [
"Runs",
"an",
"asynchronous",
"function",
"without",
"needing",
"to",
"use",
"await",
"-",
"useful",
"for",
"lambda"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/bethebot/_ui.py#L98-L108 |
ModisWorks/modis | modis/discord_modis/modules/tableflip/on_message.py | on_message | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | python | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | [
"async",
"def",
"on_message",
"(",
"message",
")",
":",
"# Simplify message info",
"server",
"=",
"message",
".",
"server",
"author",
"=",
"message",
".",
"author",
"channel",
"=",
"message",
".",
"channel",
"content",
"=",
"message",
".",
"content",
"data",
... | The on_message event handler for this module
Args:
message (discord.Message): Input message | [
"The",
"on_message",
"event",
"handler",
"for",
"this",
"module"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/tableflip/on_message.py#L6-L30 |
ModisWorks/modis | modis/discord_modis/modules/gamedeals/_ui.py | ModuleUIFrame.update_keys | def update_keys(self):
"""Updates the Google API key with the text value"""
from ...main import add_api_key
add_api_key("reddit_api_user_agent", self.reddit_api_user_agent.get())
add_api_key("reddit_api_client_id", self.reddit_api_client_id.get())
add_api_key("reddit_api_client_s... | python | def update_keys(self):
"""Updates the Google API key with the text value"""
from ...main import add_api_key
add_api_key("reddit_api_user_agent", self.reddit_api_user_agent.get())
add_api_key("reddit_api_client_id", self.reddit_api_client_id.get())
add_api_key("reddit_api_client_s... | [
"def",
"update_keys",
"(",
"self",
")",
":",
"from",
".",
".",
".",
"main",
"import",
"add_api_key",
"add_api_key",
"(",
"\"reddit_api_user_agent\"",
",",
"self",
".",
"reddit_api_user_agent",
".",
"get",
"(",
")",
")",
"add_api_key",
"(",
"\"reddit_api_client_i... | Updates the Google API key with the text value | [
"Updates",
"the",
"Google",
"API",
"key",
"with",
"the",
"text",
"value"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/gamedeals/_ui.py#L55-L60 |
ModisWorks/modis | modis/discord_modis/modules/manager/api_manager.py | activate_module | async def activate_module(channel, module_name, activate):
"""
Changes a modules activated/deactivated state for a server
Args:
channel: The channel to send the message to
module_name: The name of the module to change state for
activate: The activated/deactivated state of the module... | python | async def activate_module(channel, module_name, activate):
"""
Changes a modules activated/deactivated state for a server
Args:
channel: The channel to send the message to
module_name: The name of the module to change state for
activate: The activated/deactivated state of the module... | [
"async",
"def",
"activate_module",
"(",
"channel",
",",
"module_name",
",",
"activate",
")",
":",
"data",
"=",
"datatools",
".",
"get_data",
"(",
")",
"server_id",
"=",
"channel",
".",
"server",
".",
"id",
"_dir",
"=",
"os",
".",
"path",
".",
"realpath",... | Changes a modules activated/deactivated state for a server
Args:
channel: The channel to send the message to
module_name: The name of the module to change state for
activate: The activated/deactivated state of the module | [
"Changes",
"a",
"modules",
"activated",
"/",
"deactivated",
"state",
"for",
"a",
"server"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/manager/api_manager.py#L14-L71 |
ModisWorks/modis | modis/discord_modis/modules/manager/api_manager.py | warn_user | async def warn_user(channel, user):
"""
Gives a user a warning, and bans them if they are over the maximum warnings
Args:
channel: The channel to send the warning message in
user: The user to give the warning to
"""
data = datatools.get_data()
server_id = channel.server.id
... | python | async def warn_user(channel, user):
"""
Gives a user a warning, and bans them if they are over the maximum warnings
Args:
channel: The channel to send the warning message in
user: The user to give the warning to
"""
data = datatools.get_data()
server_id = channel.server.id
... | [
"async",
"def",
"warn_user",
"(",
"channel",
",",
"user",
")",
":",
"data",
"=",
"datatools",
".",
"get_data",
"(",
")",
"server_id",
"=",
"channel",
".",
"server",
".",
"id",
"if",
"\"warnings_max\"",
"not",
"in",
"data",
"[",
"\"discord\"",
"]",
"[",
... | Gives a user a warning, and bans them if they are over the maximum warnings
Args:
channel: The channel to send the warning message in
user: The user to give the warning to | [
"Gives",
"a",
"user",
"a",
"warning",
"and",
"bans",
"them",
"if",
"they",
"are",
"over",
"the",
"maximum",
"warnings"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/manager/api_manager.py#L74-L106 |
ModisWorks/modis | modis/discord_modis/modules/manager/api_manager.py | ban_user | async def ban_user(channel, user):
"""
Bans a user from a server
Args:
channel: The channel to send the warning message in
user: The user to give the warning to
"""
data = datatools.get_data()
server_id = channel.server.id
try:
await client.ban(user)
except dis... | python | async def ban_user(channel, user):
"""
Bans a user from a server
Args:
channel: The channel to send the warning message in
user: The user to give the warning to
"""
data = datatools.get_data()
server_id = channel.server.id
try:
await client.ban(user)
except dis... | [
"async",
"def",
"ban_user",
"(",
"channel",
",",
"user",
")",
":",
"data",
"=",
"datatools",
".",
"get_data",
"(",
")",
"server_id",
"=",
"channel",
".",
"server",
".",
"id",
"try",
":",
"await",
"client",
".",
"ban",
"(",
"user",
")",
"except",
"dis... | Bans a user from a server
Args:
channel: The channel to send the warning message in
user: The user to give the warning to | [
"Bans",
"a",
"user",
"from",
"a",
"server"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/manager/api_manager.py#L109-L144 |
ModisWorks/modis | modis/discord_modis/modules/help/api_help.py | get_help_datapacks | def get_help_datapacks(module_name, server_prefix):
"""
Get the help datapacks for a module
Args:
module_name (str): The module to get help data for
server_prefix (str): The command prefix for this server
Returns:
datapacks (list): The help datapacks for the module
"""
... | python | def get_help_datapacks(module_name, server_prefix):
"""
Get the help datapacks for a module
Args:
module_name (str): The module to get help data for
server_prefix (str): The command prefix for this server
Returns:
datapacks (list): The help datapacks for the module
"""
... | [
"def",
"get_help_datapacks",
"(",
"module_name",
",",
"server_prefix",
")",
":",
"_dir",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"os",
".",
"path",
".",
"dirname",
"(",
... | Get the help datapacks for a module
Args:
module_name (str): The module to get help data for
server_prefix (str): The command prefix for this server
Returns:
datapacks (list): The help datapacks for the module | [
"Get",
"the",
"help",
"datapacks",
"for",
"a",
"module"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/help/api_help.py#L6-L29 |
ModisWorks/modis | modis/discord_modis/modules/help/api_help.py | get_help_commands | def get_help_commands(server_prefix):
"""
Get the help commands for all modules
Args:
server_prefix: The server command prefix
Returns:
datapacks (list): A list of datapacks for the help commands for all the modules
"""
datapacks = []
_dir = os.path.realpath(
os.p... | python | def get_help_commands(server_prefix):
"""
Get the help commands for all modules
Args:
server_prefix: The server command prefix
Returns:
datapacks (list): A list of datapacks for the help commands for all the modules
"""
datapacks = []
_dir = os.path.realpath(
os.p... | [
"def",
"get_help_commands",
"(",
"server_prefix",
")",
":",
"datapacks",
"=",
"[",
"]",
"_dir",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"os",
".",
"path",
".",
"dirname"... | Get the help commands for all modules
Args:
server_prefix: The server command prefix
Returns:
datapacks (list): A list of datapacks for the help commands for all the modules | [
"Get",
"the",
"help",
"commands",
"for",
"all",
"modules"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/help/api_help.py#L32-L52 |
ModisWorks/modis | modis/discord_modis/modules/help/on_message.py | on_message | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | python | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | [
"async",
"def",
"on_message",
"(",
"message",
")",
":",
"# Simplify message info",
"server",
"=",
"message",
".",
"server",
"author",
"=",
"message",
".",
"author",
"channel",
"=",
"message",
".",
"channel",
"content",
"=",
"message",
".",
"content",
"data",
... | The on_message event handler for this module
Args:
message (discord.Message): Input message | [
"The",
"on_message",
"event",
"handler",
"for",
"this",
"module"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/help/on_message.py#L8-L59 |
ModisWorks/modis | modis/discord_modis/modules/manager/on_message.py | on_message | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | python | async def on_message(message):
"""The on_message event handler for this module
Args:
message (discord.Message): Input message
"""
# Simplify message info
server = message.server
author = message.author
channel = message.channel
content = message.content
data = datatools.ge... | [
"async",
"def",
"on_message",
"(",
"message",
")",
":",
"# Simplify message info",
"server",
"=",
"message",
".",
"server",
"author",
"=",
"message",
".",
"author",
"channel",
"=",
"message",
".",
"channel",
"content",
"=",
"message",
".",
"content",
"data",
... | The on_message event handler for this module
Args:
message (discord.Message): Input message | [
"The",
"on_message",
"event",
"handler",
"for",
"this",
"module"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/manager/on_message.py#L14-L103 |
ModisWorks/modis | modis/discord_modis/modules/music/ui_embed.py | topic_update | def topic_update(channel, topic_channel):
"""
Creates an embed UI for the topic update
Args:
channel (discord.Channel): The Discord channel to bind the embed to
topic_channel: The new topic channel
Returns:
embed: The created embed
"""
if topic_channel is not None:
... | python | def topic_update(channel, topic_channel):
"""
Creates an embed UI for the topic update
Args:
channel (discord.Channel): The Discord channel to bind the embed to
topic_channel: The new topic channel
Returns:
embed: The created embed
"""
if topic_channel is not None:
... | [
"def",
"topic_update",
"(",
"channel",
",",
"topic_channel",
")",
":",
"if",
"topic_channel",
"is",
"not",
"None",
":",
"try",
":",
"channel_message",
"=",
"\"Topic channel is now `{}`.\"",
".",
"format",
"(",
"topic_channel",
".",
"name",
")",
"except",
"Except... | Creates an embed UI for the topic update
Args:
channel (discord.Channel): The Discord channel to bind the embed to
topic_channel: The new topic channel
Returns:
embed: The created embed | [
"Creates",
"an",
"embed",
"UI",
"for",
"the",
"topic",
"update"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/ui_embed.py#L11-L41 |
ModisWorks/modis | modis/discord_modis/modules/music/ui_embed.py | error_message | def error_message(channel, err_title, err_message):
"""
Creates an embed UI for the topic update
Args:
channel (discord.Channel): The Discord channel to bind the embed to
err_title: The title for the error
err_message: The message for the error
Returns:
embed: The creat... | python | def error_message(channel, err_title, err_message):
"""
Creates an embed UI for the topic update
Args:
channel (discord.Channel): The Discord channel to bind the embed to
err_title: The title for the error
err_message: The message for the error
Returns:
embed: The creat... | [
"def",
"error_message",
"(",
"channel",
",",
"err_title",
",",
"err_message",
")",
":",
"# Create embed UI object",
"gui",
"=",
"ui_embed",
".",
"UI",
"(",
"channel",
",",
"err_title",
",",
"err_message",
",",
"modulename",
"=",
"modulename",
",",
"colour",
"=... | Creates an embed UI for the topic update
Args:
channel (discord.Channel): The Discord channel to bind the embed to
err_title: The title for the error
err_message: The message for the error
Returns:
embed: The created embed | [
"Creates",
"an",
"embed",
"UI",
"for",
"the",
"topic",
"update"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/ui_embed.py#L44-L66 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | clear_cache_root | def clear_cache_root():
"""Clears everything in the song cache"""
logger.debug("Clearing root cache")
if os.path.isdir(_root_songcache_dir):
for filename in os.listdir(_root_songcache_dir):
file_path = os.path.join(_root_songcache_dir, filename)
try:
if os.pat... | python | def clear_cache_root():
"""Clears everything in the song cache"""
logger.debug("Clearing root cache")
if os.path.isdir(_root_songcache_dir):
for filename in os.listdir(_root_songcache_dir):
file_path = os.path.join(_root_songcache_dir, filename)
try:
if os.pat... | [
"def",
"clear_cache_root",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"Clearing root cache\"",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"_root_songcache_dir",
")",
":",
"for",
"filename",
"in",
"os",
".",
"listdir",
"(",
"_root_songcache_dir",
")"... | Clears everything in the song cache | [
"Clears",
"everything",
"in",
"the",
"song",
"cache"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L25-L40 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.play | async def play(self, author, text_channel, query, index=None, stop_current=False, shuffle=False):
"""
The play command
Args:
author (discord.Member): The member that called the command
text_channel (discord.Channel): The channel where the command was called
q... | python | async def play(self, author, text_channel, query, index=None, stop_current=False, shuffle=False):
"""
The play command
Args:
author (discord.Member): The member that called the command
text_channel (discord.Channel): The channel where the command was called
q... | [
"async",
"def",
"play",
"(",
"self",
",",
"author",
",",
"text_channel",
",",
"query",
",",
"index",
"=",
"None",
",",
"stop_current",
"=",
"False",
",",
"shuffle",
"=",
"False",
")",
":",
"if",
"self",
".",
"state",
"==",
"'off'",
":",
"self",
".",
... | The play command
Args:
author (discord.Member): The member that called the command
text_channel (discord.Channel): The channel where the command was called
query (str): The argument that was passed with the command
index (str): Whether to play next or at the end ... | [
"The",
"play",
"command"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L162-L194 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.destroy | async def destroy(self):
"""Destroy the whole gui and music player"""
self.logger.debug("destroy command")
self.state = 'destroyed'
await self.set_topic("")
self.nowplayinglog.debug("---")
self.nowplayingauthorlog.debug("---")
self.nowplayingsourcelog.debug("---... | python | async def destroy(self):
"""Destroy the whole gui and music player"""
self.logger.debug("destroy command")
self.state = 'destroyed'
await self.set_topic("")
self.nowplayinglog.debug("---")
self.nowplayingauthorlog.debug("---")
self.nowplayingsourcelog.debug("---... | [
"async",
"def",
"destroy",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"destroy command\"",
")",
"self",
".",
"state",
"=",
"'destroyed'",
"await",
"self",
".",
"set_topic",
"(",
"\"\"",
")",
"self",
".",
"nowplayinglog",
".",
"deb... | Destroy the whole gui and music player | [
"Destroy",
"the",
"whole",
"gui",
"and",
"music",
"player"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L256-L301 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.toggle | async def toggle(self):
"""Toggles between pause and resume command"""
self.logger.debug("toggle command")
if not self.state == 'ready':
return
if self.streamer is None:
return
try:
if self.streamer.is_playing():
await self.... | python | async def toggle(self):
"""Toggles between pause and resume command"""
self.logger.debug("toggle command")
if not self.state == 'ready':
return
if self.streamer is None:
return
try:
if self.streamer.is_playing():
await self.... | [
"async",
"def",
"toggle",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"toggle command\"",
")",
"if",
"not",
"self",
".",
"state",
"==",
"'ready'",
":",
"return",
"if",
"self",
".",
"streamer",
"is",
"None",
":",
"return",
"try",
... | Toggles between pause and resume command | [
"Toggles",
"between",
"pause",
"and",
"resume",
"command"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L303-L321 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.pause | async def pause(self):
"""Pauses playback if playing"""
self.logger.debug("pause command")
if not self.state == 'ready':
return
if self.streamer is None:
return
try:
if self.streamer.is_playing():
self.streamer.pause()
... | python | async def pause(self):
"""Pauses playback if playing"""
self.logger.debug("pause command")
if not self.state == 'ready':
return
if self.streamer is None:
return
try:
if self.streamer.is_playing():
self.streamer.pause()
... | [
"async",
"def",
"pause",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"pause command\"",
")",
"if",
"not",
"self",
".",
"state",
"==",
"'ready'",
":",
"return",
"if",
"self",
".",
"streamer",
"is",
"None",
":",
"return",
"try",
... | Pauses playback if playing | [
"Pauses",
"playback",
"if",
"playing"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L323-L341 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.resume | async def resume(self):
"""Resumes playback if paused"""
self.logger.debug("resume command")
if not self.state == 'ready':
return
if self.streamer is None:
return
try:
if not self.streamer.is_playing():
play_state = "Streami... | python | async def resume(self):
"""Resumes playback if paused"""
self.logger.debug("resume command")
if not self.state == 'ready':
return
if self.streamer is None:
return
try:
if not self.streamer.is_playing():
play_state = "Streami... | [
"async",
"def",
"resume",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"resume command\"",
")",
"if",
"not",
"self",
".",
"state",
"==",
"'ready'",
":",
"return",
"if",
"self",
".",
"streamer",
"is",
"None",
":",
"return",
"try",
... | Resumes playback if paused | [
"Resumes",
"playback",
"if",
"paused"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L343-L365 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.skip | async def skip(self, query="1"):
"""The skip command
Args:
query (str): The number of items to skip
"""
if not self.state == 'ready':
logger.debug("Trying to skip from wrong state '{}'".format(self.state))
return
if query == "":
... | python | async def skip(self, query="1"):
"""The skip command
Args:
query (str): The number of items to skip
"""
if not self.state == 'ready':
logger.debug("Trying to skip from wrong state '{}'".format(self.state))
return
if query == "":
... | [
"async",
"def",
"skip",
"(",
"self",
",",
"query",
"=",
"\"1\"",
")",
":",
"if",
"not",
"self",
".",
"state",
"==",
"'ready'",
":",
"logger",
".",
"debug",
"(",
"\"Trying to skip from wrong state '{}'\"",
".",
"format",
"(",
"self",
".",
"state",
")",
")... | The skip command
Args:
query (str): The number of items to skip | [
"The",
"skip",
"command"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L367-L399 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.