o
    Uh5                  
   @   s   d dl Z d dlZd dlmZ e dZdZdZdZdZ	dZ
d	Zd
ZdZdee deee ee eeeef  f fddZdddZdefddZedkrUee  dS dS )    N)Optionals   diff --git a/(.*) b/(.*)s   diff --git a/s   Binary files   rename froms	   rename tos   @@   +   -    linesreturnc                 C   s  g }g }g }d } }}d}d }}	| D ]}
|
 trI|dur0|| || |||	f t|
}|s9J |d}d}d }}	d}d}q|
 trU|rUd}d}q|
 trc|rc|
dd }q|
 try|ry|snJ |d|
dd  7 }q|
 t	r|s|rd}d}q|
 t
r|r|d	7 }q|
 tr|r|	d	7 }	q|
 ts|rd}q|dur|| || |||	f |||fS )
zParse a git style diff or patch to generate diff stats.

    Args:
      lines: list of byte string lines from the diff to be parsed
    Returns: A tuple (names, is_binary, counts) of three lists
    FNr      T   s    => %s
      )
startswith_GIT_HEADER_STARTappend_git_header_namesearchgroup_GIT_BINARY_START_GIT_RENAMEFROM_START_GIT_RENAMETO_START_GIT_CHUNK_START_GIT_ADDED_START_GIT_DELETED_START_GIT_UNCHANGED_START)r   names	nametypescountsin_patch_chunkin_git_header
binaryfilecurrentfileaddeddeletedlinem r$   l/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/dulwich/contrib/diffstat.py_parse_patch;   sT   	









r&   P   c                 C   s>  t | \}}}g }g }d}d}t|D ]"\}	}
||	 \}	}||	 || t|t|
}t||	| }qd}tt|}t|D ]\}	}||	 }dt|d d t|d d }dt|d d }|sd}t|d }td	|| }||k rd
||	  d||	   }n\t||	 | | }t||	 | | }d }}||	 dkrt|}|dkrd|  k rdk rn nd}||	 dkrt|}|dkrd|  k rdk rn nd}d
t| dt|  }||t	||	 t||	 ||	  d|f 7 }qB||t	||	 df 7 }qB|dt|t
|t
|f 7 }|S )a}  Generate summary statistics from a git style diff ala
       (git diff tag1 tag2 --stat).

    Args:
      lines: list of byte string "lines" from the diff to be parsed
      max_width: maximum line length for generating the summary
                 statistics (default 80)
    Returns: A byte string that lists the changed files with change
             counts and histogram.
    r       s    %-asciis   s | %s   s %s
s   s | %s
)r(   r(   r(   r   r   r   r   s   Bins4    %d files changed, %d insertions(+), %d deletions(-))r&   	enumerater   maxlenstrencodefloatintbytessum)r   	max_widthr   r   r   insertdeletenamelenmaxdiffifilenamedoutputstatlennr   format	binformathistwidth	histwidthiratiodratioiwidthdwidthr$   r$   r%   diffstatr   sp   

  

rG   c                  C   s   t j} tt jdkr;| d }d}t|d}| }W d    n1 s$w   Y  |d}t|}t|d dS d}d}t|d}||krPtd	 dS td
 td t|d td t|d dS )Nr   r(   rb   
zutf-8r   s  
diff --git a/docs/qt512.7_remove_bad_workaround.patch b/docs/qt512.7_remove_bad_workaround.patch
new file mode 100644
index 00000000..64e34192
--- /dev/null
+++ b/docs/qt512.7_remove_bad_workaround.patch
@@ -0,0 +1,15 @@
+--- qtbase/src/gui/kernel/qwindow.cpp.orig     2019-12-12 09:15:59.000000000 -0500
++++ qtbase/src/gui/kernel/qwindow.cpp  2020-01-10 10:36:53.000000000 -0500
+@@ -218,12 +218,6 @@
+     QGuiApplicationPrivate::window_list.removeAll(this);
+     if (!QGuiApplicationPrivate::is_app_closing)
+         QGuiApplicationPrivate::instance()->modalWindowList.removeOne(this);
+-
+-    // focus_window is normally cleared in destroy(), but the window may in
+-    // some cases end up becoming the focus window again. Clear it again
+-    // here as a workaround. See QTBUG-75326.
+-    if (QGuiApplicationPrivate::focus_window == this)
+-        QGuiApplicationPrivate::focus_window = 0;
+ }
+
+ void QWindowPrivate::init(QScreen *targetScreen)
diff --git a/docs/testplugin_v017.zip b/docs/testplugin_v017.zip
new file mode 100644
index 00000000..a4cf4c4c
Binary files /dev/null and b/docs/testplugin_v017.zip differ
diff --git a/ci_scripts/macgddeploy.py b/ci_scripts/gddeploy.py
similarity index 73%
rename from ci_scripts/macgddeploy.py
rename to ci_scripts/gddeploy.py
index a512d075..f9dacd33 100644
--- a/ci_scripts/macgddeploy.py
+++ b/ci_scripts/gddeploy.py
@@ -1,19 +1,32 @@
 #!/usr/bin/env python3

 import os
+import sys
 import subprocess
 import datetime
 import shutil
