summaryrefslogtreecommitdiffstats
path: root/tools/findit/common/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/findit/common/utils.py')
-rw-r--r--tools/findit/common/utils.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/findit/common/utils.py b/tools/findit/common/utils.py
new file mode 100644
index 0000000..363048c
--- /dev/null
+++ b/tools/findit/common/utils.py
@@ -0,0 +1,31 @@
+# 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
+
+from http_client_local import HttpClientLocal
+
+
+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))
+
+
+def GetHttpClient():
+ # TODO(stgao): return implementation for appengine when running on appengine.
+ return HttpClientLocal