aboutsummaryrefslogtreecommitdiffstats
path: root/gsxws/core.py
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-08-14 11:06:26 +0300
committerFilipp Lepalaan <filipp@mac.com>2015-08-14 11:06:26 +0300
commit873282c158faa9bbd4716dab5280bf537543ce48 (patch)
tree8c31ffc2dd0232cca93663b1fbb08ba6219098ab /gsxws/core.py
parenta8806ed5c5b2cb79993820788757e86516fb92be (diff)
downloadpy-gsxws-873282c158faa9bbd4716dab5280bf537543ce48.tar.gz
py-gsxws-873282c158faa9bbd4716dab5280bf537543ce48.tar.bz2
py-gsxws-873282c158faa9bbd4716dab5280bf537543ce48.zip
Improved part number recognition
Diffstat (limited to 'gsxws/core.py')
-rw-r--r--gsxws/core.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/gsxws/core.py b/gsxws/core.py
index 55a086f..4fd4ee3 100644
--- a/gsxws/core.py
+++ b/gsxws/core.py
@@ -109,12 +109,16 @@ def validate(value, what=None):
>>> validate('XD368Z/A', 'partNumber')
True
+ >>> validate('XGWL2Z/A', 'partNumber')
+ True
>>> validate('ZM661-5883', 'partNumber')
True
>>> validate('661-01234', 'partNumber')
True
>>> validate('B661-6909', 'partNumber')
True
+ >>> validate('G143111400', 'dispatchId')
+ True
>>> validate('blaa', 'serialNumber')
False
>>> validate('MacBook Pro (Retina, Mid 2012)', 'productName')
@@ -126,12 +130,12 @@ def validate(value, what=None):
raise ValueError('%s is not valid input (%s != string)' % (value, type(value)))
rex = {
- 'partNumber': r'^([A-Z]{1,2})?\d{3}\-?(\d{4,5}|[A-Z]{1,2})(/[A-Z])?$',
+ 'partNumber': r'^([A-Z]{1,4})?\d{1,3}\-?(\d{1,5}|[A-Z]{1,2})(/[A-Z])?$',
'serialNumber': r'^[A-Z0-9]{11,12}$',
'eeeCode': r'^[A-Z0-9]{3,4}$',
'returnOrder': r'^7\d{9}$',
'repairNumber': r'^\d{12}$',
- 'dispatchId': r'^G\d{9}$',
+ 'dispatchId': r'^[A-Z]+\d{9,15}$',
'alternateDeviceId': r'^\d{15}$',
'diagnosticEventNumber': r'^\d{23}$',
'productName': r'^i?Mac',