Compare commits
	
		
			2 Commits
		
	
	
		
			29098500e2
			...
			ac7360ffe8
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | ac7360ffe8 | ||
|  | be024389ba | 
							
								
								
									
										20
									
								
								generate
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										20
									
								
								generate
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,20 @@ | |||||||
|  | #!/home/fname/Projects/OpenSource/python-mommy-venv/.venv/bin/python3 | ||||||
|  | import requests | ||||||
|  | from pathlib import Path | ||||||
|  | import json | ||||||
|  |  | ||||||
|  |  | ||||||
|  | CARGO_MOMMY_DATA = "https://raw.githubusercontent.com/diamondburned/go-mommy/refs/heads/main/responses.json" | ||||||
|  | MODULE_PATH = Path("python_mommy_venv") | ||||||
|  |  | ||||||
|  |  | ||||||
|  | if __name__ == "__main__": | ||||||
|  |     print("generating stuff") | ||||||
|  |  | ||||||
|  |     res = requests.get(CARGO_MOMMY_DATA) | ||||||
|  |     if not res.ok: | ||||||
|  |         raise Exception(f"couldn't fetch {CARGO_MOMMY_DATA} ({res.status_code})") | ||||||
|  |      | ||||||
|  |     print(f"writing {Path(MODULE_PATH, 'responses.json')}") | ||||||
|  |     with Path(MODULE_PATH, "responses.json").open("w") as f: | ||||||
|  |         json.dump(res.json(), f, indent=4) | ||||||
| @@ -1,10 +1,6 @@ | |||||||
| import random | import random | ||||||
| import subprocess |  | ||||||
| import sys | import sys | ||||||
| from typing import Optional | from typing import Optional | ||||||
| import os |  | ||||||
| import re |  | ||||||
| import signal |  | ||||||
|  |  | ||||||
| from .config import get_mood, get_template_values | from .config import get_mood, get_template_values | ||||||
| from .static import RESPONSES, Situation, colors | from .static import RESPONSES, Situation, colors | ||||||
|   | |||||||
| @@ -1,6 +1,8 @@ | |||||||
| import sys | import sys | ||||||
| from pathlib import Path | from pathlib import Path | ||||||
| import stat | import stat | ||||||
|  | import subprocess | ||||||
|  | import logging | ||||||
|  |  | ||||||
| import toml | import toml | ||||||
|  |  | ||||||
| @@ -9,6 +11,19 @@ from .static import Situation | |||||||
| from .config import CONFIG_FILES, CONFIG_DIRECTORY, generate_current_configuration | from .config import CONFIG_FILES, CONFIG_DIRECTORY, generate_current_configuration | ||||||
|  |  | ||||||
|  |  | ||||||
|  | logging.basicConfig( | ||||||
|  |     format=' %(message)s', | ||||||
|  |     force=True, | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | log_level = logging.INFO | ||||||
|  |  | ||||||
|  | mommy_logger = logging.getLogger("mommy") | ||||||
|  | mommy_logger.setLevel(logging.INFO) | ||||||
|  | serious_logger = logging.getLogger("serious") | ||||||
|  | serious_logger.setLevel(logging.WARNING) | ||||||
|  |  | ||||||
|  |  | ||||||
| def development(): | def development(): | ||||||
|     s = "positive" |     s = "positive" | ||||||
|     if len(sys.argv) > 1: |     if len(sys.argv) > 1: | ||||||
| @@ -16,6 +31,7 @@ def development(): | |||||||
|  |  | ||||||
|     print(get_response(Situation(s))) |     print(get_response(Situation(s))) | ||||||
|      |      | ||||||
|  |  | ||||||
| def write_current_config(): | def write_current_config(): | ||||||
|     f = "python-mommy.toml" |     f = "python-mommy.toml" | ||||||
|     if len(sys.argv) > 1: |     if len(sys.argv) > 1: | ||||||
| @@ -46,6 +62,7 @@ print(get_response(Situation.POSITIVE if code == 0 else Situation.NEGATIVE)) | |||||||
| exit(code=code) | exit(code=code) | ||||||
| """ | """ | ||||||
|  |  | ||||||
|  |  | ||||||
| PIP_HOOK = """# GENERATED BY MOMMY | PIP_HOOK = """# GENERATED BY MOMMY | ||||||
|     code = main() |     code = main() | ||||||
|  |  | ||||||
| @@ -80,60 +97,85 @@ PIP_HOOK = """# GENERATED BY MOMMY | |||||||
|  |  | ||||||
|     sys.exit(code)""" |     sys.exit(code)""" | ||||||
|  |  | ||||||
| def mommify_pip(path: Path): |  | ||||||
|  | def wrap_interpreter(path: Path): | ||||||
|  |     mommy_logger.info("mommy found a symlink to an interpreter~ %s", str(path)) | ||||||
|  |     serious_logger.info("interpreter symlink found at %s", str(path)) | ||||||
|  |  | ||||||
|  |     inner_symlink = path.parent / ("inner_" + path.name) | ||||||
|  |     symlink_target = path.resolve() | ||||||
|  |  | ||||||
|  |     if inner_symlink.exists(): | ||||||
|  |         raise Exception("inner symlink somehow already exists. This shouldn't happen because of prior checks") | ||||||
|  |  | ||||||
|  |     mommy_logger.info("mommy shows her girl where the interpreter is: %s -> %s", inner_symlink, symlink_target) | ||||||
|  |     serious_logger.info("creating symlink: %s -> %s", inner_symlink, symlink_target) | ||||||
|  |     inner_symlink.symlink_to(symlink_target) | ||||||
|  |  | ||||||
|  |     # remove original symlink | ||||||
|  |     mommy_logger.info("mommy deletes the original interpreter~ %s", path) | ||||||
|  |     serious_logger.info("deleting original symlink %s", path) | ||||||
|  |     path.unlink() | ||||||
|  |  | ||||||
|  |     # creating the wrapper string | ||||||
|  |     mommy_logger.info("mommy writes wrapper script as %s", Path) | ||||||
|  |     serious_logger.info("writing wrapper script at %s", path) | ||||||
|  |     with path.open("w") as f: | ||||||
|  |         f.write(WRAPPER_TEMPLATE.format(inner_bin=str(inner_symlink))) | ||||||
|  |     serious_logger.info("making wrapper script executable") | ||||||
|  |     path.chmod(path.stat().st_mode | stat.S_IEXEC) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def install_pip_hook(path: Path): | ||||||
|     text: str |     text: str | ||||||
|     with path.open("r") as f: |     with path.open("r") as f: | ||||||
|         text = f.read() |         text = f.read() | ||||||
|  |  | ||||||
|     if "# GENERATED BY MOMMY" in text: |     if "# GENERATED BY MOMMY" in text: | ||||||
|         print(f"pip hook already installed in {path}") |         mommy_logger.info("ahhhhh mommy already watches %s", str(path)) | ||||||
|  |         serious_logger.info("pip hook already installed at %s", str(path)) | ||||||
|         return |         return | ||||||
|      |      | ||||||
|     print(f"installing pip hook in {path}") |     mommy_logger.info("mommy needs to keep an eye on this little pip~ %s", str(path)) | ||||||
|  |     serious_logger.info("installing pip hook at %s", str(path)) | ||||||
|  |  | ||||||
|     text = text.replace("sys.exit(main())", PIP_HOOK, 1) |     text = text.replace("sys.exit(main())", PIP_HOOK, 1) | ||||||
|     with path.open("w") as f: |     with path.open("w") as f: | ||||||
|         f.write(text) |         f.write(text) | ||||||
|  |  | ||||||
|  |  | ||||||
| def mommify_venv(): | def mommify_venv(): | ||||||
|  |  | ||||||
|     v = ".venv" |     v = ".venv" | ||||||
|     if len(sys.argv) > 1: |     if len(sys.argv) > 1: | ||||||
|         v = sys.argv[1] |         v = sys.argv[1] | ||||||
|  |  | ||||||
|     bin_path = Path(v, "bin") |     bin_path = Path(v, "bin") | ||||||
|     bin_path = bin_path.resolve() |     bin_path = bin_path.resolve() | ||||||
|     print(bin_path) |  | ||||||
|  |  | ||||||
|     for path in bin_path.iterdir(): |     mommy_logger.info("mommy looks in %s to mess your system up~ <33", str(bin_path)) | ||||||
|         if not path.is_symlink(): |     serious_logger.info("scanning binary directory of venv at %s", str(bin_path)) | ||||||
|             if path.name.startswith("pip"): |  | ||||||
|                 mommify_pip(path) |  | ||||||
|             continue |  | ||||||
|  |  | ||||||
|  |     for path in list(bin_path.iterdir()): | ||||||
|         name = path.name |         name = path.name | ||||||
|         if name.startswith("inner_"): |  | ||||||
|             continue |  | ||||||
|         target = path.resolve() |  | ||||||
|  |  | ||||||
|         print("") |         if path.is_symlink(): | ||||||
|         print(f"modifying {name} ({target})") |             # could be python interpreter | ||||||
|  |             # check for both just to be more expressive | ||||||
|         # creating inner symlink |             if name.startswith("inner_") or not name.startswith("python"): | ||||||
|         inner_bin = Path(bin_path, "inner_" + name) |  | ||||||
|         if inner_bin.exists(): |  | ||||||
|             print(f"inner symlink does already exist {inner_bin}") |  | ||||||
|             print("skipping") |  | ||||||
|                 continue |                 continue | ||||||
|              |              | ||||||
|         print(f"creating symlink: {inner_bin} -> {target}") |             if subprocess.run([str(path), '-c', '"exit()"']) != 0: | ||||||
|         Path(bin_path, "inner_" + name).symlink_to(target) |                 continue | ||||||
|  |  | ||||||
|         # remove original symlink |             wrap_interpreter(path) | ||||||
|         print(f"removing original symlink: {path}") |  | ||||||
|         path.unlink() |  | ||||||
|  |  | ||||||
|         # creating the wrapper string |         else: | ||||||
|         print("writing wrapper script") |             # could be pip | ||||||
|         with path.open("w") as f: |             if not name.startswith("pip"): | ||||||
|             f.write(WRAPPER_TEMPLATE.format(inner_bin=str(inner_bin))) |                 continue | ||||||
|         print("making wrapper script executable") |  | ||||||
|         path.chmod(path.stat().st_mode | stat.S_IEXEC) |             install_pip_hook(path) | ||||||
|  |  | ||||||
|  |         serious_logger.info("") | ||||||
|  |         mommy_logger.info("") | ||||||
|   | |||||||
							
								
								
									
										139
									
								
								python_mommy_venv/responses.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										139
									
								
								python_mommy_venv/responses.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,139 @@ | |||||||
|  | { | ||||||
|  |     "moods": { | ||||||
|  |         "chill": { | ||||||
|  |             "positive": [ | ||||||
|  |                 "*pets your head*", | ||||||
|  |                 "*gives you scritches*", | ||||||
|  |                 "you're such a smart cookie~", | ||||||
|  |                 "that's a good {affectionate_term}~", | ||||||
|  |                 "{role} thinks {pronoun} little {affectionate_term} earned a big hug~", | ||||||
|  |                 "good {affectionate_term}~\n{role}'s so proud of you~", | ||||||
|  |                 "aww, what a good {affectionate_term}~\n{role} knew you could do it~", | ||||||
|  |                 "you did it~!", | ||||||
|  |                 "{role} loves you~", | ||||||
|  |                 "*gives you a sticker*", | ||||||
|  |                 "*boops your nose*", | ||||||
|  |                 "*wraps you in a big hug*", | ||||||
|  |                 "well done~!\n{role} is so happy for you~", | ||||||
|  |                 "what a good {affectionate_term} you are~", | ||||||
|  |                 "that's {role}'s clever little {affectionate_term}~", | ||||||
|  |                 "{role} loves {pronoun} cute little {affectionate_term}~" | ||||||
|  |             ], | ||||||
|  |             "negative": [ | ||||||
|  |                 "{role} believes in you~", | ||||||
|  |                 "don't forget to hydrate~", | ||||||
|  |                 "aww, you'll get it next time~", | ||||||
|  |                 "do you need {role}'s help~?", | ||||||
|  |                 "{role} still loves you no matter what~", | ||||||
|  |                 "oh no did {role}'s little {affectionate_term} make a big mess~?", | ||||||
|  |                 "{role} knows {pronoun} little {affectionate_term} can do better~", | ||||||
|  |                 "{role} still loves you~", | ||||||
|  |                 "{role} thinks {pronoun} little {affectionate_term} is getting close~", | ||||||
|  |                 "it's ok, {role}'s here for you~", | ||||||
|  |                 "oh, darling, you're almost there~", | ||||||
|  |                 "does {role}'s little {affectionate_term} need a bit of a break~?", | ||||||
|  |                 "oops~! {role} loves you anyways~", | ||||||
|  |                 "don't worry, {role} knows you can do it~" | ||||||
|  |             ] | ||||||
|  |         }, | ||||||
|  |         "thirsty": { | ||||||
|  |             "spiciness": "thirsty", | ||||||
|  |             "positive": [ | ||||||
|  |                 "*tugs your leash*\nthat's a VERY good {affectionate_term}~", | ||||||
|  |                 "*runs {pronoun} fingers through your hair* good {affectionate_term}~ keep going~", | ||||||
|  |                 "*smooches your forehead*\ngood job~", | ||||||
|  |                 "*nibbles on your ear*\nthat's right~\nkeep going~", | ||||||
|  |                 "*pats your butt*\nthat's a good {affectionate_term}~", | ||||||
|  |                 "*drags {pronoun} nail along your cheek*\nsuch a good {affectionate_term}~", | ||||||
|  |                 "*bites {pronoun} lip*\nmhmm~", | ||||||
|  |                 "give {pronoun} a kiss~", | ||||||
|  |                 "*heavy breathing against your neck*" | ||||||
|  |             ], | ||||||
|  |             "negative": [ | ||||||
|  |                 "do you think you're going to get a reward from {role} like that~?", | ||||||
|  |                 "*grabs your hair and pulls your head back*\nyou can do better than that for {role} can't you~?", | ||||||
|  |                 "if you don't learn how to code better, {role} is going to put you in time-out~", | ||||||
|  |                 "does {role} need to give {pronoun} little {affectionate_term} some special lessons~?", | ||||||
|  |                 "you need to work harder to please {role}~", | ||||||
|  |                 "gosh you must be flustered~", | ||||||
|  |                 "are you just keysmashing now~?\ncute~", | ||||||
|  |                 "is {role}'s little {affectionate_term} having trouble reaching the keyboard~?" | ||||||
|  |             ] | ||||||
|  |         }, | ||||||
|  |         "yikes": { | ||||||
|  |             "spiciness": "yikes", | ||||||
|  |             "positive": [ | ||||||
|  |                 "keep it up and {role} might let you cum you little {denigrating_term}~", | ||||||
|  |                 "good {denigrating_term}~\nyou've earned five minutes with the buzzy wand~", | ||||||
|  |                 "mmm~ come taste {role}'s {part}~", | ||||||
|  |                 "*slides {pronoun} finger in your mouth*\nthat's a good little {denigrating_term}~", | ||||||
|  |                 "you're so good with your fingers~\n{role} knows where {pronoun} {denigrating_term} should put them next~", | ||||||
|  |                 "{role} is getting hot~", | ||||||
|  |                 "that's a good {denigrating_term}~", | ||||||
|  |                 "yes~\nyes~~\nyes~~~", | ||||||
|  |                 "{role}'s going to keep {pronoun} good little {denigrating_term}~" | ||||||
|  |             ], | ||||||
|  |             "negative": [ | ||||||
|  |                 "you filthy {denigrating_term}~\nyou made a mess, now clean it up~\nwith your tongue~", | ||||||
|  |                 "*picks you up by the throat*\npathetic~", | ||||||
|  |                 "*drags {pronoun} claws down your back*\ndo it again~", | ||||||
|  |                 "*brandishes {pronoun} paddle*\ndon't make me use this~", | ||||||
|  |                 "{denigrating_term}.\n{denigrating_term}~\n{denigrating_term}~~", | ||||||
|  |                 "get on your knees and beg {role} for forgiveness you {denigrating_term}~", | ||||||
|  |                 "{role} doesn't think {pronoun} little {denigrating_term} should have permission to wear clothes anymore~", | ||||||
|  |                 "never forget you belong to {role}~", | ||||||
|  |                 "does {role} need to put you in the {denigrating_term} wiggler~?", | ||||||
|  |                 "{role} is starting to wonder if you should just give up and become {pronoun} breeding stock~" | ||||||
|  |             ] | ||||||
|  |         } | ||||||
|  |     }, | ||||||
|  |     "vars": { | ||||||
|  |         "mood": { | ||||||
|  |             "defaults": [ | ||||||
|  |                 "chill" | ||||||
|  |             ] | ||||||
|  |         }, | ||||||
|  |         "emote": { | ||||||
|  |             "defaults": [ | ||||||
|  |                 "\u2764\ufe0f", | ||||||
|  |                 "\ud83d\udc96", | ||||||
|  |                 "\ud83d\udc97", | ||||||
|  |                 "\ud83d\udc93", | ||||||
|  |                 "\ud83d\udc9e" | ||||||
|  |             ] | ||||||
|  |         }, | ||||||
|  |         "pronoun": { | ||||||
|  |             "defaults": [ | ||||||
|  |                 "her" | ||||||
|  |             ] | ||||||
|  |         }, | ||||||
|  |         "role": { | ||||||
|  |             "defaults": [ | ||||||
|  |                 "mommy" | ||||||
|  |             ] | ||||||
|  |         }, | ||||||
|  |         "affectionate_term": { | ||||||
|  |             "defaults": [ | ||||||
|  |                 "girl" | ||||||
|  |             ], | ||||||
|  |             "env_key": "LITTLE" | ||||||
|  |         }, | ||||||
|  |         "denigrating_term": { | ||||||
|  |             "spiciness": "yikes", | ||||||
|  |             "defaults": [ | ||||||
|  |                 "slut", | ||||||
|  |                 "toy", | ||||||
|  |                 "pet", | ||||||
|  |                 "pervert", | ||||||
|  |                 "whore" | ||||||
|  |             ], | ||||||
|  |             "env_key": "FUCKING" | ||||||
|  |         }, | ||||||
|  |         "part": { | ||||||
|  |             "spiciness": "yikes", | ||||||
|  |             "defaults": [ | ||||||
|  |                 "milk" | ||||||
|  |             ] | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user