src/eric7/Project/Project.py

branch
eric7
changeset 9210
15743bae8a50
parent 9209
b99e7fd55fd3
child 9214
bd28e56047d7
equal deleted inserted replaced
9209:b99e7fd55fd3 9210:15743bae8a50
3606 3606
3607 @param path file or directory name to convert (string) 3607 @param path file or directory name to convert (string)
3608 @return project relative path or unchanged path, if path doesn't 3608 @return project relative path or unchanged path, if path doesn't
3609 belong to the project (string) 3609 belong to the project (string)
3610 """ 3610 """
3611 if self.startswithProjectPath(path): 3611 try:
3612 if self.ppath and path == self.ppath: 3612 return str(pathlib.Path(path).relative_to(self.ppath))
3613 return "" 3613 except ValueError:
3614 else:
3615 relpath = path[len(self.ppath):]
3616 if relpath.startswith(("/", "\\")):
3617 relpath = relpath[1:]
3618 return relpath
3619 else:
3620 return path 3614 return path
3621 3615
3622 def getRelativeUniversalPath(self, path): 3616 def getRelativeUniversalPath(self, path):
3623 """ 3617 """
3624 Public method to convert a file path to a project relative 3618 Public method to convert a file path to a project relative
5095 files = [os.path.join(self.ppath, file) 5089 files = [os.path.join(self.ppath, file)
5096 for file in self.pdata["SOURCES"] if file.endswith(".py")] 5090 for file in self.pdata["SOURCES"] if file.endswith(".py")]
5097 from DataViews.CodeMetricsDialog import CodeMetricsDialog 5091 from DataViews.CodeMetricsDialog import CodeMetricsDialog
5098 self.codemetrics = CodeMetricsDialog() 5092 self.codemetrics = CodeMetricsDialog()
5099 self.codemetrics.show() 5093 self.codemetrics.show()
5100 self.codemetrics.prepare(files, self) 5094 self.codemetrics.prepare(files)
5101 5095
5102 def __showCodeCoverage(self): 5096 def __showCodeCoverage(self):
5103 """ 5097 """
5104 Private slot used to show the code coverage information for the 5098 Private slot used to show the code coverage information for the
5105 project files. 5099 project files.

eric ide

mercurial