Skip to content

Commit

Permalink
Fix #13 (genre bug)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arg0s1080 committed Dec 14, 2019
1 parent c096b92 commit 82061ed
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 20 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MRZ Generator and MRZ Checker are built according to International Civil Aviatio
country_code (str): 3 letters code (ISO 3166-1) or country name (in English)
document_number (str): Document number
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
nationality (str): 3 letters code (ISO 3166-1) or country name (in English)
surname (str): Holder primary identifier(s). This field will be transliterated
Expand All @@ -48,7 +48,7 @@ MRZ Generator and MRZ Checker are built according to International Civil Aviatio
document_number (str): Document number.
nationality (str): 3 letters code (ISO 3166-1) or country name
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
optional_data (str): Optional personal data at the discretion of the issuing State.
Non-mandatory field. Empty string by default
Expand All @@ -68,7 +68,7 @@ MRZ Generator and MRZ Checker are built according to International Civil Aviatio
document_number (str): Document number
nationality (str): 3 letters code (ISO 3166-1) or country name
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
optional data (str): Personal number. In some countries non-mandatory field. Empty string by default
transliteration (dict): Transliteration dictionary for non-ascii chars. Latin based by default
Expand All @@ -87,7 +87,7 @@ MRZ Generator and MRZ Checker are built according to International Civil Aviatio
document_number (str): Document number
nationality (str): 3 letters code (ISO 3166-1) or country name
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
optional_data (str): Optional personal data at the discretion of the issuing State.
Non-mandatory field. Empty string by default.
Expand All @@ -107,7 +107,7 @@ MRZ Generator and MRZ Checker are built according to International Civil Aviatio
document_number (str): Document number
nationality (str): 3 letters code (ISO 3166-1) or country name
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
optional_data (str): Optional personal data at the discretion of the issuing State.
Non-mandatory field. Empty string by default.
Expand Down
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TD1's (id cards):
country_code (str): 3 letters code (ISO 3166-1) or country name (in English)
document_number (str): Document number
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
nationality (str): 3 letters code (ISO 3166-1) or country name (in English)
surname (str): Holder primary identifier(s). This field will be transliterated
Expand Down Expand Up @@ -75,7 +75,7 @@ TD2
document_number (str): Document number.
nationality (str): 3 letters code (ISO 3166-1) or country name
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
optional_data (str): Optional personal data at the discretion of the issuing State.
Non-mandatory field. Empty string by default
Expand All @@ -99,7 +99,7 @@ TD3 (Passports)
document_number (str): Document number
nationality (str): 3 letters code (ISO 3166-1) or country name
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
optional data (str): Personal number. In some countries non-mandatory field. Empty string by default
transliteration (dict): Transliteration dictionary for non-ascii chars. Latin based by default
Expand All @@ -122,7 +122,7 @@ MRVA (Visas type A)
document_number (str): Document number
nationality (str): 3 letters code (ISO 3166-1) or country name
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
optional_data (str): Optional personal data at the discretion of the issuing State.
Non-mandatory field. Empty string by default.
Expand All @@ -146,7 +146,7 @@ MRVB (Visas type B)
document_number (str): Document number
nationality (str): 3 letters code (ISO 3166-1) or country name
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
optional_data (str): Optional personal data at the discretion of the issuing State.
Non-mandatory field. Empty string by default.
Expand Down
2 changes: 1 addition & 1 deletion examples/mrz_generator_samples/id_card_esp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"ESP", # Country 3 letters code or country name
"BAA000589", # Document number
"800101", # Birth date YYMMDD
"F", # Genre Male: 'M', Female: 'F' or Undefined 'X'
"F", # Genre Male: 'M', Female: 'F' or Undefined
"250101", # Expiry date YYMMDD
"ESP", # Nationality
"ESPAÑOLA ESPAÑOLA", # Surname Special characters will be transliterated
Expand Down
2 changes: 1 addition & 1 deletion mrz/base/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, msg="", cause=""):

class SexError(FieldError):
def __init__(self, msg="", cause=""):
self.msg = msg or "%sgenre. Sex code should be 'M', 'F' or 'X'" % default
self.msg = msg or "%sgenre. Sex code should be 'M', 'F' or undefined" % default
self.cause = cause
super(SexError, self).__init__(self.msg, self.cause)

Expand Down
2 changes: 1 addition & 1 deletion mrz/base/string_checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def sex(string):
>>> sex("m")
'M'
"""
if _is_string(string) and len(string) != 1 or string not in "MmFfXx":
if _is_string(string) and len(string) != 1 or string not in "MmFf<":
raise SexError(cause=string)
return string.upper()

Expand Down
2 changes: 1 addition & 1 deletion mrz/checker/_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def birth_date(self) -> bool:

@property
def sex(self) -> bool:
"""Return True if the sex is "M", "F" or "X", False otherwise."""
"""Return True if the sex is "M", "F", "X", "<" or "", False otherwise."""

ok = False
try:
Expand Down
3 changes: 2 additions & 1 deletion mrz/generator/_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ def sex(self) -> str:
def sex(self, value: str):
"""Set holder's genre
Can be used 'F' (female), 'M' (male) or 'X' (undefined). Case insensitive.
Can be used 'F' (female), 'M' (male) or undefined. Case insensitive.
"""
value = value if value not in "Xx" else "<"
self._sex = check.sex(value)

2 changes: 1 addition & 1 deletion mrz/generator/mrva.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MRVACodeGenerator(TD3CodeGenerator):
document_number (str): Document number
nationality (str): 3 letters code (ISO 3166-1) or country name
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
optional_data (str): Optional personal data at the discretion of the issuing State.
Non-mandatory field. Empty string by default.
Expand Down
2 changes: 1 addition & 1 deletion mrz/generator/mrvb.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MRVBCodeGenerator(TD2CodeGenerator):
document_number (str): Document number
nationality (str): 3 letters code (ISO 3166-1) or country name
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
optional_data (str): Optional personal data at the discretion of the issuing State.
Non-mandatory field. Empty string by default.
Expand Down
2 changes: 1 addition & 1 deletion mrz/generator/td1.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class TD1CodeGenerator(_TD1HolderName, _TD1HashGenerator, _Fields):
country_code (str): 3 letters code (ISO 3166-1) or country name (in English)
document_number (str): Document number
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
nationality (str): 3 letters code (ISO 3166-1) or country name (in English)
surname (str): Holder primary identifier(s)
Expand Down
2 changes: 1 addition & 1 deletion mrz/generator/td2.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class TD2CodeGenerator(_Fields, _TD2HashGenerator, _TD2HolderName):
document_number (str): Document number
nationality (str): 3 letters code (ISO 3166-1) or country name
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
optional_data (str): Optional personal data at the discretion of the issuing State.
Non-mandatory field. Empty string by default
Expand Down
2 changes: 1 addition & 1 deletion mrz/generator/td3.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class TD3CodeGenerator(_Fields, _TD3HashGenerator, _TD3HolderName):
document_number (str): Document number
nationality (str): 3 letters code (ISO 3166-1) or country name
birth_date (str): YYMMDD
sex (str): Genre. Male: 'M', Female: 'F' or Undefined 'X'
sex (str): Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or ""
expiry_date (str): YYMMDD
optional data (str): Personal number. In some countries non-mandatory field. Empty string by default
transliteration (dict): Transliteration dictionary for non-ascii chars. Latin based by default
Expand Down

0 comments on commit 82061ed

Please sign in to comment.