Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*-
pid = PID(resource_filename('peoplefinder', '.pid.file'))
JOB_STATUS = (
'downloading',
'ready',
)
START_STATUS = (
'started',
'already started',
)
STOP_STATUS = (
'stopped',
'not started',
)
@... | def download_tiles_start(request): |
Predict the next line after this snippet: <|code_start|>
def try_run_vty_client(self):
self.logger.info("Try to create connection to VTY!")
try:
self.vty_client_connection = telnetlib.Telnet(self.vty_host, self.vty_port, self.vty_readtimeout_secs)
except:
self... | self.logger.info("Process measurement thread FINISH!")
|
Given the following code snippet before the placeholder: <|code_start|> while not self.time_to_shutdown_event.is_set():
meas = self.measure_model.get_measurement()
if meas is not None:
self.process_measure(meas)
else:
time.sleep(0.1)
... | if ((meas['time'] - last_measure_timestamp) < self.measure_update_period) and (last_measure.timing_advance == meas['meas_rep']['L1_TA']):
|
Predict the next line after this snippet: <|code_start|> self.logger.info("Process measurement thread FINISH!")
def process_measure(self, meas):
self.logger.info("Process meas: IMSI {0}".format(meas['imsi']))
imsi = meas['imsi']
extensions = HLRDBSession.query(Subscriber.ext... | welcome_msg = self.get_formated_welcome_message(ms_phone_number=extension)
|
Here is a snippet: <|code_start|> return None
return reply_message_res[0][0].format(**wargs)
def get_last_measure(self, imsi):
last_measures = DBSession.query(
Measure
).filter(
Measure.imsi == imsi
).order_by(
Measure.id.des... | gps_lat=meas['lat'],
|
Given the code snippet: <|code_start|>
return True
def stop_tracking(self):
self.__stop_trackin_event.set()
self.__tracking_process.join()
self.__prepare_imsi_process.join()
self.logger.info("Stop tracking!")
return True
def tracking_process(self):
... | Subscriber
|
Predict the next line after this snippet: <|code_start|>from __future__ import with_statement
__all__ = ["get_coqc_version", "get_coqtop_version", "get_coqc_help", "get_coqc_coqlib", "get_coq_accepts_top", "get_coq_accepts_time", "get_coq_accepts_o", "get_coq_accepts_compile", "get_coq_native_compiler_ondemand_fragmen... | return get_coqc_version_helper(coqc_prog) |
Using the snippet: <|code_start|> clean_v_file(temp_file_name)
return any(v in util.s(stdout) for v in ('The native-compiler option is deprecated',
'Native compiler is disabled',
'native-compiler-disabled',
... | def get_multiple_help_tags(coqc_help, **kwargs): |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python2
SCRIPT_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
parser = argparse.ArgumentParser(description='Absolutize the imports of Coq files')
parser.add_argument('input_files', metavar='INFILE', nargs='*', type=argparse.FileType('r'),
<... | help='.v files to update') |
Predict the next line for this snippet: <|code_start|>
__all__ = ["join_definitions", "split_statements_to_definitions"]
def get_definitions_diff(previous_definition_string, new_definition_string):
"""Returns a triple of lists (definitions_removed,
definitions_shared, definitions_added)"""
old_definitions ... | if i < len(old_definitions) and i < len(new_definitions): |
Here is a snippet: <|code_start|> if char_end <= last_char_end: continue
match = prompt_reg.match(full_response_text)
if not match:
log('Warning: Could not find statements in %d:%d: %s' % (char_start, char_end, full_response_text), level=LOG_ALWAYS)
con... | if definitions_removed: |
Using the snippet: <|code_start|> if not get_coq_accepts_time(coqtop, log=log):
return fallback()
if not get_proof_term_works_with_time(coqtop, is_coqtop=True, log=log, **kwargs):
statements = postprocess_split_proof_term(statements, log=log, **kwargs)
p = Popen([coqtop, '-q', '-emacs', '-tim... | if prompt.strip() == '': continue |
Predict the next line for this snippet: <|code_start|> definitions_removed, definitions_shared, definitions_added = get_definitions_diff(last_definitions, cur_definition_names)
# first, to be on the safe side, we add the new
# definitions key to the dict, if it wasn't already there.
... | del cur_definition[last_definitions] |
Given the following code snippet before the placeholder: <|code_start|>from __future__ import print_function
__all__ = ["add_libname_arguments", "add_passing_libname_arguments", "ArgumentParser", "update_env_with_libnames", "add_logging_arguments", "process_logging_arguments", "update_env_with_coqpath_folders", "DEFAU... | getattr(namespace, self.dest).append(tuple(values)) |
Given the code snippet: <|code_start|>from __future__ import print_function
__all__ = ["add_libname_arguments", "add_passing_libname_arguments", "ArgumentParser", "update_env_with_libnames", "add_logging_arguments", "process_logging_arguments", "update_env_with_coqpath_folders", "DEFAULT_LOG", "DEFAULT_VERBOSITY", "LO... | for (force, fno, sys_file) in ((force_stdout, 1, sys.stdout), (force_stderr, 2, sys.stderr)): |
Given the following code snippet before the placeholder: <|code_start|>from __future__ import with_statement, print_function
__all__ = ["include_imports", "normalize_requires", "get_required_contents", "recursively_get_requires_from_file", "absolutize_and_mangle_libname"]
file_contents = {}
lib_imports_fast = {}
lib_... | DEFAULT_LIBNAMES=(('.', 'Top'), ) |
Using the snippet: <|code_start|>from __future__ import with_statement, print_function
__all__ = ["include_imports", "normalize_requires", "get_required_contents", "recursively_get_requires_from_file", "absolutize_and_mangle_libname"]
file_contents = {}
<|code_end|>
, determine the next line of code. You have imports... | lib_imports_fast = {} |
Given the code snippet: <|code_start|> i += 1
elif stack[-1] == STRING:
if term[i] == '"':
stack.pop()
i += 1
elif stack[-1] == COMMENT:
if term[i:i+2] == '(*':
stack.extend(COMMENT)
i += 2
eli... | return FOUND_BUT_UNCHANGED # already correct |
Based on the snippet: <|code_start|>COMMENT='comment'
STRING='string'
def get_end_of_first_line_location(term, **env):
stack = []
i = 0
while i < len(term):
env['log']('DEBUG: stack: %s, pre: %s' % (str(stack), repr(term[:i])), level=3)
if len(stack) == 0:
if term[i] == '.' and (... | i += 1 |
Given the code snippet: <|code_start|>#!/usr/bin/env python
from __future__ import with_statement
# TODO:
# - handle fake ambiguities from [Definition foo] in a comment
# - handle theorems inside proof blocks
# - do the right thing for [Theorem foo. Theorem bar. Proof. Qed. Qed.] (we do the wrong thing right now)
# - ... | parser.add_argument('--no-hide', dest='hide_reg', action='store_const', const=[]) |
Given the following code snippet before the placeholder: <|code_start|> prepare_cmds_for_coq_output_printed_cmd_already.add(sanitize_cmd(cmd_to_print))
kwargs['log']('\nContents:\n%s\n' % contents,
level=kwargs['verbose_base']+1)
return key, file_name, cmds, input_val, cleaner
def reset_co... | set_timeout(coqc_prog, 3 * max((1, int(math.ceil(finish - start)))), **kwargs) |
Given the code snippet: <|code_start|> else:
cmds.extend([file_name, '-q'])
cmd_to_print = '"%s%s"' % ('" "'.join(cmds), pseudocmds)
kwargs['log']('\nRunning command: %s' % cmd_to_print,
level=(kwargs['verbose_base']
- (1 if sanitize_cmd(cmd_to_print) not in... | ((stdout, stderr), returncode) = memory_robust_timeout_Popen_communicate(kwargs['log'], cmds, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, stdin=subprocess.PIPE, timeout=(timeout_val if timeout_val is not None and timeout_val > 0 else None), input=input_val, cwd=cwd) |
Based on the snippet: <|code_start|>from __future__ import with_statement, print_function
__all__ = ["has_error", "get_error_line_number", "get_error_byte_locations", "make_reg_string", "get_coq_output", "get_error_string", "get_timeout", "reset_timeout", "reset_coq_output_cache", "is_timeout"]
ACTUAL_ERROR_REG_STRIN... | p = subprocess.Popen([coqc, "-q", "-d", debug_kind, temp_file_name], stderr=subprocess.STDOUT, stdout=subprocess.PIPE) |
Based on the snippet: <|code_start|>from __future__ import with_statement, print_function
__all__ = ["has_error", "get_error_line_number", "get_error_byte_locations", "make_reg_string", "get_coq_output", "get_error_string", "get_timeout", "reset_timeout", "reset_coq_output_cache", "is_timeout"]
ACTUAL_ERROR_REG_STRIN... | DEFAULT_ERROR_REG_STRING_WITH_BYTES = DEFAULT_PRE_ERROR_REG_STRING_WITH_BYTES + '((?:.|\n)+)' |
Predict the next line for this snippet: <|code_start|> pseudocmds = '" < "%s' % file_name
else:
cmds.extend(['-load-vernac-source', file_name_root, '-q'])
else:
cmds.extend([file_name, '-q'])
cmd_to_print = '"%s%s"' % ('" "'.join(cmds), pseudocmds)
kwargs['log']('\nRun... | return COQ_OUTPUT[key][1] |
Using the snippet: <|code_start|># file)
__all__ = ["get_proof_term_works_with_time", "get_ltac_support_snippet"]
def get_proof_term_works_with_time(coqc_prog, **kwargs):
contents = r"""Lemma foo : forall _ : Type, Type.
Proof (fun x => x)."""
output, cmds, retcode, runtime = get_coq_output(coqc_prog, ('-time... | return (before, after) |
Given the following code snippet before the placeholder: <|code_start|># file)
__all__ = ["get_proof_term_works_with_time", "get_ltac_support_snippet"]
def get_proof_term_works_with_time(coqc_prog, **kwargs):
contents = r"""Lemma foo : forall _ : Type, Type.
Proof (fun x => x)."""
output, cmds, retcode, runti... | return (before, after) |
Here is a snippet: <|code_start|> backup(file_name, ext=backup_ext)
backed_up = True
except IOError as e:
print('Warning: f.write(%s) failed with %s\nTrying again in 10s' % (file_name, repr(e)))
time.sleep(10)
written = False
while not written:
... | if file_name in FILE_CACHE.keys() and os.stat(file_name).st_mtime == FILE_CACHE[file_name][0]: |
Here is a snippet: <|code_start|>parser.add_argument('--quiet', '-q', dest='quiet',
action='count',
help='the inverse of --verbose')
parser.add_argument('--log-file', '-l', dest='log_files', nargs='*', type=argparse.FileType('w'),
default=[sys.stderr],
... | try: |
Next line prediction: <|code_start|> if f(arg[start:end]) == GOOD:
orig_end = end
return arg[start:orig_end]
@memoize
def check_grep_for(in_str, search_for):
# print("echo %s | grep -q %s" % (repr(in_str), repr(search_for)))
p = subprocess.Popen(["timeout", "0.5s", "grep", search_for], u... | p.communicate(input=b(sys.argv[1])) |
Given snippet: <|code_start|>from __future__ import print_function
__all__ = ["has_dir_binding", "deduplicate_trailing_dir_bindings", "process_maybe_list"]
def topname_of_filename(file_name):
return os.path.splitext(os.path.basename(file_name))[0].replace('-', '_DASH_')
def has_dir_binding(args, coqc_help, file_... | if coq_accepts_top or binding[0] != '-top': |
Using the snippet: <|code_start|>from __future__ import print_function
__all__ = ["has_dir_binding", "deduplicate_trailing_dir_bindings", "process_maybe_list"]
def topname_of_filename(file_name):
return os.path.splitext(os.path.basename(file_name))[0].replace('-', '_DASH_')
def has_dir_binding(args, coqc_help, f... | ret = [] |
Given the following code snippet before the placeholder: <|code_start|>from __future__ import division
__all__ = ["run_binary_search"]
@memoize
def apply_as_many_times_as_possible(f, x):
if x is None: return None
fx = apply_as_many_times_as_possible(f, f(x))
if fx is None: return x
return fx
def make... | init = step(init) |
Here is a snippet: <|code_start|>
__all__ = ["join_definitions", "split_statements_to_definitions"]
DEFAULT_VERBOSITY=1
def DEFAULT_LOG(text, level=DEFAULT_VERBOSITY):
if level <= DEFAULT_VERBOSITY:
print(text)
def get_all_nowait_iter(q):
try:
<|code_end|>
. Write the next line using the current file... | while True: |
Using the snippet: <|code_start|>
__all__ = ["join_definitions", "split_statements_to_definitions"]
DEFAULT_VERBOSITY=1
def DEFAULT_LOG(text, level=DEFAULT_VERBOSITY):
if level <= DEFAULT_VERBOSITY:
print(text)
def get_all_nowait_iter(q):
try:
while True:
yield q.get_nowait()
... | return val |
Continue the code snippet: <|code_start|> cur_name, line_num1, cur_definition_names, line_num2, unknown = prompt_reg.search(stderr).groups()
definitions_removed, definitions_shared, definitions_added = get_definitions_diff(last_definitions, cur_definition_names)
# first, to be on the... | else: |
Given snippet: <|code_start|># 'times': <a list of times for each statement>
# 'output': <a string of the response from coqtop>
# }"""
# p = Popen_async([coqtop, '-q', '-emacs', '-time'], stdout=PIPE, stderr=STDOUT, stdin=PIPE)
# time.sleep(1)
def split_statements_to_definitions(statements, log=DEFAU... | p.stdin.write(statement + '\n\n') |
Given the following code snippet before the placeholder: <|code_start|>
__all__ = ["split_coq_file_contents", "split_coq_file_contents_with_comments", "get_coq_statement_byte_ranges", "UnsupportedCoqVersionError", "postprocess_split_proof_term", "split_leading_comments_and_whitespace"]
def fill_kwargs(kwargs):
ret... | if i.count('"') % 2 != 0: |
Predict the next line for this snippet: <|code_start|> cur = ''.join(curs) if curs else None
if cur is not None and is_genuine_ending(cur) and comment_level == 0: # clear out cur, if we're done with it
yield cur
cur = None
if cur is not None:
print(... | return list(split_merge_comments(merge_quotations(statements, sp=''))) |
Based on the snippet: <|code_start|> return ret
class UnsupportedCoqVersionError(Exception):
pass
def merge_quotations(statements, sp=' '):
"""If there are an odd number of "s in a statement, assume that we
broke the middle of a string. We recombine that string."""
cur = None
for i in stateme... | yield first |
Based on the snippet: <|code_start|> else:
comment_level += i2.count('(*') - i2.count('*)')
if cur is None:
cur = i
else:
cur += i
if cur is not None:
curs = list(split_leading_braces(cur))
... | statements = re.split(r'(?<=[^\.]\.\.\.) |(?<=[^\.]\.) ', |
Here is a snippet: <|code_start|>#!/usr/bin/env python2
from __future__ import with_statement
SCRIPT_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
parser = argparse.ArgumentParser(description='Move various statements out of proof blocks')
parser.add_argument('input_files', metavar='INFILE', nargs='+', type=... | r'|Let|Fixpoint|CoFixpoint' + |
Given snippet: <|code_start|>#!/usr/bin/env python2
from __future__ import with_statement
SCRIPT_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
parser = argparse.ArgumentParser(description='Move various statements out of proof blocks')
parser.add_argument('input_files', metavar='INFILE', nargs='+', type=str,... | ONELINE_DEFINITIONS_REG = re.compile(r'^\s*(?:(?:Global|Local|Polymorphic|Monomorphic|Time|Timeout)\s+)?(?:' + |
Based on the snippet: <|code_start|>
class PackageController:
user_dir = None
def __init__(self):
sublime_dir = os.path.dirname(sublime.packages_path())
installed_packages_dir = os.path.join(sublime_dir, 'Installed Packages')
packages_dir = os.path.join(sublime_dir, 'Packages')
... | self.package_control = PackageManager() |
Given snippet: <|code_start|> shutil.copyfileobj(templ, target)
target.close()
else:
template_path = "%s/%s" % (sublimious_dir, "templates/.sublimious")
shutil.copyfile(template_path, config_path)
print("[sublimious] no config found... | settings = eval(open(layer_settings_file, 'r').read()) |
Predict the next line after this snippet: <|code_start|> self.commands = []
self.collected_config = {}
self.user_config = {}
self.is_zip = False
self.zip_file = None
if "sublime-package" in sublimious_dir:
self.is_zip = True
self.zip_file = zipfile... | layer_init = __import__("layers.%s.layer" % layer, globals(), locals(), ['Layer']) |
Predict the next line for this snippet: <|code_start|> mu: int,
i_50: float,
tissue_correction: float,
m_reference_adjusted=None):
super().__init__(temp=temp, press=press, chamber=chamber, n_dw=n_dw, p_elec=p_elec,
volta... | def dose_mu_dref(self) -> float: |
Next line prediction: <|code_start|> cone: str,
mu: int,
i_50: float,
tissue_correction: float,
m_reference_adjusted=None):
super().__init__(temp=temp, press=press, chamber=chamber, n_dw=n_dw, p_elec=p_elec,
... | @property |
Given snippet: <|code_start|> cone: str,
mu: int,
i_50: float,
tissue_correction: float,
m_reference_adjusted=None):
super().__init__(temp=temp, press=press, chamber=chamber, n_dw=n_dw, p_elec=p_elec,
vo... | @property |
Given the code snippet: <|code_start|> mu: int,
i_50: float,
tissue_correction: float,
m_reference_adjusted=None):
super().__init__(temp=temp, press=press, chamber=chamber, n_dw=n_dw, p_elec=p_elec,
voltage_reference=vol... | def dose_mu_dref(self) -> float: |
Predict the next line for this snippet: <|code_start|> m_opposite: NumberOrArray,
m_reduced: NumberOrArray,
cone: str,
mu: int,
i_50: float,
tissue_correction: float,
m_reference_adjusted=None):
... | return kq_electron(chamber=self.chamber, r_50=self.r_50) |
Given the code snippet: <|code_start|> bb_shift_vector = Vector(x=0.3, y=-0.2, z=0.3)
class KatyiX2(WinstonLutzMixin, TestCase):
file_path = ['Katy iX', '2.zip']
num_images = 17
gantry_iso_size = 0.9
collimator_iso_size = 0.8
couch_iso_size = 1.5
cax2bb_max_distance = 1.1
cax2bb_median_... | couch_iso_size = 1.3 |
Next line prediction: <|code_start|>
class KatyTB2(WinstonLutzMixin, TestCase):
file_path = ['Katy TB', '2.zip']
num_images = 17
gantry_iso_size = 1
collimator_iso_size = 0.7
couch_iso_size = 0.7
cax2bb_max_distance = 1.1
cax2bb_median_distance = 0.4
bb_shift_vector = Vector(x=0.0, y=-0... | couch_iso_size = 0.3 |
Using the snippet: <|code_start|> assert c == co
assert ro == 355
g = 355
c = 355
r = 355
go, co, ro = convert(input_scale=MachineScale.IEC61217, output_scale=MachineScale.VARIAN_IEC, gantry=g, collimator=c, rotation=r)
assert g == go
assert c == co
assert ro == 5
def test_varian_i... | def test_iec_to_varian_standard(): |
Continue the code snippet: <|code_start|>
def test_iec_to_iec():
# should return the same values
g = 5
c = 5
r = 5
go, co, ro = convert(input_scale=MachineScale.IEC61217, output_scale=MachineScale.IEC61217, gantry=g, collimator=c, rotation=r)
assert g == go
assert c == co
assert r == ro... | r = 5 |
Predict the next line for this snippet: <|code_start|>
class TestMTF(unittest.TestCase):
def test_normal_mtf(self):
pair_units = (0.1, 0.2, 0.3)
maxs = (500, 300, 100)
mins = (25, 50, 75)
m = MTF(pair_units, maxs, mins)
rm = m.relative_resolution(x=50)
self.assert... | rm = m.relative_resolution(x=90) |
Continue the code snippet: <|code_start|># Copyright 2011 Fred Hatfull
#
# This file is part of Partify.
#
# Partify is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at yo... | idle_event_queue = Queue() |
Given snippet: <|code_start|>
@app.before_request
def load_viewer():
g.viewer = get_viewer_session()
if g.viewer and sentry:
sentry.user_context({
'id': g.viewer.account.id,
'username': g.viewer.account.screen_name,
<|code_end|>
, continue by predicting the next line. Co... | 'service': g.viewer.account.service |
Continue the code snippet: <|code_start|>
@app.before_request
def load_viewer():
g.viewer = get_viewer_session()
if g.viewer and sentry:
sentry.user_context({
'id': g.viewer.account.id,
'username': g.viewer.account.screen_name,
'service': g.viewer.account... | def touch_viewer(resp): |
Given the code snippet: <|code_start|> 'service': g.viewer.account.service
})
@app.context_processor
def inject_version():
v = version.get_versions()
return dict(
version=v['version'],
repo_url=libforget.version.url_for_version(v),
)
@app.context_pr... | def not_found(e): |
Continue the code snippet: <|code_start|>
@app.before_request
def load_viewer():
g.viewer = get_viewer_session()
if g.viewer and sentry:
sentry.user_context({
'id': g.viewer.account.id,
'username': g.viewer.account.screen_name,
'service': g.viewer.account... | return dict( |
Based on the snippet: <|code_start|>
@app.before_request
def load_viewer():
g.viewer = get_viewer_session()
if g.viewer and sentry:
sentry.user_context({
'id': g.viewer.account.id,
'username': g.viewer.account.screen_name,
'service': g.viewer.account.serv... | repo_url=libforget.version.url_for_version(v), |
Next line prediction: <|code_start|>
if 'CELERY_BROKER' not in app.config:
uri = app.config['REDIS_URI']
if uri.startswith('unix://'):
uri = uri.replace('unix', 'redis+socket', 1)
app.config['CELERY_BROKER'] = uri
sentry = None
if 'SENTRY_DSN' in app.config:
app.config['SENTRY_CONFIG']['release... | csp += "script-src 'self' https://cdn.ravenjs.com/;" |
Here is a snippet: <|code_start|>
class TimestampMixin(object):
created_at = db.Column(
db.DateTime(timezone=True), server_default=db.func.now(),
nullable=False)
updated_at = db.Column(
db.DateTime(timezone=True), server_default=db.func.now(),
onupdate=db.func.n... | return self.id.split(":")[0] |
Continue the code snippet: <|code_start|>
# pylint: disable=R0201
@db.validates('policy_keep_latest')
def validate_empty_string_is_zero(self, key, value):
if isinstance(value, str) and value.strip() == '':
return 0
return value
@db.validates('policy_enabled')
def on_poli... | return Post.query.with_parent(self, 'posts').count() |
Here is a snippet: <|code_start|> def significand(self, value):
if isinstance(value, str) and value.strip() == '':
value = 0
try:
value = int(value)
if not value >= 0:
raise ValueError(value)
except ValueErro... | value = abs(interval) // scale |
Using the snippet: <|code_start|>
assert app
assert routes
assert routes.misc
<|code_end|>
, determine the next line of code. You have imports:
from app import app
import routes
import routes.misc
import routes.api
and context (class names, function names, or code) available:
# Path: app.py
# def inject_static():
# ... | assert routes.api |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
def findGeoIPDB():
dbs = [Settings.value(Settings.GEOIP2DB_LOCATION),
os.path.join(os.getcwd(), 'GeoLite2-City.mmdb'),
packagePathJoin('GeoLite2-City.mmdb'),
os.path.join(os.getcwd(), 'GeoLite2-Country.mmdb'),
... | 'zipcode': ''} |
Here is a snippet: <|code_start|> os.path.join(os.getcwd(), 'GeoLite2-City.mmdb'),
packagePathJoin('GeoLite2-City.mmdb'),
os.path.join(os.getcwd(), 'GeoLite2-Country.mmdb'),
packagePathJoin('GeoLite2-Country.mmdb')]
for db in dbs:
if db and os.path.isfile(db):
... | def geolookup(ip): |
Using the snippet: <|code_start|>_loggerInitialzed = False
def logdebug():
global _loggerInitialzed
if not _loggerInitialzed:
_loggerInitialzed = True
loggerInit()
return logging.getLogger('GGPODebug')
def loguser():
global _loggerInitialzed
if not _loggerInitialzed:
_log... | debuglog.addHandler(fh) |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
def readLocalJsonDigest():
localJsonDigest = {}
d = findUnsupportedGamesavesDir()
if d:
localjson = os.path.join(d, SyncWorker.JSON_INDEX_FILENAME)
if os.path.isfile(localjson):
# noinspection PyBroad... | localJsonDigest = {} |
Given snippet: <|code_start|> else:
self.added += 1
if not self.checkonly:
time.sleep(0.05)
localfile = os.path.join(d, filename)
fileurl = self.SAVESTATES_GITHUB_BASE_URL + urllib.quote(filename)
... | cls.run(True, statusMsgCallback, finishedCallback) |
Here is a snippet: <|code_start|># -*- coding: utf-8 -*-
class Backend(object):
__metaclass__ = abc.ABCMeta
def __init__(self):
pass
@staticmethod
def wavfile():
filename = Settings.value(Settings.CUSTOM_CHALLENGE_SOUND_LOCATION)
if filename and os.path.isfile(filename):
... | class NullBackend(Backend): |
Next line prediction: <|code_start|> '666699',
'FF9900',
'99CC00',
'339966',
'33CCCC',
'3366FF',
'800080',
'FF00FF',
'00CCFF',
'993... | 'FFFF99', |
Given the following code snippet before the placeholder: <|code_start|> self.data = iface.DataInterface({"slots": [999999, 4, 2, 1]})
singleCaster = MockClasses([5], ['full'])
mixedCaster = MockClasses([1, 0], ['full', ''])
multiCaster = MockClasses([1, 1], ['full', 'full'])
self.... | slots.regain(2) |
Predict the next line for this snippet: <|code_start|>
class Settings:
def __init__(self, jf: JsonInterface):
self.record = jf
@property
def healing(self) -> 'HealingMode':
return self.record.get('/HEALING') or HealingMode.VANILLA
@healing.setter
def healing(self, value: 'HealingMo... | rv = {} |
Using the snippet: <|code_start|> LIGHT_ARMOR: [EquipmentSlot.CLOTHES, EquipmentSlot.PANTS],
MEDIUM_ARMOR: [EquipmentSlot.CLOTHES, EquipmentSlot.PANTS],
HEAVY_ARMOR: [EquipmentSlot.CLOTHES, EquipmentSlot.PANTS],
CLOTHES: [EquipmentSlot.CLOTHES, EquipmentSlot.PANTS],
HEADWEAR: [Equ... | @property |
Given the code snippet: <|code_start|> for name in jf.get('/')}
def __getitem__(self, item: str) -> 'ItemEntry':
return self.entries[item]
def __iter__(self):
yield from self.entries.values()
def add(self, name: str, quantity=1, type='item', equipped=None):
... | if item.quantity < 1: |
Given the code snippet: <|code_start|> if item.quantity < 1:
self.record.delete('/' + name)
class OwnedInventory(Inventory):
def __init__(self, jf: DataInterface, character: 'char.Character'):
super().__init__(jf)
self.owner = character
@property
def encumbrance... | try: |
Predict the next line for this snippet: <|code_start|>
class Race:
def __init__(self, jf: JsonInterface):
spec = jf.get('/')
file = 'race/{}.race'.format(spec['base'])
self.interface = JsonInterface(file, readonly=True)
self.name = spec['base']
if 'subrace' in spec:
... | self.subrace = Subrace(sub) |
Given the code snippet: <|code_start|>
class Item:
def __init__(self, name: str, spec: dict):
types = spec['type'].split()
fmt = '{}/{}.{}'
filename = fmt.format(types[-1], sanitize_filename(name), '.'.join(types))
self.record = JsonInterface(filename, readonly=True)
self.na... | self.weight = self.record.get('/weight') |
Predict the next line after this snippet: <|code_start|> self.record.set('/current', value)
else:
raise TypeError('Trying to set HP to not a number')
@property
def max(self):
return self.baseMax + self.bonusMax
@property
def baseMax(self):
return self... | self.record.set('/bonusMax', value) |
Given the following code snippet before the placeholder: <|code_start|> self.record.set('/current', value)
else:
raise TypeError('Trying to set HP to not a number')
@property
def max(self):
return self.baseMax + self.bonusMax
@property
def baseMax(self):
... | self.record.set('/bonusMax', value) |
Next line prediction: <|code_start|>
class HP:
def __init__(self, jf: DataInterface):
self.record = jf
@property
def current(self):
return self.record.get('/current') or 0
@current.setter
def current(self, value):
if isinstance(value, int):
if value < 0:
... | else: |
Predict the next line for this snippet: <|code_start|>
def parse_one(elem: Tag) -> dict:
data = {
'name': elem.find('name').text.rstrip('()ESCAG '),
'level': int(elem.level.text),
<|code_end|>
with the help of current file imports:
import json
import re
from pathlib import Path
from typing impo... | 'school': parse_school(elem.school.text), |
Given snippet: <|code_start|> def test_set(self):
inter = interface.DataInterface(self.data)
inter.set('/dict/a', 'New A')
self.assertEqual(self.data['dict']['a'], 'New A')
inter.set('/dict', 'a dict no longer')
self.assertEqual(self.data['dict'], 'a dict no longer')
i... | second = first.cd('/multiple') |
Given snippet: <|code_start|>
class Spell:
def __init__(self, jf: JsonInterface):
self.record = jf
self.name: str = jf.get('/name')
self.level: int = jf.get('/level')
self.effect: str = jf.get('/effect')
self.classes: Set[str] = set(jf.get('/class'))
self.castingTim... | available = character.classes.spells_available |
Using the snippet: <|code_start|>
class Skill:
def __init__(self, name: str, ability: abil.Ability):
self.name = name
self.ability = ability
def roll(self, advantage=False, disadvantage=False, lucky=False):
d20 = d20_roll(advantage, disadvantage, lucky)
return basic(d20, modif... | pass |
Predict the next line for this snippet: <|code_start|>
class Resource:
def __init__(self, jf: Optional[DataInterface], definition: DataInterface = None):
self.record = jf
self.definition = definition or jf
self.recharge = RestLength.from_string(self.definition.get('/recharge'))
se... | self.record.set('/maxnumber', value) |
Using the snippet: <|code_start|>
@number.setter
def number(self, value):
self.record.set('/number', value)
@property
def maxnumber(self):
return self.record.get('/maxnumber') or self.definition.get('/maxnumber')
@maxnumber.setter
def maxnumber(self, value):
self.record... | def reset(self): |
Continue the code snippet: <|code_start|> self.value = self.definition.get('/value')
self.name = self.definition.get('/name')
@property
def number(self):
return self.record.get('/number')
@number.setter
def number(self, value):
self.record.set('/number', value)
@pro... | def regain(self, number): |
Continue the code snippet: <|code_start|>
class SpellResource:
def __init__(self, jf: DataInterface):
self.record = jf
def cast(self, level: int):
raise NotImplementedError
def regain(self, level: int):
raise NotImplementedError
def reset(self):
<|code_end|>
. Use current fi... | raise NotImplementedError |
Given the following code snippet before the placeholder: <|code_start|>
__doc__ = """
The zsys class provides miscellaneous functions. Only a limited set of
functions are exposed from the czmq zsys module as many duplicate
<|code_end|>
, predict the next line using imports from the current file:
from pyczmq._cffi impo... | functionality of built-in python types or libraries. |
Here is a snippet: <|code_start|>
__doc__ = """
The zloop class provides an event-driven reactor pattern. The reactor
handles zmq_pollitem_t items (pollers or writers, sockets or fds), and
<|code_end|>
. Write the next line using the current file imports:
from pyczmq._cffi import ffi, C, ptop, cdef
and context from o... | once-off or repeated timers. Its resolution is 1 msec. It uses a |
Here is a snippet: <|code_start|>from __future__ import print_function
__doc__ = """
The zframe class provides methods to send and receive single message
frames across 0MQ sockets. A frame corresponds to one zmq_msg_t. When
you read a frame from a socket, the zframe_more() method indicates if
the frame is part of an u... | method normally destroys the frame, but with the ZFRAME_REUSE flag, |
Based on the snippet: <|code_start|>from __future__ import print_function
__doc__ = """
The zframe class provides methods to send and receive single message
frames across 0MQ sockets. A frame corresponds to one zmq_msg_t. When
you read a frame from a socket, the zframe_more() method indicates if
<|code_end|>
, predict... | the frame is part of an unfinished multipart message. The zframe_send |
Given the following code snippet before the placeholder: <|code_start|>from __future__ import print_function
__doc__ = """
The zframe class provides methods to send and receive single message
frames across 0MQ sockets. A frame corresponds to one zmq_msg_t. When
you read a frame from a socket, the zframe_more() method ... | class has no special support for text data. |
Continue the code snippet: <|code_start|>
def test_zmq():
version = zmq.version()
assert version
<|code_end|>
. Use current file imports:
from pyczmq import zmq
and context (classes, functions, or code) from other files:
# Path: pyczmq/zmq.py
# IO_THREADS = 1
# MAX_SOCKETS = 2
# IO_THREADS_DFLT = 1
# MAX_SO... | assert len(version) == 3 |
Given the code snippet: <|code_start|> void zsocket_set_plain_password (void *zocket, const char * plain_password);
void zsocket_set_curve_server (void *zocket, int curve_server);
void zsocket_set_curve_publickey (void *zocket, const char * curve_publickey);
void zsocket_set_curve_publickey_bin (void *zocket, const ... | void zsocket_set_tcp_keepalive_cnt (void *zocket, int tcp_keepalive_cnt); |
Next line prediction: <|code_start|> int zsocket_sndbuf (void *zocket);
int zsocket_rcvbuf (void *zocket);
int zsocket_linger (void *zocket);
int zsocket_reconnect_ivl (void *zocket);
int zsocket_reconnect_ivl_max (void *zocket);
int zsocket_backlog (void *zocket);
int zsocket_maxmsgsize (void *zocket);
int zsoc... | void zsocket_set_conflate (void *zocket, int conflate); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.