本文整理汇总了Python中account.Account.networkToAccount方法的典型用法代码示例。如果您正苦于以下问题:Python Account.networkToAccount方法的具体用法?Python Account.networkToAccount怎么用?Python Account.networkToAccount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类account.Account
的用法示例。
在下文中一共展示了Account.networkToAccount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: modify
# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import networkToAccount [as 别名]
def modify(self, account, newname = None):
if not Account.hasSupport(account.network):
return False
if not self.exists(account):
return False
pm = PersistenceManager()
if not pm.existsConfig():
return False
config = pm.readConfig()
accountType = Account.networkToAccount(account.network)
for entry in config['accounts'][account.network]:
if entry['name'] == account.name:
if newname:
entry['name'] = newname
if accountType == 'OAuth':
entry['key'], entry['secret'] = account.credentials()
elif accountType == 'UserPass':
entry['user'], entry['password'] = account.credentials()
break
pm.writeConfig(config)
return True
示例2: getAllByNetwork
# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import networkToAccount [as 别名]
def getAllByNetwork(self, network):
if not Account.hasSupport(network):
return None
pm = PersistenceManager()
if not pm.existsConfig():
return None
config = pm.readConfig()
accounts = []
accountType = Account.networkToAccount(network)
for entry in config['accounts'][network]:
account = Account.getAccount(network, entry['name'])
if accountType == 'OAuth':
account.setCredentials((entry['key'], entry['secret']))
elif accountType == 'UserPass':
account.setCredentials((entry['user'], entry['password']))
accounts.append(account)
return accounts
示例3: create
# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import networkToAccount [as 别名]
def create(self, account):
if not Account.hasSupport(account.network):
return False
if self.exists(account):
return False
pm = PersistenceManager()
if not pm.existsConfig():
return False
config = pm.readConfig()
accountType = Account.networkToAccount(account.network)
if accountType == 'OAuth':
config['accounts'][account.network].append(dict(name = account.name,key = account.key, secret = account.secret))
elif accountType == 'UserPass':
config['accounts'][account.network].append(dict(name = account.name,user = account.user, password = account.password))
pm.writeConfig(config)
return True