This Python script automates the process of extracting game data from a specified source directory, organizing it in a new directory, and compiling/running the game code. The script assumes a specific directory structure where games are stored in subdirectories containing the word "game" and each game has a single .go file that needs to be compiled before running.
- The data directory contains various files and directories.
- Games are stored in directories containing the word "game."
- Each game directory has a single .go file that requires compilation before running.
python get_game_data.py <source_directory> <destination_directory>
### Example
```bash
python get_game_data.py data result-
Find all game directories from the source directory:
- Traverse the source directory to identify all directories containing the word "game."
-
Create a new /games directory:
- Create a new directory named "games" in the specified destination directory.
-
Copy and rename game directories:
- Copy each game directory to the /games directory in the destination.
- Remove the "game" suffix from the copied directories.
-
Create a .json file with game information:
- Generate a JSON file containing information about each game.
- Game Name
- Original Directory
- Destination Directory
- Generate a JSON file containing information about each game.
-
Compile all game code:
- For each game directory, compile the single .go file using the
go buildcommand. - Handle any compilation errors and log the results.
- For each game directory, compile the single .go file using the
-
Run all game code:
- Execute the compiled binaries of each game.
- Log the results of each game execution.
<source_directory>: The path to the source directory containing game data.<destination_directory>: The path to the destination directory where the organized data will be stored.
- Python 3.x
- The script assumes the presence of the Go compiler for compiling .go files.
python get_game_data.py data result- Ensure that the Go compiler is installed and available in the system's PATH.
This documentation provides an overview of the script, its purpose, usage, and the steps it takes to extract and compile game data. Users can follow the provided instructions to execute the script with the necessary command-line arguments.