summaryrefslogtreecommitdiffstats
path: root/tools/findit/utils.py
blob: 4e8a0ab947c28e74887dca6732af763f4f0eb59b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import re
import sys


GIT_HASH_PATTERN = re.compile(r'^[0-9a-fA-F]{40}$')


def GetOSName(platform_name=sys.platform):
  if platform_name == 'cygwin' or platform_name.startswith('win'):
    return 'win'
  elif platform_name.startswith('linux'):
    return 'unix'
  elif platform_name.startswith('darwin'):
    return 'mac'
  else:
    return platform_name


def IsGitHash(revision):
  return GIT_HASH_PATTERN.match(str(revision))