| 1431 | return os.path.sep.join(P1) |
| 1432 | |
| 1433 | class PathClass(object): |
| 1434 | def __init__(self, File='', Root='', AlterRoot='', Type='', IsBinary=False, |
| 1435 | Arch='COMMON', ToolChainFamily='', Target='', TagName='', ToolCode=''): |
| 1436 | self.Arch = Arch |
| 1437 | self.File = str(File) |
| 1438 | if os.path.isabs(self.File): |
| 1439 | self.Root = '' |
| 1440 | self.AlterRoot = '' |
| 1441 | else: |
| 1442 | self.Root = str(Root) |
| 1443 | self.AlterRoot = str(AlterRoot) |
| 1444 | |
| 1445 | # Remove any '.' and '..' in path |
| 1446 | if self.Root: |
| 1447 | self.Root = mws.getWs(self.Root, self.File) |
| 1448 | self.Path = os.path.normpath(os.path.join(self.Root, self.File)) |
| 1449 | self.Root = os.path.normpath(CommonPath([self.Root, self.Path])) |
| 1450 | # eliminate the side-effect of 'C:' |
| 1451 | if self.Root[-1] == ':': |
| 1452 | self.Root += os.path.sep |
| 1453 | # file path should not start with path separator |
| 1454 | if self.Root[-1] == os.path.sep: |
| 1455 | self.File = self.Path[len(self.Root):] |
| 1456 | else: |
| 1457 | self.File = self.Path[len(self.Root) + 1:] |
| 1458 | else: |
| 1459 | self.Path = os.path.normpath(self.File) |
| 1460 | |
| 1461 | self.SubDir, self.Name = os.path.split(self.File) |
| 1462 | self.BaseName, self.Ext = os.path.splitext(self.Name) |
| 1463 | |
| 1464 | if self.Root: |
| 1465 | if self.SubDir: |
| 1466 | self.Dir = os.path.join(self.Root, self.SubDir) |
| 1467 | else: |
| 1468 | self.Dir = self.Root |
| 1469 | else: |
| 1470 | self.Dir = self.SubDir |
| 1471 | |
| 1472 | if IsBinary: |
| 1473 | self.Type = Type |
| 1474 | else: |
| 1475 | self.Type = self.Ext.lower() |
| 1476 | |
| 1477 | self.IsBinary = IsBinary |
| 1478 | self.Target = Target |
| 1479 | self.TagName = TagName |
| 1480 | self.ToolCode = ToolCode |
| 1481 | self.ToolChainFamily = ToolChainFamily |
| 1482 | self.OriginalPath = self |
| 1483 | |
| 1484 | ## Convert the object of this class to a string |
| 1485 | # |
| 1486 | # Convert member Path of the class to a string |
| 1487 | # |
| 1488 | # @retval string Formatted String |
| 1489 | # |
| 1490 | def __str__(self): |
no outgoing calls
no test coverage detected