Browse Source

refactoring for tools done

avkonst 11 years ago
parent
commit
7ede095db6

+ 1 - 1
mainline/ext/std/tools/export.ini

@@ -24,4 +24,4 @@ module:  export
 class:   Plugin
 class:   Plugin
 depends: mpp.dbf
 depends: mpp.dbf
 actions: export
 actions: export
-enabled: False
+enabled: True

+ 19 - 48
mainline/ext/std/tools/export.py

@@ -18,61 +18,32 @@
 #
 #
 
 
 
 
-
-import logging
-import csv
-
 import mpp.api
 import mpp.api
-import mpp.log
-import mpp.dbf
-import mpp.cmdparser
-
 import mpp.utils
 import mpp.utils
 
 
-class Tool(mpp.api.ITool):
-    def run(self, tool_args):
-        return main(tool_args)
+import csv
 
 
-def main(tool_args):
+class Plugin(mpp.api.Plugin, mpp.api.IConfigurable, mpp.api.IRunable):
     
     
-    log_plugin = mpp.log.Plugin()
-    db_plugin = mpp.dbf.Plugin()
-
-    parser = mpp.cmdparser.MultiOptionParser(usage="Usage: %prog export [options] -- [path 1] ... [path N]")
-    log_plugin.declare_configuration(parser)
-    db_plugin.declare_configuration(parser)
-    parser.add_option("--format", "--ft", default='csv', choices=['csv', 'xml'], help="Format of the output data. "
-                      "Possible values are 'xml' and 'csv' [default: %default]")
-
-    (options, args) = parser.parse_args(tool_args)
-    log_plugin.configure(options)
-    db_plugin.configure(options)
-    out_format = options.__dict__['format']
-
-    log_plugin.initialize()
-    db_plugin.initialize()
-
-    loader_prev = db_plugin.get_loader_prev()
-    loader = db_plugin.get_loader()
+    def declare_configuration(self, parser):
+        parser.add_option("--format", "--ft", default='csv', choices=['csv', 'xml'], help="Format of the output data. "
+                          "Possible values are 'xml' and 'csv' [default: %default]")
     
     
-    # Check for versions consistency
-    for each in loader.iterate_properties():
-        if db_plugin.dbfile_prev != None:
-            prev = loader_prev.get_property(each.name)
-            if prev != each.value:
-                logging.warn("Previous data has got different metadata:")
-                logging.warn(" - identification of change trends can be not reliable")
-                logging.warn(" - use 'info' tool to get more details")
-                break
+    def configure(self, options):
+        self.out_format = options.__dict__['format']
+
+    def run(self, args):
+        loader_prev = self.get_plugin_loader().get_plugin('mpp.dbf').get_loader_prev()
+        loader = self.get_plugin_loader().get_plugin('mpp.dbf').get_loader()
     
     
-    paths = None
-    if len(args) == 0:
-        paths = [""]
-    else:
-        paths = args
-        
-    exit_code = export_to_stdout(out_format, paths, loader, loader_prev)
-    return exit_code
+        paths = None
+        if len(args) == 0:
+            paths = [""]
+        else:
+            paths = args
+            
+        exit_code = export_to_stdout(self.out_format, paths, loader, loader_prev)
+        return exit_code
 
 
 def export_to_stdout(out_format, paths, loader, loader_prev):
 def export_to_stdout(out_format, paths, loader, loader_prev):
     class StdoutWriter(object):
     class StdoutWriter(object):

+ 11 - 36
mainline/metrixpp.py

@@ -26,24 +26,12 @@ import subprocess
 import itertools
 import itertools
 
 
 import mpp.log
 import mpp.log
+import mpp.internal.loader
 
 
 def main():
 def main():
     
     
     os.environ['METRIXPLUSPLUS_INSTALL_DIR'] = os.path.dirname(os.path.abspath(__file__))
     os.environ['METRIXPLUSPLUS_INSTALL_DIR'] = os.path.dirname(os.path.abspath(__file__))
     
     
-    this_file = os.path.basename(sys.argv[0])
-    
-    available_tools = []
-    excluded_tools = ['utils']
-    internal_tools = ['debug', 'test', 'export']
-    for fname in os.listdir(os.path.join(os.environ['METRIXPLUSPLUS_INSTALL_DIR'], 'tools')):
-        tool_name = os.path.splitext(fname)[0]
-        if tool_name == '__init__':
-            continue
-        if tool_name not in available_tools:
-            if tool_name not in excluded_tools + internal_tools:
-                available_tools.append(tool_name)
-    
     exemode = None
     exemode = None
     if len(sys.argv[1:]) != 0:
     if len(sys.argv[1:]) != 0:
         exemode = sys.argv[1]
         exemode = sys.argv[1]
@@ -55,30 +43,17 @@ def main():
     command = ""
     command = ""
     if len(sys.argv[1:]) > 1:
     if len(sys.argv[1:]) > 1:
         command = sys.argv[2]
         command = sys.argv[2]
-        
-    if command == '--help' or command == '-h' or command == '--h':
-        print "Usage: python {prog} <action> --help".format(prog=this_file)
-        print "   or: python {prog} <action> [options] -- [path 1] ... [path N]".format(prog=this_file)
-        print "where: actions are:"
-        for each in sorted(available_tools):
-            print "\t" + each
-        if exemode == '-D':
-            for each in sorted(internal_tools):
-                print "\t" + each + "\t[internal]"
-        exit(0)
-        
-    if command not in available_tools + internal_tools:
-        print >> sys.stderr, "Usage: python {prog} --help\n".format(prog=this_file)
-        print >> sys.stderr, "{prog}: error: no such action: {action}".format(prog=this_file, action=command)
-        exit(1)
-
-    tool = __import__('tools', globals(), locals(), [command], -1)
-    module_attr = tool.__getattribute__(command)
-    class_attr = module_attr.__getattribute__('Tool')
-    instance = class_attr.__new__(class_attr)
-    instance.__init__()
-    return instance.run(sys.argv[3:])
 
 
+    loader = mpp.internal.loader.Loader()
+    mpp_paths = []
+    # TODO document this feature
+    if 'METRIXPLUSPLUS_PATH' in os.environ.keys():
+        mpp_paths = os.environ['METRIXPLUSPLUS_PATH'].split(os.pathsep)
+    args = loader.load(command, mpp_paths, sys.argv[3:])
+    exit_code = loader.run(args)
+    loader.unload()
+    return exit_code
+    
 def start():
 def start():
     ts = time.time()
     ts = time.time()
     mpp.log.set_default_format()
     mpp.log.set_default_format()

+ 11 - 5
mainline/mpp/dbf.py

@@ -25,13 +25,19 @@ import logging
 class Plugin(mpp.api.Plugin, mpp.api.IConfigurable):
 class Plugin(mpp.api.Plugin, mpp.api.IConfigurable):
     
     
     def declare_configuration(self, parser):
     def declare_configuration(self, parser):
+        if self.get_plugin_loader().get_action() == 'collect':
+            dbfile_help = "Path to a database file to create and write [default: %default]."
+            dbfile_prev_help = ("Path to database file with data collected for the past/previous code revision."
+                             " If it is set, the tool will do an incremental/iterative collection."
+                             " It may reduce the time of processing significantly [default: %default].")
+        else:
+            dbfile_help = "Path to a database file to read and process [default: %default]."
+            dbfile_prev_help = ("Path to database file with data collected for the past/previous code revision."
+                                " It is used to identify and evaluate/analyze change trends. [default: %default].")
         parser.add_option("--db-file", "--dbf", default='./metrixpp.db',
         parser.add_option("--db-file", "--dbf", default='./metrixpp.db',
-                         help="Primary database file to write (by the collector) and post-process (by other tools) [default: %default]")
+                         help=dbfile_help)
         parser.add_option("--db-file-prev", "--dbfp", default=None,
         parser.add_option("--db-file-prev", "--dbfp", default=None,
-                         help="Database file with data collected for the past/previous revision."
-                             " If it is set for the collector tool to perform an incremental/iterative collection,"
-                             " it may reduce the processing time significantly."
-                             " Post-processing tools use it in order to recognise/evaluate change trends. [default: %default].")
+                         help=dbfile_prev_help)
         self.parser = parser
         self.parser = parser
     
     
     def configure(self, options):
     def configure(self, options):

+ 16 - 4
mainline/mpp/internal/loader.py

@@ -134,13 +134,25 @@ class Loader(object):
             self.plugins.append(item)
             self.plugins.append(item)
             self.hash[plugin_name] = item
             self.hash[plugin_name] = item
 
 
-        optparser =mpp.cmdparser.MultiOptionParser(
-            usage="Usage: %prog {command} [options] -- [path 1] ... [path N]".format(command=command))
-
+        optparser = mpp.cmdparser.MultiOptionParser(
+            usage = "Usage: python %prog --help\n" +
+                    "       python %prog <action> --help\n" +
+                    "       python %prog <action> [options] -- [path 1] ... [path N]\n" +
+                    "\n" +
+                    "Actions: \n  " + "\n  ".join(inicontainer.actions))
+        if command in ['--help', '--h', '-h']:
+            optparser.print_help()
+            exit(0)
+        if command.strip() == "":
+            optparser.error("Mandatory action argument required")
         if command not in inicontainer.actions:
         if command not in inicontainer.actions:
-            optparser.error("Unknown action: {action}".format(action={command}))
+            optparser.error("Unknown action: {action}".format(action=command))
+
         self.action = command
         self.action = command
 
 
+        optparser =mpp.cmdparser.MultiOptionParser(
+            usage="Usage: %prog {command} [options] -- [path 1] ... [path N]".format(command=command))
+
         for item in self.iterate_plugins():
         for item in self.iterate_plugins():
             if (isinstance(item, mpp.api.IConfigurable)):
             if (isinstance(item, mpp.api.IConfigurable)):
                 item.declare_configuration(optparser)
                 item.declare_configuration(optparser)

+ 1 - 1
mainline/tests/general/test_basic.py

@@ -138,7 +138,7 @@ class Test(tests.common.TestCase):
         runner = tests.common.ToolRunner('--help')
         runner = tests.common.ToolRunner('--help')
         self.assertExec(runner.run())
         self.assertExec(runner.run())
 
 
-        runner = tests.common.ToolRunner('unknown', exit_code=1)
+        runner = tests.common.ToolRunner('unknown', exit_code=2)
         self.assertExec(runner.run())
         self.assertExec(runner.run())
 
 
         runner = tests.common.ToolRunner('collect', ['--help'])
         runner = tests.common.ToolRunner('collect', ['--help'])

+ 15 - 10
mainline/tests/general/test_basic/test_help_--help_default_stdout.gold.txt

@@ -1,10 +1,15 @@
-Usage: python metrix++.py <action> --help
-   or: python metrix++.py <action> [options] -- [path 1] ... [path N]
-where: actions are:
-	collect
-	info
-	limit
-	view
-	debug	[internal]
-	export	[internal]
-	test	[internal]
+Usage: python metrix++.py --help
+       python metrix++.py <action> --help
+       python metrix++.py <action> [options] -- [path 1] ... [path N]
+
+Actions: 
+  collect
+  debug
+  export
+  info
+  limit
+  test
+  view
+
+Options:
+  -h, --help  show this help message and exit

+ 7 - 8
mainline/tests/general/test_basic/test_help_collect_default_stdout.gold.txt

@@ -3,15 +3,14 @@ Usage: metrix++.py collect [options] -- [path 1] ... [path N]
 Options:
 Options:
   -h, --help            show this help message and exit
   -h, --help            show this help message and exit
   --db-file=DB_FILE, --dbf=DB_FILE
   --db-file=DB_FILE, --dbf=DB_FILE
-                        Primary database file to write (by the collector) and
-                        post-process (by other tools) [default: ./metrixpp.db]
+                        Path to a database file to create and write [default:
+                        ./metrixpp.db].
   --db-file-prev=DB_FILE_PREV, --dbfp=DB_FILE_PREV
   --db-file-prev=DB_FILE_PREV, --dbfp=DB_FILE_PREV
-                        Database file with data collected for the
-                        past/previous revision. If it is set for the collector
-                        tool to perform an incremental/iterative collection,
-                        it may reduce the processing time significantly. Post-
-                        processing tools use it in order to recognise/evaluate
-                        change trends. [default: none].
+                        Path to database file with data collected for the
+                        past/previous code revision. If it is set, the tool
+                        will do an incremental/iterative collection. It may
+                        reduce the time of processing significantly [default:
+                        none].
   --log-level=LOG_LEVEL, --ll=LOG_LEVEL
   --log-level=LOG_LEVEL, --ll=LOG_LEVEL
                         Defines log level. Possible values are
                         Defines log level. Possible values are
                         'DEBUG','INFO','WARNING' or 'ERROR'. Default value is
                         'DEBUG','INFO','WARNING' or 'ERROR'. Default value is

+ 7 - 10
mainline/tests/general/test_basic/test_help_export_default_stdout.gold.txt

@@ -2,21 +2,18 @@ Usage: metrix++.py export [options] -- [path 1] ... [path N]
 
 
 Options:
 Options:
   -h, --help            show this help message and exit
   -h, --help            show this help message and exit
+  --db-file=DB_FILE, --dbf=DB_FILE
+                        Path to a database file to read and process [default:
+                        ./metrixpp.db].
+  --db-file-prev=DB_FILE_PREV, --dbfp=DB_FILE_PREV
+                        Path to database file with data collected for the
+                        past/previous code revision. It is used to identify
+                        and evaluate/analyze change trends. [default: none].
   --log-level=LOG_LEVEL, --ll=LOG_LEVEL
   --log-level=LOG_LEVEL, --ll=LOG_LEVEL
                         Defines log level. Possible values are
                         Defines log level. Possible values are
                         'DEBUG','INFO','WARNING' or 'ERROR'. Default value is
                         'DEBUG','INFO','WARNING' or 'ERROR'. Default value is
                         inherited from environment variable
                         inherited from environment variable
                         'METRIXPLUSPLUS_LOG_LEVEL' if set. [default: INFO]
                         'METRIXPLUSPLUS_LOG_LEVEL' if set. [default: INFO]
-  --db-file=DB_FILE, --dbf=DB_FILE
-                        Primary database file to write (by the collector) and
-                        post-process (by other tools) [default: ./metrixpp.db]
-  --db-file-prev=DB_FILE_PREV, --dbfp=DB_FILE_PREV
-                        Database file with data collected for the
-                        past/previous revision. If it is set for the collector
-                        tool to perform an incremental/iterative collection,
-                        it may reduce the processing time significantly. Post-
-                        processing tools use it in order to recognise/evaluate
-                        change trends. [default: none].
   --format=FORMAT, --ft=FORMAT
   --format=FORMAT, --ft=FORMAT
                         Format of the output data. Possible values are 'xml'
                         Format of the output data. Possible values are 'xml'
                         and 'csv' [default: csv]
                         and 'csv' [default: csv]

+ 5 - 8
mainline/tests/general/test_basic/test_help_info_default_stdout.gold.txt

@@ -3,15 +3,12 @@ Usage: metrix++.py info [options] -- [path 1] ... [path N]
 Options:
 Options:
   -h, --help            show this help message and exit
   -h, --help            show this help message and exit
   --db-file=DB_FILE, --dbf=DB_FILE
   --db-file=DB_FILE, --dbf=DB_FILE
-                        Primary database file to write (by the collector) and
-                        post-process (by other tools) [default: ./metrixpp.db]
+                        Path to a database file to read and process [default:
+                        ./metrixpp.db].
   --db-file-prev=DB_FILE_PREV, --dbfp=DB_FILE_PREV
   --db-file-prev=DB_FILE_PREV, --dbfp=DB_FILE_PREV
-                        Database file with data collected for the
-                        past/previous revision. If it is set for the collector
-                        tool to perform an incremental/iterative collection,
-                        it may reduce the processing time significantly. Post-
-                        processing tools use it in order to recognise/evaluate
-                        change trends. [default: none].
+                        Path to database file with data collected for the
+                        past/previous code revision. It is used to identify
+                        and evaluate/analyze change trends. [default: none].
   --log-level=LOG_LEVEL, --ll=LOG_LEVEL
   --log-level=LOG_LEVEL, --ll=LOG_LEVEL
                         Defines log level. Possible values are
                         Defines log level. Possible values are
                         'DEBUG','INFO','WARNING' or 'ERROR'. Default value is
                         'DEBUG','INFO','WARNING' or 'ERROR'. Default value is

+ 5 - 8
mainline/tests/general/test_basic/test_help_limit_default_stdout.gold.txt

@@ -3,15 +3,12 @@ Usage: metrix++.py limit [options] -- [path 1] ... [path N]
 Options:
 Options:
   -h, --help            show this help message and exit
   -h, --help            show this help message and exit
   --db-file=DB_FILE, --dbf=DB_FILE
   --db-file=DB_FILE, --dbf=DB_FILE
-                        Primary database file to write (by the collector) and
-                        post-process (by other tools) [default: ./metrixpp.db]
+                        Path to a database file to read and process [default:
+                        ./metrixpp.db].
   --db-file-prev=DB_FILE_PREV, --dbfp=DB_FILE_PREV
   --db-file-prev=DB_FILE_PREV, --dbfp=DB_FILE_PREV
-                        Database file with data collected for the
-                        past/previous revision. If it is set for the collector
-                        tool to perform an incremental/iterative collection,
-                        it may reduce the processing time significantly. Post-
-                        processing tools use it in order to recognise/evaluate
-                        change trends. [default: none].
+                        Path to database file with data collected for the
+                        past/previous code revision. It is used to identify
+                        and evaluate/analyze change trends. [default: none].
   --log-level=LOG_LEVEL, --ll=LOG_LEVEL
   --log-level=LOG_LEVEL, --ll=LOG_LEVEL
                         Defines log level. Possible values are
                         Defines log level. Possible values are
                         'DEBUG','INFO','WARNING' or 'ERROR'. Default value is
                         'DEBUG','INFO','WARNING' or 'ERROR'. Default value is

+ 5 - 8
mainline/tests/general/test_basic/test_help_view_default_stdout.gold.txt

@@ -3,15 +3,12 @@ Usage: metrix++.py view [options] -- [path 1] ... [path N]
 Options:
 Options:
   -h, --help            show this help message and exit
   -h, --help            show this help message and exit
   --db-file=DB_FILE, --dbf=DB_FILE
   --db-file=DB_FILE, --dbf=DB_FILE
-                        Primary database file to write (by the collector) and
-                        post-process (by other tools) [default: ./metrixpp.db]
+                        Path to a database file to read and process [default:
+                        ./metrixpp.db].
   --db-file-prev=DB_FILE_PREV, --dbfp=DB_FILE_PREV
   --db-file-prev=DB_FILE_PREV, --dbfp=DB_FILE_PREV
-                        Database file with data collected for the
-                        past/previous revision. If it is set for the collector
-                        tool to perform an incremental/iterative collection,
-                        it may reduce the processing time significantly. Post-
-                        processing tools use it in order to recognise/evaluate
-                        change trends. [default: none].
+                        Path to database file with data collected for the
+                        past/previous code revision. It is used to identify
+                        and evaluate/analyze change trends. [default: none].
   --log-level=LOG_LEVEL, --ll=LOG_LEVEL
   --log-level=LOG_LEVEL, --ll=LOG_LEVEL
                         Defines log level. Possible values are
                         Defines log level. Possible values are
                         'DEBUG','INFO','WARNING' or 'ERROR'. Default value is
                         'DEBUG','INFO','WARNING' or 'ERROR'. Default value is

+ 0 - 0
mainline/tools/__init__.py


+ 0 - 40
mainline/tools/collect.py

@@ -1,40 +0,0 @@
-#
-#    Metrix++, Copyright 2009-2013, Metrix++ Project
-#    Link: http://metrixplusplus.sourceforge.net
-#    
-#    This file is a part of Metrix++ Tool.
-#    
-#    Metrix++ is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, version 3 of the License.
-#    
-#    Metrix++ is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-#    GNU General Public License for more details.
-#    
-#    You should have received a copy of the GNU General Public License
-#    along with Metrix++.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-
-import os
-
-import mpp.internal.loader
-
-import mpp.api
-class Tool(mpp.api.ITool):
-    def run(self, tool_args):
-        return main(tool_args)
-
-def main(tool_args):
-    loader = mpp.internal.loader.Loader()
-    mpp_paths = []
-    # TODO document this feature
-    if 'METRIXPLUSPLUS_PATH' in os.environ.keys():
-        mpp_paths = os.environ['METRIXPLUSPLUS_PATH'].split(os.pathsep)
-    args = loader.load('collect', mpp_paths, tool_args)
-    exit_code = loader.run(args)
-    loader.unload()
-    return exit_code
-    

+ 0 - 39
mainline/tools/debug.py

@@ -1,39 +0,0 @@
-#
-#    Metrix++, Copyright 2009-2013, Metrix++ Project
-#    Link: http://metrixplusplus.sourceforge.net
-#    
-#    This file is a part of Metrix++ Tool.
-#    
-#    Metrix++ is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, version 3 of the License.
-#    
-#    Metrix++ is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-#    GNU General Public License for more details.
-#    
-#    You should have received a copy of the GNU General Public License
-#    along with Metrix++.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-
-import os
-
-import mpp.internal.loader
-
-import mpp.api
-class Tool(mpp.api.ITool):
-    def run(self, tool_args):
-        return main(tool_args)
-
-def main(tool_args):
-    loader = mpp.internal.loader.Loader()
-    mpp_paths = []
-    # TODO document this feature
-    if 'METRIXPLUSPLUS_PATH' in os.environ.keys():
-        mpp_paths = os.environ['METRIXPLUSPLUS_PATH'].split(os.pathsep)
-    args = loader.load('debug', mpp_paths, tool_args)
-    exit_code = loader.run(args)
-    loader.unload()
-    return exit_code

+ 0 - 125
mainline/tools/export.py

