Ejemplo n.º 1
0
 async def cd(cls, user_id: int, cd_path: str) -> bool:
     if cd_path == '/':
         await cls._directory_set(user_id, '/')
         return True
     if cd_path.endswith('/'):
         cd_path = cd_path[:-1]
     if cd_path == '..':
         user_path = await cls.pwd()
         if (user_path != '/'):
             cd_path = user_path[:user_path.rfind('/')]
             if cd_path == '':
                 cd_path = '/'
             await cls._directory_set(user_id, cd_path)
             return True
         else:
             return False
     if not cd_path.startswith('/'):
         user_path = await cls.pwd()
         if not user_path.endswith('/'):
             user_path += '/'
         user_path += cd_path
         cd_path = user_path
     package_split_point = cd_path.rfind('/')
     if cd_path[package_split_point + 1:] in Navigator.dir(
             cd_path[:package_split_point]):
         await cls._directory_set(user_id, cd_path)
         return True
     else:
         return False
Ejemplo n.º 2
0
 def dir(cls) -> list:
     return Navigator.dir(cls.pwd())
Ejemplo n.º 3
0
 async def dir(cls) -> list:
     return Navigator.dir(await cls.pwd())
Ejemplo n.º 4
0
# -*- coding: utf8 -*-

from main.core.navigator import Navigator

print(Navigator.dir('/'))
print(Navigator.get_class('/registration'))