From 6d4685fcf3531bb0d8ba5fb7fa3a72ca6fce3e94 Mon Sep 17 00:00:00 2001 From: kl0ck Date: Wed, 24 Mar 2021 18:26:34 -0300 Subject: [PATCH] =?UTF-8?q?movendo=20parsers=20para=20o=20mesmo=20m=C3=B3d?= =?UTF-8?q?ulo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataParser.py | 7 ------- leitor.py | 16 ++++++---------- numeroParser.py | 6 ------ parsers.py | 23 +++++++++++++++++++++++ tickerParser.py | 6 ------ tipoOperacaoParser.py | 7 ------- 6 files changed, 29 insertions(+), 36 deletions(-) delete mode 100644 dataParser.py delete mode 100644 numeroParser.py create mode 100644 parsers.py delete mode 100644 tickerParser.py delete mode 100644 tipoOperacaoParser.py 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)