from __future__ import absolute_import
# Standard modules
-import sys
import os
import logging
import logging.config
import re
-import traceback
import textwrap
import copy
-import shutil
import shlex
-import stat
# Third party modules
import six
-import ldap3
-
-from ldap3 import ObjectDef, AttrDef, Reader, Writer
-from ldap3 import BASE, LEVEL, SUBTREE
-
-from ldap3.core.exceptions import LDAPKeyError
+from ldap3 import ObjectDef
+from ldap3 import BASE, LEVEL, SUBTREE # noqa
# Own modules
-from .global_version import __version__ as __global_version__
-
-from .errors import FunctionNotImplementedError, PpAppError
-
-from .common import pp, terminal_can_colors, to_bytes, to_bool
-
-from .merge import merge_structure
+from .common import pp
from .ldap_app import PpLdapAppError, PpLdapApplication
from .mailaddress import MailAddress
-__version__ = '0.4.2'
+__version__ = '0.4.3'
LOG = logging.getLogger(__name__)
super(PpBarracudaSyncApp, self).perform_config()
- aliases_files = None
virtaliases_files = None
for section_name in self.cfg.keys():
if self.verbose > 2:
LOG.debug("Checking config section {!r} ...".format(section_name))
- if section_name.lower() not in ('barracuda-sync', 'barracuda_sync', 'barracudasync') :
+ if section_name.lower() not in ('barracuda-sync', 'barracuda_sync', 'barracudasync'):
continue
section = self.cfg[section_name]
self._init_postfix_dir(section['postfix_dir'])
if 'virtaliases_files' in section:
- v = section['virtaliases_files']
- files = shlex.split(v)
- if files:
- if virtaliases_files is None:
- virtaliases_files = []
- for f in files:
- if f not in virtaliases_files:
- virtaliases_files.append(f)
+ virtaliases_files = self._cfg_virtaliases_files(
+ section['virtaliases_files'], virtaliases_files)
if 'ignore_aliases' in section:
- v = section['ignore_aliases']
- aliases = shlex.split(v)
- if aliases:
- for alias in aliases:
- if alias.startswith('-'):
- alias = alias[1:]
- if alias == '':
- continue
- if alias in self.ignore_aliases:
- self.ignore_aliases.remove(alias)
- elif alias not in self.ignore_aliases:
- self.ignore_aliases.append(alias)
-
+ self._cfg_ignore_aliases(section['ignore_aliases'])
if 'base_dn' in section:
v = section['base_dn'].strip()
self._init_virtaliases_files(virtaliases_files)
+ # -------------------------------------------------------------------------
+ def _cfg_virtaliases_files(self, value, virtaliases_files):
+
+ ret = None
+ if virtaliases_files is not None:
+ ret = copy.copy(virtaliases_files)
+
+ files = shlex.split(value)
+ if files:
+ if ret is None:
+ ret = []
+ for f in files:
+ if f not in ret:
+ ret.append(f)
+
+ return ret
+
+ # -------------------------------------------------------------------------
+ def _cfg_ignore_aliases(self, value):
+
+ aliases = shlex.split(value)
+ if aliases:
+ for alias in aliases:
+ if alias.startswith('-'):
+ alias = alias[1:]
+ if alias == '':
+ continue
+ if alias in self.ignore_aliases:
+ self.ignore_aliases.remove(alias)
+ elif alias not in self.ignore_aliases:
+ self.ignore_aliases.append(alias)
+
# -------------------------------------------------------------------------
def _init_virtaliases_files(self, virtaliases_files):