~ceilometer-drivers/ceilometer/trunk

« back to all changes in this revision

Viewing changes to ceilometer/openstack/common/setup.py

  • Committer: Angus Salkeld
  • Date: 2012-11-03 00:31:11 UTC
  • Revision ID: git-v1:4c43441d9dafedbc1b73cf8abdec32b1ccb65a71
Update common (except policy)

Change-Id: I17a89a15ff3af5b9f31bf14b1bbe29b024cfc8c1

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
def parse_mailmap(mailmap='.mailmap'):
32
32
    mapping = {}
33
33
    if os.path.exists(mailmap):
34
 
        fp = open(mailmap, 'r')
35
 
        for l in fp:
36
 
            l = l.strip()
37
 
            if not l.startswith('#') and ' ' in l:
38
 
                canonical_email, alias = [x for x in l.split(' ')
39
 
                                          if x.startswith('<')]
40
 
                mapping[alias] = canonical_email
 
34
        with open(mailmap, 'r') as fp:
 
35
            for l in fp:
 
36
                l = l.strip()
 
37
                if not l.startswith('#') and ' ' in l:
 
38
                    canonical_email, alias = [x for x in l.split(' ')
 
39
                                              if x.startswith('<')]
 
40
                    mapping[alias] = canonical_email
41
41
    return mapping
42
42
 
43
43
 
54
54
def get_reqs_from_files(requirements_files):
55
55
    for requirements_file in requirements_files:
56
56
        if os.path.exists(requirements_file):
57
 
            return open(requirements_file, 'r').read().split('\n')
 
57
            with open(requirements_file, 'r') as fil:
 
58
                return fil.read().split('\n')
58
59
    return []
59
60
 
60
61
 
135
136
    _run_shell_command("git fetch origin +refs/meta/*:refs/remotes/meta/*")
136
137
    milestone_cmd = "git show meta/openstack/release:%s" % branch_name
137
138
    milestonever = _run_shell_command(milestone_cmd)
138
 
    if not milestonever:
139
 
        milestonever = ""
 
139
    if milestonever:
 
140
        first_half = "%s~%s" % (milestonever, datestamp)
 
141
    else:
 
142
        first_half = datestamp
 
143
 
140
144
    post_version = _get_git_post_version()
141
145
    # post version should look like:
142
146
    # 0.1.1.4.gcc9e28a
143
147
    # where the bit after the last . is the short sha, and the bit between
144
148
    # the last and second to last is the revno count
145
149
    (revno, sha) = post_version.split(".")[-2:]
146
 
    first_half = "%s~%s" % (milestonever, datestamp)
147
150
    second_half = "%s%s.%s" % (revno_prefix, revno, sha)
148
151
    return ".".join((first_half, second_half))
149
152
 
236
239
 
237
240
def write_versioninfo(project, version):
238
241
    """Write a simple file containing the version of the package."""
239
 
    open(os.path.join(project, 'versioninfo'), 'w').write("%s\n" % version)
 
242
    with open(os.path.join(project, 'versioninfo'), 'w') as fil:
 
243
        fil.write("%s\n" % version)
240
244
 
241
245
 
242
246
def get_cmdclass():