Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mesonium
gajim
Commits
720855a0
Commit
720855a0
authored
4 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
GUI: Improve finding modules
parent
88376197
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gajim/gui/__init__.py
+26
-11
26 additions, 11 deletions
gajim/gui/__init__.py
with
26 additions
and
11 deletions
gajim/gui/__init__.py
+
26
−
11
View file @
720855a0
...
...
@@ -13,26 +13,41 @@ def __init__(self, name, fallback=None):
if
fallback
is
not
None
:
self
.
_fallback_path
=
Path
(
__file__
).
parent
.
parent
/
fallback
self
.
_suffix
=
'
pyc
'
if
sys
.
platform
==
'
win32
'
else
'
py
'
def
find_spec
(
self
,
fullname
,
_path
,
_target
=
None
):
if
not
fullname
.
startswith
(
'
gajim.gui
'
):
return
None
_namespace
,
module_name
=
fullname
.
rsplit
(
'
.
'
,
1
)
module_path
=
self
.
_path
/
f
'
{
module_name
}
.
{
self
.
_suffix
}
'
if
not
module_path
.
exists
():
if
self
.
_fallback_path
is
None
:
return
None
module_path
=
self
.
_fallback_path
/
f
'
{
module_name
}
.
{
self
.
_suffix
}
'
if
not
module_path
.
exists
():
return
None
module_path
=
self
.
_find_module
(
module_name
)
if
module_path
is
None
:
return
None
spec
=
importlib
.
util
.
spec_from_file_location
(
fullname
,
module_path
)
return
spec
def
_find_module
(
self
,
module_name
):
module_path
=
self
.
_path
/
f
'
{
module_name
}
.py
'
if
module_path
.
exists
():
return
module_path
module_path
=
self
.
_path
/
f
'
{
module_name
}
.pyc
'
if
module_path
.
exists
():
return
module_path
if
self
.
_fallback_path
is
None
:
return
None
module_path
=
self
.
_fallback_path
/
f
'
{
module_name
}
.py
'
if
module_path
.
exists
():
return
module_path
module_path
=
self
.
_fallback_path
/
f
'
{
module_name
}
.pyc
'
if
module_path
.
exists
():
return
module_path
return
None
def
init
(
name
,
fallback
=
None
):
sys
.
meta_path
.
append
(
GUIFinder
(
name
,
fallback
=
fallback
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment