Open-AutoTools 0.0.3rc2__py3-none-any.whl → 0.0.3rc3__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.
@@ -0,0 +1,76 @@
1
+ import click
2
+ import base64
3
+ from .core import generate_password, generate_encryption_key, analyze_password_strength
4
+ from ..utils.loading import LoadingAnimation
5
+ from ..utils.updates import check_for_updates
6
+
7
+ @click.command()
8
+ @click.option('--length', '-l', default=12, help='Password length (default: 12)')
9
+ @click.option('--no-uppercase', '-u', is_flag=True, help='Exclude uppercase letters')
10
+ @click.option('--no-numbers', '-n', is_flag=True, help='Exclude numbers')
11
+ @click.option('--no-special', '-s', is_flag=True, help='Exclude special characters')
12
+ @click.option('--min-special', '-m', default=1, help='Minimum number of special characters')
13
+ @click.option('--min-numbers', '-d', default=1, help='Minimum number of numbers')
14
+ @click.option('--analyze', '-a', is_flag=True, help='Analyze password strength')
15
+ @click.option('--gen-key', '-g', is_flag=True, help='Generate encryption key')
16
+ @click.option('--password-key', '-p', help='Generate key from password')
17
+ def autopassword(length, no_uppercase, no_numbers, no_special,
18
+ min_special, min_numbers, analyze, gen_key, password_key):
19
+ """Generate secure passwords and encryption keys."""
20
+
21
+ def show_analysis(text, prefix=""):
22
+ """Helper function to show password/key analysis"""
23
+ if analyze:
24
+ with LoadingAnimation():
25
+ analysis = analyze_password_strength(text)
26
+ click.echo(f"\n{prefix}Strength Analysis:")
27
+ click.echo(f"Strength: {analysis['strength']}")
28
+ click.echo(f"Score: {analysis['score']}/5")
29
+ if analysis['suggestions']:
30
+ click.echo("\nSuggestions for improvement:")
31
+ for suggestion in analysis['suggestions']:
32
+ click.echo(f"- {suggestion}")
33
+
34
+ # GENERATE KEY
35
+ if gen_key:
36
+ with LoadingAnimation():
37
+ key = generate_encryption_key()
38
+ key_str = key.decode()
39
+ click.echo(f"Encryption Key: {key_str}")
40
+ if analyze:
41
+ show_analysis(key_str, "Key ")
42
+ return
43
+
44
+ # GENERATE KEY FROM PASSWORD
45
+ if password_key:
46
+ with LoadingAnimation():
47
+ key, salt = generate_encryption_key(password_key)
48
+ key_str = key.decode()
49
+ click.echo(f"Derived Key: {key_str}")
50
+ click.echo(f"Salt: {base64.b64encode(salt).decode()}")
51
+ if analyze:
52
+ click.echo("\nAnalyzing source password:")
53
+ show_analysis(password_key, "Password ")
54
+ click.echo("\nAnalyzing generated key:")
55
+ show_analysis(key_str, "Key ")
56
+ return
57
+
58
+ # GENERATE PASSWORD
59
+ with LoadingAnimation():
60
+ password = generate_password(
61
+ length=length,
62
+ use_uppercase=not no_uppercase,
63
+ use_numbers=not no_numbers,
64
+ use_special=not no_special,
65
+ min_special=min_special,
66
+ min_numbers=min_numbers,
67
+ )
68
+
69
+ # SHOW PASSWORD
70
+ click.echo(f"Generated Password: {password}")
71
+ show_analysis(password, "Password ")
72
+
73
+ # UPDATE CHECK AT THE END
74
+ update_msg = check_for_updates()
75
+ if update_msg:
76
+ click.echo(update_msg)
@@ -21,6 +21,7 @@ def generate_password(length=12, use_uppercase=True, use_numbers=True, use_speci
21
21
 
22
22
  # ENSURE MINIMUM REQUIREMENTS
23
23
  password = []
24
+ password.append(secrets.choice(lowercase))
24
25
  if use_uppercase:
25
26
  password.append(secrets.choice(uppercase))
26
27
  if use_numbers:
@@ -0,0 +1,123 @@
1
+ import click
2
+ import json as json_module
3
+ from .core import SpellChecker
4
+ from ..utils.loading import LoadingAnimation
5
+ from ..utils.updates import check_for_updates
6
+
7
+ @click.command()
8
+ @click.argument('texts', nargs=-1)
9
+ @click.option('--lang', '-l', default='auto', help='Language code (auto for detection)')
10
+ @click.option('--fix', '-f', is_flag=True, help='Auto-fix text and copy to clipboard')
11
+ @click.option('--copy', '-c', is_flag=True, help='Copy result to clipboard')
12
+ @click.option('--list-languages', is_flag=True, help='List supported languages')
13
+ @click.option('--json', '-j', is_flag=True, help='Output results as JSON')
14
+ @click.option('--ignore', '-i', multiple=True,
15
+ type=click.Choice(['spelling', 'grammar', 'style', 'punctuation']),
16
+ help='Error types to ignore')
17
+ @click.option('--interactive', '-n', is_flag=True,
18
+ help='Interactive mode - confirm each correction')
19
+ @click.option('--output', '-o', type=click.Path(),
20
+ help='Save corrections to file')
21
+ def autospell(texts: tuple, lang: str, fix: bool, copy: bool, list_languages: bool,
22
+ json: bool, ignore: tuple, interactive: bool, output: str):
23
+ """Check and fix text for spelling, grammar, style, and punctuation errors.
24
+
25
+ Provides comprehensive text analysis with support for multiple languages,
26
+ interactive corrections, and various output formats (text/JSON).
27
+ Can ignore specific error types: spelling, grammar, style, or punctuation."""
28
+ checker = SpellChecker()
29
+
30
+ # LIST ALL SUPPORTED LANGUAGES
31
+ if list_languages:
32
+ with LoadingAnimation():
33
+ languages = checker.get_supported_languages()
34
+ if json:
35
+ result = {'languages': languages}
36
+ click.echo(json_module.dumps(result, indent=2))
37
+ else:
38
+ click.echo("\nSupported Languages:")
39
+ for lang in languages:
40
+ click.echo(f"{lang['code']:<8} {lang['name']}")
41
+ return
42
+
43
+ # --CHECK AND FIX SPELLING/GRAMMAR IN TEXT
44
+ for text in texts:
45
+ if not text:
46
+ click.echo("Error: Please provide text to check")
47
+ continue
48
+
49
+ # --FIX OPTION: SPELLING/GRAMMAR IN TEXT
50
+ if fix:
51
+ # CORRECT TEXT WITH SPELL CHECKER
52
+ with LoadingAnimation():
53
+ corrected = checker.fix_text(text, lang, copy_to_clipboard=True,
54
+ ignore=ignore, interactive=interactive)
55
+ result = {'corrected_text': corrected}
56
+
57
+ # OUTPUT RESULTS AS JSON
58
+ if json:
59
+ click.echo(json_module.dumps(result, indent=2))
60
+ else:
61
+ # LANGUAGE INFORMATION
62
+ with LoadingAnimation():
63
+ check_result = checker.check_text(text, lang)
64
+ lang_info = check_result['language']
65
+ click.echo(f"\nLanguage detected: {lang_info['name']} ({lang_info['code']})")
66
+ click.echo(f"Confidence: {lang_info['confidence']:.2%}")
67
+ click.echo("\nCorrected text (copied to clipboard):")
68
+ click.echo(corrected)
69
+
70
+ # SAVE CORRECTIONS TO FILE
71
+ if output:
72
+ with open(output, 'w', encoding='utf-8') as f:
73
+ if json:
74
+ json_module.dump(result, f, indent=2)
75
+ else:
76
+ f.write(corrected)
77
+ else:
78
+ # CHECK SPELLING/GRAMMAR IN TEXT
79
+ with LoadingAnimation():
80
+ check_result = checker.check_text(text, lang)
81
+
82
+ # OUTPUT RESULTS AS JSON
83
+ if json:
84
+ click.echo(json_module.dumps(check_result, indent=2))
85
+ else:
86
+ lang_info = check_result['language']
87
+ click.echo(f"\nLanguage detected: {lang_info['name']} ({lang_info['code']})")
88
+ click.echo(f"Confidence: {lang_info['confidence']:.2%}")
89
+ click.echo(f"Total errors found: {check_result['statistics']['total_errors']}")
90
+
91
+ # CORRECTIONS SUGGESTED
92
+ if check_result['corrections']:
93
+ click.echo("\nCorrections suggested:")
94
+ for i, corr in enumerate(check_result['corrections'], 1):
95
+ click.echo(f"\n{i}. [{corr['severity'].upper()}] {corr['message']}")
96
+ click.echo(f" Context: {corr['context']}")
97
+ if corr['replacements']:
98
+ click.echo(f" Suggestions: {', '.join(corr['replacements'][:3])}")
99
+
100
+ # SAVE CHECK RESULT TO FILE
101
+ if output:
102
+ with open(output, 'w', encoding='utf-8') as f:
103
+ if json:
104
+ json_module.dump(check_result, f, indent=2)
105
+ else:
106
+ # WRITE A HUMAN-READABLE REPORT
107
+ f.write(f"Language: {lang_info['name']} ({lang_info['code']})\n")
108
+ f.write(f"Confidence: {lang_info['confidence']:.2%}\n")
109
+ f.write(f"Total errors: {check_result['statistics']['total_errors']}\n\n")
110
+
111
+ # CORRECTIONS SUGGESTED
112
+ if check_result['corrections']:
113
+ f.write("Corrections suggested:\n")
114
+ for i, corr in enumerate(check_result['corrections'], 1):
115
+ f.write(f"\n{i}. [{corr['severity'].upper()}] {corr['message']}\n")
116
+ f.write(f" Context: {corr['context']}\n")
117
+ if corr['replacements']:
118
+ f.write(f" Suggestions: {', '.join(corr['replacements'][:3])}\n")
119
+
120
+ # UPDATE CHECK AT THE END
121
+ update_msg = check_for_updates()
122
+ if update_msg:
123
+ click.echo(update_msg)
@@ -0,0 +1,42 @@
1
+ import click
2
+ from .core import translate_text, get_supported_languages
3
+ from ..utils.loading import LoadingAnimation
4
+ from ..utils.updates import check_for_updates
5
+
6
+ @click.command()
7
+ @click.argument('text', required=False)
8
+ @click.option('--to', default='en', help='Target language (default: en)')
9
+ @click.option('--from', 'from_lang', help='Source language (default: auto-detect)')
10
+ @click.option('--list-languages', is_flag=True, help='List all supported languages')
11
+ @click.option('--copy', is_flag=True, help='Copy translation to clipboard')
12
+ @click.option('--detect', is_flag=True, help='Show detected source language')
13
+ @click.option('--output', '-o', type=click.Path(), help='Save translation to file')
14
+ def autotranslate(text: str, to: str, from_lang: str, list_languages: bool,
15
+ copy: bool, detect: bool, output: str):
16
+ """Translate text to specified language.
17
+
18
+ Supports automatic language detection, multiple target languages,
19
+ clipboard operations and file output. Use --list-languages to see
20
+ all supported language codes."""
21
+ # LIST ALL SUPPORTED LANGUAGES
22
+ if list_languages:
23
+ with LoadingAnimation():
24
+ click.echo("\nSupported Languages:")
25
+ for code, name in get_supported_languages().items():
26
+ click.echo(f"{code:<8} {name}")
27
+ return
28
+
29
+ # CHECK IF TEXT IS PROVIDED
30
+ if not text:
31
+ click.echo("Error: Please provide text to translate")
32
+ return
33
+
34
+ with LoadingAnimation():
35
+ result = translate_text(text, to_lang=to, from_lang=from_lang,
36
+ copy=copy, detect_lang=detect, output=output)
37
+ click.echo(result)
38
+
39
+ # UPDATE CHECK AT THE END
40
+ update_msg = check_for_updates()
41
+ if update_msg:
42
+ click.echo(update_msg)