Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
amendments
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LQDN Adminsys
amendments
Commits
1bbbf35a
Commit
1bbbf35a
authored
Sep 26, 2011
by
Ollivier Robert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy form spectrum.
parent
528ad570
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
0 deletions
+115
-0
Réso/README
Réso/README
+5
-0
Réso/convert
Réso/convert
+87
-0
Réso/template.erb
Réso/template.erb
+23
-0
No files found.
Réso/README
0 → 100644
View file @
1bbbf35a
Amdts_spectre_1.odt: le fichier original
Amdts_spectre_1.txt: le fichier original enregistré au format "texte codé"
convert: le script Ruby qui convertit le .txt en wiki
template.erb: le gabarit de formattage d'un amendement
result.mediawiki: le résultat de la conversion
Réso/convert
0 → 100755
View file @
1bbbf35a
#!/usr/bin/env ruby
# Pour lancer le script il faut ruby, rubygems et les gems nokogiri et htmldiff
require
'rubygems'
require
'nokogiri'
require
'htmldiff'
require
'erb'
IN
=
ARGF
.
shift
data
=
File
.
read
(
"Amdts_spectre_
#{
i
}
.txt"
)
sections
=
data
.
scan
(
%r(<Amend>.+?</Amend>)m
)
Amendment
=
Struct
.
new
:num
,
:note
,
:color
,
:commission_rows
,
:amendement_rows
,
:members
,
:article
include
HTMLDiff
class
Amendment
Template
=
ERB
.
new
File
.
read
(
'template.erb'
),
nil
,
'-'
def
format
Template
.
result
(
binding
)
end
def
rows
[
commission_rows
.
size
,
amendement_rows
.
size
].
max
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
(
/[^-+]/
,
''
)
when
"--"
"red"
when
"-"
"IndianRed"
when
"++"
,
"+++"
"green"
when
"+"
"lightgreen"
when
""
"lightgrey"
else
raise
"Invalid note:
#{
note
.
inspect
}
"
end
infos
=
xml
.
scan
(
%r(Text proposed by the Commission
\n
Amendment
\n
(.+)
\n
Or.)m
).
first
raise
"No info found"
unless
infos
infos
=
infos
.
first
.
split
(
/\n/
)
commission_rows
=
[]
amendement_rows
=
[]
infos
.
each_slice
(
2
)
do
|
commission
,
amendment
|
commission
=
commission
.
to_s
amendment
=
amendment
.
to_s
commission_rows
<<
diff
(
commission
,
amendment
).
to_s
.
gsub
(
%r(<ins class=".+?">.+?</ins>)
,
""
).
gsub
(
%r(<del class=".+?">(.+?)</del>)
,
"'''
\\
1'''"
)
amendement_rows
<<
diff
(
commission
,
amendment
).
to_s
.
gsub
(
%r(<del class=".+?">.+?</del>)
,
""
).
gsub
(
%r(<ins class=".+?">(.+?)</ins>)
,
"'''
\\
1'''"
)
end
members
=
doc
.
css
(
'Members'
).
text
article
=
doc
.
css
(
'Article'
).
text
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
Réso/template.erb
0 → 100644
View file @
1bbbf35a
=== Amendment
<%=
num
%><%=
" "
+
note
if
note
%>
===
{| border="1" style="border-spacing:0;" cellpadding="3"
|-
! colspan="2" style="background-color:
<%=
color
%>
;" |
Amendement
<%=
num
%>
<br/>
<%=
article
%>
<br/>
<%=
members
%>
<br/>
<%=
note
%>
<%
rows
.
times
do
|
row
|
-%>
|-
|width="50%"|
<%=
commission_rows
[
row
]
%>
|width="50%"|
<%=
amendement_rows
[
row
]
%>
<%
end
-%>
|-
| colspan="2" |
Comments:
|}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment