MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / FindBestImageFit

Function FindBestImageFit

Scripts/CI_FetchRootFS.py:26–69  ·  view source on GitHub ↗
(Distro, links_file)

Source from the content-addressed store, hash-verified

24 return [DistroName, DistroVersion]
25
26def FindBestImageFit(Distro, links_file):
27 CurrentFitSize = 0
28 BestFitDistro = None
29 BestFitDistroVersion = None
30 BestFitReadableName = None
31 BestFitImagePath = None
32 BestFitHash = None
33
34 with open(links_file, 'r') as f:
35 while True:
36 # Order:
37 # Distro Name
38 # Distro Version
39 # User readable name
40 # File Path
41 # Hash
42
43 DistroName = f.readline().strip()
44 if not DistroName:
45 break
46
47 DistroVersion = f.readline().strip()
48 DistroReadableName = f.readline().strip()
49 DistroImagePath = f.readline().strip()
50 DistroHash = f.readline().strip()
51
52 FitRate = 0
53 if (DistroName == Distro[0] or
54 DistroName == None):
55 FitRate += 1
56
57 if (DistroVersion == Distro[1] or
58 DistroVersion == None):
59 FitRate += 1
60
61 if FitRate > CurrentFitSize:
62 CurrentFitSize = FitRate
63 BestFitDistro = DistroName
64 BestFitDistroVersion = DistroVersion
65 BestFitReadableName = DistroReadableName
66 BestFitImagePath = DistroImagePath
67 BestFitHash = DistroHash
68
69 return [BestFitDistro, BestFitDistroVersion, BestFitReadableName, BestFitImagePath, int(BestFitHash, 16)]
70
71
72def HashFile(file):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected