sportdb-formats 2.1.2 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -2
- data/Manifest.txt +0 -1
- data/lib/sportdb/formats/quick_match_linter.rb +36 -19
- data/lib/sportdb/formats/version.rb +1 -1
- metadata +6 -8
- data/bin/fbchk +0 -173
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8c3b1c7071b5fa1c91f3282b0563132cb775f77777d75932293c110df64ef97
|
4
|
+
data.tar.gz: 37c6e63f3c9a0bb6c274ccbe8b1262e35c351ba7013003d77c29ec9385972456
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d32a08453d637bef97a67dcb73d2291758146e7e49236be99e8f80e5a786a28873dd2fb58b18b46977698e7b16e682b393560fb041c542e75a4158cab5f3f4ee
|
7
|
+
data.tar.gz: ac9d12015aec4e1a5a453b51bf86da4c1c7284cf6a3a764b1b9f3f8c46f4948a861616ede69da8e4bb1453dbc56e4daa9cf5435c72053411afbe05dc7b8c195c
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
@@ -73,24 +73,41 @@ class QuickMatchLinter
|
|
73
73
|
Date.new( season.start_year, 7, 1 )
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
##
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
76
|
+
league_rec = nil
|
77
|
+
|
78
|
+
|
79
|
+
## if all upcase or digits - assume/try code first
|
80
|
+
## todo/fix - change to find_by( code: ) !!!!
|
81
|
+
period = Import::LeaguePeriod.find_by( code: league, season: season )
|
82
|
+
if period
|
83
|
+
## find league by qname (assumed to be unique!!)
|
84
|
+
## todo/fix - use League.find_by!( name: ) !!!!
|
85
|
+
## make more specifi
|
86
|
+
league_rec = Import::League.find!( period.qname )
|
87
|
+
puts " #{period.pretty_inspect}"
|
88
|
+
puts " OK #{league}+#{season} => #{league_rec.pretty_inspect}"
|
89
|
+
else
|
90
|
+
## try "generic" match by name (& more alt codes)
|
91
|
+
###
|
92
|
+
## db check - check league
|
93
|
+
## fix/fix - add season to match_by !!!!!!!
|
94
|
+
## note - changed to match (incl. code) from match_by(name:) only!!!
|
95
|
+
recs = Import::League.match( league )
|
96
|
+
if recs.size == 1
|
97
|
+
league_rec = recs[0]
|
98
|
+
## note - use pp (pretty_inspect) instead of league_rec.name
|
99
|
+
puts " OK #{league} => #{league_rec.pretty_inspect}"
|
100
|
+
elsif recs.size == 0
|
101
|
+
msg = "NAME ERROR - no league match found for >#{league}<"
|
102
|
+
@errors << [msg]
|
103
|
+
puts "!! #{msg}"
|
104
|
+
else
|
105
|
+
msg = "NAME ERROR - ambigous; too many league matches (#{recs.size}) found for >#{league}<"
|
106
|
+
@errors << [msg]
|
107
|
+
puts "!! #{msg}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
94
111
|
|
95
112
|
|
96
113
|
parser = MatchParser.new( lines,
|
@@ -147,7 +164,7 @@ class QuickMatchLinter
|
|
147
164
|
team_rec = nil
|
148
165
|
if recs.size == 1
|
149
166
|
team_rec = recs[0]
|
150
|
-
puts " OK #{team} => #{team_rec.
|
167
|
+
puts " OK #{team} => #{team_rec.pretty_inspect}"
|
151
168
|
elsif recs.size == 0
|
152
169
|
msg = "NAME ERROR - no team match found for >#{team}<"
|
153
170
|
@errors << [msg]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-formats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-search
|
@@ -78,18 +78,17 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '4.
|
81
|
+
version: '4.2'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '4.
|
88
|
+
version: '4.2'
|
89
89
|
description: sportdb-formats - sport.db format and text utilities
|
90
90
|
email: gerald.bauer@gmail.com
|
91
|
-
executables:
|
92
|
-
- fbchk
|
91
|
+
executables: []
|
93
92
|
extensions: []
|
94
93
|
extra_rdoc_files:
|
95
94
|
- CHANGELOG.md
|
@@ -100,7 +99,6 @@ files:
|
|
100
99
|
- Manifest.txt
|
101
100
|
- README.md
|
102
101
|
- Rakefile
|
103
|
-
- bin/fbchk
|
104
102
|
- lib/sportdb/formats.rb
|
105
103
|
- lib/sportdb/formats/datafile_package.rb
|
106
104
|
- lib/sportdb/formats/package.rb
|
@@ -128,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
126
|
- !ruby/object:Gem::Version
|
129
127
|
version: '0'
|
130
128
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
129
|
+
rubygems_version: 3.5.22
|
132
130
|
signing_key:
|
133
131
|
specification_version: 4
|
134
132
|
summary: sportdb-formats - sport.db format and text utilities
|
data/bin/fbchk
DELETED
@@ -1,173 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
## tip: to test run:
|
4
|
-
## ruby -I ./lib bin/fbchk
|
5
|
-
|
6
|
-
## our own code
|
7
|
-
require 'sportdb/formats'
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
require 'optparse'
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
## local hack
|
16
|
-
## if exists up-to-date catalog db (use local version NOT built-in)
|
17
|
-
catalog_path = '../catalog/catalog.db'
|
18
|
-
if File.exist?( catalog_path )
|
19
|
-
SportDb::Import.config.catalog_path = catalog_path
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
args = ARGV
|
24
|
-
opts = { debug: false,
|
25
|
-
file: nil,
|
26
|
-
teams: true, ## check/lint teams (name errros etc.)
|
27
|
-
}
|
28
|
-
|
29
|
-
parser = OptionParser.new do |parser|
|
30
|
-
parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
|
31
|
-
|
32
|
-
##
|
33
|
-
## check if git has a offline option?? (use same)
|
34
|
-
## check for other tools - why? why not?
|
35
|
-
# parser.on( "-q", "--quiet",
|
36
|
-
# "less debug output/messages - default is (#{!opts[:debug]})" ) do |debug|
|
37
|
-
# opts[:debug] = false
|
38
|
-
# end
|
39
|
-
parser.on( "--verbose", "--debug",
|
40
|
-
"turn on verbose / debug output (default: #{opts[:debug]})" ) do |debug|
|
41
|
-
opts[:debug] = true
|
42
|
-
end
|
43
|
-
|
44
|
-
parser.on( "-f FILE", "--file FILE",
|
45
|
-
"read datafiles (pathspecs) via .csv file") do |file|
|
46
|
-
opts[:file] = file
|
47
|
-
end
|
48
|
-
|
49
|
-
parser.on( "--[no-]teams",
|
50
|
-
"turn on/off team name checks (default: #{opts[:teams]})") do |teams|
|
51
|
-
opts[:teams] = teams
|
52
|
-
end
|
53
|
-
end
|
54
|
-
parser.parse!( args )
|
55
|
-
|
56
|
-
|
57
|
-
puts "OPTS:"
|
58
|
-
p opts
|
59
|
-
puts "ARGV:"
|
60
|
-
p args
|
61
|
-
|
62
|
-
|
63
|
-
## todo/check - use packs or projects or such
|
64
|
-
## instead of specs - why? why not?
|
65
|
-
specs = []
|
66
|
-
if opts[:file]
|
67
|
-
recs = read_csv( opts[:file] )
|
68
|
-
pp recs
|
69
|
-
## note - make pathspecs relative to passed in file arg!!!
|
70
|
-
basedir = File.dirname( opts[:file] )
|
71
|
-
recs.each do |rec|
|
72
|
-
paths = SportDb::Parser::Opts.find( rec['path'], dir: basedir )
|
73
|
-
specs << [paths, rec]
|
74
|
-
end
|
75
|
-
else
|
76
|
-
paths = if args.empty?
|
77
|
-
[]
|
78
|
-
else
|
79
|
-
## check for directories
|
80
|
-
## and auto-expand
|
81
|
-
SportDb::Parser::Opts.expand_args( args )
|
82
|
-
end
|
83
|
-
specs << [paths, {}]
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
if opts[:debug]
|
88
|
-
SportDb::QuickMatchLinter.debug = true
|
89
|
-
SportDb::QuickMatchReader.debug = true
|
90
|
-
SportDb::MatchParser.debug = true
|
91
|
-
else
|
92
|
-
SportDb::QuickMatchLinter.debug = false
|
93
|
-
SportDb::QuickMatchReader.debug = false
|
94
|
-
SportDb::MatchParser.debug = false
|
95
|
-
LogUtils::Logger.root.level = :info
|
96
|
-
end
|
97
|
-
|
98
|
-
|
99
|
-
specs.each_with_index do |(paths, rec),i|
|
100
|
-
errors = []
|
101
|
-
paths.each_with_index do |path,j|
|
102
|
-
puts "==> [#{j+1}/#{paths.size}] reading >#{path}<..."
|
103
|
-
quick = SportDb::QuickMatchLinter.new( read_text( path ),
|
104
|
-
check_teams: opts[:teams] )
|
105
|
-
matches = quick.parse
|
106
|
-
|
107
|
-
|
108
|
-
if quick.errors?
|
109
|
-
puts "!! #{quick.errors.size} error(s):"
|
110
|
-
pp quick.errors
|
111
|
-
|
112
|
-
quick.errors.each do |err|
|
113
|
-
errors << [ path, *err ] # note: use splat (*) to add extra values (starting with msg)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
puts " #{matches.size} match(es)"
|
117
|
-
end
|
118
|
-
|
119
|
-
if errors.size > 0
|
120
|
-
puts
|
121
|
-
puts "!! #{errors.size} PARSE ERRORS in #{paths.size} datafile(s)"
|
122
|
-
pp errors
|
123
|
-
else
|
124
|
-
puts
|
125
|
-
puts " OK - no parse errors in #{paths.size} datafile(s)"
|
126
|
-
end
|
127
|
-
|
128
|
-
## add errors to rec via rec['errors'] to allow
|
129
|
-
## for further processing/reporting
|
130
|
-
rec['errors'] = errors
|
131
|
-
end
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
###
|
136
|
-
## generate a report if --file option used
|
137
|
-
if opts[:file]
|
138
|
-
|
139
|
-
buf = String.new
|
140
|
-
|
141
|
-
buf << "# fbchk summary report - #{specs.size} dataset(s)\n\n"
|
142
|
-
|
143
|
-
specs.each_with_index do |(paths, rec),i|
|
144
|
-
errors = rec['errors']
|
145
|
-
|
146
|
-
if errors.size > 0
|
147
|
-
buf << "!! #{errors.size} ERROR(S) "
|
148
|
-
else
|
149
|
-
buf << " OK "
|
150
|
-
end
|
151
|
-
buf << "%-20s" % rec['path']
|
152
|
-
buf << " - #{paths.size} datafile(s)"
|
153
|
-
buf << "\n"
|
154
|
-
|
155
|
-
if errors.size > 0
|
156
|
-
buf << errors.pretty_inspect
|
157
|
-
buf << "\n"
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
puts
|
162
|
-
puts "SUMMARY:"
|
163
|
-
puts buf
|
164
|
-
|
165
|
-
basedir = File.dirname( opts[:file] )
|
166
|
-
basename = File.basename( opts[:file], File.extname( opts[:file] ))
|
167
|
-
outpath = "#{basedir}/fbcheck.#{basename}.txt"
|
168
|
-
write_text( outpath, buf )
|
169
|
-
end
|
170
|
-
|
171
|
-
|
172
|
-
puts "bye"
|
173
|
-
|