Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
db06e17e
Commit
db06e17e
authored
Apr 26, 2010
by
Luci Stanescu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ApplicationData class and made resource paths unicode friendly
parent
4cdce257
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
5 deletions
+28
-5
resources.py
blink/resources.py
+28
-5
No files found.
blink/resources.py
View file @
db06e17e
...
...
@@ -3,22 +3,45 @@
"""Provide access to Blink's resources"""
__all__
=
[
'Resources'
]
__all__
=
[
'
ApplicationData'
,
'
Resources'
]
import
os
import
platform
import
sys
from
blink.util
import
classproperty
class
DirectoryContextManager
(
str
):
class
DirectoryContextManager
(
unicode
):
def
__enter__
(
self
):
self
.
directory
=
os
.
getcwd
()
self
.
directory
=
os
.
getcwd
u
()
os
.
chdir
(
self
)
def
__exit__
(
self
,
type
,
value
,
traceback
):
os
.
chdir
(
self
.
directory
)
class
ApplicationData
(
object
):
"""Provide access to user data"""
_cached_directory
=
None
@
classproperty
def
directory
(
cls
):
if
cls
.
_cached_directory
is
None
:
if
platform
.
system
()
==
'Darwin'
:
from
Foundation
import
NSApplicationSupportDirectory
,
NSSearchPathForDirectoriesInDomains
,
NSUserDomainMask
cls
.
_cached_directory
=
NSSearchPathForDirectoriesInDomains
(
NSApplicationSupportDirectory
,
NSUserDomainMask
,
True
)[
0
]
elif
platform
.
system
()
==
'Windows'
:
cls
.
_cached_directory
=
os
.
path
.
join
(
os
.
environ
[
'APPDATA'
],
'Blink'
)
.
decode
(
sys
.
getfilesystemencoding
())
else
:
cls
.
_cached_directory
=
os
.
path
.
expanduser
(
'~/.blink'
)
.
decode
(
sys
.
getfilesystemencoding
())
return
DirectoryContextManager
(
cls
.
_cached_directory
)
@
classmethod
def
get
(
cls
,
resource
):
return
os
.
path
.
join
(
cls
.
directory
,
resource
)
class
Resources
(
object
):
"""Provide access to Blink's resources"""
...
...
@@ -37,9 +60,9 @@ class Resources(object):
else
:
application_directory
=
binary_directory
if
os
.
path
.
exists
(
os
.
path
.
join
(
application_directory
,
'resources'
,
'blink.ui'
)):
cls
.
_cached_directory
=
os
.
path
.
join
(
application_directory
,
'resources'
)
cls
.
_cached_directory
=
os
.
path
.
join
(
application_directory
,
'resources'
)
.
decode
(
sys
.
getfilesystemencoding
())
else
:
cls
.
_cached_directory
=
os
.
path
.
join
(
application_directory
,
'share'
,
'blink'
)
cls
.
_cached_directory
=
os
.
path
.
join
(
application_directory
,
'share'
,
'blink'
)
.
decode
(
sys
.
getfilesystemencoding
())
return
DirectoryContextManager
(
cls
.
_cached_directory
)
@
classmethod
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment