Skip to content

Ticket8297 remove six usage #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions check_db_file_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_syntax_stanford(self):

def test_pv_all(self):
filepath = join(self.test_folder, "test_all.db")
self.run_pv_check(filepath, [], [])
self.run_pv_check(filepath, [], ['Missing description on SHOULDFAIL:NODESC', "Invalid unit 'BADUNIT' on SHOULDFAIL:BADUNIT", 'Description too long on SHOULDFAIL:LONGDESC', 'Missing ASG on SHOULDFAIL:CALCNOREADONLY', 'Missing units on SHOULDFAIL:NOUNITS', 'Multiple instances of fields EGU on SHOULDFAIL:DUPLICATE:EGU', 'Multiple instances of fields PINI on SHOULDFAIL:DUPLICATE:PINI'])

def test_pv_log_info(self):
filepath = join(self.test_folder, "test_log_info_errors.db")
Expand All @@ -64,7 +64,20 @@ def test_pv_multiple(self):

def test_pv_units(self):
filepath = join(self.test_folder, "test_units.db")
self.run_pv_check(filepath, [], [])
self.run_pv_check(filepath, [], ["Invalid unit 'bit kbyte^-1' on SHOULDFAIL:BITS_KBYTE^-1",
"Invalid unit 'm^-1' on SHOULDFAIL:M-1",
"Invalid unit 'm s^-1' on SHOULDFAIL:m_S-1",
"Invalid unit 'kkm' on SHOULDFAIL:BADUNIT:KKM",
"Invalid unit 'kmk' on SHOULDFAIL:BADUNIT:KMK",
"Invalid unit 'k/(m s)' on SHOULDFAIL:BADUNIT:KM-1_S-1",
"Invalid unit 'm/(As)' on SHOULDFAIL:BADUNIT:MA-1S-1",
"Invalid unit 'dm' on SHOULDFAIL:BADUNIT:DM",
"Invalid unit 'kM' on SHOULDFAIL:BADUNIT:CAPS",
"Invalid unit 'Km' on SHOULDFAIL:BADUNIT:CAPS_2",
"Invalid unit '1' on SHOULDFAIL:BADUNIT:1",
"Invalid unit 'm^-2' on SHOULDFAIL:BADUNIT:negative_square_power",
"Invalid unit 'm^-1' on SHOULDFAIL:BADUNIT:negative_power"])


def run_syntax_check(self, filepath, expected_warnings, expected_errors):
self.maxDiff = 1500
Expand Down
3 changes: 1 addition & 2 deletions src/db_parser/lexer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
import six
from collections import OrderedDict

from src.db_parser.tokens import TokenTypes
Expand Down Expand Up @@ -42,7 +41,7 @@ def _escape(var):
return f"({re.escape(var)})"


class Lexer(six.Iterator):
class Lexer():
"""
Lexer, tokenises the database file into
"""
Expand Down
3 changes: 1 addition & 2 deletions src/db_parser/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import six
from contextlib import contextmanager

from src.db_parser.tokens import TokenTypes
Expand All @@ -22,7 +21,7 @@ def next_token(self):
"""
try:
# Ignore macros and comments wherever they occur
self.current_token = six.advance_iterator(self.lexer)
self.current_token = next(self.lexer)
except StopIteration:
self.raise_error("Next token was requested, but none exists.")

Expand Down
4 changes: 1 addition & 3 deletions src/db_parser/tests/test_lexer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import unittest

import six

from src.db_parser.common import DbSyntaxError
from src.db_parser.lexer import Lexer, Token
from src.db_parser.tokens import TokenTypes
Expand All @@ -11,7 +9,7 @@ def get_tokens_list(lexer):
tokens = []
while True:
try:
tokens.append(six.advance_iterator(lexer))
tokens.append(next(lexer))
except StopIteration:
break
return tokens
Expand Down
4 changes: 1 addition & 3 deletions src/db_parser/tests/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import unittest

import six

from src.db_parser.common import DbSyntaxError
from src.db_parser.lexer import Token
from src.db_parser.parser import Parser
from src.db_parser.tokens import TokenTypes


class MockLexer(six.Iterator):
class MockLexer():
"""
Mocked lexer builder.
"""
Expand Down