Skip to content

Commit

Permalink
First step of overhaul to PyQt5
Browse files Browse the repository at this point in the history
  • Loading branch information
dougmassay committed Feb 11, 2020
1 parent 814794d commit 808e569
Show file tree
Hide file tree
Showing 12 changed files with 808 additions and 789 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ TagMechanic/

# Zip files (plugin releases)
*.zip

# compiled translations files
*.qm
11 changes: 7 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ environment:
before_build:
- cmd: |-
set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
# python -m pip install --upgrade pip
# pip3.7 install six
python -m pip install --upgrade pip
pip3.7 install flake8
build_script:
- cmd: |-
set PATH=%PYTHON%;%PATH%
python buildplugin
python buildplugin --language
test_script:
- cmd: |-
flake8 buildplugin
flake8 .
artifacts:
- path: '*.zip'
Expand Down
46 changes: 36 additions & 10 deletions buildplugin
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ from __future__ import unicode_literals, division, absolute_import, print_functi
import os
import sys
import re
import subprocess
import shutil
import inspect
import zipfile
import optparse


SCRIPT_DIR = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
PLUGIN_NAME = 'TagMechanic'
TEMP_DIR = os.path.join(SCRIPT_DIR, PLUGIN_NAME)
TRANS_NAME = 'translations'
TRANS_SRC = os.path.join(SCRIPT_DIR, TRANS_NAME)
TRANS_DEST = os.path.join(SCRIPT_DIR, PLUGIN_NAME, TRANS_NAME)

PLUGIN_FILES = ['dialogs.py',
'images',
'parsing_engine.py',
'plugin.py',
'plugin.xml',
'tk_tooltips.py',
'updatecheck.py']
'utilities.py',
'plugin.png']

def findVersion():
_version_pattern = re.compile(r'<version>([^<]*)</version>')
Expand All @@ -33,6 +37,7 @@ def findVersion():
return '{}'.format(match.group(1))
return '0.X.X'


# Find version info from plugin.xml and build zip file name from it
VERS_INFO = findVersion()
ARCHIVE_NAME = os.path.join(SCRIPT_DIR, '{}_v{}.zip'.format(PLUGIN_NAME, VERS_INFO))
Expand All @@ -59,7 +64,7 @@ def removePreviousTmp(rmzip=False):
shutil.rmtree(TEMP_DIR)

if rmzip: # Remove zip file if indicated.
print ('Removing any current zip file ...')
print('Removing any current zip file ...')
if os.path.exists(ARCHIVE_NAME):
os.remove(ARCHIVE_NAME)

Expand All @@ -77,14 +82,21 @@ def ignore_in_dirs(base, items, ignored_dirs=None):
ans.append(name)
return ans


if __name__ == "__main__":
parser = optparse.OptionParser()
parser.add_option('-l', '--language',
dest="compile_lang",
default=False,
action="store_true")
options, args = parser.parse_args()
print('Removing any previous build leftovers ...')
removePreviousTmp(rmzip=True)

print ('Creating temp {} directory ...'.format(PLUGIN_NAME))
print('Creating temp {} directory ...'.format(PLUGIN_NAME))
os.mkdir(TEMP_DIR)

print ('Copying everything to temp {} directory ...'.format(PLUGIN_NAME))
print('Copying everything to temp {} directory ...'.format(PLUGIN_NAME))
for entry in PLUGIN_FILES:
entry_path = os.path.join(SCRIPT_DIR, entry)
if os.path.exists(entry_path) and os.path.isdir(entry_path):
Expand All @@ -93,13 +105,27 @@ if __name__ == "__main__":
shutil.copy2(entry_path, os.path.join(TEMP_DIR, entry))
else:
sys.exit('Couldn\'t copy necessary plugin files!')

print ('Creating {} ...'.format(os.path.basename(ARCHIVE_NAME)))
os.mkdir(TRANS_DEST)
if options.compile_lang:
if os.path.exists(TRANS_SRC) and os.path.isdir(TRANS_SRC):
for name in os.listdir(TRANS_SRC):
if name !='template.ts' and name.rpartition('.')[-1] == ('ts'):
ts_name = os.path.join(TRANS_SRC, name)
qm_name = '{}.{}'.format(os.path.join(TRANS_DEST, os.path.splitext(name)[0]), 'qm')
command = ['lrelease',
ts_name,
'-qm',
qm_name
]
print('Compiling {} with lrelease'.format(name))
proc = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)

print('Creating {} ...'.format(os.path.basename(ARCHIVE_NAME)))
outzip = zipfile.ZipFile(ARCHIVE_NAME, 'w')
zipUpDir(outzip, SCRIPT_DIR, os.path.basename(TEMP_DIR))
outzip.close()

print ('Plugin successfully created!')
print('Plugin successfully created!')

print('Removing temp build directory ...')
removePreviousTmp()
removePreviousTmp()
Loading

0 comments on commit 808e569

Please sign in to comment.