All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.bower_components.tabletopnew.caching.local.py Maven / Gradle / Ivy

There is a newer version: 1.2.0.3-jre17-rc1
Show newest version
#!/usr/bin/env python

# Caches google spreadsheet on demand in Python
# Run as python local.py your_spreadsheet_key

import sys
import urllib2
import re
import json

# Be sure to call this file with a Google Spreadsheet key as the first argument

key = sys.argv[1]

if '--old' in sys.argv:
    sq = "&sq="
else:
    sq = ""

base_json_url = "https://spreadsheets.google.com/feeds/worksheets/"+key+"/public/basic?alt=json-in-script&callback=Tabletop.singleton.loadSheets"

base_json_content = urllib2.urlopen(base_json_url).read()

sheet_ids = set(re.findall(r"/public/basic/(\w*)",base_json_content, flags=0))

for sheet_id in sheet_ids:
  sheet_url = "https://spreadsheets.google.com/feeds/list/"+key+"/"+sheet_id+"/public/values?alt=json-in-script" + sq + "&callback=Tabletop.singleton.loadSheet"
  content = urllib2.urlopen(sheet_url).read()
  with open(key+"-"+sheet_id, "w") as f:
		f.write(content)

with open(key, "w") as f:
	f.write(base_json_content)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy