-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathpy2exe_MediaCollector.py
33 lines (26 loc) · 1.1 KB
/
py2exe_MediaCollector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import glob
import lib2to3
from py2exe.build_exe import py2exe as build_exe
class MediaCollector(build_exe):
"""
This class Adds
jsonschema files draft3.json and draft4.json
lib2to3 files Grammar.txt and PatternGrammar.txt
to the list of compiled files so it will be included in the zipfile.
"""
def copy_extensions(self, extensions):
build_exe.copy_extensions(self, extensions)
# lib2to3 files Grammar.txt and PatternGrammar.txt
# Define the data path where the files reside.
data_path = os.path.join(lib2to3.__path__[0],'*.txt')
# Create the subdir where the json files are collected.
media = os.path.join('lib2to3')
full = os.path.join(self.collect_dir, media)
self.mkpath(full)
# Copy the json files to the collection dir. Also add the copied file
# to the list of compiled files so it will be included in the zipfile.
for f in glob.glob(data_path):
name = os.path.basename(f)
self.copy_file(f, os.path.join(full, name))
self.compiled_files.append(os.path.join(media, name))