2021-03-18 05:29:58 +00:00
|
|
|
# Python imports
|
|
|
|
import os
|
|
|
|
|
|
|
|
# Lib imports
|
|
|
|
|
|
|
|
# Application imports
|
|
|
|
|
|
|
|
|
|
|
|
class Path:
|
2021-04-28 03:09:21 +00:00
|
|
|
def get_home(self):
|
|
|
|
return os.path.expanduser("~") + self.subpath
|
|
|
|
|
2021-03-18 05:29:58 +00:00
|
|
|
def get_path(self):
|
|
|
|
return "/" + "/".join(self.path)
|
|
|
|
|
|
|
|
def get_path_list(self):
|
|
|
|
return self.path
|
|
|
|
|
|
|
|
def push_to_path(self, dir):
|
|
|
|
self.path.append(dir)
|
|
|
|
self.load_directory()
|
|
|
|
|
|
|
|
def pop_from_path(self):
|
|
|
|
self.path.pop()
|
|
|
|
|
|
|
|
if not self.go_past_home:
|
|
|
|
if self.get_home() not in self.get_path():
|
|
|
|
self.set_to_home()
|
|
|
|
|
|
|
|
self.load_directory()
|
|
|
|
|
|
|
|
|
|
|
|
def set_path(self, path):
|
|
|
|
self.path = list( filter(None, path.replace("\\", "/").split('/')) )
|
|
|
|
self.load_directory()
|
|
|
|
|
|
|
|
def set_path_with_sub_path(self, sub_path):
|
|
|
|
path = os.path.join(self.get_home(), sub_path)
|
|
|
|
self.path = list( filter(None, path.replace("\\", "/").split('/')) )
|
|
|
|
self.load_directory()
|
|
|
|
|
|
|
|
def set_to_home(self):
|
|
|
|
home = os.path.expanduser("~") + self.subpath
|
|
|
|
path = list( filter(None, home.replace("\\", "/").split('/')) )
|
|
|
|
self.path = path
|
|
|
|
self.load_directory()
|