Exemplo n.º 1
0
 def c_install(self, args, recursion=False):
     if args:
         if args.startswith('-i '):
             args = args[3:]
             optignore = True
         else:
             optignore = False
         dependencies = DependenciesParser(self.core)
         args = re.sub(r'([a-zA-Z0-9_:])([ ]+)([a-zA-Z0-9_:])', r'\1,\3',
                       args)
         addons = [
             addon.strip()
             for addon in list(reader([args], skipinitialspace=True))[0]
         ]
         with Progress('{task.completed}/{task.total}',
                       '|',
                       BarColumn(bar_width=None),
                       '|',
                       auto_refresh=False,
                       console=self.console) as progress:
             task = progress.add_task('', total=len(addons))
             while not progress.finished:
                 for addon in addons:
                     installed, name, version, deps = self.core.add_addon(
                         addon, optignore)
                     if installed:
                         self.table.add_row('[green]Installed[/green]',
                                            Text(name, no_wrap=True),
                                            Text(version, no_wrap=True))
                         if not recursion:
                             dependencies.add_dependency(deps)
                     else:
                         self.table.add_row(
                             '[bold black]Already installed[/bold black]',
                             Text(name, no_wrap=True),
                             Text(version, no_wrap=True))
                     progress.update(task, advance=1, refresh=True)
         self.console.print(self.table)
         dependencies = dependencies.parse_dependency()
         if dependencies:
             self.setup_table()
             self.console.print('Installing dependencies:')
             self.c_install(dependencies, recursion=True)
     else:
         self.console.print(
             '[green]Usage:[/green]\n\tThis command accepts a space-separated list of links as an arg'
             'ument.[bold white]\n\tFlags:[/bold white]\n\t\t[bold white]-i[/bold white] - Disable th'
             'e client version check.\n[bold green]Supported URL:[/bold green]\n\thttps://www.cursefo'
             'rge.com/wow/addons/\[addon_name] [bold white]|[/bold white] cf:\[addon_name]\n\thttps:/'
             '/www.wowinterface.com/downloads/\[addon_name] [bold white]|[/bold white] wowi:\[addon_i'
             'd]\n\thttps://www.tukui.org/addons.php?id=\[addon_id] [bold white]|[/bold white] tu:\[a'
             'ddon_id]\n\thttps://www.tukui.org/classic-addons.php?id=\[addon_id] [bold white]|[/bold'
             ' white] tuc:\[addon_id]\n\thttps://github.com/\[username]/\[repository_name] [bold whit'
             'e]|[/bold white] gh:\[username]/\[repository_name]\n\tElvUI [bold white]|[/bold white] '
             'ElvUI:Dev\n\tTukui\n\tShadow&Light:Dev',
             highlight=False)
Exemplo n.º 2
0
 def c_show(self, args):
     args = args.strip()
     if args.startswith('dependencies'):
         addons = sorted(list(filter(lambda k: k['URL'].startswith('https://www.curseforge.com/wow/addons/'),
                                     self.core.config['Addons'])), key=lambda k: k['Name'].lower())
         self.core.bulk_check(addons)
         for addon in addons:
             dependencies = DependenciesParser(self.core)
             name, _, _, _, _, _, _, _, _, _, deps, _ = self.core.update_addon(addon['URL'], False, False)
             dependencies.add_dependency(deps)
             deps = dependencies.parse_dependency(output=True)
             if len(deps) > 0:
                 self.console.print(f'[green]{name}[/green]\n{", ".join(deps)}')
Exemplo n.º 3
0
 def c_update(self, args, addline=False, update=True, force=False, provider=False, reversecompact=False):
     compact = not self.core.config['CompactMode'] if reversecompact else self.core.config['CompactMode']
     if len(self.core.cfCache) > 0 or len(self.core.wowiCache) > 0:
         self.core.cfCache = {}
         self.core.wowiCache = {}
         self.core.checksumCache = {}
     if args:
         addons = self.parse_args(args)
         compacted = -1
     else:
         addons = sorted(self.core.config['Addons'], key=lambda k: k['Name'].lower())
         compacted = 0
     exceptions = []
     dependencies = DependenciesParser(self.core)
     with Progress('{task.completed:.0f}/{task.total}', '|', BarColumn(bar_width=None), '|',
                   auto_refresh=False, console=None if self.headless else self.console) as progress:
         task = progress.add_task('', total=len(addons))
         if not args:
             self.core.bulk_check(addons)
             self.core.bulk_check_checksum(addons, progress)
         while not progress.finished:
             for addon in addons:
                 try:
                     name, authors, versionnew, versionold, uiversion, modified, blocked, source, sourceurl,\
                         changelog, deps, dstate = self.core.update_addon(
                             addon if isinstance(addon, str) else addon['URL'], update, force)
                     dependencies.add_dependency(deps)
                     if provider:
                         source = f' [bold white]{source}[/bold white]'
                     else:
                         source = ''
                     if versionold:
                         if versionold == versionnew:
                             if modified:
                                 self.table.add_row(f'[bold red]Modified[/bold red]{source}',
                                                    self.parse_link(name, sourceurl, authors=authors),
                                                    self.parse_link(versionold, changelog, dstate,
                                                                    uiversion=uiversion))
                             else:
                                 if compact and compacted > -1:
                                     compacted += 1
                                 else:
                                     self.table.add_row(f'[green]Up-to-date[/green]{source}',
                                                        self.parse_link(name, sourceurl, authors=authors),
                                                        self.parse_link(versionold, changelog, dstate,
                                                                        uiversion=uiversion))
                         else:
                             if modified or blocked:
                                 self.table.add_row(f'[bold red]Update suppressed[/bold red]{source}',
                                                    self.parse_link(name, sourceurl, authors=authors),
                                                    self.parse_link(versionold, changelog, dstate,
                                                                    uiversion=uiversion))
                             else:
                                 version = self.parse_link(versionnew, changelog, dstate, uiversion=uiversion)
                                 version.stylize('yellow')
                                 self.table.add_row(
                                     f'[yellow]{"Updated" if update else "Update available"}[/yellow]{source}',
                                     self.parse_link(name, sourceurl, authors=authors),
                                     version)
                     else:
                         self.table.add_row(f'[bold black]Not installed[/bold black]{source}',
                                            Text(addon, no_wrap=True),
                                            Text('', no_wrap=True))
                 except Exception as e:
                     exceptions.append(e)
                 progress.update(task, advance=1 if args else 0.5, refresh=True)
     if addline:
         self.console.print('')
     self.console.print(self.table)
     dependencies = dependencies.parse_dependency()
     if dependencies and update:
         self.setup_table()
         self.console.print('Installing dependencies:')
         self.c_install(dependencies, recursion=True)
     if compacted > 0:
         self.console.print(f'Additionally [green]{compacted}[/green] addons are up-to-date.')
     if len(addons) == 0:
         self.console.print('Apparently there are no addons installed by CurseBreaker.\n'
                            'Command [green]import[/green] might be used to detect already installed addons.')
     if len(exceptions) > 0:
         self.handle_exception(exceptions, False)