-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[1.3] Version handling, parser fixes, setup update #197
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d0fa7ee
[section] Add missing attributes to init
mpsonntag 3e83205
[tools/odmlparser] Fix open JSON file bug
mpsonntag cf60c47
[tools/odmlparser] Fix open YAML file bug
mpsonntag 52b094f
[tools/odmlparser] Fix YAML/JSON Reader.from_str
mpsonntag ea3f263
[test/parser] Fix open YAML/JSON file bug
mpsonntag e2be96f
[tools/odmlparser] Pep8 cleanup
mpsonntag d2550f6
[init] Update version number
mpsonntag 00c995b
[info] Add info file to provide version and format
mpsonntag 88fc8c9
[init] User version number from info
mpsonntag 1820178
[odmlparser] Use format version number from info
mpsonntag 7d61eac
[xmlparser] Use format version from info
mpsonntag 9e0c50a
[xmlparser] Add odml format version check
mpsonntag 713e720
[odmlparser] Add odml format version check
mpsonntag c9c4dd6
[init/setup] Update packaging information
mpsonntag 577b8ff
[odmlparser] Save only valid odML documents
mpsonntag 9b7baac
[odmlparser] Use xmlparser with ignore_errors
mpsonntag 5f29fcd
[xmlparser] Add parser warning list
mpsonntag 5d2701b
[odmlparser] Add parser warning list
mpsonntag 64a91d5
[travis] Use master branch travis file
mpsonntag 2415055
[parser] Update invalid odML format version text
mpsonntag f45e9bc
[fileio] Define parsers only in odmlparser
mpsonntag c8e6157
[fileio] Add docstrings
mpsonntag c2ae4b5
[xmlparser] Fixing typos
mpsonntag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,41 @@ | ||
from .tools.odmlparser import ODMLReader, ODMLWriter | ||
from .tools.odmlparser import ODMLReader, ODMLWriter, allowed_parsers | ||
|
||
parsers = ["xml", "json", "yaml"] | ||
PARSERS = allowed_parsers | ||
|
||
|
||
def load(filename, backend="xml"): | ||
""" | ||
Load an odML document from file. | ||
:param filename: Path and filename from where the odML document | ||
is to be loaded and parsed. | ||
:param backend: File format of the file containing the odML document. | ||
The default format is XML. | ||
:return: The parsed odML document. | ||
""" | ||
reader = ODMLReader(backend) | ||
return reader.from_file(filename) | ||
|
||
|
||
def save(obj, filename, backend="xml"): | ||
""" | ||
Save an open odML document to file of a specified format. | ||
:param obj: odML document do be saved. | ||
:param filename: Filename and path where the odML document | ||
should be saved. | ||
:param backend: Format in which the odML document is to be saved. | ||
The default format is XML. | ||
""" | ||
writer = ODMLWriter(backend) | ||
return writer.write_file(obj, filename) | ||
|
||
|
||
def display(obj, backend="xml"): | ||
""" | ||
Print an open odML document to the command line, formatted in the | ||
specified format. | ||
:param obj: odML document to be displayed. | ||
:param backend: Format in which the odML document is to be displayed. | ||
The default format is XML. | ||
""" | ||
writer = ODMLWriter(backend) | ||
print(writer.to_string(obj)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
VERSION = '1.3.3' | ||
FORMAT_VERSION = '1' | ||
AUTHOR = 'Hagen Fritsch, Christian Kellner, Jan Grewe, ' \ | ||
'Achilleas Koutsou, Michael Sonntag, Lyuba Zehl' | ||
COPYRIGHT = '(c) 2011-2017, German Neuroinformatics Node' | ||
CONTACT = 'dev@g-node.org' | ||
HOMEPAGE = 'https://github.com/G-Node/python-odml' | ||
CLASSIFIERS = [ | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 3', | ||
'License :: OSI Approved :: BSD License', | ||
'Development Status :: 5 - Production/Stable', | ||
'Topic :: Scientific/Engineering', | ||
'Intended Audience :: Science/Research' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to shuffle things around a bit to make this a bit more sane. It's possible to avoid this import cycle if we move the validation file to the
tools
submodule, but I think we have bigger import issues. One issue is we don't use explicit relative imports everywhere. This might lead to issues when testing local code while a global version of the package is installed. It might also lead to subtle bugs where local file location are changed, but the absolute import hides this by importing from an installed version.This leads me to a different issue I came across. We have a lot of functions in the top-level
__init__.py
. This isn't a problem in and of itself, but we do import one of these functions into the validation file, which makes internal package imports impossible. So we end up with a situation where the validation file importsodml
, which relies on importing everything else, which obviously would result in an import cycle.