00001 00002 00003 """ 00004 00005 ScrumPy -- Metabolic Modelling with Python 00006 00007 Copyright Mark Poolman 2009 00008 00009 This file is part of ScrumPy. 00010 00011 ScrumPy is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU General Public License as published by 00013 the Free Software Foundation; either version 2 of the License, or 00014 (at your option) any later version. 00015 00016 ScrumPy is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 GNU General Public License for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with ScrumPy; if not, write to the Free Software 00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 00025 """ 00026 00027 00028 def IsMatch(regex, s): 00029 matches = regex.findall(s) 00030 return len(matches) == 1 and matches[0] == s 00031 00032 00033 def IsQuoted(s): 00034 return len(s)>2 and (s[0] == s[-1] == '"') 00035 00036 00037 def DeQuote(s): 00038 if IsQuoted(s): 00039 return s[1:-1] 00040 return s 00041 00042 00043 def EnQuote(s): 00044 if not IsQuoted(s): 00045 return s.join(('"','"')) 00046 return s 00047 00048