"""
import os
+import sys
from datetime import datetime
from cStringIO import StringIO
sensible defaults.
'''
def __init__(self, args):
- self.data_location = args.output
+ self.yaml_location = args.yaml
+ self.csv_location = args.csv
self.host = 'gerrit.wikimedia.org'
self.port = 29418
self.format = 'JSON'
+ self.is_valid_path()
def __str__(self):
return 'Codereview settings object.'
-
+
+ def is_valid_path(self):
+ if os.path.isabs(self.csv_location) == False:
+ raise Exception("Please specify an absolute path.")
+ sys.exit(-1)
+ if os.path.isabs(self.yaml_location) == False:
+ raise Exception("Please specify an absolute path.")
+ sys.exit(-1)
class Repo(object):
self.name = name
self.dataset = {}
self.filename = ('%s.csv' % (self.determine_filename()))
- self.directory = self.determine_directory()
- self.full_path = os.path.join(self.directory, self.filename)
+ self.csv_directory = self.determine_directory(gerrit.csv_location)
+ self.yaml_directory = self.determine_directory(gerrit.yaml_location)
+ self.full_csv_path = os.path.join(self.csv_directory, self.filename)
+ self.full_yaml_path = os.path.join(self.yaml_directory, self.filename)
self.filemode = self.determine_filemode()
self.create_path()
return labels
- def determine_directory(self):
- return os.path.join(self.gerrit.data_location, self.name)
+ def determine_directory(self, location):
+ return os.path.join(location, self.name)
def create_path(self):
- if self.directory != '':
- try:
- os.makedirs(self.directory)
- print 'Creating %s...' % self.directory
- except OSError:
- pass
+ folders = [self.yaml_directory,self.csv_directory]
+ for folder in folders:
+ if folder != '':
+ try:
+ os.makedirs(folder)
+ print 'Creating %s...' % folder
+ except OSError:
+ pass
def determine_filename(self):
return os.path.basename(self.name)
def determine_filemode(self):
- if os.path.isfile(self.full_path) == False:
+ if os.path.isfile(self.full_csv_path) == False:
return 'w'
else:
return 'a'
self.set_charttype()
filename = '%s.yaml' % (self.repo.determine_filename())
- full_path = os.path.join(self.repo.directory, filename)
+ full_path = os.path.join(self.repo.yaml_directory, filename)
fh = open(full_path, 'w')
fh.write(self.buffer.getvalue())
fh.close()
\ No newline at end of file
for key, repo in repos.iteritems():
yaml = YamlConfig(settings, repo)
yaml.write_file()
- fh = open(repo.full_path, repo.filemode)
+ fh = open(repo.full_csv_path, repo.filemode)
if repo.filemode == 'w':
write_heading(fh, repo)
output_results(fh, repo.today.month,'-',repo.today.day,'-',repo.today.year,',',repo.name,',')
def parse_commandline():
parser = argparse.ArgumentParser(description='Process some integers.')
- parser.add_argument('--output', help='Specify the absolute path to store the gerrit-stats datasets.')
+ parser.add_argument('--yaml', help='Specify the absolute path to store the gerrit-stats yaml configuration files.', required=True)
+ parser.add_argument('--csv', help='Specify the absolute path to store the gerrit-stats csv datasets.', required=True)
return parser.parse_args()