Skip to content

Commit

Permalink
Removed tests from py-pkg | no open files after parsing (#113)
Browse files Browse the repository at this point in the history
* exclude tests folder from python package
* don't leave open files
* bump version
* updated release notes
  • Loading branch information
nobbi1991 authored Dec 12, 2022
1 parent 094da17 commit f72956a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.18.0] - 2022-12-13

### Changed

- Remove `tests` folder from python package
- Close all files which are opened by the ldfparser

## [0.17.0] - 2022-10-17

### Added
Expand Down
9 changes: 6 additions & 3 deletions ldfparser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ def parse_ldf_to_dict(path: str, capture_comments: bool = False, encoding: str =
:type encoding: str
"""
comments = []
lark = os.path.abspath(os.path.join(os.path.dirname(__file__), 'grammars', 'ldf.lark'))
parser = Lark(grammar=open(lark), parser='lalr', lexer_callbacks={
lark_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'grammars', 'ldf.lark'))
with open(lark_file, "r", encoding=encoding) as lark_file:
grammar = lark_file.read()
parser = Lark(grammar=grammar, parser='lalr', lexer_callbacks={
'C_COMMENT': comments.append,
'CPP_COMMENT': comments.append
}, propagate_positions=True)
ldf_file = open(path, "r", encoding=encoding).read()
with open(path, "r", encoding=encoding) as input_file:
ldf_file = input_file.read()
tree = parser.parse(ldf_file)
json = LdfTransformer().transform(tree)

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[metadata]
version = 0.17.0
version = 0.18.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/c4deszes/ldfparser",
packages=find_packages(),
packages=find_packages(exclude=["tests"]),
package_data={'': ['*.lark']},
license='MIT',
keywords=['LIN', 'LDF'],
Expand Down

0 comments on commit f72956a

Please sign in to comment.