瀏覽代碼

Search '/usr/share/gitstats/' for static files as well.

The first path to be searched is the directory of the binary, then
/usr/share/gitstats/. This is so that you can have both a "global" gitstats
version and a user-specific checkout installed, and the static files should be
taken from the matching place.

This change is done in preparation for Debian packaging.

Vincent Fourmond <fourmond@debian.org> is planning to package gitstats for
debian (RFP #440392).
Heikki Hokkanen 16 年之前
父節點
當前提交
6397a94b30
共有 1 個檔案被更改,包括 8 行新增2 行删除
  1. 8
    2
      gitstats

+ 8
- 2
gitstats 查看文件

@@ -478,9 +478,15 @@ class HTMLReportCreator(ReportCreator):
478 478
 		self.title = data.projectname
479 479
 
480 480
 		# copy static files if they do not exist
481
+		basedirs = [os.path.dirname(os.path.abspath(__file__)), '/usr/share/gitstats']
481 482
 		for file in ('gitstats.css', 'sortable.js', 'arrow-up.gif', 'arrow-down.gif', 'arrow-none.gif'):
482
-			basedir = os.path.dirname(os.path.abspath(__file__))
483
-			shutil.copyfile(basedir + '/' + file, path + '/' + file)
483
+			for base in basedirs:
484
+				src = base + '/' + file
485
+				if os.path.exists(src):
486
+					shutil.copyfile(src, path + '/' + file)
487
+					break
488
+			else:
489
+				print 'Warning: "%s" not found, so not copied (searched: %s)' % (file, basedirs)
484 490
 
485 491
 		f = open(path + "/index.html", 'w')
486 492
 		format = '%Y-%m-%d %H:%M:%S'