forked from MapComplete/MapComplete
		
	Scripts(handle_error): allow multiple files
This commit is contained in:
		
							parent
							
								
									4c0c8ae9ea
								
							
						
					
					
						commit
						ce3a049d9d
					
				
					 1 changed files with 19 additions and 8 deletions
				
			
		| 
						 | 
					@ -96,7 +96,7 @@ class HandleErrors extends Script {
 | 
				
			||||||
                    " is identical to previously seen changeset, not writing to file"
 | 
					                    " is identical to previously seen changeset, not writing to file"
 | 
				
			||||||
            )*/
 | 
					            )*/
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            const changesetWithMsg = `<!-- User: ${parsed.message.username} (${parsed.message.userid}) ${parsed.message.layout}; Version ${parsed.message.version}; Not uploaded due to ${parsed.message.message} -->
 | 
					            const changesetWithMsg = `<!-- User: ${parsed.message.username} (${parsed.message.userid}) ${parsed.message.theme}; Version ${parsed.message.version}; Not uploaded due to ${parsed.message.message} -->
 | 
				
			||||||
${changeset}`
 | 
					${changeset}`
 | 
				
			||||||
            writeFileSync(path, changesetWithMsg, "utf8")
 | 
					            writeFileSync(path, changesetWithMsg, "utf8")
 | 
				
			||||||
            createdChangesets.add(changeset)
 | 
					            createdChangesets.add(changeset)
 | 
				
			||||||
| 
						 | 
					@ -115,14 +115,13 @@ ${changeset}`
 | 
				
			||||||
            console.log("Written refused", path)
 | 
					            console.log("Written refused", path)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    private readonly osmConnection = new OsmConnection()
 | 
				
			||||||
 | 
					    private readonly downloader = new OsmObjectDownloader(this.osmConnection.Backend(), undefined)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async main(args: string[]): Promise<void> {
 | 
					    async fixForFile(path: string){
 | 
				
			||||||
        const osmConnection = new OsmConnection()
 | 
					 | 
				
			||||||
        const downloader = new OsmObjectDownloader(osmConnection.Backend(), undefined)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        const path = args[0]
 | 
					 | 
				
			||||||
        const lines = readFileSync(path, "utf8").split("\n")
 | 
					        const lines = readFileSync(path, "utf8").split("\n")
 | 
				
			||||||
 | 
					        const osmConnection = this.osmConnection
 | 
				
			||||||
 | 
					        const downloader = this.downloader
 | 
				
			||||||
        const createdChangesets = new Set<string>()
 | 
					        const createdChangesets = new Set<string>()
 | 
				
			||||||
        const refusedFiles: Set<string> = new Set<string>()
 | 
					        const refusedFiles: Set<string> = new Set<string>()
 | 
				
			||||||
        refusedFiles.add("[]")
 | 
					        refusedFiles.add("[]")
 | 
				
			||||||
| 
						 | 
					@ -143,7 +142,7 @@ ${changeset}`
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                const parsed: ErrorMessage = JSON.parse(line)
 | 
					                const parsed: ErrorMessage = JSON.parse(line)
 | 
				
			||||||
                const e = parsed.message
 | 
					                const e = parsed.message
 | 
				
			||||||
                if (e.layout === "grb") {
 | 
					                if (e.theme === "grb") {
 | 
				
			||||||
                    console.log("Skipping GRB ")
 | 
					                    console.log("Skipping GRB ")
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -182,6 +181,18 @@ ${changeset}`
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    async main(args: string[]): Promise<void> {
 | 
				
			||||||
 | 
					         if(args[0] === undefined){
 | 
				
			||||||
 | 
					            console.log("Please specify the error file to handle")
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (const path of args) {
 | 
				
			||||||
 | 
					            await this.fixForFile(path)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
new HandleErrors().run()
 | 
					new HandleErrors().run()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue