from __future__ import absolute_import
# Standard modules
-import sys
import os
import logging
import logging.config
import re
-import traceback
-import textwrap
-import datetime
import copy
import json
import socket
from subprocess import Popen, PIPE
-from email import encoders
from email.mime.text import MIMEText
from email import charset
from configparser import Error as ConfigParseError
-import argparse
-
# Own modules
from .global_version import __version__ as __global_version__
-from .errors import FunctionNotImplementedError, PpAppError
+from .errors import PpAppError
-from .common import pp, terminal_can_colors, to_bytes, to_bool
+from .common import pp, to_bool
from .merge import merge_structure
from .app import PpApplication
-__version__ = '0.6.1'
+__version__ = '0.6.2'
LOG = logging.getLogger(__name__)
VALID_MAIL_METHODS = ('smtp', 'sendmail')
s = str(stem).strip()
if not s:
msg = "Invalid configuration stem {!r} given.".format(stem)
- raise PbCfgAppError(msg)
+ raise PpCfgAppError(msg)
self.cfg_stems.append(s)
else:
s = str(cfg_stems).strip()
if not s:
msg = "Invalid configuration stem {!r} given.".format(cfg_stems)
- raise PbCfgAppError(msg)
+ raise PpCfgAppError(msg)
self.cfg_stems.append(s)
else:
self.cfg_stems = self.appname
mail_group.add_argument(
'--mail-method',
metavar="METHOD", choices=VALID_MAIL_METHODS, dest="mail_method",
- help=("Method for sending the mails generated by this script. "
+ help=(
+ "Method for sending the mails generated by this script. "
"Valid values: {v}, default: {d!r}.".format(
v=', '.join(map(lambda x: repr(x), VALID_MAIL_METHODS)),
d=self.mail_method))
mail_group.add_argument(
'--mail-server',
metavar="SERVER", dest="mail_server",
- help=("Mail server for submitting generated by this script if "
- "the mail method of this script is 'smtp'. Default: {!r}.".format(
- self.mail_server))
+ help=(
+ "Mail server for submitting generated by this script if "
+ "the mail method of this script is 'smtp'. Default: {!r}.").format(
+ self.mail_server)
)
mail_group.add_argument(
'--smtp-port',
metavar="PORT", type=int, dest='smtp_port',
- help=("The port to use for submitting generated by this script if "
+ help=(
+ "The port to use for submitting generated by this script if "
"the mail method of this script is 'smtp'. Default: {}.".format(self.smtp_port))
)
cfgfile_group.add_argument(
"--cfg-encoding",
metavar="ENCODING", dest="cfg_encoding", default=self.cfg_encoding,
- help=("The encoding character set of the configuration files "
+ help=(
+ "The encoding character set of the configuration files "
"(default: %(default)r)."),
)
# add a configfile given on command line with --cfg-file
cmdline_cfg = getattr(self.args, 'cfg_file', None)
if cmdline_cfg:
- for usercfg_fn in cmdline_cfg:
+ for usercfg_fn in cmdline_cfg:
self.cfg_files.append(usercfg_fn)
# -------------------------------------------------------------------------
open_opts['encoding'] = self.cfg_encoding
open_opts['errors'] = 'surrogateescape'
- found_cfg_files = False
for cfg_file in self.cfg_files:
if self.verbose > 2:
LOG.debug("Searching for {!r} ...".format(cfg_file))
continue
if self.verbose > 1:
LOG.debug("Reading {!r} ...".format(cfg_file))
- found_cfg_files = True
config = configparser.ConfigParser()
try:
cfg = {}
for section in config.sections():
- if not section in cfg:
+ if section not in cfg:
cfg[section] = {}
for (key, value) in config.items(section):
k = key.lower()
port = self.smtp_port
try:
port = int(v)
- except (ValueError, TypeError) as e:
+ except (ValueError, TypeError):
msg = "Found invalid SMTP port number {!r} in configuration.".format(v)
LOG.error(msg)
else: