Skip to content

Commit 068e929

Browse files
committed
Update ffpm.py
1 parent 092ebeb commit 068e929

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

ffpm.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
# * * * * * * * * * * * * * * * * * * * * *
3434
import subprocess
3535
import sys
36+
from functools import cache
3637

3738
from typing_extensions import Annotated
3839

@@ -61,6 +62,7 @@ def ensure_deps():
6162

6263
import signal
6364
from datetime import datetime
65+
import typeguard
6466
from watchdog.observers import Observer
6567
from watchdog.events import FileSystemEventHandler
6668

@@ -69,7 +71,7 @@ def ensure_deps():
6971
FIREFOX_DIR = Path.home() / ".mozilla" / "firefox" # Linux/macOS
7072
PROFILES_INI = FIREFOX_DIR / "profiles.ini"
7173
BACKUP_DIR = Path.home() / "firefox-profile-backups"
72-
74+
typeguard.install_import_hook('ffpm')
7375

7476
def get_profile_path(profile_name_or_path: str) -> Path:
7577
path = Path(profile_name_or_path).expanduser().resolve()
@@ -324,11 +326,30 @@ def watch(profile_name: str = typer.Argument(...), out: str = "watch-log.csv"):
324326

325327
def _ensureBakDir():
326328
import os
327-
os.makedirs(BACKUP_DIR)
328-
329+
if not BACKUP_DIR.exists():
330+
os.makedirs(BACKUP_DIR)
331+
332+
333+
def _logo(_):
334+
print("""
335+
M\"\"\"\"\"\"\"\"`M dP
336+
Mmmmmm .M 88
337+
MMMMP .MMM dP dP 88 .dP .d8888b.
338+
MMP .MMMMM 88 88 88888" 88' `88
339+
M' .MMMMMMM 88. .88 88 `8b. 88. .88
340+
M M `88888P' dP `YP `88888P'
341+
MMMMMMMMMMM -*- Created by Zuko -*-
342+
343+
* * * * * * * * * * * * * * * * * * * * *
344+
* - - - F.R.E.E.M.I.N.D - - - *
345+
* - Copyright © 2025 (Z) Programing - *
346+
* - - All Rights Reserved - - *
347+
* * * * * * * * * * * * * * * * * * * * *
348+
""")
329349

330350
@app.command()
331351
def list():
352+
"""List available installed profiles"""
332353
profiles = get_profiles()
333354
from rich.table import Table
334355
from rich.console import Console
@@ -361,6 +382,8 @@ def export_profile(name: str, output: Annotated[Path, typer.Argument()] = None):
361382
if not path or not path.exists():
362383
typer.echo("Profile not found.")
363384
raise typer.Exit(1)
385+
if output.exists():
386+
typer.confirm(f"Output file {str(output)} exists. Overwrite?", abort=True)
364387
with zipfile.ZipFile(output, 'w', zipfile.ZIP_DEFLATED) as zipf:
365388
for root, _, files in os.walk(path):
366389
for file in files:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ version = "1.0.1"
66
dependencies = [
77
"typer[all]",
88
"watchdog",
9+
"typeguard"
910
]
1011
optional-dependencies=[
1112
"nuitka>=2.7.5",

0 commit comments

Comments
 (0)