Skip to content

Commit

Permalink
Merge pull request #24 from claromes/file_name
Browse files Browse the repository at this point in the history
Update team name return and file name
  • Loading branch information
claromes authored Jan 27, 2024
2 parents b4ec251 + ebe449b commit 9978b00
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ pip install volleystats
- Home Points
- Guest Points
- Date
- Location
- Stadium

- Match
- Match ID
- Match date
- Home Team
- Guest Team
- Coach
- Location
- Stadium
- Total Points
- Break Points
- Win-Lost
Expand Down Expand Up @@ -104,7 +104,7 @@ volleystats --fed FED --match MATCH
- Command: $ `volleystats --fed cbv --match 1623`
- Output files:
```
data/cbv-1623-22-10-28-guest-barueri-volleyball-club.csv
data/cbv-1623-22-10-28-guest-baruerivolleyballclub.csv
data/cbv-1623-22-10-28-home-fluminense.csv
```

Expand All @@ -115,7 +115,7 @@ volleystats --fed FED --match MATCH
- Command: $ `volleystats --fed lvf --match 2093`
- Output files:
```
data/lvf-2093-2022-11-23-guest-jonavos-sc.csv
data/lvf-2093-2022-11-23-guest-jonavossc.csv
data/lvf-2093-2022-11-23-home-svaja-viktorija-lsu.csv
```

Expand Down Expand Up @@ -185,12 +185,12 @@ volleystats --fed FED --batch CSV_FILE_PATH
- Command: $ `volleystats --fed cbv --batch data/cbv-18-2022-2023-competition-matches.csv`
- Output files:
```
data/cbv-1623-22-10-28-guest-barueri-volleyball-club.csv
data/cbv-1623-22-10-28-guest-baruerivolleyballclub.csv
data/cbv-1623-22-10-28-home-fluminense.csv
data/cbv-1618-2022-11-01-guest-energis-8-s-o-caetano.csv
data/cbv-1618-2022-11-01-home-esporte-clube-pinheiros.csv
data/cbv-1619-2022-11-01-guest-abel-moda-volei.csv
data/cbv-1619-2022-11-01-home-gerdau-minas.csv
data/cbv-1618-2022-11-01-guest-energis8sãocaetano.csv
data/cbv-1618-2022-11-01-home-esporteclubepinheiros.csv
data/cbv-1619-2022-11-01-guest-abelmodavolei.csv
data/cbv-1619-2022-11-01-home-gerdauminas.csv
...
```

Expand Down Expand Up @@ -221,7 +221,7 @@ ____________________|____-_ _|_______________,
volleystats: started
volleystats: data/cbv-1623-22-10-28-home-fluminense.csv file was created
volleystats: data/cbv-1623-22-10-28-guest-barueri-volleyball-club.csv file was created
volleystats: data/cbv-1623-22-10-28-guest-baruerivolleyballclub.csv file was created
volleystats: finished
```

Expand Down
2 changes: 1 addition & 1 deletion volleystats/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#COOKIES_ENABLED = False

# Disable Telnet Console (enabled by default)
#TELNETCONSOLE_ENABLED = False
TELNETCONSOLE_ENABLED = False

# Override the default request headers:
#DEFAULT_REQUEST_HEADERS = {
Expand Down
2 changes: 1 addition & 1 deletion volleystats/spiders/competition.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def parse(self, response):
competition = {
'Match ID': match_id,
'Match Date': match_date,
'Location': match_location,
'Stadium': match_location,
'Home Team': home_team,
'Home Points': home_points,
'Guest Team': guest_team,
Expand Down
24 changes: 14 additions & 10 deletions volleystats/spiders/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self, fed_acronym='', match_id='', **kwargs):
self.match_id = match_id
match_date = ''
home_team = ''
home_team_file = ''

super().__init__(**kwargs)

Expand All @@ -27,10 +28,10 @@ def parse(self, response):
if enGB == 'EN':
match_date = parse_engb_date(match_date_text)

home_team_string = response.xpath("normalize-space(//span[@id='Content_Main_LBL_HomeTeam']/text())").get().replace(' ', '-')
home_team = re.sub('[^A-Za-z0-9]+', '-', home_team_string)
if home_team:
home_team = home_team.lower()
home_team_string = response.xpath("normalize-space(//span[@id='Content_Main_LBL_HomeTeam']/text())").get()
if home_team_string:
home_team = home_team_string.lower()
home_team_file = re.sub(' ', '', home_team)

coach = response.xpath("//span[@id='Content_Main_ctl17_RP_MatchStats_Coach_Home_0']/text()").get()
if coach:
Expand Down Expand Up @@ -98,10 +99,11 @@ def parse(self, response):

self.match_date = match_date
self.home_team = home_team
self.home_team_file = home_team_file

def closed(spider, reason):
src = f'data/{spider.fed_acronym}-{spider.match_id}-home_stats.csv'
dst = f'data/{spider.fed_acronym}-{spider.match_id}-{spider.match_date}-home-{spider.home_team}.csv'
dst = f'data/{spider.fed_acronym}-{spider.match_id}-{spider.match_date}-home-{spider.home_team_file}.csv'

try:
os.rename(src, dst)
Expand All @@ -119,6 +121,7 @@ def __init__(self, fed_acronym='', match_id='', **kwargs):
self.match_id = match_id
match_date = ''
guest_team = ''
guest_team_file = ''

super().__init__(**kwargs)

Expand All @@ -133,10 +136,10 @@ def parse(self, response):
if enGB == 'EN':
match_date = parse_engb_date(match_date_text)

guest_team_string = response.xpath("normalize-space(//span[@id='Content_Main_LBL_GuestTeam']/text())").get().replace(' ', '-')
guest_team = re.sub('[^A-Za-z0-9]+', '-', guest_team_string)
if guest_team:
guest_team = guest_team.lower()
guest_team_string = response.xpath("normalize-space(//span[@id='Content_Main_LBL_GuestTeam']/text())").get()
if guest_team_string:
guest_team = guest_team_string.lower()
guest_team_file = re.sub(' ', '', guest_team)

coach = response.xpath("//span[@id='Content_Main_ctl17_RP_MatchStats_Coach_Guest_0']/text()").get()
if coach:
Expand Down Expand Up @@ -204,10 +207,11 @@ def parse(self, response):

self.match_date = match_date
self.guest_team = guest_team
self.guest_team_file = guest_team_file

def closed(spider, reason):
src = f'data/{spider.fed_acronym}-{spider.match_id}-guest_stats.csv'
dst = f'data/{spider.fed_acronym}-{spider.match_id}-{spider.match_date}-guest-{spider.guest_team}.csv'
dst = f'data/{spider.fed_acronym}-{spider.match_id}-{spider.match_date}-guest-{spider.guest_team_file}.csv'

try:
os.rename(src, dst)
Expand Down
2 changes: 1 addition & 1 deletion volleystats/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.8'
__version__ = '0.8.1'

0 comments on commit 9978b00

Please sign in to comment.