Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: ios/build/util/canary_version.py

Issue 1784783002: Remove obsolete override "ios_extra_version_path". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/build/util/VERSION ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Writes canary version information to a specified file."""
7
8 import datetime
9 import sys
10 import optparse
11 import os
12
13
14 def WriteIfChanged(file_name, content):
15 """
16 Write |content| to |file_name| iff the content is different from the
17 current content.
18 """
19 try:
20 old_content = open(file_name, 'rb').read()
21 except EnvironmentError:
22 pass
23 else:
24 if content == old_content:
25 return
26 os.unlink(file_name)
27 open(file_name, 'wb').write(content)
28
29
30 def main(argv=None):
31 if argv is None:
32 argv = sys.argv
33
34 parser = optparse.OptionParser(usage="canary_version.py [options]")
35 parser.add_option("-o", "--output", metavar="FILE",
36 help="write patch level to FILE")
37 opts, args = parser.parse_args(argv[1:])
38 out_file = opts.output
39
40 if args and out_file is None:
41 out_file = args.pop(0)
42
43 if args:
44 sys.stderr.write('Unexpected arguments: %r\n\n' % args)
45 parser.print_help()
46 sys.exit(2)
47
48 # Number of days since January 1st, 2012.
49 day_number = (datetime.date.today() - datetime.date(2012, 1, 1)).days
50 content = "PATCH={}\n".format(day_number)
51
52 if not out_file:
53 sys.stdout.write(content)
54 else:
55 WriteIfChanged(out_file, content)
56
57 if __name__ == '__main__':
58 sys.exit(main())
OLDNEW
« no previous file with comments | « ios/build/util/VERSION ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698