Permalink
Browse files

add bin dir and tools to export objects as JSON files; add JSON files…

…; ignore ~ files
  • Loading branch information...
1 parent c8b57aa commit 67e3187a26867591a6c3d4626df389abd28440b4 straup committed Feb 25, 2012
Showing 102,161 changed files with 2,871,489 additions and 1 deletion.
The diff you're trying to view is too large. We only load the first 3000 changed files.
View
@@ -1 +1,2 @@
-.DS_Store
+.DS_Store
+*~
View
@@ -0,0 +1 @@
+*.pyc
View
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+
+# THIS IS NOT FINISHED. IT WORKS BUT IS UGLY.
+# (20120225/straup)
+
+"""
+Append the URLs for the files in media.csv to individual object JSON files.
+"""
+
+import csv
+import json
+import utils
+import os.path
+
+if __name__ == '__main__' :
+
+
+ path = '../media.csv'
+ fh = open(path, 'r')
+
+ reader = csv.DictReader(fh)
+
+ for row in reader:
+
+ root = "../objects/" + utils.id2path(row['id']) + "/"
+ fname = "%s.json" % row['id']
+
+ obj_path = root + fname
+
+ if not os.path.exists(obj_path):
+ continue
+
+ obj_fh = open(obj_path, 'r')
+ obj_data = json.load(obj_fh)
+ obj_fh.close()
+
+ obj_data['thumbnail'] = 'https://d2lp2xklsr2xgg.cloudfront.net/media/350/' + row['filename']
+
+ obj_fh = open(obj_path, 'w')
+ json.dump(obj_data, obj_fh, indent=2)
+ obj_fh.close()
+
+ print obj_path
View
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+
+# THIS IS NOT FINISHED. IT WORKS BUT IS UGLY.
+# (20120225/straup)
+
+"""
+Export the contents of objects.csv in to individual JSON files.
+"""
+
+import json
+import csv
+import utils
+import os
+import os.path
+
+class UnicodeCsvReader(object):
+ def __init__(self, f, encoding="utf-8", **kwargs):
+ self.csv_reader = csv.reader(f, **kwargs)
+ self.encoding = encoding
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ # read and split the csv row into fields
+ row = self.csv_reader.next()
+ # now decode
+
+ try:
+ return [unicode(cell, self.encoding) for cell in row]
+ except Exception, e:
+ return []
+
+ @property
+ def line_num(self):
+ return self.csv_reader.line_num
+
+class UnicodeDictReader(csv.DictReader):
+ def __init__(self, f, encoding="utf-8", fieldnames=None, **kwds):
+ csv.DictReader.__init__(self, f, fieldnames=fieldnames, **kwds)
+ self.reader = UnicodeCsvReader(f, encoding=encoding, **kwds)
+
+
+if __name__ == '__main__':
+
+ path = '../objects.csv'
+ fh = open(path, 'r')
+
+ r = UnicodeDictReader(fh)
+
+ for row in r:
+
+ root = "../objects/" + utils.id2path(row['id']) + "/"
+ fname = "%s.json" % row['id']
+
+ out = root + fname
+
+ if not os.path.exists(root):
+ os.makedirs(root)
+
+ out_fh = open(out, 'w')
+ json.dump(row, out_fh, indent=2)
+
+
+ print out
View
@@ -0,0 +1,13 @@
+def id2path(id):
+
+ tmp = str(id)
+ parts = []
+
+ while len(tmp) > 3:
+ parts.append(tmp[0:3])
+ tmp = tmp[3:]
+
+ if len(tmp):
+ parts.append(tmp)
+
+ return "/".join(parts)
@@ -0,0 +1,29 @@
+{
+ "display_date": "1812",
+ "credit_line": "Museum purchase through gift of various donors",
+ "date_end": "1812",
+ "period": "Neoclassical",
+ "dynasty": "",
+ "culture": "Italian",
+ "id": "10000",
+ "style": "",
+ "date_begin": "1812",
+ "dimensions": "18.7 x 21.8 cm (7 3/8 x 8 9/16 in.)",
+ "copyright": "",
+ "title": "Ceres is told of the Rape of Proserpina",
+ "provenance": "Giovanni Piancastelli, Rome",
+ "credit_line_repro": "",
+ "invno": "1901-39-3282",
+ "thumbnail": "https://d2lp2xklsr2xgg.cloudfront.net/media/350/chw1369.JPG",
+ "movement": "",
+ "medium": "Pen and brown ink, brush and brown wash over traces of graphite on light brown laid paper",
+ "media_id": "",
+ "description": "Ceres stands at left leaning upon chariot and holding torch in her right hand. She listens to nymph, Arethusa, who reclines upon her. At right edge, parts of two drawings of kneeling figures.",
+ "classification_id": "2",
+ "restrictions": "",
+ "school": "",
+ "name": "Drawing",
+ "region": "",
+ "caption": "",
+ "department_id": "2"
+}
@@ -0,0 +1,29 @@
+{
+ "display_date": "1812",
+ "credit_line": "Museum purchase through gift of various donors",
+ "date_end": "1812",
+ "period": "Neoclassical",
+ "dynasty": "",
+ "culture": "Italian",
+ "id": "10001",
+ "style": "",
+ "date_begin": "1812",
+ "dimensions": "20.9 x 21.3 cm (8 1/4 x 8 3/8 in.)",
+ "copyright": "",
+ "title": "Ceres asks Jupiter for Return of Proserpina",
+ "provenance": "Giovanni Piancastelli, Rome",
+ "credit_line_repro": "",
+ "invno": "1901-39-3283",
+ "thumbnail": "https://d2lp2xklsr2xgg.cloudfront.net/media/350/chw1364.JPG",
+ "movement": "",
+ "medium": "Pen and brown ink, brush and brown washes over traces of graphite on light brown paper",
+ "media_id": "",
+ "description": "Ceres shown kneeling before Jupiter throned.",
+ "classification_id": "2",
+ "restrictions": "",
+ "school": "",
+ "name": "Drawing",
+ "region": "",
+ "caption": "",
+ "department_id": "2"
+}
@@ -0,0 +1,29 @@
+{
+ "display_date": "1812",
+ "credit_line": "Museum purchase through gift of various donors",
+ "date_end": "1812",
+ "period": "Neoclassical",
+ "dynasty": "",
+ "culture": "Italian",
+ "id": "10002",
+ "style": "",
+ "date_begin": "1812",
+ "dimensions": "18.5 x 22.4 cm (7 5/16 x 8 13/16 in.)",
+ "copyright": "",
+ "title": "Phaeton Asks Apollo to Drive the Sun Chariot",
+ "provenance": "Giovanni Piancastelli, Rome",
+ "credit_line_repro": "",
+ "invno": "1901-39-3284",
+ "thumbnail": "https://d2lp2xklsr2xgg.cloudfront.net/media/350/chw1371.JPG",
+ "movement": "",
+ "medium": "Pen and ink, brush and brown watercolor wash on heavy paper",
+ "media_id": "",
+ "description": "",
+ "classification_id": "2",
+ "restrictions": "",
+ "school": "",
+ "name": "Drawing",
+ "region": "",
+ "caption": "",
+ "department_id": "2"
+}
@@ -0,0 +1,29 @@
+{
+ "display_date": "1812",
+ "credit_line": "Museum purchase through gift of various donors",
+ "date_end": "1812",
+ "period": "Neoclassical",
+ "dynasty": "",
+ "culture": "Italian",
+ "id": "10003",
+ "style": "",
+ "date_begin": "1812",
+ "dimensions": "21.9 x 24.3 cm (8 5/8 x 9 9/16 in.)",
+ "copyright": "",
+ "title": "The Seasons Bring Gifts to Ceres and Triptolemus",
+ "provenance": "Giovanni Piancastelli, Rome",
+ "credit_line_repro": "",
+ "invno": "1901-39-3285",
+ "thumbnail": "https://d2lp2xklsr2xgg.cloudfront.net/media/350/CH1247.JPG",
+ "movement": "",
+ "medium": "Pen and brown ink, brush and brown wash over traces of graphite on light brown paper and secondary support",
+ "media_id": "",
+ "description": "Ceres and Triptolemus shown entroned upon platform. Seasons kneel or come at left. At right, sketch in margin showing part of throne and platform and Ceres and Triptolemus, who holds cornucopia.",
+ "classification_id": "2",
+ "restrictions": "",
+ "school": "",
+ "name": "Drawing",
+ "region": "",
+ "caption": "",
+ "department_id": "2"
+}
@@ -0,0 +1,28 @@
+{
+ "display_date": "ca. 1810",
+ "credit_line": "Museum purchase through gift of various donors",
+ "date_end": "1810",
+ "period": "Neoclassical",
+ "dynasty": "",
+ "culture": "Italian",
+ "id": "10005",
+ "style": "",
+ "date_begin": "1810",
+ "dimensions": "34.8 x 27 cm (13 11/16 x 10 5/8 in.)",
+ "copyright": "",
+ "title": "Phaeton Bidding Apollo Farewell",
+ "provenance": "Giovanni Piancastelli, Rome",
+ "credit_line_repro": "",
+ "invno": "1901-39-3287 ",
+ "movement": "",
+ "medium": "Pen and brown ink, brush and colored washes over black chalk on textured paper",
+ "media_id": "",
+ "description": "Phaeton holding reins and with left foot in chariot, turns backward to Apollo, seated to admonish him. Aurora flies below at right.",
+ "classification_id": "2",
+ "restrictions": "",
+ "school": "",
+ "name": "Drawing",
+ "region": "",
+ "caption": "",
+ "department_id": "2"
+}
@@ -0,0 +1,28 @@
+{
+ "display_date": "ca. 1790",
+ "credit_line": "Museum purchase through gift of various donors",
+ "date_end": "1790",
+ "period": "Neoclassical",
+ "dynasty": "",
+ "culture": "Italian",
+ "id": "10006",
+ "style": "",
+ "date_begin": "1790",
+ "dimensions": "24.5 x 28.7 cm (9 5/8 x 11 5/16 in.)",
+ "copyright": "",
+ "title": "Thetis Plunges Achilles in River Styx",
+ "provenance": "Giovanni Piancastelli, Rome",
+ "credit_line_repro": "",
+ "invno": "1901-39-3288 ",
+ "movement": "",
+ "medium": "Pen and brown ink over traces of graphite on light blue paper",
+ "media_id": "",
+ "description": "Water flows from jar of god in narrow valley. Thetis holds kneeling Achilles by his right leg. She is accompanied by four girls, two of whom hold towel.",
+ "classification_id": "2",
+ "restrictions": "",
+ "school": "",
+ "name": "Drawing",
+ "region": "",
+ "caption": "",
+ "department_id": "2"
+}
@@ -0,0 +1,28 @@
+{
+ "display_date": "ca. 1790",
+ "credit_line": "Museum purchase through gift of various donors",
+ "date_end": "1790",
+ "period": "Neoclassical",
+ "dynasty": "",
+ "culture": "Italian",
+ "id": "10007",
+ "style": "",
+ "date_begin": "1790",
+ "dimensions": "24.5 x 29.5 cm (9 5/8 x 11 5/8 in.)",
+ "copyright": "",
+ "title": "Achilles Taught by Centaur Chiron How to Play Lyre",
+ "provenance": "Giovanni Piancastelli, Rome",
+ "credit_line_repro": "",
+ "invno": "1901-39-3289 ",
+ "movement": "",
+ "medium": "Pen and brown ink over traces of graphite on light blue paper",
+ "media_id": "",
+ "description": "At left, sea with Thetis and her companions. At right, Chiron and lad in grotto.",
+ "classification_id": "2",
+ "restrictions": "",
+ "school": "",
+ "name": "Drawing",
+ "region": "",
+ "caption": "",
+ "department_id": "2"
+}
@@ -0,0 +1,28 @@
+{
+ "display_date": "ca. 1780",
+ "credit_line": "Museum purchase through gift of various donors",
+ "date_end": "1780",
+ "period": "Neoclassicism",
+ "dynasty": "",
+ "culture": "Italy, Rome",
+ "id": "10008",
+ "style": "",
+ "date_begin": "1780",
+ "dimensions": "27.6 x 20 cm (10 7/8 x 7 7/8 in.)",
+ "copyright": "",
+ "title": "Landscape with a burning tower",
+ "provenance": "Ex collection: Giovanni Piancastelli",
+ "credit_line_repro": "",
+ "invno": "1901-39-329 ",
+ "movement": "",
+ "medium": "Pen and ink, brush and lustre on paper",
+ "media_id": "",
+ "description": "In a landscape of distant mountains to the right and trees to the left, a castle-like building stands ablaze as a group of people in the foreground, at left, stand watching the fire.",
+ "classification_id": "47",
+ "restrictions": "",
+ "school": "",
+ "name": "Drawing",
+ "region": "",
+ "caption": "",
+ "department_id": "2"
+}
Oops, something went wrong.

0 comments on commit 67e3187

Please sign in to comment.