Spaces:
Running
Running
ui fetch and gen
Browse files
app.py
CHANGED
|
@@ -59,22 +59,38 @@ async def get_rpk_info(filename: str):
|
|
| 59 |
attrs_info = pyprt.get_rpk_attributes_info(rpk_path)
|
| 60 |
|
| 61 |
formatted_attrs = []
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
formatted_attrs.append({
|
| 73 |
-
"name":
|
| 74 |
-
"type":
|
| 75 |
-
"defaultValue":
|
| 76 |
})
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
return {"attributes": formatted_attrs}
|
| 79 |
except Exception as e:
|
| 80 |
logger.error(f"Error inspecting RPK: {e}")
|
|
|
|
| 59 |
attrs_info = pyprt.get_rpk_attributes_info(rpk_path)
|
| 60 |
|
| 61 |
formatted_attrs = []
|
| 62 |
+
|
| 63 |
+
# Handle Dictionary return type (common in some PyPRT versions)
|
| 64 |
+
if isinstance(attrs_info, dict):
|
| 65 |
+
for name, value in attrs_info.items():
|
| 66 |
+
# Determine type from value
|
| 67 |
+
attr_type = "string"
|
| 68 |
+
if isinstance(value, bool): attr_type = "bool"
|
| 69 |
+
elif isinstance(value, float): attr_type = "float"
|
| 70 |
+
elif isinstance(value, int): attr_type = "float" # Convert int to float for consistency
|
| 71 |
+
|
| 72 |
formatted_attrs.append({
|
| 73 |
+
"name": name,
|
| 74 |
+
"type": attr_type,
|
| 75 |
+
"defaultValue": value
|
| 76 |
})
|
| 77 |
+
# Handle List of Objects return type (standard PyPRT)
|
| 78 |
+
elif hasattr(attrs_info, '__iter__'):
|
| 79 |
+
for attr in attrs_info:
|
| 80 |
+
if hasattr(attr, 'get_name'):
|
| 81 |
+
formatted_attrs.append({
|
| 82 |
+
"name": attr.get_name(),
|
| 83 |
+
"type": str(attr.get_type()),
|
| 84 |
+
"defaultValue": attr.get_default_value(),
|
| 85 |
+
})
|
| 86 |
+
elif isinstance(attr, str):
|
| 87 |
+
# Fallback if list of strings
|
| 88 |
+
formatted_attrs.append({
|
| 89 |
+
"name": attr,
|
| 90 |
+
"type": "string",
|
| 91 |
+
"defaultValue": ""
|
| 92 |
+
})
|
| 93 |
+
|
| 94 |
return {"attributes": formatted_attrs}
|
| 95 |
except Exception as e:
|
| 96 |
logger.error(f"Error inspecting RPK: {e}")
|