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 |
|---|---|---|---|---|---|---|---|---|---|---|
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.remove | async def remove(self, index=""):
"""
The remove command
Args:
index (str): The index to remove, can be either a number, or a range in the for '##-##'
"""
if not self.state == 'ready':
logger.debug("Trying to remove from wrong state '{}'".format(self.sta... | python | async def remove(self, index=""):
"""
The remove command
Args:
index (str): The index to remove, can be either a number, or a range in the for '##-##'
"""
if not self.state == 'ready':
logger.debug("Trying to remove from wrong state '{}'".format(self.sta... | [
"async",
"def",
"remove",
"(",
"self",
",",
"index",
"=",
"\"\"",
")",
":",
"if",
"not",
"self",
".",
"state",
"==",
"'ready'",
":",
"logger",
".",
"debug",
"(",
"\"Trying to remove from wrong state '{}'\"",
".",
"format",
"(",
"self",
".",
"state",
")",
... | The remove command
Args:
index (str): The index to remove, can be either a number, or a range in the for '##-##' | [
"The",
"remove",
"command"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L401-L468 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.rewind | async def rewind(self, query="1"):
"""
The rewind command
Args:
query (str): The number of items to skip
"""
if not self.state == 'ready':
logger.debug("Trying to rewind from wrong state '{}'".format(self.state))
return
if query == "... | python | async def rewind(self, query="1"):
"""
The rewind command
Args:
query (str): The number of items to skip
"""
if not self.state == 'ready':
logger.debug("Trying to rewind from wrong state '{}'".format(self.state))
return
if query == "... | [
"async",
"def",
"rewind",
"(",
"self",
",",
"query",
"=",
"\"1\"",
")",
":",
"if",
"not",
"self",
".",
"state",
"==",
"'ready'",
":",
"logger",
".",
"debug",
"(",
"\"Trying to rewind from wrong state '{}'\"",
".",
"format",
"(",
"self",
".",
"state",
")",
... | The rewind command
Args:
query (str): The number of items to skip | [
"The",
"rewind",
"command"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L470-L511 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.shuffle | async def shuffle(self):
"""The shuffle command"""
self.logger.debug("shuffle command")
if not self.state == 'ready':
return
self.statuslog.debug("Shuffling")
random.shuffle(self.queue)
self.update_queue()
self.statuslog.debug("Shuffled") | python | async def shuffle(self):
"""The shuffle command"""
self.logger.debug("shuffle command")
if not self.state == 'ready':
return
self.statuslog.debug("Shuffling")
random.shuffle(self.queue)
self.update_queue()
self.statuslog.debug("Shuffled") | [
"async",
"def",
"shuffle",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"shuffle command\"",
")",
"if",
"not",
"self",
".",
"state",
"==",
"'ready'",
":",
"return",
"self",
".",
"statuslog",
".",
"debug",
"(",
"\"Shuffling\"",
")",
... | The shuffle command | [
"The",
"shuffle",
"command"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L513-L526 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.set_loop | async def set_loop(self, loop_value):
"""Updates the loop value, can be 'off', 'on', or 'shuffle'"""
if loop_value not in ['on', 'off', 'shuffle']:
self.statuslog.error("Loop value must be `off`, `on`, or `shuffle`")
return
self.loop_type = loop_value
if self.loo... | python | async def set_loop(self, loop_value):
"""Updates the loop value, can be 'off', 'on', or 'shuffle'"""
if loop_value not in ['on', 'off', 'shuffle']:
self.statuslog.error("Loop value must be `off`, `on`, or `shuffle`")
return
self.loop_type = loop_value
if self.loo... | [
"async",
"def",
"set_loop",
"(",
"self",
",",
"loop_value",
")",
":",
"if",
"loop_value",
"not",
"in",
"[",
"'on'",
",",
"'off'",
",",
"'shuffle'",
"]",
":",
"self",
".",
"statuslog",
".",
"error",
"(",
"\"Loop value must be `off`, `on`, or `shuffle`\"",
")",
... | Updates the loop value, can be 'off', 'on', or 'shuffle | [
"Updates",
"the",
"loop",
"value",
"can",
"be",
"off",
"on",
"or",
"shuffle"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L528-L540 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.setvolume | async def setvolume(self, value):
"""The volume command
Args:
value (str): The value to set the volume to
"""
self.logger.debug("volume command")
if self.state != 'ready':
return
logger.debug("Volume command received")
if value == '+':... | python | async def setvolume(self, value):
"""The volume command
Args:
value (str): The value to set the volume to
"""
self.logger.debug("volume command")
if self.state != 'ready':
return
logger.debug("Volume command received")
if value == '+':... | [
"async",
"def",
"setvolume",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"volume command\"",
")",
"if",
"self",
".",
"state",
"!=",
"'ready'",
":",
"return",
"logger",
".",
"debug",
"(",
"\"Volume command received\"",
"... | The volume command
Args:
value (str): The value to set the volume to | [
"The",
"volume",
"command"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L542-L597 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.write_volume | def write_volume(self):
"""Writes the current volume to the data.json"""
# Update the volume
data = datatools.get_data()
data["discord"]["servers"][self.server_id][_data.modulename]["volume"] = self.volume
datatools.write_data(data) | python | def write_volume(self):
"""Writes the current volume to the data.json"""
# Update the volume
data = datatools.get_data()
data["discord"]["servers"][self.server_id][_data.modulename]["volume"] = self.volume
datatools.write_data(data) | [
"def",
"write_volume",
"(",
"self",
")",
":",
"# Update the volume",
"data",
"=",
"datatools",
".",
"get_data",
"(",
")",
"data",
"[",
"\"discord\"",
"]",
"[",
"\"servers\"",
"]",
"[",
"self",
".",
"server_id",
"]",
"[",
"_data",
".",
"modulename",
"]",
... | Writes the current volume to the data.json | [
"Writes",
"the",
"current",
"volume",
"to",
"the",
"data",
".",
"json"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L599-L604 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.movehere | async def movehere(self, channel):
"""
Moves the embed message to a new channel; can also be used to move the musicplayer to the front
Args:
channel (discord.Channel): The channel to move to
"""
self.logger.debug("movehere command")
# Delete the old message... | python | async def movehere(self, channel):
"""
Moves the embed message to a new channel; can also be used to move the musicplayer to the front
Args:
channel (discord.Channel): The channel to move to
"""
self.logger.debug("movehere command")
# Delete the old message... | [
"async",
"def",
"movehere",
"(",
"self",
",",
"channel",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"movehere command\"",
")",
"# Delete the old message",
"await",
"self",
".",
"embed",
".",
"delete",
"(",
")",
"# Set the channel to this channel",
"se... | Moves the embed message to a new channel; can also be used to move the musicplayer to the front
Args:
channel (discord.Channel): The channel to move to | [
"Moves",
"the",
"embed",
"message",
"to",
"a",
"new",
"channel",
";",
"can",
"also",
"be",
"used",
"to",
"move",
"the",
"musicplayer",
"to",
"the",
"front"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L606-L625 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.set_topic_channel | async def set_topic_channel(self, channel):
"""Set the topic channel for this server"""
data = datatools.get_data()
data["discord"]["servers"][self.server_id][_data.modulename]["topic_id"] = channel.id
datatools.write_data(data)
self.topicchannel = channel
await self.set... | python | async def set_topic_channel(self, channel):
"""Set the topic channel for this server"""
data = datatools.get_data()
data["discord"]["servers"][self.server_id][_data.modulename]["topic_id"] = channel.id
datatools.write_data(data)
self.topicchannel = channel
await self.set... | [
"async",
"def",
"set_topic_channel",
"(",
"self",
",",
"channel",
")",
":",
"data",
"=",
"datatools",
".",
"get_data",
"(",
")",
"data",
"[",
"\"discord\"",
"]",
"[",
"\"servers\"",
"]",
"[",
"self",
".",
"server_id",
"]",
"[",
"_data",
".",
"modulename"... | Set the topic channel for this server | [
"Set",
"the",
"topic",
"channel",
"for",
"this",
"server"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L627-L638 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.clear_topic_channel | async def clear_topic_channel(self, channel):
"""Set the topic channel for this server"""
try:
if self.topicchannel:
await client.edit_channel(self.topicchannel, topic="")
except Exception as e:
logger.exception(e)
self.topicchannel = None
... | python | async def clear_topic_channel(self, channel):
"""Set the topic channel for this server"""
try:
if self.topicchannel:
await client.edit_channel(self.topicchannel, topic="")
except Exception as e:
logger.exception(e)
self.topicchannel = None
... | [
"async",
"def",
"clear_topic_channel",
"(",
"self",
",",
"channel",
")",
":",
"try",
":",
"if",
"self",
".",
"topicchannel",
":",
"await",
"client",
".",
"edit_channel",
"(",
"self",
".",
"topicchannel",
",",
"topic",
"=",
"\"\"",
")",
"except",
"Exception... | Set the topic channel for this server | [
"Set",
"the",
"topic",
"channel",
"for",
"this",
"server"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L640-L657 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.vsetup | async def vsetup(self, author):
"""Creates the voice client
Args:
author (discord.Member): The user that the voice ui will seek
"""
if self.vready:
logger.warning("Attempt to init voice when already initialised")
return
if self.state != 'sta... | python | async def vsetup(self, author):
"""Creates the voice client
Args:
author (discord.Member): The user that the voice ui will seek
"""
if self.vready:
logger.warning("Attempt to init voice when already initialised")
return
if self.state != 'sta... | [
"async",
"def",
"vsetup",
"(",
"self",
",",
"author",
")",
":",
"if",
"self",
".",
"vready",
":",
"logger",
".",
"warning",
"(",
"\"Attempt to init voice when already initialised\"",
")",
"return",
"if",
"self",
".",
"state",
"!=",
"'starting'",
":",
"logger",... | Creates the voice client
Args:
author (discord.Member): The user that the voice ui will seek | [
"Creates",
"the",
"voice",
"client"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L660-L704 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.msetup | async def msetup(self, text_channel):
"""Creates the gui
Args:
text_channel (discord.Channel): The channel for the embed ui to run in
"""
if self.mready:
logger.warning("Attempt to init music when already initialised")
return
if self.state !... | python | async def msetup(self, text_channel):
"""Creates the gui
Args:
text_channel (discord.Channel): The channel for the embed ui to run in
"""
if self.mready:
logger.warning("Attempt to init music when already initialised")
return
if self.state !... | [
"async",
"def",
"msetup",
"(",
"self",
",",
"text_channel",
")",
":",
"if",
"self",
".",
"mready",
":",
"logger",
".",
"warning",
"(",
"\"Attempt to init music when already initialised\"",
")",
"return",
"if",
"self",
".",
"state",
"!=",
"'starting'",
":",
"lo... | Creates the gui
Args:
text_channel (discord.Channel): The channel for the embed ui to run in | [
"Creates",
"the",
"gui"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L706-L730 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.new_embed_ui | def new_embed_ui(self):
"""Create the embed UI object and save it to self"""
self.logger.debug("Creating new embed ui object")
# Initial queue display
queue_display = []
for i in range(self.queue_display):
queue_display.append("{}. ---\n".format(str(i + 1)))
... | python | def new_embed_ui(self):
"""Create the embed UI object and save it to self"""
self.logger.debug("Creating new embed ui object")
# Initial queue display
queue_display = []
for i in range(self.queue_display):
queue_display.append("{}. ---\n".format(str(i + 1)))
... | [
"def",
"new_embed_ui",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Creating new embed ui object\"",
")",
"# Initial queue display",
"queue_display",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"queue_display",
")",
":",
... | Create the embed UI object and save it to self | [
"Create",
"the",
"embed",
"UI",
"object",
"and",
"save",
"it",
"to",
"self"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L732-L795 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.add_reactions | async def add_reactions(self):
"""Adds the reactions buttons to the current message"""
self.statuslog.info("Loading buttons")
for e in ("⏯", "⏮", "⏹", "⏭", "🔀", "🔉", "🔊"):
try:
if self.embed is not None:
await client.add_reaction(self.embed.sent... | python | async def add_reactions(self):
"""Adds the reactions buttons to the current message"""
self.statuslog.info("Loading buttons")
for e in ("⏯", "⏮", "⏹", "⏭", "🔀", "🔉", "🔊"):
try:
if self.embed is not None:
await client.add_reaction(self.embed.sent... | [
"async",
"def",
"add_reactions",
"(",
"self",
")",
":",
"self",
".",
"statuslog",
".",
"info",
"(",
"\"Loading buttons\"",
")",
"for",
"e",
"in",
"(",
"\"⏯\", ",
"\"",
"\", \"⏹",
"\"",
" \"⏭\",",
" ",
"🔀\", \"",
"🔉",
", \"🔊\")",
":",
"",
"",
"",
"",... | Adds the reactions buttons to the current message | [
"Adds",
"the",
"reactions",
"buttons",
"to",
"the",
"current",
"message"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L797-L808 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.enqueue | async def enqueue(self, query, queue_index=None, stop_current=False, shuffle=False):
"""
Queues songs based on either a YouTube search or a link
Args:
query (str): Either a search term or a link
queue_index (str): The queue index to enqueue at (None for end)
... | python | async def enqueue(self, query, queue_index=None, stop_current=False, shuffle=False):
"""
Queues songs based on either a YouTube search or a link
Args:
query (str): Either a search term or a link
queue_index (str): The queue index to enqueue at (None for end)
... | [
"async",
"def",
"enqueue",
"(",
"self",
",",
"query",
",",
"queue_index",
"=",
"None",
",",
"stop_current",
"=",
"False",
",",
"shuffle",
"=",
"False",
")",
":",
"if",
"query",
"is",
"None",
"or",
"query",
"==",
"\"\"",
":",
"return",
"self",
".",
"s... | Queues songs based on either a YouTube search or a link
Args:
query (str): Either a search term or a link
queue_index (str): The queue index to enqueue at (None for end)
stop_current (bool): Whether to stop the current song after the songs are queued
shuffle (boo... | [
"Queues",
"songs",
"based",
"on",
"either",
"a",
"YouTube",
"search",
"or",
"a",
"link"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L810-L845 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.parse_query | def parse_query(self, query, index, stop_current, shuffle):
"""
Parses a query and adds it to the queue
Args:
query (str): Either a search term or a link
index (int): The index to enqueue at (None for end)
stop_current (bool): Whether to stop the current song... | python | def parse_query(self, query, index, stop_current, shuffle):
"""
Parses a query and adds it to the queue
Args:
query (str): Either a search term or a link
index (int): The index to enqueue at (None for end)
stop_current (bool): Whether to stop the current song... | [
"def",
"parse_query",
"(",
"self",
",",
"query",
",",
"index",
",",
"stop_current",
",",
"shuffle",
")",
":",
"if",
"index",
"is",
"not",
"None",
"and",
"len",
"(",
"self",
".",
"queue",
")",
">",
"0",
":",
"if",
"index",
"<",
"0",
"or",
"index",
... | Parses a query and adds it to the queue
Args:
query (str): Either a search term or a link
index (int): The index to enqueue at (None for end)
stop_current (bool): Whether to stop the current song after the songs are queued
shuffle (bool): Whether to shuffle the a... | [
"Parses",
"a",
"query",
"and",
"adds",
"it",
"to",
"the",
"queue"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L847-L890 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.update_queue | def update_queue(self):
"""Updates the queue in the music player """
self.logger.debug("Updating queue display")
queue_display = []
for i in range(self.queue_display):
try:
if len(self.queue[i][1]) > 40:
songname = self.queue[i][1][:37] +... | python | def update_queue(self):
"""Updates the queue in the music player """
self.logger.debug("Updating queue display")
queue_display = []
for i in range(self.queue_display):
try:
if len(self.queue[i][1]) > 40:
songname = self.queue[i][1][:37] +... | [
"def",
"update_queue",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Updating queue display\"",
")",
"queue_display",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"queue_display",
")",
":",
"try",
":",
"if",
"len",
... | Updates the queue in the music player | [
"Updates",
"the",
"queue",
"in",
"the",
"music",
"player"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L892-L909 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.set_topic | async def set_topic(self, topic):
"""Sets the topic for the topic channel"""
self.topic = topic
try:
if self.topicchannel:
await client.edit_channel(self.topicchannel, topic=topic)
except Exception as e:
logger.exception(e) | python | async def set_topic(self, topic):
"""Sets the topic for the topic channel"""
self.topic = topic
try:
if self.topicchannel:
await client.edit_channel(self.topicchannel, topic=topic)
except Exception as e:
logger.exception(e) | [
"async",
"def",
"set_topic",
"(",
"self",
",",
"topic",
")",
":",
"self",
".",
"topic",
"=",
"topic",
"try",
":",
"if",
"self",
".",
"topicchannel",
":",
"await",
"client",
".",
"edit_channel",
"(",
"self",
".",
"topicchannel",
",",
"topic",
"=",
"topi... | Sets the topic for the topic channel | [
"Sets",
"the",
"topic",
"for",
"the",
"topic",
"channel"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L911-L918 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.clear_cache | def clear_cache(self):
"""Removes all files from the songcache dir"""
self.logger.debug("Clearing cache")
if os.path.isdir(self.songcache_dir):
for filename in os.listdir(self.songcache_dir):
file_path = os.path.join(self.songcache_dir, filename)
try:
... | python | def clear_cache(self):
"""Removes all files from the songcache dir"""
self.logger.debug("Clearing cache")
if os.path.isdir(self.songcache_dir):
for filename in os.listdir(self.songcache_dir):
file_path = os.path.join(self.songcache_dir, filename)
try:
... | [
"def",
"clear_cache",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Clearing cache\"",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"songcache_dir",
")",
":",
"for",
"filename",
"in",
"os",
".",
"listdir",
"(",
... | Removes all files from the songcache dir | [
"Removes",
"all",
"files",
"from",
"the",
"songcache",
"dir"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L945-L958 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.move_next_cache | def move_next_cache(self):
"""Moves files in the 'next' cache dir to the root"""
if not os.path.isdir(self.songcache_next_dir):
return
logger.debug("Moving next cache")
files = os.listdir(self.songcache_next_dir)
for f in files:
try:
os.re... | python | def move_next_cache(self):
"""Moves files in the 'next' cache dir to the root"""
if not os.path.isdir(self.songcache_next_dir):
return
logger.debug("Moving next cache")
files = os.listdir(self.songcache_next_dir)
for f in files:
try:
os.re... | [
"def",
"move_next_cache",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"songcache_next_dir",
")",
":",
"return",
"logger",
".",
"debug",
"(",
"\"Moving next cache\"",
")",
"files",
"=",
"os",
".",
"listdir",
"(",... | Moves files in the 'next' cache dir to the root | [
"Moves",
"files",
"in",
"the",
"next",
"cache",
"dir",
"to",
"the",
"root"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L960-L974 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.ytdl_progress_hook | def ytdl_progress_hook(self, d):
"""Called when youtube-dl updates progress"""
if d['status'] == 'downloading':
self.play_empty()
if "elapsed" in d:
if d["elapsed"] > self.current_download_elapsed + 4:
self.current_download_elapsed = d["elapse... | python | def ytdl_progress_hook(self, d):
"""Called when youtube-dl updates progress"""
if d['status'] == 'downloading':
self.play_empty()
if "elapsed" in d:
if d["elapsed"] > self.current_download_elapsed + 4:
self.current_download_elapsed = d["elapse... | [
"def",
"ytdl_progress_hook",
"(",
"self",
",",
"d",
")",
":",
"if",
"d",
"[",
"'status'",
"]",
"==",
"'downloading'",
":",
"self",
".",
"play_empty",
"(",
")",
"if",
"\"elapsed\"",
"in",
"d",
":",
"if",
"d",
"[",
"\"elapsed\"",
"]",
">",
"self",
".",... | Called when youtube-dl updates progress | [
"Called",
"when",
"youtube",
"-",
"dl",
"updates",
"progress"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L976-L1031 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.play_empty | def play_empty(self):
"""Play blank audio to let Discord know we're still here"""
if self.vclient:
if self.streamer:
self.streamer.volume = 0
self.vclient.play_audio("\n".encode(), encode=False) | python | def play_empty(self):
"""Play blank audio to let Discord know we're still here"""
if self.vclient:
if self.streamer:
self.streamer.volume = 0
self.vclient.play_audio("\n".encode(), encode=False) | [
"def",
"play_empty",
"(",
"self",
")",
":",
"if",
"self",
".",
"vclient",
":",
"if",
"self",
".",
"streamer",
":",
"self",
".",
"streamer",
".",
"volume",
"=",
"0",
"self",
".",
"vclient",
".",
"play_audio",
"(",
"\"\\n\"",
".",
"encode",
"(",
")",
... | Play blank audio to let Discord know we're still here | [
"Play",
"blank",
"audio",
"to",
"let",
"Discord",
"know",
"we",
"re",
"still",
"here"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L1033-L1038 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.download_next_song | def download_next_song(self, song):
"""Downloads the next song and starts playing it"""
dl_ydl_opts = dict(ydl_opts)
dl_ydl_opts["progress_hooks"] = [self.ytdl_progress_hook]
dl_ydl_opts["outtmpl"] = self.output_format
# Move the songs from the next cache to the current cache
... | python | def download_next_song(self, song):
"""Downloads the next song and starts playing it"""
dl_ydl_opts = dict(ydl_opts)
dl_ydl_opts["progress_hooks"] = [self.ytdl_progress_hook]
dl_ydl_opts["outtmpl"] = self.output_format
# Move the songs from the next cache to the current cache
... | [
"def",
"download_next_song",
"(",
"self",
",",
"song",
")",
":",
"dl_ydl_opts",
"=",
"dict",
"(",
"ydl_opts",
")",
"dl_ydl_opts",
"[",
"\"progress_hooks\"",
"]",
"=",
"[",
"self",
".",
"ytdl_progress_hook",
"]",
"dl_ydl_opts",
"[",
"\"outtmpl\"",
"]",
"=",
"... | Downloads the next song and starts playing it | [
"Downloads",
"the",
"next",
"song",
"and",
"starts",
"playing",
"it"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L1040-L1076 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.download_next_song_cache | def download_next_song_cache(self):
"""Downloads the next song in the queue to the cache"""
if len(self.queue) == 0:
return
cache_ydl_opts = dict(ydl_opts)
cache_ydl_opts["outtmpl"] = self.output_format_next
with youtube_dl.YoutubeDL(cache_ydl_opts) as ydl:
... | python | def download_next_song_cache(self):
"""Downloads the next song in the queue to the cache"""
if len(self.queue) == 0:
return
cache_ydl_opts = dict(ydl_opts)
cache_ydl_opts["outtmpl"] = self.output_format_next
with youtube_dl.YoutubeDL(cache_ydl_opts) as ydl:
... | [
"def",
"download_next_song_cache",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"queue",
")",
"==",
"0",
":",
"return",
"cache_ydl_opts",
"=",
"dict",
"(",
"ydl_opts",
")",
"cache_ydl_opts",
"[",
"\"outtmpl\"",
"]",
"=",
"self",
".",
"output_forma... | Downloads the next song in the queue to the cache | [
"Downloads",
"the",
"next",
"song",
"in",
"the",
"queue",
"to",
"the",
"cache"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L1078-L1091 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.create_ffmpeg_player | async def create_ffmpeg_player(self, filepath):
"""Creates a streamer that plays from a file"""
self.current_download_elapsed = 0
self.streamer = self.vclient.create_ffmpeg_player(filepath, after=self.vafter_ts)
self.state = "ready"
await self.setup_streamer()
try:
... | python | async def create_ffmpeg_player(self, filepath):
"""Creates a streamer that plays from a file"""
self.current_download_elapsed = 0
self.streamer = self.vclient.create_ffmpeg_player(filepath, after=self.vafter_ts)
self.state = "ready"
await self.setup_streamer()
try:
... | [
"async",
"def",
"create_ffmpeg_player",
"(",
"self",
",",
"filepath",
")",
":",
"self",
".",
"current_download_elapsed",
"=",
"0",
"self",
".",
"streamer",
"=",
"self",
".",
"vclient",
".",
"create_ffmpeg_player",
"(",
"filepath",
",",
"after",
"=",
"self",
... | Creates a streamer that plays from a file | [
"Creates",
"a",
"streamer",
"that",
"plays",
"from",
"a",
"file"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L1093-L1126 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.create_stream_player | async def create_stream_player(self, url, opts=ydl_opts):
"""Creates a streamer that plays from a URL"""
self.current_download_elapsed = 0
self.streamer = await self.vclient.create_ytdl_player(url, ytdl_options=opts, after=self.vafter_ts)
self.state = "ready"
await self.setup_s... | python | async def create_stream_player(self, url, opts=ydl_opts):
"""Creates a streamer that plays from a URL"""
self.current_download_elapsed = 0
self.streamer = await self.vclient.create_ytdl_player(url, ytdl_options=opts, after=self.vafter_ts)
self.state = "ready"
await self.setup_s... | [
"async",
"def",
"create_stream_player",
"(",
"self",
",",
"url",
",",
"opts",
"=",
"ydl_opts",
")",
":",
"self",
".",
"current_download_elapsed",
"=",
"0",
"self",
".",
"streamer",
"=",
"await",
"self",
".",
"vclient",
".",
"create_ytdl_player",
"(",
"url",
... | Creates a streamer that plays from a URL | [
"Creates",
"a",
"streamer",
"that",
"plays",
"from",
"a",
"URL"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L1128-L1147 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.setup_streamer | async def setup_streamer(self):
"""Sets up basic defaults for the streamer"""
self.streamer.volume = self.volume / 100
self.streamer.start()
self.pause_time = None
self.vclient_starttime = self.vclient.loop.time()
# Cache next song
self.logger.debug("Caching nex... | python | async def setup_streamer(self):
"""Sets up basic defaults for the streamer"""
self.streamer.volume = self.volume / 100
self.streamer.start()
self.pause_time = None
self.vclient_starttime = self.vclient.loop.time()
# Cache next song
self.logger.debug("Caching nex... | [
"async",
"def",
"setup_streamer",
"(",
"self",
")",
":",
"self",
".",
"streamer",
".",
"volume",
"=",
"self",
".",
"volume",
"/",
"100",
"self",
".",
"streamer",
".",
"start",
"(",
")",
"self",
".",
"pause_time",
"=",
"None",
"self",
".",
"vclient_star... | Sets up basic defaults for the streamer | [
"Sets",
"up",
"basic",
"defaults",
"for",
"the",
"streamer"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L1149-L1160 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.vafter_ts | def vafter_ts(self):
"""Function that is called after a song finishes playing"""
logger.debug("Song finishing")
future = asyncio.run_coroutine_threadsafe(self.vafter(), client.loop)
try:
future.result()
except Exception as e:
logger.exception(e) | python | def vafter_ts(self):
"""Function that is called after a song finishes playing"""
logger.debug("Song finishing")
future = asyncio.run_coroutine_threadsafe(self.vafter(), client.loop)
try:
future.result()
except Exception as e:
logger.exception(e) | [
"def",
"vafter_ts",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Song finishing\"",
")",
"future",
"=",
"asyncio",
".",
"run_coroutine_threadsafe",
"(",
"self",
".",
"vafter",
"(",
")",
",",
"client",
".",
"loop",
")",
"try",
":",
"future",
"."... | Function that is called after a song finishes playing | [
"Function",
"that",
"is",
"called",
"after",
"a",
"song",
"finishes",
"playing"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L1241-L1248 |
ModisWorks/modis | modis/discord_modis/modules/music/_musicplayer.py | MusicPlayer.vafter | async def vafter(self):
"""Function that is called after a song finishes playing"""
self.logger.debug("Finished playing a song")
if self.state != 'ready':
self.logger.debug("Returning because player is in state {}".format(self.state))
return
self.pause_time = Non... | python | async def vafter(self):
"""Function that is called after a song finishes playing"""
self.logger.debug("Finished playing a song")
if self.state != 'ready':
self.logger.debug("Returning because player is in state {}".format(self.state))
return
self.pause_time = Non... | [
"async",
"def",
"vafter",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Finished playing a song\"",
")",
"if",
"self",
".",
"state",
"!=",
"'ready'",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Returning because player is in state {... | Function that is called after a song finishes playing | [
"Function",
"that",
"is",
"called",
"after",
"a",
"song",
"finishes",
"playing"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L1250-L1279 |
ModisWorks/modis | modis/discord_modis/modules/replies/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/replies/on_message.py#L6-L40 |
ModisWorks/modis | modis/discord_modis/modules/music/api_music.py | build_yt_api | def build_yt_api():
"""Build the YouTube API for future use"""
data = datatools.get_data()
if "google_api_key" not in data["discord"]["keys"]:
logger.warning("No API key found with name 'google_api_key'")
logger.info("Please add your Google API key with name 'google_api_key' "
... | python | def build_yt_api():
"""Build the YouTube API for future use"""
data = datatools.get_data()
if "google_api_key" not in data["discord"]["keys"]:
logger.warning("No API key found with name 'google_api_key'")
logger.info("Please add your Google API key with name 'google_api_key' "
... | [
"def",
"build_yt_api",
"(",
")",
":",
"data",
"=",
"datatools",
".",
"get_data",
"(",
")",
"if",
"\"google_api_key\"",
"not",
"in",
"data",
"[",
"\"discord\"",
"]",
"[",
"\"keys\"",
"]",
":",
"logger",
".",
"warning",
"(",
"\"No API key found with name 'google... | Build the YouTube API for future use | [
"Build",
"the",
"YouTube",
"API",
"for",
"future",
"use"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/api_music.py#L25-L45 |
ModisWorks/modis | modis/discord_modis/modules/music/api_music.py | build_sc_api | def build_sc_api():
"""Build the SoundCloud API for future use"""
data = datatools.get_data()
if "soundcloud_client_id" not in data["discord"]["keys"]:
logger.warning("No API key found with name 'soundcloud_client_id'")
logger.info("Please add your SoundCloud client id with name 'soundcloud_... | python | def build_sc_api():
"""Build the SoundCloud API for future use"""
data = datatools.get_data()
if "soundcloud_client_id" not in data["discord"]["keys"]:
logger.warning("No API key found with name 'soundcloud_client_id'")
logger.info("Please add your SoundCloud client id with name 'soundcloud_... | [
"def",
"build_sc_api",
"(",
")",
":",
"data",
"=",
"datatools",
".",
"get_data",
"(",
")",
"if",
"\"soundcloud_client_id\"",
"not",
"in",
"data",
"[",
"\"discord\"",
"]",
"[",
"\"keys\"",
"]",
":",
"logger",
".",
"warning",
"(",
"\"No API key found with name '... | Build the SoundCloud API for future use | [
"Build",
"the",
"SoundCloud",
"API",
"for",
"future",
"use"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/api_music.py#L48-L64 |
ModisWorks/modis | modis/discord_modis/modules/music/api_music.py | build_spotify_api | def build_spotify_api():
"""Build the Spotify API for future use"""
data = datatools.get_data()
if "spotify_client_id" not in data["discord"]["keys"]:
logger.warning("No API key found with name 'spotify_client_id'")
logger.info("Please add your Spotify client id with name 'spotify_client_id'... | python | def build_spotify_api():
"""Build the Spotify API for future use"""
data = datatools.get_data()
if "spotify_client_id" not in data["discord"]["keys"]:
logger.warning("No API key found with name 'spotify_client_id'")
logger.info("Please add your Spotify client id with name 'spotify_client_id'... | [
"def",
"build_spotify_api",
"(",
")",
":",
"data",
"=",
"datatools",
".",
"get_data",
"(",
")",
"if",
"\"spotify_client_id\"",
"not",
"in",
"data",
"[",
"\"discord\"",
"]",
"[",
"\"keys\"",
"]",
":",
"logger",
".",
"warning",
"(",
"\"No API key found with name... | Build the Spotify API for future use | [
"Build",
"the",
"Spotify",
"API",
"for",
"future",
"use"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/api_music.py#L67-L91 |
ModisWorks/modis | modis/discord_modis/modules/music/api_music.py | parse_query | def parse_query(query, ilogger):
"""
Gets either a list of videos from a query, parsing links and search queries
and playlists
Args:
query (str): The YouTube search query
ilogger (logging.logger): The logger to log API calls to
Returns:
queue (list): The items obtained from... | python | def parse_query(query, ilogger):
"""
Gets either a list of videos from a query, parsing links and search queries
and playlists
Args:
query (str): The YouTube search query
ilogger (logging.logger): The logger to log API calls to
Returns:
queue (list): The items obtained from... | [
"def",
"parse_query",
"(",
"query",
",",
"ilogger",
")",
":",
"# Try parsing this as a link",
"p",
"=",
"urlparse",
"(",
"query",
")",
"if",
"p",
"and",
"p",
".",
"scheme",
"and",
"p",
".",
"netloc",
":",
"if",
"\"youtube\"",
"in",
"p",
".",
"netloc",
... | Gets either a list of videos from a query, parsing links and search queries
and playlists
Args:
query (str): The YouTube search query
ilogger (logging.logger): The logger to log API calls to
Returns:
queue (list): The items obtained from the YouTube search | [
"Gets",
"either",
"a",
"list",
"of",
"videos",
"from",
"a",
"query",
"parsing",
"links",
"and",
"search",
"queries",
"and",
"playlists"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/api_music.py#L94-L234 |
ModisWorks/modis | modis/discord_modis/modules/music/api_music.py | get_ytvideos | def get_ytvideos(query, ilogger):
"""
Gets either a list of videos from a playlist or a single video, using the
first result of a YouTube search
Args:
query (str): The YouTube search query
ilogger (logging.logger): The logger to log API calls to
Returns:
queue (list): The i... | python | def get_ytvideos(query, ilogger):
"""
Gets either a list of videos from a playlist or a single video, using the
first result of a YouTube search
Args:
query (str): The YouTube search query
ilogger (logging.logger): The logger to log API calls to
Returns:
queue (list): The i... | [
"def",
"get_ytvideos",
"(",
"query",
",",
"ilogger",
")",
":",
"queue",
"=",
"[",
"]",
"# Search YouTube",
"search_result",
"=",
"ytdiscoveryapi",
".",
"search",
"(",
")",
".",
"list",
"(",
"q",
"=",
"query",
",",
"part",
"=",
"\"id,snippet\"",
",",
"max... | Gets either a list of videos from a playlist or a single video, using the
first result of a YouTube search
Args:
query (str): The YouTube search query
ilogger (logging.logger): The logger to log API calls to
Returns:
queue (list): The items obtained from the YouTube search | [
"Gets",
"either",
"a",
"list",
"of",
"videos",
"from",
"a",
"playlist",
"or",
"a",
"single",
"video",
"using",
"the",
"first",
"result",
"of",
"a",
"YouTube",
"search"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/api_music.py#L237-L279 |
ModisWorks/modis | modis/discord_modis/modules/music/api_music.py | duration_to_string | def duration_to_string(duration):
"""
Converts a duration to a string
Args:
duration (int): The duration in seconds to convert
Returns s (str): The duration as a string
"""
m, s = divmod(duration, 60)
h, m = divmod(m, 60)
return "%d:%02d:%02d" % (h, m, s) | python | def duration_to_string(duration):
"""
Converts a duration to a string
Args:
duration (int): The duration in seconds to convert
Returns s (str): The duration as a string
"""
m, s = divmod(duration, 60)
h, m = divmod(m, 60)
return "%d:%02d:%02d" % (h, m, s) | [
"def",
"duration_to_string",
"(",
"duration",
")",
":",
"m",
",",
"s",
"=",
"divmod",
"(",
"duration",
",",
"60",
")",
"h",
",",
"m",
"=",
"divmod",
"(",
"m",
",",
"60",
")",
"return",
"\"%d:%02d:%02d\"",
"%",
"(",
"h",
",",
"m",
",",
"s",
")"
] | Converts a duration to a string
Args:
duration (int): The duration in seconds to convert
Returns s (str): The duration as a string | [
"Converts",
"a",
"duration",
"to",
"a",
"string"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/api_music.py#L458-L470 |
ModisWorks/modis | modis/discord_modis/modules/music/api_music.py | parse_source | def parse_source(info):
"""
Parses the source info from an info dict generated by youtube-dl
Args:
info (dict): The info dict to parse
Returns:
source (str): The source of this song
"""
if "extractor_key" in info:
source = info["extractor_key"]
lower_source = s... | python | def parse_source(info):
"""
Parses the source info from an info dict generated by youtube-dl
Args:
info (dict): The info dict to parse
Returns:
source (str): The source of this song
"""
if "extractor_key" in info:
source = info["extractor_key"]
lower_source = s... | [
"def",
"parse_source",
"(",
"info",
")",
":",
"if",
"\"extractor_key\"",
"in",
"info",
":",
"source",
"=",
"info",
"[",
"\"extractor_key\"",
"]",
"lower_source",
"=",
"source",
".",
"lower",
"(",
")",
"for",
"key",
"in",
"SOURCE_TO_NAME",
":",
"lower_key",
... | Parses the source info from an info dict generated by youtube-dl
Args:
info (dict): The info dict to parse
Returns:
source (str): The source of this song | [
"Parses",
"the",
"source",
"info",
"from",
"an",
"info",
"dict",
"generated",
"by",
"youtube",
"-",
"dl"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/api_music.py#L473-L501 |
ModisWorks/modis | modis/discord_modis/modules/tableflip/api_flipcheck.py | flipcheck | def flipcheck(content):
"""Checks a string for anger and soothes said anger
Args:
content (str): The message to be flipchecked
Returns:
putitback (str): The righted table or text
"""
# Prevent tampering with flip
punct = """!"#$%&'*+,-./:;<=>?@[\]^_`{|}~ ━─"""
tamperdict =... | python | def flipcheck(content):
"""Checks a string for anger and soothes said anger
Args:
content (str): The message to be flipchecked
Returns:
putitback (str): The righted table or text
"""
# Prevent tampering with flip
punct = """!"#$%&'*+,-./:;<=>?@[\]^_`{|}~ ━─"""
tamperdict =... | [
"def",
"flipcheck",
"(",
"content",
")",
":",
"# Prevent tampering with flip",
"punct",
"=",
"\"\"\"!\"#$%&'*+,-./:;<=>?@[\\]^_`{|}~ ━─\"\"\"",
"tamperdict",
"=",
"str",
".",
"maketrans",
"(",
"''",
",",
"''",
",",
"punct",
")",
"tamperproof",
"=",
"content",
".",
... | Checks a string for anger and soothes said anger
Args:
content (str): The message to be flipchecked
Returns:
putitback (str): The righted table or text | [
"Checks",
"a",
"string",
"for",
"anger",
"and",
"soothes",
"said",
"anger"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/tableflip/api_flipcheck.py#L1-L59 |
ModisWorks/modis | modis/discord_modis/modules/_chatbot/api_mitsuku.py | get_botcust2 | def get_botcust2():
"""Gets a botcust2, used to identify a speaker with Mitsuku
Returns:
botcust2 (str): The botcust2 identifier
"""
logger.debug("Getting new botcust2")
# Set up http request packages
params = {
'botid': 'f6a012073e345a08',
'amp;skin': 'chat'
}
... | python | def get_botcust2():
"""Gets a botcust2, used to identify a speaker with Mitsuku
Returns:
botcust2 (str): The botcust2 identifier
"""
logger.debug("Getting new botcust2")
# Set up http request packages
params = {
'botid': 'f6a012073e345a08',
'amp;skin': 'chat'
}
... | [
"def",
"get_botcust2",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"Getting new botcust2\"",
")",
"# Set up http request packages",
"params",
"=",
"{",
"'botid'",
":",
"'f6a012073e345a08'",
",",
"'amp;skin'",
":",
"'chat'",
"}",
"headers",
"=",
"{",
"'Accept'",
... | Gets a botcust2, used to identify a speaker with Mitsuku
Returns:
botcust2 (str): The botcust2 identifier | [
"Gets",
"a",
"botcust2",
"used",
"to",
"identify",
"a",
"speaker",
"with",
"Mitsuku"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/_chatbot/api_mitsuku.py#L12-L55 |
ModisWorks/modis | modis/discord_modis/modules/_chatbot/api_mitsuku.py | query | def query(botcust2, message):
"""Sends a message to Mitsuku and retrieves the reply
Args:
botcust2 (str): The botcust2 identifier
message (str): The message to send to Mitsuku
Returns:
reply (str): The message Mitsuku sent back
"""
logger.debug("Getting Mitsuku reply")
... | python | def query(botcust2, message):
"""Sends a message to Mitsuku and retrieves the reply
Args:
botcust2 (str): The botcust2 identifier
message (str): The message to send to Mitsuku
Returns:
reply (str): The message Mitsuku sent back
"""
logger.debug("Getting Mitsuku reply")
... | [
"def",
"query",
"(",
"botcust2",
",",
"message",
")",
":",
"logger",
".",
"debug",
"(",
"\"Getting Mitsuku reply\"",
")",
"# Set up http request packages",
"params",
"=",
"{",
"'botid'",
":",
"'f6a012073e345a08'",
",",
"'amp;skin'",
":",
"'chat'",
"}",
"headers",
... | Sends a message to Mitsuku and retrieves the reply
Args:
botcust2 (str): The botcust2 identifier
message (str): The message to send to Mitsuku
Returns:
reply (str): The message Mitsuku sent back | [
"Sends",
"a",
"message",
"to",
"Mitsuku",
"and",
"retrieves",
"the",
"reply"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/_chatbot/api_mitsuku.py#L58-L116 |
ModisWorks/modis | modis/discord_modis/modules/music/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/music/on_message.py#L12-L122 |
ModisWorks/modis | modis/discord_modis/main.py | start | def start(token, client_id, loop, on_ready_handler=None):
"""Start the Discord client and log Modis into Discord."""
import discord
import asyncio
# Create client
logger.debug("Creating Discord client")
asyncio.set_event_loop(loop)
client = discord.Client()
from . import _client
_cl... | python | def start(token, client_id, loop, on_ready_handler=None):
"""Start the Discord client and log Modis into Discord."""
import discord
import asyncio
# Create client
logger.debug("Creating Discord client")
asyncio.set_event_loop(loop)
client = discord.Client()
from . import _client
_cl... | [
"def",
"start",
"(",
"token",
",",
"client_id",
",",
"loop",
",",
"on_ready_handler",
"=",
"None",
")",
":",
"import",
"discord",
"import",
"asyncio",
"# Create client",
"logger",
".",
"debug",
"(",
"\"Creating Discord client\"",
")",
"asyncio",
".",
"set_event_... | Start the Discord client and log Modis into Discord. | [
"Start",
"the",
"Discord",
"client",
"and",
"log",
"Modis",
"into",
"Discord",
"."
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/main.py#L6-L107 |
ModisWorks/modis | modis/discord_modis/main.py | _get_event_handlers | def _get_event_handlers():
"""
Gets dictionary of event handlers and the modules that define them
Returns:
event_handlers (dict): Contains "all", "on_ready", "on_message", "on_reaction_add", "on_error"
"""
import os
import importlib
event_handlers = {
"on_ready": [],
... | python | def _get_event_handlers():
"""
Gets dictionary of event handlers and the modules that define them
Returns:
event_handlers (dict): Contains "all", "on_ready", "on_message", "on_reaction_add", "on_error"
"""
import os
import importlib
event_handlers = {
"on_ready": [],
... | [
"def",
"_get_event_handlers",
"(",
")",
":",
"import",
"os",
"import",
"importlib",
"event_handlers",
"=",
"{",
"\"on_ready\"",
":",
"[",
"]",
",",
"\"on_resume\"",
":",
"[",
"]",
",",
"\"on_error\"",
":",
"[",
"]",
",",
"\"on_message\"",
":",
"[",
"]",
... | Gets dictionary of event handlers and the modules that define them
Returns:
event_handlers (dict): Contains "all", "on_ready", "on_message", "on_reaction_add", "on_error" | [
"Gets",
"dictionary",
"of",
"event",
"handlers",
"and",
"the",
"modules",
"that",
"define",
"them"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/main.py#L110-L180 |
ModisWorks/modis | modis/discord_modis/main.py | add_api_key | def add_api_key(key, value):
"""
Adds a key to the bot's data
Args:
key: The name of the key to add
value: The value for the key
"""
if key is None or key == "":
logger.error("Key cannot be empty")
if value is None or value == "":
logger.error("Value cannot be ... | python | def add_api_key(key, value):
"""
Adds a key to the bot's data
Args:
key: The name of the key to add
value: The value for the key
"""
if key is None or key == "":
logger.error("Key cannot be empty")
if value is None or value == "":
logger.error("Value cannot be ... | [
"def",
"add_api_key",
"(",
"key",
",",
"value",
")",
":",
"if",
"key",
"is",
"None",
"or",
"key",
"==",
"\"\"",
":",
"logger",
".",
"error",
"(",
"\"Key cannot be empty\"",
")",
"if",
"value",
"is",
"None",
"or",
"value",
"==",
"\"\"",
":",
"logger",
... | Adds a key to the bot's data
Args:
key: The name of the key to add
value: The value for the key | [
"Adds",
"a",
"key",
"to",
"the",
"bot",
"s",
"data"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/main.py#L183-L215 |
ModisWorks/modis | modis/discord_modis/modules/help/ui_embed.py | success | def success(channel, title, datapacks):
"""
Creates an embed UI containing the help message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
title (str): The title of the embed
datapacks (list): The hex value
Returns:
ui (ui_embed.UI): The embed... | python | def success(channel, title, datapacks):
"""
Creates an embed UI containing the help message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
title (str): The title of the embed
datapacks (list): The hex value
Returns:
ui (ui_embed.UI): The embed... | [
"def",
"success",
"(",
"channel",
",",
"title",
",",
"datapacks",
")",
":",
"# Create embed UI object",
"gui",
"=",
"ui_embed",
".",
"UI",
"(",
"channel",
",",
"title",
",",
"\"\"",
",",
"modulename",
"=",
"modulename",
",",
"datapacks",
"=",
"datapacks",
... | Creates an embed UI containing the help message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
title (str): The title of the embed
datapacks (list): The hex value
Returns:
ui (ui_embed.UI): The embed UI object | [
"Creates",
"an",
"embed",
"UI",
"containing",
"the",
"help",
"message"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/help/ui_embed.py#L5-L27 |
ModisWorks/modis | modis/discord_modis/modules/help/ui_embed.py | http_exception | def http_exception(channel, title):
"""
Creates an embed UI containing the 'too long' error message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
title (str): The title of the embed
Returns:
ui (ui_embed.UI): The embed UI object
"""
# Create... | python | def http_exception(channel, title):
"""
Creates an embed UI containing the 'too long' error message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
title (str): The title of the embed
Returns:
ui (ui_embed.UI): The embed UI object
"""
# Create... | [
"def",
"http_exception",
"(",
"channel",
",",
"title",
")",
":",
"# Create embed UI object",
"gui",
"=",
"ui_embed",
".",
"UI",
"(",
"channel",
",",
"\"Too much help\"",
",",
"\"{} is too helpful! Try trimming some of the help messages.\"",
".",
"format",
"(",
"title",
... | Creates an embed UI containing the 'too long' error message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
title (str): The title of the embed
Returns:
ui (ui_embed.UI): The embed UI object | [
"Creates",
"an",
"embed",
"UI",
"containing",
"the",
"too",
"long",
"error",
"message"
] | train | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/help/ui_embed.py#L30-L50 |
tarbell-project/tarbell | tarbell/configure.py | tarbell_configure | def tarbell_configure(command, args):
"""
Tarbell configuration routine.
"""
puts("Configuring Tarbell. Press ctrl-c to bail out!")
# Check if there's settings configured
settings = Settings()
path = settings.path
prompt = True
if len(args):
prompt = False
config = _ge... | python | def tarbell_configure(command, args):
"""
Tarbell configuration routine.
"""
puts("Configuring Tarbell. Press ctrl-c to bail out!")
# Check if there's settings configured
settings = Settings()
path = settings.path
prompt = True
if len(args):
prompt = False
config = _ge... | [
"def",
"tarbell_configure",
"(",
"command",
",",
"args",
")",
":",
"puts",
"(",
"\"Configuring Tarbell. Press ctrl-c to bail out!\"",
")",
"# Check if there's settings configured",
"settings",
"=",
"Settings",
"(",
")",
"path",
"=",
"settings",
".",
"path",
"prompt",
... | Tarbell configuration routine. | [
"Tarbell",
"configuration",
"routine",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/configure.py#L26-L68 |
tarbell-project/tarbell | tarbell/configure.py | _get_or_create_config | def _get_or_create_config(path, prompt=True):
"""
Get or create a Tarbell configuration directory.
"""
dirname = os.path.dirname(path)
filename = os.path.basename(path)
try:
os.makedirs(dirname)
except OSError:
pass
try:
with open(path, 'r+') as f:
i... | python | def _get_or_create_config(path, prompt=True):
"""
Get or create a Tarbell configuration directory.
"""
dirname = os.path.dirname(path)
filename = os.path.basename(path)
try:
os.makedirs(dirname)
except OSError:
pass
try:
with open(path, 'r+') as f:
i... | [
"def",
"_get_or_create_config",
"(",
"path",
",",
"prompt",
"=",
"True",
")",
":",
"dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"try",
":",
"os",
".",
"m... | Get or create a Tarbell configuration directory. | [
"Get",
"or",
"create",
"a",
"Tarbell",
"configuration",
"directory",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/configure.py#L71-L90 |
tarbell-project/tarbell | tarbell/configure.py | _setup_google_spreadsheets | def _setup_google_spreadsheets(settings, path, prompt=True):
"""
Set up a Google spreadsheet.
"""
ret = {}
if prompt:
use = raw_input("\nWould you like to use Google spreadsheets [Y/n]? ")
if use.lower() != "y" and use != "":
return settings
dirname = os.path.dirname... | python | def _setup_google_spreadsheets(settings, path, prompt=True):
"""
Set up a Google spreadsheet.
"""
ret = {}
if prompt:
use = raw_input("\nWould you like to use Google spreadsheets [Y/n]? ")
if use.lower() != "y" and use != "":
return settings
dirname = os.path.dirname... | [
"def",
"_setup_google_spreadsheets",
"(",
"settings",
",",
"path",
",",
"prompt",
"=",
"True",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"prompt",
":",
"use",
"=",
"raw_input",
"(",
"\"\\nWould you like to use Google spreadsheets [Y/n]? \"",
")",
"if",
"use",
".",
... | Set up a Google spreadsheet. | [
"Set",
"up",
"a",
"Google",
"spreadsheet",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/configure.py#L93-L158 |
tarbell-project/tarbell | tarbell/configure.py | _setup_s3 | def _setup_s3(settings, path, prompt=True):
"""
Prompt user to set up Amazon S3.
"""
ret = {'default_s3_buckets': {}, 's3_credentials': settings.get('s3_credentials', {})}
if prompt:
use = raw_input("\nWould you like to set up Amazon S3? [Y/n] ")
if use.lower() != "y" and use != "":... | python | def _setup_s3(settings, path, prompt=True):
"""
Prompt user to set up Amazon S3.
"""
ret = {'default_s3_buckets': {}, 's3_credentials': settings.get('s3_credentials', {})}
if prompt:
use = raw_input("\nWould you like to set up Amazon S3? [Y/n] ")
if use.lower() != "y" and use != "":... | [
"def",
"_setup_s3",
"(",
"settings",
",",
"path",
",",
"prompt",
"=",
"True",
")",
":",
"ret",
"=",
"{",
"'default_s3_buckets'",
":",
"{",
"}",
",",
"'s3_credentials'",
":",
"settings",
".",
"get",
"(",
"'s3_credentials'",
",",
"{",
"}",
")",
"}",
"if"... | Prompt user to set up Amazon S3. | [
"Prompt",
"user",
"to",
"set",
"up",
"Amazon",
"S3",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/configure.py#L161-L289 |
tarbell-project/tarbell | tarbell/configure.py | _setup_tarbell_project_path | def _setup_tarbell_project_path(settings, path, prompt=True):
"""
Prompt user to set up project path.
"""
default_path = os.path.expanduser(os.path.join("~", "tarbell"))
projects_path = raw_input("\nWhat is your Tarbell projects path? [Default: {0}, 'none' to skip] ".format(default_path))
if pro... | python | def _setup_tarbell_project_path(settings, path, prompt=True):
"""
Prompt user to set up project path.
"""
default_path = os.path.expanduser(os.path.join("~", "tarbell"))
projects_path = raw_input("\nWhat is your Tarbell projects path? [Default: {0}, 'none' to skip] ".format(default_path))
if pro... | [
"def",
"_setup_tarbell_project_path",
"(",
"settings",
",",
"path",
",",
"prompt",
"=",
"True",
")",
":",
"default_path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"os",
".",
"path",
".",
"join",
"(",
"\"~\"",
",",
"\"tarbell\"",
")",
")",
"project... | Prompt user to set up project path. | [
"Prompt",
"user",
"to",
"set",
"up",
"project",
"path",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/configure.py#L292-L313 |
tarbell-project/tarbell | tarbell/configure.py | _setup_default_templates | def _setup_default_templates(settings, path, prompt=True):
"""
Add some (hardcoded) default templates.
"""
project_templates = [{
"name": "Basic Bootstrap 3 template",
"url": "https://github.com/tarbell-project/tarbell-template",
}, {
"name": "Searchable map template",
... | python | def _setup_default_templates(settings, path, prompt=True):
"""
Add some (hardcoded) default templates.
"""
project_templates = [{
"name": "Basic Bootstrap 3 template",
"url": "https://github.com/tarbell-project/tarbell-template",
}, {
"name": "Searchable map template",
... | [
"def",
"_setup_default_templates",
"(",
"settings",
",",
"path",
",",
"prompt",
"=",
"True",
")",
":",
"project_templates",
"=",
"[",
"{",
"\"name\"",
":",
"\"Basic Bootstrap 3 template\"",
",",
"\"url\"",
":",
"\"https://github.com/tarbell-project/tarbell-template\"",
... | Add some (hardcoded) default templates. | [
"Add",
"some",
"(",
"hardcoded",
")",
"default",
"templates",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/configure.py#L316-L334 |
tarbell-project/tarbell | tarbell/configure.py | _backup | def _backup(path, filename):
"""
Backup a file.
"""
target = os.path.join(path, filename)
if os.path.isfile(target):
dt = datetime.now()
new_filename = ".{0}.{1}.{2}".format(
filename, dt.isoformat(), "backup"
)
destination = os.path.join(path, new_filenam... | python | def _backup(path, filename):
"""
Backup a file.
"""
target = os.path.join(path, filename)
if os.path.isfile(target):
dt = datetime.now()
new_filename = ".{0}.{1}.{2}".format(
filename, dt.isoformat(), "backup"
)
destination = os.path.join(path, new_filenam... | [
"def",
"_backup",
"(",
"path",
",",
"filename",
")",
":",
"target",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"filename",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"target",
")",
":",
"dt",
"=",
"datetime",
".",
"now",
"(",
... | Backup a file. | [
"Backup",
"a",
"file",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/configure.py#L337-L353 |
tarbell-project/tarbell | tarbell/slughifi.py | slughifi | def slughifi(value, overwrite_char_map={}):
"""
High Fidelity slugify - slughifi.py, v 0.1
Examples :
>>> text = 'C\'est déjà l\'été.'
>>> slughifi(text)
'cest-deja-lete'
>>> slughifi(text, overwrite_char_map={u'\': '-',})
'c-est-deja-l-ete'
>>> s... | python | def slughifi(value, overwrite_char_map={}):
"""
High Fidelity slugify - slughifi.py, v 0.1
Examples :
>>> text = 'C\'est déjà l\'été.'
>>> slughifi(text)
'cest-deja-lete'
>>> slughifi(text, overwrite_char_map={u'\': '-',})
'c-est-deja-l-ete'
>>> s... | [
"def",
"slughifi",
"(",
"value",
",",
"overwrite_char_map",
"=",
"{",
"}",
")",
":",
"# unicodification",
"if",
"type",
"(",
"value",
")",
"!=",
"text_type",
":",
"value",
"=",
"value",
".",
"decode",
"(",
"'utf-8'",
",",
"'ignore'",
")",
"# overwrite char... | High Fidelity slugify - slughifi.py, v 0.1
Examples :
>>> text = 'C\'est déjà l\'été.'
>>> slughifi(text)
'cest-deja-lete'
>>> slughifi(text, overwrite_char_map={u'\': '-',})
'c-est-deja-l-ete'
>>> slughifi(text, do_slugify=False)
"C'est deja l'ete."
... | [
"High",
"Fidelity",
"slugify",
"-",
"slughifi",
".",
"py",
"v",
"0",
".",
"1"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/slughifi.py#L29-L64 |
tarbell-project/tarbell | tarbell/utils.py | puts | def puts(s='', newline=True, stream=STDOUT):
"""
Wrap puts to avoid getting called twice by Werkzeug reloader.
"""
if not is_werkzeug_process():
try:
return _puts(s, newline, stream)
except UnicodeEncodeError:
return _puts(s.encode(sys.stdout.encoding), newline, s... | python | def puts(s='', newline=True, stream=STDOUT):
"""
Wrap puts to avoid getting called twice by Werkzeug reloader.
"""
if not is_werkzeug_process():
try:
return _puts(s, newline, stream)
except UnicodeEncodeError:
return _puts(s.encode(sys.stdout.encoding), newline, s... | [
"def",
"puts",
"(",
"s",
"=",
"''",
",",
"newline",
"=",
"True",
",",
"stream",
"=",
"STDOUT",
")",
":",
"if",
"not",
"is_werkzeug_process",
"(",
")",
":",
"try",
":",
"return",
"_puts",
"(",
"s",
",",
"newline",
",",
"stream",
")",
"except",
"Unic... | Wrap puts to avoid getting called twice by Werkzeug reloader. | [
"Wrap",
"puts",
"to",
"avoid",
"getting",
"called",
"twice",
"by",
"Werkzeug",
"reloader",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/utils.py#L23-L31 |
tarbell-project/tarbell | tarbell/utils.py | list_get | def list_get(l, idx, default=None):
"""
Get from a list with an optional default value.
"""
try:
if l[idx]:
return l[idx]
else:
return default
except IndexError:
return default | python | def list_get(l, idx, default=None):
"""
Get from a list with an optional default value.
"""
try:
if l[idx]:
return l[idx]
else:
return default
except IndexError:
return default | [
"def",
"list_get",
"(",
"l",
",",
"idx",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"if",
"l",
"[",
"idx",
"]",
":",
"return",
"l",
"[",
"idx",
"]",
"else",
":",
"return",
"default",
"except",
"IndexError",
":",
"return",
"default"
] | Get from a list with an optional default value. | [
"Get",
"from",
"a",
"list",
"with",
"an",
"optional",
"default",
"value",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/utils.py#L34-L44 |
tarbell-project/tarbell | tarbell/utils.py | split_sentences | def split_sentences(s, pad=0):
"""
Split sentences for formatting.
"""
sentences = []
for index, sentence in enumerate(s.split('. ')):
padding = ''
if index > 0:
padding = ' ' * (pad + 1)
if sentence.endswith('.'):
sentence = sentence[:-1]
sent... | python | def split_sentences(s, pad=0):
"""
Split sentences for formatting.
"""
sentences = []
for index, sentence in enumerate(s.split('. ')):
padding = ''
if index > 0:
padding = ' ' * (pad + 1)
if sentence.endswith('.'):
sentence = sentence[:-1]
sent... | [
"def",
"split_sentences",
"(",
"s",
",",
"pad",
"=",
"0",
")",
":",
"sentences",
"=",
"[",
"]",
"for",
"index",
",",
"sentence",
"in",
"enumerate",
"(",
"s",
".",
"split",
"(",
"'. '",
")",
")",
":",
"padding",
"=",
"''",
"if",
"index",
">",
"0",... | Split sentences for formatting. | [
"Split",
"sentences",
"for",
"formatting",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/utils.py#L47-L59 |
tarbell-project/tarbell | tarbell/utils.py | ensure_directory | def ensure_directory(path):
"""
Ensure directory exists for a given file path.
"""
dirname = os.path.dirname(path)
if not os.path.exists(dirname):
os.makedirs(dirname) | python | def ensure_directory(path):
"""
Ensure directory exists for a given file path.
"""
dirname = os.path.dirname(path)
if not os.path.exists(dirname):
os.makedirs(dirname) | [
"def",
"ensure_directory",
"(",
"path",
")",
":",
"dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dirname",
")",
":",
"os",
".",
"makedirs",
"(",
"dirname",
")"
] | Ensure directory exists for a given file path. | [
"Ensure",
"directory",
"exists",
"for",
"a",
"given",
"file",
"path",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/utils.py#L62-L68 |
tarbell-project/tarbell | tarbell/utils.py | show_error | def show_error(msg):
"""
Displays error message.
"""
sys.stdout.flush()
sys.stderr.write("\n{0!s}: {1}".format(colored.red("Error"), msg + '\n')) | python | def show_error(msg):
"""
Displays error message.
"""
sys.stdout.flush()
sys.stderr.write("\n{0!s}: {1}".format(colored.red("Error"), msg + '\n')) | [
"def",
"show_error",
"(",
"msg",
")",
":",
"sys",
".",
"stdout",
".",
"flush",
"(",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"\\n{0!s}: {1}\"",
".",
"format",
"(",
"colored",
".",
"red",
"(",
"\"Error\"",
")",
",",
"msg",
"+",
"'\\n'",
")",
... | Displays error message. | [
"Displays",
"error",
"message",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/utils.py#L71-L76 |
aiortc/pylibsrtp | pylibsrtp/__init__.py | Session.add_stream | def add_stream(self, policy):
"""
Add a stream to the SRTP session, applying the given `policy`
to the stream.
:param policy: :class:`Policy`
"""
_srtp_assert(lib.srtp_add_stream(self._srtp[0], policy._policy)) | python | def add_stream(self, policy):
"""
Add a stream to the SRTP session, applying the given `policy`
to the stream.
:param policy: :class:`Policy`
"""
_srtp_assert(lib.srtp_add_stream(self._srtp[0], policy._policy)) | [
"def",
"add_stream",
"(",
"self",
",",
"policy",
")",
":",
"_srtp_assert",
"(",
"lib",
".",
"srtp_add_stream",
"(",
"self",
".",
"_srtp",
"[",
"0",
"]",
",",
"policy",
".",
"_policy",
")",
")"
] | Add a stream to the SRTP session, applying the given `policy`
to the stream.
:param policy: :class:`Policy` | [
"Add",
"a",
"stream",
"to",
"the",
"SRTP",
"session",
"applying",
"the",
"given",
"policy",
"to",
"the",
"stream",
"."
] | train | https://github.com/aiortc/pylibsrtp/blob/31824d1f8430ff6dc217cfc101093b6ba2a307b2/pylibsrtp/__init__.py#L167-L174 |
aiortc/pylibsrtp | pylibsrtp/__init__.py | Session.remove_stream | def remove_stream(self, ssrc):
"""
Remove the stream with the given `ssrc` from the SRTP session.
:param ssrc: :class:`int`
"""
_srtp_assert(lib.srtp_remove_stream(self._srtp[0], htonl(ssrc))) | python | def remove_stream(self, ssrc):
"""
Remove the stream with the given `ssrc` from the SRTP session.
:param ssrc: :class:`int`
"""
_srtp_assert(lib.srtp_remove_stream(self._srtp[0], htonl(ssrc))) | [
"def",
"remove_stream",
"(",
"self",
",",
"ssrc",
")",
":",
"_srtp_assert",
"(",
"lib",
".",
"srtp_remove_stream",
"(",
"self",
".",
"_srtp",
"[",
"0",
"]",
",",
"htonl",
"(",
"ssrc",
")",
")",
")"
] | Remove the stream with the given `ssrc` from the SRTP session.
:param ssrc: :class:`int` | [
"Remove",
"the",
"stream",
"with",
"the",
"given",
"ssrc",
"from",
"the",
"SRTP",
"session",
"."
] | train | https://github.com/aiortc/pylibsrtp/blob/31824d1f8430ff6dc217cfc101093b6ba2a307b2/pylibsrtp/__init__.py#L176-L182 |
tarbell-project/tarbell | tarbell/app.py | process_xlsx | def process_xlsx(content):
"""
Turn Excel file contents into Tarbell worksheet data
"""
data = {}
workbook = xlrd.open_workbook(file_contents=content)
worksheets = [w for w in workbook.sheet_names() if not w.startswith('_')]
for worksheet_name in worksheets:
if worksheet_name.startsw... | python | def process_xlsx(content):
"""
Turn Excel file contents into Tarbell worksheet data
"""
data = {}
workbook = xlrd.open_workbook(file_contents=content)
worksheets = [w for w in workbook.sheet_names() if not w.startswith('_')]
for worksheet_name in worksheets:
if worksheet_name.startsw... | [
"def",
"process_xlsx",
"(",
"content",
")",
":",
"data",
"=",
"{",
"}",
"workbook",
"=",
"xlrd",
".",
"open_workbook",
"(",
"file_contents",
"=",
"content",
")",
"worksheets",
"=",
"[",
"w",
"for",
"w",
"in",
"workbook",
".",
"sheet_names",
"(",
")",
"... | Turn Excel file contents into Tarbell worksheet data | [
"Turn",
"Excel",
"file",
"contents",
"into",
"Tarbell",
"worksheet",
"data"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L43-L64 |
tarbell-project/tarbell | tarbell/app.py | copy_global_values | def copy_global_values(data):
"""
Copy values worksheet into global namespace.
"""
for k, v in data['values'].items():
if not data.get(k):
data[k] = v
else:
puts("There is both a worksheet and a "
"value named '{0}'. The worksheet data "
... | python | def copy_global_values(data):
"""
Copy values worksheet into global namespace.
"""
for k, v in data['values'].items():
if not data.get(k):
data[k] = v
else:
puts("There is both a worksheet and a "
"value named '{0}'. The worksheet data "
... | [
"def",
"copy_global_values",
"(",
"data",
")",
":",
"for",
"k",
",",
"v",
"in",
"data",
"[",
"'values'",
"]",
".",
"items",
"(",
")",
":",
"if",
"not",
"data",
".",
"get",
"(",
"k",
")",
":",
"data",
"[",
"k",
"]",
"=",
"v",
"else",
":",
"put... | Copy values worksheet into global namespace. | [
"Copy",
"values",
"worksheet",
"into",
"global",
"namespace",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L67-L79 |
tarbell-project/tarbell | tarbell/app.py | make_headers | def make_headers(worksheet):
"""
Make headers from worksheet
"""
headers = {}
cell_idx = 0
while cell_idx < worksheet.ncols:
cell_type = worksheet.cell_type(0, cell_idx)
if cell_type == 1:
header = slughifi(worksheet.cell_value(0, cell_idx))
if not header.... | python | def make_headers(worksheet):
"""
Make headers from worksheet
"""
headers = {}
cell_idx = 0
while cell_idx < worksheet.ncols:
cell_type = worksheet.cell_type(0, cell_idx)
if cell_type == 1:
header = slughifi(worksheet.cell_value(0, cell_idx))
if not header.... | [
"def",
"make_headers",
"(",
"worksheet",
")",
":",
"headers",
"=",
"{",
"}",
"cell_idx",
"=",
"0",
"while",
"cell_idx",
"<",
"worksheet",
".",
"ncols",
":",
"cell_type",
"=",
"worksheet",
".",
"cell_type",
"(",
"0",
",",
"cell_idx",
")",
"if",
"cell_type... | Make headers from worksheet | [
"Make",
"headers",
"from",
"worksheet"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L82-L95 |
tarbell-project/tarbell | tarbell/app.py | make_worksheet_data | def make_worksheet_data(headers, worksheet):
"""
Make data from worksheet
"""
data = []
row_idx = 1
while row_idx < worksheet.nrows:
cell_idx = 0
row_dict = {}
while cell_idx < worksheet.ncols:
cell_type = worksheet.cell_type(row_idx, cell_idx)
if ... | python | def make_worksheet_data(headers, worksheet):
"""
Make data from worksheet
"""
data = []
row_idx = 1
while row_idx < worksheet.nrows:
cell_idx = 0
row_dict = {}
while cell_idx < worksheet.ncols:
cell_type = worksheet.cell_type(row_idx, cell_idx)
if ... | [
"def",
"make_worksheet_data",
"(",
"headers",
",",
"worksheet",
")",
":",
"data",
"=",
"[",
"]",
"row_idx",
"=",
"1",
"while",
"row_idx",
"<",
"worksheet",
".",
"nrows",
":",
"cell_idx",
"=",
"0",
"row_dict",
"=",
"{",
"}",
"while",
"cell_idx",
"<",
"w... | Make data from worksheet | [
"Make",
"data",
"from",
"worksheet"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L98-L151 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.never_cache_preview | def never_cache_preview(self, response):
"""
Ensure preview is never cached
"""
response.cache_control.max_age = 0
response.cache_control.no_cache = True
response.cache_control.must_revalidate = True
response.cache_control.no_store = True
return response | python | def never_cache_preview(self, response):
"""
Ensure preview is never cached
"""
response.cache_control.max_age = 0
response.cache_control.no_cache = True
response.cache_control.must_revalidate = True
response.cache_control.no_store = True
return response | [
"def",
"never_cache_preview",
"(",
"self",
",",
"response",
")",
":",
"response",
".",
"cache_control",
".",
"max_age",
"=",
"0",
"response",
".",
"cache_control",
".",
"no_cache",
"=",
"True",
"response",
".",
"cache_control",
".",
"must_revalidate",
"=",
"Tr... | Ensure preview is never cached | [
"Ensure",
"preview",
"is",
"never",
"cached"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L195-L203 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.call_hook | def call_hook(self, hook, *args, **kwargs):
"""
Calls each registered hook
"""
for function in self.hooks[hook]:
function.__call__(*args, **kwargs) | python | def call_hook(self, hook, *args, **kwargs):
"""
Calls each registered hook
"""
for function in self.hooks[hook]:
function.__call__(*args, **kwargs) | [
"def",
"call_hook",
"(",
"self",
",",
"hook",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"function",
"in",
"self",
".",
"hooks",
"[",
"hook",
"]",
":",
"function",
".",
"__call__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Calls each registered hook | [
"Calls",
"each",
"registered",
"hook"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L215-L220 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite._get_base | def _get_base(self, path):
"""
Get project blueprint
"""
base = None
# Slightly ugly DRY violation for backwards compatibility with old
# "_base" convention
if os.path.isdir(os.path.join(path, "_blueprint")):
base_dir = os.path.join(path, "_blueprint/... | python | def _get_base(self, path):
"""
Get project blueprint
"""
base = None
# Slightly ugly DRY violation for backwards compatibility with old
# "_base" convention
if os.path.isdir(os.path.join(path, "_blueprint")):
base_dir = os.path.join(path, "_blueprint/... | [
"def",
"_get_base",
"(",
"self",
",",
"path",
")",
":",
"base",
"=",
"None",
"# Slightly ugly DRY violation for backwards compatibility with old",
"# \"_base\" convention",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
... | Get project blueprint | [
"Get",
"project",
"blueprint"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L222-L255 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.load_project | def load_project(self, path):
"""
Load a Tarbell project
"""
base = self._get_base(path)
filename, pathname, description = imp.find_module('tarbell_config', [path])
project = imp.load_module('project', filename, pathname, description)
try:
self.key =... | python | def load_project(self, path):
"""
Load a Tarbell project
"""
base = self._get_base(path)
filename, pathname, description = imp.find_module('tarbell_config', [path])
project = imp.load_module('project', filename, pathname, description)
try:
self.key =... | [
"def",
"load_project",
"(",
"self",
",",
"path",
")",
":",
"base",
"=",
"self",
".",
"_get_base",
"(",
"path",
")",
"filename",
",",
"pathname",
",",
"description",
"=",
"imp",
".",
"find_module",
"(",
"'tarbell_config'",
",",
"[",
"path",
"]",
")",
"p... | Load a Tarbell project | [
"Load",
"a",
"Tarbell",
"project"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L257-L314 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite._resolve_path | def _resolve_path(self, path):
"""
Resolve static file paths
"""
filepath = None
mimetype = None
for root, dirs, files in self.filter_files(self.path):
# Does it exist in error path?
error_path = os.path.join(os.path.dirname(os.path.abspath(__file... | python | def _resolve_path(self, path):
"""
Resolve static file paths
"""
filepath = None
mimetype = None
for root, dirs, files in self.filter_files(self.path):
# Does it exist in error path?
error_path = os.path.join(os.path.dirname(os.path.abspath(__file... | [
"def",
"_resolve_path",
"(",
"self",
",",
"path",
")",
":",
"filepath",
"=",
"None",
"mimetype",
"=",
"None",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"self",
".",
"filter_files",
"(",
"self",
".",
"path",
")",
":",
"# Does it exist in error path?",... | Resolve static file paths | [
"Resolve",
"static",
"file",
"paths"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L316-L352 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.data_json | def data_json(self, extra_context=None, publish=False):
"""
Serve site context as JSON. Useful for debugging.
"""
if not self.project.CREATE_JSON:
# nothing to see here, but the right mimetype
return jsonify()
if not self.data:
# this sets sit... | python | def data_json(self, extra_context=None, publish=False):
"""
Serve site context as JSON. Useful for debugging.
"""
if not self.project.CREATE_JSON:
# nothing to see here, but the right mimetype
return jsonify()
if not self.data:
# this sets sit... | [
"def",
"data_json",
"(",
"self",
",",
"extra_context",
"=",
"None",
",",
"publish",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"project",
".",
"CREATE_JSON",
":",
"# nothing to see here, but the right mimetype",
"return",
"jsonify",
"(",
")",
"if",
"not... | Serve site context as JSON. Useful for debugging. | [
"Serve",
"site",
"context",
"as",
"JSON",
".",
"Useful",
"for",
"debugging",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L354-L366 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.preview | def preview(self, path=None, extra_context=None, publish=False):
"""
Serve up a project path
"""
try:
self.call_hook("preview", self)
if path is None:
path = 'index.html'
# Detect files
filepath, mimetype = self._resolve_p... | python | def preview(self, path=None, extra_context=None, publish=False):
"""
Serve up a project path
"""
try:
self.call_hook("preview", self)
if path is None:
path = 'index.html'
# Detect files
filepath, mimetype = self._resolve_p... | [
"def",
"preview",
"(",
"self",
",",
"path",
"=",
"None",
",",
"extra_context",
"=",
"None",
",",
"publish",
"=",
"False",
")",
":",
"try",
":",
"self",
".",
"call_hook",
"(",
"\"preview\"",
",",
"self",
")",
"if",
"path",
"is",
"None",
":",
"path",
... | Serve up a project path | [
"Serve",
"up",
"a",
"project",
"path"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L368-L440 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.get_context | def get_context(self, publish=False):
"""
Use optional CONTEXT_SOURCE_FILE setting to determine data source.
Return the parsed data.
Can be an http|https url or local file. Supports csv and excel files.
"""
context = self.project.DEFAULT_CONTEXT
try:
... | python | def get_context(self, publish=False):
"""
Use optional CONTEXT_SOURCE_FILE setting to determine data source.
Return the parsed data.
Can be an http|https url or local file. Supports csv and excel files.
"""
context = self.project.DEFAULT_CONTEXT
try:
... | [
"def",
"get_context",
"(",
"self",
",",
"publish",
"=",
"False",
")",
":",
"context",
"=",
"self",
".",
"project",
".",
"DEFAULT_CONTEXT",
"try",
":",
"file",
"=",
"self",
".",
"project",
".",
"CONTEXT_SOURCE_FILE",
"# CSV",
"if",
"re",
".",
"search",
"(... | Use optional CONTEXT_SOURCE_FILE setting to determine data source.
Return the parsed data.
Can be an http|https url or local file. Supports csv and excel files. | [
"Use",
"optional",
"CONTEXT_SOURCE_FILE",
"setting",
"to",
"determine",
"data",
"source",
".",
"Return",
"the",
"parsed",
"data",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L442-L461 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.get_context_from_xlsx | def get_context_from_xlsx(self):
"""
Get context from an Excel file
"""
if re.search('^(http|https)://', self.project.CONTEXT_SOURCE_FILE):
resp = requests.get(self.project.CONTEXT_SOURCE_FILE)
content = resp.content
else:
try:
... | python | def get_context_from_xlsx(self):
"""
Get context from an Excel file
"""
if re.search('^(http|https)://', self.project.CONTEXT_SOURCE_FILE):
resp = requests.get(self.project.CONTEXT_SOURCE_FILE)
content = resp.content
else:
try:
... | [
"def",
"get_context_from_xlsx",
"(",
"self",
")",
":",
"if",
"re",
".",
"search",
"(",
"'^(http|https)://'",
",",
"self",
".",
"project",
".",
"CONTEXT_SOURCE_FILE",
")",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"project",
".",
"CONTEXT_... | Get context from an Excel file | [
"Get",
"context",
"from",
"an",
"Excel",
"file"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L463-L485 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.get_context_from_csv | def get_context_from_csv(self):
"""
Open CONTEXT_SOURCE_FILE, parse and return a context
"""
if re.search('^(http|https)://', self.project.CONTEXT_SOURCE_FILE):
data = requests.get(self.project.CONTEXT_SOURCE_FILE)
reader = csv.reader(
data.iter_li... | python | def get_context_from_csv(self):
"""
Open CONTEXT_SOURCE_FILE, parse and return a context
"""
if re.search('^(http|https)://', self.project.CONTEXT_SOURCE_FILE):
data = requests.get(self.project.CONTEXT_SOURCE_FILE)
reader = csv.reader(
data.iter_li... | [
"def",
"get_context_from_csv",
"(",
"self",
")",
":",
"if",
"re",
".",
"search",
"(",
"'^(http|https)://'",
",",
"self",
".",
"project",
".",
"CONTEXT_SOURCE_FILE",
")",
":",
"data",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"project",
".",
"CONTEXT_S... | Open CONTEXT_SOURCE_FILE, parse and return a context | [
"Open",
"CONTEXT_SOURCE_FILE",
"parse",
"and",
"return",
"a",
"context"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L487-L511 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.get_context_from_gdoc | def get_context_from_gdoc(self):
"""
Wrap getting context from Google sheets in a simple caching mechanism.
"""
try:
start = int(time.time())
if not self.data or start > self.expires:
self.data = self._get_context_from_gdoc(self.project.SPREADSHEET... | python | def get_context_from_gdoc(self):
"""
Wrap getting context from Google sheets in a simple caching mechanism.
"""
try:
start = int(time.time())
if not self.data or start > self.expires:
self.data = self._get_context_from_gdoc(self.project.SPREADSHEET... | [
"def",
"get_context_from_gdoc",
"(",
"self",
")",
":",
"try",
":",
"start",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"if",
"not",
"self",
".",
"data",
"or",
"start",
">",
"self",
".",
"expires",
":",
"self",
".",
"data",
"=",
"self",
... | Wrap getting context from Google sheets in a simple caching mechanism. | [
"Wrap",
"getting",
"context",
"from",
"Google",
"sheets",
"in",
"a",
"simple",
"caching",
"mechanism",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L513-L527 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite._get_context_from_gdoc | def _get_context_from_gdoc(self, key):
"""
Create a Jinja2 context from a Google spreadsheet.
"""
try:
content = self.export_xlsx(key)
data = process_xlsx(content)
if 'values' in data:
data = copy_global_values(data)
return ... | python | def _get_context_from_gdoc(self, key):
"""
Create a Jinja2 context from a Google spreadsheet.
"""
try:
content = self.export_xlsx(key)
data = process_xlsx(content)
if 'values' in data:
data = copy_global_values(data)
return ... | [
"def",
"_get_context_from_gdoc",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"content",
"=",
"self",
".",
"export_xlsx",
"(",
"key",
")",
"data",
"=",
"process_xlsx",
"(",
"content",
")",
"if",
"'values'",
"in",
"data",
":",
"data",
"=",
"copy_global_... | Create a Jinja2 context from a Google spreadsheet. | [
"Create",
"a",
"Jinja2",
"context",
"from",
"a",
"Google",
"spreadsheet",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L529-L543 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.export_xlsx | def export_xlsx(self, key):
"""
Download xlsx version of spreadsheet.
"""
spreadsheet_file = self.client.files().get(fileId=key).execute()
links = spreadsheet_file.get('exportLinks')
downloadurl = links.get('application/vnd.openxmlformats-officedocument.spreadsheetml.shee... | python | def export_xlsx(self, key):
"""
Download xlsx version of spreadsheet.
"""
spreadsheet_file = self.client.files().get(fileId=key).execute()
links = spreadsheet_file.get('exportLinks')
downloadurl = links.get('application/vnd.openxmlformats-officedocument.spreadsheetml.shee... | [
"def",
"export_xlsx",
"(",
"self",
",",
"key",
")",
":",
"spreadsheet_file",
"=",
"self",
".",
"client",
".",
"files",
"(",
")",
".",
"get",
"(",
"fileId",
"=",
"key",
")",
".",
"execute",
"(",
")",
"links",
"=",
"spreadsheet_file",
".",
"get",
"(",
... | Download xlsx version of spreadsheet. | [
"Download",
"xlsx",
"version",
"of",
"spreadsheet",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L545-L553 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.generate_static_site | def generate_static_site(self, output_root=None, extra_context=None):
"""
Bake out static site
"""
self.app.config['BUILD_PATH'] = output_root
# use this hook for registering URLs to freeze
self.call_hook("generate", self, output_root, extra_context)
if output_r... | python | def generate_static_site(self, output_root=None, extra_context=None):
"""
Bake out static site
"""
self.app.config['BUILD_PATH'] = output_root
# use this hook for registering URLs to freeze
self.call_hook("generate", self, output_root, extra_context)
if output_r... | [
"def",
"generate_static_site",
"(",
"self",
",",
"output_root",
"=",
"None",
",",
"extra_context",
"=",
"None",
")",
":",
"self",
".",
"app",
".",
"config",
"[",
"'BUILD_PATH'",
"]",
"=",
"output_root",
"# use this hook for registering URLs to freeze",
"self",
"."... | Bake out static site | [
"Bake",
"out",
"static",
"site"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L555-L568 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.filter_files | def filter_files(self, path):
"""
Exclude files based on blueprint and project configuration as well as hidden files.
"""
excludes = r'|'.join([fnmatch.translate(x) for x in self.project.EXCLUDES]) or r'$.'
for root, dirs, files in os.walk(path, topdown=True):
dirs[:]... | python | def filter_files(self, path):
"""
Exclude files based on blueprint and project configuration as well as hidden files.
"""
excludes = r'|'.join([fnmatch.translate(x) for x in self.project.EXCLUDES]) or r'$.'
for root, dirs, files in os.walk(path, topdown=True):
dirs[:]... | [
"def",
"filter_files",
"(",
"self",
",",
"path",
")",
":",
"excludes",
"=",
"r'|'",
".",
"join",
"(",
"[",
"fnmatch",
".",
"translate",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"project",
".",
"EXCLUDES",
"]",
")",
"or",
"r'$.'",
"for",
"root"... | Exclude files based on blueprint and project configuration as well as hidden files. | [
"Exclude",
"files",
"based",
"on",
"blueprint",
"and",
"project",
"configuration",
"as",
"well",
"as",
"hidden",
"files",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L570-L590 |
tarbell-project/tarbell | tarbell/app.py | TarbellSite.find_files | def find_files(self):
"""
Find all file paths for publishing, yield (urlname, kwargs)
"""
# yield blueprint paths first
if getattr(self, 'blueprint_name', None):
for path in walk_directory(os.path.join(self.path, self.blueprint_name), ignore=self.project.EXCLUDES):
... | python | def find_files(self):
"""
Find all file paths for publishing, yield (urlname, kwargs)
"""
# yield blueprint paths first
if getattr(self, 'blueprint_name', None):
for path in walk_directory(os.path.join(self.path, self.blueprint_name), ignore=self.project.EXCLUDES):
... | [
"def",
"find_files",
"(",
"self",
")",
":",
"# yield blueprint paths first",
"if",
"getattr",
"(",
"self",
",",
"'blueprint_name'",
",",
"None",
")",
":",
"for",
"path",
"in",
"walk_directory",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",... | Find all file paths for publishing, yield (urlname, kwargs) | [
"Find",
"all",
"file",
"paths",
"for",
"publishing",
"yield",
"(",
"urlname",
"kwargs",
")"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/app.py#L592-L603 |
tarbell-project/tarbell | tarbell/s3.py | S3Sync.deploy_to_s3 | def deploy_to_s3(self):
"""
Deploy a directory to an s3 bucket.
"""
self.tempdir = tempfile.mkdtemp('s3deploy')
for keyname, absolute_path in self.find_file_paths():
self.s3_upload(keyname, absolute_path)
shutil.rmtree(self.tempdir, True)
return True | python | def deploy_to_s3(self):
"""
Deploy a directory to an s3 bucket.
"""
self.tempdir = tempfile.mkdtemp('s3deploy')
for keyname, absolute_path in self.find_file_paths():
self.s3_upload(keyname, absolute_path)
shutil.rmtree(self.tempdir, True)
return True | [
"def",
"deploy_to_s3",
"(",
"self",
")",
":",
"self",
".",
"tempdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"'s3deploy'",
")",
"for",
"keyname",
",",
"absolute_path",
"in",
"self",
".",
"find_file_paths",
"(",
")",
":",
"self",
".",
"s3_upload",
"(",
"ke... | Deploy a directory to an s3 bucket. | [
"Deploy",
"a",
"directory",
"to",
"an",
"s3",
"bucket",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/s3.py#L54-L64 |
tarbell-project/tarbell | tarbell/s3.py | S3Sync.s3_upload | def s3_upload(self, keyname, absolute_path):
"""
Upload a file to s3
"""
mimetype = mimetypes.guess_type(absolute_path)
options = {'Content-Type': mimetype[0]}
if mimetype[0] is not None and mimetype[0].startswith('text/'):
upload = open(absolute_path, 'rb')
... | python | def s3_upload(self, keyname, absolute_path):
"""
Upload a file to s3
"""
mimetype = mimetypes.guess_type(absolute_path)
options = {'Content-Type': mimetype[0]}
if mimetype[0] is not None and mimetype[0].startswith('text/'):
upload = open(absolute_path, 'rb')
... | [
"def",
"s3_upload",
"(",
"self",
",",
"keyname",
",",
"absolute_path",
")",
":",
"mimetype",
"=",
"mimetypes",
".",
"guess_type",
"(",
"absolute_path",
")",
"options",
"=",
"{",
"'Content-Type'",
":",
"mimetype",
"[",
"0",
"]",
"}",
"if",
"mimetype",
"[",
... | Upload a file to s3 | [
"Upload",
"a",
"file",
"to",
"s3"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/s3.py#L66-L94 |
tarbell-project/tarbell | tarbell/s3.py | S3Sync.find_file_paths | def find_file_paths(self):
"""
A generator function that recursively finds all files in the upload directory.
"""
paths = []
for root, dirs, files in os.walk(self.directory, topdown=True):
rel_path = os.path.relpath(root, self.directory)
for f in files:
... | python | def find_file_paths(self):
"""
A generator function that recursively finds all files in the upload directory.
"""
paths = []
for root, dirs, files in os.walk(self.directory, topdown=True):
rel_path = os.path.relpath(root, self.directory)
for f in files:
... | [
"def",
"find_file_paths",
"(",
"self",
")",
":",
"paths",
"=",
"[",
"]",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"self",
".",
"directory",
",",
"topdown",
"=",
"True",
")",
":",
"rel_path",
"=",
"os",
".",
"path",
... | A generator function that recursively finds all files in the upload directory. | [
"A",
"generator",
"function",
"that",
"recursively",
"finds",
"all",
"files",
"in",
"the",
"upload",
"directory",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/s3.py#L97-L110 |
tarbell-project/tarbell | tarbell/oauth.py | get_drive_api | def get_drive_api():
"""
Get drive API client based on settings.
"""
settings = Settings()
if settings.credentials:
return get_drive_api_from_file(settings.credentials_path)
if settings.client_secrets:
return get_drive_api_from_client_secrets(settings.client_secrets_path) | python | def get_drive_api():
"""
Get drive API client based on settings.
"""
settings = Settings()
if settings.credentials:
return get_drive_api_from_file(settings.credentials_path)
if settings.client_secrets:
return get_drive_api_from_client_secrets(settings.client_secrets_path) | [
"def",
"get_drive_api",
"(",
")",
":",
"settings",
"=",
"Settings",
"(",
")",
"if",
"settings",
".",
"credentials",
":",
"return",
"get_drive_api_from_file",
"(",
"settings",
".",
"credentials_path",
")",
"if",
"settings",
".",
"client_secrets",
":",
"return",
... | Get drive API client based on settings. | [
"Get",
"drive",
"API",
"client",
"based",
"on",
"settings",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/oauth.py#L24-L34 |
tarbell-project/tarbell | tarbell/oauth.py | get_drive_api_from_client_secrets | def get_drive_api_from_client_secrets(path, reset_creds=False):
"""
Reads the local client secrets file if available (otherwise, opens a
browser tab to walk through the OAuth 2.0 process, and stores the client
secrets for future use) and then authorizes those credentials. Returns a
Google Drive API ... | python | def get_drive_api_from_client_secrets(path, reset_creds=False):
"""
Reads the local client secrets file if available (otherwise, opens a
browser tab to walk through the OAuth 2.0 process, and stores the client
secrets for future use) and then authorizes those credentials. Returns a
Google Drive API ... | [
"def",
"get_drive_api_from_client_secrets",
"(",
"path",
",",
"reset_creds",
"=",
"False",
")",
":",
"storage",
"=",
"keyring_storage",
".",
"Storage",
"(",
"'tarbell'",
",",
"getpass",
".",
"getuser",
"(",
")",
")",
"credentials",
"=",
"None",
"if",
"not",
... | Reads the local client secrets file if available (otherwise, opens a
browser tab to walk through the OAuth 2.0 process, and stores the client
secrets for future use) and then authorizes those credentials. Returns a
Google Drive API service object. | [
"Reads",
"the",
"local",
"client",
"secrets",
"file",
"if",
"available",
"(",
"otherwise",
"opens",
"a",
"browser",
"tab",
"to",
"walk",
"through",
"the",
"OAuth",
"2",
".",
"0",
"process",
"and",
"stores",
"the",
"client",
"secrets",
"for",
"future",
"use... | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/oauth.py#L37-L53 |
tarbell-project/tarbell | tarbell/oauth.py | get_drive_api_from_file | def get_drive_api_from_file(path):
"""
Open file with OAuth tokens.
"""
f = open(path)
credentials = client.OAuth2Credentials.from_json(f.read())
return _get_drive_api(credentials) | python | def get_drive_api_from_file(path):
"""
Open file with OAuth tokens.
"""
f = open(path)
credentials = client.OAuth2Credentials.from_json(f.read())
return _get_drive_api(credentials) | [
"def",
"get_drive_api_from_file",
"(",
"path",
")",
":",
"f",
"=",
"open",
"(",
"path",
")",
"credentials",
"=",
"client",
".",
"OAuth2Credentials",
".",
"from_json",
"(",
"f",
".",
"read",
"(",
")",
")",
"return",
"_get_drive_api",
"(",
"credentials",
")"... | Open file with OAuth tokens. | [
"Open",
"file",
"with",
"OAuth",
"tokens",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/oauth.py#L56-L62 |
tarbell-project/tarbell | tarbell/oauth.py | _get_drive_api | def _get_drive_api(credentials):
"""
For a given set of credentials, return a drive API object.
"""
http = httplib2.Http()
http = credentials.authorize(http)
service = discovery.build('drive', 'v2', http=http)
service.credentials = credentials # duck punch service obj. with credentials
... | python | def _get_drive_api(credentials):
"""
For a given set of credentials, return a drive API object.
"""
http = httplib2.Http()
http = credentials.authorize(http)
service = discovery.build('drive', 'v2', http=http)
service.credentials = credentials # duck punch service obj. with credentials
... | [
"def",
"_get_drive_api",
"(",
"credentials",
")",
":",
"http",
"=",
"httplib2",
".",
"Http",
"(",
")",
"http",
"=",
"credentials",
".",
"authorize",
"(",
"http",
")",
"service",
"=",
"discovery",
".",
"build",
"(",
"'drive'",
",",
"'v2'",
",",
"http",
... | For a given set of credentials, return a drive API object. | [
"For",
"a",
"given",
"set",
"of",
"credentials",
"return",
"a",
"drive",
"API",
"object",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/oauth.py#L65-L73 |
tarbell-project/tarbell | tarbell/cli.py | main | def main():
"""
Primary Tarbell command dispatch.
"""
command = Command.lookup(args.get(0))
if len(args) == 0 or args.contains(('-h', '--help', 'help')):
display_info(args)
sys.exit(1)
elif args.contains(('-v', '--version')):
display_version()
sys.exit(1)
e... | python | def main():
"""
Primary Tarbell command dispatch.
"""
command = Command.lookup(args.get(0))
if len(args) == 0 or args.contains(('-h', '--help', 'help')):
display_info(args)
sys.exit(1)
elif args.contains(('-v', '--version')):
display_version()
sys.exit(1)
e... | [
"def",
"main",
"(",
")",
":",
"command",
"=",
"Command",
".",
"lookup",
"(",
"args",
".",
"get",
"(",
"0",
")",
")",
"if",
"len",
"(",
"args",
")",
"==",
"0",
"or",
"args",
".",
"contains",
"(",
"(",
"'-h'",
",",
"'--help'",
",",
"'help'",
")",... | Primary Tarbell command dispatch. | [
"Primary",
"Tarbell",
"command",
"dispatch",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L59-L83 |
tarbell-project/tarbell | tarbell/cli.py | display_info | def display_info(args):
"""
Displays Tarbell info.
"""
puts('\nTarbell: Simple web publishing\n')
puts('Usage: {0}\n'.format(colored.cyan('tarbell <command>')))
puts('Commands:\n')
for command in Command.all_commands():
usage = command.usage or command.name
help = command.he... | python | def display_info(args):
"""
Displays Tarbell info.
"""
puts('\nTarbell: Simple web publishing\n')
puts('Usage: {0}\n'.format(colored.cyan('tarbell <command>')))
puts('Commands:\n')
for command in Command.all_commands():
usage = command.usage or command.name
help = command.he... | [
"def",
"display_info",
"(",
"args",
")",
":",
"puts",
"(",
"'\\nTarbell: Simple web publishing\\n'",
")",
"puts",
"(",
"'Usage: {0}\\n'",
".",
"format",
"(",
"colored",
".",
"cyan",
"(",
"'tarbell <command>'",
")",
")",
")",
"puts",
"(",
"'Commands:\\n'",
")",
... | Displays Tarbell info. | [
"Displays",
"Tarbell",
"info",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L86-L114 |
tarbell-project/tarbell | tarbell/cli.py | tarbell_generate | def tarbell_generate(command, args, skip_args=False, extra_context=None, quiet=False):
"""
Generate static files.
"""
output_root = None
with ensure_settings(command, args) as settings, ensure_project(command, args) as site:
if not skip_args:
output_root = list_get(args, 0, Fal... | python | def tarbell_generate(command, args, skip_args=False, extra_context=None, quiet=False):
"""
Generate static files.
"""
output_root = None
with ensure_settings(command, args) as settings, ensure_project(command, args) as site:
if not skip_args:
output_root = list_get(args, 0, Fal... | [
"def",
"tarbell_generate",
"(",
"command",
",",
"args",
",",
"skip_args",
"=",
"False",
",",
"extra_context",
"=",
"None",
",",
"quiet",
"=",
"False",
")",
":",
"output_root",
"=",
"None",
"with",
"ensure_settings",
"(",
"command",
",",
"args",
")",
"as",
... | Generate static files. | [
"Generate",
"static",
"files",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L126-L176 |
tarbell-project/tarbell | tarbell/cli.py | tarbell_install | def tarbell_install(command, args):
"""
Install a project.
"""
with ensure_settings(command, args) as settings:
project_url = args.get(0)
puts("\n- Getting project information for {0}".format(project_url))
project_name = project_url.split("/").pop()
error = None
... | python | def tarbell_install(command, args):
"""
Install a project.
"""
with ensure_settings(command, args) as settings:
project_url = args.get(0)
puts("\n- Getting project information for {0}".format(project_url))
project_name = project_url.split("/").pop()
error = None
... | [
"def",
"tarbell_install",
"(",
"command",
",",
"args",
")",
":",
"with",
"ensure_settings",
"(",
"command",
",",
"args",
")",
"as",
"settings",
":",
"project_url",
"=",
"args",
".",
"get",
"(",
"0",
")",
"puts",
"(",
"\"\\n- Getting project information for {0}... | Install a project. | [
"Install",
"a",
"project",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L179-L219 |
tarbell-project/tarbell | tarbell/cli.py | tarbell_install_blueprint | def tarbell_install_blueprint(command, args):
"""
Install a project template.
"""
with ensure_settings(command, args) as settings:
name = None
error = None
template_url = args.get(0)
matches = [template for template in settings.config["project_templates"] if template.get(... | python | def tarbell_install_blueprint(command, args):
"""
Install a project template.
"""
with ensure_settings(command, args) as settings:
name = None
error = None
template_url = args.get(0)
matches = [template for template in settings.config["project_templates"] if template.get(... | [
"def",
"tarbell_install_blueprint",
"(",
"command",
",",
"args",
")",
":",
"with",
"ensure_settings",
"(",
"command",
",",
"args",
")",
"as",
"settings",
":",
"name",
"=",
"None",
"error",
"=",
"None",
"template_url",
"=",
"args",
".",
"get",
"(",
"0",
"... | Install a project template. | [
"Install",
"a",
"project",
"template",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L222-L272 |
tarbell-project/tarbell | tarbell/cli.py | tarbell_list | def tarbell_list(command, args):
"""
List tarbell projects.
"""
with ensure_settings(command, args) as settings:
projects_path = settings.config.get("projects_path")
if not projects_path:
show_error("{0} does not exist".format(projects_path))
sys.exit()
p... | python | def tarbell_list(command, args):
"""
List tarbell projects.
"""
with ensure_settings(command, args) as settings:
projects_path = settings.config.get("projects_path")
if not projects_path:
show_error("{0} does not exist".format(projects_path))
sys.exit()
p... | [
"def",
"tarbell_list",
"(",
"command",
",",
"args",
")",
":",
"with",
"ensure_settings",
"(",
"command",
",",
"args",
")",
"as",
"settings",
":",
"projects_path",
"=",
"settings",
".",
"config",
".",
"get",
"(",
"\"projects_path\"",
")",
"if",
"not",
"proj... | List tarbell projects. | [
"List",
"tarbell",
"projects",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L275-L320 |
tarbell-project/tarbell | tarbell/cli.py | tarbell_list_templates | def tarbell_list_templates(command, args):
"""
List available Tarbell blueprints.
"""
with ensure_settings(command, args) as settings:
puts("\nAvailable project templates\n")
_list_templates(settings)
puts("") | python | def tarbell_list_templates(command, args):
"""
List available Tarbell blueprints.
"""
with ensure_settings(command, args) as settings:
puts("\nAvailable project templates\n")
_list_templates(settings)
puts("") | [
"def",
"tarbell_list_templates",
"(",
"command",
",",
"args",
")",
":",
"with",
"ensure_settings",
"(",
"command",
",",
"args",
")",
"as",
"settings",
":",
"puts",
"(",
"\"\\nAvailable project templates\\n\"",
")",
"_list_templates",
"(",
"settings",
")",
"puts",
... | List available Tarbell blueprints. | [
"List",
"available",
"Tarbell",
"blueprints",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L322-L329 |
tarbell-project/tarbell | tarbell/cli.py | tarbell_publish | def tarbell_publish(command, args):
"""
Publish to s3.
"""
with ensure_settings(command, args) as settings, ensure_project(command, args) as site:
bucket_name = list_get(args, 0, "staging")
try:
bucket_url = S3Url(site.project.S3_BUCKETS[bucket_name])
except KeyError... | python | def tarbell_publish(command, args):
"""
Publish to s3.
"""
with ensure_settings(command, args) as settings, ensure_project(command, args) as site:
bucket_name = list_get(args, 0, "staging")
try:
bucket_url = S3Url(site.project.S3_BUCKETS[bucket_name])
except KeyError... | [
"def",
"tarbell_publish",
"(",
"command",
",",
"args",
")",
":",
"with",
"ensure_settings",
"(",
"command",
",",
"args",
")",
"as",
"settings",
",",
"ensure_project",
"(",
"command",
",",
"args",
")",
"as",
"site",
":",
"bucket_name",
"=",
"list_get",
"(",... | Publish to s3. | [
"Publish",
"to",
"s3",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L332-L397 |
tarbell-project/tarbell | tarbell/cli.py | tarbell_newproject | def tarbell_newproject(command, args):
"""
Create new Tarbell project.
"""
with ensure_settings(command, args) as settings:
# Set it up and make the directory
name = _get_project_name(args)
puts("Creating {0}".format(colored.cyan(name)))
path = _get_path(name, settings)
... | python | def tarbell_newproject(command, args):
"""
Create new Tarbell project.
"""
with ensure_settings(command, args) as settings:
# Set it up and make the directory
name = _get_project_name(args)
puts("Creating {0}".format(colored.cyan(name)))
path = _get_path(name, settings)
... | [
"def",
"tarbell_newproject",
"(",
"command",
",",
"args",
")",
":",
"with",
"ensure_settings",
"(",
"command",
",",
"args",
")",
"as",
"settings",
":",
"# Set it up and make the directory",
"name",
"=",
"_get_project_name",
"(",
"args",
")",
"puts",
"(",
"\"Crea... | Create new Tarbell project. | [
"Create",
"new",
"Tarbell",
"project",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L400-L419 |
tarbell-project/tarbell | tarbell/cli.py | tarbell_serve | def tarbell_serve(command, args):
"""
Serve the current Tarbell project.
"""
with ensure_project(command, args) as site:
with ensure_settings(command, args) as settings:
address = list_get(args, 0, "").split(":")
ip = list_get(address, 0, settings.config['default_server_i... | python | def tarbell_serve(command, args):
"""
Serve the current Tarbell project.
"""
with ensure_project(command, args) as site:
with ensure_settings(command, args) as settings:
address = list_get(args, 0, "").split(":")
ip = list_get(address, 0, settings.config['default_server_i... | [
"def",
"tarbell_serve",
"(",
"command",
",",
"args",
")",
":",
"with",
"ensure_project",
"(",
"command",
",",
"args",
")",
"as",
"site",
":",
"with",
"ensure_settings",
"(",
"command",
",",
"args",
")",
"as",
"settings",
":",
"address",
"=",
"list_get",
... | Serve the current Tarbell project. | [
"Serve",
"the",
"current",
"Tarbell",
"project",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L422-L445 |
tarbell-project/tarbell | tarbell/cli.py | tarbell_switch | def tarbell_switch(command, args):
"""
Switch to a project.
"""
with ensure_settings(command, args) as settings:
projects_path = settings.config.get("projects_path")
if not projects_path:
show_error("{0} does not exist".format(projects_path))
sys.exit()
pr... | python | def tarbell_switch(command, args):
"""
Switch to a project.
"""
with ensure_settings(command, args) as settings:
projects_path = settings.config.get("projects_path")
if not projects_path:
show_error("{0} does not exist".format(projects_path))
sys.exit()
pr... | [
"def",
"tarbell_switch",
"(",
"command",
",",
"args",
")",
":",
"with",
"ensure_settings",
"(",
"command",
",",
"args",
")",
"as",
"settings",
":",
"projects_path",
"=",
"settings",
".",
"config",
".",
"get",
"(",
"\"projects_path\"",
")",
"if",
"not",
"pr... | Switch to a project. | [
"Switch",
"to",
"a",
"project",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L448-L465 |
tarbell-project/tarbell | tarbell/cli.py | tarbell_update | def tarbell_update(command, args):
"""
Update the current tarbell project.
"""
with ensure_settings(command, args) as settings, ensure_project(command, args) as site:
puts("Updating to latest blueprint\n")
git = sh.git.bake(_cwd=site.base.base_dir)
# stash then pull
put... | python | def tarbell_update(command, args):
"""
Update the current tarbell project.
"""
with ensure_settings(command, args) as settings, ensure_project(command, args) as site:
puts("Updating to latest blueprint\n")
git = sh.git.bake(_cwd=site.base.base_dir)
# stash then pull
put... | [
"def",
"tarbell_update",
"(",
"command",
",",
"args",
")",
":",
"with",
"ensure_settings",
"(",
"command",
",",
"args",
")",
"as",
"settings",
",",
"ensure_project",
"(",
"command",
",",
"args",
")",
"as",
"site",
":",
"puts",
"(",
"\"Updating to latest blue... | Update the current tarbell project. | [
"Update",
"the",
"current",
"tarbell",
"project",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L476-L495 |
tarbell-project/tarbell | tarbell/cli.py | tarbell_unpublish | def tarbell_unpublish(command, args):
"""
Delete a project.
"""
with ensure_settings(command, args) as settings, ensure_project(command, args) as site:
show_error("Not implemented!") | python | def tarbell_unpublish(command, args):
"""
Delete a project.
"""
with ensure_settings(command, args) as settings, ensure_project(command, args) as site:
show_error("Not implemented!") | [
"def",
"tarbell_unpublish",
"(",
"command",
",",
"args",
")",
":",
"with",
"ensure_settings",
"(",
"command",
",",
"args",
")",
"as",
"settings",
",",
"ensure_project",
"(",
"command",
",",
"args",
")",
"as",
"site",
":",
"show_error",
"(",
"\"Not implemente... | Delete a project. | [
"Delete",
"a",
"project",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L498-L503 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.