Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pep8 fixes for recent packet_net inventory #21066

Merged
merged 1 commit into from
Feb 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 9 additions & 10 deletions contrib/inventory/packet_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ def read_settings(self):
]
self.packet_device_states = []
if config.has_option(ini_section, 'device_states'):
for device_state in config.get(ini_section, 'device_states').split(','):
device_state = device_state.strip()
if device_state not in packet_valid_device_states:
continue
self.packet_device_states.append(device_state)
for device_state in config.get(ini_section, 'device_states').split(','):
device_state = device_state.strip()
if device_state not in packet_valid_device_states:
continue
self.packet_device_states.append(device_state)
else:
self.packet_device_states = packet_valid_device_states
self.packet_device_states = packet_valid_device_states

# Cache related
cache_dir = os.path.expanduser(config.get(ini_section, 'cache_path'))
Expand Down Expand Up @@ -200,7 +200,7 @@ def read_settings(self):

# Do we need to exclude hosts that match a pattern?
try:
pattern_exclude = config.get(ini_section, 'pattern_exclude');
pattern_exclude = config.get(ini_section, 'pattern_exclude')
if pattern_exclude and len(pattern_exclude) > 0:
self.pattern_exclude = re.compile(pattern_exclude)
else:
Expand Down Expand Up @@ -304,7 +304,7 @@ def add_device(self, device, project):
# Select the best destination address
dest = None
for ip_address in device.ip_addresses:
if ip_address['public'] == True and ip_address['address_family'] == 4:
if ip_address['public'] is True and ip_address['address_family'] == 4:
dest = ip_address['address']


Expand Down Expand Up @@ -389,7 +389,7 @@ def get_host_info_dict_from_device(self, device):
device_vars[key] = value
elif isinstance(value, six.string_types):
device_vars[key] = value.strip()
elif type(value) == type(None):
elif value is None:
device_vars[key] = ''
elif key == 'packet_facility':
device_vars[key] = value['code']
Expand Down Expand Up @@ -495,4 +495,3 @@ def json_format_dict(self, data, pretty=False):

# Run the script
PacketInventory()