Skip to content

Commit

Permalink
movendo parsers para o mesmo módulo
Browse files Browse the repository at this point in the history
  • Loading branch information
kl0ck committed Mar 24, 2021
1 parent 8bad3ad commit 6d4685f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 36 deletions.
7 changes: 0 additions & 7 deletions dataParser.py

This file was deleted.

16 changes: 6 additions & 10 deletions leitor.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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("#"):
Expand Down Expand Up @@ -98,4 +94,4 @@ def isEmBranco(txt):
db = Database()
for o in operacoes:
db.add(o)
db.list()
6 changes: 0 additions & 6 deletions numeroParser.py

This file was deleted.

23 changes: 23 additions & 0 deletions parsers.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 0 additions & 6 deletions tickerParser.py

This file was deleted.

7 changes: 0 additions & 7 deletions tipoOperacaoParser.py

This file was deleted.

0 comments on commit 6d4685f

Please sign in to comment.