utils.py revision 03b57e008b61dfcb1fbad3aea950ae0e001748b0
1# Copyright (c) 2011 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import re
6import sys
7
8from http_client_local import HttpClientLocal
9
10
11GIT_HASH_PATTERN = re.compile(r'^[0-9a-fA-F]{40}$')
12
13
14def GetOSName(platform_name=sys.platform):
15  if platform_name == 'cygwin' or platform_name.startswith('win'):
16    return 'win'
17  elif platform_name.startswith('linux'):
18    return 'unix'
19  elif platform_name.startswith('darwin'):
20    return 'mac'
21  else:
22    return platform_name
23
24
25def IsGitHash(revision):
26  return GIT_HASH_PATTERN.match(str(revision))
27
28
29def GetHttpClient():
30  # TODO(stgao): return implementation for appengine when running on appengine.
31  return HttpClientLocal
32