--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+@author: Frank Brehm
+@contact: frank.brehm@profitbricks.com
+@organization: Profitbricks GmbH
+@copyright: © 2010 - 2015 by Profitbricks GmbH
+@license: GPL3
+@summary: crc64 script for generating crc64digests of given parameters
+"""
+
+# Standard modules
+import sys
+import os
+import logging
+
+from distutils.version import LooseVersion
+
+# own modules:
+from pb_base.app import PbApplicationError
+from pb_base.app import PbApplication
+
+__version__ = LooseVersion('0.1.0')
+
+appname = os.path.basename(sys.argv[0])
+log = logging.getLogger(appname)
+cur_dir = os.getcwd()
+base_dir = cur_dir
+
+DEFAULT_PORTAGE_DIR = os.sep + os.path.join('etc', 'portage')
+
+# =============================================================================
+class CleanupPkgKeywordsApp(PbApplication):
+ """
+ Application class for the 'cleanup-pkg-keywords' application.
+ """
+
+ # -------------------------------------------------------------------------
+ def __init__(
+ self, verbose=0, version=__version__, *arg, **kwargs):
+ """
+ Initialisation of the cleanup-pkg-keywords application object.
+ """
+
+ indent = ' ' * self.usage_term_len
+
+ usage = "%%(prog)s [%s] [--simulate] [-R ROOT_DIR]" % ('General options')
+ usage += '\n'
+ usage += indent + "%(prog)s -h|--help\n"
+ usage += indent + "%(prog)s -V|--version"
+
+ desc = ("Cleanup all package.accept_keywords and package.keywords files under %r "
+ "in comparision to the current installed packages.") % (DEFAULT_PORTAGE_DIR)
+
+ self.simulate = False
+ self.root_dir = None
+
+ super(CleanupPkgKeywordsApp, self).__init__(
+ usage=usage,
+ description=desc,
+ verbose=verbose,
+ version=version,
+ *arg, **kwargs
+ )
+
+ self.post_init()
+ self.initialized = True
+
+ # -------------------------------------------------------------------------
+ def init_arg_parser(self):
+ """
+ Method to initiate the argument parser.
+ """
+
+ super(CleanupPkgKeywordsApp, self).init_arg_parser()
+
+ self.arg_parser.add_argument(
+ '-S', '--simulate',
+ action='store_true',
+ dest='simulate',
+ help='Simulate cleanup.',
+ )
+
+ self.arg_parser.add_argument(
+ '-R', '--root-dir',
+ dest='root_dir',
+ metavar='DIR',
+ help="Root directory (instead of /).",
+ )
+
+ # -------------------------------------------------------------------------
+ def perform_arg_parser(self):
+ """
+ Execute some actions after parsing the command line parameters.
+ """
+
+ super(CleanupPkgKeywordsApp, self).perform_arg_parser()
+
+ self.simulate = self.args.simulate
+ if self.args.root_dir:
+ if self.args.root_dir != os.sep:
+ self.root_dir = self.args.root_dir
+ if not os.path.exists(self.root_dir):
+ msg = "Root-Directory %r does not exists." % (self.root_dir)
+ sys.stderr.write(msg + '\n')
+ sys.exit(1)
+ if not os.path.isdir(self.root_dir):
+ msg = "Root-Directory %r is not a directory." % (self.root_dir)
+ sys.stderr.write(msg + '\n')
+ sys.exit(1)
+
+ # -------------------------------------------------------------------------
+ def _run(self):
+ """The underlaying startpoint of the application."""
+
+ log.info("Jetzt geht's loooos ...")
+
+# =============================================================================
+
+if __name__ == "__main__":
+ app = CleanupPkgKeywordsApp()
+ if app.verbose > 2:
+ print("CleanupPkgKeywordsApp object:\n%s" % (app))
+ app()
+ sys.exit(0)
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4