Compare commits
101 Commits
a45a3c0868
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ecbee7a8ac | |||
| eaf4e94d24 | |||
| 97e166d5f7 | |||
| 61e2d7f731 | |||
| 054dc01813 | |||
| 799b1083ab | |||
| 15db235fe1 | |||
| d09dcf06cf | |||
| 5b9589794e | |||
| 93b88917df | |||
| 25618ab5bf | |||
| 81fa68ed08 | |||
| ca6eaed146 | |||
| 1b8b32027c | |||
| a6190aeb84 | |||
| 887169e7d2 | |||
| 9565e4008e | |||
| c2aab71955 | |||
| 97dd55981b | |||
| 0e91c95e9b | |||
| a818df4a6c | |||
| 9aec57bd56 | |||
| ec9943822c | |||
| 0240ff9f8e | |||
| 45e2e1eb00 | |||
| ff20228fa6 | |||
| 9d9c09d56a | |||
| 64355fbeeb | |||
| 4a337e6b20 | |||
| f27be4d603 | |||
| 9d254ac4b7 | |||
| 590cc03ba4 | |||
| c493a99860 | |||
| 3f9ef6527f | |||
| f53e5bb527 | |||
| f2854a0df5 | |||
| defd991006 | |||
| f922e3cf9d | |||
| 06d70edaf1 | |||
| 58ab6cfafa | |||
| dba06e642a | |||
| 5868c1649b | |||
| a14184cddc | |||
| 6587f8c39c | |||
| ae6663572c | |||
| 3eb456e999 | |||
| cfa5773e62 | |||
| ddee2a6029 | |||
| 5e2b4f3408 | |||
| c238278df6 | |||
| a9c25c8c10 | |||
| 5ff25b3eb6 | |||
| c396ba8ae9 | |||
| d12f14a994 | |||
| a4b622bfd3 | |||
| 005c76119f | |||
| b1e2b266f4 | |||
| 6475a117e7 | |||
| 28a193078a | |||
| 07bbe88784 | |||
| 59554f6f17 | |||
| 02f609d829 | |||
| c8df3d0460 | |||
| 5afee97259 | |||
| ebbcbeeaa7 | |||
| 044ec67aa3 | |||
| e871d19a9f | |||
| 0ec562e0d2 | |||
| 276d177c4d | |||
| ed0076a34e | |||
| e99defc533 | |||
| 50288e9130 | |||
| c7ef63cc05 | |||
| 2395f60d11 | |||
| edba17e9a3 | |||
| e3da6c4f12 | |||
| debf55577d | |||
| 2efe83650b | |||
| 1c7a903131 | |||
| 472b828f72 | |||
| 8090a3432c | |||
| 8b406f5d4e | |||
| 053bb8696f | |||
| a31df05bb8 | |||
| e402e844c9 | |||
| 75d29a2c0d | |||
| 11f0bce116 | |||
| 6c424c6135 | |||
| 1b8eb4abd4 | |||
| 4d530a5a65 | |||
| ac21ad39b1 | |||
| 3eac53346f | |||
| e178386fff | |||
| 60f7fae8c0 | |||
| 429f1b4881 | |||
| cf83b18b43 | |||
| 0f0f222213 | |||
| b2382953db | |||
| 1bc52cc68d | |||
| cec1699030 | |||
| 094bf12e62 |
79
README.md
79
README.md
@@ -1,58 +1,40 @@
|
|||||||
# Skywipe
|
# Skywipe
|
||||||
|
|
||||||
Skywipe is a work-in-progress Python 3.13+ CLI that helps you wipe data from your Bluesky account using the AT Protocol.
|
Skywipe is a Python 3.13+ CLI that helps you wipe data from your Bluesky account using the AT Protocol SDK.
|
||||||
|
|
||||||
## Warning
|
**Warning:** This tool performs _**destructive operations**_.
|
||||||
|
|
||||||
This tool performs destructive operations. Only use it if you intend to erase data from your Bluesky account.
|
Only use it if you intend to permanently erase data from your Bluesky account.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Python 3.13+
|
Python 3.13+.
|
||||||
- [`atproto`](https://atproto.blue/en/latest/)
|
|
||||||
- [`uv`](https://github.com/astral-sh/uv) for dependency and virtual environment management
|
|
||||||
|
|
||||||
## Setup
|
The rest of the dependencies are listed in [pyproject.toml](pyproject.toml).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Use [`pipx`](https://pipx.pypa.io/latest/installation/) to install `skywipe`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://git.kharec.info/Kharec/skywipe.git
|
pipx install git+https://git.kharec.info/Kharec/skywipe.git
|
||||||
cd skywipe
|
|
||||||
uv sync # creates a local virtualenv and installs dependencies
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## How to run
|
Run the tool and see available commands with:
|
||||||
|
|
||||||
When installation will be worked out, you'll be able to :
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
skywipe all # target everything
|
skywipe -h
|
||||||
skywipe configure # create configuration
|
|
||||||
skywipe posts # only posts
|
|
||||||
skywipe medias # only posts with medias
|
|
||||||
skywipe likes # only likes
|
|
||||||
skywipe reposts # only reposts
|
|
||||||
skywipe follows # only follows
|
|
||||||
```
|
```
|
||||||
|
|
||||||
While it's being developed, you can use the tool using `uv` :
|
Use the `--yes` flag to skip the confirmation prompt and proceed with the operation. A log of the operations will be saved in `~/.cache/skywipe/skywipe.log`.
|
||||||
|
|
||||||
```bash
|
## Configuration
|
||||||
uv run main.py all # target everything
|
|
||||||
uv run main.py configure # create configuration
|
|
||||||
uv run main.py posts # only posts
|
|
||||||
uv run main.py medias # only posts with medias
|
|
||||||
uv run main.py likes # only likes
|
|
||||||
uv run main.py reposts # only reposts
|
|
||||||
uv run main.py follows # only follows
|
|
||||||
```
|
|
||||||
|
|
||||||
### Configuration
|
|
||||||
|
|
||||||
If you run the tool for the first time, it will prompt you to use `skywipe configure` to create the configuration file, which is located in `~/.config/skywipe/config.yml` :
|
If you run the tool for the first time, it will prompt you to use `skywipe configure` to create the configuration file, which is located in `~/.config/skywipe/config.yml` :
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
handle: your_handle
|
handle: your_handle
|
||||||
password: your_password_encrypted
|
password: your_password
|
||||||
batch_size: 10
|
batch_size: 10
|
||||||
delay: 1
|
delay: 1
|
||||||
verbose: true
|
verbose: true
|
||||||
@@ -60,20 +42,25 @@ verbose: true
|
|||||||
|
|
||||||
BE SURE TO USE A [BLUESKY APP PASSWORD](https://blueskyfeeds.com/faq-app-password) FOR OBVIOUS SECURITY REASONS.
|
BE SURE TO USE A [BLUESKY APP PASSWORD](https://blueskyfeeds.com/faq-app-password) FOR OBVIOUS SECURITY REASONS.
|
||||||
|
|
||||||
## Roadmap
|
## Hacking
|
||||||
|
|
||||||
- [ ] build cli parameter management
|
You can use `uv` to install dependencies:
|
||||||
- [ ] handle configuration logic
|
|
||||||
- [ ] sign in to at protocol
|
```bash
|
||||||
- [ ] delete posts in groups
|
git clone https://git.kharec.info/Kharec/skywipe.git
|
||||||
- [ ] only delete posts with media
|
cd skywipe
|
||||||
- [ ] remove likes
|
uv sync
|
||||||
- [ ] remove reposts
|
```
|
||||||
- [ ] unfollow accounts
|
|
||||||
- [ ] make `all` run the other commands
|
Then start coding.
|
||||||
- [ ] add simple progress and logging
|
|
||||||
- [ ] add safeguards like confirmations and clear dry-run info
|
If you want to test your changes, you can run the tool with:
|
||||||
- [ ] installation and run process
|
|
||||||
|
```bash
|
||||||
|
uv run python -m skywipe.cli -h
|
||||||
|
uv run python -m skywipe.cli all
|
||||||
|
# or any other command
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
9
main.py
9
main.py
@@ -1,9 +0,0 @@
|
|||||||
"""Main entry point for Skywipe"""
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
print("Hello from Skywipe!")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "skywipe"
|
name = "skywipe"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "Clean your bluesky account with style"
|
description = "Clean your bluesky account"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.13"
|
requires-python = ">=3.13"
|
||||||
dependencies = [
|
dependencies = ["atproto>=0.0.65", "pyyaml>=6.0"]
|
||||||
"atproto>=0.0.65",
|
|
||||||
"pyyaml>=6.0",
|
[project.scripts]
|
||||||
"cryptography>=42.0.0",
|
skywipe = "skywipe.cli:main"
|
||||||
]
|
|
||||||
|
|||||||
0
skywipe/__init__.py
Normal file
0
skywipe/__init__.py
Normal file
33
skywipe/auth.py
Normal file
33
skywipe/auth.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
"""Authentication module for Skywipe"""
|
||||||
|
|
||||||
|
from atproto import Client
|
||||||
|
from .configure import Configuration
|
||||||
|
|
||||||
|
|
||||||
|
class Auth:
|
||||||
|
def __init__(self):
|
||||||
|
self.config = Configuration()
|
||||||
|
self.client = None
|
||||||
|
|
||||||
|
def login(self) -> Client:
|
||||||
|
try:
|
||||||
|
config_data = self.config.load()
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
raise ValueError(
|
||||||
|
"Configuration file not found. Run 'skywipe configure' first.") from e
|
||||||
|
|
||||||
|
handle = config_data.get("handle")
|
||||||
|
password = config_data.get("password")
|
||||||
|
|
||||||
|
if not handle or not password:
|
||||||
|
raise ValueError(
|
||||||
|
"handle and password must be set in configuration")
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.client = Client()
|
||||||
|
self.client.login(handle, password)
|
||||||
|
except Exception as e:
|
||||||
|
raise ValueError(
|
||||||
|
f"Failed to authenticate: {e}") from e
|
||||||
|
|
||||||
|
return self.client
|
||||||
72
skywipe/cli.py
Normal file
72
skywipe/cli.py
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
"""Main entry point for Skywipe"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from .commands import registry
|
||||||
|
from .configure import Configuration
|
||||||
|
from .logger import setup_logger, get_logger, handle_error
|
||||||
|
|
||||||
|
|
||||||
|
LOG_FILE = Path.home() / ".cache" / "skywipe" / "skywipe.log"
|
||||||
|
|
||||||
|
|
||||||
|
def create_parser():
|
||||||
|
commands = registry.get_all_commands()
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Clean your bluesky account with style.",
|
||||||
|
epilog="WARNING: This tool deletes your Bluesky data permanently."
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--yes",
|
||||||
|
action="store_true",
|
||||||
|
help="Skip confirmation prompt and proceed with destructive operations"
|
||||||
|
)
|
||||||
|
|
||||||
|
subparsers = parser.add_subparsers(
|
||||||
|
dest="command",
|
||||||
|
help="Command to execute",
|
||||||
|
metavar="COMMAND",
|
||||||
|
required=True
|
||||||
|
)
|
||||||
|
|
||||||
|
for cmd, help_text in commands.items():
|
||||||
|
subparsers.add_parser(cmd, help=help_text)
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
def require_config(logger):
|
||||||
|
config = Configuration()
|
||||||
|
if not config.exists():
|
||||||
|
logger.error("Configuration file not found.")
|
||||||
|
logger.error("You must run 'skywipe configure' first.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = create_parser()
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
setup_logger(verbose=False, log_file=LOG_FILE)
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
if registry.requires_config(args.command):
|
||||||
|
require_config(logger)
|
||||||
|
config = Configuration()
|
||||||
|
config_data = config.load()
|
||||||
|
verbose = config_data.get("verbose", False)
|
||||||
|
setup_logger(verbose=verbose, log_file=LOG_FILE)
|
||||||
|
|
||||||
|
try:
|
||||||
|
registry.execute(
|
||||||
|
args.command, skip_confirmation=getattr(args, "yes", False))
|
||||||
|
except (ValueError, Exception) as e:
|
||||||
|
handle_error(e, logger, exit_on_error=True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
233
skywipe/commands.py
Normal file
233
skywipe/commands.py
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
"""Command implementations for Skywipe"""
|
||||||
|
|
||||||
|
from typing import Callable, Dict, Optional, Any
|
||||||
|
from .configure import Configuration
|
||||||
|
from .operations import Operation
|
||||||
|
from .post_analysis import PostAnalyzer
|
||||||
|
from .logger import get_logger, handle_error
|
||||||
|
from .safeguard import require_confirmation
|
||||||
|
|
||||||
|
|
||||||
|
CommandHandler = Callable[..., None]
|
||||||
|
|
||||||
|
|
||||||
|
COMMAND_METADATA = {
|
||||||
|
"posts": {
|
||||||
|
"confirmation": "delete all posts",
|
||||||
|
"help_text": "only posts",
|
||||||
|
"operation_name": "Deleting posts",
|
||||||
|
"strategy_type": "feed",
|
||||||
|
"collection": None,
|
||||||
|
"filter_fn": None,
|
||||||
|
},
|
||||||
|
"medias": {
|
||||||
|
"confirmation": "delete all posts with media",
|
||||||
|
"help_text": "only posts with medias",
|
||||||
|
"operation_name": "Deleting posts with media",
|
||||||
|
"strategy_type": "feed",
|
||||||
|
"collection": None,
|
||||||
|
"filter_fn": lambda post: PostAnalyzer.has_media(post.post),
|
||||||
|
},
|
||||||
|
"likes": {
|
||||||
|
"confirmation": "undo all likes",
|
||||||
|
"help_text": "only likes",
|
||||||
|
"operation_name": "Undoing likes",
|
||||||
|
"strategy_type": "record",
|
||||||
|
"collection": "app.bsky.feed.like",
|
||||||
|
"filter_fn": None,
|
||||||
|
},
|
||||||
|
"reposts": {
|
||||||
|
"confirmation": "undo all reposts",
|
||||||
|
"help_text": "only reposts",
|
||||||
|
"operation_name": "Undoing reposts",
|
||||||
|
"strategy_type": "record",
|
||||||
|
"collection": "app.bsky.feed.repost",
|
||||||
|
"filter_fn": None,
|
||||||
|
},
|
||||||
|
"quotes": {
|
||||||
|
"confirmation": "delete all quote posts",
|
||||||
|
"help_text": "only quotes",
|
||||||
|
"operation_name": "Deleting quote posts",
|
||||||
|
"strategy_type": "feed",
|
||||||
|
"collection": None,
|
||||||
|
"filter_fn": lambda post: PostAnalyzer.has_quote(post.post),
|
||||||
|
},
|
||||||
|
"follows": {
|
||||||
|
"confirmation": "unfollow all accounts",
|
||||||
|
"help_text": "only follows",
|
||||||
|
"operation_name": "Unfollowing accounts",
|
||||||
|
"strategy_type": "record",
|
||||||
|
"collection": "app.bsky.graph.follow",
|
||||||
|
"filter_fn": None,
|
||||||
|
},
|
||||||
|
"bookmarks": {
|
||||||
|
"confirmation": "delete all bookmarks",
|
||||||
|
"help_text": "only bookmarks",
|
||||||
|
"operation_name": "Deleting bookmarks",
|
||||||
|
"strategy_type": "bookmark",
|
||||||
|
"collection": None,
|
||||||
|
"filter_fn": None,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
COMMAND_EXECUTION_ORDER = [
|
||||||
|
"quotes",
|
||||||
|
"medias",
|
||||||
|
"posts",
|
||||||
|
"likes",
|
||||||
|
"reposts",
|
||||||
|
"follows",
|
||||||
|
"bookmarks",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class CommandRegistry:
|
||||||
|
def __init__(self):
|
||||||
|
self._commands = {}
|
||||||
|
self._help_texts = {}
|
||||||
|
self._requires_config = {}
|
||||||
|
|
||||||
|
def register(
|
||||||
|
self,
|
||||||
|
name: str,
|
||||||
|
handler: CommandHandler,
|
||||||
|
help_text: str,
|
||||||
|
requires_config: bool = True
|
||||||
|
):
|
||||||
|
self._commands[name] = handler
|
||||||
|
self._help_texts[name] = help_text
|
||||||
|
self._requires_config[name] = requires_config
|
||||||
|
|
||||||
|
def get_handler(self, name: str) -> Optional[CommandHandler]:
|
||||||
|
return self._commands.get(name)
|
||||||
|
|
||||||
|
def get_help_text(self, name: str) -> Optional[str]:
|
||||||
|
return self._help_texts.get(name)
|
||||||
|
|
||||||
|
def requires_config(self, name: str) -> bool:
|
||||||
|
return self._requires_config.get(name, True)
|
||||||
|
|
||||||
|
def get_all_commands(self) -> Dict[str, str]:
|
||||||
|
return self._help_texts.copy()
|
||||||
|
|
||||||
|
def execute(self, name: str, skip_confirmation: bool = False):
|
||||||
|
handler = self.get_handler(name)
|
||||||
|
if handler:
|
||||||
|
if name == "configure":
|
||||||
|
handler()
|
||||||
|
else:
|
||||||
|
handler(skip_confirmation)
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Unknown command: {name}")
|
||||||
|
|
||||||
|
|
||||||
|
registry = CommandRegistry()
|
||||||
|
|
||||||
|
|
||||||
|
def _create_operation_handler(
|
||||||
|
confirmation_message: str,
|
||||||
|
operation_name: str,
|
||||||
|
strategy_type: str = "feed",
|
||||||
|
collection: Optional[str] = None,
|
||||||
|
filter_fn: Optional[Callable[[Any], bool]] = None
|
||||||
|
) -> CommandHandler:
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
def handler(skip_confirmation: bool = False):
|
||||||
|
require_confirmation(confirmation_message, skip_confirmation, logger)
|
||||||
|
try:
|
||||||
|
Operation(
|
||||||
|
operation_name,
|
||||||
|
strategy_type=strategy_type,
|
||||||
|
collection=collection,
|
||||||
|
filter_fn=filter_fn
|
||||||
|
).run()
|
||||||
|
except (ValueError, Exception) as e:
|
||||||
|
handle_error(e, logger)
|
||||||
|
return handler
|
||||||
|
|
||||||
|
|
||||||
|
def run_configure():
|
||||||
|
config = Configuration()
|
||||||
|
config.create()
|
||||||
|
|
||||||
|
|
||||||
|
def _create_command_handlers():
|
||||||
|
handlers = {}
|
||||||
|
for cmd, metadata in COMMAND_METADATA.items():
|
||||||
|
handlers[cmd] = _create_operation_handler(
|
||||||
|
metadata["confirmation"],
|
||||||
|
metadata["operation_name"],
|
||||||
|
strategy_type=metadata["strategy_type"],
|
||||||
|
collection=metadata["collection"],
|
||||||
|
filter_fn=metadata["filter_fn"]
|
||||||
|
)
|
||||||
|
return handlers
|
||||||
|
|
||||||
|
|
||||||
|
_command_handlers = _create_command_handlers()
|
||||||
|
run_posts = _command_handlers["posts"]
|
||||||
|
run_medias = _command_handlers["medias"]
|
||||||
|
run_likes = _command_handlers["likes"]
|
||||||
|
run_reposts = _command_handlers["reposts"]
|
||||||
|
run_quotes = _command_handlers["quotes"]
|
||||||
|
run_follows = _command_handlers["follows"]
|
||||||
|
run_bookmarks = _command_handlers["bookmarks"]
|
||||||
|
|
||||||
|
|
||||||
|
def run_all(skip_confirmation: bool = False):
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
all_commands = registry.get_all_commands()
|
||||||
|
available_commands = [cmd for cmd in all_commands.keys()
|
||||||
|
if cmd not in ("configure", "all")]
|
||||||
|
|
||||||
|
commands = [cmd for cmd in COMMAND_EXECUTION_ORDER
|
||||||
|
if cmd in available_commands]
|
||||||
|
|
||||||
|
commands.extend([cmd for cmd in available_commands
|
||||||
|
if cmd not in COMMAND_EXECUTION_ORDER])
|
||||||
|
|
||||||
|
commands_str = ", ".join(commands)
|
||||||
|
all_confirmation = f"run all cleanup commands ({commands_str})"
|
||||||
|
require_confirmation(all_confirmation, skip_confirmation, logger)
|
||||||
|
|
||||||
|
logger.info("Running all cleanup commands...")
|
||||||
|
|
||||||
|
from .operations import OperationContext
|
||||||
|
try:
|
||||||
|
context = OperationContext()
|
||||||
|
shared_client = context.client
|
||||||
|
shared_config_data = context.config_data
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(
|
||||||
|
f"Failed to initialize shared context: {e}", exc_info=True)
|
||||||
|
raise
|
||||||
|
|
||||||
|
for cmd in commands:
|
||||||
|
try:
|
||||||
|
logger.info(f"Starting command: {cmd}")
|
||||||
|
metadata = COMMAND_METADATA.get(cmd)
|
||||||
|
if metadata:
|
||||||
|
Operation(
|
||||||
|
metadata["operation_name"],
|
||||||
|
strategy_type=metadata["strategy_type"],
|
||||||
|
collection=metadata["collection"],
|
||||||
|
filter_fn=metadata["filter_fn"],
|
||||||
|
client=shared_client,
|
||||||
|
config_data=shared_config_data
|
||||||
|
).run()
|
||||||
|
else:
|
||||||
|
registry.execute(cmd, skip_confirmation=True)
|
||||||
|
logger.info(f"Completed command: {cmd}")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error running '{cmd}': {e}", exc_info=True)
|
||||||
|
continue
|
||||||
|
logger.info("All commands completed.")
|
||||||
|
|
||||||
|
|
||||||
|
registry.register("configure", run_configure,
|
||||||
|
"create configuration", requires_config=False)
|
||||||
|
for cmd, metadata in COMMAND_METADATA.items():
|
||||||
|
registry.register(cmd, _command_handlers[cmd], metadata["help_text"])
|
||||||
|
registry.register("all", run_all, "target everything")
|
||||||
145
skywipe/configure.py
Normal file
145
skywipe/configure.py
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
"""Core configuration module for Skywipe"""
|
||||||
|
|
||||||
|
import getpass
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
import yaml
|
||||||
|
from .logger import setup_logger
|
||||||
|
|
||||||
|
|
||||||
|
def _validate_handle(handle: str) -> tuple[bool, str]:
|
||||||
|
if not handle:
|
||||||
|
return False, "Handle cannot be empty"
|
||||||
|
|
||||||
|
if len(handle) > 253:
|
||||||
|
return False, "Handle is too long (max 253 characters)"
|
||||||
|
|
||||||
|
if " " in handle:
|
||||||
|
return False, "Handle cannot contain spaces"
|
||||||
|
|
||||||
|
handle_pattern = re.compile(
|
||||||
|
r"^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$|"
|
||||||
|
r"^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$|"
|
||||||
|
r"^did:[a-z]+:[a-zA-Z0-9._-]+$"
|
||||||
|
)
|
||||||
|
|
||||||
|
if not handle_pattern.match(handle):
|
||||||
|
return False, (
|
||||||
|
"Invalid handle format. "
|
||||||
|
"Use a username (e.g., 'alice'), full handle (e.g., 'alice.bsky.social'), "
|
||||||
|
"or DID (e.g., 'did:plc:...')"
|
||||||
|
)
|
||||||
|
|
||||||
|
return True, ""
|
||||||
|
|
||||||
|
|
||||||
|
def _validate_password(password: str) -> tuple[bool, str]:
|
||||||
|
if not password:
|
||||||
|
return False, "Password cannot be empty"
|
||||||
|
|
||||||
|
if len(password) < 8:
|
||||||
|
return False, "Password is too short (minimum 8 characters)"
|
||||||
|
|
||||||
|
return True, ""
|
||||||
|
|
||||||
|
|
||||||
|
class Configuration:
|
||||||
|
def __init__(self):
|
||||||
|
self.config_file = Path.home() / ".config" / "skywipe" / "config.yml"
|
||||||
|
|
||||||
|
def exists(self) -> bool:
|
||||||
|
return self.config_file.exists()
|
||||||
|
|
||||||
|
def create(self):
|
||||||
|
logger = setup_logger(verbose=False)
|
||||||
|
if self.exists():
|
||||||
|
overwrite = input(
|
||||||
|
"Configuration already exists. Overwrite? (y/N): ").strip().lower()
|
||||||
|
if overwrite not in ("y", "yes"):
|
||||||
|
logger.info("Configuration creation cancelled.")
|
||||||
|
return
|
||||||
|
|
||||||
|
config_dir = self.config_file.parent
|
||||||
|
config_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
print("Skywipe Configuration")
|
||||||
|
print("=" * 50)
|
||||||
|
print("Note: You should use an app password from Bluesky settings.")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
handle = input("Bluesky handle: ").strip()
|
||||||
|
is_valid, error_msg = _validate_handle(handle)
|
||||||
|
if is_valid:
|
||||||
|
break
|
||||||
|
logger.error(error_msg)
|
||||||
|
logger.info("Please enter a valid handle and try again.")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
password = getpass.getpass(
|
||||||
|
"Bluesky (hopefully app) password: ").strip()
|
||||||
|
is_valid, error_msg = _validate_password(password)
|
||||||
|
if is_valid:
|
||||||
|
break
|
||||||
|
logger.error(error_msg)
|
||||||
|
logger.info("Please check your password and try again.")
|
||||||
|
logger.info(
|
||||||
|
"Generate an app password at: https://bsky.app/settings/app-passwords")
|
||||||
|
|
||||||
|
batch_size = input("Batch size (default: 10): ").strip() or "10"
|
||||||
|
delay = input(
|
||||||
|
"Delay between batches in seconds (default: 1): ").strip() or "1"
|
||||||
|
verbose_input = input(
|
||||||
|
"Verbose mode (y/n, default: y): ").strip().lower() or "y"
|
||||||
|
verbose = verbose_input in ("y", "yes", "true", "1")
|
||||||
|
|
||||||
|
try:
|
||||||
|
batch_size = int(batch_size)
|
||||||
|
if batch_size < 1 or batch_size > 100:
|
||||||
|
logger.error("batch_size must be between 1 and 100")
|
||||||
|
return
|
||||||
|
except ValueError:
|
||||||
|
logger.error("batch_size must be an integer")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
delay = int(delay)
|
||||||
|
if delay < 0 or delay > 60:
|
||||||
|
logger.error("delay must be between 0 and 60 seconds")
|
||||||
|
return
|
||||||
|
except ValueError:
|
||||||
|
logger.error("delay must be an integer")
|
||||||
|
return
|
||||||
|
|
||||||
|
config_data = {
|
||||||
|
"handle": handle,
|
||||||
|
"password": password,
|
||||||
|
"batch_size": batch_size,
|
||||||
|
"delay": delay,
|
||||||
|
"verbose": verbose
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(self.config_file, "w") as f:
|
||||||
|
yaml.dump(config_data, f, default_flow_style=False)
|
||||||
|
except (IOError, OSError) as e:
|
||||||
|
logger.error(f"Failed to save configuration: {e}")
|
||||||
|
return
|
||||||
|
|
||||||
|
logger.info(f"Configuration saved to {self.config_file}")
|
||||||
|
|
||||||
|
def load(self) -> dict:
|
||||||
|
if not self.exists():
|
||||||
|
raise FileNotFoundError(
|
||||||
|
f"Configuration file not found: {self.config_file}")
|
||||||
|
try:
|
||||||
|
with open(self.config_file, "r") as f:
|
||||||
|
config_data = yaml.safe_load(f)
|
||||||
|
if config_data is None:
|
||||||
|
raise ValueError("Configuration file is empty or invalid")
|
||||||
|
return config_data
|
||||||
|
except (IOError, OSError) as e:
|
||||||
|
raise ValueError(
|
||||||
|
f"Failed to read configuration file: {e}") from e
|
||||||
|
except yaml.YAMLError as e:
|
||||||
|
raise ValueError(
|
||||||
|
f"Invalid YAML in configuration file: {e}") from e
|
||||||
103
skywipe/logger.py
Normal file
103
skywipe/logger.py
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
"""Centralized logging module for Skywipe"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
|
class ProgressTracker:
|
||||||
|
def __init__(self, operation: str = "Processing"):
|
||||||
|
self.current = 0
|
||||||
|
self.operation = operation
|
||||||
|
|
||||||
|
def update(self, count: int = 1):
|
||||||
|
self.current += count
|
||||||
|
|
||||||
|
def batch(self, batch_num: int, batch_size: int, total_batches: Optional[int] = None):
|
||||||
|
logger = logging.getLogger("skywipe.progress")
|
||||||
|
if total_batches:
|
||||||
|
logger.info(
|
||||||
|
f"{self.operation} - batch {batch_num}/{total_batches} ({batch_size} items)"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.info(
|
||||||
|
f"{self.operation} - batch {batch_num} ({batch_size} items)")
|
||||||
|
|
||||||
|
|
||||||
|
class LevelFilter(logging.Filter):
|
||||||
|
def __init__(self, min_level: int, max_level: int):
|
||||||
|
super().__init__()
|
||||||
|
self.min_level = min_level
|
||||||
|
self.max_level = max_level
|
||||||
|
|
||||||
|
def filter(self, record: logging.LogRecord) -> bool:
|
||||||
|
return self.min_level <= record.levelno <= self.max_level
|
||||||
|
|
||||||
|
|
||||||
|
def setup_logger(verbose: bool = False, log_file: Optional[Path] = None) -> logging.Logger:
|
||||||
|
logger = logging.getLogger("skywipe")
|
||||||
|
target_level = logging.DEBUG if verbose else logging.INFO
|
||||||
|
logger.setLevel(target_level)
|
||||||
|
|
||||||
|
info_handler = None
|
||||||
|
error_handler = None
|
||||||
|
file_handlers = []
|
||||||
|
|
||||||
|
for handler in logger.handlers:
|
||||||
|
if isinstance(handler, logging.StreamHandler):
|
||||||
|
if handler.stream == sys.stdout:
|
||||||
|
info_handler = handler
|
||||||
|
elif handler.stream == sys.stderr:
|
||||||
|
error_handler = handler
|
||||||
|
elif isinstance(handler, logging.FileHandler):
|
||||||
|
file_handlers.append(handler)
|
||||||
|
|
||||||
|
formatter = logging.Formatter(fmt="%(levelname)s: %(message)s")
|
||||||
|
|
||||||
|
if info_handler is None:
|
||||||
|
info_handler = logging.StreamHandler(sys.stdout)
|
||||||
|
info_handler.addFilter(LevelFilter(logging.DEBUG, logging.INFO))
|
||||||
|
info_handler.setFormatter(formatter)
|
||||||
|
logger.addHandler(info_handler)
|
||||||
|
info_handler.setLevel(target_level)
|
||||||
|
|
||||||
|
if error_handler is None:
|
||||||
|
error_handler = logging.StreamHandler(sys.stderr)
|
||||||
|
error_handler.setLevel(logging.WARNING)
|
||||||
|
error_handler.setFormatter(formatter)
|
||||||
|
logger.addHandler(error_handler)
|
||||||
|
|
||||||
|
if log_file:
|
||||||
|
if not file_handlers:
|
||||||
|
log_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
file_handler = logging.FileHandler(log_file, encoding="utf-8")
|
||||||
|
file_handler.setLevel(logging.DEBUG)
|
||||||
|
file_formatter = logging.Formatter(
|
||||||
|
fmt="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
||||||
|
datefmt="%Y-%m-%d %H:%M:%S"
|
||||||
|
)
|
||||||
|
file_handler.setFormatter(file_formatter)
|
||||||
|
logger.addHandler(file_handler)
|
||||||
|
else:
|
||||||
|
for handler in file_handlers:
|
||||||
|
handler.close()
|
||||||
|
logger.removeHandler(handler)
|
||||||
|
|
||||||
|
return logger
|
||||||
|
|
||||||
|
|
||||||
|
def get_logger() -> logging.Logger:
|
||||||
|
return logging.getLogger("skywipe")
|
||||||
|
|
||||||
|
|
||||||
|
def handle_error(error: Exception, logger: logging.Logger, exit_on_error: bool = False) -> None:
|
||||||
|
if isinstance(error, ValueError):
|
||||||
|
logger.error(f"{error}")
|
||||||
|
else:
|
||||||
|
logger.error(f"Unexpected error: {error}", exc_info=True)
|
||||||
|
|
||||||
|
if exit_on_error:
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
raise error
|
||||||
207
skywipe/operations.py
Normal file
207
skywipe/operations.py
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
"""Shared operation utilities and strategies for Skywipe"""
|
||||||
|
|
||||||
|
import time
|
||||||
|
from typing import Callable, Optional, Any
|
||||||
|
from atproto import models
|
||||||
|
|
||||||
|
from .auth import Auth
|
||||||
|
from .configure import Configuration
|
||||||
|
from .logger import get_logger, ProgressTracker
|
||||||
|
|
||||||
|
|
||||||
|
class OperationContext:
|
||||||
|
def __init__(self, client=None, config_data=None):
|
||||||
|
self.logger = get_logger()
|
||||||
|
|
||||||
|
if client is not None:
|
||||||
|
self.client = client
|
||||||
|
self.did = client.me.did
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
self.auth = Auth()
|
||||||
|
self.client = self.auth.login()
|
||||||
|
self.did = self.client.me.did
|
||||||
|
except (ValueError, FileNotFoundError) as e:
|
||||||
|
self.logger.error(f"Configuration error: {e}")
|
||||||
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error(
|
||||||
|
f"Unexpected error during initialization: {e}", exc_info=True)
|
||||||
|
raise ValueError(
|
||||||
|
f"Failed to initialize operation context: {e}") from e
|
||||||
|
|
||||||
|
if config_data is not None:
|
||||||
|
self.config_data = config_data
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
self.config = Configuration()
|
||||||
|
self.config_data = self.config.load()
|
||||||
|
except (ValueError, FileNotFoundError) as e:
|
||||||
|
self.logger.error(f"Configuration error: {e}")
|
||||||
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error(
|
||||||
|
f"Unexpected error loading configuration: {e}", exc_info=True)
|
||||||
|
raise ValueError(
|
||||||
|
f"Failed to load configuration: {e}") from e
|
||||||
|
|
||||||
|
self.batch_size = self.config_data.get("batch_size", 10)
|
||||||
|
self.delay = self.config_data.get("delay", 1)
|
||||||
|
|
||||||
|
|
||||||
|
class BaseStrategy:
|
||||||
|
def get_cursor(self, response):
|
||||||
|
return response.cursor
|
||||||
|
|
||||||
|
|
||||||
|
class RecordDeletionStrategy(BaseStrategy):
|
||||||
|
def __init__(self, collection: str):
|
||||||
|
self.collection = collection
|
||||||
|
|
||||||
|
def fetch(self, context: OperationContext, cursor: Optional[str] = None):
|
||||||
|
list_params = models.ComAtprotoRepoListRecords.Params(
|
||||||
|
repo=context.did,
|
||||||
|
collection=self.collection,
|
||||||
|
limit=context.batch_size,
|
||||||
|
cursor=cursor
|
||||||
|
)
|
||||||
|
return context.client.com.atproto.repo.list_records(params=list_params)
|
||||||
|
|
||||||
|
def extract_items(self, response):
|
||||||
|
return response.records
|
||||||
|
|
||||||
|
def process_item(self, record, context: OperationContext):
|
||||||
|
record_uri = record.uri
|
||||||
|
rkey = record_uri.rsplit("/", 1)[-1]
|
||||||
|
delete_data = {
|
||||||
|
"repo": context.did,
|
||||||
|
"collection": self.collection,
|
||||||
|
"rkey": rkey
|
||||||
|
}
|
||||||
|
context.client.com.atproto.repo.delete_record(data=delete_data)
|
||||||
|
context.logger.debug(f"Deleted: {record_uri}")
|
||||||
|
|
||||||
|
|
||||||
|
class FeedStrategy(BaseStrategy):
|
||||||
|
def fetch(self, context: OperationContext, cursor: Optional[str] = None):
|
||||||
|
if cursor:
|
||||||
|
return context.client.get_author_feed(
|
||||||
|
actor=context.did, limit=context.batch_size, cursor=cursor
|
||||||
|
)
|
||||||
|
return context.client.get_author_feed(actor=context.did, limit=context.batch_size)
|
||||||
|
|
||||||
|
def extract_items(self, response):
|
||||||
|
return response.feed
|
||||||
|
|
||||||
|
def process_item(self, post, context: OperationContext):
|
||||||
|
uri = post.post.uri
|
||||||
|
context.client.delete_post(uri)
|
||||||
|
context.logger.debug(f"Deleted post: {uri}")
|
||||||
|
|
||||||
|
|
||||||
|
class BookmarkStrategy(BaseStrategy):
|
||||||
|
def fetch(self, context: OperationContext, cursor: Optional[str] = None):
|
||||||
|
get_params = models.AppBskyBookmarkGetBookmarks.Params(
|
||||||
|
limit=context.batch_size,
|
||||||
|
cursor=cursor
|
||||||
|
)
|
||||||
|
return context.client.app.bsky.bookmark.get_bookmarks(params=get_params)
|
||||||
|
|
||||||
|
def extract_items(self, response):
|
||||||
|
return response.bookmarks
|
||||||
|
|
||||||
|
def process_item(self, bookmark, context: OperationContext):
|
||||||
|
bookmark_uri = self._extract_bookmark_uri(bookmark)
|
||||||
|
if not bookmark_uri:
|
||||||
|
raise ValueError("Unable to find bookmark URI")
|
||||||
|
|
||||||
|
delete_data = models.AppBskyBookmarkDeleteBookmark.Data(
|
||||||
|
uri=bookmark_uri)
|
||||||
|
context.client.app.bsky.bookmark.delete_bookmark(data=delete_data)
|
||||||
|
context.logger.debug(f"Deleted bookmark: {bookmark_uri}")
|
||||||
|
|
||||||
|
def _extract_bookmark_uri(self, bookmark):
|
||||||
|
if hasattr(bookmark, "uri"):
|
||||||
|
return bookmark.uri
|
||||||
|
|
||||||
|
for attr_name in ("subject", "record", "post", "item"):
|
||||||
|
if hasattr(bookmark, attr_name):
|
||||||
|
nested = getattr(bookmark, attr_name)
|
||||||
|
if hasattr(nested, "uri"):
|
||||||
|
return nested.uri
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class Operation:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
operation_name: str,
|
||||||
|
strategy_type: str = "feed",
|
||||||
|
collection: Optional[str] = None,
|
||||||
|
filter_fn: Optional[Callable[[Any], bool]] = None,
|
||||||
|
client=None,
|
||||||
|
config_data=None
|
||||||
|
):
|
||||||
|
self.operation_name = operation_name
|
||||||
|
self.filter_fn = filter_fn
|
||||||
|
self._client = client
|
||||||
|
self._config_data = config_data
|
||||||
|
|
||||||
|
if strategy_type == "record":
|
||||||
|
if not collection:
|
||||||
|
raise ValueError("Collection is required for record strategy")
|
||||||
|
self.strategy = RecordDeletionStrategy(collection)
|
||||||
|
elif strategy_type == "bookmark":
|
||||||
|
self.strategy = BookmarkStrategy()
|
||||||
|
else:
|
||||||
|
self.strategy = FeedStrategy()
|
||||||
|
|
||||||
|
def run(self) -> int:
|
||||||
|
context = OperationContext(
|
||||||
|
client=self._client, config_data=self._config_data)
|
||||||
|
progress = ProgressTracker(operation=self.operation_name)
|
||||||
|
|
||||||
|
context.logger.info(
|
||||||
|
f"Starting {self.operation_name} with batch_size={context.batch_size}, delay={context.delay}s"
|
||||||
|
)
|
||||||
|
|
||||||
|
cursor = None
|
||||||
|
total_processed = 0
|
||||||
|
batch_num = 0
|
||||||
|
|
||||||
|
while True:
|
||||||
|
batch_num += 1
|
||||||
|
try:
|
||||||
|
response = self.strategy.fetch(context, cursor)
|
||||||
|
items = self.strategy.extract_items(response)
|
||||||
|
except Exception as e:
|
||||||
|
context.logger.error(
|
||||||
|
f"Error fetching items for batch {batch_num}: {e}", exc_info=True)
|
||||||
|
break
|
||||||
|
|
||||||
|
if not items:
|
||||||
|
break
|
||||||
|
|
||||||
|
progress.batch(batch_num, len(items))
|
||||||
|
|
||||||
|
for item in items:
|
||||||
|
if self.filter_fn and not self.filter_fn(item):
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.strategy.process_item(item, context)
|
||||||
|
total_processed += 1
|
||||||
|
progress.update(1)
|
||||||
|
except Exception as e:
|
||||||
|
context.logger.error(f"Error processing item: {e}")
|
||||||
|
|
||||||
|
cursor = self.strategy.get_cursor(response)
|
||||||
|
if not cursor:
|
||||||
|
break
|
||||||
|
|
||||||
|
if context.delay > 0:
|
||||||
|
time.sleep(context.delay)
|
||||||
|
|
||||||
|
context.logger.info(
|
||||||
|
f"{self.operation_name}: {total_processed} items processed.")
|
||||||
|
return total_processed
|
||||||
70
skywipe/post_analysis.py
Normal file
70
skywipe/post_analysis.py
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
"""Post analysis utilities for Skywipe"""
|
||||||
|
|
||||||
|
|
||||||
|
class PostAnalyzer:
|
||||||
|
MEDIA_TYPES = {
|
||||||
|
'app.bsky.embed.images',
|
||||||
|
'app.bsky.embed.video',
|
||||||
|
'app.bsky.embed.external'
|
||||||
|
}
|
||||||
|
|
||||||
|
QUOTE_TYPES = {
|
||||||
|
'app.bsky.embed.record',
|
||||||
|
'app.bsky.embed.recordWithMedia',
|
||||||
|
'app.bsky.embed.record_with_media'
|
||||||
|
}
|
||||||
|
|
||||||
|
QUOTE_WITH_MEDIA_TYPES = {
|
||||||
|
'app.bsky.embed.recordWithMedia',
|
||||||
|
'app.bsky.embed.record_with_media'
|
||||||
|
}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_embed(post_record):
|
||||||
|
return getattr(post_record, 'embed', None)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_embed_type_base(embed):
|
||||||
|
embed_type = getattr(embed, 'py_type', None)
|
||||||
|
if embed_type:
|
||||||
|
return embed_type.split('#')[0]
|
||||||
|
return None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def has_media(post_record):
|
||||||
|
embed = PostAnalyzer._get_embed(post_record)
|
||||||
|
if not embed:
|
||||||
|
return False
|
||||||
|
|
||||||
|
embed_type_base = PostAnalyzer._get_embed_type_base(embed)
|
||||||
|
if embed_type_base:
|
||||||
|
if embed_type_base in PostAnalyzer.MEDIA_TYPES:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if embed_type_base in PostAnalyzer.QUOTE_WITH_MEDIA_TYPES:
|
||||||
|
media = getattr(embed, 'media', None)
|
||||||
|
if media:
|
||||||
|
media_type_base = PostAnalyzer._get_embed_type_base(media)
|
||||||
|
if media_type_base and media_type_base in PostAnalyzer.MEDIA_TYPES:
|
||||||
|
return True
|
||||||
|
|
||||||
|
for attr in ('images', 'video', 'external'):
|
||||||
|
if hasattr(embed, attr):
|
||||||
|
return True
|
||||||
|
if isinstance(embed, dict) and embed.get(attr):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def has_quote(post_record):
|
||||||
|
embed = PostAnalyzer._get_embed(post_record)
|
||||||
|
if not embed:
|
||||||
|
return False
|
||||||
|
|
||||||
|
embed_type_base = PostAnalyzer._get_embed_type_base(embed)
|
||||||
|
if embed_type_base and embed_type_base in PostAnalyzer.QUOTE_TYPES:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return (hasattr(embed, 'record') or
|
||||||
|
(isinstance(embed, dict) and embed.get('record')))
|
||||||
31
skywipe/safeguard.py
Normal file
31
skywipe/safeguard.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
"""Safeguard module for Skywipe"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import logging
|
||||||
|
from typing import Optional
|
||||||
|
from .logger import get_logger
|
||||||
|
|
||||||
|
|
||||||
|
CONFIRM_RESPONSES = {"yes", "y"}
|
||||||
|
|
||||||
|
|
||||||
|
def require_confirmation(operation: str, skip_confirmation: bool = False, logger: Optional[logging.Logger] = None) -> None:
|
||||||
|
if skip_confirmation:
|
||||||
|
return
|
||||||
|
|
||||||
|
if logger is None:
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
logger.warning(f"This will {operation}")
|
||||||
|
logger.warning("This operation is DESTRUCTIVE and cannot be undone!")
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = input(
|
||||||
|
"Are you sure you want to continue? (y/N): ").strip().lower()
|
||||||
|
except (EOFError, KeyboardInterrupt):
|
||||||
|
logger.info("\nOperation cancelled.")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
if response not in CONFIRM_RESPONSES:
|
||||||
|
logger.info("Operation cancelled.")
|
||||||
|
sys.exit(0)
|
||||||
42
uv.lock
generated
42
uv.lock
generated
@@ -339,16 +339,56 @@ wheels = [
|
|||||||
{ url = "https://files.pythonhosted.org/packages/9f/ed/068e41660b832bb0b1aa5b58011dea2a3fe0ba7861ff38c4d4904c1c1a99/pydantic_core-2.41.5-cp314-cp314t-win_arm64.whl", hash = "sha256:35b44f37a3199f771c3eaa53051bc8a70cd7b54f333531c59e29fd4db5d15008", size = 1974769, upload-time = "2025-11-04T13:42:01.186Z" },
|
{ url = "https://files.pythonhosted.org/packages/9f/ed/068e41660b832bb0b1aa5b58011dea2a3fe0ba7861ff38c4d4904c1c1a99/pydantic_core-2.41.5-cp314-cp314t-win_arm64.whl", hash = "sha256:35b44f37a3199f771c3eaa53051bc8a70cd7b54f333531c59e29fd4db5d15008", size = 1974769, upload-time = "2025-11-04T13:42:01.186Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pyyaml"
|
||||||
|
version = "6.0.3"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d1/11/0fd08f8192109f7169db964b5707a2f1e8b745d4e239b784a5a1dd80d1db/pyyaml-6.0.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8", size = 181669, upload-time = "2025-09-25T21:32:23.673Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b1/16/95309993f1d3748cd644e02e38b75d50cbc0d9561d21f390a76242ce073f/pyyaml-6.0.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1", size = 173252, upload-time = "2025-09-25T21:32:25.149Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/50/31/b20f376d3f810b9b2371e72ef5adb33879b25edb7a6d072cb7ca0c486398/pyyaml-6.0.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c", size = 767081, upload-time = "2025-09-25T21:32:26.575Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/49/1e/a55ca81e949270d5d4432fbbd19dfea5321eda7c41a849d443dc92fd1ff7/pyyaml-6.0.3-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5", size = 841159, upload-time = "2025-09-25T21:32:27.727Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/74/27/e5b8f34d02d9995b80abcef563ea1f8b56d20134d8f4e5e81733b1feceb2/pyyaml-6.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6", size = 801626, upload-time = "2025-09-25T21:32:28.878Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f9/11/ba845c23988798f40e52ba45f34849aa8a1f2d4af4b798588010792ebad6/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6", size = 753613, upload-time = "2025-09-25T21:32:30.178Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3d/e0/7966e1a7bfc0a45bf0a7fb6b98ea03fc9b8d84fa7f2229e9659680b69ee3/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be", size = 794115, upload-time = "2025-09-25T21:32:31.353Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/de/94/980b50a6531b3019e45ddeada0626d45fa85cbe22300844a7983285bed3b/pyyaml-6.0.3-cp313-cp313-win32.whl", hash = "sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26", size = 137427, upload-time = "2025-09-25T21:32:32.58Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/97/c9/39d5b874e8b28845e4ec2202b5da735d0199dbe5b8fb85f91398814a9a46/pyyaml-6.0.3-cp313-cp313-win_amd64.whl", hash = "sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c", size = 154090, upload-time = "2025-09-25T21:32:33.659Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/73/e8/2bdf3ca2090f68bb3d75b44da7bbc71843b19c9f2b9cb9b0f4ab7a5a4329/pyyaml-6.0.3-cp313-cp313-win_arm64.whl", hash = "sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb", size = 140246, upload-time = "2025-09-25T21:32:34.663Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9d/8c/f4bd7f6465179953d3ac9bc44ac1a8a3e6122cf8ada906b4f96c60172d43/pyyaml-6.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac", size = 181814, upload-time = "2025-09-25T21:32:35.712Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bd/9c/4d95bb87eb2063d20db7b60faa3840c1b18025517ae857371c4dd55a6b3a/pyyaml-6.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310", size = 173809, upload-time = "2025-09-25T21:32:36.789Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/92/b5/47e807c2623074914e29dabd16cbbdd4bf5e9b2db9f8090fa64411fc5382/pyyaml-6.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7", size = 766454, upload-time = "2025-09-25T21:32:37.966Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/02/9e/e5e9b168be58564121efb3de6859c452fccde0ab093d8438905899a3a483/pyyaml-6.0.3-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788", size = 836355, upload-time = "2025-09-25T21:32:39.178Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/88/f9/16491d7ed2a919954993e48aa941b200f38040928474c9e85ea9e64222c3/pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5", size = 794175, upload-time = "2025-09-25T21:32:40.865Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/dd/3f/5989debef34dc6397317802b527dbbafb2b4760878a53d4166579111411e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764", size = 755228, upload-time = "2025-09-25T21:32:42.084Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d7/ce/af88a49043cd2e265be63d083fc75b27b6ed062f5f9fd6cdc223ad62f03e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35", size = 789194, upload-time = "2025-09-25T21:32:43.362Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/23/20/bb6982b26a40bb43951265ba29d4c246ef0ff59c9fdcdf0ed04e0687de4d/pyyaml-6.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac", size = 156429, upload-time = "2025-09-25T21:32:57.844Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f4/f4/a4541072bb9422c8a883ab55255f918fa378ecf083f5b85e87fc2b4eda1b/pyyaml-6.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3", size = 143912, upload-time = "2025-09-25T21:32:59.247Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7c/f9/07dd09ae774e4616edf6cda684ee78f97777bdd15847253637a6f052a62f/pyyaml-6.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3", size = 189108, upload-time = "2025-09-25T21:32:44.377Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4e/78/8d08c9fb7ce09ad8c38ad533c1191cf27f7ae1effe5bb9400a46d9437fcf/pyyaml-6.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba", size = 183641, upload-time = "2025-09-25T21:32:45.407Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7b/5b/3babb19104a46945cf816d047db2788bcaf8c94527a805610b0289a01c6b/pyyaml-6.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c", size = 831901, upload-time = "2025-09-25T21:32:48.83Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8b/cc/dff0684d8dc44da4d22a13f35f073d558c268780ce3c6ba1b87055bb0b87/pyyaml-6.0.3-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702", size = 861132, upload-time = "2025-09-25T21:32:50.149Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b1/5e/f77dc6b9036943e285ba76b49e118d9ea929885becb0a29ba8a7c75e29fe/pyyaml-6.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c", size = 839261, upload-time = "2025-09-25T21:32:51.808Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ce/88/a9db1376aa2a228197c58b37302f284b5617f56a5d959fd1763fb1675ce6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065", size = 805272, upload-time = "2025-09-25T21:32:52.941Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/da/92/1446574745d74df0c92e6aa4a7b0b3130706a4142b2d1a5869f2eaa423c6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65", size = 829923, upload-time = "2025-09-25T21:32:54.537Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f0/7a/1c7270340330e575b92f397352af856a8c06f230aa3e76f86b39d01b416a/pyyaml-6.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9", size = 174062, upload-time = "2025-09-25T21:32:55.767Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "skywipe"
|
name = "skywipe"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = { virtual = "." }
|
source = { virtual = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "atproto" },
|
{ name = "atproto" },
|
||||||
|
{ name = "pyyaml" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
requires-dist = [{ name = "atproto", specifier = ">=0.0.65" }]
|
requires-dist = [
|
||||||
|
{ name = "atproto", specifier = ">=0.0.65" },
|
||||||
|
{ name = "pyyaml", specifier = ">=6.0" },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typing-extensions"
|
name = "typing-extensions"
|
||||||
|
|||||||
Reference in New Issue
Block a user