[PATCH] Review and help
Tanu Hari Dixit
tokencolour at gmail.com
Mon Jun 12 02:47:10 UTC 2017
These are the changes I made to read the ini files
also, this does succeed in reading them.
But there are a lot of problems to solve.
---
rtemstoolkit/configuration.py | 11 ++++++++---
rtemstoolkit/git.py | 1 +
rtemstoolkit/macros.py | 16 +++++++++++++++-
rtemstoolkit/options.py | 1 +
tester/rt/bsps.py | 4 +++-
tester/rt/options.py | 2 +-
tester/rt/test.py | 9 ++++++---
7 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/rtemstoolkit/configuration.py b/rtemstoolkit/configuration.py
index 71ab3ca..459276e 100644
--- a/rtemstoolkit/configuration.py
+++ b/rtemstoolkit/configuration.py
@@ -41,9 +41,14 @@ try:
import configparser
except:
import ConfigParser as configparser
-
-from rtemstoolkit import error
-from rtemstoolkit import path
+
+try :
+ from . import error
+ from . import path
+except (ValueError, SystemError):
+ import error
+ import path
+
class configuration:
diff --git a/rtemstoolkit/git.py b/rtemstoolkit/git.py
index 5f3af58..4a6f2f8 100644
--- a/rtemstoolkit/git.py
+++ b/rtemstoolkit/git.py
@@ -80,6 +80,7 @@ class repo:
self.git = 'git'
else:
self.git = self.macros.expand('%{__git}')
+ #self.git = self.macros.config.get_item('global', '__git')
def git_version(self):
ec, output = self._run(['--version'], True)
diff --git a/rtemstoolkit/macros.py b/rtemstoolkit/macros.py
index 31f5a7e..4772562 100644
--- a/rtemstoolkit/macros.py
+++ b/rtemstoolkit/macros.py
@@ -48,10 +48,13 @@ try:
from . import error
from . import log
from . import path
+ from . import configuration
except (ValueError, SystemError):
import error
import log
import path
+ import configuration
+
#
# Macro tables
@@ -123,7 +126,16 @@ class macros:
self.read_map_locked = copy.copy(original.read_map_locked)
self.write_map = copy.copy(original.write_map)
if name is not None:
- self.load(name)
+ #self.load(name)
+ self.config = configuration.configuration()
+ self.config.load(name)
+ self.add_macros()
+ #self.config.load(name)
+
+ def add_macros(self):
+ for section in self.config.config.sections():
+ for label in self.config.config.options(section):
+ self.macros[section][label] = self.config.get_item(section, label)
def __copy__(self):
return macros(original = self)
@@ -474,6 +486,8 @@ class macros:
for m in self.macro_filter.findall(_str):
name = m[2:-1]
macro = self.get(name)
+ #for section in self.config.config.sections():
+ # macro = self.config.get_item(section, name)
if macro is None:
raise error.general('cannot expand default macro: %s in "%s"' %
(m, _str))
diff --git a/rtemstoolkit/options.py b/rtemstoolkit/options.py
index 70e9786..3b27a95 100644
--- a/rtemstoolkit/options.py
+++ b/rtemstoolkit/options.py
@@ -427,6 +427,7 @@ class command_line(object):
return None
um = []
configs = self.defaults.expand('%{_configdir}').split(':')
+ #configs = self.defaults.config.get_item('%{_configdir}').split(':')
for m in self.opts['macros'].split(','):
if path.exists(m):
um += [m]
diff --git a/tester/rt/bsps.py b/tester/rt/bsps.py
index 91f5f62..048d85c 100644
--- a/tester/rt/bsps.py
+++ b/tester/rt/bsps.py
@@ -33,7 +33,9 @@ from rtemstoolkit import log
from rtemstoolkit import path
def list(opts):
- path_ = opts.defaults.expand('%%{_configdir}/bsps/*.mc')
+ #path_ = opts.defaults.expand('%%{_configdir}/bsps/*.mc')
+ path_ = opts.defaults.expand('%%{_configdir}/bsps/*.ini')
+ #path_ = opts.defaults.config.get_item('%%{_configdir}/bsps/*.mc')
bsps = path.collect_files(path_)
log.notice(' BSP List:')
for bsp in bsps:
diff --git a/tester/rt/options.py b/tester/rt/options.py
index d41b721..85888d2 100644
--- a/tester/rt/options.py
+++ b/tester/rt/options.py
@@ -52,7 +52,7 @@ from rtemstoolkit import version
#
# The path for the defaults.
#
-defaults_mc = 'rtems/testing/defaults.mc'
+defaults_mc = 'rtems/testing/defaults.ini'
class command_line(options.command_line):
"""Process the command line in a common way for all Tool Builder commands."""
diff --git a/tester/rt/test.py b/tester/rt/test.py
index 7a35f59..7056667 100644
--- a/tester/rt/test.py
+++ b/tester/rt/test.py
@@ -219,7 +219,9 @@ def _job_trace(tst, msg, total, exe, active, reporting):
reporting, total, exe, s))
def list_bsps(opts):
- path_ = opts.defaults.expand('%%{_configdir}/bsps/*.mc')
+ #path_ = opts.defaults.expand('%%{_configdir}/bsps/*.mc')
+ path_ = opts.defaults.expand('%%{_configdir}/bsps/*.ini')
+ #path_ = opts.defaults.config.get_item('%%{_configdir}/bsps/*.mc')
bsps = path.collect_files(path_)
log.notice(' BSP List:')
for bsp in bsps:
@@ -277,8 +279,9 @@ def run(command_path = None):
bsp = opts.find_arg('--rtems-bsp')
if bsp is None or len(bsp) != 2:
raise error.general('RTEMS BSP not provided or invalid option')
- opts.defaults.load('%%{_configdir}/bsps/%s.mc' % (bsp[1]))
- bsp = opts.defaults.get('%{bsp}')
+ #opts.defaults.load('%%{_configdir}/bsps/%s.mc' % (bsp[1]))
+ opts.defaults.config.load(opts.defaults.expand('%%{_configdir}/bsps/%s.ini' % (bsp[1])))
+ bsp = opts.defaults.config.get_item(bsp[1], 'bsp')
if not bsp:
raise error.general('BSP definition (%{bsp}) not found in the global map')
bsp = bsp[2]
--
2.1.4
More information about the devel
mailing list