All pastes #398332 Raw Edit

Miscellany

public ruby v1 · immutable
·published 2007-03-17 03:40 UTC
rendered paste body
Dir.foreach(".") { |x|  next if !File.directory?(x)  next if x.to_i < 1 # and x.to_i > 1    lines = []  File.open(x + "/__init__.py", "r").each_line { |line|    lines.push(line)  }    i = 0  while i < lines.length    break if (lines[i].index("import") == 0)    i += 1  end  while i < lines.length    i += 1    break unless (lines[i].index("from") == 0)  end    lines.insert(i, '', 'qn = "' + x + '"')    while i < lines.length do    if lines[i].index('Quest(' + x.to_i.to_s).nil? == false      lines[i].sub!(/,"[^"]+",/, ",qn,")      break    end    i += 1  end    File.open(x + "/__init__.py", "w") { |file|    lines.each { |line|      file.puts line    }  }    puts x}