sequencer 1.0.1 → 1.0.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.
- data/.autotest +0 -0
- data/History.txt +6 -0
- data/Manifest.txt +1 -1
- data/README.txt +0 -0
- data/Rakefile +0 -0
- data/bin/{seqls → rseqls} +0 -0
- data/lib/sequencer.rb +40 -1
- data/test/test_sequencer.rb +28 -1
- metadata +5 -5
data/.autotest
CHANGED
File without changes
|
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 1.0.2 / 2010-05-06
|
2
|
+
|
3
|
+
* Add Sequence#from_glob for scavenging all sequences from all subdirs
|
4
|
+
* Add Sequence#first_frame_no and Sequence#last_frame_no for first and last frame offset
|
5
|
+
* Add Sequence#to_sequences that returns the whole subsequences contained within a sequence
|
6
|
+
|
1
7
|
=== 1.0.1 / 2010-02-10
|
2
8
|
|
3
9
|
* Add Sequence#length, Sequence#to_a, Sequence#directory and Sequence#to_paths
|
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/bin/{seqls → rseqls}
RENAMED
File without changes
|
data/lib/sequencer.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Sequencer
|
2
|
-
VERSION = '1.0.
|
2
|
+
VERSION = '1.0.2'
|
3
3
|
NUMBERS_AT_END = /(\d+)([^\d]+)?$/
|
4
4
|
|
5
5
|
extend self
|
@@ -11,6 +11,8 @@ module Sequencer
|
|
11
11
|
groups = {}
|
12
12
|
|
13
13
|
actual_files.each do | e |
|
14
|
+
next if File.directory?(File.join(of_dir, e))
|
15
|
+
|
14
16
|
if e =~ NUMBERS_AT_END
|
15
17
|
base = e[0...-([$1, $2].join.length)]
|
16
18
|
key = [base, $2]
|
@@ -37,6 +39,12 @@ module Sequencer
|
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
42
|
+
# Detect multiple sequences from a glob result
|
43
|
+
def from_glob(glob_pattern)
|
44
|
+
dirs_of_matched_files = Dir.glob(glob_pattern).map(&File.method(:dirname)).uniq
|
45
|
+
dirs_of_matched_files.map(&method(:entries)).flatten
|
46
|
+
end
|
47
|
+
|
40
48
|
# Get a glob pattern and padding offset for a file in a sequence
|
41
49
|
def glob_and_padding_for(path)
|
42
50
|
plen = 0
|
@@ -105,6 +113,23 @@ module Sequencer
|
|
105
113
|
'#<%s>' % to_s
|
106
114
|
end
|
107
115
|
|
116
|
+
# If this Sequence has gaps, this method will return an array of all subsequences that it contains
|
117
|
+
# s # => #<broken_seq.[123..568, 578..702].tif>
|
118
|
+
# s.to_sequences # => [#<broken_seq.[123..568].tif>, #<broken_seq.[578..702].tif>]
|
119
|
+
def to_sequences
|
120
|
+
return [self] unless gaps?
|
121
|
+
|
122
|
+
last_offset = 0
|
123
|
+
|
124
|
+
@ranges.map do | frame_range |
|
125
|
+
frames_in_seg = frame_range.end - frame_range.begin
|
126
|
+
seg_filenames = @filenames[last_offset..(last_offset + frames_in_seg)]
|
127
|
+
last_offset = last_offset + frames_in_seg + 1
|
128
|
+
s = self.class.new(@directory, seg_filenames)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
|
108
133
|
def to_s
|
109
134
|
return @filenames[0] if (!numbered? || single_file?)
|
110
135
|
|
@@ -126,6 +151,10 @@ module Sequencer
|
|
126
151
|
@ranges.length - 1
|
127
152
|
end
|
128
153
|
|
154
|
+
def segment_count
|
155
|
+
@ranges.length
|
156
|
+
end
|
157
|
+
|
129
158
|
# Returns the number of frames that the sequence should contain to be continuous
|
130
159
|
def missing_frames
|
131
160
|
expected_frames - file_count
|
@@ -162,6 +191,16 @@ module Sequencer
|
|
162
191
|
@filenames.map{|f| File.join(@directory, f) }
|
163
192
|
end
|
164
193
|
|
194
|
+
# Returns the number of the first frame in the sequence
|
195
|
+
def first_frame_no
|
196
|
+
@ranges[0].begin
|
197
|
+
end
|
198
|
+
|
199
|
+
# Returns the number of the last frame in the sequence
|
200
|
+
def last_frame_no
|
201
|
+
@ranges[-1].end
|
202
|
+
end
|
203
|
+
|
165
204
|
private
|
166
205
|
|
167
206
|
def natural_sort(ar)
|
data/test/test_sequencer.rb
CHANGED
@@ -47,7 +47,12 @@ def emit_test_dirs
|
|
47
47
|
FileUtils.touch(TEST_DIR + "/many_seqs/anotherS %d.tif" % i)
|
48
48
|
end
|
49
49
|
FileUtils.touch(TEST_DIR + "/many_seqs/single.tif")
|
50
|
-
|
50
|
+
|
51
|
+
FileUtils.mkdir_p(TEST_DIR + "/many_seqs/subdir")
|
52
|
+
(445..471).each do | i |
|
53
|
+
FileUtils.touch(TEST_DIR + "/many_seqs/subdir/in_subdir %d.tif" % i)
|
54
|
+
end
|
55
|
+
|
51
56
|
end
|
52
57
|
|
53
58
|
def teardown_test_dirs
|
@@ -145,12 +150,34 @@ context "A Sequence created from pad-numbered files should" do
|
|
145
150
|
|
146
151
|
@with_gaps.should.be.gaps?
|
147
152
|
@with_gaps.gap_count.should.equal 1
|
153
|
+
@with_gaps.segment_count.should.equal 2
|
148
154
|
@with_gaps.missing_frames.should.equal(9)
|
149
155
|
@with_gaps.inspect.should.blaming("inspect itself").equal('#<broken_seq.[123..568, 578..702].tif>')
|
150
156
|
@with_gaps.should.include("broken_seq.000123.tif")
|
151
157
|
@with_gaps.should.not.include("bogus.123.tif")
|
152
158
|
end
|
153
159
|
|
160
|
+
specify "return subsequences without gaps" do
|
161
|
+
subseqs = @with_gaps.to_sequences
|
162
|
+
subseqs[0].should.be.kind_of(Sequencer::Sequence)
|
163
|
+
subseqs[1].should.be.kind_of(Sequencer::Sequence)
|
164
|
+
|
165
|
+
first_seq, second_seq = subseqs
|
166
|
+
first_seq.first_frame_no.should.equal 123
|
167
|
+
first_seq.last_frame_no.should.equal 568
|
168
|
+
second_seq.first_frame_no.should.equal 578
|
169
|
+
second_seq.last_frame_no.should.equal 702
|
170
|
+
|
171
|
+
first_seq.directory.should.equal second_seq.directory
|
172
|
+
first_seq.directory.should.equal @with_gaps.directory
|
173
|
+
end
|
174
|
+
|
175
|
+
specify "list all sequences in directory and subdirectories using the pattern" do
|
176
|
+
s = Sequencer.from_glob(TEST_DIR + "/**/*.tif")
|
177
|
+
inspected = '[#<single.tif>, #<seq1.[458..512].tif>, #<anotherS [228..312].tif>, #<in_subdir [445..471].tif>, #<seq1.[123..568].tif>, #<somefile.tif>, #<single_file.002123154.tif>, #<broken_seq.[123..568, 578..702].tif>]'
|
178
|
+
s.inspect.should.equal inspected
|
179
|
+
end
|
180
|
+
|
154
181
|
specify "initialize itself from a single file" do
|
155
182
|
@single.should.be.single_file?
|
156
183
|
@single.inspect.should.equal '#<single_file.002123154.tif>'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequencer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-05-06 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,13 +30,13 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.6.0
|
34
34
|
version:
|
35
35
|
description: Simplifies working with image sequences
|
36
36
|
email:
|
37
37
|
- me@julik.nl
|
38
38
|
executables:
|
39
|
-
-
|
39
|
+
- rseqls
|
40
40
|
extensions: []
|
41
41
|
|
42
42
|
extra_rdoc_files:
|
@@ -49,7 +49,7 @@ files:
|
|
49
49
|
- Manifest.txt
|
50
50
|
- README.txt
|
51
51
|
- Rakefile
|
52
|
-
- bin/
|
52
|
+
- bin/rseqls
|
53
53
|
- lib/sequencer.rb
|
54
54
|
- test/test_sequencer.rb
|
55
55
|
has_rdoc: true
|