MCPcopy Create free account
hub / github.com/breck7/scroll / updateParserFiles

Function updateParserFiles

updatePopularity.js:62–81  ·  view source on GitHub ↗
(popularityData, parsersDir)

Source from the content-addressed store, hash-verified

60
61// Function to update parser files
62function updateParserFiles(popularityData, parsersDir) {
63 const files = fs.readdirSync(parsersDir)
64 for (let file of files) {
65 if (file.endsWith(".parsers")) {
66 const filePath = path.join(parsersDir, file)
67 let content = fs.readFileSync(filePath, "utf-8")
68 const lines = content.split("\n")
69 const updatedLines = []
70 for (let line of lines) {
71 updatedLines.push(line)
72 for (let parserId in popularityData) {
73 if (line.startsWith(parserId)) {
74 updatedLines.push(` popularity ${popularityData[parserId].toFixed(6)}`)
75 }
76 }
77 }
78 fs.writeFileSync(filePath, updatedLines.join("\n"))
79 }
80 }
81}
82
83// Main function
84function main(csvFilePaths, parsersDir) {

Callers 1

mainFunction · 0.85

Calls 2

splitMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected