(mod_file, client)
| 10 | USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36" # noqa: E501 |
| 11 | |
| 12 | def preset(mod_file, client): |
| 13 | if mod_file.startswith("http"): |
| 14 | req = urllib.request.Request( |
| 15 | mod_file, |
| 16 | headers={"User-Agent": USER_AGENT}, |
| 17 | ) |
| 18 | remote = urllib.request.urlopen(req) |
| 19 | with open("preset.html", "wb") as f: |
| 20 | f.write(remote.read()) |
| 21 | mod_file = "preset.html" |
| 22 | mods = [] |
| 23 | moddirs = [] |
| 24 | with open(mod_file) as f: |
| 25 | html = f.read() |
| 26 | regex = r"filedetails\/\?id=(\d+)\"" |
| 27 | matches = re.finditer(regex, html, re.MULTILINE) |
| 28 | for _, match in enumerate(matches, start=1): |
| 29 | mods.append(match.group(1)) |
| 30 | api.download_workshop(client, int(match.group(1))) |
| 31 | moddirs.append("workshop/" + match.group(1)) |
| 32 | for moddir in moddirs: |
| 33 | keys.copy("server/"+moddir) |
| 34 | return moddirs |
nothing calls this directly
no outgoing calls
no test coverage detected