Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Next line prediction: <|code_start|> _inputArray = True _returns = kwparams['_returns'] if isinstance(_returns,xmltypes.Array): _output = _returns _outputArray = True elif isinstance(_returns,list) or issubclass(_returns,xmltypes.PrimitiveType) or issubclass(_returns,complextypes.ComplexType): ...
fault = soap.SoapMessage()
Using the snippet: <|code_start|> """ Global variable. If you want use your own wsdl file """ wsdl_path = None def webservice(*params,**kwparams): """ Decorator method for web services operators """ def method(f): _input = None _output = None _inputArray = False _outputArray = False _args = None if len(...
if isinstance(_params,xmltypes.Array):
Here is a snippet: <|code_start|># Copyright 2011 Rodrigo Ancavil del Pino # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required b...
if inspect.isclass(_params) and issubclass(_params,complextypes.ComplexType):
Next line prediction: <|code_start|># Copyright 2017 Bo Shao. 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 # # Unles...
corp_dir = os.path.join(PROJECT_ROOT, 'Data', 'Corpus')
Next line prediction: <|code_start|># # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in wr...
predictor = BotPredictor(sess, corpus_dir=corp_dir, knbase_dir=knbs_dir,
Given the code snippet: <|code_start|> def init_login_manager(db): """Init security extensions (login manager and principal) :param db: Database which stores user accounts and roles :type db: ``flask_sqlalchemy.SQLAlchemy`` :return: Login manager and principal extensions :rtype: (``flask_login.Lo...
return db.session.query(UserAccount).get(int(user_id))
Based on the snippet: <|code_start|> def init_login_manager(db): """Init security extensions (login manager and principal) :param db: Database which stores user accounts and roles :type db: ``flask_sqlalchemy.SQLAlchemy`` :return: Login manager and principal extensions :rtype: (``flask_login.Logi...
login_manager.anonymous_user = Anonymous
Given snippet: <|code_start|>def logout(): """Logout the current user from the app""" flask_login.logout_user() clear_session('identity.name', 'identity.auth_type') flask_principal.identity_changed.send( flask.current_app._get_current_object(), identity=flask_principal.AnonymousIdentity(...
anonymous_role = db.session.query(Role).filter_by(
Continue the code snippet: <|code_start|> permissions = self.app.container.get('permissions') for role_name, role in self.provide_roles().items(): permissions.register_role(role_name) create_default_role(self.app, self.db, role) reload_anonymous_role(self.app, self.db) ...
return ExtensionView.from_class(self.__class__)
Given the following code snippet before the placeholder: <|code_start|> """ return [self.rolename] def owns_repo(self, repo): """Check if user owns the repository :param repo: Repository which shoudl be tested :type repo: ``repocribro.models.Repository`` :return: Fal...
roles_users = db.Table(
Predict the next line for this snippet: <|code_start|> """Repocribro is Flask web application :ivar container: Service container for the app :type container: ``repocribro.repocribro.DI_Container`` """ def __init__(self): """Setup Flask app and prepare service container""" super().__...
ext_master = ExtensionsMaster(app=app, db=db)
Predict the next line for this snippet: <|code_start|> """Setup Flask app and prepare service container""" super().__init__(PROG_NAME) self.container = DI_Container() def ext_call(self, what_to_call): """Call hook on all extensions :param what_to_call: name of hook to call ...
config = create_config(cfg_files)
Given the code snippet: <|code_start|> """Call hook on all extensions :param what_to_call: name of hook to call :type what_to_call: str :return: result of the call """ ext_master = self.container.get('ext_master') return ext_master.call(what_to_call) def create_...
check_config(config)
Next line prediction: <|code_start|> def test_login_logout(app, empty_db_session): with app.test_request_context('/'): account = UserAccount() account.id = 666 empty_db_session.add(account) empty_db_session.commit() <|code_end|> . Use current file imports: (import flask_login imp...
login(account)
Predict the next line after this snippet: <|code_start|> def test_login_logout(app, empty_db_session): with app.test_request_context('/'): account = UserAccount() account.id = 666 empty_db_session.add(account) empty_db_session.commit() login(account) assert flask_l...
logout()
Next line prediction: <|code_start|> def test_login_logout(app, empty_db_session): with app.test_request_context('/'): account = UserAccount() account.id = 666 empty_db_session.add(account) empty_db_session.commit() login(account) assert flask_login.current_user.id...
@permissions.roles.admin.require(403)
Predict the next line after this snippet: <|code_start|> def test_login_logout(app, empty_db_session): with app.test_request_context('/'): account = UserAccount() account.id = 666 empty_db_session.add(account) empty_db_session.commit() login(account) assert flask_l...
role_admin = Role('testadmin', '*', '')
Predict the next line for this snippet: <|code_start|>"""Start a tcp gateway.""" def common_tcp_options(func): """Supply common tcp gateway options.""" func = click.option( "-p", "--port", default=5003, show_default=True, type=int, help="TCP port of the connect...
@common_gateway_options
Given the code snippet: <|code_start|>"""Start a tcp gateway.""" def common_tcp_options(func): """Supply common tcp gateway options.""" func = click.option( "-p", "--port", default=5003, show_default=True, type=int, help="TCP port of the connection.", )(fun...
gateway = TCPGateway(event_callback=handle_msg, **kwargs)
Continue the code snippet: <|code_start|> """Supply common tcp gateway options.""" func = click.option( "-p", "--port", default=5003, show_default=True, type=int, help="TCP port of the connection.", )(func) func = click.option( "-H", "--host", requi...
run_async_gateway(gateway)
Based on the snippet: <|code_start|>"""Start a tcp gateway.""" def common_tcp_options(func): """Supply common tcp gateway options.""" func = click.option( "-p", "--port", default=5003, show_default=True, type=int, help="TCP port of the connection.", )(func)...
run_gateway(gateway)
Given snippet: <|code_start|>def common_tcp_options(func): """Supply common tcp gateway options.""" func = click.option( "-p", "--port", default=5003, show_default=True, type=int, help="TCP port of the connection.", )(func) func = click.option( "-H...
gateway = AsyncTCPGateway(event_callback=handle_msg, **kwargs)
Given the code snippet: <|code_start|>"""Start a tcp gateway.""" def common_tcp_options(func): """Supply common tcp gateway options.""" func = click.option( "-p", "--port", default=5003, show_default=True, type=int, help="TCP port of the connection.", )(fun...
gateway = TCPGateway(event_callback=handle_msg, **kwargs)
Given the code snippet: <|code_start|> I_SKETCH_VERSION = 12 # Used by OTA firmware updates. Request for node to reboot. I_REBOOT = 13 # Send by gateway to controller when startup is complete I_GATEWAY_READY = 14 class Stream(BaseConst): """MySensors stream sub-types.""" # Request new FW, ...
{Presentation.S_ARDUINO_NODE: is_version, Presentation.S_ARDUINO_RELAY: is_version}
Given snippet: <|code_start|> SetReq.V_VAR3, SetReq.V_VAR4, SetReq.V_VAR5, ], Presentation.S_DUST: [SetReq.V_DUST_LEVEL], Presentation.S_SCENE_CONTROLLER: [SetReq.V_SCENE_ON, SetReq.V_SCENE_OFF], } LOGICAL_ZERO = "0" LOGICAL_ONE = "1" OFF = "Off" HEAT_ON = "HeatOn" COOL_ON = "CoolOn"...
percent_int,
Based on the snippet: <|code_start|> help="Turn on retain on published messages at broker.", )(func) func = click.option( "--out-prefix", default="mygateway1-in", show_default=True, help="Topic prefix for outgoing messages.", )(func) func = click.option( "-...
@common_gateway_options
Given snippet: <|code_start|> show_default=True, help="Topic prefix for outgoing messages.", )(func) func = click.option( "--in-prefix", default="mygateway1-out", show_default=True, help="Topic prefix for incoming messages.", )(func) func = click.option( ...
mqttc.publish, mqttc.subscribe, event_callback=handle_msg, **kwargs
Based on the snippet: <|code_start|> help="MQTT port of the connection.", )(func) func = click.option("-b", "--broker", required=True, help="MQTT broker address.")( func ) return func @click.command(options_metavar="<options>") @common_mqtt_options @common_gateway_options def mqtt_gatew...
run_async_gateway(gateway, mqttc.stop())
Continue the code snippet: <|code_start|> )(func) func = click.option( "--in-prefix", default="mygateway1-out", show_default=True, help="Topic prefix for incoming messages.", )(func) func = click.option( "-p", "--port", default=1883, show_de...
run_gateway(gateway)
Predict the next line for this snippet: <|code_start|> default=1883, show_default=True, type=int, help="MQTT port of the connection.", )(func) func = click.option("-b", "--broker", required=True, help="MQTT broker address.")( func ) return func @click.command(opt...
gateway = AsyncMQTTGateway(
Given snippet: <|code_start|> default="mygateway1-in", show_default=True, help="Topic prefix for outgoing messages.", )(func) func = click.option( "--in-prefix", default="mygateway1-out", show_default=True, help="Topic prefix for incoming messages.", )(...
gateway = MQTTGateway(
Based on the snippet: <|code_start|> int(self.ack), int(self.sub_type), self.payload, ] ] ) + "\n" ) except ValueError: _LOGGER.e...
max=SYSTEM_CHILD_ID,
Given snippet: <|code_start|> raise def encode(self, delimiter=";"): """Encode a command string from message.""" try: return ( delimiter.join( [ str(f) for f in [ i...
const = get_const(protocol_version)
Using the snippet: <|code_start|> SetReq.V_PRESSURE: str, SetReq.V_FORECAST: vol.Any( str, vol.In( FORECASTS, msg=f"forecast must be one of: {', '.join(FORECASTS)}", ), ), SetReq.V_RAIN: str, SetReq.V_RAINRATE: str, SetReq.V_WIND: str, SetReq.V_...
[OFF, HEAT_ON, COOL_ON, AUTO_CHANGE_OVER],
Given the code snippet: <|code_start|> SetReq.V_PRESSURE: str, SetReq.V_FORECAST: vol.Any( str, vol.In( FORECASTS, msg=f"forecast must be one of: {', '.join(FORECASTS)}", ), ), SetReq.V_RAIN: str, SetReq.V_RAINRATE: str, SetReq.V_WIND: str, SetR...
[OFF, HEAT_ON, COOL_ON, AUTO_CHANGE_OVER],
Given the following code snippet before the placeholder: <|code_start|> def validate_v_rgbw(value): """Validate a V_RGBW value.""" if len(value) != 8: raise vol.Invalid(f"{value} is not eight characters long") return validate_hex(value) AUTO = "Auto" MAX = "Max" MIN = "Min" NORMAL = "Normal" # De...
FORECASTS,
Predict the next line after this snippet: <|code_start|> SetReq.V_PRESSURE: str, SetReq.V_FORECAST: vol.Any( str, vol.In( FORECASTS, msg=f"forecast must be one of: {', '.join(FORECASTS)}", ), ), SetReq.V_RAIN: str, SetReq.V_RAINRATE: str, SetReq.V_W...
[OFF, HEAT_ON, COOL_ON, AUTO_CHANGE_OVER],
Given snippet: <|code_start|> binascii.unhexlify(value) except Exception as exc: raise vol.Invalid(f"{value} is not of hex format") from exc return value def validate_v_rgb(value): """Validate a V_RGB value.""" if len(value) != 6: raise vol.Invalid(f"{value} is not six character...
[LOGICAL_ZERO, LOGICAL_ONE],
Continue the code snippet: <|code_start|> binascii.unhexlify(value) except Exception as exc: raise vol.Invalid(f"{value} is not of hex format") from exc return value def validate_v_rgb(value): """Validate a V_RGB value.""" if len(value) != 6: raise vol.Invalid(f"{value} is not s...
[LOGICAL_ZERO, LOGICAL_ONE],
Here is a snippet: <|code_start|> SetReq.V_PRESSURE: str, SetReq.V_FORECAST: vol.Any( str, vol.In( FORECASTS, msg=f"forecast must be one of: {', '.join(FORECASTS)}", ), ), SetReq.V_RAIN: str, SetReq.V_RAINRATE: str, SetReq.V_WIND: str, SetReq.V_...
[OFF, HEAT_ON, COOL_ON, AUTO_CHANGE_OVER],
Given the code snippet: <|code_start|> SetReq.V_IR_SEND: str, SetReq.V_IR_RECEIVE: str, SetReq.V_FLOW: str, SetReq.V_VOLUME: str, SetReq.V_LOCK_STATUS: vol.In( [LOGICAL_ZERO, LOGICAL_ONE], msg=f"value must be either {LOGICAL_ZERO} or {LOGICAL_ONE}", ), SetReq.V_LEVEL: str, ...
VALID_INTERNAL = dict(VALID_INTERNAL)
Here is a snippet: <|code_start|> SetReq.V_UNIT_PREFIX: str, SetReq.V_HVAC_SETPOINT_COOL: vol.All( vol.Coerce(float), vol.Range(min=0.0, max=100.0), vol.Coerce(str), msg=f"value must be between {0.0} and {100.0}", ), SetReq.V_HVAC_SETPOINT_HEAT: vol.All( vol.Coerce...
MessageType.stream: VALID_STREAM,
Here is a snippet: <|code_start|> I_CONFIG = 6 # When a sensor starts up, it broadcast a search request to all neighbor # nodes. They reply with a I_FIND_PARENT_RESPONSE. I_FIND_PARENT = 7 # Reply message type to I_FIND_PARENT request. I_FIND_PARENT_RESPONSE = 8 # Sent by the gateway to the C...
MessageType.presentation: list(Presentation),
Continue the code snippet: <|code_start|> # Reply message type to I_FIND_PARENT request. I_FIND_PARENT_RESPONSE = 8 # Sent by the gateway to the Controller to trace-log a message I_LOG_MESSAGE = 9 # A message that can be used to transfer child sensors # (from EEPROM routing table) of a repeating ...
MessageType.stream: list(Stream),
Predict the next line for this snippet: <|code_start|> I_CHILDREN = 10 # Optional sketch name that can be used to identify sensor in the # Controller GUI I_SKETCH_NAME = 11 # Optional sketch version that can be reported to keep track of the version # of sensor in the Controller GUI. I_SKETCH_...
Presentation.S_ARDUINO_NODE: is_version,
Using the snippet: <|code_start|> def validate_v_rgb(value): """Validate a V_RGB value.""" if len(value) != 6: raise vol.Invalid(f"{value} is not six characters long") return validate_hex(value) def validate_v_rgbw(value): """Validate a V_RGBW value.""" if len(value) != 8: raise v...
percent_int,
Continue the code snippet: <|code_start|>"""Show how to implement pymysensors async.""" logging.basicConfig(level=logging.DEBUG) def event(message): """Handle mysensors updates.""" print("sensor_update " + str(message.node_id)) LOOP = asyncio.get_event_loop() LOOP.set_debug(True) try: # To create a ...
GATEWAY = mysensors.AsyncSerialGateway(
Using the snippet: <|code_start|> I_HEARTBEAT = 18 # alias from version 2.0 I_PRESENTATION = 19 I_DISCOVER_REQUEST = 20 I_DISCOVER = 20 # alias from version 2.0 I_DISCOVER_RESPONSE = 21 I_HEARTBEAT_RESPONSE = 22 # Node is locked (reason in string-payload). I_LOCKED = 23 I_PING = 24 ...
VALID_INTERNAL = dict(VALID_INTERNAL)
Predict the next line after this snippet: <|code_start|> I_REGISTRATION_RESPONSE = 27 # Register response from GW I_DEBUG = 28 # Debug message I_SIGNAL_REPORT_REQUEST = 29 # Device signal strength request I_SIGNAL_REPORT_REVERSE = 30 # Internal I_SIGNAL_REPORT_RESPONSE = 31 # Device signal stren...
MessageType.presentation: VALID_PRESENTATION,
Here is a snippet: <|code_start|> I_DEBUG = 28 # Debug message I_SIGNAL_REPORT_REQUEST = 29 # Device signal strength request I_SIGNAL_REPORT_REVERSE = 30 # Internal I_SIGNAL_REPORT_RESPONSE = 31 # Device signal strength response (RSSI) I_PRE_SLEEP_NOTIFICATION = 32 # Message sent before node is ...
MessageType.set: VALID_SETREQ,
Predict the next line after this snippet: <|code_start|> I_SIGNAL_REPORT_RESPONSE = 31 # Device signal strength response (RSSI) I_PRE_SLEEP_NOTIFICATION = 32 # Message sent before node is going to sleep I_POST_SLEEP_NOTIFICATION = 33 # Message sent after node woke up VALID_MESSAGE_TYPES = { MessageT...
MessageType.stream: VALID_STREAM,
Given the code snippet: <|code_start|> I_REQUEST_SIGNING = 15 # alias from version 1.5 # Request for a nonce. I_NONCE_REQUEST = 16 I_GET_NONCE = 16 # alias from version 1.5 # Payload is nonce data. I_NONCE_RESPONSE = 17 I_GET_NONCE_RESPONSE = 17 # alias from version 1.5 I_HEARTBEAT_REQ...
MessageType.presentation: list(Presentation),
Given the following code snippet before the placeholder: <|code_start|> I_REQUEST_SIGNING = 15 # alias from version 1.5 # Request for a nonce. I_NONCE_REQUEST = 16 I_GET_NONCE = 16 # alias from version 1.5 # Payload is nonce data. I_NONCE_RESPONSE = 17 I_GET_NONCE_RESPONSE = 17 # alias fro...
MessageType.presentation: list(Presentation),
Continue the code snippet: <|code_start|> # Request for a nonce. I_NONCE_REQUEST = 16 I_GET_NONCE = 16 # alias from version 1.5 # Payload is nonce data. I_NONCE_RESPONSE = 17 I_GET_NONCE_RESPONSE = 17 # alias from version 1.5 I_HEARTBEAT_REQUEST = 18 I_HEARTBEAT = 18 # alias from versi...
MessageType.set: list(SetReq),
Given snippet: <|code_start|> # Payload is nonce data. I_NONCE_RESPONSE = 17 I_GET_NONCE_RESPONSE = 17 # alias from version 1.5 I_HEARTBEAT_REQUEST = 18 I_HEARTBEAT = 18 # alias from version 2.0 I_PRESENTATION = 19 I_DISCOVER_REQUEST = 20 I_DISCOVER = 20 # alias from version 2.0 I_...
MessageType.stream: list(Stream),
Next line prediction: <|code_start|> sensor.init_smart_sleep_mode() while sensor.queue: job = sensor.queue.popleft() msg.gateway.tasks.add_job(str, job) for child in sensor.children.values(): new_child_state = sensor.new_state.get(child.id) if not new_child_state: ...
if msg.child_id == SYSTEM_CHILD_ID:
Next line prediction: <|code_start|>"""Start a serial gateway.""" def common_serial_options(func): """Supply common serial gateway options.""" func = click.option( "-b", "--baud", default=115200, show_default=True, type=int, help="Baud rate of the serial connec...
@common_gateway_options
Given the code snippet: <|code_start|>"""Start a serial gateway.""" def common_serial_options(func): """Supply common serial gateway options.""" func = click.option( "-b", "--baud", default=115200, show_default=True, type=int, help="Baud rate of the serial conn...
gateway = SerialGateway(event_callback=handle_msg, **kwargs)
Continue the code snippet: <|code_start|> """Supply common serial gateway options.""" func = click.option( "-b", "--baud", default=115200, show_default=True, type=int, help="Baud rate of the serial connection.", )(func) func = click.option( "-p", "-...
run_async_gateway(gateway)
Using the snippet: <|code_start|>"""Start a serial gateway.""" def common_serial_options(func): """Supply common serial gateway options.""" func = click.option( "-b", "--baud", default=115200, show_default=True, type=int, help="Baud rate of the serial connectio...
run_gateway(gateway)
Predict the next line after this snippet: <|code_start|>def common_serial_options(func): """Supply common serial gateway options.""" func = click.option( "-b", "--baud", default=115200, show_default=True, type=int, help="Baud rate of the serial connection.", )...
gateway = AsyncSerialGateway(event_callback=handle_msg, **kwargs)
Predict the next line for this snippet: <|code_start|>"""Start a serial gateway.""" def common_serial_options(func): """Supply common serial gateway options.""" func = click.option( "-b", "--baud", default=115200, show_default=True, type=int, help="Baud rate of...
gateway = SerialGateway(event_callback=handle_msg, **kwargs)
Based on the snippet: <|code_start|> return def _message_callback(mqttc, userdata, msg): """Run callback for received message.""" callback(msg.topic, msg.payload.decode("utf-8"), msg.qos) self._mqttc.subscribe(topic, qos) self._mqttc.message_callback_add(topi...
GATEWAY = mysensors.MQTTGateway(
Predict the next line after this snippet: <|code_start|>"""Example for using pymysensors.""" logging.basicConfig(level=logging.DEBUG) def event(message): """Handle mysensors updates.""" print("sensor_update " + str(message.node_id)) # To create a serial gateway. <|code_end|> using the current file's impo...
GATEWAY = mysensors.SerialGateway(
Given the code snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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...
cstring = RegularExpression('.*')
Here is a snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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 opti...
guesser = Guesser(memorylist)
Predict the next line after this snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- #Copyright (C) 2008-2013 Nestor Arocha """Test BNF file loading""" class TestFileLoader(unittest.TestCase): """Loading a bnf instance from a .bnf file""" def testFileLoader(self): repository = {'integer...
self.assertTrue(load_bnf_file("pydsl/contrib/grammar/Date.bnf", repository))
Predict the next line after this snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- #Copyright (C) 2008-2013 Nestor Arocha """Test BNF file loading""" class TestFileLoader(unittest.TestCase): """Loading a bnf instance from a .bnf file""" def testFileLoader(self): repository = {'integer...
'DayOfMonth':load_python_file('pydsl/contrib/grammar/DayOfMonth.py')}
Using the snippet: <|code_start|># Needed because Python's regular expression matcher # uses "first match" not "longest match" rules. # For example, "C|Cl" matches only the "C" in "Cl" # The "-" in "-len(symbol)" is a trick to reverse the sort order. # # - then by the full symbol, to make it easier for people # (Thi...
raise ParseError("unknown character", t.lexpos)
Using the snippet: <|code_start|> def __eq__(self, anotherset): """Tests on itemlist equality""" if not isinstance(anotherset, LR0ItemSet): raise TypeError if len(self.itemlist) != len(anotherset.itemlist): return False for element in self.itemlist: ...
class LR0Parser(BottomUpParser):
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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...
Extended_S = NonTerminalSymbol("EI")
Given the code snippet: <|code_start|> #returns a set of itemsets while changed: changed = False for itemset in result[:]: for symbol in symbollist: if itemset.has_transition(symbol): #FIXME a symbol in a LR0item list? continue newit...
if isinstance(symbol, TerminalSymbol) and lritem.next_symbol() == symbol and itemset.has_transition(symbol):
Next line prediction: <|code_start|> # xxx <cursor><nonterminalSymbol> xxx append every rule from self._productionruleset that begins with that NonTerminalSymbol if not isinstance(itemset, LR0ItemSet): raise TypeError resultset = copy.copy(itemset) changed = True while changed: chan...
symbollist = productionset.getSymbols() + [EndSymbol()]
Given snippet: <|code_start|> if not isinstance(itemset, LR0ItemSet): raise TypeError resultset = copy.copy(itemset) changed = True while changed: changed = False for currentitem in resultset.itemlist: nextsymbol = currentitem.next_symbol() if nextsymbol is...
mainproductionrule = Production([Extended_S] , [productionset.initialsymbol, EndSymbol()])
Predict the next line after this snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- # This file is part of pydsl. # # pydsl 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...
return ParsleyGrammar(file.read(), root_rule, repository)
Next line prediction: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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...
if isinstance(definition, Choice):
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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...
mygrammar = OneOrMore(String("a"))
Here is a snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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 ...
self.assertTrue(isinstance(mygrammar, Grammar))
Using the snippet: <|code_start|>#the Free Software Foundation, either version 3 of the License, or #(at your option) any later version. # #pydsl 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 ...
mygrammar = ZeroOrMore(String("a"))
Given snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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 opti...
mygrammar = OneOrMore(String("a"))
Continue the code snippet: <|code_start|> class TestPEG(unittest.TestCase): def testOneOrMore(self): mygrammar = OneOrMore(String("a")) self.assertTrue(isinstance(mygrammar, Grammar)) self.assertEqual(mygrammar.first(), Choice([String("a")])) self.assertTrue(check(mygrammar, "a")) ...
mygrammar = Not(String("a"))
Using the snippet: <|code_start|> mygrammar = OneOrMore(String("a")) self.assertTrue(isinstance(mygrammar, Grammar)) self.assertEqual(mygrammar.first(), Choice([String("a")])) self.assertTrue(check(mygrammar, "a")) self.assertTrue(check(mygrammar, "aa")) self.assertTrue(ch...
mygrammar = Sequence((String("a"), String("b")))
Next line prediction: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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 yo...
self.assertEqual(mygrammar.first(), Choice([String("a")]))
Here is a snippet: <|code_start|>#!/usr/bin/env python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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 ...
self.assertTrue(check(mygrammar, "a"))
Given the following code snippet before the placeholder: <|code_start|> __author__ = "Nestor Arocha" __copyright__ = "Copyright 2008-2014, Nestor Arocha" __email__ = "nesaro@gmail.com" LOG = logging.getLogger(__name__) class LL1RecursiveDescentParser(TopDownParser): def get_trees(self, data, showerrors = False):...
if check(first_of_production, [self.current]):
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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...
class LL1RecursiveDescentParser(TopDownParser):
Continue the code snippet: <|code_start|>class LL1RecursiveDescentParser(TopDownParser): def get_trees(self, data, showerrors = False): # -> list: """ returns a list of trees with valid guesses """ if showerrors: raise NotImplementedError("This parser doesn't implement errors") s...
return ParseTree(left, right, symbol, content, childlist=childlist)
Predict the next line for this snippet: <|code_start|>#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. # #pydsl is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; witho...
except (IndexError, ParseError):
Using the snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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 opt...
ascii_encoding = Choice([String(chr(x)) for x in range(128)], calculate_base_alphabet=False)
Given snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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)...
ascii_encoding = Choice([String(chr(x)) for x in range(128)], calculate_base_alphabet=False)
Continue the code snippet: <|code_start|># along with pydsl. If not, see <http://www.gnu.org/licenses/>. __author__ = "Nestor Arocha" __copyright__ = "Copyright 2008-2015, Nestor Arocha" __email__ = "nesaro@gmail.com" LOG = logging.getLogger(__name__) class Symbol(object): pass class NonTerminalSymbol(str, Sym...
if not isinstance(gd, Grammar):
Continue the code snippet: <|code_start|> class NonTerminalSymbol(str, Symbol): def __init__(self, name): Symbol.__init__(self) def __str__(self): return "<NonTS: " + self + ">" def __hash__(self): return str.__hash__(self) def __eq__(self, other): if not isinstance(ot...
def check(self, data):# ->bool:
Given snippet: <|code_start|>__all__ = ['repository', 'iclass', 'root_rule', 'rules'] rules = """digit = anything:x ?(x in '0123456789') number = <digit+>:ds -> int(ds) expr = number:left ( '+' number:right -> left + right | -> left)""" root_rule="expr" <|code_end|> , continue by predicting the nex...
repository={'string':Sequence.from_string('fas')}
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python #This file is part of pydsl. # #pydsl 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,...
self.assertTrue(equal(String('a'), 'a', 'a'))
Given snippet: <|code_start|>#!/usr/bin/env python #This file is part of pydsl. # #pydsl 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. #...
self.assertTrue(equal(String('a'), 'a', 'a'))
Next line prediction: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- # This file is part of pydsl. # # pydsl 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 yo...
T=translator_factory(G)
Here is a snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- # This file is part of pydsl. # # pydsl 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 ...
C=checker_factory(G)
Here is a snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- # This file is part of pydsl. # # pydsl 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 ...
repository = {'DayOfMonth':load_python_file('pydsl/contrib/grammar/DayOfMonth.py')} #DayOfMonth loaded as checker
Next line prediction: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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...
ascii_lexer = lexer_factory(ascii_encoding, None)
Predict the next line after this snippet: <|code_start|>#!/usr/bin/python # -*- coding: utf-8 -*- #This file is part of pydsl. # #pydsl 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...
ascii_lexer = lexer_factory(ascii_encoding, None)