Skip to content

Commit 43d3946

Browse files
author
Ram Rachum
committed
-
1 parent eaf92ac commit 43d3946

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

garlicsim/garlicsim/general_misc/nifty_collections/ordered_dict.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2121
# OTHER DEALINGS IN THE SOFTWARE.
2222

23-
# blocktodo: move out of third party
2423

2524
from UserDict import DictMixin
2625

misc/testing/zip/make_zip.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,33 @@
2121
from __future__ import with_statement
2222

2323
import sys
24+
import re
25+
import fnmatch
2426
import os.path
2527
import zipfile
2628
import contextlib
2729
import shutil
2830

2931

30-
def zip_folder(folder, zip_path, ignored_extenstions=[]):
32+
def zip_folder(folder, zip_path, ignored_patterns=[]):
3133
'''
34+
3235
note: creates a folder inside the zip with the same name of the original
3336
folder, in contrast to other implementation which put all of the files on
3437
the root level of the zip.
3538
3639
Doesn't put empty folders in the zip file.
40+
41+
tododoc ignored_patterns, they're fnmatch style
3742
'''
3843
assert os.path.isdir(folder)
3944
source_folder = os.path.realpath(folder)
4045

46+
ignored_re_patterns = [re.compile(fnmatch.translate(ignored_pattern)) for
47+
ignored_pattern in ignored_patterns]
48+
4149
zip_name = os.path.splitext(os.path.split(zip_path)[1])[0]
4250
source_folder_name = os.path.split(source_folder)[1]
43-
44-
### Ensuring ignored extensions start with '.': ###########################
45-
# #
46-
for ignored_extenstion in ignored_extenstions:
47-
if not ignored_extenstion.startswith('.'):
48-
ignored_extenstions[
49-
ignored_extenstions.index(ignored_extenstion)
50-
] = \
51-
('.' + ignored_extenstion)
52-
# #
53-
### Finished ensuring ignored extensions start with '.'. ##################
5451

5552
with contextlib.closing(
5653
zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
@@ -60,9 +57,9 @@ def zip_folder(folder, zip_path, ignored_extenstions=[]):
6057

6158
for file_path in files:
6259

63-
extension = os.path.splitext(file_path)[1]
64-
if extension in ignored_extenstions:
65-
continue
60+
for ignored_re_pattern in ignored_re_patterns:
61+
if ignored_re_pattern.match(file_path):
62+
continue
6663

6764
absolute_file_path = os.path.join(root, file_path)
6865

@@ -114,7 +111,7 @@ def make_zip():
114111

115112
sys.stdout.write('Zipping... ')
116113
zip_folder(package_path, zip_destination_path,
117-
ignored_extenstions=['.pyc', '.pyo'])
114+
ignored_patterns=['*.pyc', '*.pyo', '*__pycache__*'])
118115

119116
sys.stdout.write('Done.\n')
120117
# #

0 commit comments

Comments
 (0)