diff --git a/README.md b/README.md index aa7463b..8e29b5d 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,11 @@ XML Menu Diff Compare the content of two XML trigger menus. - $ tm-diff [-f|--format ] [-s|--skip ] [--sort ] - [-d|--dump] [-o ] - +```bash +tm-diff [-f|--format ] [-s|--skip ] [--sort ] + [-d|--dump] [-o ] + +``` ### Format @@ -23,7 +25,9 @@ Default format is `unified`. **Example:** - $ tm-diff ... -fhtml -o diff.html # dumps diff as HTML table to file +```bash +tm-diff ... -fhtml -o diff.html # dumps diff as HTML table to file +``` ### Skip @@ -34,7 +38,9 @@ Use flag `-s|--skip ` to ignore certain attributes. Options are **Example:** - $ tm-diff ... -smodule -scomment # ignores module_is/index and any comments +```bash +tm-diff ... -smodule -scomment # ignores module_is/index and any comments +``` ### Sort @@ -53,7 +59,9 @@ option will create two text files with the menu names at the current working loc **Example:** - $ tm-diff foo.xml bar.xml -d # dumps raw text to foo.xml.txt bar.xml.txt +```bash +tm-diff foo.xml bar.xml -d # dumps raw text to foo.xml.txt bar.xml.txt +``` ### Output @@ -61,25 +69,36 @@ Use flag `-o ` to write the output to a file. **Example:** - $ tm-diff foo.xml bar.xml -o diff.txt # write output to file +```bash +tm-diff foo.xml bar.xml -o diff.txt # write output to file +``` This is equivalent to: - $ tm-diff foo.xml bar.xml > diff.txt # pipe stdout to file - +```bash +tm-diff foo.xml bar.xml > diff.txt # pipe stdout to file +``` ## Dependencies - * `tmTable` +Install following l1t-utm wheel or build l1t-utm python bindings. + + * `tmTable>=0.7.3` + -**Note:** make sure to set `UTM_ROOT` before executing. +## Install +Install using pip -## Setup +```bash +pip install https://github.com/cms-l1-globaltrigger/tm-diff/archive/master.zip#egg=tm-diff-0.6.0 +``` - $ . /path/to/utm-0.6.x/setup.sh # source UTM environment +Install from local source - $ git clone https://gitlab.cern.ch/.../tm-diff.git - $ cd tm-diff - $ . setup.sh - $ +```bash +git clone https://gitlab.cern.ch/cms-l1-globaltrigger/tm-diff.git +cd tm-diff +python setup.py test +python setup.py install +``` diff --git a/requirements.txt b/requirements.txt index e69de29..d6e107e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1 @@ +#tmTable>=0.7.3 diff --git a/setup.py b/setup.py index b0d01f1..10fbdc6 100644 --- a/setup.py +++ b/setup.py @@ -1,18 +1,25 @@ -from distutils.core import setup -from tmDiff import __version__ as version +from setuptools import setup long_description = open('README.md').read() setup( name="tm-diff", - version=version, + version='0.6.0', url="https://github.com/cms-l1-globaltrigger/tm-diff", author="Bernhard Arnold", author_email="bernhard.arnold@cern.ch", description="Compare the content of two XML trigger menus.", long_description=long_description, - packages=["tmDiff"], - scripts=["scripts/tm-diff"], + packages=['tmDiff'], + install_requires=[ + #'tmTable>=0.7.3', + ], + entry_points={ + 'console_scripts': [ + 'tm-diff = tmDiff.main:main', + ], + }, + test_suite='tests', license="GPLv3", keywords="", platforms="any", diff --git a/setup.sh b/setup.sh deleted file mode 100644 index b8408e9..0000000 --- a/setup.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Setup for local environment - -PWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -export PYTHONPATH=$PWD:$PYTHONPATH -export PATH=$PWD/scripts:$PATH - - diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tmDiff/__init__.py b/tmDiff/__init__.py index 7568cb9..ef7eb44 100644 --- a/tmDiff/__init__.py +++ b/tmDiff/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - -__version__ = '0.5.0' +__version__ = '0.6.0' diff --git a/scripts/tm-diff b/tmDiff/main.py similarity index 96% rename from scripts/tm-diff rename to tmDiff/main.py index e7a8b24..172b5bf 100755 --- a/scripts/tm-diff +++ b/tmDiff/main.py @@ -3,8 +3,8 @@ import argparse import sys, os -from tmDiff import menudiff -from tmDiff import __version__ +from . import menudiff +from . import __version__ FMT_UNIFIED = 'unified' FMT_CONTEXT = 'context' @@ -112,11 +112,11 @@ def main(): DIFF_FUNCTIONS[args.format]( fromfile=from_menu, tofile=to_menu, - verbose=args.verbose > 0, + verbose=args.verbose, ostream=args.ostream ) - sys.exit() + return 0 if __name__ == '__main__': - main() + sys.exit(main()) diff --git a/tmDiff/menudiff.py b/tmDiff/menudiff.py index 7493c88..8b09f17 100644 --- a/tmDiff/menudiff.py +++ b/tmDiff/menudiff.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python -# # Diff for XML menus # # The algorithm specific content is extracted into a simple text representation