Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Next line prediction: <|code_start|>
raw_dir = osp.join(self.root, 'raw')
mkdir_if_missing(raw_dir)
# Download the raw zip file
fpath = osp.join(raw_dir, 'VIPeR.v1.0.zip')
if osp.isfile(fpath) and \
hashlib.md5(open(fpath, 'rb').read()).hexdigest() == self.md5:
... | fname = '{:08d}_{:02d}_{:04d}.jpg'.format(pid, 0, 0) |
Given the following code snippet before the placeholder: <|code_start|> url = 'http://users.soe.ucsc.edu/~manduchi/VIPeR.v1.0.zip'
md5 = '1c2d9fc1cc800332567a0da25a1ce68c'
def __init__(self, root, split_id=0, num_val=100, download=True):
super(VIPeR, self).__init__(root, split_id=split_id)
... | print("Downloading {} to {}".format(self.url, fpath)) |
Predict the next line after this snippet: <|code_start|>class CUHK03(Dataset):
url = 'https://docs.google.com/spreadsheet/viewform?usp=drive_web&formkey=dHRkMkFVSUFvbTJIRkRDLWRwZWpONnc6MA#gid=0'
md5 = '728939e58ad9f0ff53e521857dd8fb43'
def __init__(self, root, split_id=0, num_val=100, download=True):
... | else: |
Using the snippet: <|code_start|>
class CUHK03(Dataset):
url = 'https://docs.google.com/spreadsheet/viewform?usp=drive_web&formkey=dHRkMkFVSUFvbTJIRkRDLWRwZWpONnc6MA#gid=0'
md5 = '728939e58ad9f0ff53e521857dd8fb43'
def __init__(self, root, split_id=0, num_val=100, download=True):
super(CUHK03, self)... | print("Using downloaded file: " + fpath) |
Next line prediction: <|code_start|>from __future__ import absolute_import
class Logger(object):
def __init__(self, fpath=None):
self.console = sys.stdout
self.file = None
if fpath is not None:
mkdir_if_missing(os.path.dirname(fpath))
self.file = open(fpath, 'w')
... | self.console.write(msg) |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
# 上传策略,参数规格详见
# https://developer.qiniu.com/kodo/manual/1206/put-policy
_policy_fields = set([
'callbackUrl', # 回调URL
'callbackBody', # 回调Body
'callbackHost', # 回调URL指定的Host
'callbackBodyType', # 回调Body的Content-Type
'callbackFetchKey',... | 'fileType', # 文件的存储类型,0为普通存储,1为低频存储 |
Given snippet: <|code_start|># -*- coding: utf-8 -*-
def urlencode(str):
if is_py2:
return urllib2.quote(str)
elif is_py3:
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from qiniu import http
from qiniu.compat import is_py2
from qiniu.compat import is_py3
impo... | return urllib.parse.quote(str) |
Given the code snippet: <|code_start|>
class TestCase_Transformations(unittest.TestCase):
def test_something(self):
t = FieldTransformation()
t.field_name = 'id'
t.new_step('lower({fld})')
<|code_end|>
, generate the next line using the imports in this file:
import unittest
from pyelt.map... | t.new_step("concat({fld}, '01')") |
Given the code snippet: <|code_start|> def __init__(self, huisnummer=''):
super().__init__()
param1 = DbFunctionParameter('huisnummer_input', 'text', huisnummer)
self.func_params.append(param1)
self.sql_body = """DECLARE
pos_split INT := 0;
huisnummer_deel TEXT := '';... | IF chr >= '0' and chr <= '9' THEN |
Given snippet: <|code_start|> self.schema = 'sor_test_system'
class SplitHuisnummer(DbFunction):
def __init__(self, huisnummer=''):
super().__init__()
param1 = DbFunctionParameter('huisnummer_input', 'text', huisnummer)
self.func_params.append(param1)
self.sql_body = """DEC... | chars := regexp_split_to_array(huisnummer_input, ''); |
Given snippet: <|code_start|>
class QueryMaker():
def __init__(self, name = ''):
self.name = name
self.__elements = {}
def append(self, elm, alias = ''):
if isinstance(elm, Column):
if not alias:
alias = elm.name
else:
if not alias:
<|... | alias = elm.__dbname__ |
Using the snippet: <|code_start|>--select sor_timeff.split_huisnummer('10-1hoog');
--select sor_timeff.split_huisnummer('10');
--select sor_timeff.split_huisnummer('a');
--select sor_timeff.split_huisnummer('');
--select sor_timeff.split_huisnummer(NULL);
--select sor_timeff.split_huisnummer(' 10 a ' );
--select sor... | END IF; |
Given the following code snippet before the placeholder: <|code_start|> self.func_params.append(param1)
self.func_params.append(param2)
self.sql_body = """DECLARE
pos_split INT := 0;
huisnummer_deel TEXT := '';
huisnummer INT;
huisnummer_toevoeging TEXT;
c... | -- RAISE NOTICE 'test%', pos_split; |
Given the code snippet: <|code_start|>
def init_test_valueset_mappings():
mappings = []
mapping = SorToValueSetMapping('patient_hstage', Valueset)
mapping.map_field("target_valueset", Valueset.valueset_naam)
mapping.map_field("target_code", Valueset.code)
mapping.map_field("ta... | self.assertEqual(len(valuset_mapping.field_mappings), 3) |
Predict the next line for this snippet: <|code_start|>
def init_test_valueset_mappings():
mappings = []
mapping = SorToValueSetMapping('patient_hstage', Valueset)
mapping.map_field("target_valueset", Valueset.valueset_naam)
mapping.map_field("target_code", Valueset.code)
mappi... | self.assertEqual(len(valuset_mapping.field_mappings), 3) |
Using the snippet: <|code_start|>
def delete_all_logs(folder):
for the_file in os.listdir(folder):
file_path = os.path.join(folder, the_file)
try:
if os.path.isfile(file_path):
os.unlink(file_path)
except Exception as e:
print(e)
def delete_all_ddl... | if 'DDL' in the_file: |
Using the snippet: <|code_start|>
config = {
'log_path': '/logs/',
'ddl_log_path': '/logs/ddl/',
'sql_log_path': '/logs/sql/',
'conn_dwh': 'postgresql://postgres:' + SimpleEncrypt.decode('pwd', 'wrTCrMOGw4DCtcKzwr3ClsKjwoF4e2k=')+ '@localhost:5432/dwh',
'debug': True, # Zet debug op true om een gel... | 'sor_schema': 'sor_sample', |
Given snippet: <|code_start|> # result = get_field_value_from_dv_table('landcode','zorgverlener','contactgegevens','455',['_active = True', """type = 'mobiel'"""])
sql = """select a.land from pyelt_unittests.dv.adres_sat a
inner join pyelt_unittests.dv.zorgverlener_adres_link za
... | on za.fk_zorgverlener_hub = z._id |
Given the following code snippet before the placeholder: <|code_start|> new_hub.bk = 'ajshdgashdg4'
pat_hub.save()
Patient.cls_init()
sat = Patient.Naamgegevens()
rows = sat.load()
for row in rows.values():
print(row._id, row._runid, row._revision, row.geslachtsnaam)
new_hub = pat_h... | print('--------') |
Continue the code snippet: <|code_start|>
def test10_dv_view_updated(self):
pass
#todo[rob]: test de hybrid-links
def test_row_count(unittest, table_name, count):
test_sql = "SELECT * FROM " + table_name
result = execute_sql(test_sql)
unittest.assertEqual(len(result), count, table_name)
def ... | sql = """select s.{1} |
Continue the code snippet: <|code_start|> self.log(sql)
start = time.time()
connection = self.engine.raw_connection()
cursor = connection.cursor(cursor_factory=psycopg2.extras.DictCursor)
cursor.execute(sql)
result = cursor.fetchall()
self.log('-- duur: ' + str(t... | def log(self, msg: str) -> None: |
Continue the code snippet: <|code_start|> self.file_kwargs = {}
self.csv_kwargs = {}
self.csv_kwargs['delimiter'] = self.delimiter
for k,v in kwargs.items():
if k == 'encoding':
self.file_kwargs[k] = v
if v == 'utf-8-sig':
v ... | super().__init__(file_name ) |
Given the code snippet: <|code_start|>
urlpatterns = [
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^login/', login, name='login'),
url(r'^logout/', logout, {'next_page': '/'}, name='logout'),
<|code_end|>
, generate the next line using the imports in this file:
from django.conf import settin... | url(r'^', include('fpr.urls')), |
Here is a snippet: <|code_start|># Django core, alphabetical
# External dependencies, alphabetical
# This project, alphabetical
# ########## FORMATS ############
class FormatForm(forms.ModelForm):
group = forms.ChoiceField(
widget=forms.Select(attrs={'class': 'form-control'}),
choices=fprmodels... | fields = ('description',) |
Next line prediction: <|code_start|>
UUID_REGEX = r'[\w]{8}(-[\w]{4}){3}-[\w]{12}'
urlpatterns = [
url(r'^$', views.home, name='fpr_index'),
url(r'^(?P<category>format|formatgroup|idrule|idcommand|fprule|fpcommand)/(?P<uuid>' + UUID_REGEX + ')/toggle_enabled/$', views.toggle_enabled,
name='toggle_enabl... | name='formatversion_create'), |
Predict the next line for this snippet: <|code_start|> def error_code(self):
try:
return "resp %d" % int(self.err)
except ValueError:
return self.err
def process_resp(resp, datatype):
if resp is None:
if datatype == 'boolean':
return False
if d... | pass |
Given the code snippet: <|code_start|> device_capture.append({
'symbol': 'midi_loopback',
'img': midi_input_img,
'connected_img': midi_input_connected,
'type': 'midi',
})
for ix in range(0, pb['hardware']['cv_outs']):
device_playback.append({
... | screenshot_path = None |
Here is a snippet: <|code_start|>
def get_uid():
if DEVICE_UID is None:
raise Exception('Missing device uid')
if os.path.isfile(DEVICE_UID):
with open(DEVICE_UID, 'r') as fh:
return fh.read().strip()
return DEVICE_UID
def get_tag():
if DEVICE_TAG is None:
raise Excep... | return fh.read().strip() |
Using the snippet: <|code_start|>
def get_uid():
if DEVICE_UID is None:
raise Exception('Missing device uid')
if os.path.isfile(DEVICE_UID):
with open(DEVICE_UID, 'r') as fh:
return fh.read().strip()
return DEVICE_UID
def get_tag():
if DEVICE_TAG is None:
raise Excep... | raise Exception('Missing API key') |
Based on the snippet: <|code_start|>
def get_uid():
if DEVICE_UID is None:
raise Exception('Missing device uid')
if os.path.isfile(DEVICE_UID):
with open(DEVICE_UID, 'r') as fh:
return fh.read().strip()
return DEVICE_UID
def get_tag():
if DEVICE_TAG is None:
raise Ex... | raise Exception('Missing API key') |
Given the following code snippet before the placeholder: <|code_start|> return fh.read().strip()
return DEVICE_UID
def get_tag():
if DEVICE_TAG is None:
raise Exception('Missing device tag')
if os.path.isfile(DEVICE_TAG):
with open(DEVICE_TAG, 'r') as fh:
return fh.re... | return 'none' |
Given the following code snippet before the placeholder: <|code_start|>#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License ... | configs = [{ |
Given the code snippet: <|code_start|> self.__config_dir = config_dir
BackwardCompatibilityAdapter.CONFIG_PATH = self.__config_dir
self.__keys = ['host', 'port', 'type', 'method', 'timeout', 'byteOrder', 'wordOrder', 'retries', 'retryOnEmpty',
'retryOnInvalid', 'baudrate']
... | slave['pollPeriod'] = slave['timeseriesPollPeriod'] |
Next line prediction: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | try: |
Next line prediction: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | self.dict_result["telemetry"] = [] |
Here is a snippet: <|code_start|> self.__connector.add_device(data_to_connector)
elif iocb.ioError:
log.exception(iocb.ioError)
@staticmethod
def form_iocb(device, config=None, request_type="readProperty"):
config = config if config is not None else device
address... | if (isinstance(value, str) and value.lower() == 'null') or value is None: |
Next line prediction: <|code_start|>
except Exception as e:
log.exception(e)
def indication(self, apdu: APDU):
if isinstance(apdu, IAmRequest):
log.debug("Received IAmRequest from device with ID: %i and address %s:%i",
apdu.iAmDeviceIdentifier[1],
... | iocb.add_callback(self.__general_cb) |
Given snippet: <|code_start|># Copyright 2020. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License"];
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... | if not isinstance(data, dict) or not data: |
Predict the next line for this snippet: <|code_start|> def convert(self, config, data):
try:
if config.get("dataInHex", ""):
return list(bytearray.fromhex(config["dataInHex"]))
if not isinstance(data, dict) or not data:
log.error("Failed to convert TB ... | byteorder = config["dataByteorder"] if config.get("dataByteorder", "") else "big" |
Next line prediction: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | pass |
Given snippet: <|code_start|># You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CON... | message_types = [message_types] |
Given the code snippet: <|code_start|>
@staticmethod
def __convert_connector_configuration_msg(basic_msg, msg, additional_data=None):
pass
@staticmethod
def __convert_gateway_attribute_update_notification_msg(basic_msg, msg, additional_data=None):
ts = int(time()*1000)
gw_attr_u... | rpc_request_msg = ToDeviceRpcRequestMsg() |
Given snippet: <|code_start|> DownlinkMessageType.ConnectorConfigurationMsg: self.__convert_connector_configuration_msg,
DownlinkMessageType.GatewayAttributeUpdateNotificationMsg: self.__convert_gateway_attribute_update_notification_msg,
DownlinkMessageType.GatewayAttributeResponseMsg... | basic_msg.response.status = ResponseStatus.Value(msg.name) |
Given snippet: <|code_start|> module = TBModuleLoader.import_module(self._connector_type, converter_class_name)
if module:
log.debug('Converter %s for device %s - found!', converter_class_name, self.name)
return module
log.error("Cannot find converter for %s device", sel... | self.__connections[address] = conn |
Next line prediction: <|code_start|> conn, address = self.__socket.accept()
self.__connections[address] = conn
self.__log.debug('New connection %s established', address)
thread = Thread(target=self.__process_tcp_connection, daemon=True,
... | (address, port), data = self.__converting_requests.get() |
Given the code snippet: <|code_start|> self.__log.exception(e)
return e
@staticmethod
def __write_value_via_udp(address, port, value):
new_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
new_socket.sendto(value, (address, int(port)))
new_socket.c... | rpc_method = rpc_config['methodProcessing'] |
Based on the snippet: <|code_start|># Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing p... | else: |
Continue the code snippet: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#... | converted_data = {} |
Using the snippet: <|code_start|># See the License for the specific language governing permissions and
# limitations under the License.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of th... | self.dict_result["telemetry"] = [] |
Given snippet: <|code_start|> self.dict_result = {"deviceName": config['deviceName'],
"deviceType": config['deviceType']
}
def convert(self, config, data):
if data is None:
return {}
try:
self.dict_result["telem... | data_to_replace += str(item['data'][int(indexes[0])]) |
Given the code snippet: <|code_start|> if self.buffered_reader is not None and not self.buffered_reader.closed:
self.buffered_reader.close()
self.write_info_to_state_file(self.new_pos)
self.current_pos = self.new_pos
self.current_batch = None
... | try: |
Predict the next line after this snippet: <|code_start|> records_to_read = self.settings.get_max_read_records_count()
while records_to_read > 0:
try:
current_line_in_file = self.new_pos.get_line()
self.buffered_reader = self.get_or_init_buffered_reader(self.new... | next_file = self.get_next_file(self.files, self.new_pos) |
Continue the code snippet: <|code_start|># distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class EventS... | line = self.buffered_reader.readline() |
Predict the next line after this snippet: <|code_start|>
return self.buffered_reader
except IOError as e:
log.error("Failed to initialize buffered reader! Error: %s", e)
raise RuntimeError("Failed to initialize buffered reader!", e)
except Exception as e:
... | reader_pos = 0 |
Here is a snippet: <|code_start|># You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS... | self.settings.get_data_folder_path() + self.current_file): |
Predict the next line for this snippet: <|code_start|>
class DataFileCountError(Exception):
pass
class EventStorageWriter:
def __init__(self, files: EventStorageFiles, settings: FileEventStorageSettings):
self.files = files
self.settings = settings
self.buffered_writer = None
... | except IOError as e: |
Predict the next line for this snippet: <|code_start|># Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific la... | except IOError as e: |
Based on the snippet: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | def put(self, event): |
Predict the next line for this snippet: <|code_start|># Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required ... | success = True |
Given snippet: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... | pass |
Given snippet: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... | 'deviceName': config.get('name', 'CustomSerialDevice'), |
Given snippet: <|code_start|># distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class CustomSerialUplinkCo... | if to_byte == -1: |
Continue the code snippet: <|code_start|>#
# Licensed under the Apache License, Version 2.0 (the "License"];
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | value = bool(can_data[config["start"]]) |
Given the code snippet: <|code_start|># Copyright 2020. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License"];
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | try: |
Next line prediction: <|code_start|> decoded = decoder_functions[lower_type]()
elif lower_type in ['int', 'long', 'integer']:
type_ = str(objects_count * 16) + "int"
assert decoder_functions.get(type_) is not None
decoded = decoder_functions[type_]()
elif... | result_data = [int(bit) for bit in decoded] |
Here is a snippet: <|code_start|> log.debug(self.__result)
return self.__result
@staticmethod
def __decode_from_registers(decoder, configuration):
type_ = configuration["type"]
objects_count = configuration.get("objectsCount", configuration.get("registersCount", configuration.get... | decoded_lastbyte= decoder_functions[type_]() |
Given the following code snippet before the placeholder: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | self.data = data |
Predict the next line after this snippet: <|code_start|> for node in node_paths:
if not self.__is_file(ftp, node):
arr.append(ftp.pwd() + node)
final_arr = arr
ftp.cwd(current)
else:
... | 'devicePatternType': self.device_type, |
Based on the snippet: <|code_start|> ts_kv_list_dict = {"ts": ts_kv_list.ts, "values": {}}
for kv in ts_kv_list.kv:
ts_kv_list_dict['values'][kv.key] = GrpcUplinkConverter.get_value(kv)
device_dict['telemetry'].append(ts_kv_list_dict)
result... | def __convert_disconnect_msg(msg: DisconnectMsg): |
Based on the snippet: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | pass |
Given snippet: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... | pass |
Based on the snippet: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | -1] # getting all data after last '/' symbol in this case: if topic = 'devices/temperature/sensor1' device name will be 'sensor1'. |
Based on the snippet: <|code_start|>#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# ... | telemetry_to_send = {telemetry_key.replace("Bytes", ""): value} # creating telemetry data for sending into Thingsboard |
Given the following code snippet before the placeholder: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | pass |
Based on the snippet: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | pass |
Based on the snippet: <|code_start|> self.assertListEqual(actual_can_data, list(value.encode(encoding)))
def test_expression_data(self):
default_data_length = 1
default_byteorder = "big"
data = {
"one": 1,
"two": 2,
"three": 3
}
... | config = {"dataBefore": "00 01 02 03"} |
Using the snippet: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# U... | "telemetry": "telemetry"} |
Next line prediction: <|code_start|> value = self.__property_value_from_apdu(data)
if config is not None:
datatypes = {"attributes": "attributes",
"timeseries": "telemetry",
"telemetry": "telemetry"}
dict_result = {"deviceName"... | return value |
Given the code snippet: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | pass |
Next line prediction: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | pass |
Given the following code snippet before the placeholder: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | result = { |
Based on the snippet: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | result[config[0]].append({config[1]["key"]: {str(k): str(v) for k, v in data.items()}}) |
Given the code snippet: <|code_start|> super().__init__()
self.loop = None
self.stopped = False
self.name = config['name']
self.device_type = config.get('deviceType', 'default')
self.timeout = config.get('timeout', 10000) / 1000
self.connect_retry = config.get('con... | self.callback = config['callback'] |
Predict the next line for this snippet: <|code_start|> connect_try += 1
if connect_try == self.connect_retry:
sleep(self.wait_after_connect_retries)
sleep(self.connect_retry_in_seconds)
sleep(.2)
async def notif... | async def __process_self(self): |
Predict the next line after this snippet: <|code_start|> not_converted_data = {'telemetry': [], 'attributes': []}
for section in ('telemetry', 'attributes'):
for item in self.config[section]:
char_id = item['characteristicUUID']
if item['method'] == 'read':
... | data_for_converter = { |
Based on the snippet: <|code_start|># Copyright 2022. ThingsBoard
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | builder = BinaryPayloadBuilder(byteorder=byte_order, wordorder=word_order, repack=repack) |
Continue the code snippet: <|code_start|> lower_type = config.get("type", config.get("tag", "error")).lower()
if lower_type == "error":
log.error('"type" and "tag" - not found in configuration.')
variable_size = config.get("objectsCount", config.get("registersCount", config.get("regi... | elif lower_type in builder_functions and 'float' in lower_type: |
Given snippet: <|code_start|># you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is dist... | expected_data = {} |
Based on the snippet: <|code_start|>"""
Goal: expose one method for getting a logger
"""
CONFIG_FILE = 'config/logs.cfg'
def get_figlet(name):
if 'hasher.py' in name:
return """
_ _ _
| | | | __ _ ___| |__ ___ _ __
| |_| |/ _` / __| '_ \ / _ \ '__|
| _ | (_| \__ \ | | | __/ |
|_| |_|\__... | | | | | '_ \| |/ / _ \ '__| |
Given the code snippet: <|code_start|> opt_ask = '--ask' if ask else ''
ctx.run('PYTHONPATH=. python run/hasher.py -i {} -o {} {}'
.format(inputfolder, outputfolder, opt_ask))
@task
def demo(ctx, ask=True):
""" Generate hashes from PHI """
inputfolder = '.'
outputfolder = '.'
opt_a... | Usage: |
Given the code snippet: <|code_start|> opt_ask = '--ask' if ask else ''
ctx.run('PYTHONPATH=. python run/hasher.py -i {} -o {} {}'
.format(inputfolder, outputfolder, opt_ask))
@task
def demo(ctx, ask=True):
""" Generate hashes from PHI """
inputfolder = '.'
outputfolder = '.'
opt_a... | Usage: |
Predict the next line after this snippet: <|code_start|> assert os.path.isfile(os.path.join(output_path, uid + '.png'))
assert os.path.isfile(os.path.join(output_path, uid + '.json'))
shutil.rmtree(output_path)
def test_context_manager_disabled(self):
output_path = tempfile.mkdtemp(... | foo() |
Predict the next line for this snippet: <|code_start|> del os.environ[data_path_key]
path_ = None
try:
path_ = MarvinData.data_path
except InvalidConfigException:
assert not path_
@mock.patch('marvin_python_toolbox.common.data.check_path')
def test_unable_to_create_path(check_path, data... | mocked_fp.read.assert_called_once() |
Next line prediction: <|code_start|>
file_path = MarvinData.download_file(file_url, local_file_name='myfile')
assert file_path == '/tmp/data/myfile'
@mock.patch('marvin_python_toolbox.common.data.progressbar')
@mock.patch('marvin_python_toolbox.common.data.requests')
def test_download_file_delete_file_if_excep... | mocked_open.assert_called_once_with('/tmp/data/file.json', 'wb') |
Based on the snippet: <|code_start|># Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writi... | spark_conf = '/opt/spark/conf' |
Here is a snippet: <|code_start|>@mock.patch('marvin_python_toolbox.management.notebook.sys')
@mock.patch('marvin_python_toolbox.management.notebook.os.system')
def test_notebook(system_mocked, sys_mocked):
ctx = mocked_ctx()
port = 8888
enable_security = False
allow_root = False
spark_conf = '/opt/... | @mock.patch('marvin_python_toolbox.management.notebook.sys') |
Predict the next line after this snippet: <|code_start|> return json.load(f)
else:
return serializer.load(object_file_path)
def _save_obj(self, object_reference, obj):
if not self._is_remote_calling:
if getattr(self, object_reference, None) is not None:
... | logger.info("Removing object {} from memory..".format(object_reference)) |
Given the code snippet: <|code_start|> logger.info("Object {} saved!".format(object_reference))
self._local_saved_objects[object_reference] = object_file_path
def _load_obj(self, object_reference, force=False):
if (getattr(self, object_reference, None) is None and self._persistence_m... | message = "Reloaded" |
Given snippet: <|code_start|># coding=utf-8
# Copyright [2017] [B2W Digital]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | load_source_mocked.assert_called_once_with('custom_commands', '/tmp') |
Using the snippet: <|code_start|> pr = self.pr
pr.disable()
# args accept functions
output_path = self.output_path
uid = self.uid
info = self.info
if callable(uid):
uid = uid()
# make sure the output path exi... | subprocess.call(['dot', '-Tpng', '-o', png_path, dot_path]) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.