Exemple #1
0
def changeEmail(securityID: str, newEmail: str,
                singlevalue: SingleValue) -> None:
    """
    changes the email
    :param securityID: users ID
    :param newEmail: the new email
    :param singlevalue: SingleValue for the email
    :return: None
    """
    singlevalue._changeInfo(securityID, 'data', newEmail)
Exemple #2
0
def changeUsername(securityID: str, newUsername: str,
                   singlevalue: SingleValue) -> None:
    """
    changes the  username
    :param securityID: users ID
    :param newUsername: the new username
    :param singlevalue: SingleValue for the username
    :return: None
    """
    singlevalue._changeInfo(securityID, 'data', newUsername)
def changePassword(securityID: str, new_password: str,
                   singlevalue: SingleValue) -> None:
    """
    changes the password
    :param securityID: users ID
    :param new_password: the new password
    :param singlevalue: SingleValue for the password
    :return: None
    """
    singlevalue._changeInfo(securityID, 'data', new_password)
Exemple #4
0
def getUsername(securityID: str, singlevalue: SingleValue) -> str:
    """
    :param securityID: users ID
    :param singlevalue: SingleValue for the username
    :return: the username
    """
    return str(singlevalue._data(securityID))
Exemple #5
0
def getEmail(securityID: str, singlevalue: SingleValue) -> str:
    """
    :param securityID: users ID
    :param singleValue: SingleValue for the email
    :return: the email
    """
    return str(singlevalue._data(securityID))
def getPassword(securityID: str, singlevalue: SingleValue) -> str:
    """
    :param securityID: users ID
    :param singlevalue: SingleValue for the password
    :return: the password
    """
    return str(singlevalue._data(securityID))
Exemple #7
0
def createNewEmail(securityID: str, email: str, filePath: str = '../userInfo/singleValue/infoData/emailInfo.csv') -> \
        Optional[SingleValue]:
    """
    creates a SingleVale object for a username and creates a new
    username data file
    :param securityID: users ID
    :param email: the users email
    :param filePath: path to the email information file
    :return: SingleValue object for a username or call createEmail() if a data file is already found
    """
    if not path.exists(filePath):
        return SingleValue(securityID, filePath, 'email', email)
    else:
        print('Data file already exists for email... calling createEmail()')
        createEmail(securityID, filePath)
def createNewID(
    filePath: str = '../userInfo/singleValue/infoData/securityIDInfo.csv'
) -> Optional[SingleValue]:
    """
    creates a SingleValue object for a ID and a new securityID and securityIDInfo
    data file
    :param filePath: path to the password data file
    :return: SingleValue object for a password
    """
    newid = ''
    for i in range(1, 8):
        newid = newid + str(random.randint(1, 9))
    if path.exists(filePath):
        remove(filePath)
    return SingleValue(newid, filePath, 'id', newid)
def loadID(
    securityID: str,
    filePath: str = '../userInfo/singleValue/infoData/securityIDInfo.csv'
) -> Optional[SingleValue]:
    """
    creates a SingleValue object for a ID from an exiting ID data file
    :param securityID: users ID
    :param filePath: path to the ID data file
    :return: SingleValue object for a ID or None if a data file is not found
    """
    if path.exists(filePath):
        return SingleValue(securityID, filePath)
    else:
        print(
            'Data File Does not exist for the ID... Please call createNewID()')
        return None
Exemple #10
0
def loadUsername(
    securityID: str,
    filePath: str = '../userInfo/singleValue/infoData/usernameInfo.csv'
) -> object:
    """
    creates a SingleValue object for a username from an exiting username
    data file
    :param securityID: users ID
    :param filePath: path to the username data file
    :return: SingleValue object for a username or None if a data file is not found
    """
    if path.exists(filePath):
        return SingleValue(securityID, filePath)
    else:
        print(
            'Data File Does not exist for username... Please call createNewUsername()'
        )
        return None
Exemple #11
0
def loadEmail(
    securityID: str,
    filePath: str = '../userInfo/singleValue/infoData/emailInfo.csv'
) -> object:
    """
    creates a SingleValue object for a email from an exiting email
    data file
    :param securityID: users ID
    :param filePath: path to the email data file
    :return: SingleValue object for a email or None if a data file is not found
    """
    if path.exists(filePath):
        return SingleValue(securityID, filePath)
    else:
        print(
            'Data File Does not exist for email... Please call createNewEmail()'
        )
        return None
def loadPassword(
    securityID: str,
    filePath: str = '../userInfo/singleValue/infoData/passwordInfo.csv'
) -> Optional[SingleValue]:
    """
    creates a SingleValue object for a password from an exiting password
    data file
    :param securityID: users ID
    :param filePath: path to the password data file
    :return: SingleValue object for a password or None if a data file is not found
    """
    if path.exists(filePath):
        return SingleValue(securityID, filePath)
    else:
        print(
            'Data File Does not exist for password... Please call createNewPassword()'
        )
        return None
def createNewPassword(
    securityID: str,
    new_password: str,
    filePath: str = '../userInfo/singleValue/infoData/passwordInfo.csv'
) -> Optional[SingleValue]:
    """
    creates a SingleVale object for a password and creates a new
    password data file
    :param securityID: users ID
    :param new_password: the users password
    :param filePath: path to the password information file
    :return: SingleValue object for a password or call loadPassword() if a data file is already found
    """
    if not path.exists(filePath):
        return SingleValue(securityID, filePath, 'password', new_password)
    else:
        print(
            'Data file already exists for password... calling loadPassword()')
        loadPassword(securityID, filePath)
Exemple #14
0
def createNewUsername(
    securityID: str,
    username: str,
    filePath: str = '../userInfo/singleValue/infoData/usernameInfo.csv'
) -> Optional[SingleValue]:
    """
    creates a SingleVale object for a username and creates a new
    username data file
    :param securityID: users ID
    :param username: the users username
    :param filePath:
    :return: SingleValue object for a username or call createUsername() if a data file is already found
    """
    if not path.exists(filePath):
        return SingleValue(securityID, filePath, 'username', username)
    else:
        print(
            'Data file already exists for  username... calling create username()'
        )
        loadUsername(securityID, filePath)
from userInfo.singleValue.singleValue import SingleValue

print("Testing construction without an existing data file...\n")
s = SingleValue("8416826", 'userInfo/singleValue/infoData/testSingleValue.csv',
                'type', 'data')
first_path = s._path("8416826")
first_type = s._type("8416826")
first_data = s._data("8416826")

s._changeInfo("8416826", 'data', '*****@*****.**')
first_data_two = s._data("8416826")
print("All methods tested with new data file construction!\n\n")

print("Testing construction from an existing data file...\n")
v = SingleValue("8416826", 'userInfo/singleValue/infoData/testSingleValue.csv')
second_path = v._path("8416826")
second_type = v._type("8416826")
second_data = v._data("8416826")

v._changeInfo("8416826", 'data', '*****@*****.**')
second_data_two = v._data("8416826")

v._removeDataFile("8416826")
print("All methods tested with existing data file construction!\n\n")
print("Both tests have the same...")
print("Path:", first_path == second_path)
print("Type:", first_type == second_type)
print("Data:", first_data == second_data)
print("Changed data:", first_data_two == second_data_two)
def getID(singlevalue: SingleValue) -> str:
    """
    :param singlevalue: SingleValue for the id
    :return: the users id
    """
    return str(singlevalue._data('securityID'))