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

Side by Side Diff: tools/publish_pkg.py

Issue 11617022: Add LICENSE if none exists, and skip .svn directories. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 # 6 #
7 # Script to push a package to pub. 7 # Script to push a package to pub.
8 # 8 #
9 # Usage: publish_pkg.py pkg_dir 9 # Usage: publish_pkg.py pkg_dir
10 # 10 #
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 shutil.copytree(os.path.join(HOME, argv[1]), 104 shutil.copytree(os.path.join(HOME, argv[1]),
105 os.path.join(tmpDir, pkgName)) 105 os.path.join(tmpDir, pkgName))
106 else: 106 else:
107 os.makedirs(os.path.join(tmpDir, pkgName)) 107 os.makedirs(os.path.join(tmpDir, pkgName))
108 shutil.copytree(os.path.join(HOME, argv[1]), 108 shutil.copytree(os.path.join(HOME, argv[1]),
109 os.path.join(tmpDir, pkgName, 'lib')) 109 os.path.join(tmpDir, pkgName, 'lib'))
110 110
111 # Create pubspec.yaml . 111 # Create pubspec.yaml .
112 with open(pubspec, 'w') as pubspecFile: 112 with open(pubspec, 'w') as pubspecFile:
113 pubspecFile.write('name: ' + pkgName + '_unsupported\n') 113 pubspecFile.write('name: ' + pkgName + '_unsupported\n')
114 pubspecFile.write('author: None\n')
115 pubspecFile.write('homepage: http://None\n')
114 pubspecFile.write('version: ' + version + '\n') 116 pubspecFile.write('version: ' + version + '\n')
115 pubspecFile.write("description: >\n") 117 pubspecFile.write("description: >\n")
116 pubspecFile.write(' A completely unsupported clone of Dart SDK library\n' ) 118 pubspecFile.write(' A completely unsupported clone of Dart SDK library\n' )
117 pubspecFile.write(' ' + argv[1] + ' . This package will change in\n') 119 pubspecFile.write(' ' + argv[1] + ' . This package will change in\n')
118 pubspecFile.write(' unpredictable/incompatible ways without warning.\n') 120 pubspecFile.write(' unpredictable/incompatible ways without warning.\n')
119 pubspecFile.write('dependencies:\n') 121 pubspecFile.write('dependencies:\n')
120 122
121 libpath = os.path.join(HOME, argv[1], '../libraries.dart') 123 libpath = os.path.join(HOME, argv[1], '../libraries.dart')
122 if os.path.exists(libpath): 124 if os.path.exists(libpath):
123 # Copy libraries.dart into the package source code 125 # Copy libraries.dart into the package source code
124 shutil.copy(libpath, os.path.join(tmpDir, pkgName, 'lib/libraries.dart')) 126 shutil.copy(libpath, os.path.join(tmpDir, pkgName, 'lib/libraries.dart'))
125 127
126 # Replace '../../libraries.dart' with '../libraries.dart' 128 # Replace '../../libraries.dart' with '../libraries.dart'
127 replaceInFiles.append( 129 replaceInFiles.append(
128 (r'(import|part)(\s+)(\'|")\.\./(\.\./)*libraries.dart', 130 (r'(import|part)(\s+)(\'|")\.\./(\.\./)*libraries.dart',
129 r'\1\2\3\4libraries.dart')) 131 r'\1\2\3\4libraries.dart'))
130 132
133 if not os.path.exists(os.path.join(tmpDir, pkgName, 'LICENSE')):
134 with open(os.path.join(tmpDir, pkgName, 'LICENSE'), 'w') as licenseFile:
135 licenseFile.write('''
136 Copyright 2012, the Dart project authors. All rights reserved.
137 Redistribution and use in source and binary forms, with or without
138 modification, are permitted provided that the following conditions are
139 met:
140 * Redistributions of source code must retain the above copyright
141 notice, this list of conditions and the following disclaimer.
142 * Redistributions in binary form must reproduce the above
143 copyright notice, this list of conditions and the following
144 disclaimer in the documentation and/or other materials provided
145 with the distribution.
146 * Neither the name of Google Inc. nor the names of its
147 contributors may be used to endorse or promote products derived
148 from this software without specific prior written permission.
149 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
150 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
151 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
152 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
153 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
154 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
155 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
156 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
157 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
158 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
159 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
160 ''');
161
131 replaceInFiles.append( 162 replaceInFiles.append(
132 (r'(import|part)(\s+)(\'|")(\.\./)+pkg/', r'\1\2\3package:')) 163 (r'(import|part)(\s+)(\'|")(\.\./)+pkg/', r'\1\2\3package:'))
133 164
134 # Replace '../*/pkg' imports and parts. 165 # Replace '../*/pkg' imports and parts.
135 for root, dirs, files in os.walk(os.path.join(tmpDir, pkgName)): 166 for root, dirs, files in os.walk(os.path.join(tmpDir, pkgName)):
167 # TODO(dgrove): Remove this when dartbug.com/7487 is fixed.
168 if '.svn' in dirs:
169 shutil.rmtree(os.path.join(root, '.svn'))
136 for name in files: 170 for name in files:
137 if name.endswith('.dart'): 171 if name.endswith('.dart'):
138 ReplaceInFiles([os.path.join(root, name)], replaceInFiles) 172 ReplaceInFiles([os.path.join(root, name)], replaceInFiles)
139 173
140 print 'publishing version ' + version + ' of ' + argv[1] + ' to pub.\n' 174 print 'publishing version ' + version + ' of ' + argv[1] + ' to pub.\n'
141 subprocess.call(['pub', 'publish'], cwd=os.path.join(tmpDir, pkgName)) 175 subprocess.call(['pub', 'publish'], cwd=os.path.join(tmpDir, pkgName))
142 shutil.rmtree(tmpDir) 176 shutil.rmtree(tmpDir)
143 177
144 if __name__ == '__main__': 178 if __name__ == '__main__':
145 sys.exit(Main(sys.argv)) 179 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698