@@ -1,125 +0,0 @@
-#
-#    Metrix++, Copyright 2009-2013, Metrix++ Project
-#    Link: http://metrixplusplus.sourceforge.net
-#    
-#    This file is a part of Metrix++ Tool.
-#    
-#    Metrix++ is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, version 3 of the License.
-#    
-#    Metrix++ is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-#    GNU General Public License for more details.
-#    
-#    You should have received a copy of the GNU General Public License
-#    along with Metrix++.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-
-
-import logging
-import csv
-
-import mpp.api
-import mpp.log
-import mpp.dbf
-import mpp.cmdparser
-
-import mpp.utils
-
-class Tool(mpp.api.ITool):
-    def run(self, tool_args):
-        return main(tool_args)
-
-def main(tool_args):
-    
-    log_plugin = mpp.log.Plugin()
-    db_plugin = mpp.dbf.Plugin()
-
-    parser = mpp.cmdparser.MultiOptionParser(usage="Usage: %prog export [options] -- [path 1] ... [path N]")
-    log_plugin.declare_configuration(parser)
-    db_plugin.declare_configuration(parser)
-    parser.add_option("--format", "--ft", default='csv', choices=['csv', 'xml'], help="Format of the output data. "
-                      "Possible values are 'xml' and 'csv' [default: %default]")
-
-    (options, args) = parser.parse_args(tool_args)
-    log_plugin.configure(options)
-    db_plugin.configure(options)
-    out_format = options.__dict__['format']
-
-    log_plugin.initialize()
-    db_plugin.initialize()
-
-    loader_prev = db_plugin.get_loader_prev()
-    loader = db_plugin.get_loader()
-    
-    # Check for versions consistency
-    for each in loader.iterate_properties():
-        if db_plugin.dbfile_prev != None:
-            prev = loader_prev.get_property(each.name)
-            if prev != each.value:
-                logging.warn("Previous data has got different metadata:")
-                logging.warn(" - identification of change trends can be not reliable")
-                logging.warn(" - use 'info' tool to get more details")
-                break
-    
-    paths = None
-    if len(args) == 0:
-        paths = [""]
-    else:
-        paths = args
-        
-    exit_code = export_to_stdout(out_format, paths, loader, loader_prev)
-    return exit_code
-
-def export_to_stdout(out_format, paths, loader, loader_prev):
-    class StdoutWriter(object):
-        def write(self, *args, **kwargs):
-            print args[0],
-    
-    exit_code = 0
-
-
-    columnNames = ["file", "region", ]
-    columns = []
-    for name in loader.iterate_namespace_names():
-        namespace = loader.get_namespace(name)
-        for field in namespace.iterate_field_names():
-            columns.append((name, field, namespace.are_regions_supported()))
-            columnNames.append(name + ":" + field)
-
-    writer = StdoutWriter()
-    csvWriter = csv.writer(writer)
-    csvWriter.writerow(columnNames)
-    
-    if out_format == 'xml':
-        print "<export>\n"
-    elif out_format == 'csv':
-        print "CSV"
-    else:
-        assert False, "Unknown output format " + out_format
-
-    for path in paths:
-        path = mpp.utils.preprocess_path(path)
-        
-        files = loader.iterate_file_data(path)
-        if files != None:
-            for file_data in files:
-                for reg in file_data.iterate_regions():
-                    per_reg_data = []
-                    for column in columns:
-                        per_reg_data.append(reg.get_data(column[0], column[1]))
-                    csvWriter.writerow([file_data.get_path(), reg.get_name()] + per_reg_data)
-                per_file_data = []
-                for column in columns:
-                    per_file_data.append(file_data.get_data(column[0], column[1]))
-                csvWriter.writerow([file_data.get_path(), None] + per_file_data)
-        else:
-            mpp.utils.report_bad_path(path)
-            exit_code += 1
-
-    if out_format == 'xml':
-        print "XML"
-    return 0

+ 0 - 39
mainline/tools/info.py

@@ -1,39 +0,0 @@
-#
-#    Metrix++, Copyright 2009-2013, Metrix++ Project
-#    Link: http://metrixplusplus.sourceforge.net
-#    
-#    This file is a part of Metrix++ Tool.
-#    
-#    Metrix++ is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, version 3 of the License.
-#    
-#    Metrix++ is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-#    GNU General Public License for more details.
-#    
-#    You should have received a copy of the GNU General Public License
-#    along with Metrix++.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-
-import os
-
-import mpp.internal.loader
-
-import mpp.api
-class Tool(mpp.api.ITool):
-    def run(self, tool_args):
-        return main(tool_args)
-
-def main(tool_args):
-    loader = mpp.internal.loader.Loader()
-    mpp_paths = []
-    # TODO document this feature
-    if 'METRIXPLUSPLUS_PATH' in os.environ.keys():
-        mpp_paths = os.environ['METRIXPLUSPLUS_PATH'].split(os.pathsep)
-    args = loader.load('info', mpp_paths, tool_args)
-    exit_code = loader.run(args)
-    loader.unload()
-    return exit_code

