当前位置: 首页>>代码示例>>Python>>正文


Python Account.select方法代码示例

本文整理汇总了Python中account.Account.select方法的典型用法代码示例。如果您正苦于以下问题:Python Account.select方法的具体用法?Python Account.select怎么用?Python Account.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在account.Account的用法示例。


在下文中一共展示了Account.select方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_handler

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import select [as 别名]
def add_handler(sub_args):
    alias = sub_args.alias
    service = sub_args.service
    account = sub_args.account
    if alias is None:
        alias = str(click.prompt("Please type an alias to store the credential (this alias must be unique)"))
    if not _alias_valid(alias):
        select = Account.select().where(Account.alias == alias)
        service = str(select[0].service)
        account = str(select[0].account)
        sys.exit("Aborting , this alias already exist for the service " + service + " and the account " + account)
    if service is None:
        service = str(click.prompt("Please type the name of the service you want to use"))
    if not sub_args.noformat:
        if service.split("://")[0].lower() == "http":
            service = urlparse(service).netloc
        service = service.lower()
    if account is None:
        account = str(click.prompt("Please enter the account for the credential (aka login)"))
    select = Account.select().where((Account.service == service) & (Account.account == account))
    if len(select) != 0:
        print "The account " + account + " associated to the service " + service + " already exist"
        if not click.confirm("Do you wish to continue adding this credential ?"):
            sys.exit("Aborting")
    passphrase = getpass.getpass("Enter passphrase:")
    Account.create(service=service,
                   account=account,
                   passphrase=passphrase,
                   alias=alias)
开发者ID:LudoZipsin,项目名称:credential,代码行数:31,代码来源:credential.py

示例2: list_handler

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import select [as 别名]
def list_handler(sub_args):

    if sub_args.service is None:
        # list all with indication of the number of account stored for each service
        service_dict = {}
        for i in Account.select():
            if i.service in service_dict:
                service_dict[i.service] += 1
            else:
                service_dict[i.service] = 1
        _list_service_printer(service_dict, ["service name", "nbs account"])
    else:
        # list only the account of the given service if the service is used
        account_dict = {}
        for i in Account.select().where(Account.service == sub_args.service):
            account_dict[i.alias] = i.account
        _list_account_printer(account_dict, ["alias", "account name"])
开发者ID:LudoZipsin,项目名称:credential,代码行数:19,代码来源:credential.py

示例3: get_handler

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import select [as 别名]
def get_handler(sub_args):
    credential = Account.select().where(Account.alias == sub_args.alias)
    alias = sub_args.alias[0]
    if len(credential) == 0:
        sys.exit("There is no credential for the alias " + alias)
    credential = credential[0]
    selection = sub_args.selection[0]
    get = credential.account if selection == "account" \
        else credential.passphrase if selection == "passphrase" \
        else credential.service
    if sub_args.prompt:
        print get
    else:
        import pyperclip
        pyperclip.copy(get)
开发者ID:LudoZipsin,项目名称:credential,代码行数:17,代码来源:credential.py

示例4: remove_handler

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import select [as 别名]
def remove_handler(sub_args):
    alias = sub_args.alias[0]
    credential = Account.select().where(Account.alias == alias)
    if len(credential) == 0:
        sys.exit("There is no credential with alias " + alias)
    else:
        if sub_args.force:
            _delete_alias(alias)
        else:
            account = str(credential[0].account)
            service = str(credential[0].service)
            print "The credential for the account " + account + " of the service " + service + " will be removed."
            if click.confirm("Confirm credential removal:"):
                _delete_alias(alias)
            else:
                sys.exit("Removal aborted")
开发者ID:LudoZipsin,项目名称:credential,代码行数:18,代码来源:credential.py

示例5: _alias_valid

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import select [as 别名]
def _alias_valid(alias):
    select = Account.select().where(Account.alias == alias)
    return True if len(select) == 0 else False
开发者ID:LudoZipsin,项目名称:credential,代码行数:5,代码来源:credential.py


注:本文中的account.Account.select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。