├── README.md ├── data ├── a.py ├── b.py ├── hello_world_game │ └── main.go ├── info.txt ├── my_game.go ├── rock_paper_scissors_game │ └── code.go ├── simon_says_game │ └── file.go └── spiderGame.py ├── get_game_data.py └── project.txt /README.md: -------------------------------------------------------------------------------- 1 | # Python-Scripting-Project 2 | 3 | # 💻 Launch Your Software Development Career Today! 4 | 5 | 🎓 **No degree? No problem!** My program equips you with everything you need to break into tech and land an entry-level software development role. 6 | 7 | 🚀 **Why Join?** 8 | - 💼 **$70k+ starting salary potential** 9 | - 🕐 **Self-paced:** Complete on your own time 10 | - 🤑 **Affordable:** Low risk compared to expensive bootcamps or degrees 11 | - 🎯 **45,000+ job openings** in the market 12 | 13 | 👉 **[Start your journey today!](https://techwithtim.net/dev)** 14 | No experience needed—just your determination. Future-proof your career and unlock six-figure potential like many of our students have! 15 | -------------------------------------------------------------------------------- /data/a.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Python-Scripting-Project/9559f1ab7a4e5a7dd86767414e2424affa548bd1/data/a.py -------------------------------------------------------------------------------- /data/b.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Python-Scripting-Project/9559f1ab7a4e5a7dd86767414e2424affa548bd1/data/b.py -------------------------------------------------------------------------------- /data/hello_world_game/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Hello world") 7 | } 8 | -------------------------------------------------------------------------------- /data/info.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Python-Scripting-Project/9559f1ab7a4e5a7dd86767414e2424affa548bd1/data/info.txt -------------------------------------------------------------------------------- /data/my_game.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Rock paper scissors") 7 | } 8 | -------------------------------------------------------------------------------- /data/rock_paper_scissors_game/code.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Rock paper scissors"); 7 | } -------------------------------------------------------------------------------- /data/simon_says_game/file.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Simon says") 7 | } 8 | -------------------------------------------------------------------------------- /data/spiderGame.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Python-Scripting-Project/9559f1ab7a4e5a7dd86767414e2424affa548bd1/data/spiderGame.py -------------------------------------------------------------------------------- /get_game_data.py: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | import shutil 4 | from subprocess import PIPE, run 5 | import sys 6 | 7 | 8 | GAME_DIR_PATTERN = "game" 9 | GAME_CODE_EXTENSION = ".go" 10 | GAME_COMPILE_COMMAND = ["go", "build"] 11 | 12 | 13 | def find_all_game_paths(source): 14 | game_paths = [] 15 | 16 | for root, dirs, files in os.walk(source): 17 | for directory in dirs: 18 | if GAME_DIR_PATTERN in directory.lower(): 19 | path = os.path.join(source, directory) 20 | game_paths.append(path) 21 | 22 | break 23 | 24 | return game_paths 25 | 26 | 27 | def get_name_from_paths(paths, to_strip): 28 | new_names = [] 29 | for path in paths: 30 | _, dir_name = os.path.split(path) 31 | new_dir_name = dir_name.replace(to_strip, "") 32 | new_names.append(new_dir_name) 33 | 34 | return new_names 35 | 36 | 37 | def create_dir(path): 38 | if not os.path.exists(path): 39 | os.mkdir(path) 40 | 41 | 42 | def copy_and_overwrite(source, dest): 43 | if os.path.exists(dest): 44 | shutil.rmtree(dest) 45 | shutil.copytree(source, dest) 46 | 47 | 48 | def make_json_metadata_file(path, game_dirs): 49 | data = { 50 | "gameNames": game_dirs, 51 | "numberOfGames": len(game_dirs) 52 | } 53 | 54 | with open(path, "w") as f: 55 | json.dump(data, f) 56 | 57 | 58 | def compile_game_code(path): 59 | code_file_name = None 60 | for root, dirs, files in os.walk(path): 61 | for file in files: 62 | if file.endswith(GAME_CODE_EXTENSION): 63 | code_file_name = file 64 | break 65 | 66 | break 67 | 68 | if code_file_name is None: 69 | return 70 | 71 | command = GAME_COMPILE_COMMAND + [code_file_name] 72 | run_command(command, path) 73 | 74 | 75 | def run_command(command, path): 76 | cwd = os.getcwd() 77 | os.chdir(path) 78 | 79 | result = run(command, stdout=PIPE, stdin=PIPE, universal_newlines=True) 80 | print("compile result", result) 81 | 82 | os.chdir(cwd) 83 | 84 | def main(source, target): 85 | cwd = os.getcwd() 86 | source_path = os.path.join(cwd, source) 87 | target_path = os.path.join(cwd, target) 88 | 89 | game_paths = find_all_game_paths(source_path) 90 | new_game_dirs = get_name_from_paths(game_paths, "_game") 91 | 92 | create_dir(target_path) 93 | 94 | for src, dest in zip(game_paths, new_game_dirs): 95 | dest_path = os.path.join(target_path, dest) 96 | copy_and_overwrite(src, dest_path) 97 | compile_game_code(dest_path) 98 | 99 | json_path = os.path.join(target_path, "metadata.json") 100 | make_json_metadata_file(json_path, new_game_dirs) 101 | 102 | 103 | if __name__ == "__main__": 104 | args = sys.argv 105 | if len(args) != 3: 106 | raise Exception("You must pass a source and target directory - only.") 107 | 108 | source, target = args[1:] 109 | main(source, target) 110 | -------------------------------------------------------------------------------- /project.txt: -------------------------------------------------------------------------------- 1 | Assumptions: 2 | 3 | - data directory contains many files and directories 4 | - you are only interested in the games contaiend in this directory 5 | - each game is stored in a directory that contains the word "game" 6 | - each game directory contains a single .go file that must be compiled before it can be run 7 | 8 | 9 | Project Steps/Requirements: 10 | 11 | - Find all game directories from /data 12 | - Create a new /games directory 13 | - Copy and remove the "game" suffix of all games into the /games directory 14 | - Create a .json file with the information about the games 15 | - Compile all of the game code 16 | - Run all of the game code- --------------------------------------------------------------------------------