+ 0 - 38
mainline/tools/limit.py

@@ -1,38 +0,0 @@
-#
-#    Metrix++, Copyright 2009-2013, Metrix++ Project
-#    Link: http://metrixplusplus.sourceforge.net
-#    
-#    This file is a part of Metrix++ Tool.
-#    
-#    Metrix++ is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, version 3 of the License.
-#    
-#    Metrix++ is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-#    GNU General Public License for more details.
-#    
-#    You should have received a copy of the GNU General Public License
-#    along with Metrix++.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-import os
-
-import mpp.internal.loader
-
-import mpp.api
-class Tool(mpp.api.ITool):
-    def run(self, tool_args):
-        return main(tool_args)
-
-def main(tool_args):
-    loader = mpp.internal.loader.Loader()
-    mpp_paths = []
-    # TODO document this feature
-    if 'METRIXPLUSPLUS_PATH' in os.environ.keys():
-        mpp_paths = os.environ['METRIXPLUSPLUS_PATH'].split(os.pathsep)
-    args = loader.load('limit', mpp_paths, tool_args)
-    exit_code = loader.run(args)
-    loader.unload()
-    return exit_code

+ 0 - 39
mainline/tools/test.py

@@ -1,39 +0,0 @@
-#
-#    Metrix++, Copyright 2009-2013, Metrix++ Project
-#    Link: http://metrixplusplus.sourceforge.net
-#    
-#    This file is a part of Metrix++ Tool.
-#    
-#    Metrix++ is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, version 3 of the License.
-#    
-#    Metrix++ is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-#    GNU General Public License for more details.
-#    
-#    You should have received a copy of the GNU General Public License
-#    along with Metrix++.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-
-import os
-
-import mpp.internal.loader
-
-import mpp.api
-class Tool(mpp.api.ITool):
-    def run(self, tool_args):
-        return main(tool_args)
-
-def main(tool_args):
-    loader = mpp.internal.loader.Loader()
-    mpp_paths = []
-    # TODO document this feature
-    if 'METRIXPLUSPLUS_PATH' in os.environ.keys():
-        mpp_paths = os.environ['METRIXPLUSPLUS_PATH'].split(os.pathsep)
-    args = loader.load('test', mpp_paths, tool_args)
-    exit_code = loader.run(args)
-    loader.unload()
-    return exit_code

+ 0 - 39
mainline/tools/view.py

@@ -1,39 +0,0 @@
-#
-#    Metrix++, Copyright 2009-2013, Metrix++ Project
-#    Link: http://metrixplusplus.sourceforge.net
-#    
-#    This file is a part of Metrix++ Tool.
-#    
-#    Metrix++ is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, version 3 of the License.
-#    
-#    Metrix++ is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-#    GNU General Public License for more details.
-#    
-#    You should have received a copy of the GNU General Public License
-#    along with Metrix++.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-
-import os
-
-import mpp.internal.loader
-
-import mpp.api
-class Tool(mpp.api.ITool):
-    def run(self, tool_args):
-        return main(tool_args)
-
-def main(tool_args):
-    loader = mpp.internal.loader.Loader()
-    mpp_paths = []
-    # TODO document this feature
-    if 'METRIXPLUSPLUS_PATH' in os.environ.keys():
-        mpp_paths = os.environ['METRIXPLUSPLUS_PATH'].split(os.pathsep)
-    args = loader.load('view', mpp_paths, tool_args)
-    exit_code = loader.run(args)
-    loader.unload()
-    return exit_code