Cannot use reserved keywords when writing to config.php
authorFred <fmcell@gmail.com>
Mon, 4 Mar 2013 09:42:02 +0000 (17:42 +0800)
committerFred <fmcell@gmail.com>
Mon, 4 Mar 2013 09:42:02 +0000 (17:42 +0800)
lib/moodle.py

index 8b28a77..86cdea3 100644 (file)
@@ -50,7 +50,19 @@ class Moodle(object):
     _cos_hasstash = False
     _cos_oldbranch = None
 
-    def __init__(self, path, identifier = None):
+    _reservedKeywords = [
+        'branch',
+        'identifier',
+        'installed',
+        'integration',
+        'maturity',
+        'path',
+        'release',
+        'stablebranch',
+        'version'
+    ]
+
+    def __init__(self, path, identifier=None):
         self.path = path
         self.identifier = identifier
         self.version = {}
@@ -64,6 +76,9 @@ class Moodle(object):
         if not os.path.isfile(configFile):
             return None
 
+        if name in self._reservedKeywords:
+            raise Exception('Cannot use reserved keywords for settings in config.php')
+
         if type(value) == bool:
             value = 'true' if value else 'false'
         elif type(value) != int: