calwash 0.3.0__tar.gz

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.
Files changed (49) hide show
  1. calwash-0.3.0/LICENSE +21 -0
  2. calwash-0.3.0/PKG-INFO +232 -0
  3. calwash-0.3.0/README.md +206 -0
  4. calwash-0.3.0/calwash/__init__.py +34 -0
  5. calwash-0.3.0/calwash/__main__.py +6 -0
  6. calwash-0.3.0/calwash/ai.py +706 -0
  7. calwash-0.3.0/calwash/auth.py +235 -0
  8. calwash-0.3.0/calwash/cleaner.py +694 -0
  9. calwash-0.3.0/calwash/cli.py +932 -0
  10. calwash-0.3.0/calwash/data/__init__.py +1 -0
  11. calwash-0.3.0/calwash/data/credentials.json +1 -0
  12. calwash-0.3.0/calwash/dates.py +600 -0
  13. calwash-0.3.0/calwash/engine/__init__.py +0 -0
  14. calwash-0.3.0/calwash/engine/patterns/__init__.py +56 -0
  15. calwash-0.3.0/calwash/engine/patterns/base.py +370 -0
  16. calwash-0.3.0/calwash/engine/patterns/compatibility.py +277 -0
  17. calwash-0.3.0/calwash/engine/patterns/detectors/__init__.py +0 -0
  18. calwash-0.3.0/calwash/engine/patterns/detectors/base_detector.py +152 -0
  19. calwash-0.3.0/calwash/engine/patterns/detectors/email_detector.py +81 -0
  20. calwash-0.3.0/calwash/engine/patterns/detectors/phone_detector.py +249 -0
  21. calwash-0.3.0/calwash/engine/patterns/detectors/ssn_detector.py +222 -0
  22. calwash-0.3.0/calwash/engine/patterns/registry/__init__.py +0 -0
  23. calwash-0.3.0/calwash/engine/patterns/registry/config_loader.py +474 -0
  24. calwash-0.3.0/calwash/engine/patterns/registry/pattern_registry.py +351 -0
  25. calwash-0.3.0/calwash/engine/patterns/services/__init__.py +0 -0
  26. calwash-0.3.0/calwash/engine/patterns/services/pattern_detection_service.py +373 -0
  27. calwash-0.3.0/calwash/engine/patterns/services/pattern_factory.py +330 -0
  28. calwash-0.3.0/calwash/engine/patterns/validators/__init__.py +0 -0
  29. calwash-0.3.0/calwash/engine/patterns/validators/bank_account_validator.py +227 -0
  30. calwash-0.3.0/calwash/engine/patterns/validators/base_validators.py +419 -0
  31. calwash-0.3.0/calwash/engine/patterns/validators/credit_card_validator.py +163 -0
  32. calwash-0.3.0/calwash/engine/patterns/validators/email_validator.py +232 -0
  33. calwash-0.3.0/calwash/patterns.py +462 -0
  34. calwash-0.3.0/calwash/providers/__init__.py +28 -0
  35. calwash-0.3.0/calwash/providers/apple.py +86 -0
  36. calwash-0.3.0/calwash/providers/base.py +66 -0
  37. calwash-0.3.0/calwash/providers/google.py +290 -0
  38. calwash-0.3.0/calwash/py.typed +0 -0
  39. calwash-0.3.0/calwash/redaction.py +79 -0
  40. calwash-0.3.0/calwash/restore.py +337 -0
  41. calwash-0.3.0/calwash/validators.py +305 -0
  42. calwash-0.3.0/calwash.egg-info/PKG-INFO +232 -0
  43. calwash-0.3.0/calwash.egg-info/SOURCES.txt +47 -0
  44. calwash-0.3.0/calwash.egg-info/dependency_links.txt +1 -0
  45. calwash-0.3.0/calwash.egg-info/entry_points.txt +2 -0
  46. calwash-0.3.0/calwash.egg-info/requires.txt +6 -0
  47. calwash-0.3.0/calwash.egg-info/top_level.txt +1 -0
  48. calwash-0.3.0/pyproject.toml +42 -0
  49. calwash-0.3.0/setup.cfg +4 -0
calwash-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Samuel Ahuno
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
calwash-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,232 @@
1
+ Metadata-Version: 2.4
2
+ Name: calwash
3
+ Version: 0.3.0
4
+ Summary: Redact sensitive data from your calendar events
5
+ Author-email: Samuel Ahuno <ekwame001@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/sahuno/calwash
8
+ Project-URL: Issues, https://github.com/sahuno/calwash/issues
9
+ Keywords: calendar,privacy,redaction,google-calendar,pii,sensitive-data
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: End Users/Desktop
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Security
16
+ Classifier: Topic :: Office/Business :: Scheduling
17
+ Requires-Python: >=3.12
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: google-api-python-client>=2.179.0
21
+ Requires-Dist: google-auth-oauthlib>=1.2.2
22
+ Provides-Extra: caldav
23
+ Requires-Dist: caldav>=1.3; extra == "caldav"
24
+ Requires-Dist: icalendar>=5.0; extra == "caldav"
25
+ Dynamic: license-file
26
+
27
+ # calwash
28
+
29
+ Redact sensitive data from your calendar events. Detect and remove PII (phone numbers, emails, SSNs, credit cards), medical terms, legal references, and more — with optional local AI detection that never sends your data to the cloud.
30
+
31
+ ## Install
32
+
33
+ ```bash
34
+ pipx install calwash
35
+ ```
36
+
37
+ Or with pip:
38
+
39
+ ```bash
40
+ pip install calwash
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ ```bash
46
+ # 1. Log in to your Google account (opens browser)
47
+ calwash login
48
+
49
+ # 2. Preview what would be redacted
50
+ calwash clean --dry-run
51
+
52
+ # 3. Apply redactions (creates backup first)
53
+ calwash clean
54
+ ```
55
+
56
+ ## What It Detects
57
+
58
+ **Regex (always on):**
59
+
60
+ | Pattern | Example | Replaced with |
61
+ |---|---|---|
62
+ | Email addresses | `john@example.com` | `[EMAIL REMOVED]` |
63
+ | Phone numbers | `555-123-4567` | `[PHONE REMOVED]` |
64
+ | Social Security Numbers | `123-45-6789` | `[SSN REMOVED]` |
65
+ | Credit card numbers | `4111-1111-1111-1111` | `[CARD REMOVED]` |
66
+ | URLs | `https://zoom.us/j/123` | `[URL REMOVED]` |
67
+ | Medical terms | `Dr. appointment at clinic` | `Private` |
68
+
69
+ **AI detection (opt-in, local only):**
70
+
71
+ | Category | Example |
72
+ |---|---|
73
+ | Medical | "Picking up lithium prescription" |
74
+ | Legal | "Meeting with divorce lawyer" |
75
+ | Financial | "Salary negotiation with HR" |
76
+ | Substance use | "AA meeting at St. Mark's Church" |
77
+ | Career | "Interview at Google" (optional) |
78
+ | Relationship | "Couples counseling" (optional) |
79
+ | Political | "Campaign fundraiser" (optional) |
80
+ | Religious | "Prayer group meeting" (optional) |
81
+
82
+ ## CLI Reference
83
+
84
+ ### Core Commands
85
+
86
+ ```bash
87
+ calwash login # Authenticate with Google
88
+ calwash clean --dry-run # Preview redactions
89
+ calwash clean # Apply redactions (backs up first)
90
+ calwash restore --dry-run # Preview restore from backup
91
+ calwash restore # Restore events from backup
92
+ calwash accounts # List saved accounts
93
+ ```
94
+
95
+ ### Date Filtering
96
+
97
+ ```bash
98
+ calwash clean --dry-run --days-back 30 # Last 30 days
99
+ calwash clean --dry-run --from-date 2025-01-01 --to-date 2025-12-31
100
+ calwash clean --dry-run --year 2024 # All of 2024
101
+ calwash clean --dry-run --month 2025-08 # August 2025
102
+ calwash clean --dry-run --from-date today --to-date next-month
103
+ ```
104
+
105
+ ### Redaction Levels
106
+
107
+ ```bash
108
+ calwash clean --dry-run --redaction-level coarse # Replace entire event content
109
+ calwash clean --dry-run --redaction-level medium # Replace only matched patterns (default)
110
+ ```
111
+
112
+ ### Multiple Accounts
113
+
114
+ ```bash
115
+ calwash login --account work # Add a second Google account
116
+ calwash clean --dry-run --account work # Use the work account
117
+ calwash accounts # List all accounts
118
+ ```
119
+
120
+ ### Multiple Providers
121
+
122
+ ```bash
123
+ calwash login # Google (default)
124
+ calwash login --provider apple # Apple iCloud (requires calwash[caldav])
125
+ calwash clean --dry-run --provider apple
126
+ ```
127
+
128
+ Install Apple Calendar support:
129
+
130
+ ```bash
131
+ pipx install calwash[caldav]
132
+ ```
133
+
134
+ ## AI Detection
135
+
136
+ calwash can use a local LLM via [ollama](https://ollama.ai) to catch sensitive content that regex patterns miss — things like "AA meeting" or "meeting with divorce lawyer" that don't contain obvious PII but are still private.
137
+
138
+ **All AI processing happens locally. Your calendar data never leaves your machine.**
139
+
140
+ ### Setup
141
+
142
+ ```bash
143
+ # Interactive setup — installs ollama + downloads a model
144
+ calwash ai setup
145
+
146
+ # Or set up manually
147
+ brew install ollama # macOS
148
+ ollama serve # Start the server
149
+ ollama pull phi4-mini # Download a model (2.5 GB)
150
+ ```
151
+
152
+ ### Usage
153
+
154
+ ```bash
155
+ calwash clean --dry-run --ai # Use default model
156
+ calwash clean --dry-run --ai --ai-model phi4-mini # Choose model
157
+ calwash clean --dry-run --ai --ai-categories medical,legal,substance_use
158
+ ```
159
+
160
+ ### Recommended Models
161
+
162
+ | Model | Size | Notes |
163
+ |---|---|---|
164
+ | phi4-mini | 2.5 GB | Fast, good accuracy (recommended) |
165
+ | llama3.2 | 2.0 GB | Lightweight default |
166
+ | llama3.1 | 4.7 GB | Best accuracy |
167
+ | gemma3n | 5.6 GB | Google, efficient on-device |
168
+ | nemotron-mini | 4.7 GB | Nvidia, strong reasoning |
169
+
170
+ Any ollama-compatible model works: `calwash clean --dry-run --ai --ai-model <name>`
171
+
172
+ ### AI Management
173
+
174
+ ```bash
175
+ calwash ai setup # Guided setup (install + model + test)
176
+ calwash ai setup --model llama3.1 # Install a specific model
177
+ calwash ai status # Check ollama + model readiness
178
+ calwash ai models # List recommended models with sizes
179
+ ```
180
+
181
+ ## How It Works
182
+
183
+ 1. **Backup** — calwash saves a full JSON backup of your events before any changes
184
+ 2. **Regex pass** — scans event summaries, descriptions, and locations for PII patterns with validation (Luhn checksum for credit cards, format checks for SSNs, etc.)
185
+ 3. **AI pass** (if `--ai`) — sends events to a local LLM to classify context-dependent sensitive content
186
+ 4. **Redact** — replaces matched text with tags like `[EMAIL REMOVED]` or `[SENSITIVE: MEDICAL]`
187
+ 5. **Update** — pushes cleaned events back to your calendar (or shows a dry-run preview)
188
+
189
+ ### Dry-Run Output
190
+
191
+ ```
192
+ CLEANING PREVIEW
193
+ ============================================================
194
+ User: you@gmail.com
195
+ Total events that would be modified: 96
196
+
197
+ Event 1:
198
+ Date: 2024-01-03T11:15:00-05:00
199
+ Description:
200
+ Original: Contact: john@example.com, Phone: 555-123-4567
201
+ Would change to: Contact: [EMAIL REMOVED], Phone: [PHONE REMOVED]
202
+ ```
203
+
204
+ ## Privacy
205
+
206
+ - **No cloud APIs for detection** — regex runs locally, AI runs on your machine via ollama
207
+ - **Google OAuth** is used only to access your calendar (read + write events)
208
+ - **Bundled OAuth credentials** — calwash ships with a Google OAuth client ID for convenience. You can use your own by placing `credentials.json` at `~/.calwash/credentials.json`
209
+ - **Tokens stored locally** at `~/.calwash/accounts/`
210
+
211
+ ## Data Storage
212
+
213
+ ```
214
+ ~/.calwash/
215
+ accounts/
216
+ default/
217
+ token.pickle # Google OAuth token
218
+ email.txt # Cached email address
219
+ work/
220
+ token.pickle
221
+ credentials.json # Optional: your own OAuth client ID
222
+ ```
223
+
224
+ ## Requirements
225
+
226
+ - Python 3.12+
227
+ - Google account (for Google Calendar)
228
+ - ollama (optional, for AI detection)
229
+
230
+ ## License
231
+
232
+ MIT
@@ -0,0 +1,206 @@
1
+ # calwash
2
+
3
+ Redact sensitive data from your calendar events. Detect and remove PII (phone numbers, emails, SSNs, credit cards), medical terms, legal references, and more — with optional local AI detection that never sends your data to the cloud.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pipx install calwash
9
+ ```
10
+
11
+ Or with pip:
12
+
13
+ ```bash
14
+ pip install calwash
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```bash
20
+ # 1. Log in to your Google account (opens browser)
21
+ calwash login
22
+
23
+ # 2. Preview what would be redacted
24
+ calwash clean --dry-run
25
+
26
+ # 3. Apply redactions (creates backup first)
27
+ calwash clean
28
+ ```
29
+
30
+ ## What It Detects
31
+
32
+ **Regex (always on):**
33
+
34
+ | Pattern | Example | Replaced with |
35
+ |---|---|---|
36
+ | Email addresses | `john@example.com` | `[EMAIL REMOVED]` |
37
+ | Phone numbers | `555-123-4567` | `[PHONE REMOVED]` |
38
+ | Social Security Numbers | `123-45-6789` | `[SSN REMOVED]` |
39
+ | Credit card numbers | `4111-1111-1111-1111` | `[CARD REMOVED]` |
40
+ | URLs | `https://zoom.us/j/123` | `[URL REMOVED]` |
41
+ | Medical terms | `Dr. appointment at clinic` | `Private` |
42
+
43
+ **AI detection (opt-in, local only):**
44
+
45
+ | Category | Example |
46
+ |---|---|
47
+ | Medical | "Picking up lithium prescription" |
48
+ | Legal | "Meeting with divorce lawyer" |
49
+ | Financial | "Salary negotiation with HR" |
50
+ | Substance use | "AA meeting at St. Mark's Church" |
51
+ | Career | "Interview at Google" (optional) |
52
+ | Relationship | "Couples counseling" (optional) |
53
+ | Political | "Campaign fundraiser" (optional) |
54
+ | Religious | "Prayer group meeting" (optional) |
55
+
56
+ ## CLI Reference
57
+
58
+ ### Core Commands
59
+
60
+ ```bash
61
+ calwash login # Authenticate with Google
62
+ calwash clean --dry-run # Preview redactions
63
+ calwash clean # Apply redactions (backs up first)
64
+ calwash restore --dry-run # Preview restore from backup
65
+ calwash restore # Restore events from backup
66
+ calwash accounts # List saved accounts
67
+ ```
68
+
69
+ ### Date Filtering
70
+
71
+ ```bash
72
+ calwash clean --dry-run --days-back 30 # Last 30 days
73
+ calwash clean --dry-run --from-date 2025-01-01 --to-date 2025-12-31
74
+ calwash clean --dry-run --year 2024 # All of 2024
75
+ calwash clean --dry-run --month 2025-08 # August 2025
76
+ calwash clean --dry-run --from-date today --to-date next-month
77
+ ```
78
+
79
+ ### Redaction Levels
80
+
81
+ ```bash
82
+ calwash clean --dry-run --redaction-level coarse # Replace entire event content
83
+ calwash clean --dry-run --redaction-level medium # Replace only matched patterns (default)
84
+ ```
85
+
86
+ ### Multiple Accounts
87
+
88
+ ```bash
89
+ calwash login --account work # Add a second Google account
90
+ calwash clean --dry-run --account work # Use the work account
91
+ calwash accounts # List all accounts
92
+ ```
93
+
94
+ ### Multiple Providers
95
+
96
+ ```bash
97
+ calwash login # Google (default)
98
+ calwash login --provider apple # Apple iCloud (requires calwash[caldav])
99
+ calwash clean --dry-run --provider apple
100
+ ```
101
+
102
+ Install Apple Calendar support:
103
+
104
+ ```bash
105
+ pipx install calwash[caldav]
106
+ ```
107
+
108
+ ## AI Detection
109
+
110
+ calwash can use a local LLM via [ollama](https://ollama.ai) to catch sensitive content that regex patterns miss — things like "AA meeting" or "meeting with divorce lawyer" that don't contain obvious PII but are still private.
111
+
112
+ **All AI processing happens locally. Your calendar data never leaves your machine.**
113
+
114
+ ### Setup
115
+
116
+ ```bash
117
+ # Interactive setup — installs ollama + downloads a model
118
+ calwash ai setup
119
+
120
+ # Or set up manually
121
+ brew install ollama # macOS
122
+ ollama serve # Start the server
123
+ ollama pull phi4-mini # Download a model (2.5 GB)
124
+ ```
125
+
126
+ ### Usage
127
+
128
+ ```bash
129
+ calwash clean --dry-run --ai # Use default model
130
+ calwash clean --dry-run --ai --ai-model phi4-mini # Choose model
131
+ calwash clean --dry-run --ai --ai-categories medical,legal,substance_use
132
+ ```
133
+
134
+ ### Recommended Models
135
+
136
+ | Model | Size | Notes |
137
+ |---|---|---|
138
+ | phi4-mini | 2.5 GB | Fast, good accuracy (recommended) |
139
+ | llama3.2 | 2.0 GB | Lightweight default |
140
+ | llama3.1 | 4.7 GB | Best accuracy |
141
+ | gemma3n | 5.6 GB | Google, efficient on-device |
142
+ | nemotron-mini | 4.7 GB | Nvidia, strong reasoning |
143
+
144
+ Any ollama-compatible model works: `calwash clean --dry-run --ai --ai-model <name>`
145
+
146
+ ### AI Management
147
+
148
+ ```bash
149
+ calwash ai setup # Guided setup (install + model + test)
150
+ calwash ai setup --model llama3.1 # Install a specific model
151
+ calwash ai status # Check ollama + model readiness
152
+ calwash ai models # List recommended models with sizes
153
+ ```
154
+
155
+ ## How It Works
156
+
157
+ 1. **Backup** — calwash saves a full JSON backup of your events before any changes
158
+ 2. **Regex pass** — scans event summaries, descriptions, and locations for PII patterns with validation (Luhn checksum for credit cards, format checks for SSNs, etc.)
159
+ 3. **AI pass** (if `--ai`) — sends events to a local LLM to classify context-dependent sensitive content
160
+ 4. **Redact** — replaces matched text with tags like `[EMAIL REMOVED]` or `[SENSITIVE: MEDICAL]`
161
+ 5. **Update** — pushes cleaned events back to your calendar (or shows a dry-run preview)
162
+
163
+ ### Dry-Run Output
164
+
165
+ ```
166
+ CLEANING PREVIEW
167
+ ============================================================
168
+ User: you@gmail.com
169
+ Total events that would be modified: 96
170
+
171
+ Event 1:
172
+ Date: 2024-01-03T11:15:00-05:00
173
+ Description:
174
+ Original: Contact: john@example.com, Phone: 555-123-4567
175
+ Would change to: Contact: [EMAIL REMOVED], Phone: [PHONE REMOVED]
176
+ ```
177
+
178
+ ## Privacy
179
+
180
+ - **No cloud APIs for detection** — regex runs locally, AI runs on your machine via ollama
181
+ - **Google OAuth** is used only to access your calendar (read + write events)
182
+ - **Bundled OAuth credentials** — calwash ships with a Google OAuth client ID for convenience. You can use your own by placing `credentials.json` at `~/.calwash/credentials.json`
183
+ - **Tokens stored locally** at `~/.calwash/accounts/`
184
+
185
+ ## Data Storage
186
+
187
+ ```
188
+ ~/.calwash/
189
+ accounts/
190
+ default/
191
+ token.pickle # Google OAuth token
192
+ email.txt # Cached email address
193
+ work/
194
+ token.pickle
195
+ credentials.json # Optional: your own OAuth client ID
196
+ ```
197
+
198
+ ## Requirements
199
+
200
+ - Python 3.12+
201
+ - Google account (for Google Calendar)
202
+ - ollama (optional, for AI detection)
203
+
204
+ ## License
205
+
206
+ MIT
@@ -0,0 +1,34 @@
1
+ """calwash - Google Calendar sensitive data cleaner.
2
+
3
+ A tool to detect and remove sensitive information (SSNs, phone numbers,
4
+ emails, credit cards, medical terms, etc.) from Google Calendar events.
5
+
6
+ Install: pipx install calwash
7
+ Usage: calwash clean --dry-run
8
+ """
9
+
10
+ __version__ = "0.3.0"
11
+
12
+ from calwash.redaction import RedactionLevel
13
+ from calwash.dates import DateRange, DateParsingError
14
+ from calwash.patterns import (
15
+ get_patterns_for_cleaning,
16
+ get_validated_patterns_for_cleaning,
17
+ clean_text_with_validation,
18
+ SensitivePattern,
19
+ )
20
+ from calwash.auth import setup_service
21
+ from calwash.cleaner import clean_event_data
22
+
23
+ __all__ = [
24
+ "__version__",
25
+ "RedactionLevel",
26
+ "DateRange",
27
+ "DateParsingError",
28
+ "get_patterns_for_cleaning",
29
+ "get_validated_patterns_for_cleaning",
30
+ "clean_text_with_validation",
31
+ "SensitivePattern",
32
+ "setup_service",
33
+ "clean_event_data",
34
+ ]
@@ -0,0 +1,6 @@
1
+ """Entry point for python -m calwash."""
2
+
3
+ from calwash.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ main()