-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 022aecb
Showing
13 changed files
with
1,602 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.txt text | ||
*.py text | ||
*.cfg text | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
*.DS_Store | ||
|
||
# Vim temp/swap files | ||
*~ | ||
*.swp | ||
*.swo | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
*.log | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
*.ini | ||
|
||
# Temporary build directories | ||
TagMechanic/ | ||
|
||
# Zip files (plugin releases) | ||
*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
TagMechanic (A Sigil Plugin) | ||
============ | ||
|
||
A Sigil plugin that helps users manipulate/remove spans, divs and other elements based on their attributes (or lack thereof) in a nesting-safe manner. | ||
|
||
|
||
Links | ||
===== | ||
|
||
* Sigil website is at http://sigil-ebook.com | ||
* The Tooltip for Tkinter script can be found at http://code.activestate.com/recipes/576688-tooltip-for-tkinter/ | ||
|
||
|
||
Building | ||
======== | ||
|
||
First, clone the repo and cd into it: | ||
|
||
$ git clone https://github.com/dougmassay/tagmechanic-sigil-plugin.git | ||
$ cd ./tagmechanic-sigil-plugin | ||
$ cd .. | ||
|
||
To create the plugin zip file, run the buildplugin.py script (root of the repository tree) with Python (2 or 3) | ||
|
||
$python buildplugin.py | ||
|
||
This will create the TagMechanic_vX.X.X.zip file that can then be installed into Sigil's plugin manager. | ||
|
||
Contributing / Modifying | ||
============ | ||
From here on out, a proficiency with developing / creating Sigil plugins is assumed. | ||
If you need a crash-course, an introduction to creating Sigil plugins is available at | ||
http://www.mobileread.com/forums/showthread.php?t=251452. | ||
|
||
|
||
The core plugin files (this is where most contributors will spend their time) are: | ||
|
||
> dialogs.py | ||
> images/icon.png | ||
> parsing_engine.py | ||
> plugin.py | ||
> plugin.xml | ||
> tk_tooltips.py | ||
> updatecheck.py | ||
|
||
|
||
Files used for building/maintaining the plugin: | ||
|
||
> buildplugin.py -- this is used to build the plugin. | ||
> checkversion.xml -- used by automatic update checking (not yet implemented). | ||
> setup.cfg -- used for flake8 style and PEP checking. Use it to see if your code complies. | ||
(if my setup.cfg doesn't bark about it, then I don't care about it) | ||
|
||
Feel free to fork the repository and submit pull requests (or just use it privately to experiment). | ||
|
||
|
||
|
||
License Information | ||
======= | ||
|
||
###TagMechanic (a Sigil plugin) | ||
|
||
Licensed under the GPLv3. | ||
|
||
###Tooltip for Tkinter | ||
|
||
Created by Tucker Beck | ||
Licensed under the MIT license | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab | ||
|
||
from __future__ import (unicode_literals, division, absolute_import, | ||
print_function) | ||
|
||
import os | ||
import sys | ||
import re | ||
import shutil | ||
import inspect | ||
import zipfile | ||
|
||
|
||
SCRIPT_DIR = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) | ||
PLUGIN_NAME = 'TagMechanic' | ||
TEMP_DIR = os.path.join(SCRIPT_DIR, PLUGIN_NAME) | ||
|
||
PLUGIN_FILES = ['dialogs.py', | ||
'images', | ||
'parsing_engine.py', | ||
'plugin.py', | ||
'plugin.xml', | ||
'tk_tooltips.py', | ||
'updatecheck.py',] | ||
|
||
def findVersion(): | ||
_version_pattern = re.compile(r'<version>([^<]*)</version>') | ||
with open('plugin.xml', 'r') as fd: | ||
data = fd.read() | ||
match = re.search(_version_pattern, data) | ||
if match is not None: | ||
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)) | ||
|
||
|
||
# recursive zip creation support routine | ||
def zipUpDir(myzip, tdir, localname): | ||
currentdir = tdir | ||
if localname != "": | ||
currentdir = os.path.join(currentdir,localname) | ||
dir_contents = os.listdir(currentdir) | ||
for entry in dir_contents: | ||
afilename = entry | ||
localfilePath = os.path.join(localname, afilename) | ||
realfilePath = os.path.join(currentdir, entry) | ||
if os.path.isfile(realfilePath): | ||
myzip.write(realfilePath, localfilePath, zipfile.ZIP_DEFLATED) | ||
elif os.path.isdir(realfilePath): | ||
zipUpDir(myzip, tdir, localfilePath) | ||
|
||
def removePreviousTmp(rmzip=False): | ||
# Remove temp folder and contents if it exists | ||
if os.path.exists(TEMP_DIR) and os.path.isdir(TEMP_DIR): | ||
shutil.rmtree(TEMP_DIR) | ||
|
||
if rmzip: # Remove zip file if indicated. | ||
print ('Removing any current zip file ...') | ||
if os.path.exists(ARCHIVE_NAME): | ||
os.remove(ARCHIVE_NAME) | ||
|
||
def ignore_in_dirs(base, items, ignored_dirs=None): | ||
ans = [] | ||
if ignored_dirs is None: | ||
ignored_dirs = {'.git', '__pycache__'} | ||
for name in items: | ||
path = os.path.join(base, name) | ||
if os.path.isdir(path): | ||
if name in ignored_dirs: | ||
ans.append(name) | ||
else: | ||
if name.rpartition('.')[-1] in ('pyc', 'pyo'): | ||
ans.append(name) | ||
return ans | ||
|
||
if __name__ == "__main__": | ||
print('Removing any previous build leftovers ...') | ||
removePreviousTmp(rmzip=True) | ||
|
||
print ('Creating temp {} directory ...'.format(PLUGIN_NAME)) | ||
os.mkdir(TEMP_DIR) | ||
|
||
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): | ||
shutil.copytree(entry_path, os.path.join(TEMP_DIR, entry), ignore=ignore_in_dirs) | ||
elif os.path.exists(entry_path) and os.path.isfile(entry_path): | ||
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))) | ||
outzip = zipfile.ZipFile(ARCHIVE_NAME, 'w') | ||
zipUpDir(outzip, SCRIPT_DIR, os.path.basename(TEMP_DIR)) | ||
outzip.close() | ||
|
||
print ('Plugin successfully created!') | ||
|
||
print('Removing temp build directory ...') | ||
removePreviousTmp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<information> | ||
<current-version>0.3.</current-version> | ||
</information> |
Oops, something went wrong.