On Fri, Dec 26, 2014 at 12:15 PM, Denis McMahon <denismfmcma...@gmail.com> wrote:
> Note, I think the 1981 model year ran KCA - DCA prefixes, not as shown on > the website you quoted. > ​Denis, Regarding the KCA - DCA prefixes, do you have a source as to why you think this? Here is what I have so far with a simple test at the end. I don't show is a dict which contains more information about the year/model, its not relivant. I am happy with how it is working, I hope to be able to decode BSA, and other British or more generally vintage motorcycle frame and engine numbers. BSA looks like a mess. def vin_to_year2(vin): vin = vin.lower() alpha_digit_alpha = re.match(r'^(\D+)(\d+)(\D+)$', vin) digit_alpha = re.match(r'^(\d+)(\D+)$', vin) alpha_digit = re.match(r'^(\D+)+(\d+)$', vin) alpha = re.match(r'^(\d+)$', vin) if alpha_digit_alpha: alpha_digit_alpha.groups() elif digit_alpha: g = digit_alpha.groups() if 100<=int(g[0]) and g[-1]=='n': # Triumph 1950: From 100N return 't1950' elif 101<=int(g[0])<=15808 and g[-1]=='na': # Triumph 1951: 101NA - 15808NA return 't1951' elif 15809<=int(g[0])<=25000 and g[-1]=='na': # Triumph 1952: 15809NA - 25000NA, see also alpha only vin for 1952 # Triumph 1952: 15809NA - 25000NA return 't1952' else: return None elif alpha_digit: g = alpha_digit.groups() if g[0] == 'h' and 101 <= int(g[1]) <= 760: # tu1957: H101 - H760 return 'tu1957' elif g[0] == 'h' and 761 <= int(g[1]) <= 5484: # tu1958: H761 - H5484 return 'tu1958' elif g[0] == 'h' and 5485 <= int(g[1]) <= 11511: # tu1959: H5485 - H11511 return 'tu1959' elif g[0] == 'h' and 11512 <= int(g[1]) <= 18611: # tu1960: H11512 - H18611 return 'tu1960' elif g[0] == 'h' and 18612 <= int(g[1]) <= 25251: # tu1961: H18612 - H25251 return 'tu1961' elif g[0] == 'h' and 25252 <= int(g[1]) <= 29732: # tu1962: H25252 - H29732 return 'tu1962' elif g[0] == 'h' and 29733 <= int(g[1]) <= 32464: # tu1963: H29733 - H32464 return 'tu1963' elif g[0] == 'h' and 32465 <= int(g[1]) <= 35986: # tu1964: H32465 - H35986 return 'tu1964' elif g[0] == 'h' and 35987 <= int(g[1]) <= 40527: # tu1965: H35987 - H40527 return 'tu1965' elif g[0] == 'h' and 40528 <= int(g[1]) <= 49832: # tu1966: H40528 - H49832 return 'tu1966' elif g[0] == 'h' and 49833 <= int(g[1]) <= 57082: # tu1967: H49833 - H57082 return 'tu1967' elif g[0] == 'h' and 57083 <= int(g[1]) <= 65572: # tu1968: H57083 - H65572 return 'tu1968' elif g[0] == 'h' and 65573 <= int(g[1]) <= 67331: # tu1969: H65573 - H67331 return 'tu1969' elif g[0] == 'd' and 101 <= int(g[1]) <= 7726: # tp1960: D101 - D7726 return 'tp1960' elif g[0] == 'd' and 7727 <= int(g[1]) <= 15788: # tp1961: D7727 - D15788 return 'tp1961' elif g[0] == 'd' and 15789 <= int(g[1]): # tp1962: D15789 - onward return 'tp1962' elif g[0] == 'du' and 101 <= int(g[1]) <= 5824: # 650 t65u1963: DU101 - DU5824 return 't65u1963' elif g[0] == 'du' and 5825 <= int(g[1]) <= 13374: # 650 t65u1964: DU5825 - DU13374 return 't65u1964' elif g[0] == 'du' and 5825 <= int(g[1]) <= 13374: # 650 t65u1965: DU5825 - DU13374 return 't65u1965' elif g[0] == 'du' and 24875 <= int(g[1]) <= 44393: # 650 t65u1966: DU24875 - DU44393 return 't65u1966' elif g[0] == 'du' and 44394 <= int(g[1]) <= 66245: # 650 t65u1967: DU44394 - DU66245 return 't65u1967' elif g[0] == 'du' and 66246 <= int(g[1]) <= 85903: # 650 t65u1968: DU66246 - DU85903 return 't65u1968' elif g[0] == 'du' and 85904 <= int(g[1]) <= 90282: # 650 t65u1969: DU85904 - DU90282 return 't65u1969' else: return None elif alpha: g = alpha.groups() if 25000 <= int(g[0]) <= 32302: # t1952: 25000 - 32302 return 't1952' elif 32303 <= int(g[0]) <= 44134: # t1953: 32303 - 44134 return 't1953' elif 44135 <= int(g[0]) <= 56699: # t1954: 44135 - 56699 return 't1954' elif 56700 <= int(g[0]) <= 70929: # t1955: 56700 - 70929 return 't1955' elif 70930 <= int(g[0]) <= 82799: # t1956: 70930 - 82799 return 't1956' elif 100 <= int(g[0]) <= 944 and g[0][0]=='0': # t1956: 0100 - 0944 return 't1956' elif g[0][0] == '0' and 945 <= int(g[0]) <= 11115: # tp1957: 0945 - 011115 return 'tp1957' elif g[0][0] == '0' and 11116 <= int(g[0]) <= 20075: # tp1958: 011116 - 020075 return 'tp1958' elif g[0][0] == '0' and 20076 <= int(g[0]) <= 29363: # tp1959: 020076 - 029363 return 'tp1959' elif g[0][0] == '0' and 29364 <= int(g[0]) <= 30424: # tp1960: 029364 - 030424 return 'tp1960' else: return None else: return None vin_test_list = ['101n', '500n', '234na', '15809NA', '25000', '32303', '44135', '56700', '70930', '0100', 'H11512', 'D15789', 'DU101'] for vin in vin_test_list: print(vin_to_year2(vin)) Vincent Davis 720-301-3003
-- https://mail.python.org/mailman/listinfo/python-list