forked from Mediacore/mediaserver
59 lines
2 KiB
Python
59 lines
2 KiB
Python
# License for this source file
|
|
#
|
|
# Copyright (c) 2014 Miqra Engineering
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
# in the Software without restriction, including without limitation the rights
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
# furnished to do so, subject to the following conditions:
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
# THE SOFTWARE
|
|
|
|
import os,sys
|
|
import pkg_resources
|
|
|
|
class Resources(object): # needs to be explicitly subclassed from object to get the __new__ method to work
|
|
|
|
PACKAGE = __name__
|
|
|
|
|
|
@classmethod
|
|
def SetPackage(cls, package):
|
|
"""
|
|
Set the package from which to load localization data
|
|
"""
|
|
cls.PACKAGE = package
|
|
pass
|
|
|
|
|
|
@classmethod
|
|
def string_from(cls,path):
|
|
return pkg_resources.resource_string(cls.PACKAGE, path)
|
|
|
|
@classmethod
|
|
def filename(cls,path):
|
|
return pkg_resources.resource_filename(cls.PACKAGE, path)
|
|
|
|
@classmethod
|
|
def stream_from(cls,path):
|
|
return pkg_resources.resource_stream(cls.PACKAGE, path)
|
|
|
|
@classmethod
|
|
def isdir(cls,path):
|
|
return pkg_resources.resource_isdir(cls.PACKAGE,path)
|
|
|
|
@classmethod
|
|
def exists(cls,path):
|
|
return pkg_resources.resource_exists(cls.PACKAGE,path)
|
|
|
|
@classmethod
|
|
def listdir(cls,path):
|
|
return pkg_resources.resource_listdir(cls.PACKAGE,path)
|