Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Given the following code snippet before the placeholder: <|code_start|> max_list_size=1,
port=161,
timeout=DEFAULT_TIMEOUT,
version=Version.V2C,
):
# type: (str, str, List[str], List[str], int, int, int, int) -> BulkResult
# pylint: disable=unused-argument
"""
Delegates to :py:func:`~pure... | return BulkResult(pythonized_scalars, pythonized_list) |
Given snippet: <|code_start|> Receive the data and close the connection.
"""
if LOG.isEnabledFor(logging.DEBUG) and isinstance(data, bytes):
hexdump = visible_octets(data)
LOG.debug("Received packet:\n%s", hexdump)
self.future.set_result(data)
if self.tran... | raise Timeout(f"{timeout} second timeout exceeded") from exc |
Given the code snippet: <|code_start|> hexdump = visible_octets(data)
LOG.debug("Received packet:\n%s", hexdump)
self.future.set_result(data)
if self.transport:
self.transport.close()
def error_received(self, exc):
# type: (Exception) -> None
"""
... | class Transport(SyncTransport): |
Using the snippet: <|code_start|>"""
Unit-tests for utility functions
"""
OID = ObjectIdentifier.from_string
def test_group_varbinds():
"""
"group_varbinds" should convert an interleaved list of OIDs into a more
usable dictionary.
"""
varbinds = [
<|code_end|>
, determine the next line of code. ... | VarBind(OID("1.1.1"), Null()), |
Given the following code snippet before the placeholder: <|code_start|> VarBind(OID("3.3.1"), Null()),
VarBind(OID("3.3.2"), Null()),
VarBind(OID("3.3.3"), Null()),
],
}
assert result == expected
def test_get_unfinished_walk_oids():
"""
Using get_unfinished_... | (OID("1.1"), WalkRow(VarBind(OID("1.1.2"), Null()), unfinished=True)), |
Predict the next line after this snippet: <|code_start|> ],
OID("3.3"): [
VarBind(OID("3.3.1"), Null()),
VarBind(OID("3.3.2"), Null()),
VarBind(OID("3.3.3"), Null()),
],
}
assert result == expected
def test_get_unfinished_walk_oids():
"""
Usi... | result = get_unfinished_walk_oids(oid_groups) |
Given the following code snippet before the placeholder: <|code_start|>"""
Unit-tests for utility functions
"""
OID = ObjectIdentifier.from_string
def test_group_varbinds():
"""
"group_varbinds" should convert an interleaved list of OIDs into a more
usable dictionary.
"""
varbinds = [
Va... | result = group_varbinds(varbinds, effective_roots) |
Given the following code snippet before the placeholder: <|code_start|> if checked_ip.version == 4:
address_family = socket.AF_INET
else:
address_family = socket.AF_INET6
sock = socket.socket(address_family, socket.SOCK_DGRAM)
sock.settimeout(timeout or self.timeo... | raise Timeout("Max of %d retries reached" % self.retries) |
Given snippet: <|code_start|> LOG.debug("Received packet:\n%s", hexdump)
return response
def listen(self, bind_address="0.0.0.0", port=162): # pragma: no cover
# type: (str, int) -> Generator[SocketResponse, None, None]
"""
Sets up a listening UDP socket and returns a g... | yield SocketResponse(request, SocketInfo(addr[0], addr[1])) |
Given snippet: <|code_start|> LOG.debug("Received packet:\n%s", hexdump)
return response
def listen(self, bind_address="0.0.0.0", port=162): # pragma: no cover
# type: (str, int) -> Generator[SocketResponse, None, None]
"""
Sets up a listening UDP socket and returns a g... | yield SocketResponse(request, SocketInfo(addr[0], addr[1])) |
Next line prediction: <|code_start|>class GenErr(ErrorResponse):
"""
This error is returned for any error which is not covered in the previous
error classes.
"""
DEFAULT_MESSAGE = "General Error (genErr)"
def __init__(self, offending_oid, message=""):
# type: (Optional[ObjectIdentifier... | " RFC3416 limits requests to %d!" % (num_oids, MAX_VARBINDS) |
Predict the next line for this snippet: <|code_start|># Copyright 2017 The TensorFlow Agents Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/L... | obj = attr_dict.AttrDict(initial) |
Given snippet: <|code_start|># Copyright 2017 The TensorFlow Agents Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless req... | self.assertEqual(15 + 1 + 5, count_weights()) |
Given the code snippet: <|code_start|># Copyright 2017 The TensorFlow Agents Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# U... | self.assertEqual(42, nested.zip(42)) |
Based on the snippet: <|code_start|>
class CodeBlock(idaapi.BasicBlock):
def __init__(self, id_ea=None, bb=None, fc=None):
if bb is None and fc is None:
if id_ea is None:
id_ea = idaapi.get_screen_ea()
temp_codeblock = get_codeblock(id_ea)
self.__dict__.... | def lines(self): |
Continue the code snippet: <|code_start|> """Get the start address of an IDA Graph block."""
return get_codeblock(ea).start_ea
def get_nx_graph(ea, ignore_external=False):
"""Convert an IDA flowchart to a NetworkX graph."""
nx_graph = networkx.DiGraph()
func = idaapi.get_func(ea)
flowchart = Fl... | for function in functions(start, end): |
Predict the next line after this snippet: <|code_start|>
@property
def color(self):
node_info = idaapi.node_info_t()
success = idaapi.get_node_info(node_info, self._fc._q.bounds.start_ea, self.id)
if not success:
return None
if not node_info.valid_bg_color():
... | f = get_func(f) |
Given snippet: <|code_start|> nx_graph = networkx.DiGraph()
func = idaapi.get_func(ea)
flowchart = FlowChart(func, ignore_external=ignore_external)
for block in flowchart:
# Make sure all nodes are added (including edge-less nodes)
nx_graph.add_node(block.start_ea)
for pred in bl... | start, end = fix_addresses(start, end) |
Given the code snippet: <|code_start|> if function.ea == ea:
name = function.demangled
except:
pass
if not name:
name = idc.Name(ea)
if not name:
raise NoName("No named for address 0x{:08X}".format(ea))
return name
def show_meaningful_in_function(function)... | string = get_string(xref.to) |
Continue the code snippet: <|code_start|> name = function.demangled
except:
pass
if not name:
name = idc.Name(ea)
if not name:
raise NoName("No named for address 0x{:08X}".format(ea))
return name
def show_meaningful_in_function(function):
idaapi.msg("\n\nMeani... | except exceptions.SarkNoString: |
Based on the snippet: <|code_start|>"""
Pytest configuration module, required to setup fixtures and
other specific test configuration, and allow pytest to find and use them.
"""
@pytest.fixture(autouse=True, name='mockuuid4')
def mock_uuid(mocker):
"""
Fixture to override the default uuid.uuid4 function t... | muuid = mock_uuid_generator() |
Here is a snippet: <|code_start|>
@pytest.fixture(autouse=True, name='mockuuid4')
def mock_uuid(mocker):
"""
Fixture to override the default uuid.uuid4 function to return a
deterministic uuid instead of a random one.
"""
muuid = mock_uuid_generator()
def getuuid():
return next(muui... | new=MockModelCreate(cls), |
Predict the next line for this snippet: <|code_start|>"""
Items view: this module provides methods to interact
with items resources
"""
SEARCH_FIELDS = ['name', 'description']
class ItemsHandler(Resource):
"""Handler of the collection of items"""
def get(self):
"""Retrieve every item"""
<|code_e... | data = Item.json_list(Item.select()) |
Given snippet: <|code_start|>"""
Items view: this module provides methods to interact
with items resources
"""
SEARCH_FIELDS = ['name', 'description']
class ItemsHandler(Resource):
"""Handler of the collection of items"""
def get(self):
"""Retrieve every item"""
data = Item.json_list(Ite... | return generate_response(data, client.OK) |
Predict the next line after this snippet: <|code_start|> and matching `weights`
Args:
values(iterable): Values to average, either `int` or `float`
weights(iterable): Matching weights iterable
Returns:
float: weighted average
"""
if len(values) != len(weights):
raise... | w for w in re.split(config.STR_SPLIT_REGEX, string) |
Predict the next line for this snippet: <|code_start|> """
return current_user._get_current_object()
@staticmethod
def init_app(app):
"""
Wrapper for the flask_login method ``LoginManager::init_app``.
Args:
Flask app (Flask): The Flask app to initialize with ... | return User.get(User.id == user_id) |
Given the following code snippet before the placeholder: <|code_start|>"""
Auth login view: this module provides the login method
"""
class LoginHandler(Resource):
"""Handler of the login authentication"""
@cross_origin(supports_credentials=True)
def post(self):
request_data = request.get_json(... | user = User.get(User.email == email) |
Given the following code snippet before the placeholder: <|code_start|>"""
Auth login view: this module provides the login method
"""
class LoginHandler(Resource):
"""Handler of the login authentication"""
@cross_origin(supports_credentials=True)
def post(self):
request_data = request.get_json(... | return generate_response({}, client.OK) |
Continue the code snippet: <|code_start|>
init(autoreset=True)
def drops_all_tables(database):
"""Doesn't drop unknown tables."""
tables = database.get_tables()
for table in tables:
if table == 'item':
Item.drop_table()
if table == 'order':
Order.drop_table()
... | User.drop_table() |
Next line prediction: <|code_start|>
init(autoreset=True)
def drops_all_tables(database):
"""Doesn't drop unknown tables."""
tables = database.get_tables()
for table in tables:
if table == 'item':
<|code_end|>
. Use current file imports:
(from colorama import init, Fore, Style
from models import... | Item.drop_table() |
Given snippet: <|code_start|>
init(autoreset=True)
def drops_all_tables(database):
"""Doesn't drop unknown tables."""
tables = database.get_tables()
for table in tables:
if table == 'item':
Item.drop_table()
if table == 'order':
<|code_end|>
, continue by predicting the next l... | Order.drop_table() |
Predict the next line for this snippet: <|code_start|>
init(autoreset=True)
def drops_all_tables(database):
"""Doesn't drop unknown tables."""
tables = database.get_tables()
for table in tables:
if table == 'item':
Item.drop_table()
if table == 'order':
Order.drop_... | OrderItem.drop_table() |
Using the snippet: <|code_start|>
init(autoreset=True)
def drops_all_tables(database):
"""Doesn't drop unknown tables."""
tables = database.get_tables()
for table in tables:
if table == 'item':
Item.drop_table()
if table == 'order':
Order.drop_table()
if ta... | Address.drop_table() |
Based on the snippet: <|code_start|>
init(autoreset=True)
def drops_all_tables(database):
"""Doesn't drop unknown tables."""
tables = database.get_tables()
for table in tables:
if table == 'item':
Item.drop_table()
if table == 'order':
Order.drop_table()
if... | Picture.drop_table() |
Given snippet: <|code_start|>
init(autoreset=True)
def drops_all_tables(database):
"""Doesn't drop unknown tables."""
tables = database.get_tables()
for table in tables:
if table == 'item':
Item.drop_table()
if table == 'order':
Order.drop_table()
if table ... | Favorite.drop_table() |
Using the snippet: <|code_start|>
class UsersHandler(Resource):
"""
Handler for main user endpoint.
Implements:
* `get` method to retrieve the list of all the users
* `post` method to add a new user to the database.
"""
<|code_end|>
, determine the next line of code. You have imports:
from ... | @auth.login_required |
Given the code snippet: <|code_start|>
class UsersHandler(Resource):
"""
Handler for main user endpoint.
Implements:
* `get` method to retrieve the list of all the users
* `post` method to add a new user to the database.
"""
@auth.login_required
def get(self):
if not auth.cur... | data = User.json_list(User.select()) |
Here is a snippet: <|code_start|>
class UsersHandler(Resource):
"""
Handler for main user endpoint.
Implements:
* `get` method to retrieve the list of all the users
* `post` method to add a new user to the database.
"""
@auth.login_required
def get(self):
if not auth.current_... | return generate_response(data, OK) |
Here is a snippet: <|code_start|> def get(self):
if not auth.current_user.admin:
return ({'message': "You can't get the list users."}, UNAUTHORIZED)
data = User.json_list(User.select())
return generate_response(data, OK)
def post(self):
""" Add an user to the databas... | notify_new_user(first_name=new_user.first_name, |
Predict the next line after this snippet: <|code_start|>
ALLOWED_EXTENSION = ['jpg', 'jpeg', 'png', 'gif']
class ItemPictureHandler(Resource):
def get(self, item_uuid):
"""Retrieve every picture of an item"""
<|code_end|>
using the current file's imports:
import http.client as client
import os
import... | pictures = Picture.select().join(Item).where(Item.uuid == item_uuid) |
Based on the snippet: <|code_start|>
ALLOWED_EXTENSION = ['jpg', 'jpeg', 'png', 'gif']
class ItemPictureHandler(Resource):
def get(self, item_uuid):
"""Retrieve every picture of an item"""
<|code_end|>
, predict the immediate next line with the help of imports:
import http.client as client
import os
i... | pictures = Picture.select().join(Item).where(Item.uuid == item_uuid) |
Based on the snippet: <|code_start|>
ALLOWED_EXTENSION = ['jpg', 'jpeg', 'png', 'gif']
class ItemPictureHandler(Resource):
def get(self, item_uuid):
"""Retrieve every picture of an item"""
pictures = Picture.select().join(Item).where(Item.uuid == item_uuid)
if pictures:
dat... | return generate_response(data, client.OK) |
Given the code snippet: <|code_start|>
class FavoritesHandler(Resource):
@auth.login_required
def get(self):
<|code_end|>
, generate the next line using the imports in this file:
from auth import auth
from flask import request
from flask_restful import Resource
from models import Favorite, Item
from http.clie... | data = Favorite.json_list(auth.current_user.favorites) |
Continue the code snippet: <|code_start|>
class FavoritesHandler(Resource):
@auth.login_required
def get(self):
data = Favorite.json_list(auth.current_user.favorites)
return generate_response(data, OK)
@auth.login_required
def post(self):
user = auth.current_user
res ... | item = Item.get(Item.uuid == data['item_uuid']) |
Based on the snippet: <|code_start|>
class FavoritesHandler(Resource):
@auth.login_required
def get(self):
data = Favorite.json_list(auth.current_user.favorites)
<|code_end|>
, predict the immediate next line with the help of imports:
from auth import auth
from flask import request
from flask_restful... | return generate_response(data, OK) |
Using the snippet: <|code_start|>
AUTH_API_ENDPOINT = '/auth/login/'
TEST_USER_PASSWORD = 'user_password'
TEST_USER_WRONG_PASSWORD = 'wrong_password'
<|code_end|>
, determine the next line of code. You have imports:
import json
from http.client import BAD_REQUEST, OK, UNAUTHORIZED
from tests.test_case import TestC... | class TestAuth(TestCase): |
Next line prediction: <|code_start|>
AUTH_API_ENDPOINT = '/auth/login/'
TEST_USER_PASSWORD = 'user_password'
TEST_USER_WRONG_PASSWORD = 'wrong_password'
class TestAuth(TestCase):
def test_post_auth__success(self):
<|code_end|>
. Use current file imports:
(import json
from http.client import BAD_REQUEST, OK, U... | user = add_user('user@email.com', TEST_USER_PASSWORD) |
Predict the next line for this snippet: <|code_start|>
NAMES = [
'scarpe', 'scarpine', 'scarpette', 'scarpe da ballo',
'scarpe da ginnastica', 'scarponi', 'scarpacce',
'sedie', 'sedie deco', 'sedie da cucina', 'set di sedie',
'tavolo con sedie', 'tavolo con set di sedie', 'divano', 'divano letto',
... | Item.delete().execute() |
Using the snippet: <|code_start|>
NAMES = [
'scarpe', 'scarpine', 'scarpette', 'scarpe da ballo',
'scarpe da ginnastica', 'scarponi', 'scarpacce',
'sedie', 'sedie deco', 'sedie da cucina', 'set di sedie',
'tavolo con sedie', 'tavolo con set di sedie', 'divano', 'divano letto',
'letto', 'letto singo... | test_utils.add_item( |
Next line prediction: <|code_start|>
NAMES = [
'scarpe', 'scarpine', 'scarpette', 'scarpe da ballo',
'scarpe da ginnastica', 'scarponi', 'scarpacce',
'sedie', 'sedie deco', 'sedie da cucina', 'set di sedie',
'tavolo con sedie', 'tavolo con set di sedie', 'divano', 'divano letto',
'letto', 'letto si... | class TestSearchItems(TestCase): |
Based on the snippet: <|code_start|>"""
Orders-view: this module contains functions for the interaction with the orders.
"""
class OrdersHandler(Resource):
""" Orders endpoint. """
def get(self):
""" Get all the orders."""
data = Order.json_list(Order.select())
return generate_res... | @auth.login_required |
Predict the next line after this snippet: <|code_start|> try:
user = User.get(User.uuid == req_user['id'])
except User.DoesNotExist:
abort(BAD_REQUEST)
# get the user from the flask.g global object registered inside the
# auth.py::verify() function, called by @aut... | with database.atomic(): |
Given the following code snippet before the placeholder: <|code_start|> if errors:
return errors, BAD_REQUEST
# Extract data to create the new order
req_items = res['data']['relationships']['items']['data']
req_address = res['data']['relationships']['delivery_address']['data'... | address = Address.get(Address.uuid == req_address['id']) |
Continue the code snippet: <|code_start|>"""
Orders-view: this module contains functions for the interaction with the orders.
"""
class OrdersHandler(Resource):
""" Orders endpoint. """
def get(self):
""" Get all the orders."""
<|code_end|>
. Use current file imports:
from http.client import (BA... | data = Order.json_list(Order.select()) |
Predict the next line after this snippet: <|code_start|> @auth.login_required
def post(self):
""" Insert a new order."""
res = request.get_json(force=True)
errors = Order.validate_input(res)
if errors:
return errors, BAD_REQUEST
# Extract data to create the n... | items = Item.select().where(Item.uuid << item_ids) |
Predict the next line after this snippet: <|code_start|>
class OrdersHandler(Resource):
""" Orders endpoint. """
def get(self):
""" Get all the orders."""
data = Order.json_list(Order.select())
return generate_response(data, OK)
@auth.login_required
def post(self):
... | user = User.get(User.uuid == req_user['id']) |
Given snippet: <|code_start|> item_ids = [req_item['id'] for req_item in req_items]
items = Item.select().where(Item.uuid << item_ids)
if items.count() != len(req_items):
abort(BAD_REQUEST)
# Check that the address exist
try:
address = Address.get(Address.... | notify_new_order(address=order.delivery_address, user=order.user) |
Given snippet: <|code_start|>"""
Orders-view: this module contains functions for the interaction with the orders.
"""
class OrdersHandler(Resource):
""" Orders endpoint. """
def get(self):
""" Get all the orders."""
data = Order.json_list(Order.select())
<|code_end|>
, continue by predict... | return generate_response(data, OK) |
Predict the next line for this snippet: <|code_start|> items = Item.select().where(Item.uuid << item_ids)
if items.count() != len(req_items):
abort(BAD_REQUEST)
# Check that the address exist
try:
address = Address.get(Address.uuid == req_address['id'])
ex... | except InsufficientAvailabilityException: |
Predict the next line after this snippet: <|code_start|> return User.create(
first_name=first_name,
last_name=last_name,
email=email,
password=User.hash_password(password),
uuid=id or uuid.uuid4(),
)
def add_admin_user(email, psw, id=None):
"""
Create a single us... | return Address.create( |
Predict the next line after this snippet: <|code_start|>
def __call__(self, created_at=mock_datetime(), uuid=None, **query):
query['created_at'] = created_at
query['uuid'] = uuid or next(self.uuid_generator)
return self.original(**query)
def get_all_models_names():
"""
Returns the ... | return User.create( |
Given snippet: <|code_start|> by the function before adding the User to the database.
"""
email = email or 'johndoe{}@email.com'.format(int(random.random() * 100))
return User.create(
first_name='John Admin',
last_name='Doe',
email=email,
password=User.hash_password(psw),... | return Favorite.create( |
Using the snippet: <|code_start|>
return Address.create(
uuid=id or uuid.uuid4(),
user=user,
country=country,
city=city,
post_code=post_code,
address=address,
phone=phone,
)
def add_favorite(user, item, id=None):
"""Link the favorite item to user."""... | return Item.create( |
Given the following code snippet before the placeholder: <|code_start|># Flask helpers
# Common operations for flask functionalities
def open_with_auth(app, url, method, username, password, content_type, data):
"""
Generic call to app for http request, required for requests that need
to send a ``Basic Aut... | shutil.rmtree(get_image_folder(), onerror=None) |
Given snippet: <|code_start|> click.echo('####################\n####################\nADMIN USER SCRIPT\n')
click.echo('####################\n####################\n')
click.echo('Here you can create an admin user. For eachone you have to insert:\n')
click.echo('first name\n-last name\n-email\n-password')... | if User.exists(request_data['email']): |
Using the snippet: <|code_start|>@click.command()
@click.option('--first_name')
@click.option('--last_name')
@click.option('--email')
@click.option('--password')
def main(first_name, last_name, email, password):
click.echo('####################\n####################\nADMIN USER SCRIPT\n')
click.echo('##########... | non_empty_str(value, field) |
Here is a snippet: <|code_start|>
class AddressesHandler(Resource):
""" Addresses endpoint. """
@auth.login_required
def get(self):
<|code_end|>
. Write the next line using the current file imports:
from auth import auth
from flask import request
from flask_restful import Resource
from http.client import... | user_addrs = list(Address.select().where( |
Here is a snippet: <|code_start|>
class AddressesHandler(Resource):
""" Addresses endpoint. """
@auth.login_required
def get(self):
user_addrs = list(Address.select().where(
Address.user == auth.current_user))
<|code_end|>
. Write the next line using the current file imports:
from au... | return generate_response(Address.json_list(user_addrs), OK) |
Predict the next line for this snippet: <|code_start|>"""
Search API core module
Contains the main functions to get match values and searching
"""
def similarity(query, string):
"""
Calculate the match for the given `query` and `string`.
The match is calculated using the `jaro winkler` for each set of ... | query = utils.tokenize(query.lower()) |
Continue the code snippet: <|code_start|> query = utils.tokenize(query.lower())
string = utils.tokenize(string.lower())
# if one of the two strings is falsy (no content, or was passed with items
# short enough to be trimmed out), return 0 here to avoid ZeroDivisionError
# later on while processing.
... | _weights = (config.MATCH_WEIGHT, config.DIST_WEIGHT) |
Predict the next line after this snippet: <|code_start|> 'uuid': '429994bf-784e-47cc-a823-e0c394b823e8',
'name': 'mario',
'price': 20.20,
'description': 'svariati mariii',
'availability': 1,
'category': 'scarpe',
}
TEST_ITEM2 = {
'uuid': 'd46b13a1-f4bb-4cfb-8076-6953358145f3',
'name': 'G... | class TestPictures(TestCase): |
Based on the snippet: <|code_start|> 'price': 30.20,
'description': 'svariati GINIIIII',
'availability': 1,
'category': 'accessori',
}
TEST_PICTURE = {
'uuid': 'df690434-a488-419f-899e-8853cba1a22b',
'extension': 'jpg'
}
TEST_PICTURE2 = {
'uuid': 'c0001a48-10a3-43c1-b87b-eabac0b2d42f',
... | item = Item.create(**TEST_ITEM) |
Given the code snippet: <|code_start|> 'description': 'svariati GINIIIII',
'availability': 1,
'category': 'accessori',
}
TEST_PICTURE = {
'uuid': 'df690434-a488-419f-899e-8853cba1a22b',
'extension': 'jpg'
}
TEST_PICTURE2 = {
'uuid': 'c0001a48-10a3-43c1-b87b-eabac0b2d42f',
'extension': 'png'... | picture = Picture.create(item=item, **TEST_PICTURE) |
Here is a snippet: <|code_start|> if name == "":
return self
else:
return Resource.getChild(self, name, request)
def render_GET(self, request):
"""Called for all requests to this object"""
log.debug("render_GET")
# Rendering
request.setHeader... | xul += u' value="eXe Version '+version.release+'"/>\n' |
Here is a snippet: <|code_start|>#!/usr/bin/env python
# another thinly disguised shell script written in Python
# TOPDIR root of RPM build tree typically /usr/src/redhat or /home/xxx/.rpm
#TOPDIR = '/usr/src/redhat'
TOPDIR = os.path.join(os.environ['HOME'], '.rpm')
# where the SVN exe source directory is
#SRCDIR =... | 'exe-%s-%d.*.i386.rpm' % (version.version, clrelease))) |
Given the following code snippet before the placeholder: <|code_start|><ul>
<li> What learning outcomes are the questions testing</li>
<li> What intellectual skills are being tested</li>
<li> What are the language skills of the audience</li>
<li> Gender and cultural issues</li>
<li> Avoid grammar language and questi... | question = SelectQuestionField(self, x_(u'Question')) |
Next line prediction: <|code_start|> "different types of activity "
"planned for your resource that "
"will be visually signalled in the "
"content. Avoid using ... | readingAct.addField(TextAreaField(_(u"What to read"), |
Given snippet: <|code_start|> self.__upgradeGeneric()
else:
self.__createGeneric()
# generate new ids for these iDevices, to avoid any clashes
for idevice in self.generic:
idevice.id = self.getNewIdeviceId()
def __upgradeGeneric(self):
"""
... | if isinstance(field, FeedbackField): |
Using the snippet: <|code_start|># 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 3... | self.rss = TextAreaField(x_(u"RSS")) |
Given the following code snippet before the placeholder: <|code_start|> Initialize
"""
RenderableResource.__init__(self, parent)
self.localeNames = []
for locale, translation in self.config.locales.items():
localeName = locale + ": "
langName = ... | html = common.docType() |
Predict the next line after this 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 this ... | self.answerTextArea = TextAreaField(x_(u'Option'), |
Next line prediction: <|code_start|> html += self.renderEdit(style)
elif self.mode == Block.View:
html += self.renderView(style)
elif self.mode == Block.Preview:
if self.idevice.lastIdevice:
html += u'<a name="currentBlock"></a>\... | html = common.submitImage(u"done", self.id, |
Given the following code snippet before the placeholder: <|code_start|>'''
Created on Apr 4, 2014
@author: tangliuxiang
'''
MAX_CHECK_INVOKE_DEEP = 50
class SAutoCom(object):
'''
classdocs
'''
@staticmethod
def autocom(vendorDir, aospDir, bospDir, mergedDir, outdir, comModuleList):
sRe... | print Paint.bold(" Complete missed method in %s") % module |
Predict the next line after this snippet: <|code_start|>
# Increment total conflicts
Error.TOTAL_CONFLICTS += conflictNum;
Error.CONFLICT_FILE_NUM += 1
# Increment conflicts of each part
key = Error.getStatisticKey(target)
if not Error.CONFLICT_STATISTIC.has_key(... | print Paint.bold("%3d files not found totally, they might be removed or moved to other place by vendor?" % Error.TOTAL_FILENOTFOUND) |
Here is a snippet: <|code_start|> return True
else:
print Paint.red("<<< phase %s failed" % action)
return False
# End of CoronStateMachine
class Shell:
""" Subprocess to run shell command
"""
@staticmethod
def run(cmd):
""" Run command in shell.
... | Log.d(TAG, "Shell.run() %s return %s" %(cmd, subp.returncode)) |
Given snippet: <|code_start|>
def doAction(self, action):
""" Return True: do action succeed. Otherwise return false
"""
raise Exception("Should be implemented by subclass")
# End of class StateMachine
class CoronStateMachine(StateMachine):
""" Coron State Machine
"""
XML =... | print Paint.blue(">>> In phase %s" % action) |
Using the snippet: <|code_start|>class pull(object):
'''
classdocs
'''
mPull = None
PROC_PARTITIONS = "/proc/partitions"
BLOCK_DIR = "/dev/block"
MIN_SIZE = 4096
MAX_SIZE = 20480
def __init__(self):
'''
Constructor
'''
self.mWorkdir = tempfil... | Log.i(LOG_TAG, "Try to create block of partitions ...") |
Given the code snippet: <|code_start|>KEY_STATIC = "static"
KEY_FINAL = "final"
KEY_SYNTHETIC = "synthetic"
# only use in methods
KEY_ABSTRACT = "abstract"
KEY_CONSTRUCTOR = "constructor"
KEY_BRIDGE = "bridge"
KEY_DECLARED_SYNCHRONIZED = "declared-synchronized"
KEY_NATIVE = "native"
KEY_SYNCHRONIZED = "synchronized"
K... | Log.e(SLog.TAG, s) |
Using the snippet: <|code_start|> SUCCESS_LIST = []
ADVICE = ""
SUCCESS = ""
@staticmethod
def e(s):
Log.e(SLog.TAG, s)
@staticmethod
def w(s):
Log.w(SLog.TAG, s)
@staticmethod
def d(s):
if SLog.DEBUG:
Log.i(SLog.TAG, s)
else:
... | print Paint.red(" ____________________________________________________________________________________") |
Given the code snippet: <|code_start|> def __exit(self):
hasReject = self.hasReject(self.rejSmali.toString())
if hasReject:
self.rejSmali.out()
if hasReject:
self.rejSmali = Smali.Smali(self.rejSmali.getPath())
self.rejSmali.out(self.getOutRejectFilePath())... | print " %s %s" % (Paint.bold("FIX CONFLICTS IN"), target) |
Next line prediction: <|code_start|> "framework2.jar",
"mediatek-framework.jar")
PARTITIONS = ("secondary_framework.jar.out", "secondary-framework.jar.out",
"framework-ext.jar.out", "framework_ext.jar.out",
"framework2.jar.out")
class Options... | Log.d(TAG, "Program args = %s" %args) |
Given the following code snippet before the placeholder: <|code_start|>
def upgrade(self):
""" Prepare precondition of upgrade
"""
# Remove last_bosp and bosp
Utils.run(["rm", "-rf", OPTIONS.olderRoot], stdout=subprocess.PIPE).communicate()
Utils.run(["rm", "-rf", OPTIONS.n... | Log.w(TAG, Paint.red("Nothing to upgrade. Did you forget to sync the %s ?" %OPTIONS.baseName)) |
Predict the next line after this snippet: <|code_start|>"""
__author__ = 'duanqz@gmail.com'
try:
except ImportError:
#from lxml import etree as ET
TAG="changelist"
class ChangeList:
def __init__(self, olderRoot, newerRoot, patchXML):
ChangeList.OLDER_ROOT = olderRoot
ChangeList.NEWER_ROO... | Log.d(TAG, "Using the existing %s" % ChangeList.PATCH_XML) |
Predict the next line after this snippet: <|code_start|> if not os.path.isfile(linesPatch):
return
# Patch the lines to no line file
cmd = "patch -f %s -r /dev/null < %s > /dev/null" % \
(commands.mkarg(smaliFile), commands.mkarg(linesPatch))
commands.getstatu... | smaliFileList = utils.getSmaliPathList(libPath) |
Predict the next line for this snippet: <|code_start|>class SmaliSplitter:
""" Independent splitter of SMALI file
"""
def split(self, origSmali, output=None):
""" Split the original SMALI file into partitions
"""
if output == None: output = os.path.dirname(origSmali)
self.... | Log.d(TAG, " [Add new part %s ] " % part) |
Predict the next line after this snippet: <|code_start|>#!/usr/bin/python
'''
Coron
'''
__author__ = "duanqz@gmail.com"
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
def coronUsage():
helpEntry = HelpFactory.createHelp()
<|code_end|>
using the current file's imports:
import ... | print Paint.bold("Coron - an open source project for Android ROM porting.") |
Predict the next line after this snippet: <|code_start|> name = key
code = self.NAME_TO_CODE.get(name)
tag = self.ITEM_TAGS.get(code)
if tag == None:
return None
item = Item(code, name)
for child in tag.getchildren():
if child.tag == "so... | print Paint.bold("%s\t%s\n" % (item.code, item.name)) |
Here is a snippet: <|code_start|>
DEFAULT_TIMEOUT = 30
DEFAULT_SHARE = 'data'
class IfcbConnectionError(Exception):
pass
def do_nothing(*args, **kw):
pass
class RemoteIfcb(object):
def __init__(self, addr, username, password, netbios_name=None, timeout=DEFAULT_TIMEOUT,
share=DEFAULT... | self._c = smb_connect(self.addr, self.username, self.password, self.netbios_name, self.timeout) |
Given the code snippet: <|code_start|> self.directory = directory
self._c = None
def open(self):
if self._c is not None:
return
try:
self._c = smb_connect(self.addr, self.username, self.password, self.netbios_name, self.timeout)
except:
rais... | get_netbios_name(self.addr, timeout=self.timeout) |
Predict the next line for this snippet: <|code_start|>
class TestH5Utils(unittest.TestCase):
@withfile
def test_hdfopen(self, F):
attr = 'test'
v1, v2 = 5, 6
for group in [None, 'g']:
<|code_end|>
with the help of current file imports:
import unittest
import os
import numpy as np
i... | with hdfopen(F, group, replace=True) as f: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.