-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from HenningTimm/line_numbers
Line numbers
- Loading branch information
Showing
17 changed files
with
331 additions
and
36 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Changelog | ||
|
||
## Version 0.6.0 (2024-03-18) | ||
|
||
- Added a CHANGELOG file. | ||
- Switched yaml input to use the ruamel.yaml round trip parser. | ||
This parser is also "safe", i.e. does not allow code execution. | ||
- Added line numbers and columns to error messages where possible. | ||
For yaml files, these are taken from the ruamel.yaml round trip parser. | ||
For tsv files, the column names within the specified block are reported. | ||
- Added `--strict` flag to the `convert` sub-command that prevents converting files that produced warnings. | ||
- The rules `keys_valid` and `keys_unique` now correctly report their name in output. | ||
- Added integration tests checking tsv files. | ||
- Improved user feedback for parameters dealing with rule names, e.g. `--skip`. | ||
|
||
|
||
## Version 0.5.0 (2024-01-10) | ||
|
||
- Improved documentation and user feedback | ||
- Added option to check multiple files. You can now specify multiple input file paths for the check sub-command and those file paths can be glob patterns. | ||
- Added suggestions for fixes to some lints. | ||
|
||
Please note that the convert sub-command currently only works with one input file. | ||
|
||
|
||
## Version 0.4.0 (2023-12-21) | ||
|
||
- Added option to skip lints or reduce their severity to warning. | ||
- Added first suggestions for fixes, e.g. minor typo detection with string matching. | ||
- Added RULES.md to have a human readable documentation of employed lints. | ||
|
||
|
||
## Version 0.3.0 (2023-12-05) | ||
|
||
This release adds: | ||
|
||
- Lints to detect trailing spaces | ||
- Internal preparations to support multiple files | ||
- Minor documentation improvements |
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
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,10 @@ | ||
#metadataBlock name dataverseAlias displayName | ||
ValidExample Valid | ||
#datasetField name title description watermark fieldType displayOrder displayFormat advancedSearchField allowControlledVocabulary allowmultiples facetable displayoncreate required parent metadatablock_id | ||
Duplicate Duplicate key 1 This field describes duplicate 1. textbox TRUE FALSE FALSE FALSE TRUE TRUE ValidExample | ||
Duplicate Duplicate key 2 This field describes duplicate 2. textbox TRUE FALSE FALSE FALSE TRUE TRUE ValidExample | ||
Answer Answer text TRUE TRUE TRUE TRUE TRUE TRUE ValidExample | ||
#controlledVocabulary DatasetField Value identifier displayOrder | ||
AnswerYes Yes answer_positive | ||
AnswerNo No answer_negative | ||
AnswerMaybeSo Maybe answer_unclear |
File renamed without changes.
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,9 @@ | ||
#metadataBlock name dataverseAlias displayName | ||
InvalidExample Invalid | ||
#datasetFields name title description watermark fieldType displayOrder displayFormat advancedSearchField allowControlledVocabulary allowmultiples facetable displayoncreate required parent metadatablock_id | ||
Description Description This field describes. textbox TRUE FALSE FALSE FALSE TRUE TRUE InvalidExample | ||
Answer Answer text TRUE TRUE TRUE TRUE TRUE TRUE InvalidExample | ||
#controlledVocabulary DatasetField Value identifier displayOrder | ||
AnswerYes Yes answer_positive | ||
AnswerNo No answer_negative | ||
AnswerMaybeSo Maybe answer_unclear |
File renamed without changes.
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,9 @@ | ||
#metadataBlock name dataverseAlias displayName | ||
InvalidExample Invalid | ||
#datasetField name title description watermark fieldType displayOrder displayFormat advancedSearchField allowControlledVocabulary allowmultiples facetable displayoncreate required parent metadatablock_id | ||
Description Description This field describes. textbox TRUE FALSE FALSE FALSE TRUE TRUE InvalidExample | ||
Answer Answer text TRUE TRUE TRUE TRUE TRUE TRUE InvalidExample | ||
#controlledVocabulary DatasetField Value identifier displayOrder | ||
AnswerYes Yes answer_positive | ||
AnswerNo No answer_negative | ||
AnswerMaybeSo Maybe answer_unclear |
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
from . import tsv_input | ||
from . import yaml_input | ||
from . import suggestions | ||
from . import datatypes |
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
"""This moudle contains custom datatypes used to create the internal YAML-like | ||
structure used for metadata block lints. MOst importantly these types allow to | ||
track line and column numbers for input data to enable more helpful user feedback. | ||
""" | ||
|
||
# from ruamel.yaml.scalarstring import LiteralScalarString, FoldedScalarString, DoubleQuotedScalarString, SingleQuotedScalarString, PlainScalarString | ||
# from ruamel.yaml.scalarint import ScalarInt | ||
# from ruamel.yaml.scalarbool import ScalarBoolean | ||
|
||
# TODO: Implement custom constructor for ruamel yaml | ||
# to get line and colum numbers for leafs in the yaml file | ||
# https://stackoverflow.com/a/45717104 | ||
|
||
|
||
class MDBlockList(list): | ||
__slots__ = ("line", "column") | ||
|
||
def __init__(self, iterable=None, line=None, column=None): | ||
"""Create a new MDBlock list that behaves like a normal list | ||
but tracks line an column number in object slots. | ||
""" | ||
self.line = line | ||
self.column = column | ||
|
||
# Delegate initialization to the list constructore | ||
if iterable is None: | ||
super().__init__() | ||
else: | ||
super().__init__(iterable) | ||
|
||
@classmethod | ||
def from_ruamel(cls, ruamel_list): | ||
"""Create a MDBlock list from an existing list read by the | ||
ruamel.yaml round trip parser. | ||
""" | ||
return cls(ruamel_list, line=ruamel_list.lc.line, column=ruamel_list.lc.col) | ||
|
||
|
||
class MDBlockDict(dict): | ||
__slots__ = ("line", "column") | ||
|
||
def __init__(self, mapping=None, /, line=None, column=None, **kwargs): | ||
"""Create a new MDBlock Dictionary that behaves like a normal dictionary | ||
but tracks line an column number in object slots. | ||
""" | ||
self.line = line | ||
self.column = column | ||
|
||
# Ensure an inner dict exists | ||
if mapping is None: | ||
mapping = dict() | ||
|
||
# Remain compatible with pythons regular dict constructor by | ||
# allowing kwargs to extend the passed mapping | ||
mapping.update(kwargs) | ||
|
||
super().__init__(mapping) | ||
|
||
@classmethod | ||
def from_ruamel(cls, ruamel_dict): | ||
"""Create a MDBlock dict from an existing dict read by the | ||
ruamel.yaml round trip parser. | ||
""" | ||
return cls(ruamel_dict, line=ruamel_dict.lc.line, column=ruamel_dict.lc.col) | ||
|
||
|
||
class MDBlockNode: | ||
__slots__ = ("line", "column", "value") | ||
|
||
def __init__(self, value, line=None, column=None): | ||
self.line = line | ||
self.column = column | ||
self.value = value | ||
|
||
def __repr__(self): | ||
return f"({self.line}, {self.column}) {self.value}" |
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.