dcm 0.1.33 → 0.1.34
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/cli.rb +13 -3
- data/lib/codinginfo.rb +61 -42
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fa54183039b54a526760fa32fe22759f2f868930bb26fcf66f20b7d160d8a808
|
|
4
|
+
data.tar.gz: 397b66f1946176da83b407d05253f4d4a6bde08af07e455e0a21589bf2e42c45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1f5128b226d63f2ce8f20160cc7e7bedeb02d36226b9f29f7877986f29e156c7ecb1114339aa4b75189689a32f2642804634db03ccaf77cf6e86371b779fa88
|
|
7
|
+
data.tar.gz: 6b7c96a428049abdfdd05fc8bbdd0d8d22a74b26a3b3f984b1796fafff6503972a2cd65d54a7c7d49f9197b179fc8a1971eb03db89dcf3e8ce628508728cb728
|
data/lib/cli.rb
CHANGED
|
@@ -79,7 +79,7 @@ module Dcm
|
|
|
79
79
|
filter = VariantFilter.new(expr)
|
|
80
80
|
list = parse_file(file)
|
|
81
81
|
|
|
82
|
-
puts Codinginfo.new(codingpath, filter)
|
|
82
|
+
puts Codinginfo.new(codingpath, filter, nocache: options[:nocache])
|
|
83
83
|
.flatten_list(list)
|
|
84
84
|
.to_dcm
|
|
85
85
|
end
|
|
@@ -89,17 +89,27 @@ module Dcm
|
|
|
89
89
|
filter = VariantFilter.new(expr)
|
|
90
90
|
list = parse_file(file)
|
|
91
91
|
|
|
92
|
-
puts Codinginfo.new(codingpath, filter)
|
|
92
|
+
puts Codinginfo.new(codingpath, filter, nocache: options[:nocache])
|
|
93
93
|
.filter_list(list)
|
|
94
94
|
.to_dcm
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
+
desc "cretaattrs FILTER CODING", "Output attributes for a given variant"
|
|
98
|
+
def cretaattrs(expr, codingpath)
|
|
99
|
+
filter = VariantFilter.new(expr)
|
|
100
|
+
|
|
101
|
+
puts Codinginfo.new(codingpath, filter, nocache: options[:nocache])
|
|
102
|
+
.variant
|
|
103
|
+
.attributes
|
|
104
|
+
.to_json
|
|
105
|
+
end
|
|
106
|
+
|
|
97
107
|
desc "begu2creta FILTER CODING FILE", "Convert a flat DCM to a hierarchical DCM"
|
|
98
108
|
def begu2creta(expr, codingpath, file)
|
|
99
109
|
filter = VariantFilter.new(expr)
|
|
100
110
|
list = parse_file(file)
|
|
101
111
|
|
|
102
|
-
puts Codinginfo.new(codingpath, filter)
|
|
112
|
+
puts Codinginfo.new(codingpath, filter, nocache: options[:nocache])
|
|
103
113
|
.unflatten_list(list)
|
|
104
114
|
.to_dcm
|
|
105
115
|
end
|
data/lib/codinginfo.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "simple_xlsx_reader"
|
|
2
|
+
require_relative "file_cache"
|
|
2
3
|
|
|
3
4
|
class Codinginfo
|
|
4
5
|
CVAR_PREFIX_REGEXP = /^CVAR_[A-Za-z0-9_]+_\d+\./
|
|
@@ -59,6 +60,13 @@ class Codinginfo
|
|
|
59
60
|
.map { Cvar.new(name: _1, value: _2.to_i) }
|
|
60
61
|
end
|
|
61
62
|
|
|
63
|
+
def attributes
|
|
64
|
+
@attrs ||= @properties
|
|
65
|
+
.reject { |key, _| key.start_with?("CSIG_") }
|
|
66
|
+
.reject { |key, _| key.start_with?("CVAR_") }
|
|
67
|
+
.select { |_, val| val == 0 || val == 1 || val == "-" }
|
|
68
|
+
end
|
|
69
|
+
|
|
62
70
|
def has_matching_cvar?(label)
|
|
63
71
|
cvars.any? { _1.match?(label) }
|
|
64
72
|
end
|
|
@@ -66,43 +74,20 @@ class Codinginfo
|
|
|
66
74
|
def description = @properties[:swfk_id]
|
|
67
75
|
end
|
|
68
76
|
|
|
69
|
-
def initialize(filepath, filter)
|
|
70
|
-
@doc = SimpleXlsxReader.open(filepath)
|
|
77
|
+
def initialize(filepath, filter, nocache: false)
|
|
71
78
|
@filter = filter
|
|
72
|
-
@headers = []
|
|
73
79
|
@variants = []
|
|
74
|
-
@assignments = {}
|
|
75
|
-
|
|
76
|
-
overview_sheet
|
|
77
|
-
.rows
|
|
78
|
-
.each do |row|
|
|
79
|
-
next unless headers_parsed?(row)
|
|
80
|
-
next unless filter.match?(@headers, row)
|
|
81
80
|
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
param_assignment_sheet
|
|
86
|
-
.rows
|
|
87
|
-
.each(headers: PARAM_ASSIGNMENT_HEADERS) do |row|
|
|
88
|
-
next if row[:cvar].nil?
|
|
81
|
+
parsed = nocache ? parse_xlsx(filepath) : FileCache.get(filepath) { parse_xlsx(filepath) }
|
|
89
82
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
end
|
|
83
|
+
@headers = parsed[:headers]
|
|
84
|
+
@assignments = parsed[:assignments]
|
|
93
85
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
.sheets
|
|
97
|
-
.find { _1.name == "Gesamtübersicht" }
|
|
98
|
-
.tap { fail "Cannot find sheet Gesamtübersicht" if _1.nil? }
|
|
99
|
-
end
|
|
86
|
+
parsed[:rows].each do |row|
|
|
87
|
+
next unless filter.match?(@headers, row)
|
|
100
88
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
.sheets
|
|
104
|
-
.find { _1.name == "Parameterdefinition" }
|
|
105
|
-
.tap { fail "Cannot find sheet Parameterdefinition" if _1.nil? }
|
|
89
|
+
@variants << Variant.new(@headers, row)
|
|
90
|
+
end
|
|
106
91
|
end
|
|
107
92
|
|
|
108
93
|
def variant
|
|
@@ -167,21 +152,55 @@ class Codinginfo
|
|
|
167
152
|
name.sub(CVAR_PREFIX_REGEXP, "")
|
|
168
153
|
end
|
|
169
154
|
|
|
170
|
-
|
|
171
|
-
|
|
155
|
+
private
|
|
156
|
+
|
|
157
|
+
def parse_xlsx(filepath)
|
|
158
|
+
doc = SimpleXlsxReader.open(filepath)
|
|
159
|
+
headers = []
|
|
160
|
+
rows = []
|
|
161
|
+
assignments = {}
|
|
162
|
+
|
|
163
|
+
doc.sheets
|
|
164
|
+
.find { _1.name == "Gesamtübersicht" }
|
|
165
|
+
.tap { fail "Cannot find sheet Gesamtübersicht" if _1.nil? }
|
|
166
|
+
.rows
|
|
167
|
+
.each do |row|
|
|
168
|
+
unless headers.any?
|
|
169
|
+
next unless parse_headers!(headers, row)
|
|
170
|
+
next
|
|
171
|
+
end
|
|
172
|
+
rows << row
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
doc.sheets
|
|
176
|
+
.find { _1.name == "Parameterdefinition" }
|
|
177
|
+
.tap { fail "Cannot find sheet Parameterdefinition" if _1.nil? }
|
|
178
|
+
.rows
|
|
179
|
+
.each(headers: PARAM_ASSIGNMENT_HEADERS) do |row|
|
|
180
|
+
next if row[:cvar].nil?
|
|
181
|
+
|
|
182
|
+
assignments[row[:name]] = Cvar.new(name: row[:cvar], package: row[:package])
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
{ headers: headers, rows: rows, assignments: assignments }
|
|
186
|
+
end
|
|
172
187
|
|
|
188
|
+
def parse_headers!(headers, row)
|
|
173
189
|
return false unless row[1]&.match?(/SWFK-ID/)
|
|
174
190
|
return false unless row[1]&.match?(/CVAR_BeguData/)
|
|
175
191
|
return false unless row[2]&.match?(/Kommentar/)
|
|
176
192
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
headers.replace(
|
|
194
|
+
row
|
|
195
|
+
.map(&:chomp)
|
|
196
|
+
.map(&:lstrip)
|
|
197
|
+
.map(&:strip)
|
|
198
|
+
.map { _1.sub(/\n.*/, "") }
|
|
199
|
+
.tap { _1[0] = :typestr }
|
|
200
|
+
.tap { _1[1] = :swfk_id }
|
|
201
|
+
.tap { _1[4] = :typekey }
|
|
202
|
+
.tap { _1[6] = :devkey }
|
|
203
|
+
)
|
|
204
|
+
true
|
|
186
205
|
end
|
|
187
206
|
end
|
data/lib/version.rb
CHANGED