sportdb-writers 0.1.1 → 0.2.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.
@@ -1,35 +0,0 @@
1
- module Writer
2
-
3
- ########################
4
- # Austria
5
-
6
- LEAGUES.merge!(
7
- 'at.1' => { name: 'Österr. Bundesliga',
8
- basename: '1-bundesliga',
9
- stages: ->(season) {
10
- if season.start_year >= 2018
11
- [['Grunddurchgang'],
12
- ['Finaldurchgang - Meister',
13
- 'Finaldurchgang - Qualifikation',
14
- 'Europa League Play-off']]
15
- else
16
- nil
17
- end
18
- },
19
- },
20
- 'at.2' => { name: ->(season) { season.start_year >= 2018 ?
21
- 'Österr. 2. Liga' :
22
- 'Österr. Erste Liga' },
23
- basename: ->(season) { season.start_year >= 2018 ?
24
- '2-liga2' :
25
- '2-liga1' },
26
- },
27
- 'at.3.o' => { name: 'Österr. Regionalliga Ost',
28
- basename: '3-regionalliga-ost',
29
- },
30
- 'at.cup' => { name: 'ÖFB Cup',
31
- basename: 'cup',
32
- }
33
- )
34
-
35
- end # module Writer
@@ -1,21 +0,0 @@
1
- module Writer
2
-
3
- ############################
4
- # Germany / Deutschland
5
-
6
- LEAGUES.merge!(
7
- 'de.1' => { name: 'Deutsche Bundesliga',
8
- basename: '1-bundesliga',
9
- },
10
- 'de.2' => { name: 'Deutsche 2. Bundesliga',
11
- basename: '2-bundesliga2',
12
- },
13
- 'de.3' => { name: 'Deutsche 3. Liga',
14
- basename: '3-liga3',
15
- },
16
- 'de.cup' => { name: 'DFB Pokal',
17
- basename: 'cup',
18
- }
19
- )
20
-
21
- end # module Writer
@@ -1,58 +0,0 @@
1
- module Writer
2
-
3
- ####################
4
- # England
5
-
6
-
7
- def self.eng1( season )
8
- case season ## todo/fix: - use cast e.g. Season(season) - make sure it's a season obj
9
- when Season('1888/89')..Season('1891/92') ## single league (no divisions)
10
- {name: 'English Football League',
11
- basename: '1-footballleague'}
12
- when Season('1892/93')..Season('1991/92') ## start of division 1 & 2
13
- {name: 'English Division One',
14
- basename: '1-division1'}
15
- else ## starts in season 1992/93
16
- {name: 'English Premier League',
17
- basename: '1-premierleague'}
18
- end
19
- end
20
-
21
- def self.eng2( season )
22
- case season
23
- when Season('1892/93')..Season('1991/92')
24
- {name: 'English Division Two', ## or use English Football League Second Division ???
25
- basename: '2-division2'}
26
- when Season('1992/93')..Season('2003/04') ## start of premier league
27
- {name: 'English Division One',
28
- basename: '2-division1'}
29
- else # starts in 2004/05
30
- {name: 'English Championship', ## rebranding divsion 1 => championship
31
- basename: '2-championship'}
32
- end
33
- end
34
-
35
-
36
- LEAGUES.merge!(
37
- 'eng.1' => { name: ->(season) { eng1( season )[ :name ] },
38
- basename: ->(season) { eng1( season )[ :basename ] },
39
- },
40
- 'eng.2' => { name: ->(season) { eng2( season )[ :name ] },
41
- basename: ->(season) { eng2( season )[ :basename ] },
42
- },
43
- 'eng.3' => { name: 'English League One',
44
- basename: '3-league1',
45
- },
46
- 'eng.4' => { name: 'English League Two',
47
- basename: '4-league2',
48
- },
49
- 'eng.5' => { name: 'English National League',
50
- basename: '5-nationalleague',
51
- },
52
- 'eng.cup' => { name: 'English FA Cup',
53
- basename: 'facup',
54
- }
55
- )
56
-
57
- end # module Writer
58
-
@@ -1,15 +0,0 @@
1
- module Writer
2
-
3
- LEAGUES.merge!(
4
- ###################
5
- # Spain / Espana
6
- 'es.1' => { name: 'Primera División de España',
7
- basename: '1-liga',
8
- },
9
- 'es.2' => { name: 'Segunda División de España',
10
- basename: '2-liga2',
11
- },
12
- )
13
-
14
- end # module Writer
15
-
@@ -1,185 +0,0 @@
1
- module Writer
2
-
3
- LEAGUES.merge!(
4
-
5
- ###
6
- # Uefa
7
- ## quick and dirty add for champions league
8
- 'uefa.cl' => { name: 'UEFA Champions League',
9
- basename: 'cl',
10
- },
11
-
12
- ########################
13
- # France
14
- 'fr.1' => { name: 'French Ligue 1',
15
- basename: '1-ligue1',
16
- },
17
- 'fr.2' => { name: 'French Ligue 2',
18
- basename: '2-ligue2',
19
- },
20
-
21
- 'hu.1' => { name: 'Hungarian NB I',
22
- basename: '1-nbi',
23
- },
24
- 'gr.1' => { name: 'Super League Greece',
25
- basename: '1-superleague',
26
- stages: ->(season) {
27
- if season.start_year >= 2019 # new league system starting with 2015/16 season
28
- [['Regular Season'],
29
- ['Playoffs - Championship',
30
- 'Playoffs - Relegation']]
31
- elsif [2017,2018].include?( season.start_year ) ## 2017/18, 2018/19
32
- nil
33
- elsif [2013,2014,2015,2016].include?( season.start_year )
34
- [['Regular Season'],
35
- ['Playoffs']]
36
- elsif season.start_year == 2012
37
- [['Regular Season'],
38
- ['Playoffs',
39
- 'Match 6th Place']]
40
- elsif [2010,2011].include?( season.start_year )
41
- [['Regular Season'],
42
- ['Playoffs']]
43
- else
44
- nil
45
- end
46
- },
47
- },
48
-
49
- 'pt.1' => { name: 'Portuguese Primeira Liga',
50
- basename: '1-primeiraliga',
51
- },
52
- 'pt.2' => { name: 'Portuguese Segunda Liga',
53
- basename: '2-segundaliga',
54
- },
55
-
56
- 'ch.1' => { name: 'Swiss Super League',
57
- basename: '1-superleague',
58
- },
59
- 'ch.2' => { name: 'Swiss Challenge League',
60
- basename: '2-challengeleague',
61
- },
62
- 'tr.1' => { name: 'Turkish Süper Lig',
63
- basename: '1-superlig',
64
- },
65
- 'tr.2' => { name: 'Turkish 1. Lig',
66
- basename: '2-lig1',
67
- },
68
-
69
-
70
- 'is.1' => { name: 'Iceland Urvalsdeild',
71
- basename: '1-urvalsdeild',
72
- },
73
- 'sco.1' => { name: 'Scottish Premiership',
74
- basename: '1-premiership',
75
- stages: [['Regular Season'],
76
- ['Playoffs - Championship',
77
- 'Playoffs - Relegation' ]]
78
- },
79
- 'ie.1' => { name: 'Irish Premier Division',
80
- basename: '1-premierdivision',
81
- },
82
-
83
- 'fi.1' => { name: 'Finland Veikkausliiga', ## note: make optional!!! override here (otherwise (re)use "regular" lookup "canonical" name from league!!!)
84
- basename: '1-veikkausliiga',
85
- stages: [['Regular Season'],
86
- ['Playoffs - Championship',
87
- 'Playoffs - Challenger',
88
- 'Europa League Finals' ]]
89
- },
90
- 'se.1' => { name: 'Sweden Allsvenskan',
91
- basename: '1-allsvenskan',
92
- },
93
- 'se.2' => { name: 'Sweden Superettan',
94
- basename: '2-superettan',
95
- },
96
- 'no.1' => { name: 'Norwegian Eliteserien',
97
- basename: '1-eliteserien',
98
- },
99
- 'dk.1' => { name: 'Denmark Superligaen',
100
- basename: '1-superligaen',
101
- stages: [['Regular Season'],
102
- ['Playoffs - Championship',
103
- 'Playoffs - Relegation',
104
- 'Europa League Finals']]
105
- },
106
-
107
- 'lu.1' => { name: 'Luxembourger First Division',
108
- basename: '1-nationaldivision',
109
- },
110
- 'be.1' => { name: 'Belgian First Division A',
111
- basename: '1-firstdivisiona',
112
- stages: [['Regular Season'],
113
- ['Playoffs - Championship',
114
- 'Playoffs - Europa League',
115
- 'Playoffs - Europa League - Finals']]
116
- },
117
- 'nl.1' => { name: 'Dutch Eredivisie',
118
- basename: '1-eredivisie',
119
- },
120
- 'cz.1' => { name: 'Czech First League',
121
- basename: '1-firstleague',
122
- stages: [['Regular Season'],
123
- ['Playoffs - Championship',
124
- 'Europa League Play-off',
125
- 'Playoffs - Relegation'
126
- ]]
127
- },
128
- 'sk.1' => { name: 'Slovakia First League',
129
- basename: '1-superliga',
130
- stages: [['Regular Season'],
131
- ['Playoffs - Championship',
132
- 'Playoffs - Relegation',
133
- 'Europa League Finals']]
134
- },
135
- 'hr.1' => { name: 'Croatia 1. HNL',
136
- basename: '1-hnl',
137
- },
138
- 'pl.1' => { name: 'Poland Ekstraklasa',
139
- basename: '1-ekstraklasa',
140
- stages: [['Regular Season'],
141
- ['Playoffs - Championship',
142
- 'Playoffs - Relegation']]
143
- },
144
-
145
- 'ro.1' => { name: 'Romanian Liga 1',
146
- basename: '1-liga1',
147
- stages: ->(season) {
148
- if season.start_year >= 2015 # new league system starting with 2015/16 season
149
- [['Regular Season'],
150
- ['Playoffs - Championship',
151
- 'Playoffs - Relegation']]
152
- else
153
- nil
154
- end
155
- },
156
- },
157
-
158
- 'ua.1' => { name: 'Ukraine Premier League',
159
- basename: '1-premierleague',
160
- stages: [['Regular Season'],
161
- ['Playoffs - Championship',
162
- 'Playoffs - Relegation',
163
- 'Europa League Finals']]
164
- },
165
-
166
-
167
- 'ru.1' => { name: 'Russian Premier League',
168
- basename: '1-premierliga',
169
- stages: ->(season) {
170
- if season.start_year == 2011 # 2011/12 - new (transition) league system during season switch from calendar year to academic
171
- [['Regular Season'],
172
- ['Playoffs - Championship',
173
- 'Playoffs - Relegation']]
174
- else
175
- nil
176
- end
177
- },
178
- },
179
- 'ru.2' => { name: 'Russian 1. Division',
180
- basename: '2-division1',
181
- },
182
- )
183
-
184
-
185
- end # module Writer
@@ -1,16 +0,0 @@
1
- module Writer
2
-
3
- LEAGUES.merge!(
4
-
5
- ########################
6
- # Italy
7
- 'it.1' => { name: 'Italian Serie A',
8
- basename: '1-seriea',
9
- },
10
- 'it.2' => { name: 'Italian Serie B',
11
- basename: '2-serieb',
12
- },
13
-
14
- )
15
-
16
- end # module Writer
@@ -1,23 +0,0 @@
1
- module Writer
2
-
3
- LEAGUES.merge!(
4
-
5
- ##############################
6
- # Mexico
7
- #
8
- # - Viertelfinale
9
- # - Halbfinale
10
- # - Finale
11
-
12
- 'mx.1' => { name: 'Liga MX',
13
- basename: '1-ligamx', ## note: gets "overwritten" by stages (see below)
14
- stages: [{basename: '1-apertura', names: ['Apertura']},
15
- {basename: '1-apertura_liguilla', names: ['Apertura - Liguilla']},
16
- {basename: '1-clausura', names: ['Clausura']},
17
- {basename: '1-clausura_liguilla', names: ['Clausura - Liguilla']},
18
- ],
19
- },
20
- )
21
-
22
-
23
- end # module Writer
@@ -1,17 +0,0 @@
1
- module Writer
2
-
3
-
4
- LEAGUES.merge!(
5
- 'ar.1' => { name: 'Argentina Primera Division',
6
- basename: '1-primeradivision',
7
- },
8
-
9
- ############################
10
- # Brazil
11
- 'br.1' => { name: 'Brasileiro Série A', ## league name
12
- basename: '1-seriea',
13
- },
14
- )
15
-
16
-
17
- end # module Writer
@@ -1,14 +0,0 @@
1
-
2
- module Writer
3
-
4
- LEAGUES.merge!(
5
- 'cn.1' => { name: 'Chinese Super League',
6
- basename: '1-superleague',
7
- },
8
- 'jp.1' => { name: 'Japan J1 League',
9
- basename: '1-j1league',
10
- },
11
- )
12
-
13
- end # module Writer
14
-
@@ -1,195 +0,0 @@
1
-
2
- module SportDb
3
-
4
- ###
5
- ## todo/fix:
6
- ## add -i/--interactive flag
7
- ## will prompt yes/no before git operations (with consequences)!!!
8
-
9
- class GitHubSync
10
-
11
- ## map leagues to repo+path
12
- ## e.g. fr.1 => europe/france
13
- ## eng..1 => england
14
- REPOS = {
15
- 'at.1' => 'austria',
16
- 'at.2' => 'austria',
17
- 'at.3.o' => 'austria',
18
- 'at.cup' => 'austria',
19
-
20
- 'de.1' => 'deutschland',
21
- 'de.2' => 'deutschland',
22
- 'de.3' => 'deutschland',
23
- 'de.cup' => 'deutschland',
24
-
25
- 'eng.1' => 'england',
26
- 'eng.2' => 'england',
27
- 'eng.3' => 'england',
28
- 'eng.4' => 'england',
29
- 'eng.5' => 'england',
30
- 'eng.cup' => 'england', # English FA Cup
31
-
32
- 'es.1' => 'espana',
33
- 'es.2' => 'espana',
34
-
35
- 'fr.1' => 'europe/france',
36
- 'fr.2' => 'europe/france',
37
-
38
- 'hu.1' => 'europe/hungary',
39
- 'gr.1' => 'europe/greece',
40
- 'pt.1' => 'europe/portugal',
41
- 'pt.2' => 'europe/portugal',
42
-
43
- 'ch.1' => 'europe/switzerland',
44
- 'ch.2' => 'europe/switzerland',
45
-
46
- 'tr.1' => 'europe/turkey',
47
- 'tr.2' => 'europe/turkey',
48
-
49
- 'is.1' => 'europe/iceland',
50
- 'sco.1' => 'europe/scotland',
51
- 'ie.1' => 'europe/ireland',
52
-
53
- 'fi.1' => 'europe/finland',
54
- 'se.1' => 'europe/sweden',
55
- 'se.2' => 'europe/sweden',
56
- 'no.1' => 'europe/norway',
57
- 'dk.1' => 'europe/denmark',
58
-
59
- 'lu.1' => 'europe/luxembourg',
60
- 'be.1' => 'europe/belgium',
61
- 'nl.1' => 'europe/netherlands',
62
- 'cz.1' => 'europe/czech-republic',
63
-
64
- 'sk.1' => 'europe/slovakia',
65
- 'hr.1' => 'europe/croatia',
66
- 'pl.1' => 'europe/poland',
67
-
68
- 'ro.1' => 'europe/romania',
69
-
70
- 'ua.1' => 'europe/ukraine',
71
-
72
- 'ru.1' => 'europe/russia',
73
- 'ru.2' => 'europe/russia',
74
-
75
- 'it.1' => 'italy',
76
- 'it.2' => 'italy',
77
-
78
- 'mx.1' => 'mexico',
79
-
80
- 'ar.1' => 'south-america/argentina',
81
- 'br.1' => 'south-america/brazil',
82
-
83
- 'cn.1' => 'world/asia/china',
84
- 'jp.1' => 'world/asia/japan',
85
- }
86
-
87
-
88
-
89
- ########
90
- ## (auto)default to Writer.config.out_dir - why? why not?
91
- ##
92
- ## note - is root for org (NOT monotree for now - why?`why not?)
93
- def self.root() @root || "/sports/openfootball"; end
94
- def self.root=( dir ) @root = dir; end
95
- ## use root_dir (alias) - why? why not?
96
-
97
-
98
- def initialize( datasets )
99
- @repos = _find_repos( datasets )
100
- end
101
-
102
-
103
- def git_push_if_changes
104
- _git_push_if_changes( @repos )
105
- end
106
-
107
- def git_fast_forward_if_clean
108
- _git_fast_forward_if_clean( @repos )
109
- end
110
-
111
-
112
- ## todo/fix: rename to something like
113
- ## git_(auto_)commit_and_push_if_changes/if_dirty()
114
-
115
- def _git_push_if_changes( names ) ## optenfootball repo names e.g. world, england, etc.
116
- message = "auto-update week #{Date.today.cweek}" ## add /#{Date.today.cday - why? why not?
117
- puts message
118
-
119
- names.each do |name|
120
- path = "#{self.class.root}/#{name}"
121
-
122
- Gitti::GitProject.open( path ) do |proj|
123
- puts ''
124
- puts "###########################################"
125
- puts "## trying to commit & push repo in path >#{path}<"
126
- puts "Dir.getwd: #{Dir.getwd}"
127
- output = proj.changes
128
- if output.empty?
129
- puts "no changes found; skipping commit & push"
130
- else
131
- proj.add( '.' )
132
- proj.commit( message )
133
- proj.push
134
- end
135
- end
136
- end
137
- end
138
-
139
-
140
- def _git_fast_forward_if_clean( names )
141
- names.each do |name|
142
- path = "#{self.class.root}/#{name}"
143
-
144
- Gitti::GitProject.open( path ) do |proj|
145
- output = proj.changes
146
- unless output.empty?
147
- puts "FAIL - cannot git pull (fast-forward) - working tree has changes:"
148
- puts output
149
- exit 1
150
- end
151
-
152
- proj.fast_forward
153
- end
154
- end
155
- end
156
-
157
-
158
- ## todo/check: find a better name for helper?
159
- ## note: datasets of format
160
- ##
161
- ## DATASETS = [
162
- ## ['it.1', %w[2020/21 2019/20]],
163
- ## ['it.2', %w[2019/20]],
164
- ## ['es.1', %w[2019/20]],
165
- ## ['es.2', %w[2019/20]],
166
- ## ]
167
-
168
-
169
- def _find_repos( datasets )
170
- repos = []
171
- datasets.each do |dataset|
172
- league_key = dataset[0]
173
- path = REPOS[ league_key ]
174
- ## pp path
175
- if path.nil?
176
- puts "!! ERROR - no repo path found for league >#{league_key}<; sorry"
177
- exit 1
178
- end
179
-
180
- ## auto-add
181
- ## openfootball/ org here
182
- ## and keep root "generic" to monoroot - why? why not?
183
-
184
- ## use only first part e.g. europe/belgium => europe
185
- repos << path.split( '/' )[0]
186
- end
187
- pp repos
188
- repos.uniq ## note: remove duplicates (e.g. europe or world or such)
189
- end
190
-
191
-
192
-
193
-
194
- end # class GitHub
195
- end # module SportDb