| 1234567891011121314151617181920212223242526272829 |
- # This class manages the browser's current path
- class PathObject:
- def __init__(self, text):
- text = text.replace('\\', '/')
- self.pathtext = text
- def __str__(self):
- return self.pathtext
- def set(self, text:str):
- text = str(text).replace('\\', '/')
- self.pathtext = text
- def add(self, dir): # adds a folder's name to the end of the path
- self.pathtext += '/'
- self.pathtext += str(dir)
- def back(self): # removes the current folder from the end of the path
- if "/" not in self.pathtext:
- return
- dir = self.pathtext.rsplit('/', 1)[1]
- self.pathtext = self.pathtext.rsplit('/', 1)[0]
- return dir
- def is_root(self):
- if "/" not in self.pathtext:
- return True
- return False
|