_ = XLATOR.gettext
ngettext = XLATOR.ngettext
-__version__ = '0.10.0'
+__version__ = '0.10.1'
# =============================================================================
def check_output_file(self, ofile, must_exists=False, must_absolute=False):
"""Check all nessacary thinks about an output file, before it can be used."""
if ofile is None:
- msg = _('The output file to chack must not be None.')
+ msg = _('The output file to check must not be None.')
raise TypeError(msg)
ofile = Path(ofile)
from .. import pp
from ..xlate import XLATOR
-__version__ = '0.5.1'
+__version__ = '0.6.0'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
self._base_dn = None
self.instance = None
self.connect_info = None
+ self.only_one = False
list_oc = format_list(self.group_object_classes, do_repr=True)
list_attr = format_list(self.member_attributes, do_repr=True)
return res
+ # -------------------------------------------------------------------------
+ def init_arg_parser(self):
+ """Public available method to initiate the argument parser."""
+ group_title = _('Options for {}').format(self.appname)
+ app_group = self.arg_parser.add_argument_group(group_title)
+
+ app_group.add_argument(
+ '-1', '--one', dest='only_one', action='store_true',
+ help=_('Delete only the first found empty group and exit.'),
+ )
+
+ super(CleanEmptyLdapGroupsApplication, self).init_arg_parser()
+
# -------------------------------------------------------------------------
def _verify_instances(self):
"""Execute some steps before calling run()."""
super(CleanEmptyLdapGroupsApplication, self).post_init()
+ only_one = getattr(self.args, 'only_one', False)
+ if only_one:
+ self.only_one = True
+
self.check_instances()
self.instance = self.ldap_instances[0]
msg = _('Lap {} on searching for empty groups to remove.').format(i)
LOG.info(msg)
self.remove_empty_groups()
+ if self.only_one:
+ break
# -------------------------------------------------------------------------
def get_empty_groups(self):
"""Ask for removing and remove it then."""
for dn in self.dns_todo:
self.remove_empty_group(dn)
+ if self.only_one:
+ break
# -------------------------------------------------------------------------
def remove_empty_group(self, dn):