Skip to content

Commit

Permalink
Refactored by Sourcery
Browse files Browse the repository at this point in the history
  • Loading branch information
SourceryAI authored and KeyboardInterrupt committed May 30, 2020
1 parent b9c787a commit c69c7a1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions xlsx_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ def main():
config = load_config(config_path)
try:
wb = load_workbook(config['xlsx_inventory_file'])
if 'sheet' in config:
sheet = wb[config['sheet']]
else:
sheet = wb.active
sheet = wb[config['sheet']] if 'sheet' in config else wb.active
inventory = sheet_to_inventory(group_by_col=config['group_by_col'], hostname_col=config['hostname_col'],
sheet=sheet)
if args.list:
Expand Down Expand Up @@ -133,7 +130,7 @@ def sheet_to_inventory(group_by_col, hostname_col, sheet):
'hosts': [],
'vars': {}
}
groups[group]['hosts'].append(row[hostname_col].value)
groups[group]['hosts'].append(host)
groups['_meta']['hostvars'][row[hostname_col].value] = {}
for xlsx_head in rows[:1]:
for idx, var_name in enumerate(xlsx_head):
Expand Down

0 comments on commit c69c7a1

Please sign in to comment.