from pathlib import Path
# Third party modules
-from fb_tools.common import pp
from fb_tools.argparse_actions import DirectoryOptionAction
+from fb_tools.common import pp
from fb_tools.handler import BaseHandler
from fb_tools.multi_config import DEFAULT_ENCODING
from fb_tools.xlate import format_list
from .ldap import BaseLdapApplication
from ..xlate import XLATOR
-__version__ = '0.7.1'
+__version__ = '0.7.2'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
self.exit(6)
if self.verbose > 1:
- LOG.debug(_("Candidate for lookup table type: {!r}.").format(self.postfix_db_hashtype))
+ LOG.debug(_('Candidate for lookup table type: {!r}.').format(self.postfix_db_hashtype))
if self.postfix_db_hashtype not in self.usable_postfix_hashtypes:
msg = _(
LOG.debug(_('Collecting all available virtual aliases table files ...'))
va_files = []
- basenames = ['virtual', 'virtual-alias', 'virtual-aliases',
- 'virtualalias', 'virtualaliases']
+ basenames = [
+ 'virtual', 'virtual-alias', 'virtual-aliases',
+ 'virtualalias', 'virtualaliases']
if self.args.basename:
for basename in self.args.basename:
for va_file in self.default_virtaliases_files:
if va_file.exists() and va_file.is_file():
if self.verbose > 1:
- LOG.debug(_("Using virtual aliases file: {!r}").format(str(va_file)))
+ LOG.debug(_('Using virtual aliases file: {!r}').format(str(va_file)))
va_files.append(va_file)
for maps_dir in (self.postfix_config_dir, self.postfix_maps_dir):
if not maps_dir.exists():
- LOG.debug(_("Directory {!r} does not exists.").format(str(maps_dir)))
+ LOG.debug(_('Directory {!r} does not exists.').format(str(maps_dir)))
continue
if not maps_dir.is_dir():
- LOG.debug(_("Path {!r} exists, but is not a directory.").format(str(maps_dir)))
+ LOG.debug(_('Path {!r} exists, but is not a directory.').format(str(maps_dir)))
continue
for basename in basenames:
va_file = va_file.resolve()
if va_file not in va_files:
if self.verbose > 1:
- LOG.debug(_("Using virtual aliases file: {!r}").format(str(va_file)))
+ LOG.debug(_('Using virtual aliases file: {!r}').format(str(va_file)))
va_files.append(va_file)
if not len(va_files):
- LOG.error(_("Did not found any virtual aliases files."))
+ LOG.error(_('Did not found any virtual aliases files.'))
self.exit(6)
- LOG.debug(_("Found virtual aliases files:") + '\n' + pp(
+ LOG.debug(_('Found virtual aliases files:') + '\n' + pp(
list(map(lambda x: str(x), va_files))))
self.virtaliases_files = va_files
db_extension = self.postfix_filetype_extensions[self.postfix_db_hashtype]
if self.verbose > 1:
- LOG.debug(_("Using file extension for db-files: {!r}.").format(db_extension))
+ LOG.debug(_('Using file extension for db-files: {!r}.').format(db_extension))
for va_file in self.virtaliases_files:
db_file = va_file.parent / (va_file.name + db_extension)
if not db_file.exists() or not db_file.is_file():
LOG.error(_(
- "DB file for virtual aliases {!r} does not exists or is not a regular "
- "file.").format(str(db_file)))
+ 'DB file for virtual aliases {!r} does not exists or is not a regular '
+ 'file.').format(str(db_file)))
self.virtaliases_files.remove(va_file)
continue
mtime_db_file = db_file.stat().st_mtime
mtime_va_file = va_file.stat().st_mtime
if mtime_db_file < mtime_va_file:
LOG.warn(_(
- "The last modification time of {db!r} is older than this "
- "of {va!r}.").format(db=str(db_file), va=str(va_file)))
+ 'The last modification time of {db!r} is older than this '
+ 'of {va!r}.').format(db=str(db_file), va=str(va_file)))
elif self.verbose > 1:
LOG.debug(_(
- "The last modification time of {db!r} and {va!r} are "
- "okay.").format(db=str(db_file), va=str(va_file)))
+ 'The last modification time of {db!r} and {va!r} are '
+ 'okay.').format(db=str(db_file), va=str(va_file)))
# -------------------------------------------------------------------------
def read_local_virtual_aliases(self):
- """Reading virtual alias files."""
- LOG.info(_("Reading in virtual alias files ..."))
+ """Read virtual alias files."""
+ LOG.info(_('Reading in virtual alias files ...'))
self.existing_aliases = []
# -------------------------------------------------------------------------
def read_virtual_alias_file(self, va_file):
- """Reading virtual aliases from given file."""
- LOG.info(_("Reading in from virtual alias file {!r} ...").format(str(va_file)))
+ """Read virtual aliases from given file."""
+ LOG.info(_('Reading in from virtual alias file {!r} ...').format(str(va_file)))
handler = BaseHandler(appname=self.appname, verbose=self.verbose)
pdata = handler.call([str(self.postmap_command), '-s', str(va_file)], quiet=True)