author Monica Chew <mmc@mozilla.com>
Thu, 07 Mar 2013 08:35:38 -0500
changeset 124107 99ef1303095d41f4bb647fcb0e318cef22d42d3b
parent 121817 d01bf199fcbacb932347767aa3023d73759020a1
permissions -rw-r--r--
Bug 844392 - Fix race condition where ProcessStateChange can remove a file before cleanup. r=paolo

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from __future__ import unicode_literals

import os

def parse_test_path(test_path, topsrcdir):
    """Returns a dict containing:
    * 'normalized': the normalized path, relative to the topsrcdir
    * 'isdir': whether the path points to a directory
    is_dir = os.path.isdir(test_path)

    normalized = os.path.normpath(test_path)
    topsrcdir = os.path.normpath(topsrcdir)

    if normalized.startswith(topsrcdir):
        normalized = normalized[len(topsrcdir):]

    return {
        'normalized': normalized,
        'is_dir': is_dir,