Changeset 56747 in webkit


Ignore:
Timestamp:
Mar 29, 2010 4:18:27 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-29 Chris Jerdonek <Chris Jerdonek>

Reviewed by Shinichiro Hamaji.

Eliminate explicit slash characters from check-webkit-style's
_rel_path() method to make its implementation more platform
independent.

https://bugs.webkit.org/show_bug.cgi?id=36759

  • Scripts/webkitpy/style/main.py:
    • Changed to use os.sep instead of slash_chars "/
      ". This can be done since os.path.abspath() converts slashes to os.sep.
Location:
trunk/WebKitTools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r56746 r56747  
     12010-03-29  Chris Jerdonek  <cjerdonek@webkit.org>
     2
     3        Reviewed by Shinichiro Hamaji.
     4
     5        Eliminate explicit slash characters from check-webkit-style's
     6        _rel_path() method to make its implementation more platform
     7        independent.
     8
     9        https://bugs.webkit.org/show_bug.cgi?id=36759
     10
     11        * Scripts/webkitpy/style/main.py:
     12          - Changed to use os.sep instead of slash_chars "/\\".  This can
     13            be done since os.path.abspath() converts slashes to os.sep.
     14
    1152010-03-29  Dirk Pranke  <dpranke@chromium.org>
    216
  • trunk/WebKitTools/Scripts/webkitpy/style/main.py

    r56682 r56747  
    5050        os_path_abspath = os.path.abspath
    5151
    52     # Calling os_path_abspath() also removes any trailing slashes.
     52    # Since os_path_abspath() calls os.path.normpath()--
     53    #
     54    # (see http://docs.python.org/library/os.path.html#os.path.abspath )
     55    #
     56    # it also removes trailing slashes and converts forward and backward
     57    # slashes to the preferred slash os.sep.
    5358    start_path = os_path_abspath(start_path)
    5459    path = os_path_abspath(path)
    55 
    56     slash_chars = "/\\"
    5760
    5861    if not path.lower().startswith(start_path.lower()):
     
    6265    rel_path = path[len(start_path):]
    6366
    64     if rel_path and rel_path[0] not in slash_chars:
    65         # Then we are in the case typified by the following example:
     67    if not rel_path:
     68        # Then the paths are the same.
     69        pass
     70    elif rel_path[0] == os.sep:
     71        # It is probably sufficient to remove just the first character
     72        # since os.path.normpath() collapses separators, but we use
     73        # lstrip() just to be sure.
     74        rel_path = rel_path.lstrip(os.sep)
     75    else:
     76        # We are in the case typified by the following example:
    6677        #
    6778        # start_path = "/tmp/foo"
     
    6980        # rel_path = "bar"
    7081        return None
    71     # Otherwise rel_path is "" or begins with a slash.
    72 
    73     rel_path = rel_path.lstrip(slash_chars)
    7482
    7583    return rel_path
Note: See TracChangeset for help on using the changeset viewer.