Skip to content

Commit

Permalink
travis: add postgresql service
Browse files Browse the repository at this point in the history
Seems this wasn't required before, see if it it fixes build
  • Loading branch information
odinho committed Jun 8, 2021
1 parent ec34a00 commit 74fd433
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ sudo: false
language: python
python:
- '2.7'
services:
- postgresql
install: pip install -r requirements/local.txt
script: python manage.py test
cache:
Expand Down
24 changes: 15 additions & 9 deletions medlemssys/innhenting/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,12 @@ class OCR(object):
"21": "Nettgiro - kjøp m fritekst",
}

def __init__(self):
self.data = []

def from_filename(self, path):
fp = open(path)
self._parse(fp)
self.data = self._parse(fp)

def from_string(self, string):
self._parse(iter(string.splitlines()))
self.data = self._parse(iter(string.splitlines()))

def process_to_db(self):
for f in self.data:
Expand Down Expand Up @@ -110,7 +107,8 @@ def process_to_db(self):
update_denormalized_fields()


def _parse(self, ocr_data):
@classmethod
def _parse(cls, ocr_data):
for row in ocr_data:
row = row.strip()
if row[0:8] == "NY000010":
Expand All @@ -120,6 +118,7 @@ def _parse(self, ocr_data):
else:
raise OCRError('Fann ikkje startrecord for sending')

data = []
for row in ocr_data:
row = row.strip()

Expand All @@ -139,7 +138,7 @@ def _parse(self, ocr_data):
raise OCRError("Venta startrecord 30, fekk {0}. ({1})!".format(row[6:8], row))

# Transaksjon
trans = self.TRANSAKSJONSTYPE[row[4:6]]
trans = cls.TRANSAKSJONSTYPE[row[4:6]]
dato = row[15:21]
dato = datetime.date(2000 + int(dato[4:6]), int(dato[2:4]), int(dato[0:2]))
belop = int(row[32:49])/100.0
Expand All @@ -156,7 +155,7 @@ def _parse(self, ocr_data):
row3 = ocr_data.next()
fritekst = row3[15:55]

self.data.append(dict(
data.append(dict(
transaksjon=trans,
dato=dato,
belop=belop,
Expand All @@ -165,4 +164,11 @@ def _parse(self, ocr_data):
fra_konto=fra_konto,
fritekst=fritekst,
))
return self.data
return data

if __name__ == '__main__':
import fileinput
import pprint

data = OCR._parse(fileinput.input())
pprint.pprint(data)

0 comments on commit 74fd433

Please sign in to comment.