Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Based on the snippet: <|code_start|> def __next__(self): cmd = self.stream.read_vint() if cmd == bp.AUTHENTICATION_RESP: return cmd, self.stream.read_tuple("b") elif cmd == bp.OUTPUT: return cmd, self.stream.read_tuple("bb") elif cmd == bp.PARTITIONED_OUTPUT: ...
class TestFileConnection(WDTestCase):
Here is a snippet: <|code_start|> return not roles.isdisjoint(user_roles) async def on_message(self, message): if message.channel != self.channel: return user = message.author name = user.name data = message.content config = self.script.config comm...
command, args = parse_command(command)
Using the snippet: <|code_start|> def handle_command(self, name, command): command, args = parse_command(command) try: return self.commands[command](self, *args) except KeyError: pass ret = self.server.call_command(self.interface, command, args) if ret ...
class DiscordScriptServer(ServerScript):
Given the following code snippet before the placeholder: <|code_start|> if not result: return self.send(f'{user.mention}: {result}') elif data.startswith(chat_prefix): top_role = user.top_role if not self.has_role(user, config.chat_roles): ...
class DiscordScriptConnection(ConnectionScript):
Given the following code snippet before the placeholder: <|code_start|># cuwo is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should ...
self.interface = ScriptInterface('Discord', self.server,
Given the following code snippet before the placeholder: <|code_start|> @irc3.event(irc3.rfc.PRIVMSG) def on_privmsg(self, mask, event, target, data=None): if event != 'PRIVMSG': return user = mask.nick if user in self.command_users: prefix = '@' elif user...
command, args = parse_command(command)
Here is a snippet: <|code_start|> users.add(name) else: users.discard(name) def send(self, msg): self.bot.privmsg(self.script.channel, msg) def me(self, msg): msg = 'ACTION ' + msg self.bot.ctcp(self.script.channel, msg) class IRCScriptConne...
class IRCScriptServer(ServerScript):
Given the following code snippet before the placeholder: <|code_start|> modes, names = params[0], params[1:] if modes[0] not in '-+': modes = '+' + modes if channel == self.bot.nick: return for c in modes: if c in '-+': sign = c ...
class IRCScriptConnection(ConnectionScript):
Based on the snippet: <|code_start|># but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with cuwo. If not, see <http:...
self.interface = ScriptInterface('IRC', self.server, *config.rights)
Given the following code snippet before the placeholder: <|code_start|> WRITE_INTERVAL = 10 DEFAULT_PORT = 12364 EXPIRE_TIME = master.UPDATE_RATE * 1.5 BLACKLIST_FILE = 'blacklist.json' def is_sane_count(count): return count < 500 class MasterServer(master.MasterProtocol): def __init__(self, loop, filenam...
if port != constants.SERVER_PORT:
Here is a snippet: <|code_start|> return info[0][4][0] @asyncio.coroutine def on_server(self, data, addr): host, port = addr if data.ip is None: data.ip = host else: use_ip = False try: ip = yield from self.resolve(data.ip) ...
except InvalidData:
Using the snippet: <|code_start|> def connection_made(self, transport): self.transport = transport self.task = asyncio.get_event_loop().create_task(self.send_loop()) @asyncio.coroutine def send_loop(self): config = self.server.config.base data = ServerData() while T...
class MasterRelay(ServerScript):
Based on the snippet: <|code_start|> def error_received(self, exc): print('Master error:', exc) def on_packet(self, data, addr): pass def send_packet(self, value, addr): if self.transport is None: return data = zlib.compress(json.dumps(value).encode('utf-8')) ...
raise InvalidData()
Continue the code snippet: <|code_start|> for value in self.cache.values(): if value is None: continue yield value def stop(self): self.running = False def run(self): print('Initializing tgen...') tgen.initialize(self.parent.seed, './data/...
self.pos = Vector3((40.31, 158.36, 173.21))
Given the following code snippet before the placeholder: <|code_start|> def run(self): print('Initializing tgen...') tgen.initialize(self.parent.seed, './data/') print('Done') while self.running: key = self.gen_queue.get() x, y = key print('Generat...
rot = Quaternion()
Continue the code snippet: <|code_start|>""" Performs logging """ class LoggerWriter: data = '' errors = 'strict' def __init__(self, fp, logger, level): self.fp = fp self.errors = fp.errors self.encoding = fp.encoding self.logger = logger self.level = level ...
class LogServer(ServerScript):
Predict the next line for this snippet: <|code_start|> self.errors = fp.errors self.encoding = fp.encoding self.logger = logger self.level = level def write(self, message): self.data += message splitted = self.data.split('\n') for message in splitted[:-1]: ...
create_file_path(logfile)
Based on the snippet: <|code_start|># Copyright (c) Mathias Kaerlev 2013-2017. # # This file is part of cuwo. # # cuwo is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at ...
qmo_file = QubicleFile()
Given the following code snippet before the placeholder: <|code_start|># Copyright (c) Mathias Kaerlev 2013-2017. # # This file is part of cuwo. # # cuwo is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either ...
qmo_model = QubicleModel()
Next line prediction: <|code_start|># Copyright (c) Mathias Kaerlev 2013-2017. # # This file is part of cuwo. # # cuwo is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at ...
cub = CubModel(ByteReader(open(in_file, 'rb').read()))
Given the code snippet: <|code_start|># GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with cuwo. If not, see <http://www.gnu.org/licenses/>. """ Prevents Denial of Service attacks to some degree. XXX should probably be merged with anticheat...
class SaneServer(ServerScript):
Using the snippet: <|code_start|># Copyright (c) Mathias Kaerlev 2013-2017. # # This file is part of cuwo. # # cuwo is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at you...
LEGAL_CLASSES = (WARRIOR_CLASS, RANGER_CLASS, MAGE_CLASS, ROGUE_CLASS)
Given the code snippet: <|code_start|># Copyright (c) Mathias Kaerlev 2013-2017. # # This file is part of cuwo. # # cuwo is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (a...
LEGAL_CLASSES = (WARRIOR_CLASS, RANGER_CLASS, MAGE_CLASS, ROGUE_CLASS)
Using the snippet: <|code_start|># Copyright (c) Mathias Kaerlev 2013-2017. # # This file is part of cuwo. # # cuwo is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at you...
LEGAL_CLASSES = (WARRIOR_CLASS, RANGER_CLASS, MAGE_CLASS, ROGUE_CLASS)
Based on the snippet: <|code_start|># Copyright (c) Mathias Kaerlev 2013-2017. # # This file is part of cuwo. # # cuwo is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at ...
LEGAL_CLASSES = (WARRIOR_CLASS, RANGER_CLASS, MAGE_CLASS, ROGUE_CLASS)
Continue the code snippet: <|code_start|> 103: {'class': (MAGE_CLASS, ), }, # Shield 104: {'class': (WARRIOR_CLASS, ), 'weapon': (13, )}, # Generic 80: {}, # Drink potion 81: {}, # Eat 82: {}, # Present pet food 83: {}, # Sit 84: {}, # Sleep 106: {...
'offset_body': vec3(0, 0, -5),
Using the snippet: <|code_start|># it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # cuwo is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the impli...
class VersusServer(ServerScript):
Continue the code snippet: <|code_start|># Copyright (c) Mathias Kaerlev 2013-2017. # # This file is part of cuwo. # # cuwo is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or #...
self.entity.flags |= HOSTILE_FLAG
Given snippet: <|code_start|> command = self.commands.get(command, None) if not command: return user.parent = self # for ScriptInterface if len(args) < command.min_args: return command.get_syntax() if command.max_args is not None and len(args) > command.m...
self.rights = AttributeSet(rights)
Based on the snippet: <|code_start|> def __contains__(self, name): return name in self.items def add(self, script): self.items[script.script_name] = script self.cached_calls.clear() def remove(self, script): del self.items[script.script_name] self.cached_calls.clear(...
event = AttributeDict(kw)
Predict the next line for this snippet: <|code_start|># cuwo is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # cuwo is distributed in...
entity = StaticEntityHeader()
Using the snippet: <|code_start|> @asyncio.coroutine def async_stdin(): global reader if reader is None: reader = yield from get_stdin() line = yield from reader.readline() return line.decode('utf8') class ConsoleServer(ServerScript): connection_class = None ...
command, args = parse_command(line[1:])
Based on the snippet: <|code_start|> elif c == '\x08': # delete current = current[:-1] write_stdout('\x08 \x08') else: current += c write_stdout(c) stdout.flush() yield from as...
class ConsoleServer(ServerScript):
Next line prediction: <|code_start|> stdout.flush() yield from asyncio.sleep(0.04) return current else: reader = None @asyncio.coroutine def get_stdin(): loop = asyncio.get_event_loop() reader = asyncio.StreamReader() reader_protocol = asyncio...
self.interface = ScriptInterface('Console', self.server, 'admin',
Based on the snippet: <|code_start|># Copyright (c) Mathias Kaerlev 2013-2017. # # This file is part of cuwo. # # cuwo is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at ...
class BanServer(ServerScript):
Using the snippet: <|code_start|> connection.send_chat(SELF_BANNED.format(reason=reason)) connection.disconnect() banned_players.append(connection) if name is None: continue message = PLAYER_BANNED.format(name=name, reason=reason) ...
@command
Given the following code snippet before the placeholder: <|code_start|> connection.disconnect() banned_players.append(connection) if name is None: continue message = PLAYER_BANNED.format(name=name, reason=reason) print(message) self....
@admin
Given the code snippet: <|code_start|># Copyright (c) Mathias Kaerlev 2013-2017. # # This file is part of cuwo. # # cuwo is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (a...
qmo_file = QubicleFile()
Given snippet: <|code_start|># Copyright (c) Mathias Kaerlev 2013-2017. # # This file is part of cuwo. # # cuwo is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your op...
qmo_model = QubicleModel()
Predict the next line after this snippet: <|code_start|> def __init__(self, pickled_model_path, delay=0.2): """ Create a MarioKart Agent instance. Args: pickled_model_path: Path to the stored state-decision model file. screenshot_folder: Name of the folder where the current ...
dp_screenshot.take_screenshot()
Next line prediction: <|code_start|> distributed random number between 0 and 1 and comparing it to the probability of pressing a button in a given state. If the random number is above the probability threshold, the action is taken. If a state has never been encountered before, an action is chosen...
self.screenshot_dir = os.path.join(helper.get_home_folder(), '.dolphin-emu', 'ScreenShots', self.game_name)
Using the snippet: <|code_start|> screenshot_folder: Name of the folder where the current Dolphin game's screenshots are stored. """ saved_model_file = open(pickled_model_path, 'rb') saved_model_obj = pickle.load(saved_model_file) self.decision_map = saved_model_obj.get("model...
ds_image = mk_downsampler.Downsampler(self.game_name, final_dim=15).downsample(screenshot_file)
Using the snippet: <|code_start|> state. If the random number is above the probability threshold, the action is taken. If a state has never been encountered before, an action is chosen based on how often that action is taken in total out of all encountered states. 3) The basic Mario Kart AI a...
self.key_map = key2pad.KeyPadMap()
Given snippet: <|code_start|>class MarioKartAgent: """ Class implementing a basic Mario Kart AI agent using conditional probability. """ game_name = "NABE01" def __init__(self, pickled_model_path, delay=0.2): """ Create a MarioKart Agent instance. Args: pickled_model_path: Path...
dp_frames.advance('P')
Here is a snippet: <|code_start|> """ Save data as a pickled file in dir """ output = os.path.join(directory, "{}.pkl".format(name)) with open(output, 'wb') as m: pickle.dump(data, m, pickle.HIGHEST_PROTOCOL) def generate_img_key(image): try: image_single_channel = image[:, :, 1] ex...
for key in keylog.Keyboard:
Given snippet: <|code_start|> class KeyPadMap: def __init__(self): self.previous_keys = dict((el.name, False) for el in keylog.Keyboard) <|code_end|> , continue by predicting the next line. Consider current file imports: import src.keylog as keylog from src import dp_controller and context: # Path: src/...
self.p = dp_controller.DolphinController("~/.dolphin-emu/Pipes/pipe").__enter__()
Here is a snippet: <|code_start|> # on key press callback. sets pressed key state to 1. shows warning if key is not defined. def on_press(self, key): if key == keyboard.Key.f9 or key == keyboard.Key.esc: return try: value = self._get_key_value(key) self.state[Keyboard[valu...
dp_screenshot.take_screenshot()
Using the snippet: <|code_start|> except KeyError: logger.warning("Pressed key not defined within allowable controller inputs.") # on key release callback. sets released key state to False def on_release(self, key): try: value = self._get_key_value(key) self.s...
output_dir = helper.get_output_folder()
Given the code snippet: <|code_start|> for step, (x, y) in enumerate(train_loader): # Wrap label 'y' in variable y_label = y.view(-1, output_vec) if torch.cuda.is_available(): y_label = y_label.cuda() nn_label = Variable(y_label) # Forw...
torch.save(mkcnn, os.path.join(helper.get_models_folder(), "mkcnn_{}_frames.pkl".format(num_input_frames)))
Next line prediction: <|code_start|>""" This module implements a Convolutional Neural Network (CNN) Mario Kart AI Agent using PyTorch. """ logger = logging.getLogger(__name__) # Hyper Parameters input_size = 15 <|code_end|> . Use current file imports: (import logging import os import matplotlib.pyplot as plt impo...
output_vec = len(keylog.Keyboard)
Based on the snippet: <|code_start|> nn.LeakyReLU(), nn.Linear(self.fc_hidden3, output_vec), ) if torch.cuda.is_available(): print("cuda is available.") self.cuda() def forward(self, x): """ Forward pass of the neural network. Accepts a tensor...
train_loader, valid_loader = get_mario_train_valid_loader(batch_size, False, 123, history=num_input_frames)
Using the snippet: <|code_start|> for step, (x, y) in enumerate(train_loader): # Wrap label 'y' in variable y_label = y.view(-1, output_vec) if torch.cuda.is_available(): y_label = y_label.cuda() nn_label = Variable(y_label) # Forward p...
torch.save(mkcrnn, os.path.join(helper.get_models_folder(), "mkcrnn_{}_gru.pkl".format(history)))
Here is a snippet: <|code_start|>""" This module implements a Convolutional Recurrent Neural Network (CRNN) Mario Kart AI Agent using Gated Recurrent Units (GRUs) and PyTorch. """ logger = logging.getLogger(__name__) # Hyper Parameters input_size = 15 hidden_size_1 = 64 hidden_size_2 = 64 hidden_size_3 = 64 <|code...
output_vec = len(keylog.Keyboard)
Continue the code snippet: <|code_start|> num_layers=history, dropout=0.5) if torch.cuda.is_available(): print("cuda is available.") self.cuda() def forward(self, x): """ Forward pass of the neural network. Accepts a tensor of size input_size*inpu...
train_loader, valid_loader = get_mario_train_valid_loader(batch_size, False, 123, history=history)
Based on the snippet: <|code_start|> for step, (x, y) in enumerate(train_loader): # Wrap label 'y' in variable y_label = y.view(-1, output_vec) if torch.cuda.is_available(): y_label = y_label.cuda() nn_label = Variable(y_label) # Forwar...
torch.save(mkrnn, os.path.join(helper.get_models_folder(), "mkrnn_{}_lstm.pkl".format(history)))
Given the following code snippet before the placeholder: <|code_start|>""" This module implements a Recurrent Neural Network (RNN) Mario Kart AI Agent using Long Short-Term Memory (LSTM) and PyTorch. """ logger = logging.getLogger(__name__) # Hyper Parameters input_size = 15 hidden_size_1 = 64 hidden_size_2 = 64 h...
output_vec = len(keylog.Keyboard)
Given the code snippet: <|code_start|> nn.Dropout(0.5), nn.LeakyReLU(), nn.Linear(self.hidden_size_3, self.output_vec) ) if torch.cuda.is_available(): print("cuda is available.") self.cuda() def forward(self, x): """ Forward pass o...
train_loader, valid_loader = get_mario_train_valid_loader(batch_size, False, 123, history=history)
Next line prediction: <|code_start|>logger = logging.getLogger(__name__) class MarioKartNN: """ Class implementing a neural network Mario Kart AI agent """ game_name = "NABE01" def __init__(self, pickled_model_path, history_length=1, delay=0.2): """ Create a MarioKart Agent instance. Args...
dp_screenshot.take_screenshot()
Here is a snippet: <|code_start|>""" This module implements a Mario Kart AI agent using a Neural Network. """ logger = logging.getLogger(__name__) class MarioKartNN: """ Class implementing a neural network Mario Kart AI agent """ game_name = "NABE01" def __init__(self, pickled_model_path, history_leng...
self.screenshot_dir = os.path.join(helper.get_home_folder(), '.dolphin-emu', 'ScreenShots', self.game_name)
Here is a snippet: <|code_start|> def __init__(self, pickled_model_path, history_length=1, delay=0.2): """ Create a MarioKart Agent instance. Args: pickled_model_path: Path to the neural network model file. """ self.model = torch.load(pickled_model_path) self.fra...
ds_image = mk_downsampler.Downsampler(self.game_name, final_dim=15).downsample(screenshot_file)
Continue the code snippet: <|code_start|>""" This module implements a Mario Kart AI agent using a Neural Network. """ logger = logging.getLogger(__name__) class MarioKartNN: """ Class implementing a neural network Mario Kart AI agent """ game_name = "NABE01" def __init__(self, pickled_model_path, hist...
self.key_map = key2pad.KeyPadMap()
Next line prediction: <|code_start|>""" This module provides tools for programmatic control of the Dolphin emulator's save state functionality. """ logger = logging.getLogger(__name__) def save_dolphin_state(slot_key): """ Save the current state of a running Dolphin emulator. Args: slot_key: Keyboa...
helper.validate_function_key(slot_key)
Given the code snippet: <|code_start|> for step, (x, y) in enumerate(train_loader): # Wrap label 'y' in variable y_label = y.view(-1, output_vec) if torch.cuda.is_available(): y_label = y_label.cuda() nn_label = Variable(y_label) # Forw...
torch.save(mknn, os.path.join(helper.get_models_folder(), "mknn.pkl"))
Continue the code snippet: <|code_start|>""" This module implements a Neural Network (NN) Mario Kart AI Agent using PyTorch. """ logger = logging.getLogger(__name__) # Hyper Parameters input_size = 15 hidden_size_1 = 64 hidden_size_2 = 64 hidden_size_3 = 32 <|code_end|> . Use current file imports: import logging ...
output_vec = len(keylog.Keyboard)
Continue the code snippet: <|code_start|> nn.LeakyReLU(), nn.Linear(self.hidden_size_2, self.hidden_size_3), nn.Dropout(0.5), nn.LeakyReLU(), nn.Linear(self.hidden_size_3, self.output_vec) ) if torch.cuda.is_available(): print("cuda...
train_loader, valid_loader = get_mario_train_valid_loader(batch_size, False, 123)
Continue the code snippet: <|code_start|>""" This module implements the image downsampling component of the basic Mario Kart AI agent. """ logger = logging.getLogger(__name__) class Downsampler: def __init__(self, game_name, blur_size=25, intermediate_dim=300, final_dim=10): self.game_name = game_name ...
self.screenshot_dir = os.path.join(helper.get_home_folder(), '.dolphin-emu', 'ScreenShots')
Continue the code snippet: <|code_start|> True if using GPU. Returns ------- - train_loader: training set iterator. - valid_loader: validation set iterator. """ error_msg = "[!] valid_size should be in the range [0, 1]." assert ((valid_size >= 0) and (valid_size <= 1)), error_msg n...
train_dataset = MarioKartDataset(transform=train_transform, history=history)
Continue the code snippet: <|code_start|>""" This module contains code for maintaining the basic Mario Kart AI agent's state-decision map. """ logger = logging.getLogger(__name__) class StateModel: """ Class for storing the basic Mario Kart AI agent's state-decision probabilities in a lookup table. Attrib...
self.screenshot_dir = os.path.join(helper.get_home_folder(), '.dolphin-emu', 'ScreenShots')
Using the snippet: <|code_start|>""" This module contains code for maintaining the basic Mario Kart AI agent's state-decision map. """ logger = logging.getLogger(__name__) class StateModel: """ Class for storing the basic Mario Kart AI agent's state-decision probabilities in a lookup table. Attributes: ...
self.defaults = {k.name: 0 for k in keylog.Keyboard}
Predict the next line after this snippet: <|code_start|> for step, (x, y) in enumerate(train_loader): # Wrap label 'y' in variable y_label = y.view(-1, output_vec) if torch.cuda.is_available(): y_label = y_label.cuda() nn_label = Variable(y_label) ...
torch.save(mkcrnn, os.path.join(helper.get_models_folder(), "mkcrnn_{}_frames_{}_lstm.pkl".format(num_input_frames, history)))
Next line prediction: <|code_start|>""" This module implements a Convolutional Recurrent Neural Network (CRNN) Mario Kart AI Agent using Long Short-Term Memory (LSTM) and PyTorch. """ logger = logging.getLogger(__name__) # Hyper Parameters input_size = 15 hidden_size_2 = 64 hidden_size_3 = 64 hidden_size_4 = 64 <|...
output_vec = len(keylog.Keyboard)
Next line prediction: <|code_start|> ) if torch.cuda.is_available(): print("cuda is available.") self.cuda() def forward(self, x): """ Forward pass of the neural network. Accepts a tensor of size input_size*input_size. """ x = x.view(-1, self.conv1_in, self.i...
train_loader, valid_loader = get_mario_train_valid_loader(batch_size, False, 123, history=num_input_frames)
Next line prediction: <|code_start|> initial=0.1, maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( core_exceptions.DeadlineExceeded, core_exceptions.ServiceUnavailable, ...
[datatransfer.GetDataSourceRequest],
Based on the snippet: <|code_start|> with other clients - this may cause errors in other clients! """ raise NotImplementedError() @property def get_data_source( self, ) -> Callable[ [datatransfer.GetDataSourceRequest], Union[datatransfer.DataSource, Awaita...
Union[transfer.TransferConfig, Awaitable[transfer.TransferConfig]],
Here is a snippet: <|code_start|> default_data_refresh_window_days (int): Default data refresh window on days. Only meaningful when ``data_refresh_type`` = ``SLIDING_WINDOW``. manual_runs_disabled (bool): Disables backfilling and manual run scheduling for t...
transfer_type = proto.Field(proto.ENUM, number=7, enum=transfer.TransferType,)
Continue the code snippet: <|code_start|># # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permission...
method: Callable[..., datatransfer.ListDataSourcesResponse],
Next line prediction: <|code_start|> metadata: Sequence[Tuple[str, str]] = () ): """Instantiate the pager. Args: method (Callable): The method that was originally called, and which instantiated this pager. request (google.cloud.bigquery_datatransfer_v1...
def __iter__(self) -> Iterator[transfer.TransferConfig]:
Given snippet: <|code_start|> "203.104.209.23", "203.104.209.39", "203.104.209.55", "203.104.209.102", ) # 伪装成Win7 x64上的IE11 user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko' # 匹配网页中所需信息的正则表达式 patterns = {'dmm_token': re.compile(r'ht...
if config.proxy:
Predict the next line after this snippet: <|code_start|> self.world_ip = None self.api_token = None self.api_starttime = None self.entry = None def __del__(self): """析构函数,用于关闭aiohttp的会话。 :return: none """ self.session.close() @asyncio.coroutine ...
raise OOIAuthException(timeout_message)
Given snippet: <|code_start|> :param request: aiohttp.web.Request :return: dict """ session = yield from get_session(request) if 'mode' in session: mode = session['mode'] else: session['mode'] = 1 mode = 1 return {'mode': mode}...
kancolle = KancolleAuth(login_id, password)
Given the following code snippet before the placeholder: <|code_start|> def login(self, request): """接受登录表单提交的数据,登录后跳转或登录失败后展示错误信息。 :param request: aiohttp.web.Request :return: aiohttp.web.HTTPFound or aiohttp.web.Response """ post = yield from request.post() session ...
except OOIAuthException as e:
Continue the code snippet: <|code_start|>"""转发客户端FLASH和游戏服务器之间的通信。 接受客户端FLASH发送到OOI3服务器的请求,将其转发给用户所在的游戏服务器,获得响应后再返回给客户端FLASH。 """ class APIHandler: """ OOI3中用于转发客户端FLASH和游戏服务器间通信的类。""" def __init__(self): """ 构造函数,根据环境变量初始化代理服务器。 :return: none """ <|code_end|> . Use current file im...
if config.proxy:
Next line prediction: <|code_start|> news = [] h3s = soup.find_all('h3', class_='tec--card__title') # Limit to 10 news i = 0 for h3 in h3s: title = h3.a.string link = h3.a['href'] news.append(dict(title=title, link=link)) i += 1 if i == 10: ...
response, content = getpage(ns.url) # Download the page
Continue the code snippet: <|code_start|> h3s = soup.find_all('h3', class_='tec--card__title') # Limit to 10 news i = 0 for h3 in h3s: title = h3.a.string link = h3.a['href'] news.append(dict(title=title, link=link)) i += 1 if i == 10: break...
soup = parsepage(content) # Then we parse it
Given the following code snippet before the placeholder: <|code_start|> title = a.string link = a['href'] news.append(dict(title=title, link=link)) return news def __tec_olhar(soup): """ Gets the most read news from the Olhar Digital page :param soup: the BeautifulSo...
ns = get_ns('tec_conv')
Using the snippet: <|code_start|>""" news_source_technology.py: Scraping functions for the most read Technology News Sources __author__ = "Fernando P. Lopes" __email__ = "fpedrosa@gmail.com" """ def __tec_g1(soup): """ Gets the most read news from the G1 Technology page :param soup: the BeautifulSoup ob...
news = g1(soup)
Here is a snippet: <|code_start|> Gets the most read news from the Rock Bizz page :param soup: the BeautifulSoup object :return: a list with the most read news from the Rock Bizz page """ news = [] ns = get_ns('m_bizz') main = soup.find('main', id='main') articles = main.find_all('article') ...
response, content = getpage(ns.url) # Download the page
Given the code snippet: <|code_start|> :param soup: the BeautifulSoup object :return: a list with the most read news from the Rock Bizz page """ news = [] ns = get_ns('m_bizz') main = soup.find('main', id='main') articles = main.find_all('article') for article in articles: title = ...
soup = parsepage(content) # Then we parse it
Continue the code snippet: <|code_start|>__email__ = "fpedrosa@gmail.com" """ def __m_rs(soup): """ Gets the most read news from the Rolling Stone page :param soup: the BeautifulSoup object :return: a list with the most read news from the Rolling Stone page """ news = [] anchors = soup.find(...
ns = get_ns('m_whiplash')
Next line prediction: <|code_start|> """ Gets the most read news from the Grande Premio page :param soup: the BeautifulSoup object :return: a list with the most read news from the Grande Premio page """ news = [] ns = get_ns('e_gp') divs = soup.find_all('div', class_='bloco-trending') ...
response, content = getpage(ns.url) # Download the page
Continue the code snippet: <|code_start|> Gets the most read news from the Grande Premio page :param soup: the BeautifulSoup object :return: a list with the most read news from the Grande Premio page """ news = [] ns = get_ns('e_gp') divs = soup.find_all('div', class_='bloco-trending') ...
soup = parsepage(content) # Then we parse it
Given the following code snippet before the placeholder: <|code_start|>""" news_source_sports.py: Scraping functions for the most read News Sources of the Sports Category __author__ = "Fernando P. Lopes" __email__ = "fpedrosa@gmail.com" """ def __e_fox_br(soup): """ Gets the most read news from the Fox Spo...
ns = get_ns('e_fox_br')
Continue the code snippet: <|code_start|> Gets the most read news from the Área Vip page :param soup: the BeautifulSoup object :return: a list with the most read news from the Área Vip page """ news = [] divs = soup.find_all('div', class_='td-block-span12') for d in divs[:3]: a = d....
response, content = getpage(ns.url) # Download the page
Based on the snippet: <|code_start|> :param soup: the BeautifulSoup object :return: a list with the most read news from the Área Vip page """ news = [] divs = soup.find_all('div', class_='td-block-span12') for d in divs[:3]: a = d.find(anchor_has_no_class) title = a['title'] ...
soup = parsepage(content) # Then we parse it
Predict the next line for this snippet: <|code_start|> def __en_fuxico(soup): """ Gets the most read news from the Fuxico page :param soup: the BeautifulSoup object :return: a list with the most read news from the Fuxico page """ news = [] links = soup.find_all('a', class_='news-box-link') ...
ns = get_ns('en_contigo')
Given snippet: <|code_start|> """ Gets the most read news from the Tititi page :param soup: the BeautifulSoup object :return: a list with the most read news from the Tititi page """ # DEPRECATED news = [] ns = get_ns('en_tititi') anchors = soup.find('div', class_='box mais-lidas clea...
a = d.find(anchor_has_no_class)
Given snippet: <|code_start|>def __re_any(subreddit): """ Gets the most read entries of the Ask Reddit/TIL/IAmA subreddits from the last 24 hours :param soup: the BeautifulSoup object :return: a list with the most read news from the Ask Reddit page """ posts = [] base_url = f'https://www.re...
ns=get_ns(key)
Predict the next line for this snippet: <|code_start|>def __ny(soup): """ DEPRECATED Gets the most read news from NY Times page :param soup: the BeautifulSoup object :return: a list with the most read news from the NY Times page """ news = [] divs = soup.find_all('div', class_='story') ...
response, content = getpage(ns.url) # Download the page
Based on the snippet: <|code_start|> """ DEPRECATED Gets the most read news from NY Times page :param soup: the BeautifulSoup object :return: a list with the most read news from the NY Times page """ news = [] divs = soup.find_all('div', class_='story') for d in divs[:10]: link =...
soup = parsepage(content) # Then we parse it
Next line prediction: <|code_start|> link = a['href'] title = a.text news.append(dict(title=title, link=link)) return news def __lf(soup): """ Gets the most read news from the Le Figaro page :param soup: the BeautifulSoup object :return: a list with the most read news from the ...
ns = get_ns('tt')