prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># Copyright (C) 2011-2015 Patrick Totzke <[email protected]> # This file is released under the GNU GPL, version 3 or a later revision. # For further details see the COPYING file from __future__ import absolute_import import re import abc class AddressbookError(Exception): pass class AddressBook(object): """can look up email addresses and realnames for contacts. .. note:: This is an abstract class that leaves :meth:`get_contacts` unspecified. See :class:`AbookAddressBook` and :class:`ExternalAddressbook` for implementations. """ __metaclass__ = abc.ABCMeta def __init__(self, ignorecase=True): self.reflags = re.IGNORECASE if ignorecase else 0 @abc.abstractmethod def get_contacts(self): # pragma no cover """list all contacts tuples in this abook as (name, email) tuples""" return [] def <|fim_middle|>(self, query=''): """looks up all contacts where name or address match query""" res = [] query = re.compile('.*%s.*' % query, self.reflags) for name, email in self.get_contacts(): if query.match(name) or query.match(email): res.append((name, email)) return res <|fim▁end|>
lookup
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2022 Google LLC # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<|fim▁hole|># See the License for the specific language governing permissions and # limitations under the License. # from .client import SearchServiceClient from .async_client import SearchServiceAsyncClient __all__ = ( "SearchServiceClient", "SearchServiceAsyncClient", )<|fim▁end|>
<|file_name|>object_fca.py<|end_file_name|><|fim▁begin|>class Object: def __init__(self, name):<|fim▁hole|> @property def name(self): return self._name<|fim▁end|>
self._name = name
<|file_name|>object_fca.py<|end_file_name|><|fim▁begin|>class Object: <|fim_middle|> <|fim▁end|>
def __init__(self, name): self._name = name @property def name(self): return self._name
<|file_name|>object_fca.py<|end_file_name|><|fim▁begin|>class Object: def __init__(self, name): <|fim_middle|> @property def name(self): return self._name <|fim▁end|>
self._name = name
<|file_name|>object_fca.py<|end_file_name|><|fim▁begin|>class Object: def __init__(self, name): self._name = name @property def name(self): <|fim_middle|> <|fim▁end|>
return self._name
<|file_name|>object_fca.py<|end_file_name|><|fim▁begin|>class Object: def <|fim_middle|>(self, name): self._name = name @property def name(self): return self._name <|fim▁end|>
__init__
<|file_name|>object_fca.py<|end_file_name|><|fim▁begin|>class Object: def __init__(self, name): self._name = name @property def <|fim_middle|>(self): return self._name <|fim▁end|>
name
<|file_name|>Execute.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # # Copyright (c) 2001 - 2016 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # __revision__ = "test/Execute.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" """ Test the Execute() function for executing actions directly. """ import TestSCons _python_ = TestSCons._python_ test = TestSCons.TestSCons() test.write('my_copy.py', """\ import sys open(sys.argv[2], 'wb').write(open(sys.argv[1], 'rb').read()) try: exitval = int(sys.argv[3]) except IndexError: exitval = 0 sys.exit(exitval) """) test.write('SConstruct', """\ Execute(r'%(_python_)s my_copy.py a.in a.out') Execute(Action(r'%(_python_)s my_copy.py b.in b.out')) env = Environment(COPY = 'my_copy.py') env.Execute(r'%(_python_)s my_copy.py c.in c.out') env.Execute(Action(r'%(_python_)s my_copy.py d.in d.out')) v = env.Execute(r'%(_python_)s $COPY e.in e.out')<|fim▁hole|>assert v == 0, v v = env.Execute(r'%(_python_)s $COPY g.in g.out 1') assert v == 1, v v = env.Execute(Action(r'%(_python_)s $COPY h.in h.out 2')) assert v == 2, v import shutil Execute(lambda target, source, env: shutil.copy('i.in', 'i.out')) Execute(Action(lambda target, source, env: shutil.copy('j.in', 'j.out'))) env.Execute(lambda target, source, env: shutil.copy('k.in', 'k.out')) env.Execute(Action(lambda target, source, env: shutil.copy('l.in', 'l.out'))) Execute(Copy('m.out', 'm.in')) Execute(Copy('nonexistent.out', 'nonexistent.in')) """ % locals()) test.write('a.in', "a.in\n") test.write('b.in', "b.in\n") test.write('c.in', "c.in\n") test.write('d.in', "d.in\n") test.write('e.in', "e.in\n") test.write('f.in', "f.in\n") test.write('g.in', "g.in\n") test.write('h.in', "h.in\n") test.write('i.in', "i.in\n") test.write('j.in', "j.in\n") test.write('k.in', "k.in\n") test.write('l.in', "l.in\n") test.write('m.in', "m.in\n") import sys if sys.platform == 'win32': expect = r"""scons: \*\*\* Error 1 scons: \*\*\* Error 2 scons: \*\*\* nonexistent.in/\*\.\*: (The system cannot find the path specified|Das System kann den angegebenen Pfad nicht finden)""" else: expect = r"""scons: \*\*\* Error 1 scons: \*\*\* Error 2 scons: \*\*\* nonexistent\.in: No such file or directory""" test.run(arguments = '.', stdout = None, stderr = None) test.must_contain_all_lines(test.stderr(), expect.splitlines(), find=TestSCons.search_re) test.must_match('a.out', "a.in\n") test.must_match('b.out', "b.in\n") test.must_match('c.out', "c.in\n") test.must_match('d.out', "d.in\n") test.must_match('e.out', "e.in\n") test.must_match('f.out', "f.in\n") test.must_match('g.out', "g.in\n") test.must_match('h.out', "h.in\n") test.must_match('i.out', "i.in\n") test.must_match('j.out', "j.in\n") test.must_match('k.out', "k.in\n") test.must_match('l.out', "l.in\n") test.must_match('m.out', "m.in\n") test.pass_test() # Local Variables: # tab-width:4 # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4:<|fim▁end|>
assert v == 0, v v = env.Execute(Action(r'%(_python_)s $COPY f.in f.out'))
<|file_name|>Execute.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # # Copyright (c) 2001 - 2016 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # __revision__ = "test/Execute.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" """ Test the Execute() function for executing actions directly. """ import TestSCons _python_ = TestSCons._python_ test = TestSCons.TestSCons() test.write('my_copy.py', """\ import sys open(sys.argv[2], 'wb').write(open(sys.argv[1], 'rb').read()) try: exitval = int(sys.argv[3]) except IndexError: exitval = 0 sys.exit(exitval) """) test.write('SConstruct', """\ Execute(r'%(_python_)s my_copy.py a.in a.out') Execute(Action(r'%(_python_)s my_copy.py b.in b.out')) env = Environment(COPY = 'my_copy.py') env.Execute(r'%(_python_)s my_copy.py c.in c.out') env.Execute(Action(r'%(_python_)s my_copy.py d.in d.out')) v = env.Execute(r'%(_python_)s $COPY e.in e.out') assert v == 0, v v = env.Execute(Action(r'%(_python_)s $COPY f.in f.out')) assert v == 0, v v = env.Execute(r'%(_python_)s $COPY g.in g.out 1') assert v == 1, v v = env.Execute(Action(r'%(_python_)s $COPY h.in h.out 2')) assert v == 2, v import shutil Execute(lambda target, source, env: shutil.copy('i.in', 'i.out')) Execute(Action(lambda target, source, env: shutil.copy('j.in', 'j.out'))) env.Execute(lambda target, source, env: shutil.copy('k.in', 'k.out')) env.Execute(Action(lambda target, source, env: shutil.copy('l.in', 'l.out'))) Execute(Copy('m.out', 'm.in')) Execute(Copy('nonexistent.out', 'nonexistent.in')) """ % locals()) test.write('a.in', "a.in\n") test.write('b.in', "b.in\n") test.write('c.in', "c.in\n") test.write('d.in', "d.in\n") test.write('e.in', "e.in\n") test.write('f.in', "f.in\n") test.write('g.in', "g.in\n") test.write('h.in', "h.in\n") test.write('i.in', "i.in\n") test.write('j.in', "j.in\n") test.write('k.in', "k.in\n") test.write('l.in', "l.in\n") test.write('m.in', "m.in\n") import sys if sys.platform == 'win32': <|fim_middle|> else: expect = r"""scons: \*\*\* Error 1 scons: \*\*\* Error 2 scons: \*\*\* nonexistent\.in: No such file or directory""" test.run(arguments = '.', stdout = None, stderr = None) test.must_contain_all_lines(test.stderr(), expect.splitlines(), find=TestSCons.search_re) test.must_match('a.out', "a.in\n") test.must_match('b.out', "b.in\n") test.must_match('c.out', "c.in\n") test.must_match('d.out', "d.in\n") test.must_match('e.out', "e.in\n") test.must_match('f.out', "f.in\n") test.must_match('g.out', "g.in\n") test.must_match('h.out', "h.in\n") test.must_match('i.out', "i.in\n") test.must_match('j.out', "j.in\n") test.must_match('k.out', "k.in\n") test.must_match('l.out', "l.in\n") test.must_match('m.out', "m.in\n") test.pass_test() # Local Variables: # tab-width:4 # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4: <|fim▁end|>
expect = r"""scons: \*\*\* Error 1 scons: \*\*\* Error 2 scons: \*\*\* nonexistent.in/\*\.\*: (The system cannot find the path specified|Das System kann den angegebenen Pfad nicht finden)"""
<|file_name|>Execute.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # # Copyright (c) 2001 - 2016 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # __revision__ = "test/Execute.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" """ Test the Execute() function for executing actions directly. """ import TestSCons _python_ = TestSCons._python_ test = TestSCons.TestSCons() test.write('my_copy.py', """\ import sys open(sys.argv[2], 'wb').write(open(sys.argv[1], 'rb').read()) try: exitval = int(sys.argv[3]) except IndexError: exitval = 0 sys.exit(exitval) """) test.write('SConstruct', """\ Execute(r'%(_python_)s my_copy.py a.in a.out') Execute(Action(r'%(_python_)s my_copy.py b.in b.out')) env = Environment(COPY = 'my_copy.py') env.Execute(r'%(_python_)s my_copy.py c.in c.out') env.Execute(Action(r'%(_python_)s my_copy.py d.in d.out')) v = env.Execute(r'%(_python_)s $COPY e.in e.out') assert v == 0, v v = env.Execute(Action(r'%(_python_)s $COPY f.in f.out')) assert v == 0, v v = env.Execute(r'%(_python_)s $COPY g.in g.out 1') assert v == 1, v v = env.Execute(Action(r'%(_python_)s $COPY h.in h.out 2')) assert v == 2, v import shutil Execute(lambda target, source, env: shutil.copy('i.in', 'i.out')) Execute(Action(lambda target, source, env: shutil.copy('j.in', 'j.out'))) env.Execute(lambda target, source, env: shutil.copy('k.in', 'k.out')) env.Execute(Action(lambda target, source, env: shutil.copy('l.in', 'l.out'))) Execute(Copy('m.out', 'm.in')) Execute(Copy('nonexistent.out', 'nonexistent.in')) """ % locals()) test.write('a.in', "a.in\n") test.write('b.in', "b.in\n") test.write('c.in', "c.in\n") test.write('d.in', "d.in\n") test.write('e.in', "e.in\n") test.write('f.in', "f.in\n") test.write('g.in', "g.in\n") test.write('h.in', "h.in\n") test.write('i.in', "i.in\n") test.write('j.in', "j.in\n") test.write('k.in', "k.in\n") test.write('l.in', "l.in\n") test.write('m.in', "m.in\n") import sys if sys.platform == 'win32': expect = r"""scons: \*\*\* Error 1 scons: \*\*\* Error 2 scons: \*\*\* nonexistent.in/\*\.\*: (The system cannot find the path specified|Das System kann den angegebenen Pfad nicht finden)""" else: <|fim_middle|> test.run(arguments = '.', stdout = None, stderr = None) test.must_contain_all_lines(test.stderr(), expect.splitlines(), find=TestSCons.search_re) test.must_match('a.out', "a.in\n") test.must_match('b.out', "b.in\n") test.must_match('c.out', "c.in\n") test.must_match('d.out', "d.in\n") test.must_match('e.out', "e.in\n") test.must_match('f.out', "f.in\n") test.must_match('g.out', "g.in\n") test.must_match('h.out', "h.in\n") test.must_match('i.out', "i.in\n") test.must_match('j.out', "j.in\n") test.must_match('k.out', "k.in\n") test.must_match('l.out', "l.in\n") test.must_match('m.out', "m.in\n") test.pass_test() # Local Variables: # tab-width:4 # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4: <|fim▁end|>
expect = r"""scons: \*\*\* Error 1 scons: \*\*\* Error 2 scons: \*\*\* nonexistent\.in: No such file or directory"""
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>from .DiscreteFactor import State, DiscreteFactor from .CPD import TabularCPD from .JointProbabilityDistribution import JointProbabilityDistribution<|fim▁hole|> 'DiscreteFactor', 'State' ]<|fim▁end|>
__all__ = ['TabularCPD',
<|file_name|>server.py<|end_file_name|><|fim▁begin|># DO NOT EDIT THIS FILE. This file will be overwritten when re-running go-raml. from app import app import gevent from gevent.pywsgi import WSGIServer from gevent.pool import Pool from gevent import monkey import signal monkey.patch_all() server = WSGIServer(('', 5000), app, spawn=Pool(None)) <|fim▁hole|> server.stop() gevent.signal(signal.SIGINT, stop) if __name__ == "__main__": server.serve_forever()<|fim▁end|>
def stop():
<|file_name|>server.py<|end_file_name|><|fim▁begin|># DO NOT EDIT THIS FILE. This file will be overwritten when re-running go-raml. from app import app import gevent from gevent.pywsgi import WSGIServer from gevent.pool import Pool from gevent import monkey import signal monkey.patch_all() server = WSGIServer(('', 5000), app, spawn=Pool(None)) def stop(): <|fim_middle|> gevent.signal(signal.SIGINT, stop) if __name__ == "__main__": server.serve_forever() <|fim▁end|>
server.stop()
<|file_name|>server.py<|end_file_name|><|fim▁begin|># DO NOT EDIT THIS FILE. This file will be overwritten when re-running go-raml. from app import app import gevent from gevent.pywsgi import WSGIServer from gevent.pool import Pool from gevent import monkey import signal monkey.patch_all() server = WSGIServer(('', 5000), app, spawn=Pool(None)) def stop(): server.stop() gevent.signal(signal.SIGINT, stop) if __name__ == "__main__": <|fim_middle|> <|fim▁end|>
server.serve_forever()
<|file_name|>server.py<|end_file_name|><|fim▁begin|># DO NOT EDIT THIS FILE. This file will be overwritten when re-running go-raml. from app import app import gevent from gevent.pywsgi import WSGIServer from gevent.pool import Pool from gevent import monkey import signal monkey.patch_all() server = WSGIServer(('', 5000), app, spawn=Pool(None)) def <|fim_middle|>(): server.stop() gevent.signal(signal.SIGINT, stop) if __name__ == "__main__": server.serve_forever() <|fim▁end|>
stop
<|file_name|>test_twelve_tone.py<|end_file_name|><|fim▁begin|>from click.testing import CliRunner<|fim▁hole|>from twelve_tone.cli import main def test_main(): runner = CliRunner() result = runner.invoke(main, []) assert result.exit_code == 0<|fim▁end|>
<|file_name|>test_twelve_tone.py<|end_file_name|><|fim▁begin|> from click.testing import CliRunner from twelve_tone.cli import main def test_main(): <|fim_middle|> <|fim▁end|>
runner = CliRunner() result = runner.invoke(main, []) assert result.exit_code == 0
<|file_name|>test_twelve_tone.py<|end_file_name|><|fim▁begin|> from click.testing import CliRunner from twelve_tone.cli import main def <|fim_middle|>(): runner = CliRunner() result = runner.invoke(main, []) assert result.exit_code == 0 <|fim▁end|>
test_main
<|file_name|>flow_management.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import render_template, redirect, url_for, flash, abort from purchasing.decorators import requires_roles from purchasing.data.stages import Stage from purchasing.data.flows import Flow from purchasing.conductor.forms import FlowForm, NewFlowForm from purchasing.conductor.manager import blueprint @blueprint.route('/flow/new', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def new_flow(): '''Create a new flow :status 200: Render the new flow template :status 302: Try to create a new flow using the :py:class:`~purchasing.conductor.forms.NewFlowForm`, redirect to the flows list view if successful ''' stages = Stage.choices_factory() form = NewFlowForm(stages=stages) if form.validate_on_submit(): stage_order = [] for entry in form.stage_order.entries: # try to evaluate the return value as an ID try: stage_id = int(entry.data) # otherwise it's a new stage except ValueError: new_stage = Stage.create(name=entry.data) stage_id = new_stage.id stage_order.append(stage_id) Flow.create(flow_name=form.flow_name.data, stage_order=stage_order) flash('Flow created successfully!', 'alert-success') return redirect(url_for('conductor.flows_list')) return render_template('conductor/flows/new.html', stages=stages, form=form) @blueprint.route('/flows') @requires_roles('conductor', 'admin', 'superadmin') def flows_list(): '''List all flows :status 200: Render the all flows list template ''' flows = Flow.query.order_by(Flow.flow_name).all() active, archived = [], [] for flow in flows: if flow.is_archived: archived.append(flow) else: active.append(flow) return render_template('conductor/flows/browse.html', active=active, archived=archived) @blueprint.route('/flow/<int:flow_id>', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def flow_detail(flow_id): '''View/edit a flow's details :status 200: Render the flow edit template :status 302: Post changes to the a flow using the submitted :py:class:`~purchasing.conductor.forms.FlowForm`, redirect back to the current flow's detail page if successful ''' flow = Flow.query.get(flow_id) if flow: form = FlowForm(obj=flow) if form.validate_on_submit(): flow.update( flow_name=form.data['flow_name'], is_archived=form.data['is_archived'] )<|fim▁hole|> return render_template('conductor/flows/edit.html', form=form, flow=flow) abort(404)<|fim▁end|>
flash('Flow successfully updated', 'alert-success') return redirect(url_for('conductor.flow_detail', flow_id=flow.id))
<|file_name|>flow_management.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import render_template, redirect, url_for, flash, abort from purchasing.decorators import requires_roles from purchasing.data.stages import Stage from purchasing.data.flows import Flow from purchasing.conductor.forms import FlowForm, NewFlowForm from purchasing.conductor.manager import blueprint @blueprint.route('/flow/new', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def new_flow(): <|fim_middle|> @blueprint.route('/flows') @requires_roles('conductor', 'admin', 'superadmin') def flows_list(): '''List all flows :status 200: Render the all flows list template ''' flows = Flow.query.order_by(Flow.flow_name).all() active, archived = [], [] for flow in flows: if flow.is_archived: archived.append(flow) else: active.append(flow) return render_template('conductor/flows/browse.html', active=active, archived=archived) @blueprint.route('/flow/<int:flow_id>', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def flow_detail(flow_id): '''View/edit a flow's details :status 200: Render the flow edit template :status 302: Post changes to the a flow using the submitted :py:class:`~purchasing.conductor.forms.FlowForm`, redirect back to the current flow's detail page if successful ''' flow = Flow.query.get(flow_id) if flow: form = FlowForm(obj=flow) if form.validate_on_submit(): flow.update( flow_name=form.data['flow_name'], is_archived=form.data['is_archived'] ) flash('Flow successfully updated', 'alert-success') return redirect(url_for('conductor.flow_detail', flow_id=flow.id)) return render_template('conductor/flows/edit.html', form=form, flow=flow) abort(404) <|fim▁end|>
'''Create a new flow :status 200: Render the new flow template :status 302: Try to create a new flow using the :py:class:`~purchasing.conductor.forms.NewFlowForm`, redirect to the flows list view if successful ''' stages = Stage.choices_factory() form = NewFlowForm(stages=stages) if form.validate_on_submit(): stage_order = [] for entry in form.stage_order.entries: # try to evaluate the return value as an ID try: stage_id = int(entry.data) # otherwise it's a new stage except ValueError: new_stage = Stage.create(name=entry.data) stage_id = new_stage.id stage_order.append(stage_id) Flow.create(flow_name=form.flow_name.data, stage_order=stage_order) flash('Flow created successfully!', 'alert-success') return redirect(url_for('conductor.flows_list')) return render_template('conductor/flows/new.html', stages=stages, form=form)
<|file_name|>flow_management.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import render_template, redirect, url_for, flash, abort from purchasing.decorators import requires_roles from purchasing.data.stages import Stage from purchasing.data.flows import Flow from purchasing.conductor.forms import FlowForm, NewFlowForm from purchasing.conductor.manager import blueprint @blueprint.route('/flow/new', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def new_flow(): '''Create a new flow :status 200: Render the new flow template :status 302: Try to create a new flow using the :py:class:`~purchasing.conductor.forms.NewFlowForm`, redirect to the flows list view if successful ''' stages = Stage.choices_factory() form = NewFlowForm(stages=stages) if form.validate_on_submit(): stage_order = [] for entry in form.stage_order.entries: # try to evaluate the return value as an ID try: stage_id = int(entry.data) # otherwise it's a new stage except ValueError: new_stage = Stage.create(name=entry.data) stage_id = new_stage.id stage_order.append(stage_id) Flow.create(flow_name=form.flow_name.data, stage_order=stage_order) flash('Flow created successfully!', 'alert-success') return redirect(url_for('conductor.flows_list')) return render_template('conductor/flows/new.html', stages=stages, form=form) @blueprint.route('/flows') @requires_roles('conductor', 'admin', 'superadmin') def flows_list(): <|fim_middle|> @blueprint.route('/flow/<int:flow_id>', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def flow_detail(flow_id): '''View/edit a flow's details :status 200: Render the flow edit template :status 302: Post changes to the a flow using the submitted :py:class:`~purchasing.conductor.forms.FlowForm`, redirect back to the current flow's detail page if successful ''' flow = Flow.query.get(flow_id) if flow: form = FlowForm(obj=flow) if form.validate_on_submit(): flow.update( flow_name=form.data['flow_name'], is_archived=form.data['is_archived'] ) flash('Flow successfully updated', 'alert-success') return redirect(url_for('conductor.flow_detail', flow_id=flow.id)) return render_template('conductor/flows/edit.html', form=form, flow=flow) abort(404) <|fim▁end|>
'''List all flows :status 200: Render the all flows list template ''' flows = Flow.query.order_by(Flow.flow_name).all() active, archived = [], [] for flow in flows: if flow.is_archived: archived.append(flow) else: active.append(flow) return render_template('conductor/flows/browse.html', active=active, archived=archived)
<|file_name|>flow_management.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import render_template, redirect, url_for, flash, abort from purchasing.decorators import requires_roles from purchasing.data.stages import Stage from purchasing.data.flows import Flow from purchasing.conductor.forms import FlowForm, NewFlowForm from purchasing.conductor.manager import blueprint @blueprint.route('/flow/new', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def new_flow(): '''Create a new flow :status 200: Render the new flow template :status 302: Try to create a new flow using the :py:class:`~purchasing.conductor.forms.NewFlowForm`, redirect to the flows list view if successful ''' stages = Stage.choices_factory() form = NewFlowForm(stages=stages) if form.validate_on_submit(): stage_order = [] for entry in form.stage_order.entries: # try to evaluate the return value as an ID try: stage_id = int(entry.data) # otherwise it's a new stage except ValueError: new_stage = Stage.create(name=entry.data) stage_id = new_stage.id stage_order.append(stage_id) Flow.create(flow_name=form.flow_name.data, stage_order=stage_order) flash('Flow created successfully!', 'alert-success') return redirect(url_for('conductor.flows_list')) return render_template('conductor/flows/new.html', stages=stages, form=form) @blueprint.route('/flows') @requires_roles('conductor', 'admin', 'superadmin') def flows_list(): '''List all flows :status 200: Render the all flows list template ''' flows = Flow.query.order_by(Flow.flow_name).all() active, archived = [], [] for flow in flows: if flow.is_archived: archived.append(flow) else: active.append(flow) return render_template('conductor/flows/browse.html', active=active, archived=archived) @blueprint.route('/flow/<int:flow_id>', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def flow_detail(flow_id): <|fim_middle|> <|fim▁end|>
'''View/edit a flow's details :status 200: Render the flow edit template :status 302: Post changes to the a flow using the submitted :py:class:`~purchasing.conductor.forms.FlowForm`, redirect back to the current flow's detail page if successful ''' flow = Flow.query.get(flow_id) if flow: form = FlowForm(obj=flow) if form.validate_on_submit(): flow.update( flow_name=form.data['flow_name'], is_archived=form.data['is_archived'] ) flash('Flow successfully updated', 'alert-success') return redirect(url_for('conductor.flow_detail', flow_id=flow.id)) return render_template('conductor/flows/edit.html', form=form, flow=flow) abort(404)
<|file_name|>flow_management.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import render_template, redirect, url_for, flash, abort from purchasing.decorators import requires_roles from purchasing.data.stages import Stage from purchasing.data.flows import Flow from purchasing.conductor.forms import FlowForm, NewFlowForm from purchasing.conductor.manager import blueprint @blueprint.route('/flow/new', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def new_flow(): '''Create a new flow :status 200: Render the new flow template :status 302: Try to create a new flow using the :py:class:`~purchasing.conductor.forms.NewFlowForm`, redirect to the flows list view if successful ''' stages = Stage.choices_factory() form = NewFlowForm(stages=stages) if form.validate_on_submit(): <|fim_middle|> return render_template('conductor/flows/new.html', stages=stages, form=form) @blueprint.route('/flows') @requires_roles('conductor', 'admin', 'superadmin') def flows_list(): '''List all flows :status 200: Render the all flows list template ''' flows = Flow.query.order_by(Flow.flow_name).all() active, archived = [], [] for flow in flows: if flow.is_archived: archived.append(flow) else: active.append(flow) return render_template('conductor/flows/browse.html', active=active, archived=archived) @blueprint.route('/flow/<int:flow_id>', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def flow_detail(flow_id): '''View/edit a flow's details :status 200: Render the flow edit template :status 302: Post changes to the a flow using the submitted :py:class:`~purchasing.conductor.forms.FlowForm`, redirect back to the current flow's detail page if successful ''' flow = Flow.query.get(flow_id) if flow: form = FlowForm(obj=flow) if form.validate_on_submit(): flow.update( flow_name=form.data['flow_name'], is_archived=form.data['is_archived'] ) flash('Flow successfully updated', 'alert-success') return redirect(url_for('conductor.flow_detail', flow_id=flow.id)) return render_template('conductor/flows/edit.html', form=form, flow=flow) abort(404) <|fim▁end|>
stage_order = [] for entry in form.stage_order.entries: # try to evaluate the return value as an ID try: stage_id = int(entry.data) # otherwise it's a new stage except ValueError: new_stage = Stage.create(name=entry.data) stage_id = new_stage.id stage_order.append(stage_id) Flow.create(flow_name=form.flow_name.data, stage_order=stage_order) flash('Flow created successfully!', 'alert-success') return redirect(url_for('conductor.flows_list'))
<|file_name|>flow_management.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import render_template, redirect, url_for, flash, abort from purchasing.decorators import requires_roles from purchasing.data.stages import Stage from purchasing.data.flows import Flow from purchasing.conductor.forms import FlowForm, NewFlowForm from purchasing.conductor.manager import blueprint @blueprint.route('/flow/new', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def new_flow(): '''Create a new flow :status 200: Render the new flow template :status 302: Try to create a new flow using the :py:class:`~purchasing.conductor.forms.NewFlowForm`, redirect to the flows list view if successful ''' stages = Stage.choices_factory() form = NewFlowForm(stages=stages) if form.validate_on_submit(): stage_order = [] for entry in form.stage_order.entries: # try to evaluate the return value as an ID try: stage_id = int(entry.data) # otherwise it's a new stage except ValueError: new_stage = Stage.create(name=entry.data) stage_id = new_stage.id stage_order.append(stage_id) Flow.create(flow_name=form.flow_name.data, stage_order=stage_order) flash('Flow created successfully!', 'alert-success') return redirect(url_for('conductor.flows_list')) return render_template('conductor/flows/new.html', stages=stages, form=form) @blueprint.route('/flows') @requires_roles('conductor', 'admin', 'superadmin') def flows_list(): '''List all flows :status 200: Render the all flows list template ''' flows = Flow.query.order_by(Flow.flow_name).all() active, archived = [], [] for flow in flows: if flow.is_archived: <|fim_middle|> else: active.append(flow) return render_template('conductor/flows/browse.html', active=active, archived=archived) @blueprint.route('/flow/<int:flow_id>', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def flow_detail(flow_id): '''View/edit a flow's details :status 200: Render the flow edit template :status 302: Post changes to the a flow using the submitted :py:class:`~purchasing.conductor.forms.FlowForm`, redirect back to the current flow's detail page if successful ''' flow = Flow.query.get(flow_id) if flow: form = FlowForm(obj=flow) if form.validate_on_submit(): flow.update( flow_name=form.data['flow_name'], is_archived=form.data['is_archived'] ) flash('Flow successfully updated', 'alert-success') return redirect(url_for('conductor.flow_detail', flow_id=flow.id)) return render_template('conductor/flows/edit.html', form=form, flow=flow) abort(404) <|fim▁end|>
archived.append(flow)
<|file_name|>flow_management.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import render_template, redirect, url_for, flash, abort from purchasing.decorators import requires_roles from purchasing.data.stages import Stage from purchasing.data.flows import Flow from purchasing.conductor.forms import FlowForm, NewFlowForm from purchasing.conductor.manager import blueprint @blueprint.route('/flow/new', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def new_flow(): '''Create a new flow :status 200: Render the new flow template :status 302: Try to create a new flow using the :py:class:`~purchasing.conductor.forms.NewFlowForm`, redirect to the flows list view if successful ''' stages = Stage.choices_factory() form = NewFlowForm(stages=stages) if form.validate_on_submit(): stage_order = [] for entry in form.stage_order.entries: # try to evaluate the return value as an ID try: stage_id = int(entry.data) # otherwise it's a new stage except ValueError: new_stage = Stage.create(name=entry.data) stage_id = new_stage.id stage_order.append(stage_id) Flow.create(flow_name=form.flow_name.data, stage_order=stage_order) flash('Flow created successfully!', 'alert-success') return redirect(url_for('conductor.flows_list')) return render_template('conductor/flows/new.html', stages=stages, form=form) @blueprint.route('/flows') @requires_roles('conductor', 'admin', 'superadmin') def flows_list(): '''List all flows :status 200: Render the all flows list template ''' flows = Flow.query.order_by(Flow.flow_name).all() active, archived = [], [] for flow in flows: if flow.is_archived: archived.append(flow) else: <|fim_middle|> return render_template('conductor/flows/browse.html', active=active, archived=archived) @blueprint.route('/flow/<int:flow_id>', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def flow_detail(flow_id): '''View/edit a flow's details :status 200: Render the flow edit template :status 302: Post changes to the a flow using the submitted :py:class:`~purchasing.conductor.forms.FlowForm`, redirect back to the current flow's detail page if successful ''' flow = Flow.query.get(flow_id) if flow: form = FlowForm(obj=flow) if form.validate_on_submit(): flow.update( flow_name=form.data['flow_name'], is_archived=form.data['is_archived'] ) flash('Flow successfully updated', 'alert-success') return redirect(url_for('conductor.flow_detail', flow_id=flow.id)) return render_template('conductor/flows/edit.html', form=form, flow=flow) abort(404) <|fim▁end|>
active.append(flow)
<|file_name|>flow_management.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import render_template, redirect, url_for, flash, abort from purchasing.decorators import requires_roles from purchasing.data.stages import Stage from purchasing.data.flows import Flow from purchasing.conductor.forms import FlowForm, NewFlowForm from purchasing.conductor.manager import blueprint @blueprint.route('/flow/new', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def new_flow(): '''Create a new flow :status 200: Render the new flow template :status 302: Try to create a new flow using the :py:class:`~purchasing.conductor.forms.NewFlowForm`, redirect to the flows list view if successful ''' stages = Stage.choices_factory() form = NewFlowForm(stages=stages) if form.validate_on_submit(): stage_order = [] for entry in form.stage_order.entries: # try to evaluate the return value as an ID try: stage_id = int(entry.data) # otherwise it's a new stage except ValueError: new_stage = Stage.create(name=entry.data) stage_id = new_stage.id stage_order.append(stage_id) Flow.create(flow_name=form.flow_name.data, stage_order=stage_order) flash('Flow created successfully!', 'alert-success') return redirect(url_for('conductor.flows_list')) return render_template('conductor/flows/new.html', stages=stages, form=form) @blueprint.route('/flows') @requires_roles('conductor', 'admin', 'superadmin') def flows_list(): '''List all flows :status 200: Render the all flows list template ''' flows = Flow.query.order_by(Flow.flow_name).all() active, archived = [], [] for flow in flows: if flow.is_archived: archived.append(flow) else: active.append(flow) return render_template('conductor/flows/browse.html', active=active, archived=archived) @blueprint.route('/flow/<int:flow_id>', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def flow_detail(flow_id): '''View/edit a flow's details :status 200: Render the flow edit template :status 302: Post changes to the a flow using the submitted :py:class:`~purchasing.conductor.forms.FlowForm`, redirect back to the current flow's detail page if successful ''' flow = Flow.query.get(flow_id) if flow: <|fim_middle|> abort(404) <|fim▁end|>
form = FlowForm(obj=flow) if form.validate_on_submit(): flow.update( flow_name=form.data['flow_name'], is_archived=form.data['is_archived'] ) flash('Flow successfully updated', 'alert-success') return redirect(url_for('conductor.flow_detail', flow_id=flow.id)) return render_template('conductor/flows/edit.html', form=form, flow=flow)
<|file_name|>flow_management.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import render_template, redirect, url_for, flash, abort from purchasing.decorators import requires_roles from purchasing.data.stages import Stage from purchasing.data.flows import Flow from purchasing.conductor.forms import FlowForm, NewFlowForm from purchasing.conductor.manager import blueprint @blueprint.route('/flow/new', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def new_flow(): '''Create a new flow :status 200: Render the new flow template :status 302: Try to create a new flow using the :py:class:`~purchasing.conductor.forms.NewFlowForm`, redirect to the flows list view if successful ''' stages = Stage.choices_factory() form = NewFlowForm(stages=stages) if form.validate_on_submit(): stage_order = [] for entry in form.stage_order.entries: # try to evaluate the return value as an ID try: stage_id = int(entry.data) # otherwise it's a new stage except ValueError: new_stage = Stage.create(name=entry.data) stage_id = new_stage.id stage_order.append(stage_id) Flow.create(flow_name=form.flow_name.data, stage_order=stage_order) flash('Flow created successfully!', 'alert-success') return redirect(url_for('conductor.flows_list')) return render_template('conductor/flows/new.html', stages=stages, form=form) @blueprint.route('/flows') @requires_roles('conductor', 'admin', 'superadmin') def flows_list(): '''List all flows :status 200: Render the all flows list template ''' flows = Flow.query.order_by(Flow.flow_name).all() active, archived = [], [] for flow in flows: if flow.is_archived: archived.append(flow) else: active.append(flow) return render_template('conductor/flows/browse.html', active=active, archived=archived) @blueprint.route('/flow/<int:flow_id>', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def flow_detail(flow_id): '''View/edit a flow's details :status 200: Render the flow edit template :status 302: Post changes to the a flow using the submitted :py:class:`~purchasing.conductor.forms.FlowForm`, redirect back to the current flow's detail page if successful ''' flow = Flow.query.get(flow_id) if flow: form = FlowForm(obj=flow) if form.validate_on_submit(): <|fim_middle|> return render_template('conductor/flows/edit.html', form=form, flow=flow) abort(404) <|fim▁end|>
flow.update( flow_name=form.data['flow_name'], is_archived=form.data['is_archived'] ) flash('Flow successfully updated', 'alert-success') return redirect(url_for('conductor.flow_detail', flow_id=flow.id))
<|file_name|>flow_management.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import render_template, redirect, url_for, flash, abort from purchasing.decorators import requires_roles from purchasing.data.stages import Stage from purchasing.data.flows import Flow from purchasing.conductor.forms import FlowForm, NewFlowForm from purchasing.conductor.manager import blueprint @blueprint.route('/flow/new', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def <|fim_middle|>(): '''Create a new flow :status 200: Render the new flow template :status 302: Try to create a new flow using the :py:class:`~purchasing.conductor.forms.NewFlowForm`, redirect to the flows list view if successful ''' stages = Stage.choices_factory() form = NewFlowForm(stages=stages) if form.validate_on_submit(): stage_order = [] for entry in form.stage_order.entries: # try to evaluate the return value as an ID try: stage_id = int(entry.data) # otherwise it's a new stage except ValueError: new_stage = Stage.create(name=entry.data) stage_id = new_stage.id stage_order.append(stage_id) Flow.create(flow_name=form.flow_name.data, stage_order=stage_order) flash('Flow created successfully!', 'alert-success') return redirect(url_for('conductor.flows_list')) return render_template('conductor/flows/new.html', stages=stages, form=form) @blueprint.route('/flows') @requires_roles('conductor', 'admin', 'superadmin') def flows_list(): '''List all flows :status 200: Render the all flows list template ''' flows = Flow.query.order_by(Flow.flow_name).all() active, archived = [], [] for flow in flows: if flow.is_archived: archived.append(flow) else: active.append(flow) return render_template('conductor/flows/browse.html', active=active, archived=archived) @blueprint.route('/flow/<int:flow_id>', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def flow_detail(flow_id): '''View/edit a flow's details :status 200: Render the flow edit template :status 302: Post changes to the a flow using the submitted :py:class:`~purchasing.conductor.forms.FlowForm`, redirect back to the current flow's detail page if successful ''' flow = Flow.query.get(flow_id) if flow: form = FlowForm(obj=flow) if form.validate_on_submit(): flow.update( flow_name=form.data['flow_name'], is_archived=form.data['is_archived'] ) flash('Flow successfully updated', 'alert-success') return redirect(url_for('conductor.flow_detail', flow_id=flow.id)) return render_template('conductor/flows/edit.html', form=form, flow=flow) abort(404) <|fim▁end|>
new_flow
<|file_name|>flow_management.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import render_template, redirect, url_for, flash, abort from purchasing.decorators import requires_roles from purchasing.data.stages import Stage from purchasing.data.flows import Flow from purchasing.conductor.forms import FlowForm, NewFlowForm from purchasing.conductor.manager import blueprint @blueprint.route('/flow/new', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def new_flow(): '''Create a new flow :status 200: Render the new flow template :status 302: Try to create a new flow using the :py:class:`~purchasing.conductor.forms.NewFlowForm`, redirect to the flows list view if successful ''' stages = Stage.choices_factory() form = NewFlowForm(stages=stages) if form.validate_on_submit(): stage_order = [] for entry in form.stage_order.entries: # try to evaluate the return value as an ID try: stage_id = int(entry.data) # otherwise it's a new stage except ValueError: new_stage = Stage.create(name=entry.data) stage_id = new_stage.id stage_order.append(stage_id) Flow.create(flow_name=form.flow_name.data, stage_order=stage_order) flash('Flow created successfully!', 'alert-success') return redirect(url_for('conductor.flows_list')) return render_template('conductor/flows/new.html', stages=stages, form=form) @blueprint.route('/flows') @requires_roles('conductor', 'admin', 'superadmin') def <|fim_middle|>(): '''List all flows :status 200: Render the all flows list template ''' flows = Flow.query.order_by(Flow.flow_name).all() active, archived = [], [] for flow in flows: if flow.is_archived: archived.append(flow) else: active.append(flow) return render_template('conductor/flows/browse.html', active=active, archived=archived) @blueprint.route('/flow/<int:flow_id>', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def flow_detail(flow_id): '''View/edit a flow's details :status 200: Render the flow edit template :status 302: Post changes to the a flow using the submitted :py:class:`~purchasing.conductor.forms.FlowForm`, redirect back to the current flow's detail page if successful ''' flow = Flow.query.get(flow_id) if flow: form = FlowForm(obj=flow) if form.validate_on_submit(): flow.update( flow_name=form.data['flow_name'], is_archived=form.data['is_archived'] ) flash('Flow successfully updated', 'alert-success') return redirect(url_for('conductor.flow_detail', flow_id=flow.id)) return render_template('conductor/flows/edit.html', form=form, flow=flow) abort(404) <|fim▁end|>
flows_list
<|file_name|>flow_management.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import render_template, redirect, url_for, flash, abort from purchasing.decorators import requires_roles from purchasing.data.stages import Stage from purchasing.data.flows import Flow from purchasing.conductor.forms import FlowForm, NewFlowForm from purchasing.conductor.manager import blueprint @blueprint.route('/flow/new', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def new_flow(): '''Create a new flow :status 200: Render the new flow template :status 302: Try to create a new flow using the :py:class:`~purchasing.conductor.forms.NewFlowForm`, redirect to the flows list view if successful ''' stages = Stage.choices_factory() form = NewFlowForm(stages=stages) if form.validate_on_submit(): stage_order = [] for entry in form.stage_order.entries: # try to evaluate the return value as an ID try: stage_id = int(entry.data) # otherwise it's a new stage except ValueError: new_stage = Stage.create(name=entry.data) stage_id = new_stage.id stage_order.append(stage_id) Flow.create(flow_name=form.flow_name.data, stage_order=stage_order) flash('Flow created successfully!', 'alert-success') return redirect(url_for('conductor.flows_list')) return render_template('conductor/flows/new.html', stages=stages, form=form) @blueprint.route('/flows') @requires_roles('conductor', 'admin', 'superadmin') def flows_list(): '''List all flows :status 200: Render the all flows list template ''' flows = Flow.query.order_by(Flow.flow_name).all() active, archived = [], [] for flow in flows: if flow.is_archived: archived.append(flow) else: active.append(flow) return render_template('conductor/flows/browse.html', active=active, archived=archived) @blueprint.route('/flow/<int:flow_id>', methods=['GET', 'POST']) @requires_roles('conductor', 'admin', 'superadmin') def <|fim_middle|>(flow_id): '''View/edit a flow's details :status 200: Render the flow edit template :status 302: Post changes to the a flow using the submitted :py:class:`~purchasing.conductor.forms.FlowForm`, redirect back to the current flow's detail page if successful ''' flow = Flow.query.get(flow_id) if flow: form = FlowForm(obj=flow) if form.validate_on_submit(): flow.update( flow_name=form.data['flow_name'], is_archived=form.data['is_archived'] ) flash('Flow successfully updated', 'alert-success') return redirect(url_for('conductor.flow_detail', flow_id=flow.id)) return render_template('conductor/flows/edit.html', form=form, flow=flow) abort(404) <|fim▁end|>
flow_detail
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put() def test_get_custom_prop(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def test_append(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def test_ljust(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0]<|fim▁hole|> m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test)<|fim▁end|>
print 'Expected: %r' % expected
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): <|fim_middle|> <|fim▁end|>
l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put() def test_get_custom_prop(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def test_append(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def test_ljust(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test)
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): <|fim_middle|> def test_get_custom_prop(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def test_append(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def test_ljust(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test) <|fim▁end|>
mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put()
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): <|fim_middle|> m = MyModel(key_name='test') m.test = TestCase.l m.put() def test_get_custom_prop(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def test_append(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def test_ljust(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test) <|fim▁end|>
pass
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put() def test_get_custom_prop(self): <|fim_middle|> def test_append(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def test_ljust(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test) <|fim▁end|>
class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring))
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put() def test_get_custom_prop(self): class MyModel(CompressedIntegerListExpando): <|fim_middle|> m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def test_append(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def test_ljust(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test) <|fim▁end|>
_attribute_prefix = 'test'
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put() def test_get_custom_prop(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def test_append(self): <|fim_middle|> def test_ljust(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test) <|fim▁end|>
class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test)
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put() def test_get_custom_prop(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def test_append(self): class MyModel(CompressedIntegerListExpando): <|fim_middle|> m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def test_ljust(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test) <|fim▁end|>
_attribute_prefix = 'test'
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put() def test_get_custom_prop(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def test_append(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def test_ljust(self): <|fim_middle|> <|fim▁end|>
class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test)
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put() def test_get_custom_prop(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def test_append(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def test_ljust(self): class MyModel(CompressedIntegerListExpando): <|fim_middle|> m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test) <|fim▁end|>
_attribute_prefix = 'test'
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def <|fim_middle|>(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put() def test_get_custom_prop(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def test_append(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def test_ljust(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test) <|fim▁end|>
setUp
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put() def <|fim_middle|>(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def test_append(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def test_ljust(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test) <|fim▁end|>
test_get_custom_prop
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put() def test_get_custom_prop(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def <|fim_middle|>(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def test_ljust(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test) <|fim▁end|>
test_append
<|file_name|>test_compressed_int_list.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright 2017 GIG Technology NV # # 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 writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @@license_version:1.3@@ from google.appengine.ext import db import mc_unittest from rogerthat.models import CompressedIntegerListExpando class TestCase(mc_unittest.TestCase): l = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1] def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp(self, datastore_hr_probability=datastore_hr_probability) class MyModel(db.Expando): pass m = MyModel(key_name='test') m.test = TestCase.l m.put() def test_get_custom_prop(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l, m.test) dict_repr = db.to_dict(m) self.assertTrue(isinstance(dict_repr['test'], basestring)) def test_append(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') m.test.append(5) m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(TestCase.l + [5], m.test) def <|fim_middle|>(self): class MyModel(CompressedIntegerListExpando): _attribute_prefix = 'test' m = MyModel.get_by_key_name('test') print 'Before: %r' % m.test m.test.ljust(5, 0, 10) # will append 5 zeroes, and limit the number of entries to 10 print 'After: %r' % m.test expected = (TestCase.l + 5 * [0])[-10:] # [1, 0, 0, 0, 1, 0, 0, 0, 0, 0] print 'Expected: %r' % expected m.put() m = MyModel.get_by_key_name('test') self.assertListEqual(expected, m.test) <|fim▁end|>
test_ljust
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor<|fim▁hole|> # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e))<|fim▁end|>
chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: <|fim_middle|> <|fim▁end|>
""" Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e))
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): <|fim_middle|> def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor()
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): <|fim_middle|> def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
""" Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))]
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): <|fim_middle|> def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"])
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): <|fim_middle|> def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine))
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): <|fim_middle|> def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
""" Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): <|fim_middle|> def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e))
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers <|fim_middle|> <|fim▁end|>
self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e))
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: <|fim_middle|> else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
self.windowsManager.commands('__Compiled__', ["normal G$a Dt"])
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: <|fim_middle|> def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
self.windowsManager.commands('__Compiled__', ["normal G$a PR"])
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : <|fim_middle|> def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine))
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): <|fim_middle|> def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine))
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: <|fim_middle|> else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
chunkStart = (0, textCursorPos(self.output)[1] + 1, 2)
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: <|fim_middle|> chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0)
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: <|fim_middle|> else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1)
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: <|fim_middle|> self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0)
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: <|fim_middle|> actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
print("No chunk to backtrack !") return None
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: <|fim_middle|> def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: <|fim_middle|> else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
self.editNewLine = False
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: <|fim_middle|> self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
self.editNewLine = self.chunks[-1][2]
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: <|fim_middle|> file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
interline += self.input[0]
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line <|fim_middle|> else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
self.input[0] = line firstLine = False
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: <|fim_middle|> file.close() except IOError as e: error(str(e)) <|fim▁end|>
self.input.append(line)
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def <|fim_middle|>(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
__init__
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def <|fim_middle|>(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
initOutputCursor
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def <|fim_middle|>(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
drawNewlineCursor
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def <|fim_middle|>(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
next
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def <|fim_middle|>(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
prev
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def <|fim_middle|>(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def open(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
write
<|file_name|>file.py<|end_file_name|><|fim▁begin|>from utils import textAppend, textPrepend, textCut, textEditLastChar, error, textCursorPos class File: """ Represents a file (A separated class allow to open several files at a time. The class also holds the whole file content. (The vim buffers only store either the accepted chunks, or the editing statement) """ def __init__(self, plugin, buffers): self.windowsManager = plugin.windowsManager self.coqManager = plugin.coqManager self.input = buffers[0] self.output = buffers[1] # Each chunk is describe by the following tuple : (startPos, endPos, newLine), where startPos and endPos are coords tuple self.chunks = [] # The whole file content self.code = [] self.editPosition = (0, 0) # We manage a virtual new-line at the end of the compiled buffer. self.initOutputCursor() def initOutputCursor(self): """ Init the newline-cursor in the Compiled buffer. """ self.output.options['modifiable'] = True del self.output[:] self.drawNewlineCursor(False) self.output.options['modifiable'] = False self.editNewLine = False # We backtrack every chunks self.chunks = self.chunks[:- self.coqManager.rewind(len(self.chunks))] def drawNewlineCursor(self, newLine): if newLine: self.windowsManager.commands('__Compiled__', ["normal G$a Dt"]) else: self.windowsManager.commands('__Compiled__', ["normal G$a PR"]) def next(self): nextChunk = self.windowsManager.input.getChunk(self.input, (0, 0)) if nextChunk : if self.coqManager.sendChunk(nextChunk[0]): if self.editNewLine: chunkStart = (0, textCursorPos(self.output)[1] + 1, 2) else: chunkStart = textCursorPos(self.output, diffX = 3) # diffX=2 to ignore the newline-cursor chunkStart = (chunkStart[0], chunkStart[1], 0) chunk = textCut(self.input, (0, 0, 2), nextChunk[1]) self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) textAppend(self.output, chunk, self.editNewLine) self.editNewLine = nextChunk[2] chunkEnd = textCursorPos(self.output) if self.editNewLine: self.drawNewlineCursor(True) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 1) else: self.drawNewlineCursor(False) chunkEnd = (chunkEnd[0] + 1, chunkEnd[1], 0) self.output.options['modifiable'] = False self.chunks.append((chunkStart, chunkEnd, self.editNewLine)) def prev(self): """ Backtrack of one chunk """ if len(self.chunks) <= 0: print("No chunk to backtrack !") return None actualRewind = self.coqManager.rewind(1) if actualRewind == 1: self.output.options['modifiable'] = True # Remove the last newline-cursor self.windowsManager.commands('__Compiled__', ["normal G$a"]) lastChunk = self.chunks[-1] chunk = textCut(self.output, lastChunk[0], lastChunk[1]) textPrepend(self.input, chunk, lastChunk[2]) self.chunks.pop() if len(self.chunks) == 0: self.editNewLine = False else: self.editNewLine = self.chunks[-1][2] self.drawNewlineCursor(self.editNewLine) self.output.options['modifiable'] = False def write(self, filename): try: file = open(filename, 'w') # We write the compiled buffer, and then the edit buffer for i in xrange(len(self.output) - 1): file.write(self.output[i] + "\n") interline = self.output[-1][:-4] # We don't take the newline-cursor if not self.editNewLine: interline += self.input[0] file.write(interline + "\n") for i in xrange(0 if self.editNewLine else 1, len(self.input)): file.write(self.input[i] + "\n") file.close() except IOError as e: error(str(e)) def <|fim_middle|>(self, filename): # First, clear the buffers self.initOutputCursor() del self.chunks[:] del self.input[:] try: file = open(filename, 'r') # We simply add every lines in the Edit buffer firstLine = True for line in file: if firstLine: # We don't want to skip the first line self.input[0] = line firstLine = False else: self.input.append(line) file.close() except IOError as e: error(str(e)) <|fim▁end|>
open
<|file_name|>Process58TestElement.py<|end_file_name|><|fim▁begin|># Copyright 2016 Casey Jaymes # This file is part of PySCAP. # # PySCAP 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. # # PySCAP 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 GNU General Public License # along with PySCAP. If not, see <http://www.gnu.org/licenses/>. import logging <|fim▁hole|>from scap.model.oval_5.defs.windows.TestType import TestType logger = logging.getLogger(__name__) class Process58TestElement(TestType): MODEL_MAP = { 'tag_name': 'process58_test', }<|fim▁end|>
<|file_name|>Process58TestElement.py<|end_file_name|><|fim▁begin|># Copyright 2016 Casey Jaymes # This file is part of PySCAP. # # PySCAP 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. # # PySCAP 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 GNU General Public License # along with PySCAP. If not, see <http://www.gnu.org/licenses/>. import logging from scap.model.oval_5.defs.windows.TestType import TestType logger = logging.getLogger(__name__) class Process58TestElement(TestType): <|fim_middle|> <|fim▁end|>
MODEL_MAP = { 'tag_name': 'process58_test', }
<|file_name|>test_form.py<|end_file_name|><|fim▁begin|>from constance.admin import ConstanceForm from django.forms import fields from django.test import TestCase class TestForm(TestCase): def test_form_field_types(self): f = ConstanceForm({}) self.assertIsInstance(f.fields['INT_VALUE'], fields.IntegerField)<|fim▁hole|> self.assertIsInstance(f.fields['BOOL_VALUE'], fields.BooleanField) self.assertIsInstance(f.fields['STRING_VALUE'], fields.CharField) self.assertIsInstance(f.fields['DECIMAL_VALUE'], fields.DecimalField) self.assertIsInstance(f.fields['DATETIME_VALUE'], fields.SplitDateTimeField) self.assertIsInstance(f.fields['TIMEDELTA_VALUE'], fields.DurationField) self.assertIsInstance(f.fields['FLOAT_VALUE'], fields.FloatField) self.assertIsInstance(f.fields['DATE_VALUE'], fields.DateField) self.assertIsInstance(f.fields['TIME_VALUE'], fields.TimeField) # from CONSTANCE_ADDITIONAL_FIELDS self.assertIsInstance(f.fields['CHOICE_VALUE'], fields.ChoiceField) self.assertIsInstance(f.fields['EMAIL_VALUE'], fields.EmailField)<|fim▁end|>
<|file_name|>test_form.py<|end_file_name|><|fim▁begin|>from constance.admin import ConstanceForm from django.forms import fields from django.test import TestCase class TestForm(TestCase): <|fim_middle|> <|fim▁end|>
def test_form_field_types(self): f = ConstanceForm({}) self.assertIsInstance(f.fields['INT_VALUE'], fields.IntegerField) self.assertIsInstance(f.fields['BOOL_VALUE'], fields.BooleanField) self.assertIsInstance(f.fields['STRING_VALUE'], fields.CharField) self.assertIsInstance(f.fields['DECIMAL_VALUE'], fields.DecimalField) self.assertIsInstance(f.fields['DATETIME_VALUE'], fields.SplitDateTimeField) self.assertIsInstance(f.fields['TIMEDELTA_VALUE'], fields.DurationField) self.assertIsInstance(f.fields['FLOAT_VALUE'], fields.FloatField) self.assertIsInstance(f.fields['DATE_VALUE'], fields.DateField) self.assertIsInstance(f.fields['TIME_VALUE'], fields.TimeField) # from CONSTANCE_ADDITIONAL_FIELDS self.assertIsInstance(f.fields['CHOICE_VALUE'], fields.ChoiceField) self.assertIsInstance(f.fields['EMAIL_VALUE'], fields.EmailField)
<|file_name|>test_form.py<|end_file_name|><|fim▁begin|>from constance.admin import ConstanceForm from django.forms import fields from django.test import TestCase class TestForm(TestCase): def test_form_field_types(self): <|fim_middle|> <|fim▁end|>
f = ConstanceForm({}) self.assertIsInstance(f.fields['INT_VALUE'], fields.IntegerField) self.assertIsInstance(f.fields['BOOL_VALUE'], fields.BooleanField) self.assertIsInstance(f.fields['STRING_VALUE'], fields.CharField) self.assertIsInstance(f.fields['DECIMAL_VALUE'], fields.DecimalField) self.assertIsInstance(f.fields['DATETIME_VALUE'], fields.SplitDateTimeField) self.assertIsInstance(f.fields['TIMEDELTA_VALUE'], fields.DurationField) self.assertIsInstance(f.fields['FLOAT_VALUE'], fields.FloatField) self.assertIsInstance(f.fields['DATE_VALUE'], fields.DateField) self.assertIsInstance(f.fields['TIME_VALUE'], fields.TimeField) # from CONSTANCE_ADDITIONAL_FIELDS self.assertIsInstance(f.fields['CHOICE_VALUE'], fields.ChoiceField) self.assertIsInstance(f.fields['EMAIL_VALUE'], fields.EmailField)
<|file_name|>test_form.py<|end_file_name|><|fim▁begin|>from constance.admin import ConstanceForm from django.forms import fields from django.test import TestCase class TestForm(TestCase): def <|fim_middle|>(self): f = ConstanceForm({}) self.assertIsInstance(f.fields['INT_VALUE'], fields.IntegerField) self.assertIsInstance(f.fields['BOOL_VALUE'], fields.BooleanField) self.assertIsInstance(f.fields['STRING_VALUE'], fields.CharField) self.assertIsInstance(f.fields['DECIMAL_VALUE'], fields.DecimalField) self.assertIsInstance(f.fields['DATETIME_VALUE'], fields.SplitDateTimeField) self.assertIsInstance(f.fields['TIMEDELTA_VALUE'], fields.DurationField) self.assertIsInstance(f.fields['FLOAT_VALUE'], fields.FloatField) self.assertIsInstance(f.fields['DATE_VALUE'], fields.DateField) self.assertIsInstance(f.fields['TIME_VALUE'], fields.TimeField) # from CONSTANCE_ADDITIONAL_FIELDS self.assertIsInstance(f.fields['CHOICE_VALUE'], fields.ChoiceField) self.assertIsInstance(f.fields['EMAIL_VALUE'], fields.EmailField) <|fim▁end|>
test_form_field_types
<|file_name|>plot_weighted_samples.py<|end_file_name|><|fim▁begin|>""" ===================== SVM: Weighted samples ===================== Plot decision function of a weighted dataset, where the size of points is proportional to its weight. """ print __doc__ import numpy as np import pylab as pl from sklearn import svm # we create 20 points np.random.seed(0)<|fim▁hole|># and assign a bigger weight to the last 10 samples sample_weight[:10] *= 10 # # fit the model clf = svm.SVC() clf.fit(X, Y, sample_weight=sample_weight) # plot the decision function xx, yy = np.meshgrid(np.linspace(-4, 5, 500), np.linspace(-4, 5, 500)) Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()]) Z = Z.reshape(xx.shape) # plot the line, the points, and the nearest vectors to the plane pl.contourf(xx, yy, Z, alpha=0.75, cmap=pl.cm.bone) pl.scatter(X[:, 0], X[:, 1], c=Y, s=sample_weight, alpha=0.9, cmap=pl.cm.bone) pl.axis('off') pl.show()<|fim▁end|>
X = np.r_[np.random.randn(10, 2) + [1, 1], np.random.randn(10, 2)] Y = [1] * 10 + [-1] * 10 sample_weight = 100 * np.abs(np.random.randn(20))
<|file_name|>grove_slide_potentiometer.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # # GrovePi Example for using the Grove Slide Potentiometer (http://www.seeedstudio.com/wiki/Grove_-_Slide_Potentiometer) # # The GrovePi connects the Raspberry Pi and Grove sensors. You can learn more about GrovePi here: http://www.dexterindustries.com/GrovePi # # Have a question about this example? Ask on the forums here: http://forum.dexterindustries.com/c/grovepi # ''' ## License The MIT License (MIT) GrovePi for the Raspberry Pi: an open source platform for connecting Grove Sensors to the Raspberry Pi. Copyright (C) 2015 Dexter Industries Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal<|fim▁hole|>furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' import time import grovepi # Connect the Grove Slide Potentiometer to analog port A0 # OUT,LED,VCC,GND slide = 0 # pin 1 (yellow wire) # The device has an onboard LED accessible as pin 2 on port A0 # OUT,LED,VCC,GND led = 1 # pin 2 (white wire) grovepi.pinMode(slide,"INPUT") grovepi.pinMode(led,"OUTPUT") time.sleep(1) while True: try: # Read sensor value from potentiometer sensor_value = grovepi.analogRead(slide) # Illuminate onboard LED if sensor_value > 500: grovepi.digitalWrite(led,1) else: grovepi.digitalWrite(led,0) print("sensor_value =", sensor_value) except IOError: print ("Error")<|fim▁end|>
in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
<|file_name|>grove_slide_potentiometer.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # # GrovePi Example for using the Grove Slide Potentiometer (http://www.seeedstudio.com/wiki/Grove_-_Slide_Potentiometer) # # The GrovePi connects the Raspberry Pi and Grove sensors. You can learn more about GrovePi here: http://www.dexterindustries.com/GrovePi # # Have a question about this example? Ask on the forums here: http://forum.dexterindustries.com/c/grovepi # ''' ## License The MIT License (MIT) GrovePi for the Raspberry Pi: an open source platform for connecting Grove Sensors to the Raspberry Pi. Copyright (C) 2015 Dexter Industries Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' import time import grovepi # Connect the Grove Slide Potentiometer to analog port A0 # OUT,LED,VCC,GND slide = 0 # pin 1 (yellow wire) # The device has an onboard LED accessible as pin 2 on port A0 # OUT,LED,VCC,GND led = 1 # pin 2 (white wire) grovepi.pinMode(slide,"INPUT") grovepi.pinMode(led,"OUTPUT") time.sleep(1) while True: try: # Read sensor value from potentiometer sensor_value = grovepi.analogRead(slide) # Illuminate onboard LED if sensor_value > 500: <|fim_middle|> else: grovepi.digitalWrite(led,0) print("sensor_value =", sensor_value) except IOError: print ("Error") <|fim▁end|>
grovepi.digitalWrite(led,1)
<|file_name|>grove_slide_potentiometer.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python # # GrovePi Example for using the Grove Slide Potentiometer (http://www.seeedstudio.com/wiki/Grove_-_Slide_Potentiometer) # # The GrovePi connects the Raspberry Pi and Grove sensors. You can learn more about GrovePi here: http://www.dexterindustries.com/GrovePi # # Have a question about this example? Ask on the forums here: http://forum.dexterindustries.com/c/grovepi # ''' ## License The MIT License (MIT) GrovePi for the Raspberry Pi: an open source platform for connecting Grove Sensors to the Raspberry Pi. Copyright (C) 2015 Dexter Industries Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' import time import grovepi # Connect the Grove Slide Potentiometer to analog port A0 # OUT,LED,VCC,GND slide = 0 # pin 1 (yellow wire) # The device has an onboard LED accessible as pin 2 on port A0 # OUT,LED,VCC,GND led = 1 # pin 2 (white wire) grovepi.pinMode(slide,"INPUT") grovepi.pinMode(led,"OUTPUT") time.sleep(1) while True: try: # Read sensor value from potentiometer sensor_value = grovepi.analogRead(slide) # Illuminate onboard LED if sensor_value > 500: grovepi.digitalWrite(led,1) else: <|fim_middle|> print("sensor_value =", sensor_value) except IOError: print ("Error") <|fim▁end|>
grovepi.digitalWrite(led,0)
<|file_name|>tests_iso_14443_a_card_1_hydranfc_v2.py<|end_file_name|><|fim▁begin|>import time from pynfcreader.sessions.iso14443.iso14443a import Iso14443ASession def test_iso_14443_a_card_1_generic(hydranfc_connection): hn = Iso14443ASession(drv=hydranfc_connection, block_size=120) hn.connect() hn.field_off() time.sleep(0.1)<|fim▁hole|> hn.polling() r = hn.send_apdu("00 a4 04 00 0E 32 50 41 59 2E 53 59 53 2E 44 44 46 30 31 00") assert b'oW\x84\x0e2PAY.S.DDF01\xa5E\xbf\x0cBO\x07\xa0\x00\x00\x00B\x10\x10P\x02\x87\x01\x01\x9f(\x08@\x02\x00\x00\x00\x00a#O\x07\xa0\x00\x00\x00\x04\x10\nMASTERCARD\x02\x9f(\x08@\x00 \x00\x00\x00\x00' == r r = hn.send_apdu("00 a4 04 00 07 A0 00 00 00 42 10 10 00") assert b'o?\x84\x07\xa0\x00\x00\x00B\x104P\x02CB\x87\x01\x01\x9f\x11\x01\x12\x0eTransacti CB_-\x04fren\xbf\xdf`\x02\x0b\x14\x9fM\x02\x0b\x14\xdf\x04' == r r = hn.send_apdu("00 a4 04 00 07 A0 00 00 00 04 10 10 00") assert b'o?\x84\x07\xa0\x00\x00\x00\x04\x104P\nMASTERCA\x87\x01\x02\x9f\x11\x01\x01\x9f\x12\nMTERCARD_-\x04fn\xbf\x0c\n\xdf`\x02\x0b\x14\x9fM\x14' == r hn.field_off()<|fim▁end|>
hn.field_on()
<|file_name|>tests_iso_14443_a_card_1_hydranfc_v2.py<|end_file_name|><|fim▁begin|>import time from pynfcreader.sessions.iso14443.iso14443a import Iso14443ASession def test_iso_14443_a_card_1_generic(hydranfc_connection): <|fim_middle|> <|fim▁end|>
hn = Iso14443ASession(drv=hydranfc_connection, block_size=120) hn.connect() hn.field_off() time.sleep(0.1) hn.field_on() hn.polling() r = hn.send_apdu("00 a4 04 00 0E 32 50 41 59 2E 53 59 53 2E 44 44 46 30 31 00") assert b'oW\x84\x0e2PAY.S.DDF01\xa5E\xbf\x0cBO\x07\xa0\x00\x00\x00B\x10\x10P\x02\x87\x01\x01\x9f(\x08@\x02\x00\x00\x00\x00a#O\x07\xa0\x00\x00\x00\x04\x10\nMASTERCARD\x02\x9f(\x08@\x00 \x00\x00\x00\x00' == r r = hn.send_apdu("00 a4 04 00 07 A0 00 00 00 42 10 10 00") assert b'o?\x84\x07\xa0\x00\x00\x00B\x104P\x02CB\x87\x01\x01\x9f\x11\x01\x12\x0eTransacti CB_-\x04fren\xbf\xdf`\x02\x0b\x14\x9fM\x02\x0b\x14\xdf\x04' == r r = hn.send_apdu("00 a4 04 00 07 A0 00 00 00 04 10 10 00") assert b'o?\x84\x07\xa0\x00\x00\x00\x04\x104P\nMASTERCA\x87\x01\x02\x9f\x11\x01\x01\x9f\x12\nMTERCARD_-\x04fn\xbf\x0c\n\xdf`\x02\x0b\x14\x9fM\x14' == r hn.field_off()
<|file_name|>tests_iso_14443_a_card_1_hydranfc_v2.py<|end_file_name|><|fim▁begin|>import time from pynfcreader.sessions.iso14443.iso14443a import Iso14443ASession def <|fim_middle|>(hydranfc_connection): hn = Iso14443ASession(drv=hydranfc_connection, block_size=120) hn.connect() hn.field_off() time.sleep(0.1) hn.field_on() hn.polling() r = hn.send_apdu("00 a4 04 00 0E 32 50 41 59 2E 53 59 53 2E 44 44 46 30 31 00") assert b'oW\x84\x0e2PAY.S.DDF01\xa5E\xbf\x0cBO\x07\xa0\x00\x00\x00B\x10\x10P\x02\x87\x01\x01\x9f(\x08@\x02\x00\x00\x00\x00a#O\x07\xa0\x00\x00\x00\x04\x10\nMASTERCARD\x02\x9f(\x08@\x00 \x00\x00\x00\x00' == r r = hn.send_apdu("00 a4 04 00 07 A0 00 00 00 42 10 10 00") assert b'o?\x84\x07\xa0\x00\x00\x00B\x104P\x02CB\x87\x01\x01\x9f\x11\x01\x12\x0eTransacti CB_-\x04fren\xbf\xdf`\x02\x0b\x14\x9fM\x02\x0b\x14\xdf\x04' == r r = hn.send_apdu("00 a4 04 00 07 A0 00 00 00 04 10 10 00") assert b'o?\x84\x07\xa0\x00\x00\x00\x04\x104P\nMASTERCA\x87\x01\x02\x9f\x11\x01\x01\x9f\x12\nMTERCARD_-\x04fn\xbf\x0c\n\xdf`\x02\x0b\x14\x9fM\x14' == r hn.field_off() <|fim▁end|>
test_iso_14443_a_card_1_generic
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|># TODO When raising an exception pass a lambda function, the function being the module/path/name thing ERROR = {'default': "Unknown engine error ({0})", 400: "Bad request sent to search API ({0})", 401: "Incorrect API Key ({0})", 403: "Correct API but request refused ({0})", 404: "Bad request sent to search API ({0})"} class SearchException(Exception): """ Abstract class representing an ifind search exception. """ def __init__(self, module, message): """ SearchException constructor. Args: module (str): name of module/class that's raising exception message (str): exception message to be displayed Usage: raise SearchException("Test", "this is an error") """ message = "{0} - {1}".format(module, message) Exception.__init__(self, message) class EngineConnectionException(SearchException): """ Thrown when an Engine connectivity error occurs. Returns specific response message if status code specified. """ def __init__(self, engine, message, code=None): """ EngineException constructor. Args: engine (str): name of engine that's raising exception message (str): exception message to be displayed (ignored usually here) Kwargs: code (int): response status code of issued request Usage: raise EngineException("Bing", "", code=200) """ self.message = message self.code = code if code: self.message = ERROR.get(code, ERROR['default']).format(self.code) SearchException.__init__(self, engine, self.message) class EngineLoadException(SearchException): """ Thrown when an Engine can't be dynamically loaded. """ pass <|fim▁hole|> class EngineAPIKeyException(SearchException): """ Thrown when an Engine's API key hasn't been provided. """ pass class QueryParamException(SearchException): """ Thrown when a query parameters incompatible or missing. """ pass class CacheConnectionException(SearchException): """ Thrown when cache connectivity error occurs. """ pass class InvalidQueryException(SearchException): """ Thrown when an invalid query is passed to engine's search method. """ pass class RateLimitException(SearchException): """ Thrown when an engine's request rate limit has been exceeded. """ pass<|fim▁end|>
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|># TODO When raising an exception pass a lambda function, the function being the module/path/name thing ERROR = {'default': "Unknown engine error ({0})", 400: "Bad request sent to search API ({0})", 401: "Incorrect API Key ({0})", 403: "Correct API but request refused ({0})", 404: "Bad request sent to search API ({0})"} class SearchException(Exception): <|fim_middle|> class EngineConnectionException(SearchException): """ Thrown when an Engine connectivity error occurs. Returns specific response message if status code specified. """ def __init__(self, engine, message, code=None): """ EngineException constructor. Args: engine (str): name of engine that's raising exception message (str): exception message to be displayed (ignored usually here) Kwargs: code (int): response status code of issued request Usage: raise EngineException("Bing", "", code=200) """ self.message = message self.code = code if code: self.message = ERROR.get(code, ERROR['default']).format(self.code) SearchException.__init__(self, engine, self.message) class EngineLoadException(SearchException): """ Thrown when an Engine can't be dynamically loaded. """ pass class EngineAPIKeyException(SearchException): """ Thrown when an Engine's API key hasn't been provided. """ pass class QueryParamException(SearchException): """ Thrown when a query parameters incompatible or missing. """ pass class CacheConnectionException(SearchException): """ Thrown when cache connectivity error occurs. """ pass class InvalidQueryException(SearchException): """ Thrown when an invalid query is passed to engine's search method. """ pass class RateLimitException(SearchException): """ Thrown when an engine's request rate limit has been exceeded. """ pass<|fim▁end|>
""" Abstract class representing an ifind search exception. """ def __init__(self, module, message): """ SearchException constructor. Args: module (str): name of module/class that's raising exception message (str): exception message to be displayed Usage: raise SearchException("Test", "this is an error") """ message = "{0} - {1}".format(module, message) Exception.__init__(self, message)
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|># TODO When raising an exception pass a lambda function, the function being the module/path/name thing ERROR = {'default': "Unknown engine error ({0})", 400: "Bad request sent to search API ({0})", 401: "Incorrect API Key ({0})", 403: "Correct API but request refused ({0})", 404: "Bad request sent to search API ({0})"} class SearchException(Exception): """ Abstract class representing an ifind search exception. """ def __init__(self, module, message): <|fim_middle|> class EngineConnectionException(SearchException): """ Thrown when an Engine connectivity error occurs. Returns specific response message if status code specified. """ def __init__(self, engine, message, code=None): """ EngineException constructor. Args: engine (str): name of engine that's raising exception message (str): exception message to be displayed (ignored usually here) Kwargs: code (int): response status code of issued request Usage: raise EngineException("Bing", "", code=200) """ self.message = message self.code = code if code: self.message = ERROR.get(code, ERROR['default']).format(self.code) SearchException.__init__(self, engine, self.message) class EngineLoadException(SearchException): """ Thrown when an Engine can't be dynamically loaded. """ pass class EngineAPIKeyException(SearchException): """ Thrown when an Engine's API key hasn't been provided. """ pass class QueryParamException(SearchException): """ Thrown when a query parameters incompatible or missing. """ pass class CacheConnectionException(SearchException): """ Thrown when cache connectivity error occurs. """ pass class InvalidQueryException(SearchException): """ Thrown when an invalid query is passed to engine's search method. """ pass class RateLimitException(SearchException): """ Thrown when an engine's request rate limit has been exceeded. """ pass<|fim▁end|>
""" SearchException constructor. Args: module (str): name of module/class that's raising exception message (str): exception message to be displayed Usage: raise SearchException("Test", "this is an error") """ message = "{0} - {1}".format(module, message) Exception.__init__(self, message)
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|># TODO When raising an exception pass a lambda function, the function being the module/path/name thing ERROR = {'default': "Unknown engine error ({0})", 400: "Bad request sent to search API ({0})", 401: "Incorrect API Key ({0})", 403: "Correct API but request refused ({0})", 404: "Bad request sent to search API ({0})"} class SearchException(Exception): """ Abstract class representing an ifind search exception. """ def __init__(self, module, message): """ SearchException constructor. Args: module (str): name of module/class that's raising exception message (str): exception message to be displayed Usage: raise SearchException("Test", "this is an error") """ message = "{0} - {1}".format(module, message) Exception.__init__(self, message) class EngineConnectionException(SearchException): <|fim_middle|> class EngineLoadException(SearchException): """ Thrown when an Engine can't be dynamically loaded. """ pass class EngineAPIKeyException(SearchException): """ Thrown when an Engine's API key hasn't been provided. """ pass class QueryParamException(SearchException): """ Thrown when a query parameters incompatible or missing. """ pass class CacheConnectionException(SearchException): """ Thrown when cache connectivity error occurs. """ pass class InvalidQueryException(SearchException): """ Thrown when an invalid query is passed to engine's search method. """ pass class RateLimitException(SearchException): """ Thrown when an engine's request rate limit has been exceeded. """ pass<|fim▁end|>
""" Thrown when an Engine connectivity error occurs. Returns specific response message if status code specified. """ def __init__(self, engine, message, code=None): """ EngineException constructor. Args: engine (str): name of engine that's raising exception message (str): exception message to be displayed (ignored usually here) Kwargs: code (int): response status code of issued request Usage: raise EngineException("Bing", "", code=200) """ self.message = message self.code = code if code: self.message = ERROR.get(code, ERROR['default']).format(self.code) SearchException.__init__(self, engine, self.message)
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|># TODO When raising an exception pass a lambda function, the function being the module/path/name thing ERROR = {'default': "Unknown engine error ({0})", 400: "Bad request sent to search API ({0})", 401: "Incorrect API Key ({0})", 403: "Correct API but request refused ({0})", 404: "Bad request sent to search API ({0})"} class SearchException(Exception): """ Abstract class representing an ifind search exception. """ def __init__(self, module, message): """ SearchException constructor. Args: module (str): name of module/class that's raising exception message (str): exception message to be displayed Usage: raise SearchException("Test", "this is an error") """ message = "{0} - {1}".format(module, message) Exception.__init__(self, message) class EngineConnectionException(SearchException): """ Thrown when an Engine connectivity error occurs. Returns specific response message if status code specified. """ def __init__(self, engine, message, code=None): <|fim_middle|> class EngineLoadException(SearchException): """ Thrown when an Engine can't be dynamically loaded. """ pass class EngineAPIKeyException(SearchException): """ Thrown when an Engine's API key hasn't been provided. """ pass class QueryParamException(SearchException): """ Thrown when a query parameters incompatible or missing. """ pass class CacheConnectionException(SearchException): """ Thrown when cache connectivity error occurs. """ pass class InvalidQueryException(SearchException): """ Thrown when an invalid query is passed to engine's search method. """ pass class RateLimitException(SearchException): """ Thrown when an engine's request rate limit has been exceeded. """ pass<|fim▁end|>
""" EngineException constructor. Args: engine (str): name of engine that's raising exception message (str): exception message to be displayed (ignored usually here) Kwargs: code (int): response status code of issued request Usage: raise EngineException("Bing", "", code=200) """ self.message = message self.code = code if code: self.message = ERROR.get(code, ERROR['default']).format(self.code) SearchException.__init__(self, engine, self.message)
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|># TODO When raising an exception pass a lambda function, the function being the module/path/name thing ERROR = {'default': "Unknown engine error ({0})", 400: "Bad request sent to search API ({0})", 401: "Incorrect API Key ({0})", 403: "Correct API but request refused ({0})", 404: "Bad request sent to search API ({0})"} class SearchException(Exception): """ Abstract class representing an ifind search exception. """ def __init__(self, module, message): """ SearchException constructor. Args: module (str): name of module/class that's raising exception message (str): exception message to be displayed Usage: raise SearchException("Test", "this is an error") """ message = "{0} - {1}".format(module, message) Exception.__init__(self, message) class EngineConnectionException(SearchException): """ Thrown when an Engine connectivity error occurs. Returns specific response message if status code specified. """ def __init__(self, engine, message, code=None): """ EngineException constructor. Args: engine (str): name of engine that's raising exception message (str): exception message to be displayed (ignored usually here) Kwargs: code (int): response status code of issued request Usage: raise EngineException("Bing", "", code=200) """ self.message = message self.code = code if code: self.message = ERROR.get(code, ERROR['default']).format(self.code) SearchException.__init__(self, engine, self.message) class EngineLoadException(SearchException): <|fim_middle|> class EngineAPIKeyException(SearchException): """ Thrown when an Engine's API key hasn't been provided. """ pass class QueryParamException(SearchException): """ Thrown when a query parameters incompatible or missing. """ pass class CacheConnectionException(SearchException): """ Thrown when cache connectivity error occurs. """ pass class InvalidQueryException(SearchException): """ Thrown when an invalid query is passed to engine's search method. """ pass class RateLimitException(SearchException): """ Thrown when an engine's request rate limit has been exceeded. """ pass<|fim▁end|>
""" Thrown when an Engine can't be dynamically loaded. """ pass
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|># TODO When raising an exception pass a lambda function, the function being the module/path/name thing ERROR = {'default': "Unknown engine error ({0})", 400: "Bad request sent to search API ({0})", 401: "Incorrect API Key ({0})", 403: "Correct API but request refused ({0})", 404: "Bad request sent to search API ({0})"} class SearchException(Exception): """ Abstract class representing an ifind search exception. """ def __init__(self, module, message): """ SearchException constructor. Args: module (str): name of module/class that's raising exception message (str): exception message to be displayed Usage: raise SearchException("Test", "this is an error") """ message = "{0} - {1}".format(module, message) Exception.__init__(self, message) class EngineConnectionException(SearchException): """ Thrown when an Engine connectivity error occurs. Returns specific response message if status code specified. """ def __init__(self, engine, message, code=None): """ EngineException constructor. Args: engine (str): name of engine that's raising exception message (str): exception message to be displayed (ignored usually here) Kwargs: code (int): response status code of issued request Usage: raise EngineException("Bing", "", code=200) """ self.message = message self.code = code if code: self.message = ERROR.get(code, ERROR['default']).format(self.code) SearchException.__init__(self, engine, self.message) class EngineLoadException(SearchException): """ Thrown when an Engine can't be dynamically loaded. """ pass class EngineAPIKeyException(SearchException): <|fim_middle|> class QueryParamException(SearchException): """ Thrown when a query parameters incompatible or missing. """ pass class CacheConnectionException(SearchException): """ Thrown when cache connectivity error occurs. """ pass class InvalidQueryException(SearchException): """ Thrown when an invalid query is passed to engine's search method. """ pass class RateLimitException(SearchException): """ Thrown when an engine's request rate limit has been exceeded. """ pass<|fim▁end|>
""" Thrown when an Engine's API key hasn't been provided. """ pass
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|># TODO When raising an exception pass a lambda function, the function being the module/path/name thing ERROR = {'default': "Unknown engine error ({0})", 400: "Bad request sent to search API ({0})", 401: "Incorrect API Key ({0})", 403: "Correct API but request refused ({0})", 404: "Bad request sent to search API ({0})"} class SearchException(Exception): """ Abstract class representing an ifind search exception. """ def __init__(self, module, message): """ SearchException constructor. Args: module (str): name of module/class that's raising exception message (str): exception message to be displayed Usage: raise SearchException("Test", "this is an error") """ message = "{0} - {1}".format(module, message) Exception.__init__(self, message) class EngineConnectionException(SearchException): """ Thrown when an Engine connectivity error occurs. Returns specific response message if status code specified. """ def __init__(self, engine, message, code=None): """ EngineException constructor. Args: engine (str): name of engine that's raising exception message (str): exception message to be displayed (ignored usually here) Kwargs: code (int): response status code of issued request Usage: raise EngineException("Bing", "", code=200) """ self.message = message self.code = code if code: self.message = ERROR.get(code, ERROR['default']).format(self.code) SearchException.__init__(self, engine, self.message) class EngineLoadException(SearchException): """ Thrown when an Engine can't be dynamically loaded. """ pass class EngineAPIKeyException(SearchException): """ Thrown when an Engine's API key hasn't been provided. """ pass class QueryParamException(SearchException): <|fim_middle|> class CacheConnectionException(SearchException): """ Thrown when cache connectivity error occurs. """ pass class InvalidQueryException(SearchException): """ Thrown when an invalid query is passed to engine's search method. """ pass class RateLimitException(SearchException): """ Thrown when an engine's request rate limit has been exceeded. """ pass<|fim▁end|>
""" Thrown when a query parameters incompatible or missing. """ pass
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|># TODO When raising an exception pass a lambda function, the function being the module/path/name thing ERROR = {'default': "Unknown engine error ({0})", 400: "Bad request sent to search API ({0})", 401: "Incorrect API Key ({0})", 403: "Correct API but request refused ({0})", 404: "Bad request sent to search API ({0})"} class SearchException(Exception): """ Abstract class representing an ifind search exception. """ def __init__(self, module, message): """ SearchException constructor. Args: module (str): name of module/class that's raising exception message (str): exception message to be displayed Usage: raise SearchException("Test", "this is an error") """ message = "{0} - {1}".format(module, message) Exception.__init__(self, message) class EngineConnectionException(SearchException): """ Thrown when an Engine connectivity error occurs. Returns specific response message if status code specified. """ def __init__(self, engine, message, code=None): """ EngineException constructor. Args: engine (str): name of engine that's raising exception message (str): exception message to be displayed (ignored usually here) Kwargs: code (int): response status code of issued request Usage: raise EngineException("Bing", "", code=200) """ self.message = message self.code = code if code: self.message = ERROR.get(code, ERROR['default']).format(self.code) SearchException.__init__(self, engine, self.message) class EngineLoadException(SearchException): """ Thrown when an Engine can't be dynamically loaded. """ pass class EngineAPIKeyException(SearchException): """ Thrown when an Engine's API key hasn't been provided. """ pass class QueryParamException(SearchException): """ Thrown when a query parameters incompatible or missing. """ pass class CacheConnectionException(SearchException): <|fim_middle|> class InvalidQueryException(SearchException): """ Thrown when an invalid query is passed to engine's search method. """ pass class RateLimitException(SearchException): """ Thrown when an engine's request rate limit has been exceeded. """ pass<|fim▁end|>
""" Thrown when cache connectivity error occurs. """ pass
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|># TODO When raising an exception pass a lambda function, the function being the module/path/name thing ERROR = {'default': "Unknown engine error ({0})", 400: "Bad request sent to search API ({0})", 401: "Incorrect API Key ({0})", 403: "Correct API but request refused ({0})", 404: "Bad request sent to search API ({0})"} class SearchException(Exception): """ Abstract class representing an ifind search exception. """ def __init__(self, module, message): """ SearchException constructor. Args: module (str): name of module/class that's raising exception message (str): exception message to be displayed Usage: raise SearchException("Test", "this is an error") """ message = "{0} - {1}".format(module, message) Exception.__init__(self, message) class EngineConnectionException(SearchException): """ Thrown when an Engine connectivity error occurs. Returns specific response message if status code specified. """ def __init__(self, engine, message, code=None): """ EngineException constructor. Args: engine (str): name of engine that's raising exception message (str): exception message to be displayed (ignored usually here) Kwargs: code (int): response status code of issued request Usage: raise EngineException("Bing", "", code=200) """ self.message = message self.code = code if code: self.message = ERROR.get(code, ERROR['default']).format(self.code) SearchException.__init__(self, engine, self.message) class EngineLoadException(SearchException): """ Thrown when an Engine can't be dynamically loaded. """ pass class EngineAPIKeyException(SearchException): """ Thrown when an Engine's API key hasn't been provided. """ pass class QueryParamException(SearchException): """ Thrown when a query parameters incompatible or missing. """ pass class CacheConnectionException(SearchException): """ Thrown when cache connectivity error occurs. """ pass class InvalidQueryException(SearchException): <|fim_middle|> class RateLimitException(SearchException): """ Thrown when an engine's request rate limit has been exceeded. """ pass<|fim▁end|>
""" Thrown when an invalid query is passed to engine's search method. """ pass
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|># TODO When raising an exception pass a lambda function, the function being the module/path/name thing ERROR = {'default': "Unknown engine error ({0})", 400: "Bad request sent to search API ({0})", 401: "Incorrect API Key ({0})", 403: "Correct API but request refused ({0})", 404: "Bad request sent to search API ({0})"} class SearchException(Exception): """ Abstract class representing an ifind search exception. """ def __init__(self, module, message): """ SearchException constructor. Args: module (str): name of module/class that's raising exception message (str): exception message to be displayed Usage: raise SearchException("Test", "this is an error") """ message = "{0} - {1}".format(module, message) Exception.__init__(self, message) class EngineConnectionException(SearchException): """ Thrown when an Engine connectivity error occurs. Returns specific response message if status code specified. """ def __init__(self, engine, message, code=None): """ EngineException constructor. Args: engine (str): name of engine that's raising exception message (str): exception message to be displayed (ignored usually here) Kwargs: code (int): response status code of issued request Usage: raise EngineException("Bing", "", code=200) """ self.message = message self.code = code if code: self.message = ERROR.get(code, ERROR['default']).format(self.code) SearchException.__init__(self, engine, self.message) class EngineLoadException(SearchException): """ Thrown when an Engine can't be dynamically loaded. """ pass class EngineAPIKeyException(SearchException): """ Thrown when an Engine's API key hasn't been provided. """ pass class QueryParamException(SearchException): """ Thrown when a query parameters incompatible or missing. """ pass class CacheConnectionException(SearchException): """ Thrown when cache connectivity error occurs. """ pass class InvalidQueryException(SearchException): """ Thrown when an invalid query is passed to engine's search method. """ pass class RateLimitException(SearchException): <|fim_middle|> <|fim▁end|>
""" Thrown when an engine's request rate limit has been exceeded. """ pass