Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Predict the next line for this snippet: <|code_start|>
__all__ = [
'Zorrolet',
'Hub',
'gethub',
'Future',
'Condition',
'Lock',
]
FUTURE_EXCEPTION = marker_object('FUTURE_EXCEPTION')
FUTURE_PENDING = marker_object('FUTURE_PENDING')
<|code_end|>
with the help of current file imports:
imp... | os_errors = (IOError, OSError) |
Here is a snippet: <|code_start|>
__all__ = [
'Zorrolet',
'Hub',
'gethub',
'Future',
'Condition',
<|code_end|>
. Write the next line using the current file imports:
import heapq
import time
import threading
import select
import weakref
import logging
import errno
import greenlet
from collections ... | 'Lock', |
Using the snippet: <|code_start|>
__all__ = [
'Zorrolet',
'Hub',
'gethub',
'Future',
'Condition',
'Lock',
]
FUTURE_EXCEPTION = marker_object('FUTURE_EXCEPTION')
FUTURE_PENDING = marker_object('FUTURE_PENDING')
os_errors = (IOError, OSError)
class TimeoutError(Exception):
pass
<|c... | class WaitingError(Exception): |
Given snippet: <|code_start|> def setUp(self):
super().setUp()
def collectd_putval(self):
self.z.sleep(0.1)
sock = self.z.collectd.Connection(unixsock=TEST_SOCKET)
self.assertEqual((bytearray(b'0 Success'),),
sock.putval('test/test/test', [('123', '256')], time=1234))... | b'PUTNOTIF message="hello" severity=warning time=1234') |
Next line prediction: <|code_start|>
def make_request(self):
sock = self.z.zmq.req_socket()
sock.connect('tcp://127.0.0.1:9999')
self.assertEqual(sock.request([b"hello", b"world"]).get(),
[b"world", b"hello"])
self.assertEqual(sock.request([b"abra", b"kadabra"]).get(),
... | self.pub = self.z.zmq.pub_socket() |
Continue the code snippet: <|code_start|> [b"kadabra", b"abra"])
@interactive(make_request)
def test_req(self):
ctx = zmq.Context(1)
sock = ctx.socket(zmq.REP)
sock.bind('tcp://127.0.0.1:9999')
data = sock.recv_multipart()
sock.send_multipart(list(reversed(dat... | self.pub2.connect('tcp://127.0.0.1:9998') |
Continue the code snippet: <|code_start|> b'1_end',
b'2_end',
b'3_start',
b'4_start',
b'3_end',
b'4_end',
])
def subscriber(self, name, time):
self.data.append(name+b'_start')
if float(time) > 0.15:
with ... | sock.send_multipart([b'1', b"0.1"]) |
Predict the next line for this snippet: <|code_start|> except TypeError:
pass
#------------------------------------------------------------------------------
to_string_converters = {
int: str,
float: str,
str: str,
list: list_to_str,
tuple: list_to_str,
bool: lambda x: 'True... | return to_string_converters[type(a_thing)](a_thing) |
Predict the next line for this snippet: <|code_start|> into "subject_key, function -> function_key, etc."""
# is it None?
if a_thing is None:
return ''
# is it already a string?
if isinstance(a_thing, six.string_types):
return a_thing
if six.PY3 and isinstance(a_thing, six.binary_... | return known_mapping_type_to_str[a_thing] |
Continue the code snippet: <|code_start|> .strip('.')
)
else:
module_name = a_thing.__module__
return "%s.%s" % (module_name, a_thing.__name__)
except AttributeError:
# nope, not one of these
pass
# maybe it has a __name_... | def py3_to_str(a_bytes): |
Continue the code snippet: <|code_start|> return a_bytes.decode('utf-8')
#------------------------------------------------------------------------------
known_mapping_type_to_str = {}
for key, val in sorted(builtins.__dict__.items()):
if val not in (True, False, list, dict):
try:
known_mappi... | to_string_converters[six.text_type] = py2_to_str |
Continue the code snippet: <|code_start|> # does it have a to_str function?
try:
return a_thing.to_str()
except (AttributeError, KeyError, TypeError):
# AttributeError - no to_str function?
# KeyError - DotDict has no to_str?
# TypeError - problem converting
# nope, no... | .strip('.') |
Continue the code snippet: <|code_start|> datetime.date: date_converter,
datetime.timedelta: timedelta_converter,
type: class_converter,
types.FunctionType: class_converter,
compiled_regexp_type: regex_converter,
}
if six.PY2:
str_to_instance_of_type_converters[six.text_type] = py2_to_unicode
if ... | pass |
Given snippet: <|code_start|># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, division, print_function
def setup_definitions(sou... | json_dict = json.loads(source) |
Based on the snippet: <|code_start|> namespace.alpha = 1
my_birthday = datetime.datetime(1960, 5, 4, 15, 10)
namespace.beta = my_birthday
self.assertEqual(namespace.alpha.name, 'alpha')
self.assertEqual(namespace.alpha.doc, None)
self.assertEqual(namespace.alpha.default, 1... | ) |
Given the code snippet: <|code_start|> self.assertEqual(b.counter, 10)
#--------------------------------------------------------------------------
def test_memoize_class_method(self):
class A(object):
counter = 0
@classmethod
@memoize()
def foo(k... | A.counter += 1 |
Predict the next line for this snippet: <|code_start|> assert 'c' not in d.a.b
d = DotDict()
d['a.b.c'] = 8
del d.a
assert 'a' not in d
"""
key_split = key.split('.')
current = self
for k in key_split[:-1]:
current = geta... | namespaces = [] |
Using the snippet: <|code_start|># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, division, print_function
#------------------... | if key.startswith('__'): |
Predict the next line for this snippet: <|code_start|> else:
self.add_msg = add_msg
class cls_pilconfig:
#
# initialize: create instance
#
def __init__(self):
self.__config__= { }
self.__userconfig__ = None
return
#
# open: read in the configuration file into the dictionary
# i... | def get(self,name,param,default=None): |
Continue the code snippet: <|code_start|># - class statement syntax update
# 17.09.2016 jsi:
# - open method introduced
# 14.10.2016 jsi:
# - added filename parameter to cls_userconfig
# 17.08.2017 jsi:
# - assign "" to self.add_msg if parameter is none in PilConfigError
# 20.01.2018 jsi
# - added get_dual method
# 12.... | self.__config__= { } |
Based on the snippet: <|code_start|> t=get_finfo_type(ft)[0]
l= getLifInt(e,16,4)*256
# HP-75 ROM
elif ft== 0xE08B:
t=get_finfo_type(ft)[0]
l= getLifInt(e,16,4)*256
# other ...
else:
t= "0x{:4X}".format(ft)
l= getLifInt(e,16,4)* 256
return [... | self.isWindows= True |
Given snippet: <|code_start|> self.screen[pos:pos + len(s)] = s
def fill(self, y0, x0, y1, x1, char):
n = self.w * (y1 - y0 - 1) + (x1 - x0)
self.poke(y0, x0, array.array('i', [char] * n))
def clear(self, y0, x0, y1, x1):
self.fill(y0, x0, y1, x1, CHAR_ATTRIB_NONE | 0x20)
#
# ... | if self.linelength[cy]==-1: |
Given the following code snippet before the placeholder: <|code_start|> if item == CHAR_ATTRIB_UNDERLINE_SHORT:
self._font.setUnderline(True)
y += self._char_height
#
# add selection area to scene
#
cursor_in_selection= False
if start_row is not None:
#
#... | self._cursorItem= TermCursor(self._char_width,self._char_height,self._cursortype, cursor_foreground_color) |
Next line prediction: <|code_start|>#
# enable: start update timer (one shot timer)
#
def enable(self):
self.UpdateTimer.start(UPDATE_TIMER)
pass
#
# disable: do nothing
#
def disable(self):
pass
#
# Terminal window was resized, update display and scrollbar
#
def resize_rows(self,... | self.win.scrollbar.setPageStep(self.view_h) |
Predict the next line after this snippet: <|code_start|> self.terminalwidget.setHPTerminal(self.HPTerminal)
#
# initialize scrollbar
#
self.scrollbar.valueChanged.connect(self.do_scrollbar)
self.scrollbar.setEnabled(False)
#
# enable/disable
#
def enable(self):
self.scroll... | def do_scrollbar(self): |
Given the code snippet: <|code_start|> def __init__(self,parent,name,tabwidget):
super().__init__(parent)
#
# initialize Variables
#
self._name= name # name of tab
self._tabwidget=tabwidget # widget of tab
self._cols= -1 # terminal config, initial... | self._isVisible= False # visible state |
Based on the snippet: <|code_start|> self.linewrapped[cy-1]=True
self.linelength[cy]=-1
self.linewrapped[cy]=False
#
# remove wrapped part of a line, cy must be in the non wrapped part
#
def remove_wrapped_part(self,cy):
self.linewrapped[cy]=False
self.linelength[cy+1]=0
s... | def scroll_line_right(self, y, x): |
Predict the next line for this snippet: <|code_start|> self._HPTerminal.selectionStop()
self._selectionText=""
self._press_pos = event.pos()
if not self._HPTerminal.selectionStart(self._press_pos,self._true_w, self._char_height):
self._press_pos = None
#
# ... | if mode != self._autoscrollMode: |
Predict the next line after this snippet: <|code_start|> self.actual_h+=1
self.update_scrollbar()
return(newcy)
#
# remove buffer line
#
def remove_bufferline(self,cy):
newcy= cy-1
self.actual_h= newcy
self.update_scrollbar()
return(newcy)
#
# Update scroll bar ... | def cursor_up(self): |
Predict the next line for this snippet: <|code_start|>#
# keyboard pressed event, process keys and put them into the HP-IL outdata buffer
#
def keyPressEvent(self, event):
if self._kbdfunc is None:
event.accept()
return
if event.isAutoRepeat():
if self.isAutorepeat... | self._ctrl_modifier=True |
Continue the code snippet: <|code_start|>#
def set_charset(self,charset):
self.HPTerminal.set_charset(charset)
#
# set keyboard type
#
def set_keyboardtype(self,t):
self.terminalwidget.set_keyboardtype(t)
#
# tab becomes visible, call appropriate methods to:
# - stop cursor blink
# - dis... | self.HPTerminal.out_terminal(t) |
Given snippet: <|code_start|> return
self.inhibitAutorepeat()
text = event.text()
key = event.key()
#
# handle modifier keys first
#
if key == QtCore.Qt.Key_Alt:
self._alt_modifier= True
self._modifier_flags= self._modifier_flags | KEYBOARD_ALT
... | if key >= QtCore.Qt.Key_0 and key <= QtCore.Qt.Key_9: |
Given snippet: <|code_start|> def ctrl_CR(self):
if self.is_wrapped(self.cy) and self.in_wrapped_part(self.cy):
self.cy-=1
self.cursor_set_x(0)
#
# Dumb echo, if we exceed the wrapped part then issue a CR/LF
#
def dumb_echo(self, char):
# print("dumb_echo ",char)
if sel... | def dump(self): |
Predict the next line for this snippet: <|code_start|> self._cols, self._char_height, self._true_w,
self._cursor_color)
selectAreaItem.setPos(0,start_row* self._char_height)
self._scene.addItem(selectAreaItem)
#
# add cursor at curso... | self.name=name # name of tab |
Predict the next line after this snippet: <|code_start|># - removed special Mac key lookup
# - update self.actual_h on "delete to end of display"
# 28.01.2019 jsi
# - autorepeat delay improved
# 10.02.2019 jsi
# - disable tab widget switching in terminal widget and enable TAB key for
# keyboard input
# 11.02.2019 js... | CHAR_ATTRIB_INVERSE_SHORT= CHAR_ATTRIB_INVERSE >> 16 |
Here is a snippet: <|code_start|> @staticmethod
def getPenConfig():
dialog= cls_PenConfigWindow()
dialog.resize(650,600)
result= dialog.exec_()
if result== QtWidgets.QDialog.Accepted:
return True
else:
return False
class PenConfigError(Exception):
def __init__(sel... | ["Green 0.3 mm", 0x00,0xff,0x00,0xff,1.0], |
Based on the snippet: <|code_start|>#
self.tablemodel=PenTableModel(PENCONFIG.get_all())
self.tableview= QtWidgets.QTableView()
self.tableview.setModel(self.tablemodel)
self.tableview.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
self.tableview.verticalHeader().set... | def do_reset(self): |
Given the code snippet: <|code_start|> except OSError as e:
raise ConfigError("Cannot write default configuration file", e.strerror)
return default
f=None
try:
f= open(self.__configfile__,"r")
config= json.load(f)
except json.JSONDecodeError as e:
... | finally: |
Given the code snippet: <|code_start|> submenu=QtWidgets.QMenu(option_text,parent=self.menu)
self.menu.addMenu(submenu)
submenu.aboutToShow.connect(functools.partial(self.do_before_show_submenu,n))
k=0
option_actions=[]
for choice in option_choices:
if option_type== T_BOOLEAN... | if self.config_changed==None: |
Based on the snippet: <|code_start|> self.vlayout = QtWidgets.QVBoxLayout()
#
# item list and up/down buttons
#
self.hlayout = QtWidgets.QHBoxLayout()
self.devList = QtWidgets.QListWidget()
self.hlayout.addWidget(self.devList)
self.vlayout2= QtWidgets.QVBoxLayout()
self.buttonUp= ... | self.buttonBox.rejected.connect(self.do_cancel) |
Predict the next line for this snippet: <|code_start|>
class cls_pilbox:
def __init__(self,ttydevice,baudrate,idyframe):
self.__baudrate__= baudrate # baudrate of connection or 0 for autodetect
self.__idyframe__= idyframe # switch box to send idy frames
self.__tty__= cls_rs232() # serial dev... | except TypeError: |
Based on the snippet: <|code_start|>#
# no success with any baud rate, throw exception and exit
#
if not success:
self.__tty__.close()
raise PilBoxError("Cannot connect to PIL-Box", errmsg)
if self.__idyframe__:
self.__sendCmd__(COFI,TMOUTCMD)
#
# Disconnect PIL... | def write(self,lbyt,hbyt=None): |
Here is a snippet: <|code_start|> QtCore.Qt.Key_Semicolon | KEYBOARD_CTRL: [30], # Sterling
QtCore.Qt.Key_8 | KEYBOARD_CTRL: [31], # smear
QtCore.Qt.Key_9 | KEYBOARD_CTRL: [127], # append
QtCore.Qt.Key_0 | KEYBOARD_CTRL: [176], # u... | QtCore.Qt.Key_F4 | KEYBOARD_CTRL | KEYBOARD_SHIFT: [227], # -- |
Based on the snippet: <|code_start|># - text editing for the second column (shortcut text)
# - combo box editing for the third column (shortcut type)
#
class ShortcutDelegate(QtWidgets.QItemDelegate):
def __init__(self, parent=None):
super(ShortcutDelegate, self).__init__(parent)
self.items = ["Input on... | editor.setCurrentIndex(int(text)) |
Next line prediction: <|code_start|> self.tablemodel.setAll(SHORTCUTCONFIG.default_config())
@staticmethod
def getShortcutConfig():
dialog= cls_ShortcutConfigWindow()
dialog.resize(650,600)
result= dialog.exec_()
if result== QtWidgets.QDialog.Accepted:
return True
else... | def default_config(self): |
Based on the snippet: <|code_start|># You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# serial device object class --------------------------------------------
... | def __init__(self,parent=None): |
Given the following code snippet before the placeholder: <|code_start|>sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
headers = u"""
Geography
Climate
Economy
Transport
Education
<|code_end|>
, predict the next line using imports from the current file:
import codecs
import sys
import orm
from wikihead import head... | Demographics |
Based on the snippet: <|code_start|>
indicator_list = """
SP.POP.TOTL
SP.POP.DPND.OL
SP.POP.DPND.YG
SH.DTH.IMRT
SM.POP.TOTL.ZS
AG.LND.TOTL.K2
SP.POP.GROW
EN.POP.DNST
EN.URB.MCTY
NY.GNP.MKTP.CD
SI.POV.DDAY
SP.DYN.AMRT.FE
SP.DYN.AMRT.MA
LP.LPI.OVRL.XQ
IS.ROD.TOTL.KM
IS.RRS.TOTL.KM
NY.GNP.MKTP.PP.CD
<|code_end|>
, predict... | NY.GDP.PCAP.PP.CD |
Next line prediction: <|code_start|>
indicator_list = """
SP.POP.TOTL
SP.POP.DPND.OL
SP.POP.DPND.YG
SH.DTH.IMRT
SM.POP.TOTL.ZS
AG.LND.TOTL.K2
SP.POP.GROW
EN.POP.DNST
EN.URB.MCTY
NY.GNP.MKTP.CD
SI.POV.DDAY
SP.DYN.AMRT.FE
SP.DYN.AMRT.MA
LP.LPI.OVRL.XQ
IS.ROD.TOTL.KM
IS.RRS.TOTL.KM
<|code_end|>
. Use current file imports:... | NY.GNP.MKTP.PP.CD |
Continue the code snippet: <|code_start|>
indicator_list = """
SP.POP.TOTL
SP.POP.DPND.OL
SP.POP.DPND.YG
SH.DTH.IMRT
SM.POP.TOTL.ZS
AG.LND.TOTL.K2
SP.POP.GROW
<|code_end|>
. Use current file imports:
import xypath
import messytables
import orm
import re
import time
import dl
from hamcrest import equal_to, is_in
from o... | EN.POP.DNST |
Given the code snippet: <|code_start|> __tablename__ = "dataset"
dsID = Column(String, primary_key=True)
last_updated = Column(String)
last_scraped = Column(String)
name = Column(String)
def save(self):
session.merge(self)
class Indicator(Base):
__tablename__ = "indicator"
indI... | @atexit.register |
Next line prediction: <|code_start|>
def now():
return datetime.datetime.now().isoformat()
@event.listens_for(Engine, "connect")
def set_sqlite_pragma(dbapi_connection, connection_record):
cursor = dbapi_connection.cursor()
cursor.execute("PRAGMA foreign_keys=ON")
cursor.close()
echo = False
<|code_... | engine = create_engine("sqlite:///ocha.db", echo=echo) |
Given the following code snippet before the placeholder: <|code_start|> self.value = canon_number(self.value)
if self.value is None:
return
assert not self.is_blank()
try:
session.merge(self)
except:
print self.__dict__
r... | session.merge(self) |
Given snippet: <|code_start|>engine = create_engine("sqlite:///ocha.db", echo=echo)
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()
class Value(Base):
__tablename__ = "value"
dsID = Column(String, ForeignKey('dataset.dsID'), primary_key=True)
region = Column(String, prima... | if self.is_number: |
Given the following code snippet before the placeholder: <|code_start|>
rawformdata = '''__Click:85256981006B94CD.d6a31b1f4f85ddbb8525716a0059e321/$Body/0.44EA
%%Surrogate_col3:1
%%Surrogate_col4:1
col4:Fr
%%Surrogate_col6:1
col6:Sp
%%Surrogate_col5:1
col5:Ru
%%Surrogate_col2:1
col2:Ch
%%Surrogate_col1:1
col1:Ar
Query:... | Ar: |
Given snippet: <|code_start|>En:
Ea:
Fr:
Fa:
Sp:
Sa:
Ru:
Ra:
Ch:
Ca:
Ar:
%%Surrogate_MaxResults:1
MaxResults:2500
%%Surrogate_SearchWv:1
SearchWv:1
%%Surrogate_SearchFuzzy:1
%%Surrogate_Sort:1
Sort:1'''
indicators = {"Date of Entry into UN": xypath.RIGHT,
"ISO Country alpha-3-code": xypath.RIGHT,
... | 'last_updated': "", |
Given the following code snippet before the placeholder: <|code_start|>
rawformdata = '''__Click:85256981006B94CD.d6a31b1f4f85ddbb8525716a0059e321/$Body/0.44EA
%%Surrogate_col3:1
%%Surrogate_col4:1
col4:Fr
%%Surrogate_col6:1
col6:Sp
%%Surrogate_col5:1
col5:Ru
%%Surrogate_col2:1
col2:Ch
%%Surrogate_col1:1
col1:Ar
Query:... | Ar: |
Predict the next line after this snippet: <|code_start|>
rawformdata = '''__Click:85256981006B94CD.d6a31b1f4f85ddbb8525716a0059e321/$Body/0.44EA
%%Surrogate_col3:1
%%Surrogate_col4:1
col4:Fr
%%Surrogate_col6:1
col6:Sp
%%Surrogate_col5:1
col5:Ru
%%Surrogate_col2:1
col2:Ch
%%Surrogate_col1:1
col1:Ar
Query:
FTSearch:
%%Su... | Ea: |
Next line prediction: <|code_start|>
urlpatterns = [
url('^create/$', views.Create.as_view(), name='create'),
url('^c:(?P<slug>[-\w]+)/$', views.Detail.as_view(), name='detail'),
url('^$', views.List.as_view(), name='list'),
<|code_end|>
. Use current file imports:
(from django.conf.urls import url
from .... | ] |
Based on the snippet: <|code_start|>
urlpatterns = [
url('^create/$', views.Create.as_view(), name='create'),
url('^trash/$', views.Trash.as_view(), name='trash'),
url('^search/$', views.Search.as_view(), name='search'),
url('^update/(?P<pk>\d+)/$', views.Update.as_view(), name='update'),
url('^del... | ] |
Predict the next line after this snippet: <|code_start|> def get(self, section, option, option_type=str):
"""Try to get option value in section of configuration. Raise
HPCStatsConfigurationException if not found.
"""
try:
if option_type is bool:
return s... | items = self.get_default(section, option, '') |
Based on the snippet: <|code_start|>
"""
logger = logging.getLogger(__name__)
class Cluster(object):
"""Model class for Cluster table"""
def __init__(self, name, cluster_id=None):
self.cluster_id = cluster_id
self.name = name
def __str__(self):
return self.name
def __e... | FROM Cluster |
Given the code snippet: <|code_start|> if self.cluster_id is None:
raise HPCStatsRuntimeError(
"could not search for data with cluster %s since not " \
"found in database" \
% (str(self)))
req = """
SELECT SUM(node... | FROM Job |
Predict the next line for this snippet: <|code_start|># modify it under the terms of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTA... | def setUp(self): |
Given the following code snippet before the placeholder: <|code_start|># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with HPCStats. If not, see
# <http://www.gnu.org/licenses/>.... | self.conf.conf = CONFIG.copy() |
Predict the next line after this snippet: <|code_start|># 1, Avenue du General de Gaulle
# 92140 Clamart
#
# Authors: CCN - HPC <dsp-cspit-ccn-hpc@edf.fr>
#
# This file is part of HPCStats.
#
# HPCStats is free software: you can redistribute in and/or
# modify it under the terms of the GNU General Public Li... | 'option_list': 'john,doe', |
Given the code snippet: <|code_start|> % (str(self)))
req = """
INSERT INTO Userhpc ( userhpc_login,
userhpc_firstname,
userhpc_name,
userhpc_department)
... | UPDATE Userhpc |
Using the snippet: <|code_start|> return None
elif nb_rows > 1:
raise HPCStatsDBIntegrityError(
"several user_id found in DB for user %s" \
% (str(self)))
else:
self.user_id = db.cur.fetchone()[0]
logger.debug("user... | userhpc_department) |
Given snippet: <|code_start|> creation,
deletion
FROM users
WHERE uid = %s
AND cluster = %s; """
data = (
uid,
cluster_name )
cur = self._db.cur
#print cur.mogrify(req, data)
cur.execu... | else: |
Next line prediction: <|code_start|># HPCStats is free software: you can redistribute in and/or
# modify it under the terms of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; withou... | logger.debug("adding error %s to set of ignored errors", error_s) |
Based on the snippet: <|code_start|> fsquota_file_limit,
fsquota_file_in_doubt,
fsquota_file_grace )
VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )
"""
... | AND filesystem_id = %s |
Predict the next line after this snippet: <|code_start|> db.execute(req, params)
nb_rows = db.cur.rowcount
if nb_rows == 0:
logger.debug("fsusage %s not found in DB", str(self))
self.exists = False
elif nb_rows > 1:
raise HPCStatsDBIntegrityError(
... | cluster_id, |
Given the following code snippet before the placeholder: <|code_start|> str(self),
self.job_id )
return self.job_id
def save(self, db):
"""Insert Job in database. You must make sure that the Job does not
already exist in database yet... | job_walltime, |
Next line prediction: <|code_start|> self.end,
self.walltime,
self.account.cluster.cluster_id,
self.account.user.user_id,
project_id,
business_code )
#print db.cur.mogrify(req, params)
db.ex... | job_department = %s, |
Given snippet: <|code_start|> db.execute(req, params)
nb_rows = db.cur.rowcount
if nb_rows == 0:
logger.debug("project %s not found in DB", str(self))
return None
elif nb_rows > 1:
raise HPCStatsDBIntegrityError(
"several project_id ... | project_description, |
Continue the code snippet: <|code_start|> if nb_rows == 0:
logger.debug("project %s not found in DB", str(self))
return None
elif nb_rows > 1:
raise HPCStatsDBIntegrityError(
"several project_id found in DB for project %s" \
% ... | FROM Project |
Given snippet: <|code_start|> db.execute(req, params)
nb_rows = db.cur.rowcount
if nb_rows == 0:
logger.debug("project %s not found in DB", str(self))
return None
elif nb_rows > 1:
raise HPCStatsDBIntegrityError(
"several project_id ... | project_description, |
Given the code snippet: <|code_start|>
if nb_rows == 0:
logger.debug("node %s not found in DB", str(self))
return None
elif nb_rows > 1:
raise HPCStatsDBIntegrityError(
"several node_id found in DB for node %s" \
% (str(self))... | INSERT INTO Node ( node_name, |
Next line prediction: <|code_start|> % (str(self)))
else:
self.node_id = db.cur.fetchone()[0]
logger.debug("node %s found in DB with id %d",
str(self),
self.node_id )
return self.node_id
def save(self... | VALUES ( %s, %s, %s, %s, %s, %s, %s ) |
Here is a snippet: <|code_start|> logger.info("creating business code %s" % str(self))
req = """
INSERT INTO Business ( business_code,
business_description )
VALUES (%s, %s)
"""
params = ( self.code, self.descri... | WHERE business_code = %s |
Using the snippet: <|code_start|>
logger = logging.getLogger(__name__)
class Business(object):
"""Model class for the Business table."""
def __init__(self, code, description):
self.code = code
self.description = description
self.exists = None
def __str__(self):
if self.d... | SELECT business_code |
Given snippet: <|code_start|># Contact:
# CCN - HPC <dsp-cspit-ccn-hpc@edf.fr>
# 1, Avenue du General de Gaulle
# 92140 Clamart
#
# Authors: CCN - HPC <dsp-cspit-ccn-hpc@edf.fr>
#
# This file is part of HPCStats.
#
# HPCStats is free software: you can redistribute in and/or
# modify it under the terms... | 'since_jobid': -1 } |
Based on the snippet: <|code_start|> self.job.job_id )
db.execute(req, params)
nb_rows = db.cur.rowcount
if nb_rows == 0:
logger.debug("run %s not found in DB", str(self))
self.exists = False
elif nb_rows > 1:
raise HPCStatsDBIntegrit... | INSERT INTO Run ( job_id, |
Predict the next line for this snippet: <|code_start|>
logger = logging.getLogger(__name__)
class Run(object):
"""Model class for the Run table."""
def __init__(self, cluster, node, job):
self.cluster = cluster
self.node = node
self.job = job
self.exists = None
def __str... | AND node_id = %s |
Continue the code snippet: <|code_start|> params = ( self.user.user_id,
self.cluster.cluster_id )
db.execute(req, params)
# We know here there is only one result thanks to existing() method
result = db.cur.fetchone()
self.uid = result[0]
self.gid = resul... | cluster_id ) |
Based on the snippet: <|code_start|> if nb_rows == 0:
logger.debug("account %s not found in DB", str(self))
self.exists = False
elif nb_rows > 1:
raise HPCStatsDBIntegrityError(
"several account found in DB for account %s" \
% ... | FROM Account |
Predict the next line after this snippet: <|code_start|> cluster_id )
VALUES ( %s, %s, %s, %s, %s, %s )
"""
params = ( self.uid,
self.gid,
self.creation_date,
self.deletion_date,
... | account_deletion = %s |
Predict the next line after this snippet: <|code_start|> """Set Event end datetime equals to event in parameter end datetime.
"""
self.end_datetime = event.end_datetime
def get_datetime_end_last_event(db, cluster):
"""Returns the end datetime of the last event on the cluster in DB. Returns
... | WHERE cluster_id = %s |
Given snippet: <|code_start|> """Returns the start datetime of the oldest event on the cluster in DB.
Returns None if no unfinished event found.
"""
req = """
SELECT MIN(event_start)
FROM Event
WHERE cluster_id = %s
AND event_end IS NULL
... | AND event_end IS NULL |
Using the snippet: <|code_start|> return None
elif nb_rows > 1:
raise HPCStatsDBIntegrityError(
"several filesystem_id found in DB for filesystem %s" \
% (str(self)))
else:
self.fs_id = db.cur.fetchone()[0]
logger.d... | RETURNING filesystem_id |
Here is a snippet: <|code_start|>class Filesystem(object):
"""Model class for the filesystem table."""
def __init__(self, mountpoint, cluster, fs_id=None):
self.fs_id = fs_id
self.mountpoint = mountpoint
self.cluster = cluster
def __str__(self):
return "filesystem: %s [cl... | FROM filesystem |
Predict the next line after this snippet: <|code_start|> db.execute(req, params)
nb_rows = db.cur.rowcount
if nb_rows == 0:
logger.debug("fsusage %s not found in DB", str(self))
self.exists = False
elif nb_rows > 1:
raise HPCStatsDBIntegrityError(
... | INSERT INTO fsusage ( filesystem_id, |
Given the code snippet: <|code_start|> self.existing(db)
if self.exists is True:
raise HPCStatsRuntimeError(
"could not insert fsusage %s since already existing in "\
"database" % (str(self)))
req = """
INSERT INTO fsusage ... | WHERE cluster_id = %s |
Continue the code snippet: <|code_start|>
logger = logging.getLogger(__name__)
class Domain(object):
"""Model class for the Domain table."""
def __init__(self, key, name):
self.key = key
self.name = name
self.exists = None
def __str__(self):
return "domain [%s] ... | WHERE domain_id = %s |
Using the snippet: <|code_start|> nb_rows = db.cur.rowcount
if nb_rows == 0:
logger.debug("domain %s not found in DB", str(self))
self.exists = False
elif nb_rows > 1:
raise HPCStatsDBIntegrityError(
"several domain found in DB for domain %s... | VALUES ( %s, %s ) |
Given snippet: <|code_start|> wcounter += 1
# dictionaries
elif command in ['dict', 'dicts', 'dictionary', 'dictionaries']:
log.info('Wait for it...')
dicts_summary = db['dict'].get_summary()
print(dicts_summary)
"""if len(dicts) > 0:
# comput... | elif command.lower() == 'force_exit': |
Given snippet: <|code_start|> def __missing__(self, key: str):
"""Get the missing name.
The missing name will be returned. The result is not cached to avoid
surprise.
"""
if key.startswith('__') and key.endswith('__'):
raise KeyError(key)
for entry, exc... | finally setting a global variable named ``{}`` for the drudge. |
Next line prediction: <|code_start|>
@mock.patch("pytube.request.urlopen")
def test_streaming(mock_urlopen):
# Given
fake_stream_binary = [
os.urandom(8 * 1024),
os.urandom(8 * 1024),
os.urandom(8 * 1024),
None,
]
mock_response = mock.Mock()
mock_response.read.side_... | mock_urlopen.side_effect = exc |
Predict the next line for this snippet: <|code_start|> assert result == {}
def test_parse_longer_empty_object():
test_html = """test = {
}"""
result = parse_for_object(test_html, r'test\s*=\s*')
assert result == {}
def test_parse_empty_object_with_trailing_characters():
test_html = 'test = ... | assert result == { |
Here is a snippet: <|code_start|>
def test_invalid_start():
with pytest.raises(HTMLParseError):
parse_for_object('test = {}', r'invalid_regex')
def test_parse_simple_empty_object():
result = parse_for_object('test = {}', r'test\s*=\s*')
<|code_end|>
. Write the next line using the current file impor... | assert result == {} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.