Dont re-download the liberation fonts if they are already present

This commit is contained in:
Kovid Goyal 2020-12-15 11:53:20 +05:30
parent 5f67dd54b5
commit a1558ff4b9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -21,7 +21,20 @@ class LiberationFonts(ReVendor):
def vendored_dir(self):
return self.j(self.RESOURCES, 'fonts', 'liberation')
@property
def version_file(self):
return self.j(self.vendored_dir, 'version.txt')
def already_present(self):
if os.path.exists(self.version_file):
with open(self.version_file) as f:
return f.read() == self.VERSION
return False
def run(self, opts):
if not opts.system_liberation_fonts and self.already_present():
self.info('Liberation Fonts already present in the resources directory, not downloading')
return
self.clean()
os.makedirs(self.vendored_dir)
self.use_symlinks = opts.system_liberation_fonts
@ -33,3 +46,5 @@ class LiberationFonts(ReVendor):
for x in font_files:
self.add_file(x, os.path.basename(x))
with open(self.j(self.vendored_dir, 'version.txt'), 'w') as f:
f.write(self.VERSION)