mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-22 05:14:59 +00:00
style: Format code according to linter rules
This commit is contained in:
parent
8c78e09f03
commit
aad6c63206
1 changed files with 40 additions and 25 deletions
|
@ -29,8 +29,7 @@ def get_downloads_from_bigquery(credentials_path=None, package_name="aider-chat"
|
||||||
credentials = None
|
credentials = None
|
||||||
if credentials_path:
|
if credentials_path:
|
||||||
credentials = service_account.Credentials.from_service_account_file(
|
credentials = service_account.Credentials.from_service_account_file(
|
||||||
credentials_path,
|
credentials_path, scopes=["https://www.googleapis.com/auth/cloud-platform"]
|
||||||
scopes=["https://www.googleapis.com/auth/cloud-platform"]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create a client
|
# Create a client
|
||||||
|
@ -57,7 +56,9 @@ def get_downloads_from_bigquery(credentials_path=None, package_name="aider-chat"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_total_downloads(api_key=None, package_name="aider-chat", use_bigquery=False, credentials_path=None):
|
def get_total_downloads(
|
||||||
|
api_key=None, package_name="aider-chat", use_bigquery=False, credentials_path=None
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Fetch total downloads for a Python package
|
Fetch total downloads for a Python package
|
||||||
|
|
||||||
|
@ -216,7 +217,10 @@ def get_badges_md():
|
||||||
api_key = os.environ.get("PEPY_API_KEY")
|
api_key = os.environ.get("PEPY_API_KEY")
|
||||||
if not api_key:
|
if not api_key:
|
||||||
print(
|
print(
|
||||||
"API key not provided and BigQuery not enabled. Please set PEPY_API_KEY environment variable",
|
(
|
||||||
|
"API key not provided and BigQuery not enabled. Please set PEPY_API_KEY"
|
||||||
|
" environment variable"
|
||||||
|
),
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -251,7 +255,10 @@ def get_badges_html():
|
||||||
api_key = os.environ.get("PEPY_API_KEY")
|
api_key = os.environ.get("PEPY_API_KEY")
|
||||||
if not api_key:
|
if not api_key:
|
||||||
print(
|
print(
|
||||||
"API key not provided and BigQuery not enabled. Please set PEPY_API_KEY environment variable",
|
(
|
||||||
|
"API key not provided and BigQuery not enabled. Please set PEPY_API_KEY"
|
||||||
|
" environment variable"
|
||||||
|
),
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -327,17 +334,21 @@ def main():
|
||||||
)
|
)
|
||||||
parser.add_argument("--markdown", action="store_true", help="Generate markdown badges block")
|
parser.add_argument("--markdown", action="store_true", help="Generate markdown badges block")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use-bigquery", action="store_true",
|
"--use-bigquery",
|
||||||
help="Use BigQuery to fetch download statistics instead of pepy.tech"
|
action="store_true",
|
||||||
|
help="Use BigQuery to fetch download statistics instead of pepy.tech",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--credentials-path",
|
"--credentials-path", help="Path to Google Cloud service account credentials JSON file"
|
||||||
help="Path to Google Cloud service account credentials JSON file"
|
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Determine whether to use BigQuery
|
# Determine whether to use BigQuery
|
||||||
use_bigquery = args.use_bigquery or os.environ.get("USE_BIGQUERY", "false").lower() in ("true", "1", "yes")
|
use_bigquery = args.use_bigquery or os.environ.get("USE_BIGQUERY", "false").lower() in (
|
||||||
|
"true",
|
||||||
|
"1",
|
||||||
|
"yes",
|
||||||
|
)
|
||||||
credentials_path = args.credentials_path or os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")
|
credentials_path = args.credentials_path or os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")
|
||||||
|
|
||||||
# Check for required parameters
|
# Check for required parameters
|
||||||
|
@ -347,15 +358,19 @@ def main():
|
||||||
api_key = args.api_key or os.environ.get("PEPY_API_KEY")
|
api_key = args.api_key or os.environ.get("PEPY_API_KEY")
|
||||||
if not api_key:
|
if not api_key:
|
||||||
print(
|
print(
|
||||||
"API key not provided and BigQuery not enabled. Please set PEPY_API_KEY environment variable, "
|
(
|
||||||
"use --api-key, or enable BigQuery with --use-bigquery",
|
"API key not provided and BigQuery not enabled. Please set PEPY_API_KEY"
|
||||||
|
" environment variable, use --api-key, or enable BigQuery with --use-bigquery"
|
||||||
|
),
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
elif use_bigquery and not credentials_path and not args.credentials_path:
|
elif use_bigquery and not credentials_path and not args.credentials_path:
|
||||||
print(
|
print(
|
||||||
"BigQuery enabled but no credentials provided. Please set GOOGLE_APPLICATION_CREDENTIALS "
|
(
|
||||||
"environment variable or use --credentials-path",
|
"BigQuery enabled but no credentials provided. Please set"
|
||||||
|
" GOOGLE_APPLICATION_CREDENTIALS environment variable or use --credentials-path"
|
||||||
|
),
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
# Continue execution - BigQuery might work without explicit credentials in some environments
|
# Continue execution - BigQuery might work without explicit credentials in some environments
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue