mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 15:34:01 -07:00
Migrate most uses of if type() to if isinstance()
Also convert those checks to use abcs instead of dict and list. Make a sentinel class for strategies to report when they've reache the end
This commit is contained in:
parent
64fe7402ff
commit
6bad4e57bd
12 changed files with 49 additions and 34 deletions
|
@ -43,13 +43,16 @@
|
|||
import argparse
|
||||
import os.path
|
||||
import sys
|
||||
import paramiko
|
||||
from collections import MutableSequence
|
||||
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
import paramiko
|
||||
|
||||
|
||||
SSH_CONF = '~/.ssh/config'
|
||||
|
||||
_key = 'ssh_config'
|
||||
|
@ -68,7 +71,7 @@ def get_config():
|
|||
cfg.parse(f)
|
||||
ret_dict = {}
|
||||
for d in cfg._config:
|
||||
if type(d['host']) is list:
|
||||
if isinstance(d['host'], MutableSequence):
|
||||
alias = d['host'][0]
|
||||
else:
|
||||
alias = d['host']
|
||||
|
@ -93,7 +96,7 @@ def print_list():
|
|||
# If the attribute is a list, just take the first element.
|
||||
# Private key is returned in a list for some reason.
|
||||
attr = attributes[ssh_opt]
|
||||
if type(attr) is list:
|
||||
if isinstance(attr, MutableSequence):
|
||||
attr = attr[0]
|
||||
tmp_dict[ans_opt] = attr
|
||||
if tmp_dict:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue