#!/bin/env python3
# -*- coding: utf-8 -*-
-__version__ = '1.1.2'
+__version__ = '1.2.1'
# vim: ts=4 et list
self._cachefile = self.default_cachefile_stem
self._mail_subject = None
self._mail_headline = None
+ self._sort_by_name = False
if not hasattr(self, '_output_type'):
self._output_type = self.default_output_type
def read_stdin(self, value):
self._read_stdin = to_bool(value)
+ # -----------------------------------------------------------
+ @property
+ def sort_by_name(self):
+ """Sorting all lists of modules by name and vendor, instead of the full name."""
+ return self._sort_by_name
+
# -----------------------------------------------------------
@property
def html_title(self):
res['main_branches'] = copy.copy(self.main_branches)
res['mail_subject'] = self.mail_subject
res['mail_headline'] = self.mail_headline
+ res['sort_by_name'] = self.sort_by_name
return res
help="Data directory, default: {!r}.".format(self.data_dir),
)
+ sort_group = general_group.add_mutually_exclusive_group()
+
+ sort_group.add_argument(
+ '-o', '--sort-by-name', action="store_true", dest='sort_by_name',
+ help="Sorting all lists of modules by name and vendor, in this order."
+ )
+
+ sort_group.add_argument(
+ '-O', '--sort-by-fullname', action="store_false", dest='sort_by_name',
+ help="Sorting all lists of modules by the full name of the module (default)."
+ )
+
general_group.add_argument(
"-v", "--verbose", action="count", dest='verbose',
help='Increase the verbosity level',
sys.stderr.write("\nSimulation mode - nothing is really done.\n\n")
self.simulate = True
+ if self.cmdline_args.sort_by_name:
+ self._sort_by_name = True
+
self._get_query()
if 'output_type' in self.query:
try:
"Cache file {!r} not readable.".format(self.cachefile))
modules = ModuleInfoDict(
- appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
+ appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
+ sort_by_name=self.sort_by_name)
LOG.debug("Reading {!r} ...".format(self.cachefile))
try:
appname=appname, verbose=verbose, version=version)
self.modules = ModuleInfoDict(
- appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
+ appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
+ sort_by_name=self.sort_by_name)
# -----------------------------------------------------------
@property
def collect_local_modules(self):
self.modules = ModuleInfoDict(
- appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
+ appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
+ sort_by_name=self.sort_by_name)
for env in self.environments:
LOG.debug("Evaluating environment {!r} ..".format(env))
# Own modules
from .obj import BaseObject
+from .common import to_bool
from .module_info import ModuleInfo
-__version__ = '1.0.0'
+__version__ = '1.1.0'
LOG = logging.getLogger(__name__)
# -------------------------------------------------------------------------
# __init__() method required to create instance from class.
def __init__(
- self, appname=None, verbose=0, version=__version__, base_dir=None, *args, **kwargs):
+ self, appname=None, verbose=0, version=__version__, base_dir=None,
+ sort_by_name=False, *args, **kwargs):
self._map = dict()
+ self._sort_by_name = False
super(ModuleInfoDict, self).__init__(
appname=appname, verbose=verbose, version=version,
base_dir=base_dir, initialized=False,
)
+ self.sort_by_name = sort_by_name
+
for arg in args:
self.append(arg)
+ # -----------------------------------------------------------
+ @property
+ def sort_by_name(self):
+ """Sorting modules by name and vendor, instead of the full name."""
+ return self._sort_by_name
+
+ @sort_by_name.setter
+ def sort_by_name(self, value):
+ self._sort_by_name = to_bool(value)
+
# -------------------------------------------------------------------------
def _set_item(self, key, module_info):
res = super(ModuleInfoDict, self).as_dict(short=short)
+ res['sort_by_name'] = self.sort_by_name
res['items'] = {}
res['keys'] = []
for full_name in self.keys():
def keys(self):
def compare_items(x, y):
+ if self.sort_by_name:
+ if self.verbose > 4:
+ LOG.debug("Comparing names {!r} > {!r}".format(x.name, y.name))
+ if x.name != y.name:
+ if x.name > y.name:
+ return 1
+ return -1
+ if self.verbose > 4:
+ LOG.debug("Comparing vendor {!r} > {!r}".format(x.vendor, y.vendor))
+ if x.vendor != y.vendor:
+ if x.vendor > y.vendor:
+ return 1
+ return -1
+ return 0
if self.verbose > 4:
- LOG.debug("Comparing names {!r} > {!r}".format(x.name, y.name))
- if x.name != y.name:
- if x.name > y.name:
- return 1
- return -1
- if self.verbose > 4:
- LOG.debug("Comparing vendor {!r} > {!r}".format(x.vendor, y.vendor))
- if x.vendor != y.vendor:
- if x.vendor > y.vendor:
+ LOG.debug("Comparing full names {!r} > {!r}".format(x.full_name, y.full_name))
+ if x.full_name != y.full_name:
+ if x.full_name > y.full_name:
return 1
return -1
return 0