diff --git a/dataParser.py b/dataParser.py deleted file mode 100644 index 77f55c3..0000000 --- a/dataParser.py +++ /dev/null @@ -1,7 +0,0 @@ -import re - -class DataParser: - - # DD/MM/YYYY - def parse(self, txt): - return re.findall(r"\b\d{2}/\d{2}/\d{4}\b", txt) diff --git a/leitor.py b/leitor.py index ddd86a4..c085d8d 100644 --- a/leitor.py +++ b/leitor.py @@ -1,9 +1,5 @@ import sys - -from numeroParser import NumeroParser -from tipoOperacaoParser import TipoOperacaoParser -from dataParser import DataParser -from tickerParser import TickerParser +import parsers from operacao import Operacao from database import Database @@ -26,10 +22,10 @@ print("Extraindo operações...\n") -dataParser = DataParser() -tipoOperacaoParser = TipoOperacaoParser() -numeroParser = NumeroParser() -tickerParser = TickerParser() +dataParser = parsers.DataParser() +tipoOperacaoParser = parsers.TipoOperacaoParser() +numeroParser = parsers.NumeroParser() +tickerParser = parsers.TickerParser() def isComentario(txt): if txt.startswith("#"): @@ -98,4 +94,4 @@ def isEmBranco(txt): db = Database() for o in operacoes: db.add(o) -db.list() + diff --git a/numeroParser.py b/numeroParser.py deleted file mode 100644 index 945ba04..0000000 --- a/numeroParser.py +++ /dev/null @@ -1,6 +0,0 @@ -import re - -class NumeroParser: - - def parse(self, txt): - return re.findall(r"\b(\d*\,*\d+)\b", txt) diff --git a/parsers.py b/parsers.py new file mode 100644 index 0000000..c4cc977 --- /dev/null +++ b/parsers.py @@ -0,0 +1,23 @@ +import re + +class DataParser: + + # DD/MM/YYYY + def parse(self, txt): + return re.findall(r"\b\d{2}/\d{2}/\d{4}\b", txt) + +class TickerParser: + + def parse(self, txt): + return re.findall(r"\b([A-Za-z]\w*)\b", txt) + +class TipoOperacaoParser: + + # C/V + def parse(self, txt): + return re.findall(r"\b(C|V)\b", txt) + +class NumeroParser: + + def parse(self, txt): + return re.findall(r"\b(\d*\,*\d+)\b", txt) diff --git a/tickerParser.py b/tickerParser.py deleted file mode 100644 index 1c03d07..0000000 --- a/tickerParser.py +++ /dev/null @@ -1,6 +0,0 @@ -import re - -class TickerParser: - - def parse(self, txt): - return re.findall(r"\b([A-Za-z]\w*)\b", txt) diff --git a/tipoOperacaoParser.py b/tipoOperacaoParser.py deleted file mode 100644 index 359dd51..0000000 --- a/tipoOperacaoParser.py +++ /dev/null @@ -1,7 +0,0 @@ -import re - -class TipoOperacaoParser: - - # C/V - def parse(self, txt): - return re.findall(r"\b(C|V)\b", txt)