8000 wip: major change in project structure · jaypyles/obsidian-to-bookstack@8f1ff25 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f1ff25

Browse files
committed
wip: major change in project structure
1 parent d2170fa commit 8f1ff25

File tree

8 files changed

+248
-110
lines changed

8 files changed

+248
-110
lines changed

obsidian_to_bookstack/__main__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import click
44
from dotenv import load_dotenv
55

6-
from .bookstack.Bookstack import Bookstack
6+
from .bookstack.bookstack import Bookstack
77
from .config import load_toml
88

99
if os.path.exists(".env"):
@@ -63,9 +63,15 @@ def update(remote, local):
6363
print("Must specify remote or local!")
6464

6565

66+
@cli.command()
67+
def delete():
68+
...
69+
70+
6671
def main():
6772
cli()
6873

6974

7075
if __name__ == "__main__":
71-
main()
76+
# main()
77+
...
Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +0,0 @@
1-
import os
2-
3-
from .Page import Page
4-
5-
6-
class Book:
7-
def __init__(self, path, name, client, shelf) -> None:
8-
self.path = path
9-
self.name = name
10-
self.client = client
11-
self.shelf = shelf
12-
self.pages = [
13-
Page(
14-
path=os.path.join(self.path, page),
15-
name=page,
16-
client=self.client,
17-
book=self,
18-
)
19-
for page in os.listdir(self.path)
20-
if os.path.splitext(page)[1] == ".md"
21-
]
22-
23-
def __str__(self) -> str:
24-
return self.name

obsidian_to_bookstack/bookstack/Page.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

obsidian_to_bookstack/bookstack/Shelf.py

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .Bookstack import Bookstack
1+
from .bookstack import Bookstack
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import os
2+
from typing import Dict
3+
4+
from .client import Client
5+
6+
7+
class Shelf:
8+
def __init__(
9+
self,
10+
name: str,
11+
client: Client | None = None,
12+
from_client: bool = True,
13+
path: str = "",
14+
details: Dict = {},
15+
) -> None:
16+
self.path = path
17+
self.name = name
18+
self.client = client
19+
if from_client:
20+
self.books = []
21+
else:
22+
self.books = self._set_books()
23+
self.client_books: list[dict] = []
24+
self.details = details
25+
26+
def __str__(self) -> str:
27+
return self.name
28+
29+
def _set_books(self):
30+
books = []
31+
for book in os.listdir(self.path):
32+
if os.path.isdir(os.path.join(self.path, book)) and not book.startswith(
33+
"."
34+
):
35+
b = Book(
36+
path=os.path.join(self.path, book),
37+
name=book,
38+
client=self.client,
39+
shelf=self,
40+
from_client=False,
41+
)
42+
books.append(b)
43+
44+
return books
45+
46+
47+
class Book:
48+
def __init__(
49+
self,
50+
name: str,
51+
shelf: Shelf | None = None,
52+
client: Client | None = None,
53+
path: str = "",
54+
details: Dict = {},
55+
from_client: bool = True,
56+
) -> None:
57+
self.path = path
58+
self.name = name
59+
self.client = client
60+
self.shelf = shelf
61+
self.details = details
62+
if from_client:
63+
self.pages = []
64+
else:
65+
self.pages = [
66+
Page(
67+
path=os.path.join(self.path, page),
68+
name=page,
69+
client ECE1 =self.client,
70+
book=self,
71+
)
72+
for page in os.listdir(self.path)
73+
if os.path.splitext(page)[1] == ".md"
74+
]
75+
76+
def __str__(self) -> str:
77+
return self.name
78+
79+
80+
class Page:
81+
def __init__(
82+
self,
83+
name: str,
84+
path: str = "",
85+
client: Client | None = None,
86+
book: Book | None = None,
87+
details: Dict = {},
88+
) -> None:
89+
self.path = path
90+
self.name = name
91+
self.client = client
92+
self.content = self._get_content() if self.path else ""
93+
self.book = book
94+
self.details = details
95+
96+
def __str__(self) -> str:
97+
return self.name
98+
99+
def _get_content(self):
100+
with open(self.path, "r") as f:
101+
return f.read()

0 commit comments

Comments
 (0)
0