fbtxt-pp 0.0.2 → 0.1.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/bin/fbhub +2 -2
- data/lib/fbtxt-pp/config.rb +1 -1
- data/lib/fbtxt-pp/config_clubs.csv +25 -10
- data/lib/fbtxt-pp/models/document.rb +1 -3
- data/lib/fbtxt-pp/models/match.rb +27 -13
- data/lib/fbtxt-pp/models/score.rb +1 -1
- data/lib/fbtxt-pp/pp/ppmatch.rb +26 -13
- data/lib/fbtxt-pp/tool-fbhub.rb +23 -48
- data/lib/fbtxt-pp/tool-fbpp.rb +1 -0
- data/lib/fbtxt-pp/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db5f011b7eb6f90695401a5de2672d1f210684df87033b2592831692f17fe92a
|
|
4
|
+
data.tar.gz: 04c710000abbf7f491bed97d92f86b06288902058a234a048fb4927c631c7625
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3f194fdcf1896b83ed82d4fe6546e3918839bf0e65b0ebf69fe8ca0a63ad20219ca5183f5808b74333cf234c4961b747d2d937239086c54e2b7c24f3ca174e0e
|
|
7
|
+
data.tar.gz: 7b2f42b11e823c4f2668a8d7802c97c0b69754ea502e2985e1b15c1a2c0a016be18b70032917de1c95465e1af5adfcc31edba4a648e1f1cae94b72ff30e2d51c
|
data/CHANGELOG.md
CHANGED
data/bin/fbhub
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
##
|
|
8
8
|
## note - always use latest (local) if present
|
|
9
|
-
$LOAD_PATH.unshift( '/sports/yorobot/fbup/
|
|
10
|
-
require '
|
|
9
|
+
$LOAD_PATH.unshift( '/sports/yorobot/fbup/openfootball/lib' )
|
|
10
|
+
require 'openfootball'
|
|
11
11
|
|
|
12
12
|
##
|
|
13
13
|
## note - always use latest (local) if present
|
data/lib/fbtxt-pp/config.rb
CHANGED
|
@@ -4,20 +4,35 @@ code, name, seasons, opts, opts_full
|
|
|
4
4
|
##
|
|
5
5
|
## remove seasons - why? why not?
|
|
6
6
|
|
|
7
|
-
at, Austria | Bundesliga, 2025/26,,
|
|
8
|
-
|
|
9
|
-
eng, England | Premier League, 2025/26,,
|
|
7
|
+
at, Austria | Bundesliga, 2026/27 2025/26,,
|
|
8
|
+
at.cup, Austria | Cup, 2026/27 2025/26,,
|
|
10
9
|
|
|
10
|
+
de, Germany | Bundesliga, 2026/27 2025/26,,
|
|
11
|
+
eng, England | Premier League, 2026/27 2025/26,,
|
|
11
12
|
|
|
12
|
-
fr, France | Ligue 1, 2025/26,,
|
|
13
|
-
it, Italy | Serie A, 2025/26,,
|
|
14
|
-
es, Spain | Primera División, 2025/26,,
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
fr, France | Ligue 1, 2026/27 2025/26,,
|
|
15
|
+
it, Italy | Serie A, 2026/27 2025/26,,
|
|
16
|
+
es, Spain | Primera División, 2026/27 2025/26,,
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
|
|
19
|
+
be, Belgium | First Division A, 2026/27,,
|
|
20
|
+
ch, Switzerland | Super League, 2026/27,,
|
|
21
|
+
cz, Czech Republic | First League, 2026/27,,
|
|
22
|
+
|
|
23
|
+
gr, Greece | Super League, 2026/27,,
|
|
24
|
+
tr, Turkey | Süper Lig, 2026/27,,
|
|
25
|
+
|
|
26
|
+
sco, Scotland | Premiership, 2026/27,,
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
uefa.cl, UEFA | Champions League, 2026/27 2025/26, country|city, country
|
|
30
|
+
uefa.europa, UEFA | Europa League, 2026/27 2025/26, country|city, country
|
|
31
|
+
uefa.con, UEFA | Conference League, 2026/27 2025/26, country|city, country
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
mx, Mexico | Liga MX, 2026/27 2025/26,,
|
|
21
36
|
|
|
22
37
|
###
|
|
23
38
|
# opts
|
|
@@ -62,10 +62,8 @@ def calc_start_end_dates
|
|
|
62
62
|
|
|
63
63
|
@data['matches'].each do |_m|
|
|
64
64
|
|
|
65
|
-
## date_utc = parse_date_utc( _m['datetime_utc'] )
|
|
66
|
-
date_local = parse_date_local( _m['datetime_local'] )
|
|
67
|
-
|
|
68
65
|
## note - alway use local datetime for now
|
|
66
|
+
date_local = Date.strptime( _m['date_local'], '%Y-%m-%d' )
|
|
69
67
|
|
|
70
68
|
if start_date.nil? || date_local < start_date
|
|
71
69
|
start_date = date_local
|
|
@@ -8,7 +8,9 @@ class Match
|
|
|
8
8
|
|
|
9
9
|
attr_reader :team1, :team2,
|
|
10
10
|
:score,
|
|
11
|
-
:
|
|
11
|
+
:datetime_utc,
|
|
12
|
+
:date_local,
|
|
13
|
+
:time_local, :utc_offset,
|
|
12
14
|
:stadium,
|
|
13
15
|
:goals1, :goals2
|
|
14
16
|
|
|
@@ -25,21 +27,33 @@ def initialize( doc, data )
|
|
|
25
27
|
@team2 = @doc.find_team!( @h['team2'] )
|
|
26
28
|
|
|
27
29
|
|
|
28
|
-
@date_utc = parse_date_utc( @h['datetime_utc'] )
|
|
29
|
-
@date_local = parse_date_local( @h['datetime_local'] )
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
####
|
|
32
|
+
# note - match might NOT be timed only scheduled (e.g. only date no time)
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
##
|
|
35
|
+
## todo/fix
|
|
36
|
+
## support different date style formats - why? why not?
|
|
37
|
+
## for now use/prefer:
|
|
38
|
+
## "datetime_utc": "2026-08-08T16:15Z",
|
|
39
|
+
## "date_local": "2026-08-08",
|
|
40
|
+
## "time_local": "18:15 UTC+2",
|
|
37
41
|
|
|
38
|
-
# note - offset is in rational fraction of a day (e.g. 1/12 for 2hours)
|
|
39
|
-
## was diff_in_hours
|
|
40
|
-
@utc_offset = (@date_local.offset * 24).to_i
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
if @h['date_local'] && @h['time_local'].nil?
|
|
44
|
+
@date_local = Date.strptime( @h['date_local'], '%Y-%m-%d' )
|
|
45
|
+
else
|
|
46
|
+
@datetime_utc = parse_date_utc( @h['datetime_utc'] )
|
|
47
|
+
assert( @datetime_utc.sec == 0, "sec 00 expected" )
|
|
48
|
+
|
|
49
|
+
@date_local = Date.strptime( @h['date_local'], '%Y-%m-%d' )
|
|
50
|
+
## 18:15 UTC+2
|
|
51
|
+
## split into 18:15 and UTC+2
|
|
52
|
+
@time_local, @utc_offset = @h['time_local'].split( /[ ]+/, 2)
|
|
53
|
+
|
|
54
|
+
## pp [@datetime_utc, @date_local, @time_local, @utc_offset]
|
|
55
|
+
end
|
|
56
|
+
|
|
43
57
|
|
|
44
58
|
## note - always lookup full stadium record (use match inline only as ref)
|
|
45
59
|
@stadium = @doc.find_stadium!( @h['stadium'] )
|
|
@@ -61,7 +75,7 @@ def data() @h; end
|
|
|
61
75
|
|
|
62
76
|
## todo - find a better name for timezone offset
|
|
63
77
|
## use utc_offset - why? why not?
|
|
64
|
-
alias_method :diff_in_hours, :utc_offset
|
|
78
|
+
## alias_method :diff_in_hours, :utc_offset
|
|
65
79
|
|
|
66
80
|
|
|
67
81
|
def stage() @h['stage']; end
|
|
@@ -6,7 +6,7 @@ def self.build( score )
|
|
|
6
6
|
if score.nil?
|
|
7
7
|
raise ArgumentError, "Score.build - expected Hash or Array; got nil"
|
|
8
8
|
elsif score.is_a?(Hash)
|
|
9
|
-
new( **score.transform_keys(&:to_sym) )
|
|
9
|
+
new( **score.transform_keys(&:to_sym).except( :type ) )
|
|
10
10
|
elsif score.is_a?(Array)
|
|
11
11
|
new( reported: score )
|
|
12
12
|
else
|
data/lib/fbtxt-pp/pp/ppmatch.rb
CHANGED
|
@@ -24,9 +24,11 @@ def pp_matches( season:,
|
|
|
24
24
|
buf << "\n"
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
last_round
|
|
28
|
-
last_date
|
|
29
|
-
|
|
27
|
+
last_round = nil
|
|
28
|
+
last_date = nil
|
|
29
|
+
last_time = nil
|
|
30
|
+
last_utc_offset = nil
|
|
31
|
+
last_year = nil ## track running year
|
|
30
32
|
|
|
31
33
|
|
|
32
34
|
doc.each_match do |m|
|
|
@@ -42,8 +44,8 @@ doc.each_match do |m|
|
|
|
42
44
|
## note - make round
|
|
43
45
|
## = stage + group (optional) + matchday (optional)
|
|
44
46
|
round = m.stage
|
|
45
|
-
round += ", #{m.group}" if m.group
|
|
46
47
|
round += " - #{m.matchday}" if m.matchday
|
|
48
|
+
round += ", #{m.group}" if m.group
|
|
47
49
|
|
|
48
50
|
|
|
49
51
|
|
|
@@ -54,7 +56,9 @@ doc.each_match do |m|
|
|
|
54
56
|
buf << "▪ #{round}\n"
|
|
55
57
|
|
|
56
58
|
last_round = round
|
|
57
|
-
last_date
|
|
59
|
+
last_date = nil
|
|
60
|
+
last_time = nil
|
|
61
|
+
last_utc_offsset = nil
|
|
58
62
|
end
|
|
59
63
|
|
|
60
64
|
|
|
@@ -70,15 +74,22 @@ doc.each_match do |m|
|
|
|
70
74
|
else
|
|
71
75
|
buf << "#{m.date_local.strftime('%a %b %-e')}\n"
|
|
72
76
|
end
|
|
77
|
+
last_time = nil
|
|
78
|
+
last_utc_offsset = nil
|
|
73
79
|
end
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
## note - skip printing same time again (use inheritance)
|
|
82
|
+
if m.time_local.nil? ||
|
|
83
|
+
(last_time == m.time_local &&
|
|
84
|
+
last_utc_offset == m.utc_offset)
|
|
85
|
+
buf << " "
|
|
80
86
|
else
|
|
81
|
-
|
|
87
|
+
if opts.timezone?
|
|
88
|
+
## use 20:30 UTC+1 or 20:30 UTC-3
|
|
89
|
+
buf << " #{m.time_local} #{m.utc_offset}"
|
|
90
|
+
else
|
|
91
|
+
buf << " #{m.time_local}"
|
|
92
|
+
end
|
|
82
93
|
end
|
|
83
94
|
|
|
84
95
|
|
|
@@ -111,8 +122,10 @@ doc.each_match do |m|
|
|
|
111
122
|
buf << "\n"
|
|
112
123
|
|
|
113
124
|
|
|
114
|
-
last_date
|
|
115
|
-
last_year
|
|
125
|
+
last_date = m.date_local
|
|
126
|
+
last_year = m.date_local.year
|
|
127
|
+
last_time = m.time_local
|
|
128
|
+
last_utc_offset = m.utc_offset
|
|
116
129
|
|
|
117
130
|
|
|
118
131
|
## skip adding goals if teams not yet known!!
|
data/lib/fbtxt-pp/tool-fbhub.rb
CHANGED
|
@@ -9,12 +9,19 @@ module Fbhub
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
LEAGUE_CODES = {
|
|
12
|
-
'de' => 'de.1',
|
|
13
12
|
'eng' => 'eng.1',
|
|
13
|
+
'de' => 'de.1',
|
|
14
14
|
'es' => 'es.1',
|
|
15
15
|
'it' => 'it.1',
|
|
16
16
|
'fr' => 'fr.1',
|
|
17
|
+
|
|
17
18
|
'at' => 'at.1',
|
|
19
|
+
'ch' => 'ch.1',
|
|
20
|
+
'cz' => 'cz.1',
|
|
21
|
+
'tr' => 'tr.1',
|
|
22
|
+
'gr' => 'gr.1',
|
|
23
|
+
'sco' => 'sco.1',
|
|
24
|
+
|
|
18
25
|
'mx' => 'mx.1',
|
|
19
26
|
}
|
|
20
27
|
|
|
@@ -26,7 +33,9 @@ opts = {
|
|
|
26
33
|
push: false,
|
|
27
34
|
ffwd: false,
|
|
28
35
|
|
|
29
|
-
full:
|
|
36
|
+
full: false,
|
|
37
|
+
## full: true, ## add full details page - true|false
|
|
38
|
+
|
|
30
39
|
test: true, ## true, ## sets push & ffwd to false
|
|
31
40
|
test_dir: './o',
|
|
32
41
|
convert_dir: '/sports/cache.api.fifa',
|
|
@@ -91,17 +100,17 @@ pp datasets
|
|
|
91
100
|
root_dir = if opts[:test]
|
|
92
101
|
opts[:test_dir]
|
|
93
102
|
else
|
|
94
|
-
|
|
103
|
+
Openfootball::GitHubSync.root # e.g. "/sports"
|
|
95
104
|
end
|
|
96
105
|
|
|
97
106
|
puts " (output) root_dir: >#{root_dir}<"
|
|
98
107
|
|
|
99
108
|
|
|
100
|
-
repos =
|
|
109
|
+
repos = Openfootball.find_repos( datasets )
|
|
101
110
|
puts " #{repos.size} repo(s):"
|
|
102
111
|
pp repos
|
|
103
112
|
|
|
104
|
-
sync =
|
|
113
|
+
sync = Openfootball::GitHubSync.new( repos )
|
|
105
114
|
puts " sync:"
|
|
106
115
|
pp sync
|
|
107
116
|
|
|
@@ -112,7 +121,7 @@ sync.git_fast_forward_if_clean if opts[:ffwd]
|
|
|
112
121
|
datasets.each do |slug, seasons|
|
|
113
122
|
puts "==> gen #{slug} - #{seasons.size} seasons(s)..."
|
|
114
123
|
|
|
115
|
-
config = CONFIGS[ slug ]
|
|
124
|
+
config = CONFIGS[ slug.to_sym ] ## note - use symbol for lookup!!
|
|
116
125
|
if config.nil?
|
|
117
126
|
puts "!! no pp config found for slug >#{slug}<; keys/codes include:"
|
|
118
127
|
pp CONFIGS.keys
|
|
@@ -120,54 +129,20 @@ datasets.each do |slug, seasons|
|
|
|
120
129
|
end
|
|
121
130
|
|
|
122
131
|
seasons.each do |season|
|
|
123
|
-
## get repo config for flags and more
|
|
124
|
-
repo = Fbup::GitHubSync::REPOS[ slug ]
|
|
125
|
-
flags = repo['flags'] || {}
|
|
126
|
-
classic_flag = flags['classic'] || false
|
|
127
|
-
|
|
128
|
-
pp repo
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
basename = nil
|
|
132
|
-
if classic_flag
|
|
133
|
-
league_config = Fbup::LeagueConfig.find_by( code: LEAGUE_CODES[slug]||slug,
|
|
134
|
-
season: season )
|
|
135
|
-
if league_config.nil?
|
|
136
|
-
puts "!! ERROR - basename league config required for classic format; no config found for #{league_query} #{season}; sorry"
|
|
137
|
-
exit 1
|
|
138
|
-
end
|
|
139
|
-
basename = league_config['basename']
|
|
140
|
-
else
|
|
141
|
-
## change base name to league key
|
|
142
|
-
## todo - fix - make gsub smarter
|
|
143
|
-
## change at.cup to at_cup - why? why not?
|
|
144
|
-
basename = (LEAGUE_CODES[slug]||slug).gsub( '.', '' )
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
repo_path = "#{repo['owner']}/#{repo['name']}"
|
|
149
|
-
repo_path << "/#{repo['path']}" if repo['path'] ## note: do NOT forget to add optional extra path!!!
|
|
150
132
|
|
|
133
|
+
repo_path = Openfootball.mkpath( code: LEAGUE_CODES[slug]||slug,
|
|
134
|
+
season: season )
|
|
135
|
+
repo_path_full = Openfootball.mkpath( code: LEAGUE_CODES[slug]||slug,
|
|
136
|
+
season: season,
|
|
137
|
+
suffix: 'full' )
|
|
151
138
|
|
|
152
|
-
outpath
|
|
153
|
-
|
|
154
|
-
"/#{season.to_path}/#{basename}.txt"
|
|
155
|
-
else
|
|
156
|
-
## note - add season "inline" (to basename) or use dir
|
|
157
|
-
"/#{season.to_path}_#{basename}.txt"
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
outpath_full = "#{root_dir}/#{repo_path}"
|
|
161
|
-
outpath_full += if classic_flag
|
|
162
|
-
"/#{season.to_path}/#{basename}-full.txt"
|
|
163
|
-
else
|
|
164
|
-
## note - add season "inline" (to basename) or use dir
|
|
165
|
-
"/#{season.to_path}_#{basename}-full.txt"
|
|
166
|
-
end
|
|
139
|
+
outpath = "#{root_dir}/#{repo_path}"
|
|
140
|
+
outpath_full = "#{root_dir}/#{repo_path_full}"
|
|
167
141
|
|
|
168
142
|
puts " writing to >#{outpath}<..."
|
|
169
143
|
puts " writing (full) to >#{outpath_full}<..."
|
|
170
144
|
|
|
145
|
+
|
|
171
146
|
league_name = config[:name]
|
|
172
147
|
format_opts = config[:opts]
|
|
173
148
|
format_opts_full = config[:opts_full]
|
data/lib/fbtxt-pp/tool-fbpp.rb
CHANGED
data/lib/fbtxt-pp/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fbtxt-pp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.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: 2026-
|
|
11
|
+
date: 2026-10-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cocos
|