def load_media(resourcesPath): resources = { "Images": {}, "Icons": {}, "Themes": {}, "Mapping": {}, "Glyphs": {}, "External": {} } # Load Icons iconsPath = os.path.join(resourcesPath, "Media", "Icons") if os.path.exists(iconsPath): for dirpath, dirnames, filenames in os.walk(iconsPath): for filename in filenames: iconPath = os.path.join(dirpath, filename) name = build_resource_key(iconPath[len(iconsPath):]) resources["Icons"][name] = iconPath # Load Images imagesPath = os.path.join(resourcesPath, "Media", "Images") if os.path.exists(imagesPath): for dirpath, dirnames, filenames in os.walk(imagesPath): for filename in filenames: imagePath = os.path.join(dirpath, filename) name = build_resource_key(imagePath[len(imagesPath):]) resources["Images"][name] = imagePath # Load Themes themesPaths = [ os.path.join(resourcesPath, "Media", "Themes") ] + QtGui.QIcon.themeSearchPaths() for themesPath in themesPaths: if not os.path.exists(themesPath): continue for name in os.listdir(themesPath): descriptor = os.path.join(themesPath, name, "index.theme") if os.path.exists(descriptor): resources["Themes"][name] = IconTheme(name, "pix", os.path.join(themesPath, name)) # Load Glyphs glyphsNames = ["FontAwesome", "WebHostingHub-Glyphs"] for glyphNames in glyphsNames: gly = glyph.QtGlyph(glyphNames) resources["Glyphs"][gly.name()] = gly resources["Themes"][gly.name()] = IconTheme(gly.name(), "glyph", glyphNames) # Load Mapping mappingsPath = os.path.join(resourcesPath, "Media", "Mapping") if os.path.exists(mappingsPath): for mappingFileName in os.listdir(mappingsPath): name = os.path.splitext(mappingFileName)[0] file_content, _ = encoding.read(os.path.join(mappingsPath, mappingFileName)) resources["Mapping"][name] = json.loads(file_content) return resources
def readFile(self, filePath): """Read from file""" content, encode = encoding.read(filePath) return content
def readFile(self, file_path): """Read from file""" return encoding.read(file_path)