-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_movie_panels.py
126 lines (102 loc) · 4.41 KB
/
gen_movie_panels.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#
# Configuration...
#
MOVIE_PANEL_DEFS = { \
"animation_gallery":"https://docs.google.com/spreadsheet/pub?key=0AuRz1oxD7nNEdEg4VGhhZzVKNU5JdmE4ejhfLUNtVmc&output=csv", \
"motiondesign_gallery":"https://docs.google.com/spreadsheet/pub?key=0AvPzUVdJ7YGedG1GWkRVUWtQdl9sOFZWcDhpd1ZrYnc&output=csv", \
"previs":"https://docs.google.com/spreadsheet/pub?key=0AuRz1oxD7nNEdDNvUDE2NVVCRTgxQ2M3OFpRbnIyaWc&output=csv", \
"interactive":"https://docs.google.com/spreadsheet/pub?key=0AvPzUVdJ7YGedHg2cGstNGI4bk1WZHpma0p6RG5STVE&output=csv", \
"etcetera":"https://docs.google.com/spreadsheet/pub?key=0AuRz1oxD7nNEdHEtUFJZUHg1MWRBMkdjd3NWbzA0M3c&output=csv" }
MOVIES1_PREFIX = "../phil_assets"
MOVIES2_PREFIX = "../movies"
#
# Library...
#
import common
import os
import sys
import gen_movies
import gen_images
import gen_embeds
def get_dct( pagekeys=None ):
if pagekeys==None:
pagekeys = MOVIE_PANEL_DEFS.keys()
newdct = {}
for code in pagekeys:
if not MOVIE_PANEL_DEFS.has_key(code): continue
items = common.parse_spreadsheet1( MOVIE_PANEL_DEFS[code], "movie panels %s" % str(pagekeys) )
dct = common.dct_join( items,'name')
for ky in dct.keys():
newdct[ky] = dct[ky]
return newdct
def get_item_path( name, movies_dct ):
item_def = movies_dct[name][0]
path = item_def['path']
fname = item_def['filename']
fpath = os.path.join(path,fname)
fpath = fpath.replace("MOVIES1",MOVIES1_PREFIX)
fpath = fpath.replace("MOVIES2",MOVIES2_PREFIX)
return fpath
def expand_item( accum_ids, page_item, images_dct, movies_dct, movie_panels_dct, embeds_dct ):
asset_name = page_item["asset_name"]
item_def = movie_panels_dct[asset_name]
tot_style = ""
tot_content = ""
scriptlet_dct = {}
scriptlet_dct['on'] = ''
scriptlet_dct['off'] = ''
scriptlet_dct['init'] = ''
htmlid = common.get_id( asset_name, accum_ids )
accum_ids.append( htmlid )
for item in item_def:
asn = item["asset_name"]
if asn.startswith("mov"):
style, content, scr_dct = gen_movies.expand_item( accum_ids, item, images_dct, movies_dct )
tot_style += style
tot_content += content
scriptlet_dct['on'] += scr_dct['on']
scriptlet_dct['off'] += scr_dct['off']
scriptlet_dct['init'] += scr_dct['init']
elif asn.startswith("img"):
# determine the script, if any...
script = None
ahref = None
exturl = None
if item.has_key("link") and item["link"]!="":
link = item["link"]
if link.startswith("option:"):
ltype,parm = link.split(":")
funcname = "func_%s_%s" % (menu_name, parm)
test = action_scripts[funcname]
script = "%s ();" % funcname
elif link.startswith("url:"):
idx = link.find(":") + 1
ahref = link[idx:]
print "MENUS AHREF->", ahref
elif link.startswith("nurl:"):
idx = link.find(":") + 1
ahref = link[idx:]
exturl = True
else:
print "ERROR: gen_movie_panels: Unknown link type", asset_name, item
sys.exit(1)
style, content, foo, scr_dct = gen_images.expand_item( accum_ids, item, images_dct, script, None, ahref, exturl )
tot_style += style
tot_content += content
scriptlet_dct['on'] += scr_dct['on']
scriptlet_dct['off'] += scr_dct['off']
scriptlet_dct['init'] += scr_dct['init']
elif asn.startswith("embed"):
style, content, foo, scr_dct = gen_embeds.expand_item( accum_ids, item, embeds_dct, images_dct, None, None)
tot_style += style
tot_content += content
scriptlet_dct['on'] += scr_dct['on']
scriptlet_dct['off'] += scr_dct['off']
scriptlet_dct['init'] += scr_dct['init']
else:
print "ERROR: gen_movie_panels: Cannot process->", item
sys.exit(1)
return [ tot_style, tot_content, scriptlet_dct ]
if __name__ == "__main__":
dct = get_dct()
print dct