Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the following code snippet before the placeholder: <|code_start|> DEFAULT_NUM_RANDOM_NUMS = 200 #TODO should create a config to set this DEFAULT_BITS = 32 #TODO should create a config to set this # we want to use the same random numbers across all documents we check, that is why I'm using # a thread safe, singl...
def run(shingles_list):
Using the snippet: <|code_start|> DEFAULT_NUM_RANDOM_NUMS = 200 #TODO should create a config to set this DEFAULT_BITS = 32 #TODO should create a config to set this # we want to use the same random numbers across all documents we check, that is why I'm using # a thread safe, singleton to generate my random numbers RAN...
def run(shingles_list):
Based on the snippet: <|code_start|> DEFAULT_NUM_TWEETS = 600 TWEET_BATCH_SIZE = 40 def get_tweets(duik, old_duik): this_app = AppOpenLSH.get_or_insert('KeyOpenLSH') auth = tweepy.OAuthHandler(this_app.twitter_consumer_key, this_app.twitter_consumer_secret) <|code_end|> , predict the immediate next line wit...
auth.set_access_token(this_app.twitter_access_token_key, this_app.twitter_access_token_secret)
Next line prediction: <|code_start|> class BlobDataset(Dataset): filename = ndb.StringProperty() blob_key = ndb.BlobKeyProperty() @classmethod def create(cls, blob_key, **kwargs): blob_key = blob_key filename = kwargs.get('filename') rows = kwargs.get('rows', 5) bands ...
minhash_modulo = minhash_modulo)
Next line prediction: <|code_start|> class BlobDataset(Dataset): filename = ndb.StringProperty() blob_key = ndb.BlobKeyProperty() @classmethod def create(cls, blob_key, **kwargs): blob_key = blob_key filename = kwargs.get('filename') rows = kwargs.get('rows', 5) bands ...
buckets_per_band = kwargs.get('buckets_per_band', 100)
Given the code snippet: <|code_start|> class BlobDataset(Dataset): filename = ndb.StringProperty() blob_key = ndb.BlobKeyProperty() @classmethod def create(cls, blob_key, **kwargs): blob_key = blob_key filename = kwargs.get('filename') rows = kwargs.get('rows', 5) band...
shingle_type = kwargs.get('shingle_type', 'c4')
Using the snippet: <|code_start|> upload_url = blobstore.create_upload_url("/test_upload_blob") self.response.out.write(self.template_env.get_template("blobs.html").render( {"username": username, "items": items, "length": length, "upload_url": upload_ur...
blob_key = blob_info.key()
Here is a snippet: <|code_start|> time.sleep(1) self.get() class UploadHandler(blobstore_handlers.BlobstoreUploadHandler): def post(self): upload_files = self.get_uploads("file") blob_info = upload_files[0] blob_key = blob_info.key() logging.info('filename %s key %s'...
for name in valnames:
Given the following code snippet before the placeholder: <|code_start|> class UploadHandler(blobstore_handlers.BlobstoreUploadHandler): def post(self): upload_files = self.get_uploads("file") blob_info = upload_files[0] blob_key = blob_info.key() <|code_end|> , predict the next line using i...
logging.info('(REFACTORED) filename %s key %s', blob_info.filename, blob_key)
Continue the code snippet: <|code_start|>dir_path = os.path.dirname([p for p in sys.path if p][0]) sys.path.insert(0, 'libs') LOG_FILENAME = dir_path+'/CassDriver.log' logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG) shingle_cache = Cache(max_size = 1) max_bits = 32 max_mask = 2**max_bits - 1 text_...
class UnknownException(Exception):
Given the following code snippet before the placeholder: <|code_start|>dir_path = os.path.dirname([p for p in sys.path if p][0]) sys.path.insert(0, 'libs') LOG_FILENAME = dir_path+'/CassDriver.log' logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG) shingle_cache = Cache(max_size = 1) max_bits = 32 ma...
class CassandraInt(object):
Continue the code snippet: <|code_start|>dir_path = os.path.dirname([p for p in sys.path if p][0]) sys.path.insert(0, 'libs') LOG_FILENAME = dir_path+'/CassDriver.log' logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG) shingle_cache = Cache(max_size = 1) max_bits = 32 max_mask = 2**max_bits - 1 <|cod...
text_file_pattern = re.compile('^{"id":"([^"]*):html","text":"(.*)}', flags=re.DOTALL)
Predict the next line after this snippet: <|code_start|> # this will be the number of signatures in a vector to be hashed self.num_rows_per_band = rows_per_band #should be thread safe if one instance of this class is used by threads in a pool for example #we may need to make a centralize...
vector_tuple = tuple(vector)
Based on the snippet: <|code_start|>def _get_documents(hash_code, band_dict): if hash_code and band_dict: return band_dict.get(hash_code, None) return None def _update_bucket(hash_code, band_dict, new_document): docs = band_dict.get(hash_code, None) if docs: updated_docs = copy.deepcopy...
if threshold == 0.0:
Based on the snippet: <|code_start|> def _get_documents(hash_code, band_dict): if hash_code and band_dict: return band_dict.get(hash_code, None) return None def _update_bucket(hash_code, band_dict, new_document): docs = band_dict.get(hash_code, None) if docs: updated_docs = copy.deepcop...
self.num_rows_per_band = rows_per_band
Predict the next line for this snippet: <|code_start|>logging.basicConfig(filename=settings.LOG_FILENAME, level=logging.DEBUG) DbType = settings.DATABASES['default']['ENGINE'] if DbType == 'cassandra': elif DbType == 'datastore': else: class UnknownException(Exception): pass class Matrix(object): __metaclas...
'buckets list<int>',
Given the code snippet: <|code_start|>class UnknownException(Exception): pass class Matrix(object): __metaclass__ = Table attrs = [ 'ds_key text', 'source text', 'filename text', 'file_key text', 'lsh_output text', 'eval_output t...
if ds:
Predict the next line after this snippet: <|code_start|> BC = Register("BC") DE = Register("DE") HL = Register("HL") SP = Register("SP") AF = Register("AF") B = Register("B") C = Register("C") D = Register("D") E = Register("E") H = Register("H") L = Register("L") A = Register("A") deref_HL = Dereference(HL, address.f...
)
Given the following code snippet before the placeholder: <|code_start|>SP = Register("SP") AF = Register("AF") B = Register("B") C = Register("C") D = Register("D") E = Register("E") H = Register("H") L = Register("L") A = Register("A") deref_HL = Dereference(HL, address.fromVirtual(0)) # XXX: TODO: very very bad FN...
return tab[name][value]
Predict the next line for this snippet: <|code_start|># along with this program. If not, see <http://www.gnu.org/licenses/>. BC = Register("BC") DE = Register("DE") HL = Register("HL") SP = Register("SP") AF = Register("AF") B = Register("B") C = Register("C") D = Register("D") E = Register("E") H = Register("H") L...
Z=[B, C, D, E, H, L, deref_HL, A],
Given the code snippet: <|code_start|>B = Register("B") C = Register("C") D = Register("D") E = Register("E") H = Register("H") L = Register("L") A = Register("A") deref_HL = Dereference(HL, address.fromVirtual(0)) # XXX: TODO: very very bad FNZ = Condition("FNZ") FZ = Condition("FZ") FNC = Condition("FNC") FC = Cond...
elif name == "I":
Predict the next line after this snippet: <|code_start|> BC = Register("BC") DE = Register("DE") HL = Register("HL") SP = Register("SP") AF = Register("AF") B = Register("B") C = Register("C") D = Register("D") E = Register("E") H = Register("H") L = Register("L") A = Register("A") deref_HL = Dereference(HL, address....
F=[FNZ, FZ, FNC, FC],
Next line prediction: <|code_start|># This file is part of Awake - GB decompiler. # Copyright (C) 2012 Wojciech Marczenko (devdri) <wojtek.marczenko@gmail.com> # # This program 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 Soft...
a = addr.offset(i*2)
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 this program. If not, see <http://www.gnu.org/licenses...
renderer.hline()
Using the snippet: <|code_start|># This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GN...
else:
Here is a snippet: <|code_start|>def dependParallel(a, b): reads = a.reads | b.reads writes = a.writes | b.writes return DependencySet(reads, writes) def unknownDependencySet(): return DependencySet(ALL_REGS - set(['FZ', 'FC', 'FN', 'FH']), ALL_REGS - set(['ROMBANK'])) class DependencySet: def __i...
return DependencySet()
Next line prediction: <|code_start|>def dependParallel(a, b): reads = a.reads | b.reads writes = a.writes | b.writes return DependencySet(reads, writes) def unknownDependencySet(): return DependencySet(ALL_REGS - set(['FZ', 'FC', 'FN', 'FH']), ALL_REGS - set(['ROMBANK'])) class DependencySet: def ...
return DependencySet()
Given the code snippet: <|code_start|> self.assertEquals(str(address.fromPhysical(0x008000)), "0002:4000") self.assertEquals(str(address.fromPhysical(0x008888)), "0002:4888") def testFromVirtual(self): self.assertEquals(str(address.fromVirtual(0x0000)), "0000:0000") self.assertEqual...
self.assertEquals(str(zero.offset(0x4000)), "(A):4000")
Given the code snippet: <|code_start|> return [x[0] for x in c.fetchall()] def getAllInBank(self, bank): bank_name = "{:04X}".format(bank) with closing(self.connection.cursor()) as c: c.execute('select addr from procs where substr(addr, 0, 5)=? order by addr', (bank_name,)) ...
return reads, writes
Predict the next line after this snippet: <|code_start|> 'IO:FF41': 'IO:STAT', 'IO:FF42': 'IO:SCY', 'IO:FF43': 'IO:SCX', 'IO:FF44': 'IO:LY', 'IO:FF45': 'IO:LYC', 'IO:FF46': 'IO:DMA', 'IO:FF47': 'IO:BGP', 'IO:FF48': 'IO:OBP0', 'IO:FF49': 'IO:OBP1', ...
if str(addr) in self.default_tags:
Here is a snippet: <|code_start|> c.execute('select name from tags where addr=?', (addr,)) return bool(getFirst(c.fetchone())) def nameForAddress(self, addr): if str(addr) in self.default_tags: return self.default_tags[str(addr)] with closing(self.connection.curs...
with closing(self.connection.cursor()) as c:
Based on the snippet: <|code_start|> for addr, reftype in c.fetchall(): if reftype == 'read': reads.add(addr) else: writes.add(addr) c.close() return reads, writes def produce_map(self, proj): romsize = 512*1024 width =...
img.putpixel((x, y), color)
Predict the next line for this snippet: <|code_start|> c.close() class BankSummaryPage(Page): def load(self): p = self.url.split('/') self.bank = int(p[2], 16) def render(self, renderer): bank_name = "{:04X}".format(self.bank) c = self.proj.database.connection.c...
c.execute('select addr from memref where substr(proc, 0, 5)=? and type=? group by addr order by addr', (bank_name, 'read'))
Predict the next line after this snippet: <|code_start|> def render(self, r): with r.lineAddress(self.addr), r.comment(): r.hline() r.startNewLine() r.write("procedure ") r.writeSymbol(self.addr, 'procedure') r.startNewLine() r.write...
def render(self, renderer):
Next line prediction: <|code_start|># but WITHOUT ANY WARRANTY; without even the implied warranty of # 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 this program. If not, se...
r.startNewLine()
Predict the next line after this snippet: <|code_start|> renderer.startNewLine() ProcAddress(addr).render(renderer) renderer.startNewLine() renderer.add('dependencies:') c.execute('select destination from calls where substr(source, 0, 5)=? and substr(destination, ...
if url.startswith('/proc/'):
Given the code snippet: <|code_start|> has_name_form = True def load(self): p = self.url.split('/') self.addr = address.fromConventional(p[2]) self.info = self.proj.database.procInfo(self.addr) self.proc = loadProcedureRange(self.proj, self.addr) def render(self, r): ...
has_name_form = True
Predict the next line for this snippet: <|code_start|># the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNES...
values[name] = value
Predict the next line after this snippet: <|code_start|># along with this program. If not, see <http://www.gnu.org/licenses/>. class OpcodeEffect(object): def __init__(self, text): m = re.search('^\s*read:(.*)write:(.*)$', text) assert m reads = [] for name in m.group(1).split():...
def filled(self, params, ctx):
Based on the snippet: <|code_start|># # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of t...
name = w
Given the code snippet: <|code_start|># This file is part of Awake - GB decompiler. # Copyright (C) 2012 Wojciech Marczenko (devdri) <wojtek.marczenko@gmail.com> # # This program 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 So...
info = database.procInfo(addr)
Here is a snippet: <|code_start|> while self.queue or self.jumptable_queue: if self.queue: x = self.queue.pop() self.visitInstruction(proj, x) else: x = self.jumptable_queue.pop() self.tryExpandJumptable(proj, x) def fir...
if addr.inPhysicalMem():
Predict the next line after this snippet: <|code_start|> def dfs(self, proj): while self.queue or self.jumptable_queue: if self.queue: x = self.queue.pop() self.visitInstruction(proj, x) else: x = self.jumptable_queue.pop() ...
def getLimit(proj, addr):
Given the code snippet: <|code_start|> def __init__(self, proj, addr, limit): self.proj=proj self.start_addr = addr self.limit_addr = limit self.visited = set() self.owned_bytes = set() self.labels = set() self.block_starts = set([self.start_addr]) sel...
print('byte not available', addr, 'visited:', ', '.join(str(x) for x in self.visited))
Predict the next line after this snippet: <|code_start|> self.setValue(register[0], HighByte(value)) self.setValue(register[1], LowByte(value)) elif register == 'AF': self.setValue('A', HighByte(value)) self.setValueComplex('FZ') self.setValueComplex('F...
return self.hasValue('FZ')
Predict the next line for this snippet: <|code_start|># along with this program. If not, see <http://www.gnu.org/licenses/>. class Context: def __init__(self, values=None): if not values: self.values = dict() else: self.values = dict(values) def setValueComplex(self, ...
else:
Here is a snippet: <|code_start|> assert not isinstance(value, int) # detect common errors if register in ('BC', 'DE', 'HL'): self.setValue(register[0], HighByte(value)) self.setValue(register[1], LowByte(value)) elif register == 'AF': self.setValue('A', High...
if register in ('BC', 'DE', 'HL'):
Continue the code snippet: <|code_start|> self.setValue(register[1], LowByte(value)) elif register == 'AF': self.setValue('A', HighByte(value)) self.setValueComplex('FZ') self.setValueComplex('FC') self.setValueComplex('FN') self.setValueCom...
if register == 'FNC':
Given snippet: <|code_start|> assert not isinstance(value, int) # detect common errors if register in ('BC', 'DE', 'HL'): self.setValue(register[0], HighByte(value)) self.setValue(register[1], LowByte(value)) elif register == 'AF': self.setValue('A', HighByte...
if register in ('BC', 'DE', 'HL'):
Given the following code snippet before the placeholder: <|code_start|> def __hash__(self): return hash((self.symbol, self.left, self.right)) def __eq__(self, other): try: return self.symbol == other.symbol and self.left == other.left and self.right == other.right except Attr...
return super(BinOp, cls).make(left, right)
Given snippet: <|code_start|>class Add(BinOp): symbol = '+' @staticmethod def calculate(left, right): return (left + right) & 0xFF @classmethod def make(cls, left, right): if isConstant(left): left, right = right, left if right.value == 0: return lef...
if right.value == 0:
Continue the code snippet: <|code_start|># You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class Test(unittest.TestCase): def testDepend(self): self.assertFalse('A' in operand.Constant(1).getDependencies()) ...
c = instruction.LoadInstruction('LD', placeholders.deref_HL, placeholders.A)
Predict the next line for this snippet: <|code_start|># Copyright (C) 2012 Wojciech Marczenko (devdri) <wojtek.marczenko@gmail.com> # # This program 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 vers...
def decode(self, proj, addr):
Predict the next line after this snippet: <|code_start|>00010111 1 RLA @ read: A FC write: A:((A<<1) | FC); FC; FN:0; FZ:0; FH:0; 00011111 1 RRA @ read: A FC write: A:((A>>1) | (FC<<7)); FC; FN:0; FZ:0; FH:0; 00100111 1 DAA @ read: A FN F...
11IIISSS 2 SET #I, #S @ read: #S write: #S:(#S | (1<<#I));
Based on the snippet: <|code_start|> except AttributeError: return False @property def bits(self): if self.value > 0xFF: return 16 else: return 8 class ComplexValue(Operand): def __init__(self, hint='complex', deps=None): self.hint = hint ...
if not hasattr(addr, 'virtual'):
Predict the next line after this snippet: <|code_start|> return self.name def render(self, renderer): renderer.add(str(self), 'register') def optimizedWithContext(self, ctx): if ctx.hasValue(self.name): return ctx.getValue(self.name) return self def getDependenc...
return Condition(dict(FZ='FNZ', FNZ='FZ', FC='FNC', FNC='FC')[self.name])
Next line prediction: <|code_start|> return hex(self.value) def render(self, renderer): renderer.add(str(self), 'constant') def __hash__(self): return hash(self.value) def __eq__(self, other): try: return self.value == other.value except AttributeError: ...
return True
Continue the code snippet: <|code_start|> def testBasic(self): e = OpcodeEffect('read: write:') reads, writes, values = e.filled(None) self.assertFalse(reads) self.assertFalse(writes) self.assertFalse(values) e = OpcodeEffect('read: A HL write: BC HL') reads, ...
if __name__ == "__main__":
Here is a snippet: <|code_start|># This file is part of Awake - GB decompiler. # Copyright (C) 2012 Wojciech Marczenko (devdri) <wojtek.marczenko@gmail.com> # # This program 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 Softwar...
def testMatch(self):
Given the code snippet: <|code_start|> points = [{ "type": "Feature", "properties": {}, "geometry": { "type": "Point", "coordinates": [ -87, 36]}}, { "type": "Feature", <|code_end|> , generate the next line using the imports in this file: import pytest import responses fro...
"properties": {},
Based on the snippet: <|code_start|> points = [{ "type": "Feature", "properties": {}, "geometry": { "type": "Point", "coordinates": [ -87, 36]}}, { "type": "Feature", "properties": {}, "geometry": { "type": "Point", "coordinates": [ -86, ...
"properties": {},
Next line prediction: <|code_start|> with pytest.raises(ValueError) as exc: encode_waypoints(gj_point_features, max_limit=1) assert 'at most' in str(exc.value) def test_unsupported_geometry(): unsupported = copy.deepcopy(gj_point_features) unsupported[0]['geometry']['type'] = "MultiPolygonnnnnn...
[-87.33787536621092, 36.539156961321574],
Given snippet: <|code_start|> [-87.33787536621092, 36.539156961321574], [-88.2476806640625, 36.92217534275667]]}}] class GeoThing(object): __geo_interface__ = None def __init__(self, thing): self.__geo_interface__ = thing def test_read_geojson_featur...
geoms = [GeoThing(gj_point_features[0]['geometry']),
Continue the code snippet: <|code_start|> gj_point_features = [{ "type": "Feature", "properties": {}, "geometry": { "type": "Point", "coordinates": [ -87.33787536621092, 36.539156961321574]}}, { "type": "Feature", "properties": {}, "geometry": { "...
"type": "MultiPoint",
Predict the next line for this snippet: <|code_start|> 36.539156961321574], [-88.2476806640625, 36.92217534275667]]}}] class GeoThing(object): __geo_interface__ = None def __init__(self, thing): self.__geo_interface__ = thing def test_read_geojson_features(): ...
GeoThing(gj_point_features[1]['geometry'])]
Using the snippet: <|code_start|> def validate_lat(val): if val < -85.0511 or val > 85.0511: raise errors.InvalidCoordError( "Latitude must be between -85.0511 and 85.0511") return val def validate_lon(val): if val < -180 or val > 180: raise errors.InvalidCoordError( ...
return val
Given the following code snippet before the placeholder: <|code_start|> def validate_lat(val): if val < -85.0511 or val > 85.0511: raise errors.InvalidCoordError( "Latitude must be between -85.0511 and 85.0511") return val def validate_lon(val): if val < -180 or val > 180: r...
"GeoJSON is too large for the static maps API, "
Here is a snippet: <|code_start|> for pt in types: if pt not in self.place_types: raise InvalidPlaceTypeError(pt) return {'types': ",".join(types)} def forward(self, address, types=None, lon=None, lat=None, country=None, bbox=None, limit=None, languages=No...
if bbox is not None:
Predict the next line after this snippet: <|code_start|> collection of places matching the given address. `response.geojson()` returns the geocoding result as GeoJSON. `response.status_code` returns the HTTP API status code. Place results may be constrained to those of one or more types...
def geojson():
Continue the code snippet: <|code_start|> return {'types': ",".join(types)} def forward(self, address, types=None, lon=None, lat=None, country=None, bbox=None, limit=None, languages=None): """Returns a Requests response object that contains a GeoJSON collection of places matc...
params.update(limit='{0}'.format(limit))
Next line prediction: <|code_start|> class BaseSystem: endian_id: Endian = Endian.UNKNOWN processor_id: Processor = Processor.UNKNOWN def __init__(self, system_name: str) -> None: self.system_name = system_name def get_processor_id(self) -> Processor: <|code_end|> . Use current file imports: ...
return self.processor_id
Given snippet: <|code_start|> self.dis_disassemble_one_line_func = None self.dis_disassemble_as_data_func = None self.dis_constant_pc_offset = None self.dis_get_default_symbol_name_func = None self.dis_is_operand_pointer_sized = None # loaderlib: self.loader_data_...
line_data: Optional[List[Any]] = None
Predict the next line after this snippet: <|code_start|> self.dis_disassemble_one_line_func = None self.dis_disassemble_as_data_func = None self.dis_constant_pc_offset = None self.dis_get_default_symbol_name_func = None self.dis_is_operand_pointer_sized = None # loaderlib...
line_data: Optional[List[Any]] = None
Here is a snippet: <|code_start|> self.dis_disassemble_one_line_func = None self.dis_disassemble_as_data_func = None self.dis_constant_pc_offset = None self.dis_get_default_symbol_name_func = None self.dis_is_operand_pointer_sized = None # loaderlib: self.loader_d...
line_data: Optional[List[Any]] = None
Predict the next line for this snippet: <|code_start|> self.dis_disassemble_one_line_func = None self.dis_disassemble_as_data_func = None self.dis_constant_pc_offset = None self.dis_get_default_symbol_name_func = None self.dis_is_operand_pointer_sized = None # loaderlib: ...
line_data: Optional[List[Any]] = None
Here is a snippet: <|code_start|> self.dis_disassemble_one_line_func = None self.dis_disassemble_as_data_func = None self.dis_constant_pc_offset = None self.dis_get_default_symbol_name_func = None self.dis_is_operand_pointer_sized = None # loaderlib: self.loader_d...
line_data: Optional[List[Any]] = None
Given the code snippet: <|code_start|> self.dis_disassemble_one_line_func = None self.dis_disassemble_as_data_func = None self.dis_constant_pc_offset = None self.dis_get_default_symbol_name_func = None self.dis_is_operand_pointer_sized = None # loaderlib: self.loa...
line_data: Optional[List[Any]] = None
Continue the code snippet: <|code_start|> self.dis_disassemble_one_line_func = None self.dis_disassemble_as_data_func = None self.dis_constant_pc_offset = None self.dis_get_default_symbol_name_func = None self.dis_is_operand_pointer_sized = None # loaderlib: self....
line_data: Optional[List[Any]] = None
Based on the snippet: <|code_start|> self.dis_disassemble_one_line_func = None self.dis_disassemble_as_data_func = None self.dis_constant_pc_offset = None self.dis_get_default_symbol_name_func = None self.dis_is_operand_pointer_sized = None # loaderlib: self.loade...
line_data: Optional[List[Any]] = None
Predict the next line after this snippet: <|code_start|> self.dis_disassemble_one_line_func = None self.dis_disassemble_as_data_func = None self.dis_constant_pc_offset = None self.dis_get_default_symbol_name_func = None self.dis_is_operand_pointer_sized = None # loaderlib...
line_data: Optional[List[Any]] = None
Using the snippet: <|code_start|> data = b"testdata" signature = keyhandler.key.sign(data) pkey = keyhandler.key.public_key() self.assertIsNotNone(pkey) # would throw InvalidSignature if not correct pkey.verify(signature, data) self.assertIsNotNone(keyhandler.key) ...
key.create_key("ed25519", None)
Given the following code snippet before the placeholder: <|code_start|> class CreateSuperUserView(SignupView): form_class = SuperUserSignupForm success_url = reverse_lazy("admin:index") def dispatch(self, request, *args, **kwargs): if User.objects.exists(): return HttpResponseNotFound...
return complete_signup(
Next line prediction: <|code_start|> class CategorySchema(ModelSchema): class Meta: model = Category class PetSchema(ModelSchema): category = ma.fields.Nested(CategorySchema) <|code_end|> . Use current file imports: (import marshmallow as ma from marshmallow_peewee import ModelSchema from .model...
class Meta:
Predict the next line for this snippet: <|code_start|> class CategorySchema(ModelSchema): class Meta: model = Category class PetSchema(ModelSchema): category = ma.fields.Nested(CategorySchema) class Meta: model = Pet dump_only = 'created', <|code_end|> with the help of curre...
@ma.post_load
Continue the code snippet: <|code_start|>def read_dir(startdir, *, excludes=(), binary=False): assert isinstance(excludes, list) or isinstance(excludes, tuple), \ "excludes must be a list or a tuple, not " + repr(type(excludes)) startdir = Path(startdir) exclude_tuples = [Path(e).parts for e in excl...
*,
Using the snippet: <|code_start|> assert ret in allowed_returns, \ 'run_peru_command() returned an error: ' + repr(ret) return capture_stream.getvalue() class Repo: def __init__(self, path): self.path = path def run(self, *command): output = subprocess.check_output(command, cwd...
hgrc_path = os.path.join(content_dir, '.hg', 'hgrc')
Based on the snippet: <|code_start|> _set_last_imports(runtime, imports_tree) async def get_imports_tree(runtime, scope, imports, base_tree=None): target_trees = await get_trees(runtime, scope, imports.keys()) imports_tree = await merge_imports_tree(runtime.cache, imports, ...
return Path(runtime.state_dir) / 'lastimports'
Given snippet: <|code_start|> module, rules = await scope.parse_target(runtime, target_str) context = 'target "{}"'.format(target_str) with error_context(context): tree = await module.get_tree(runtime) if module.default_rule: tree = await module.default_rule.get_tree(runtime, tree...
f.write(tree)
Given the following code snippet before the placeholder: <|code_start|> cache_dir = shared.create_dir() shared.run_peru_command(['sync'], self.cwd, env={ 'PERU_CACHE_DIR': cache_dir, ...
self.assert_success(
Predict the next line after this snippet: <|code_start|> cache_dir = shared.create_dir() shared.run_peru_command(['sync'], self.cwd, env={ 'PERU_CACHE_DIR': cache_dir, }) ...
self.assert_success(
Given snippet: <|code_start|> class MergeTest(PeruTest): @make_synchronous async def setUp(self): self.cache_dir = create_dir() self.cache = await Cache(self.cache_dir) # These tests use this simple one-file tree as module contents. content = {'a': 'a'} content_dir = c...
@make_synchronous
Using the snippet: <|code_start|> class MergeTest(PeruTest): @make_synchronous async def setUp(self): self.cache_dir = create_dir() self.cache = await Cache(self.cache_dir) # These tests use this simple one-file tree as module contents. content = {'a': 'a'} content_dir...
imports = {'foo': ('path1', ), 'bar': ('path2', )}
Predict the next line after this snippet: <|code_start|> 'b/c': 'foo', 'x': 'foo', 'y/c': 'bar', COLON + 'd': 'baz', }) @shared.make_synchronous async def test_move(self): # Same semantics as copy above. Also, make sure that mov...
COLON + 'd': 'baz'
Here is a snippet: <|code_start|> class AsyncTest(PeruTest): @make_synchronous async def test_safe_communicate(self): # Test safe_communicate with both empty and non-empty input. cat_command = [ sys.executable, "-c", "import sys; sys.stdout.write(sys.stdin.read())" ...
self.assertEqual(stdout, b"")
Predict the next line after this snippet: <|code_start|> # The --prefix argument to read-tree chokes on paths that contain dot # or dot-dot. Instead of './', it wants the empty string. Oblige it. # NOTE: This parameter must be forward-slash-separated, even on # Windows. os.path.normpath()...
async def get_new_files_in_tree(self, previous_tree, new_tree):
Given the following code snippet before the placeholder: <|code_start|> elif path.parts[0] == '/': raise ModifyTreeError('Cannot modify an absolute path.') elif '..' in path.parts: raise ModifyTreeError('.. is not allowed in tree paths.') if len(path.p...
sub_modifications)
Using the snippet: <|code_start|> plugin_fields) self.assertDictEqual({'rev': '1'}, output) def test_git_plugin_with_submodule(self): content_repo = GitRepo(self.content_dir) # Git has a small bug: The .gitmodules file is always created with "\n" ...
self.do_plugin_test('git', {'url': self.content_dir}, expected_content)
Here is a snippet: <|code_start|>#! /usr/bin/env python3 # Unfortunately we need to make sure to keep this import above the others, # because async_helpers needs to set the global event loop at import time. __doc__ = '''\ Usage: peru [-hqv] [--file=<file>] [--sync-dir=<dir>] [--state-dir=<dir>] [--cac...
override substitute a local directory for the contents of a module
Given snippet: <|code_start|> sys.stdout = open( sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1) sys.stderr = open( sys.stderr.fileno(), mode='w', encoding='utf8', buffering=1) # Called as a setup.py entry point, or from __main__.py (`python3 -m peru`). def main(*, ...
except PrintableError as e:
Given the following code snippet before the placeholder: <|code_start|> ['args', 'runtime', 'scope', 'imports']) def force_utf8_in_ascii_mode_hack(): '''In systems without a UTF8 locale configured, Python will default to ASCII mode for stdout and stderr. This causes our f...
return ret