Debug package

This commit is contained in:
Loic Guegan 2020-04-22 07:39:07 +02:00
parent 5c0cc8e2f4
commit a7217345e1
14 changed files with 86 additions and 65 deletions

1
MANIFEST.in Normal file
View file

@ -0,0 +1 @@
recursive-include bcst/themes/ **

View file

@ -4,8 +4,8 @@ BCST allow you to create a beautiful start page very quickly. To install the dep
> pip install jinja2 > pip install jinja2
Simple right a simple json resource file: Simple write a simple json resource file:
```
{ {
"title":"Default Theme", "title":"Default Theme",
"bookmarks":{ "bookmarks":{
@ -26,6 +26,7 @@ Simple right a simple json resource file:
} }
} }
} }
```
Then simply run: Then simply run:
> ./src/bcst.py \<resource-file-path> \<start-page-destination> > ./src/bcst.py \<resource-file-path> \<start-page-destination>

11
bcst
View file

@ -1,11 +0,0 @@
#!/usr/bin/env python
from libs.args import args
from libs.resource import Resource
from libs.theme import Theme
res=Resource(args.resource)
t=Theme("themes/default",res.json)
t.deploy(args.destination)

9
bcst/bcst Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env python
from bcst.args import args
from bcst.resource import Resource
from bcst.theme import Theme
res=Resource(args.resource)
t=Theme("default",res.json)
t.deploy(args.destination)

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
from os import path from os import path
import json, jsonschema import json
class Resource: class Resource:

48
bcst/theme.py Normal file
View file

@ -0,0 +1,48 @@
#!/usr/bin/env python
from bcst.resource import Resource
from shutil import copytree, ignore_patterns
from jinja2 import Template
import os
from os import path
themes_location=path.join(path.dirname(path.abspath(__file__)),"themes")
def list_themes():
themes=list()
for f in os.listdir(themes_location):
if(not(os.path.isfile(os.path.join(themes_location,f)))):
themes.append(f)
return(themes)
def get_theme_path(name):
p=path.join(themes_location,name)
if(path.isdir(p)):
return(p)
else:
print("Could not find theme: "+name)
exit(1)
class Theme:
def __init__(self, name, resource_data):
self.theme_path=get_theme_path(name)
res=Resource(self.theme_path+"/resources.json")
self.data=res.json
self.data.update(resource_data)
# Read theme
try:
with open(self.theme_path+"/index.html",'r') as f:
self.template=Template(f.read())
except IOError:
print("Unable to found "+resource)
exit(1)
def deploy(self, dest_path):
copytree(self.theme_path, dest_path, dirs_exist_ok=True,ignore=ignore_patterns("*.json","index.html"))
themes_dir=os.path.split(self.theme_path)[0]
theme_dir=os.path.split(self.theme_path)[1]
with open(dest_path+"/index.html", "w") as index:
index.write(self.template.render(self.data))

View file

@ -1,29 +0,0 @@
#!/usr/bin/env python
from resource import Resource
from shutil import copytree, ignore_patterns
from jinja2 import Template
import os
class Theme:
def __init__(self, path, resource_data):
res=Resource(path+"/resources.json")
self.theme_path=path.strip('/')
self.data=res.json
self.data.update(resource_data)
# Read theme
try:
with open(path+"/index.html",'r') as f:
self.template=Template(f.read())
except IOError:
print("Unable to found "+resource)
exit(1)
def deploy(self, path):
copytree(self.theme_path, path, dirs_exist_ok=True,ignore=ignore_patterns("*.json","index.html"))
themes_dir=os.path.split(self.theme_path)[0]
theme_dir=os.path.split(self.theme_path)[1]
with open(path+"/index.html", "w") as index:
index.write(self.template.render(self.data))

View file

@ -5,14 +5,16 @@ with open("README.md", "r") as readme:
setuptools.setup( setuptools.setup(
name="bcst", name="bcst",
version="0.0.1", version="0.0.3",
scripts=['bcst'], scripts=["bcst/bcst"],
author="Loic Guegan", author="Loic Guegan",
author_email="manzerbredes@mailbox.org", author_email="manzerbredes@mailbox.org",
description="A web browser start page generator.", description="A web browser start page generator.",
long_description=long_description, long_description=long_description,
long_description_content_type='text/markdown',
url="https://gitlab.com/manzerbredes/bcst", url="https://gitlab.com/manzerbredes/bcst",
install_requires=["jinja2"], install_requires=["jinja2"],
include_package_data=True,
packages=setuptools.find_packages(), packages=setuptools.find_packages(),
classifiers=["License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)"]) classifiers=["License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)"])