fix(backup): pylint fixes
This commit is contained in:
parent
932c9f61ed
commit
35ffec9c3f
1 changed files with 18 additions and 4 deletions
|
@ -6,11 +6,10 @@
|
|||
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
|
||||
|
||||
import json
|
||||
import itertools
|
||||
|
||||
from redbot.core import commands
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core.utils.chat_formatting import text_to_file
|
||||
from redbot.core.utils.chat_formatting import error, text_to_file
|
||||
|
||||
class Backup(commands.Cog):
|
||||
"""A utility to make reinstalling repositories and cogs after migrating the bot far easier."""
|
||||
|
@ -33,10 +32,10 @@ class Backup(commands.Cog):
|
|||
"""Export your installed repositories and cogs to a file."""
|
||||
downloader = ctx.bot.get_cog("Downloader")
|
||||
if downloader is None:
|
||||
await ctx.send(f"You do not have the `Downloader` cog loaded.\nPlease run `{ctx.prefix}load downloader` and try again.")
|
||||
await ctx.send(error(f"You do not have the `Downloader` cog loaded. Please run `{ctx.prefix}load downloader` and try again."))
|
||||
return
|
||||
|
||||
all_repos = list(downloader._repo_manager.repos)
|
||||
all_repos = list(downloader._repo_manager.repos) # pylint: disable=protected-access
|
||||
|
||||
export_data = []
|
||||
|
||||
|
@ -56,3 +55,18 @@ class Backup(commands.Cog):
|
|||
export_data.append(repo_dict)
|
||||
|
||||
await ctx.send(file=text_to_file(json.dumps(export_data, indent=4), 'backup.json'))
|
||||
|
||||
@backup.command(name='import')
|
||||
@commands.is_owner()
|
||||
async def backup_import(self, ctx: commands.Context, json: str = None):
|
||||
"""Import your installed repositories and cogs from an export."""
|
||||
if json is None:
|
||||
json = await ctx.message.attachments[0].read()
|
||||
if json is None:
|
||||
await ctx.send(error("Please provide a valid JSON export."))
|
||||
return
|
||||
|
||||
downloader = ctx.bot.get_cog("Downloader")
|
||||
if downloader is None:
|
||||
await ctx.send(error(f"You do not have the `Downloader` cog loaded. Please run `{ctx.prefix}load downloader` and try again."))
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue