Skip to content

Commit

Permalink
More Pythonic EAPF than LBYL style
Browse files Browse the repository at this point in the history
  • Loading branch information
rockinrobstar committed Jan 13, 2019
1 parent cb16983 commit e55e74b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ def create_config():
config = configparser.ConfigParser()
# get existing values if they exist
fileName = os.path.join(local_dir, '.nemweb_config.ini')
if (os.path.isfile(fileName)) and (os.path.exists(fileName)):
print("found existing config file: %s" % fileName)
try:
config.read_file(open(fileName))
else:
print("failed to find existing config file: %s" % fileName)
print("found existing config file: %s" % fileName)
except (OSError, configparser.ParsingError):
print("failed to read existing config file: %s" % fileName)
if not config.has_section('local_settings'):
config.add_section('local_settings')
print('added local_settings')
if config.has_option("local_settings","sqlite_dir"):
try:
old_sqlite_db_dir = config.get("local_settings","sqlite_dir")
else:
except configparser.NoOptionError:
old_sqlite_db_dir = os.path.expanduser("~/NEMData/")
sqlite_db_dir = input("Enter sqlite directory (abs path)[" + old_sqlite_db_dir + "]:")
sqlite_db_dir = sqlite_db_dir or old_sqlite_db_dir
print("set sqlite_dir to %s" % sqlite_db_dir)
if config.has_option("local_settings","start_date"):
try:
old_start_date = config.get("local_settings","start_date")
else:
except configparser.NoOptionError:
old_start_date = "20090701" # oldest known NEM data date
start_date = input("Enter start date to begin down loading from (YYYYMMDD):[" + old_start_date + "]:")
start_date = start_date or old_start_date
Expand All @@ -42,7 +42,7 @@ def run(self):
try:
create_config()
except:
pass
print("failed to create config file")
install.run(self)

class PostDevelopCommand(develop):
Expand Down

0 comments on commit e55e74b

Please sign in to comment.