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

Unified Diff: tools/nixysa/nixysa/writer.py

Issue 2043006: WTF NPAPI extension. Early draft. Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 10 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/nixysa/nixysa/unsized_array_binding.py ('k') | tools/nixysa/third_party/gflags-1.0/AUTHORS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/nixysa/nixysa/writer.py
===================================================================
--- tools/nixysa/nixysa/writer.py (revision 0)
+++ tools/nixysa/nixysa/writer.py (revision 0)
@@ -0,0 +1,44 @@
+#!/usr/bin/python2.4
+#
+# Copyright 2009 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""File writing functions.
+
+This module contain function to write files only if their contents would
+change.
+"""
+
+import os.path
+import log
+
+
+def WriteIfContentDifferent(filename, content):
+ """Write file only if content is different or if filename does not exist.
+
+ Args:
+ filename: filename of file.
+ content: string containing contents of file.
+ """
+ if os.path.exists(filename):
+ f = open(filename, 'r');
+ old_content = f.read()
+ f.close()
+ if old_content == content:
+ return
+ f = open(filename, 'w')
+ f.write(content)
+ f.close()
+ log.Info('Writing %s' % filename)
+
Property changes on: tools/nixysa/nixysa/writer.py
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « tools/nixysa/nixysa/unsized_array_binding.py ('k') | tools/nixysa/third_party/gflags-1.0/AUTHORS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698