created a module for absolute path conversion
This commit is contained in:
parent
598953b8a3
commit
f9ddca42e9
|
|
@ -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()
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Module sequencing the successive actions necessary for website building
|
# Module sequencing the successive actions necessary for website building
|
||||||
|
|
||||||
import bootstraparse.modules.config as config
|
import bootstraparse.modules.config as config
|
||||||
|
from bootstraparse.modules.pathresolver import bpath
|
||||||
|
|
||||||
|
|
||||||
def create_website():
|
def create_website():
|
||||||
|
|
@ -24,7 +24,7 @@ def create_config():
|
||||||
"""
|
"""
|
||||||
Returns globalConfig as an object from parser_config.yml settings.
|
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():
|
def create_crawler():
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
import modules.sitecreator as sitecreator
|
from bootstraparse.modules.pathresolver import bpath
|
||||||
from rich import print, pretty, inspect
|
import bootstraparse.modules.sitecreator
|
||||||
|
|
||||||
|
|
||||||
pretty.install()
|
print(bpath())
|
||||||
|
print(bootstraparse.modules.sitecreator.create_config())
|
||||||
|
|
||||||
conf = sitecreator.create_config()
|
|
||||||
print("[red]test",conf)
|
|
||||||
inspect(conf)
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue