Skip to content

Instantly share code, notes, and snippets.

@Cryolitia
Created April 27, 2025 01:36
Show Gist options
  • Select an option

  • Save Cryolitia/ede57996b501fd0c3a787427a9c5e783 to your computer and use it in GitHub Desktop.

Select an option

Save Cryolitia/ede57996b501fd0c3a787427a9c5e783 to your computer and use it in GitHub Desktop.
youdao-dict-deepin-patch
diff --git a/app/plugins/youdao/pyquery/pyquery.py b/app/plugins/youdao/pyquery/pyquery.py
index 0d2e781..c24de0f 100644
--- a/app/plugins/youdao/pyquery/pyquery.py
+++ b/app/plugins/youdao/pyquery/pyquery.py
@@ -12,6 +12,8 @@ import inspect
import types
import sys
+if not hasattr(inspect, 'getargspec'):
+ inspect.getargspec = inspect.getfullargspec
PY3k = sys.version_info >= (3,)
diff --git a/app/plugins/youdao/window.py b/app/plugins/youdao/window.py
index 1b8b433..9e5099a 100644
--- a/app/plugins/youdao/window.py
+++ b/app/plugins/youdao/window.py
@@ -287,8 +287,8 @@ class SplashWindow(Window):
geometry = desktop.screenGeometry(desktop.primaryScreen())
x = geometry.x() + (geometry.width() - self.width())/2
y = geometry.y() + (geometry.height() - self.height())/2
- self.setX(x)
- self.setY(y)
+ self.setX(int(x))
+ self.setY(int(y))
self.show()
@QtCore.pyqtSlot()
@@ -326,8 +326,8 @@ class AboutWindow(Window):
geometry = desktop.screenGeometry(desktop.primaryScreen())
x = geometry.x() + (geometry.width() - self.width())/2
y = geometry.y() + (geometry.height() - self.height())/2
- self.setX(x)
- self.setY(y)
+ self.setX(int(x))
+ self.setY(int(y))
self.show()
class Menu(Window):
diff --git a/dae/plugins.py b/dae/plugins.py
index 6189850..39421f7 100644
--- a/dae/plugins.py
+++ b/dae/plugins.py
@@ -20,11 +20,24 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import imp
+import importlib
import os
import sys
import traceback
+import importlib.util
+import importlib.machinery
+
+def load_source(modname, filename):
+ loader = importlib.machinery.SourceFileLoader(modname, filename)
+ spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
+ module = importlib.util.module_from_spec(spec)
+ # The module is always executed and not cached in sys.modules.
+ # Uncomment the following line to cache the module.
+ # sys.modules[module.__name__] = module
+ loader.exec_module(module)
+ return module
+
class PluginsManager(object):
def __init__(self, plugindir, load=True):
@@ -50,7 +63,7 @@ class PluginsManager(object):
if path is None:
return False
sys.path.insert(0, path)
- plugin = imp.load_source(plugin_name, os.path.join(path, '__init__.py'))
+ plugin = load_source(plugin_name, os.path.join(path, '__init__.py'))
sys.path = sys.path[1:]
self.loaded_plugins[plugin_name] = plugin
return plugin
diff --git a/dae/window.py b/dae/window.py
index 907939c..062af83 100644
--- a/dae/window.py
+++ b/dae/window.py
@@ -641,5 +641,5 @@ class Window(ShadowWindow):
geometry = screen.availableGeometry()
x = geometry.x() + (geometry.width() - self.width())/2
y = geometry.y() + (geometry.height() - self.height())/2
- self.move(x, y)
+ self.move(int(x), int(y))
self.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment