feat: Add new gcloud commands, API clients, and third-party libraries across various services.

This commit is contained in:
2026-01-01 20:26:35 +01:00
parent 5e23cbece0
commit a19e592eb7
25221 changed files with 8324611 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
#!/usr/bin/env python
# PYTHON_ARGCOMPLETE_OK
# Copyright 2012-2013, Andrey Kislyuk and argcomplete contributors.
# Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info.
'''
Activate the generic bash-completion script for the argcomplete module.
'''
import os, sys, argparse, argcomplete, shutil, fileinput
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
dest_opt = parser.add_argument("--dest", default="/etc/bash_completion.d",
help="Specify the bash completion modules directory to install into")
parser.add_argument("--user", help="Install into user directory (~/.bash_completion.d/)", action='store_true')
parser.add_argument("--no-defaults", dest="use_defaults", action="store_false", default=True,
help="When no matches are generated, do not fallback to readline\'s default completion")
parser.add_argument("--complete-arguments", nargs=argparse.REMAINDER,
help="arguments to call complete with; use of this option discards default options")
argcomplete.autocomplete(parser)
args = parser.parse_args()
if args.user:
args.dest = os.path.expanduser("~/.bash_completion.d/")
if not os.path.exists(args.dest):
try:
os.mkdir(args.dest)
except Exception as e:
parser.error("Path {d} does not exist and could not be created: {e}".format(d=args.dest, e=e))
elif not os.path.exists(args.dest) and args.dest != '-':
if sys.platform == 'darwin' and args.dest == dest_opt.default and os.path.exists("/usr/local" + dest_opt.default):
args.dest = "/usr/local" + dest_opt.default
else:
parser.error("Path {d} does not exist".format(d=args.dest))
activator = os.path.join(os.path.dirname(argcomplete.__file__), 'bash_completion.d', 'python-argcomplete.sh')
if args.complete_arguments is None:
complete_options = '-o default -o bashdefault' if args.use_defaults else '-o bashdefault'
else:
complete_options = " ".join(args.complete_arguments)
complete_call = "complete{} -D -F _python_argcomplete_global".format(" " + complete_options if complete_options else "")
def replaceCompleteCall(line):
if line.startswith("complete") and "_python_argcomplete_global" in line:
return complete_call + ('\n' if line.endswith('\n') else '')
else:
return line
if args.dest == '-':
for l in open(activator):
sys.stdout.write(replaceCompleteCall(l))
else:
dest = os.path.join(args.dest, "python-argcomplete.sh")
sys.stdout.write("Installing bash completion script " + dest)
if not args.use_defaults:
sys.stdout.write(" without -o default")
elif args.complete_arguments:
sys.stdout.write(" with options: " + complete_options)
sys.stdout.write("\n")
try:
shutil.copy(activator, dest)
if not args.complete_arguments is None or not args.use_defaults:
for l in fileinput.input(dest, inplace=True):
# fileinput with inplace=True redirects stdout to the edited file
sys.stdout.write(replaceCompleteCall(l))
except Exception as e:
err = str(e)
if args.dest == dest_opt.default:
err += "\nPlease try --user to install into a user directory, or --dest to specify the bash completion modules directory"
parser.error(err)

View File

@@ -0,0 +1,55 @@
#!/usr/bin/env python
# Copyright 2012-2013, Andrey Kislyuk and argcomplete contributors.
# Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info.
'''
This script is part of the Python argcomplete package (https://github.com/kislyuk/argcomplete).
It is used to check if an EASY-INSTALL-SCRIPT wrapper redirects to a script that contains the string
"PYTHON_ARGCOMPLETE_OK". If you have enabled global completion in argcomplete, the completion hook will run it every
time you press <TAB> in your shell.
Usage:
python-argcomplete-check-easy-install-script <input executable file>
'''
import sys
if len(sys.argv) != 2:
sys.exit(__doc__)
sys.tracebacklimit = 0
with open(sys.argv[1]) as fh:
line1, head = fh.read(1024).split("\n", 1)[:2]
if line1.startswith('#') and ('py' in line1 or 'Py' in line1):
import re
lines = head.split("\n", 12)
for line in lines:
if line.startswith("# EASY-INSTALL-SCRIPT"):
import pkg_resources
dist, script = re.match("# EASY-INSTALL-SCRIPT: '(.+)','(.+)'", line).groups()
if "PYTHON_ARGCOMPLETE_OK" in pkg_resources.get_distribution(dist).get_metadata('scripts/' + script):
exit(0)
elif line.startswith("# EASY-INSTALL-ENTRY-SCRIPT"):
dist, group, name = re.match("# EASY-INSTALL-ENTRY-SCRIPT: '(.+)','(.+)','(.+)'", line).groups()
import pkg_resources, pkgutil
module_name = pkg_resources.get_distribution(dist).get_entry_info(group, name).module_name
with open(pkgutil.get_loader(module_name).get_filename()) as mod_fh:
if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
exit(0)
elif line.startswith("# EASY-INSTALL-DEV-SCRIPT"):
for line2 in lines:
if line2.startswith('__file__'):
filename = re.match("__file__ = '(.+)'", line2).group(1)
with open(filename) as mod_fh:
if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
exit(0)
elif line.startswith("# PBR Generated"):
module = re.search("from (.*) import", head).groups()[0]
import pkg_resources, pkgutil
with open(pkgutil.get_loader(module).get_filename()) as mod_fh:
if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
exit(0)
exit(1)

View File

@@ -0,0 +1,23 @@
#!/bin/sh
IFS=
export IFS
COMP_WORDBREAKS=
export COMP_WORDBREAKS
COMP_TYPE=
export COMP_TYPE
COMP_LINE=${COMMAND_LINE}
export COMP_LINE
COMP_POINT=${#COMMAND_LINE}
export COMP_POINT
_ARGCOMPLETE=1
export _ARGCOMPLETE
_ARGCOMPLETE_SHELL=tcsh
export _ARGCOMPLETE_SHELL
"$1" 8>&1 9>&2 1>/dev/null 2>/dev/null

View File

@@ -0,0 +1,54 @@
#!/usr/bin/env python
# PYTHON_ARGCOMPLETE_OK
# Copyright 2012-2013, Andrey Kislyuk and argcomplete contributors.
# Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info.
'''
Register a Python executable for use with the argcomplete module.
To perform the registration, source the output of this script in your bash shell (quote the output to avoid interpolation).
Example:
$ eval "$(register-python-argcomplete my-favorite-script.py)"
For Tcsh
$ eval `register-python-argcomplete --shell tcsh my-favorite-script.py`
'''
import sys
import argparse
import argcomplete
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
'--no-defaults',
dest='use_defaults', action='store_false', default=True,
help='When no matches are generated, do not fallback to readline\'s default completion')
parser.add_argument(
'--complete-arguments',
nargs=argparse.REMAINDER,
help='arguments to call complete with; use of this option discards default options')
parser.add_argument(
'-s', '--shell',
choices=('bash', 'tcsh'), default='bash',
help='output code for the specified shell')
parser.add_argument(
'executable',
help='executable to completed (when invoked by exactly this name)')
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
sys.stdout.write(argcomplete.shellcode(
args.executable, args.use_defaults, args.shell, args.complete_arguments))