MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / RepositoryName

Method RepositoryName

steps/cpplint.py:1579–1637  ·  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

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

FullNameMethod · 0.95
FileInfoClass · 0.85

Tested by

no test coverage detected