from functools import cmp_to_key
# Own modules
-from .common import pp, compare_fqdn
+from .common import pp, compare_fqdn, to_str
+from .common import RE_DOT_AT_END
from .pdns_app import PpPDNSAppError, PpPDNSApplication
from .pdns_zone import PdnsApiZone
-__version__ = '0.1.0'
+__version__ = '0.2.0'
LOG = logging.getLogger(__name__)
# -------------------------------------------------------------------------
def __init__(self, appname=None, version=__version__):
- self.zone = None
+ self.zones = []
description = textwrap.dedent('''\
Lists all available zones from given PowerDNS API.
self.initialized = True
+ # -------------------------------------------------------------------------
+ def init_arg_parser(self):
+ """
+ Method to initiate the argument parser.
+
+ This method should be explicitely called by all init_arg_parser()
+ methods in descendant classes.
+ """
+
+ super(PpPDNSShowZoneApp, self).init_arg_parser()
+
+ self.arg_parser.add_argument(
+ 'zones', metavar='ZONE', nargs='+',
+ help="All zones, for which the complete information should shown",
+ )
+
+ # -------------------------------------------------------------------------
+ def perform_arg_parser(self):
+ """
+ Public available method to execute some actions after parsing
+ the command line parameters.
+ """
+
+ super(PpPDNSShowZoneApp, self).perform_arg_parser()
+
+ for zone in self.args.zones:
+ zone_idna = zone
+ if 'xn--' not in zone:
+ zone_idna = to_str(zone.encode('idna'))
+ zone_idna = RE_DOT_AT_END.sub('.', zone_idna)
+ self.zones.append(zone_idna)
+
# -------------------------------------------------------------------------
def _run(self):
- LOG.info("Show all information about zone {!r} from PowerDNS environment {!r}.".format(
- self.zone, self.environment))
+ for zone in self.zones:
+
+ zone_unicode = zone
+ zout = "{!r}".format(zone)
+ if 'xn--' in zone:
+ zone_unicode = zone.encode('idna').decode('idna')
+ zout = "{!r} ({})".format(zone, zone_unicode)
+
+ LOG.info("Show all information about zone {} from PowerDNS environment {!r}.".format(
+ zout, self.environment))