rbbt-util 5.44.1 → 6.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rbbt +67 -90
- data/etc/app.d/base.rb +2 -2
- data/etc/app.d/semaphores.rb +3 -3
- data/lib/rbbt/annotations/annotated_array.rb +207 -207
- data/lib/rbbt/annotations/refactor.rb +27 -0
- data/lib/rbbt/annotations/util.rb +282 -282
- data/lib/rbbt/annotations.rb +343 -320
- data/lib/rbbt/association/database.rb +200 -225
- data/lib/rbbt/association/index.rb +294 -291
- data/lib/rbbt/association/item.rb +227 -227
- data/lib/rbbt/association/open.rb +35 -34
- data/lib/rbbt/association/util.rb +0 -169
- data/lib/rbbt/association.rb +2 -4
- data/lib/rbbt/entity/identifiers.rb +119 -118
- data/lib/rbbt/entity/refactor.rb +12 -0
- data/lib/rbbt/entity.rb +319 -315
- data/lib/rbbt/hpc/batch.rb +72 -53
- data/lib/rbbt/hpc/lsf.rb +2 -2
- data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
- data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
- data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
- data/lib/rbbt/hpc/orchestrate.rb +19 -13
- data/lib/rbbt/hpc/slurm.rb +18 -18
- data/lib/rbbt/knowledge_base/entity.rb +13 -5
- data/lib/rbbt/knowledge_base/query.rb +2 -2
- data/lib/rbbt/knowledge_base/registry.rb +32 -31
- data/lib/rbbt/knowledge_base/traverse.rb +1 -1
- data/lib/rbbt/knowledge_base.rb +1 -1
- data/lib/rbbt/monitor.rb +36 -25
- data/lib/rbbt/persist/refactor.rb +166 -0
- data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
- data/lib/rbbt/persist/tsv.rb +187 -185
- data/lib/rbbt/persist.rb +556 -551
- data/lib/rbbt/refactor.rb +20 -0
- data/lib/rbbt/resource/path/refactor.rb +178 -0
- data/lib/rbbt/resource/path.rb +317 -497
- data/lib/rbbt/resource/util.rb +0 -48
- data/lib/rbbt/resource.rb +3 -390
- data/lib/rbbt/tsv/accessor.rb +2 -838
- data/lib/rbbt/tsv/attach.rb +303 -299
- data/lib/rbbt/tsv/change_id.rb +244 -245
- data/lib/rbbt/tsv/csv.rb +87 -85
- data/lib/rbbt/tsv/dumper.rb +2 -100
- data/lib/rbbt/tsv/excel.rb +26 -24
- data/lib/rbbt/tsv/field_index.rb +4 -1
- data/lib/rbbt/tsv/filter.rb +3 -2
- data/lib/rbbt/tsv/index.rb +2 -284
- data/lib/rbbt/tsv/manipulate.rb +750 -747
- data/lib/rbbt/tsv/marshal.rb +3 -3
- data/lib/rbbt/tsv/matrix.rb +2 -2
- data/lib/rbbt/tsv/parallel/through.rb +2 -1
- data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
- data/lib/rbbt/tsv/parser.rb +678 -678
- data/lib/rbbt/tsv/refactor.rb +195 -0
- data/lib/rbbt/tsv/stream.rb +253 -251
- data/lib/rbbt/tsv/util.rb +420 -420
- data/lib/rbbt/tsv.rb +210 -208
- data/lib/rbbt/util/R/eval.rb +4 -4
- data/lib/rbbt/util/R/plot.rb +62 -166
- data/lib/rbbt/util/R.rb +21 -18
- data/lib/rbbt/util/cmd.rb +2 -318
- data/lib/rbbt/util/color.rb +269 -269
- data/lib/rbbt/util/colorize.rb +89 -89
- data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
- data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
- data/lib/rbbt/util/concurrency/processes.rb +389 -386
- data/lib/rbbt/util/config.rb +169 -167
- data/lib/rbbt/util/iruby.rb +20 -0
- data/lib/rbbt/util/log/progress/report.rb +241 -241
- data/lib/rbbt/util/log/progress/util.rb +99 -99
- data/lib/rbbt/util/log/progress.rb +102 -102
- data/lib/rbbt/util/log/refactor.rb +49 -0
- data/lib/rbbt/util/log.rb +486 -532
- data/lib/rbbt/util/migrate.rb +1 -1
- data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
- data/lib/rbbt/util/misc/development.rb +12 -11
- data/lib/rbbt/util/misc/exceptions.rb +117 -112
- data/lib/rbbt/util/misc/format.rb +2 -230
- data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
- data/lib/rbbt/util/misc/inspect.rb +2 -476
- data/lib/rbbt/util/misc/lock.rb +109 -106
- data/lib/rbbt/util/misc/omics.rb +9 -1
- data/lib/rbbt/util/misc/pipes.rb +765 -793
- data/lib/rbbt/util/misc/refactor.rb +20 -0
- data/lib/rbbt/util/misc/ssw.rb +27 -17
- data/lib/rbbt/util/misc/system.rb +0 -15
- data/lib/rbbt/util/misc.rb +39 -20
- data/lib/rbbt/util/named_array/refactor.rb +4 -0
- data/lib/rbbt/util/named_array.rb +3 -220
- data/lib/rbbt/util/open/refactor.rb +7 -0
- data/lib/rbbt/util/open.rb +3 -857
- data/lib/rbbt/util/procpath.rb +6 -6
- data/lib/rbbt/util/python/paths.rb +27 -0
- data/lib/rbbt/util/python/run.rb +115 -0
- data/lib/rbbt/util/python/script.rb +110 -0
- data/lib/rbbt/util/python/util.rb +3 -3
- data/lib/rbbt/util/python.rb +22 -81
- data/lib/rbbt/util/semaphore.rb +152 -148
- data/lib/rbbt/util/simpleopt.rb +9 -8
- data/lib/rbbt/util/ssh/refactor.rb +19 -0
- data/lib/rbbt/util/ssh.rb +122 -118
- data/lib/rbbt/util/tar.rb +117 -115
- data/lib/rbbt/util/tmpfile.rb +69 -67
- data/lib/rbbt/util/version.rb +2 -0
- data/lib/rbbt/workflow/refactor/entity.rb +11 -0
- data/lib/rbbt/workflow/refactor/export.rb +66 -0
- data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
- data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
- data/lib/rbbt/workflow/refactor/task_info.rb +65 -0
- data/lib/rbbt/workflow/refactor.rb +153 -0
- data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
- data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
- data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
- data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
- data/lib/rbbt/workflow/remote_workflow.rb +6 -1
- data/lib/rbbt/workflow/step/run.rb +766 -766
- data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
- data/lib/rbbt/workflow/step.rb +2 -362
- data/lib/rbbt/workflow/task.rb +118 -118
- data/lib/rbbt/workflow/usage.rb +289 -287
- data/lib/rbbt/workflow/util/archive.rb +6 -5
- data/lib/rbbt/workflow/util/data.rb +1 -1
- data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
- data/lib/rbbt/workflow/util/trace.rb +79 -44
- data/lib/rbbt/workflow.rb +4 -882
- data/lib/rbbt-util.rb +21 -13
- data/lib/rbbt.rb +16 -3
- data/python/rbbt/__init__.py +19 -1
- data/share/Rlib/plot.R +37 -37
- data/share/Rlib/svg.R +22 -5
- data/share/install/software/lib/install_helpers +1 -1
- data/share/rbbt_commands/hpc/list +2 -3
- data/share/rbbt_commands/hpc/orchestrate +4 -4
- data/share/rbbt_commands/hpc/tail +2 -0
- data/share/rbbt_commands/hpc/task +10 -7
- data/share/rbbt_commands/lsf/list +2 -3
- data/share/rbbt_commands/lsf/orchestrate +4 -4
- data/share/rbbt_commands/lsf/tail +2 -0
- data/share/rbbt_commands/lsf/task +10 -7
- data/share/rbbt_commands/migrate +1 -1
- data/share/rbbt_commands/pbs/list +2 -3
- data/share/rbbt_commands/pbs/orchestrate +4 -4
- data/share/rbbt_commands/pbs/tail +2 -0
- data/share/rbbt_commands/pbs/task +10 -7
- data/share/rbbt_commands/resource/produce +8 -1
- data/share/rbbt_commands/slurm/list +2 -3
- data/share/rbbt_commands/slurm/orchestrate +4 -4
- data/share/rbbt_commands/slurm/tail +2 -0
- data/share/rbbt_commands/slurm/task +10 -7
- data/share/rbbt_commands/system/clean +5 -5
- data/share/rbbt_commands/system/status +5 -5
- data/share/rbbt_commands/tsv/get +2 -3
- data/share/rbbt_commands/tsv/info +10 -13
- data/share/rbbt_commands/tsv/keys +18 -14
- data/share/rbbt_commands/tsv/slice +2 -2
- data/share/rbbt_commands/tsv/transpose +6 -2
- data/share/rbbt_commands/workflow/info +20 -24
- data/share/rbbt_commands/workflow/list +1 -1
- data/share/rbbt_commands/workflow/prov +20 -13
- data/share/rbbt_commands/workflow/server +11 -1
- data/share/rbbt_commands/workflow/task +76 -71
- data/share/rbbt_commands/workflow/write_info +26 -9
- data/share/software/opt/ssw/ssw.c +861 -0
- data/share/software/opt/ssw/ssw.h +130 -0
- data/share/workflow_config.ru +3 -3
- metadata +40 -2
data/lib/rbbt/tsv/csv.rb
CHANGED
@@ -1,85 +1,87 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
when
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
CSV.read obj, options
|
32
|
-
|
33
|
-
CSV.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
key,
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
when :
|
61
|
-
tsv
|
62
|
-
when :
|
63
|
-
tsv[key] = values
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
when :
|
74
|
-
tsv.
|
75
|
-
when :
|
76
|
-
tsv.
|
77
|
-
when :
|
78
|
-
tsv.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
1
|
+
require_relative '../refactor'
|
2
|
+
Rbbt.require_instead 'scout/tsv'
|
3
|
+
#require 'csv'
|
4
|
+
#
|
5
|
+
#module TSV
|
6
|
+
# def self.csv(obj, options = {})
|
7
|
+
# options = Misc.add_defaults IndiferentHash.setup(options.dup), :headers => true, :type => :list
|
8
|
+
# headers = options[:headers]
|
9
|
+
#
|
10
|
+
# noheaders = ! headers
|
11
|
+
#
|
12
|
+
# type = options.delete :type
|
13
|
+
# cast = options.delete :cast
|
14
|
+
# merge = options.delete :merge
|
15
|
+
# key_field = options.delete :key_field
|
16
|
+
# fields = options.delete :fields
|
17
|
+
#
|
18
|
+
# if key_field || fields
|
19
|
+
# orig_type = type
|
20
|
+
# type = :double
|
21
|
+
# merge = true
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# options[:headers] = false
|
25
|
+
#
|
26
|
+
# csv = case obj
|
27
|
+
# when Path
|
28
|
+
# CSV.read obj.find.open, **options
|
29
|
+
# when String
|
30
|
+
# if Open.remote?(obj)
|
31
|
+
# CSV.read Open.open(obj), **options
|
32
|
+
# elsif Misc.is_filename?(obj)
|
33
|
+
# CSV.read obj, **options
|
34
|
+
# else
|
35
|
+
# CSV.new obj, **options
|
36
|
+
# end
|
37
|
+
# else
|
38
|
+
# CSV.new obj, **options
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# tsv = if noheaders
|
42
|
+
# TSV.setup({}, :key_field => nil, :fields => nil, :type => type)
|
43
|
+
# else
|
44
|
+
# key, *csv_fields = csv.shift
|
45
|
+
# TSV.setup({}, :key_field => key, :fields => csv_fields, :type => type)
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# csv.each_with_index do |row,i|
|
49
|
+
# if noheaders
|
50
|
+
# key, values = ["row-#{i}", row]
|
51
|
+
# else
|
52
|
+
# key, *values = row
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# if cast
|
56
|
+
# values = values.collect{|v| v.send cast }
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# case type
|
60
|
+
# when :double, :flat
|
61
|
+
# tsv.zip_new(key, values)
|
62
|
+
# when :single
|
63
|
+
# tsv[key] = values.first
|
64
|
+
# when :list
|
65
|
+
# tsv[key] = values
|
66
|
+
# end
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# if key_field || fields
|
70
|
+
# tsv = tsv.reorder(key_field, fields, :zipped => true, :merge => true)
|
71
|
+
# if tsv.type != orig_type
|
72
|
+
# tsv = case orig_type
|
73
|
+
# when :list
|
74
|
+
# tsv.to_list
|
75
|
+
# when :single
|
76
|
+
# tsv.to_single
|
77
|
+
# when :list
|
78
|
+
# tsv.to_list
|
79
|
+
# when :flat
|
80
|
+
# tsv.to_flat
|
81
|
+
# end
|
82
|
+
# end
|
83
|
+
# end
|
84
|
+
#
|
85
|
+
# tsv
|
86
|
+
# end
|
87
|
+
#end
|
data/lib/rbbt/tsv/dumper.rb
CHANGED
@@ -1,100 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
attr_accessor :in_stream, :stream, :options, :filename, :sep
|
4
|
-
def self.stream(options = {}, filename = nil, stream = nil, &block)
|
5
|
-
dumper = TSV::Dumper.new options, filename
|
6
|
-
if stream
|
7
|
-
dumper.set_stream stream if stream
|
8
|
-
yield dumper
|
9
|
-
stream
|
10
|
-
else
|
11
|
-
thread = Thread.new(Thread.current) do |parent|
|
12
|
-
yield dumper
|
13
|
-
end
|
14
|
-
ConcurrentStream.setup(dumper.stream, threads: thread)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def set_stream(stream)
|
19
|
-
@stream.close
|
20
|
-
@in_stream.close
|
21
|
-
@in_stream = @stream = stream
|
22
|
-
end
|
23
|
-
|
24
|
-
def initialize(options, filename = nil)
|
25
|
-
if TSV === options
|
26
|
-
@options = options.options.merge(:key_field => options.key_field, :fields => options.fields)
|
27
|
-
@filename ||= options.filename
|
28
|
-
else
|
29
|
-
@options = options
|
30
|
-
@filename = filename
|
31
|
-
end
|
32
|
-
@filename ||= Misc.fingerprint options
|
33
|
-
@stream, @in_stream = Misc.pipe
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.values_to_s(values, fields = nil, sep = "\t")
|
37
|
-
sep = "\t" if sep.nil?
|
38
|
-
case values
|
39
|
-
when nil
|
40
|
-
if fields.nil? or fields.empty?
|
41
|
-
"\n"
|
42
|
-
else
|
43
|
-
sep + ([""] * fields.length) * sep << "\n"
|
44
|
-
end
|
45
|
-
when Array
|
46
|
-
if fields.nil?
|
47
|
-
sep + (values.collect{|v| Array === v ? v * "|" : v} * sep) << "\n"
|
48
|
-
elsif fields.empty?
|
49
|
-
"\n"
|
50
|
-
else
|
51
|
-
sep + (values.collect{|v| Array === v ? v * "|" : v} * sep) << "\n"
|
52
|
-
end
|
53
|
-
else
|
54
|
-
if fields.nil?
|
55
|
-
sep + values.to_s + "\n"
|
56
|
-
elsif fields.empty?
|
57
|
-
"\n"
|
58
|
-
else
|
59
|
-
sep + values.to_s << "\n"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def init(init_options = {})
|
65
|
-
options = @options.dup
|
66
|
-
key_field, fields = Misc.process_options options, :key_field, :fields
|
67
|
-
|
68
|
-
str = TSV.header_lines(key_field, fields, options.merge(init_options || {}))
|
69
|
-
|
70
|
-
Thread.pass while IO.select(nil, [@in_stream],nil,1).nil? if IO === @in_stream
|
71
|
-
|
72
|
-
@in_stream << str
|
73
|
-
end
|
74
|
-
|
75
|
-
def add(k,v)
|
76
|
-
@fields ||= @options[:fields]
|
77
|
-
@sep ||= @options[:sep]
|
78
|
-
begin
|
79
|
-
Thread.pass while IO.select(nil, [@in_stream],nil,1).nil? if IO === @in_stream
|
80
|
-
@in_stream << k << TSV::Dumper.values_to_s(v, @fields, @sep)
|
81
|
-
rescue IOError
|
82
|
-
rescue Exception
|
83
|
-
raise $!
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def close_out
|
88
|
-
@stream.close unless StringIO === @stream || @stream.closed?
|
89
|
-
end
|
90
|
-
|
91
|
-
def close_in
|
92
|
-
@in_stream.join if @in_stream.respond_to?(:join) && ! @in_stream.joined?
|
93
|
-
@in_stream.close if @in_stream.respond_to?(:close) && ! @in_stream.closed?
|
94
|
-
end
|
95
|
-
|
96
|
-
def close
|
97
|
-
close_in unless @in_stream == @stream
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
1
|
+
require_relative '../refactor'
|
2
|
+
Rbbt.require_instead 'scout/tsv'
|
data/lib/rbbt/tsv/excel.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
require_relative '../refactor'
|
2
|
+
Rbbt.require_instead 'scout/tsv'
|
1
3
|
require 'spreadsheet'
|
2
4
|
require 'rubyXL'
|
3
5
|
|
4
6
|
module TSV
|
5
7
|
|
6
8
|
def self._remove_link(value)
|
7
|
-
if value =~ /<([\w]+)[^>]*>(.*?)<\/\1>/
|
9
|
+
if String === value && value =~ /<([\w]+)[^>]*>(.*?)<\/\1>/
|
8
10
|
$2
|
9
11
|
else
|
10
12
|
value
|
@@ -28,14 +30,14 @@ module TSV
|
|
28
30
|
|
29
31
|
|
30
32
|
def self._excel_data(tsv, options ={})
|
31
|
-
options =
|
33
|
+
options = IndiferentHash.add_defaults options, :sep2 => ', '
|
32
34
|
|
33
|
-
name =
|
34
|
-
sep2 =
|
35
|
-
unmerge =
|
36
|
-
sort_by =
|
37
|
-
sort_by_cast =
|
38
|
-
remove_links =
|
35
|
+
name = IndiferentHash.process_options options, :name
|
36
|
+
sep2 = IndiferentHash.process_options options, :sep2
|
37
|
+
unmerge = IndiferentHash.process_options options, :unmerge
|
38
|
+
sort_by = IndiferentHash.process_options options, :sort_by
|
39
|
+
sort_by_cast = IndiferentHash.process_options options, :sort_by_cast
|
40
|
+
remove_links = IndiferentHash.process_options options, :remove_links
|
39
41
|
|
40
42
|
i = 1
|
41
43
|
if sort_by
|
@@ -83,7 +85,7 @@ module TSV
|
|
83
85
|
new_rows = []
|
84
86
|
rows.each do |row|
|
85
87
|
header = row.shift
|
86
|
-
|
88
|
+
NamedArray.zip_fields(row).each do |values|
|
87
89
|
new_rows << [header] + values
|
88
90
|
end
|
89
91
|
end
|
@@ -94,11 +96,11 @@ module TSV
|
|
94
96
|
|
95
97
|
module XLS
|
96
98
|
def self.read(file, options = {})
|
97
|
-
options =
|
98
|
-
sheet =
|
99
|
-
header =
|
100
|
-
text =
|
101
|
-
skip_rows =
|
99
|
+
options = IndiferentHash.add_defaults options, :sep2 => /[,|]\s?/, :skip_rows => 0
|
100
|
+
sheet = IndiferentHash.process_options options, :sheet
|
101
|
+
header = IndiferentHash.process_options options, :header
|
102
|
+
text = IndiferentHash.process_options options, :text
|
103
|
+
skip_rows = IndiferentHash.process_options options, :skip_rows
|
102
104
|
skip_rows = skip_rows.to_i
|
103
105
|
|
104
106
|
header = true unless header == false
|
@@ -112,7 +114,7 @@ module TSV
|
|
112
114
|
sheet_name = sheet
|
113
115
|
Log.debug "Opening LSX #{file} sheet #{ sheet_name }"
|
114
116
|
|
115
|
-
TmpFile.with_file :extension =>
|
117
|
+
TmpFile.with_file :extension => Path.sanitize_filename(sheet_name.to_s) do |filename|
|
116
118
|
|
117
119
|
sheet = workbook.worksheet sheet
|
118
120
|
|
@@ -146,8 +148,8 @@ module TSV
|
|
146
148
|
end
|
147
149
|
|
148
150
|
def self.write(tsv, file, options = {})
|
149
|
-
options =
|
150
|
-
sheet =
|
151
|
+
options = IndiferentHash.add_defaults options, :sheet => "Sheet1"
|
152
|
+
sheet = IndiferentHash.process_options options, :sheet
|
151
153
|
fields, rows = TSV._excel_data(tsv, options)
|
152
154
|
|
153
155
|
book = Spreadsheet::Workbook.new
|
@@ -170,11 +172,11 @@ module TSV
|
|
170
172
|
|
171
173
|
module XLSX
|
172
174
|
def self.read(file, options = {})
|
173
|
-
options =
|
174
|
-
sheet =
|
175
|
-
header =
|
176
|
-
text =
|
177
|
-
skip_rows =
|
175
|
+
options = IndiferentHash.add_defaults options, :sep2 => /[,|]\s?/, :skip_rows => 0
|
176
|
+
sheet = IndiferentHash.process_options options, :sheet
|
177
|
+
header = IndiferentHash.process_options options, :header
|
178
|
+
text = IndiferentHash.process_options options, :text
|
179
|
+
skip_rows = IndiferentHash.process_options options, :skip_rows
|
178
180
|
skip_rows = skip_rows.to_i
|
179
181
|
|
180
182
|
header = true unless header == false
|
@@ -187,7 +189,7 @@ module TSV
|
|
187
189
|
sheet_name = sheet
|
188
190
|
Log.debug "Opening XLSX #{file} sheet #{ sheet_name }"
|
189
191
|
|
190
|
-
TmpFile.with_file :extension =>
|
192
|
+
TmpFile.with_file :extension => Path.sanitize_filename(sheet_name.to_s) do |filename|
|
191
193
|
|
192
194
|
sheet = sheet_name ? workbook[sheet_name] : workbook.worksheets.first
|
193
195
|
|
@@ -223,7 +225,7 @@ module TSV
|
|
223
225
|
end
|
224
226
|
|
225
227
|
def self.write(tsv, file, options = {})
|
226
|
-
sheet, add_sheet =
|
228
|
+
sheet, add_sheet = IndiferentHash.process_options options, :sheet, :add_sheet
|
227
229
|
|
228
230
|
fields, rows = TSV._excel_data(tsv, options)
|
229
231
|
|
data/lib/rbbt/tsv/field_index.rb
CHANGED
@@ -13,6 +13,8 @@ module TSV
|
|
13
13
|
def field_index(field)
|
14
14
|
@field_indices ||= {}
|
15
15
|
@field_indices[field] ||= Persist.persist_tsv(self, filename, {:field => field}, :prefix => "FieldIndex", :dir => TSV.field_index_dir, :persist => true, :serializer => :list, :engine => "BDB" ) do |data|
|
16
|
+
data.serializer = :flat
|
17
|
+
|
16
18
|
tsv = {}
|
17
19
|
case type
|
18
20
|
when :single, :list
|
@@ -30,6 +32,7 @@ module TSV
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
35
|
+
TSV.setup(data, :key_field => field, :fields => ["Keys"], :type => :flat)
|
33
36
|
tsv.each do |v,keys|
|
34
37
|
data[v] = keys.sort
|
35
38
|
end
|
@@ -44,7 +47,7 @@ module TSV
|
|
44
47
|
i = field_index(field)
|
45
48
|
|
46
49
|
if Array === values
|
47
|
-
keys = values.inject([]){|acc,value| m = i[value]; acc = m.nil? ? acc : Misc.merge_sorted_arrays(
|
50
|
+
keys = values.inject([]){|acc,value| m = i[value]; acc = m.nil? ? acc : Misc.merge_sorted_arrays(acc, m) }
|
48
51
|
else
|
49
52
|
keys = i[values] || []
|
50
53
|
end
|
data/lib/rbbt/tsv/filter.rb
CHANGED
@@ -32,7 +32,8 @@ module Filtered
|
|
32
32
|
when Hash === persistence
|
33
33
|
@persistence = persistence
|
34
34
|
when String === persistence
|
35
|
-
@persistence =
|
35
|
+
@persistence = Persist.open_tokyocabinet(persistence, false, :list)
|
36
|
+
@persistence = TSV.setup(@persistence)
|
36
37
|
@persistence.read
|
37
38
|
end
|
38
39
|
|
@@ -192,7 +193,7 @@ module Filtered
|
|
192
193
|
if filters.empty?
|
193
194
|
unfiltered_filename
|
194
195
|
else
|
195
|
-
unfiltered_filename + ":Filtered[#{filters.collect{|f| [f.match, Array === f.value ? Misc.
|
196
|
+
unfiltered_filename + ":Filtered[#{filters.collect{|f| [f.match, Array === f.value ? Misc.digest(:values => f.value) : f.value] * "="} * ", "}]"
|
196
197
|
end
|
197
198
|
end
|
198
199
|
|