2 # The contents of this file are subject to the Common Public Attribution
3 # License Version 1.0. (the "License"); you may not use this file except in
4 # compliance with the License. You may obtain a copy of the License at
5 # http://code.reddit.com/LICENSE. The License is based on the Mozilla Public
6 # License Version 1.1, but Sections 14 and 15 have been added to cover use of
7 # software over a computer network and provide for limited attribution for the
8 # Original Developer. In addition, Exhibit A has been modified to be consistent
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
13 # the specific language governing rights and limitations under the License.
15 # The Original Code is reddit.
17 # The Original Developer is the Initial Developer. The Initial Developer of
18 # the Original Code is reddit Inc.
20 # All portions of the code written by reddit are Copyright (c) 2006-2015 reddit
21 # Inc. All Rights Reserved.
22 ###############################################################################
24 from ConfigParser
import MissingSectionHeaderError
25 from StringIO
import StringIO
28 from r2
.lib
.utils
import parse_ini_file
31 # YOU DO NOT NEED TO EDIT THIS FILE
32 # This is a generated file. To update the configuration,
33 # edit the *.update file of the same name, and then
35 # Configuration settings in the *.update file will override
36 # or be added to the base 'example.ini' file.
39 def main(source_ini
, update_ini
):
40 with
open(source_ini
) as source
:
41 parser
= parse_ini_file(source
)
42 with
open(update_ini
) as f
:
45 # Existing *.update files don't include section
46 # headers; inject a [DEFAULT] header if the parsing
48 parser
.readfp(StringIO(updates
))
49 except MissingSectionHeaderError
:
50 updates
= "[DEFAULT]\n" + updates
51 parser
.readfp(StringIO(updates
))
53 parser
.write(sys
.stdout
)
55 if __name__
== '__main__':
58 print 'usage: %s [source] [update]' % sys
.argv
[0]
61 main(sys
.argv
[1], sys
.argv
[2])