rename sender address variable
Its makes more sense to call the variable sender_address than email_address
This commit is contained in:
parent
66f6430ecb
commit
5fc01ec52a
|
@ -1,4 +1,4 @@
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
smtp_server:
|
smtp_server:
|
||||||
email_address:
|
sender_address:
|
||||||
password: foo
|
password: foo
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Email(object):
|
||||||
def __init__ (self):
|
def __init__ (self):
|
||||||
self.email = ""
|
self.email = ""
|
||||||
|
|
||||||
def prompt_for_email(self):
|
def prompt_for_recipient(self):
|
||||||
self.email = input("Please enter your email address:")
|
self.email = input("Please enter your email address:")
|
||||||
return self.email
|
return self.email
|
||||||
|
|
||||||
|
@ -50,14 +50,15 @@ class Price(object):
|
||||||
|
|
||||||
class Configuration():
|
class Configuration():
|
||||||
def __init__ (self):
|
def __init__ (self):
|
||||||
|
self.config = ""
|
||||||
self.password = ""
|
self.password = ""
|
||||||
self.smtp_server = ""
|
self.smtp_server = ""
|
||||||
self.email_address = ""
|
self.sender_address = ""
|
||||||
self.check_location()
|
self.check_location()
|
||||||
|
|
||||||
def check_location(self):
|
def check_location(self):
|
||||||
# setup the config parser
|
# setup the config parser
|
||||||
config = configparser.ConfigParser()
|
self.config = configparser.ConfigParser()
|
||||||
# check whether the config file exists either in the home folder or
|
# check whether the config file exists either in the home folder or
|
||||||
# next to the binary
|
# next to the binary
|
||||||
home = os.getenv('HOME')
|
home = os.getenv('HOME')
|
||||||
|
@ -65,20 +66,20 @@ class Configuration():
|
||||||
config_folder = ".config/price_checker/"
|
config_folder = ".config/price_checker/"
|
||||||
config_path = os.path.join(home, config_folder, config_file)
|
config_path = os.path.join(home, config_folder, config_file)
|
||||||
if os.path.isfile(config_path):
|
if os.path.isfile(config_path):
|
||||||
config.read(config_path)
|
self.config.read(config_path)
|
||||||
elif os.path.isfile(config_file):
|
elif os.path.isfile(config_file):
|
||||||
config.read(config_file)
|
self.config.read(config_file)
|
||||||
else:
|
else:
|
||||||
print("Configuration file not found.")
|
print("Configuration file not found.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def apply_settings(self):
|
def apply_settings(self):
|
||||||
# assign the password variable
|
# assign the password variable
|
||||||
self.password = config['DEFAULT']['password']
|
self.password = self.config['DEFAULT']['password']
|
||||||
# assign the smtp_server variable
|
# assign the smtp_server variable
|
||||||
self.password = config['DEFAULT']['smtp_server']
|
self.smtp_server = self.config['DEFAULT']['smtp_server']
|
||||||
# assign the email_address variable
|
# assign the email_address variable
|
||||||
self.password = config['DEFAULT']['email_address']
|
self.sender_address = self.config['DEFAULT']['sender_address']
|
||||||
|
|
||||||
|
|
||||||
config = Config()
|
config = Config()
|
||||||
|
@ -86,7 +87,9 @@ email = Email()
|
||||||
website = Website()
|
website = Website()
|
||||||
price = Price()
|
price = Price()
|
||||||
|
|
||||||
email.prompt_for_email()
|
config.apply_settings()
|
||||||
|
|
||||||
|
email.prompt_for_recipient()
|
||||||
website.prompt_for_url()
|
website.prompt_for_url()
|
||||||
price.prompt_for_amount()
|
price.prompt_for_amount()
|
||||||
website.get_page()
|
website.get_page()
|
||||||
|
|
Reference in New Issue