Commit f4a81181 authored by Michael Witrant's avatar Michael Witrant

intégration autres fichiers

parent 12896820
.~lock.*
This diff is collapsed.
This diff is collapsed.
......@@ -6,17 +6,26 @@ require 'rubygems'
require 'nokogiri'
require 'erb'
data = File.read('Amdts_spectre_1.txt')
data = %w(3 1 2).map { |i| File.read("Amdts_spectre_#{i}.txt") }.join
sections = data.scan(%r(<Amend>.+?</Amend>)m)
Amendment = Struct.new :num, :note, :color, :commission_rows, :amendement_rows, :members, :article
template = ERB.new File.read('template.erb'), nil, '-'
File.open "result.mediawiki", "w" do |f|
sections.each do |xml|
class Amendment
Template = ERB.new File.read('template.erb'), nil, '-'
def format
Template.result(binding)
end
end
amendments = sections.map do |xml|
doc = Nokogiri::XML(xml)
num, note = doc.css('NumAm').text.split(' ', 2)
num = num.to_i
note.gsub!(/\s/, '') if note
color = case note.to_s.gsub(/[^-+]/, '')
......@@ -24,7 +33,7 @@ File.open "result.mediawiki", "w" do |f|
"red"
when "-"
"IndianRed"
when "++"
when "++", "+++"
"green"
when "+"
"lightgreen"
......@@ -54,6 +63,20 @@ File.open "result.mediawiki", "w" do |f|
members = doc.css('Members').text
article = doc.css('Article').text
f.puts template.result(binding)
Amendment.new num, note, color, commission_rows, amendement_rows, members, article
end
File.open "result.mediawiki", "w" do |f|
grouped = amendments.group_by { |am| (am.num - 1) / 10 }
grouped.keys.sort.each do |index|
ams = grouped[index].sort_by { |am| am.num }
first = ams.first.num
last = ams.last.num
f.puts "== Amendments #{first}#{last} =="
ams.each do |am|
f.puts am.format
end
f.puts
end
end
This diff is collapsed.
== Amendement <%= num %><%= " " + note if note %> ==
=== Amendment <%= num %><%= " " + note if note %> ===
{| border="1" style="border-spacing:0;" cellpadding="3"
|-
! colspan="2" style="background-color: <%= color %>;" |
......@@ -16,6 +16,6 @@ Amendement <%= num %>
<%= amendement_rows.join("\n\n") %>
|-
| colspan="2" |
<!-- Commentaires -->
Comments:
|}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment