nwn-lib 0.3.6 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/BINARIES +40 -45
- data/CHANGELOG +4 -0
- data/CHEATSHEET +7 -73
- data/COPYING +1 -1
- data/DATA_STRUCTURES +50 -0
- data/README +27 -37
- data/Rakefile +7 -5
- data/SCRIPTING +44 -0
- data/SETTINGS +80 -0
- data/TYPE_VALUE_INFERRING +93 -0
- data/bin/nwn-dsl +28 -0
- data/bin/nwn-gff +192 -0
- data/bin/nwn-irb +51 -0
- data/data/gff-common-nwn1.yaml +982 -0
- data/lib/nwn/all.rb +7 -0
- data/lib/nwn/gff.rb +47 -861
- data/lib/nwn/gff/api.rb +88 -0
- data/lib/nwn/gff/cexolocstr.rb +28 -0
- data/lib/nwn/gff/field.rb +105 -0
- data/lib/nwn/gff/list.rb +2 -0
- data/lib/nwn/gff/reader.rb +220 -0
- data/lib/nwn/gff/struct.rb +34 -0
- data/lib/nwn/gff/writer.rb +201 -0
- data/lib/nwn/helpers.rb +1 -30
- data/lib/nwn/infer.rb +125 -0
- data/lib/nwn/kivinen.rb +55 -0
- data/lib/nwn/scripting.rb +129 -0
- data/lib/nwn/settings.rb +7 -0
- data/lib/nwn/twoda.rb +105 -7
- data/lib/nwn/yaml.rb +276 -5
- data/scripts/clean_locstrs.rb +46 -0
- data/scripts/extract_all_items.rb +19 -0
- data/scripts/fix_facings.rb +22 -0
- data/scripts/truncate_floats.rb +18 -0
- data/tools/migrate_03x_to_04x.sh +17 -0
- data/tools/verify.sh +35 -0
- metadata +36 -8
- data/bin/nwn-gff-import +0 -69
- data/bin/nwn-gff-irb +0 -62
- data/bin/nwn-gff-print +0 -133
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env nwn-dsl
|
2
|
+
|
3
|
+
# This FILTER walks all cexolocstrs and makes sure
|
4
|
+
# that there are no stray language-ids.
|
5
|
+
#
|
6
|
+
# This is obviously only useful for single-language projects.
|
7
|
+
|
8
|
+
want Gff::Struct
|
9
|
+
|
10
|
+
count = 0
|
11
|
+
|
12
|
+
self.each_by_flat_path do |label, field|
|
13
|
+
next unless field.is_a?(Gff::Cexolocstr)
|
14
|
+
next if field.v.size == 0
|
15
|
+
|
16
|
+
compactable = field.v.values.reject {|x| x == ""}.uniq.size < 2
|
17
|
+
|
18
|
+
unless will_output?
|
19
|
+
unless compactable
|
20
|
+
log "%s: need interactive." % [label]
|
21
|
+
log " %s" % [field.v.inspect]
|
22
|
+
else
|
23
|
+
log "%s: can fix for myself." % label
|
24
|
+
end
|
25
|
+
|
26
|
+
else
|
27
|
+
str = nil
|
28
|
+
unless compactable
|
29
|
+
log "Cannot compact #{label}, because the contained strings are not unique."
|
30
|
+
selection = ask "Use what string?", field.v
|
31
|
+
log "Using: #{selection.inspect}"
|
32
|
+
str = field.v[selection.to_i]
|
33
|
+
else
|
34
|
+
str = field.v[field.v.keys.sort[0]]
|
35
|
+
end
|
36
|
+
field.v.clear
|
37
|
+
field.v[0] = str
|
38
|
+
|
39
|
+
field.str_ref = Gff::Field::DEFAULT_STR_REF
|
40
|
+
|
41
|
+
count += 1
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
log "#{count} str-refs modified." if will_output?
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env nwn-dsl
|
2
|
+
|
3
|
+
# This script will extract all items the worked-on
|
4
|
+
# struct is currently in possession of.
|
5
|
+
o = need ARGV.shift, :bic, :utc, :uti
|
6
|
+
|
7
|
+
log "Extracting .."
|
8
|
+
list = []
|
9
|
+
list += o['Equip_ItemList'].field_value if o['Equip_ItemList']
|
10
|
+
list += o['ItemList'].field_value if o['ItemList']
|
11
|
+
log "#{list.size} items found."
|
12
|
+
list.each_with_index {|item, index|
|
13
|
+
File.open(fname = "item_#{index}.uti", "w") {|file|
|
14
|
+
file.write item.to_gff("UTI")
|
15
|
+
log "Written item: #{item['Tag'].field_value} as #{fname}"
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
log "All done."
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env nwn-dsl
|
2
|
+
|
3
|
+
# The nwn toolset sometimes does weird things with facings;
|
4
|
+
# they flip signedness for no apparent reason.
|
5
|
+
|
6
|
+
# This script fixes that by forcing all facings to be unsigned.
|
7
|
+
|
8
|
+
want Gff::Struct
|
9
|
+
|
10
|
+
count = 0
|
11
|
+
|
12
|
+
self.each_by_flat_path do |label, field|
|
13
|
+
next unless field.is_a?(Gff::Field)
|
14
|
+
next unless field.field_type == :float
|
15
|
+
next unless label =~ %r{\[\d+\]/(Facing|Bearing)$}
|
16
|
+
if field.field_value < 0
|
17
|
+
field.field_value = field.field_value.abs
|
18
|
+
count += 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
log "#{count} bearings modified."
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env nwn-dsl
|
2
|
+
|
3
|
+
# This truncates position floats to a sane width, thus avoiding
|
4
|
+
# miniscule floating point differences in version control diffs.
|
5
|
+
|
6
|
+
PRECISION = 4
|
7
|
+
|
8
|
+
count = 0
|
9
|
+
|
10
|
+
self.each_by_flat_path do |label, field|
|
11
|
+
next unless field.is_a?(Gff::Field)
|
12
|
+
next unless field.field_type == :float
|
13
|
+
field.field_value =
|
14
|
+
("%.#{PRECISION}f" % field.field_value).to_f
|
15
|
+
count += 1
|
16
|
+
end
|
17
|
+
|
18
|
+
log "#{count} floats truncated."
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# This script automages migrating <= 0.3.6-formatted YAML
|
3
|
+
# dumps to the current format.
|
4
|
+
# You need both versions of nwn-lib installed.
|
5
|
+
set -e
|
6
|
+
|
7
|
+
for in_yml in $@; do
|
8
|
+
if [ ! -e "$in_yml" ]; then
|
9
|
+
echo "$in_yml: does not exist"
|
10
|
+
exit 1
|
11
|
+
fi
|
12
|
+
tmp=$1.gff
|
13
|
+
|
14
|
+
echo -n "$in_yml: "
|
15
|
+
( nwn-gff-import _0.3.6_ -y $in_yml | nwn-gff -lg -ky > $tmp ) && mv $tmp $in_yml
|
16
|
+
echo "ok."
|
17
|
+
done
|
data/tools/verify.sh
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
cmp() {
|
4
|
+
gffcmp.pl -d $1 $2 | \
|
5
|
+
fgrep -v "File $2 do not match" | \
|
6
|
+
egrep -v "^Number of items in localized string array .* differ, " | \
|
7
|
+
egrep -v "^Localized string array .* differ, key .* missing$" | \
|
8
|
+
egrep -v "^Key .* missing from" | \
|
9
|
+
fgrep -v "Number of keys at level" | \
|
10
|
+
fgrep -v "First gff has extra key"
|
11
|
+
}
|
12
|
+
|
13
|
+
tmp=/tmp/nwn-gff-tmp
|
14
|
+
|
15
|
+
for x in $@; do
|
16
|
+
|
17
|
+
echo "| $x: test kivinen printer: y -> k | cmp" | ts
|
18
|
+
nwn-gff -i$x -kk -t | gffencode.pl - -o $tmp
|
19
|
+
cmp $x $tmp
|
20
|
+
|
21
|
+
echo "| $x: test gff printer: y -> g | cmp" | ts
|
22
|
+
nwn-gff -i$x -kg > $tmp
|
23
|
+
cmp $x $tmp
|
24
|
+
|
25
|
+
echo "| $x: test marshal re-read: m -> m -> k | cmp" | ts
|
26
|
+
nwn-gff -i$x -km | nwn-gff -lm -kk -t | gffencode.pl - -o $tmp
|
27
|
+
cmp $x $tmp
|
28
|
+
|
29
|
+
echo "| $x: test yaml re-read: y -> y -> k | cmp" | ts
|
30
|
+
nwn-gff -i$x -ky | nwn-gff -ly -ky | tee /tmp/blah | \
|
31
|
+
nwn-gff -ly -kk -t | gffencode.pl - -o $tmp
|
32
|
+
cmp $x $tmp
|
33
|
+
done
|
34
|
+
|
35
|
+
exit 0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nwn-lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernhard Stoeckner
|
@@ -9,21 +9,25 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-02-03 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: a ruby library for accessing Neverwinter Nights resource files
|
17
17
|
email: elven@swordcoast.net
|
18
18
|
executables:
|
19
|
-
- nwn-gff
|
20
|
-
- nwn-
|
21
|
-
- nwn-
|
19
|
+
- nwn-gff
|
20
|
+
- nwn-dsl
|
21
|
+
- nwn-irb
|
22
22
|
extensions: []
|
23
23
|
|
24
24
|
extra_rdoc_files:
|
25
25
|
- README
|
26
26
|
- BINARIES
|
27
|
+
- DATA_STRUCTURES
|
28
|
+
- SCRIPTING
|
29
|
+
- SETTINGS
|
30
|
+
- TYPE_VALUE_INFERRING
|
27
31
|
- CHEATSHEET
|
28
32
|
- CHANGELOG
|
29
33
|
- COPYING
|
@@ -32,17 +36,41 @@ files:
|
|
32
36
|
- CHANGELOG
|
33
37
|
- README
|
34
38
|
- Rakefile
|
35
|
-
- bin/nwn-
|
36
|
-
- bin/nwn-gff
|
37
|
-
- bin/nwn-
|
39
|
+
- bin/nwn-dsl
|
40
|
+
- bin/nwn-gff
|
41
|
+
- bin/nwn-irb
|
38
42
|
- spec/spec.opts
|
39
43
|
- spec/rcov.opts
|
40
44
|
- lib/nwn
|
45
|
+
- lib/nwn/scripting.rb
|
41
46
|
- lib/nwn/yaml.rb
|
42
47
|
- lib/nwn/twoda.rb
|
48
|
+
- lib/nwn/settings.rb
|
43
49
|
- lib/nwn/gff.rb
|
50
|
+
- lib/nwn/infer.rb
|
51
|
+
- lib/nwn/kivinen.rb
|
52
|
+
- lib/nwn/all.rb
|
44
53
|
- lib/nwn/helpers.rb
|
54
|
+
- lib/nwn/gff
|
55
|
+
- lib/nwn/gff/field.rb
|
56
|
+
- lib/nwn/gff/reader.rb
|
57
|
+
- lib/nwn/gff/cexolocstr.rb
|
58
|
+
- lib/nwn/gff/struct.rb
|
59
|
+
- lib/nwn/gff/list.rb
|
60
|
+
- lib/nwn/gff/writer.rb
|
61
|
+
- lib/nwn/gff/api.rb
|
62
|
+
- tools/verify.sh
|
63
|
+
- tools/migrate_03x_to_04x.sh
|
64
|
+
- scripts/truncate_floats.rb
|
65
|
+
- scripts/fix_facings.rb
|
66
|
+
- scripts/clean_locstrs.rb
|
67
|
+
- scripts/extract_all_items.rb
|
68
|
+
- data/gff-common-nwn1.yaml
|
45
69
|
- BINARIES
|
70
|
+
- DATA_STRUCTURES
|
71
|
+
- SCRIPTING
|
72
|
+
- SETTINGS
|
73
|
+
- TYPE_VALUE_INFERRING
|
46
74
|
- CHEATSHEET
|
47
75
|
has_rdoc: true
|
48
76
|
homepage: http://nwn-lib.elv.es
|
data/bin/nwn-gff-import
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
require 'rubygems'
|
3
|
-
require 'optparse'
|
4
|
-
require 'nwn/gff'
|
5
|
-
require 'nwn/helpers'
|
6
|
-
require 'yaml'
|
7
|
-
|
8
|
-
format = nil
|
9
|
-
postfix = nil
|
10
|
-
outfile = nil
|
11
|
-
|
12
|
-
OptionParser.new do |o|
|
13
|
-
o.banner = "Usage: nwn-gff-import [options] file/- [file, file, file]"
|
14
|
-
|
15
|
-
o.on "-y", "--yaml", "Import as yaml" do
|
16
|
-
format = :yaml
|
17
|
-
end
|
18
|
-
o.on "-m", "--marshal", "Import as native ruby marshal data" do
|
19
|
-
format = :marshal
|
20
|
-
end
|
21
|
-
|
22
|
-
o.on "-o", "--outfile F", "Write to outfile instead of stdout" do |out|
|
23
|
-
outfile = out
|
24
|
-
end
|
25
|
-
|
26
|
-
o.on "--postfix P", "Strip the given postfix from file and write to that instead of stdout (overrides -o)" do |p|
|
27
|
-
postfix = p
|
28
|
-
end
|
29
|
-
|
30
|
-
end.parse!
|
31
|
-
|
32
|
-
ARGV.size > 0 or begin
|
33
|
-
$stderr.puts "Required argument: filename to read, or - for stdin (try -h)."
|
34
|
-
exit 1
|
35
|
-
end
|
36
|
-
|
37
|
-
ARGV.each do |infile|
|
38
|
-
data = nil
|
39
|
-
|
40
|
-
if !postfix && !outfile
|
41
|
-
outfile = $stdout
|
42
|
-
elsif postfix && outfile
|
43
|
-
outfile = outfile.gsub(/#{Regexp.escape(postfix)}$/, "")
|
44
|
-
outfile = File.new(outfile, "w")
|
45
|
-
elsif outfile && !postfix
|
46
|
-
outfile = File.new(outfile, "w")
|
47
|
-
end
|
48
|
-
|
49
|
-
inbytes = infile == "-" ? $stdin.read : IO.read(infile)
|
50
|
-
|
51
|
-
case format
|
52
|
-
when :yaml
|
53
|
-
data = YAML.load(inbytes)
|
54
|
-
when :marshal
|
55
|
-
data = Marshal.load(inbytes)
|
56
|
-
else
|
57
|
-
raise ArgumentError, "Unknown format; try -h"
|
58
|
-
end
|
59
|
-
|
60
|
-
raise ArgumentError, "Input stream is NOT a valid gff object" unless
|
61
|
-
data.is_a?(NWN::Gff::Gff)
|
62
|
-
|
63
|
-
outbytes = NWN::Gff::Writer.dump(data)
|
64
|
-
|
65
|
-
|
66
|
-
outfile.write(outbytes)
|
67
|
-
|
68
|
-
outfile.close
|
69
|
-
end
|
data/bin/nwn-gff-irb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
require 'rubygems'
|
3
|
-
require 'optparse'
|
4
|
-
require 'nwn/gff'
|
5
|
-
require 'nwn/twoda'
|
6
|
-
require 'yaml'
|
7
|
-
require 'irb'
|
8
|
-
require 'irb/completion'
|
9
|
-
|
10
|
-
OptionParser.new do |o|
|
11
|
-
o.banner = "Usage: nwn-gff-irb file"
|
12
|
-
end.parse!
|
13
|
-
|
14
|
-
file = ARGV.shift or begin
|
15
|
-
$stderr.puts "Required argument: filename to process, or - for stdin (try -h)."
|
16
|
-
exit 1
|
17
|
-
end
|
18
|
-
|
19
|
-
if file == "-"
|
20
|
-
bytes = $stdin.read
|
21
|
-
else
|
22
|
-
bytes = IO.read(file)
|
23
|
-
end
|
24
|
-
$file = File.expand_path(file)
|
25
|
-
|
26
|
-
if File.extname($file) == ".yml"
|
27
|
-
GFF = YAML.load(bytes)
|
28
|
-
else
|
29
|
-
GFF = NWN::Gff::Reader.read(bytes)
|
30
|
-
end
|
31
|
-
|
32
|
-
def save destination = nil
|
33
|
-
destination ||= $file
|
34
|
-
puts "Saving to ´#{destination}' .."
|
35
|
-
if File.extname($file) == ".yml"
|
36
|
-
bytes = GFF.to_yaml
|
37
|
-
else
|
38
|
-
bytes = NWN::Gff::Writer.dump(GFF)
|
39
|
-
end
|
40
|
-
File.open(destination, "w") {|f|
|
41
|
-
f.write(bytes)
|
42
|
-
}
|
43
|
-
puts "saved."
|
44
|
-
end
|
45
|
-
|
46
|
-
if __cache_location = ENV['NWN2DAHOME']
|
47
|
-
require 'nwn/helpers'
|
48
|
-
puts "Setting up 2da cache at #{__cache_location} .."
|
49
|
-
NWN::TwoDA::Cache.setup __cache_location
|
50
|
-
else
|
51
|
-
puts "Warning: Environment variable `NWN2DAHOME' is not available, not using 2da cache (helpers not available)."
|
52
|
-
end
|
53
|
-
|
54
|
-
include NWN::Gff
|
55
|
-
include NWN::TwoDA
|
56
|
-
|
57
|
-
puts "Your GFF file is in `GFF' (type: #{GFF.type.inspect})."
|
58
|
-
puts "Type `save' to save to the filename it came from (make a backup!), `exit' (or Ctrl+D) to exit (without saving)."
|
59
|
-
puts "To save to a different location, type `save \"path/to/new/location.ext\"'."
|
60
|
-
puts ""
|
61
|
-
|
62
|
-
IRB.start
|
data/bin/nwn-gff-print
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
require 'rubygems'
|
3
|
-
require 'optparse'
|
4
|
-
require 'nwn/gff'
|
5
|
-
require 'nwn/helpers'
|
6
|
-
require 'yaml'
|
7
|
-
require 'nwn/yaml'
|
8
|
-
|
9
|
-
format = nil
|
10
|
-
types_too = false
|
11
|
-
full = false
|
12
|
-
file_type = nil
|
13
|
-
struct_id = nil
|
14
|
-
path = nil
|
15
|
-
prefix = :none
|
16
|
-
postfix = nil
|
17
|
-
verbose = false
|
18
|
-
options = {}
|
19
|
-
|
20
|
-
OptionParser.new do |o|
|
21
|
-
o.banner = "Usage: nwn-gff-print [options] file/- [file, file, ..]"
|
22
|
-
|
23
|
-
o.on "-y", "--yaml", "Dump as yaml" do
|
24
|
-
format = :yaml
|
25
|
-
end
|
26
|
-
|
27
|
-
o.on "-k", "--kivinen", "Dump as kivinens dump format (like the perl tools)" do
|
28
|
-
format = :kivinen
|
29
|
-
end
|
30
|
-
o.on "--kivinen-full-path", "Print the full path (implies -k)" do
|
31
|
-
format = :kivinen
|
32
|
-
full = true
|
33
|
-
end
|
34
|
-
|
35
|
-
o.on "-b", "--print-basename", "Prefix the file basename to the output" do |b|
|
36
|
-
prefix = :base
|
37
|
-
end
|
38
|
-
o.on "-f", "--print-filename", "Prefix the full filename to the output" do |b|
|
39
|
-
prefix = :full
|
40
|
-
end
|
41
|
-
|
42
|
-
o.on "-t", "--print-types", "Print types as well" do
|
43
|
-
types_too = true
|
44
|
-
end
|
45
|
-
|
46
|
-
o.on "-m", "--marshal", "Native ruby marshalling. Warning: raw bytes" do
|
47
|
-
format = :marshal
|
48
|
-
end
|
49
|
-
|
50
|
-
o.on "--postfix P", "Write output to file postfixed with P instead of stdout" do |p|
|
51
|
-
postfix = p
|
52
|
-
end
|
53
|
-
|
54
|
-
o.on "--float_rounding F", "Round floating point numbers to the specified number of righthand digits" do |fr|
|
55
|
-
options[:float_rounding] = fr.to_i
|
56
|
-
end
|
57
|
-
|
58
|
-
o.on "--type filetype", "Override the file type (implies --struct 0xffffffff)" do |t|
|
59
|
-
if t.size != 3
|
60
|
-
$stderr.puts "Invalid type #{t} passwd."
|
61
|
-
exit 1
|
62
|
-
end
|
63
|
-
file_type = t.upcase + " "
|
64
|
-
struct_id = 0xffffffff
|
65
|
-
end
|
66
|
-
|
67
|
-
o.on "--struct id", "Override struct id (as hex, please)" do |s|
|
68
|
-
struct_id = s.hex
|
69
|
-
end
|
70
|
-
o.on "-p=path", "--path path", "Only print the given path" do |p|
|
71
|
-
path = p
|
72
|
-
end
|
73
|
-
|
74
|
-
o.on "-v", "--verbose", "Be verbose" do
|
75
|
-
verbose = true
|
76
|
-
end
|
77
|
-
end.parse!
|
78
|
-
|
79
|
-
ARGV.size > 0 or begin
|
80
|
-
$stderr.puts "Required argument: filename to read, or - for stdin (try -h)."
|
81
|
-
exit 1
|
82
|
-
end
|
83
|
-
|
84
|
-
ARGV.each {|file|
|
85
|
-
|
86
|
-
if file == "-"
|
87
|
-
bytes = $stdin.read
|
88
|
-
else
|
89
|
-
bytes = IO.read(file)
|
90
|
-
end
|
91
|
-
|
92
|
-
g = NWN::Gff::Reader.read(bytes, options)
|
93
|
-
|
94
|
-
if path
|
95
|
-
begin
|
96
|
-
g = g[path]
|
97
|
-
rescue Exception => e
|
98
|
-
$stderr.puts "Error: " + e.to_s
|
99
|
-
exit 1
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
my_prefix = case prefix
|
104
|
-
when :none
|
105
|
-
""
|
106
|
-
when :base
|
107
|
-
File.basename(file) + ": "
|
108
|
-
when :full
|
109
|
-
File.expand_path(file) + ": "
|
110
|
-
end
|
111
|
-
|
112
|
-
write_to = postfix ? File.new(file + postfix, "w") : $stdout
|
113
|
-
$stderr.puts "Processing `#{file}`" if verbose
|
114
|
-
case format
|
115
|
-
when :yaml
|
116
|
-
if prefix == :none
|
117
|
-
write_to.puts g.to_yaml
|
118
|
-
else
|
119
|
-
write_to.puts g.to_yaml.split("\n").map {|ln| my_prefix + ln }.join("\n")
|
120
|
-
end
|
121
|
-
when :kivinen
|
122
|
-
NWN::Gff.kivinen_format g, my_prefix + "/", types_too, full, file_type, struct_id do |label, value|
|
123
|
-
write_to.puts "%s:\t%s" % [label, value]
|
124
|
-
end
|
125
|
-
when :marshal
|
126
|
-
write_to.print Marshal.dump(g)
|
127
|
-
else
|
128
|
-
$stderr.puts "Unknown format; try -h"
|
129
|
-
exit 1
|
130
|
-
end
|
131
|
-
|
132
|
-
write_to.close if postfix
|
133
|
-
}
|