fbup 0.2.0 → 0.2.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 +2 -0
- data/Rakefile +2 -2
- data/config/leagues.csv +111 -0
- data/config/openfootball.csv +2 -1
- data/lib/fbup/league_config.rb +99 -0
- data/lib/fbup/main.rb +17 -9
- data/lib/fbup/version.rb +1 -1
- data/lib/fbup.rb +1 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0cc7c6bdb92fe41bd89ddf67258bf59ce8feb70ad16c9b1908fdda37f165c03
|
4
|
+
data.tar.gz: 3d7cc168bd623108f549e4c531738350065a1c7743ffd42ab0a7d7e66d89c8d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4851fcc456089aa461f5fa01f2866c414acfa5ed75e921e58e28224fa2a23e8190e581627d36637732d4065a7a01d06f1d7c0843b26f9e7d5e3154dc1041f1c4
|
7
|
+
data.tar.gz: 5c38c8ea0aa370ad42e1f9a7be5b2df211bd0989af16d14efe7a634ec5ffe07c10884a4ff672035ae396a8ce8dd0ded746ee136c8bacf63806ccda4dc27ca856
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
data/config/leagues.csv
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
code,basename,start_season,end_season
|
2
|
+
|
3
|
+
########
|
4
|
+
### use a "custom" basename for "classic" leagues
|
5
|
+
|
6
|
+
|
7
|
+
####
|
8
|
+
## /austria
|
9
|
+
at.1,1-bundesliga,,
|
10
|
+
## -- add new name - Erste Liga => 2. Liga
|
11
|
+
at.2,2-liga2,2018/19,
|
12
|
+
at.2,2-liga1,,2017/18
|
13
|
+
at.3.o,3-regionalliga-ost,,
|
14
|
+
at.3.m,3-regionalliga-mitte,,
|
15
|
+
at.3.w,3-regionalliga-west,,
|
16
|
+
at.3.sbg,3-regionalliga-salzburg,,
|
17
|
+
at.3.t,3-regionalliga-tirol,,
|
18
|
+
at.3.v,3-regionalliga-vorarlberg,,
|
19
|
+
at.cup,cup,,
|
20
|
+
|
21
|
+
####
|
22
|
+
## /deutschland
|
23
|
+
de.1,1-bundesliga,,
|
24
|
+
de.2,2-bundesliga2,,
|
25
|
+
de.3,3-liga3,,
|
26
|
+
de.cup,cup,,
|
27
|
+
de.super,super,,
|
28
|
+
de.4.nord,4-regionalliga-nord,,
|
29
|
+
de.4.nordost,4-regionalliga-nordost,,
|
30
|
+
de.4.west,4-regionalliga-west,,
|
31
|
+
de.4.suedwest,4-regionalliga-suedwest,,
|
32
|
+
de.4.bayern,4-regionalliga-bayern,,
|
33
|
+
# -- add alternate keys for de.4
|
34
|
+
# todo/fix - find a way to add alternate keys (WITHOUT repeating basename) !!!
|
35
|
+
de.4.n,4-regionalliga-nord,,
|
36
|
+
de.4.no,4-regionalliga-nordost,,
|
37
|
+
de.4.w,4-regionalliga-west,,
|
38
|
+
de.4.sw,4-regionalliga-suedwest,,
|
39
|
+
|
40
|
+
################
|
41
|
+
## /england
|
42
|
+
eng.2,2-championship,2004/05,
|
43
|
+
eng.3,3-league1,2004/05,
|
44
|
+
eng.4,4-league2,2004/05,
|
45
|
+
|
46
|
+
eng.1,1-premierleague,1992/93,
|
47
|
+
eng.2,2-division1,1992/93,2003/04
|
48
|
+
eng.3,3-division2,1992/93,2003/04
|
49
|
+
eng.4,4-division3,1992/93,2003/04
|
50
|
+
eng.5,5-nationalleague,1992/93,
|
51
|
+
|
52
|
+
eng.1,1-division1,1892/93,1991/92
|
53
|
+
eng.2,2-division2,1892/93,1991/92
|
54
|
+
eng.3,3-division3,,1991/92
|
55
|
+
eng.3.a,3-division3-north,,
|
56
|
+
eng.3.b,3-division3-south,,
|
57
|
+
eng.1,1-footballleague,1888/89,1891/92
|
58
|
+
|
59
|
+
|
60
|
+
###
|
61
|
+
## fix - always use fa.cup and efl.cup - why? why not?
|
62
|
+
eng.cup,facup,, ## FA CuP
|
63
|
+
eng.super,super,, ## FA Community Shield
|
64
|
+
eng.cup.l,eflcup,, ## EFL Cup
|
65
|
+
eng.cup.t,efltrophy,, ## EFL Trophy
|
66
|
+
eng.cup.t.ii,fatrophy,, ## FA Trophy
|
67
|
+
|
68
|
+
## -- add alternate codes / keys
|
69
|
+
eng.fa.cup,facup,, ## FA Cup
|
70
|
+
eng.efl.cup,eflcup,, ## EFL Cup
|
71
|
+
|
72
|
+
|
73
|
+
#######
|
74
|
+
## /espana
|
75
|
+
es.1,1-liga,,
|
76
|
+
es.2,2-liga2,,
|
77
|
+
es.3,3-liga2b,, ## Segunda División B
|
78
|
+
es.cup,cup,,
|
79
|
+
es.super,supercopa,, ## check - use only super - why? why not?
|
80
|
+
|
81
|
+
|
82
|
+
#####
|
83
|
+
## /italy
|
84
|
+
it.1,1-seriea,,
|
85
|
+
it.2,2-serieb,,
|
86
|
+
it.3.a,3-seriec_a,, ## North & Central West
|
87
|
+
it.3.b,3-seriec_b,, ## North & Central East
|
88
|
+
it.3.c,3-seriec_c,, ## South
|
89
|
+
it.cup,cup,,
|
90
|
+
it.super,super,,
|
91
|
+
## it.cup.c -- Italian Coppa Italia Serie C
|
92
|
+
|
93
|
+
|
94
|
+
#####
|
95
|
+
## /champions-league - uefa incl. europa & conference
|
96
|
+
uefa.cl, cl,,
|
97
|
+
uefa.champs, cl,,
|
98
|
+
uefa.el, el,,
|
99
|
+
uefa.europa, el,,
|
100
|
+
uefa.conf, conf,,
|
101
|
+
uefa.con, conf,,
|
102
|
+
|
103
|
+
#####
|
104
|
+
## /club-worldcup
|
105
|
+
world.clubs, clubworldcup,,
|
106
|
+
world.club, clubworldcup,,
|
107
|
+
## - use world.clubs or club ??
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
data/config/openfootball.csv
CHANGED
@@ -131,12 +131,13 @@ jp, world/asia/japan,
|
|
131
131
|
kz, world/asia/kazakhstan,
|
132
132
|
|
133
133
|
il, world/middle-east/israel,
|
134
|
+
sa, world/middle-east/saudi-arabia,
|
134
135
|
|
135
136
|
|
136
137
|
mls, world/north-america/major-league-soccer,
|
137
138
|
|
138
139
|
|
139
|
-
mx,
|
140
|
+
mx, world/north-america/mexico,
|
140
141
|
|
141
142
|
|
142
143
|
## fix/change concacaf.cl to concacaf.champs !!!
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Fbup
|
2
|
+
|
3
|
+
####
|
4
|
+
### check - rename to ExtraLeagueConfig or such - why? why not?
|
5
|
+
|
6
|
+
class LeagueConfig
|
7
|
+
|
8
|
+
def self.find_by( code:, season: )
|
9
|
+
## return league code record/item or nil
|
10
|
+
builtin.find_by( code: code, season: season )
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
#####
|
15
|
+
## (static) helpers
|
16
|
+
def self.builtin
|
17
|
+
## get builtin league code index (build on demand)
|
18
|
+
@leagues ||= begin
|
19
|
+
leagues = LeagueConfig.new
|
20
|
+
['leagues',
|
21
|
+
].each do |name|
|
22
|
+
recs = read_csv( "#{SportDb::Module::Fbup.root}/config/#{name}.csv" )
|
23
|
+
leagues.add( recs )
|
24
|
+
end
|
25
|
+
leagues
|
26
|
+
end
|
27
|
+
@leagues
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def self.norm( code ) ## use norm_(league)code - why? why not?
|
32
|
+
## norm league code
|
33
|
+
## downcase
|
34
|
+
## and remove all non-letters/digits e.g. at.1 => at1, at 1 => at1 etc.
|
35
|
+
## ö.1 => ö1
|
36
|
+
## note - allow unicode letters!!!
|
37
|
+
## note - assume downcase works for unicode too e.g. Ö=>ö
|
38
|
+
## for now no need to use our own downcase - why? why not?
|
39
|
+
|
40
|
+
code.downcase.gsub( /[^\p{Ll}0-9]/, '' )
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
def initialize
|
47
|
+
@leagues = {}
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def add( recs )
|
52
|
+
recs.each do |rec|
|
53
|
+
key = LeagueConfig.norm( rec['code'] )
|
54
|
+
@leagues[ key ] ||= []
|
55
|
+
|
56
|
+
## note: auto-change seasons to season object or nil
|
57
|
+
@leagues[ key ] << { 'code' => rec['code'],
|
58
|
+
'basename' => rec['basename'],
|
59
|
+
'start_season' => rec['start_season'].empty? ? nil : Season.parse( rec['start_season'] ),
|
60
|
+
'end_season' => rec['end_season'].empty? ? nil : Season.parse( rec['end_season'] ),
|
61
|
+
}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def find_by( code:, season: )
|
67
|
+
raise ArgumentError, "league code as string|symbol expected" unless code.is_a?(String) || code.is_a?(Symbol)
|
68
|
+
|
69
|
+
## return league code record/item or nil
|
70
|
+
## check for alt code first
|
71
|
+
season = Season( season )
|
72
|
+
key = LeagueCodes.norm( code )
|
73
|
+
rec = nil
|
74
|
+
|
75
|
+
recs = @leagues[ key ]
|
76
|
+
|
77
|
+
if recs
|
78
|
+
rec = _find_by_season( recs, season )
|
79
|
+
end
|
80
|
+
|
81
|
+
rec ## return nil if no code record/item found
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def _find_by_season( recs, season )
|
86
|
+
recs.each do |rec|
|
87
|
+
start_season = rec['start_season']
|
88
|
+
end_season = rec['end_season']
|
89
|
+
return rec if (start_season.nil? || start_season <= season) &&
|
90
|
+
(end_season.nil? || end_season >= season)
|
91
|
+
end
|
92
|
+
nil
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
end # class LeagueConfig
|
97
|
+
|
98
|
+
|
99
|
+
end # module Fbup
|
data/lib/fbup/main.rb
CHANGED
@@ -159,6 +159,9 @@ sync.git_fast_forward_if_clean if opts[:ffwd]
|
|
159
159
|
|
160
160
|
|
161
161
|
### step 0 - validate and fill-in seasons etc.
|
162
|
+
##
|
163
|
+
## todo/fix - remove fill-in seasons from validate!!
|
164
|
+
## use new autofill on init!!!
|
162
165
|
datasets.validate!( source_path: source_path )
|
163
166
|
|
164
167
|
|
@@ -181,7 +184,7 @@ datasets.each do |league_query, seasons|
|
|
181
184
|
|
182
185
|
### todo/fix - move basename out of league_info
|
183
186
|
### make it github/openfootball "legacy" code
|
184
|
-
basename = league_info[ 'basename' ] #.e.g 1-seriea
|
187
|
+
## basename = league_info[ 'basename' ] #.e.g 1-seriea
|
185
188
|
|
186
189
|
|
187
190
|
filename = "#{season.to_path}/#{league_code}.csv"
|
@@ -211,11 +214,20 @@ datasets.each do |league_query, seasons|
|
|
211
214
|
|
212
215
|
|
213
216
|
|
214
|
-
|
217
|
+
basename = nil
|
215
218
|
if classic_flag || opts[:classic]
|
216
|
-
|
219
|
+
league_config = LeagueConfig.find_by( code: league_query, season: season )
|
220
|
+
if league_config.nil?
|
221
|
+
puts "!! ERROR - basename league config required for classic format; no config found for #{league_query} #{season}; sorry"
|
222
|
+
exit 1
|
223
|
+
end
|
224
|
+
basename = league_config['basename']
|
217
225
|
else
|
218
|
-
##
|
226
|
+
## change base name to league key
|
227
|
+
## todo - fix - make gsub smarter
|
228
|
+
## change at.cup to at_cup - why? why not?
|
229
|
+
basename = league_code.gsub( '.', '' )
|
230
|
+
## bonus - add quick fix for new league name overwrites
|
219
231
|
league_name = LEAGUE_NAMES_V2[league_code] || league_name
|
220
232
|
end
|
221
233
|
|
@@ -235,11 +247,7 @@ datasets.each do |league_query, seasons|
|
|
235
247
|
outpath += if classic_flag || opts[:classic]
|
236
248
|
"/#{season.to_path}/#{basename}.txt"
|
237
249
|
else
|
238
|
-
## add season "inline" (to basename) or use dir
|
239
|
-
## change base name to league key
|
240
|
-
## todo - fix - make gsub smarter
|
241
|
-
## change at.cup to at_cup - why? why not?
|
242
|
-
basename = league_code.gsub( '.', '' )
|
250
|
+
## note - add season "inline" (to basename) or use dir
|
243
251
|
"/#{season.to_path}_#{basename}.txt"
|
244
252
|
end
|
245
253
|
|
data/lib/fbup/version.rb
CHANGED
data/lib/fbup.rb
CHANGED
@@ -18,6 +18,7 @@ require_relative 'fbup/version'
|
|
18
18
|
require_relative 'fbup/github_config'
|
19
19
|
require_relative 'fbup/github' ## github helpers/update machinery
|
20
20
|
|
21
|
+
require_relative 'fbup/league_config' ## for "classic" custom basenames e.g. eng.1 => 1-premierleague etc.
|
21
22
|
|
22
23
|
require_relative 'fbup/main'
|
23
24
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fbup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gitti
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.4.
|
33
|
+
version: 0.4.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.4.
|
40
|
+
version: 0.4.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: leagues
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.2.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.2.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,10 +103,12 @@ files:
|
|
103
103
|
- README.md
|
104
104
|
- Rakefile
|
105
105
|
- bin/fbup
|
106
|
+
- config/leagues.csv
|
106
107
|
- config/openfootball.csv
|
107
108
|
- lib/fbup.rb
|
108
109
|
- lib/fbup/github.rb
|
109
110
|
- lib/fbup/github_config.rb
|
111
|
+
- lib/fbup/league_config.rb
|
110
112
|
- lib/fbup/main.rb
|
111
113
|
- lib/fbup/version.rb
|
112
114
|
homepage: https://github.com/sportdb/sport.db
|