Skip to content

Commit

Permalink
Merge pull request #74 from stratofax/dev-make-flat
Browse files Browse the repository at this point in the history
Consolidate code to use ElectionData class
  • Loading branch information
stratofax authored Aug 17, 2022
2 parents d5f38b5 + 5980e96 commit 5e2674c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 52 deletions.
1 change: 0 additions & 1 deletion src/electos/ballotmaker/election_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __post_init__(self):
self.election_report.election[0].name.text[0].content
)
log.info(f"Election: {self.election_name}")

self.start_date = self.election_report.election[0].start_date
log.info(f"Start date: {self.start_date}")
self.end_date = self.election_report.election[0].end_date
Expand Down
14 changes: 4 additions & 10 deletions src/electos/ballotmaker/make_ballots.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from pathlib import Path

from electos.ballotmaker.constants import NO_ERRORS, NO_FILE
from electos.ballotmaker.election_data import ElectionData

log = logging.getLogger(__name__)

Expand All @@ -16,13 +16,7 @@ def make_ballots(
Output directory for generated PDF files
Styles file for ballot formatting
"""
# is the EDF a file?
if _edf is None:
log.debug("No EDF file provided to make ballots.")
return NO_FILE
if not _edf.is_file():
log.debug(f"Can't make ballots, EDF {_edf} is not a file")
return NO_FILE
# was a valid output directory provided?
# was a styles file provided?
return NO_ERRORS
# was a styles file provided
election_data = ElectionData(_edf)
return election_data.edf_error
14 changes: 0 additions & 14 deletions src/electos/ballotmaker/read_edf.py

This file was deleted.

15 changes: 3 additions & 12 deletions src/electos/ballotmaker/validate_edf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import logging
from pathlib import Path

from electos.ballotmaker.constants import NO_DATA, NO_ERRORS, NO_FILE
from electos.ballotmaker.read_edf import read_edf
from electos.ballotmaker.election_data import ElectionData

log = logging.getLogger(__name__)

Expand All @@ -14,14 +13,6 @@ def validate_edf(
Requires:
EDF file (JSON format) edf_file: Path,
"""
# is the EDF a file?
if _edf is None:
log.debug("No EDF file provided for validation.")
return NO_FILE
if not _edf.is_file():
log.debug(f"Can't validate, EDF {_edf} is not a file")
return NO_FILE
election_data = ElectionData(_edf)

ballot_style_count = read_edf(_edf)
log.info(f"Found {ballot_style_count} ballots in {_edf}")
return NO_ERRORS
return election_data.edf_error
15 changes: 0 additions & 15 deletions tests/test_read_edf.py

This file was deleted.

0 comments on commit 5e2674c

Please sign in to comment.