source: CMIP6dreq/manage/step1.py @ 449

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreq/manage/step1.py@449
Revision 449, 2.4 KB checked in by mjuckes, 5 years ago (diff)

add dreqML project

Line 
1""" Tag generation script.
2--------------------------
3
4USAGE
5-----
6
7python step1.py "<comment on version>"  ## updates versionConfig.py and creates "step2.sh"
8           Uses version specified in trunk
9bash step2.sh    ## checks trunk into repository, creates tagged version
10"""
11
12import sys, os, glob, string, time
13if os.path.isfile( 'step2.sh' ):
14  os.unlink( 'step2.sh' )
15
16d1 = os.getcwd()
17print d1
18sys.path.append('../trunk/dreqPy' )
19##os.chdir( '../trunk/dreqPy' )
20##print os.getcwd()
21##time.sleep(1)
22##import packageConfig
23import __init__
24version = __init__.__version__
25##os.chdir( d1 )
26
27svnBaseUrl = 'http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreq'
28
29ii = string.join( open( 'versionConfig.tmpl' ).readlines() )
30tags = glob.glob( '../tags/*' )
31
32##f1 = lambda x: map( int, string.split(x, '.' ) )
33def f1( vs ):
34  if vs == 'latest':
35    return (0,0)
36  bits = string.split(vs, '.' )
37  estr = 'Version string should be "nn.nn" or "nn.[alpha|beta].nn": %s' % vs
38  assert len(bits) in [2,3], estr
39  if len( bits ) == 3:
40    assert bits[1] in ['alpha','beta'], estr
41  assert len(bits[0]) == 2 and len(bits[-1]) == 2, estr
42  bits[0] = int( bits[0] )
43  bits[-1] = int( bits[-1] )
44  return bits
45
46def tcmp(t1,t2):
47  if len(t1) != len(t2):
48    if t1[0] == t2[0]:
49      return cmp( len(t1), len(t2) )
50    else:
51      return cmp( t1[0], t2[0] )
52  elif len(t1) == 2:
53    if t1[0] == t2[0]:
54      return cmp( t1[1], t2[1] )
55    else:
56      return cmp( t1[0], t2[0] )
57  elif len(t1) == 3:
58    if t1[0] == t2[0]:
59      if t1[1] == t2[1]:
60        return cmp( t1[2], t2[2] )
61      else:
62        return cmp( t1[1], t2[1] )
63    else:
64      return cmp( t1[0], t2[0] )
65   
66##thistag, thiscomment = sys.argv[1:]
67thiscomment = sys.argv[1]
68thistag = version
69thistn = tuple( f1( version ) )
70if len(tags) > 0:
71  tn = map( lambda x: tuple( f1(string.split(x,'/')[-1]) ),  tags )
72  tn.sort(tcmp)
73  assert thistn > tn[-1], 'Requested tag not greater than last tag: %s' % str(tn[-1])
74
75oo = open( '../trunk/dreqPy/versionConfig.py', 'w' )
76for l in string.split( ii % (thistag, thiscomment), '\n' ):
77  oo.write( '%s\n' % string.strip(l) )
78oo.close()
79
80bashtmpl = """
81tag=%(thistag)s
82comment='"%(thiscomment)s"'
83
84echo $tag, $comment
85cd ../trunk
86svn ci -m "Updated setup for tag %(thistag)s"
87svn copy %(svnBaseUrl)s/trunk %(svnBaseUrl)s/tags/%(thistag)s -m "%(thiscomment)s"
88"""
89
90oo = open( 'step2.sh', 'w' )
91oo.write( bashtmpl % locals() )
92oo.close()
Note: See TracBrowser for help on using the repository browser.