<commit_before>from getpass import getpass
from os import makedirs
from os import path
import sys

def get_user_credentials():

	"""Gets the user credentials from the commandline.

	Asks the user for his McGill email address and password.


	Args:
		None

	Returns:
		An array containing the user credentials.

		Notice that no checks for validity is applied to the input.
		For testing purposes, if not executed in a tty, the username
		and password are goign to be read from stdin.

		Example:

			['username','password']

	Raises:
		IOError: An error occurred accessing the username file.
	"""

	if sys.stdin.isatty():
		# Gets the credentials from the userFile if it exists
		_mail = getusername()
		_pass = getpass(stream=sys.stderr)
		_cred = [_mail, _pass]

	else:
		# Gets the credentials from stdin
		_cred = sys.stdin.readlines()
		_cred = map(str.strip, _cred)

		print 'autologin\t:', _cred[0] 
		if len(_cred) != 2:
			print 'Error: Malformed input. Missing arguments.'
			exit()
			
	return _cred


def getusername(reset=False):

	"""	Gets the username either from the commandline,
		either from the user file (in ~/.minerva/).

	Asks the user for his McGill email address if no previous session
	has been stored, and save the session in the user file.


	Args:
		None

	Returns:
		A string containing the user email.

		Example:

			'<EMAIL>'

	Raises:
		IOError: An error occurred accessing the username file.
	"""

	_mailSaved = savedusername()
	_mail = ""
	
	if reset or ('@' and '.' in _mailSaved):
		print 'Read\t:', _mailSaved
		_mail = _mailSaved
	else:
		_mail = raw_input('Email\t: ')

		# Auto-completes the username if domain missing 
		if '.' in _mail and not '@' in _mail:
			_mail = _mail + '@mail.mcgill.ca'

	# Stores the email to the user file
	if _mail != _mailSaved:
		savedusername(_mail)

	return _mail<commit_msg>Fix: reset was not properly implemented.<commit_after>from getpass import getpass
from os import makedirs
from os import path
import sys

def get_user_credentials():

	"""Gets the user credentials from the commandline.

	Asks the user for his McGill email address and password.


	Args:
		None

	Returns:
		An array containing the user credentials.

		Notice that no checks for validity is applied to the input.
		For testing purposes, if not executed in a tty, the username
		and password are goign to be read from stdin.

		Example:

			['username','password']

	Raises:
		IOError: An error occurred accessing the username file.
	"""

	if sys.stdin.isatty():
		# Gets the credentials from the userFile if it exists
		_mail = getusername()
		_pass = getpass(stream=sys.stderr)
		_cred = [_mail, _pass]

	else:
		# Gets the credentials from stdin
		_cred = sys.stdin.readlines()
		_cred = map(str.strip, _cred)

		print 'autologin\t:', _cred[0] 
		if len(_cred) != 2:
			print 'Error: Malformed input. Missing arguments.'
			exit()
			
	return _cred


def getusername(reset=False):

	"""	Gets the username either from the commandline,
		either from the user file (in ~/.minerva/).

	Asks the user for his McGill email address if no previous session
	has been stored, and save the session in the user file.


	Args:
		None

	Returns:
		A string containing the user email.

		Example:

			'<EMAIL>'

	Raises:
		IOError: An error occurred accessing the username file.
	"""

	_mailSaved = savedusername()
	_mail = ""
	
	if not reset or ('@' and '.' in _mailSaved):
		print 'Read\t:', _mailSaved
		_mail = _mailSaved
	else:
		_mail = raw_input('Email\t: ')

		# Auto-completes the username if domain missing 
		if '.' in _mail and not '@' in _mail:
			_mail = _mail + '@mail.mcgill.ca'

	# Stores the email to the user file
	if _mail != _mailSaved:
		savedusername(_mail)

	return _mail
{'fraction_non_alphanumeric': 0.08791208791208792, 'fraction_numerical': 0.0010720986330742428, 'mean_word_length': 3.464114832535885, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '599530', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1175, 'n_words': 471}