Commit 46b806a 1 parent 190c46f commit 46b806a Copy full SHA for 46b806a
File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -34,10 +34,23 @@ def _normalize_obj(obj):
34
34
return obj
35
35
36
36
37
+ def is_csv (output ):
38
+ """Verifies if the output string is eligible for converting into CSV"""
39
+ sniffer = csv .Sniffer ()
40
+ try :
41
+ sniffer .sniff (output )
42
+ return True
43
+ except csv .Error :
44
+ return False
45
+
46
+
37
47
def parse_csv (output ):
38
48
"""Parse CSV output from Hammer CLI and convert it to python dictionary."""
39
49
# ignore warning about puppet and ostree deprecation
40
50
output .replace ('Puppet and OSTree will no longer be supported in Katello 3.16\n ' , '' )
51
+ # Validate if the output is eligible for CSV conversions else return as it is
52
+ if not is_csv (output ):
53
+ return output
41
54
reader = csv .reader (output .splitlines ())
42
55
# Generate the key names, spaces will be converted to dashes "-"
43
56
keys = [_normalize (header ) for header in next (reader )]
You can’t perform that action at this time.
0 commit comments