Skip to content

Commit

Permalink
Fix datetime parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater committed Jul 27, 2020
1 parent f4a56b3 commit 9966e9e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 55 deletions.
57 changes: 16 additions & 41 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ packages = [
]

[tool.poetry.dependencies]
python = "~2.7 || ^3.4"
python = "~2.7 || ^3.5"

# enum34 is needed for Python 2.7
enum34 = { version = "^1.1", python = "~2.7" }
Expand All @@ -34,7 +34,7 @@ black = { version = "^19.3b0", markers = "python_version >= '3.6' and python_ver
pre-commit = "^1.10"
tox = "^3.1"
codecov = "^2.0"
pyyaml = "~5.1.1"
pyyaml = "~5.3.1"
isort = {version = "^5.2.0", python = "^3.6"}

[tool.black]
Expand Down
7 changes: 1 addition & 6 deletions tests/test_toml_spec_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# The following tests trigger a RecursionError
IGNORED_TESTS += ["qa-array-inline-nested-1000", "qa-table-inline-nested-1000"]
# The following tests don't work due to time microseconds precision of the tests
IGNORED_TESTS += ["spec-date-time-6", "spec-date-time-local-2"]
IGNORED_TESTS += ["spec-date-time-6", "spec-date-time-local-2", "spec-time-2"]
# The following tests don't work due to nan always comparing to False
IGNORED_TESTS += ["spec-float-13", "spec-float-14", "spec-float-15"]
# The following tests don't work due to issues with th epyyaml library
Expand Down Expand Up @@ -103,11 +103,6 @@ def test_valid_decode(test):
yaml_val = untag(json.loads(f.read()))

assert toml_val == yaml_val
print("1")
print(toml_val.as_string())
print(toml_val._body)
print("2")
print(toml_content)
assert toml_val.as_string() == toml_content


Expand Down
9 changes: 3 additions & 6 deletions tomlkit/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ def _parse_key_value(self, parse_comment=False): # type: (bool) -> (Key, Item)
if parse_comment:
cws, comment, trail = self._parse_comment_trail()
meta = val.trivia
meta.comment_ws = cws
if not meta.comment_ws:
meta.comment_ws = cws

meta.comment = comment
meta.trail = trail
else:
Expand Down Expand Up @@ -468,11 +470,9 @@ def _handle_dotted_key(
self, container, key, value
): # type: (Union[Container, Table], Key, Any) -> None
names = tuple(self._split_table_name(key.as_string()))
print("NAMES", names)
name = names[0]
name._dotted = True
if name in container:
print("IN", name)
table = container[name]
else:
table = Table(Container(True), Trivia(), False, is_super_table=True)
Expand Down Expand Up @@ -1007,7 +1007,6 @@ def _parse_table(

key = Key(name, sep="")
name_parts = tuple(self._split_table_name(name))
print("TABLE", name_parts)
missing_table = False
if parent_name:
parent_name_parts = tuple(self._split_table_name(parent_name))
Expand All @@ -1018,7 +1017,6 @@ def _parse_table(
missing_table = True

name_parts = name_parts[len(parent_name_parts) :]
print(name_parts)

values = Container(True)

Expand Down Expand Up @@ -1095,7 +1093,6 @@ def _parse_table(
else:
if self._current == "[":
is_aot_next, name_next = self._peek_table()
print(name, name_next, self._is_child(name, name_next))

if self._is_child(name, name_next):
key_next, table_next = self._parse_table(name, table)
Expand Down

0 comments on commit 9966e9e

Please sign in to comment.