SConstruct (5571:7f81bb169068) SConstruct (5588:d8b246a665c1)
1# -*- mode:python -*-
2
3# Copyright (c) 2004-2005 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

--- 77 unchanged lines hidden (view full) ---

86# helper function: compare arrays or strings of version numbers.
87# E.g., compare_version((1,3,25), (1,4,1)')
88# returns -1, 0, 1 if v1 is <, ==, > v2
89def compare_versions(v1, v2):
90 def make_version_list(v):
91 if isinstance(v, (list,tuple)):
92 return v
93 elif isinstance(v, str):
1# -*- mode:python -*-
2
3# Copyright (c) 2004-2005 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

--- 77 unchanged lines hidden (view full) ---

86# helper function: compare arrays or strings of version numbers.
87# E.g., compare_version((1,3,25), (1,4,1)')
88# returns -1, 0, 1 if v1 is <, ==, > v2
89def compare_versions(v1, v2):
90 def make_version_list(v):
91 if isinstance(v, (list,tuple)):
92 return v
93 elif isinstance(v, str):
94 return map(int, v.split('.'))
94 return map(lambda x: int(re.match('\d+', x).group()), v.split('.'))
95 else:
96 raise TypeError
97
98 v1 = make_version_list(v1)
99 v2 = make_version_list(v2)
100 # Compare corresponding elements of lists
101 for n1,n2 in zip(v1, v2):
102 if n1 < n2: return -1

--- 772 unchanged lines hidden ---
95 else:
96 raise TypeError
97
98 v1 = make_version_list(v1)
99 v2 = make_version_list(v2)
100 # Compare corresponding elements of lists
101 for n1,n2 in zip(v1, v2):
102 if n1 < n2: return -1

--- 772 unchanged lines hidden ---