[GRASS-SVN] r55277 - grass/branches/releasebranch_6_4/lib/python
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Mar 3 00:41:38 PST 2013
Author: annakrat
Date: 2013-03-03 00:41:38 -0800 (Sun, 03 Mar 2013)
New Revision: 55277
Modified:
grass/branches/releasebranch_6_4/lib/python/core.py
Log:
backport r55229
Modified: grass/branches/releasebranch_6_4/lib/python/core.py
===================================================================
--- grass/branches/releasebranch_6_4/lib/python/core.py 2013-03-01 21:01:50 UTC (rev 55276)
+++ grass/branches/releasebranch_6_4/lib/python/core.py 2013-03-03 08:41:38 UTC (rev 55277)
@@ -1199,3 +1199,25 @@
# get debug_level
if find_program('g.gisenv', ['--help']):
debug_level = int(gisenv().get('DEBUG', 0))
+
+
+def legal_name(s):
+ """!Checks if the string contains only allowed characters.
+
+ This is the Python implementation of G_legal_filename() function.
+
+ @note It is not clear when to use this function.
+ """
+ if not s or s[0] == '.':
+ warning(_("Illegal filename <%s>. Cannot be empty or start with '.'.") % s)
+ return False
+
+ illegal = [c
+ for c in s
+ if c in '/"\'@,=*~' or c <= ' ' or c >= '\177']
+ if illegal:
+ illegal = ''.join(sorted(set(illegal)))
+ warning(_("Illegal filename <%s>. <%s> not allowed.\n") % (s, illegal))
+ return False
+
+ return True
More information about the grass-commit
mailing list