source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/add-license.rb @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

  • Property svn:executable set to *
File size: 939 bytes
Line 
1#!/usr/bin/ruby
2
3exts = ['m', 'cpp', 'sh']
4
5# check license in files, add it if not present
6require 'find'
7
8updated = 0
9conform = 0
10exts.each() do |ext|
11        puts "--- processing #{ext} files"
12        license = IO.readlines('license.'+ext).join()
13        Find.find('./') do |f|
14                if File.file?(f) && File.extname(f) == '.'+ext
15                        content = ''
16                        header = ''
17                        IO.readlines(f).each() do |line|
18                                if content.length == 0 && (ext == 'xml' || ext == 'html') && (line.index('<?') == 0 || (line.index('<!') == 0 && line.index('<!--') != 0))
19                                        header += line
20                                else
21                                        content += line
22                                end
23                        end
24                        if content.index(license) != 0
25                                File.open(f, 'w') do |f2|
26                                        f2.puts header + license + content
27                                end
28                                puts "#{f} updated"
29                                updated += 1
30                        else
31                                conform += 1
32                        end
33                end
34        end
35end
36puts "------------------------------------------------"
37puts "#{updated} files updated, #{conform} already compliant"
Note: See TracBrowser for help on using the repository browser.