6 Author : Valentin Kuznetsov <vkuznet@gmail.com> 7 Description: CMS-related utils 15 from FWCore.Skeletons.utils
import code_generator
17 def config(tmpl, pkg_help, tmpl_dir):
18 "Parse input arguments to mk-script" 19 kwds = {
'author':
'',
'tmpl': tmpl,
20 'args': {},
'debug':
False,
'tmpl_dir': tmpl_dir}
22 if len(sys.argv) >= 2:
23 if sys.argv[1]
in [
'-h',
'--help',
'-help']:
26 kwds[
'pname'] = sys.argv[1]
27 for idx
in xrange(2, len(sys.argv)):
30 kwds[
'author'] = sys.argv[idx+1]
32 if opt.find(
'example') != -1:
33 etags.append(
'@%s' % opt)
35 if opt
in [
'-h',
'--help',
'-help']:
41 elif len(sys.argv) == 1:
43 msg =
'Please enter %s name: ' % tmpl.lower()
44 kwds[
'pname'] = raw_input(msg)
48 kwds[
'tmpl_etags'] = etags
52 "Standard CMS error message" 53 msg =
"\nPackages must be created in a 'subsystem'." 54 msg +=
"\nPlease set your CMSSW environment and go to $CMSSW_BASE/src" 55 msg +=
"\nCreate or choose directory from there and then " 56 msg +=
"\nrun the script from that directory" 61 Test CMS environment and requirements to run within CMSSW_BASE. 62 Return True if we fullfill requirements and False otherwise. 64 base = os.environ.get(
'CMSSW_BASE',
None)
68 ldir = cdir.replace(os.path.join(base,
'src'),
'')
69 dirs = ldir.split(
'/')
71 if ldir
and ldir[0] ==
'/' and len(dirs) == 2:
72 return 'subsystem', ldir
74 if ldir
and ldir[0] ==
'/' and len(dirs) == 3:
75 return 'package', ldir
83 if ldir
and ldir[0] ==
'/' and len(dirs) == 4:
88 "Run generator code based on provided set of arguments" 90 tmpl = kwds.get(
'tmpl')
91 stand_alone_group = [
'Record',
'Skeleton']
92 config.update({
'not_in_dir': stand_alone_group})
93 if tmpl
in stand_alone_group:
95 dirs = ldir.split(
'/')
96 config.update({
'pkgname': kwds.get(
'pname')})
97 config.update({
'subsystem':
'Subsystem'})
98 config.update({
'pkgname':
'Package'})
101 config.update({
'subsystem': dirs[1]})
102 config.update({
'pkgname': dirs[2]})
104 config.update({
'subsystem': dirs[1]})
105 config.update({
'pkgname': dirs[1]})
108 dirs = ldir.split(
'/')
109 if not dirs
or not whereami:
112 config.update({
'subsystem': dirs[1]})
113 config.update({
'pkgname': kwds.get(
'pname')})
114 if whereami
in [
'src',
'plugins']:
115 config.update({
'tmpl_files':
'.cc'})
116 config.update({
'pkgname': dirs[2]})
117 elif whereami ==
'subsystem':
118 config.update({
'tmpl_files':
'all'})
def test_cms_environment(tmpl)
def config(tmpl, pkg_help, tmpl_dir)