예제 #1
0
 def importMacro(self, path, file_name, isCore=False):
     lname = file_name.lower()
     if lname.endswith('.fcmacro'):
         macro = build_macro_package(path, file_name, isCore, install_path=path)
         flags.apply_predefined_flags(macro)
         analyseInstalledMacro(macro)
         return macro
예제 #2
0
    def getMacroList(self):

        macros = []
        install_dir = get_macro_path()
        default_icon = utils.path_to_url(
            get_resource_path('html', 'img', 'package_macro.svg'))

        try:
            content = http_get(self.url, timeout=45)
            if content:
                data = json.loads(content)
                wiki = get_page_content_from_json(data)

                for m_link in MACRO_LINK.finditer(wiki):

                    name = m_link.group('name').replace(' ', '_')
                    label = m_link.group('label')
                    description = m_link.group('description')

                    icon = m_link.group('icon')
                    if icon:
                        icon = self.wiki + '/Special:Redirect/file/' + icon.replace(
                            ' ', '_')
                    else:
                        icon = default_icon

                    pkg = PackageInfo(
                        key=name,
                        installDir=install_dir,
                        installFile=Path(install_dir, name + '.FCMacro'),
                        name=name,
                        title=label,
                        description=description,
                        icon=icon,
                        isCore=False,
                        type='Macro',
                        isGit=False,
                        isWiki=True,
                        markedAsSafe=False,
                        categories=[tr('Uncategorized')],
                        date=None,
                        version=None,
                        readmeUrl='{0}/Macro_{1}?origin=*'.format(
                            self.wiki, name),
                        readmeFormat='html')
                    flags.apply_predefined_flags(pkg)
                    macros.append(pkg)

        except:
            traceback.print_exc(file=sys.stderr)

        return macros
예제 #3
0
 def importMod(self, path, installDir, isCore):
     pdir = installDir.name
     if installDir.is_dir():
         wbKey = utils.get_workbench_key(pdir)
         wb = self.workbenches.get(wbKey)
         pkg = PackageInfo(key=wbKey,
                           type='Workbench' if wb else 'Mod',
                           name=pdir,
                           isCore=isCore,
                           installDir=installDir,
                           icon=self.getModIcon(pdir, installDir, wbKey,
                                                wb),
                           title=wb.MenuText if wb else pdir,
                           description=wb.ToolTip if wb else pdir,
                           categories=utils.get_workbench_categories(wb),
                           isGit=Path(installDir, '.git').is_dir())
         flags.apply_predefined_flags(pkg)
         analyseInstalledMod(pkg)
         return pkg
예제 #4
0
 def getMacroList(self):
     install_dir = get_macro_path()
     macros = []
     path = self.downloadMacroList()
     if path:
         workers = []
         for entry in path.glob('**/*'):
             if '.git' in entry.name.lower():
                 continue
             if entry.name.lower().endswith('.fcmacro'):
                 worker = Worker(build_macro_package,
                                 entry,
                                 entry.stem,
                                 is_git=True,
                                 install_path=Path(install_dir, entry.name),
                                 base_path=entry.relative_to(path).parent)
                 worker.start()
                 workers.append(worker)
         macros = [flags.apply_predefined_flags(w.get()) for w in workers]
     return macros
예제 #5
0
    def modFromSubModule(self,
                         mod,
                         index,
                         syncManifest=False,
                         syncReadme=False):

        repo = self.RepoImpl(mod['url'])

        if syncManifest:
            repo.syncManifestHttp()

        if syncReadme:
            repo.syncReadmeHttp()

        icon_path = "Resources/icons/{0}.svg".format(mod['name'])

        index_key = mod['url']
        if index_key.endswith('.git'):
            index_key = index_key[:-4]

        indexed = index.get(index_key)
        if indexed:
            icon_path = indexed.get('icon', icon_path)

        if repo.manifest:
            general = repo.manifest.general
            if general and general.iconPath:
                icon_path = repo.manifest.iconPath

        install_dir = Path(get_mod_path(), mod['name'])

        icon_sources = utils.get_workbench_icon_candidates(
            mod['name'], repo.getRawFileUrl(), icon_path, install_dir)

        pkg_info = {
            'name': mod['name'],
            'title': mod['name'],
            'description': None,
            'categories': None,
            'iconSources': icon_sources,
            'readmeUrl': repo.getReadmeUrl(),
            'readmeFormat': repo.getReadmeFormat()
        }

        # Copy data from index
        if indexed:
            pkg_info['title'] = indexed.get('title', pkg_info['title'])
            pkg_info['description'] = indexed.get('description',
                                                  pkg_info['description'])
            pkg_info['categories'] = indexed.get('categories',
                                                 pkg_info['categories'])
            pkg_info['author'] = indexed.get('author')
            flag = indexed.get('flag')
            if flag:
                iflags = pkg_info.get('flags', {})
                iflags['obsolete'] = True
                pkg_info['flags'] = iflags

        # Copy all manifest attributes
        if repo.manifest:
            repo.manifest.getData(pkg_info)

        # Override some things
        pkg_info.update(
            dict(key=mod['name'],
                 type='Workbench',
                 isCore=False,
                 installDir=install_dir,
                 icon=icon_sources[0],
                 categories=utils.get_workbench_categories_from_string(
                     mod['name'], pkg_info['categories']),
                 isGit=True,
                 git=mod['url']))

        pkg = PackageInfo(**pkg_info)
        flags.apply_predefined_flags(pkg)
        return pkg