Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Here is a snippet: <|code_start|> def __init__(self, right_platform, attack=True):
self.right_platform = right_platform
self.interruptible = True
self.attack = attack
def step(self, gamestate, smashbot_state, opponent_state):
if self.logger:
self.logger.log("Notes", "... | else: |
Continue the code snippet: <|code_start|> controller.empty_input()
return
isshielding = smashbot_state.action == Action.SHIELD \
or smashbot_state.action == Action.SHIELD_START \
or smashbot_state.action == Action.SHIELD_REFLECT \
or smashbot_state.act... | else: |
Here is a snippet: <|code_start|>
# Causes an empty_input if hitting left did not cause Smashbot to be TURNING or DASHING left, i.e. if Smashbot attempts a dashback during frames 1-3 of initial dash forward.
if (self.controller.prev.main_stick[0] == 0) and (smashbot_state.action == Action.DASHING and sm... | self.controller.empty_input() |
Given snippet: <|code_start|>
#If we can't interrupt the chain, just continue it
if self.chain != None and not self.chain.interruptible:
self.chain.step(gamestate, smashbot_state, opponent_state)
return
if self.dashdance:
self.chain = None
# Don't... | endposition = opponent_state.position.x + self.framedata.slide_distance(opponent_state, opponent_state.speed_ground_x_self, 7) |
Next line prediction: <|code_start|>
# Edgestall
class Edgestall(Chain):
def step(self, gamestate, smashbot_state, opponent_state):
controller = self.controller
# If we just grabbed the edge, wait
if smashbot_state.action == Action.EDGE_CATCHING:
<|code_end|>
. Use current file imports:
(i... | self.interruptible = True |
Next line prediction: <|code_start|>
class SD(Chain):
def step(self, gamestate, smashbot_state, opponent_state):
self.interruptible = True
if smashbot_state.action in [Action.FALLING, Action.ON_HALO_WAIT]:
self.controller.tilt_analog(Button.BUTTON_MAIN, .5, 0)
return
... | self.controller.tilt_analog(Button.BUTTON_MAIN, 1, 0.5) |
Predict the next line for this snippet: <|code_start|> self.interruptible = True
controller.release_all()
return
# Drop down with a fastfall
if smashbot_state.action == Action.EDGE_HANGING:
self.interruptible = False
if self.controller.prev.c_s... | controller.tilt_analog(melee.Button.BUTTON_MAIN, 0.5, 0) |
Using the snippet: <|code_start|> endposition += self.framedata.slide_distance(opponent_state, speed, framesleft)
# But don't go off the end of the stage
if opponent_state.action in [Action.TECH_MISS_DOWN, Action.TECH_MISS_UP, Action.NEUTRAL_TECH]:
if ... | self.logger.log("Notes", "smashbot_endposition: " + str(smashbot_endposition) + " ", concat=True) |
Predict the next line for this snippet: <|code_start|> if opponent_state.hitstun_frames_left > 0:
# Special case here for lying on the ground.
# For some reason, the hitstun count is totally wrong for these actions
if opponent_state.action in [Action.LYING_GROUND_UP, Action.... | Action.SWORD_DANCE_4_MID, Action.SWORD_DANCE_3_LOW]: |
Continue the code snippet: <|code_start|> # Can't punish opponent in shield
shieldactions = [Action.SHIELD_START, Action.SHIELD, Action.SHIELD_RELEASE, \
Action.SHIELD_STUN, Action.SHIELD_REFLECT]
if opponent_state.action in shieldactions:
return False
if smashbot... | Action.WALK_FAST, Action.EDGE_TEETERING_START, Action.EDGE_TEETERING, Action.CROUCHING, \ |
Given the following code snippet before the placeholder: <|code_start|>
class Run(Chain):
def __init__(self, rundirection):
self.rundirection = rundirection
def step(self, gamestate, smashbot_state, opponent_state):
#If we're starting the turn around animation, keep pressing that way or
... | self.interruptible = True |
Using the snippet: <|code_start|>
class Glide(Chain):
def __init__(self, pivot_point):
self.pivot_point = pivot_point
def step(self, gamestate, smashbot_state, opponent_state):
controller = self.controller
self.interruptible = True
if gamestate.frame % 2 == 0:
x = 0... | controller.tilt_analog(Button.BUTTON_MAIN, x, 0.5) |
Next line prediction: <|code_start|>
# Shine turnaround
if smashbot_state.action == Action.DOWN_B_STUN and not facinginwards:
self.interruptible = False
controller.tilt_analog(melee.Button.BUTTON_MAIN, int(not smashbot_state.facing), .5)
return
# Jump out of ... | controller.empty_input() |
Predict the next line after this snippet: <|code_start|> controller.tilt_analog(Button.BUTTON_MAIN, 0.5, 1)
controller.press_button(Button.BUTTON_B)
return
self.interruptible = False
controller.empty_input()
return
# If we are ... | if smashbot_state.position.y + smashbot_state.ecb.bottom.y > 0.25: |
Predict the next line for this snippet: <|code_start|>
class Mitigate(Tactic):
def __init__(self, logger, controller, framedata, difficulty):
Tactic.__init__(self, logger, controller, framedata, difficulty)
self.random_di = random.randint(0, 1)
<|code_end|>
with the help of current file imports:
... | def needsmitigation(smashbot_state): |
Given the code snippet: <|code_start|>
# Don't multishine off the stage
if abs(abs(smashbot_state.position.x) - melee.stages.EDGE_GROUND_POSITION[gamestate.stage]) < 10:
self.direction = MULTISHINE_DIRECTION.NEUTRAL
# Pivot if we're dashing. Or else we might dash right off stag... | controller.tilt_analog(Button.BUTTON_MAIN, int(smashbot_state.facing), .5) #advancing JC shine
|
Given the following code snippet before the placeholder: <|code_start|>
class SpotDodge(Chain):
def step(self, gamestate, smashbot_state, opponent_state):
controller = self.controller
# Don't try to spot dodge in the air
if not smashbot_state.on_ground:
self.interruptible = True... | if controller.prev.button[Button.BUTTON_L]: |
Given the following code snippet before the placeholder: <|code_start|> controller = self.controller
# Don't try to spot dodge in the air
if not smashbot_state.on_ground:
self.interruptible = True
controller.empty_input()
return
# If we're shielding, ... | controller.press_button(Button.BUTTON_L) |
Based on the snippet: <|code_start|>
class DI(Chain):
def __init__(self, x=0.5, y=0.5, cx = 0.5, cy = 0.5):
self.x = x
self.y = y
self.cx = cx
self.cy = cy
def step(self, gamestate, smashbot_state, opponent_state):
controller = self.controller
self.interruptible ... | controller.tilt_analog(Button.BUTTON_MAIN, self.x, self.y) |
Continue the code snippet: <|code_start|> return
# If somehow we are off stage, give up immediately
if smashbot_state.off_stage:
self.interruptible = True
controller.empty_input()
return
# We shouldn't need these. It's just there in case we miss t... | controller.empty_input() |
Next line prediction: <|code_start|>
class TECH_DIRECTION(Enum):
TECH_IN_PLACE = 0
TECH_BACK = 1
TECH_FORWARD = 2
TECH_RANDOM = 3
# Grab and throw opponent
class Tech(Chain):
<|code_end|>
. Use current file imports:
(import melee
import random
from melee.enums import Action, Button
from Chains.chain i... | def __init__(self, direction=TECH_DIRECTION.TECH_RANDOM): |
Continue the code snippet: <|code_start|> PSDTILT = 2
PSJAB = 3
class ShieldAction(Chain):
def __init__(self, action=SHIELD_ACTION.PSSHINE):
self.action = action
def step(self, gamestate, smashbot_state, opponent_state):
controller = self.controller
self.interruptible = True
... | return |
Here is a snippet: <|code_start|>
class Airdodge(Chain):
def __init__(self, x=0.5, y=0.5):
self.x = x
self.y = y
def step(self, gamestate, smashbot_state, opponent_state):
<|code_end|>
. Write the next line using the current file imports:
import melee
from melee.enums import Action, Button
fro... | controller = self.controller |
Given the following code snippet before the placeholder: <|code_start|> # Unless we're RIGHT on top of the edge. In which case the only safe wavedash is back on the stage
edge_x = melee.stages.EDGE_GROUND_POSITION[gamestate.stage]
if opponent_state.position.x < 0:
edge... | self.interruptible = True |
Continue the code snippet: <|code_start|>
class Jump(Chain):
def __init__(self, x=0.5):
self.x = x
def step(self, gamestate, smashbot_state, opponent_state):
controller = self.controller
self.interruptible = True
controller.tilt_analog(Button.BUTTON_MAIN, self.x, 0.5)
i... | controller.release_button(Button.BUTTON_Y) |
Given the following code snippet before the placeholder: <|code_start|>
class SHFFL_DIRECTION(Enum):
UP = 0
DOWN = 1
FORWARD = 2
BACK = 3
NEUTRAL = 4
class Shffl(Chain):
def __init__(self, direction=SHFFL_DIRECTION.DOWN):
self.direction = direction
def step(self, gamestate, smashbo... | if opponent_state.position.x < smashbot_state.position.x: |
Given the following code snippet before the placeholder: <|code_start|>
class THROW_DIRECTION(Enum):
UP = 0
DOWN = 1
FORWARD = 2
<|code_end|>
, predict the next line using imports from the current file:
import melee
from melee.enums import Action, Button
from Chains.chain import Chain
from enum import Enum... | BACK = 3 |
Here is a snippet: <|code_start|>
# If we just grabbed the edge, wait
if smashbot_state.action == Action.EDGE_CATCHING:
self.interruptible = True
controller.empty_input()
return
# If we just grabbed the edge, wait
if smashbot_state.on_ground:
... | if smashbot_state.position.x < 0: |
Given the following code snippet before the placeholder: <|code_start|>
class SMASH_DIRECTION(Enum):
UP = 0
DOWN = 1
LEFT = 2
RIGHT = 3
class SmashAttack(Chain):
def __init__(self, charge=0, direction=SMASH_DIRECTION.UP):
self.charge = charge
self.direction = direction
self.... | return |
Given snippet: <|code_start|>
# Struggle out of a grab
class Struggle(Chain):
def step(self, gamestate, smashbot_state, opponent_state):
# Just naively press and release every button every other frame
controller = self.controller
# Press every button
if gamestate.frame % 2:
... | controller.tilt_analog(Button.BUTTON_MAIN, .5, 0) |
Predict the next line after this snippet: <|code_start|>
class TILT_DIRECTION(Enum):
UP = 0
DOWN = 1
FORWARD = 2
class Tilt(Chain):
def __init__(self, direction=TILT_DIRECTION.UP):
"""NOTE: Don't call this from a dashing state. You need to pivot into it, but then the attack goes the wrong way.
... | self.direction = direction |
Continue the code snippet: <|code_start|> """
def __init__(self, parent):
self.parent = parent
# Central buffer for storing PDF code not in pages.
self.buffer = b''
# Offest is used to calculate the binary lengths in the cross-reference
# section
self.... | else:
|
Predict the next line after this snippet: <|code_start|> if name in self.color_dict:
self._set_from_dict(name)
else:
raise ValueError("Color (%s) not found." % name)
def set_color_by_number(self, r, g, b):
self.red = r
self.green = g
self.blue ... | self.value = self.color_dict[name] # Triplet from color ref
|
Given snippet: <|code_start|>
class PDFGraphBackground(object):
def __init__(self, background_style=None, border_size=None, background_border_color=None, background_fill_color=None, padding=0.0, stroke=None):
self.style = background_style
self.size = border_size
self.border_color = backgrou... | self.padding = padding |
Predict the next line for this snippet: <|code_start|>
CORE_FONTS = {
'courier': 'Courier',
'courier_bold': 'Courier-Bold',
'courier_italic': 'Courier-Oblique',
'courier_bold_italic': 'Courier-BoldOblique',
'helvetica': 'Helvetica',
'helvetica_bold': 'Helvetica-Bold',
'helvetica_ital... | def _copy(self):
|
Given snippet: <|code_start|>
class PDFRectangle(PDFDraw):
def __init__(self, session, page, cursor_start, cursor_end, border_color=None, fill_color=None, style=None, stroke=None, size=1):
super(PDFRectangle, self).__init__(session, page, border_color, style, stroke, size)
self.fill_color ... | self._draw_line_size()
|
Continue the code snippet: <|code_start|>
class PDFTable(object):
def __init__(self, session, page, rows, cols, cursor, def_font):
self.session = session
self.page = page
self.font = def_font
self.number_of_rows = rows
self.number_of_columns = cols
self.cursor = cur... | for x in range(self.number_of_rows): |
Continue the code snippet: <|code_start|> def parse_proxy_file(self, fname):
"""Parses a proxy file
The format should be like the following:
socks5 XX.XXX.XX.XX:1080 username:password
socks4 XX.XXX.XX.XX:80 username:password
http XX.XXX.XX.XX:80
If user... | Invalid proxy file. |
Continue the code snippet: <|code_start|>
logger = Logger()
logger.setup_logger()
logger = logger.get_logger()
class PhantomInstall():
home_dir = os.path.expanduser('phantomjs/')
binary_win = 'phantomjs-2.1.1-windows/bin/phantomjs.exe'
<|code_end|>
. Use current file imports:
import os
import platform
impor... | binary_linux64 = 'phantomjs-2.1.1-linux-x86_64/bin/phantomjs' |
Predict the next line after this snippet: <|code_start|>logger = Logger()
logger.setup_logger()
logger = logger.get_logger()
class ChromeInstall():
home_dir = os.path.expanduser('chromedriver/')
binary_win = 'chromedriver.exe'
binary_linux = 'chromedriver'
binary_mac64 = 'chromedriver'
def get_o... | else: |
Based on the snippet: <|code_start|> self, *fields: Union[str, Combinable], **expressions: Any
) -> "_QuerySet[_MT_co, Dict[str, Any]]":
...
class ModelDictQuerySetMixin:
def dicts(
self: IsQuerySet[_MT_co], *fields: str, **named_fields: str
) -> "_QuerySet[_MT_co, Dict[str, Any]]":... | _MT = TypeVar("_MT", bound=Model) |
Here is a snippet: <|code_start|>
urlpatterns = [re_path(r"^admin/", admin.site.urls)]
api.register(FooAPI)
api.register(HamAPI)
urlpatterns += [
re_path(r"^api/bananas", include("bananas.admin.api.urls")),
re_path(r"^api/separate", include(separate_api)),
re_path(r"^api/", include(fenced_api)),
<|code... | ] |
Next line prediction: <|code_start|>
urlpatterns = [re_path(r"^admin/", admin.site.urls)]
api.register(FooAPI)
api.register(HamAPI)
urlpatterns += [
<|code_end|>
. Use current file imports:
(from django.urls import include, re_path
from bananas import admin
from bananas.admin import api
from . import separate_api... | re_path(r"^api/bananas", include("bananas.admin.api.urls")), |
Using the snippet: <|code_start|>
urlpatterns = [re_path(r"^admin/", admin.site.urls)]
api.register(FooAPI)
api.register(HamAPI)
urlpatterns += [
<|code_end|>
, determine the next line of code. You have imports:
from django.urls import include, re_path
from bananas import admin
from bananas.admin import api
from ... | re_path(r"^api/bananas", include("bananas.admin.api.urls")), |
Given the following code snippet before the placeholder: <|code_start|>
class TestParseHeaderDatetime(TestCase):
def test_raises_missing_header(self):
request = FakeRequest.fake()
with self.assertRaises(MissingHeader):
<|code_end|>
, predict the next line using imports from the current file:
imp... | parse_header_datetime(request, "missing") |
Based on the snippet: <|code_start|>
apipatterns = [
re_path(
rf"^{version.__version__}/",
include(
<|code_end|>
, predict the immediate next line with the help of imports:
from django.urls import include, re_path
from .versioning import __versions__
and context (classes, functions, sometimes cod... | (f"{version.__name__}.urls", "bananas"), |
Continue the code snippet: <|code_start|> self.assertEqual(parsed, dt)
@isolate_apps("tests.project.drf")
class TestParseDateModified(TestCase):
def test_replaces_microsecond(self):
class A(TimeStampedModel):
date_modified = datetime.datetime( # type: ignore[assignment]
... | @override_settings(USE_TZ=False) |
Given snippet: <|code_start|>
class BananasEndpointEnumerator(EndpointEnumerator):
def should_include_endpoint(
self,
path: str,
callback: Callable,
app_name: str = "",
namespace: str = "",
url_name: Optional[str] = None,
) -> bool:
# Fall back to check... | path, callback, app_name, namespace, url_name |
Next line prediction: <|code_start|>
class BananasEndpointEnumerator(EndpointEnumerator):
def should_include_endpoint(
self,
path: str,
callback: Callable,
app_name: str = "",
namespace: str = "",
url_name: Optional[str] = None,
) -> bool:
# Fall back t... | super().should_include_endpoint( |
Based on the snippet: <|code_start|>
class SimpleSerializer(ModelSerializer):
class Meta:
model = Parent
fields = ("name",)
class AllowIfUnmodifiedSinceAPI(FencedUpdateModelMixin, GenericViewSet):
fence = allow_if_unmodified_since()
serializer_class = SimpleSerializer
queryset = Par... | class AllowIfMatchAPI(FencedUpdateModelMixin, GenericViewSet): |
Predict the next line after this snippet: <|code_start|>
BANANAS_SECRETS_DIR_ENV_KEY: Final = "BANANAS_SECRETS_DIR"
@overload
def get_secret(secret_name: str, default: str) -> str:
...
<|code_end|>
using the current file's imports:
import os
from typing import Optional
from typing_extensions import Final, o... | @overload |
Predict the next line after this snippet: <|code_start|>
return parse
T = TypeVar("T")
def as_set(
fn: Callable[[InstanceType], Optional[T]]
) -> Callable[[InstanceType], Optional[FrozenSet[T]]]:
@wraps(fn)
def wrapper(instance: InstanceType) -> Optional[FrozenSet[T]]:
version = fn(instance)... | description=( |
Using the snippet: <|code_start|>
__all__ = (
"Fence",
"FencedUpdateModelMixin",
"header_date_parser",
"parse_date_modified",
"allow_if_unmodified_since",
"header_etag_parser",
"allow_if_match",
<|code_end|>
, determine the next line of code. You have imports:
import abc
import datetime
... | ) |
Based on the snippet: <|code_start|>
__all__ = (
"Fence",
"FencedUpdateModelMixin",
"header_date_parser",
"parse_date_modified",
"allow_if_unmodified_since",
"header_etag_parser",
"allow_if_match",
)
TokenType = TypeVar("TokenType")
InstanceType = TypeVar("InstanceType")
<|code_end|>
... | @final |
Next line prediction: <|code_start|>
__all__ = (
"HeaderError",
"MissingHeader",
"InvalidHeader",
"parse_header_datetime",
"parse_header_etags",
)
<|code_end|>
. Use current file imports:
(import datetime
from typing import FrozenSet, Iterable
from django.utils.http import parse_http_date
from ... | class HeaderError(ValueError): |
Based on the snippet: <|code_start|> self.assertEqual(
response.json()["detail"], "Header missing in request: If-Unmodified-Since"
)
def test_returns_bad_request_for_invalid_header(self):
item = Parent.objects.create()
response = self.client.put(
self.url(args... | def test_allows_request_for_valid_token(self): |
Given the code snippet: <|code_start|> self.settings.update(getattr(django_settings, "ADMIN", {}))
self.site_title = self.settings["SITE_TITLE"]
self.site_header = self.settings["SITE_HEADER"]
self.index_title = self.settings["INDEX_TITLE"]
def each_context(self, request: WSGIReques... | app_label = self.model._meta.app_label |
Based on the snippet: <|code_start|> self.assertEqual(global_settings.DEBUG, False)
self.assertEqual(settings.DEBUG, True)
self.assertListEqual(settings.INTERNAL_IPS, ["127.0.0.1", "10.0.0.1"]) # type: ignore[attr-defined]
self.assertIsNone(global_settings.FILE_UPLOAD_DIRECTORY_PERMISSIO... | pre_date_modified = parent.date_modified |
Given snippet: <|code_start|>
def test_parse_list(self):
self.assertListEqual(environment.parse_list("a, b, c"), ["a", "b", "c"])
def test_parse_set(self):
self.assertSetEqual(environment.parse_set("b, a, c"), {"a", "b", "c"})
def test_env_wrapper(self):
self.assertEqual(env.get("f... | list_result = env.get_list("foobar") |
Here is a snippet: <|code_start|> self.assertEqual(child.parent.name, self.parent.name)
def test_dicts_rename(self):
child = Child.objects.dicts("parent__name", alias="name").first()
self.assertEqual(child.alias, self.child.name)
self.assertEqual(child.parent.name, self.parent.name)
... | expected_dicts = [ |
Predict the next line for this snippet: <|code_start|> {"id": self.parent.pk, "child_name": self.child.name},
{"id": self.parent.pk, "child_name": self.other_child.name},
]
self.assertListEqual(
list(Parent.objects.filter(name="A").dicts("id", child_name="child__name"... | }, |
Predict the next line after this snippet: <|code_start|> self.assertSetEqual(environment.parse_set("b, a, c"), {"a", "b", "c"})
def test_env_wrapper(self):
self.assertEqual(env.get("foo", "bar"), "bar")
self.assertEqual(env.get("foo", "bar"), "bar")
self.assertIsNone(env.get_bool("... | set_result = env.get_set("foobar") |
Based on the snippet: <|code_start|> environ["DJANGO_ADMINS"] = "foobar"
self.assertRaises(ValueError, environment.get_settings)
del environ["DJANGO_ADMINS"]
def test_unsupported_settings_type(self):
environ["DJANGO_DATABASES"] = "foobar"
self.assertRaises(NotImplementedError... | parent.save(update_fields={"name"}) |
Here is a snippet: <|code_start|> d = ModelDict(foo="bar", baz__ham="spam")
self.assertIn("foo", d, 'should have key "foo"')
self.assertNotIn("baz", d, 'should not have key "baz"')
self.assertRaises(AttributeError, d.__getattr__, "x")
self.assertTrue(hasattr(d, "foo"), 'should not... | d = ModelDict.from_model( |
Predict the next line for this snippet: <|code_start|> p = int(nls[1])
else:
p = 80
#conn = HTTPConnection(h, p)
return h, p, res.path
def get(conn, dst):
#conn = HTTPConnection("10.0.0.7", 8080)
echo(repr(dst))
conn.request("GET", dst)
resp = conn.getresponse()
echo(res... | resp = conn.getresponse() |
Next line prediction: <|code_start|> p.wait()
if p.returncode == 0:
return "ffmpeg"
p = Popen(['which', 'avconv'])
p.wait()
if p.returncode == 0:
return "avconv"
return ""
def merge(name, ext, cnt, clean=False, ists=False):
# ext = 'x-mpeg-ts'
# avconv -i 12.mp4 -c copy... | "-i", "-", |
Given the code snippet: <|code_start|> def U(dat):
if not isinstance(dat, unicode):
return dat.decode('utf8')
return dat
#USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:33.0) '
#USER_AGENT += 'Gecko/20100101 Firefox/33.0'
USER_AGENT = 'Mozilla/5.0 (X11; Linux i686) Appl... | self.url = url |
Continue the code snippet: <|code_start|> def U(dat):
return dat
except ImportError:
py3 = False
class ConnectionResetError(Exception):
pass
def echo(*args):
# sys.stdout.write(" ".join(map(str, args)) + "\n")
for arg in args:
if isinstance(arg, unicode):
... | USER_AGENT = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36' |
Based on the snippet: <|code_start|>DEBUG = False
UTITLE = "UnknownTitle"
def debug(*args):
global DEBUG
if DEBUG:
echo(*args)
return DEBUG
def norm_url(url):
if isinstance(url, unicode):
url = url.encode('utf8')
return quote(unquote(url), ":=?/&#;,@")
class UO(object):
def... | no_proxy = False |
Using the snippet: <|code_start|># -*- coding: utf8 -*-
try:
py3 = True
def echo(*args):
sys.stdout.write(" ".join(map(str, args)) + "\n")
sys.stdout.flush()
def U(dat):
return dat
except ImportError:
<|code_end|>
, determine the next line of code. You have imports:
import os
im... | py3 = False |
Here is a snippet: <|code_start|> hutf = self.get_hutf(src)
dst = match1(hutf, 'var play_url \= "([^"]+)"')
echo(dst)
if not dst:
echo("Can not find var play_url")
sys.exit(1)
if ('youku.com/' in dst and '/m3u8' in dst) \
or 'lecloud.com/' in dst... | hutf = self.get_hutf(url) |
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf8 -*-
class TTWanDa(DWM): # http://www.ttwanda.com/
handle_list = ['\.ttwanda\.com/films/', '\.ttwanda\.com/tv/']
def query_info(self, url):
#url = 'http://www.ttwanda.com/films/us/1693.html?xf'
hutf... | r = r.decode('utf8') |
Here is a snippet: <|code_start|> echo("Can not find var play_url")
sys.exit(1)
if ('youku.com/' in dst and '/m3u8' in dst) \
or 'lecloud.com/' in dst \
or '/letv-uts/' in dst:
return title, None, self.try_m3u8(dst), None
if 'ttwanda.com/ftn_handl... | for a in ns: |
Given snippet: <|code_start|> if 'ttwanda.com/ftn_handler/' in dst:
cs = ["%s=%s" % (c.name, c.value)
for c in self.cookie.cookiejar
if c.name != 'PHPSESSID']
echo(cs)
self.wget_cookie = "; ".join(cs)
k, s = get_kind_size(dst, se... | return urls |
Next line prediction: <|code_start|> echo(src)
self.extra_headers['Referer'] = url # this is important
hutf = self.get_hutf(src)
dst = match1(hutf, 'var play_url \= "([^"]+)"')
echo(dst)
if not dst:
echo("Can not find var play_url")
sys.exit(1)
... | return [] |
Predict the next line for this snippet: <|code_start|> hutf = self.get_hutf(url)
title = SelStr("div.video-content article p strong", hutf)[0].text
r = "《(.+)》"
if not py3:
r = r.decode('utf8')
t = match1(title, r)
if t and '/films/' in url:
tit... | if 'ttwanda.com/ftn_handler/' in dst: |
Based on the snippet: <|code_start|> title = SelStr("div.video-content article p strong", hutf)[0].text
r = "《(.+)》"
if not py3:
r = r.decode('utf8')
t = match1(title, r)
if t and '/films/' in url:
title = t
src = SelStr('iframe.player', hutf)[0]['s... | cs = ["%s=%s" % (c.name, c.value) |
Here is a snippet: <|code_start|>#! /usr/bin/python -B
# python -B
sys.dont_write_bytecode = True
def find_kls(url):
p = os.path.dirname(sys.argv[0])
n = os.path.basename(sys.argv[0])
if not p:
p = "."
dwmkls = re.compile("^class\s+(\S+)\s*\(DWM\)\:", re.M)
for fn in os.listdir(p):
... | continue |
Here is a snippet: <|code_start|>#! /usr/bin/python -B
# python -B
sys.dont_write_bytecode = True
def find_kls(url):
p = os.path.dirname(sys.argv[0])
n = os.path.basename(sys.argv[0])
if not p:
p = "."
dwmkls = re.compile("^class\s+(\S+)\s*\(DWM\)\:", re.M)
for fn in os.listdir(p):
... | try: |
Predict the next line after this snippet: <|code_start|>#! /usr/bin/python3 -B
try:
py3 = False
except ImportError:
<|code_end|>
using the current file's imports:
import re
import sys
import cgi
from itertools import chain
from gettext import gettext
from HTMLParser import HTMLParser
from html.parser imp... | py3 = True |
Given snippet: <|code_start|>#-*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
class DebugToolbar(object):
@property
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from ..utils import merge_items
and context:
# Path... | def MIDDLEWARE_CLASSES(self): |
Predict the next line after this snippet: <|code_start|>
class Command(BaseCommand):
help = '''Starts monitoring the instance /data folder for file events,
specifically for the addition of complete DICOM series datasets'''
<|code_end|>
using the current file's imports:
from sendit.apps.watcher.com... | def handle(self, *args, **options): |
Given the following code snippet before the placeholder: <|code_start|>
class Command(BaseCommand):
help = '''show batch logs with errors'''
def add_arguments(self, parser):
parser.add_argument('bid', nargs='*', type=int)
def handle(self,*args, **options):
<|code_end|>
, predict the next... | nbids = len(options['bid']) |
Given the code snippet: <|code_start|>
class Command(BaseCommand):
help = '''show batch logs with errors'''
def add_arguments(self, parser):
parser.add_argument('bid', nargs='*', type=int)
def handle(self,*args, **options):
nbids = len(options['bid'])
if nbids > 0:
... | for error in errors: |
Continue the code snippet: <|code_start|>
class Command(BaseCommand):
help = '''start queue will parse over:
1. First preference: a list of subfolders DATA_INPUT_FOLDERS
<|code_end|>
. Use current file imports:
from sendit.logger import bot
from django.core.management.base import BaseCommand
from s... | 2. Second preference, a single subfolder at the base (eg /data/<subfolder>) |
Based on the snippet: <|code_start|># Licensed under a 3-clause BSD style license - see LICENSE.rst
# If additional pytest markers are defined the key in the dictionary below
# should be the name of the marker.
DEFAULTS = {
'seed': 123,
'data_size': 100,
'data_scale': 1.0,
'data_mean': 0.0
}
DEFAU... | def ccd_data(data_size=DEFAULT_DATA_SIZE, |
Using the snippet: <|code_start|># Licensed under a 3-clause BSD style license - see LICENSE.rst
# none of these are properly enclosed in brackets; is an error raised?
@pytest.mark.parametrize('arg',
['1:2', '[1:2', '1:2]'])
def test_slice_from_string_needs_enclosing_brackets(arg):
wit... | (None, None, -1), |
Here is a snippet: <|code_start|># Licensed under a 3-clause BSD style license - see LICENSE.rst
def test_bitfield_not_integer():
with pytest.raises(TypeError):
bitfield_to_boolean_mask(np.random.random((10, 10)))
def test_bitfield_negative_flags():
bm = np.random.randint(0, 10, (10, 10))
with... | with pytest.raises(ValueError): |
Predict the next line for this snippet: <|code_start|># Licensed under a 3-clause BSD style license - see LICENSE.rst
logger = logging.getLogger(__name__)
__all__ = ['ImageFileCollection']
__doctest_skip__ = ['*']
<|code_end|>
with the help of current file imports:
from collections import OrderedDict
from os... | _ASTROPY_LT_1_3 = not minversion("astropy", "1.3") |
Continue the code snippet: <|code_start|>
def test_medianfilter_correct():
ccd = CCDData([[2, 6, 6, 1, 7, 2, 4, 5, 9, 1],
[10, 10, 9, 0, 2, 10, 8, 3, 9, 7],
[2, 4, 0, 4, 4, 10, 0, 5, 6, 5],
[7, 10, 8, 7, 7, 0, 5, 3, 5, 9],
[9, 6, 3, 8,... | assert all(getattr(result, attr) is None |
Given the code snippet: <|code_start|> assert key.name == key_name
assert key.unit == u.second
def test_keyword_properties_read_only():
key = Keyword('observer')
with pytest.raises(AttributeError):
key.name = 'error'
with pytest.raises(AttributeError):
key.unit = u.hour
unit = u.s... | name = 'exposure' |
Given the code snippet: <|code_start|>def test_rebin_smaller():
ccd_data = ccd_data_func(data_size=10)
a = ccd_data.data
with pytest.warns(AstropyDeprecationWarning):
b = rebin(a, (20, 20))
c = rebin(b, (10, 10))
assert c.shape == (10, 10)
assert (c - a).sum() == 0
# test rebinnin... | assert b.uncertainty.array.shape == (20, 20) |
Continue the code snippet: <|code_start|>
# test rebinning ndarray
def test_rebin_ndarray():
with pytest.raises(TypeError), pytest.warns(AstropyDeprecationWarning):
rebin(1, (5, 5))
# test rebinning dimensions
def test_rebin_dimensions():
ccd_data = ccd_data_func(data_size=10)
with pytest.raises(... | np.testing.assert_almost_equal(b.sum(), 4 * a.sum()) |
Predict the next line after this snippet: <|code_start|>
class SmtpServerDetailView(DetailView):
model = SmtpServer
class SmtpServerUpdateView(UpdateView):
model = SmtpServer
class SmtpServerListView(ListView):
model = SmtpServer
# Create your views here.
#, JsonResponse Django 1.7
def debug(*ar... | print("imapclient module not available, please install it (pip install imapclient)") |
Predict the next line after this snippet: <|code_start|>class ImapServerDetailView(DetailView):
model = ImapServer
class ImapServerUpdateView(UpdateView):
model = ImapServer
class ImapServerListView(ListView):
model = ImapServer
class SmtpServerCreateView(CreateView):
model = SmtpServer
clas... | class SmtpServerUpdateView(UpdateView): |
Given the following code snippet before the placeholder: <|code_start|> #if imap.has_capability(u'MOVE'):
# rtext = imap.move(uids, newfolder)
#else:
# raise # I'm lazy, if their server doesn't support move, neither do we
rtext1 = imap.copy(uids, newfolde... | s2, enc = email.header.decode_header(s)[0] |
Given the following code snippet before the placeholder: <|code_start|> rtext2 = imap.delete_messages(uids)
rtext3 = imap.expunge()
rtext.extend(rtext1)
rtext.extend(rtext2)
rtext.extend(rtext3)
except:
rstat = 'FAILURE'
imap.logout()
... | s = s2.decode(enc) |
Continue the code snippet: <|code_start|>
class ImapServerForm(forms.ModelForm):
class Meta:
model = ImapServer
exclude = ['user']
widgets = {
<|code_end|>
. Use current file imports:
from django import forms
from .models import ImapServer, SmtpServer
and context (classes, functions, or co... | 'passwd': forms.PasswordInput(), |
Next line prediction: <|code_start|>
class ImapServerForm(forms.ModelForm):
class Meta:
model = ImapServer
exclude = ['user']
widgets = {
'passwd': forms.PasswordInput(),
}
<|code_end|>
. Use current file imports:
(from django import forms
from .models import ImapServer... | class SmtpServerForm(forms.ModelForm): |
Next line prediction: <|code_start|> rts = model(imgLR, disc_aux)
torch.cuda.synchronize()
ttime = (time.time() - start_time); print('time = %.2f' % (ttime*1000) )
flow, logmid, occ, biseg, objseg = rts
# upsampling
flow = torch.squeeze(flow).data.cpu().numpy()
flow = np.conc... | return alp, refpp,center,length[0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.