~ubuntu-branches/ubuntu/oneiric/mozc/oneiric

« back to all changes in this revision

Viewing changes to build_tools/mozc_version.py

  • Committer: Bazaar Package Importer
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2010-07-14 03:26:47 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100714032647-13qjisj6m8cm8jdx
Tags: 0.12.410.102-1
* New upstream release (Closes: #588971).
  - Add mozc-server, mozc-utils-gui and scim-mozc packages.
* Update debian/rules.
  Add --gypdir option to build_mozc.py.
* Update debian/control.
  - Bumped standards-version to 3.9.0.
  - Update description.
* Add mozc icon (Closes: #588972).
* Add patch which revises issue 18.
  ibus_mozc_issue18.patch
* kFreeBSD build support.
  support_kfreebsd.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
1
2
# Copyright 2010, Google Inc.
2
3
# All rights reserved.
3
4
#
37
38
"""
38
39
 
39
40
import datetime
 
41
import os
40
42
import re
41
43
import sys
42
44
 
43
45
 
 
46
def IsWindows():
 
47
  """Returns true if the platform is Windows."""
 
48
  return os.name == 'nt'
 
49
 
 
50
 
 
51
def IsMac():
 
52
  """Returns true if the platform is Mac."""
 
53
  return os.name == 'posix' and os.uname()[0] == 'Darwin'
 
54
 
 
55
 
 
56
def IsLinux():
 
57
  """Returns true if the platform is Linux."""
 
58
  return os.name == 'posix' and os.uname()[0] == 'Linux'
 
59
 
 
60
 
 
61
def CalculateRevisionForPlatform(revision):
 
62
  """Returns the revision for the current platform."""
 
63
  if not revision:
 
64
    return revision
 
65
  if IsWindows():
 
66
    last_digit = '0'
 
67
  elif IsMac():
 
68
    last_digit = '1'
 
69
  elif IsLinux():
 
70
    last_digit = '2'
 
71
  if last_digit:
 
72
    return revision[0:-1] + last_digit
 
73
 
 
74
  # If not supported, just use the specified version.
 
75
  return revision
 
76
 
 
77
 
44
78
class MozcVersion(object):
45
79
  """A class to parse the version definition file and maintain the
46
80
  version data.
67
101
    self._major = self._dict['MAJOR']
68
102
    self._minor = self._dict['MINOR']
69
103
    self._build = self._dict['BUILD']
70
 
    self._revision = self._dict['REVISION']
 
104
    self._revision = CalculateRevisionForPlatform(self._dict['REVISION'])
71
105
    if expand_daily and self._build == 'daily':
72
106
      zero_day = datetime.date(2009, 5, 24)
73
107
      self._build = str(
74
108
          datetime.date.today().toordinal() - zero_day.toordinal())
75
109
 
 
110
  def IsDevChannel(self):
 
111
    """Returns true if the parsed version is dev-channel."""
 
112
    if len(self._revision) >= 3 and self._revision[-3] == '1':
 
113
      return True
 
114
 
 
115
    return False
76
116
 
77
117
  def GetVersionString(self):
78
118
    """Returns the normal version info string.