Skip to content

Commit

Permalink
Merge pull request #70 from MrTeferi/directory-restructure
Browse files Browse the repository at this point in the history
Directory structural rewrite complete
  • Loading branch information
Investigamer authored Mar 16, 2023
2 parents 3dc9c9d + 94cf778 commit 9001e13
Show file tree
Hide file tree
Showing 2,231 changed files with 51,167 additions and 2,042 deletions.
22 changes: 12 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,26 +159,28 @@ cython_debug/
# Render output folder
/out
# Temporary logging directory
/tmp
/logs
# PSD templates directory
/templates
# For personal testing
/testing.py
# User generated data files
/proxyshop/datas/
/src/data/sets/
# User specific version tracker
/proxyshop/version_tracker.json
/src/data/version_tracker.json
# Generated new release
/release
# Environmental variables
/proxyshop/__env__.py
/src/__env__.py
# All plugins that aren't MrTeferi or SilvanMTG
/proxyshop/plugins/*
!/proxyshop/plugins/MrTeferi
!/proxyshop/plugins/SilvanMTG
/plugins/*
!/plugins/MrTeferi
!/plugins/SilvanMTG
# All plugin templates
/plugins/*/templates/*
# User generated config files
/proxyshop/configs/*.ini
/src/configs/*.ini
# User generated plugin config files
/proxyshop/plugins/*/configs/*.ini
/plugins/*/configs/*.ini
# Test generated symbol images
/proxyshop/tests/symbols/**/*[.png, .jpg, .jpeg, .tif, .tga, .webp, .psd]
/src/tests/symbols/**/*[.png, .jpg, .jpeg, .tif, .tga, .webp, .psd]
2 changes: 1 addition & 1 deletion .idea/Proxyshop.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Proxyshop.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ a = Analysis(['..\\Proxyshop\main.py'],
binaries=[],
datas=[],
hiddenimports=[
'proxyshop.templates',
'proxyshop.gui',
'src.templates',
'src.gui',
'kivy',
'svglib.svglib',
'reportlab.graphics',
Expand All @@ -28,7 +28,7 @@ pyz = PYZ(a.pure, a.zipped_data,

a.datas += [
('fonts/Beleren Small Caps.ttf', 'fonts/Beleren Small Caps.ttf', 'DATA'),
('proxyshop/img/proxyshop.png', 'proxyshop/img/proxyshop.png', 'DATA')
('src/img/proxyshop.png', 'src/img/proxyshop.png', 'DATA')
]

exe = EXE(pyz,
Expand All @@ -47,4 +47,4 @@ exe = EXE(pyz,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
icon='proxyshop/img/favicon.ico')
icon='src/img/favicon.ico')
80 changes: 48 additions & 32 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@
from shutil import copy2, copytree, rmtree, move
import PyInstaller.__main__

from proxyshop.__version__ import version
from src.__version__ import version

# Folder definitions
CWD = os.getcwd()
PS = os.path.join(os.getcwd(), 'proxyshop')
DIST = os.path.join(CWD, 'dist')
DIST_PS = os.path.join(os.getcwd(), 'dist/proxyshop')
DIST_PS_PLUGINS = os.path.join(DIST_PS, 'plugins')

SRC = os.path.join(CWD, 'src')
DIST_SRC = os.path.join(DIST, 'src')

DATA = os.path.join(SRC, 'data')
DIST_DATA = os.path.join(DIST_SRC, 'data')

PLUGINS = os.path.join(CWD, 'plugins')
DIST_PLUGINS = os.path.join(DIST, 'plugins')

# All individual files that need to be copied upon pyinstaller completion
files = [
Expand All @@ -24,32 +30,34 @@
{'src': os.path.join(CWD, 'LICENSE'), 'dst': os.path.join(DIST, 'LICENSE')},
{'src': os.path.join(CWD, 'README.md'), 'dst': os.path.join(DIST, 'README.md')},
# --- PROXYSHOP DIRECTORY
{'src': os.path.join(PS, 'tests.json'), 'dst': os.path.join(DIST_PS, 'tests.json')},
{'src': os.path.join(PS, 'manifest.json'), 'dst': os.path.join(DIST_PS, 'manifest.json')},
{'src': os.path.join(PS, 'symbols.json'), 'dst': os.path.join(DIST_PS, 'symbols.json')},
{'src': os.path.join(PS, 'custom_symbols.json'), 'dst': os.path.join(DIST_PS, 'custom_symbols.json')},
{'src': os.path.join(PS, 'templates.json'), 'dst': os.path.join(DIST_PS, 'templates.json')},
{'src': os.path.join(PS, 'app_settings.json'), 'dst': os.path.join(DIST_PS, 'app_settings.json')},
{'src': os.path.join(DATA, 'tests.json'), 'dst': os.path.join(DIST_DATA, 'tests.json')},
{'src': os.path.join(DATA, 'manifest.json'), 'dst': os.path.join(DIST_DATA, 'manifest.json')},
{'src': os.path.join(DATA, 'symbols.json'), 'dst': os.path.join(DIST_DATA, 'symbols.json')},
{'src': os.path.join(DATA, 'templates.json'), 'dst': os.path.join(DIST_DATA, 'templates.json')},
{'src': os.path.join(DATA, 'watermarks.json'), 'dst': os.path.join(DIST_DATA, 'watermarks.json')},
{'src': os.path.join(DATA, 'app_settings.json'), 'dst': os.path.join(DIST_DATA, 'app_settings.json')},
]

# Folders that need to be copied
folders = [
# --- WORKING DIRECTORY
{'src': os.path.join(CWD, "fonts"), 'dst': os.path.join(DIST, 'fonts')},
# --- PROXYSHOP DIRECTORY
{'src': os.path.join(PS, "kv"), 'dst': os.path.join(DIST_PS, 'kv')},
{'src': os.path.join(PS, "img"), 'dst': os.path.join(DIST_PS, 'img')},
{'src': os.path.join(PS, "configs"), 'dst': os.path.join(DIST_PS, 'configs')},
{'src': os.path.join(SRC, "kv"), 'dst': os.path.join(DIST_SRC, 'kv')},
{'src': os.path.join(SRC, "img"), 'dst': os.path.join(DIST_SRC, 'img')},
{'src': os.path.join(SRC, "configs"), 'dst': os.path.join(DIST_SRC, 'configs')},
# --- PLUGINS DIRECTORY
{'src': os.path.join(PS, "plugins/MrTeferi"), 'dst': os.path.join(DIST_PS_PLUGINS, 'MrTeferi')},
{'src': os.path.join(PS, "plugins/SilvanMTG"), 'dst': os.path.join(DIST_PS_PLUGINS, 'SilvanMTG')},
{'src': os.path.join(PLUGINS, "MrTeferi"), 'dst': os.path.join(DIST_PLUGINS, 'MrTeferi')},
{'src': os.path.join(PLUGINS, "SilvanMTG"), 'dst': os.path.join(DIST_PLUGINS, 'SilvanMTG')},
]

# Directories containing ini files
cfg_dirs = [
os.path.join(DIST_PS, 'configs'),
os.path.join(DIST_PS_PLUGINS, 'MrTeferi/configs'),
os.path.join(DIST_PS_PLUGINS, 'SilvanMTG/configs')
remove_dirs = [
os.path.join(DIST_SRC, 'configs'),
os.path.join(DIST_PLUGINS, 'MrTeferi/configs'),
os.path.join(DIST_PLUGINS, 'SilvanMTG/configs'),
os.path.join(DIST_PLUGINS, 'MrTeferi/templates'),
os.path.join(DIST_PLUGINS, 'SilvanMTG/templates')
]


Expand All @@ -58,11 +66,17 @@ def clear_build_files(clear_dist=True):
Clean out all PYCACHE files and Pyinstaller files
"""
os.system("pyclean -v .")
try: rmtree(os.path.join(os.getcwd(), 'build'))
except Exception as e: print(e)
if os.path.exists(os.path.join(CWD, '.venv')):
os.system("pyclean -v .venv")
try:
rmtree(os.path.join(os.getcwd(), 'build'))
except Exception as e:
print(e)
if clear_dist:
try: rmtree(os.path.join(os.getcwd(), 'dist'))
except Exception as e: print(e)
try:
rmtree(os.path.join(os.getcwd(), 'dist'))
except Exception as e:
print(e)


def make_dirs():
Expand All @@ -71,10 +85,10 @@ def make_dirs():
"""
# Ensure folders exist
Path(DIST).mkdir(mode=511, parents=True, exist_ok=True)
Path(DIST_PS).mkdir(mode=511, parents=True, exist_ok=True)
Path(DIST_DATA).mkdir(mode=511, parents=True, exist_ok=True)
Path(DIST_PLUGINS).mkdir(mode=511, parents=True, exist_ok=True)
Path(os.path.join(DIST, "art")).mkdir(mode=511, parents=True, exist_ok=True)
Path(os.path.join(DIST, "templates")).mkdir(mode=511, parents=True, exist_ok=True)
Path(DIST_PS_PLUGINS).mkdir(mode=511, parents=True, exist_ok=True)


def move_data():
Expand All @@ -83,20 +97,22 @@ def move_data():
"""
# Transfer our necessary files
print("Transferring data files...")
for f in files: copy2(f['src'], f['dst'])
for f in files:
copy2(f['src'], f['dst'])

# Transfer our necessary folders
print("Transferring data folders...")
for f in folders: copytree(f['src'], f['dst'])
for f in folders:
copytree(f['src'], f['dst'])


def remove_ini_files():
def remove_unneeded_files():
"""
Remove autogenerated ini config files.
Remove autogenerated ini config files and PSD templates.
"""
for directory in cfg_dirs:
for directory in remove_dirs:
for file_name in os.listdir(directory):
if file_name.endswith(".ini"):
if file_name.endswith(('.ini', '.psd', '.psb')):
os.remove(os.path.join(directory, file_name))


Expand Down Expand Up @@ -129,6 +145,6 @@ def build_zip():

# Post-build steps
move_data()
remove_ini_files()
remove_unneeded_files()
build_zip()
clear_build_files(False)
13 changes: 8 additions & 5 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ True.Collector.Info = 1
Force.English.Formatting = 0

[SYMBOLS]
Default.Symbol =
Auto.Set.Symbol = 1
Auto.Symbol.Size = 1
Symbol.Mode = default
Default.Symbol = MTG
Force.Default.Symbol = 0
Symbol.Stroke.Size = 6
Fill.Symbol.Background = 0
Classic.Symbol.Rendering = 0

[WATERMARK]
Enable.Watermark = 0

[APP]
Manual.Edit = 0
Expand All @@ -27,6 +28,8 @@ Targeted.Replace = 1
Dev.Mode = 0

[TEMPLATES]
Border.Color = black
Render.Snow = 0
Render.Miracle = 0
Render.Basic = 1

Loading

0 comments on commit 9001e13

Please sign in to comment.