2016-02-22 20:34:26 +00:00
|
|
|
#! /usr/bin/python
|
|
|
|
# -*- coding: utf8 -*-
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
2016-03-15 05:18:09 +00:00
|
|
|
from __future__ import unicode_literals
|
2016-02-22 20:34:26 +00:00
|
|
|
|
2016-02-25 20:28:41 +00:00
|
|
|
import logging
|
2016-02-23 21:13:52 +00:00
|
|
|
|
|
|
|
from tldp.utils import arg_isdirectory, arg_isloglevel, arg_isreadablefile
|
2016-02-22 21:04:16 +00:00
|
|
|
from tldp.cascadingconfig import CascadingConfig, DefaultFreeArgumentParser
|
2016-02-22 20:34:26 +00:00
|
|
|
|
2016-02-25 17:58:11 +00:00
|
|
|
import tldp.typeguesser
|
2016-02-22 20:34:26 +00:00
|
|
|
|
2016-03-01 04:32:36 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2016-03-10 16:50:31 +00:00
|
|
|
DEFAULT_CONFIGFILE = '/etc/ldptool/ldptool.ini'
|
2016-02-22 20:34:26 +00:00
|
|
|
|
2016-03-10 19:17:09 +00:00
|
|
|
|
2016-02-23 05:21:24 +00:00
|
|
|
def collectconfiguration(tag, argv):
|
2016-02-23 16:59:37 +00:00
|
|
|
ap = DefaultFreeArgumentParser()
|
2016-03-01 04:32:36 +00:00
|
|
|
|
2016-03-01 01:56:41 +00:00
|
|
|
g = ap.add_mutually_exclusive_group()
|
|
|
|
g.add_argument('--build',
|
2016-03-01 04:32:36 +00:00
|
|
|
'-b',
|
|
|
|
action='store_true', default=False,
|
|
|
|
help='build LDP documentation [%(default)s]')
|
2016-03-07 17:03:57 +00:00
|
|
|
g.add_argument('--publish',
|
|
|
|
'-p',
|
|
|
|
action='store_true', default=False,
|
|
|
|
help='build and publish LDP documentation [%(default)s]')
|
2016-03-01 01:56:41 +00:00
|
|
|
g.add_argument('--script',
|
2016-03-01 04:32:36 +00:00
|
|
|
'-S',
|
|
|
|
action='store_true', default=False,
|
|
|
|
help='dump runnable script [%(default)s]')
|
2016-03-01 01:56:41 +00:00
|
|
|
g.add_argument('--detail', '--list',
|
2016-03-01 04:32:36 +00:00
|
|
|
'-l',
|
|
|
|
action='store_true', default=False,
|
|
|
|
help='list elements of LDP system [%(default)s]')
|
2016-03-01 01:56:41 +00:00
|
|
|
g.add_argument('--summary',
|
2016-03-01 04:32:36 +00:00
|
|
|
'-t',
|
|
|
|
action='store_true', default=False,
|
2016-03-01 21:21:11 +00:00
|
|
|
help='dump inventory summary report [%(default)s]')
|
2016-03-07 20:10:49 +00:00
|
|
|
g.add_argument('--doctypes', '--formats', '--format',
|
2016-03-06 19:29:13 +00:00
|
|
|
'--list-doctypes', '--list-formats',
|
|
|
|
'-T',
|
|
|
|
action='store_true', default=False,
|
|
|
|
help='show supported doctypes [%(default)s]')
|
|
|
|
g.add_argument('--statustypes', '--list-statustypes',
|
|
|
|
action='store_true', default=False,
|
|
|
|
help='show status types and classes [%(default)s]')
|
2016-03-01 04:32:36 +00:00
|
|
|
|
2016-02-23 16:59:37 +00:00
|
|
|
ap.add_argument('--verbose',
|
|
|
|
action='store_true', default=False,
|
2016-03-01 21:21:11 +00:00
|
|
|
help='more info in --list/--detail [%(default)s]')
|
2016-02-23 16:59:37 +00:00
|
|
|
ap.add_argument('--loglevel',
|
2016-02-23 19:04:43 +00:00
|
|
|
default=logging.ERROR, type=arg_isloglevel,
|
2016-02-23 16:59:37 +00:00
|
|
|
help='set the loglevel')
|
2016-02-25 20:28:41 +00:00
|
|
|
ap.add_argument('--skip',
|
2016-02-26 08:30:05 +00:00
|
|
|
default=[], action='append', type=str,
|
2016-02-25 20:28:41 +00:00
|
|
|
help='skip this stem during processing')
|
2016-03-07 17:39:34 +00:00
|
|
|
ap.add_argument('--resources',
|
|
|
|
default=['images', 'resources'], action='append', type=str,
|
|
|
|
help='subdirs to copy during build [%(default)s]')
|
2016-02-23 16:59:37 +00:00
|
|
|
ap.add_argument('--sourcedir', '--source-dir', '--source-directory',
|
|
|
|
'-s',
|
2016-02-23 19:04:43 +00:00
|
|
|
action='append', default='', type=arg_isdirectory,
|
2016-02-23 16:59:37 +00:00
|
|
|
help='a directory containing LDP source documents')
|
|
|
|
ap.add_argument('--pubdir', '--output', '--outputdir', '--outdir',
|
|
|
|
'-o',
|
2016-02-23 19:04:43 +00:00
|
|
|
default=None, type=arg_isdirectory,
|
2016-02-23 16:59:37 +00:00
|
|
|
help='a directory containing LDP output documents')
|
2016-03-07 16:06:17 +00:00
|
|
|
ap.add_argument('--builddir', '--build-dir', '--build-directory',
|
|
|
|
'-d',
|
|
|
|
default=None, type=arg_isdirectory,
|
|
|
|
help='a scratch directory used for building')
|
2016-02-23 16:59:37 +00:00
|
|
|
ap.add_argument('--configfile', '--config-file', '--cfg',
|
|
|
|
'-c',
|
2016-03-10 16:50:31 +00:00
|
|
|
default=DEFAULT_CONFIGFILE,
|
2016-03-01 17:04:45 +00:00
|
|
|
type=arg_isreadablefile,
|
2016-02-23 16:59:37 +00:00
|
|
|
help='a configuration file')
|
2016-02-22 20:34:26 +00:00
|
|
|
|
2016-02-25 17:58:11 +00:00
|
|
|
# -- collect up the distributed configuration fragments
|
2016-02-22 20:34:26 +00:00
|
|
|
#
|
2016-02-25 18:38:38 +00:00
|
|
|
for cls in tldp.typeguesser.knowndoctypes:
|
|
|
|
argparse_method = getattr(cls, 'argparse', None)
|
|
|
|
if argparse_method:
|
|
|
|
argparse_method(ap)
|
2016-02-22 20:34:26 +00:00
|
|
|
|
2016-02-23 16:59:37 +00:00
|
|
|
cc = CascadingConfig(tag, ap, argv)
|
2016-02-23 00:19:05 +00:00
|
|
|
config, args = cc.parse()
|
2016-02-23 16:59:37 +00:00
|
|
|
return config, args
|
2016-02-22 20:34:26 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# -- end of file
|