Last active
June 14, 2016 18:22
-
-
Save brad-anton/16cd63abc9304fb065bc14298999c7fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __process_manifest_json(self, fullpath): | |
"""The manifest.json files contain less information | |
then the Preferences files, so we'll use this menthod | |
on if the preferences file is unavaible""" | |
extension = fullpath.split(self.os.SLASH)[-3] | |
if path.isfile(fullpath): | |
with open(fullpath, 'rb') as f: | |
manifest = json.load(f) | |
name = manifest['name'] | |
version = manifest['version'] | |
return name, version, extension | |
def __check_app_directory(self, extension_dirs): | |
"""Checks each directory in self.dirs for stuff | |
""" | |
extensions = [] | |
for root, dirs, files in walk(extension_dirs): | |
for f in files: | |
if f == 'manifest.json': | |
manifest = path.join(root, f) | |
name, version, extension = self.__process_manifest_json(manifest) | |
if name[0] == '_': | |
# Check locale for more friendlier name | |
locale_paths = [ '_locales{0}en_US{0}messages.json'.format(self.os.SLASH), | |
'_locales{0}en{0}messages.json'.format(self.os.SLASH)] | |
for locale_path in locale_paths: | |
locale_json = path.join(root, locale_path) | |
if path.isfile(locale_json): | |
with open(locale_json, 'rb') as f: | |
locale_manifest = json.load(f) | |
if 'appName' in locale_manifest: | |
if 'message' in locale_manifest['appName']: | |
name = locale_manifest['appName']['message'] | |
elif 'extName' in locale_manifest: | |
if 'message' in locale_manifest['extName']: | |
name = locale_manifest['extName']['message'] | |
elif 'app_name' in locale_manifest: | |
if 'message' in locale_manifest['app_name']: | |
name = locale_manifest['app_name']['message'] | |
#e = Extension(self.os.CHROME_NAME, name, version, None, extension) | |
e = Extension(name, version, None, extension) | |
extensions.append(e.todict()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment