MCPcopy Index your code
hub / github.com/cpplint/cpplint / RepositoryName

Method RepositoryName

cpplint.py:1716–1779  ·  view source on GitHub ↗

r"""FullName after removing the local path to the repository. If we have a real absolute path name here we can try to do something smart: detecting the root of the checkout and truncating /path/to/checkout from the name so that we get header guards that don't include things

(self)

Source from the content-addressed store, hash-verified

1714 return os.path.abspath(self._filename).replace("\\", "/")
1715
1716 def RepositoryName(self):
1717 r"""FullName after removing the local path to the repository.
1718
1719 If we have a real absolute path name here we can try to do something smart:
1720 detecting the root of the checkout and truncating /path/to/checkout from
1721 the name so that we get header guards that don't include things like
1722 "C:\\Documents and Settings\\..." or "/home/username/..." in them and thus
1723 people on different computers who have checked the source out to different
1724 locations won't see bogus errors.
1725 """
1726 fullname = self.FullName()
1727
1728 if os.path.exists(fullname):
1729 project_dir = os.path.dirname(fullname)
1730
1731 # If the user specified a repository path, it exists, and the file is
1732 # contained in it, use the specified repository path
1733 if _repository:
1734 repo = FileInfo(_repository).FullName()
1735 root_dir = project_dir
1736 while os.path.exists(root_dir):
1737 # allow case insensitive compare on Windows
1738 if os.path.normcase(root_dir) == os.path.normcase(repo):
1739 return os.path.relpath(fullname, root_dir).replace("\\", "/")
1740 one_up_dir = os.path.dirname(root_dir)
1741 if one_up_dir == root_dir:
1742 break
1743 root_dir = one_up_dir
1744
1745 if os.path.exists(os.path.join(project_dir, ".svn")):
1746 # If there's a .svn file in the current directory, we recursively look
1747 # up the directory tree for the top of the SVN checkout
1748 root_dir = project_dir
1749 one_up_dir = os.path.dirname(root_dir)
1750 while os.path.exists(os.path.join(one_up_dir, ".svn")):
1751 root_dir = os.path.dirname(root_dir)
1752 one_up_dir = os.path.dirname(one_up_dir)
1753
1754 prefix = os.path.commonprefix([root_dir, project_dir])
1755 return fullname[len(prefix) + 1 :]
1756
1757 # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by
1758 # searching up from the current path.
1759 root_dir = current_dir = os.path.dirname(fullname)
1760 while current_dir != os.path.dirname(current_dir):
1761 if (
1762 os.path.exists(os.path.join(current_dir, ".git"))
1763 or os.path.exists(os.path.join(current_dir, ".hg"))
1764 or os.path.exists(os.path.join(current_dir, ".svn"))
1765 ):
1766 root_dir = current_dir
1767 break
1768 current_dir = os.path.dirname(current_dir)
1769
1770 if (
1771 os.path.exists(os.path.join(root_dir, ".git"))
1772 or os.path.exists(os.path.join(root_dir, ".hg"))
1773 or os.path.exists(os.path.join(root_dir, ".svn"))

Callers 7

SplitMethod · 0.95
CheckHeaderFileIncludedFunction · 0.95
CheckIncludeLineFunction · 0.95
FixupPathFromRootFunction · 0.80
_ClassifyIncludeFunction · 0.80

Calls 2

FullNameMethod · 0.95
FileInfoClass · 0.85

Tested by 1