Skip to content

Commit

Permalink
Remove nested try block
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Birkett committed Jul 25, 2018
1 parent ce27317 commit 0f81047
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions publicholiday/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ def main(country):
country.lower() == x.lower()), '')

try:
country_holidays = getattr(holidays, country_name)
try:
isinstance(country_holidays(), holidays.HolidayBase)
except TypeError:
raise AttributeError

except AttributeError:
country_holidays = getattr(holidays, country_name)()
isinstance(country_holidays, holidays.HolidayBase)
except (TypeError, AttributeError):
logging.error("Country: %s not found." % country)
sys.exit(127)

sys.exit(date.today() not in country_holidays())
sys.exit(date.today() not in country_holidays)

0 comments on commit 0f81047

Please sign in to comment.