source: CMIP6dreq/manage/step1.py @ 519

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

cleaning

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