Skip to content
Snippets Groups Projects
Commit 8080385c authored by Christian Elberfeld's avatar Christian Elberfeld
Browse files

Etiketten moved

parent 17e833de
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File added
<?xml version="1.0" encoding="UTF-8"?>
<!-- inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension" -->
<inkscape-extension>
<_name>Generator</_name>
<id>generator.aurium.colivre.coop.br</id>
<dependency type="executable" location="extensions">generator.sh</dependency>
<param name="tab" type="notebook">
<page name="tabA" _gui-text="Configuration">
<param name="var-type" type="enum" _gui-text="Collect values by:">
<_item value="column">column position</_item>
<_item value="name">column name</_item>
</param>
<param name="sep" type="description">•••••••••••••••••••••••••••••••••••••••••••••••••••••••••</param>
<_param name="info1" type="description">Extra textual values to be replaced:</_param>
<param name="extra-vars" type="string" gui-text=" "></param>
<param name="sep" type="description">•••••••••••••••••••••••••••••••••••••••••••••••••••••••••</param>
<param name="data-file" type="string" _gui-text="Data file:"></param>
<_param name="extraVarInfo" type="description">The data file must be a CSV with comma separated columns</_param>
<param name="sep" type="description">•••••••••••••••••••••••••••••••••••••••••••••••••••••••••</param>
<param name="format" type="enum" _gui-text="Exportation format:">
<item>PDF</item>
<item>SVG</item>
<item>PS</item>
<item>EPS</item>
<item>PNG</item>
<item>JPG</item>
</param>
<param name="dpi" type="string" _gui-text="DPI (for PNG and JPG):">90</param>
<param name="output" type="string" _gui-text="Output pattern:">$HOME/generator-output/%VAR_1%.pdf</param>
<param name="preview" type="boolean" _gui-text="Preview (make and show only the frist register):"></param>
</page>
<page name="tabB" _gui-text="Help">
<_param name="helpTxt" type="description">
How vars are replaced?
The replacer will walk in each data column, line-by-line, and will try to replace the %VAR_#% in the SVG by the column value.
If you select "column position", # is the column number.
If you select "column name", # is the column name, defined in the first line.
I can replace other text paterns, like element values?
Yes. On the second field, add all extra text to be replaced in a line separated by "|", pointing to the replacer column with "=>" (name or number depending on the choice up). Do not use spaces if that is not part of the blocks!
For example, we can make the red and green colors as variables to be replaced by some other colors form the database at the columns "secure color" and "sector color":
#ff0000=>secure_color|#00ff00=>sector_color
All pure red and pure green elementes will have new colors for each data line.
If you are not sure about the usable variables, run it on preview mode and the replaceable texts wil be showed to you.
</_param>
</page>
</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu _name="Misc"/>
</effects-menu>
</effect>
<script>
<command reldir="extensions">generator.sh</command>
</script>
</inkscape-extension>
#!/bin/bash
# Generator - a Inkscape extension to generate end-use files from a model
# Copyright (C) 2008 Aurélio A. Heckert
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# Version 0.4
# Collect all args and create local variables:
for arg in "$@"; do
if ( echo -n $arg | grep -q '^--.*=' ); then
key="$( echo -n "$arg" |
sed 's/^--\([^=]*\)=.*$/\1/; s/[^a-zA-Z0-9]/_/' )"
val="$( echo -n "$arg" |
sed 's/^--\([^=]*\)=\(.*\)$/\2/' )"
eval "$key=\"$val\""
else
svg_file="$arg"
fi
done
if ! zenity --version 2>/dev/null; then
function zenity() {
echo -e "\n$@\n" >&2
}
zenity "You must to install Zenity to have a better interaction
with this script, but it will work anyway."
fi
if [ "${data_file:0:1}" != "/" ]; then
data_file="$(pwd)/$data_file"
fi
if ! test -f "$data_file"; then
zenity --error --title="User Information Error" \
--text="The CSV file \"$data_file\" was not found.
Please, give the right name, or give the full path for the CSV file."
exit 1
fi
function sep_line {
sed 's/^\([^"]*\("[^"]*"[^"]*\)*"[^"]*\),/\1#COMMAHACK#/g' |
sed 's/,/\n/g' | sed "s/\"\"/\"/g; s/^['\"]\|['\"]$//g"
}
# Set column names:
eval "$(
col=0
head --lines=1 "$data_file" | sep_line |
while read name; do
let col++
if [ "$var_type" == "name" ]; then
echo col_name[$col]=$( echo $name | sed "s/[][ \$'\"]/_/g" )
else
echo col_name[$col]=$col
fi
echo tot_col=$col
done
)"
# '
eval "$(
echo "$extra_vars" | sed 's/|/\n/g' |
while read extra; do
key="$( echo "$extra" | sed 's/^.*=>\(.*\)$/\1/g' )"
for i in $( seq $tot_col ); do
if [ "${col_name[$i]}" = "$key" ]; then
echo extracol[$i]="'$( echo "$extra" | sed 's/^\(.*\)=>.*$/\1/g' )'"
fi
done
done
)"
if [ "$preview" = "true" ]; then
# debug:
txt=''
for i in $( seq $tot_col ); do
txt="$txt\n%VAR_${col_name[$i]}%"
done
for i in $( seq $tot_col ); do
[ "${extracol[$i]}" != "" ] && txt="$txt\n${extracol[$i]}"
done
zenity --info --title="Generator Variables" \
--text="The replaceable text, based on your configuration and on the CSV are:\n$txt"
fi
eval "output=\"$output\""
[ "$( dirname "$output" )" != "" ] && mkdir --parents "$( dirname "$output" )"
[ "$format" = "" ] && format=PDF
format=$( echo $format | tr a-z A-Z )
if ! ( echo "$output" | grep -qi "$format\$" ); then
if zenity --question --text="
Your output pattern has a file extension diferent from the export format.
Did you want to add the file extension?"; then
output="$output.$( echo $format | tr A-Z a-z )"
fi
fi
tmp_svg=$( mktemp )
tmp_png=$( mktemp )
ink_error=$( mktemp )
my_pid=$$
function the_end {
rm $tmp_svg $tmp_png $ink_error
kill $my_pid
}
function ink-generate {
f="$( echo "$1" | sed 's/^[^=]*=\(.*\)$/\1/' )"
rm "$f" 2>/dev/null
( inkscape --without-gui \
"$1" --export-dpi="$dpi" \
$tmp_svg 2>&1 ) > $ink_error
if ! test -f "$f"; then
zenity --error --title="Inkscape Converting Error" \
--text="$(cat $ink_error |
sed 's/&/&amp;/g; s/</&lt;/g; s/>/&gt;/g' )"
the_end
exit 1
fi
}
function show_preview {
case $format in
SVG)
( inkview "$1" || inkscape "$1" ) 2>/dev/null ||
echo 'There is no visualizator for SVG' >&2 ;;
PDF)
( evince "$1" || kpdf "$1" || xpdf "$1" || gs "$1" ) 2>/dev/null ||
echo 'There is no visualizator for PDF' >&2 ;;
PS)
( evince "$1" || gs "$1" ) 2>/dev/null ||
echo 'There is no visualizator for PS' >&2 ;;
EPS)
( evince "$1" || gs "$1" ) 2>/dev/null ||
echo 'There is no visualizator for EPS' >&2 ;;
PNG)
( eog "$1" || kview "$1" || display "$1" ) 2>/dev/null ||
echo 'There is no visualizator for PNG' >&2 ;;
JPG)
( eog "$1" || kview "$1" || display "$1" ) 2>/dev/null ||
echo 'There is no visualizator for JPG' >&2 ;;
esac
echo 100
the_end
}
tot_lines=$( wc --lines "$data_file" | sed 's/^\([0-9]\+\).*/\1/' )
if [ "$var_type" == "name" ]; then
let tot_lines--
fi
cur_line=0
cat "$data_file" | (
[ "$var_type" == "name" ] && read cut_frist_line
while read line; do
col=0
replace="$(
echo "$line" | sep_line |
while read val; do
let col++
echo -n "s/%VAR_${col_name[$col]}%/$(
echo "$val" | sed "s/\//\\\\\//g; s/'//g"
)/g; " | sed 's/#COMMAHACK#/,/g'
if [ "${extracol[$col]}" != "" ]; then
echo -n "s/${extracol[$col]}/$(
echo "$val" | sed "s/\//\\\\\//g; s/'//g"
)/g; " | sed 's/#COMMAHACK#/,/g'
fi
done
)"
eval "sed '$replace' '$svg_file' > $tmp_svg"
out_file="$( echo "$output" | sed "$replace" )"
#echo "Gerando $out_file ..."
case $format in
SVG)
cp "$tmp_svg" "$out_file" ;;
PDF)
ink-generate --export-pdf="$out_file" ;;
PS)
ink-generate --export-ps="$out_file" ;;
EPS)
ink-generate --export-eps="$out_file" ;;
PNG)
ink-generate --export-png="$out_file" ;;
JPG)
ink-generate --export-png="$tmp_png"
if ! ( echo "$output" | grep -qi '.jpe\?g$' ); then
output="$output.jpg"
fi
convert $tmp_png "$out_file" ;;
esac
let cur_line++
echo $(( ( $cur_line * 100 ) / $tot_lines ))
[ "$preview" = "true" ] && show_preview "$out_file" && exit 0
done |
zenity --progress --title="Generator" \
--text="Generating..." --auto-close --width=400
)
[ "$preview" = "true" ] && exit 0
the_end
File added
Inventarnummer | Gerät | Hersteller | Modellbezeichnung | Seriennummer | Erworben am? Gebraucht? |Verleihbar|
1| Kühlschrank | NPG | FR-KSE1300 |9359086776| 16.9.2009, gebraucht |nein|
2| Kaffeemaschine | Philips | Senseo | n.a. | 11.2009, gebraucht | - nicht verleihbar - |
3| VGA-Beamer | Geha | Compact 211 Plus | ACRN24000041 | 10.2009 |-|
4| VGA-Beamer | Geha | Compact 520 - pn 101620 |1348| 10.2009 |-|
5| Analog-Oszilloskop | Siemens | Oscillar M07192 | n.a. | 09.2009 |-|
8| JBL Lautsprecher | JBL | Control 1 Pro | ...-014606-A | n.A. |-|
9| Stationärer Beamer Lounge| Epson |EB-W8|m58f040635l| n.A. |- nicht verleihbar -|
10| Mikrowelle | Clatronic | MWG 776H |1660302001415| n.A. | - nicht verleihbar - |
11| Messcomputer | Fujitsu-Siemens | Scaleo 600 | n.A. | n.A. | - nicht verleihbar - |
12| Monitor des Messcomputers | HP |1720| n.A. | n.A. | - nicht verleihbar - |
13| stationäres Multimeter | Uni-T | U803 |1090582683| n.A. | - nicht verleihbar - |
14| Lötstation | Ersa | RD80 | GER008385 | n.A. | - nicht verleihbar - |
15| mobiles Multimeter | Peaktech | 3340 DMM |10039736| n.A. | - nicht verleihbar - |
16| Developmentboard | Atmel | STK500 |20060111| gebraucht | - nicht verleihbar - |
17| VP1710 | Pollin | VP1710 |1561657725| gebraucht | - nicht verleihbar - |
18| Whiteboard Wekstatt| n.A. | n.A. | n.A. | gebraucht | - nicht verleihbar - |
19|3D-Drucker|RepRap|Mendel|n.A.|Oktober 2011|-nicht verleihbar-|
20|Computer-Oszilloskop|Velleman|PC Scope PCS500|200408296|n.A.|nein|
21|Peaktech Labornetzteil|PeakTech|6035D|100784135|n.A.|nein|
22|Kontaktkartenleser|Omnikey|3121|IM 20042 0000301995 0004|n.A., gebraucht|nein|
23|Akkuladegerät|ELV|ELV63755|n.A.|n.A.|nein|
24|Kabeltrommel|Gamma|HJA-4R|n.A.|n.A.|nein|
25|19''-Oszilloskop|Tektronix|7613 mit Einschüben|n.A.|n.A.|nein|
26|Isolationsmessgerät|H&B Elima|Isolavi 10|n.A.|n.A.|nein|
27|defekter Acer-Beamer|Acer|PD 721|EY72101001407000CDPP00|n.A., defekt|nein|
28|Alix Board|Alix||n.A.|n.A.|nein|
29|Heißtluftfön|Parkside|Heißluftgebläse|24652|n.A.|nein|
30|Analogmultimeter|BBC Goerz Metrawatt|MA 4E|n.A.|n.A.|nein|
31|verstellbarer Trenntrafo|n.A.|n.A.|n.A.|n.A.|nein|
32|Miniofen|Bomann|Minibackofen 20297|n.A.|2009|nein|
33|Feuerlöscher|Gloria|Protex|n.A.|n.A.|nein|
34|Elko-Kapazitätsmessgerät|Selbstbau|Selbstbau|n.A.|n.A.|nein|Stu
35|Labornetzteil|Selbstbau|Umgebautes ATX-Netzteil|n.A.|n.A.|nein|Stu
36|Staubsauger|Progress|PC3716|n.A.|n.A.|nein|
37|Karstens Scope|Hameg|HM 512|n.A.|n.A.|nein|Karsten
38|Marvins Touchscreen|Acer|Tś30H|nachzutragen|n.A.|nein|
39|Marvin|PC|(alter DSL-Router)|n.A.|n.A.|nein|
40|Heizstrahler|Fakir|Prestige QS 1800|n.A.|n.A.|nein|
inventarnummer
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Etiketten/radial.png

22.5 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment