created a module for absolute path conversion

This commit is contained in:
vky 2022-01-26 17:29:54 +01:00
parent 598953b8a3
commit f9ddca42e9
3 changed files with 36 additions and 10 deletions

View File

@ -0,0 +1,30 @@
# Module for resolving relative path problems
import os
class pathresolver():
"""
Intialised with a relative path and returns the translated absolute path
"""
def __init__(self, basepath):
self.basepath = os.path.normpath(basepath)
def __call__(self, relativepath='.'):
return self.giveabsolute(relativepath)
def giveabsolute(self, relativepath='.'):
return os.path.normpath(os.path.join(self.basepath, relativepath))
class boostrapath(pathresolver):
"""
Initialises pathresolver with the path of the bootstraparse installation folder
"""
def __init__(self):
calculatedpath = os.path.join(__file__, "../../")
super().__init__(calculatedpath)
bpath = boostrapath()

View File

@ -1,7 +1,7 @@
# Module sequencing the successive actions necessary for website building
import bootstraparse.modules.config as config
from bootstraparse.modules.pathresolver import bpath
def create_website():
@ -24,7 +24,7 @@ def create_config():
"""
Returns globalConfig as an object from parser_config.yml settings.
"""
return config.GlobalConfig("configs/parser_config.yml")
return config.GlobalConfig(bpath("configs/parser_config.yml"))
def create_crawler():

View File

@ -1,10 +1,6 @@
import modules.sitecreator as sitecreator
from rich import print, pretty, inspect
from bootstraparse.modules.pathresolver import bpath
import bootstraparse.modules.sitecreator
pretty.install()
conf = sitecreator.create_config()
print("[red]test",conf)
inspect(conf)
print(bpath())
print(bootstraparse.modules.sitecreator.create_config())