notionary 0.2.11__py3-none-any.whl → 0.2.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- notionary/cli/main.py +184 -0
- notionary/cli/onboarding.py +0 -0
- notionary/database/notion_database.py +1 -1
- {notionary-0.2.11.dist-info → notionary-0.2.12.dist-info}/METADATA +2 -1
- {notionary-0.2.11.dist-info → notionary-0.2.12.dist-info}/RECORD +9 -6
- notionary-0.2.12.dist-info/entry_points.txt +2 -0
- {notionary-0.2.11.dist-info → notionary-0.2.12.dist-info}/WHEEL +0 -0
- {notionary-0.2.11.dist-info → notionary-0.2.12.dist-info}/licenses/LICENSE +0 -0
- {notionary-0.2.11.dist-info → notionary-0.2.12.dist-info}/top_level.txt +0 -0
notionary/cli/main.py
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
Notionary CLI - Integration Key Setup
|
4
|
+
"""
|
5
|
+
|
6
|
+
import click
|
7
|
+
import os
|
8
|
+
import platform
|
9
|
+
from pathlib import Path
|
10
|
+
from dotenv import load_dotenv
|
11
|
+
from rich.console import Console
|
12
|
+
from rich.panel import Panel
|
13
|
+
from rich.prompt import Prompt, Confirm
|
14
|
+
|
15
|
+
console = Console()
|
16
|
+
|
17
|
+
def get_paste_tips():
|
18
|
+
"""Get platform-specific paste tips"""
|
19
|
+
system = platform.system().lower()
|
20
|
+
|
21
|
+
if system == "darwin": # macOS
|
22
|
+
return [
|
23
|
+
"• Terminal: [cyan]Cmd+V[/cyan]",
|
24
|
+
"• iTerm2: [cyan]Cmd+V[/cyan]",
|
25
|
+
]
|
26
|
+
elif system == "windows":
|
27
|
+
return [
|
28
|
+
"• PowerShell: [cyan]Right-click[/cyan] or [cyan]Shift+Insert[/cyan]",
|
29
|
+
"• cmd: [cyan]Right-click[/cyan]",
|
30
|
+
]
|
31
|
+
else: # Linux and others
|
32
|
+
return [
|
33
|
+
"• Terminal: [cyan]Ctrl+Shift+V[/cyan] or [cyan]Right-click[/cyan]",
|
34
|
+
"• Some terminals: [cyan]Shift+Insert[/cyan]",
|
35
|
+
]
|
36
|
+
|
37
|
+
def show_paste_tips():
|
38
|
+
"""Show platform-specific paste tips"""
|
39
|
+
console.print("\n[bold yellow]💡 Paste Tips:[/bold yellow]")
|
40
|
+
for tip in get_paste_tips():
|
41
|
+
console.print(tip)
|
42
|
+
console.print()
|
43
|
+
|
44
|
+
def get_notion_secret() -> str:
|
45
|
+
"""Get NOTION_SECRET using the same logic as NotionClient"""
|
46
|
+
load_dotenv()
|
47
|
+
return os.getenv("NOTION_SECRET", "")
|
48
|
+
|
49
|
+
@click.group()
|
50
|
+
@click.version_option() # Automatische Version aus setup.py
|
51
|
+
def main():
|
52
|
+
"""
|
53
|
+
Notionary CLI - Notion API Integration
|
54
|
+
"""
|
55
|
+
pass
|
56
|
+
|
57
|
+
@main.command()
|
58
|
+
def init():
|
59
|
+
"""
|
60
|
+
Setup your Notion Integration Key
|
61
|
+
"""
|
62
|
+
# Check if key already exists
|
63
|
+
existing_key = get_notion_secret()
|
64
|
+
|
65
|
+
if existing_key:
|
66
|
+
console.print(Panel.fit(
|
67
|
+
"[bold green]✅ You're all set![/bold green]\n"
|
68
|
+
f"Your Notion Integration Key is already configured.\n"
|
69
|
+
f"Key: [dim]{existing_key[:8]}...[/dim]",
|
70
|
+
title="Already Configured"
|
71
|
+
))
|
72
|
+
|
73
|
+
# Option to reconfigure
|
74
|
+
if Confirm.ask("\n[yellow]Would you like to update your key?[/yellow]"):
|
75
|
+
setup_new_key()
|
76
|
+
else:
|
77
|
+
console.print("\n[blue]No changes made. Happy coding! 🚀[/blue]")
|
78
|
+
else:
|
79
|
+
# No key found, start setup
|
80
|
+
console.print(Panel.fit(
|
81
|
+
"[bold green]🚀 Notionary Setup[/bold green]\n"
|
82
|
+
"Enter your Notion Integration Key to get started...\n\n"
|
83
|
+
"[bold blue]🔗 Create an Integration Key or get an existing one:[/bold blue]\n"
|
84
|
+
"[cyan]https://www.notion.so/profile/integrations[/cyan]",
|
85
|
+
title="Initialization"
|
86
|
+
))
|
87
|
+
setup_new_key()
|
88
|
+
|
89
|
+
def setup_new_key():
|
90
|
+
"""Handle the key setup process"""
|
91
|
+
try:
|
92
|
+
# Show Integration Key creation link
|
93
|
+
console.print("\n[bold blue]🔗 Create an Integration Key:[/bold blue]")
|
94
|
+
console.print("[cyan]https://www.notion.so/profile/integrations[/cyan]")
|
95
|
+
console.print()
|
96
|
+
|
97
|
+
# Get integration key
|
98
|
+
integration_key = Prompt.ask(
|
99
|
+
"[bold cyan]Notion Integration Key[/bold cyan]"
|
100
|
+
)
|
101
|
+
|
102
|
+
# Input validation
|
103
|
+
if not integration_key or not integration_key.strip():
|
104
|
+
console.print("[bold red]❌ Integration Key cannot be empty![/bold red]")
|
105
|
+
return
|
106
|
+
|
107
|
+
# Trim whitespace
|
108
|
+
integration_key = integration_key.strip()
|
109
|
+
|
110
|
+
# Check for common paste issues
|
111
|
+
if integration_key in ["^V", "^v", "^C", "^c"]:
|
112
|
+
console.print("[bold red]❌ Paste didn't work! Try:[/bold red]")
|
113
|
+
show_paste_tips()
|
114
|
+
return
|
115
|
+
|
116
|
+
# Show masked feedback that paste worked
|
117
|
+
masked_key = "•" * len(integration_key)
|
118
|
+
console.print(f"[dim]Received: {masked_key} ({len(integration_key)} characters)[/dim]")
|
119
|
+
|
120
|
+
# Basic validation for Notion keys
|
121
|
+
if not integration_key.startswith('ntn_') or len(integration_key) < 30:
|
122
|
+
console.print("[bold yellow]⚠️ Warning: This doesn't look like a valid Notion Integration Key[/bold yellow]")
|
123
|
+
console.print("[dim]Notion keys usually start with 'ntn_' and are about 50+ characters long[/dim]")
|
124
|
+
if not Confirm.ask("Continue anyway?"):
|
125
|
+
return
|
126
|
+
|
127
|
+
# Save the key
|
128
|
+
if save_integration_key(integration_key):
|
129
|
+
return # Success!
|
130
|
+
|
131
|
+
except KeyboardInterrupt:
|
132
|
+
console.print("\n[yellow]Setup cancelled.[/yellow]")
|
133
|
+
except Exception as e:
|
134
|
+
console.print(f"\n[bold red]❌ Error during setup: {e}[/bold red]")
|
135
|
+
raise click.Abort()
|
136
|
+
|
137
|
+
def save_integration_key(integration_key: str) -> bool:
|
138
|
+
"""Save the integration key to .env file"""
|
139
|
+
try:
|
140
|
+
# .env Datei im aktuellen Verzeichnis erstellen/aktualisieren
|
141
|
+
env_file = Path.cwd() / ".env"
|
142
|
+
|
143
|
+
# Bestehende .env lesen falls vorhanden
|
144
|
+
existing_lines = []
|
145
|
+
if env_file.exists():
|
146
|
+
with open(env_file, 'r', encoding='utf-8') as f:
|
147
|
+
existing_lines = [line.rstrip() for line in f.readlines()]
|
148
|
+
|
149
|
+
# NOTION_SECRET Zeile hinzufügen/ersetzen
|
150
|
+
updated_lines = []
|
151
|
+
notion_secret_found = False
|
152
|
+
|
153
|
+
for line in existing_lines:
|
154
|
+
if line.startswith('NOTION_SECRET='):
|
155
|
+
updated_lines.append(f'NOTION_SECRET={integration_key}')
|
156
|
+
notion_secret_found = True
|
157
|
+
else:
|
158
|
+
updated_lines.append(line)
|
159
|
+
|
160
|
+
# Falls NOTION_SECRET noch nicht existiert, hinzufügen
|
161
|
+
if not notion_secret_found:
|
162
|
+
updated_lines.append(f'NOTION_SECRET={integration_key}')
|
163
|
+
|
164
|
+
# .env Datei schreiben
|
165
|
+
with open(env_file, 'w', encoding='utf-8') as f:
|
166
|
+
f.write('\n'.join(updated_lines) + '\n')
|
167
|
+
|
168
|
+
# Verification
|
169
|
+
written_key = get_notion_secret()
|
170
|
+
if written_key == integration_key:
|
171
|
+
console.print("\n[bold green]✅ Integration Key saved and verified![/bold green]")
|
172
|
+
console.print(f"[dim]Configuration: {env_file}[/dim]")
|
173
|
+
console.print("\n[blue]Ready to use notionary in your Python code! 🚀[/blue]")
|
174
|
+
return True
|
175
|
+
else:
|
176
|
+
console.print("\n[bold red]❌ Error: Key verification failed![/bold red]")
|
177
|
+
return False
|
178
|
+
|
179
|
+
except Exception as e:
|
180
|
+
console.print(f"\n[bold red]❌ Error saving key: {e}[/bold red]")
|
181
|
+
return False
|
182
|
+
|
183
|
+
if __name__ == '__main__':
|
184
|
+
main()
|
File without changes
|
@@ -26,7 +26,7 @@ class NotionDatabase(LoggingMixin):
|
|
26
26
|
token: Optional Notion API token
|
27
27
|
"""
|
28
28
|
self.database_id = database_id
|
29
|
-
self._telemetry = NotionaryTelemetry
|
29
|
+
self._telemetry = NotionaryTelemetry()
|
30
30
|
self._client = NotionClient(token=token)
|
31
31
|
|
32
32
|
@classmethod
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: notionary
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.12
|
4
4
|
Summary: A toolkit to convert between Markdown and Notion blocks
|
5
5
|
Home-page: https://github.com/mathisarends/notionary
|
6
6
|
Author: Mathis Arends
|
@@ -14,6 +14,7 @@ Requires-Dist: httpx>=0.28.0
|
|
14
14
|
Requires-Dist: python-dotenv>=1.1.0
|
15
15
|
Requires-Dist: pydantic>=2.11.4
|
16
16
|
Requires-Dist: posthog>=3.0.0
|
17
|
+
Requires-Dist: click>=8.0.0
|
17
18
|
Dynamic: author
|
18
19
|
Dynamic: author-email
|
19
20
|
Dynamic: classifier
|
@@ -1,7 +1,9 @@
|
|
1
1
|
notionary/__init__.py,sha256=I4kPJ_LEy_IIQuBVGZ-U_kiIUWeRUP9DZ_F3w9BvS-4,809
|
2
2
|
notionary/notion_client.py,sha256=gkREAr8LkUUKK9cOvq72r8jNjlXDleBP2fYm7LjjbjM,7311
|
3
|
+
notionary/cli/main.py,sha256=GmUfdrJZjHYo689ZhrMuA4Lr_sBE2YeqrkFloXgrfvY,6663
|
4
|
+
notionary/cli/onboarding.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
5
|
notionary/database/database_discovery.py,sha256=l9IjthwdA_Y_k_JXcAW-KnvZDwNYylIbsrQ5cpgtb5w,4484
|
4
|
-
notionary/database/notion_database.py,sha256=
|
6
|
+
notionary/database/notion_database.py,sha256=yTGMK1EOuJDNiP6boc_dvWDLTTEhOOYa_ZdJWiOP19c,7695
|
5
7
|
notionary/database/notion_database_factory.py,sha256=pOu4MDu7jaSkNQHk-TSEezsJ1pPGJXiSTOouygh2JuY,6783
|
6
8
|
notionary/database/models/page_result.py,sha256=Vmm5_oYpYAkIIJVoTd1ZZGloeC3cmFLMYP255mAmtaw,233
|
7
9
|
notionary/elements/audio_element.py,sha256=wXSo0DQs_KIVdLB-Ax5Yk4puW-_gFwAbJHcgcpwZjoA,5392
|
@@ -60,8 +62,9 @@ notionary/util/logging_mixin.py,sha256=d5sRSmUtgQeuckdNBkO025IXPGe4oOb-7ueVAIP8a
|
|
60
62
|
notionary/util/page_id_utils.py,sha256=EYNMxgf-7ghzL5K8lKZBZfW7g5CsdY0Xuj4IYmU8RPk,1381
|
61
63
|
notionary/util/singleton.py,sha256=CKAvykndwPRZsA3n3MAY_XdCR59MBjjKP0vtm2BcvF0,428
|
62
64
|
notionary/util/warn_direct_constructor_usage.py,sha256=vyJR73F95XVSRWIbyij-82IGOpAne9SBPM25eDpZfSU,1715
|
63
|
-
notionary-0.2.
|
64
|
-
notionary-0.2.
|
65
|
-
notionary-0.2.
|
66
|
-
notionary-0.2.
|
67
|
-
notionary-0.2.
|
65
|
+
notionary-0.2.12.dist-info/licenses/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
|
66
|
+
notionary-0.2.12.dist-info/METADATA,sha256=vZNayJWGNmJAJBfitVjQXYEkJC2YjJRE0fmEK6s3Aeg,7582
|
67
|
+
notionary-0.2.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
68
|
+
notionary-0.2.12.dist-info/entry_points.txt,sha256=V7X21u3QNm7h7p6Cx0Sx2SO3mtmA7gVwXM8lNYnv9fk,54
|
69
|
+
notionary-0.2.12.dist-info/top_level.txt,sha256=fhONa6BMHQXqthx5PanWGbPL0b8rdFqhrJKVLf_adSs,10
|
70
|
+
notionary-0.2.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|