File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
bittensor_cli/src/bittensor Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -1266,23 +1266,29 @@ def is_valid_contact(contact: str) -> bool:
1266
1266
return bool (re .match (email_pattern , contact ))
1267
1267
1268
1268
1269
- def get_subnet_name (subnet_info ) -> str :
1269
+ def get_subnet_name (subnet_info , max_length : int = 20 ) -> str :
1270
1270
"""Get the subnet name, prioritizing subnet_identity.subnet_name over subnet.subnet_name.
1271
+ Truncates the name if it exceeds max_length.
1271
1272
1272
1273
Args:
1273
- subnet: The subnet dynamic info
1274
+ subnet_info: The subnet dynamic info
1275
+ max_length: Maximum length of the returned name. Names longer than this will be truncated with '...'
1274
1276
1275
1277
Returns:
1276
- str: The subnet name or empty string if no name is found
1278
+ str: The subnet name (truncated if necessary) or empty string if no name is found
1277
1279
"""
1278
- return (
1280
+ name = (
1279
1281
subnet_info .subnet_identity .subnet_name
1280
1282
if hasattr (subnet_info , "subnet_identity" )
1281
1283
and subnet_info .subnet_identity is not None
1282
1284
and subnet_info .subnet_identity .subnet_name is not None
1283
1285
else (subnet_info .subnet_name if subnet_info .subnet_name is not None else "" )
1284
1286
)
1285
1287
1288
+ if len (name ) > max_length :
1289
+ return name [: max_length - 3 ] + "..."
1290
+ return name
1291
+
1286
1292
1287
1293
def print_linux_dependency_message ():
1288
1294
"""Prints the WebKit dependency message for Linux systems."""
You can’t perform that action at this time.
0 commit comments