aboutsummaryrefslogtreecommitdiff
path: root/contrib/googletest/googlemock/scripts/generator/cpp/utils.py
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2019-02-13 02:46:46 +0000
committerEnji Cooper <ngie@FreeBSD.org>2019-02-13 02:46:46 +0000
commitb89a7cc2ed6e4398d5be502f5bb5885d1ec6ff0f (patch)
treef0004df881245692a8477517ef4df2d8f64d66cc /contrib/googletest/googlemock/scripts/generator/cpp/utils.py
parenta73b2e25e1e2b69fb172fbb391e5bd1c3878e881 (diff)
parent83481c8c5c0cd0b3fc86f39b2985efd4e300200a (diff)
Notes
Diffstat (limited to 'contrib/googletest/googlemock/scripts/generator/cpp/utils.py')
-rwxr-xr-xcontrib/googletest/googlemock/scripts/generator/cpp/utils.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/contrib/googletest/googlemock/scripts/generator/cpp/utils.py b/contrib/googletest/googlemock/scripts/generator/cpp/utils.py
new file mode 100755
index 000000000000..eab36eec335e
--- /dev/null
+++ b/contrib/googletest/googlemock/scripts/generator/cpp/utils.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+#
+# Copyright 2007 Neal Norwitz
+# Portions Copyright 2007 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Generic utilities for C++ parsing."""
+
+__author__ = 'nnorwitz@google.com (Neal Norwitz)'
+
+
+import sys
+
+
+# Set to True to see the start/end token indices.
+DEBUG = True
+
+
+def ReadFile(filename, print_error=True):
+ """Returns the contents of a file."""
+ try:
+ fp = open(filename)
+ try:
+ return fp.read()
+ finally:
+ fp.close()
+ except IOError:
+ if print_error:
+ print('Error reading %s: %s' % (filename, sys.exc_info()[1]))
+ return None