Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Based on the snippet: <|code_start|># coding: utf-8 def test_to_json_schema(): struct = Dictionary({ 'list': List( <|code_end|> , predict the immediate next line with the help of imports: from jinja2schema import core from jinja2schema.model import Dictionary, Scalar, List, Unknown, Tuple, Number, Boolea...
Tuple((
Based on the snippet: <|code_start|># coding: utf-8 def test_to_json_schema(): struct = Dictionary({ 'list': List( Tuple(( Dictionary({ 'field': Scalar(label='field', linenos=[3]), }, label='a', linenos=[3]), Scalar(label='b',...
'number_var': Number(),
Predict the next line for this snippet: <|code_start|># coding: utf-8 def test_to_json_schema(): struct = Dictionary({ 'list': List( Tuple(( Dictionary({ 'field': Scalar(label='field', linenos=[3]), }, label='a', linenos=[3]), ...
'boolean_var': Boolean(),
Based on the snippet: <|code_start|># coding: utf-8 def test_to_json_schema(): struct = Dictionary({ 'list': List( Tuple(( Dictionary({ 'field': Scalar(label='field', linenos=[3]), }, label='a', linenos=[3]), Scalar(label='b',...
'string_var': String(),
Given snippet: <|code_start|> Add a order number to make schema sortable. """ ORDER_NUMBER_SUB_COUNTER = True """Independent subsection order numbers Use a separate counter in subsections as order number creator. """ def __init__(self, TYPE_OF_VARIABLE_INDEXED_WITH_VARIAB...
self.ORDER_OBJECT = OrderNumber(number=1, enabled=self.ORDER_NUMBER,
Given snippet: <|code_start|> self.protocol.on(pattern, callback) log.msg('Registered %s for channel: %s' % (callback, pattern)) def cancel(self, pattern, callback): if not self.protocol: raise Exception('Event bus is not connected yet!') self.protocol.cancel(pattern, cal...
return txtimeout(d, timeout, lambda: d.callback(None))
Given the code snippet: <|code_start|> def test_inject_services(): class Boo(): pass class Baz(): pass def configure(binder): binder.bind(Boo, Baz()) <|code_end|> , generate the next line using the imports in this file: import inject from mcloud.util import inject_services and...
with inject_services(configure):
Continue the code snippet: <|code_start|> protocol.sendClose() self.clients = [] def register_task(self, name, callback): """ Add new task to task list """ self.tasks[name] = callback def bind(self): """ Start listening on the port specified ...
listen_ssl(self.port, Site(rootResource), interface=self.settings.websocket_ip)
Given snippet: <|code_start|> class ApiError(Exception): pass class ApiRpcServer(object): redis = inject.attr(txredisapi.Connection) <|code_end|> , continue by predicting the next line. Consider current file imports: import json import os import sys import inject import txredisapi from autobahn.twiste...
eb = inject.attr(EventBus)
Here is a snippet: <|code_start|>html_theme_path = ['themes/cloud.modera.org'] html_theme = 'docs_theme' # html_theme = 'basic' plantuml = 'java -jar %s/plantuml.jar' % os.path.dirname(__file__) # if not on_rtd: # only import and set the theme if we're building docs locally # import sphinx_rtd_theme # html_...
project = metadata.project
Given the code snippet: <|code_start|> def green(text): print(color_text(text, color='green')) def yellow(text): print(color_text(text, color='blue', bcolor='yellow')) def info(text): print() class ShellCancelInterruptHandler(object): def interrupt(self, last=None): if last is None: ...
raise InterruptCancel()
Given the following code snippet before the placeholder: <|code_start|> settings = inject.instance('settings') interrupt_manager = inject.instance('interrupt_manager') readline.parse_and_bind('tab: complete') if host_ref: app, host = host_ref.split('@') state = { 'app': app,...
cmd = subparsers.add_parser('use')
Given the following code snippet before the placeholder: <|code_start|> pass interrupt_manager.append(ShellCancelInterruptHandler()) # prevent stop reactor on Ctrl + C line = '' while line != 'exit': print('') prompt = 'mcloud: %s@%s> ' % (state['app'] or '~', state['host']) ...
args = arg_parser.parse_args(params)
Continue the code snippet: <|code_start|> readline.write_history_file(histfile) params = line.split(' ') args = arg_parser.parse_args(params) args.argv0 = sys.argv[0] if args.host: host = args.host elif state['host'] == 'me' or no...
client = ApiRpcClient(host=host, port=port, settings=settings)
Based on the snippet: <|code_start|> params = line.split(' ') args = arg_parser.parse_args(params) args.argv0 = sys.argv[0] if args.host: host = args.host elif state['host'] == 'me' or not state['host']: # manual variable ...
interrupt_manager.append(ClientProcessInterruptHandler(client))
Predict the next line after this snippet: <|code_start|> # no image or build {'foo': {}}, # some random key { 'foo': { 'build1': 'boo' } } ]) def test_validate_invalid(config): c = YamlConfig() with pytest.raises(ValueError): assert c.validate(config) d...
assert isinstance(c.services['nginx'], Service)
Given the code snippet: <|code_start|> assert isinstance(s.image_builder, InlineDockerfileImageBuilder) assert s.image_builder.files['Dockerfile'] == 'FROM foo\nWORKDIR boo' def test_build_image_dockerfile_no_path(): s = Service() c = YamlConfig() with pytest.raises(ConfigParseError): c.pr...
with pytest.raises(UnknownServiceError):
Continue the code snippet: <|code_start|>def test_load_config(tmpdir): p = tmpdir.join('mcloud.yml') p.write('foo: bar') config = YamlConfig(file=p.realpath(), app_name='myapp') flexmock(config).should_receive('prepare').with_args({'foo': 'bar'}).once().and_return({'foo': 'bar1'}) flexmock(config)...
with pytest.raises(ConfigParseError):
Given the following code snippet before the placeholder: <|code_start|> c = YamlConfig(env='dev') c.process_env_build(s, {}, '/base/path') assert s.env == {'env': 'dev'} def test_build_build_env_several(): s = Service() c = YamlConfig(env='prod') c.process_env_build(s, {'env': { 'foo1...
assert isinstance(s.image_builder, PrebuiltImageBuilder)
Given snippet: <|code_start|> c.process_env_build(s, {'env': { 'foo1': 'bar1', 'foo2': 'bar2', 'foo3': 'bar3', }}, '/base/path') assert s.env == { 'env': 'prod', 'foo1': 'bar1', 'foo2': 'bar2', 'foo3': 'bar3', } def test_build_image_image(): ...
assert isinstance(s.image_builder, DockerfileImageBuilder)
Using the snippet: <|code_start|> 'foo2': 'bar2', 'foo3': 'bar3', } def test_build_image_image(): s = Service() c = YamlConfig() c.process_image_build(s, {'image': 'foo/bar'}, '/base/path') assert isinstance(s.image_builder, PrebuiltImageBuilder) assert s.image_builder.image =...
assert isinstance(s.image_builder, InlineDockerfileImageBuilder)
Predict the next line for this snippet: <|code_start|> @pytest.inlineCallbacks def test_events(): inject.clear() rc = yield redis.Connection(dbid=2) yield rc.flushdb() <|code_end|> with the help of current file imports: import inject import pytest import txredisapi as redis from mcloud.events import Eve...
eb = EventBus(rc)
Using the snippet: <|code_start|> else: return [params] @staticmethod def _default_flatten(numq): if numq == 1: return lambda x: x else: return lambda x: itertools.chain(*x) def add_and_matches(self, matcher, lhs, params, numq=1, flatten=None): ...
expr = repeat(adapt_matcher(matcher)(lhs, *qs), len(params))
Next line prediction: <|code_start|># Copyright (C) 2013- Takafumi Arakaki # 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 version 3 of the License, or # (at your option) any later vers...
kwds = expand_query(self.config, {})
Given the code snippet: <|code_start|> :type data: dict :rtype: str .. [#] PID of the shell, i.e., PPID of this Python process. """ host = data['environ']['HOST'] tty = data['environ'].get('TTY') or 'NO_TTY' return ':'.join(map(str, [ host, tty, os.getppid(), data['start']])) def...
mkdirp(os.path.dirname(json_path))
Here is a snippet: <|code_start|> return ':'.join(map(str, [ host, tty, os.getppid(), data['start']])) def record_run(record_type, print_session_id, **kwds): """ Record shell history. """ if print_session_id and record_type != 'init': raise RuntimeError( '--print-session...
data.setdefault('cwd', getcwd())
Given snippet: <|code_start|> setifnonempty('TTY', get_tty()) if needset('RASH_SPENV_TERMINAL'): setifnonempty('RASH_SPENV_TERMINAL', detect_terminal()) return subenv def generate_session_id(data): """ Generate session ID based on HOST, TTY, PID [#]_ and start time. :type data: dic...
cfstore = ConfigStore()
Here is a 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 ConfigStore(object): """ Configuration and data file store. RASH stores data in the following directory in Linux:: ...
self.base_path = base_path or get_config_directory('RASH')
Next line prediction: <|code_start|> self.data_path = os.path.join(self.base_path, 'data') """ Directory to store data collected by RASH (``~/.config/rash/data``). """ self.record_path = os.path.join(self.data_path, 'record') """ Shell history is stored in this di...
mkdirp(self.record_path)
Predict the next line for this snippet: <|code_start|> if len(queue) > num: queue.pop(0) yield False for _ in queue: yield False def _forward_shifted_predicate(predicate, num, iterative, include_zero=True): counter = 0 for elem in iterative: if pr...
return (e for (e, p) in zip(it0, ps) if p)
Based on the snippet: <|code_start|> self.assertEqual(len(records['exit']), 1) self.assertEqual(len(records['command']), 1) command_data = [d['data'] for d in records['command']] self.assertEqual(command_data[0]['pipestatus'], [1, 0]) test_pipe_status_script = None """Set this t...
@skipIf(PY3, "watchdog does not support Python 3")
Using the snippet: <|code_start|> run_cli, ['init', '--shell', 'UNKNOWN_SHELL'], stderr=subprocess.PIPE) class FunctionalTestMixIn(object): """ MixIn class for isolating functional test environment. SOMEDAY: Make FunctionalTestMixIn work in non-*nix systems. (I think) This iso...
self.cfstore = ConfigStore(self.conf_base_path)
Given the following code snippet before the placeholder: <|code_start|> try: if os.path.exists(self.cfstore.daemon_pid_path): with open(self.cfstore.daemon_pid_path) as f: pid = f.read().strip() print("Daemon (PID={0}) may be left alive. Killing it...
class TestIsolation(FunctionalTestMixIn, BaseTestCase):
Predict the next line for this snippet: <|code_start|> self.assertEqual(len(records['exit']), 1) self.assertEqual(len(records['command']), 1) command_data = [d['data'] for d in records['command']] self.assertEqual(command_data[0]['pipestatus'], [1, 0]) test_pipe_status_script = None...
@skipIf(PY3, "watchdog does not support Python 3")
Given the code snippet: <|code_start|> def wrapper(*args, **kwds): if condition: print("Skipping {0} because:".format(func.__name__)) print(reason) else: return func(*args, **kwds) return wrapper r...
for values in zip_longest(*lists, fillvalue=fillvalue):
Based on the snippet: <|code_start|># (void)walker CPU architecture support # Copyright (C) 2013 David Holm <dholmster@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 version ...
return Architecture.Generic
Predict the next line for this snippet: <|code_start|># (void)walker CPU architecture support # Copyright (C) 2013 David Holm <dholmster@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 Foundatio...
registers[group] = [Register(x) for x in register_list]
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 ...
class TestInferiorFactory(InferiorFactory):
Next line prediction: <|code_start|> def __init__(self, cpu, inferior_id): super(TestInferior, self).__init__(cpu) self._id = inferior_id def id(self): return self._id def disassemble(self, address, length): return None def read_memory(self, address, length): re...
class TestThread(Thread):
Here is a snippet: <|code_start|> class TestInferiorFactory(InferiorFactory): def __init__(self): super(TestInferiorFactory, self).__init__(TestCpuFactory()) def create_inferior(self, cpu, inferior_id): return TestInferior(cpu, inferior_id) def create_thread(self, inferior, thread_id): ...
class TestThreadFactory(ThreadFactory):
Using the 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 this program. If not, see <...
super(TestInferiorFactory, self).__init__(TestCpuFactory())
Continue the code snippet: <|code_start|> return TestDataCommand() if issubclass(command_type, Command): class TestCommand(command_type): __doc__ = command_type.__doc__ def __init__(self): command_type.__init__(self) ...
elif issubclass(parameter_type, BooleanParameter):
Continue the code snippet: <|code_start|># (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 FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more detail...
if issubclass(command_type, Command):
Predict the next line for this snippet: <|code_start|># (void)walker unit test backend # Copyright (C) 2012 David Holm <dholmster@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; eith...
if issubclass(command_type, DataCommand):
Continue the code snippet: <|code_start|> def __init__(self): command_type.__init__(self) def invoke(self, argument, _): inferior = TestInferior() thread = TestThread(inferior.id(), 0) command_type.execute(s...
if issubclass(parameter_type, EnumParameter):
Given the following code snippet before the placeholder: <|code_start|> command_type.__init__(self) def invoke(self, argument, _): command_type.execute(self, terminal, argument) return TestCommand() else: raise TypeError('Command ...
elif issubclass(parameter_type, Parameter):
Given the code snippet: <|code_start|> class TestDataCommand(command_type): __doc__ = command_type.__doc__ def __init__(self): command_type.__init__(self) def invoke(self, argument, _): inferior = TestInferior() ...
class TestParameterFactory(ParameterFactory, object):
Next line prediction: <|code_start|># (void)walker unit test backend # Copyright (C) 2012 David Holm <dholmster@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 version 3 of th...
inferior = TestInferior()
Here is a snippet: <|code_start|># Copyright (C) 2012 David Holm <dholmster@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 version 3 of the License, or # (at your option) any...
thread = TestThread(inferior.id(), 0)
Next line prediction: <|code_start|> def __init__(self): super(HookParameter, self).__init__() def default_value(self): return None @staticmethod def name(): return '%s %s' % (VoidwalkerParameter.name(), 'hook') @register_parameter class ContextHookParameter(BooleanParameter)...
class VoidwalkerHookStop(StackCommand):
Given the following code snippet before the placeholder: <|code_start|> '''(void)walker hook parameters''' def __init__(self): super(HookParameter, self).__init__() def default_value(self): return None @staticmethod def name(): return '%s %s' % (VoidwalkerParameter.name(), ...
@register_command
Based on the snippet: <|code_start|># (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 FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # ...
class ContextHookParameter(BooleanParameter):
Predict the next line after this snippet: <|code_start|> def name(): return '%s %s' % (HookParameter.name(), 'context') def default_value(self): return self.DEFAULT_VALUE @register_command class VoidwalkerHookStop(StackCommand): '''This command should be called from GDB hook-stop. To supp...
gdb.execute(ContextCommand.name())
Continue the code snippet: <|code_start|> def __init__(self): super(ContextHookParameter, self).__init__() @staticmethod def name(): return '%s %s' % (HookParameter.name(), 'context') def default_value(self): return self.DEFAULT_VALUE @register_command class VoidwalkerHookSto...
return '%s %s' % (VoidwalkerCommand.name(), 'hook-stop')
Given the code snippet: <|code_start|> # 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 version 3 of the License, or # (at your option) any later version. # # This program is distributed i...
return '%s %s' % (VoidwalkerParameter.name(), 'hook')
Using the snippet: <|code_start|> super(SnippetCommand, self).__init__() class SnippetCommandBuilder(object): def __init__(self, snippet_repository): @register_command class ListSnippetsCommand(SupportCommand): '''List all the available snippets''' @staticmethod ...
class ApplySnippetCommand(StackCommand):
Given the code snippet: <|code_start|> @register_command class PatchCommand(PrefixCommand): '''Commands for patching code''' @staticmethod def name(): return '%s %s' % (VoidwalkerCommand.name(), 'patch') def __init__(self): super(PatchCommand, self).__init__() @register_command cla...
class ListSnippetsCommand(SupportCommand):
Given the code snippet: <|code_start|> '''Apply a snippet: <name> <address> Apply the specified snippet at the specified address. This operation will overwrite whatever is at that location in memory. The original binary is never touched by this command.''' @staticmethod def name(): ...
if ((architecture == Architecture.X8664 and
Predict the next line for this snippet: <|code_start|># (void)walker code patching interface # Copyright (C) 2012-2013 David Holm <dholmster@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 Found...
return '%s %s' % (VoidwalkerCommand.name(), 'patch')
Next line prediction: <|code_start|># (void)walker nop snippets # Copyright (C) 2012 David Holm <dholmster@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 version 3 of the Lic...
Architecture.Mips: CodeBlock(mips.nop())}
Using the snippet: <|code_start|> def create_generic_command(self, command_type): class GdbCommand(gdb.Command, command_type): __doc__ = command_type.__doc__ def __init__(self): command_type.__init__(self) gdb.Command.__init__(self, command_type.name(...
(BreakpointCommand, partial(self.create_brkp_command,
Using the snippet: <|code_start|>def get_current_thread(inferior_repository, inferior_factory, thread_factory): if gdb.selected_thread() is not None: thread_num = gdb.selected_thread().num inferior = get_current_inferior(inferior_repository, inferior_factory) if not i...
class GdbDataCommand(gdb.Command, command_type):
Here is a snippet: <|code_start|> return inferior_repository.get_inferior(inferior_num) def get_current_thread(inferior_repository, inferior_factory, thread_factory): if gdb.selected_thread() is not None: thread_num = gdb.selected_thread().num inferior = get_current_infe...
class GdbCommandFactory(CommandFactory, object):
Given the code snippet: <|code_start|> def create_brkp_command(self, command_type, terminal, inferior_repo): class GdbBreakpointCommand(gdb.Command, command_type): def __init__(self): command_type.__init__(self) gdb.Command.__init__(self, command_type.name(), ...
create_method = [(DataCommand, partial(self.create_data_command,
Given snippet: <|code_start|> args = parse_argument_list(argument) command_type.execute(self, terminal, inferior, args) return GdbBreakpointCommand() def create_generic_command(self, command_type): class GdbCommand(gdb.Command, command_type): __do...
(PrefixCommand, partial(self.create_prefix_command,
Using the snippet: <|code_start|> gdb.COMMAND_BREAKPOINTS, gdb.COMPLETE_NONE) def invoke(self, argument, _): inferior = get_current_inferior(inferior_repo) if inferior is not None: a...
(StackCommand, partial(self.create_stack_command,
Using the snippet: <|code_start|> return GdbBreakpointCommand() def create_generic_command(self, command_type): class GdbCommand(gdb.Command, command_type): __doc__ = command_type.__doc__ def __init__(self): command_type.__init__(self) gdb.Co...
(SupportCommand, partial(self.create_support_command,
Continue the code snippet: <|code_start|> self._address = address self._buffer = data_buffer def __len__(self): return len(self._buffer) def address(self): return self._address def buffer(self): return self._buffer class DataWidget(Widget): _ascii_filter = ''....
for line in grouper(line_len, self._data_chunk.buffer()):
Based on the 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 FITNESS FOR A PARTICULAR...
class ContextStackParameter(IntegerParameter):
Given the code snippet: <|code_start|># Copyright (C) 2012-2013 David Holm <dholmster@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 version 3 of the License, or # (at your o...
return '%s %s' % (VoidwalkerParameter.name(), 'context')
Continue the code snippet: <|code_start|># (void)walker GDB-specific interface # Copyright (C) 2012 David Holm <dholmster@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 versi...
return '%s %s' % (VoidwalkerCommand.name(), 'gdb')
Given snippet: <|code_start|> return GdbParameterInteger() def create_boolean_parameter(self, parameter_type): class GdbParameterBoolean(GdbBaseParameter, parameter_type): __doc__ = parameter_type.__doc__ show_doc = __doc__ set_doc = __doc__ def __ini...
(BooleanParameter, self.create_boolean_parameter),
Continue the code snippet: <|code_start|> self.value = parameter_type.default_value(self) return GdbParameterInteger() def create_boolean_parameter(self, parameter_type): class GdbParameterBoolean(GdbBaseParameter, parameter_type): __doc__ = parameter_type.__doc__ ...
create_method = [(EnumParameter, self.create_enum_parameter),
Using the snippet: <|code_start|> return GdbParameterInteger() def create_boolean_parameter(self, parameter_type): class GdbParameterBoolean(GdbBaseParameter, parameter_type): __doc__ = parameter_type.__doc__ show_doc = __doc__ set_doc = __doc__ def ...
(IntegerParameter, self.create_integer_parameter),
Next line prediction: <|code_start|> def create_boolean_parameter(self, parameter_type): class GdbParameterBoolean(GdbBaseParameter, parameter_type): __doc__ = parameter_type.__doc__ show_doc = __doc__ set_doc = __doc__ def __init__(self): par...
(PrefixParameter, self.create_generic_parameter),
Based on the snippet: <|code_start|># Copyright (C) 2012 David Holm <dholmster@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 version 3 of the License, or # (at your option) ...
return '%s %s' % (VoidwalkerParameter.name(), 'show')
Next line prediction: <|code_start|># 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 version 3 of the License, or # (at your option) any later version. # # This program is distributed in t...
class BreakTextCommand(BreakpointCommand):
Predict the next line for this snippet: <|code_start|># (void)walker GDB breakpoint control # Copyright (C) 2012 David Holm <dholmster@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;...
return '%s %s' % (GdbCommand.name(), 'break')
Based on the snippet: <|code_start|># (void)walker unit tests # Copyright (C) 2012 David Holm <dholmster@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 version 3 of the Licen...
inferior_repository = InferiorRepository()
Continue the code snippet: <|code_start|># 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/>. class InferiorTest(TestCase): def setUp(self): cpu_factory = TestCpuFact...
thread_factory = TestThreadFactory()
Given the following code snippet before the placeholder: <|code_start|># Copyright (C) 2012 David Holm <dholmster@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 version 3 of ...
inferior_factory = TestInferiorFactory()
Predict the next line after this snippet: <|code_start|># (void)walker assembler composer # Based on Pyasm by Florian Boesch, https://bitbucket.org/pyalot/pyasm/ # Copyright (C) 2012 David Holm <dholmster@gmail.com> # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU ...
stream = ByteStream()
Based on the snippet: <|code_start|> return self._process(unions) def _prepare_clipper(self, poly): """Prepare 2D polygons for clipping operations. :param poly: The clip polygon. :returns: A Pyclipper object. """ s1 = pc.scale_to_clipper(self.vertices_list) ...
if almostequal(poly.normal_vector, self.normal_vector):
Predict the next line after this snippet: <|code_start|> def test_copy_geometry(extracts_idf): idf = copy_geometry(extracts_idf) assert idf.getobject("ZONE", "z1 Thermal Zone") assert not idf.getobject("MATERIAL", "Spam") def test_copy_constructions(extracts_idf): <|code_end|> using the current file's i...
idf = copy_constructions(extracts_idf)
Based on the snippet: <|code_start|>"""Tests for fetching surfaces.""" class TestSurfaces: def test_surfaces(self, wwr_idf): # type: () -> None idf = wwr_idf surfaces = idf.getsurfaces() assert surfaces <|code_end|> , predict the immediate next line with the help of imports: from ...
assert all(isinstance(s, EpBunch) for s in surfaces)
Given the code snippet: <|code_start|> def __repr__(self): # type: () -> str class_name = type(self).__name__ return "{}({}, {})".format(class_name, self.p1, self.p2) def __neg__(self): # type: () -> Segment return Segment(self.p2, self.p1) def __iter__(self): ...
if almostequal(angle_between, Vector3D(0, 0, 0)):
Next line prediction: <|code_start|> def __init__(self, *vertices): # type: (*Vector3D) -> None self.vertices = vertices self.p1 = vertices[0] self.p2 = vertices[1] def __repr__(self): # type: () -> str class_name = type(self).__name__ return "{}({}, {})"....
if almostequal(other, self) or almostequal(other, -self):
Given the following code snippet before the placeholder: <|code_start|> }, { "name": "PN1001_Bld1003 Zone4", "coordinates": [ (-83616.24896021019, -100960.96199999936), (-83619.72295787116, -100976.95590000041), (-83636.55229433342, ...
adjacencies = get_adjacencies(new_idf.getsurfaces() + new_idf.getshadingsurfaces())
Given snippet: <|code_start|> "num_stories": 1, }, ] return {"zones": zones, "shadows": shadow_blocks} def _test_adjacencies(new_idf, shadow_intersecting): """Test in a single plane, but angled.""" try: ggr = new_idf.idfobjects["GLOBALGEOMETRYRULES"][0] except IndexError...
set_coords(new, new_coords, ggr)
Next line prediction: <|code_start|>"""Module for extracting the geometry from an existing IDF. There is the option to copy: - thermal zone description and geometry - surface construction elements """ def copy_constructions(source_idf, target_idf=None, fname="new.idf"): # type: (IDF, Optional[IDF], str) -> ID...
target_idf = target_idf or new_idf(fname)
Predict the next line after this snippet: <|code_start|>"""Tests for polygons.""" def test_polygon_repr(): # type: () -> None s2D = Polygon2D([(0, 0), (2, 0), (2, 0), (0, 0)]) # vertical assert eval(repr(s2D)) == s2D <|code_end|> using the current file's imports: from geomeppy.geom.polygons import ( ...
s3D = Polygon3D([(0, 0, 0), (2, 0, 0), (2, 2, 0), (0, 2, 0)]) # vertical
Predict the next line after this snippet: <|code_start|> """ childpid = os.fork() root = kwargs.get("root", "/mnt/sysimage") if not childpid: if not root in ["","/"]: os.chroot(root) os.chdir("/") del(os.environ["LIBUSER_CONF"])...
iutil.mkdirChain(root+'/home')
Here is a snippet: <|code_start|> message = _("Requested password contains " "non-ASCII characters, which are " "not allowed.") valid = False break if valid: try: strength = settings.check(pw, None, user) exc...
username = strip_accents(username).encode("utf-8")
Here is a snippet: <|code_start|> pwquality will raise a PWQError on a weak password, which, honestly, is kind of dumb behavior. A weak password isn't exceptional, it's what we're asking about! Anyway, this function does not raise PWQError. If the password fails the PWQSettings conditions, th...
validatePassword.pwqsettings.minlen = PASSWORD_MIN_LEN
Given snippet: <|code_start|># Chris Lumens <clumens@redhat.com> # __all__ = ["FakeDiskLabel", "FakeDisk", "getDisks", "isLocalDisk", "size_str"] class FakeDiskLabel(object): def __init__(self, free=0): self.free = free class FakeDisk(object): def __init__(self, name, size=0, fre...
if not flags.imageInstall:
Given the following code snippet before the placeholder: <|code_start|> :rtype: None """ if lang: lang.lang = locale os.environ["LANG"] = locale def get_english_name(locale): """ Function returning english name for the given locale. :param locale: locale to return english name fo...
return upcase_first_letter(name)
Given the following code snippet before the placeholder: <|code_start|> self._queue.put(('post', None)) def do_transaction(base, queue): try: display = PayloadRPMDisplay(queue) base.do_transaction(display=display) except BaseException as e: log.error('The transaction process ...
repo.sslverify = not (ksrepo.noverifyssl or flags.noverifyssl)
Given the code snippet: <|code_start|> if fileName[-3:] != ".py" and fileName[-4:-1] != ".py": continue mainName = fileName.split(".")[0] if done.has_key(mainName): continue done[mainName] = 1 try: found = imputil.imp.find_module(mainName) ...
if flags.debug: raise
Predict the next line for this snippet: <|code_start|> @property def l10n_domain(self): if self._l10n_domain is None: raise RuntimeError("Localization domain for '%s' not set." % self.name) return self._l10n_domain def setPackageSelection(self, ana...
disk_space = getAvailableDiskSpace(storage)
Given the code snippet: <|code_start|> if not keyboard.vc_keymap: populate_missing_items(keyboard) args = set() args.add("vconsole.keymap=%s" % keyboard.vc_keymap) args.add("vconsole.font=%s" % DEFAULT_VC_FONT) return args def _try_to_load_keymap(keymap): """ Method that tries to ...
ret = iutil.execWithRedirect("loadkeys", [keymap])