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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Manifest.txt +9 -10
- data/bin/fbgen +1 -87
- data/bin/fbtxt +1 -36
- data/config/leagues_america.csv +6 -0
- data/config/leagues_europe.csv +94 -0
- data/config/leagues_world.csv +4 -0
- data/config/openfootball.csv +52 -0
- data/lib/sportdb/fbgen/github.rb +83 -0
- data/lib/sportdb/fbgen/github_config.rb +97 -0
- data/lib/sportdb/fbgen/main.rb +211 -0
- data/lib/sportdb/fbtxt/main.rb +37 -0
- data/lib/sportdb/writers/league_config.rb +83 -0
- data/lib/sportdb/writers/txt_writer.rb +108 -4
- data/lib/sportdb/writers/version.rb +2 -2
- data/lib/sportdb/writers/write.rb +11 -8
- data/lib/sportdb/writers.rb +60 -13
- metadata +11 -12
- data/lib/sportdb/leagues/leagues_at.rb +0 -35
- data/lib/sportdb/leagues/leagues_de.rb +0 -21
- data/lib/sportdb/leagues/leagues_eng.rb +0 -58
- data/lib/sportdb/leagues/leagues_es.rb +0 -15
- data/lib/sportdb/leagues/leagues_europe.rb +0 -185
- data/lib/sportdb/leagues/leagues_it.rb +0 -16
- data/lib/sportdb/leagues/leagues_mx.rb +0 -23
- data/lib/sportdb/leagues/leagues_south_america.rb +0 -17
- data/lib/sportdb/leagues/leagues_world.rb +0 -14
- data/lib/sportdb/writers/github.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: 3483a7e2f321970a2e970ba30e272127892013b61c63be66431a318d32b52c3f
|
4
|
+
data.tar.gz: 4d213ad75e6973aa6ef95bee7fb39a62bca69cd3261fc18e2bfcfc9a6b913b87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7b00a033d247555ca57acc503c88de73111605738998a9e5b3ea4e53f0353b08df19cfa1f9d5c84a5ad22b5528ddb632ba927b4f0b53fb5493f5391732d3d13
|
7
|
+
data.tar.gz: 23cec6ae8fa9b9ca04cf2242c86f8310de76a191b5a66bc4f2cab09aff7ea5c3e0a0d312bfe582dd2150d344302bdabab592c9b1944385bd75ae86de2367d207
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
@@ -4,18 +4,17 @@ README.md
|
|
4
4
|
Rakefile
|
5
5
|
bin/fbgen
|
6
6
|
bin/fbtxt
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
lib/sportdb/
|
12
|
-
lib/sportdb/
|
13
|
-
lib/sportdb/
|
14
|
-
lib/sportdb/
|
15
|
-
lib/sportdb/leagues/leagues_world.rb
|
7
|
+
config/leagues_america.csv
|
8
|
+
config/leagues_europe.csv
|
9
|
+
config/leagues_world.csv
|
10
|
+
config/openfootball.csv
|
11
|
+
lib/sportdb/fbgen/github.rb
|
12
|
+
lib/sportdb/fbgen/github_config.rb
|
13
|
+
lib/sportdb/fbgen/main.rb
|
14
|
+
lib/sportdb/fbtxt/main.rb
|
16
15
|
lib/sportdb/writers.rb
|
17
|
-
lib/sportdb/writers/github.rb
|
18
16
|
lib/sportdb/writers/goals.rb
|
17
|
+
lib/sportdb/writers/league_config.rb
|
19
18
|
lib/sportdb/writers/txt_writer.rb
|
20
19
|
lib/sportdb/writers/version.rb
|
21
20
|
lib/sportdb/writers/write.rb
|
data/bin/fbgen
CHANGED
@@ -6,94 +6,8 @@
|
|
6
6
|
|
7
7
|
require 'sportdb/writers'
|
8
8
|
|
9
|
-
require 'optparse'
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
args=ARGV
|
14
|
-
|
15
|
-
|
16
|
-
opts = {
|
17
|
-
}
|
18
|
-
|
19
|
-
parser = OptionParser.new do |parser|
|
20
|
-
parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
|
21
|
-
end
|
22
|
-
parser.parse!( args )
|
23
|
-
|
24
|
-
puts "OPTS:"
|
25
|
-
p opts
|
26
|
-
puts "ARGV:"
|
27
|
-
p args
|
28
|
-
|
29
|
-
|
30
|
-
### split args in datasets with leagues and seasons
|
31
|
-
datasets = []
|
32
|
-
|
33
|
-
|
34
|
-
args.each do |arg|
|
35
|
-
if arg =~ %r{^[0-9/-]+$} ## season
|
36
|
-
if datasets.empty?
|
37
|
-
puts "!! ERROR - league required before season arg; sorry"
|
38
|
-
exit 1
|
39
|
-
end
|
40
|
-
|
41
|
-
season = Season.parse( arg ) ## check season
|
42
|
-
datasets[-1][1] << season
|
43
|
-
else ## assume league key
|
44
|
-
key = arg.downcase
|
45
|
-
league_info = Writer::LEAGUES[ key ]
|
46
|
-
|
47
|
-
if league_info.nil?
|
48
|
-
puts "!! ERROR - no league found for >#{key}<; sorry"
|
49
|
-
exit 1
|
50
|
-
end
|
51
|
-
|
52
|
-
datasets << [key, []]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
pp datasets
|
57
|
-
|
58
|
-
|
59
|
-
datasets.each do |league_key, seasons|
|
60
|
-
seasons = [ Season('2024/25') ] if seasons.empty?
|
61
|
-
|
62
|
-
puts "==> gen #{league_key} - #{seasons.size} seasons(s)..."
|
63
|
-
|
64
|
-
league_info = Writer::LEAGUES[ league_key ]
|
65
|
-
pp league_info
|
66
|
-
|
67
|
-
seasons.each do |season|
|
68
|
-
### get matches
|
69
|
-
src_dir = "/sports/cache.wfb"
|
70
|
-
path = "#{src_dir}/#{season.to_path}/#{league_key}.csv"
|
71
|
-
puts " ---> reading matches in #{path} ..."
|
72
|
-
matches = SportDb::CsvMatchParser.read( path )
|
73
|
-
puts " #{matches.size} matches"
|
74
|
-
|
75
|
-
## build
|
76
|
-
txt = SportDb::TxtMatchWriter.build( matches )
|
77
|
-
puts txt
|
78
|
-
|
79
|
-
league_name = league_info[ :name ] # e.g. Brasileiro Série A
|
80
|
-
basename = league_info[ :basename] #.e.g 1-seriea
|
81
|
-
|
82
|
-
league_name = league_name.call( season ) if league_name.is_a?( Proc ) ## is proc/func - name depends on season
|
83
|
-
basename = basename.call( season ) if basename.is_a?( Proc ) ## is proc/func - name depends on season
|
84
|
-
|
85
|
-
buf = String.new
|
86
|
-
buf << "= #{league_name} #{season}\n\n"
|
87
|
-
buf << txt
|
88
|
-
|
89
|
-
## note - repo_path moved!!!
|
90
|
-
## repo_path = league_info[ :path ] # e.g. brazil or world/europe/portugal etc.
|
91
|
-
repo_path = SportDb::GitHubSync::REPOS[ league_key ]
|
92
|
-
|
93
|
-
outpath = "./o/#{repo_path}/#{season.to_path}/#{basename}.txt"
|
94
|
-
write_text( outpath, buf )
|
95
|
-
end
|
96
|
-
end
|
10
|
+
Fbgen.main( ARGV )
|
97
11
|
|
98
12
|
|
99
13
|
puts "bye"
|
data/bin/fbtxt
CHANGED
@@ -9,44 +9,9 @@
|
|
9
9
|
|
10
10
|
require 'sportdb/writers'
|
11
11
|
|
12
|
-
require 'optparse'
|
13
12
|
|
13
|
+
Fbtxt.main( ARGV )
|
14
14
|
|
15
15
|
|
16
|
-
args=ARGV
|
17
|
-
|
18
|
-
|
19
|
-
opts = {
|
20
|
-
}
|
21
|
-
|
22
|
-
parser = OptionParser.new do |parser|
|
23
|
-
parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
|
24
|
-
end
|
25
|
-
parser.parse!( args )
|
26
|
-
|
27
|
-
puts "OPTS:"
|
28
|
-
p opts
|
29
|
-
puts "ARGV:"
|
30
|
-
p args
|
31
|
-
|
32
|
-
|
33
|
-
matches = []
|
34
|
-
|
35
|
-
## step 1 - get all matches via csv
|
36
|
-
args.each do |arg|
|
37
|
-
path = arg
|
38
|
-
puts "==> reading matches in #{path} ..."
|
39
|
-
more_matches = SportDb::CsvMatchParser.read( path )
|
40
|
-
matches += more_matches
|
41
|
-
end
|
42
|
-
|
43
|
-
puts "#{matches.size} matches"
|
44
|
-
puts
|
45
|
-
|
46
|
-
|
47
|
-
txt = SportDb::TxtMatchWriter.build( matches )
|
48
|
-
puts txt
|
49
|
-
puts
|
50
|
-
|
51
16
|
puts "bye"
|
52
17
|
|
@@ -0,0 +1,94 @@
|
|
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.cup, ÖFB Cup, cup,,,
|
8
|
+
|
9
|
+
|
10
|
+
de.1, Deutsche Bundesliga, 1-bundesliga,,,
|
11
|
+
de.2, Deutsche 2. Bundesliga, 2-bundesliga2,,,
|
12
|
+
de.3, Deutsche 3. Liga, 3-liga3,,,
|
13
|
+
de.4.bayern, Deutsche Regionalliga Bayern, 4-regionalliga-bayern,,,
|
14
|
+
de.4.n, Deutsche Regionalliga Nord, 4-regionalliga-nord,,,
|
15
|
+
de.4.no, Deutsche Regionalliga Nordost, 4-regionalliga-nordost,,,
|
16
|
+
de.4.w, Deutsche Regionalliga West, 4-regionalliga-west,,,
|
17
|
+
de.4.sw, Deutsche Regionalliga Südwest, 4-regionalliga-suedwest,,,
|
18
|
+
de.cup, DFB Pokal, cup,,,
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
it.1, Italian Serie A, 1-seriea,,,
|
23
|
+
it.2, Italian Serie B, 2-serieb,,,
|
24
|
+
|
25
|
+
es.1, Primera División de España, 1-liga,,,
|
26
|
+
es.2, Segunda División de España, 2-liga2,,,
|
27
|
+
|
28
|
+
fr.1, French Ligue 1, 1-ligue1,,,
|
29
|
+
fr.2, French Ligue 2, 2-ligue2,,,
|
30
|
+
|
31
|
+
|
32
|
+
eng.1, English Premier League, 1-premierleague, 1992/93,,
|
33
|
+
eng.1, English Division One, 1-division1, 1892/93, 1991/92, ## start of division 1 & 2
|
34
|
+
eng.1, English Football League, 1-footballleague, 1888/89, 1891/92, ## single league (no divisions)
|
35
|
+
|
36
|
+
eng.2, English Championship, 2-championship, 2004/05,, ## rebranding divsion 1 => championship
|
37
|
+
eng.2, English Division One, 2-division1, 1992/93, 2003/04, ## start of premier league
|
38
|
+
eng.2, English Division Two, 2-division2, 1892/93, 1991/92, ## or use English Football League Second Division ???
|
39
|
+
|
40
|
+
eng.3, English League One, 3-league1,,,
|
41
|
+
eng.4, English League Two, 4-league2,,,
|
42
|
+
eng.5, English National League, 5-nationalleague,,,
|
43
|
+
eng.cup, English FA Cup, facup,,,
|
44
|
+
|
45
|
+
|
46
|
+
hu.1, Hungarian NB I, 1-nbi,,,
|
47
|
+
|
48
|
+
gr.1, Super League Greece, 1-superleague,,,
|
49
|
+
|
50
|
+
pt.1, Portuguese Primeira Liga, 1-primeiraliga,,,
|
51
|
+
pt.2, Portuguese Segunda Liga, 2-segundaliga,,,
|
52
|
+
|
53
|
+
ch.1, Swiss Super League, 1-superleague,,,
|
54
|
+
ch.2, Swiss Challenge League, 2-challengeleague,,,
|
55
|
+
ch.cup, Swiss Cup, cup,,,
|
56
|
+
|
57
|
+
|
58
|
+
tr.1, Turkish Süper Lig, 1-superlig,,,
|
59
|
+
tr.2, Turkish 1. Lig, 2-lig1,,,
|
60
|
+
|
61
|
+
is.1, Iceland Urvalsdeild, 1-urvalsdeild,,,
|
62
|
+
|
63
|
+
sco.1, Scottish Premiership, 1-premiership,,,
|
64
|
+
|
65
|
+
ie.1, Irish Premier Division, 1-premierdivision,,,
|
66
|
+
|
67
|
+
fi.1, Finland Veikkausliiga, 1-veikkausliiga,,,
|
68
|
+
|
69
|
+
se.1, Sweden Allsvenskan, 1-allsvenskan,,,
|
70
|
+
se.2, Sweden Superettan, 2-superettan,,,
|
71
|
+
|
72
|
+
no.1, Norwegian Eliteserien, 1-eliteserien,,,
|
73
|
+
dk.1, Denmark Superligaen, 1-superligaen,,,
|
74
|
+
|
75
|
+
lu.1, Luxembourger First Division, 1-nationaldivision,,,
|
76
|
+
|
77
|
+
be.1, Belgian First Division A, 1-firstdivisiona,,,
|
78
|
+
|
79
|
+
nl.1, Dutch Eredivisie, 1-eredivisie,,,
|
80
|
+
|
81
|
+
cz.1, Czech First League, 1-firstleague,,,
|
82
|
+
sk.1, Slovakia First League, 1-superliga,,,
|
83
|
+
hr.1, Croatia 1. HNL, 1-hnl,,,
|
84
|
+
|
85
|
+
pl.1, Poland Ekstraklasa, 1-ekstraklasa,,,
|
86
|
+
|
87
|
+
ro.1, Romanian Liga 1, 1-liga1,,,
|
88
|
+
|
89
|
+
ua.1, Ukraine Premier League, 1-premierleague,,,
|
90
|
+
|
91
|
+
ru.1, Russian Premier League, 1-premierliga,,,
|
92
|
+
ru.2, Russian 1. Division, 2-division1,,,
|
93
|
+
|
94
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
key, path
|
2
|
+
|
3
|
+
at, austria
|
4
|
+
|
5
|
+
de, deutschland
|
6
|
+
eng, england
|
7
|
+
es, espana
|
8
|
+
it, italy
|
9
|
+
|
10
|
+
fr, europe/france
|
11
|
+
|
12
|
+
hu, europe/hungary
|
13
|
+
gr, europe/greece
|
14
|
+
pt, europe/portugal
|
15
|
+
|
16
|
+
ch, europe/switzerland
|
17
|
+
|
18
|
+
tr, europe/turkey
|
19
|
+
|
20
|
+
is, europe/iceland
|
21
|
+
sco, europe/scotland
|
22
|
+
ie, europe/ireland
|
23
|
+
|
24
|
+
fi, europe/finland
|
25
|
+
se, europe/sweden
|
26
|
+
no, europe/norway
|
27
|
+
dk, europe/denmark
|
28
|
+
|
29
|
+
lu, europe/luxembourg
|
30
|
+
be, europe/belgium
|
31
|
+
nl, europe/netherlands
|
32
|
+
cz, europe/czech-republic
|
33
|
+
|
34
|
+
sk, europe/slovakia
|
35
|
+
hr, europe/croatia
|
36
|
+
pl, europe/poland
|
37
|
+
|
38
|
+
ro, europe/romania
|
39
|
+
|
40
|
+
ua, europe/ukraine
|
41
|
+
|
42
|
+
ru, europe/russia
|
43
|
+
|
44
|
+
|
45
|
+
mx, mexico
|
46
|
+
|
47
|
+
ar, south-america/argentina
|
48
|
+
br, south-america/brazil
|
49
|
+
|
50
|
+
cn, world/asia/china
|
51
|
+
jp, world/asia/japan
|
52
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
|
2
|
+
module Fbgen
|
3
|
+
|
4
|
+
###
|
5
|
+
## todo/fix:
|
6
|
+
## add -i/--interactive flag
|
7
|
+
## will prompt yes/no before git operations (with consequences)!!!
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
class GitHubSync
|
12
|
+
|
13
|
+
########
|
14
|
+
## (auto)default to Writer.config.out_dir - why? why not?
|
15
|
+
##
|
16
|
+
## note - is monotree (that is, requires openfootball/england etc.
|
17
|
+
## for repo pathspecs)
|
18
|
+
def self.root() @root || "/sports"; end
|
19
|
+
def self.root=( dir ) @root = dir; end
|
20
|
+
## use root_dir (alias) - why? why not?
|
21
|
+
|
22
|
+
|
23
|
+
def initialize( repos )
|
24
|
+
@repos = repos
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def git_push_if_changes
|
29
|
+
message = "auto-update week #{Date.today.cweek}" ## add /#{Date.today.cday - why? why not?
|
30
|
+
puts message
|
31
|
+
|
32
|
+
@repos.each do |pathspec|
|
33
|
+
_git_push_if_changes( pathspec, message: message )
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def git_fast_forward_if_clean
|
38
|
+
@repos.each do |pathspec|
|
39
|
+
_git_fast_forward_if_clean( pathspec )
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
## todo/fix: rename to something like
|
46
|
+
## git_(auto_)commit_and_push_if_changes/if_dirty()
|
47
|
+
|
48
|
+
def _git_push_if_changes( pathspec, message: )
|
49
|
+
path = "#{self.class.root}/#{pathspec}"
|
50
|
+
|
51
|
+
Gitti::GitProject.open( path ) do |proj|
|
52
|
+
puts ''
|
53
|
+
puts "###########################################"
|
54
|
+
puts "## trying to commit & push repo in path >#{path}<"
|
55
|
+
puts "Dir.getwd: #{Dir.getwd}"
|
56
|
+
output = proj.changes
|
57
|
+
if output.empty?
|
58
|
+
puts "no changes found; skipping commit & push"
|
59
|
+
else
|
60
|
+
proj.add( '.' )
|
61
|
+
proj.commit( message )
|
62
|
+
proj.push
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def _git_fast_forward_if_clean( pathspec )
|
69
|
+
path = "#{self.class.root}/#{pathspec}"
|
70
|
+
|
71
|
+
Gitti::GitProject.open( path ) do |proj|
|
72
|
+
output = proj.changes
|
73
|
+
unless output.empty?
|
74
|
+
puts "FAIL - cannot git pull (fast-forward) - working tree has changes:"
|
75
|
+
puts output
|
76
|
+
exit 1
|
77
|
+
end
|
78
|
+
|
79
|
+
proj.fast_forward
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end # class GitHub
|
83
|
+
end # module Fbgen
|
@@ -0,0 +1,97 @@
|
|
1
|
+
|
2
|
+
module Fbgen
|
3
|
+
class GitHubConfig
|
4
|
+
|
5
|
+
## map leagues to repo+path
|
6
|
+
## e.g. fr.1 => europe/france
|
7
|
+
## eng..1 => england
|
8
|
+
##
|
9
|
+
## for other than openfootball (default)
|
10
|
+
## use @
|
11
|
+
## e.g. myorg@austria
|
12
|
+
## austria@myorg ??
|
13
|
+
##
|
14
|
+
## myorg@europe/france
|
15
|
+
## europe/france@myorg
|
16
|
+
|
17
|
+
|
18
|
+
def self.read( path )
|
19
|
+
recs = read_csv( path )
|
20
|
+
new( recs )
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize( recs=nil )
|
24
|
+
@table = {}
|
25
|
+
add( recs ) if recs
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def add( recs )
|
30
|
+
recs.each do |rec|
|
31
|
+
path = rec['path'] ## use pathspec - why? why not?
|
32
|
+
## or repospec or such
|
33
|
+
|
34
|
+
## auto-expand to openfootball as default org if no @ specified
|
35
|
+
owner, path = if path.index( '@')
|
36
|
+
path.split( '@', 2 )
|
37
|
+
else
|
38
|
+
['openfootball', path ]
|
39
|
+
end
|
40
|
+
name, path = path.split( '/', 2 )
|
41
|
+
|
42
|
+
|
43
|
+
## openfootball@europe/france
|
44
|
+
## =>
|
45
|
+
## owner: openfootball
|
46
|
+
## name: europe
|
47
|
+
## path: france
|
48
|
+
##
|
49
|
+
## openfootball@austria
|
50
|
+
## =>
|
51
|
+
## owner: openfootball
|
52
|
+
## name: austria
|
53
|
+
## path: nil
|
54
|
+
@table[ rec['key'] ] = { 'owner' => owner, ## (required)
|
55
|
+
'name' => name, ## (required)
|
56
|
+
'path' => path ## extra/inner/inside/local path (optional)
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
##
|
63
|
+
## todo/fix:
|
64
|
+
## make key lookup more flexible
|
65
|
+
## auto-add more variants!!!
|
66
|
+
## e.g. at.1 AT1, AT or such
|
67
|
+
##
|
68
|
+
|
69
|
+
## find (full) record by key
|
70
|
+
def find( key )
|
71
|
+
key = key.to_s.downcase
|
72
|
+
|
73
|
+
## first check for 1:1 match
|
74
|
+
rec = @table[key]
|
75
|
+
if rec.nil?
|
76
|
+
## try match by (country / first) code
|
77
|
+
## split by .
|
78
|
+
key, _ = key.split( '.' )
|
79
|
+
rec = @table[key]
|
80
|
+
end
|
81
|
+
|
82
|
+
rec
|
83
|
+
end
|
84
|
+
alias_method :[], :find ## keep alias - why? why not?
|
85
|
+
|
86
|
+
|
87
|
+
def find_repo( key )
|
88
|
+
rec = _find( key )
|
89
|
+
|
90
|
+
rec ? "#{rec['owner']}/#{rec['name']}" : nil
|
91
|
+
end
|
92
|
+
|
93
|
+
end # class GitHubConfig
|
94
|
+
end # module Fbgen
|
95
|
+
|
96
|
+
|
97
|
+
|