MCPcopy Create free account
hub / github.com/alibaba/GraphScope / RepositoryName

Method RepositoryName

analytical_engine/misc/cpplint.py:1568–1626  ·  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 like "C:

(self)

Source from the content-addressed store, hash-verified

1566 return os.path.abspath(self._filename).replace('\\', '/')
1567
1568 def RepositoryName(self):
1569 r"""FullName after removing the local path to the repository.
1570
1571 If we have a real absolute path name here we can try to do something smart:
1572 detecting the root of the checkout and truncating /path/to/checkout from
1573 the name so that we get header guards that don't include things like
1574 "C:\\Documents and Settings\\..." or "/home/username/..." in them and thus
1575 people on different computers who have checked the source out to different
1576 locations won't see bogus errors.
1577 """
1578 fullname = self.FullName()
1579
1580 if os.path.exists(fullname):
1581 project_dir = os.path.dirname(fullname)
1582
1583 # If the user specified a repository path, it exists, and the file is
1584 # contained in it, use the specified repository path
1585 if _repository:
1586 repo = FileInfo(_repository).FullName()
1587 root_dir = project_dir
1588 while os.path.exists(root_dir):
1589 # allow case-insensitive compare on Windows
1590 if os.path.normcase(root_dir) == os.path.normcase(repo):
1591 return os.path.relpath(fullname, root_dir).replace('\\', '/')
1592 one_up_dir = os.path.dirname(root_dir)
1593 if one_up_dir == root_dir:
1594 break
1595 root_dir = one_up_dir
1596
1597 if os.path.exists(os.path.join(project_dir, ".svn")):
1598 # If there's a .svn file in the current directory, we recursively look
1599 # up the directory tree for the top of the SVN checkout
1600 root_dir = project_dir
1601 one_up_dir = os.path.dirname(root_dir)
1602 while os.path.exists(os.path.join(one_up_dir, ".svn")):
1603 root_dir = os.path.dirname(root_dir)
1604 one_up_dir = os.path.dirname(one_up_dir)
1605
1606 prefix = os.path.commonprefix([root_dir, project_dir])
1607 return fullname[len(prefix) + 1:]
1608
1609 # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by
1610 # searching up from the current path.
1611 root_dir = current_dir = os.path.dirname(fullname)
1612 while current_dir != os.path.dirname(current_dir):
1613 if (os.path.exists(os.path.join(current_dir, ".git")) or
1614 os.path.exists(os.path.join(current_dir, ".hg")) or
1615 os.path.exists(os.path.join(current_dir, ".svn"))):
1616 root_dir = current_dir
1617 current_dir = os.path.dirname(current_dir)
1618
1619 if (os.path.exists(os.path.join(root_dir, ".git")) or
1620 os.path.exists(os.path.join(root_dir, ".hg")) or
1621 os.path.exists(os.path.join(root_dir, ".svn"))):
1622 prefix = os.path.commonprefix([root_dir, project_dir])
1623 return fullname[len(prefix) + 1:]
1624
1625 # Don't know what to do; header guard warnings may be wrong...

Callers 6

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

Calls 4

FullNameMethod · 0.95
FileInfoClass · 0.85
existsMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected