Skip to content

Commit ea535c0

Browse files
authored
Support EGP, AED and SAR (scrapinghub#75)
1 parent 32b6b80 commit ea535c0

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

price_parser/parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ def or_regex(symbols: list[str]) -> Pattern[str]:
189189
"ل.ل.\u200f",
190190
" تومان",
191191
"تومان",
192+
"درهم",
193+
"ريال",
194+
"جنيه",
192195
# other common symbols, which we consider unambiguous
193196
"EUR",
194197
"euro",

tests/test_price_parsing.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ def idfn(val: object) -> str | None:
102102
Example(None, "3,500円", "円", "3,500", 3500),
103103
Example(None, "CHF 1'049,95", "CHF", "1049,95", 1049.95),
104104
Example(None, "€1'049,95", "€", "1049,95", 1049.95),
105+
Example(None, "644.00 جنيه", "جنيه", "644.00", 644.0), # Egyptian pound (EGP)
106+
Example(None, "3,439.00 درهم", "درهم", "3,439.00", 3439.0), # UAE dirham (AED)
107+
Example(None, "106.61 ريال", "ريال", "106.61", 106.61), # Saudi riyal (SAR)
105108
]
106109

107110

@@ -1271,7 +1274,6 @@ def idfn(val: object) -> str | None:
12711274
Example(None, "1 บาท", "บาท", "1", 1.0), # Thai baht
12721275
Example(None, "1 ر.س", "ر.س", "1", 1.0), # Saudi riyal
12731276
Example(None, "1.198,- Kr", "Kr", "1.198", 1198.0),
1274-
Example(None, "45 جنيه", "جنيه", "45", 45.0), # Egyptian Pound (EGP)
12751277
Example(None, "45 ج.م", "ج.م", "45", 45.0), # Egyptian Pound (EGP)
12761278
Example(None, "45 E£", "E£", "45", 45.0), # Egyptian Pound (EGP)
12771279
Example(None, "2000 zl", "zl", "2000", 2000.0), # Polish zloty (PLN)
@@ -1384,7 +1386,6 @@ def idfn(val: object) -> str | None:
13841386
Example(None, "1 دينار كويتي", "دينار كويتي", "1", 1.0), # Kuwaiti dinar
13851387
Example(None, "1 ر.ع", "ر.ع", "1", 1.0), # Omani rial
13861388
Example(None, "1 ر.ق", "ر.ق", "1", 1.0), # Qatari riyal
1387-
Example(None, "1 ريال", "ريال", "1", 1.0), # Saudi riyal
13881389
Example(None, "1 ش.ج", "ش.ج", "1", 1.0), # Israeli new shekel
13891390
Example(None, "1 ل.س", "ل.س", "1", 1.0), # Syrian pound
13901391
Example(None, "1 ل.ل", "ل.ل", "1", 1.0), # Lebanese pound
@@ -1407,13 +1408,6 @@ def idfn(val: object) -> str | None:
14071408
Example(None, "ש'ח", "ש'ח", "1", 1.0), # Israeli new shekel
14081409
Example(None, "د.ع", "د.ع", "1", 1.0), # Iraqi dinar
14091410
Example(None, "د.ل", "د.ل", "1", 1.0), # Libyan dinar
1410-
Example(
1411-
None,
1412-
"درهم", # United Arab Emirates dirham, Moroccan dirham
1413-
"درهم",
1414-
"1",
1415-
1.0,
1416-
),
14171411
Example(None, "ر.ي", "ر.ي", "1", 1.0), # Yemeni rial
14181412
Example(None, "ش.ص", "ش.ص", "1", 1.0), # Somali shilling
14191413
Example(

0 commit comments

Comments
 (0)