<commit_before>import sqlite3
import urllib2
import xml.etree.ElementTree as ET


MARKET_URL = 'http://api.eve-central.com/api/marketstat?hours=24&%s'

ITEMS = [
	34, # Tritanium
	35, # Pyerite
	36, # Mexallon
	37, # Isogen
	38, # Nocxium
	39, # Zydrine
	40, # Megacyte
	11399, # Morphite
]


def main():
	conn = sqlite3.connect('everdi.db')
	cur = conn.cursor()
	
	url = MARKET_URL % ('&'.join('typeid=%s' % i for i in ITEMS))
	f = urllib2.urlopen(url)
	data = f.read()
	f.close()
	#open('data.txt', 'w').write(data)
	#data = open('data.txt').read()
	
	root = ET.fromstring(data)
	for t in root.findall('marketstat/type'):
		typeid = t.get('id')
		sell_median = t.find('sell/median').text
		buy_median = t.find('buy/median').text
		
		cur.execute('UPDATE blueprints_item SET sell_median=?, buy_median=? WHERE id=?', (sell_median, buy_median, typeid))
	
	conn.commit()

if __name__ == '__main__':
	main()<commit_msg>Update prices for all BlueprintInstances we currently have<commit_after>import sqlite3
import urllib2
import xml.etree.ElementTree as ET


MARKET_URL = 'http://api.eve-central.com/api/marketstat?hours=24&%s'


def main():
	conn = sqlite3.connect('everdi.db')
	cur = conn.cursor()
	
	# Get all items used in current BlueprintInstances
	cur.execute("""
SELECT DISTINCT c.item_id
FROM blueprints_blueprintcomponent c
  INNER JOIN blueprints_blueprintinstance AS bi
    ON c.blueprint_id = bi.blueprint_id
""")
	rows = cur.fetchall()
	
	for i in range(0, len(rows), 20):
		url = MARKET_URL % ('&'.join('typeid=%s' % item for item in rows[i:i+20]))
		f = urllib2.urlopen(url)
		data = f.read()
		f.close()
		#open('data.txt', 'w').write(data)
		#data = open('data.txt').read()
		
		root = ET.fromstring(data)
		for t in root.findall('marketstat/type'):
			typeid = t.get('id')
			sell_median = t.find('sell/median').text
			buy_median = t.find('buy/median').text
			
			cur.execute('UPDATE blueprints_item SET sell_median=?, buy_median=? WHERE id=?', (sell_median, buy_median, typeid))
		
		conn.commit()

if __name__ == '__main__':
	main()
{'fraction_non_alphanumeric': 0.16187225743539738, 'fraction_numerical': 0.017552413456850317, 'mean_word_length': 4.2615384615384615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1826565', 'n_tokens_mistral': 882, 'n_tokens_neox': 778, 'n_words': 173}