def main():
"""
Main program
"""
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - \
%(levelname)s - %(funcName)s [%(lineno)d] - \
\t%(message)s",
)
LOGGER = logging.getLogger(__name__)
# ArgumentParser to parse arguments and options
PARSER = get_parser()
ARGS = PARSER.parse_args()
# Assign global variables
try:
# Set log level
LOGGER.setLevel(getattr(logging, ARGS.loglevel.upper(), None))
MARKDOWN_FILE = ARGS.markdownFile
SPACE_KEY = ARGS.spacekey
USERNAME = os.getenv("CONFLUENCE_USERNAME", ARGS.username)
API_KEY = os.getenv("CONFLUENCE_API_KEY", ARGS.apikey)
ORGNAME = os.getenv("CONFLUENCE_ORGNAME", ARGS.orgname)
ANCESTOR = ARGS.ancestor
NOSSL = ARGS.nossl
DELETE = ARGS.delete
SIMULATE = ARGS.simulate
VERSION = ARGS.version
MARKDOWN_SOURCE = ARGS.markdownsrc
LABELS = ARGS.labels
PROPERTIES = dict(ARGS.properties)
ATTACHMENTS = ARGS.attachment
CONTENTS = ARGS.contents
TITLE = ARGS.title
REMOVE_EMOJIES = ARGS.remove_emojies
validate_args(USERNAME, API_KEY, MARKDOWN_FILE, ORGNAME)
except Exception as err:
LOGGER.error("\n\nException caught:\n%s ", err)
LOGGER.error("\nFailed to process command line arguments. Exiting.")
sys.exit(1)
LOGGER.info("\t----------------------------------")
LOGGER.info("\tMarkdown to Confluence Upload Tool")
LOGGER.info("\t----------------------------------")
LOGGER.info("Markdown file:\t%s", MARKDOWN_FILE)
LOGGER.info("Space Key:\t%s", SPACE_KEY)
confluence_converter: ConfluenceConverter = ConfluenceConverter(
MARKDOWN_FILE,
MARKDOWN_SOURCE,
TITLE,
ORGNAME,
not NOSSL,
USERNAME,
SPACE_KEY,
API_KEY,
ANCESTOR,
VERSION,
)
confluence_converter.convert(
SIMULATE, DELETE, REMOVE_EMOJIES, CONTENTS, LABELS, PROPERTIES, ATTACHMENTS
)