PageRenderTime 56ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/gtk/src/makedeps.py

https://github.com/shkolnik/HandBrake
Python | 116 lines | 106 code | 9 blank | 1 comment | 12 complexity | 356d957e3de592a22dfdaf407ef6686e MD5 | raw file
  1. #! /usr/bin/python
  2. import collections
  3. import plistlib
  4. DepEntry = collections.namedtuple('DepEntry', 'widget dep enable die hide')
  5. dep_map = (
  6. DepEntry("title", "queue_add", "none", True, False),
  7. DepEntry("title", "queue_add_menu", "none", True, False),
  8. DepEntry("title", "preview_frame", "none", True, False),
  9. DepEntry("title", "picture_label", "none", True, False),
  10. DepEntry("title", "picture_tab", "none", True, False),
  11. DepEntry("title", "chapters_label", "none", True, False),
  12. DepEntry("title", "chapters_tab", "none", True, False),
  13. DepEntry("title", "start_point", "none", True, False),
  14. DepEntry("title", "end_point", "none", True, False),
  15. DepEntry("title", "angle", "none", True, False),
  16. DepEntry("title", "angle_label", "1", True, False),
  17. DepEntry("use_dvdnav", "angle", "FALSE", True, True),
  18. DepEntry("use_dvdnav", "angle_label", "FALSE", True, True),
  19. DepEntry("angle_count", "angle", "1", True, True),
  20. DepEntry("angle_count", "angle_label", "1", True, True),
  21. DepEntry("vquality_type_bitrate", "VideoAvgBitrate", "TRUE", False, False),
  22. DepEntry("vquality_type_constant", "VideoQualitySlider", "TRUE", False, False),
  23. DepEntry("vquality_type_constant", "VideoTwoPass", "TRUE", True, False),
  24. DepEntry("vquality_type_constant", "VideoTurboTwoPass", "TRUE", True, False),
  25. DepEntry("VideoFramerate", "VideoFrameratePFR", "source", True, True),
  26. DepEntry("VideoFramerate", "VideoFramerateVFR", "source", False, True),
  27. DepEntry("VideoTwoPass", "VideoTurboTwoPass", "TRUE", False, False),
  28. DepEntry("FileFormat", "Mp4LargeFile", "mp4", False, True),
  29. DepEntry("FileFormat", "Mp4HttpOptimize", "mp4", False, True),
  30. DepEntry("FileFormat", "Mp4iPodCompatible", "mp4", False, True),
  31. DepEntry("PictureDecombDeinterlace", "PictureDeinterlace", "TRUE", True, True),
  32. DepEntry("PictureDecombDeinterlace", "PictureDeinterlaceCustom", "TRUE", True, True),
  33. DepEntry("PictureDecombDeinterlace", "PictureDeinterlaceLabel", "TRUE", True, True),
  34. DepEntry("PictureDecombDeinterlace", "PictureDecomb", "FALSE", True, True),
  35. DepEntry("PictureDecombDeinterlace", "PictureDecombCustom", "FALSE", True, True),
  36. DepEntry("PictureDecombDeinterlace", "PictureDecombLabel", "FALSE", True, True),
  37. DepEntry("PictureDeinterlace", "PictureDeinterlaceCustom", "custom", False, True),
  38. DepEntry("PictureDenoise", "PictureDenoiseCustom", "custom", False, True),
  39. DepEntry("PictureDecomb", "PictureDecombCustom", "custom", False, True),
  40. DepEntry("PictureDetelecine", "PictureDetelecineCustom", "custom", False, True),
  41. DepEntry("PictureWidthEnable", "PictureWidth", "TRUE", False, False),
  42. DepEntry("PictureHeightEnable", "PictureHeight", "TRUE", False, False),
  43. DepEntry("PictureAutoCrop", "PictureTopCrop", "FALSE", False, False),
  44. DepEntry("PictureAutoCrop", "PictureBottomCrop", "FALSE", False, False),
  45. DepEntry("PictureAutoCrop", "PictureLeftCrop", "FALSE", False, False),
  46. DepEntry("PictureAutoCrop", "PictureRightCrop", "FALSE", False, False),
  47. DepEntry("VideoEncoder", "x264_tab", "x264", False, True),
  48. DepEntry("VideoEncoder", "lavc_mpeg4_tab", "ffmpeg|ffmpeg2", False, True),
  49. DepEntry("VideoEncoder", "Mp4iPodCompatible", "x264", False, False),
  50. DepEntry("AudioEncoderActual", "AudioBitrate", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False),
  51. DepEntry("AudioEncoderActual", "AudioSamplerate", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False),
  52. DepEntry("AudioEncoderActual", "AudioMixdown", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False),
  53. DepEntry("AudioEncoderActual", "AudioTrackDRCSlider", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False),
  54. DepEntry("AudioEncoderActual", "drc_label", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False),
  55. DepEntry("AudioEncoderActual", "AudioTrackGain", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False),
  56. DepEntry("AudioEncoderActual", "gain_label", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False),
  57. DepEntry("AudioEncoder", "AudioAllowMP3Pass", "auto", False, False),
  58. DepEntry("AudioEncoder", "AudioAllowAACPass", "auto", False, False),
  59. DepEntry("AudioEncoder", "AudioAllowAC3Pass", "auto", False, False),
  60. DepEntry("AudioEncoder", "AudioAllowDTSPass", "auto", False, False),
  61. DepEntry("AudioEncoder", "AudioAllowDTSHDPass", "auto", False, False),
  62. DepEntry("x264_bframes", "x264_bpyramid", "<2", True, False),
  63. DepEntry("x264_bframes", "x264_direct", "0", True, False),
  64. DepEntry("x264_bframes", "x264_b_adapt", "0", True, False),
  65. DepEntry("x264_subme", "x264_psy_rd", "<6", True, False),
  66. DepEntry("x264_subme", "x264_psy_trell", "<6", True, False),
  67. DepEntry("x264_trellis", "x264_psy_trell", "0", True, False),
  68. DepEntry("use_source_name", "chapters_in_destination", "TRUE", False, False),
  69. DepEntry("use_source_name", "title_no_in_destination", "TRUE", False, False),
  70. )
  71. def main():
  72. try:
  73. depsfile = open("widget.deps", "w")
  74. except Exception, err:
  75. print >> sys.stderr, ( "Error: %s" % str(err) )
  76. sys.exit(1)
  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. top = dict()
  83. for ii in dep_map:
  84. if ii.widget in top:
  85. continue
  86. deps = list()
  87. for jj in dep_map:
  88. if jj.widget == ii.widget:
  89. deps.append(jj.dep)
  90. top[ii.widget] = deps
  91. plistlib.writePlist(top, depsfile)
  92. top = dict()
  93. for ii in dep_map:
  94. if ii.dep in top:
  95. continue
  96. deps = list()
  97. for jj in dep_map:
  98. if ii.dep == jj.dep:
  99. rec = list()
  100. rec.append(jj.widget)
  101. rec.append(jj.enable)
  102. rec.append(jj.die)
  103. rec.append(jj.hide)
  104. deps.append(rec)
  105. top[ii.dep] = deps
  106. plistlib.writePlist(top, revfile)
  107. main()