# | limitations under the License.

import sys
from datasetListFromX import addDatasetListOptions, discoverDataset
from gcSupport import Options, scriptOptions, utils

parser = Options(usage = '%s [OPTIONS] <config file / work directory>')
parser.addText(None, 'J', 'job-selector', dest = 'external job selector', default = '',
	help = 'Specify which jobs to process')
parser.addText(None, 'i', 'info-scanner',
	help = 'Specify which info scanner to run')
parser.addText(None, 'm', 'event-mode',   dest = 'mode',                  default = 'CMSSW-Out',
	help = 'Specify how to determine events - available: [CMSSW-Out], CMSSW-In, DataMod')
parser.addText(None, 'l', 'lfn',          dest = 'lfn marker',            default = '/store/',
	help = 'Assume everything starting with marker to be a logical file name')
parser.addBool(None, 'c', 'config',       dest = 'include config infos',  default = False,
	help = 'CMSSW specific: Add configuration data to metadata')
parser.addBool(None, 'p', 'parents',      dest = 'include parent infos',  default = False,
	help = 'CMSSW specific: Add parent infos to metadata')
addDatasetListOptions(parser)
options = scriptOptions(parser, arg_keys = ['dataset'])

# Positional parameters override options
if len(options.args) == 0:
	utils.exitWithUsage(parser.usage())
tmp = {'cmssw-out': 'CMSSW_EVENTS_WRITE', 'cmssw-in': 'CMSSW_EVENTS_READ', 'datamod': 'MAX_EVENTS'}
if options.opts.info_scanner:
	options.config_dict['scanner'] = options.opts.info_scanner.replace(',', ' ')
options.config_dict['events key'] = tmp.get(options.config_dict['mode'].lower(), '')
sys.exit(discoverDataset('GCProvider', options.config_dict))
#-#  You may obtain a copy of the License at
#-#
#-#      http://www.apache.org/licenses/LICENSE-2.0
#-#
#-#  Unless required by applicable law or agreed to in writing, software
#-#  distributed under the License is distributed on an "AS IS" BASIS,
#-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#-#  See the License for the specific language governing permissions and
#-#  limitations under the License.

import gcSupport, sys, optparse, datasetListFromX

parser = optparse.OptionParser('%prog [options] <data path> <dataset name> <pattern (*.root) / files>')
parser.add_option('-p', '--path', dest='path', default='.', help='Path to dataset files')
datasetListFromX.addOptions(parser)
(opts, args) = gcSupport.parseOptions(parser)

# Positional parameters override options
if len(args) > 0:
	opts.path = args[0]
if len(args) > 1:
	setattr(opts, 'dataset name pattern', args[1])
if len(args) > 2:
	setattr(opts, 'filename filter', str.join(' ', args[2:]))
def conditionalSet(name, source, sourceKey):
	if not getattr(opts, name) and getattr(opts, source):
		setattr(opts, name, sourceKey)
conditionalSet('dataset name pattern', 'delimeter dataset key', '/PRIVATE/@DELIMETER_DS@')
conditionalSet('block name pattern', 'delimeter block key', '@DELIMETER_B@')
datasetListFromX.discoverDataset(opts, parser, 'ScanProvider', opts.path)
# | Unless required by applicable law or agreed to in writing, software
# | distributed under the License is distributed on an "AS IS" BASIS,
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# | See the License for the specific language governing permissions and
# | limitations under the License.

import sys
from datasetListFromX import addDatasetListOptions, discoverDataset
from gcSupport import Options, scriptOptions, utils

parser = Options(usage = '%s [OPTIONS] <config file / work directory>')
parser.addText(None, 'J', 'job-selector', dest = 'external job selector', default = '',
	help = 'Specify which jobs to process')
parser.addText(None, 'm', 'event-mode',   dest = 'mode',                  default = 'CMSSW-Out',
	help = 'Specify how to determine events - available: [CMSSW-Out], CMSSW-In, DataMod')
parser.addText(None, 'l', 'lfn',          dest = 'lfn marker',            default = '/store/',
	help = 'Assume everything starting with marker to be a logical file name')
parser.addBool(None, 'c', 'config',       dest = 'include config infos',  default = False,
	help = 'CMSSW specific: Add configuration data to metadata')
parser.addBool(None, 'p', 'parents',      dest = 'include parent infos',  default = False,
	help = 'CMSSW specific: Add parent infos to metadata')
addDatasetListOptions(parser)
options = scriptOptions(parser, arg_keys = ['dataset'])

# Positional parameters override options
if len(options.args) == 0:
	utils.exitWithUsage(parser.usage())
tmp = {'cmssw-out': 'CMSSW_EVENTS_WRITE', 'cmssw-in': 'CMSSW_EVENTS_READ', 'datamod': 'MAX_EVENTS'}
options.config_dict['events key'] = tmp.get(options.config_dict['mode'].lower(), '')
sys.exit(discoverDataset('GCProvider', options.config_dict))
#-#
#-#  Unless required by applicable law or agreed to in writing, software
#-#  distributed under the License is distributed on an "AS IS" BASIS,
#-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#-#  See the License for the specific language governing permissions and
#-#  limitations under the License.

import os, gcSupport, sys, optparse, datasetListFromX

usage = '[options] <config file / work directory>'
parser = optparse.OptionParser(usage='%%prog %s' % usage)
parser.add_option('-J', '--job-selector', dest='external job selector', default='',
	help='Specify which jobs to process')
parser.add_option('-m', '--event-mode',   dest='mode',                  default='CMSSW-Out',
	help='Specify how to determine events - available: [CMSSW-Out], CMSSW-In, DataMod')
parser.add_option('-l', '--lfn',          dest='lfn marker',            default='/store/',
	help='Assume everything starting with marker to be a logical file name')
parser.add_option('-c', '--config',       dest='include config infos',  default='False',
	help='CMSSW specific: Add configuration data to metadata', action='store_const', const='True')
parser.add_option('-p', '--parents',      dest='include parent infos',  default='False', 
	help='CMSSW specific: Add parent infos to metadata',       action='store_const', const='True')
datasetListFromX.addOptions(parser)
(opts, args) = gcSupport.parseOptions(parser)

# Positional parameters override options
if len(args) == 0:
	gcSupport.utils.exitWithUsage('%s %s' % (sys.argv[0], usage))
tmp = {'cmssw-out': 'CMSSW_EVENTS_WRITE', 'cmssw-in': 'CMSSW_EVENTS_READ', 'datamod': 'MAX_EVENTS'}
setattr(opts, 'events key', tmp.get(opts.mode.lower(), ''))
datasetListFromX.discoverDataset(opts, parser, 'GCProvider', args[0])