Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the code snippet: <|code_start|> if len(arguments) == 3: flags = _xpath_flags_to_re_flags(arguments[2]) else: flags = 0 def construct(eval_fn): def evaluate(): value = eval_fn() if is_sequence(value): return [re.sub(arguments[0], argument...
else:
Predict the next line for this snippet: <|code_start|> else: return re.sub(arguments[0], arguments[1], string_value(value), flags=flags) return evaluate return construct def _truncate_filter_link(arguments): def construct(eval_fn): length = int(arguments[0]) ...
r'rr:([^:]+):([^:]*):([i]*):': _regex_replace_filter_link,
Continue the code snippet: <|code_start|> clauses_pattern = re.compile(r'(\$\{[^\}]+\})|(\$[a-zA-Z_]\w*)|((?:[^\$]+))') def _join_filter_link(arguments): if arguments is None or len(arguments) == 0: delimiter = '' else: delimiter = arguments[0] def construct(eval_fn): return lam...
flags = 0
Using the snippet: <|code_start|> clauses_pattern = re.compile(r'(\$\{[^\}]+\})|(\$[a-zA-Z_]\w*)|((?:[^\$]+))') def _join_filter_link(arguments): if arguments is None or len(arguments) == 0: delimiter = '' <|code_end|> , determine the next line of code. You have imports: import re from hq.hquery.functi...
else:
Given snippet: <|code_start|> msg = 'interpolated string regex replace filter expects three arguments; got {0}' raise HquerySyntaxError(msg.format(arguments)) if len(arguments) == 3: flags = _xpath_flags_to_re_flags(arguments[2]) else: flags = 0 def construct(eval_fn): ...
value = eval_fn()
Here is a snippet: <|code_start|> return [re.sub(arguments[0], arguments[1], string_value(item), flags=flags) for item in value] else: return re.sub(arguments[0], arguments[1], string_value(value), flags=flags) return evaluate return construct def _truncate_filt...
r'j:([^:]*):': _join_filter_link,
Predict the next line after this snippet: <|code_start|> else: return truncate_string(string_value(value), length, suffix=suffix) return evaluate return construct filters = { r'j:([^:]*):': _join_filter_link, r'rr:([^:]+):([^:]*):([i]*):': _regex_replace_filter_link, ...
return eval_fn
Given the code snippet: <|code_start|> for pattern in filters: match = re.match(pattern, remainder) if match is not None: filter_constructor = filters[pattern]([html_entity_decode(arg) for arg in match.groups()]) remainder = remainder[match.span()[1]:] if chain is ...
else:
Using the snippet: <|code_start|> def _join_filter_link(arguments): if arguments is None or len(arguments) == 0: delimiter = '' else: delimiter = arguments[0] def construct(eval_fn): return lambda: string_join(eval_fn(), delimiter) return construct def _regex_replace_filter_l...
return evaluate
Continue the code snippet: <|code_start|> class RelationalOperator: def __init__(self, op): if op == '>': self.base_op = gt elif op == '>=': self.base_op = ge elif op == '<': <|code_end|> . Use current file imports: from operator import gt, lt, ge, le from hq.hque...
self.base_op = lt
Predict the next line for this snippet: <|code_start|> html_body = """ <p>bar</p> <p>foo</p>""" assert query_html_doc(html_body, '//p[matches("^f.+")]/text()') == expected_result('foo') def test_replace_function_performs_regex_replacement_as_per_xpath_30_functions_spec(): assert query_html_doc('',...
ta
Continue the code snippet: <|code_start|> def test_class_function_returns_true_when_element_has_name_in_class_attribute(): html_body = """ <p class="not selected">not selected</p> <p class="foo bar">expected</p>""" assert query_html_doc(html_body, 'class(//p[1], "foo")') == 'false' assert query_h...
even.""")
Here is a snippet: <|code_start|> sys.path.insert(0, os.path.abspath('../..')) def test_the_sum_of_decimals_is_a_decimal(): assert query_html_doc('', '90+8.6') == expected_result('98.6') assert query_html_doc('', '-0.2 + 0.1') == expected_result('-0.1') <|code_end|> . Write the next line using the current ...
def test_the_sum_of_integers_is_an_integer():
Given the code snippet: <|code_start|> assert query_html_doc('', '6div2') == expected_result('3') def test_mod_operator(): assert query_html_doc('', '11 mod 5') == expected_result('1') def test_interpretation_of_div_and_mod_and_other_arithmetic_operators_as_operators_vs_node_tests(): div = """ <div> ...
num_in_text = """
Using the snippet: <|code_start|> def make_node_set(node_set, reverse=False): ids = set() def is_unique_id(node): node_id = id(node) if node_id in ids: return False else: ids.add(node_id) return True if not isinstance(node_set, list): n...
if not isinstance(sequence, list):
Continue the code snippet: <|code_start|> def make_node_set(node_set, reverse=False): ids = set() def is_unique_id(node): node_id = id(node) if node_id in ids: return False else: ids.add(node_id) return True if not isinstance(node_set, list): ...
def make_sequence(sequence):
Given snippet: <|code_start|> def make_node_set(node_set, reverse=False): ids = set() def is_unique_id(node): node_id = id(node) if node_id in ids: return False else: ids.add(node_id) return True if not isinstance(node_set, list): node_...
if not isinstance(sequence, list):
Here is a snippet: <|code_start|> def test_equals_operator_interprets_integer_and_fractional_numbers_correctly(): actual = query_html_doc('', '101.0 != 101') assert actual == expected_result('false') def test_equals_operator_compares_string_value_of_node_converted_to_number_with_number(): actual = query_h...
</p>
Using the snippet: <|code_start|> sys.path.insert(0, os.path.abspath('../..')) def test_node_set_equality_is_based_on_text_contents(): html_body = """ <p>foo</p> <div>foo</div>""" actual = query_html_doc(html_body, '//p = //div') assert actual == expected_result('true') def test_node_sets_are_e...
</div>
Given the following code snippet before the placeholder: <|code_start|> return NUMBER elif is_string(obj): return STRING else: verbose_print('UH-OH! Returning None from object_type({0})'.format(obj.__class__.__name__)) return None def object_type_name(obj): result = 'NULL OR...
elif is_string(obj):
Given snippet: <|code_start|> return NUMBER elif is_string(obj): return STRING else: verbose_print('UH-OH! Returning None from object_type({0})'.format(obj.__class__.__name__)) return None def object_type_name(obj): result = 'NULL OR UNKNOWN TYPE' if obj is not None: ...
elif is_string(obj):
Based on the snippet: <|code_start|> def is_hash(obj): return obj.__class__.__name__ == 'JsonHash' def is_node_set(obj): return isinstance(obj, list) and all(is_any_node(x) for x in obj) def is_number(obj): return obj.__class__.__name__ == 'number' def is_sequence(obj): return isinstance(obj, list...
elif is_sequence(obj):
Using the snippet: <|code_start|> BOOLEAN, SEQUENCE, NUMBER, STRING = range(4) TYPE_NAMES = ('BOOLEAN', 'SEQUENCE', 'NUMBER', 'STRING') def debug_dump_anything(obj): if is_any_node(obj): result = debug_dump_node(obj) elif is_boolean(obj) or is_number(obj) or is_hash(obj) or is_array(obj): res...
def is_hash(obj):
Continue the code snippet: <|code_start|> def debug_dump_anything(obj): if is_any_node(obj): result = debug_dump_node(obj) elif is_boolean(obj) or is_number(obj) or is_hash(obj) or is_array(obj): result = repr(obj) elif is_string(obj): result = u'string("{0}")'.format(obj) elif ...
def is_node_set(obj):
Given snippet: <|code_start|> return STRING else: verbose_print('UH-OH! Returning None from object_type({0})'.format(obj.__class__.__name__)) return None def object_type_name(obj): result = 'NULL OR UNKNOWN TYPE' if obj is not None: if isinstance(obj, int): inde...
else:
Given the following code snippet before the placeholder: <|code_start|> result = u'string("{0}")'.format(obj) elif is_node_set(obj): result = u'node-set({0})'.format(', '.join(truncate_string(debug_dump_node(node), 20) for node in obj)) elif is_sequence(obj): result = u'sequence({0})'.for...
def is_sequence(obj):
Next line prediction: <|code_start|> return isinstance(obj, list) and all(is_any_node(x) for x in obj) def is_number(obj): return obj.__class__.__name__ == 'number' def is_sequence(obj): return isinstance(obj, list) def is_string(obj): return is_a_string(obj) def normalize_content(value): ret...
else:
Using the snippet: <|code_start|> def is_sequence(obj): return isinstance(obj, list) def is_string(obj): return is_a_string(obj) def normalize_content(value): return re.sub(r'\s+', ' ', string_value(value)) def object_type(obj): if is_boolean(obj): return BOOLEAN elif is_node_set(obj):...
result = 'NULL OR UNKNOWN TYPE'
Based on the snippet: <|code_start|> install_aliases() BOOLEAN, SEQUENCE, NUMBER, STRING = range(4) TYPE_NAMES = ('BOOLEAN', 'SEQUENCE', 'NUMBER', 'STRING') def debug_dump_anything(obj): if is_any_node(obj): result = debug_dump_node(obj) elif is_boolean(obj) or is_number(obj) or is_hash(obj) or is...
result = u'string("{0}")'.format(obj)
Using the snippet: <|code_start|> return isinstance(obj, list) def is_string(obj): return is_a_string(obj) def normalize_content(value): return re.sub(r'\s+', ' ', string_value(value)) def object_type(obj): if is_boolean(obj): return BOOLEAN elif is_node_set(obj): return SEQUENC...
if obj is not None:
Using the snippet: <|code_start|> def _route_choices(): # Only type='3' for buses at the moment ids = [] for route in Route.objects.filter(type='3').only('name'): try: name = int(route.name) except ValueError: <|code_end|> , determine the next line of code. You have imports: f...
name = route.name
Next line prediction: <|code_start|> class JinjaFilterTestCase(TestCase): def test_slugify(self): self.assertEquals('my-foo-bar', slugify('my @foo bar!!!')) self.assertEquals('my-foo-bar', slugify('MY______Foo@bAR')) def test_safe_strftime(self): self.assertEquals('', safe_strftime(N...
def test_money(self):
Continue the code snippet: <|code_start|> class JinjaFilterTestCase(TestCase): def test_slugify(self): self.assertEquals('my-foo-bar', slugify('my @foo bar!!!')) self.assertEquals('my-foo-bar', slugify('MY______Foo@bAR')) def test_safe_strftime(self): self.assertEquals('', safe_strft...
def test_money(self):
Given the code snippet: <|code_start|> class JinjaFilterTestCase(TestCase): def test_slugify(self): self.assertEquals('my-foo-bar', slugify('my @foo bar!!!')) self.assertEquals('my-foo-bar', slugify('MY______Foo@bAR')) def test_safe_strftime(self): self.assertEquals('', safe_strftime...
for period in ['seconds', 'minutes', 'hours', 'days', 'weeks']:
Predict the next line after this snippet: <|code_start|>REMINDER_TYPES = ReminderType.objects.all_tuples() NOTIFICATION_CHOICES = [ ('EMAIL', 'Email'), ('SMS', 'Text Message') ] class _DateForm(Form): month = SelectField('Month', coerce=int, choices=MONTH_CH...
validators=[
Using the snippet: <|code_start|> class ReminderForm(Form): type = SelectField('When', choices=REMINDER_TYPES, validators=[Required()]) # Type BAL, conditionally Required if type is BAL balance_threshold = DecimalField('Falls Below', ...
exp_threshold = SelectField('Is',
Here is a snippet: <|code_start|>class ReminderForm(Form): type = SelectField('When', choices=REMINDER_TYPES, validators=[Required()]) # Type BAL, conditionally Required if type is BAL balance_threshold = DecimalField('Falls Below', ...
validators=[
Predict the next line for this snippet: <|code_start|> def _create_tuple_range(start, stop): return [(int(x), str(x)) for x in xrange(start, stop)] DATE_QUANTIFIERS = ['Days', 'Weeks', 'Months'] DATE_RANGE_CHOICES = [(x, x) for x in DATE_QUANTIFIERS] DATE_THRESHOLD_CHOICES = _create_tuple_range(1, 11) # For Da...
datetime.now().year + 10))
Continue the code snippet: <|code_start|> class ReminderForm(Form): type = SelectField('When', choices=REMINDER_TYPES, validators=[Required()]) # Type BAL, conditionally Required if type is BAL balance_threshold = DecimalField('Falls Below', ...
exp_threshold = SelectField('Is',
Given snippet: <|code_start|> def setUp(self): super(PositiveNumberTestCase, self).setUp() self.validator = PositiveNumber() self.valids = ['1', '0', '100', '1000', '+1'] self.invalids = ['foo', '-1', '-1000'] def fake_raising_validator(*args): raise ValidationError('FooBar') ...
self.validator_ne(self.form, self.field)
Based on the snippet: <|code_start|> super(PhoneNumberTestCase, self).setUp() self.validator = PhoneNumber() self.valids = ['4042004824', '6782229899', '4042001234'] self.invalids = ['4045551234', '+14042004824', # Th...
def setUp(self):
Continue the code snippet: <|code_start|> self.valids = ['1111222233334444', '1111a2222b3333c4444d', ' 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4'] self.invalids = ['123', 'foo', '111222333444'] class ExactLengthTestCase(ValidatorTestCase): def setUp(self):...
'9113774878']
Given snippet: <|code_start|> '911', '411', '4049111234', '9113774878'] class PositiveNumberTestCase(ValidatorTestCase): def setUp(self): super(PositiveNumberTestCase, self).setUp() self.validator =...
validators=[fake_raising_validator],
Next line prediction: <|code_start|> def setUp(self): super(CardNumberTestCase, self).setUp() self.validator = CardNumber() self.valids = ['1111222233334444', '1111a2222b3333c4444d', ' 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4'] self.invalids ...
'911',
Next line prediction: <|code_start|> class ValidatorTestCase(TestCase): def setUp(self): self.form = Mock() self.field = Mock() self.valids = [] self.invalids = [] def test_for_valids(self): for val in self.valids: self.field.data = val self.as...
self.validator(self.form, self.field)
Given the following code snippet before the placeholder: <|code_start|> class BaseQuerySetTestCase(TestCase): def setUp(self): self.qs = BaseQuerySet(Mock(), Mock()) self.qs._document = Mock(spec=['_fields']) self.qs._document._fields = ['foo', 'bar', 'baz'] def test_get_or_404(self)...
def test_check_pk_hash(self):
Next line prediction: <|code_start|> model.train(X, y[:, 0]) super(DemoAcquisitionFunction, self).__init__(model) def compute(self, x, **kwargs): y = (0.5 - x) ** 2 return np.array([y]) class TestMaximizers1D(unittest.TestCase): def setUp(self): self.lower = np.array(...
assert len(x.shape) == 1
Using the snippet: <|code_start|> b = np.argmin(self.y) np.testing.assert_almost_equal(inc, self.X[b], decimal=5) class TestWrapperBohamiannMultiTask(unittest.TestCase): def setUp(self): X_task_1 = np.random.rand(10, 2) y_task_1 = np.sinc(X_task_1 * 10 - 5).sum(axis=1) X_ta...
assert len(m.shape) == 1
Given the following code snippet before the placeholder: <|code_start|> class TestPosteriorOptimization(unittest.TestCase): def setUp(self): X = np.random.randn(5, 2) y = np.sum((0.5 - X) ** 2, axis=1) self.model = DemoQuadraticModel() self.model.train(X, y) self.lower =...
def test_posterior_mean_optimization(self):
Predict the next line after this snippet: <|code_start|> class TestPosteriorOptimization(unittest.TestCase): def setUp(self): X = np.random.randn(5, 2) y = np.sum((0.5 - X) ** 2, axis=1) self.model = DemoQuadraticModel() self.model.train(X, y) self.lower = np.array([0, 0...
def test_posterior_mean_plus_std_optimization(self):
Predict the next line after this snippet: <|code_start|># coding=utf-8 class UserAdmin(BaseUserAdmin): list_display = ('username', 'full_name', 'date_joined', 'last_login', 'is_active') list_filter = ('is_active', 'is_staff', 'is_superuser') search_fields = ('username', 'email') date_hierarchy = 'dat...
)
Predict the next line for this snippet: <|code_start|># coding=utf-8 User = get_user_model() class DetailUser(DetailView): model = User def get_object(self, queryset=None): return self.request.user class CreateUser(CreateView): <|code_end|> with the help of current file imports: from django.v...
model = User
Given the code snippet: <|code_start|># coding=utf-8 User = get_user_model() class DetailUser(DetailView): model = User def get_object(self, queryset=None): return self.request.user class CreateUser(CreateView): model = User form_class = UserCreationForm <|code_end|> , generate the ne...
class UpdateUser(UpdateView):
Next line prediction: <|code_start|># coding=utf-8 class UserCreationForm(forms.ModelForm): """A form for creating new users. Includes all the required fields, plus a repeated password.""" password1 = forms.CharField(label=_('Password'), widget=forms.PasswordInput) password2 = forms.CharField(label=...
if password1 and password2 and password1 != password2:
Using the snippet: <|code_start|># coding=utf- class AccountTestCase(TestCase): def test_signin(self): client = Client() response = client.get(reverse('login')) self.assertEqual(response.status_code, 200) response = client.post(reverse('login'), {'username': 'wrong', 'password': ...
def test_change_password(self):
Given the code snippet: <|code_start|> def test_point_in_polygon(): point = {'x': 7500.0, 'y': 0.0, 'z': 7500.0} polygon_square = [[0, 0], [15000, 0], [15000, 15000], [0, 15000]] assert point_in_polygon(point=point, polygon=polygon_square) # точка окружена полигоном polygon_square = [[0, 0],...
pos1 = {'x': 0.0, 'y': 0.0, 'z': 0.0}
Given snippet: <|code_start|> def test_point_in_polygon(): point = {'x': 7500.0, 'y': 0.0, 'z': 7500.0} polygon_square = [[0, 0], [15000, 0], [15000, 15000], [0, 15000]] assert point_in_polygon(point=point, polygon=polygon_square) # точка окружена полигоном polygon_square = [[0, 0], [15000, ...
pos = None
Predict the next line after this snippet: <|code_start|># утилизация объекта? # T:32497 AType:16 BOTID:108551 POS(23899.598,154.684,20580.168) atype_16 = re.compile(r'^T:(?P<tik>\d+) AType:16 BOTID:(?P<bot_id>\d+) POS\((?P<pos>.+)\)$') # текущая позиция объекта # T:58 AType:17 ID:107519 POS(39013.016,45.535,16807...
atype_handlers = [
Predict the next line after this snippet: <|code_start|> def tours(request): return { 'TOURS': OrderedDict(((tour.id, tour) for tour in Tour.objects.all().order_by('-id'))) } def coalition_names(request): return { 'COAL_1_NAME': settings.COAL_1_NAME, 'COAL_2_NAME': ...
}
Next line prediction: <|code_start|>def test_atype_12_parachute(): line = 'T:171760 AType:12 ID:1266700 TYPE:CParachute_1266700 COUNTRY:101 NAME:CParachute_1266700 PID:-1' result = {'tik': 171760, 'atype_id': 12, 'object_id': 1266700, 'object_name': 'CParachute', 'country_id': 101, 'name': 'CPa...
result = {'tik': 0, 'atype_id': 13, 'area_id': 39936, 'country_id': 501, 'enabled': True,
Given the code snippet: <|code_start|> 'IDS:6f3b5e69-38d7-4d83-868c-4e7b8129f41a LOGIN:60dc67e3-ffb2-4df3-a6e5-579e945b4018 NAME:=FB=Vaal ' 'TYPE:Il-2 mod.1942 COUNTRY:101 FORM:0 FIELD:0 INAIR:0 PARENT:-1 ISPL:1 ISTSTART:1 PAYLOAD:0 FUEL:1.000 SKIN: WM:1') result = {'tik': 15, 'atype_id': 1...
result = {'tik': 51768, 'atype_id': 10, 'aircraft_id': 743436, 'bot_id': 840716, 'cartridges': 1200, 'shells': 0,
Using the snippet: <|code_start|> def assert_field_in_schema(self, syncano_class, unique): has_field = False for field_schema in syncano_class.schema: if field_schema['name'] == 'test_field{unique}'.format(unique=unique) and field_schema['type'] == 'string': has_field = Tr...
)
Continue the code snippet: <|code_start|> if script.label == script_name: is_script = True check_script = script # be explicit; break self.assertTrue(is_script) self.assertEqual(check_script.source, source) def get_script_path(self, unique...
{'name': 'test_field{unique}'.format(unique=unique), 'type': 'string'}
Here is a snippet: <|code_start|> raise Exception('not supported operation') with open(self.yml_file, 'wt') as f: f.write(yaml.safe_dump(yml_syncano, default_flow_style=False)) def create_syncano_class(self, unique): self.instance.classes.create( name='test_class...
)
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- class InstancesCommandsTest(BaseCLITest): def test_list(self): result = self._list_command() <|code_end|> , generate the next line using the imports in this file: from syncano_cli.config import ACCOUNT_CONFIG from syncano_cli.main import cli ...
self.assertIn(self.instance.name, result.output)
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- class InstancesCommandsTest(BaseCLITest): def test_list(self): result = self._list_command() self.assertIn(self.instance.name, result.output) def test_details(self): result = self.runner.invoke(cli, args=...
instance_name = 'some-cli-test-instance'
Predict the next line for this snippet: <|code_start|>class ConfigCommand(BaseInstanceCommand): def config_show(self): config = self.instance.get_config() self._show_config(config) def _show_config(self, config): self.formatter.write('Config for Instance {}'.format(self.instance.name),...
if name in config:
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- class VariableInConfigException(CLIBaseException): default_message = u'`{}` already in config, use `syncano config modify` instead.' class VariableNotFoundException(CLIBaseException): <|code_end|> , predict the next ...
default_message = u'Variable `{}` not found.'
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- @click.group() def top_instance(): pass @top_instance.group() <|code_end|> , predict the immediate next line with the help of imports: import sys import click from syncano_cli.base.connection import get_instance_name from syncano_cli.base.options im...
@click.pass_context
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- @click.group() def top_instance(): pass @top_instance.group() @click.pass_context @click.option('--config', help=u'Account configuration file.', default=ACCOUNT_CONFIG_PATH) <|code_end|> using the current file's imports: import ...
def instances(ctx, config):
Continue the code snippet: <|code_start|> @instances.command() @click.pass_context @click.argument('instance_name', required=False) def delete(ctx, instance_name): """Delete the Instance. Command will prompt you for permission.""" instance_commands = ctx.obj['instance_commands'] instance_name = get_instance...
@instances.command()
Given the code snippet: <|code_start|>@click.argument('instance_name', required=False) def delete(ctx, instance_name): """Delete the Instance. Command will prompt you for permission.""" instance_commands = ctx.obj['instance_commands'] instance_name = get_instance_name(ctx.obj['config'], instance_name) # de...
@click.option('--description')
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- @click.group() def top_instance(): pass @top_instance.group() @click.pass_context @click.option('--config', help=u'Account configuration file.', default=ACCOUNT_CONFIG_PATH) <|code_end|> , predict the immediate next line with the help of imports: im...
def instances(ctx, config):
Using the snippet: <|code_start|>@click.argument('instance_name', required=False) def delete(ctx, instance_name): """Delete the Instance. Command will prompt you for permission.""" instance_commands = ctx.obj['instance_commands'] instance_name = get_instance_name(ctx.obj['config'], instance_name) # default...
@click.option('--description')
Predict the next line for this snippet: <|code_start|>if six.PY2: elif six.PY3: else: raise ImportError() def get_instance_name(config, instance_name): ACCOUNT_CONFIG.read(config) try: instance_name = instance_name or ACCOUNT_CONFIG.get('DEFAULT', 'instance_name') except (NoOptionError, NoSect...
try:
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- if six.PY2: elif six.PY3: else: raise ImportError() def get_instance_name(config, instance_name): ACCOUNT_CONFIG.read(config) try: instance_name = instance_name or ACCOUNT_CONFIG.get('DEFAULT', 'instance_name') except (NoOptionE...
connection_dict = {
Given snippet: <|code_start|># -*- coding: utf-8 -*- if six.PY2: elif six.PY3: else: raise ImportError() def get_instance_name(config, instance_name): ACCOUNT_CONFIG.read(config) try: instance_name = instance_name or ACCOUNT_CONFIG.get('DEFAULT', 'instance_name') except (NoOptionError, NoSect...
try:
Given snippet: <|code_start|># -*- coding: utf-8 -*- class AccountCommands(BaseCommand): def __init__(self, config_path): self.connection = syncano.connect() self.config_path = config_path def register(self, email, password, first_name=None, last_name=None): api_key = self.connectio...
with open(self.config_path, 'wt') as fp:
Next line prediction: <|code_start|># coding=UTF8 from __future__ import print_function, unicode_literals ALLOWED_RUNTIMES = { 'golang': '.go', 'nodejs': '.js', 'nodejs_library_v0.4': '.js', <|code_end|> . Use current file imports: (import os import re import six from collections import defaultdict from...
'nodejs_library_v1.0': '.js',
Given the code snippet: <|code_start|> ALLOWED_RUNTIMES = { 'golang': '.go', 'nodejs': '.js', 'nodejs_library_v0.4': '.js', 'nodejs_library_v1.0': '.js', 'php': '.php', 'python': '.py', 'python3': '.py', 'python_library_v4.2': '.py', 'python_library_v5.0': '.py', 'ruby': '.rb', ...
if not filename.endswith(ext):
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- class ParseConnectionMixin(object): _parse = None @property def parse(self): if self._parse: return self._parse parse_connection = ParseConnection( application_id=self.config.get('P2S', 'PARSE_APPLICA...
)
Next line prediction: <|code_start|># -*- coding: utf-8 -*- class ParseConnectionMixin(object): _parse = None @property def parse(self): if self._parse: return self._parse parse_connection = ParseConnection( application_id=self.config.get('P2S', 'PARSE_APPLICATI...
)
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- class CLIBaseException(ClickException): default_message = u'A CLI processing exception.' def __init__(self, message=None, format_args=None): message = message or self.default_message if format_args: message = message.forma...
class SyncanoLibraryException(CLIBaseException):
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- class CLIBaseException(ClickException): default_message = u'A CLI processing exception.' def __init__(self, message=None, format_args=None): message = message or self.default_message if format_arg...
default_message = u'Invalid JSON data. Parse error.'
Given snippet: <|code_start|># -*- coding: utf-8 -*- class CLIBaseException(ClickException): default_message = u'A CLI processing exception.' def __init__(self, message=None, format_args=None): message = message or self.default_message if format_args: message = message.format(*f...
default_message = u'Invalid JSON data. Parse error.'
Continue the code snippet: <|code_start|> file_path = single_file self._validate_path(file_path) sys_path = os.path.join(folder, single_file) with open(sys_path, 'rb') as upload_file: self.formatter.write('* Uploading file: {}'.for...
def update_single_file(self, domain, path, file):
Based on the snippet: <|code_start|> def create_hosting(self, label, domain): hosting = self.instance.hostings.create( label=label, domains=[domain] ) return hosting def _get_hosting(self, domain, is_new=False): hostings = self.instance.hostings.all() ...
for hosting_file in hosting_files:
Next line prediction: <|code_start|> if domain_url[1:]: for domain_url in domain_url[1:]: self.formatter.write( '{0:30}{1:20}{2:20}'.format('', domain_url[0], domain_url[1]) ) self.formatter.empty_line() def list_hos...
for single_file in files:
Given the following code snippet before the placeholder: <|code_start|> for single_file in files: if path: file_path = '{}/{}'.format(path, single_file) else: file_path = single_file self._validate_path(file_path) ...
hosting_file.delete()
Next line prediction: <|code_start|># -*- coding: utf-8 -*- class HostingCommands(BaseInstanceCommand): VALID_PATH_REGEX = re.compile(r'^(?!/)([a-zA-Z0-9\-\._]+/{0,1})+(?<!/)\Z') def list_hostings(self): return [ (hosting.label, hosting.domains) for hosting in self.instance.hostings.all...
]
Next line prediction: <|code_start|> '{0:30}{1:20}{2:20}'.format('', domain_url[0], domain_url[1]) ) self.formatter.empty_line() def list_hosting_files(self, domain): hosting = self._get_hosting(domain=domain) files_list = hosting.list_files() ...
else:
Given the code snippet: <|code_start|> def list_hosting_files(self, domain): hosting = self._get_hosting(domain=domain) files_list = hosting.list_files() return files_list def publish(self, domain, base_dir): self.formatter.write('Your site is publishing.', SpacedOpt()) ...
self._validate_path(file_path)
Using the snippet: <|code_start|> class HostingCommands(BaseInstanceCommand): VALID_PATH_REGEX = re.compile(r'^(?!/)([a-zA-Z0-9\-\._]+/{0,1})+(?<!/)\Z') def list_hostings(self): return [ (hosting.label, hosting.domains) for hosting in self.instance.hostings.all() ] def print...
for domain_url in domain_url[1:]:
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- class ConfigCommandsTest(BaseCLITest): def test_config(self): self._add_config('test', '123') result = self._list_config() self.assertIn('test', result.output) self.assertIn('123', result.output) def test_add_config...
self.assertIn('already in config', result.output)
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- @click.group() def top_init(): pass @top_init.command() <|code_end|> using the current file's imports: import click from syncano_cli.base.command import BaseCommand from syncano_cli.base.options import DefaultOpt from syncano_cli....
@click.pass_context
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- class ExecuteCommand(BaseInstanceCommand): def execute(self, script_endpoint_name, data): se = self.instance.script_endpoints.get(name=script_endpoint_name) data = parse_input_data(data) response = se.run(**data) se...
except ValueError:
Next line prediction: <|code_start|># -*- coding: utf-8 -*- class ExecuteCommand(BaseInstanceCommand): def execute(self, script_endpoint_name, data): se = self.instance.script_endpoints.get(name=script_endpoint_name) data = parse_input_data(data) response = se.run(**data) self.fo...
self._print_result(response.result['stdout'])
Given snippet: <|code_start|># -*- coding: utf-8 -*- class ExecuteCommand(BaseInstanceCommand): def execute(self, script_endpoint_name, data): se = self.instance.script_endpoints.get(name=script_endpoint_name) data = parse_input_data(data) response = se.run(**data) self.formatter...
self.print_response(response)
Using the snippet: <|code_start|># -*- coding: utf-8 -*- class ExecuteCommand(BaseInstanceCommand): def execute(self, script_endpoint_name, data): se = self.instance.script_endpoints.get(name=script_endpoint_name) data = parse_input_data(data) response = se.run(**data) self.forma...
else:
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- class ExecuteCommand(BaseInstanceCommand): def execute(self, script_endpoint_name, data): se = self.instance.script_endpoints.get(name=script_endpoint_name) data = parse_input_data(data) respon...
def _print_result(self, result):