Author: bugman Date: Tue Jan 24 16:08:40 2012 New Revision: 15231 URL: http://svn.gna.org/viewcvs/relax?rev=15231&view=rev Log: Merged revisions 15230 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r15230 | bugman | 2012-01-24 16:08:00 +0100 (Tue, 24 Jan 2012) | 6 lines Simplified the generic_fns.relax_re.search() function. This is to minimise the number of isinstance() calls when dealing with the relax mol-res-spin sequence data. ........ Modified: branches/frame_order_testing/ (props changed) branches/frame_order_testing/generic_fns/relax_re.py Propchange: branches/frame_order_testing/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Tue Jan 24 16:08:40 2012 @@ -1,1 +1,1 @@ -/1.3:1-15228 +/1.3:1-15230 Modified: branches/frame_order_testing/generic_fns/relax_re.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/generic_fns/relax_re.py?rev=15231&r1=15230&r2=15231&view=diff ============================================================================== --- branches/frame_order_testing/generic_fns/relax_re.py (original) +++ branches/frame_order_testing/generic_fns/relax_re.py Tue Jan 24 16:08:40 2012 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2003-2004, 2006-2008 Edward d'Auvergne # +# Copyright (C) 2003-2012 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -38,13 +38,10 @@ 1. All '*' to '.*'. 2. The identifier is bracketed, '^' is added to the start and '$' to the end. - After conversion of both the string and patterns, the comparison is then performed both ways - from the converted string matching the original string (using re.search()). + After conversion of both the string and patterns, the comparison is then performed both ways from the converted string matching the original string (using re.search()). - @param pattern: The pattern to match the string to. This can be a list of patterns. All - elements will be converted to strings, so the pattern or list can consist of - anything. + @param pattern: The pattern to match the string to. This can be a list of patterns. All elements will be converted to strings, so the pattern or list can consist of anything. @type pattern: anything @param id: The identification object. @type id: None, str, or number @@ -56,9 +53,8 @@ if id == None: return False - # If a number, convert to a string. - if isinstance(id, int) or isinstance(id, float): - id = str(id) + # Convert to a string. + id = str(id) # If pattern is not a list, convert it to one. if not isinstance(pattern, list): @@ -76,8 +72,8 @@ id_re = replace(id, '*', '.*') # Bracket the pattern. - pattern_re = '^' + pattern_re + '$' - id_re = '^' + id_re + '$' + pattern_re = '^%s$' % pattern_re + id_re = '^%s$' % id_re # String matches (both ways). if re.search(pattern_re, id):