Package: treefrog
treefrogDescriptionOrganize the Slippi game files in your filesystem according to their attributes.InstallationWithPythoninstalled, simply run the following command to add the package to your project.python-mpipinstalltreefrogUsageModuleCurrently, the package supports organizing the files according to a supplied ordering of parsers, flattening the files against the supplied root folder, and renaming all the files according to their attributes. These may be accomplished programmatically with the use of theTreeclass or through the command-line interface.OrganizeTheorganizemethod serves the purpose of moving each game file found (deeply or otherwise) under the root folder to its proper location according to the supplied ordering of parsers. If no ordering is given, then treefrog will use its default. Here is a simple example of calling this method:fromtreefrogimportTreefromtreefrog.parse.parsersimportyear,month,matchup,stageordering=(year,month,matchup,stage)# An iterable of the desired levels of the hierarchywithTree("slp/",show_progress=True)astree:tree.organize(ordering)# Organize the files into subfolders according to the supplied attributesFeel free to provide your own logic for formatting the names of the folders at a particular level with a corresponding iterable of functions:fromtreefrogimportTreefromtreefrog.parse.parsersimportyear,month,stagefromtreefrog.parse.utilsimportcharacter_name,most_used_character,opponent,userdefordered_matchup(game):p1=user(game,"DTB#566")p2=opponent(game,"DTB#566")returnf"{character_name(most_used_character(p1))}vs{character_name(most_used_character(p2))}"ordering=(year,month,lambdagame:opponent(game,"DTB#566").netplay.code,ordered_matchup,stage)withTree("slp/",show_progress=True)astree:tree.organize(ordering)Any custom parser you provide will need to be aCallablethat takes in aGameinstance and returns astr.Further, you can use cascading methods to simplify your programming. Each of the methodsorganize,flatten, andrenamewill return a reference to the instance object on which it was called. Something like this:tree.organize().rename()will both organize and rename the game files.FlattenTheflattenmethod serves the simple purpose of moving each game file found (deeply or otherwise) under the root folder back to the root folder itself. Here's an example of what calling this method may look like:fromtreefrogimportTreetree=Tree("slp/")tree.flatten().resolve()Note that you do not have to useTreewith a context manager. If you do not use thewithkeyword as in the first couple of examples, you will need to end your operations with a call to theresolvemethod in order to see the changes reflected in your filesystem.RenameTherenamemethod simply renames each game file according to its attributes. Without a rename function supplied, treefrog will use thedefault_filenamefunction found in thetreefrog.renamemodule. Alternatively, you may provide your own rename function as shown below:fromtreefrogimportTreefromtreefrog.parse.parsersimportstage,timestampfromtreefrog.parse.utilsimportcharacter_name,charactersdefcreate_filename(game:Game):p1,p2=tuple(characters(game))returnf"{timestamp(game)}-{character_name(p1)}vs{character_name(p2)}-{stage(game)}.slp"withTree("slp/")astree:tree.rename(create_filename=create_filename)Command-LineThis is also command-line program, and can be executed as follows:python -m treefrog [-h] [-g GLOB] [-c NETPLAY_CODE] [-p] [-d] [-o | -f] [-r] root_folderOptions:ArgumentDescriptionroot_folderSlippi folder root path-h, --helpshow this help message and exit-g GLOB, --glob GLOBThe glob pattern to search with-c NETPLAY_CODE, --netplay-code NETPLAY_CODENetplay code (e.g. DTB#566)-p, --show-progressWhether to show a progress bar-d, --default-renameWhether to restore the filenames to their defaults-o, --organizeWhether to organize the folder hierarchy-f, --flattenWhether to flatten your Slippi game files to a shared parent folder-r, --renameWhether to rename the files according to their featuresFor example, the following command will organize all the game files under theslpdirectory with a progress bar.python-mtreefrog"slp"-c"DTB#566"-opFeel free tocheck out the docsfor more information.LicenseThis software is released under the terms ofMIT license.