Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- # This is the class that reads in the user's credentials:
- class InputReader():
- def __init__(self):
- self.username = ""
- self.password = ""
- self.credentials = ""
- def readInput(self):
- self.username = raw_input("Username: ")
- self.password = raw_input("Password: ")
- self.credentials = self.username + ", " + self.password
- def getCredentials(self):
- return self.credentials
- class CredentialWriter():
- def __init__(self, line = ""):
- self.line = line
- def validCredentials(self):
- ### Purpose: Determine whether or not the credentials (username + password) are valid.
- if re.search("[%^&\d]", self.line) == None:
- return True
- else:
- return False
- def writeToCorrectFile(self):
- ### Purpose: Write the credentials to one of two files.
- if self.validCredentials():
- ### ^ We don't have to pass in line as an argument anymore.
- file = open("human_login.csv","a")
- file.write(self.line + "\n")
- file.close()
- else:
- file = open("bot_login.csv","a")
- file.write(self.line + "\n")
- file.close()
- # Create a new InputReader named ir.
- ir = InputReader()
- # Run the readInput function to get the user's credentials.
- ir.readInput()
- # Print out the username and password separated by a comma.
- print ir.getCredentials()
- cw = CredentialWriter(ir.getCredentials())
- ### ^ ir.getCredentials is passed in here now because of __init__
- cw.writeToCorrectFile()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement