Skip to content

Commit a7f9729

Browse files
committed
1. Created MANIFEST.in for inclusion of non-code resource files
-- build_version.json 2. Revision to setup.py
1 parent 7a049d5 commit a7f9729

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ref/build_versions.json

dasc2/bin/download_replays.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@
2929
import requests
3030
import json
3131
import argparse
32-
import urlparse
3332
import shutil
3433

34+
# support both python 2 & 3
35+
try:
36+
import urlparse as urlparser
37+
except ImportError:
38+
import urllib.parse as urlparser
39+
40+
3541
from dasc2.lib.replay_helpers import check_build_version
3642

3743
API_BASE_URL = 'https://us.api.battle.net'
@@ -57,7 +63,7 @@ def get_base_url(access_token):
5763
params = {
5864
'namespace' : API_NAMESPACE,
5965
}
60-
response = requests.get(urlparse.urljoin(API_BASE_URL, "/data/sc2/archive_url/base_url"), headers=headers,
66+
response = requests.get(urlparser.urljoin(API_BASE_URL, "/data/sc2/archive_url/base_url"), headers=headers,
6167
params=params)
6268
return json.loads(response.text)["base_url"]
6369

@@ -69,7 +75,7 @@ def search_by_client_version(access_token, client_version):
6975
'client_version' : client_version,
7076
'_pageSize' : 25
7177
}
72-
response = requests.get(urlparse.urljoin(API_BASE_URL, "/data/sc2/search/archive"), headers=headers, params=params)
78+
response = requests.get(urlparser.urljoin(API_BASE_URL, "/data/sc2/search/archive"), headers=headers, params=params)
7379
response = json.loads(response.text)
7480
meta_urls = []
7581
for result in response['results']:
@@ -111,19 +117,19 @@ def get_replay_pack(client_version, client_key, client_secret, output_dir, extra
111117
download_base_url = get_base_url(access_token)
112118

113119
# Get meta file infos for the give client version
114-
print 'Searching replay packs with client version=' + client_version
120+
print('Searching replay packs with client version=' + client_version)
115121
meta_file_urls = search_by_client_version(access_token, client_version)
116122
if len(meta_file_urls) == 0:
117-
print 'No matching replay packs found for the client version!'
123+
print('No matching replay packs found for the client version!')
118124
return
119125

120126
# For each meta file, construct full url to download replay packs
121-
print 'Building urls for downloading replay packs. num_files={0}'.format(len(meta_file_urls))
127+
print('Building urls for downloading replay packs. num_files={0}'.format(len(meta_file_urls)))
122128
download_urls=[]
123129
for meta_file_url in meta_file_urls:
124130
meta_file_info = get_meta_file_info(access_token, meta_file_url)
125131
file_path = meta_file_info['path']
126-
download_urls.append(urlparse.urljoin(download_base_url, file_path))
132+
download_urls.append(urlparser.urljoin(download_base_url, file_path))
127133

128134

129135
files = []
@@ -141,12 +147,12 @@ def get_replay_pack(client_version, client_key, client_secret, output_dir, extra
141147

142148
# Download replay packs.
143149
for archive_url in sorted_urls:
144-
print 'Downloading replay packs. url=' + archive_url
150+
print('Downloading replay packs. url=' + archive_url)
145151
files.append(download_file(archive_url, output_dir))
146152

147153
except Exception as e:
148154
import traceback
149-
print 'Failed to download replay packs. traceback={}'.format(traceback.format_exc())
155+
print('Failed to download replay packs. traceback={}'.format(traceback.format_exc()))
150156

151157

152158
def parse_args():

dasc2/bin/extract_replays.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ def __prompt_for_licensing_agreement(license_agreement):
7676
# Output the license_agreement and prompt
7777
sys.stdout.write(license_agreement + prompt)
7878
# Assign user input to choice
79-
choice = raw_input().lower()
79+
try:
80+
choice = raw_input().lower()
81+
except NameError:
82+
choice = input().lower()
8083

8184
# If user entires a valid option return it's corresponding value
8285
if choice in valid_option:

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
setup(
3434
name='daSC2',
35-
version='0.2.0-dev3',
35+
version='0.2.1-dev3',
3636
description='Data Analytics Library for StarCraft II',
3737
long_description=description,
3838
author='David Kuhta',
@@ -75,4 +75,5 @@
7575
'Programming Language :: Python :: 3.4',
7676
'Topic :: Scientific/Engineering :: Artificial Intelligence',
7777
],
78+
include_package_data = True
7879
)

0 commit comments

Comments
 (0)