def getOptions(kinds, step=steps.ALL): """ Constructs the parser needed for cppstats. Includes following procedure: * addition of step-specific arguments * parsing * addition of constants * checking of constraints :arg kinds : the list of preperation/analysis kinds, dependent on the step parameter :arg step : the variant of cppstats to execute: one of cli.steps (ALL, PREPARATION, ANALYSIS) :rtype : the resulting options """ parser = ArgumentParser(formatter_class=RawTextHelpFormatter) # version (uses CppstatsVersionAction instead of 'version' as action) parser.add_argument('--version', action=CppstatsVersionAction, version=cstats.version()) # ADD KIND ARGUMENT # kinds kindgroup = parser.add_mutually_exclusive_group(required=False) kindgroup.add_argument("--kind", choices=kinds.keys(), dest="kind", default=kinds.keys()[0], metavar="<K>", help="the preparation to be performed [default: %(default)s]") kindgroup.add_argument("-a", "--all", action="store_true", dest="allkinds", default=False, help="perform all available kinds of preparation/analysis [default: %(default)s]") # ADD INPUT TYPE (list or file) # input 1 inputgroup = parser.add_mutually_exclusive_group(required=False) # TODO check if True is possible some time... inputgroup.add_argument("--list", type=str, dest="inputlist", metavar="LIST", nargs="?", default=__inputlist_default, const=__inputlist_default, help="a file that contains the list of input projects/folders [default: %(default)s]") # input 2 if step == steps.ALL: inputgroup.add_argument("--file", type=str, dest="inputfile", nargs=2, metavar=("IN", "OUT"), help="a source file IN that is prepared and analyzed, the analysis results are written to OUT" "\n(--list is the default)") elif step == steps.PREPARATION: inputgroup.add_argument("--file", type=str, dest="inputfile", nargs=2, metavar=("IN", "OUT"), help="a source file IN that is prepared, the preparation result is written to OUT" "\n(--list is the default)") elif step == steps.ANALYSIS: inputgroup.add_argument("--file", type=str, dest="inputfile", nargs=2, metavar=("IN", "OUT"), help="a srcML file IN that is analyzed, the analysis results are written to OUT" "\n(--list is the default)") # ADD VARIOUS STEP-DEPENDENT ARGUMENTS # no backup files if step == steps.ALL or step == steps.PREPARATION: parser.add_argument("--nobak", action="store_true", dest="nobak", default=False, help="do not backup files during preparation [default: %(default)s]") # add general CLI options applying for all or several analyses if step == steps.ALL or step == steps.ANALYSIS: # constants for the choices of '--filenames' are added in method 'addConstants' parser.add_argument("--filenames", choices=[0, 1], dest="filenames", default=0, help="determines the file paths to print [default: %(default)s]\n" "(0=paths to srcML files, 1=paths to source files)") parser.add_argument("--filenamesRelative", action="store_true", dest="filenamesRelative", default=False, help="print relative file names [default: %(default)s]\n" "e.g., '/projects/apache/_cppstats/afile.c.xml' gets 'afile.c.xml'.") # ADD POSSIBLE PREPARATION/ANALYSIS KINDS AND THEIR COMMAND-LINE ARGUMENTS if step == steps.ALL: parser.add_argument_group("Possible Kinds of Analyses <K>".upper(), ", ".join(kinds.keys())) # add options for each analysis kind for kind in kinds.values(): analysisPart = kind[1] analysisThread = analysis.getKinds().get(analysisPart) analysisThread.addCommandLineOptions(parser) elif step == steps.PREPARATION: parser.add_argument_group("Possible Kinds of Preparation <K>".upper(), ", ".join(kinds.keys())) elif step == steps.ANALYSIS: parser.add_argument_group("Possible Kinds of Analyses <K>".upper(), ", ".join(kinds.keys())) # add options for each analysis kind for cls in kinds.values(): cls.addCommandLineOptions(parser) # PARSE OPTIONS options = parser.parse_args() # ADD CONSTANTS TO OPTIONS addConstants(options) # CHECK CONSTRAINTS ON OPTIONS checkConstraints(options) # RETURN return options
# Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this program. If not, see # <http://www.gnu.org/licenses/>. # # Contributors: # Claus Hunsen <*****@*****.**> # Andreas Ringlstetter <*****@*****.**> from setuptools import setup, find_packages import cppstats setup( name='cppstats', version=cppstats.version(), packages=find_packages(exclude=['scripts']), url='http://www.fosd.net/cppstats', license='LGPLv3', author='Claus Hunsen', author_email='*****@*****.**', description= 'toolsuite for analyzing preprocessor-based software product lines', package_data={ 'scripts': ['*.sh'], 'preparations': ['*.xsl'] }, install_requires=[ 'statlib==1.2', 'pyparsing==2.0.3', 'enum==0.4.4', 'lxml==3.4.4' ], dependency_links=[
# # You should have received a copy of the GNU Lesser General Public # License along with this program. If not, see # <http://www.gnu.org/licenses/>. # # Contributors: # Claus Hunsen <*****@*****.**> # Andreas Ringlstetter <*****@*****.**> from setuptools import setup, find_packages import cppstats setup( name='cppstats', version=cppstats.version(), packages=find_packages(exclude=['scripts']), url='http://www.fosd.net/cppstats', license='LGPLv3', author='Claus Hunsen', author_email='*****@*****.**', description='toolsuite for analyzing preprocessor-based software product lines', package_data={ 'scripts' : ['*.sh'], 'preparations' : ['*.xsl'] }, install_requires=[ 'statlib==1.2', 'pyparsing==2.0.3',