fbtok 0.3.4 → 0.4.1
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/CHANGELOG.md +1 -1
- data/Manifest.txt +7 -4
- data/README.md +54 -8
- data/Rakefile +3 -5
- data/bin/fbquick +15 -0
- data/bin/fbquik +11 -0
- data/bin/fbtok +2 -131
- data/bin/fbtree +2 -142
- data/bin/fbx +2 -144
- data/{bin/fbt → lib/fbtok/fbquick.rb} +24 -46
- data/lib/fbtok/fbtok.rb +127 -0
- data/lib/fbtok/fbtree.rb +141 -0
- data/lib/fbtok/fbx.rb +107 -0
- data/lib/fbtok/pathspec.rb +230 -0
- data/lib/fbtok.rb +6 -7
- metadata +16 -13
- data/bin/fbchk +0 -158
- data/lib/fbtok/linter.rb +0 -119
- data/lib/fbtok/opts.rb +0 -195
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a133154bf34937e2961a05a9f3768e92cd2e4d633e64f2a52977e7eb3a7d4ae3
|
|
4
|
+
data.tar.gz: 382ba42bb20a0038f9efeec721481d70efc41c6241a209da5ea9e2a1fb177ac1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 800048bae44e60c94fc87073a029075d3e8d88c620ecbc3b2b4217939b4a42b40d57f855e50b60f8fe52c37593a8fe30ce786ed98169bdf87b3f64e7d1987016
|
|
7
|
+
data.tar.gz: '0921aa61b66e4ca43c1a9643dbe951ad9fcb0bba493bc9d93c2c5ce9ef099629694323b003be701970364d2b05008826a52699d1a7759be301da48ae463db76a'
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
|
@@ -2,11 +2,14 @@ CHANGELOG.md
|
|
|
2
2
|
Manifest.txt
|
|
3
3
|
README.md
|
|
4
4
|
Rakefile
|
|
5
|
-
bin/
|
|
6
|
-
bin/
|
|
5
|
+
bin/fbquick
|
|
6
|
+
bin/fbquik
|
|
7
7
|
bin/fbtok
|
|
8
8
|
bin/fbtree
|
|
9
9
|
bin/fbx
|
|
10
10
|
lib/fbtok.rb
|
|
11
|
-
lib/fbtok/
|
|
12
|
-
lib/fbtok/
|
|
11
|
+
lib/fbtok/fbquick.rb
|
|
12
|
+
lib/fbtok/fbtok.rb
|
|
13
|
+
lib/fbtok/fbtree.rb
|
|
14
|
+
lib/fbtok/fbx.rb
|
|
15
|
+
lib/fbtok/pathspec.rb
|
data/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# fbtok - football.txt lint tools incl. tokenizer, parser & more
|
|
2
|
-
|
|
1
|
+
# fbtok - football.txt lint tools incl. tokenizer (lexer), parser & more
|
|
2
|
+
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
* home :: [github.com/sportdb/footty](https://github.com/sportdb/footty)
|
|
@@ -20,20 +20,66 @@ $ gem install fbtok
|
|
|
20
20
|
## Usage
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
### fbtok - use tokenizer
|
|
23
|
+
### fbtok & fbtree - use tokenizer (lexer) & parser
|
|
24
24
|
|
|
25
25
|
- depends on sportdb-parser
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
get help
|
|
28
|
+
```
|
|
29
|
+
$ fbtok -h
|
|
30
|
+
$ fbtree -h
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
run on single / individual (data)files
|
|
34
|
+
````
|
|
35
|
+
$ fbtok england/2025-26/1-permierleague.txt
|
|
36
|
+
$ fbtok worldcup/min/2022.txt
|
|
37
|
+
|
|
38
|
+
$ fbtree england/2025-26/1-permierleague.txt
|
|
39
|
+
$ fbtree worldcup/min/2022.txt
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
or on directories (auto-collecting all datafiles)
|
|
44
|
+
|
|
45
|
+
$ fbtok england
|
|
46
|
+
$ fbtok worldcup
|
|
47
|
+
|
|
48
|
+
$ fbtree england
|
|
49
|
+
$ fbtree worldcup
|
|
50
|
+
```
|
|
51
|
+
|
|
28
52
|
|
|
29
|
-
- depends on sportdb-quick
|
|
30
53
|
|
|
31
|
-
###
|
|
54
|
+
### fbquick/fbquik & fbx - use quick match reader & dump match schedule
|
|
55
|
+
|
|
56
|
+
- depends on sportdb-quick (& sportdb-parser)
|
|
57
|
+
|
|
58
|
+
get help
|
|
59
|
+
```
|
|
60
|
+
$ fbquik -h
|
|
61
|
+
$ fbx -h
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
run on single / individual (data)files
|
|
65
|
+
````
|
|
66
|
+
$ fbquik england/2025-26/1-permierleague.txt
|
|
67
|
+
$ fbquik worldcup/min/2022.txt
|
|
68
|
+
|
|
69
|
+
$ fbx england/2025-26/1-permierleague.txt
|
|
70
|
+
$ fbx worldcup/min/2022.txt
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
or on directories (auto-collecting all datafiles)
|
|
74
|
+
|
|
75
|
+
$ fbquik england
|
|
76
|
+
$ fbquik worldcup
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
note: `fbx` only works with single / individual (data)files
|
|
32
80
|
|
|
33
|
-
- depends on sportdb-formats (incl. sportdb-search & sportdb-catalogs)
|
|
34
81
|
|
|
35
82
|
|
|
36
|
-
...
|
|
37
83
|
|
|
38
84
|
|
|
39
85
|
|
data/Rakefile
CHANGED
|
@@ -2,7 +2,7 @@ require 'hoe'
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
Hoe.spec 'fbtok' do
|
|
5
|
-
self.version = '0.
|
|
5
|
+
self.version = '0.4.1'
|
|
6
6
|
|
|
7
7
|
self.summary = "fbtok - football.txt lint tools incl. tokenizer, parser & more"
|
|
8
8
|
self.description = summary
|
|
@@ -19,10 +19,8 @@ Hoe.spec 'fbtok' do
|
|
|
19
19
|
self.licenses = ['Public Domain']
|
|
20
20
|
|
|
21
21
|
self.extra_deps = [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
['sportdb-parser', '>= 0.5.8'],
|
|
25
|
-
['sportdb-formats', '>= 2.1.2'],
|
|
22
|
+
['sportdb-parser', '>= 0.7.1'],
|
|
23
|
+
['sportdb-quick', '>= 0.7.0'],
|
|
26
24
|
]
|
|
27
25
|
|
|
28
26
|
self.spec_extras = {
|
data/bin/fbquick
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
## tip: to test run:
|
|
4
|
+
## $ ruby -I ./lib bin/fbquick
|
|
5
|
+
## -or-
|
|
6
|
+
## $ ruby -I ../parser/lib -I ./lib bin/fbquick
|
|
7
|
+
## -or-
|
|
8
|
+
## $ ruby -I ../parser/lib -I ../quick/lib -I ./lib bin/fbquick
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## our own code
|
|
12
|
+
require 'fbtok'
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Fbquick.main
|
data/bin/fbquik
ADDED
data/bin/fbtok
CHANGED
|
@@ -1,138 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
## tip: to test run:
|
|
4
|
-
## ruby -I ./lib bin/fbtok
|
|
4
|
+
## $ ruby -I ./lib bin/fbtok
|
|
5
5
|
|
|
6
6
|
require 'fbtok'
|
|
7
7
|
|
|
8
|
-
args = ARGV
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
opts = {
|
|
12
|
-
debug: true,
|
|
13
|
-
warn: false,
|
|
14
|
-
file: nil,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
parser = OptionParser.new do |parser|
|
|
18
|
-
parser.banner = "Usage: #{$PROGRAM_NAME} [options] PATH"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
parser.on( "-q", "--quiet",
|
|
22
|
-
"less debug output/messages (default: #{!opts[:debug]})" ) do |debug|
|
|
23
|
-
opts[:debug] = false
|
|
24
|
-
end
|
|
25
|
-
parser.on( "--verbose", "--debug",
|
|
26
|
-
"turn on verbose / debug output (default: #{opts[:debug]})" ) do |debug|
|
|
27
|
-
opts[:debug] = true
|
|
28
|
-
end
|
|
29
|
-
parser.on( "-w", "--warn",
|
|
30
|
-
"turn warnings into errors (default: #{opts[:warn]})" ) do |warn|
|
|
31
|
-
opts[:warn] = true
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
=begin
|
|
35
|
-
parser.on( "--metal",
|
|
36
|
-
"turn off typed parse tree; show to the metal tokens"+
|
|
37
|
-
" (default: #{opts[:metal]})" ) do |metal|
|
|
38
|
-
opts[:metal] = true
|
|
39
|
-
end
|
|
40
|
-
=end
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
parser.on( "-f FILE", "--file FILE",
|
|
44
|
-
"read datafiles (pathspecs) via .csv file") do |file|
|
|
45
|
-
opts[:file] = file
|
|
46
|
-
## note: for batch (massive) processing auto-set debug (verbose output) to false (as default)
|
|
47
|
-
opts[:debug] = false
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
parser.parse!( args )
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if opts[:debug]
|
|
55
|
-
puts "OPTS:"
|
|
56
|
-
p opts
|
|
57
|
-
puts "ARGV:"
|
|
58
|
-
p args
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
SportDb::Parser::Linter.debug = opts[:debug]
|
|
62
|
-
SportDb::Parser::Opts.debug = opts[:debug]
|
|
63
|
-
|
|
64
|
-
SportDb::Parser::Linter.warn = opts[:warn]
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
## todo/check - use packs or projects or such
|
|
69
|
-
## instead of specs - why? why not?
|
|
70
|
-
specs = if opts[:file]
|
|
71
|
-
SportDb::Parser::Opts.read_pathspecs( opts[:file] )
|
|
72
|
-
else
|
|
73
|
-
paths = if args.empty?
|
|
74
|
-
['/sports/openfootball/euro/2021--europe/euro.txt',
|
|
75
|
-
'/sports/openfootball/euro/2024--germany/euro.txt']
|
|
76
|
-
else
|
|
77
|
-
## check for directories
|
|
78
|
-
## and auto-expand
|
|
79
|
-
SportDb::Parser::Opts.expand_args( args )
|
|
80
|
-
end
|
|
81
|
-
## always return array of specs
|
|
82
|
-
[SportDb::Parser::Opts.build_pathspec( paths: paths)]
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
linter = SportDb::Parser::Linter.new
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
specs.each_with_index do |spec,i|
|
|
90
|
-
paths = spec.paths
|
|
91
|
-
rec = spec.rec
|
|
92
|
-
|
|
93
|
-
errors = []
|
|
94
|
-
|
|
95
|
-
paths.each_with_index do |path,j|
|
|
96
|
-
puts "==> [#{i+1}/#{specs.size}, #{j+1}/#{paths.size}] reading >#{path}<..."
|
|
97
|
-
tokens = linter.read( path, parse: false ) ## only tokenize (do NOT parse)
|
|
98
|
-
|
|
99
|
-
puts " #{tokens.size} token(s)"
|
|
100
|
-
|
|
101
|
-
errors += linter.errors if linter.errors?
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
if errors.size > 0
|
|
105
|
-
puts
|
|
106
|
-
pp errors
|
|
107
|
-
puts
|
|
108
|
-
puts "!! #{errors.size} tokenize error(s) in #{paths.size} datafiles(s)"
|
|
109
|
-
else
|
|
110
|
-
puts
|
|
111
|
-
puts "OK no tokenize errors found in #{paths.size} datafile(s)"
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
## add errors to rec via rec['errors'] to allow
|
|
115
|
-
## for further processing/reporting
|
|
116
|
-
rec['errors'] = errors
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
###
|
|
121
|
-
## generate a report if --file option used
|
|
122
|
-
if opts[:file]
|
|
123
|
-
|
|
124
|
-
buf = SportDb::Parser::BatchReport.new(
|
|
125
|
-
specs,
|
|
126
|
-
title: 'fbtok summary report' ).build
|
|
127
|
-
|
|
128
|
-
puts
|
|
129
|
-
puts "SUMMARY:"
|
|
130
|
-
puts buf
|
|
131
|
-
|
|
132
|
-
# maybe write out in the future?
|
|
133
|
-
# basedir = File.dirname( opts[:file] )
|
|
134
|
-
# basename = File.basename( opts[:file], File.extname( opts[:file] ))
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
puts "bye"
|
|
138
8
|
|
|
9
|
+
Fbtok.main
|
data/bin/fbtree
CHANGED
|
@@ -1,148 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
## tip: to test run:
|
|
4
|
-
## ruby -I ./lib bin/fbtree
|
|
4
|
+
## $ ruby -I ./lib bin/fbtree
|
|
5
5
|
|
|
6
6
|
require 'fbtok'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
opts = {
|
|
12
|
-
debug: true,
|
|
13
|
-
warn: false,
|
|
14
|
-
file: nil,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
parser = OptionParser.new do |parser|
|
|
18
|
-
parser.banner = "Usage: #{$PROGRAM_NAME} [options] PATH"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
parser.on( "-q", "--quiet",
|
|
22
|
-
"less debug output/messages (default: #{!opts[:debug]})" ) do |debug|
|
|
23
|
-
opts[:debug] = false
|
|
24
|
-
end
|
|
25
|
-
parser.on( "--verbose", "--debug",
|
|
26
|
-
"turn on verbose / debug output (default: #{opts[:debug]})" ) do |debug|
|
|
27
|
-
opts[:debug] = true
|
|
28
|
-
end
|
|
29
|
-
parser.on( "-w", "--warn",
|
|
30
|
-
"turn warnings into errors (default: #{opts[:warn]})" ) do |warn|
|
|
31
|
-
opts[:warn] = true
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
parser.on( "-f FILE", "--file FILE",
|
|
36
|
-
"read datafiles (pathspecs) via .csv file") do |file|
|
|
37
|
-
opts[:file] = file
|
|
38
|
-
## note: for batch (massive) processing auto-set debug (verbose output) to false (as default)
|
|
39
|
-
opts[:debug] = false
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
|
43
|
-
parser.parse!( args )
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if opts[:debug]
|
|
47
|
-
puts "OPTS:"
|
|
48
|
-
p opts
|
|
49
|
-
puts "ARGV:"
|
|
50
|
-
p args
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
SportDb::Parser::Linter.debug = opts[:debug]
|
|
54
|
-
SportDb::Parser::Opts.debug = opts[:debug]
|
|
55
|
-
|
|
56
|
-
SportDb::Parser::Linter.warn = opts[:warn]
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
## todo/check - use packs or projects or such
|
|
62
|
-
## instead of specs - why? why not?
|
|
63
|
-
specs = if opts[:file]
|
|
64
|
-
SportDb::Parser::Opts.read_pathspecs( opts[:file] )
|
|
65
|
-
else
|
|
66
|
-
paths = if args.empty?
|
|
67
|
-
['/sports/openfootball/euro/2021--europe/euro.txt',
|
|
68
|
-
'/sports/openfootball/euro/2024--germany/euro.txt']
|
|
69
|
-
else
|
|
70
|
-
## check for directories
|
|
71
|
-
## and auto-expand
|
|
72
|
-
SportDb::Parser::Opts.expand_args( args )
|
|
73
|
-
end
|
|
74
|
-
## always return array of specs
|
|
75
|
-
[SportDb::Parser::Opts.build_pathspec( paths: paths)]
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def dump_tree_stats( tree )
|
|
81
|
-
stats = Hash.new(0) ## track counts only for now
|
|
82
|
-
tree.each do |node|
|
|
83
|
-
stats[ node.class ] += 1
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
match_count = stats[ RaccMatchParser::MatchLine ]
|
|
87
|
-
goal_count = stats[ RaccMatchParser::GoalLine ]
|
|
88
|
-
lineup_count = stats[ RaccMatchParser::LineupLine ]
|
|
89
|
-
|
|
90
|
-
puts " #{match_count} MatchLine(s)" if match_count > 0
|
|
91
|
-
puts " #{goal_count} GoalLine(s)" if goal_count > 0
|
|
92
|
-
puts " #{lineup_count} LineupLine(s)" if lineup_count > 0
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
linter = SportDb::Parser::Linter.new
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
specs.each_with_index do |spec,i|
|
|
102
|
-
paths = spec.paths
|
|
103
|
-
rec = spec.rec
|
|
104
|
-
|
|
105
|
-
errors = []
|
|
106
|
-
|
|
107
|
-
paths.each_with_index do |path,j|
|
|
108
|
-
puts "==> [#{i+1}/#{specs.size}, #{j+1}/#{paths.size}] reading >#{path}<..."
|
|
109
|
-
tree = linter.read( path, parse: true )
|
|
110
|
-
dump_tree_stats( tree )
|
|
111
|
-
|
|
112
|
-
errors += linter.errors if linter.errors?
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
if errors.size > 0
|
|
116
|
-
puts
|
|
117
|
-
pp errors
|
|
118
|
-
puts
|
|
119
|
-
puts "!! #{errors.size} parse error(s) in #{paths.size} datafiles(s)"
|
|
120
|
-
else
|
|
121
|
-
puts
|
|
122
|
-
puts "OK no parse errors found in #{paths.size} datafile(s)"
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
## add errors to rec via rec['errors'] to allow
|
|
126
|
-
## for further processing/reporting
|
|
127
|
-
rec['errors'] = errors
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
###
|
|
132
|
-
## generate a report if --file option used
|
|
133
|
-
if opts[:file]
|
|
134
|
-
|
|
135
|
-
buf = SportDb::Parser::BatchReport.new(
|
|
136
|
-
specs,
|
|
137
|
-
title: 'fbtree summary report' ).build
|
|
138
|
-
|
|
139
|
-
puts
|
|
140
|
-
puts "SUMMARY:"
|
|
141
|
-
puts buf
|
|
142
|
-
|
|
143
|
-
# maybe write out in the future?
|
|
144
|
-
# basedir = File.dirname( opts[:file] )
|
|
145
|
-
# basename = File.basename( opts[:file], File.extname( opts[:file] ))
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
puts "bye"
|
|
8
|
+
Fbtree.main
|
data/bin/fbx
CHANGED
|
@@ -1,153 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
## tip: to test run:
|
|
4
|
-
## ruby -I ./lib
|
|
5
|
-
|
|
6
|
-
##
|
|
7
|
-
## todo/fix - use for testing
|
|
8
|
-
# reads textfile and dumps results in json
|
|
9
|
-
#
|
|
10
|
-
# check - keep fbx name or find a differnt name - why? why not?
|
|
4
|
+
## $ ruby -I ./lib bin/fbx
|
|
11
5
|
|
|
12
6
|
|
|
13
7
|
## our own code
|
|
14
8
|
require 'fbtok'
|
|
15
9
|
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
## read textfile
|
|
19
|
-
## and dump match parse results
|
|
20
|
-
##
|
|
21
|
-
## fbt ../openfootball/.../euro.txt
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
args = ARGV
|
|
27
|
-
opts = { debug: false,
|
|
28
|
-
outline: false }
|
|
29
|
-
|
|
30
|
-
parser = OptionParser.new do |parser|
|
|
31
|
-
parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
|
|
32
|
-
|
|
33
|
-
##
|
|
34
|
-
## check if git has a offline option?? (use same)
|
|
35
|
-
## check for other tools - why? why not?
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
parser.on( "--verbose", "--debug",
|
|
39
|
-
"turn on verbose / debug output (default: #{opts[:debug]})" ) do |debug|
|
|
40
|
-
opts[:debug] = debug
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
parser.on( "--outline",
|
|
44
|
-
"turn on outline (only) output (default: #{opts[:outline]})" ) do |outline|
|
|
45
|
-
opts[:outline] = outline
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
parser.parse!( args )
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if opts[:debug]
|
|
52
|
-
puts "OPTS:"
|
|
53
|
-
p opts
|
|
54
|
-
puts "ARGV:"
|
|
55
|
-
p args
|
|
56
|
-
|
|
57
|
-
SportDb::MatchParser.debug = true
|
|
58
|
-
else
|
|
59
|
-
SportDb::MatchParser.debug = false
|
|
60
|
-
LogUtils::Logger.root.level = :info
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
paths = if args.empty?
|
|
65
|
-
[
|
|
66
|
-
'../../../openfootball/euro/2021--europe/euro.txt',
|
|
67
|
-
'../../../openfootball/euro/2024--germany/euro.txt',
|
|
68
|
-
]
|
|
69
|
-
else
|
|
70
|
-
## check for directories
|
|
71
|
-
## and auto-expand
|
|
72
|
-
|
|
73
|
-
SportDb::Parser::Opts.expand_args( args )
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
## errors = []
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
paths.each_with_index do |path,i|
|
|
83
|
-
puts "==> [#{i+1}/#{paths.size}] reading >#{path}<..."
|
|
84
|
-
|
|
85
|
-
txt = read_text( path )
|
|
86
|
-
outline = SportDb::QuickLeagueOutline.parse( txt )
|
|
87
|
-
|
|
88
|
-
## todo/fix - add each_sec_with_index upstream
|
|
89
|
-
## add outline.secs.size - why? why not?
|
|
90
|
-
j = 0
|
|
91
|
-
secs_count = '?'
|
|
92
|
-
outline.each_sec do |sec| ## sec(tion)s
|
|
93
|
-
season = Season.parse( sec.season ) ## convert (str) to season obj!!!
|
|
94
|
-
league = sec.league
|
|
95
|
-
stage = sec.stage
|
|
96
|
-
lines = sec.lines
|
|
97
|
-
|
|
98
|
-
puts " section #{j+1}/#{secs_count} - #{league} #{season}, #{stage} - #{lines.size} line(s)"
|
|
99
|
-
|
|
100
|
-
next if opts[:outline]
|
|
101
|
-
|
|
102
|
-
=begin
|
|
103
|
-
### check if event info availabe - use start_date;
|
|
104
|
-
## otherwise we have to guess (use a "synthetic" start_date)
|
|
105
|
-
event_info = catalog.events.find_by( season: season,
|
|
106
|
-
league: league )
|
|
107
|
-
|
|
108
|
-
start = if event_info && event_info.start_date
|
|
109
|
-
puts "event info found:"
|
|
110
|
-
puts " using start date from event: "
|
|
111
|
-
pp event_info
|
|
112
|
-
pp event_info.start_date
|
|
113
|
-
event_info.start_date
|
|
114
|
-
else
|
|
115
|
-
=end
|
|
116
|
-
start = if season.year?
|
|
117
|
-
Date.new( season.start_year, 1, 1 )
|
|
118
|
-
else
|
|
119
|
-
Date.new( season.start_year, 7, 1 )
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
parser = SportDb::MatchParser.new( lines,
|
|
123
|
-
start ) ## note: keep season start_at date for now (no need for more specific stage date need for now)
|
|
124
|
-
|
|
125
|
-
auto_conf_teams, matches, rounds, groups = parser.parse
|
|
126
|
-
|
|
127
|
-
puts ">>> #{auto_conf_teams.size} teams:"
|
|
128
|
-
pp auto_conf_teams
|
|
129
|
-
puts ">>> #{matches.size} matches:"
|
|
130
|
-
## pp matches
|
|
131
|
-
puts ">>> #{rounds.size} rounds:"
|
|
132
|
-
pp rounds
|
|
133
|
-
puts ">>> #{groups.size} groups:"
|
|
134
|
-
pp groups
|
|
135
|
-
|
|
136
|
-
j += 1
|
|
137
|
-
end # each secs
|
|
138
|
-
end # each paths
|
|
139
|
-
|
|
140
|
-
=begin
|
|
141
|
-
if errors.size > 0
|
|
142
|
-
puts
|
|
143
|
-
pp errors
|
|
144
|
-
puts
|
|
145
|
-
puts "!! #{errors.size} parse error(s) in #{paths.size} datafiles(s)"
|
|
146
|
-
else
|
|
147
|
-
puts
|
|
148
|
-
puts "OK no parse errors found in #{paths.size} datafile(s)"
|
|
149
|
-
end
|
|
150
|
-
=end
|
|
151
|
-
|
|
152
|
-
puts "bye"
|
|
153
|
-
|
|
11
|
+
Fbx.main
|