Last active
January 16, 2019 10:40
-
-
Save MCOfficer/57dcb101b739073f0d4210e54259552d to your computer and use it in GitHub Desktop.
[ES][Python] Landscapecounter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import requests | |
import json | |
from os import listdir | |
import urllib | |
urllib.urlretrieve("https://raw.githubusercontent.com/endless-sky/endless-sky/master/data/map.txt", "map.txt") | |
images = requests.get("http://api.github.com/repos/endless-sky/endless-sky/contents/images/land") | |
for f in images.json(): | |
f, dummy = os.path.splitext(f["name"]) | |
total = 0 | |
with open("map.txt") as g: | |
for line in g: | |
finded = line.find(f) | |
if finded != -1 and finded != 0: | |
total += 1 | |
out = open("out.txt", "a") | |
out.write(f + ": " + str(total) + "\n") | |
out.close() | |
os.remove("map.txt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from os import listdir | |
import os.path | |
esdir = "/home/x/Git/endless-sky/" | |
onlyfiles = [f for f in listdir(esdir + "images/land/")] | |
for f in onlyfiles: | |
f, dummy = os.path.splitext(f) | |
total = 0 | |
with open(esdir + "data/map.txt") as g: | |
for line in g: | |
finded = line.find(f) | |
if finded != -1 and finded != 0: | |
total += 1 | |
out = open("out.txt", "a") | |
out.write(f + ": " + str(total) + "\n") | |
out.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment