[rtems-tools commit] VERSION as an INI format file.

Chris Johns chrisj at rtems.org
Fri Dec 11 06:19:22 UTC 2015


Module:    rtems-tools
Branch:    master
Commit:    3828e5033c9a251c2901e67c88e2ef2ea5f69a81
Changeset: http://git.rtems.org/rtems-tools/commit/?id=3828e5033c9a251c2901e67c88e2ef2ea5f69a81

Author:    Chris Johns <chrisj at rtems.org>
Date:      Fri Dec 11 17:01:51 2015 +1100

VERSION as an INI format file.

One section is supported [version] with a 'release' entry.

---

 rtemstoolkit/version.py | 19 +++++++++++--------
 wscript                 | 13 +++++++------
 2 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/rtemstoolkit/version.py b/rtemstoolkit/version.py
index df74510..542a8e0 100644
--- a/rtemstoolkit/version.py
+++ b/rtemstoolkit/version.py
@@ -42,7 +42,9 @@ import path
 #
 # Default to an internal string.
 #
-_version_str = '4.12.not_release'
+_version = '4.12'
+_revision = 'not_released'
+_version_str = '%s.%s' % (_version, _revision)
 _released = False
 _git = False
 
@@ -56,12 +58,13 @@ def _load_released_version():
     for ver in [at, path.join(at, '..')]:
         if path.exists(path.join(ver, 'VERSION')):
             try:
-                with open(path.join(ver, 'VERSION')) as v:
-                    _version_str = v.readline().strip()
-                v.close()
-                _released = True
-            except:
-                raise error.general('Cannot access the VERSION file')
+                import configparser
+            except ImportError:
+                import ConfigParser as configparser
+            v = configparser.SafeConfigParser()
+            v.read(path.join(ver, 'VERSION'))
+            _version_str = v.get('version', 'release')
+            _released = True
     return _released
 
 def _load_git_version():
@@ -74,7 +77,7 @@ def _load_git_version():
             modified = ' modified'
         else:
             modified = ''
-        _version_str = '%s (%s%s)' % (_version_str, head[0:12], modified)
+        _version_str = '%s (%s%s)' % (_version, head[0:12], modified)
         _git = True
     return _git
 
diff --git a/wscript b/wscript
index d519f06..9cbf682 100644
--- a/wscript
+++ b/wscript
@@ -41,11 +41,12 @@ def get_version(ctx):
     release = '%s.%s' % (version, revision)
     if os.path.exists('VERSION'):
         try:
-            with open('VERSION') as v:
-                release = v.readline().strip()
-            v.close()
-        except:
-            ctx.fatal('cannot access the VERSION file')
+            import configparser
+        except ImportError:
+            import ConfigParser as configparser
+        v = configparser.SafeConfigParser()
+        v.read('VERSION')
+        release = v.get('version', 'release')
     else:
         from rtemstoolkit import git
         repo = git.repo('.')
@@ -55,7 +56,7 @@ def get_version(ctx):
                 modified = '_modified'
             else:
                 modified = ''
-            release = '%s.%s%s)' % (version, head[0:12], modified)
+            release = '%s.%s%s' % (version, head[0:12], modified)
     last_dot = release.rfind('.')
     if last_dot == -1:
         ctx.fatal('invalid VERSION file')




More information about the vc mailing list