PathObject.py 815 B

1234567891011121314151617181920212223242526272829
  1. # This class manages the browser's current path
  2. class PathObject:
  3. def __init__(self, text):
  4. text = text.replace('\\', '/')
  5. self.pathtext = text
  6. def __str__(self):
  7. return self.pathtext
  8. def set(self, text:str):
  9. text = str(text).replace('\\', '/')
  10. self.pathtext = text
  11. def add(self, dir): # adds a folder's name to the end of the path
  12. self.pathtext += '/'
  13. self.pathtext += str(dir)
  14. def back(self): # removes the current folder from the end of the path
  15. if "/" not in self.pathtext:
  16. return
  17. dir = self.pathtext.rsplit('/', 1)[1]
  18. self.pathtext = self.pathtext.rsplit('/', 1)[0]
  19. return dir
  20. def is_root(self):
  21. if "/" not in self.pathtext:
  22. return True
  23. return False