Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Here is a snippet: <|code_start|> print '""".split()' max_score = float(length) / max(lengths) print 'for index, name in enumerate(POPULAR_%sES[%d]):' % ( upper, length) print ' %s_SCORES[name] = (%d - index) / %.1f' % ( upper, len(names), len(names) / max_score...
all_lengths(Suffix, LENGTHS)
Based on the snippet: <|code_start|> def get_count(name): """ Retrieve the value for a given sharded counter. """ total = memcache.get(name) if total is None: total = 0 <|code_end|> , predict the immediate next line with the help of imports: import random from google.appengine.ext import...
for counter in Shard.all().filter('name = ', name):
Here is a snippet: <|code_start|> def get_count(name): """ Retrieve the value for a given sharded counter. """ total = memcache.get(name) if total is None: total = 0 for counter in Shard.all().filter('name = ', name): total += counter.count memcache.add(name, s...
config = Config.get_or_insert(name, name=name)
Predict the next line after this snippet: <|code_start|> class FeedbackAdmin(admin.ModelAdmin): list_display = ('message', 'page', 'points', 'submitter', 'submitted') search_fields = ('message', 'page') <|code_end|> using the current file's imports: from django.contrib import admin from feedback.models im...
admin.site.register(Feedback, FeedbackAdmin)
Based on the snippet: <|code_start|> def statistics(path): results = {'path': path} missing = [] seconds1 = [] seconds2 = [] total = errors = failures = 0 <|code_end|> , predict the immediate next line with the help of imports: from datetime import datetime, timedelta from ragendja.template impo...
query = Comparison.all().filter('path', path)
Continue the code snippet: <|code_start|>#!/usr/bin/env python # Setup project environment in the parent directory. sys.path[0] = os.path.dirname(sys.path[0]) setup_env() LETTERS = 'abcdefghijklmnopqrstuvwxyz' for c1 in LETTERS: for c2 in LETTERS: for c3 in LETTERS: for c4 in LETTERS: ...
score = word_score(word, english.TRIPLE_SCORES)
Next line prediction: <|code_start|>#!/usr/bin/env python # Setup project environment in the parent directory. sys.path[0] = os.path.dirname(sys.path[0]) setup_env() LETTERS = 'abcdefghijklmnopqrstuvwxyz' for c1 in LETTERS: for c2 in LETTERS: for c3 in LETTERS: for c4 in LETTERS: ...
score = word_score(word, english.TRIPLE_SCORES)
Here is a snippet: <|code_start|>def fetch_file(Model, length): kind = Model.kind() filename = '.data/popular/%ses.%d.txt' % (kind.split('_')[-1], length) outfile = open(filename, 'w') start = db.Key.from_path(kind, '-') while True: query = Model.all().filter('length', length).order('__key__...
fetch_file(Prefix, length)
Based on the snippet: <|code_start|> kind = Model.kind() filename = '.data/popular/%ses.%d.txt' % (kind.split('_')[-1], length) outfile = open(filename, 'w') start = db.Key.from_path(kind, '-') while True: query = Model.all().filter('length', length).order('__key__') query.filter('__k...
fetch_file(Suffix, length)
Given the code snippet: <|code_start|>#!/usr/bin/env python # Setup project environment in the parent directory. sys.path[0] = os.path.dirname(sys.path[0]) setup_env() def fetch_file(Model, length): kind = Model.kind() filename = '.data/popular/%ses.%d.txt' % (kind.split('_')[-1], length) outfile = ope...
prefixes = retry(query.fetch, 1000)
Predict the next line after this snippet: <|code_start|> register = template.Library() @register.simple_tag def feedback_form(request): page = request.META['PATH_INFO'] feedback_form = FeedbackForm(initial={'page': page}) return render_to_string('feedback/form.html', locals()) def render_query(request...
query = Feedback.all()
Predict the next line for this snippet: <|code_start|> register = template.Library() @register.simple_tag def feedback_form(request): page = request.META['PATH_INFO'] <|code_end|> with the help of current file imports: from django import template from django.template.loader import render_to_string from google...
feedback_form = FeedbackForm(initial={'page': page})
Using the snippet: <|code_start|> register = template.Library() @register.simple_tag def feedback_form(request): page = request.META['PATH_INFO'] feedback_form = FeedbackForm(initial={'page': page}) return render_to_string('feedback/form.html', locals()) def render_query(request, query, limit=10): ...
already_voted = get_already_voted(request)
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python # Setup project environment in the parent directory. sys.path[0] = os.path.dirname(sys.path[0]) WORDS = """ ich mit einem wenig kostenlosen begabten verschraubenden Fuchs Traum Menschenfresser Dampfschiffahrt Dampfschifffahrt me with anoth...
word_score(word, english.TRIPLE_SCORES),
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python # Setup project environment in the parent directory. sys.path[0] = os.path.dirname(sys.path[0]) WORDS = """ ich mit einem wenig kostenlosen begabten verschraubenden Fuchs Traum Menschenfresser Dampfschiffahrt Dampfschifffahrt me with anoth...
word_score(word, english.TRIPLE_SCORES),
Given snippet: <|code_start|>#!/usr/bin/env python # Setup project environment in the parent directory. sys.path[0] = os.path.dirname(sys.path[0]) WORDS = """ ich mit einem wenig kostenlosen begabten verschraubenden Fuchs Traum Menschenfresser Dampfschiffahrt Dampfschifffahrt me with another little inexpensive ridic...
word_score(word, spanish.TRIPLE_SCORES),
Next line prediction: <|code_start|>#!/usr/bin/env python # Setup project environment in the parent directory. sys.path[0] = os.path.dirname(sys.path[0]) WORDS = """ ich mit einem wenig kostenlosen begabten verschraubenden Fuchs Traum Menschenfresser Dampfschiffahrt Dampfschifffahrt me with another little inexpensiv...
word_score(word, french.TRIPLE_SCORES),
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python # Setup project environment in the parent directory. sys.path[0] = os.path.dirname(sys.path[0]) WORDS = """ ich mit einem wenig kostenlosen begabten verschraubenden Fuchs Traum Menschenfresser Dampfschiffahrt Dampfschifffahrt me with another...
word_score(word, german.TRIPLE_SCORES),
Here is a snippet: <|code_start|>#!/usr/bin/env python # Setup project environment in the parent directory. sys.path[0] = os.path.dirname(sys.path[0]) setup_env() def auth_func(): return open('.passwd').read().split(':') def print_counts(name, counts): print name, '= {' keys = counts.keys() keys....
for c1 in DOMAIN_CHARS:
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python # Setup project environment in the parent directory. sys.path[0] = os.path.dirname(sys.path[0]) setup_env() def auth_func(): return open('.passwd').read().split(':') def print_counts(name, counts): print name, '= {' keys = co...
query = Prefix.all().filter('length', 2)
Based on the snippet: <|code_start|>#!/usr/bin/env python # Setup project environment in the parent directory. sys.path[0] = os.path.dirname(sys.path[0]) ACCEPTABLE_WORD_REGEX = re.compile('^[a-z0-9-]+$') def count_triples(words, counters): rejfile = open('rejected.txt', 'w') for word in words: wo...
for triple in word_triples(word):
Here is a snippet: <|code_start|> .. code-block:: json { "jsonrpc": "2.0", "method": "runCmds", "params": { "version": 1, "cmds": [ <commands> ], "f...
commands = make_iterable(commands)
Next line prediction: <|code_start|> super(Acls, self).__init__(node, *args, **kwargs) self._instances = dict() def get(self, name): return self.get_instance(name)[name] def getall(self): """Returns all ACLs in a dict object. Returns: A Python dictionary obj...
return ProxyCall(self.marshall, name)
Continue the code snippet: <|code_start|> command = 'no vrf instance %s' % vrf_name else: command = 'no vrf definition %s' % vrf_name return self.configure(command) def default(self, vrf_name): """ Defaults the VRF configuration for given name Args: ...
commands = make_iterable(commands)
Given snippet: <|code_start|> True if the create operation succeeds otherwise False. """ string = 'switchport trunk allowed vlan' command = self.command_builder(string, value=value, default=default, disable=disable) return self.configure_...
value = make_iterable(value)
Next line prediction: <|code_start|> def __init__(self, node, *args, **kwargs): super(Interfaces, self).__init__(node, *args, **kwargs) self._instances = dict() def get(self, name): return self.get_instance(name)[name] def getall(self): """Returns all interfaces in a dict ob...
return ProxyCall(self.marshall, name)
Here is a snippet: <|code_start|> """ command = 'no vlan %s' % vid return self.configure(command) if isvlan(vid) else False def default(self, vid): """ Defaults the VLAN configuration .. code-block:: none default vlan <vlanid> Args: vid (str...
commands = make_iterable(commands)
Given the following code snippet before the placeholder: <|code_start|> """ try: parent = r'^%s$' % parent return self.node.section(parent, config=config) except TypeError: return None def configure(self, commands): """Sends the commands list to th...
except (CommandError):
Next line prediction: <|code_start|> disable (bool): Specifies the command should use the no keyword argument. Disable preempts value. Returns: A command string that can be used to configure the node """ if default: return 'default %s' % string...
commands = make_iterable(commands)
Predict the next line for this snippet: <|code_start|> def create(self, ospf_process_id, vrf=None): """Creates a OSPF process in the specified VRF or the default VRF. Args: ospf_process_id (str): The OSPF process Id value vrf (str): The VRF to apply this OSPF proce...
cmds.extend(make_iterable(cmd))
Given the code snippet: <|code_start|> match = re.search(r'^router bgp (\d+)', config) return dict(bgp_as=int(match.group(1))) def _parse_router_id(self, config): match = re.search(r'router-id ([^\s]+)', config) value = match.group(1) if match else None return dict(router_id=...
cmds.extend(make_iterable(cmd))
Based on the snippet: <|code_start|>#!/usr/bin/env python # # Patchwork - automated patch tracking system # Copyright (C) 2008 Jeremy Kerr <jk@ozlabs.org> # Copyright (C) 2015 Intel Corporation # # This file is part of the Patchwork package. # # Patchwork is free software; you can redistribute it and/or modify # it und...
query = Patch.objects
Continue the code snippet: <|code_start|># # Patchwork is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Patchwork is distributed in ...
return {'bundles': Bundle.objects.filter(owner=user)}
Here is a snippet: <|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 Patchwork; if not, write to ...
EmailConfirmation.objects.all().delete()
Next line prediction: <|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 Patchwork; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 3...
Person.objects.all().delete()
Based on the snippet: <|code_start|># Patchwork - automated patch tracking system # Copyright (C) 2015 Intel Corporation # # This file is part of the Patchwork package. # # Patchwork 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...
self.user = TestUser()
Predict the next line after this snippet: <|code_start|># (at your option) any later version. # # Patchwork 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...
patch = Patch(project=defaults.project, msgid=name,
Predict the next line after this snippet: <|code_start|># Patchwork 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 recei...
submitter=Person.objects.get(user=self.user))
Here is a snippet: <|code_start|> response = self.client.post(self.url, data) self.assertContains(response, 'No patches to display', status_code=200) for patch in [Patch.objects.get(pk=p.pk) for p in self.patches]: self.assertTrue(patch.archived) def t...
state = State.objects.exclude(pk__in=states)[0]
Predict the next line after this snippet: <|code_start|># # Patchwork is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Patchwork is ...
self.patch = Patch(project=self.project, msgid='testpatch',
Predict the next line after this snippet: <|code_start|> self.project = defaults.project self.project.send_notifications = True self.project.save() self.submitter = defaults.patch_author_person self.submitter.save() self.patch = Patch(project=self.project, msgid='testpatch...
state = State.objects.exclude(pk=oldstate.pk)[0]
Predict the next line for this snippet: <|code_start|># along with Patchwork; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA class PatchNotificationModelTest(TestCase): fixtures = ['default_states', 'default_events'] """Tests for the creation...
self.assertEqual(PatchChangeNotification.objects.count(), 0)
Predict the next line for this snippet: <|code_start|> orig_state=self.patch.state).save() self._expireNotifications() errors = send_notifications() self.assertEqual(errors, []) self.assertEqual(len(mail.outbox), 1) msg = mail.outbox[0] sel...
EmailOptout(email=self.submitter.email).save()
Based on the snippet: <|code_start|> def series(self): try: rev = SeriesRevisionPatch.objects.filter(patch=self)[0].revision return rev.series except Exception: return None def _set_tag(self, tag, count): if count == 0: self.patchtag_set.fi...
self.hash = hash_patch(self.content).hexdigest()
Using the snippet: <|code_start|> def answers(self): """Retrieves the answers (ie all comments but the commit message)""" return Comment.objects.filter(Q(patch=self) & ~Q(msgid=self.msgid)) def comments(self): """Retrieves all comments of this patch ie. the commit message and the ...
counter = counter + extract_tags(comment.content, tags)
Next line prediction: <|code_start|> response = self.client.post(self.url, {'email': email}) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'patchwork/mail-settings.html') self.assertEqual(response.context['email'], email) def testMailSettingsPOSTEmpty(...
EmailOptout(email=email).save()
Predict the next line after this snippet: <|code_start|> self.assertContains(response, '<strong>may</strong>') optout_url = reverse('mail_optout') self.assertContains(response, ('action="%s"' % optout_url)) def testMailSettingsPOSTOptedOut(self): email = u'foo@example.com' Em...
self.assertEqual(EmailConfirmation.objects.count(), 1)
Here is a snippet: <|code_start|> self.url = reverse('user') self.optout_url = reverse('mail_optout') self.optin_url = reverse('mail_optin') self.form_re_template = (r'<form\s+[^>]*action="%(url)s"[^>]*>' r'.*?<input\s+[^>]*value="%(email)s"[^>]*>.*?' ...
p = Person(email=self.secondary_email, user=self.user)
Next line prediction: <|code_start|> ('WGirwRXgK', 'WGSrwRXgK@TriIETY.GhE', d(2014, 2, 14, 13, 4, 50, 169305)), ('isjNIuiAc', 'issNIuiAc@OsEirYx.EJh', d(2014, 3, 15, 13, 4, 50, 176264)), ('XkAQpYGws', 'XkFQpYGws@hzntTcm.JSE', d(2014, 1, 18, 13, 4, 50, 182493)), ...
person = Person(name=name, email=email)
Continue the code snippet: <|code_start|> ('isjNIuiAc', 'issNIuiAc@OsEirYx.EJh', d(2014, 3, 15, 13, 4, 50, 176264)), ('XkAQpYGws', 'XkFQpYGws@hzntTcm.JSE', d(2014, 1, 18, 13, 4, 50, 182493)), ('uJuCPWMvi', 'uJACPWMvi@AVRBOBl.ecy', d(2014, 3, 12, 13, 4, 50, 189554)), ...
patch = Patch(project=defaults.project, msgid=patch_name,
Given the code snippet: <|code_start|>#! /usr/bin/python #-------------------------------------------------------------------- # PROGRAM : get_path.py # CREATED BY : hjkim @IIS.2015-07-13 13:02:05.942756 # MODIFED BY : # # USAGE : $ ./get_path.py # # DESCRIPTION: #-----------------------------------------------...
parse_fname = {'TRMM': parse_fname_trmm,
Given the following code snippet before the placeholder: <|code_start|>#! /usr/bin/python #-------------------------------------------------------------------- # PROGRAM : get_path.py # CREATED BY : hjkim @IIS.2015-07-13 13:02:05.942756 # MODIFED BY : # # USAGE : $ ./get_path.py # # DESCRIPTION: #--------------...
'GPM' : parse_fname_gpm}[ prjName.split('.')[0] ]
Here is a snippet: <|code_start|>#! /usr/bin/python #-------------------------------------------------------------------- # PROGRAM : search_granules.py # CREATED BY : hjkim @IIS.2015-07-13 12:59:51.759752 # MODIFED BY : # # USAGE : $ ./search_granules.py # # DESCRIPTION: #--------------------------------------...
srcPATH = get_path(srcDir, sDTime, eDTime)
Next line prediction: <|code_start|>#! /usr/bin/python #-------------------------------------------------------------------- # PROGRAM : search_granules.py # CREATED BY : hjkim @IIS.2015-07-13 12:59:51.759752 # MODIFED BY : # # USAGE : $ ./search_granules.py # # DESCRIPTION: #-----------------------------------...
gtrkDim = [get_gtrack_dim(path, self.func_read, self.cached, self.cacheDir)
Using the snippet: <|code_start|>""" GridEYE_test.py Alexander Hiam <alex@graycat.io> Example program for PyBBIO's GridEYE library. Reads the current thermal sensor data and saves to thermal-image.png in the current directory. Requires the Python Imaging Library: # pip install PIL This example program is ...
grideye = GridEYE(I2C1)
Continue the code snippet: <|code_start|> exiting. *This should generally not be called directly from user code. """ if not gpio_pin: print "*unknown pinmux pin: %s" % gpio_pin return if SLOTS_FILE: status = pinMux_dtOverlays(gpio_pin, mode, preserve_mode_on_exit) else: status = pinMux...
addToCleanup(lambda: unexport(gpio_pin))
Here is a snippet: <|code_start|>""" GridEYE_test.py Alexander Hiam <alex@graycat.io> Example program for PyBBIO's GridEYE library. This example program is in the public domain. """ # Initialize the I2C bus: I2C1.open() # Create a GridEYE object: <|code_end|> . Write the next line using the current file imp...
grideye = GridEYE(I2C1)
Given snippet: <|code_start|> if not self.term.protocol: # Empty protocol list means any protocol, but any protocol in HF is # represented as "all" protocols_and_ports = [{'ipProtocol': 'all'}] else: for proto in filtered_protocols: # If the protocol name is not supported, use the...
any_ip = [nacaddr.IP('0.0.0.0/0')]
Given snippet: <|code_start|> self.destination = [] self.sport = [] self.dport = [] self.action = [] self.option = [] self.protocol = [] def __str__(self): rval = [] rval.append(' Term: %s' % self.name) rval.append(' Source-address:: %s' % ' '.join(self.source)) rval.append('...
self.defs = naming.Naming(defs_data)
Predict the next line after this snippet: <|code_start|> self._Parse(naming_dir, 'services') self._CheckUnseen('services') self._Parse(naming_dir, 'networks') self._CheckUnseen('networks') def _CheckUnseen(self, def_type): if def_type == 'services': if self.unseen_services: ...
if (not isinstance(query, nacaddr.IPv4) and
Next line prediction: <|code_start|> service = next_item.split('#')[0].strip() # Recognized token, not a value. if '/' not in service: # Make sure we are not descending into recursion hell. if service not in already_done: already_done.add(service) try: ex...
given_ppp = portlib.PPP(query + '/' + proto)
Predict the next line after this snippet: <|code_start|> To find the difference of network tokens to which 2 IPs belong use $ cgrep.py -g 1.1.1.1 2.2.2.2 To find which IPs are in the 'FOO' network token use $ cgrep.py -o FOO To find which port & protocol pairs are in a service token 'FOO' use $ cgrep.py -...
nacaddr.IP(arg)
Predict the next line for this snippet: <|code_start|> metavar=('OBJ', 'OBJ'), help=('Compare the two given network ' 'definition tokens')) exclusive_group.add_argument('-g', '--gmp', dest='gmp', nargs=2, ...
db = naming.Naming(options.defs)
Given the code snippet: <|code_start|># Copyright 2017 Google Inc. All Rights Reserved. # # 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 # # ...
class Term(aclgenerator.Term):
Using the snippet: <|code_start|># Copyright 2014 Google Inc. All Rights Reserved. # 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 ...
class Term(juniper.Term):
Given snippet: <|code_start|> a text representation of the config can be extracted with str(). attributes: indent: The number of leading spaces on the current line. lines: the text lines of the configuration. """ def __init__(self): self.lines = [] def __str__(self): return "\n".join(self.line...
class Term(aclgenerator.Term):
Continue the code snippet: <|code_start|># Copyright 2015 Google Inc. All Rights Reserved. # # 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 #...
class Term(iptables.Term):
Next line prediction: <|code_start|> """ target_af = self.AF_MAP[self.af] src_addr_list = self._CalculateAddrList(src_addr_list, src_addr_exclude_list, target_af, 'src') dst_addr_list = self._CalculateAddrList(dst_add...
addr_list = nacaddr.ExcludeAddrs(addr_list, addr_exclude_list)
Continue the code snippet: <|code_start|># Copyright 2016 Google Inc. All Rights Reserved. # # 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 #...
f = policy_simple.Field('Testvalue')
Predict the next line after this snippet: <|code_start|>"""Unittest for GCP Firewall Generator module.""" class HelperFunctionsTest(parameterized.TestCase): @parameterized.named_parameters( ('lowercase', 'project'), ('lowercase_w_hyphen', 'project-id'), ('lowercase_w_numbers', 'project123'), ...
self.assertTrue(gcp.IsProjectIDValid(project))
Given snippet: <|code_start|># Copyright 2007 Google Inc. All Rights Reserved. # # 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 re...
self.addr1 = nacaddr.IPv4(u'10.0.0.0/8', 'The 10 block')
Predict the next line after this snippet: <|code_start|>"""Google Cloud Armor Firewall Generator. Refer to the links below for more information https://cloud.google.com/armor/ https://cloud.google.com/armor/docs/ """ # Generic error class class Error(Exception): """Generic error class.""" class ExceededMaxTer...
class Term(aclgenerator.Term):
Predict the next line for this snippet: <|code_start|>NO_OVERFLOW_LONG = \ "This " + \ "is a long header. It's long on purpose. It's " + \ "purpose is to test that the splitting works co" + \ "rrectly. It should be well over the line limit" + \ ". If it is shorter, it would not test the limit." NO_...
result = WrapWords([test_input], 70)
Given the code snippet: <|code_start|> """ counter = 0 for i in self.source_address: if i.version == 6 and i.version in address_family: counter += self._IPV6_BYTE_SIZE elif i.version == 4 and i.version in address_family: counter += self._IPV4_BYTE_SIZE for i in self.destinatio...
self.flattened_saddr = nacaddr.AddressListExclude(
Predict the next line after this snippet: <|code_start|> Returns: policy object or False (if parse error). """ data = _ReadFile(filename) p = ParsePolicy(data, definitions, optimize, base_dir=base_dir, shade_check=shade_check, filename=filename) return p def ParsePolicy(data, definition...
globals()['DEFINITIONS'] = naming.Naming(DEFAULT_DEFINITIONS)
Predict the next line after this snippet: <|code_start|> This generate a pcap packet filter expression that either: 1) Matches (i.e., captures), the packets that match the ACCEPT clauses specified in a given policy, or 2) Matches the packets that match opposite of that, i.e., the DENY or REJECT clauses. S...
class Term(aclgenerator.Term):
Given the following code snippet before the placeholder: <|code_start|>"""Generic Google Cloud Platform multi-product generator. Base class for GCP firewalling products. """ class Error(Exception): """Generic error class.""" class TermError(Error): """Raised when a term is not valid.""" class HeaderError(...
class Term(aclgenerator.Term):
Given the code snippet: <|code_start|> file_directory = pathlib.Path(__file__).parent.absolute() exclude_address_testcases = [] with open(str(file_directory)+"/address_exclude_test_cases.txt", 'r') as f: for line in f: ipstr, exstrs, restrs = line.strip().split(' ') ip = nacaddr.IP(ipstr) exclude_ips =...
result = iputils.exclude_address(ip, exclude)
Given the following code snippet before the placeholder: <|code_start|> file_directory = pathlib.Path(__file__).parent.absolute() exclude_address_testcases = [] with open(str(file_directory)+"/address_exclude_test_cases.txt", 'r') as f: for line in f: ipstr, exstrs, restrs = line.strip().split(' ') <|code_end|...
ip = nacaddr.IP(ipstr)
Based on the snippet: <|code_start|> ('192.168.0.64', '0.0.255.31')) test_data = [(summarizer.DSMNet(3232235584, 4294967295), True, ('192.168.0.64', '32')), (summarizer.DSMNet(3232235584, 4294901760), True, ('192.168.0.64', '16')), ...
net = nacaddr.IPv4('192.' + str(255 - octet) + '.' +
Next line prediction: <|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 OF ANY KIND, eit...
net = summarizer.DSMNet(1 << 32, 4294967264)
Next line prediction: <|code_start|> def IsDefaultDeny(term): """Returns true if a term is a default deny without IPs, ports, etc.""" skip_attrs = ['flattened', 'flattened_addr', 'flattened_saddr', 'flattened_daddr', 'action', 'comment', 'name', 'logging'] if 'deny' not in term.action: return...
class Term(gcp.Term):
Given the code snippet: <|code_start|> rule['sourceRanges'] = [str(saddr) for saddr in chunk] rules.append(rule) elif daddrs: dest_addr_chunks = [ daddrs[x:x+self._TERM_ADDRESS_LIMIT] for x in range( 0, len(daddrs), self._TERM_ADDRESS_LIMIT)] for i, chunk in enumer...
'inet': nacaddr.IP('0.0.0.0/0'),
Here is a snippet: <|code_start|> """Returns true if a term is a default deny without IPs, ports, etc.""" skip_attrs = [ 'flattened', 'flattened_addr', 'flattened_saddr', 'flattened_daddr', 'action', 'comment', 'name', 'logging', 'direction' ] if 'deny' not in term.action: return False # This l...
class Term(aclgenerator.Term):
Next line prediction: <|code_start|> """Test proper handling of a non-existant service request.""" self.assertListEqual(self.defs.GetServiceByProto('SVC1', 'fud'), []) def testGetServiceByProto(self): self.assertListEqual(self.defs.GetServiceByProto('SVC1', 'tcp'), ['80', '82']) ...
[nacaddr.IPv4('10.0.0.0/8')])
Next line prediction: <|code_start|># Copyright 2007 Google Inc. All Rights Reserved. # # 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 # # un...
self.defs = naming.Naming(None)
Here is a snippet: <|code_start|> Useful for debugging. Args: num: number to be prettily formatted Returns: prettily formatted string """ # like ipaddr make assumption that this is ipv4 byte_strings = [] while num > 0 or len(byte_strings) < 4: byte_strings.append('{0:08b}'.format(num & 0xff)...
optimized_nets = nacaddr.CollapseAddrList(nets)
Based on the snippet: <|code_start|> class CgrepTest(absltest.TestCase): def setUp(self): super().setUp() self.db = naming.Naming(None) self.db.ParseServiceList(_SERVICE.split('\n')) self.db.ParseNetworkList(_NETWORK.split('\n')) # # test ip->token resolution (-i) # # 1.1.1.1 should only be...
ip = nacaddr.IP('1.1.1.1/32')
Given the code snippet: <|code_start|>LDAPS = 636/tcp IMAPS = 993/tcp POP_SSL = 995/tcp HIGH_PORTS = 1024-65535/tcp 1024-65535/udp MSSQL = 1433/tcp MSSQL_MONITOR = 1434/tcp RADIUS = 1812/tcp 1812/udp HSRP = 1985/udp NFSD = 2049/tcp 2049/udp NETFLOW = 2056/udp SQUID_PROXY = 3128/tcp MYSQL = 3306/tcp RDP = 3389/tcp IPSEC...
self.db = naming.Naming(None)
Predict the next line for this snippet: <|code_start|>MYSQL = 3306/tcp RDP = 3389/tcp IPSEC = 4500/udp POSTGRESQL = 5432/tcp TRACEROUTE = 33434-33534/udp """ class Namespace: def __init__(self, **kwargs): for arg in kwargs: setattr(self, arg, kwargs[arg]) class CgrepTest(absltest.TestCase): def setU...
results = cgrep.get_ip_parents(ip, self.db)
Given the following code snippet before the placeholder: <|code_start|> def __str__(self): return "[%d] %s" % (self.channel, self.payload) class PayloadMeta(type): def __new__(cls, name, bases, cls_members): for req in ("encode", "decode", "type"): if req not in cls_members: ...
argspec = ["%s: %s" % (pythonize(f.name), f.type)
Next line prediction: <|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 permissions ...
name = "%s_%s" % (pythonize(method.klass.name),
Given the following code snippet before the placeholder: <|code_start|> ordering = ['-created'] db_table = 'poloniex_balance' # def __str__(self): # return '{usd:0>6} US$ | {btc:0>10} BTC'.format( # usd=self.usd_balance, # btc=self.btc_balance # ) """ ...
choices=constants.ORDER_TYPES,
Based on the snippet: <|code_start|> @python_2_unicode_compatible class TradingStrategyProfile(models.Model): """Base trading strategy configuration models class.""" name = models.CharField(max_length=100) note = models.CharField(max_length=255, blank=True) account = models.ForeignKey(UserAccount) ...
buy = PriceField()
Predict the next line after this snippet: <|code_start|> @python_2_unicode_compatible class TradingStrategyProfile(models.Model): """Base trading strategy configuration models class.""" name = models.CharField(max_length=100) note = models.CharField(max_length=255, blank=True) account = models.Foreign...
buy = PercentField()
Continue the code snippet: <|code_start|> # NEVER BUY OR SELL UNLESS THESE ASSERTS PASS assert self.buy < 100 - min_fee assert self.sell > 100 + min_fee return super().save(*args, **kwargs) class SimpleMovingAverage(models.Model): period = models.CharField(max_length=100, default=25...
parameter = AmountField()
Given snippet: <|code_start|> @python_2_unicode_compatible class TradingStrategyProfile(models.Model): """Base trading strategy configuration models class.""" name = models.CharField(max_length=100) note = models.CharField(max_length=255, blank=True) <|code_end|> , continue by predicting the next line. C...
account = models.ForeignKey(UserAccount)
Given the code snippet: <|code_start|> class UserAccountForm(forms.Form): exchange = forms.ChoiceField( required=True, label=_("Exchange"), <|code_end|> , generate the next line using the imports in this file: from django import forms from crumpet.profiles import constants from django.utils.trans...
choices=constants.CRYPTO_EXCHANGES
Given the code snippet: <|code_start|> class ToTheMoonStrategyForm(forms.Form): exchange = forms.ChoiceField( required=False, label=_("Exchange"), <|code_end|> , generate the next line using the imports in this file: from django import forms from django.utils.translation import ugettext_lazy as ...
choices=constants.CRYPTO_EXCHANGES
Continue the code snippet: <|code_start|> urlpatterns = [ url( r"^$", <|code_end|> . Use current file imports: from django.conf.urls import url from django.contrib.auth.decorators import login_required from crumpet.backtests import views and context (classes, functions, or code) from other files: # Path...
login_required(views.BacktestingView.as_view(