Index: packager.py |
diff --git a/packager.py b/packager.py |
index ab9557148de8834951ea1ea93e83c55a0be18cf9..ecf110886a34281e46d0f48f77c21f48456b3f26 100644 |
--- a/packager.py |
+++ b/packager.py |
@@ -9,6 +9,7 @@ import sys |
import os |
import re |
import subprocess |
+import tempfile |
import json |
import zipfile |
from StringIO import StringIO |
@@ -167,6 +168,25 @@ class Files(dict): |
for name in sorted(self, key=sortKey): |
zf.writestr(name, self[name]) |
+ def to_tmp_folder(self, subfolder=None): |
Sebastian Noack
2018/07/09 12:35:19
See the devenv() function in the "build" module. T
tlucas
2018/07/09 13:23:56
Done.
|
+ tmp_dir = tempfile.mkdtemp('adblockplus_package') |
+ if subfolder: |
+ cwtd = os.path.join(tmp_dir, subfolder) |
+ os.makedirs(cwtd) |
+ else: |
+ cwtd = tmp_dir |
+ |
+ for name in sorted(self): |
+ dest = os.path.join(cwtd, name) |
+ try: |
+ os.makedirs(os.path.dirname(dest)) |
+ except OSError: |
+ pass |
+ |
+ with open(dest, 'w') as fp: |
+ fp.write(self[name]) |
+ return tmp_dir |
+ |
def zipToString(self, sortKey=None): |
buffer = StringIO() |
self.zip(buffer, sortKey=sortKey) |