瀏覽代碼

Use lists instead of tuples for better readability.

Heikki Hokkanen 17 年之前
父節點
當前提交
be2cbda242
共有 1 個檔案被更改,包括 12 行新增14 行删除
  1. 12
    14
      gitstats

+ 12
- 14
gitstats 查看文件

@@ -109,7 +109,7 @@ class GitDataCollector(DataCollector):
109 109
 		DataCollector.collect(self, dir)
110 110
 
111 111
 		try:
112
-			self.total_authors = int(getpipeoutput(('git-log', 'git-shortlog -s', 'wc -l')))
112
+			self.total_authors = int(getpipeoutput(['git-log', 'git-shortlog -s', 'wc -l']))
113 113
 		except:
114 114
 			self.total_authors = 0
115 115
 		#self.total_lines = int(getoutput('git-ls-files -z |xargs -0 cat |wc -l'))
@@ -131,7 +131,7 @@ class GitDataCollector(DataCollector):
131 131
 
132 132
 		# tags
133 133
 		self.tags = {}
134
-		lines = getpipeoutput((('git-show-ref --tags'),)).split('\n')
134
+		lines = getpipeoutput(['git-show-ref --tags']).split('\n')
135 135
 		for line in lines:
136 136
 			if len(line) == 0:
137 137
 				continue
@@ -141,7 +141,7 @@ class GitDataCollector(DataCollector):
141 141
 			(hash, tag) = splitted_str
142 142
 
143 143
 			tag = tag.replace('refs/tags/', '')
144
-			output = getpipeoutput((('git-log "%s" --pretty=format:"%%at %%an" -n 1' % hash),))
144
+			output = getpipeoutput(['git-log "%s" --pretty=format:"%%at %%an" -n 1' % hash])
145 145
 			if len(output) > 0:
146 146
 				parts = output.split(' ')
147 147
 				stamp = 0
@@ -154,7 +154,7 @@ class GitDataCollector(DataCollector):
154 154
 
155 155
 		# Collect revision statistics
156 156
 		# Outputs "<stamp> <author>"
157
-		lines = getpipeoutput(('git-rev-list --pretty=format:"%at %an" HEAD', 'grep -v ^commit')).split('\n')
157
+		lines = getpipeoutput(['git-rev-list --pretty=format:"%at %an" HEAD', 'grep -v ^commit']).split('\n')
158 158
 		for line in lines:
159 159
 			# linux-2.6 says "<unknown>" for one line O_o
160 160
 			parts = line.split(' ')
@@ -249,13 +249,12 @@ class GitDataCollector(DataCollector):
249 249
 		# TODO Optimize this, it's the worst bottleneck
250 250
 		# outputs "<stamp> <files>" for each revision
251 251
 		self.files_by_stamp = {} # stamp -> files
252
-		lines = getpipeoutput(('git-rev-list --pretty=format:"%at %H" HEAD',
253
-				       'grep -v ^commit')).strip().split('\n')
252
+		lines = getpipeoutput(['git-rev-list --pretty=format:"%at %H" HEAD', 'grep -v ^commit']).strip().split('\n')
254 253
 		#'sh while read line; do set $line; echo "$1 $(git-ls-tree -r "$2" |wc -l)"; done')).split('\n')
255 254
 		tmp = [None] * len(lines)
256 255
 		for idx in xrange(len(lines)):
257 256
 			(a, b) = lines[idx].split(" ")
258
-			tmp[idx] = a + getpipeoutput(('git-ls-tree -r ' + b, 'wc -l')).strip('\n')
257
+			tmp[idx] = a + getpipeoutput(['git-ls-tree -r ' + b, 'wc -l']).strip('\n')
259 258
 		lines = tmp
260 259
 
261 260
 		self.total_commits = len(lines)
@@ -271,7 +270,7 @@ class GitDataCollector(DataCollector):
271 270
 
272 271
 		# extensions
273 272
 		self.extensions = {} # extension -> files, lines
274
-		lines = getpipeoutput(('git-ls-files',)).split('\n')
273
+		lines = getpipeoutput(['git-ls-files']).split('\n')
275 274
 		self.total_files = len(lines)
276 275
 		for line in lines:
277 276
 			base = os.path.basename(line)
@@ -286,7 +285,7 @@ class GitDataCollector(DataCollector):
286 285
 			self.extensions[ext]['files'] += 1
287 286
 			try:
288 287
 				# Escaping could probably be improved here
289
-				self.extensions[ext]['lines'] += int(getpipeoutput(('wc -l "%s"' % line,)).split()[0])
288
+				self.extensions[ext]['lines'] += int(getpipeoutput(['wc -l "%s"' % line]).split()[0])
290 289
 			except:
291 290
 				print 'Warning: Could not count lines for file "%s"' % line
292 291
 
@@ -295,7 +294,7 @@ class GitDataCollector(DataCollector):
295 294
 		#  N files changed, N insertions (+), N deletions(-)
296 295
 		# <stamp> <author>
297 296
 		self.changes_by_date = {} # stamp -> { files, ins, del }
298
-		lines = getpipeoutput(('git-log --shortstat --pretty=format:"%at %an"',)).split('\n')
297
+		lines = getpipeoutput(['git-log --shortstat --pretty=format:"%at %an"']).split('\n')
299 298
 		lines.reverse()
300 299
 		files = 0; inserted = 0; deleted = 0; total_lines = 0
301 300
 		for line in lines:
@@ -359,8 +358,7 @@ class GitDataCollector(DataCollector):
359 358
 		return datetime.datetime.fromtimestamp(self.last_commit_stamp)
360 359
 	
361 360
 	def getTags(self):
362
-		lines = getpipeoutput(('git-show-ref --tags',
363
-				       'cut -d/ -f3'))
361
+		lines = getpipeoutput(['git-show-ref --tags', 'cut -d/ -f3'])
364 362
 		return lines.split('\n')
365 363
 	
366 364
 	def getTagDate(self, tag):
@@ -379,7 +377,7 @@ class GitDataCollector(DataCollector):
379 377
 		return self.total_lines
380 378
 	
381 379
 	def revToDate(self, rev):
382
-		stamp = int(getpipeoutput(('git-log --pretty=format:%%at "%s" -n 1' % rev,)))
380
+		stamp = int(getpipeoutput(['git-log --pretty=format:%%at "%s" -n 1' % rev]))
383 381
 		return datetime.datetime.fromtimestamp(stamp).strftime('%Y-%m-%d')
384 382
 
385 383
 class ReportCreator:
@@ -806,7 +804,7 @@ plot 'lines_of_code.dat' using 1:2 w lines
806 804
 		os.chdir(path)
807 805
 		files = glob.glob(path + '/*.plot')
808 806
 		for f in files:
809
-			out = getpipeoutput((gnuplot_cmd + ' "%s"' % f,))
807
+			out = getpipeoutput([gnuplot_cmd + ' "%s"' % f])
810 808
 			if len(out) > 0:
811 809
 				print out
812 810