Chromium Code Reviews| Index: tools/telemetry/telemetry/core/util.py |
| diff --git a/tools/telemetry/telemetry/core/util.py b/tools/telemetry/telemetry/core/util.py |
| index 460eb61ec7fb42bd131ac891b96af6769eaaeef3..9e17d8597dbea4bf1efbca23f0303aed723e3a58 100644 |
| --- a/tools/telemetry/telemetry/core/util.py |
| +++ b/tools/telemetry/telemetry/core/util.py |
| @@ -126,6 +126,7 @@ def GetBuildDirectories(): |
| for build_type in build_types: |
| yield build_dir, build_type |
| + |
| def GetSequentialFileName(base_name): |
| """Returns the next sequential file name based on |base_name| and the |
| existing files. base_name should not contain extension. |
| @@ -142,3 +143,16 @@ def GetSequentialFileName(base_name): |
| break |
| index = index + 1 |
| return output_name |
| + |
| + |
| +def GetAbsPathIfExist(path, base_dir): |
|
dtu
2014/10/06 21:30:22
Is this the same as os.path.realpath(os.path.relpa
nednguyen
2014/10/07 20:11:09
Not really, this returns path if path is already a
dtu
2014/10/08 21:34:18
This is true of realpath(relpath()) as well, but i
|
| + """ Returns the absolute path for |path| if it exists. If |path| is relative, |
| + then it is relative to the directory of |base_dir|. """ |
| + abs_path = None |
| + if os.path.isabs(path): |
| + abs_path = path |
| + else: |
| + abs_path = os.path.join(base_dir, path) |
| + if not os.path.exists(abs_path): |
| + return None |
| + return os.path.realpath(abs_path) |