Skip to content

Instantly share code, notes, and snippets.

@MCOfficer
Last active January 16, 2019 10:40
Show Gist options
  • Save MCOfficer/57dcb101b739073f0d4210e54259552d to your computer and use it in GitHub Desktop.
Save MCOfficer/57dcb101b739073f0d4210e54259552d to your computer and use it in GitHub Desktop.
[ES][Python] Landscapecounter
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")
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