sportdb-writers 0.3.0 → 0.4.0
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 -2
- data/Manifest.txt +0 -8
- data/lib/sportdb/writers/txt_writer.rb +32 -28
- data/lib/sportdb/writers/version.rb +1 -1
- data/lib/sportdb/writers.rb +1 -25
- metadata +6 -16
- data/bin/fbgen +0 -13
- data/bin/fbtxt +0 -17
- data/config/leagues_america.csv +0 -29
- data/config/leagues_europe.csv +0 -160
- data/config/leagues_world.csv +0 -23
- data/lib/sportdb/fbgen/main.rb +0 -172
- data/lib/sportdb/fbtxt/main.rb +0 -37
- data/lib/sportdb/writers/league_config.rb +0 -83
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3106f4f09e01a5434628f1818c445de04b332df0d2b9b57787eee944444dc715
|
4
|
+
data.tar.gz: aeb997f0576680cf2500f118ebac827303983021992a714ca0fd65ad03e395fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53a96142090a0b7edbc2dadda557cff02124103e655bf801f47b08d61d658b8218c13f03220f86cf7d29cc0afebab329461d3e42c88000dafeff57e79306aeef
|
7
|
+
data.tar.gz: 6a7b9ceab580231e026a7b2dfe232ae14bad110bfa8c727e4e20a6329252994412916339354f6a93f9f7a61003a87f2969ecdbef7a94a189a0a1a21027d0cf4d
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
@@ -2,15 +2,7 @@ CHANGELOG.md
|
|
2
2
|
Manifest.txt
|
3
3
|
README.md
|
4
4
|
Rakefile
|
5
|
-
bin/fbgen
|
6
|
-
bin/fbtxt
|
7
|
-
config/leagues_america.csv
|
8
|
-
config/leagues_europe.csv
|
9
|
-
config/leagues_world.csv
|
10
|
-
lib/sportdb/fbgen/main.rb
|
11
|
-
lib/sportdb/fbtxt/main.rb
|
12
5
|
lib/sportdb/writers.rb
|
13
6
|
lib/sportdb/writers/goals.rb
|
14
|
-
lib/sportdb/writers/league_config.rb
|
15
7
|
lib/sportdb/writers/txt_writer.rb
|
16
8
|
lib/sportdb/writers/version.rb
|
@@ -68,16 +68,19 @@ def self.build( matches, rounds: true )
|
|
68
68
|
buf = String.new
|
69
69
|
# e.g. 13 April – 25 September 2024
|
70
70
|
# or 16 August 2024 – 25 May 2025
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
## note - date is optional!!
|
72
|
+
if stats['date']['start_date']
|
73
|
+
buf << "# Date "
|
74
|
+
start_date = stats['date']['start_date']
|
75
|
+
end_date = stats['date']['end_date']
|
76
|
+
if start_date.year != end_date.year
|
77
|
+
buf << "#{start_date.strftime('%a %b/%-d %Y')} - #{end_date.strftime('%a %b/%-d %Y')}"
|
78
|
+
else
|
79
|
+
buf << "#{start_date.strftime('%a %b/%-d')} - #{end_date.strftime('%a %b/%-d %Y')}"
|
80
|
+
end
|
81
|
+
buf << " (#{end_date.jd-start_date.jd}d)" ## add days
|
82
|
+
buf << "\n"
|
78
83
|
end
|
79
|
-
buf << " (#{end_date.jd-start_date.jd}d)" ## add days
|
80
|
-
buf << "\n"
|
81
84
|
|
82
85
|
buf << "# Teams #{stats['teams'].size}\n"
|
83
86
|
buf << "# Matches #{matches.size}\n"
|
@@ -159,14 +162,18 @@ def self._build_batch( matches, rounds: true )
|
|
159
162
|
|
160
163
|
buf << (round_translations[match.round] || match.round)
|
161
164
|
end
|
162
|
-
|
165
|
+
## note - reset last_date & last_time on every new round header
|
166
|
+
last_date = nil
|
167
|
+
last_time = nil
|
168
|
+
|
169
|
+
buf << "\n"
|
163
170
|
end
|
164
171
|
end
|
165
172
|
|
166
173
|
|
167
174
|
date = if match.date.is_a?( String )
|
168
175
|
Date.strptime( match.date, '%Y-%m-%d' )
|
169
|
-
else ## assume it's already a date (object)
|
176
|
+
else ## assume it's already a date (object) or nil!!!!
|
170
177
|
match.date
|
171
178
|
end
|
172
179
|
|
@@ -177,25 +184,22 @@ def self._build_batch( matches, rounds: true )
|
|
177
184
|
end
|
178
185
|
|
179
186
|
|
180
|
-
|
187
|
+
## note - date might be NIL!!!!!
|
188
|
+
date_yyyymmdd = date ? date.strftime( '%Y-%m-%d' ) : nil
|
181
189
|
|
182
190
|
## note: time is OPTIONAL for now
|
183
191
|
## note: use 17.00 and NOT 17:00 for now
|
184
192
|
time_hhmm = time ? time.strftime( '%H.%M' ) : nil
|
185
193
|
|
186
194
|
|
187
|
-
if
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
buf << "[#{format_date.call( date )}]\n"
|
196
|
-
last_time = nil
|
197
|
-
end
|
198
|
-
end
|
195
|
+
if date_yyyymmdd
|
196
|
+
if date_yyyymmdd != last_date
|
197
|
+
## note: add an extra leading blank line (if no round headings printed)
|
198
|
+
buf << "\n" unless rounds
|
199
|
+
buf << "[#{format_date.call( date )}]\n"
|
200
|
+
last_time = nil
|
201
|
+
end
|
202
|
+
end
|
199
203
|
|
200
204
|
|
201
205
|
## allow strings and structs for team names
|
@@ -207,17 +211,16 @@ def self._build_batch( matches, rounds: true )
|
|
207
211
|
line << ' '
|
208
212
|
|
209
213
|
if time
|
210
|
-
if last_time
|
214
|
+
if last_time != time_hhmm
|
211
215
|
line << "%5s" % time_hhmm
|
212
216
|
else
|
213
217
|
line << ' '
|
214
218
|
end
|
215
219
|
line << ' '
|
216
220
|
else
|
217
|
-
|
221
|
+
line << ' '
|
218
222
|
end
|
219
223
|
|
220
|
-
|
221
224
|
line << "%-23s" % team1 ## note: use %-s for left-align
|
222
225
|
|
223
226
|
line << " #{format_score.call( match )} " ## note: separate by at least two spaces for now
|
@@ -237,7 +240,8 @@ def self._build_batch( matches, rounds: true )
|
|
237
240
|
when Status::REPLAY
|
238
241
|
line << '[replay]'
|
239
242
|
when Status::POSTPONED
|
240
|
-
|
243
|
+
line << '[postponed]'
|
244
|
+
## was -- note: add NOTHING for postponed for now
|
241
245
|
else
|
242
246
|
puts "!! WARN - unknown match status >#{match.status}<:"
|
243
247
|
pp match
|
data/lib/sportdb/writers.rb
CHANGED
@@ -2,9 +2,6 @@
|
|
2
2
|
require 'sportdb/quick'
|
3
3
|
|
4
4
|
|
5
|
-
require 'optparse' ## command-line processing; check if included updstream?
|
6
|
-
|
7
|
-
|
8
5
|
|
9
6
|
module Writer
|
10
7
|
class Configuration
|
@@ -26,35 +23,14 @@ end # module Writer
|
|
26
23
|
###
|
27
24
|
# our own code
|
28
25
|
require_relative 'writers/version'
|
29
|
-
|
30
|
-
## setup leagues (info) table
|
31
|
-
require_relative 'writers/league_config'
|
32
|
-
|
33
|
-
module Writer
|
34
|
-
LEAGUES = SportDb::LeagueConfig.new
|
35
|
-
|
36
|
-
['leagues_europe',
|
37
|
-
'leagues_america',
|
38
|
-
'leagues_world'
|
39
|
-
].each do |name|
|
40
|
-
recs = read_csv( "#{SportDb::Module::Writers.root}/config/#{name}.csv" )
|
41
|
-
LEAGUES.add( recs )
|
42
|
-
end
|
43
|
-
end # module Writer
|
44
|
-
|
45
|
-
|
46
26
|
require_relative 'writers/goals'
|
47
27
|
require_relative 'writers/txt_writer'
|
48
28
|
|
49
29
|
|
50
30
|
###
|
51
|
-
# fbtxt
|
31
|
+
# fbtxt & friends tools - remove in future - why? why not?
|
52
32
|
require 'football/timezones' ## pulls in read_datasets, etc.
|
53
33
|
|
54
|
-
require_relative 'fbtxt/main'
|
55
|
-
require_relative 'fbgen/main'
|
56
|
-
|
57
|
-
|
58
34
|
|
59
35
|
|
60
36
|
puts SportDb::Module::Writers.banner # say hello
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-writers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: football-timezones
|
@@ -64,20 +64,18 @@ dependencies:
|
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '4.
|
67
|
+
version: '4.2'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '4.
|
74
|
+
version: '4.2'
|
75
75
|
description: sportdb-writers - sport.db writers for match schedules and results, and
|
76
76
|
more
|
77
77
|
email: gerald.bauer@gmail.com
|
78
|
-
executables:
|
79
|
-
- fbgen
|
80
|
-
- fbtxt
|
78
|
+
executables: []
|
81
79
|
extensions: []
|
82
80
|
extra_rdoc_files:
|
83
81
|
- CHANGELOG.md
|
@@ -88,16 +86,8 @@ files:
|
|
88
86
|
- Manifest.txt
|
89
87
|
- README.md
|
90
88
|
- Rakefile
|
91
|
-
- bin/fbgen
|
92
|
-
- bin/fbtxt
|
93
|
-
- config/leagues_america.csv
|
94
|
-
- config/leagues_europe.csv
|
95
|
-
- config/leagues_world.csv
|
96
|
-
- lib/sportdb/fbgen/main.rb
|
97
|
-
- lib/sportdb/fbtxt/main.rb
|
98
89
|
- lib/sportdb/writers.rb
|
99
90
|
- lib/sportdb/writers/goals.rb
|
100
|
-
- lib/sportdb/writers/league_config.rb
|
101
91
|
- lib/sportdb/writers/txt_writer.rb
|
102
92
|
- lib/sportdb/writers/version.rb
|
103
93
|
homepage: https://github.com/sportdb/sport.db
|
@@ -121,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
111
|
- !ruby/object:Gem::Version
|
122
112
|
version: '0'
|
123
113
|
requirements: []
|
124
|
-
rubygems_version: 3.
|
114
|
+
rubygems_version: 3.5.22
|
125
115
|
signing_key:
|
126
116
|
specification_version: 4
|
127
117
|
summary: sportdb-writers - sport.db writers for match schedules and results, and more
|
data/bin/fbgen
DELETED
data/bin/fbtxt
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
## tip: to test run:
|
4
|
-
## ruby -I ./lib bin/fbtxt
|
5
|
-
|
6
|
-
# $LOAD_PATH.unshift( '../../../sportdb/sport.db/parser/lib' )
|
7
|
-
# $LOAD_PATH.unshift( '../../../sportdb/sport.db/sportdb-structs/lib' )
|
8
|
-
# $LOAD_PATH.unshift( '../../../sportdb/sport.db/quick/lib' )
|
9
|
-
|
10
|
-
require 'sportdb/writers'
|
11
|
-
|
12
|
-
|
13
|
-
Fbtxt.main( ARGV )
|
14
|
-
|
15
|
-
|
16
|
-
puts "bye"
|
17
|
-
|
data/config/leagues_america.csv
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
key, name, basename, start_season, end_season, comments
|
2
|
-
|
3
|
-
ar.1, Argentina Primera Division, 1-primeradivision,,,
|
4
|
-
|
5
|
-
br.1, Brasileiro Série A, 1-seriea,,,
|
6
|
-
br.2, Brasileiro Série B, 2-serieb,,,
|
7
|
-
br.3, Brasileiro Série C, 3-seriec,,,
|
8
|
-
br.4, Brasileiro Série D, 4-seried,,,
|
9
|
-
br.cup, Copa do Brasil, cup,,,
|
10
|
-
|
11
|
-
br.carioca, Campeonato Carioca, carioca,,,
|
12
|
-
br.gauchao, Campeonato Gaúcho, gauchao,,,
|
13
|
-
br.mineiro, Campeonato Mineiro, mineiro,,,
|
14
|
-
br.paranaense, Campeonato Paranaense, paranaense,,,
|
15
|
-
br.paulistao, Campeonato Paulista, paulistao,,,
|
16
|
-
|
17
|
-
co.1, Colombia Primera A, 1-primeraa,,,
|
18
|
-
|
19
|
-
|
20
|
-
copa.l, Copa Libertadores, libertadores,,,
|
21
|
-
copa.s, Copa Sudamericana, sudamericana,,,
|
22
|
-
|
23
|
-
|
24
|
-
mx.1, Liga MX, 1-ligamx,,,
|
25
|
-
mx.2, Liga de Expansión MX, 2-ligaexpansionmx, 2020/21,,
|
26
|
-
mx.2, Ascenso MX, 2-ascensomx, ,2019/20,
|
27
|
-
|
28
|
-
|
29
|
-
|
data/config/leagues_europe.csv
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
key, name, basename, start_season, end_season, comments
|
2
|
-
|
3
|
-
at.1, Österr. Bundesliga, 1-bundesliga,,,
|
4
|
-
at.2, Österr. 2. Liga, 2-liga2, 2018/19,,
|
5
|
-
at.2, Österr. Erste Liga, 2-liga1, , 2017/18,
|
6
|
-
at.3.o, Österr. Regionalliga Ost, 3-regionalliga-ost,,,
|
7
|
-
at.3.m, Österr. Regionalliga Mitte, 3-regionalliga-mitte,,,
|
8
|
-
at.cup, ÖFB Cup, cup,,,
|
9
|
-
|
10
|
-
|
11
|
-
de.1, Deutsche Bundesliga, 1-bundesliga,,,
|
12
|
-
de.2, Deutsche 2. Bundesliga, 2-bundesliga2,,,
|
13
|
-
de.3, Deutsche 3. Liga, 3-liga3,,,
|
14
|
-
de.4.bayern, Deutsche Regionalliga Bayern, 4-regionalliga-bayern,,,
|
15
|
-
de.4.n, Deutsche Regionalliga Nord, 4-regionalliga-nord,,,
|
16
|
-
de.4.no, Deutsche Regionalliga Nordost, 4-regionalliga-nordost,,,
|
17
|
-
de.4.w, Deutsche Regionalliga West, 4-regionalliga-west,,,
|
18
|
-
de.4.sw, Deutsche Regionalliga Südwest, 4-regionalliga-suedwest,,,
|
19
|
-
de.cup, DFB Pokal, cup,,,
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
it.1, Italian Serie A, 1-seriea,,,
|
24
|
-
it.2, Italian Serie B, 2-serieb,,,
|
25
|
-
it.cup, Coppa Italia, cup,,,
|
26
|
-
|
27
|
-
|
28
|
-
es.1, Primera División de España, 1-liga,,,
|
29
|
-
es.2, Segunda División de España, 2-liga2,,,
|
30
|
-
es.cup, Copa del Rey de España, cup,,,
|
31
|
-
|
32
|
-
|
33
|
-
fr.1, French Ligue 1, 1-ligue1,,,
|
34
|
-
fr.2, French Ligue 2, 2-ligue2,,,
|
35
|
-
|
36
|
-
|
37
|
-
##
|
38
|
-
## note - starting with the 2004/05 season
|
39
|
-
# the Football League's Division 1, Division 2 and Division 3
|
40
|
-
## changed to Championship, League One and League Two.
|
41
|
-
|
42
|
-
eng.2, English Championship, 2-championship, 2004/05,, ## rebranding divsion 1 => championship
|
43
|
-
eng.3, English League One, 3-league1, 2004/05,,
|
44
|
-
eng.4, English League Two, 4-league2, 2004/05,,
|
45
|
-
|
46
|
-
eng.1, English Premier League, 1-premierleague, 1992/93,,
|
47
|
-
eng.2, English Division One, 2-division1, 1992/93, 2003/04, ## start of premier league
|
48
|
-
eng.3, English Division Two, 3-division2, 1992/93, 2003/04,
|
49
|
-
eng.4, English Division Three, 4-division3, 1992/93, 2003/04,
|
50
|
-
eng.5, English National League, 5-nationalleague, 1992/93,,
|
51
|
-
|
52
|
-
eng.1, English Division One, 1-division1, 1892/93, 1991/92, ## start of division 1 & 2
|
53
|
-
eng.2, English Division Two, 2-division2, 1892/93, 1991/92, ## or use English Football League Second Division ???
|
54
|
-
eng.3, English Division Three, 3-division3, , 1991/92,
|
55
|
-
|
56
|
-
eng.1, English Football League, 1-footballleague, 1888/89, 1891/92, ## single league (no divisions)
|
57
|
-
|
58
|
-
|
59
|
-
eng.cup, English FA Cup, facup,,,
|
60
|
-
|
61
|
-
wal.1, Welsh Premier League, 1-premierleague,,,
|
62
|
-
nir.1, Northern Irish Premiership, 1-premiership,,,
|
63
|
-
|
64
|
-
hu.1, Hungarian NB I, 1-nbi,,,
|
65
|
-
|
66
|
-
gr.1, Super League Greece, 1-superleague,,,
|
67
|
-
|
68
|
-
pt.1, Portuguese Primeira Liga, 1-primeiraliga,,,
|
69
|
-
pt.2, Portuguese Segunda Liga, 2-segundaliga,,,
|
70
|
-
|
71
|
-
ch.1, Swiss Super League, 1-superleague,,,
|
72
|
-
ch.2, Swiss Challenge League, 2-challengeleague,,,
|
73
|
-
ch.cup, Swiss Cup, cup,,,
|
74
|
-
|
75
|
-
|
76
|
-
tr.1, Turkish Süper Lig, 1-superlig,,,
|
77
|
-
tr.2, Turkish 1. Lig, 2-lig1,,,
|
78
|
-
|
79
|
-
is.1, Iceland Urvalsdeild, 1-urvalsdeild,,,
|
80
|
-
|
81
|
-
sco.1, Scottish Premiership, 1-premiership,,,
|
82
|
-
|
83
|
-
ie.1, Irish Premier Division, 1-premierdivision,,,
|
84
|
-
|
85
|
-
fi.1, Finland Veikkausliiga, 1-veikkausliiga,,,
|
86
|
-
|
87
|
-
se.1, Sweden Allsvenskan, 1-allsvenskan,,,
|
88
|
-
se.2, Sweden Superettan, 2-superettan,,,
|
89
|
-
|
90
|
-
no.1, Norwegian Eliteserien, 1-eliteserien,,,
|
91
|
-
dk.1, Denmark Superligaen, 1-superligaen,,,
|
92
|
-
|
93
|
-
lu.1, Luxembourger First Division, 1-nationaldivision,,,
|
94
|
-
|
95
|
-
be.1, Belgian First Division A, 1-firstdivisiona,,,
|
96
|
-
|
97
|
-
nl.1, Dutch Eredivisie, 1-eredivisie,,,
|
98
|
-
|
99
|
-
cz.1, Czech First League, 1-firstleague,,,
|
100
|
-
sk.1, Slovakia First League, 1-superliga,,,
|
101
|
-
hr.1, Croatia 1. HNL, 1-hnl,,,
|
102
|
-
|
103
|
-
pl.1, Poland Ekstraklasa, 1-ekstraklasa,,,
|
104
|
-
|
105
|
-
ro.1, Romanian Liga 1, 1-liga1,,,
|
106
|
-
|
107
|
-
ua.1, Ukraine Premier League, 1-premierleague,,,
|
108
|
-
|
109
|
-
ru.1, Russian Premier League, 1-premierliga,,,
|
110
|
-
ru.2, Russian 1. Division, 2-division1,,,
|
111
|
-
|
112
|
-
by.1, Belarusian Premier League, 1-premierleague,,,
|
113
|
-
|
114
|
-
al.1, Albanian Super League, 1-superleague,,,
|
115
|
-
ad.1, Andorran Premier Division, 1-premierdisvision,,,
|
116
|
-
|
117
|
-
ba.1, Bosnian-Herzegovinian Premier League, 1-premierleague,,,
|
118
|
-
bg.1, Bulgarian A League, 1-aleague,,,
|
119
|
-
|
120
|
-
cy.1, Cypriot First Division, 1-firstdivision,,,
|
121
|
-
|
122
|
-
ee.1, Estonian First League, 1-firstleague,,,
|
123
|
-
lv.1, Latvian First Division, 1-firstdivision,,,
|
124
|
-
lt.1, Lithuanian First Division, 1-firstdivision,,,
|
125
|
-
|
126
|
-
li.cup, Liechtensteiner Cup, cup,,,
|
127
|
-
|
128
|
-
mk.1, Macedonian First League, 1-firstleague,,,
|
129
|
-
mt.1, Macedonian First League, 1-firstleague,,,
|
130
|
-
md.1, Moldovan First Division, 1-firstdivision,,,
|
131
|
-
me.1, Montenegrin First League, 1-firstleague,,,
|
132
|
-
|
133
|
-
sm.1, San Marinese Championship, 1-championship,,,
|
134
|
-
rs.1, Serbian Super League, 1-superleague,,,
|
135
|
-
si.1, Slovene First League, 1-firstleague,,,
|
136
|
-
|
137
|
-
kos.1, Kosovan Superliga, 1-superliga,,,
|
138
|
-
xk.1, Kosovan Superliga, 1-superliga,,,
|
139
|
-
|
140
|
-
am.1, Armenian Premier League, 1-premierleague,,,
|
141
|
-
az.1, Azerbaijani Premier League, 1-premierleague,,,
|
142
|
-
ge.1, Georgian Premier League, 1-premierleague,,,
|
143
|
-
|
144
|
-
fo.1, Faroese Premier Division, 1-premierdivision,,,
|
145
|
-
gi.1, Gibraltarian Premier League, 1-premierleague,,,
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
## use uefa.1 - why? why not?
|
150
|
-
## uefa.2,
|
151
|
-
## uefa.3
|
152
|
-
uefa.cl, UEFA Champions League, cl,,, ### use champs or such?
|
153
|
-
uefa.champs, UEFA Champions League, champs,,,
|
154
|
-
uefa.el, UEFA Europa League, el,,, ### use europa?
|
155
|
-
uefa.europa, UEFA Europa League, europa,,,
|
156
|
-
uefa.conf, UEFA Conference League, conf,,, ### use con (conf - confusion with config files?)
|
157
|
-
uefa.con, UEFA Conference League, con,,,
|
158
|
-
|
159
|
-
uefa.nl, UEFA Nations League, nl,,,
|
160
|
-
euro, Euro, euro,,,
|
data/config/leagues_world.csv
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
key, name, basename, start_season, end_season, comments
|
2
|
-
|
3
|
-
cn.1, Chinese Super League, 1-superleague,,,
|
4
|
-
jp.1, Japan J1 League, 1-j1league,,,
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
kz.1, Kazakh Premier League, 1-premierleague,,,
|
9
|
-
|
10
|
-
|
11
|
-
il.1, Israeli Premier League, 1-premierleague,,,
|
12
|
-
|
13
|
-
|
14
|
-
eg.1, Egypt Premiership, 1-premiership,,,
|
15
|
-
ma.1, Morocco Botola Pro 1, 1-botolapro1,,,
|
16
|
-
dz.1, Algeria Ligue 1, 1-ligue1,,,
|
17
|
-
|
18
|
-
afl, African Football League, afl,,,
|
19
|
-
caf.cl, CAF Champions League, cl,,,
|
20
|
-
caf.champs, CAF Champions League, champs,,, ## use alternate code - why? why not?
|
21
|
-
|
22
|
-
|
23
|
-
world, World Cup, cup,,,
|
data/lib/sportdb/fbgen/main.rb
DELETED
@@ -1,172 +0,0 @@
|
|
1
|
-
|
2
|
-
module Fbgen
|
3
|
-
def self.main( args=ARGV )
|
4
|
-
|
5
|
-
opts = {
|
6
|
-
source_path: [],
|
7
|
-
dry: false,
|
8
|
-
debug: true,
|
9
|
-
file: nil,
|
10
|
-
}
|
11
|
-
|
12
|
-
parser = OptionParser.new do |parser|
|
13
|
-
parser.banner = "Usage: #{$PROGRAM_NAME} [options] [args]"
|
14
|
-
|
15
|
-
parser.on( "--dry",
|
16
|
-
"dry run; do NOT write - default is (#{opts[:dry]})" ) do |dry|
|
17
|
-
opts[:dry] = true
|
18
|
-
end
|
19
|
-
parser.on( "-q", "--quiet",
|
20
|
-
"less debug output/messages - default is (#{!opts[:debug]})" ) do |debug|
|
21
|
-
opts[:debug] = false
|
22
|
-
end
|
23
|
-
|
24
|
-
parser.on( "-I DIR", "--include DIR",
|
25
|
-
"add directory to (source) search path - default is (#{opts[:source_path].join(',')})") do |dir|
|
26
|
-
opts[:source_path] += path
|
27
|
-
end
|
28
|
-
|
29
|
-
parser.on( "-f FILE", "--file FILE",
|
30
|
-
"read leagues (and seasons) via .csv file") do |file|
|
31
|
-
opts[:file] = file
|
32
|
-
end
|
33
|
-
end
|
34
|
-
parser.parse!( args )
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
if opts[:source_path].empty? &&
|
39
|
-
File.exist?( '/sports/cache.api.fbdat') &&
|
40
|
-
File.exist?( '/sports/cache.wfb' )
|
41
|
-
opts[:source_path] << '/sports/cache.api.fbdat'
|
42
|
-
opts[:source_path] << '/sports/cache.wfb'
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
if opts[:source_path].empty?
|
47
|
-
opts[:source_path] = ['.'] ## use ./ as default
|
48
|
-
end
|
49
|
-
|
50
|
-
source_path = opts[:source_path]
|
51
|
-
|
52
|
-
|
53
|
-
puts "OPTS:"
|
54
|
-
p opts
|
55
|
-
puts "ARGV:"
|
56
|
-
p args
|
57
|
-
|
58
|
-
|
59
|
-
datasets = if opts[:file]
|
60
|
-
read_datasets( opts[:file] )
|
61
|
-
else
|
62
|
-
parse_datasets_args( args )
|
63
|
-
end
|
64
|
-
|
65
|
-
puts "datasets:"
|
66
|
-
pp datasets
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
root_dir = './o'
|
71
|
-
puts " (output) root_dir: >#{root_dir}<"
|
72
|
-
|
73
|
-
|
74
|
-
### step 0 - validate and fill-in seasons etc.
|
75
|
-
validate_datasets!( datasets, source_path: source_path )
|
76
|
-
|
77
|
-
## step 1 - generate
|
78
|
-
datasets.each do |league_key, seasons|
|
79
|
-
puts "==> gen #{league_key} - #{seasons.size} seasons(s)..."
|
80
|
-
|
81
|
-
league_info = Writer::LEAGUES[ league_key ]
|
82
|
-
pp league_info
|
83
|
-
|
84
|
-
seasons.each do |season|
|
85
|
-
filename = "#{season.to_path}/#{league_key}.csv"
|
86
|
-
path = find_file( filename, path: source_path )
|
87
|
-
|
88
|
-
## get matches
|
89
|
-
puts " ---> reading matches in #{path} ..."
|
90
|
-
matches = SportDb::CsvMatchParser.read( path )
|
91
|
-
puts " #{matches.size} matches"
|
92
|
-
|
93
|
-
## build
|
94
|
-
txt = SportDb::TxtMatchWriter.build( matches )
|
95
|
-
puts txt if opts[:debug]
|
96
|
-
|
97
|
-
league_name = league_info[ :name ] # e.g. Brasileiro Série A
|
98
|
-
league_name = league_name.call( season ) if league_name.is_a?( Proc ) ## is proc/func - name depends on season
|
99
|
-
|
100
|
-
buf = String.new
|
101
|
-
buf << "= #{league_name} #{season}\n\n"
|
102
|
-
buf << txt
|
103
|
-
|
104
|
-
outpath = "#{root_dir}/foot/#{season.to_path}/#{league_key}.txt"
|
105
|
-
|
106
|
-
if opts[:dry]
|
107
|
-
puts " (dry) writing to >#{outpath}<..."
|
108
|
-
else
|
109
|
-
write_text( outpath, buf )
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end # method self.main
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
def self.find_file( filename, path: )
|
118
|
-
path.each do |src_dir|
|
119
|
-
path = "#{src_dir}/#{filename}"
|
120
|
-
return path if File.exist?( path )
|
121
|
-
end
|
122
|
-
|
123
|
-
## fix - raise file not found error!!!
|
124
|
-
nil ## not found - raise filenot found error - why? why not?
|
125
|
-
end
|
126
|
-
|
127
|
-
|
128
|
-
### use a function for (re)use
|
129
|
-
### note - may add seasons in place!! (if seasons is empty)
|
130
|
-
def self.validate_datasets!( datasets, source_path: )
|
131
|
-
datasets.each do |dataset|
|
132
|
-
league_key, seasons = dataset
|
133
|
-
|
134
|
-
league_info = Writer::LEAGUES[ league_key ]
|
135
|
-
if league_info.nil?
|
136
|
-
puts "!! ERROR - no league (config) found for >#{league_key}<; sorry"
|
137
|
-
exit 1
|
138
|
-
end
|
139
|
-
|
140
|
-
|
141
|
-
if seasons.empty?
|
142
|
-
## simple heuristic to find current season
|
143
|
-
[ Season( '2024/25'), Season( '2024') ].each do |season|
|
144
|
-
filename = "#{season.to_path}/#{league_key}.csv"
|
145
|
-
path = find_file( filename, path: source_path )
|
146
|
-
if path
|
147
|
-
seasons = [season]
|
148
|
-
dataset[1] = seasons
|
149
|
-
break
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
if seasons.empty?
|
154
|
-
puts "!! ERROR - no latest auto-season via source found for #{league_key}; sorry"
|
155
|
-
exit 1
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
## check source path too upfronat - why? why not?
|
160
|
-
seasons.each do |season|
|
161
|
-
filename = "#{season.to_path}/#{league_key}.csv"
|
162
|
-
path = find_file( filename, path: source_path )
|
163
|
-
|
164
|
-
if path.nil?
|
165
|
-
puts "!! ERROR - no source found for #{filename}; sorry"
|
166
|
-
exit 1
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
datasets
|
171
|
-
end
|
172
|
-
end # module Fbgen
|
data/lib/sportdb/fbtxt/main.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
|
2
|
-
module Fbtxt
|
3
|
-
def self.main( args=ARGV )
|
4
|
-
|
5
|
-
|
6
|
-
opts = {
|
7
|
-
}
|
8
|
-
|
9
|
-
parser = OptionParser.new do |parser|
|
10
|
-
parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
|
11
|
-
end
|
12
|
-
parser.parse!( args )
|
13
|
-
|
14
|
-
puts "OPTS:"
|
15
|
-
p opts
|
16
|
-
puts "ARGV:"
|
17
|
-
p args
|
18
|
-
|
19
|
-
|
20
|
-
matches = []
|
21
|
-
|
22
|
-
## step 1 - get all matches via csv
|
23
|
-
args.each do |arg|
|
24
|
-
path = arg
|
25
|
-
puts "==> reading matches in #{path} ..."
|
26
|
-
more_matches = SportDb::CsvMatchParser.read( path )
|
27
|
-
matches += more_matches
|
28
|
-
end
|
29
|
-
|
30
|
-
puts "#{matches.size} matches"
|
31
|
-
puts
|
32
|
-
|
33
|
-
txt = SportDb::TxtMatchWriter.build( matches )
|
34
|
-
puts txt
|
35
|
-
puts
|
36
|
-
end
|
37
|
-
end # module Fbtxt
|
@@ -1,83 +0,0 @@
|
|
1
|
-
|
2
|
-
module SportDb
|
3
|
-
class LeagueConfig
|
4
|
-
|
5
|
-
def self.read( path )
|
6
|
-
recs = read_csv( path )
|
7
|
-
new( recs )
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize( recs=nil )
|
11
|
-
@table = {}
|
12
|
-
add( recs ) if recs
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
class LeagueItem
|
17
|
-
def initialize
|
18
|
-
@recs = []
|
19
|
-
end
|
20
|
-
def add( rec ) @recs << rec; end
|
21
|
-
alias_method :<<, :add
|
22
|
-
|
23
|
-
def find_by_season( season )
|
24
|
-
@recs.each do |rec|
|
25
|
-
start_season = rec['start_season']
|
26
|
-
end_season = rec['end_season']
|
27
|
-
return rec if (start_season.nil? || start_season <= season) &&
|
28
|
-
(end_season.nil? || end_season >= season)
|
29
|
-
end
|
30
|
-
nil
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
def name_by_season( season )
|
35
|
-
rec = find_by_season( season )
|
36
|
-
rec ? rec['name'] : nil
|
37
|
-
end
|
38
|
-
|
39
|
-
def basename_by_season( season )
|
40
|
-
rec = find_by_season( season )
|
41
|
-
rec ? rec['basename'] : nil
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
def [](key)
|
46
|
-
## short cut - if only one or zero rec
|
47
|
-
## return directly
|
48
|
-
if @recs.empty?
|
49
|
-
nil
|
50
|
-
elsif @recs.size == 1 &&
|
51
|
-
@recs[0]['start_season'].nil? &&
|
52
|
-
@recs[0]['end_season'].nil?
|
53
|
-
@recs[0][key.to_s]
|
54
|
-
else ### return proc that requires season arg
|
55
|
-
case key.to_sym
|
56
|
-
when :name then method(:name_by_season).to_proc
|
57
|
-
when :basename then method(:basename_by_season).to_proc
|
58
|
-
else
|
59
|
-
nil ## return nil - why? why not?
|
60
|
-
## raise ArgumentError, "invalid key #{key}; use :name or :basename"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def add( recs )
|
67
|
-
recs.each do |rec|
|
68
|
-
@table[ rec['key'] ] ||= LeagueItem.new
|
69
|
-
|
70
|
-
## note: auto-change seasons to season object or nil
|
71
|
-
@table[ rec['key'] ] << { 'name' => rec['name'],
|
72
|
-
'basename' => rec['basename'],
|
73
|
-
'start_season' => rec['start_season'].empty? ? nil : Season.parse( rec['start_season'] ),
|
74
|
-
'end_season' => rec['end_season'].empty? ? nil : Season.parse( rec['end_season'] ),
|
75
|
-
}
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
def [](key) @table[ key.to_s.downcase ]; end
|
81
|
-
|
82
|
-
end # class LeagueConfig
|
83
|
-
end # module SportDb
|