OSDN Git Service

LinGui: rewrite widget dependency creator in python
[handbrake-jp/handbrake-jp-git.git] / gtk / src / makedeps.py
1 #! /usr/bin/python
2
3 import collections
4 import plistlib
5
6 DepMap = collections.namedtuple('DepMap', 'widget dep enable die hide')
7 dep_map = (
8         DepMap("title", "queue_add", "none", True, False),
9         DepMap("title", "queue_add_menu", "none", True, False),
10         DepMap("title", "show_picture", "none", True, False),
11         DepMap("title", "show_preview_menu", "none", True, False),
12         DepMap("title", "preview_frame", "none", True, False),
13         DepMap("title", "picture_label", "none", True, False),
14         DepMap("title", "picture_tab", "none", True, False),
15         DepMap("title", "chapters_label", "none", True, False),
16         DepMap("title", "chapters_tab", "none", True, False),
17         DepMap("title", "title", "none", True, False),
18         DepMap("title", "start_chapter", "none", True, False),
19         DepMap("title", "end_chapter", "none", True, False),
20         DepMap("vquality_type_bitrate", "VideoAvgBitrate", "TRUE", False, False),
21         DepMap("vquality_type_target", "VideoTargetSize", "TRUE", False, False),
22         DepMap("vquality_type_constant", "VideoQualitySlider", "TRUE", False, False),
23         DepMap("vquality_type_constant", "constant_rate_factor", "TRUE", False, False),
24         DepMap("vquality_type_constant", "VideoTwoPass", "TRUE", True, False),
25         DepMap("vquality_type_constant", "VideoTurboTwoPass", "TRUE", True, False),
26         DepMap("VideoTwoPass", "VideoTurboTwoPass", "TRUE", False, False),
27         DepMap("FileFormat", "Mp4LargeFile", "mp4|m4v", False, True),
28         DepMap("FileFormat", "Mp4HttpOptimize", "mp4|m4v", False, True),
29         DepMap("FileFormat", "Mp4iPodCompatible", "mp4|m4v", False, True),
30         DepMap("PictureDecomb", "PictureDeinterlace", "none", False, False),
31         DepMap("PictureDecomb", "PictureDeinterlaceCustom", "none", False, True),
32         DepMap("PictureDeinterlace", "PictureDeinterlaceCustom", "custom", False, True),
33         DepMap("PictureDenoise", "PictureDenoiseCustom", "custom", False, True),
34         DepMap("PictureDecomb", "PictureDecombCustom", "custom", False, True),
35         DepMap("PictureDetelecine", "PictureDetelecineCustom", "custom", False, True),
36         DepMap("PictureAutoCrop", "PictureTopCrop", "FALSE", False, False),
37         DepMap("PictureAutoCrop", "PictureBottomCrop", "FALSE", False, False),
38         DepMap("PictureAutoCrop", "PictureLeftCrop", "FALSE", False, False),
39         DepMap("PictureAutoCrop", "PictureRightCrop", "FALSE", False, False),
40         DepMap("autoscale", "scale_width", "FALSE", False, False),
41         DepMap("autoscale", "scale_height", "FALSE", False, False),
42         DepMap("anamorphic", "PictureKeepRatio", "FALSE", False, False),
43         ## "CHECK" is a dummy value that forces scale_height deps to
44         ## be re-evaluated whenever anamorphic changes
45         DepMap("anamorphic", "scale_height", "CHECK", True, False),
46         DepMap("PictureKeepRatio", "scale_height", "FALSE", False, False),
47         DepMap("VideoEncoder", "x264_tab", "x264", False, False),
48         DepMap("VideoEncoder", "x264_tab_label", "x264", False, False),
49         DepMap("VideoEncoder", "Mp4iPodCompatible", "x264", False, False),
50         DepMap("AudioEncoder", "AudioBitrate", "ac3|dts", True, False),
51         DepMap("AudioEncoder", "AudioSamplerate", "ac3|dts", True, False),
52         DepMap("AudioEncoder", "AudioMixdown", "ac3|dts", True, False),
53         DepMap("AudioEncoder", "AudioTrackDRCSlider", "ac3|dts", True, False),
54         DepMap("x264_bframes", "x264_weighted_bframes", "0", True, False),
55         DepMap("x264_bframes", "x264_bpyramid", "<2", True, False),
56         DepMap("x264_bframes", "x264_direct", "0", True, False),
57         DepMap("x264_bframes", "x264_b_adapt", "0", True, False),
58         DepMap("x264_refs", "x264_mixed_refs", "<2", True, False),
59         DepMap("x264_cabac", "x264_trellis", "TRUE", False, False),
60         DepMap("x264_subme", "x264_psy_rd", "<6", True, False),
61         DepMap("x264_subme", "x264_psy_trell", "<6", True, False),
62         DepMap("x264_cabac", "x264_psy_trell", "TRUE", False, False),
63         DepMap("x264_trellis", "x264_psy_trell", "0", True, False),
64         DepMap("ChapterMarkers", "chapters_list", "TRUE", False, False),
65         DepMap("use_source_name", "chapters_in_destination", "TRUE", False, False),
66         DepMap("use_source_name", "title_no_in_destination", "TRUE", False, False),
67         )
68
69 def main():
70
71         try:
72                 depsfile = open("widget.deps", "w")
73         except Exception, err:
74                 print >> sys.stderr, ( "Error: %s"  % str(err) )
75                 sys.exit(1)
76
77         try:
78                 revfile = open("widget_reverse.deps", "w")
79         except Exception, err:
80                 print >> sys.stderr, ( "Error: %s"  % str(err))
81                 sys.exit(1)
82
83         top = dict()
84         for ii in dep_map:
85                 if ii.widget in top:
86                         continue
87                 deps = list()
88                 for jj in dep_map:
89                         if jj.widget == ii.widget:
90                                 deps.append(jj.dep)
91                 top[ii.widget] = deps
92         plistlib.writePlist(top, depsfile)
93
94         top = dict()
95         for ii in dep_map:
96                 if ii.dep in top:
97                         continue
98                 deps = list()
99                 for jj in dep_map:
100                         if ii.dep == jj.dep:
101                                 rec = list()
102                                 rec.append(jj.widget)
103                                 rec.append(jj.enable)
104                                 rec.append(jj.die)
105                                 rec.append(jj.hide)
106                                 deps.append(rec)
107                 top[ii.dep] = deps
108         plistlib.writePlist(top, revfile)
109         
110 main()
111