Slight improvements

This commit is contained in:
Gabriel Augendre 2019-07-11 19:29:08 +02:00
parent 8d2df2db0b
commit 5624cc870d

10
main.py
View file

@ -22,7 +22,7 @@ class InseeData:
city = insee_number[8:10] city = insee_number[8:10]
self.foreign = False self.foreign = False
if department == "99": if department in ["91", "92", "93", "94", "95", "96", "99"]:
self.foreign = True self.foreign = True
self._country = city self._country = city
else: else:
@ -79,11 +79,12 @@ class InseeData:
return self._department return self._department
def __str__(self): def __str__(self):
message = [] message = [self.insee_number]
if self.is_valid: if self.is_valid:
message.append("The number is valid") message.append("The number is valid.")
else: else:
message.append("The number is invalid") message.append("The number is invalid.")
message.append( message.append(
f"You're a {self.gender}, born in {calendar.month_name[self.month]}, probably in {self.year}." f"You're a {self.gender}, born in {calendar.month_name[self.month]}, probably in {self.year}."
@ -122,6 +123,7 @@ class InseeData:
def to_dict(self): def to_dict(self):
data = { data = {
"insee_number": self.insee_number,
"is_valid": self.is_valid, "is_valid": self.is_valid,
"gender": self.gender_short, "gender": self.gender_short,
"month": self.month, "month": self.month,