From f5776a2b98d25c2b7aa20b8fa02cd583855476df Mon Sep 17 00:00:00 2001 From: Lasse Schuirmann Date: Sat, 30 May 2015 12:32:07 +0200 Subject: [PATCH] SectionParser: Remove (useless) This is part of a refactoring to make all parser objects, which are essentially only one method, a bunch of functions. --- coalib/parsing/CliParser.py | 5 +---- coalib/parsing/ConfParser.py | 4 +--- coalib/parsing/SectionParser.py | 26 -------------------------- coalib/tests/parsing/ParserTest.py | 23 ----------------------- 4 files changed, 2 insertions(+), 56 deletions(-) delete mode 100644 coalib/parsing/SectionParser.py delete mode 100644 coalib/tests/parsing/ParserTest.py diff --git a/coalib/parsing/CliParser.py b/coalib/parsing/CliParser.py index c1199094df..92cff6edfa 100644 --- a/coalib/parsing/CliParser.py +++ b/coalib/parsing/CliParser.py @@ -4,13 +4,12 @@ import sys from coalib.parsing.LineParser import LineParser -from coalib.parsing.SectionParser import SectionParser from coalib.settings.Setting import Setting from coalib.settings.Section import Section from coalib.parsing.DefaultArgParser import default_arg_parser -class CliParser(SectionParser): +class CliParser: def __init__(self, arg_parser=default_arg_parser, key_value_delimiters=['=', ':'], @@ -37,8 +36,6 @@ def __init__(self, if not isinstance(arg_parser, argparse.ArgumentParser): raise TypeError("arg_parser must be an ArgumentParser") - SectionParser.__init__(self) - self._arg_parser = arg_parser self._line_parser = LineParser(key_value_delimiters, comment_seperators, diff --git a/coalib/parsing/ConfParser.py b/coalib/parsing/ConfParser.py index 95289f0f7d..53b31658f7 100644 --- a/coalib/parsing/ConfParser.py +++ b/coalib/parsing/ConfParser.py @@ -3,18 +3,16 @@ import os from coalib.parsing.LineParser import LineParser -from coalib.parsing.SectionParser import SectionParser from coalib.settings.Setting import Setting from coalib.settings.Section import Section -class ConfParser(SectionParser): +class ConfParser: def __init__(self, key_value_delimiters=['='], comment_seperators=['#', ';', '//'], key_delimiters=[',', ' '], section_name_surroundings={'[': "]"}): - SectionParser.__init__(self) self.line_parser = LineParser(key_value_delimiters, comment_seperators, key_delimiters, diff --git a/coalib/parsing/SectionParser.py b/coalib/parsing/SectionParser.py deleted file mode 100644 index cf4c8d09f6..0000000000 --- a/coalib/parsing/SectionParser.py +++ /dev/null @@ -1,26 +0,0 @@ -class SectionParser: - def parse(self, input_data): - """ - Parses the input and adds the new data to the existing - - :param input_data: filename or other input - :return: the section dictionary - """ - - raise NotImplementedError - - def reparse(self, input_data): - """ - Parses the input and overwrites all existent data - - :param input_data: filename or other input - :return: the section dictionary - """ - raise NotImplementedError - - def export_to_settings(self): - """ - :return: a dict of section objects representing the current parsed - things - """ - raise NotImplementedError diff --git a/coalib/tests/parsing/ParserTest.py b/coalib/tests/parsing/ParserTest.py deleted file mode 100644 index c97a546a96..0000000000 --- a/coalib/tests/parsing/ParserTest.py +++ /dev/null @@ -1,23 +0,0 @@ -import sys - -sys.path.insert(0, ".") -from coalib.parsing.SectionParser import SectionParser -import unittest - - -class ParserTest(unittest.TestCase): - def test_parse_available(self): - self.uut = SectionParser() - self.assertRaises(NotImplementedError, self.uut.parse, None) - - def test_reparse_available(self): - self.uut = SectionParser() - self.assertRaises(NotImplementedError, self.uut.reparse, None) - - def test_export_available(self): - self.uut = SectionParser() - self.assertRaises(NotImplementedError, self.uut.export_to_settings) - - -if __name__ == '__main__': - unittest.main(verbosity=2)