+import glob

 gparent = os.path.expandvars('$GDRIVE_DIR')
 grefresh_token = os.path.expandvars('$GDRIVE_REFRESH_TOKEN')

-travis_branch = os.path.expandvars('$TRAVIS_BRANCH')
-travis_commit = os.path.expandvars('$TRAVIS_COMMIT')
-travis_build_number = os.path.expandvars('$TRAVIS_BUILD_NUMBER')
+if sys.platform.lower().startswith('darwin'):
+    travis_branch = os.path.expandvars('$TRAVIS_BRANCH')
+    travis_commit = os.path.expandvars('$TRAVIS_COMMIT')
+    travis_build_number = os.path.expandvars('$TRAVIS_BUILD_NUMBER')
+
+    origfilename = './bin/Sigil.tar.xz'
+    newfilename = './bin/Sigil-{}-{}-build_num-{}.tar.xz'.format(travis_branch, travis_commit[:7],travis_build_number)
+else:
+    appveyor_branch = os.path.expandvars('$APPVEYOR_REPO_BRANCH')
+    appveyor_commit = os.path.expandvars('$APPVEYOR_REPO_COMMIT')
+    appveyor_build_number = os.path.expandvars('$APPVEYOR_BUILD_NUMBER')
+    names = glob.glob('.\installer\Sigil-*-Setup.exe')
+    if not names:
+        exit(1)
+    origfilename = names[0]
+    newfilename = '.\installer\Sigil-{}-{}-build_num-{}-Setup.exe'.format(appveyor_branch, appveyor_commit[:7], appveyor_build_number)

-origfilename = './bin/Sigil.tar.xz'
-newfilename = './bin/Sigil-{}-{}-build_num-{}.tar.xz'.format(travis_branch, travis_commit[:7],travis_build_number)
 shutil.copy2(origfilename, newfilename)

 folder_name = datetime.date.today()
diff --git a/docs/qt512.6_backport_009abcd_fix.patch b/docs/qt512.6_backport_009abcd_fix.patch
deleted file mode 100644
index f4724347..00000000
--- a/docs/qt512.6_backport_009abcd_fix.patch
+++ /dev/null
@@ -1,26 +0,0 @@
---- qtbase/src/widgets/kernel/qwidget.cpp.orig 2019-11-08 10:57:07.000000000 -0500
-+++ qtbase/src/widgets/kernel/qwidget.cpp      2019-12-11 12:32:24.000000000 -0500
-@@ -8934,6 +8934,23 @@
-         }
-     }
-     switch (event->type()) {
-+    case QEvent::PlatformSurface: {
-+        // Sync up QWidget's view of whether or not the widget has been created
-+        switch (static_cast<QPlatformSurfaceEvent*>(event)->surfaceEventType()) {
-+        case QPlatformSurfaceEvent::SurfaceCreated:
-+            if (!testAttribute(Qt::WA_WState_Created))
-+                create();
-+            break;
-+        case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
-+            if (testAttribute(Qt::WA_WState_Created)) {
-+                // Child windows have already been destroyed by QWindow,
-+                // so we skip them here.
-+                destroy(false, false);
-+            }
-+            break;
-+        }
-+        break;
-+    }
-     case QEvent::MouseMove:
-         mouseMoveEvent((QMouseEvent*)event);
-         break;
diff --git a/docs/Building_Sigil_On_MacOSX.txt b/docs/Building_Sigil_On_MacOSX.txt
index 3b41fd80..64914c78 100644
--- a/docs/Building_Sigil_On_MacOSX.txt
+++ b/docs/Building_Sigil_On_MacOSX.txt
@@ -113,7 +113,7 @@ install_name_tool -add_rpath @loader_path/../../Frameworks ./bin/Sigil.app/Content
 
 # To test if the newly bundled python 3 version of Sigil is working properly ypou can do the following:
 
-1. download testplugin_v014.zip from https://github.com/Sigil-Ebook/Sigil/tree/master/docs
+1. download testplugin_v017.zip from https://github.com/Sigil-Ebook/Sigil/tree/master/docs
 2. open Sigil.app to the normal nearly blank template epub it generates when opened
 3. use Plugins->Manage Plugins menu and make sure the "Use Bundled Python" checkbox is checked
 4. use the "Add Plugin" button to navigate to and add testplugin.zip and then hit "Okay" to exit the Manage Plugins Dialog
s}   docs/qt512.7_remove_bad_workaround.patch            | 15 ++++++++++++
 docs/testplugin_v017.zip                            | Bin
 ci_scripts/macgddeploy.py => ci_scripts/gddeploy.py |  0 
 docs/qt512.6_backport_009abcd_fix.patch             | 26 ---------------------
 docs/Building_Sigil_On_MacOSX.txt                   |  2 +-
 5 files changed, 16 insertions(+), 27 deletions(-)zself test passedzself test failedz	Received:z	Expected:)	sysargvr,   openreadsplitrG   printdecode)rL   diffpathdatafr   resultselftest
testoutputr$   r$   r%   main   s.   

xrX   __main__)r'   )rerK   typingr   compiler   r   r   r   r   r   r   r   r   listr1   tupleboolr0   r&   rG   rX   __name__exitr$   r$   r$   r%   <module>   s.   #
 

7N  