-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
69 lines (52 loc) · 1.76 KB
/
Copy pathutils.py
File metadata and controls
69 lines (52 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
"""
Utility Module for GitHub Repository Analyzer
Contains utility functions and configuration.
"""
import os
import sys
import warnings
import urllib3
def setup_ssl_warnings(verify_ssl: bool) -> None:
"""
Configure SSL warning handling.
Args:
verify_ssl: Whether SSL verification is enabled
"""
if not verify_ssl:
# Suppress SSL warnings when verification is disabled
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
warnings.filterwarnings('ignore', message='Unverified HTTPS request')
def get_env_variables() -> tuple:
"""
Get GitHub token and organization from environment variables.
Returns:
Tuple of (token, org) from environment variables
"""
token = os.getenv('GITHUB_TOKEN')
org = os.getenv('GITHUB_ORG')
return token, org
def validate_required_args(token: str, org: str) -> None:
"""
Validate that required arguments are provided.
Args:
token: GitHub token
org: GitHub organization name
Raises:
SystemExit: If required arguments are missing
"""
if not token:
print("Error: GitHub token is required. Use --token argument or set GITHUB_TOKEN environment variable.")
sys.exit(1)
if not org:
print("Error: GitHub organization is required. Use --org argument or set GITHUB_ORG environment variable.")
sys.exit(1)
def should_show_progress(no_progress_flag: bool) -> bool:
"""
Determine if progress bar should be shown.
Args:
no_progress_flag: Whether --no-progress flag was set
Returns:
Boolean indicating if progress should be shown
"""
return sys.stdout.isatty() and not no_progress_flag