Skip to content

Commit

Permalink
Updated print commands
Browse files Browse the repository at this point in the history
  • Loading branch information
MattMaginniss committed Nov 16, 2021
1 parent 8e4a9fa commit dac9a71
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions scripts/classes/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run(self):

# log
if(self.options['verbose']):
print "Fetching " + filename
print ("Fetching " + filename)

# determine the local path
f = "%s/%s" % (self.path, filename)
Expand All @@ -42,7 +42,7 @@ def run(self):

#log
if(self.options['verbose']):
print "Zip file detected. Extracting " + filename
print("Zip file detected. Extracting " + filename)

# extract the zip file
zip = zipfile.ZipFile(f, "r")
Expand Down
12 changes: 6 additions & 6 deletions scripts/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
try:
os.chdir(absolute_path)
except OSError:
print "Directory %s does not exist, creating..." % absolute_path
print ("Directory %s does not exist, creating..." % absolute_path)
os.makedirs(absolute_path)


Expand All @@ -40,7 +40,7 @@
try:
opts, args = getopt.getopt(sys.argv[1:], "y:", ["year="])
except getopt.GetoptError as e:
print 'Invalid arguments. Exiting.'
print ('Invalid arguments. Exiting.')
raise SystemExit

# set year if passed in
Expand All @@ -55,9 +55,9 @@

# log next action
if YEAR:
print "Queuing up Event Files for download (%s only)." % YEAR
print ("Queuing up Event Files for download (%s only)." % YEAR)
else:
print "Queuing up Event Files for download."
print ("Queuing up Event Files for download.")

# parse retrosheet page for files and add urls to the queue
retrosheet_url = config.get('retrosheet', 'eventfiles_url')
Expand All @@ -82,9 +82,9 @@

# log next action
if YEAR:
print "Queuing up Game Logs for download (%s only)." % YEAR
print ("Queuing up Game Logs for download (%s only)." % YEAR)
else:
print "Queuing up Game Logs for download."
print ("Queuing up Game Logs for download.")

# parse retrosheet page for files and add urls to the queue
retrosheet_url = config.get('retrosheet', 'gamelogs_url')
Expand Down
23 changes: 11 additions & 12 deletions scripts/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def connect(config):
USER = None if not config.has_option('database', 'user') else config.get('database', 'user')
SCHEMA = None if not config.has_option('database', 'schema') else config.get('database', 'schema')
PASSWORD = None if not config.has_option('database', 'password') else config.get('database', 'password')
except ConfigParser.NoOptionError:
print 'Need to define engine, user, password, host, and database parameters'
print ('Need to define engine, user, password, host, and database parameters')
raise SystemExit

if ENGINE == 'sqlite':
Expand All @@ -42,12 +41,12 @@ def connect(config):


def parse_rosters(file, conn, bound_param):
print "processing %s" % file
print ("processing %s" % file)

try:
year = re.search(r"\d{4}", os.path.basename(file)).group(0)
except:
print 'cannot get year from roster file %s' % file
print ('cannot get year from roster file %s' % file)
return None

reader = csv.reader(open(file))
Expand All @@ -68,7 +67,7 @@ def parse_rosters(file, conn, bound_param):


def parse_teams(file, conn, bound_param):
print "processing %s" % file
print ("processing %s" % file)

reader = csv.reader(open(file))
for row in reader:
Expand All @@ -86,12 +85,12 @@ def parse_teams(file, conn, bound_param):


def parse_games(file, conn, bound_param):
print "processing %s" % file
print ("processing %s" % file)

try:
year = re.search(r"\d{4}", os.path.basename(file)).group(0)
except:
print 'cannot get year from game file %s' % file
print ('cannot get year from game file %s' % file)
return None

if conn.engine.driver == 'psycopg2':
Expand All @@ -112,12 +111,12 @@ def parse_games(file, conn, bound_param):


def parse_events(file, conn, bound_param):
print "processing %s" % file
print ("processing %s" % file)

try:
year = re.search(r"\d{4}", os.path.basename(file)).group(0)
except:
print 'cannot get year from event file %s' % file
print ('cannot get year from event file %s' % file)
return None

if conn.engine.driver == 'psycopg2':
Expand Down Expand Up @@ -185,7 +184,7 @@ def main():
if not os.path.exists(chadwick) \
or not os.path.exists('%s/cwevent' % chadwick) \
or not os.path.exists('%s/cwgame' % chadwick):
print 'chadwick does not exist in %s - exiting' % chadwick
print ('chadwick does not exist in %s - exiting' % chadwick)
raise SystemExit

os.chdir(path) # Chadwick seems to need to be in the directory
Expand Down Expand Up @@ -213,13 +212,13 @@ def main():
if not os.path.isfile('%s/events-%d.csv' % (csvpath, year)):
cmd = "%s/cwevent -q -n -f 0-96 -x 0-62 -y %d %d*.EV* > %s/events-%d.csv" % (chadwick, year, year, csvpath, year)
if(verbose):
print "calling '" + cmd + "'"
print ("calling '" + cmd + "'")
subprocess.call(cmd, shell=True)

if not os.path.isfile('%s/games-%d.csv' % (csvpath, year)):
cmd = "%s/cwgame -q -n -f 0-83 -y %d %d*.EV* > %s/games-%d.csv" % (chadwick, year, year, csvpath, year)
if(verbose):
print "calling '" + cmd + "'"
print ("calling '" + cmd + "'")
subprocess.call(cmd, shell=True)

if 'teams' in modules:
Expand Down

0 comments on commit dac9a71

Please sign in to comment.