rbbt-util 5.12.1 → 5.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rbbt/tsv/accessor.rb +7 -6
- data/lib/rbbt/tsv/parallel/traverse.rb +2 -2
- data/lib/rbbt/tsv/parser.rb +10 -1
- data/lib/rbbt/util/misc/objects.rb +10 -6
- data/lib/rbbt/util/misc/pipes.rb +1 -2
- data/lib/rbbt/util/simpleopt/get.rb +4 -0
- data/lib/rbbt/workflow/examples.rb +1 -1
- data/share/rbbt_commands/tsv/info +1 -1
- data/share/rbbt_commands/tsv/unzip +19 -2
- data/share/rbbt_commands/workflow/example +9 -3
- data/share/rbbt_commands/workflow/task +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 957c675de87a163f988c6175828d6de03d346987
|
|
4
|
+
data.tar.gz: 937b879524577ae29d2b41a436ceb0a69e5ba285
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d5959cd1b7e3a412f16f3a28379d8f1cda0e6677b6eefda51072b6b85095567cea8dee27fd9aaa661ff152e5c748a5c90d7f2c6c716c8b177cc57c2b9235c1e
|
|
7
|
+
data.tar.gz: 6ae212b12a951921efe4405568cf57d1bcb84f9a4393f7eec532e8131ae2e1526b8697540019a7bf98909cb0344c0bc82c7092f868bcea98d7840961a28b5087
|
data/lib/rbbt/tsv/accessor.rb
CHANGED
|
@@ -621,7 +621,7 @@ Example:
|
|
|
621
621
|
else
|
|
622
622
|
self.through do |key,values|
|
|
623
623
|
field_values = values.delete_at field_pos
|
|
624
|
-
zipped =
|
|
624
|
+
zipped = Misc.zip_fields(values)
|
|
625
625
|
field_values.zip(zipped).each do |field_value,rest|
|
|
626
626
|
k = [key,field_value]*":"
|
|
627
627
|
new[k] = rest
|
|
@@ -631,11 +631,12 @@ Example:
|
|
|
631
631
|
end
|
|
632
632
|
end
|
|
633
633
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
634
|
+
if self.key_field and self.fields
|
|
635
|
+
new.key_field = [self.key_field, self.fields[field_pos]] * ":"
|
|
636
|
+
new_fields = self.fields.dup
|
|
637
|
+
new_fields.delete_at field_pos
|
|
638
|
+
new.fields = new_fields
|
|
639
|
+
end
|
|
639
640
|
|
|
640
641
|
new
|
|
641
642
|
end
|
|
@@ -306,9 +306,9 @@ module TSV
|
|
|
306
306
|
end
|
|
307
307
|
end
|
|
308
308
|
|
|
309
|
-
def self.traverse_stream(obj, threads, cpus, options, &block)
|
|
309
|
+
def self.traverse_stream(obj, threads = nil, cpus = nil, options = {}, &block)
|
|
310
310
|
into = options[:into]
|
|
311
|
-
thread = Thread.new(Thread.current
|
|
311
|
+
thread = Thread.new(Thread.current) do |parent|
|
|
312
312
|
begin
|
|
313
313
|
traverse_run(obj, threads, cpus, options, &block)
|
|
314
314
|
into.close if into.respond_to? :close
|
data/lib/rbbt/tsv/parser.rb
CHANGED
|
@@ -277,6 +277,15 @@ module TSV
|
|
|
277
277
|
end
|
|
278
278
|
end
|
|
279
279
|
|
|
280
|
+
def cast_values_flat(values)
|
|
281
|
+
case
|
|
282
|
+
when Symbol === cast
|
|
283
|
+
values.collect{|v| v.send(cast)}
|
|
284
|
+
when Proc === cast
|
|
285
|
+
values.collect{|v| cast.call v }
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
280
289
|
def cast_values_double(values)
|
|
281
290
|
case
|
|
282
291
|
when Symbol === cast
|
|
@@ -408,7 +417,7 @@ module TSV
|
|
|
408
417
|
when :flat
|
|
409
418
|
@take_all = true if field_positions.nil?
|
|
410
419
|
self.instance_eval do alias get_values get_values_flat end
|
|
411
|
-
self.instance_eval do alias cast_values
|
|
420
|
+
self.instance_eval do alias cast_values cast_values_flat end
|
|
412
421
|
if merge
|
|
413
422
|
if key_position and key_position != 0 and field_positions.nil?
|
|
414
423
|
self.instance_eval do alias add_to_data add_to_data_flat_merge_keys end
|
|
@@ -35,12 +35,16 @@ module Misc
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def self.append_zipped(current, new)
|
|
38
|
-
current.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
if current.empty?
|
|
39
|
+
current.replace new.collect{|e| [e]}
|
|
40
|
+
else
|
|
41
|
+
current.each do |v|
|
|
42
|
+
n = new.shift
|
|
43
|
+
if Array === n
|
|
44
|
+
v.concat new
|
|
45
|
+
else
|
|
46
|
+
v << n
|
|
47
|
+
end
|
|
44
48
|
end
|
|
45
49
|
end
|
|
46
50
|
current
|
data/lib/rbbt/util/misc/pipes.rb
CHANGED
|
@@ -57,7 +57,7 @@ module Misc
|
|
|
57
57
|
end
|
|
58
58
|
Kernel.exit! 0
|
|
59
59
|
}
|
|
60
|
-
sin.close
|
|
60
|
+
sin.close
|
|
61
61
|
ConcurrentStream.setup sout, :pids => [pid]
|
|
62
62
|
else
|
|
63
63
|
thread = Thread.new(Thread.current) do |parent|
|
|
@@ -181,7 +181,6 @@ module Misc
|
|
|
181
181
|
io.join if io.respond_to? :join
|
|
182
182
|
rescue
|
|
183
183
|
Log.error "Exception consuming stream: #{io.inspect}"
|
|
184
|
-
ddd caller
|
|
185
184
|
Log.exception $!
|
|
186
185
|
io.abort if io.respond_to? :abort
|
|
187
186
|
end
|
|
@@ -25,6 +25,10 @@ module SOPT
|
|
|
25
25
|
value = args.delete_at(i) if value.nil?
|
|
26
26
|
values[input] = value
|
|
27
27
|
else
|
|
28
|
+
if value.nil? and %w(F false FALSE no).include?(args[i])
|
|
29
|
+
Log.warn "Boolean values must are best specified as #{current}[=true|false], not #{ current } [true|false]. Token '#{args[i]}' following '#{current}' automatically assigned as value"
|
|
30
|
+
value = args.delete_at(i)
|
|
31
|
+
end
|
|
28
32
|
values[input] = %w(F false FALSE no).include?(value)? false : true
|
|
29
33
|
end
|
|
30
34
|
end
|
|
@@ -15,7 +15,7 @@ Display summary information. Works with Tokyocabinet HDB and BDB as well.
|
|
|
15
15
|
-tch--tokyocabinet File is a TC HDB
|
|
16
16
|
-tcb--tokyocabinet_bd File is a TC BDB
|
|
17
17
|
-t--type* Type of tsv (single, list, double, flat)
|
|
18
|
-
-
|
|
18
|
+
-hh--header_hash* Change the character used to mark the header line (defaults to #)
|
|
19
19
|
-k--key_field* Change the key field
|
|
20
20
|
-f--fields* Change the fields to load
|
|
21
21
|
-h--help Help
|
|
@@ -3,7 +3,24 @@
|
|
|
3
3
|
require 'rbbt-util'
|
|
4
4
|
require 'rbbt/util/simpleopt'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
|
|
7
|
+
|
|
8
|
+
options = SOPT.setup <<EOF
|
|
9
|
+
Zip fields in a TSV file
|
|
10
|
+
|
|
11
|
+
$ rbbt tsv info [options] file.tsv
|
|
12
|
+
|
|
13
|
+
Display summary information. Works with Tokyocabinet HDB and BDB as well.
|
|
14
|
+
|
|
15
|
+
-tch--tokyocabinet File is a TC HDB
|
|
16
|
+
-tcb--tokyocabinet_bd File is a TC BDB
|
|
17
|
+
-hh--header_hash* Change the character used to mark the header line (defaults to #)
|
|
18
|
+
-m--merge* Merge lines
|
|
19
|
+
-f--field* Field to unzip
|
|
20
|
+
-h--help Help
|
|
21
|
+
EOF
|
|
22
|
+
|
|
23
|
+
SOPT.usage if options[:help]
|
|
7
24
|
|
|
8
25
|
file = ARGV.shift
|
|
9
26
|
|
|
@@ -22,7 +39,7 @@ else
|
|
|
22
39
|
file = file.dup
|
|
23
40
|
Path.setup(File.expand_path(file))
|
|
24
41
|
end
|
|
25
|
-
tsv = TSV.open(file, :type => :double)
|
|
42
|
+
tsv = TSV.open(file, {:type => :double}.merge(options))
|
|
26
43
|
end
|
|
27
44
|
|
|
28
45
|
puts tsv.unzip(field, merge).to_s
|
|
@@ -29,7 +29,7 @@ def run_task(workflow, task, name)
|
|
|
29
29
|
end
|
|
30
30
|
Process.wait @pid
|
|
31
31
|
end
|
|
32
|
-
path = Open.read(res) if File.exists? res
|
|
32
|
+
path = Open.read(res).strip if File.exists? res
|
|
33
33
|
end
|
|
34
34
|
path = "NO RESULT" if path.nil? or path.empty?
|
|
35
35
|
|
|
@@ -51,6 +51,8 @@ task = nil if task == '--'
|
|
|
51
51
|
name = ARGV.shift if task
|
|
52
52
|
name = nil if name == '--'
|
|
53
53
|
|
|
54
|
+
orig_name = name
|
|
55
|
+
|
|
54
56
|
$saved_args = ARGV.dup
|
|
55
57
|
|
|
56
58
|
workflow = Workflow.require_workflow workflow
|
|
@@ -70,8 +72,12 @@ task_result.each do |code,res|
|
|
|
70
72
|
task, name = code
|
|
71
73
|
path, success = res
|
|
72
74
|
if success
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
if orig_name
|
|
76
|
+
puts Open.read(path)
|
|
77
|
+
else
|
|
78
|
+
puts "#{Log.color :green, "SUCCESS"} #{Log.color :magenta, workflow.to_s}##{Log.color :yellow, task} -- #{Log.color :cyan, name}"
|
|
79
|
+
puts path
|
|
80
|
+
end
|
|
75
81
|
else
|
|
76
82
|
puts "#{Log.color :red, "ERROR"} #{Log.color :magenta, workflow.to_s}##{Log.color :yellow, task} -- #{Log.color :cyan, name}"
|
|
77
83
|
puts path
|
|
@@ -100,7 +100,7 @@ def fix_options(workflow, task, job_options)
|
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
when :array
|
|
103
|
-
if input_options[name] and input_options[name][:stream] and String === value
|
|
103
|
+
if input_options[name] and input_options[name][:stream] and String === value and Misc.is_filename? value
|
|
104
104
|
get_value_stream(value)
|
|
105
105
|
else
|
|
106
106
|
if Array === value
|
|
@@ -132,9 +132,11 @@ def fix_options(workflow, task, job_options)
|
|
|
132
132
|
when TSV
|
|
133
133
|
value
|
|
134
134
|
when '-'
|
|
135
|
-
TSV.open(STDIN, :unnamed => true, :sep => $field_separator, :sep2 => $array_separator || "|")
|
|
135
|
+
TSV.open(STDIN, :unnamed => true, :sep => $field_separator, :sep2 => ($array_separator || "|"))
|
|
136
|
+
when (Misc.is_filename?(value) and String)
|
|
137
|
+
TSV.open(value, :unnamed => true, :sep => $field_separator, :sep2 => ($array_separator || "|"))
|
|
136
138
|
else
|
|
137
|
-
TSV.open(value, :unnamed => true, :sep => $field_separator, :sep2 => $array_separator || "|")
|
|
139
|
+
TSV.open(StringIO.new(value), :unnamed => true, :sep => $field_separator, :sep2 => ($array_separator || "|"))
|
|
138
140
|
end
|
|
139
141
|
end
|
|
140
142
|
else
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rbbt-util
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.12.
|
|
4
|
+
version: 5.12.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Miguel Vazquez
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-04-
|
|
11
|
+
date: 2014-04-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|