• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

shogi-server source


Commit MetaInfo

Révision86b89d77b8d33397df8a248a564eb0a75f79136d (tree)
l'heure2016-12-09 21:15:41
AuteurDaigo Moriwaki <beatles@user...>
CommiterDaigo Moriwaki

Message de Log

Fix #36855: Allow util/statistics.rb to set a filtering condition of found files

Regarding util/statistics.rb, add a new command line option,
--filter regexp, to process files that are matched with a regexp.
It would make it easier to calculate statistics of certain games.

Change Summary

Modification

--- a/changelog
+++ b/changelog
@@ -1,3 +1,11 @@
1+2016-12-09 Daigo Moriwaki <daigo at debian dot org>
2+
3+ * Allow util/statistics.rb to set a filtering condition of found files
4+ Regarding util/statistics.rb, add a new command line option,
5+ --filter regexp, to process files that are matched with a regexp.
6+ It would make it easier to calculate statistics of certain games.
7+ (Closes #36855)
8+
19 2016-11-26 Daigo Moriwaki <daigo at debian dot org>
210
311 * [shogi-server] Allow to customize maximum lenght of a login indentifier
--- a/utils/statistics.rb
+++ b/utils/statistics.rb
@@ -139,15 +139,30 @@ end
139139
140140 if $0 == __FILE__
141141 def usage
142- puts "Usage: #{$0} [OPTIONS] dir [...]"
143- puts "Options:"
142+puts <<-EOF
143+SYNOPSIS:
144+ #{$0} [OPTION]... file or dir [...]
145+
146+DESCRIPTION:
147+ It calculates game statistics, reading CSA record files.
148+ If an argument is a directory, it attempts to find files in its
149+ subdirectories recursively.
150+
151+ --filter regexp
152+ only files that are matched with a regexp are processed (default: no filter)
153+
154+ --repeat n
155+ at most n files are processed (default: unlimitted)
156+EOF
144157 exit 1
145158 end
146159
147160 usage if ARGV.empty?
148161
149162 parser = GetoptLong.new(
150- ['--repeat', '-n', GetoptLong::REQUIRED_ARGUMENT]
163+ ['--repeat', '-n', GetoptLong::REQUIRED_ARGUMENT],
164+ ['--filter', GetoptLong::REQUIRED_ARGUMENT],
165+ ['--h', '-h', GetoptLong::NO_ARGUMENT]
151166 )
152167 begin
153168 parser.each_option do |name, arg|
@@ -157,6 +172,10 @@ if $0 == __FILE__
157172 usage
158173 end
159174
175+ if $OPT_H
176+ usage
177+ end
178+
160179 $OPT_REPEAT = $OPT_REPEAT.to_i
161180 if $OPT_REPEAT == 0
162181 $OPT_REPEAT = -1
@@ -167,11 +186,15 @@ if $0 == __FILE__
167186 if FileTest.directory?(cmd)
168187 Dir.glob(File.join(cmd, "**", "*.csa")).each do |file|
169188 break if $OPT_REPEAT == 0
170- do_file(file)
189+ if $OPT_FILTER.nil? || /#{$OPT_FILTER}/ =~ file
190+ do_file(file)
191+ end
171192 end
172193 elsif FileTest.file?(cmd)
173194 break if $OPT_REPEAT == 0
174- do_file(cmd)
195+ if $OPT_FILTER.nil? || /#{$OPT_FILTER}/ =~ cmd
196+ do_file(cmd)
197+ end
175198 else
176199 throw "Unknown file or directory: #{cmd}"
177200 end