solutions icon indicating copy to clipboard operation
solutions copied to clipboard

Adaptation of remove_imported_prefix.py to french version

Open fxlequere opened this issue 1 year ago • 1 comments

Hello đź‘‹ I adapt the script from remove_imported_prefix.py for the french version.

You can find bellow the code.

# French version for 1Password renaming.
import subprocess
import json
import sys


# Check CLI version
def checkCLIVersion():
    r = subprocess.run(["op", "--version", "--format=json"], capture_output=True)
    major, minor = r.stdout.decode("utf-8").rstrip().split(".", 2)[:2]
    if not major == 2 and not int(minor) >= 25:
        sys.exit(
            "❌ You must be using version 2.25 or greater of the 1Password CLI. Please visit https://developer.1password.com/docs/cli/get-started to download the lastest version."
        )


def getVaults():
    try:
        return subprocess.run(
            ["op", "vault", "list", "--permission=manage_vault", "--format=json"],
            check=True,
            capture_output=True,
        ).stdout
    except Exception as err:
        print(
            f"Encountered an error getting the list of vaults you have access to: ", err
        )
        return


def main():
    checkCLIVersion()
    vaultList = json.loads(getVaults())
    print(
        "Removing 'Importé' suffix from all imported vaults in your 1Password account.\n\n"
    )
    for vault in vaultList:
        vaultID = vault["id"]
        vaultName = vault["name"]
        if vaultName.endswith(" importé"):
            trimmedName = vaultName.removesuffix(" importé")
            try:
                subprocess.run(
                    ["op", "vault", "edit", vaultID, f"--name={trimmedName}"],
                    check=True,
                    capture_output=True,
                )
                print(f'\t Changed "{vaultName}" => "{trimmedName}"')
            except Exception as err:
                print(f"Encountered an error renaming {vaultName}: ", err)
                continue


main()

Best

fxlequere avatar Jun 11 '24 10:06 fxlequere

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two weeks if no further activity occurs. 1Password employees have been nudged.

github-actions[bot] avatar Oct 02 '24 19:10 github-actions[bot]

This issue has been automatically closed due to inactivity. Please re-open if this still requires attention.

github-actions[bot] avatar Oct 17 '24 04:10 github-actions[bot]