MCPcopy Create free account
hub / github.com/SkyworkAI/DeepResearchAgent / compare_versions

Method compare_versions

src/version/server.py:338–365  ·  view source on GitHub ↗

Compare two version strings. Returns 1 if v1 > v2, -1 if v1 < v2, 0 if equal. Args: v1: First version string (e.g., "1.0.0") v2: Second version string (e.g., "1.0.1") Returns: 1 if v1 > v2, -1 if v1 < v2, 0 if equal

(v1: str, v2: str)

Source from the content-addressed store, hash-verified

336
337 @staticmethod
338 def compare_versions(v1: str, v2: str) -> int:
339 """Compare two version strings. Returns 1 if v1 > v2, -1 if v1 < v2, 0 if equal.
340
341 Args:
342 v1: First version string (e.g., "1.0.0")
343 v2: Second version string (e.g., "1.0.1")
344
345 Returns:
346 1 if v1 > v2, -1 if v1 < v2, 0 if equal
347 """
348 try:
349 parts1 = [int(x) for x in v1.split(".")]
350 parts2 = [int(x) for x in v2.split(".")]
351
352 # Pad with zeros to same length
353 max_len = max(len(parts1), len(parts2))
354 parts1.extend([0] * (max_len - len(parts1)))
355 parts2.extend([0] * (max_len - len(parts2)))
356
357 for p1, p2 in zip(parts1, parts2):
358 if p1 > p2:
359 return 1
360 elif p1 < p2:
361 return -1
362 return 0
363 except:
364 # Fallback: string comparison
365 return 1 if v1 > v2 else (-1 if v1 < v2 else 0)
366
367
368# Global version manager instance

Callers 15

initializeMethod · 0.80
save_to_jsonMethod · 0.80
load_from_jsonMethod · 0.80
initializeMethod · 0.80
save_to_jsonMethod · 0.80
load_from_jsonMethod · 0.80
initializeMethod · 0.80
initializeMethod · 0.80
save_to_jsonMethod · 0.80
load_from_jsonMethod · 0.80
initializeMethod · 0.80
save_to_jsonMethod · 0.80

Calls 1

extendMethod · 0.45

Tested by

no test coverage detected