mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
calibre-customize: When building plugins from a directory, exclude known version control subdirectories
This commit is contained in:
parent
d1674cc8a4
commit
cdd267637b
@ -619,7 +619,7 @@ def build_plugin(path):
|
||||
raise SystemExit(1)
|
||||
t = PersistentTemporaryFile(u'.zip')
|
||||
with ZipFile(t, u'w', ZIP_STORED) as zf:
|
||||
zf.add_dir(path)
|
||||
zf.add_dir(path, simple_filter=lambda x:x in {'.git', '.bzr', '.svn', '.hg'})
|
||||
t.close()
|
||||
plugin = add_plugin(t.name)
|
||||
os.remove(t.name)
|
||||
|
@ -1303,7 +1303,7 @@ class ZipFile:
|
||||
self.filelist.append(zinfo)
|
||||
self.NameToInfo[zinfo.filename] = zinfo
|
||||
|
||||
def add_dir(self, path, prefix=''):
|
||||
def add_dir(self, path, prefix='', simple_filter=lambda x:False):
|
||||
'''
|
||||
Add a directory recursively to the zip file with an optional prefix.
|
||||
'''
|
||||
@ -1314,9 +1314,11 @@ class ZipFile:
|
||||
os.chdir(path)
|
||||
fp = (prefix + ('/' if prefix else '')).replace('//', '/')
|
||||
for f in os.listdir('.'):
|
||||
if simple_filter(f): # Added by Kovid
|
||||
continue
|
||||
arcname = fp + f
|
||||
if os.path.isdir(f):
|
||||
self.add_dir(f, prefix=arcname)
|
||||
self.add_dir(f, prefix=arcname, simple_filter=simple_filter)
|
||||
else:
|
||||
self.write(f, arcname)
|
||||
finally:
|
||||
|
Loading…
x
Reference in New Issue
Block a user