mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-05-08 01:39:50 +00:00
Compare commits
4 Commits
47dbe805bb
...
809116c764
Author | SHA1 | Date | |
---|---|---|---|
809116c764 | |||
83f401595d | |||
814d145366 | |||
efb76c7686 |
@ -1,3 +1,6 @@
|
|||||||
recursive-include core *.h
|
recursive-include core *.h
|
||||||
recursive-include core *.m
|
recursive-include core *.m
|
||||||
include run.py
|
include run.py
|
||||||
|
graft locale
|
||||||
|
graft help
|
||||||
|
graft qtlib/locale
|
81
build.py
81
build.py
@ -4,19 +4,16 @@
|
|||||||
# which should be included with this package. The terms are also available at
|
# which should be included with this package. The terms are also available at
|
||||||
# http://www.gnu.org/licenses/gpl-3.0.html
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
import os
|
from pathlib import Path
|
||||||
import os.path as op
|
|
||||||
import sys
|
import sys
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from setuptools import setup, Extension
|
from setuptools import sandbox
|
||||||
|
|
||||||
from hscommon import sphinxgen
|
from hscommon import sphinxgen
|
||||||
from hscommon.build import (
|
from hscommon.build import (
|
||||||
add_to_pythonpath,
|
add_to_pythonpath,
|
||||||
print_and_do,
|
print_and_do,
|
||||||
move_all,
|
|
||||||
fix_qt_resource_file,
|
fix_qt_resource_file,
|
||||||
)
|
)
|
||||||
from hscommon import loc
|
from hscommon import loc
|
||||||
@ -63,14 +60,14 @@ def parse_args():
|
|||||||
|
|
||||||
def build_help():
|
def build_help():
|
||||||
print("Generating Help")
|
print("Generating Help")
|
||||||
current_path = op.abspath(".")
|
current_path = Path(".").absolute()
|
||||||
help_basepath = op.join(current_path, "help", "en")
|
help_basepath = current_path.joinpath("help", "en")
|
||||||
help_destpath = op.join(current_path, "build", "help")
|
help_destpath = current_path.joinpath("build", "help")
|
||||||
changelog_path = op.join(current_path, "help", "changelog")
|
changelog_path = current_path.joinpath("help", "changelog")
|
||||||
tixurl = "https://github.com/arsenetar/dupeguru/issues/{}"
|
tixurl = "https://github.com/arsenetar/dupeguru/issues/{}"
|
||||||
confrepl = {"language": "en"}
|
confrepl = {"language": "en"}
|
||||||
changelogtmpl = op.join(current_path, "help", "changelog.tmpl")
|
changelogtmpl = current_path.joinpath("help", "changelog.tmpl")
|
||||||
conftmpl = op.join(current_path, "help", "conf.tmpl")
|
conftmpl = current_path.joinpath("help", "conf.tmpl")
|
||||||
sphinxgen.gen(
|
sphinxgen.gen(
|
||||||
help_basepath,
|
help_basepath,
|
||||||
help_destpath,
|
help_destpath,
|
||||||
@ -83,15 +80,15 @@ def build_help():
|
|||||||
|
|
||||||
|
|
||||||
def build_qt_localizations():
|
def build_qt_localizations():
|
||||||
loc.compile_all_po(op.join("qtlib", "locale"))
|
loc.compile_all_po(Path("qtlib", "locale"))
|
||||||
loc.merge_locale_dir(op.join("qtlib", "locale"), "locale")
|
loc.merge_locale_dir(Path("qtlib", "locale"), "locale")
|
||||||
|
|
||||||
|
|
||||||
def build_localizations():
|
def build_localizations():
|
||||||
loc.compile_all_po("locale")
|
loc.compile_all_po("locale")
|
||||||
build_qt_localizations()
|
build_qt_localizations()
|
||||||
locale_dest = op.join("build", "locale")
|
locale_dest = Path("build", "locale")
|
||||||
if op.exists(locale_dest):
|
if locale_dest.exists():
|
||||||
shutil.rmtree(locale_dest)
|
shutil.rmtree(locale_dest)
|
||||||
shutil.copytree("locale", locale_dest, ignore=shutil.ignore_patterns("*.po", "*.pot"))
|
shutil.copytree("locale", locale_dest, ignore=shutil.ignore_patterns("*.po", "*.pot"))
|
||||||
|
|
||||||
@ -99,57 +96,35 @@ def build_localizations():
|
|||||||
def build_updatepot():
|
def build_updatepot():
|
||||||
print("Building .pot files from source files")
|
print("Building .pot files from source files")
|
||||||
print("Building core.pot")
|
print("Building core.pot")
|
||||||
loc.generate_pot(["core"], op.join("locale", "core.pot"), ["tr"])
|
loc.generate_pot(["core"], Path("locale", "core.pot"), ["tr"])
|
||||||
print("Building columns.pot")
|
print("Building columns.pot")
|
||||||
loc.generate_pot(["core"], op.join("locale", "columns.pot"), ["coltr"])
|
loc.generate_pot(["core"], Path("locale", "columns.pot"), ["coltr"])
|
||||||
print("Building ui.pot")
|
print("Building ui.pot")
|
||||||
# When we're not under OS X, we don't want to overwrite ui.pot because it contains Cocoa locs
|
# When we're not under OS X, we don't want to overwrite ui.pot because it contains Cocoa locs
|
||||||
# We want to merge the generated pot with the old pot in the most preserving way possible.
|
# We want to merge the generated pot with the old pot in the most preserving way possible.
|
||||||
ui_packages = ["qt", op.join("cocoa", "inter")]
|
ui_packages = ["qt", Path("cocoa", "inter")]
|
||||||
loc.generate_pot(ui_packages, op.join("locale", "ui.pot"), ["tr"], merge=True)
|
loc.generate_pot(ui_packages, Path("locale", "ui.pot"), ["tr"], merge=True)
|
||||||
print("Building qtlib.pot")
|
print("Building qtlib.pot")
|
||||||
loc.generate_pot(["qtlib"], op.join("qtlib", "locale", "qtlib.pot"), ["tr"])
|
loc.generate_pot(["qtlib"], Path("qtlib", "locale", "qtlib.pot"), ["tr"])
|
||||||
|
|
||||||
|
|
||||||
def build_mergepot():
|
def build_mergepot():
|
||||||
print("Updating .po files using .pot files")
|
print("Updating .po files using .pot files")
|
||||||
loc.merge_pots_into_pos("locale")
|
loc.merge_pots_into_pos("locale")
|
||||||
loc.merge_pots_into_pos(op.join("qtlib", "locale"))
|
loc.merge_pots_into_pos(Path("qtlib", "locale"))
|
||||||
# loc.merge_pots_into_pos(op.join("cocoalib", "locale"))
|
# loc.merge_pots_into_pos(Path("cocoalib", "locale"))
|
||||||
|
|
||||||
|
|
||||||
def build_normpo():
|
def build_normpo():
|
||||||
loc.normalize_all_pos("locale")
|
loc.normalize_all_pos("locale")
|
||||||
loc.normalize_all_pos(op.join("qtlib", "locale"))
|
loc.normalize_all_pos(Path("qtlib", "locale"))
|
||||||
# loc.normalize_all_pos(op.join("cocoalib", "locale"))
|
# loc.normalize_all_pos(Path("cocoalib", "locale"))
|
||||||
|
|
||||||
|
|
||||||
def build_pe_modules():
|
def build_pe_modules():
|
||||||
print("Building PE Modules")
|
print("Building PE Modules")
|
||||||
exts = [
|
# Leverage setup.py to build modules
|
||||||
Extension(
|
sandbox.run_setup("setup.py", ["build_ext", "--inplace"])
|
||||||
"_block",
|
|
||||||
[
|
|
||||||
op.join("core", "pe", "modules", "block.c"),
|
|
||||||
op.join("core", "pe", "modules", "common.c"),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Extension(
|
|
||||||
"_cache",
|
|
||||||
[
|
|
||||||
op.join("core", "pe", "modules", "cache.c"),
|
|
||||||
op.join("core", "pe", "modules", "common.c"),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
||||||
exts.append(Extension("_block_qt", [op.join("qt", "pe", "modules", "block.c")]))
|
|
||||||
setup(
|
|
||||||
script_args=["build_ext", "--inplace"],
|
|
||||||
ext_modules=exts,
|
|
||||||
)
|
|
||||||
move_all("_block_qt*", op.join("qt", "pe"))
|
|
||||||
move_all("_block*", op.join("core", "pe"))
|
|
||||||
move_all("_cache*", op.join("core", "pe"))
|
|
||||||
|
|
||||||
|
|
||||||
def build_normal():
|
def build_normal():
|
||||||
@ -160,8 +135,8 @@ def build_normal():
|
|||||||
print("Building localizations")
|
print("Building localizations")
|
||||||
build_localizations()
|
build_localizations()
|
||||||
print("Building Qt stuff")
|
print("Building Qt stuff")
|
||||||
print_and_do("pyrcc5 {0} > {1}".format(op.join("qt", "dg.qrc"), op.join("qt", "dg_rc.py")))
|
print_and_do("pyrcc5 {0} > {1}".format(Path("qt", "dg.qrc"), Path("qt", "dg_rc.py")))
|
||||||
fix_qt_resource_file(op.join("qt", "dg_rc.py"))
|
fix_qt_resource_file(Path("qt", "dg_rc.py"))
|
||||||
build_help()
|
build_help()
|
||||||
|
|
||||||
|
|
||||||
@ -169,10 +144,10 @@ def main():
|
|||||||
if sys.version_info < (3, 6):
|
if sys.version_info < (3, 6):
|
||||||
sys.exit("Python < 3.6 is unsupported.")
|
sys.exit("Python < 3.6 is unsupported.")
|
||||||
options = parse_args()
|
options = parse_args()
|
||||||
if options.clean and op.exists("build"):
|
if options.clean and Path("build").exists():
|
||||||
shutil.rmtree("build")
|
shutil.rmtree("build")
|
||||||
if not op.exists("build"):
|
if not Path("build").exists():
|
||||||
os.mkdir("build")
|
Path("build").mkdir()
|
||||||
if options.doc:
|
if options.doc:
|
||||||
build_help()
|
build_help()
|
||||||
elif options.loc:
|
elif options.loc:
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* Created On: 2010-01-30
|
* Created On: 2010-01-30
|
||||||
* Copyright 2014 Hardcoded Software (http://www.hardcoded.net)
|
* Copyright 2014 Hardcoded Software (http://www.hardcoded.net)
|
||||||
*
|
*
|
||||||
* This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
* This software is licensed under the "BSD" License as described in the
|
||||||
* which should be included with this package. The terms are also available at
|
* "LICENSE" file, which should be included with this package. The terms are
|
||||||
* http://www.hardcoded.net/licenses/bsd_license
|
* also available at http://www.hardcoded.net/licenses/bsd_license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -14,86 +14,84 @@ static PyObject *NoBlocksError;
|
|||||||
/* avgdiff/maxdiff has been called with 2 block lists of different size. */
|
/* avgdiff/maxdiff has been called with 2 block lists of different size. */
|
||||||
static PyObject *DifferentBlockCountError;
|
static PyObject *DifferentBlockCountError;
|
||||||
|
|
||||||
/* Returns a 3 sized tuple containing the mean color of 'image'.
|
/* Returns a 3 sized tuple containing the mean color of 'image'.
|
||||||
* image: a PIL image or crop.
|
* image: a PIL image or crop.
|
||||||
*/
|
*/
|
||||||
static PyObject* getblock(PyObject *image)
|
static PyObject *getblock(PyObject *image) {
|
||||||
{
|
int i, totr, totg, totb;
|
||||||
int i, totr, totg, totb;
|
Py_ssize_t pixel_count;
|
||||||
Py_ssize_t pixel_count;
|
PyObject *ppixels;
|
||||||
PyObject *ppixels;
|
|
||||||
|
totr = totg = totb = 0;
|
||||||
totr = totg = totb = 0;
|
ppixels = PyObject_CallMethod(image, "getdata", NULL);
|
||||||
ppixels = PyObject_CallMethod(image, "getdata", NULL);
|
if (ppixels == NULL) {
|
||||||
if (ppixels == NULL) {
|
return NULL;
|
||||||
return NULL;
|
}
|
||||||
}
|
|
||||||
|
pixel_count = PySequence_Length(ppixels);
|
||||||
pixel_count = PySequence_Length(ppixels);
|
for (i = 0; i < pixel_count; i++) {
|
||||||
for (i=0; i<pixel_count; i++) {
|
PyObject *ppixel, *pr, *pg, *pb;
|
||||||
PyObject *ppixel, *pr, *pg, *pb;
|
int r, g, b;
|
||||||
int r, g, b;
|
|
||||||
|
ppixel = PySequence_ITEM(ppixels, i);
|
||||||
ppixel = PySequence_ITEM(ppixels, i);
|
pr = PySequence_ITEM(ppixel, 0);
|
||||||
pr = PySequence_ITEM(ppixel, 0);
|
pg = PySequence_ITEM(ppixel, 1);
|
||||||
pg = PySequence_ITEM(ppixel, 1);
|
pb = PySequence_ITEM(ppixel, 2);
|
||||||
pb = PySequence_ITEM(ppixel, 2);
|
Py_DECREF(ppixel);
|
||||||
Py_DECREF(ppixel);
|
r = PyLong_AsLong(pr);
|
||||||
r = PyLong_AsLong(pr);
|
g = PyLong_AsLong(pg);
|
||||||
g = PyLong_AsLong(pg);
|
b = PyLong_AsLong(pb);
|
||||||
b = PyLong_AsLong(pb);
|
Py_DECREF(pr);
|
||||||
Py_DECREF(pr);
|
Py_DECREF(pg);
|
||||||
Py_DECREF(pg);
|
Py_DECREF(pb);
|
||||||
Py_DECREF(pb);
|
|
||||||
|
totr += r;
|
||||||
totr += r;
|
totg += g;
|
||||||
totg += g;
|
totb += b;
|
||||||
totb += b;
|
}
|
||||||
}
|
|
||||||
|
Py_DECREF(ppixels);
|
||||||
Py_DECREF(ppixels);
|
|
||||||
|
if (pixel_count) {
|
||||||
if (pixel_count) {
|
totr /= pixel_count;
|
||||||
totr /= pixel_count;
|
totg /= pixel_count;
|
||||||
totg /= pixel_count;
|
totb /= pixel_count;
|
||||||
totb /= pixel_count;
|
}
|
||||||
}
|
|
||||||
|
return inttuple(3, totr, totg, totb);
|
||||||
return inttuple(3, totr, totg, totb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the difference between the first block and the second.
|
/* Returns the difference between the first block and the second.
|
||||||
* It returns an absolute sum of the 3 differences (RGB).
|
* It returns an absolute sum of the 3 differences (RGB).
|
||||||
*/
|
*/
|
||||||
static int diff(PyObject *first, PyObject *second)
|
static int diff(PyObject *first, PyObject *second) {
|
||||||
{
|
int r1, g1, b1, r2, b2, g2;
|
||||||
int r1, g1, b1, r2, b2, g2;
|
PyObject *pr, *pg, *pb;
|
||||||
PyObject *pr, *pg, *pb;
|
pr = PySequence_ITEM(first, 0);
|
||||||
pr = PySequence_ITEM(first, 0);
|
pg = PySequence_ITEM(first, 1);
|
||||||
pg = PySequence_ITEM(first, 1);
|
pb = PySequence_ITEM(first, 2);
|
||||||
pb = PySequence_ITEM(first, 2);
|
r1 = PyLong_AsLong(pr);
|
||||||
r1 = PyLong_AsLong(pr);
|
g1 = PyLong_AsLong(pg);
|
||||||
g1 = PyLong_AsLong(pg);
|
b1 = PyLong_AsLong(pb);
|
||||||
b1 = PyLong_AsLong(pb);
|
Py_DECREF(pr);
|
||||||
Py_DECREF(pr);
|
Py_DECREF(pg);
|
||||||
Py_DECREF(pg);
|
Py_DECREF(pb);
|
||||||
Py_DECREF(pb);
|
|
||||||
|
pr = PySequence_ITEM(second, 0);
|
||||||
pr = PySequence_ITEM(second, 0);
|
pg = PySequence_ITEM(second, 1);
|
||||||
pg = PySequence_ITEM(second, 1);
|
pb = PySequence_ITEM(second, 2);
|
||||||
pb = PySequence_ITEM(second, 2);
|
r2 = PyLong_AsLong(pr);
|
||||||
r2 = PyLong_AsLong(pr);
|
g2 = PyLong_AsLong(pg);
|
||||||
g2 = PyLong_AsLong(pg);
|
b2 = PyLong_AsLong(pb);
|
||||||
b2 = PyLong_AsLong(pb);
|
Py_DECREF(pr);
|
||||||
Py_DECREF(pr);
|
Py_DECREF(pg);
|
||||||
Py_DECREF(pg);
|
Py_DECREF(pb);
|
||||||
Py_DECREF(pb);
|
|
||||||
|
return abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2);
|
||||||
return abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(block_getblocks2_doc,
|
PyDoc_STRVAR(block_getblocks2_doc,
|
||||||
"Returns a list of blocks (3 sized tuples).\n\
|
"Returns a list of blocks (3 sized tuples).\n\
|
||||||
\n\
|
\n\
|
||||||
image: A PIL image to base the blocks on.\n\
|
image: A PIL image to base the blocks on.\n\
|
||||||
block_count_per_side: This integer determine the number of blocks the function will return.\n\
|
block_count_per_side: This integer determine the number of blocks the function will return.\n\
|
||||||
@ -101,153 +99,150 @@ If it is 10, for example, 100 blocks will be returns (10 width, 10 height). The
|
|||||||
necessarely cover square areas. The area covered by each block will be proportional to the image\n\
|
necessarely cover square areas. The area covered by each block will be proportional to the image\n\
|
||||||
itself.\n");
|
itself.\n");
|
||||||
|
|
||||||
static PyObject* block_getblocks2(PyObject *self, PyObject *args)
|
static PyObject *block_getblocks2(PyObject *self, PyObject *args) {
|
||||||
{
|
int block_count_per_side, width, height, block_width, block_height, ih;
|
||||||
int block_count_per_side, width, height, block_width, block_height, ih;
|
PyObject *image;
|
||||||
PyObject *image;
|
PyObject *pimage_size, *pwidth, *pheight;
|
||||||
PyObject *pimage_size, *pwidth, *pheight;
|
PyObject *result;
|
||||||
PyObject *result;
|
|
||||||
|
if (!PyArg_ParseTuple(args, "Oi", &image, &block_count_per_side)) {
|
||||||
if (!PyArg_ParseTuple(args, "Oi", &image, &block_count_per_side)) {
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pimage_size = PyObject_GetAttrString(image, "size");
|
||||||
|
pwidth = PySequence_ITEM(pimage_size, 0);
|
||||||
|
pheight = PySequence_ITEM(pimage_size, 1);
|
||||||
|
width = PyLong_AsLong(pwidth);
|
||||||
|
height = PyLong_AsLong(pheight);
|
||||||
|
Py_DECREF(pimage_size);
|
||||||
|
Py_DECREF(pwidth);
|
||||||
|
Py_DECREF(pheight);
|
||||||
|
|
||||||
|
if (!(width && height)) {
|
||||||
|
return PyList_New(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
block_width = max(width / block_count_per_side, 1);
|
||||||
|
block_height = max(height / block_count_per_side, 1);
|
||||||
|
|
||||||
|
result = PyList_New((Py_ssize_t)block_count_per_side * block_count_per_side);
|
||||||
|
if (result == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ih = 0; ih < block_count_per_side; ih++) {
|
||||||
|
int top, bottom, iw;
|
||||||
|
top = min(ih * block_height, height - block_height);
|
||||||
|
bottom = top + block_height;
|
||||||
|
for (iw = 0; iw < block_count_per_side; iw++) {
|
||||||
|
int left, right;
|
||||||
|
PyObject *pbox;
|
||||||
|
PyObject *pmethodname;
|
||||||
|
PyObject *pcrop;
|
||||||
|
PyObject *pblock;
|
||||||
|
|
||||||
|
left = min(iw * block_width, width - block_width);
|
||||||
|
right = left + block_width;
|
||||||
|
pbox = inttuple(4, left, top, right, bottom);
|
||||||
|
pmethodname = PyUnicode_FromString("crop");
|
||||||
|
pcrop = PyObject_CallMethodObjArgs(image, pmethodname, pbox, NULL);
|
||||||
|
Py_DECREF(pmethodname);
|
||||||
|
Py_DECREF(pbox);
|
||||||
|
if (pcrop == NULL) {
|
||||||
|
Py_DECREF(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
pblock = getblock(pcrop);
|
||||||
pimage_size = PyObject_GetAttrString(image, "size");
|
Py_DECREF(pcrop);
|
||||||
pwidth = PySequence_ITEM(pimage_size, 0);
|
if (pblock == NULL) {
|
||||||
pheight = PySequence_ITEM(pimage_size, 1);
|
Py_DECREF(result);
|
||||||
width = PyLong_AsLong(pwidth);
|
|
||||||
height = PyLong_AsLong(pheight);
|
|
||||||
Py_DECREF(pimage_size);
|
|
||||||
Py_DECREF(pwidth);
|
|
||||||
Py_DECREF(pheight);
|
|
||||||
|
|
||||||
if (!(width && height)) {
|
|
||||||
return PyList_New(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
block_width = max(width / block_count_per_side, 1);
|
|
||||||
block_height = max(height / block_count_per_side, 1);
|
|
||||||
|
|
||||||
result = PyList_New(block_count_per_side * block_count_per_side);
|
|
||||||
if (result == NULL) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
PyList_SET_ITEM(result, ih * block_count_per_side + iw, pblock);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (ih=0; ih<block_count_per_side; ih++) {
|
|
||||||
int top, bottom, iw;
|
return result;
|
||||||
top = min(ih*block_height, height-block_height);
|
|
||||||
bottom = top + block_height;
|
|
||||||
for (iw=0; iw<block_count_per_side; iw++) {
|
|
||||||
int left, right;
|
|
||||||
PyObject *pbox;
|
|
||||||
PyObject *pmethodname;
|
|
||||||
PyObject *pcrop;
|
|
||||||
PyObject *pblock;
|
|
||||||
|
|
||||||
left = min(iw*block_width, width-block_width);
|
|
||||||
right = left + block_width;
|
|
||||||
pbox = inttuple(4, left, top, right, bottom);
|
|
||||||
pmethodname = PyUnicode_FromString("crop");
|
|
||||||
pcrop = PyObject_CallMethodObjArgs(image, pmethodname, pbox, NULL);
|
|
||||||
Py_DECREF(pmethodname);
|
|
||||||
Py_DECREF(pbox);
|
|
||||||
if (pcrop == NULL) {
|
|
||||||
Py_DECREF(result);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
pblock = getblock(pcrop);
|
|
||||||
Py_DECREF(pcrop);
|
|
||||||
if (pblock == NULL) {
|
|
||||||
Py_DECREF(result);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
PyList_SET_ITEM(result, ih*block_count_per_side+iw, pblock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(block_avgdiff_doc,
|
PyDoc_STRVAR(block_avgdiff_doc,
|
||||||
"Returns the average diff between first blocks and seconds.\n\
|
"Returns the average diff between first blocks and seconds.\n\
|
||||||
\n\
|
\n\
|
||||||
If the result surpasses limit, limit + 1 is returned, except if less than min_iterations\n\
|
If the result surpasses limit, limit + 1 is returned, except if less than min_iterations\n\
|
||||||
iterations have been made in the blocks.\n");
|
iterations have been made in the blocks.\n");
|
||||||
|
|
||||||
static PyObject* block_avgdiff(PyObject *self, PyObject *args)
|
static PyObject *block_avgdiff(PyObject *self, PyObject *args) {
|
||||||
{
|
PyObject *first, *second;
|
||||||
PyObject *first, *second;
|
int limit, min_iterations;
|
||||||
int limit, min_iterations;
|
Py_ssize_t count;
|
||||||
Py_ssize_t count;
|
int sum, i, result;
|
||||||
int sum, i, result;
|
|
||||||
|
if (!PyArg_ParseTuple(args, "OOii", &first, &second, &limit,
|
||||||
if (!PyArg_ParseTuple(args, "OOii", &first, &second, &limit, &min_iterations)) {
|
&min_iterations)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
count = PySequence_Length(first);
|
||||||
|
if (count != PySequence_Length(second)) {
|
||||||
|
PyErr_SetString(DifferentBlockCountError, "");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (!count) {
|
||||||
|
PyErr_SetString(NoBlocksError, "");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sum = 0;
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
int iteration_count;
|
||||||
|
PyObject *item1, *item2;
|
||||||
|
|
||||||
|
iteration_count = i + 1;
|
||||||
|
item1 = PySequence_ITEM(first, i);
|
||||||
|
item2 = PySequence_ITEM(second, i);
|
||||||
|
sum += diff(item1, item2);
|
||||||
|
Py_DECREF(item1);
|
||||||
|
Py_DECREF(item2);
|
||||||
|
if ((sum > limit * iteration_count) &&
|
||||||
|
(iteration_count >= min_iterations)) {
|
||||||
|
return PyLong_FromLong(limit + 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
count = PySequence_Length(first);
|
|
||||||
if (count != PySequence_Length(second)) {
|
result = sum / count;
|
||||||
PyErr_SetString(DifferentBlockCountError, "");
|
if (!result && sum) {
|
||||||
return NULL;
|
result = 1;
|
||||||
}
|
}
|
||||||
if (!count) {
|
return PyLong_FromLong(result);
|
||||||
PyErr_SetString(NoBlocksError, "");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
sum = 0;
|
|
||||||
for (i=0; i<count; i++) {
|
|
||||||
int iteration_count;
|
|
||||||
PyObject *item1, *item2;
|
|
||||||
|
|
||||||
iteration_count = i + 1;
|
|
||||||
item1 = PySequence_ITEM(first, i);
|
|
||||||
item2 = PySequence_ITEM(second, i);
|
|
||||||
sum += diff(item1, item2);
|
|
||||||
Py_DECREF(item1);
|
|
||||||
Py_DECREF(item2);
|
|
||||||
if ((sum > limit*iteration_count) && (iteration_count >= min_iterations)) {
|
|
||||||
return PyLong_FromLong(limit + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = sum / count;
|
|
||||||
if (!result && sum) {
|
|
||||||
result = 1;
|
|
||||||
}
|
|
||||||
return PyLong_FromLong(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef BlockMethods[] = {
|
static PyMethodDef BlockMethods[] = {
|
||||||
{"getblocks2", block_getblocks2, METH_VARARGS, block_getblocks2_doc},
|
{"getblocks2", block_getblocks2, METH_VARARGS, block_getblocks2_doc},
|
||||||
{"avgdiff", block_avgdiff, METH_VARARGS, block_avgdiff_doc},
|
{"avgdiff", block_avgdiff, METH_VARARGS, block_avgdiff_doc},
|
||||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct PyModuleDef BlockDef = {
|
static struct PyModuleDef BlockDef = {PyModuleDef_HEAD_INIT,
|
||||||
PyModuleDef_HEAD_INIT,
|
"_block",
|
||||||
"_block",
|
NULL,
|
||||||
NULL,
|
-1,
|
||||||
-1,
|
BlockMethods,
|
||||||
BlockMethods,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL};
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
PyObject *
|
PyObject *PyInit__block(void) {
|
||||||
PyInit__block(void)
|
PyObject *m = PyModule_Create(&BlockDef);
|
||||||
{
|
if (m == NULL) {
|
||||||
PyObject *m = PyModule_Create(&BlockDef);
|
return NULL;
|
||||||
if (m == NULL) {
|
}
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
NoBlocksError = PyErr_NewException("_block.NoBlocksError", NULL, NULL);
|
|
||||||
PyModule_AddObject(m, "NoBlocksError", NoBlocksError);
|
|
||||||
DifferentBlockCountError = PyErr_NewException("_block.DifferentBlockCountError", NULL, NULL);
|
|
||||||
PyModule_AddObject(m, "DifferentBlockCountError", DifferentBlockCountError);
|
|
||||||
|
|
||||||
return m;
|
NoBlocksError = PyErr_NewException("_block.NoBlocksError", NULL, NULL);
|
||||||
|
PyModule_AddObject(m, "NoBlocksError", NoBlocksError);
|
||||||
|
DifferentBlockCountError =
|
||||||
|
PyErr_NewException("_block.DifferentBlockCountError", NULL, NULL);
|
||||||
|
PyModule_AddObject(m, "DifferentBlockCountError", DifferentBlockCountError);
|
||||||
|
|
||||||
|
return m;
|
||||||
}
|
}
|
@ -4,7 +4,7 @@
|
|||||||
# which should be included with this package. The terms are also available at
|
# which should be included with this package. The terms are also available at
|
||||||
# http://www.gnu.org/licenses/gpl-3.0.html
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
import os.path as op
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .build import read_changelog_file, filereplace
|
from .build import read_changelog_file, filereplace
|
||||||
@ -48,9 +48,9 @@ def gen(
|
|||||||
if confrepl is None:
|
if confrepl is None:
|
||||||
confrepl = {}
|
confrepl = {}
|
||||||
if confpath is None:
|
if confpath is None:
|
||||||
confpath = op.join(basepath, "conf.tmpl")
|
confpath = Path(basepath, "conf.tmpl")
|
||||||
if changelogtmpl is None:
|
if changelogtmpl is None:
|
||||||
changelogtmpl = op.join(basepath, "changelog.tmpl")
|
changelogtmpl = Path(basepath, "changelog.tmpl")
|
||||||
changelog = read_changelog_file(changelogpath)
|
changelog = read_changelog_file(changelogpath)
|
||||||
tix = tixgen(tixurl)
|
tix = tixgen(tixurl)
|
||||||
rendered_logs = []
|
rendered_logs = []
|
||||||
@ -62,13 +62,13 @@ def gen(
|
|||||||
rendered = CHANGELOG_FORMAT.format(version=log["version"], date=log["date_str"], description=description)
|
rendered = CHANGELOG_FORMAT.format(version=log["version"], date=log["date_str"], description=description)
|
||||||
rendered_logs.append(rendered)
|
rendered_logs.append(rendered)
|
||||||
confrepl["version"] = changelog[0]["version"]
|
confrepl["version"] = changelog[0]["version"]
|
||||||
changelog_out = op.join(basepath, "changelog.rst")
|
changelog_out = Path(basepath, "changelog.rst")
|
||||||
filereplace(changelogtmpl, changelog_out, changelog="\n".join(rendered_logs))
|
filereplace(changelogtmpl, changelog_out, changelog="\n".join(rendered_logs))
|
||||||
if op.exists(confpath):
|
if Path(confpath).exists():
|
||||||
conf_out = op.join(basepath, "conf.py")
|
conf_out = Path(basepath, "conf.py")
|
||||||
filereplace(confpath, conf_out, **confrepl)
|
filereplace(confpath, conf_out, **confrepl)
|
||||||
# Call the sphinx_build function, which is the same as doing sphinx-build from cli
|
# Call the sphinx_build function, which is the same as doing sphinx-build from cli
|
||||||
try:
|
try:
|
||||||
sphinx_build([basepath, destpath])
|
sphinx_build([str(basepath), str(destpath)])
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
print("Sphinx called sys.exit(), but we're cancelling it because we don't actually want to exit")
|
print("Sphinx called sys.exit(), but we're cancelling it because we don't actually want to exit")
|
||||||
|
14
package.py
14
package.py
@ -71,7 +71,7 @@ def package_debian_distribution(distribution):
|
|||||||
version = "{}~{}".format(app_version, distribution)
|
version = "{}~{}".format(app_version, distribution)
|
||||||
destpath = op.join("build", "dupeguru-{}".format(version))
|
destpath = op.join("build", "dupeguru-{}".format(version))
|
||||||
srcpath = op.join(destpath, "src")
|
srcpath = op.join(destpath, "src")
|
||||||
packages = ["hscommon", "core", "qtlib", "qt", "send2trash", "hsaudiotag"]
|
packages = ["hscommon", "core", "qtlib", "qt", "send2trash"]
|
||||||
copy_files_to_package(srcpath, packages, with_so=False)
|
copy_files_to_package(srcpath, packages, with_so=False)
|
||||||
os.mkdir(op.join(destpath, "modules"))
|
os.mkdir(op.join(destpath, "modules"))
|
||||||
copy_all(op.join("core", "pe", "modules", "*.*"), op.join(destpath, "modules"))
|
copy_all(op.join("core", "pe", "modules", "*.*"), op.join(destpath, "modules"))
|
||||||
@ -122,14 +122,7 @@ def package_arch():
|
|||||||
# need to include them).
|
# need to include them).
|
||||||
print("Packaging for Arch")
|
print("Packaging for Arch")
|
||||||
srcpath = op.join("build", "dupeguru-arch")
|
srcpath = op.join("build", "dupeguru-arch")
|
||||||
packages = [
|
packages = ["hscommon", "core", "qtlib", "qt", "send2trash"]
|
||||||
"hscommon",
|
|
||||||
"core",
|
|
||||||
"qtlib",
|
|
||||||
"qt",
|
|
||||||
"send2trash",
|
|
||||||
"hsaudiotag",
|
|
||||||
]
|
|
||||||
copy_files_to_package(srcpath, packages, with_so=True)
|
copy_files_to_package(srcpath, packages, with_so=True)
|
||||||
shutil.copy(op.join("images", "dgse_logo_128.png"), srcpath)
|
shutil.copy(op.join("images", "dgse_logo_128.png"), srcpath)
|
||||||
debopts = json.load(open(op.join("pkg", "arch", "dupeguru.json")))
|
debopts = json.load(open(op.join("pkg", "arch", "dupeguru.json")))
|
||||||
@ -233,7 +226,8 @@ def main():
|
|||||||
return
|
return
|
||||||
print("Packaging dupeGuru with UI qt")
|
print("Packaging dupeGuru with UI qt")
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
package_windows()
|
package_debian()
|
||||||
|
# package_windows()
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
package_macos()
|
package_macos()
|
||||||
else:
|
else:
|
||||||
|
@ -2,178 +2,165 @@
|
|||||||
* Created On: 2010-01-31
|
* Created On: 2010-01-31
|
||||||
* Copyright 2014 Hardcoded Software (http://www.hardcoded.net)
|
* Copyright 2014 Hardcoded Software (http://www.hardcoded.net)
|
||||||
*
|
*
|
||||||
* This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
* This software is licensed under the "BSD" License as described in the
|
||||||
* which should be included with this package. The terms are also available at
|
*"LICENSE" file, which should be included with this package. The terms are also
|
||||||
* http://www.hardcoded.net/licenses/bsd_license
|
*available at http://www.hardcoded.net/licenses/bsd_license
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#define PY_SSIZE_T_CLEAN
|
#define PY_SSIZE_T_CLEAN
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
|
||||||
/* It seems like MS VC defines min/max already */
|
/* It seems like MS VC defines min/max already */
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
static int
|
static int max(int a, int b) { return b > a ? b : a; }
|
||||||
max(int a, int b)
|
|
||||||
{
|
|
||||||
return b > a ? b : a;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int min(int a, int b) { return b < a ? b : a; }
|
||||||
min(int a, int b)
|
|
||||||
{
|
|
||||||
return b < a ? b : a;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static PyObject*
|
static PyObject *getblock(PyObject *image, int width, int height) {
|
||||||
getblock(PyObject *image, int width, int height)
|
int pixel_count, red, green, blue, bytes_per_line;
|
||||||
{
|
PyObject *pred, *pgreen, *pblue;
|
||||||
int pixel_count, red, green, blue, bytes_per_line;
|
PyObject *result;
|
||||||
PyObject *pred, *pgreen, *pblue;
|
|
||||||
PyObject *result;
|
red = green = blue = 0;
|
||||||
|
pixel_count = width * height;
|
||||||
red = green = blue = 0;
|
if (pixel_count) {
|
||||||
pixel_count = width * height;
|
PyObject *sipptr, *bits_capsule, *pi;
|
||||||
if (pixel_count) {
|
char *s;
|
||||||
PyObject *sipptr, *bits_capsule, *pi;
|
int i;
|
||||||
char *s;
|
|
||||||
int i;
|
pi = PyObject_CallMethod(image, "bytesPerLine", NULL);
|
||||||
|
bytes_per_line = PyLong_AsLong(pi);
|
||||||
pi = PyObject_CallMethod(image, "bytesPerLine", NULL);
|
Py_DECREF(pi);
|
||||||
bytes_per_line = PyLong_AsLong(pi);
|
|
||||||
Py_DECREF(pi);
|
sipptr = PyObject_CallMethod(image, "bits", NULL);
|
||||||
|
bits_capsule = PyObject_CallMethod(sipptr, "ascapsule", NULL);
|
||||||
sipptr = PyObject_CallMethod(image, "bits", NULL);
|
Py_DECREF(sipptr);
|
||||||
bits_capsule = PyObject_CallMethod(sipptr, "ascapsule", NULL);
|
s = (char *)PyCapsule_GetPointer(bits_capsule, NULL);
|
||||||
Py_DECREF(sipptr);
|
Py_DECREF(bits_capsule);
|
||||||
s = (char *)PyCapsule_GetPointer(bits_capsule, NULL);
|
/* Qt aligns all its lines on 32bit, which means that if the number of bytes
|
||||||
Py_DECREF(bits_capsule);
|
*per line for image is not divisible by 4, there's going to be crap
|
||||||
/* Qt aligns all its lines on 32bit, which means that if the number of bytes per
|
*inserted in "s" We have to take this into account when calculating offsets
|
||||||
* line for image is not divisible by 4, there's going to be crap inserted in "s"
|
**/
|
||||||
* We have to take this into account when calculating offsets
|
for (i = 0; i < height; i++) {
|
||||||
**/
|
int j;
|
||||||
for (i=0; i<height; i++) {
|
for (j = 0; j < width; j++) {
|
||||||
int j;
|
int offset;
|
||||||
for (j=0; j<width; j++) {
|
unsigned char r, g, b;
|
||||||
int offset;
|
|
||||||
unsigned char r, g, b;
|
offset = i * bytes_per_line + j * 3;
|
||||||
|
r = s[offset];
|
||||||
offset = i * bytes_per_line + j * 3;
|
g = s[offset + 1];
|
||||||
r = s[offset];
|
b = s[offset + 2];
|
||||||
g = s[offset + 1];
|
red += r;
|
||||||
b = s[offset + 2];
|
green += g;
|
||||||
red += r;
|
blue += b;
|
||||||
green += g;
|
}
|
||||||
blue += b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
red /= pixel_count;
|
|
||||||
green /= pixel_count;
|
|
||||||
blue /= pixel_count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pred = PyLong_FromLong(red);
|
red /= pixel_count;
|
||||||
pgreen = PyLong_FromLong(green);
|
green /= pixel_count;
|
||||||
pblue = PyLong_FromLong(blue);
|
blue /= pixel_count;
|
||||||
result = PyTuple_Pack(3, pred, pgreen, pblue);
|
}
|
||||||
Py_DECREF(pred);
|
|
||||||
Py_DECREF(pgreen);
|
pred = PyLong_FromLong(red);
|
||||||
Py_DECREF(pblue);
|
pgreen = PyLong_FromLong(green);
|
||||||
|
pblue = PyLong_FromLong(blue);
|
||||||
return result;
|
result = PyTuple_Pack(3, pred, pgreen, pblue);
|
||||||
|
Py_DECREF(pred);
|
||||||
|
Py_DECREF(pgreen);
|
||||||
|
Py_DECREF(pblue);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* block_getblocks(QImage image, int block_count_per_side) -> [(int r, int g, int b), ...]
|
/* block_getblocks(QImage image, int block_count_per_side) -> [(int r, int g,
|
||||||
|
*int b), ...]
|
||||||
*
|
*
|
||||||
* Compute blocks out of `image`. Note the use of min/max when compes the time of computing widths
|
* Compute blocks out of `image`. Note the use of min/max when compes the time
|
||||||
* and heights and positions. This is to cover the case where the width or height of the image is
|
*of computing widths and heights and positions. This is to cover the case where
|
||||||
* smaller than `block_count_per_side`. In these cases, blocks will be, of course, 1 pixel big. But
|
*the width or height of the image is smaller than `block_count_per_side`. In
|
||||||
* also, because all compared block lists are required to be of the same size, any block that has
|
*these cases, blocks will be, of course, 1 pixel big. But also, because all
|
||||||
* no pixel to be assigned to will simply be assigned the last pixel. This is why we have
|
*compared block lists are required to be of the same size, any block that has
|
||||||
* min(..., height-block_height-1) and stuff like that.
|
* no pixel to be assigned to will simply be assigned the last pixel. This is
|
||||||
**/
|
*why we have min(..., height-block_height-1) and stuff like that.
|
||||||
static PyObject*
|
**/
|
||||||
block_getblocks(PyObject *self, PyObject *args)
|
static PyObject *block_getblocks(PyObject *self, PyObject *args) {
|
||||||
{
|
int block_count_per_side, width, height, block_width, block_height, ih;
|
||||||
int block_count_per_side, width, height, block_width, block_height, ih;
|
PyObject *image;
|
||||||
PyObject *image;
|
PyObject *pi;
|
||||||
PyObject *pi;
|
PyObject *result;
|
||||||
PyObject *result;
|
|
||||||
|
if (!PyArg_ParseTuple(args, "Oi", &image, &block_count_per_side)) {
|
||||||
if (!PyArg_ParseTuple(args, "Oi", &image, &block_count_per_side)) {
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pi = PyObject_CallMethod(image, "width", NULL);
|
||||||
|
width = PyLong_AsLong(pi);
|
||||||
|
Py_DECREF(pi);
|
||||||
|
pi = PyObject_CallMethod(image, "height", NULL);
|
||||||
|
height = PyLong_AsLong(pi);
|
||||||
|
Py_DECREF(pi);
|
||||||
|
|
||||||
|
if (!(width && height)) {
|
||||||
|
return PyList_New(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
block_width = max(width / block_count_per_side, 1);
|
||||||
|
block_height = max(height / block_count_per_side, 1);
|
||||||
|
|
||||||
|
result = PyList_New((Py_ssize_t)block_count_per_side * block_count_per_side);
|
||||||
|
if (result == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ih = 0; ih < block_count_per_side; ih++) {
|
||||||
|
int top, iw;
|
||||||
|
top = min(ih * block_height, height - block_height - 1);
|
||||||
|
for (iw = 0; iw < block_count_per_side; iw++) {
|
||||||
|
int left;
|
||||||
|
PyObject *pcrop;
|
||||||
|
PyObject *pblock;
|
||||||
|
|
||||||
|
left = min(iw * block_width, width - block_width - 1);
|
||||||
|
pcrop = PyObject_CallMethod(image, "copy", "iiii", left, top, block_width,
|
||||||
|
block_height);
|
||||||
|
if (pcrop == NULL) {
|
||||||
|
Py_DECREF(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
pblock = getblock(pcrop, block_width, block_height);
|
||||||
pi = PyObject_CallMethod(image, "width", NULL);
|
Py_DECREF(pcrop);
|
||||||
width = PyLong_AsLong(pi);
|
if (pblock == NULL) {
|
||||||
Py_DECREF(pi);
|
Py_DECREF(result);
|
||||||
pi = PyObject_CallMethod(image, "height", NULL);
|
|
||||||
height = PyLong_AsLong(pi);
|
|
||||||
Py_DECREF(pi);
|
|
||||||
|
|
||||||
if (!(width && height)) {
|
|
||||||
return PyList_New(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
block_width = max(width / block_count_per_side, 1);
|
|
||||||
block_height = max(height / block_count_per_side, 1);
|
|
||||||
|
|
||||||
result = PyList_New(block_count_per_side * block_count_per_side);
|
|
||||||
if (result == NULL) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
PyList_SET_ITEM(result, ih * block_count_per_side + iw, pblock);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (ih=0; ih<block_count_per_side; ih++) {
|
|
||||||
int top, iw;
|
return result;
|
||||||
top = min(ih*block_height, height-block_height-1);
|
|
||||||
for (iw=0; iw<block_count_per_side; iw++) {
|
|
||||||
int left;
|
|
||||||
PyObject *pcrop;
|
|
||||||
PyObject *pblock;
|
|
||||||
|
|
||||||
left = min(iw*block_width, width-block_width-1);
|
|
||||||
pcrop = PyObject_CallMethod(image, "copy", "iiii", left, top, block_width, block_height);
|
|
||||||
if (pcrop == NULL) {
|
|
||||||
Py_DECREF(result);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
pblock = getblock(pcrop, block_width, block_height);
|
|
||||||
Py_DECREF(pcrop);
|
|
||||||
if (pblock == NULL) {
|
|
||||||
Py_DECREF(result);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
PyList_SET_ITEM(result, ih*block_count_per_side+iw, pblock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef BlockMethods[] = {
|
static PyMethodDef BlockMethods[] = {
|
||||||
{"getblocks", block_getblocks, METH_VARARGS, ""},
|
{"getblocks", block_getblocks, METH_VARARGS, ""},
|
||||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct PyModuleDef BlockDef = {
|
static struct PyModuleDef BlockDef = {PyModuleDef_HEAD_INIT,
|
||||||
PyModuleDef_HEAD_INIT,
|
"_block_qt",
|
||||||
"_block_qt",
|
NULL,
|
||||||
NULL,
|
-1,
|
||||||
-1,
|
BlockMethods,
|
||||||
BlockMethods,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL};
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
PyObject *
|
PyObject *PyInit__block_qt(void) {
|
||||||
PyInit__block_qt(void)
|
PyObject *m = PyModule_Create(&BlockDef);
|
||||||
{
|
if (m == NULL) {
|
||||||
PyObject *m = PyModule_Create(&BlockDef);
|
return NULL;
|
||||||
if (m == NULL) {
|
}
|
||||||
return NULL;
|
return m;
|
||||||
}
|
|
||||||
return m;
|
|
||||||
}
|
}
|
@ -9,6 +9,7 @@
|
|||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QCoreApplication, QSize
|
from PyQt5.QtCore import Qt, QCoreApplication, QSize
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
@ -34,7 +35,9 @@ class ErrorReportDialog(QDialog):
|
|||||||
self._setupUi()
|
self._setupUi()
|
||||||
name = QCoreApplication.applicationName()
|
name = QCoreApplication.applicationName()
|
||||||
version = QCoreApplication.applicationVersion()
|
version = QCoreApplication.applicationVersion()
|
||||||
error_text = "Application Name: {}\nVersion: {}\n\n{}".format(name, version, error)
|
error_text = "Application Name: {}\nVersion: {}\nPython: {}\nOperating System: {}\n\n{}".format(
|
||||||
|
name, version, platform.python_version(), platform.platform(), error
|
||||||
|
)
|
||||||
# Under windows, we end up with an error report without linesep if we don't mangle it
|
# Under windows, we end up with an error report without linesep if we don't mangle it
|
||||||
error_text = error_text.replace("\n", os.linesep)
|
error_text = error_text.replace("\n", os.linesep)
|
||||||
self.errorTextEdit.setPlainText(error_text)
|
self.errorTextEdit.setPlainText(error_text)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Send2Trash>=1.3.0
|
Send2Trash>=1.3.0
|
||||||
sphinx>=3.0.0
|
sphinx>=3.0.0
|
||||||
polib>=1.1.0
|
polib>=1.1.0
|
||||||
mutagen>=1.45.1
|
mutagen>=1.44.0
|
||||||
distro>=1.5.0
|
distro>=1.5.0
|
||||||
PyQt5 >=5.14.1,<6.0; sys_platform != 'linux'
|
PyQt5 >=5.14.1,<6.0; sys_platform != 'linux'
|
||||||
pywin32>=228; sys_platform == 'win32'
|
pywin32>=228; sys_platform == 'win32'
|
@ -31,12 +31,15 @@ python_requires = >=3.6
|
|||||||
install_requires =
|
install_requires =
|
||||||
Send2Trash>=1.3.0
|
Send2Trash>=1.3.0
|
||||||
polib>=1.1.0
|
polib>=1.1.0
|
||||||
hsaudiotag3k>=1.1.3*
|
mutagen>=1.45.1
|
||||||
distro>=1.5.0
|
distro>=1.5.0
|
||||||
PyQt5 >=5.14.1,<6.0; sys_platform != 'linux'
|
PyQt5 >=5.14.1,<6.0; sys_platform != 'linux'
|
||||||
pywin32>=228; sys_platform == 'win32'
|
pywin32>=228; sys_platform == 'win32'
|
||||||
|
setup_requires =
|
||||||
|
sphinx>=3.0.0
|
||||||
tests_require =
|
tests_require =
|
||||||
pytest >=6,<7
|
pytest >=6,<7
|
||||||
|
include_package_data = true
|
||||||
|
|
||||||
[options.entry_points]
|
[options.entry_points]
|
||||||
console_scripts =
|
console_scripts =
|
||||||
|
11
setup.py
11
setup.py
@ -3,7 +3,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
exts = [
|
exts = [
|
||||||
Extension(
|
Extension(
|
||||||
"_block",
|
"core.pe._block",
|
||||||
[
|
[
|
||||||
str(Path("core", "pe", "modules", "block.c")),
|
str(Path("core", "pe", "modules", "block.c")),
|
||||||
str(Path("core", "pe", "modules", "common.c")),
|
str(Path("core", "pe", "modules", "common.c")),
|
||||||
@ -11,19 +11,16 @@ exts = [
|
|||||||
include_dirs=[str(Path("core", "pe", "modules"))],
|
include_dirs=[str(Path("core", "pe", "modules"))],
|
||||||
),
|
),
|
||||||
Extension(
|
Extension(
|
||||||
"_cache",
|
"core.pe._cache",
|
||||||
[
|
[
|
||||||
str(Path("core", "pe", "modules", "cache.c")),
|
str(Path("core", "pe", "modules", "cache.c")),
|
||||||
str(Path("core", "pe", "modules", "common.c")),
|
str(Path("core", "pe", "modules", "common.c")),
|
||||||
],
|
],
|
||||||
include_dirs=[str(Path("core", "pe", "modules"))],
|
include_dirs=[str(Path("core", "pe", "modules"))],
|
||||||
),
|
),
|
||||||
Extension("_block_qt", [str(Path("qt", "pe", "modules", "block.c"))]),
|
Extension("qt.pe._block_qt", [str(Path("qt", "pe", "modules", "block.c"))]),
|
||||||
]
|
]
|
||||||
|
|
||||||
headers = [str(Path("core", "pe", "modules", "common.h"))]
|
headers = [str(Path("core", "pe", "modules", "common.h"))]
|
||||||
|
|
||||||
setup(
|
setup(ext_modules=exts, headers=headers)
|
||||||
ext_modules=exts,
|
|
||||||
headers=headers,
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user