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"
 | 
			
		||||
            )*/
 | 
			
		||||
        } 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}`
 | 
			
		||||
            writeFileSync(path, changesetWithMsg, "utf8")
 | 
			
		||||
            createdChangesets.add(changeset)
 | 
			
		||||
| 
						 | 
				
			
			@ -115,14 +115,13 @@ ${changeset}`
 | 
			
		|||
            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> {
 | 
			
		||||
        const osmConnection = new OsmConnection()
 | 
			
		||||
        const downloader = new OsmObjectDownloader(osmConnection.Backend(), undefined)
 | 
			
		||||
 | 
			
		||||
        const path = args[0]
 | 
			
		||||
    async fixForFile(path: string){
 | 
			
		||||
        const lines = readFileSync(path, "utf8").split("\n")
 | 
			
		||||
 | 
			
		||||
        const osmConnection = this.osmConnection
 | 
			
		||||
        const downloader = this.downloader
 | 
			
		||||
        const createdChangesets = new Set<string>()
 | 
			
		||||
        const refusedFiles: Set<string> = new Set<string>()
 | 
			
		||||
        refusedFiles.add("[]")
 | 
			
		||||
| 
						 | 
				
			
			@ -143,7 +142,7 @@ ${changeset}`
 | 
			
		|||
            try {
 | 
			
		||||
                const parsed: ErrorMessage = JSON.parse(line)
 | 
			
		||||
                const e = parsed.message
 | 
			
		||||
                if (e.layout === "grb") {
 | 
			
		||||
                if (e.theme === "grb") {
 | 
			
		||||
                    console.log("Skipping GRB ")
 | 
			
		||||
                    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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue