Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Using the snippet: <|code_start|>
logging.basicConfig(level=logging.INFO)
class Command(BaseCommand):
def handle(self, *args, **options):
<|code_end|>
, determine the next line of code. You have imports:
import logging
from django.core.management.base import BaseCommand
from auv_control_pi.components.remote_pr... | main() |
Given the code snippet: <|code_start|>
logging.basicConfig(level=logging.INFO)
class Command(BaseCommand):
def handle(self, *args, **options):
comp = Component(
transports="ws://crossbar:8080/ws",
realm="realm1",
<|code_end|>
, generate the next line using the imports in this fil... | session_factory=Camera, |
Predict the next line after this snippet: <|code_start|>
logger = logging.getLogger(__name__)
config = Configuration.get_solo()
def download_image(url):
resp = requests.get(url, stream=True)
with open('img.jpg', 'wb') as f:
resp.raw.decode_content = True
shutil.copyfileobj(resp.raw, f)
... | class Camera(ApplicationSession): |
Given the code snippet: <|code_start|>
logger = logging.getLogger(__name__)
config = Configuration.get_solo()
def download_image(url):
resp = requests.get(url, stream=True)
with open('img.jpg', 'wb') as f:
resp.raw.decode_content = True
shutil.copyfileobj(resp.raw, f)
img_uri = DataURI.fr... | @rpc('camera.take_snapshot') |
Given the code snippet: <|code_start|>
SIMULATION = os.getenv('SIMULATION', False)
logger = logging.getLogger(__name__)
class Navitgator(ApplicationSession):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.enabled = False
self.heading = None
self.targ... | self.pid = PID(config.kP, config.kI, config.kD, setpoint=0, output_limits=(-100, 100)) |
Given the code snippet: <|code_start|>SIMULATION = os.getenv('SIMULATION', False)
logger = logging.getLogger(__name__)
class Navitgator(ApplicationSession):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.enabled = False
self.heading = None
self.target_... | self.current_location = Point(lat=data.get('lat'), lng=data.get('lng')) |
Here is a snippet: <|code_start|> 'target_heading': self.target_heading,
'kP': self.pid.Kp,
'kI': self.pid.Ki,
'kD': self.pid.Kd,
'heading_error': self.heading_error,
'pid_output': self.pid_output,
'arrived': ... | return distance_to_point(self.current_location, self.target_waypoint) |
Given snippet: <|code_start|>
@rpc('nav.get_pid_values')
def get_pid_values(self):
return {
'kP': self.pid.Kp,
'kI': self.pid.Ki,
'kD': self.pid.Kd,
'debounce': config.pid_error_debounce
}
@rpc('nav.get_target_waypoint_distance')
def get_t... | self.target_heading = heading_to_point(self.current_location, waypoint) |
Using the snippet: <|code_start|> self.stop()
logger.info('Arrived at {}'.format(self.target_waypoint))
# otherwise keep steering towards the target waypoint
else:
self._steer()
config.refresh_from_db()
... | self.heading_error = get_error_angle(self.target_heading, self.heading) |
Predict the next line after this snippet: <|code_start|>
class Navitgator(ApplicationSession):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.enabled = False
self.heading = None
self.target_heading = None
self.current_location = None
sel... | @rpc('nav.set_pid_values') |
Using the snippet: <|code_start|>
SIMULATION = os.getenv('SIMULATION', False)
logger = logging.getLogger(__name__)
class Navitgator(ApplicationSession):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.enabled = False
self.heading = None
self.target_he... | @subscribe('ahrs.update') |
Given the code snippet: <|code_start|>
def test_point():
point = Point(10, 20)
assert point.lat == 10
assert point.lng == 20
def test_heading_to_point():
start_point = Point(49, -120)
end_point = Point(50, -120)
heading = heading_to_point(start_point, end_point)
assert heading == 0.0
de... | result = get_error_angle(target=10, heading=0) |
Given the code snippet: <|code_start|>
def test_point():
point = Point(10, 20)
assert point.lat == 10
assert point.lng == 20
def test_heading_to_point():
start_point = Point(49, -120)
end_point = Point(50, -120)
<|code_end|>
, generate the next line using the imports in this file:
from ..utils i... | heading = heading_to_point(start_point, end_point) |
Given the following code snippet before the placeholder: <|code_start|>
def test_point():
point = Point(10, 20)
assert point.lat == 10
assert point.lng == 20
def test_heading_to_point():
start_point = Point(49, -120)
end_point = Point(50, -120)
heading = heading_to_point(start_point, end_poin... | distance = distance_to_point(start_point, end_point) |
Predict the next line after this snippet: <|code_start|>
logging.basicConfig(level=logging.INFO)
class Command(BaseCommand):
def handle(self, *args, **options):
comp = Component(
transports="ws://crossbar:8080/ws",
realm="realm1",
<|code_end|>
using the current file's imports:
... | session_factory=RCControler, |
Next line prediction: <|code_start|>This is adapted from https://github.com/micropython-IMU/micropython-fusion
Basically things have been renamed to AHRS naming scheme, pep8 improvements
and adjusted to work with CPython instead of MicroPython.
Supports 6 and 9 degrees of freedom sensors. Tested with InvenSense MPU-... | class AHRS(ApplicationSession): |
Predict the next line for this snippet: <|code_start|> name = 'ahrs'
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if not SIMULATION:
self.imu = LSM9DS1()
self.imu.initialize()
self.declination = config.declination
self.board_offse... | @rpc('ahrs.get_heading') |
Predict the next line after this snippet: <|code_start|> magxyz = tuple(getxyz())
for x in range(3):
magmax[x] = max(magmax[x], magxyz[x])
magmin[x] = min(magmin[x], magxyz[x])
self.magbias = tuple(map(lambda a, b: (a + b)/2, magmin, magmax))
@rpc('ahr... | @subscribe('auv.update') |
Predict the next line for this snippet: <|code_start|>The sensor should be slowly rotated around each orthogonal axis while this runs.
arguments:
getxyz must return current magnetometer (x, y, z) tuple from the sensor
stopfunc (responding to time or user input) tells it to stop
waitfunc provides an optional delay betwe... | self.declination = config.declination |
Continue the code snippet: <|code_start|> @property
def heading(self):
if SIMULATION:
heading = self.declination + self.board_offset + self._simulated_heading
return clamp_angle(heading)
else:
offset = self.declination + self.board_offset
heading = ... | self.start_time = micros() # First run |
Next line prediction: <|code_start|> q3q3 = q3 * q3
q4q4 = q4 * q4
# Normalise accelerometer measurement
norm = sqrt(ax * ax + ay * ay + az * az)
if norm == 0:
return # handle NaN
norm = 1 / norm # use reciprocal for division
ax *= norm
... | deltat = elapsed_micros(self.start_time) / 1e6 |
Next line prediction: <|code_start|> @rpc('ahrs.get_declination')
def get_declination(self):
return config.declination
@rpc('ahrs.get_board_offset')
def get_board_offset(self):
return config.board_offset
@rpc('ahrs.set_declination')
def set_declination(self, val):
self.d... | return clamp_angle(heading) |
Given the code snippet: <|code_start|>
@pytest.fixture
def sim():
starting_point = Point(50, 120)
<|code_end|>
, generate the next line using the imports in this file:
import pytest
from pygc import great_circle
from ..simulator import Navitgator, GPS, Motor, AHRS
from ..components.navigation import Point, dist... | return Navitgator(gps=GPS(), |
Based on the snippet: <|code_start|>
@pytest.fixture
def sim():
starting_point = Point(50, 120)
<|code_end|>
, predict the immediate next line with the help of imports:
import pytest
from pygc import great_circle
from ..simulator import Navitgator, GPS, Motor, AHRS
from ..components.navigation import Point, dis... | return Navitgator(gps=GPS(), |
Continue the code snippet: <|code_start|>def sim():
starting_point = Point(50, 120)
return Navitgator(gps=GPS(),
current_location=starting_point,
update_period=1)
def test_simulator_move_to_waypoint(sim):
waypoint = Point(49, 120)
sim.move_to_waypoint(waypoi... | distance_moved = distance_to_point(starting_point, sim._current_location) |
Predict the next line for this snippet: <|code_start|>
logging.basicConfig(level=logging.INFO)
class Command(BaseCommand):
def handle(self, *args, **options):
comp = Component(
transports="ws://crossbar:8080/ws",
realm="realm1",
<|code_end|>
with the help of current file imports... | session_factory=GPSComponent, |
Predict the next line after this snippet: <|code_start|># 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 required by... | self.mock_log = mock.patch.object(ip_lib, "LOG").start() |
Predict the next line for this snippet: <|code_start|> address=None, promisc=None, master=None):
check_exit_code = check_exit_code or []
with iproute.IPRoute() as ip:
idx = self.lookup_interface(ip, device)
args = {'index': idx}
if state:
ar... | raise exception.NetworkInterfaceNotFound(interface=link) |
Given the following code snippet before the placeholder: <|code_start|>
class PyRoute2(ip_command.IpCommand):
def _ip_link(self, ip, command, check_exit_code, **kwargs):
try:
LOG.debug('pyroute2 command %(command)s, arguments %(args)s' %
{'command': command, 'args': kwarg... | args['flags'] = (utils.set_mask(flags, ifinfmsg.IFF_PROMISC) |
Predict the next line after this snippet: <|code_start|> max_version=max_version)
@base.VersionedObjectRegistry.register
class HostPortProfileInfo(osv_base.VersionedObject,
base.ComparableVersionedObject,
osv_base.VersionedObjectPrintableMi... | exception.NoMatchingPortProfileClass, |
Continue the code snippet: <|code_start|># under the License.
def _get_common_version(object_name, max_version, min_version, exc_notmatch,
exc_notsupported):
"""Returns the accepted version from the loaded OVO registry"""
reg = base.VersionedObjectRegistry.obj_classes()
if ob... | class HostPortProfileInfo(osv_base.VersionedObject, |
Predict the next line for this snippet: <|code_start|> return False
return True
class _CatchTimeoutMetaclass(abc.ABCMeta):
def __init__(cls, name, bases, dct):
super(_CatchTimeoutMetaclass, cls).__init__(name, bases, dct)
for name, method in inspect.getmembers(
# NOTE(ih... | {'prog': sys.argv[0], 'version': osvif_version.__version__}) |
Next line prediction: <|code_start|>
class BaseOVS(object):
def __init__(self, config):
self.timeout = config.ovs_vsctl_timeout
self.connection = config.ovsdb_connection
self.interface = config.ovsdb_interface
self._ovsdb = None
# NOTE(sean-k-mooney): when using the native ovsd... | constants.OVS_VHOSTUSER_INTERFACE_TYPE, |
Using the snippet: <|code_start|> self._ovsdb = None
# NOTE(sean-k-mooney): when using the native ovsdb bindings
# creating an instance of the ovsdb api connects to the ovsdb
# to initialize the library based on the schema version
# of the ovsdb. To avoid that we lazy load the ovsdb
# instan... | linux_net.set_device_mtu(dev, mtu) |
Predict the next line after this 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 la... | self._ovsdb = ovsdb_api.get_instance(self) |
Given snippet: <|code_start|># Copyright (c) 2011 X.commerce, a business unit of eBay Inc.
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); y... | ip_lib.set(dev, mtu=mtu, check_exit_code=[0, 2, 254]) |
Based on the snippet: <|code_start|># License for the specific language governing permissions and limitations
# under the License.
"""Implements vlans, bridges, and iptables rules using linux utilities."""
LOG = logging.getLogger(__name__)
_IPTABLES_MANAGER = None
def _set_device_mtu(dev, mtu):
"""Set... | @privsep.vif_plug.entrypoint |
Given the code snippet: <|code_start|>#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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
# Licen... | @mock.patch.object(ip_lib, "set") |
Given 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 permissions a... | linux_net._set_device_mtu(dev='fakedev', mtu=1500) |
Given the following code snippet before the placeholder: <|code_start|># 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 required by... | privsep.vif_plug.set_client_mode(False) |
Here is a snippet: <|code_start|>
Despite the confusing name, direct-style VIFs utilize macvtap which is a
device driver that inserts a software layer between a guest and an SR-IOV
Virtual Function (VF). Contrast this with
:class:`~os_vif.objects.vif.VIFHostDevice`, which allows the guest to
directl... | 'mode': osv_fields.VIFDirectModeField(), |
Here is a snippet: <|code_start|>CONF = cfg.CONF
class BaseOVSTest(testtools.TestCase):
def setUp(self):
super(BaseOVSTest, self).setUp()
test_vif_plug_ovs_group = cfg.OptGroup('test_vif_plug_ovs')
CONF.register_group(test_vif_plug_ovs_group)
CONF.register_opt(cfg.IntOpt('ovs_vsct... | @mock.patch('sys.platform', constants.PLATFORM_LINUX) |
Predict the next line for this snippet: <|code_start|>
class BaseOVSTest(testtools.TestCase):
def setUp(self):
super(BaseOVSTest, self).setUp()
test_vif_plug_ovs_group = cfg.OptGroup('test_vif_plug_ovs')
CONF.register_group(test_vif_plug_ovs_group)
CONF.register_opt(cfg.IntOpt('ovs... | @mock.patch.object(linux_net, 'set_device_mtu') |
Given the code snippet: <|code_start|># a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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 ... | self.br = ovsdb_lib.BaseOVS(cfg.CONF.test_vif_plug_ovs) |
Based on the snippet: <|code_start|> def show_state(self, device):
regex = re.compile(r".*state (?P<state>\w+)")
match = regex.match(self.show_device(device)[0])
if match is None:
return
return match.group('state')
def show_promisc(self, device):
regex = re.co... | ip_lib.set(*args, **kwargs) |
Here is a snippet: <|code_start|> return match.group('mac')
def show_mtu(self, device):
regex = re.compile(r".*mtu (?P<mtu>\d+)")
match = regex.match(self.show_device(device)[0])
if match is None:
return
return int(match.group('mtu'))
@privsep.os_vif_pctxt.entry... | class TestIpCommand(ShellIpCommands, base.BaseFunctionalTestCase): |
Predict the next line for this snippet: <|code_start|>
# phys_port_name only contains the VF number
INT_RE = re.compile(r"^(\d+)$")
# phys_port_name contains VF## or vf##
VF_RE = re.compile(r"vf(\d+)", re.IGNORECASE)
# phys_port_name contains PF## or pf##
PF_RE = re.compile(r"pf(\d+)", re.IGNORECASE)
# bus_info (bdf) c... | if ip_lib.exists(dev): |
Here is a snippet: <|code_start|># License for the specific language governing permissions and limitations
# under the License.
"""Implements vlans, bridges using linux utilities."""
LOG = logging.getLogger(__name__)
VIRTFN_RE = re.compile(r"virtfn(\d+)")
# phys_port_name only contains the VF number
INT_RE... | if sys.platform != constants.PLATFORM_WIN32: |
Given snippet: <|code_start|> return None, False
def _get_pf_func(pf_ifname):
"""Gets PF function number using pf_ifname and returns function
number or None.
"""
address_str, pf = get_function_by_ifname(pf_ifname)
if not address_str:
return None
match = PF_FUNC_RE.search(address_st... | raise exception.RepresentorNotFound(ifname=pf_ifname, vf_num=vf_num) |
Given the following code snippet before the placeholder: <|code_start|>LOG = logging.getLogger(__name__)
VIRTFN_RE = re.compile(r"virtfn(\d+)")
# phys_port_name only contains the VF number
INT_RE = re.compile(r"^(\d+)$")
# phys_port_name contains VF## or vf##
VF_RE = re.compile(r"vf(\d+)", re.IGNORECASE)
# phys_port_... | @privsep.vif_plug.entrypoint |
Using the snippet: <|code_start|># 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 required by applicable law or agre... | msg_fmt = _("An unknown exception occurred.") |
Based on the snippet: <|code_start|># http://www.apache.org/licenses/LICENSE-2.0
#
# 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... | class NeutronOvsdbIdl(impl_idl.OvsdbIdl, api.ImplAPI): |
Given snippet: <|code_start|># 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 required by applicable law or agreed t... | 'floating_ips': osv_fields.ListOfIPAddressField(), |
Predict the next line for this snippet: <|code_start|># 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 required by applicable law o... | @mock.patch.object(ip_lib, "add") |
Based on the snippet: <|code_start|> @mock.patch.object(linux_net, "_get_phys_switch_id")
def test_get_representor_port_2_pfs(
self, mock__get_phys_switch_id, mock__get_phys_port_name,
mock__get_pf_func, mock_listdir):
mock_listdir.return_value = [
'pf_ifname1', 'pf_if... | exception.RepresentorNotFound, |
Next line prediction: <|code_start|># 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 required by applicable law or agreed to in wri... | @mock.patch.object(linux_net, "_arp_filtering") |
Using the snippet: <|code_start|># 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 required by applicable law or agreed to in writin... | privsep.vif_plug.set_client_mode(False) |
Given snippet: <|code_start|># 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 required by applicable law or agreed t... | importlib.reload(api) |
Predict the next line after this snippet: <|code_start|> with mock.patch.object(iproute.IPRoute, 'link_lookup',
return_value=[1]) as mock_link_lookup:
self.ip_link.return_value = [{'flags': 0x4000}]
self.ip.set(self.DEVICE, state=self.UP, mtu=self.MTU,
... | self.assertRaises(exception.NetworkInterfaceNotFound, self.ip.set, |
Predict the next line for this snippet: <|code_start|># a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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,... | self.ip = impl_pyroute2.PyRoute2() |
Predict the next line for this snippet: <|code_start|># 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 required by a... | @privsep.vif_plug.entrypoint |
Continue the code snippet: <|code_start|>#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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. ... | exception.NotImplementedForOS(function='ip.set', os='Windows') |
Predict the next line after this snippet: <|code_start|># 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 required by... | 'dns': osv_fields.ListOfIPAddressField(), |
Using the snippet: <|code_start|> if self._result:
self._result = list(self._result[0].values())[0]
class DbCreateCommand(BaseCommand):
def __init__(self, context, opts=None, args=None):
super(DbCreateCommand, self).__init__(context, "create", opts, args)
# NOTE(twilson) pre-com... | class OvsdbVsctl(ovsdb_api.API, api.ImplAPI): |
Using the snippet: <|code_start|>LOG = logging.getLogger(__name__)
def _val_to_py(val):
"""Convert a json ovsdb return value to native python object"""
if isinstance(val, collections.abc.Sequence) and len(val) == 2:
if val[0] == "uuid":
return uuid.UUID(val[1])
elif val[0] == "set"... | @privsep.vif_plug.entrypoint |
Next line prediction: <|code_start|>
SEASON_NUMBER = 32002
SPECIALS = 20381
UNKNOWN_SOURCE = 32000
CHOOSE_TYPE_HEADER = 32050
CHOOSE_ART_HEADER = 32051
REFRESH_ITEM = 32409
AVAILABLE_COUNT = 32006
def prompt_for_artwork(mediatype, medialabel, availableart, monitor):
if not availableart:
return None, None
... | medialabel=medialabel, show_refresh=mediatype in mediatypes.require_manualid) |
Given snippet: <|code_start|>
SEASON_NUMBER = 32002
SPECIALS = 20381
UNKNOWN_SOURCE = 32000
CHOOSE_TYPE_HEADER = 32050
CHOOSE_ART_HEADER = 32051
REFRESH_ITEM = 32409
AVAILABLE_COUNT = 32006
def prompt_for_artwork(mediatype, medialabel, availableart, monitor):
if not availableart:
return None, None
ar... | typeselectwindow = ArtworkTypeSelector('DialogSelect.xml', settings.addon_path, arttypes=arttypes, |
Given snippet: <|code_start|> typelist = [at['arttype'] for at in arttypes]
while selectedart is None and not monitor.abortRequested():
# The loop shows the first window if viewer backs out of the second
selectedarttype = typeselectwindow.prompt()
if selectedarttype not in typelist:
... | self.getControl(1).setLabel("Artwork Beef: " + L(CHOOSE_TYPE_HEADER).format(self.medialabel)) |
Next line prediction: <|code_start|>
TVSHOW = 'tvshow'
MOVIE = 'movie'
EPISODE = 'episode'
SEASON = 'season'
MOVIESET = 'set'
MUSICVIDEO = 'musicvideo'
ARTIST = 'artist'
ALBUM = 'album'
SONG = 'song'
audiotypes = (ARTIST, ALBUM, SONG)
require_manualid = (MOVIESET, MUSICVIDEO)
PREFERRED_SOURCE_SHARED = {'0': None, '1':... | addon = pykodi.get_main_addon() |
Continue the code snippet: <|code_start|>
try:
except ImportError:
projectkeys = None
<|code_end|>
. Use current file imports:
import xbmc
import projectkeys
from lib.libs import pykodi
from lib.libs import quickjson
and context (classes, functions, or code) from other files:
# Path: lib/libs/py... | addon = pykodi.get_main_addon() |
Predict the next line after this snippet: <|code_start|>
CANT_CONTACT_PROVIDER = 32034
HTTP_ERROR = 32035
urllib3.disable_warnings()
languages = ()
cache = StorageServer.StorageServer('script.artwork.beef', 72)
monitor = xbmc.Monitor()
# Result of `get_images` is dict of lists, keyed on art type
# {'url': URL, 'la... | self.getter.session.headers['User-Agent'] = settings.useragent |
Here is a snippet: <|code_start|>HTTP_ERROR = 32035
urllib3.disable_warnings()
languages = ()
cache = StorageServer.StorageServer('script.artwork.beef', 72)
monitor = xbmc.Monitor()
# Result of `get_images` is dict of lists, keyed on art type
# {'url': URL, 'language': ISO alpha-2 code, 'rating': SortedDisplay, 'si... | message = L(CANT_CONTACT_PROVIDER) if ex.connection_error else L(HTTP_ERROR).format(ex.message) |
Based on the snippet: <|code_start|>
CANT_CONTACT_PROVIDER = 32034
HTTP_ERROR = 32035
urllib3.disable_warnings()
languages = ()
cache = StorageServer.StorageServer('script.artwork.beef', 72)
monitor = xbmc.Monitor()
# Result of `get_images` is dict of lists, keyed on art type
# {'url': URL, 'language': ISO alpha-2... | name = SortedDisplay(0, '') |
Given the code snippet: <|code_start|>
CANT_CONTACT_PROVIDER = 32034
HTTP_ERROR = 32035
urllib3.disable_warnings()
languages = ()
cache = StorageServer.StorageServer('script.artwork.beef', 72)
monitor = xbmc.Monitor()
# Result of `get_images` is dict of lists, keyed on art type
# {'url': URL, 'language': ISO alpha... | self.getter = Getter(self.contenttype, self.login) |
Continue the code snippet: <|code_start|>CANT_CONTACT_PROVIDER = 32034
HTTP_ERROR = 32035
urllib3.disable_warnings()
languages = ()
cache = StorageServer.StorageServer('script.artwork.beef', 72)
monitor = xbmc.Monitor()
# Result of `get_images` is dict of lists, keyed on art type
# {'url': URL, 'language': ISO alph... | except GetterError as ex: |
Based on the snippet: <|code_start|>
if sys.version_info < (2, 7):
else:
NFO_FILE = 32003
class NFOFileAbstractProvider(object):
__metaclass__ = ABCMeta
name = SortedDisplay('file:nfo', NFO_FILE)
def build_resultimage(self, url, title):
if isinstance(url, unicode):
url = url.encode('... | mediatype = mediatypes.TVSHOW |
Based on the snippet: <|code_start|>
if sys.version_info < (2, 7):
else:
NFO_FILE = 32003
class NFOFileAbstractProvider(object):
__metaclass__ = ABCMeta
<|code_end|>
, predict the immediate next line with the help of imports:
import os
import sys
import urllib
import xbmcvfs
import xml.etree.ElementTree as ET
f... | name = SortedDisplay('file:nfo', NFO_FILE) |
Next line prediction: <|code_start|> if root is None or root.find('art') is None:
return {}
artlistelement = root.find('art')
result = {}
for artelement in artlistelement:
arttype = artelement.tag.lower()
if arttype == 'season':
num = a... | paths = get_movie_path_list(mediaitem.file) |
Given the following code snippet before the placeholder: <|code_start|> def does_not_exist(self, mediaid, mediatype, medialabel):
return not self.exists(mediaid, mediatype, medialabel)
def _key_exists(self, mediaid, mediatype):
return bool(self.db.fetchone("SELECT * FROM processeditems WHERE med... | dbpath = settings.datapath |
Next line prediction: <|code_start|> if not stackedpath.startswith('stack://'):
result = [stackedpath]
else:
firstpath, path2 = stackedpath[8:].split(' , ')[0:2]
path, filename = split(firstpath)
if filename:
filename2 = basename(path2)
for regex in movies... | log("Couldn't get an unstacked path from \"{0}\"".format(stackedpath), xbmc.LOGWARNING) |
Given snippet: <|code_start|>
FILENAME = 'special://userdata/advancedsettings.xml'
FILENAME_BAK = FILENAME + '.beef.bak'
ROOT_TAG = 'advancedsettings'
VIDEO_TAG = 'videolibrary'
MUSIC_TAG = 'musiclibrary'
ARTTYPE_TAG = 'arttype'
# 0: mediatype tag name, 1: library tag name, 2: Kodi's hardcoded art types to exclude fr... | xbmcgui.Dialog().notification("Artwork Beef", L(MALFORMED), xbmcgui.NOTIFICATION_WARNING) |
Predict the next line after this snippet: <|code_start|>
cfgurl = 'https://api.themoviedb.org/3/configuration'
class TheMovieDBAbstractProvider(AbstractImageProvider):
__metaclass__ = ABCMeta
contenttype = 'application/json'
name = SortedDisplay('themoviedb.org', 'The Movie Database')
_baseurl = None... | apikey = settings.get_apikey('tmdb') |
Here is a snippet: <|code_start|>
cfgurl = 'https://api.themoviedb.org/3/configuration'
class TheMovieDBAbstractProvider(AbstractImageProvider):
__metaclass__ = ABCMeta
contenttype = 'application/json'
name = SortedDisplay('themoviedb.org', 'The Movie Database')
_baseurl = None
artmap = {}
@... | self._baseurl = response.json()['images']['secure_base_url'] |
Next line prediction: <|code_start|>
cfgurl = 'https://api.themoviedb.org/3/configuration'
class TheMovieDBAbstractProvider(AbstractImageProvider):
__metaclass__ = ABCMeta
contenttype = 'application/json'
<|code_end|>
. Use current file imports:
(import xbmc
from abc import ABCMeta
from lib.libs import medi... | name = SortedDisplay('themoviedb.org', 'The Movie Database') |
Using the snippet: <|code_start|>
cfgurl = 'https://api.themoviedb.org/3/configuration'
class TheMovieDBAbstractProvider(AbstractImageProvider):
__metaclass__ = ABCMeta
contenttype = 'application/json'
name = SortedDisplay('themoviedb.org', 'The Movie Database')
_baseurl = None
artmap = {}
@... | raise build_key_error('tmdb') |
Predict the next line for this snippet: <|code_start|>
class FanartTVAbstractProvider(AbstractImageProvider):
__metaclass__ = ABCMeta
api_section = None
mediatype = None
contenttype = 'application/json'
name = SortedDisplay('fanart.tv', 'fanart.tv')
apiurl = 'https://webservice.fanart.tv/v3/%s... | if self.mediatype == mediatypes.MUSICVIDEO: |
Next line prediction: <|code_start|>
class FanartTVAbstractProvider(AbstractImageProvider):
__metaclass__ = ABCMeta
api_section = None
mediatype = None
contenttype = 'application/json'
name = SortedDisplay('fanart.tv', 'fanart.tv')
apiurl = 'https://webservice.fanart.tv/v3/%s/%s'
def get_... | if not settings.get_apienabled('fanarttv'): |
Next line prediction: <|code_start|>
class FanartTVAbstractProvider(AbstractImageProvider):
__metaclass__ = ABCMeta
api_section = None
mediatype = None
contenttype = 'application/json'
<|code_end|>
. Use current file imports:
(import re
import urllib
import xbmc
from abc import ABCMeta, abstractmetho... | name = SortedDisplay('fanart.tv', 'fanart.tv') |
Using the snippet: <|code_start|>
VIDEO_FILE = 32004
VIDEO_FILE_THUMB = 32005
class VideoFileAbstractProvider(object):
__metaclass__ = ABCMeta
name = SortedDisplay('video:thumb', VIDEO_FILE)
def build_video_thumbnail(self, path):
url = build_video_thumbnail_path(path)
return {'url': url, ... | mediatype = mediatypes.MOVIE |
Next line prediction: <|code_start|>
VIDEO_FILE = 32004
VIDEO_FILE_THUMB = 32005
class VideoFileAbstractProvider(object):
__metaclass__ = ABCMeta
name = SortedDisplay('video:thumb', VIDEO_FILE)
def build_video_thumbnail(self, path):
url = build_video_thumbnail_path(path)
<|code_end|>
. Use curren... | return {'url': url, 'rating': SortedDisplay(0, ''), 'language': 'xx', 'title': L(VIDEO_FILE_THUMB), |
Based on the snippet: <|code_start|>
VIDEO_FILE = 32004
VIDEO_FILE_THUMB = 32005
class VideoFileAbstractProvider(object):
__metaclass__ = ABCMeta
<|code_end|>
, predict the immediate next line with the help of imports:
import re
import urllib
from abc import ABCMeta
from lib.libs import mediatypes
from lib.libs.... | name = SortedDisplay('video:thumb', VIDEO_FILE) |
Given snippet: <|code_start|>
VIDEO_FILE = 32004
VIDEO_FILE_THUMB = 32005
class VideoFileAbstractProvider(object):
__metaclass__ = ABCMeta
name = SortedDisplay('video:thumb', VIDEO_FILE)
def build_video_thumbnail(self, path):
url = build_video_thumbnail_path(path)
return {'url': url, 'rat... | path = get_movie_path_list(mediaitem.file)[0] |
Continue the code snippet: <|code_start|>
ACTION_SELECTSERIES = 32400
# TODO: Don't use 'imdbnumber'
class SeriesSelector(xbmcgui.WindowXMLDialog):
def __init__(self, *args, **kwargs):
super(SeriesSelector, self).__init__(args, kwargs)
self.serieslist = kwargs.get('serieslist')
self.origi... | self.getControl(1).setLabel(L(ACTION_SELECTSERIES)) |
Here is a snippet: <|code_start|>
# [0] method part, [1] list: properties, [2] dict: extra params
typemap = {mediatypes.MOVIE: ('Movie', ['art', 'imdbnumber', 'file', 'premiered', 'uniqueid', 'setid'], None),
mediatypes.MOVIESET: ('MovieSet', ['art'], {'movies': {'properties': ['art', 'file']}}),
mediatypes.TV... | return mediatype in (mediatypes.MOVIE, mediatypes.TVSHOW) and get_kodi_version() < 17 |
Here is a snippet: <|code_start|>
def get_base_json_request(method):
return {'jsonrpc': '2.0', 'method': method, 'params': {}, 'id': 1}
def get_application_properties(properties):
json_request = get_base_json_request('Application.GetProperties')
json_request['params']['properties'] = properties
json_re... | message += json.dumps(json_request, cls=pykodi.UTF8PrettyJSONEncoder) |
Given the code snippet: <|code_start|>
# Scrapy settings for crawler project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
# http://doc.scrapy.org/en/latest/topics/settings.html
# http://scrapy.readthedocs... | DOWNLOAD_DELAY = bs.DOWNLOAD_DELAY |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
"""
Created on 2018/3/14
@author: will4906
采集的内容、方式定义
"""
class PatentId(BaseItem):
is_required = True
<|code_end|>
using the current file's imports:
from bs4 import BeautifulSoup
from controller.url_config import url_search, url... | crawler_id = url_search.get('crawler_id') |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
"""
Created on 2018/3/14
@author: will4906
采集的内容、方式定义
"""
class PatentId(BaseItem):
is_required = True
crawler_id = url_search.get('crawler_id')
english = 'patent_id'
chinese = ['专利标志', '专利id', '专利ID', '专利Id']
@classmethod
def par... | crawler_id = url_detail.get('crawler_id') |
Predict the next line for this snippet: <|code_start|> crawler_id = url_detail.get('crawler_id')
english = ['proposer_post_code', 'zip_code_of_the_applicant', 'proposer_zip_code']
chinese = '申请人邮编'
@classmethod
def parse(cls, raw, item, process=None):
return push_item(process, item, 'propose... | crawler_id = url_related_info.get('crawler_id') |
Predict the next line for this snippet: <|code_start|> crawler_id = url_related_info.get('crawler_id')
table_name = 'law_state'
english = 'law_state_list'
chinese = '法律状态表'
title = ['法律状态', '法律状态时间']
@classmethod
def set_title(cls, title):
if title == cls.english:
cls.tit... | crawler_id = url_full_text.get('crawler_id') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.