Skip to content

Commit

Permalink
Merge pull request #1 from MosesofEgypt/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
MosesofEgypt authored Sep 6, 2019
2 parents 0dd021a + 5077a36 commit bd236c5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 41 deletions.
61 changes: 24 additions & 37 deletions build_mek_releases.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import fnmatch
try:
import gitignore_parser
except ImportError:
print("Need to install 'gitignore_parser' library")
input()
raise SystemExit(0)

import os
import shutil
import subprocess
Expand All @@ -24,25 +30,24 @@
temp_root = os.path.realpath(os.path.join(tempfile.gettempdir(), "mek_build_temp_folder"))
prebuilt_mek_dir = os.path.join(temp_root, "MEK_Prebuilt")

mek_download_url = "https://bitbucket.org/Moses_of_Egypt/mek/get/default.zip"
mek_download_url = "https://github.com/MosesofEgypt/mek/archive/master.zip"
script_test = (
input("Type 'y' to do an actual upload: ").strip().lower() != 'y')

def unzip_zipfile(zipfile_path, dst, del_zipfile=False):
with zipfile.ZipFile(zipfile_path) as zf:
for zip_name in zf.namelist():
# ignore the root directory of the zipfile
filepath = zip_name.split("/", 1)[-1]
if filepath[:1] == '.':
if filepath[:1] == '.' or zip_name[-1:] == "/":
continue

try:
filepath = os.path.join(dst, filepath).replace("\\", "/")
filename = os.path.basename(filepath)
dirpath = os.path.dirname(filepath)

if not os.path.exists(dirpath):
os.makedirs(dirpath)
if os.sep == "\\":
filepath = filepath.replace("/", "\\")

os.makedirs(os.path.dirname(filepath), exist_ok=True)
with zf.open(zip_name) as zzf, open(filepath, "wb+") as f:
f.write(zzf.read())
except Exception:
Expand All @@ -61,8 +66,8 @@ def copy_module_files(src, dst):
os.makedirs(dst, exist_ok=True)
for _, dirs, __ in os.walk(src):
for dirname in dirs:
if dirname.lower() not in (
".hg", ".vs", "test_files", "x64", "__pycache__",
if dirname[:1] != "." and dirname.lower() not in (
"test_files", "x64", "__pycache__",
"arbytmap_ext", "bitmap_io_ext", "dds_defs_ext",
"raw_packer_ext", "raw_unpacker_ext", "swizzler_ext",
"tiler_ext"):
Expand All @@ -81,7 +86,7 @@ def copy_module_files(src, dst):
continue
elif ext in (".backup", ".sln", ".user", ".filters", ".vcxproj"):
continue
elif ext == "" and name == ".hgignore":
elif ext == "" and name == ".gitignore":
continue

shutil.copy(os.path.join(src, filename),
Expand All @@ -90,24 +95,8 @@ def copy_module_files(src, dst):
# only copy the root files
break

glob_ignore = []
ignore_filepath = os.path.join(src, ".hgignore")
try:
with open(ignore_filepath, "r") as f:
for line in f:
line = line.strip(" \n")
if line and line[0] != "#":
glob_ignore.append(line.replace("\\", "/"))

# ignore the first line
if glob_ignore:
syntax_line = tuple(
s.strip() for s in glob_ignore.pop(0).lower().split(" ") if s)
if syntax_line != ("syntax:", "glob"):
glob_ignore = ()

except Exception:
pass
ignore_matches = gitignore_parser.parse_gitignore(
os.path.join(src, ".gitignore"), dst)

# remove compiled python files and ignored files
for root, dirs, files in os.walk(dst):
Expand All @@ -116,19 +105,17 @@ def copy_module_files(src, dst):
rel_filepath = os.path.relpath(filepath, dst)
# explicitly include any .pyd accelerators
if os.path.splitext(filename)[-1].lower() != ".pyd":
for pattern in glob_ignore:
if fnmatch.fnmatch(rel_filepath, pattern):
os.remove(filepath)
break
if ignore_matches(filepath):
print("IGNORE FILE:", filename)
os.remove(filepath)

for dirname in dirs:
dirpath = os.path.realpath(os.path.join(root, dirname))
rel_dirpath = os.path.join(os.path.normpath(
os.path.join("/", os.path.relpath(dirpath, dst))), "")
for pattern in glob_ignore:
if fnmatch.fnmatch(rel_dirpath, pattern):
shutil.rmtree(dirpath)
break
if ignore_matches(dirpath):
print("IGNORE DIR:", dirpath)
shutil.rmtree(dirpath)


def pypi_upload(root="", module_name="", egg=True, wheel=True, source=False, *,
Expand Down
6 changes: 3 additions & 3 deletions src/exe_lib_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
for folder in dirs:
if os.path.join(root, "") == os.path.join(op_dir, ""):
break
if folder.lower() in (
".hg", ".vs", "styles", "docs", "test_files", "x64",
if folder[1:] != "." and folder.lower() in (
"styles", "docs", "test_files", "x64",
"arbytmap_ext", "bitmap_io_ext", "dds_defs_ext",
"raw_packer_ext", "raw_unpacker_ext", "swizzler_ext",
"tiler_ext"):
Expand All @@ -26,7 +26,7 @@
if cur_dir in os.path.join(root, filename):
continue

if filename.lower() in ("todo.txt", ".recent.txt", ".hgignore",
if filename.lower() in ("todo.txt", ".recent.txt", ".gitignore",
"pool_colors.txt", "pool_actions.txt",
"refinery.cfg", "mozzarilla.cfg",
"binilla.cfg", "hek_pool.cfg"):
Expand Down
2 changes: 1 addition & 1 deletion src/make_installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "MEK Essentials"
#define MyAppVersion "1.0.5.6"
#define MyAppVersion "1.0.6.0"
#define MyAppPublisher "Moses of Egypt"
#define MyAppURL "https://bitbucket.org/Moses_of_Egypt/"
#define MekeDir "F:\My Files\Applications\My Repos\meke\"
Expand Down

0 comments on commit bd236c5

Please sign in to comment.