web-automation-demo/Library/ProjectHome.py

13 lines
417 B
Python
Raw Normal View History

2023-03-13 18:49:49 +08:00
import os
def project_home():
path = os.environ.get('PYTHONPATH')
if not path:
raise Exception('No environment variables of PYTHONPATH.')
here = os.path.dirname(__file__).replace("\\", '/')
for j in [i.replace("\\", '/').strip() for i in path.split(os.pathsep)]:
if here.startswith(j):
return j
else:
raise Exception('Project directory is not in PYTHONPATH.')