Skip to content

Commit

Permalink
Merge pull request textX#92 from goto40/master
Browse files Browse the repository at this point in the history
flake8, coverage, etc. and minor code updates
  • Loading branch information
goto40 authored Oct 17, 2018
2 parents 35f3638 + 08513ab commit 55a774a
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 29 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ before_install:
# Installing Arpeggio as a dependency
- cd ..
- pip install Jinja2
- pip install coverage
- pip install flake8
- git clone --depth=1 --branch=master git://github.com/igordejanovic/Arpeggio.git
- cd Arpeggio && python setup.py install
- cd ../textX
install:
- python setup.py install
script:
- py.test tests/functional
- coverage run --source textx -m py.test tests/functional
- coverage report --fail-under 80
- flake8 textx tests --exclude tests/perf,textx/six.py,textx/lang.py

matrix:
include:
Expand Down
15 changes: 11 additions & 4 deletions docs/about/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Ready to contribute? Here's how to set up `textX` for local development.

To verify that everything is setup properly run tests:

$ flake8 tests/functional/
$ flake8 textx tests --exclude tests/perf,textx/six.py,textx/lang.py
$ py.test tests/functional/

4. Create a branch for local development::
Expand All @@ -97,11 +97,18 @@ Ready to contribute? Here's how to set up `textX` for local development.

Now you can make your changes locally.

5. When you're done making changes, check that your changes pass flake8 and the
tests:
5. When you're done making changes, check that your changes pass flake8, the
tests, and have a look at the coverage:

$ flake8 textX tests
$ flake8 textx tests/functional
$ py.test tests/functional/
$ coverage run --source textx -m py.test tests/functional
$ coverage report

In case you have doubts, have also a look at the html rendered version of
the coverage results:

$ coverage html

6. Commit your changes and push your branch to GitHub:

Expand Down
8 changes: 2 additions & 6 deletions examples/StateMachine/smdot.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
"""
Export state machine models to dot.
"""
from __future__ import unicode_literals
import codecs
import sys
from os.path import dirname, join
from textx import metamodel_from_file
if sys.version < '3':
text = unicode
else:
text = str


HEADER = '''
digraph xtext {
Expand Down Expand Up @@ -64,5 +60,5 @@ def sm_to_dot(model):
meta = metamodel_from_file(join(this_folder, 'state_machine.tx'))
model = meta.model_from_file(model_name)
with codecs.open("{}.dot".format(model_name), 'w',
encoding='utf-8') as f:
encoding='utf-8') as f:
f.write(sm_to_dot(model))
3 changes: 1 addition & 2 deletions examples/StateMachine/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ def interpret(self):
return
event = int(event)
event = self.model.events[event-1]
except:
except Exception:
print('Invalid input')

self.event(event)
self.print_menu()



if __name__ == '__main__':
this_folder = dirname(__file__)
if len(sys.argv) != 2:
Expand Down
4 changes: 0 additions & 4 deletions examples/hello_world/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,3 @@ def main(debug=False):

if __name__ == '__main__':
main()




1 change: 0 additions & 1 deletion examples/pyFlies/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ def main(debug=False):

if __name__ == '__main__':
main()

1 change: 0 additions & 1 deletion examples/workflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ def main(debug=False):

if __name__ == '__main__':
main()

1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pytest
flake8
coverage
jinja2
mkdocs
mike
4 changes: 2 additions & 2 deletions tests/functional/test_regexp_with_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
grammar = r"""
Model: entries += Entry;
Entry:
'data' '=' data=/\"(?ms){3}(.*?)\"{3}/
'data' '=' data=/(?ms)\"{3}(.*?)\"{3}/
;
"""
grammar2 = r"""
Model:
'data' '=' data=/\"(?ms){3}(.*?)\"{3}\s*\-(\w+)\-/
'data' '=' data=/(?ms)\"{3}(.*?)\"{3}\s*\-(\w+)\-/
;
"""

Expand Down
3 changes: 2 additions & 1 deletion textx/commands/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def textx():
class MyParser(argparse.ArgumentParser):
"""
Custom argument parser for printing help message in case of an error.
See http://stackoverflow.com/questions/4042452/display-help-message-with-python-argparse-when-script-is-called-without-any-argu
See
http://stackoverflow.com/questions/4042452/display-help-message-with-python-argparse-when-script-is-called-without-any-argu
"""
def error(self, message):
sys.stderr.write('error: %s\n' % message)
Expand Down
2 changes: 1 addition & 1 deletion textx/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,4 @@ def _export_subgraph(m):
else:
_export(model)

f.write('\n}\n')
f.write('\n}\n')
8 changes: 3 additions & 5 deletions textx/scoping/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def load_model(
return self.local_models.filename_to_model[filename]

def _add_model(self, model):
filename =self.update_model_in_repo_based_on_filename(model)
filename = self.update_model_in_repo_based_on_filename(model)
self.local_models.filename_to_model[filename] = model

def update_model_in_repo_based_on_filename(self, model):
Expand All @@ -234,9 +234,9 @@ def update_model_in_repo_based_on_filename(self, model):
for fn in self.all_models.filename_to_model:
if self.all_models.filename_to_model[fn] == model:
return fn
i=0
i = 0
while self.all_models.has_model("anonymous{}".format(i)):
i+=1
i += 1
myfilename = "anonymous{}".format(i)
self.all_models.filename_to_model[myfilename] = model
else:
Expand All @@ -245,7 +245,6 @@ def update_model_in_repo_based_on_filename(self, model):
self.all_models.filename_to_model[myfilename] = model
return myfilename


def pre_ref_resolution_callback(self, other_model):
"""
(internal: used to store a model after parsing into the repository)
Expand Down Expand Up @@ -296,4 +295,3 @@ def get_all_models_including_attached_models(model):
else:
models = [model]
return models

2 changes: 1 addition & 1 deletion textx/scoping/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import textx.scoping as scoping

"""
This module defines scope providers to be used in conjunctions with a
This module defines scope providers to be used in conjunctions with a
textx.metamodel meta model.
See docs/scoping.md
Expand Down

0 comments on commit 55a774a

Please sign in to comment.