partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Env.resync | make sure we can ping the head and assigned node.
Possibly after an env.exit() | MalmoEnv/malmoenv/core.py | def resync(self):
"""make sure we can ping the head and assigned node.
Possibly after an env.exit()"""
success = 0
for head in [True, False]:
for _ in range(30):
try:
self.status(head)
success += 1
br... | def resync(self):
"""make sure we can ping the head and assigned node.
Possibly after an env.exit()"""
success = 0
for head in [True, False]:
for _ in range(30):
try:
self.status(head)
success += 1
br... | [
"make",
"sure",
"we",
"can",
"ping",
"the",
"head",
"and",
"assigned",
"node",
".",
"Possibly",
"after",
"an",
"env",
".",
"exit",
"()"
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/MalmoEnv/malmoenv/core.py#L390-L405 | [
"def",
"resync",
"(",
"self",
")",
":",
"success",
"=",
"0",
"for",
"head",
"in",
"[",
"True",
",",
"False",
"]",
":",
"for",
"_",
"in",
"range",
"(",
"30",
")",
":",
"try",
":",
"self",
".",
"status",
"(",
"head",
")",
"success",
"+=",
"1",
... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | Env.exit_resync | Exit the current Minecraft and wait for new one to replace it. | MalmoEnv/malmoenv/core.py | def exit_resync(self):
"""Exit the current Minecraft and wait for new one to replace it."""
print("********** exit & resync **********")
try:
if self.client_socket:
self.client_socket.close()
self.client_socket = None
try:
s... | def exit_resync(self):
"""Exit the current Minecraft and wait for new one to replace it."""
print("********** exit & resync **********")
try:
if self.client_socket:
self.client_socket.close()
self.client_socket = None
try:
s... | [
"Exit",
"the",
"current",
"Minecraft",
"and",
"wait",
"for",
"new",
"one",
"to",
"replace",
"it",
"."
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/MalmoEnv/malmoenv/core.py#L407-L422 | [
"def",
"exit_resync",
"(",
"self",
")",
":",
"print",
"(",
"\"********** exit & resync **********\"",
")",
"try",
":",
"if",
"self",
".",
"client_socket",
":",
"self",
".",
"client_socket",
".",
"close",
"(",
")",
"self",
".",
"client_socket",
"=",
"None",
"... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | TabQAgent.updateQTable | Change q_table to reflect what we have learnt. | Malmo/samples/Python_examples/tutorial_6.py | def updateQTable( self, reward, current_state ):
"""Change q_table to reflect what we have learnt."""
# retrieve the old action value from the Q-table (indexed by the previous state and the previous action)
old_q = self.q_table[self.prev_s][self.prev_a]
# TODO: what sho... | def updateQTable( self, reward, current_state ):
"""Change q_table to reflect what we have learnt."""
# retrieve the old action value from the Q-table (indexed by the previous state and the previous action)
old_q = self.q_table[self.prev_s][self.prev_a]
# TODO: what sho... | [
"Change",
"q_table",
"to",
"reflect",
"what",
"we",
"have",
"learnt",
"."
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Malmo/samples/Python_examples/tutorial_6.py#L65-L75 | [
"def",
"updateQTable",
"(",
"self",
",",
"reward",
",",
"current_state",
")",
":",
"# retrieve the old action value from the Q-table (indexed by the previous state and the previous action)",
"old_q",
"=",
"self",
".",
"q_table",
"[",
"self",
".",
"prev_s",
"]",
"[",
"self... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | TabQAgent.updateQTableFromTerminatingState | Change q_table to reflect what we have learnt, after reaching a terminal state. | Malmo/samples/Python_examples/tutorial_6.py | def updateQTableFromTerminatingState( self, reward ):
"""Change q_table to reflect what we have learnt, after reaching a terminal state."""
# retrieve the old action value from the Q-table (indexed by the previous state and the previous action)
old_q = self.q_table[self.prev_s][self.pre... | def updateQTableFromTerminatingState( self, reward ):
"""Change q_table to reflect what we have learnt, after reaching a terminal state."""
# retrieve the old action value from the Q-table (indexed by the previous state and the previous action)
old_q = self.q_table[self.prev_s][self.pre... | [
"Change",
"q_table",
"to",
"reflect",
"what",
"we",
"have",
"learnt",
"after",
"reaching",
"a",
"terminal",
"state",
"."
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Malmo/samples/Python_examples/tutorial_6.py#L77-L87 | [
"def",
"updateQTableFromTerminatingState",
"(",
"self",
",",
"reward",
")",
":",
"# retrieve the old action value from the Q-table (indexed by the previous state and the previous action)",
"old_q",
"=",
"self",
".",
"q_table",
"[",
"self",
".",
"prev_s",
"]",
"[",
"self",
"... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | TabQAgent.act | take 1 action in response to the current world state | Malmo/samples/Python_examples/tutorial_6.py | def act(self, world_state, agent_host, current_r ):
"""take 1 action in response to the current world state"""
obs_text = world_state.observations[-1].text
obs = json.loads(obs_text) # most recent observation
self.logger.debug(obs)
if not u'XPos' in obs or not u'ZPos' in... | def act(self, world_state, agent_host, current_r ):
"""take 1 action in response to the current world state"""
obs_text = world_state.observations[-1].text
obs = json.loads(obs_text) # most recent observation
self.logger.debug(obs)
if not u'XPos' in obs or not u'ZPos' in... | [
"take",
"1",
"action",
"in",
"response",
"to",
"the",
"current",
"world",
"state"
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Malmo/samples/Python_examples/tutorial_6.py#L89-L134 | [
"def",
"act",
"(",
"self",
",",
"world_state",
",",
"agent_host",
",",
"current_r",
")",
":",
"obs_text",
"=",
"world_state",
".",
"observations",
"[",
"-",
"1",
"]",
".",
"text",
"obs",
"=",
"json",
".",
"loads",
"(",
"obs_text",
")",
"# most recent obs... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | TabQAgent.run | run the agent on the world | Malmo/samples/Python_examples/tutorial_6.py | def run(self, agent_host):
"""run the agent on the world"""
total_reward = 0
self.prev_s = None
self.prev_a = None
is_first_action = True
# main loop:
world_state = agent_host.getWorldState()
while world_state.is_mission_running... | def run(self, agent_host):
"""run the agent on the world"""
total_reward = 0
self.prev_s = None
self.prev_a = None
is_first_action = True
# main loop:
world_state = agent_host.getWorldState()
while world_state.is_mission_running... | [
"run",
"the",
"agent",
"on",
"the",
"world"
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Malmo/samples/Python_examples/tutorial_6.py#L136-L200 | [
"def",
"run",
"(",
"self",
",",
"agent_host",
")",
":",
"total_reward",
"=",
"0",
"self",
".",
"prev_s",
"=",
"None",
"self",
".",
"prev_a",
"=",
"None",
"is_first_action",
"=",
"True",
"# main loop:",
"world_state",
"=",
"agent_host",
".",
"getWorldState",
... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | CommandParser.get_commands | Get commands from xml string as a list of (command_type:int, turnbased:boolean, command:string) | MalmoEnv/malmoenv/commands.py | def get_commands(self, mission_xml, role):
"""Get commands from xml string as a list of (command_type:int, turnbased:boolean, command:string)"""
mission = etree.fromstring(mission_xml)
return self.get_commands_from_xml(mission, role) | def get_commands(self, mission_xml, role):
"""Get commands from xml string as a list of (command_type:int, turnbased:boolean, command:string)"""
mission = etree.fromstring(mission_xml)
return self.get_commands_from_xml(mission, role) | [
"Get",
"commands",
"from",
"xml",
"string",
"as",
"a",
"list",
"of",
"(",
"command_type",
":",
"int",
"turnbased",
":",
"boolean",
"command",
":",
"string",
")"
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/MalmoEnv/malmoenv/commands.py#L65-L68 | [
"def",
"get_commands",
"(",
"self",
",",
"mission_xml",
",",
"role",
")",
":",
"mission",
"=",
"etree",
".",
"fromstring",
"(",
"mission_xml",
")",
"return",
"self",
".",
"get_commands_from_xml",
"(",
"mission",
",",
"role",
")"
] | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | CommandParser.get_commands_from_file | Get commands from xml file as a list of (command_type:int, turnbased:boolean, command:string) | MalmoEnv/malmoenv/commands.py | def get_commands_from_file(self, mission_file, role):
"""Get commands from xml file as a list of (command_type:int, turnbased:boolean, command:string)"""
doc = etree.parse(mission_file)
mission = doc.getroot()
return self.get_commands_from_xml(mission, role) | def get_commands_from_file(self, mission_file, role):
"""Get commands from xml file as a list of (command_type:int, turnbased:boolean, command:string)"""
doc = etree.parse(mission_file)
mission = doc.getroot()
return self.get_commands_from_xml(mission, role) | [
"Get",
"commands",
"from",
"xml",
"file",
"as",
"a",
"list",
"of",
"(",
"command_type",
":",
"int",
"turnbased",
":",
"boolean",
"command",
":",
"string",
")"
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/MalmoEnv/malmoenv/commands.py#L70-L74 | [
"def",
"get_commands_from_file",
"(",
"self",
",",
"mission_file",
",",
"role",
")",
":",
"doc",
"=",
"etree",
".",
"parse",
"(",
"mission_file",
")",
"mission",
"=",
"doc",
".",
"getroot",
"(",
")",
"return",
"self",
".",
"get_commands_from_xml",
"(",
"mi... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | CommandParser.get_commands_from_xml | Get commands from etree | MalmoEnv/malmoenv/commands.py | def get_commands_from_xml(self, mission, role):
"""Get commands from etree"""
handlers = mission.findall(CommandParser.ns + "AgentSection" + "/" + CommandParser.ns + "AgentHandlers")
if len(handlers) <= role:
raise CommandHandlerException("Not enough agents sections in XML")
... | def get_commands_from_xml(self, mission, role):
"""Get commands from etree"""
handlers = mission.findall(CommandParser.ns + "AgentSection" + "/" + CommandParser.ns + "AgentHandlers")
if len(handlers) <= role:
raise CommandHandlerException("Not enough agents sections in XML")
... | [
"Get",
"commands",
"from",
"etree"
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/MalmoEnv/malmoenv/commands.py#L76-L83 | [
"def",
"get_commands_from_xml",
"(",
"self",
",",
"mission",
",",
"role",
")",
":",
"handlers",
"=",
"mission",
".",
"findall",
"(",
"CommandParser",
".",
"ns",
"+",
"\"AgentSection\"",
"+",
"\"/\"",
"+",
"CommandParser",
".",
"ns",
"+",
"\"AgentHandlers\"",
... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | CommandParser.get_actions | Get parameterized actions from command list based on command type and verb. | MalmoEnv/malmoenv/commands.py | def get_actions(self, commands):
"""Get parameterized actions from command list based on command type and verb."""
actions = []
for type, turn_based, verb in commands:
if len(self.action_filter) != 0 and verb not in self.action_filter:
continue
if type == ... | def get_actions(self, commands):
"""Get parameterized actions from command list based on command type and verb."""
actions = []
for type, turn_based, verb in commands:
if len(self.action_filter) != 0 and verb not in self.action_filter:
continue
if type == ... | [
"Get",
"parameterized",
"actions",
"from",
"command",
"list",
"based",
"on",
"command",
"type",
"and",
"verb",
"."
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/MalmoEnv/malmoenv/commands.py#L85-L135 | [
"def",
"get_actions",
"(",
"self",
",",
"commands",
")",
":",
"actions",
"=",
"[",
"]",
"for",
"type",
",",
"turn_based",
",",
"verb",
"in",
"commands",
":",
"if",
"len",
"(",
"self",
".",
"action_filter",
")",
"!=",
"0",
"and",
"verb",
"not",
"in",
... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | TabQAgent.loadModel | load q table from model_file | Malmo/samples/Python_examples/tabular_q_learning.py | def loadModel(self, model_file):
"""load q table from model_file"""
with open(model_file) as f:
self.q_table = json.load(f) | def loadModel(self, model_file):
"""load q table from model_file"""
with open(model_file) as f:
self.q_table = json.load(f) | [
"load",
"q",
"table",
"from",
"model_file"
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Malmo/samples/Python_examples/tabular_q_learning.py#L78-L81 | [
"def",
"loadModel",
"(",
"self",
",",
"model_file",
")",
":",
"with",
"open",
"(",
"model_file",
")",
"as",
"f",
":",
"self",
".",
"q_table",
"=",
"json",
".",
"load",
"(",
"f",
")"
] | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | TabQAgent.run | run the agent on the world | Malmo/samples/Python_examples/tabular_q_learning.py | def run(self, agent_host):
"""run the agent on the world"""
total_reward = 0
current_r = 0
tol = 0.01
self.prev_s = None
self.prev_a = None
# wait for a valid observation
world_state = agent_host.peekWorldState()
while world_stat... | def run(self, agent_host):
"""run the agent on the world"""
total_reward = 0
current_r = 0
tol = 0.01
self.prev_s = None
self.prev_a = None
# wait for a valid observation
world_state = agent_host.peekWorldState()
while world_stat... | [
"run",
"the",
"agent",
"on",
"the",
"world"
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Malmo/samples/Python_examples/tabular_q_learning.py#L137-L268 | [
"def",
"run",
"(",
"self",
",",
"agent_host",
")",
":",
"total_reward",
"=",
"0",
"current_r",
"=",
"0",
"tol",
"=",
"0.01",
"self",
".",
"prev_s",
"=",
"None",
"self",
".",
"prev_a",
"=",
"None",
"# wait for a valid observation",
"world_state",
"=",
"agen... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | download | Download Malmo from github and build (by default) the Minecraft Mod.
Example usage: import malmoenv.bootstrap; malmoenv.bootstrap.download()
Args:
branch: optional branch to clone. TODO Default is release version.
build: build the Mod unless build arg is given as False.
installdir: th... | MalmoEnv/malmoenv/bootstrap.py | def download(branch=None, build=True, installdir="MalmoPlatform"):
"""Download Malmo from github and build (by default) the Minecraft Mod.
Example usage: import malmoenv.bootstrap; malmoenv.bootstrap.download()
Args:
branch: optional branch to clone. TODO Default is release version.
build... | def download(branch=None, build=True, installdir="MalmoPlatform"):
"""Download Malmo from github and build (by default) the Minecraft Mod.
Example usage: import malmoenv.bootstrap; malmoenv.bootstrap.download()
Args:
branch: optional branch to clone. TODO Default is release version.
build... | [
"Download",
"Malmo",
"from",
"github",
"and",
"build",
"(",
"by",
"default",
")",
"the",
"Minecraft",
"Mod",
".",
"Example",
"usage",
":",
"import",
"malmoenv",
".",
"bootstrap",
";",
"malmoenv",
".",
"bootstrap",
".",
"download",
"()",
"Args",
":",
"branc... | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/MalmoEnv/malmoenv/bootstrap.py#L26-L42 | [
"def",
"download",
"(",
"branch",
"=",
"None",
",",
"build",
"=",
"True",
",",
"installdir",
"=",
"\"MalmoPlatform\"",
")",
":",
"if",
"branch",
"is",
"None",
":",
"branch",
"=",
"malmo_version",
"subprocess",
".",
"check_call",
"(",
"[",
"\"git\"",
",",
... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | setup | Set up Minecraft for use with the MalmoEnv gym environment | MalmoEnv/malmoenv/bootstrap.py | def setup(build=True, installdir="MalmoPlatform"):
"""Set up Minecraft for use with the MalmoEnv gym environment"""
gradlew = './gradlew'
if os.name == 'nt':
gradlew = 'gradlew.bat'
cwd = os.getcwd()
os.chdir(installdir)
os.chdir("Minecraft")
try:
# Create the version prope... | def setup(build=True, installdir="MalmoPlatform"):
"""Set up Minecraft for use with the MalmoEnv gym environment"""
gradlew = './gradlew'
if os.name == 'nt':
gradlew = 'gradlew.bat'
cwd = os.getcwd()
os.chdir(installdir)
os.chdir("Minecraft")
try:
# Create the version prope... | [
"Set",
"up",
"Minecraft",
"for",
"use",
"with",
"the",
"MalmoEnv",
"gym",
"environment"
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/MalmoEnv/malmoenv/bootstrap.py#L45-L65 | [
"def",
"setup",
"(",
"build",
"=",
"True",
",",
"installdir",
"=",
"\"MalmoPlatform\"",
")",
":",
"gradlew",
"=",
"'./gradlew'",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"gradlew",
"=",
"'gradlew.bat'",
"cwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"os... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | launch_minecraft | Launch Minecraft listening for malmoenv connections.
Args:
port: the TCP port to listen on.
installdir: the install dir name. Defaults to MalmoPlatform.
Must be same as given (or defaulted) in download call if used.
replaceable: whether or not to automatically restart Minecraft (def... | MalmoEnv/malmoenv/bootstrap.py | def launch_minecraft(port, installdir="MalmoPlatform", replaceable=False):
"""Launch Minecraft listening for malmoenv connections.
Args:
port: the TCP port to listen on.
installdir: the install dir name. Defaults to MalmoPlatform.
Must be same as given (or defaulted) in download call if... | def launch_minecraft(port, installdir="MalmoPlatform", replaceable=False):
"""Launch Minecraft listening for malmoenv connections.
Args:
port: the TCP port to listen on.
installdir: the install dir name. Defaults to MalmoPlatform.
Must be same as given (or defaulted) in download call if... | [
"Launch",
"Minecraft",
"listening",
"for",
"malmoenv",
"connections",
".",
"Args",
":",
"port",
":",
"the",
"TCP",
"port",
"to",
"listen",
"on",
".",
"installdir",
":",
"the",
"install",
"dir",
"name",
".",
"Defaults",
"to",
"MalmoPlatform",
".",
"Must",
"... | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/MalmoEnv/malmoenv/bootstrap.py#L68-L88 | [
"def",
"launch_minecraft",
"(",
"port",
",",
"installdir",
"=",
"\"MalmoPlatform\"",
",",
"replaceable",
"=",
"False",
")",
":",
"launch_script",
"=",
"'./launchClient.sh'",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"launch_script",
"=",
"'launchClient.bat'",
... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | processFrame | Track through the middle line of the depth data and find the max discontinuities | Malmo/samples/Python_examples/depth_map_runner.py | def processFrame( frame ):
'''Track through the middle line of the depth data and find the max discontinuities'''
global current_yaw_delta_from_depth
y = int(old_div(video_height, 2))
rowstart = y * video_width
v = 0
v_max = 0
v_max_pos = 0
v_min = 0
v_min_pos = 0
dv =... | def processFrame( frame ):
'''Track through the middle line of the depth data and find the max discontinuities'''
global current_yaw_delta_from_depth
y = int(old_div(video_height, 2))
rowstart = y * video_width
v = 0
v_max = 0
v_max_pos = 0
v_min = 0
v_min_pos = 0
dv =... | [
"Track",
"through",
"the",
"middle",
"line",
"of",
"the",
"depth",
"data",
"and",
"find",
"the",
"max",
"discontinuities"
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Malmo/samples/Python_examples/depth_map_runner.py#L58-L132 | [
"def",
"processFrame",
"(",
"frame",
")",
":",
"global",
"current_yaw_delta_from_depth",
"y",
"=",
"int",
"(",
"old_div",
"(",
"video_height",
",",
"2",
")",
")",
"rowstart",
"=",
"y",
"*",
"video_width",
"v",
"=",
"0",
"v_max",
"=",
"0",
"v_max_pos",
"=... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | checkFuelPosition | Make sure our coal, if we have any, is in slot 0. | Malmo/samples/Python_examples/craft_work.py | def checkFuelPosition(obs, agent_host):
'''Make sure our coal, if we have any, is in slot 0.'''
# (We need to do this because the furnace crafting commands - cooking the potato and the rabbit -
# take the first available item of fuel in the inventory. If this isn't the coal, it could end up burning the wood... | def checkFuelPosition(obs, agent_host):
'''Make sure our coal, if we have any, is in slot 0.'''
# (We need to do this because the furnace crafting commands - cooking the potato and the rabbit -
# take the first available item of fuel in the inventory. If this isn't the coal, it could end up burning the wood... | [
"Make",
"sure",
"our",
"coal",
"if",
"we",
"have",
"any",
"is",
"in",
"slot",
"0",
"."
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Malmo/samples/Python_examples/craft_work.py#L110-L121 | [
"def",
"checkFuelPosition",
"(",
"obs",
",",
"agent_host",
")",
":",
"# (We need to do this because the furnace crafting commands - cooking the potato and the rabbit -",
"# take the first available item of fuel in the inventory. If this isn't the coal, it could end up burning the wood",
"# that ... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | GetMissionXML | Build an XML mission string that uses the RewardForCollectingItem mission handler. | Malmo/samples/Python_examples/craft_work.py | def GetMissionXML(summary):
''' Build an XML mission string that uses the RewardForCollectingItem mission handler.'''
positions = buildPositionList(items)
return '''<?xml version="1.0" encoding="UTF-8" ?>
<Mission xmlns="http://ProjectMalmo.microsoft.com" xmlns:xsi="http://www.w3.org/2001/XMLS... | def GetMissionXML(summary):
''' Build an XML mission string that uses the RewardForCollectingItem mission handler.'''
positions = buildPositionList(items)
return '''<?xml version="1.0" encoding="UTF-8" ?>
<Mission xmlns="http://ProjectMalmo.microsoft.com" xmlns:xsi="http://www.w3.org/2001/XMLS... | [
"Build",
"an",
"XML",
"mission",
"string",
"that",
"uses",
"the",
"RewardForCollectingItem",
"mission",
"handler",
"."
] | Microsoft/malmo | python | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Malmo/samples/Python_examples/craft_work.py#L136-L192 | [
"def",
"GetMissionXML",
"(",
"summary",
")",
":",
"positions",
"=",
"buildPositionList",
"(",
"items",
")",
"return",
"'''<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n <Mission xmlns=\"http://ProjectMalmo.microsoft.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n ... | 4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a |
train | SubscriptionPage.refresh_content | Re-download all subscriptions and reset the page index | rtv/subscription_page.py | def refresh_content(self, order=None, name=None):
"""
Re-download all subscriptions and reset the page index
"""
# reddit.get_my_subreddits() does not support sorting by order
if order:
self.term.flash()
return
with self.term.loader():
... | def refresh_content(self, order=None, name=None):
"""
Re-download all subscriptions and reset the page index
"""
# reddit.get_my_subreddits() does not support sorting by order
if order:
self.term.flash()
return
with self.term.loader():
... | [
"Re",
"-",
"download",
"all",
"subscriptions",
"and",
"reset",
"the",
"page",
"index"
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/subscription_page.py#L36-L49 | [
"def",
"refresh_content",
"(",
"self",
",",
"order",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"# reddit.get_my_subreddits() does not support sorting by order",
"if",
"order",
":",
"self",
".",
"term",
".",
"flash",
"(",
")",
"return",
"with",
"self",
"... | ccef2af042566ad384977028cf0bde01bc524dda |
train | SubscriptionPage.select_subreddit | Store the selected subreddit and return to the subreddit page | rtv/subscription_page.py | def select_subreddit(self):
"""
Store the selected subreddit and return to the subreddit page
"""
name = self.get_selected_item()['name']
self.selected_page = self.open_subreddit_page(name) | def select_subreddit(self):
"""
Store the selected subreddit and return to the subreddit page
"""
name = self.get_selected_item()['name']
self.selected_page = self.open_subreddit_page(name) | [
"Store",
"the",
"selected",
"subreddit",
"and",
"return",
"to",
"the",
"subreddit",
"page"
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/subscription_page.py#L52-L57 | [
"def",
"select_subreddit",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"get_selected_item",
"(",
")",
"[",
"'name'",
"]",
"self",
".",
"selected_page",
"=",
"self",
".",
"open_subreddit_page",
"(",
"name",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | alias_function | Create a RedditContentObject function mapped to a BaseReddit function.
The BaseReddit classes define the majority of the API's functions. The
first argument for many of these functions is the RedditContentObject that
they operate on. This factory returns functions appropriate to be called on
a RedditCo... | rtv/packages/praw/decorators.py | def alias_function(function, class_name):
"""Create a RedditContentObject function mapped to a BaseReddit function.
The BaseReddit classes define the majority of the API's functions. The
first argument for many of these functions is the RedditContentObject that
they operate on. This factory returns fun... | def alias_function(function, class_name):
"""Create a RedditContentObject function mapped to a BaseReddit function.
The BaseReddit classes define the majority of the API's functions. The
first argument for many of these functions is the RedditContentObject that
they operate on. This factory returns fun... | [
"Create",
"a",
"RedditContentObject",
"function",
"mapped",
"to",
"a",
"BaseReddit",
"function",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/decorators.py#L44-L70 | [
"def",
"alias_function",
"(",
"function",
",",
"class_name",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"func_args",
"=",
"_make_func_args",
"(",
"function",
")",
"i... | ccef2af042566ad384977028cf0bde01bc524dda |
train | deprecated | Deprecate decorated method. | rtv/packages/praw/decorators.py | def deprecated(msg=''):
"""Deprecate decorated method."""
@decorator.decorator
def wrap(function, *args, **kwargs):
if not kwargs.pop('disable_warning', False):
warn(msg, DeprecationWarning)
return function(*args, **kwargs)
return wrap | def deprecated(msg=''):
"""Deprecate decorated method."""
@decorator.decorator
def wrap(function, *args, **kwargs):
if not kwargs.pop('disable_warning', False):
warn(msg, DeprecationWarning)
return function(*args, **kwargs)
return wrap | [
"Deprecate",
"decorated",
"method",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/decorators.py#L73-L80 | [
"def",
"deprecated",
"(",
"msg",
"=",
"''",
")",
":",
"@",
"decorator",
".",
"decorator",
"def",
"wrap",
"(",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"kwargs",
".",
"pop",
"(",
"'disable_warning'",
",",
"False",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | limit_chars | Truncate the string returned from a function and return the result. | rtv/packages/praw/decorators.py | def limit_chars(function, *args, **kwargs):
"""Truncate the string returned from a function and return the result."""
output_chars_limit = args[0].reddit_session.config.output_chars_limit
output_string = function(*args, **kwargs)
if -1 < output_chars_limit < len(output_string):
output_string = o... | def limit_chars(function, *args, **kwargs):
"""Truncate the string returned from a function and return the result."""
output_chars_limit = args[0].reddit_session.config.output_chars_limit
output_string = function(*args, **kwargs)
if -1 < output_chars_limit < len(output_string):
output_string = o... | [
"Truncate",
"the",
"string",
"returned",
"from",
"a",
"function",
"and",
"return",
"the",
"result",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/decorators.py#L84-L90 | [
"def",
"limit_chars",
"(",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"output_chars_limit",
"=",
"args",
"[",
"0",
"]",
".",
"reddit_session",
".",
"config",
".",
"output_chars_limit",
"output_string",
"=",
"function",
"(",
"*",
"args... | ccef2af042566ad384977028cf0bde01bc524dda |
train | oauth_generator | Set the _use_oauth keyword argument to True when appropriate.
This is needed because generator functions may be called at anytime, and
PRAW relies on the Reddit._use_oauth value at original call time to know
when to make OAuth requests.
Returned data is not modified. | rtv/packages/praw/decorators.py | def oauth_generator(function, *args, **kwargs):
"""Set the _use_oauth keyword argument to True when appropriate.
This is needed because generator functions may be called at anytime, and
PRAW relies on the Reddit._use_oauth value at original call time to know
when to make OAuth requests.
Returned d... | def oauth_generator(function, *args, **kwargs):
"""Set the _use_oauth keyword argument to True when appropriate.
This is needed because generator functions may be called at anytime, and
PRAW relies on the Reddit._use_oauth value at original call time to know
when to make OAuth requests.
Returned d... | [
"Set",
"the",
"_use_oauth",
"keyword",
"argument",
"to",
"True",
"when",
"appropriate",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/decorators.py#L94-L106 | [
"def",
"oauth_generator",
"(",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"getattr",
"(",
"args",
"[",
"0",
"]",
",",
"'_use_oauth'",
",",
"False",
")",
":",
"kwargs",
"[",
"'_use_oauth'",
"]",
"=",
"True",
"return",
"func... | ccef2af042566ad384977028cf0bde01bc524dda |
train | raise_api_exceptions | Raise client side exception(s) when present in the API response.
Returned data is not modified. | rtv/packages/praw/decorators.py | def raise_api_exceptions(function, *args, **kwargs):
"""Raise client side exception(s) when present in the API response.
Returned data is not modified.
"""
try:
return_value = function(*args, **kwargs)
except errors.HTTPException as exc:
if exc._raw.status_code != 400: # pylint: d... | def raise_api_exceptions(function, *args, **kwargs):
"""Raise client side exception(s) when present in the API response.
Returned data is not modified.
"""
try:
return_value = function(*args, **kwargs)
except errors.HTTPException as exc:
if exc._raw.status_code != 400: # pylint: d... | [
"Raise",
"client",
"side",
"exception",
"(",
"s",
")",
"when",
"present",
"in",
"the",
"API",
"response",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/decorators.py#L110-L146 | [
"def",
"raise_api_exceptions",
"(",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return_value",
"=",
"function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"errors",
".",
"HTTPException",
"as",
"exc",
":"... | ccef2af042566ad384977028cf0bde01bc524dda |
train | require_captcha | Return a decorator for methods that require captchas. | rtv/packages/praw/decorators.py | def require_captcha(function, *args, **kwargs):
"""Return a decorator for methods that require captchas."""
raise_captcha_exception = kwargs.pop('raise_captcha_exception', False)
captcha_id = None
# Get a handle to the reddit session
if hasattr(args[0], 'reddit_session'):
reddit_session = a... | def require_captcha(function, *args, **kwargs):
"""Return a decorator for methods that require captchas."""
raise_captcha_exception = kwargs.pop('raise_captcha_exception', False)
captcha_id = None
# Get a handle to the reddit session
if hasattr(args[0], 'reddit_session'):
reddit_session = a... | [
"Return",
"a",
"decorator",
"for",
"methods",
"that",
"require",
"captchas",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/decorators.py#L150-L183 | [
"def",
"require_captcha",
"(",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise_captcha_exception",
"=",
"kwargs",
".",
"pop",
"(",
"'raise_captcha_exception'",
",",
"False",
")",
"captcha_id",
"=",
"None",
"# Get a handle to the reddit sess... | ccef2af042566ad384977028cf0bde01bc524dda |
train | restrict_access | Restrict function access unless the user has the necessary permissions.
Raises one of the following exceptions when appropriate:
* LoginRequired
* LoginOrOAuthRequired
* the scope attribute will provide the necessary scope name
* ModeratorRequired
* ModeratorOrOAuthRequired
... | rtv/packages/praw/decorators.py | def restrict_access(scope, mod=None, login=None, oauth_only=False,
generator_called=False):
"""Restrict function access unless the user has the necessary permissions.
Raises one of the following exceptions when appropriate:
* LoginRequired
* LoginOrOAuthRequired
* the sc... | def restrict_access(scope, mod=None, login=None, oauth_only=False,
generator_called=False):
"""Restrict function access unless the user has the necessary permissions.
Raises one of the following exceptions when appropriate:
* LoginRequired
* LoginOrOAuthRequired
* the sc... | [
"Restrict",
"function",
"access",
"unless",
"the",
"user",
"has",
"the",
"necessary",
"permissions",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/decorators.py#L186-L280 | [
"def",
"restrict_access",
"(",
"scope",
",",
"mod",
"=",
"None",
",",
"login",
"=",
"None",
",",
"oauth_only",
"=",
"False",
",",
"generator_called",
"=",
"False",
")",
":",
"if",
"not",
"scope",
"and",
"oauth_only",
":",
"raise",
"TypeError",
"(",
"'`sc... | ccef2af042566ad384977028cf0bde01bc524dda |
train | require_oauth | Verify that the OAuth functions can be used prior to use.
Returned data is not modified. | rtv/packages/praw/decorators.py | def require_oauth(function, *args, **kwargs):
"""Verify that the OAuth functions can be used prior to use.
Returned data is not modified.
"""
if not args[0].has_oauth_app_info:
err_msg = ("The OAuth app config parameters client_id, client_secret "
"and redirect_url must be s... | def require_oauth(function, *args, **kwargs):
"""Verify that the OAuth functions can be used prior to use.
Returned data is not modified.
"""
if not args[0].has_oauth_app_info:
err_msg = ("The OAuth app config parameters client_id, client_secret "
"and redirect_url must be s... | [
"Verify",
"that",
"the",
"OAuth",
"functions",
"can",
"be",
"used",
"prior",
"to",
"use",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/decorators.py#L284-L294 | [
"def",
"require_oauth",
"(",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"args",
"[",
"0",
"]",
".",
"has_oauth_app_info",
":",
"err_msg",
"=",
"(",
"\"The OAuth app config parameters client_id, client_secret \"",
"\"and redirect_... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Content.iterate | Return an iterator that starts and the current index and increments
by the given step. | rtv/content.py | def iterate(self, index, step, n_cols=70):
"""
Return an iterator that starts and the current index and increments
by the given step.
"""
while True:
if step < 0 and index < 0:
# Hack to prevent displaying a submission's post if iterating
... | def iterate(self, index, step, n_cols=70):
"""
Return an iterator that starts and the current index and increments
by the given step.
"""
while True:
if step < 0 and index < 0:
# Hack to prevent displaying a submission's post if iterating
... | [
"Return",
"an",
"iterator",
"that",
"starts",
"and",
"the",
"current",
"index",
"and",
"increments",
"by",
"the",
"given",
"step",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L32-L47 | [
"def",
"iterate",
"(",
"self",
",",
"index",
",",
"step",
",",
"n_cols",
"=",
"70",
")",
":",
"while",
"True",
":",
"if",
"step",
"<",
"0",
"and",
"index",
"<",
"0",
":",
"# Hack to prevent displaying a submission's post if iterating",
"# comments in the negativ... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Content.flatten_comments | Flatten a PRAW comment tree while preserving the nested level of each
comment via the `nested_level` attribute.
There are a couple of different ways that the input comment list can be
organized depending on its source:
1. Comments that are returned from the get_submission() api cal... | rtv/content.py | def flatten_comments(comments, root_level=0):
"""
Flatten a PRAW comment tree while preserving the nested level of each
comment via the `nested_level` attribute.
There are a couple of different ways that the input comment list can be
organized depending on its source:
... | def flatten_comments(comments, root_level=0):
"""
Flatten a PRAW comment tree while preserving the nested level of each
comment via the `nested_level` attribute.
There are a couple of different ways that the input comment list can be
organized depending on its source:
... | [
"Flatten",
"a",
"PRAW",
"comment",
"tree",
"while",
"preserving",
"the",
"nested",
"level",
"of",
"each",
"comment",
"via",
"the",
"nested_level",
"attribute",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L57-L120 | [
"def",
"flatten_comments",
"(",
"comments",
",",
"root_level",
"=",
"0",
")",
":",
"stack",
"=",
"comments",
"[",
":",
"]",
"for",
"item",
"in",
"stack",
":",
"item",
".",
"nested_level",
"=",
"root_level",
"retval",
",",
"parent_candidates",
"=",
"[",
"... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Content.strip_praw_comment | Parse through a submission comment and return a dict with data ready to
be displayed through the terminal. | rtv/content.py | def strip_praw_comment(cls, comment):
"""
Parse through a submission comment and return a dict with data ready to
be displayed through the terminal.
"""
data = {}
data['object'] = comment
if isinstance(comment, praw.objects.MoreComments):
data['type'... | def strip_praw_comment(cls, comment):
"""
Parse through a submission comment and return a dict with data ready to
be displayed through the terminal.
"""
data = {}
data['object'] = comment
if isinstance(comment, praw.objects.MoreComments):
data['type'... | [
"Parse",
"through",
"a",
"submission",
"comment",
"and",
"return",
"a",
"dict",
"with",
"data",
"ready",
"to",
"be",
"displayed",
"through",
"the",
"terminal",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L123-L205 | [
"def",
"strip_praw_comment",
"(",
"cls",
",",
"comment",
")",
":",
"data",
"=",
"{",
"}",
"data",
"[",
"'object'",
"]",
"=",
"comment",
"if",
"isinstance",
"(",
"comment",
",",
"praw",
".",
"objects",
".",
"MoreComments",
")",
":",
"data",
"[",
"'type'... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Content.strip_praw_submission | Parse through a submission and return a dict with data ready to be
displayed through the terminal.
Definitions:
permalink - URL to the reddit page with submission comments.
url_full - URL that the submission points to.
url - URL that will be displayed on the subreddi... | rtv/content.py | def strip_praw_submission(cls, sub):
"""
Parse through a submission and return a dict with data ready to be
displayed through the terminal.
Definitions:
permalink - URL to the reddit page with submission comments.
url_full - URL that the submission points to.
... | def strip_praw_submission(cls, sub):
"""
Parse through a submission and return a dict with data ready to be
displayed through the terminal.
Definitions:
permalink - URL to the reddit page with submission comments.
url_full - URL that the submission points to.
... | [
"Parse",
"through",
"a",
"submission",
"and",
"return",
"a",
"dict",
"with",
"data",
"ready",
"to",
"be",
"displayed",
"through",
"the",
"terminal",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L208-L276 | [
"def",
"strip_praw_submission",
"(",
"cls",
",",
"sub",
")",
":",
"reddit_link",
"=",
"re",
".",
"compile",
"(",
"r'https?://(www\\.)?(np\\.)?redd(it\\.com|\\.it)/r/.*'",
")",
"author",
"=",
"getattr",
"(",
"sub",
",",
"'author'",
",",
"'[deleted]'",
")",
"name",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Content.strip_praw_subscription | Parse through a subscription and return a dict with data ready to be
displayed through the terminal. | rtv/content.py | def strip_praw_subscription(subscription):
"""
Parse through a subscription and return a dict with data ready to be
displayed through the terminal.
"""
data = {}
data['object'] = subscription
if isinstance(subscription, praw.objects.Multireddit):
data... | def strip_praw_subscription(subscription):
"""
Parse through a subscription and return a dict with data ready to be
displayed through the terminal.
"""
data = {}
data['object'] = subscription
if isinstance(subscription, praw.objects.Multireddit):
data... | [
"Parse",
"through",
"a",
"subscription",
"and",
"return",
"a",
"dict",
"with",
"data",
"ready",
"to",
"be",
"displayed",
"through",
"the",
"terminal",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L279-L296 | [
"def",
"strip_praw_subscription",
"(",
"subscription",
")",
":",
"data",
"=",
"{",
"}",
"data",
"[",
"'object'",
"]",
"=",
"subscription",
"if",
"isinstance",
"(",
"subscription",
",",
"praw",
".",
"objects",
".",
"Multireddit",
")",
":",
"data",
"[",
"'ty... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Content.strip_praw_message | Parse through a message and return a dict with data ready to be
displayed through the terminal. Messages can be of either type
praw.objects.Message or praw.object.Comment. The comments returned will
contain special fields unique to messages and can't be parsed as normal
comment objects. | rtv/content.py | def strip_praw_message(cls, msg):
"""
Parse through a message and return a dict with data ready to be
displayed through the terminal. Messages can be of either type
praw.objects.Message or praw.object.Comment. The comments returned will
contain special fields unique to messages a... | def strip_praw_message(cls, msg):
"""
Parse through a message and return a dict with data ready to be
displayed through the terminal. Messages can be of either type
praw.objects.Message or praw.object.Comment. The comments returned will
contain special fields unique to messages a... | [
"Parse",
"through",
"a",
"message",
"and",
"return",
"a",
"dict",
"with",
"data",
"ready",
"to",
"be",
"displayed",
"through",
"the",
"terminal",
".",
"Messages",
"can",
"be",
"of",
"either",
"type",
"praw",
".",
"objects",
".",
"Message",
"or",
"praw",
... | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L299-L342 | [
"def",
"strip_praw_message",
"(",
"cls",
",",
"msg",
")",
":",
"author",
"=",
"getattr",
"(",
"msg",
",",
"'author'",
",",
"None",
")",
"data",
"=",
"{",
"}",
"data",
"[",
"'object'",
"]",
"=",
"msg",
"if",
"isinstance",
"(",
"msg",
",",
"praw",
".... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Content.humanize_timestamp | Convert a utc timestamp into a human readable relative-time. | rtv/content.py | def humanize_timestamp(utc_timestamp, verbose=False):
"""
Convert a utc timestamp into a human readable relative-time.
"""
timedelta = datetime.utcnow() - datetime.utcfromtimestamp(utc_timestamp)
seconds = int(timedelta.total_seconds())
if seconds < 60:
retu... | def humanize_timestamp(utc_timestamp, verbose=False):
"""
Convert a utc timestamp into a human readable relative-time.
"""
timedelta = datetime.utcnow() - datetime.utcfromtimestamp(utc_timestamp)
seconds = int(timedelta.total_seconds())
if seconds < 60:
retu... | [
"Convert",
"a",
"utc",
"timestamp",
"into",
"a",
"human",
"readable",
"relative",
"-",
"time",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L345-L398 | [
"def",
"humanize_timestamp",
"(",
"utc_timestamp",
",",
"verbose",
"=",
"False",
")",
":",
"timedelta",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"-",
"datetime",
".",
"utcfromtimestamp",
"(",
"utc_timestamp",
")",
"seconds",
"=",
"int",
"(",
"timedelta",
".... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Content.wrap_text | Wrap text paragraphs to the given character width while preserving
newlines. | rtv/content.py | def wrap_text(text, width):
"""
Wrap text paragraphs to the given character width while preserving
newlines.
"""
out = []
for paragraph in text.splitlines():
# Wrap returns an empty list when paragraph is a newline. In order
# to preserve newlines ... | def wrap_text(text, width):
"""
Wrap text paragraphs to the given character width while preserving
newlines.
"""
out = []
for paragraph in text.splitlines():
# Wrap returns an empty list when paragraph is a newline. In order
# to preserve newlines ... | [
"Wrap",
"text",
"paragraphs",
"to",
"the",
"given",
"character",
"width",
"while",
"preserving",
"newlines",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L401-L413 | [
"def",
"wrap_text",
"(",
"text",
",",
"width",
")",
":",
"out",
"=",
"[",
"]",
"for",
"paragraph",
"in",
"text",
".",
"splitlines",
"(",
")",
":",
"# Wrap returns an empty list when paragraph is a newline. In order",
"# to preserve newlines we substitute a list containing... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Content.extract_links | Extract a list of hyperlinks from an HTML document. | rtv/content.py | def extract_links(html):
"""
Extract a list of hyperlinks from an HTML document.
"""
links = []
soup = BeautifulSoup(html, 'html.parser')
for link in soup.findAll('a'):
href = link.get('href')
if not href:
continue
if hr... | def extract_links(html):
"""
Extract a list of hyperlinks from an HTML document.
"""
links = []
soup = BeautifulSoup(html, 'html.parser')
for link in soup.findAll('a'):
href = link.get('href')
if not href:
continue
if hr... | [
"Extract",
"a",
"list",
"of",
"hyperlinks",
"from",
"an",
"HTML",
"document",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L416-L429 | [
"def",
"extract_links",
"(",
"html",
")",
":",
"links",
"=",
"[",
"]",
"soup",
"=",
"BeautifulSoup",
"(",
"html",
",",
"'html.parser'",
")",
"for",
"link",
"in",
"soup",
".",
"findAll",
"(",
"'a'",
")",
":",
"href",
"=",
"link",
".",
"get",
"(",
"'... | ccef2af042566ad384977028cf0bde01bc524dda |
train | SubmissionContent.get | Grab the `i`th submission, with the title field formatted to fit inside
of a window of width `n` | rtv/content.py | def get(self, index, n_cols=70):
"""
Grab the `i`th submission, with the title field formatted to fit inside
of a window of width `n`
"""
if index < -1:
raise IndexError
elif index == -1:
data = self._submission_data
data['split_title... | def get(self, index, n_cols=70):
"""
Grab the `i`th submission, with the title field formatted to fit inside
of a window of width `n`
"""
if index < -1:
raise IndexError
elif index == -1:
data = self._submission_data
data['split_title... | [
"Grab",
"the",
"i",
"th",
"submission",
"with",
"the",
"title",
"field",
"formatted",
"to",
"fit",
"inside",
"of",
"a",
"window",
"of",
"width",
"n"
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L479-L507 | [
"def",
"get",
"(",
"self",
",",
"index",
",",
"n_cols",
"=",
"70",
")",
":",
"if",
"index",
"<",
"-",
"1",
":",
"raise",
"IndexError",
"elif",
"index",
"==",
"-",
"1",
":",
"data",
"=",
"self",
".",
"_submission_data",
"data",
"[",
"'split_title'",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | SubmissionContent.toggle | Toggle the state of the object at the given index.
If it is a comment, pack it into a hidden comment.
If it is a hidden comment, unpack it.
If it is more comments, load the comments. | rtv/content.py | def toggle(self, index, n_cols=70):
"""
Toggle the state of the object at the given index.
If it is a comment, pack it into a hidden comment.
If it is a hidden comment, unpack it.
If it is more comments, load the comments.
"""
data = self.get(index)
if d... | def toggle(self, index, n_cols=70):
"""
Toggle the state of the object at the given index.
If it is a comment, pack it into a hidden comment.
If it is a hidden comment, unpack it.
If it is more comments, load the comments.
"""
data = self.get(index)
if d... | [
"Toggle",
"the",
"state",
"of",
"the",
"object",
"at",
"the",
"given",
"index",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L509-L557 | [
"def",
"toggle",
"(",
"self",
",",
"index",
",",
"n_cols",
"=",
"70",
")",
":",
"data",
"=",
"self",
".",
"get",
"(",
"index",
")",
"if",
"data",
"[",
"'type'",
"]",
"==",
"'Submission'",
":",
"# Can't hide the submission!",
"pass",
"elif",
"data",
"["... | ccef2af042566ad384977028cf0bde01bc524dda |
train | SubredditContent.from_name | Params:
reddit (praw.Reddit): Instance of the reddit api.
name (text): The name of the desired subreddit, user, multireddit,
etc. In most cases this translates directly from the URL that
reddit itself uses. This is what users will type in the command
... | rtv/content.py | def from_name(cls, reddit, name, loader, order=None, query=None):
"""
Params:
reddit (praw.Reddit): Instance of the reddit api.
name (text): The name of the desired subreddit, user, multireddit,
etc. In most cases this translates directly from the URL that
... | def from_name(cls, reddit, name, loader, order=None, query=None):
"""
Params:
reddit (praw.Reddit): Instance of the reddit api.
name (text): The name of the desired subreddit, user, multireddit,
etc. In most cases this translates directly from the URL that
... | [
"Params",
":",
"reddit",
"(",
"praw",
".",
"Reddit",
")",
":",
"Instance",
"of",
"the",
"reddit",
"api",
".",
"name",
"(",
"text",
")",
":",
"The",
"name",
"of",
"the",
"desired",
"subreddit",
"user",
"multireddit",
"etc",
".",
"In",
"most",
"cases",
... | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L591-L800 | [
"def",
"from_name",
"(",
"cls",
",",
"reddit",
",",
"name",
",",
"loader",
",",
"order",
"=",
"None",
",",
"query",
"=",
"None",
")",
":",
"# TODO: This desperately needs to be refactored",
"# Strip leading, trailing, and redundant backslashes",
"parts",
"=",
"[",
"... | ccef2af042566ad384977028cf0bde01bc524dda |
train | SubredditContent.get | Grab the `i`th submission, with the title field formatted to fit inside
of a window of width `n_cols` | rtv/content.py | def get(self, index, n_cols=70):
"""
Grab the `i`th submission, with the title field formatted to fit inside
of a window of width `n_cols`
"""
if index < 0:
raise IndexError
nsfw_count = 0
while index >= len(self._submission_data):
try:
... | def get(self, index, n_cols=70):
"""
Grab the `i`th submission, with the title field formatted to fit inside
of a window of width `n_cols`
"""
if index < 0:
raise IndexError
nsfw_count = 0
while index >= len(self._submission_data):
try:
... | [
"Grab",
"the",
"i",
"th",
"submission",
"with",
"the",
"title",
"field",
"formatted",
"to",
"fit",
"inside",
"of",
"a",
"window",
"of",
"width",
"n_cols"
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L809-L863 | [
"def",
"get",
"(",
"self",
",",
"index",
",",
"n_cols",
"=",
"70",
")",
":",
"if",
"index",
"<",
"0",
":",
"raise",
"IndexError",
"nsfw_count",
"=",
"0",
"while",
"index",
">=",
"len",
"(",
"self",
".",
"_submission_data",
")",
":",
"try",
":",
"wi... | ccef2af042566ad384977028cf0bde01bc524dda |
train | SubscriptionContent.get | Grab the `i`th object, with the title field formatted to fit
inside of a window of width `n_cols` | rtv/content.py | def get(self, index, n_cols=70):
"""
Grab the `i`th object, with the title field formatted to fit
inside of a window of width `n_cols`
"""
if index < 0:
raise IndexError
while index >= len(self._subscription_data):
try:
with self.... | def get(self, index, n_cols=70):
"""
Grab the `i`th object, with the title field formatted to fit
inside of a window of width `n_cols`
"""
if index < 0:
raise IndexError
while index >= len(self._subscription_data):
try:
with self.... | [
"Grab",
"the",
"i",
"th",
"object",
"with",
"the",
"title",
"field",
"formatted",
"to",
"fit",
"inside",
"of",
"a",
"window",
"of",
"width",
"n_cols"
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L912-L938 | [
"def",
"get",
"(",
"self",
",",
"index",
",",
"n_cols",
"=",
"70",
")",
":",
"if",
"index",
"<",
"0",
":",
"raise",
"IndexError",
"while",
"index",
">=",
"len",
"(",
"self",
".",
"_subscription_data",
")",
":",
"try",
":",
"with",
"self",
".",
"_lo... | ccef2af042566ad384977028cf0bde01bc524dda |
train | InboxContent.get | Grab the `i`th object, with the title field formatted to fit
inside of a window of width `n_cols` | rtv/content.py | def get(self, index, n_cols=70):
"""
Grab the `i`th object, with the title field formatted to fit
inside of a window of width `n_cols`
"""
if index < 0:
raise IndexError
while index >= len(self._content_data):
try:
with self._load... | def get(self, index, n_cols=70):
"""
Grab the `i`th object, with the title field formatted to fit
inside of a window of width `n_cols`
"""
if index < 0:
raise IndexError
while index >= len(self._content_data):
try:
with self._load... | [
"Grab",
"the",
"i",
"th",
"object",
"with",
"the",
"title",
"field",
"formatted",
"to",
"fit",
"inside",
"of",
"a",
"window",
"of",
"width",
"n_cols"
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L988-L1024 | [
"def",
"get",
"(",
"self",
",",
"index",
",",
"n_cols",
"=",
"70",
")",
":",
"if",
"index",
"<",
"0",
":",
"raise",
"IndexError",
"while",
"index",
">=",
"len",
"(",
"self",
".",
"_content_data",
")",
":",
"try",
":",
"with",
"self",
".",
"_loader"... | ccef2af042566ad384977028cf0bde01bc524dda |
train | RequestHeaderRateLimiter._delay | Pause before making the next HTTP request. | rtv/content.py | def _delay(self):
"""
Pause before making the next HTTP request.
"""
if self.next_request_timestamp is None:
return
sleep_seconds = self.next_request_timestamp - time.time()
if sleep_seconds <= 0:
return
time.sleep(sleep_seconds) | def _delay(self):
"""
Pause before making the next HTTP request.
"""
if self.next_request_timestamp is None:
return
sleep_seconds = self.next_request_timestamp - time.time()
if sleep_seconds <= 0:
return
time.sleep(sleep_seconds) | [
"Pause",
"before",
"making",
"the",
"next",
"HTTP",
"request",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L1058-L1068 | [
"def",
"_delay",
"(",
"self",
")",
":",
"if",
"self",
".",
"next_request_timestamp",
"is",
"None",
":",
"return",
"sleep_seconds",
"=",
"self",
".",
"next_request_timestamp",
"-",
"time",
".",
"time",
"(",
")",
"if",
"sleep_seconds",
"<=",
"0",
":",
"retur... | ccef2af042566ad384977028cf0bde01bc524dda |
train | RequestHeaderRateLimiter._update | Update the state of the rate limiter based on the response headers:
X-Ratelimit-Used: Approximate number of requests used this period
X-Ratelimit-Remaining: Approximate number of requests left to use
X-Ratelimit-Reset: Approximate number of seconds to end of period
PRAW 5's... | rtv/content.py | def _update(self, response_headers):
"""
Update the state of the rate limiter based on the response headers:
X-Ratelimit-Used: Approximate number of requests used this period
X-Ratelimit-Remaining: Approximate number of requests left to use
X-Ratelimit-Reset: Approxi... | def _update(self, response_headers):
"""
Update the state of the rate limiter based on the response headers:
X-Ratelimit-Used: Approximate number of requests used this period
X-Ratelimit-Remaining: Approximate number of requests left to use
X-Ratelimit-Reset: Approxi... | [
"Update",
"the",
"state",
"of",
"the",
"rate",
"limiter",
"based",
"on",
"the",
"response",
"headers",
":"
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L1070-L1104 | [
"def",
"_update",
"(",
"self",
",",
"response_headers",
")",
":",
"if",
"'x-ratelimit-remaining'",
"not",
"in",
"response_headers",
":",
"# This could be because the API returned an error response, or it",
"# could be because we're using something like read-only credentials",
"# whic... | ccef2af042566ad384977028cf0bde01bc524dda |
train | RequestHeaderRateLimiter._clear_timeouts | Clear the cache of timed out results. | rtv/content.py | def _clear_timeouts(self, cache_timeout):
"""
Clear the cache of timed out results.
"""
for key in list(self.timeouts):
if timer() - self.timeouts[key] > cache_timeout:
del self.timeouts[key]
del self.cache[key] | def _clear_timeouts(self, cache_timeout):
"""
Clear the cache of timed out results.
"""
for key in list(self.timeouts):
if timer() - self.timeouts[key] > cache_timeout:
del self.timeouts[key]
del self.cache[key] | [
"Clear",
"the",
"cache",
"of",
"timed",
"out",
"results",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L1106-L1114 | [
"def",
"_clear_timeouts",
"(",
"self",
",",
"cache_timeout",
")",
":",
"for",
"key",
"in",
"list",
"(",
"self",
".",
"timeouts",
")",
":",
"if",
"timer",
"(",
")",
"-",
"self",
".",
"timeouts",
"[",
"key",
"]",
">",
"cache_timeout",
":",
"del",
"self... | ccef2af042566ad384977028cf0bde01bc524dda |
train | RequestHeaderRateLimiter.evict | Remove items from cache matching URLs.
Return the number of items removed. | rtv/content.py | def evict(self, urls):
"""Remove items from cache matching URLs.
Return the number of items removed.
"""
if isinstance(urls, six.text_type):
urls = [urls]
urls = set(normalize_url(url) for url in urls)
retval = 0
for key in list(self.cache):
... | def evict(self, urls):
"""Remove items from cache matching URLs.
Return the number of items removed.
"""
if isinstance(urls, six.text_type):
urls = [urls]
urls = set(normalize_url(url) for url in urls)
retval = 0
for key in list(self.cache):
... | [
"Remove",
"items",
"from",
"cache",
"matching",
"URLs",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L1121-L1135 | [
"def",
"evict",
"(",
"self",
",",
"urls",
")",
":",
"if",
"isinstance",
"(",
"urls",
",",
"six",
".",
"text_type",
")",
":",
"urls",
"=",
"[",
"urls",
"]",
"urls",
"=",
"set",
"(",
"normalize_url",
"(",
"url",
")",
"for",
"url",
"in",
"urls",
")"... | ccef2af042566ad384977028cf0bde01bc524dda |
train | RequestHeaderRateLimiter.request | This is a wrapper function that handles the caching of the request.
See DefaultHandler.with_cache for reference. | rtv/content.py | def request(self, _cache_key, _cache_ignore, _cache_timeout, **kwargs):
"""
This is a wrapper function that handles the caching of the request.
See DefaultHandler.with_cache for reference.
"""
if _cache_key:
# Pop the request's session cookies from the cache key.
... | def request(self, _cache_key, _cache_ignore, _cache_timeout, **kwargs):
"""
This is a wrapper function that handles the caching of the request.
See DefaultHandler.with_cache for reference.
"""
if _cache_key:
# Pop the request's session cookies from the cache key.
... | [
"This",
"is",
"a",
"wrapper",
"function",
"that",
"handles",
"the",
"caching",
"of",
"the",
"request",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L1137-L1174 | [
"def",
"request",
"(",
"self",
",",
"_cache_key",
",",
"_cache_ignore",
",",
"_cache_timeout",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"_cache_key",
":",
"# Pop the request's session cookies from the cache key.",
"# These appear to be unreliable and change with every",
"# ... | ccef2af042566ad384977028cf0bde01bc524dda |
train | RequestHeaderRateLimiter._request | This is where we apply rate limiting and make the HTTP request. | rtv/content.py | def _request(self, request, proxies, timeout, verify, **_):
"""
This is where we apply rate limiting and make the HTTP request.
"""
settings = self.http.merge_environment_settings(
request.url, proxies, False, verify, None)
self._delay()
response = self.http... | def _request(self, request, proxies, timeout, verify, **_):
"""
This is where we apply rate limiting and make the HTTP request.
"""
settings = self.http.merge_environment_settings(
request.url, proxies, False, verify, None)
self._delay()
response = self.http... | [
"This",
"is",
"where",
"we",
"apply",
"rate",
"limiting",
"and",
"make",
"the",
"HTTP",
"request",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/content.py#L1176-L1189 | [
"def",
"_request",
"(",
"self",
",",
"request",
",",
"proxies",
",",
"timeout",
",",
"verify",
",",
"*",
"*",
"_",
")",
":",
"settings",
"=",
"self",
".",
"http",
".",
"merge_environment_settings",
"(",
"request",
".",
"url",
",",
"proxies",
",",
"Fals... | ccef2af042566ad384977028cf0bde01bc524dda |
train | Config.ua_string | Return the user-agent string.
The user-agent string contains PRAW version and platform version info. | rtv/packages/praw/__init__.py | def ua_string(praw_info):
"""Return the user-agent string.
The user-agent string contains PRAW version and platform version info.
"""
if os.environ.get('SERVER_SOFTWARE') is not None:
# Google App Engine information
# https://developers.google.com/appengine/docs... | def ua_string(praw_info):
"""Return the user-agent string.
The user-agent string contains PRAW version and platform version info.
"""
if os.environ.get('SERVER_SOFTWARE') is not None:
# Google App Engine information
# https://developers.google.com/appengine/docs... | [
"Return",
"the",
"user",
"-",
"agent",
"string",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L197-L212 | [
"def",
"ua_string",
"(",
"praw_info",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'SERVER_SOFTWARE'",
")",
"is",
"not",
"None",
":",
"# Google App Engine information",
"# https://developers.google.com/appengine/docs/python/",
"info",
"=",
"os",
".",
"env... | ccef2af042566ad384977028cf0bde01bc524dda |
train | BaseReddit._request | Given a page url and a dict of params, open and return the page.
:param url: the url to grab content from.
:param params: a dictionary containing the GET data to put in the url
:param data: a dictionary containing the extra data to submit
:param files: a dictionary specifying the files ... | rtv/packages/praw/__init__.py | def _request(self, url, params=None, data=None, files=None, auth=None,
timeout=None, raw_response=False, retry_on_error=True,
method=None):
"""Given a page url and a dict of params, open and return the page.
:param url: the url to grab content from.
:param para... | def _request(self, url, params=None, data=None, files=None, auth=None,
timeout=None, raw_response=False, retry_on_error=True,
method=None):
"""Given a page url and a dict of params, open and return the page.
:param url: the url to grab content from.
:param para... | [
"Given",
"a",
"page",
"url",
"and",
"a",
"dict",
"of",
"params",
"open",
"and",
"return",
"the",
"page",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L378-L475 | [
"def",
"_request",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"files",
"=",
"None",
",",
"auth",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"raw_response",
"=",
"False",
",",
"retry_on_error",
"=",
"True",... | ccef2af042566ad384977028cf0bde01bc524dda |
train | BaseReddit._json_reddit_objecter | Return an appropriate RedditObject from json_data when possible. | rtv/packages/praw/__init__.py | def _json_reddit_objecter(self, json_data):
"""Return an appropriate RedditObject from json_data when possible."""
try:
object_class = self.config.by_kind[json_data['kind']]
except KeyError:
if 'json' in json_data:
if len(json_data) != 1:
... | def _json_reddit_objecter(self, json_data):
"""Return an appropriate RedditObject from json_data when possible."""
try:
object_class = self.config.by_kind[json_data['kind']]
except KeyError:
if 'json' in json_data:
if len(json_data) != 1:
... | [
"Return",
"an",
"appropriate",
"RedditObject",
"from",
"json_data",
"when",
"possible",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L477-L489 | [
"def",
"_json_reddit_objecter",
"(",
"self",
",",
"json_data",
")",
":",
"try",
":",
"object_class",
"=",
"self",
".",
"config",
".",
"by_kind",
"[",
"json_data",
"[",
"'kind'",
"]",
"]",
"except",
"KeyError",
":",
"if",
"'json'",
"in",
"json_data",
":",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | BaseReddit.evict | Evict url(s) from the cache.
:param urls: An iterable containing normalized urls.
:returns: The number of items removed from the cache. | rtv/packages/praw/__init__.py | def evict(self, urls):
"""Evict url(s) from the cache.
:param urls: An iterable containing normalized urls.
:returns: The number of items removed from the cache.
"""
if isinstance(urls, six.string_types):
urls = (urls,)
return self.handler.evict(urls) | def evict(self, urls):
"""Evict url(s) from the cache.
:param urls: An iterable containing normalized urls.
:returns: The number of items removed from the cache.
"""
if isinstance(urls, six.string_types):
urls = (urls,)
return self.handler.evict(urls) | [
"Evict",
"url",
"(",
"s",
")",
"from",
"the",
"cache",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L491-L500 | [
"def",
"evict",
"(",
"self",
",",
"urls",
")",
":",
"if",
"isinstance",
"(",
"urls",
",",
"six",
".",
"string_types",
")",
":",
"urls",
"=",
"(",
"urls",
",",
")",
"return",
"self",
".",
"handler",
".",
"evict",
"(",
"urls",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | BaseReddit.get_content | A generator method to return reddit content from a URL.
Starts at the initial url, and fetches content using the `after`
JSON data until `limit` entries have been fetched, or the
`place_holder` has been reached.
:param url: the url to start fetching content from
:param params: ... | rtv/packages/praw/__init__.py | def get_content(self, url, params=None, limit=0, place_holder=None,
root_field='data', thing_field='children',
after_field='after', object_filter=None, **kwargs):
"""A generator method to return reddit content from a URL.
Starts at the initial url, and fetches co... | def get_content(self, url, params=None, limit=0, place_holder=None,
root_field='data', thing_field='children',
after_field='after', object_filter=None, **kwargs):
"""A generator method to return reddit content from a URL.
Starts at the initial url, and fetches co... | [
"A",
"generator",
"method",
"to",
"return",
"reddit",
"content",
"from",
"a",
"URL",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L503-L585 | [
"def",
"get_content",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
",",
"limit",
"=",
"0",
",",
"place_holder",
"=",
"None",
",",
"root_field",
"=",
"'data'",
",",
"thing_field",
"=",
"'children'",
",",
"after_field",
"=",
"'after'",
",",
"object... | ccef2af042566ad384977028cf0bde01bc524dda |
train | BaseReddit.request | Make a HTTP request and return the response.
:param url: the url to grab content from.
:param params: a dictionary containing the GET data to put in the url
:param data: a dictionary containing the extra data to submit
:param retry_on_error: if True retry the request, if it fails, for u... | rtv/packages/praw/__init__.py | def request(self, url, params=None, data=None, retry_on_error=True,
method=None):
"""Make a HTTP request and return the response.
:param url: the url to grab content from.
:param params: a dictionary containing the GET data to put in the url
:param data: a dictionary con... | def request(self, url, params=None, data=None, retry_on_error=True,
method=None):
"""Make a HTTP request and return the response.
:param url: the url to grab content from.
:param params: a dictionary containing the GET data to put in the url
:param data: a dictionary con... | [
"Make",
"a",
"HTTP",
"request",
"and",
"return",
"the",
"response",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L588-L601 | [
"def",
"request",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"retry_on_error",
"=",
"True",
",",
"method",
"=",
"None",
")",
":",
"return",
"self",
".",
"_request",
"(",
"url",
",",
"params",
",",
"data",
",... | ccef2af042566ad384977028cf0bde01bc524dda |
train | BaseReddit.request_json | Get the JSON processed from a page.
:param url: the url to grab content from.
:param params: a dictionary containing the GET data to put in the url
:param data: a dictionary containing the extra data to submit
:param as_objects: if True return reddit objects else raw json dict.
... | rtv/packages/praw/__init__.py | def request_json(self, url, params=None, data=None, as_objects=True,
retry_on_error=True, method=None):
"""Get the JSON processed from a page.
:param url: the url to grab content from.
:param params: a dictionary containing the GET data to put in the url
:param data... | def request_json(self, url, params=None, data=None, as_objects=True,
retry_on_error=True, method=None):
"""Get the JSON processed from a page.
:param url: the url to grab content from.
:param params: a dictionary containing the GET data to put in the url
:param data... | [
"Get",
"the",
"JSON",
"processed",
"from",
"a",
"page",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L604-L636 | [
"def",
"request_json",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"as_objects",
"=",
"True",
",",
"retry_on_error",
"=",
"True",
",",
"method",
"=",
"None",
")",
":",
"if",
"not",
"url",
".",
"endswith",
"(",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | OAuth2Reddit.get_access_information | Return the access information for an OAuth2 authorization grant.
:param code: the code received in the request from the OAuth2 server
:returns: A dictionary with the key/value pairs for ``access_token``,
``refresh_token`` and ``scope``. The ``refresh_token`` value will
be None w... | rtv/packages/praw/__init__.py | def get_access_information(self, code):
"""Return the access information for an OAuth2 authorization grant.
:param code: the code received in the request from the OAuth2 server
:returns: A dictionary with the key/value pairs for ``access_token``,
``refresh_token`` and ``scope``. The... | def get_access_information(self, code):
"""Return the access information for an OAuth2 authorization grant.
:param code: the code received in the request from the OAuth2 server
:returns: A dictionary with the key/value pairs for ``access_token``,
``refresh_token`` and ``scope``. The... | [
"Return",
"the",
"access",
"information",
"for",
"an",
"OAuth2",
"authorization",
"grant",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L670-L690 | [
"def",
"get_access_information",
"(",
"self",
",",
"code",
")",
":",
"if",
"self",
".",
"config",
".",
"grant_type",
"==",
"'password'",
":",
"data",
"=",
"{",
"'grant_type'",
":",
"'password'",
",",
"'username'",
":",
"self",
".",
"config",
".",
"user",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | OAuth2Reddit.get_authorize_url | Return the URL to send the user to for OAuth2 authorization.
:param state: a unique string of your choice that represents this
individual client
:param scope: the reddit scope to ask permissions for. Multiple scopes
can be enabled by passing in a container of strings.
:p... | rtv/packages/praw/__init__.py | def get_authorize_url(self, state, scope='identity', refreshable=False):
"""Return the URL to send the user to for OAuth2 authorization.
:param state: a unique string of your choice that represents this
individual client
:param scope: the reddit scope to ask permissions for. Multipl... | def get_authorize_url(self, state, scope='identity', refreshable=False):
"""Return the URL to send the user to for OAuth2 authorization.
:param state: a unique string of your choice that represents this
individual client
:param scope: the reddit scope to ask permissions for. Multipl... | [
"Return",
"the",
"URL",
"to",
"send",
"the",
"user",
"to",
"for",
"OAuth2",
"authorization",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L693-L709 | [
"def",
"get_authorize_url",
"(",
"self",
",",
"state",
",",
"scope",
"=",
"'identity'",
",",
"refreshable",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'response_type'",
":",
"'code'",
",",
"'redirect_uri'"... | ccef2af042566ad384977028cf0bde01bc524dda |
train | OAuth2Reddit.refresh_access_information | Return updated access information for an OAuth2 authorization grant.
:param refresh_token: the refresh token used to obtain the updated
information
:returns: A dictionary with the key/value pairs for access_token,
refresh_token and scope. The refresh_token value will be done whe... | rtv/packages/praw/__init__.py | def refresh_access_information(self, refresh_token):
"""Return updated access information for an OAuth2 authorization grant.
:param refresh_token: the refresh token used to obtain the updated
information
:returns: A dictionary with the key/value pairs for access_token,
r... | def refresh_access_information(self, refresh_token):
"""Return updated access information for an OAuth2 authorization grant.
:param refresh_token: the refresh token used to obtain the updated
information
:returns: A dictionary with the key/value pairs for access_token,
r... | [
"Return",
"updated",
"access",
"information",
"for",
"an",
"OAuth2",
"authorization",
"grant",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L724-L748 | [
"def",
"refresh_access_information",
"(",
"self",
",",
"refresh_token",
")",
":",
"if",
"self",
".",
"config",
".",
"grant_type",
"==",
"'password'",
":",
"data",
"=",
"{",
"'grant_type'",
":",
"'password'",
",",
"'username'",
":",
"self",
".",
"config",
"."... | ccef2af042566ad384977028cf0bde01bc524dda |
train | OAuth2Reddit.set_oauth_app_info | Set the app information to use with OAuth2.
This function need only be called if your praw.ini site configuration
does not already contain the necessary information.
Go to https://www.reddit.com/prefs/apps/ to discover the appropriate
values for your application.
:param client... | rtv/packages/praw/__init__.py | def set_oauth_app_info(self, client_id, client_secret, redirect_uri):
"""Set the app information to use with OAuth2.
This function need only be called if your praw.ini site configuration
does not already contain the necessary information.
Go to https://www.reddit.com/prefs/apps/ to dis... | def set_oauth_app_info(self, client_id, client_secret, redirect_uri):
"""Set the app information to use with OAuth2.
This function need only be called if your praw.ini site configuration
does not already contain the necessary information.
Go to https://www.reddit.com/prefs/apps/ to dis... | [
"Set",
"the",
"app",
"information",
"to",
"use",
"with",
"OAuth2",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L750-L766 | [
"def",
"set_oauth_app_info",
"(",
"self",
",",
"client_id",
",",
"client_secret",
",",
"redirect_uri",
")",
":",
"self",
".",
"client_id",
"=",
"client_id",
"self",
".",
"client_secret",
"=",
"client_secret",
"self",
".",
"redirect_uri",
"=",
"redirect_uri"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.create_redditor | Register a new user.
:returns: The json response from the server. | rtv/packages/praw/__init__.py | def create_redditor(self, user_name, password, email=''):
"""Register a new user.
:returns: The json response from the server.
"""
data = {'email': email,
'passwd': password,
'passwd2': password,
'user': user_name}
return self.req... | def create_redditor(self, user_name, password, email=''):
"""Register a new user.
:returns: The json response from the server.
"""
data = {'email': email,
'passwd': password,
'passwd2': password,
'user': user_name}
return self.req... | [
"Register",
"a",
"new",
"user",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L786-L796 | [
"def",
"create_redditor",
"(",
"self",
",",
"user_name",
",",
"password",
",",
"email",
"=",
"''",
")",
":",
"data",
"=",
"{",
"'email'",
":",
"email",
",",
"'passwd'",
":",
"password",
",",
"'passwd2'",
":",
"password",
",",
"'user'",
":",
"user_name",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.default_subreddits | Return a get_content generator for the default subreddits.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered. | rtv/packages/praw/__init__.py | def default_subreddits(self, *args, **kwargs):
"""Return a get_content generator for the default subreddits.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered.
"""
url = self.config['default_subreddits']
... | def default_subreddits(self, *args, **kwargs):
"""Return a get_content generator for the default subreddits.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered.
"""
url = self.config['default_subreddits']
... | [
"Return",
"a",
"get_content",
"generator",
"for",
"the",
"default",
"subreddits",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L798-L806 | [
"def",
"default_subreddits",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"config",
"[",
"'default_subreddits'",
"]",
"return",
"self",
".",
"get_content",
"(",
"url",
",",
"*",
"args",
",",
"*",
"*",
"kw... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_comments | Return a get_content generator for comments in the given subreddit.
:param gilded_only: If True only return gilded comments.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered. | rtv/packages/praw/__init__.py | def get_comments(self, subreddit, gilded_only=False, *args, **kwargs):
"""Return a get_content generator for comments in the given subreddit.
:param gilded_only: If True only return gilded comments.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url... | def get_comments(self, subreddit, gilded_only=False, *args, **kwargs):
"""Return a get_content generator for comments in the given subreddit.
:param gilded_only: If True only return gilded comments.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url... | [
"Return",
"a",
"get_content",
"generator",
"for",
"comments",
"in",
"the",
"given",
"subreddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L809-L820 | [
"def",
"get_comments",
"(",
"self",
",",
"subreddit",
",",
"gilded_only",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"key",
"=",
"'sub_comments_gilded'",
"if",
"gilded_only",
"else",
"'subreddit_comments'",
"url",
"=",
"self",
".",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_controversial | Return a get_content generator for controversial submissions.
Corresponds to submissions provided by
``https://www.reddit.com/controversial/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered. | rtv/packages/praw/__init__.py | def get_controversial(self, *args, **kwargs):
"""Return a get_content generator for controversial submissions.
Corresponds to submissions provided by
``https://www.reddit.com/controversial/`` for the session.
The additional parameters are passed directly into
:meth:`.get_conten... | def get_controversial(self, *args, **kwargs):
"""Return a get_content generator for controversial submissions.
Corresponds to submissions provided by
``https://www.reddit.com/controversial/`` for the session.
The additional parameters are passed directly into
:meth:`.get_conten... | [
"Return",
"a",
"get_content",
"generator",
"for",
"controversial",
"submissions",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L823-L833 | [
"def",
"get_controversial",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"get_content",
"(",
"self",
".",
"config",
"[",
"'controversial'",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_domain_listing | Return a get_content generator for submissions by domain.
Corresponds to the submissions provided by
``https://www.reddit.com/domain/{domain}``.
:param domain: The domain to generate a submission listing for.
:param sort: When provided must be one of 'hot', 'new', 'rising',
... | rtv/packages/praw/__init__.py | def get_domain_listing(self, domain, sort='hot', period=None, *args,
**kwargs):
"""Return a get_content generator for submissions by domain.
Corresponds to the submissions provided by
``https://www.reddit.com/domain/{domain}``.
:param domain: The domain to ge... | def get_domain_listing(self, domain, sort='hot', period=None, *args,
**kwargs):
"""Return a get_content generator for submissions by domain.
Corresponds to the submissions provided by
``https://www.reddit.com/domain/{domain}``.
:param domain: The domain to ge... | [
"Return",
"a",
"get_content",
"generator",
"for",
"submissions",
"by",
"domain",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L836-L868 | [
"def",
"get_domain_listing",
"(",
"self",
",",
"domain",
",",
"sort",
"=",
"'hot'",
",",
"period",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Verify arguments",
"if",
"sort",
"not",
"in",
"(",
"'controversial'",
",",
"'hot'",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_flair | Return the flair for a user on the given subreddit.
:param subreddit: Can be either a Subreddit object or the name of a
subreddit.
:param redditor: Can be either a Redditor object or the name of a
redditor.
:returns: None if the user doesn't exist, otherwise a dictionary... | rtv/packages/praw/__init__.py | def get_flair(self, subreddit, redditor, **params):
"""Return the flair for a user on the given subreddit.
:param subreddit: Can be either a Subreddit object or the name of a
subreddit.
:param redditor: Can be either a Redditor object or the name of a
redditor.
:... | def get_flair(self, subreddit, redditor, **params):
"""Return the flair for a user on the given subreddit.
:param subreddit: Can be either a Subreddit object or the name of a
subreddit.
:param redditor: Can be either a Redditor object or the name of a
redditor.
:... | [
"Return",
"the",
"flair",
"for",
"a",
"user",
"on",
"the",
"given",
"subreddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L871-L890 | [
"def",
"get_flair",
"(",
"self",
",",
"subreddit",
",",
"redditor",
",",
"*",
"*",
"params",
")",
":",
"name",
"=",
"six",
".",
"text_type",
"(",
"redditor",
")",
"params",
".",
"update",
"(",
"name",
"=",
"name",
")",
"url",
"=",
"self",
".",
"con... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_front_page | Return a get_content generator for the front page submissions.
Corresponds to the submissions provided by ``https://www.reddit.com/``
for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered. | rtv/packages/praw/__init__.py | def get_front_page(self, *args, **kwargs):
"""Return a get_content generator for the front page submissions.
Corresponds to the submissions provided by ``https://www.reddit.com/``
for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: th... | def get_front_page(self, *args, **kwargs):
"""Return a get_content generator for the front page submissions.
Corresponds to the submissions provided by ``https://www.reddit.com/``
for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: th... | [
"Return",
"a",
"get_content",
"generator",
"for",
"the",
"front",
"page",
"submissions",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L893-L903 | [
"def",
"get_front_page",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"get_content",
"(",
"self",
".",
"config",
"[",
"'reddit_url'",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_info | Look up existing items by thing_id (fullname) or url.
:param url: A url to lookup.
:param thing_id: A single thing_id, or a list of thing_ids. A thing_id
can be any one of Comment (``t1_``), Link (``t3_``), or Subreddit
(``t5_``) to lookup by fullname.
:returns: When a s... | rtv/packages/praw/__init__.py | def get_info(self, url=None, thing_id=None, *args, **kwargs):
"""Look up existing items by thing_id (fullname) or url.
:param url: A url to lookup.
:param thing_id: A single thing_id, or a list of thing_ids. A thing_id
can be any one of Comment (``t1_``), Link (``t3_``), or Subreddi... | def get_info(self, url=None, thing_id=None, *args, **kwargs):
"""Look up existing items by thing_id (fullname) or url.
:param url: A url to lookup.
:param thing_id: A single thing_id, or a list of thing_ids. A thing_id
can be any one of Comment (``t1_``), Link (``t3_``), or Subreddi... | [
"Look",
"up",
"existing",
"items",
"by",
"thing_id",
"(",
"fullname",
")",
"or",
"url",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L906-L966 | [
"def",
"get_info",
"(",
"self",
",",
"url",
"=",
"None",
",",
"thing_id",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"bool",
"(",
"url",
")",
"==",
"bool",
"(",
"thing_id",
")",
":",
"raise",
"TypeError",
"(",
"'Only ... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_moderators | Return the list of moderators for the given subreddit. | rtv/packages/praw/__init__.py | def get_moderators(self, subreddit, **kwargs):
"""Return the list of moderators for the given subreddit."""
url = self.config['moderators'].format(
subreddit=six.text_type(subreddit))
return self.request_json(url, **kwargs) | def get_moderators(self, subreddit, **kwargs):
"""Return the list of moderators for the given subreddit."""
url = self.config['moderators'].format(
subreddit=six.text_type(subreddit))
return self.request_json(url, **kwargs) | [
"Return",
"the",
"list",
"of",
"moderators",
"for",
"the",
"given",
"subreddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L969-L973 | [
"def",
"get_moderators",
"(",
"self",
",",
"subreddit",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"config",
"[",
"'moderators'",
"]",
".",
"format",
"(",
"subreddit",
"=",
"six",
".",
"text_type",
"(",
"subreddit",
")",
")",
"return",... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_new | Return a get_content generator for new submissions.
Corresponds to the submissions provided by
``https://www.reddit.com/new/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered. | rtv/packages/praw/__init__.py | def get_new(self, *args, **kwargs):
"""Return a get_content generator for new submissions.
Corresponds to the submissions provided by
``https://www.reddit.com/new/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parame... | def get_new(self, *args, **kwargs):
"""Return a get_content generator for new submissions.
Corresponds to the submissions provided by
``https://www.reddit.com/new/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parame... | [
"Return",
"a",
"get_content",
"generator",
"for",
"new",
"submissions",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L976-L986 | [
"def",
"get_new",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"get_content",
"(",
"self",
".",
"config",
"[",
"'new'",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_new_subreddits | Return a get_content generator for the newest subreddits.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered. | rtv/packages/praw/__init__.py | def get_new_subreddits(self, *args, **kwargs):
"""Return a get_content generator for the newest subreddits.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered.
"""
url = self.config['new_subreddits']
retu... | def get_new_subreddits(self, *args, **kwargs):
"""Return a get_content generator for the newest subreddits.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered.
"""
url = self.config['new_subreddits']
retu... | [
"Return",
"a",
"get_content",
"generator",
"for",
"the",
"newest",
"subreddits",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L988-L996 | [
"def",
"get_new_subreddits",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"config",
"[",
"'new_subreddits'",
"]",
"return",
"self",
".",
"get_content",
"(",
"url",
",",
"*",
"args",
",",
"*",
"*",
"kwargs... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_popular_subreddits | Return a get_content generator for the most active subreddits.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered. | rtv/packages/praw/__init__.py | def get_popular_subreddits(self, *args, **kwargs):
"""Return a get_content generator for the most active subreddits.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered.
"""
url = self.config['popular_subreddits']... | def get_popular_subreddits(self, *args, **kwargs):
"""Return a get_content generator for the most active subreddits.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered.
"""
url = self.config['popular_subreddits']... | [
"Return",
"a",
"get_content",
"generator",
"for",
"the",
"most",
"active",
"subreddits",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L998-L1006 | [
"def",
"get_popular_subreddits",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"config",
"[",
"'popular_subreddits'",
"]",
"return",
"self",
".",
"get_content",
"(",
"url",
",",
"*",
"args",
",",
"*",
"*",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_random_subreddit | Return a random Subreddit object.
:param nsfw: When true, return a random NSFW Subreddit object. Calling
in this manner will set the 'over18' cookie for the duration of the
PRAW session. | rtv/packages/praw/__init__.py | def get_random_subreddit(self, nsfw=False):
"""Return a random Subreddit object.
:param nsfw: When true, return a random NSFW Subreddit object. Calling
in this manner will set the 'over18' cookie for the duration of the
PRAW session.
"""
path = 'random'
... | def get_random_subreddit(self, nsfw=False):
"""Return a random Subreddit object.
:param nsfw: When true, return a random NSFW Subreddit object. Calling
in this manner will set the 'over18' cookie for the duration of the
PRAW session.
"""
path = 'random'
... | [
"Return",
"a",
"random",
"Subreddit",
"object",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1008-L1024 | [
"def",
"get_random_subreddit",
"(",
"self",
",",
"nsfw",
"=",
"False",
")",
":",
"path",
"=",
"'random'",
"if",
"nsfw",
":",
"self",
".",
"http",
".",
"cookies",
".",
"set",
"(",
"'over18'",
",",
"'1'",
")",
"path",
"=",
"'randnsfw'",
"url",
"=",
"se... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_random_submission | Return a random Submission object.
:param subreddit: Limit the submission to the specified
subreddit(s). Default: all | rtv/packages/praw/__init__.py | def get_random_submission(self, subreddit='all'):
"""Return a random Submission object.
:param subreddit: Limit the submission to the specified
subreddit(s). Default: all
"""
url = self.config['subreddit_random'].format(
subreddit=six.text_type(subreddit))
... | def get_random_submission(self, subreddit='all'):
"""Return a random Submission object.
:param subreddit: Limit the submission to the specified
subreddit(s). Default: all
"""
url = self.config['subreddit_random'].format(
subreddit=six.text_type(subreddit))
... | [
"Return",
"a",
"random",
"Submission",
"object",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1026-L1043 | [
"def",
"get_random_submission",
"(",
"self",
",",
"subreddit",
"=",
"'all'",
")",
":",
"url",
"=",
"self",
".",
"config",
"[",
"'subreddit_random'",
"]",
".",
"format",
"(",
"subreddit",
"=",
"six",
".",
"text_type",
"(",
"subreddit",
")",
")",
"try",
":... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_redditor | Return a Redditor instance for the user_name specified.
The additional parameters are passed directly into the
:class:`.Redditor` constructor. | rtv/packages/praw/__init__.py | def get_redditor(self, user_name, *args, **kwargs):
"""Return a Redditor instance for the user_name specified.
The additional parameters are passed directly into the
:class:`.Redditor` constructor.
"""
return objects.Redditor(self, user_name, *args, **kwargs) | def get_redditor(self, user_name, *args, **kwargs):
"""Return a Redditor instance for the user_name specified.
The additional parameters are passed directly into the
:class:`.Redditor` constructor.
"""
return objects.Redditor(self, user_name, *args, **kwargs) | [
"Return",
"a",
"Redditor",
"instance",
"for",
"the",
"user_name",
"specified",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1045-L1052 | [
"def",
"get_redditor",
"(",
"self",
",",
"user_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"objects",
".",
"Redditor",
"(",
"self",
",",
"user_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_rising | Return a get_content generator for rising submissions.
Corresponds to the submissions provided by
``https://www.reddit.com/rising/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered. | rtv/packages/praw/__init__.py | def get_rising(self, *args, **kwargs):
"""Return a get_content generator for rising submissions.
Corresponds to the submissions provided by
``https://www.reddit.com/rising/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `ur... | def get_rising(self, *args, **kwargs):
"""Return a get_content generator for rising submissions.
Corresponds to the submissions provided by
``https://www.reddit.com/rising/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `ur... | [
"Return",
"a",
"get_content",
"generator",
"for",
"rising",
"submissions",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1055-L1065 | [
"def",
"get_rising",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"get_content",
"(",
"self",
".",
"config",
"[",
"'rising'",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_rules | Return the json dictionary containing rules for a subreddit.
:param subreddit: The subreddit whose rules we will return. | rtv/packages/praw/__init__.py | def get_rules(self, subreddit, bottom=False):
"""Return the json dictionary containing rules for a subreddit.
:param subreddit: The subreddit whose rules we will return.
"""
url = self.config['rules'].format(subreddit=six.text_type(subreddit))
return self.request_json(url) | def get_rules(self, subreddit, bottom=False):
"""Return the json dictionary containing rules for a subreddit.
:param subreddit: The subreddit whose rules we will return.
"""
url = self.config['rules'].format(subreddit=six.text_type(subreddit))
return self.request_json(url) | [
"Return",
"the",
"json",
"dictionary",
"containing",
"rules",
"for",
"a",
"subreddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1068-L1075 | [
"def",
"get_rules",
"(",
"self",
",",
"subreddit",
",",
"bottom",
"=",
"False",
")",
":",
"url",
"=",
"self",
".",
"config",
"[",
"'rules'",
"]",
".",
"format",
"(",
"subreddit",
"=",
"six",
".",
"text_type",
"(",
"subreddit",
")",
")",
"return",
"se... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_sticky | Return a Submission object for the sticky of the subreddit.
:param bottom: Get the top or bottom sticky. If the subreddit has only
a single sticky, it is considered the top one. | rtv/packages/praw/__init__.py | def get_sticky(self, subreddit, bottom=False):
"""Return a Submission object for the sticky of the subreddit.
:param bottom: Get the top or bottom sticky. If the subreddit has only
a single sticky, it is considered the top one.
"""
url = self.config['sticky'].format(subredd... | def get_sticky(self, subreddit, bottom=False):
"""Return a Submission object for the sticky of the subreddit.
:param bottom: Get the top or bottom sticky. If the subreddit has only
a single sticky, it is considered the top one.
"""
url = self.config['sticky'].format(subredd... | [
"Return",
"a",
"Submission",
"object",
"for",
"the",
"sticky",
"of",
"the",
"subreddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1078-L1088 | [
"def",
"get_sticky",
"(",
"self",
",",
"subreddit",
",",
"bottom",
"=",
"False",
")",
":",
"url",
"=",
"self",
".",
"config",
"[",
"'sticky'",
"]",
".",
"format",
"(",
"subreddit",
"=",
"six",
".",
"text_type",
"(",
"subreddit",
")",
")",
"param",
"=... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_submission | Return a Submission object for the given url or submission_id.
:param comment_limit: The desired number of comments to fetch. If <= 0
fetch the default number for the session's user. If None, fetch the
maximum possible.
:param comment_sort: The sort order for retrieved comments.... | rtv/packages/praw/__init__.py | def get_submission(self, url=None, submission_id=None, comment_limit=0,
comment_sort=None, params=None):
"""Return a Submission object for the given url or submission_id.
:param comment_limit: The desired number of comments to fetch. If <= 0
fetch the default number f... | def get_submission(self, url=None, submission_id=None, comment_limit=0,
comment_sort=None, params=None):
"""Return a Submission object for the given url or submission_id.
:param comment_limit: The desired number of comments to fetch. If <= 0
fetch the default number f... | [
"Return",
"a",
"Submission",
"object",
"for",
"the",
"given",
"url",
"or",
"submission_id",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1090-L1109 | [
"def",
"get_submission",
"(",
"self",
",",
"url",
"=",
"None",
",",
"submission_id",
"=",
"None",
",",
"comment_limit",
"=",
"0",
",",
"comment_sort",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"bool",
"(",
"url",
")",
"==",
"bool",
"("... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_submissions | Generate Submission objects for each item provided in `fullnames`.
A submission fullname looks like `t3_<base36_id>`. Submissions are
yielded in the same order they appear in `fullnames`.
Up to 100 items are batched at a time -- this happens transparently.
The additional parameters ar... | rtv/packages/praw/__init__.py | def get_submissions(self, fullnames, *args, **kwargs):
"""Generate Submission objects for each item provided in `fullnames`.
A submission fullname looks like `t3_<base36_id>`. Submissions are
yielded in the same order they appear in `fullnames`.
Up to 100 items are batched at a time --... | def get_submissions(self, fullnames, *args, **kwargs):
"""Generate Submission objects for each item provided in `fullnames`.
A submission fullname looks like `t3_<base36_id>`. Submissions are
yielded in the same order they appear in `fullnames`.
Up to 100 items are batched at a time --... | [
"Generate",
"Submission",
"objects",
"for",
"each",
"item",
"provided",
"in",
"fullnames",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1111-L1130 | [
"def",
"get_submissions",
"(",
"self",
",",
"fullnames",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"fullnames",
"=",
"fullnames",
"[",
":",
"]",
"while",
"fullnames",
":",
"cur",
"=",
"fullnames",
"[",
":",
"100",
"]",
"fullnames",
"[",
":... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_subreddit | Return a Subreddit object for the subreddit_name specified.
The additional parameters are passed directly into the
:class:`.Subreddit` constructor. | rtv/packages/praw/__init__.py | def get_subreddit(self, subreddit_name, *args, **kwargs):
"""Return a Subreddit object for the subreddit_name specified.
The additional parameters are passed directly into the
:class:`.Subreddit` constructor.
"""
sr_name_lower = subreddit_name.lower()
if sr_name_lower =... | def get_subreddit(self, subreddit_name, *args, **kwargs):
"""Return a Subreddit object for the subreddit_name specified.
The additional parameters are passed directly into the
:class:`.Subreddit` constructor.
"""
sr_name_lower = subreddit_name.lower()
if sr_name_lower =... | [
"Return",
"a",
"Subreddit",
"object",
"for",
"the",
"subreddit_name",
"specified",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1132-L1144 | [
"def",
"get_subreddit",
"(",
"self",
",",
"subreddit_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"sr_name_lower",
"=",
"subreddit_name",
".",
"lower",
"(",
")",
"if",
"sr_name_lower",
"==",
"'random'",
":",
"return",
"self",
".",
"get_rando... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_subreddit_recommendations | Return a list of recommended subreddits as Subreddit objects.
Subreddits with activity less than a certain threshold, will not have
any recommendations due to lack of data.
:param subreddits: A list of subreddits (either names or Subreddit
objects) to base the recommendations on.
... | rtv/packages/praw/__init__.py | def get_subreddit_recommendations(self, subreddits, omit=None):
"""Return a list of recommended subreddits as Subreddit objects.
Subreddits with activity less than a certain threshold, will not have
any recommendations due to lack of data.
:param subreddits: A list of subreddits (eithe... | def get_subreddit_recommendations(self, subreddits, omit=None):
"""Return a list of recommended subreddits as Subreddit objects.
Subreddits with activity less than a certain threshold, will not have
any recommendations due to lack of data.
:param subreddits: A list of subreddits (eithe... | [
"Return",
"a",
"list",
"of",
"recommended",
"subreddits",
"as",
"Subreddit",
"objects",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1146-L1162 | [
"def",
"get_subreddit_recommendations",
"(",
"self",
",",
"subreddits",
",",
"omit",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'omit'",
":",
"_to_reddit_list",
"(",
"omit",
"or",
"[",
"]",
")",
"}",
"url",
"=",
"self",
".",
"config",
"[",
"'sub_recomme... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_top | Return a get_content generator for top submissions.
Corresponds to the submissions provided by
``https://www.reddit.com/top/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered. | rtv/packages/praw/__init__.py | def get_top(self, *args, **kwargs):
"""Return a get_content generator for top submissions.
Corresponds to the submissions provided by
``https://www.reddit.com/top/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parame... | def get_top(self, *args, **kwargs):
"""Return a get_content generator for top submissions.
Corresponds to the submissions provided by
``https://www.reddit.com/top/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parame... | [
"Return",
"a",
"get_content",
"generator",
"for",
"top",
"submissions",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1165-L1175 | [
"def",
"get_top",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"get_content",
"(",
"self",
".",
"config",
"[",
"'top'",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_gilded | Return a get_content generator for gilded submissions.
Corresponds to the submissions provided by
``https://www.reddit.com/gilded/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `url` parameter cannot be altered. | rtv/packages/praw/__init__.py | def get_gilded(self, *args, **kwargs):
"""Return a get_content generator for gilded submissions.
Corresponds to the submissions provided by
``https://www.reddit.com/gilded/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `ur... | def get_gilded(self, *args, **kwargs):
"""Return a get_content generator for gilded submissions.
Corresponds to the submissions provided by
``https://www.reddit.com/gilded/`` for the session.
The additional parameters are passed directly into
:meth:`.get_content`. Note: the `ur... | [
"Return",
"a",
"get_content",
"generator",
"for",
"gilded",
"submissions",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1178-L1188 | [
"def",
"get_gilded",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"get_content",
"(",
"self",
".",
"config",
"[",
"'gilded'",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_traffic | Return the json dictionary containing traffic stats for a subreddit.
:param subreddit: The subreddit whose /about/traffic page we will
collect. | rtv/packages/praw/__init__.py | def get_traffic(self, subreddit):
"""Return the json dictionary containing traffic stats for a subreddit.
:param subreddit: The subreddit whose /about/traffic page we will
collect.
"""
url = self.config['subreddit_traffic'].format(
subreddit=six.text_type(subred... | def get_traffic(self, subreddit):
"""Return the json dictionary containing traffic stats for a subreddit.
:param subreddit: The subreddit whose /about/traffic page we will
collect.
"""
url = self.config['subreddit_traffic'].format(
subreddit=six.text_type(subred... | [
"Return",
"the",
"json",
"dictionary",
"containing",
"traffic",
"stats",
"for",
"a",
"subreddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1192-L1201 | [
"def",
"get_traffic",
"(",
"self",
",",
"subreddit",
")",
":",
"url",
"=",
"self",
".",
"config",
"[",
"'subreddit_traffic'",
"]",
".",
"format",
"(",
"subreddit",
"=",
"six",
".",
"text_type",
"(",
"subreddit",
")",
")",
"return",
"self",
".",
"request_... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.get_wiki_page | Return a WikiPage object for the subreddit and page provided. | rtv/packages/praw/__init__.py | def get_wiki_page(self, subreddit, page):
"""Return a WikiPage object for the subreddit and page provided."""
return objects.WikiPage(self, six.text_type(subreddit), page.lower()) | def get_wiki_page(self, subreddit, page):
"""Return a WikiPage object for the subreddit and page provided."""
return objects.WikiPage(self, six.text_type(subreddit), page.lower()) | [
"Return",
"a",
"WikiPage",
"object",
"for",
"the",
"subreddit",
"and",
"page",
"provided",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1204-L1206 | [
"def",
"get_wiki_page",
"(",
"self",
",",
"subreddit",
",",
"page",
")",
":",
"return",
"objects",
".",
"WikiPage",
"(",
"self",
",",
"six",
".",
"text_type",
"(",
"subreddit",
")",
",",
"page",
".",
"lower",
"(",
")",
")"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.is_username_available | Return True if username is valid and available, otherwise False. | rtv/packages/praw/__init__.py | def is_username_available(self, username):
"""Return True if username is valid and available, otherwise False."""
params = {'user': username}
try:
result = self.request_json(self.config['username_available'],
params=params)
except errors... | def is_username_available(self, username):
"""Return True if username is valid and available, otherwise False."""
params = {'user': username}
try:
result = self.request_json(self.config['username_available'],
params=params)
except errors... | [
"Return",
"True",
"if",
"username",
"is",
"valid",
"and",
"available",
"otherwise",
"False",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1215-L1223 | [
"def",
"is_username_available",
"(",
"self",
",",
"username",
")",
":",
"params",
"=",
"{",
"'user'",
":",
"username",
"}",
"try",
":",
"result",
"=",
"self",
".",
"request_json",
"(",
"self",
".",
"config",
"[",
"'username_available'",
"]",
",",
"params",... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.search | Return a generator for submissions that match the search query.
:param query: The query string to search for. If query is a URL only
submissions which link to that URL will be returned.
:param subreddit: Limit search results to the subreddit if provided.
:param sort: The sort order ... | rtv/packages/praw/__init__.py | def search(self, query, subreddit=None, sort=None, syntax=None,
period=None, *args, **kwargs):
"""Return a generator for submissions that match the search query.
:param query: The query string to search for. If query is a URL only
submissions which link to that URL will be re... | def search(self, query, subreddit=None, sort=None, syntax=None,
period=None, *args, **kwargs):
"""Return a generator for submissions that match the search query.
:param query: The query string to search for. If query is a URL only
submissions which link to that URL will be re... | [
"Return",
"a",
"generator",
"for",
"submissions",
"that",
"match",
"the",
"search",
"query",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1225-L1276 | [
"def",
"search",
"(",
"self",
",",
"query",
",",
"subreddit",
"=",
"None",
",",
"sort",
"=",
"None",
",",
"syntax",
"=",
"None",
",",
"period",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"'q'",
":",
"q... | ccef2af042566ad384977028cf0bde01bc524dda |
train | UnauthenticatedReddit.search_reddit_names | Return subreddits whose display name contains the query. | rtv/packages/praw/__init__.py | def search_reddit_names(self, query):
"""Return subreddits whose display name contains the query."""
data = {'query': query}
results = self.request_json(self.config['search_reddit_names'],
data=data)
return [self.get_subreddit(name) for name in results... | def search_reddit_names(self, query):
"""Return subreddits whose display name contains the query."""
data = {'query': query}
results = self.request_json(self.config['search_reddit_names'],
data=data)
return [self.get_subreddit(name) for name in results... | [
"Return",
"subreddits",
"whose",
"display",
"name",
"contains",
"the",
"query",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1278-L1283 | [
"def",
"search_reddit_names",
"(",
"self",
",",
"query",
")",
":",
"data",
"=",
"{",
"'query'",
":",
"query",
"}",
"results",
"=",
"self",
".",
"request_json",
"(",
"self",
".",
"config",
"[",
"'search_reddit_names'",
"]",
",",
"data",
"=",
"data",
")",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | AuthenticatedReddit.accept_moderator_invite | Accept a moderator invite to the given subreddit.
Callable upon an instance of Subreddit with no arguments.
:returns: The json response from the server. | rtv/packages/praw/__init__.py | def accept_moderator_invite(self, subreddit):
"""Accept a moderator invite to the given subreddit.
Callable upon an instance of Subreddit with no arguments.
:returns: The json response from the server.
"""
data = {'r': six.text_type(subreddit)}
# Clear moderated subred... | def accept_moderator_invite(self, subreddit):
"""Accept a moderator invite to the given subreddit.
Callable upon an instance of Subreddit with no arguments.
:returns: The json response from the server.
"""
data = {'r': six.text_type(subreddit)}
# Clear moderated subred... | [
"Accept",
"a",
"moderator",
"invite",
"to",
"the",
"given",
"subreddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1331-L1343 | [
"def",
"accept_moderator_invite",
"(",
"self",
",",
"subreddit",
")",
":",
"data",
"=",
"{",
"'r'",
":",
"six",
".",
"text_type",
"(",
"subreddit",
")",
"}",
"# Clear moderated subreddits and cache",
"self",
".",
"user",
".",
"_mod_subs",
"=",
"None",
"# pylin... | ccef2af042566ad384977028cf0bde01bc524dda |
train | AuthenticatedReddit.clear_authentication | Clear any existing authentication on the reddit object.
This function is implicitly called on `login` and
`set_access_credentials`. | rtv/packages/praw/__init__.py | def clear_authentication(self):
"""Clear any existing authentication on the reddit object.
This function is implicitly called on `login` and
`set_access_credentials`.
"""
self._authentication = None
self.access_token = None
self.refresh_token = None
self... | def clear_authentication(self):
"""Clear any existing authentication on the reddit object.
This function is implicitly called on `login` and
`set_access_credentials`.
"""
self._authentication = None
self.access_token = None
self.refresh_token = None
self... | [
"Clear",
"any",
"existing",
"authentication",
"on",
"the",
"reddit",
"object",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1345-L1356 | [
"def",
"clear_authentication",
"(",
"self",
")",
":",
"self",
".",
"_authentication",
"=",
"None",
"self",
".",
"access_token",
"=",
"None",
"self",
".",
"refresh_token",
"=",
"None",
"self",
".",
"http",
".",
"cookies",
".",
"clear",
"(",
")",
"self",
"... | ccef2af042566ad384977028cf0bde01bc524dda |
train | AuthenticatedReddit.delete | Delete the currently authenticated redditor.
WARNING!
This action is IRREVERSIBLE. Use only if you're okay with NEVER
accessing this reddit account again.
:param password: password for currently authenticated account
:param message: optional 'reason for deletion' message.
... | rtv/packages/praw/__init__.py | def delete(self, password, message=""):
"""Delete the currently authenticated redditor.
WARNING!
This action is IRREVERSIBLE. Use only if you're okay with NEVER
accessing this reddit account again.
:param password: password for currently authenticated account
:param me... | def delete(self, password, message=""):
"""Delete the currently authenticated redditor.
WARNING!
This action is IRREVERSIBLE. Use only if you're okay with NEVER
accessing this reddit account again.
:param password: password for currently authenticated account
:param me... | [
"Delete",
"the",
"currently",
"authenticated",
"redditor",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1358-L1375 | [
"def",
"delete",
"(",
"self",
",",
"password",
",",
"message",
"=",
"\"\"",
")",
":",
"data",
"=",
"{",
"'user'",
":",
"self",
".",
"user",
".",
"name",
",",
"'passwd'",
":",
"password",
",",
"'delete_message'",
":",
"message",
",",
"'confirm'",
":",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | AuthenticatedReddit.edit_wiki_page | Create or edit a wiki page with title `page` for `subreddit`.
:returns: The json response from the server. | rtv/packages/praw/__init__.py | def edit_wiki_page(self, subreddit, page, content, reason=''):
"""Create or edit a wiki page with title `page` for `subreddit`.
:returns: The json response from the server.
"""
data = {'content': content,
'page': page,
'r': six.text_type(subreddit),
... | def edit_wiki_page(self, subreddit, page, content, reason=''):
"""Create or edit a wiki page with title `page` for `subreddit`.
:returns: The json response from the server.
"""
data = {'content': content,
'page': page,
'r': six.text_type(subreddit),
... | [
"Create",
"or",
"edit",
"a",
"wiki",
"page",
"with",
"title",
"page",
"for",
"subreddit",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1378-L1391 | [
"def",
"edit_wiki_page",
"(",
"self",
",",
"subreddit",
",",
"page",
",",
"content",
",",
"reason",
"=",
"''",
")",
":",
"data",
"=",
"{",
"'content'",
":",
"content",
",",
"'page'",
":",
"page",
",",
"'r'",
":",
"six",
".",
"text_type",
"(",
"subred... | ccef2af042566ad384977028cf0bde01bc524dda |
train | AuthenticatedReddit.get_access_information | Return the access information for an OAuth2 authorization grant.
:param code: the code received in the request from the OAuth2 server
:param update_session: Update the current session with the retrieved
token(s).
:returns: A dictionary with the key/value pairs for access_token,
... | rtv/packages/praw/__init__.py | def get_access_information(self, code, # pylint: disable=W0221
update_session=True):
"""Return the access information for an OAuth2 authorization grant.
:param code: the code received in the request from the OAuth2 server
:param update_session: Update the current... | def get_access_information(self, code, # pylint: disable=W0221
update_session=True):
"""Return the access information for an OAuth2 authorization grant.
:param code: the code received in the request from the OAuth2 server
:param update_session: Update the current... | [
"Return",
"the",
"access",
"information",
"for",
"an",
"OAuth2",
"authorization",
"grant",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1393-L1408 | [
"def",
"get_access_information",
"(",
"self",
",",
"code",
",",
"# pylint: disable=W0221",
"update_session",
"=",
"True",
")",
":",
"retval",
"=",
"super",
"(",
"AuthenticatedReddit",
",",
"self",
")",
".",
"get_access_information",
"(",
"code",
")",
"if",
"upda... | ccef2af042566ad384977028cf0bde01bc524dda |
train | AuthenticatedReddit.get_flair_choices | Return available flair choices and current flair.
:param link: If link is given, return the flair options for this
submission. Not normally given directly, but instead set by calling
the flair_choices method for Submission objects.
Use the default for the session's user.
... | rtv/packages/praw/__init__.py | def get_flair_choices(self, subreddit, link=None):
"""Return available flair choices and current flair.
:param link: If link is given, return the flair options for this
submission. Not normally given directly, but instead set by calling
the flair_choices method for Submission ob... | def get_flair_choices(self, subreddit, link=None):
"""Return available flair choices and current flair.
:param link: If link is given, return the flair options for this
submission. Not normally given directly, but instead set by calling
the flair_choices method for Submission ob... | [
"Return",
"available",
"flair",
"choices",
"and",
"current",
"flair",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1411-L1425 | [
"def",
"get_flair_choices",
"(",
"self",
",",
"subreddit",
",",
"link",
"=",
"None",
")",
":",
"data",
"=",
"{",
"'r'",
":",
"six",
".",
"text_type",
"(",
"subreddit",
")",
",",
"'link'",
":",
"link",
"}",
"return",
"self",
".",
"request_json",
"(",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | AuthenticatedReddit.get_friends | Return a UserList of Redditors with whom the user is friends. | rtv/packages/praw/__init__.py | def get_friends(self, **params):
"""Return a UserList of Redditors with whom the user is friends."""
url = self.config['friends']
return self.request_json(url, params=params)[0] | def get_friends(self, **params):
"""Return a UserList of Redditors with whom the user is friends."""
url = self.config['friends']
return self.request_json(url, params=params)[0] | [
"Return",
"a",
"UserList",
"of",
"Redditors",
"with",
"whom",
"the",
"user",
"is",
"friends",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1428-L1431 | [
"def",
"get_friends",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"url",
"=",
"self",
".",
"config",
"[",
"'friends'",
"]",
"return",
"self",
".",
"request_json",
"(",
"url",
",",
"params",
"=",
"params",
")",
"[",
"0",
"]"
] | ccef2af042566ad384977028cf0bde01bc524dda |
train | AuthenticatedReddit.get_me | Return a LoggedInRedditor object.
Note: This function is only intended to be used with an 'identity'
providing OAuth2 grant. | rtv/packages/praw/__init__.py | def get_me(self):
"""Return a LoggedInRedditor object.
Note: This function is only intended to be used with an 'identity'
providing OAuth2 grant.
"""
response = self.request_json(self.config['me'])
user = objects.Redditor(self, response['name'], response)
user.__... | def get_me(self):
"""Return a LoggedInRedditor object.
Note: This function is only intended to be used with an 'identity'
providing OAuth2 grant.
"""
response = self.request_json(self.config['me'])
user = objects.Redditor(self, response['name'], response)
user.__... | [
"Return",
"a",
"LoggedInRedditor",
"object",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1434-L1443 | [
"def",
"get_me",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"request_json",
"(",
"self",
".",
"config",
"[",
"'me'",
"]",
")",
"user",
"=",
"objects",
".",
"Redditor",
"(",
"self",
",",
"response",
"[",
"'name'",
"]",
",",
"response",
")",
... | ccef2af042566ad384977028cf0bde01bc524dda |
train | AuthenticatedReddit.has_scope | Return True if OAuth2 authorized for the passed in scope(s). | rtv/packages/praw/__init__.py | def has_scope(self, scope):
"""Return True if OAuth2 authorized for the passed in scope(s)."""
if not self.is_oauth_session():
return False
if '*' in self._authentication:
return True
if isinstance(scope, six.string_types):
scope = [scope]
retu... | def has_scope(self, scope):
"""Return True if OAuth2 authorized for the passed in scope(s)."""
if not self.is_oauth_session():
return False
if '*' in self._authentication:
return True
if isinstance(scope, six.string_types):
scope = [scope]
retu... | [
"Return",
"True",
"if",
"OAuth2",
"authorized",
"for",
"the",
"passed",
"in",
"scope",
"(",
"s",
")",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1445-L1453 | [
"def",
"has_scope",
"(",
"self",
",",
"scope",
")",
":",
"if",
"not",
"self",
".",
"is_oauth_session",
"(",
")",
":",
"return",
"False",
"if",
"'*'",
"in",
"self",
".",
"_authentication",
":",
"return",
"True",
"if",
"isinstance",
"(",
"scope",
",",
"s... | ccef2af042566ad384977028cf0bde01bc524dda |
train | AuthenticatedReddit.login | Login to a reddit site.
**DEPRECATED**. Will be removed in a future version of PRAW.
https://www.reddit.com/comments/2ujhkr/
https://www.reddit.com/comments/37e2mv/
Look for username first in parameter, then praw.ini and finally if both
were empty get it from stdin. Look for p... | rtv/packages/praw/__init__.py | def login(self, username=None, password=None, **kwargs):
"""Login to a reddit site.
**DEPRECATED**. Will be removed in a future version of PRAW.
https://www.reddit.com/comments/2ujhkr/
https://www.reddit.com/comments/37e2mv/
Look for username first in parameter, then praw.ini ... | def login(self, username=None, password=None, **kwargs):
"""Login to a reddit site.
**DEPRECATED**. Will be removed in a future version of PRAW.
https://www.reddit.com/comments/2ujhkr/
https://www.reddit.com/comments/37e2mv/
Look for username first in parameter, then praw.ini ... | [
"Login",
"to",
"a",
"reddit",
"site",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1479-L1519 | [
"def",
"login",
"(",
"self",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"password",
"and",
"not",
"username",
":",
"raise",
"Exception",
"(",
"'Username must be provided when password is.'",
")",
"use... | ccef2af042566ad384977028cf0bde01bc524dda |
train | AuthenticatedReddit.refresh_access_information | Return updated access information for an OAuth2 authorization grant.
:param refresh_token: The refresh token used to obtain the updated
information. When not provided, use the stored refresh_token.
:param update_session: Update the session with the returned data.
:returns: A diction... | rtv/packages/praw/__init__.py | def refresh_access_information(self, # pylint: disable=W0221
refresh_token=None,
update_session=True):
"""Return updated access information for an OAuth2 authorization grant.
:param refresh_token: The refresh token used to obtain th... | def refresh_access_information(self, # pylint: disable=W0221
refresh_token=None,
update_session=True):
"""Return updated access information for an OAuth2 authorization grant.
:param refresh_token: The refresh token used to obtain th... | [
"Return",
"updated",
"access",
"information",
"for",
"an",
"OAuth2",
"authorization",
"grant",
"."
] | michael-lazar/rtv | python | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1521-L1539 | [
"def",
"refresh_access_information",
"(",
"self",
",",
"# pylint: disable=W0221",
"refresh_token",
"=",
"None",
",",
"update_session",
"=",
"True",
")",
":",
"response",
"=",
"super",
"(",
"AuthenticatedReddit",
",",
"self",
")",
".",
"refresh_access_information",
"... | ccef2af042566ad384977028cf0bde01bc524dda |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.