diff --git a/Fenv.egg-info/PKG-INFO b/Fenv.egg-info/PKG-INFO index b2f3fda..964f792 100644 --- a/Fenv.egg-info/PKG-INFO +++ b/Fenv.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: Fenv -Version: 0.0.11.2 +Version: 0.0.11.4 Summary: Generate a folder, establish a virtual environment with a single command. Author: wk18k (watchakorn-18k) Author-email: @@ -32,6 +32,21 @@ Fenv is a simple and efficient tool to help you manage your virtual environments ## Docs https://watchakorn-18k.github.io/Fenv/ +## Installer +``` +pip install fenv +``` +or +``` +pip install --upgrade fenv +``` + +## Start + +```sh +fenv new +``` + ## Command @@ -72,8 +87,14 @@ Fenv is a powerful tool for managing virtual environments and creating basic Pyt ## Changelog -### 0.0.11 - +### 0.0.11.4 +- [x] fix bugs small +### 0.0.11.3 +- [x] fix bugs settings in .vscode +- [x] fix bugs line 609 and 624 +### 0.0.11.2 +- [x] fix bugs small +### 0.0.11.1 - [x] change new pattern command ### 0.0.10 diff --git a/build/lib/fenv/fenv.py b/build/lib/fenv/fenv.py index 5b6271c..54f50f3 100644 --- a/build/lib/fenv/fenv.py +++ b/build/lib/fenv/fenv.py @@ -6,7 +6,19 @@ class bcolors: - """It's a class that contains a bunch of variables that are strings of ANSI escape codes.""" + """It's a class that contains a bunch of variables that are strings of ANSI escape codes. + Example: + ``` + bcolors.HEADER + bcolors.OKBLUE + bcolors.OKGREEN + bcolors.WARNING + bcolors.FAIL + bcolors.ENDC + ``` + Return: + None + """ HEADER = "\033[95m" OKBLUE = "\033[94m" @@ -62,7 +74,7 @@ def create_virtualenv(virtual_env_name): """ It creates a virtual environment in the current directory - :param virtual_env_name: The name of the virtual environment you want to create + :param virtual_env_name (str): The name of the virtual environment you want to create """ os.chdir(virtual_env_name) if not os.path.exists(virtual_env_name): @@ -77,8 +89,15 @@ def create_folder(folder_name): """ It creates a folder with the name of the argument passed to it - :param folder_name: The name of the folder you want to create - :return: 1 + Args: + folder_name (str): The name of the folder you want to create + + Example: + ```py + create_folder("project_name") + ``` + Return: + 1 : if has folder already """ try: os.mkdir(folder_name) @@ -91,30 +110,45 @@ def create_folder(folder_name): def create_setting_vscode(env_path): """ - It creates a file called `settings.json` in a directory called `.vscode` in the current directory. - - The file contains a JSON object with two keys: `python.formatting.provider` and `python.pythonPath`. - - - The value of the first key is `black` and the value of the second key is the path to the virtual - environment. - - The third key is `editor.formatOnSave` and its value is `true`. - - The function prints a message to the console when it's done. - - The function is called in the `create_env` function. - - The `create_env` function is called in the `main` function. - - The `main` function is called when the script is run. - - The `create_env` function is called with the name of the virtual environment as an argument. - - The - - :param env_path: The path to the virtual environment + It creates a file called settings.json in a directory called .vscode. + + The file contains a JSON object with two keys: + + - python.formatting.provider + - python.pythonPath + + The value of the first key is the string "black". + + The value of the second key is the path to the virtual environment. + + The function also prints a message to the console. + + The message is a string that contains the value of the global variable notice. + + The message also contains the string "Successfully created the .vscode/settings.json". + + The function ends with the keyword def. + + The function is called create_setting_vscode. + + The function takes one argument. + + The argument is called env_path. + + The function begins with the keyword def. + + The function ends with the + + Args: + env_path (str): The path to the virtual environment + Example: + ```py + create_setting_vscode("env_path") + ``` + Return: + None """ + text_vscode = """{{"python.formatting.provider": "black","python.pythonPath": "{name_env}","editor.formatOnSave": true,}}""" create_dir_file(".vscode/settings.json", text_vscode.format(name_env=env_path)) print(notice + f"Successfully created the .vscode/settings.json") @@ -124,7 +158,14 @@ def create_file_base(name): """ It creates a file called main.py and writes a function called main() inside of it - :param name: The name of the project + Args: + name (str): The name of the project + Example: + ```py + create_file_base("project_name") + ``` + Return: + None """ def create_file_main_py(): @@ -218,10 +259,20 @@ def run_install_module_base(env): os.system(f".\env_{env}\Scripts\python.exe -m pip install --upgrade pip") -def create_project_all(args, name): +def create_project_all(name): """ It creates a folder, creates a virtual environment, creates a settings file for VSCode, and creates a base file for the project + + Args: + name (str): The name of the folder you want to create + + Example: + ```py + create_project_all("project_name") + ``` + Return: + None """ if create_folder(name) != 1: @@ -275,7 +326,14 @@ def cmd_install_package(args): """ It installs a package using pip - :param args: The arguments passed to the command + Args: + args (str): The arguments passed to the command + Example: + ```py + cmd_install_package("package_name") + ``` + Return: + None """ try: if platform.system() == "Windows": @@ -290,8 +348,16 @@ def cmd_install_package(args): def add_module_to_txt(args): """ It takes the argument from the command line and adds it to the requirements.txt file + Args: + args (str): The arguments passed to the script + + Example: + ```py + add_module_to_txt("package_name") + ``` + Return: + None - :param args: The arguments passed to the script """ os.system(f"pip freeze > requirements.txt") print(notice + f'Successfully module {args.install} added to "requirements.txt"') @@ -300,6 +366,9 @@ def add_module_to_txt(args): def find_dir_env() -> str: """ It prints the contents of the current directory + + Return: + None """ for i in os.listdir("."): print(i) @@ -309,8 +378,15 @@ def find_dir_env() -> str: def install_package(args): """ It takes a list of packages, and installs them using the `pip` command - - :param args: The arguments passed to the command + + Args: + args (str): The arguments passed to the command + Example: + ```py + install_package("package_name") + ``` + Return: + None """ print(notice + "Installing...") cmd_install_package(args) @@ -321,7 +397,14 @@ def cmd_uninstall_package(args): """ It uninstalls a package from the virtual environment - :param args: The arguments passed to the command + Args: + args (str): The arguments passed to the command + Example: + ```py + cmd_uninstall_package("package_name") + ``` + Return: + None """ try: if platform.system() == "Windows": @@ -336,9 +419,17 @@ def cmd_uninstall_package(args): def remove_module_exit_txt(args): """ It removes the module from the requirements.txt file - - :param args: This is the argument that is passed to the function + + Args: + args (str): This is the argument that is passed to the function. + Example: + ```py + remove_module_exit_txt("package_name") + ``` + Return: + None """ + try: os.system(f"pip freeze > requirements.txt") print( @@ -351,9 +442,16 @@ def remove_module_exit_txt(args): def uninstall_package(args): """ - It takes a list of packages, and installs them using the `pip` command - - :param args: The arguments passed to the command + It will uninstall the package and remove the module exit text file + + Args: + args (str): The arguments passed to the script. + Example: + ```py + uninstall_package("package_name") + ``` + Return: + None """ cmd_uninstall_package(args) remove_module_exit_txt(args) @@ -418,12 +516,20 @@ def setup_parse(): def run_cmd_new(args): """ - It creates a new project folder, and then creates a virtual environment inside that folder - - :param args: Namespace(new='test', project_folder='test') + It creates a new project folder and then creates a virtual environment inside that folder + + Args: + args (str): The arguments passed to the command. + Example: + ```py + run_cmd_new("project_name") + ``` + Return: + None """ + try: - create_project_all(args, args.new) + create_project_all(args.new) except TypeError as err: print( "Maybe you forgot to enter the name of the folder? for example" @@ -439,10 +545,18 @@ def run_cmd_new(args): def run_cmd_install(args): """ - It's a function that installs a package - - :param args: The arguments passed to the command + It tries to install a package, if it fails, it prints a message + + Args: + args (str): The arguments passed to the command. + Example: + ```py + run_cmd_install("package_name") + ``` + Return: + None """ + try: print("Installing...") install_package(args) @@ -456,9 +570,19 @@ def run_cmd_install(args): def run_cmd_uninstall(args): """ - A function that is called when the user runs the command "uninstall" - - :param args: The arguments passed to the command + "A function that is called when the user runs the command "uninstall"." + + The first line of the function is a docstring. It's a string that describes what the function does. + It's a good idea to include a docstring for every function you write + + Args: + args (str): The arguments passed to the command + Example: + ```py + run_cmd_uninstall("package_name") + ``` + Return: + None """ try: print(notice + "Uninstalling...") @@ -471,15 +595,18 @@ def run_cmd_onlyenv(): """ It creates a virtual environment with a random name, and then creates a settings.json file for vscode + Return: + None """ + def create_name_env_auto() -> str: """ > It creates a random name for the environment :return: A string """ name_ = random.choice(["samai", "danai"]) - middle_ = random.choice("!@#$&$") + middle_ = random.choice("_#") no_ = random.randint(0, 100) return f"{name_}{middle_}{no_}" @@ -494,7 +621,7 @@ def create_name_env() -> str: ).replace(" ", "_") def is_english_only(s): - return bool(re.match("^[A-Za-z0-9_!@#$%^&*()\-+=]+$", s)) + return bool(re.match("^[A-Za-z0-9_#]+$", s)) if is_english_only(_name): _name = _name[:10] @@ -507,9 +634,18 @@ def is_english_only(s): def create_virtualenv(virtual_env_name): """ It creates a virtual environment with the name you pass to it - - :param virtual_env_name: The name of the virtual environment you want to create + + Args: + virtual_env_name (str): The name of the virtual environment you want to create. + + Example: + ```py + create_virtualenv("virtual_env_name") + ``` + Return: + None """ + if not os.path.exists(virtual_env_name): try: os.system(f"virtualenv env_{virtual_env_name}") @@ -520,10 +656,17 @@ def create_virtualenv(virtual_env_name): _name_env = create_name_env() print(f"your env name is `{bcolors.OKGREEN}{_name_env}{bcolors.ENDC}`") create_virtualenv(_name_env) - create_setting_vscode(_name_env) + dir_name_only = os.path.basename(os.getcwd()) # get name dir main + create_setting_vscode(dir_name_only) def run_cmd_clean(): + """ + It finds the directory of the environment that you're currently in, and then runs the command `conda + clean --all` in that directory + Return: + None + """ find_dir_env() @@ -531,7 +674,15 @@ def check_command(args): """ It checks the command that the user has entered and then runs the appropriate function - :param args: The arguments passed to the script + Args: + args (str): The arguments passed to the script + + Example: + ```py + check_command("new" or "install" or "uninstall" or "update" or "onlyenv") + ``` + Return: + None """ if args.__dict__["command"] == "new": run_cmd_new(args) @@ -570,6 +721,8 @@ def check_command(args): def main(): """ It takes the arguments from the command line and passes them to the create_project_all function + Return: + None """ args = setup_parse() version: str = "v0.0.11" diff --git a/dist/Fenv-0.0.11.2-py3-none-any.whl b/dist/Fenv-0.0.11.2-py3-none-any.whl deleted file mode 100644 index ef895e1..0000000 Binary files a/dist/Fenv-0.0.11.2-py3-none-any.whl and /dev/null differ diff --git a/dist/Fenv-0.0.11.2.tar.gz b/dist/Fenv-0.0.11.2.tar.gz deleted file mode 100644 index 1fa7d25..0000000 Binary files a/dist/Fenv-0.0.11.2.tar.gz and /dev/null differ diff --git a/dist/Fenv-0.0.11.4-py3-none-any.whl b/dist/Fenv-0.0.11.4-py3-none-any.whl new file mode 100644 index 0000000..b0eb52a Binary files /dev/null and b/dist/Fenv-0.0.11.4-py3-none-any.whl differ diff --git a/dist/Fenv-0.0.11.4.tar.gz b/dist/Fenv-0.0.11.4.tar.gz new file mode 100644 index 0000000..1998851 Binary files /dev/null and b/dist/Fenv-0.0.11.4.tar.gz differ diff --git a/docs/how-to-guides.md b/docs/how-to-guides.md index c924b28..ec2febf 100644 --- a/docs/how-to-guides.md +++ b/docs/how-to-guides.md @@ -10,7 +10,7 @@ pip install fenv Fenv makes it easy to get started with a new Python project by providing an all-in-one solution. Here's how to use it: -## Create a new project folder: +## Create a new project with virtualenv and basic files: ```sh fenv new @@ -50,13 +50,13 @@ fenv uninstall Uninstall the package and delete it from requirements.txt -## Uninstall packages +## Update requirements.txt ``` fenv update ``` -Update the package all to requirements.txt +Update all packages to a file. requirements.txt ## Create virtualenv only @@ -64,4 +64,4 @@ Update the package all to requirements.txt fenv onlyenv ``` -Create virtualenv only with 2 choice custom name and auto name then create file settings.json for vscode \ No newline at end of file +Create a virtualenv with a custom name or an optional 2 autoname, then create a file. settings.json for vscode does not generate additional base files \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 8cf3178..b0733b5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,6 +17,15 @@ Fenv is a simple and efficient tool to help you manage your virtual environments - Add `black` for format python - Packages can be installed and uninstalled and added to files. `requirements.txt` at the same time +## Installer +``` +pip install fenv +``` +or +``` +pip install --upgrade fenv +``` + ## Command ```cmd @@ -37,3 +46,18 @@ General Options: -h, --help Show this help message and exit ``` + +## Layout + + |_ .vscode/ + | |_ settings.json + | + |_ env_name/ + | |_ Lib + | |_ Scripts + | |_ .gitignore + | |_ pyvenv + | + |_ main.py + |_ readme.md + |_ requirements.txt diff --git a/docs/th/index.md b/docs/th/index.md index f94949a..2c139a6 100644 --- a/docs/th/index.md +++ b/docs/th/index.md @@ -11,16 +11,115 @@ Fenv เป็นเครื่องมือที่ง่ายและม - เพิ่ม `black` สำหรับจัดการรูปแบบ python - แพ็คเกจสามารถติดตั้งและถอนการติดตั้งและเพิ่มลงในไฟล์ `requirements.txt` พร้อมๆกันในเวลาเดียวกัน -## Commands +## ติดตั้ง +``` +pip install fenv +``` +or +``` +pip install --upgrade fenv +``` -- `mkdocs new [dir-name]` - Create a new project. -- `mkdocs serve` - Start the live-reloading docs server. -- `mkdocs build` - Build the documentation site. -- `mkdocs -h` - Print help message and exit. -## Project layout +## คำสั่ง - mkdocs.yml # The configuration file. - docs/ - index.md # The documentation homepage. - ... # Other markdown pages, images and other files. +```cmd +$ fenv -h + +Usage: + fenv [options] + +Commands: + + new Create a new project + install Install packages + uninstall Uninstall packages + update Update packages to file requirements.txt + onlyenv Create only virtualenv and no create base file + +General Options: + -h, --help Show this help message and exit + +``` + +## โครงสร้าง + + |_ .vscode/ + | |_ settings.json + | + |_ env_name/ + | |_ Lib + | |_ Scripts + | |_ .gitignore + | |_ pyvenv + | + |_ main.py + |_ readme.md + |_ requirements.txt + +## การติดตั้ง + +ในการติดตั้ง Fenv เพียงเรียกใช้คำสั่งต่อไปนี้: + +```sh +pip install fenv +``` + +## การใช้งาน + +Fenv ช่วยให้การเริ่มต้นโครงการ Python ใหม่เป็นเรื่องง่ายด้วยการจัดเตรียมโซลูชันแบบ all-in-one นี่คือวิธีการใช้งาน: + +## สร้างโฟลเดอร์โครงการใหม่พร้อม virtualenv และไฟล์พื้นฐาน: + +```sh +fenv new +``` + +## เปิดใช้งานสภาพแวดล้อมเสมือนจริง: + +### for windows + +``` +cd project_folder +source env/bin/activate +``` + +### for linux + +``` +cd project_folder +source env/bin/activate +``` + +# คำสั่งสำหรับ Windows เท่านั้น + +## ติดตั้งแพ็คเกจ + +``` +fenv install +``` + +ติดตั้งแพ็คเกจและเพิ่มลงใน requirement.txt หากไม่ใส่ชื่อแพ็คเกจ ข้อความ `Maybe you forgot to put the name of the package to install? for example fenv install ` จะปรากฏขึ้น +## ถอนการติดตั้งแพ็คเกจ + +``` +fenv uninstall +``` + +ถอนการติดตั้งแพ็คเกจและลบออกจาก requirement.txt + +## อัปเดต requirements.txt + +``` +fenv update +``` + +อัปเดตแพ็คเกจทั้งหมดลงในไฟล์ requirement.txt + +## สร้างแค่ virtualenv เท่านั้น + +``` +fenv onlyenv +``` + +สร้าง virtualenv ด้วยชื่อที่กำหนดเองหรือชื่ออัตโนมัติ 2 ตัวเลือก จากนั้นสร้างไฟล์ settings.json สำหรับ vscode ไม่ได้สร้างไฟล์พื้นฐานเพิ่มให้ \ No newline at end of file diff --git a/fenv/__pycache__/fenv.cpython-310.pyc b/fenv/__pycache__/fenv.cpython-310.pyc index c795c6f..3bd6436 100644 Binary files a/fenv/__pycache__/fenv.cpython-310.pyc and b/fenv/__pycache__/fenv.cpython-310.pyc differ diff --git a/fenv/fenv.py b/fenv/fenv.py index 5b6271c..54f50f3 100644 --- a/fenv/fenv.py +++ b/fenv/fenv.py @@ -6,7 +6,19 @@ class bcolors: - """It's a class that contains a bunch of variables that are strings of ANSI escape codes.""" + """It's a class that contains a bunch of variables that are strings of ANSI escape codes. + Example: + ``` + bcolors.HEADER + bcolors.OKBLUE + bcolors.OKGREEN + bcolors.WARNING + bcolors.FAIL + bcolors.ENDC + ``` + Return: + None + """ HEADER = "\033[95m" OKBLUE = "\033[94m" @@ -62,7 +74,7 @@ def create_virtualenv(virtual_env_name): """ It creates a virtual environment in the current directory - :param virtual_env_name: The name of the virtual environment you want to create + :param virtual_env_name (str): The name of the virtual environment you want to create """ os.chdir(virtual_env_name) if not os.path.exists(virtual_env_name): @@ -77,8 +89,15 @@ def create_folder(folder_name): """ It creates a folder with the name of the argument passed to it - :param folder_name: The name of the folder you want to create - :return: 1 + Args: + folder_name (str): The name of the folder you want to create + + Example: + ```py + create_folder("project_name") + ``` + Return: + 1 : if has folder already """ try: os.mkdir(folder_name) @@ -91,30 +110,45 @@ def create_folder(folder_name): def create_setting_vscode(env_path): """ - It creates a file called `settings.json` in a directory called `.vscode` in the current directory. - - The file contains a JSON object with two keys: `python.formatting.provider` and `python.pythonPath`. - - - The value of the first key is `black` and the value of the second key is the path to the virtual - environment. - - The third key is `editor.formatOnSave` and its value is `true`. - - The function prints a message to the console when it's done. - - The function is called in the `create_env` function. - - The `create_env` function is called in the `main` function. - - The `main` function is called when the script is run. - - The `create_env` function is called with the name of the virtual environment as an argument. - - The - - :param env_path: The path to the virtual environment + It creates a file called settings.json in a directory called .vscode. + + The file contains a JSON object with two keys: + + - python.formatting.provider + - python.pythonPath + + The value of the first key is the string "black". + + The value of the second key is the path to the virtual environment. + + The function also prints a message to the console. + + The message is a string that contains the value of the global variable notice. + + The message also contains the string "Successfully created the .vscode/settings.json". + + The function ends with the keyword def. + + The function is called create_setting_vscode. + + The function takes one argument. + + The argument is called env_path. + + The function begins with the keyword def. + + The function ends with the + + Args: + env_path (str): The path to the virtual environment + Example: + ```py + create_setting_vscode("env_path") + ``` + Return: + None """ + text_vscode = """{{"python.formatting.provider": "black","python.pythonPath": "{name_env}","editor.formatOnSave": true,}}""" create_dir_file(".vscode/settings.json", text_vscode.format(name_env=env_path)) print(notice + f"Successfully created the .vscode/settings.json") @@ -124,7 +158,14 @@ def create_file_base(name): """ It creates a file called main.py and writes a function called main() inside of it - :param name: The name of the project + Args: + name (str): The name of the project + Example: + ```py + create_file_base("project_name") + ``` + Return: + None """ def create_file_main_py(): @@ -218,10 +259,20 @@ def run_install_module_base(env): os.system(f".\env_{env}\Scripts\python.exe -m pip install --upgrade pip") -def create_project_all(args, name): +def create_project_all(name): """ It creates a folder, creates a virtual environment, creates a settings file for VSCode, and creates a base file for the project + + Args: + name (str): The name of the folder you want to create + + Example: + ```py + create_project_all("project_name") + ``` + Return: + None """ if create_folder(name) != 1: @@ -275,7 +326,14 @@ def cmd_install_package(args): """ It installs a package using pip - :param args: The arguments passed to the command + Args: + args (str): The arguments passed to the command + Example: + ```py + cmd_install_package("package_name") + ``` + Return: + None """ try: if platform.system() == "Windows": @@ -290,8 +348,16 @@ def cmd_install_package(args): def add_module_to_txt(args): """ It takes the argument from the command line and adds it to the requirements.txt file + Args: + args (str): The arguments passed to the script + + Example: + ```py + add_module_to_txt("package_name") + ``` + Return: + None - :param args: The arguments passed to the script """ os.system(f"pip freeze > requirements.txt") print(notice + f'Successfully module {args.install} added to "requirements.txt"') @@ -300,6 +366,9 @@ def add_module_to_txt(args): def find_dir_env() -> str: """ It prints the contents of the current directory + + Return: + None """ for i in os.listdir("."): print(i) @@ -309,8 +378,15 @@ def find_dir_env() -> str: def install_package(args): """ It takes a list of packages, and installs them using the `pip` command - - :param args: The arguments passed to the command + + Args: + args (str): The arguments passed to the command + Example: + ```py + install_package("package_name") + ``` + Return: + None """ print(notice + "Installing...") cmd_install_package(args) @@ -321,7 +397,14 @@ def cmd_uninstall_package(args): """ It uninstalls a package from the virtual environment - :param args: The arguments passed to the command + Args: + args (str): The arguments passed to the command + Example: + ```py + cmd_uninstall_package("package_name") + ``` + Return: + None """ try: if platform.system() == "Windows": @@ -336,9 +419,17 @@ def cmd_uninstall_package(args): def remove_module_exit_txt(args): """ It removes the module from the requirements.txt file - - :param args: This is the argument that is passed to the function + + Args: + args (str): This is the argument that is passed to the function. + Example: + ```py + remove_module_exit_txt("package_name") + ``` + Return: + None """ + try: os.system(f"pip freeze > requirements.txt") print( @@ -351,9 +442,16 @@ def remove_module_exit_txt(args): def uninstall_package(args): """ - It takes a list of packages, and installs them using the `pip` command - - :param args: The arguments passed to the command + It will uninstall the package and remove the module exit text file + + Args: + args (str): The arguments passed to the script. + Example: + ```py + uninstall_package("package_name") + ``` + Return: + None """ cmd_uninstall_package(args) remove_module_exit_txt(args) @@ -418,12 +516,20 @@ def setup_parse(): def run_cmd_new(args): """ - It creates a new project folder, and then creates a virtual environment inside that folder - - :param args: Namespace(new='test', project_folder='test') + It creates a new project folder and then creates a virtual environment inside that folder + + Args: + args (str): The arguments passed to the command. + Example: + ```py + run_cmd_new("project_name") + ``` + Return: + None """ + try: - create_project_all(args, args.new) + create_project_all(args.new) except TypeError as err: print( "Maybe you forgot to enter the name of the folder? for example" @@ -439,10 +545,18 @@ def run_cmd_new(args): def run_cmd_install(args): """ - It's a function that installs a package - - :param args: The arguments passed to the command + It tries to install a package, if it fails, it prints a message + + Args: + args (str): The arguments passed to the command. + Example: + ```py + run_cmd_install("package_name") + ``` + Return: + None """ + try: print("Installing...") install_package(args) @@ -456,9 +570,19 @@ def run_cmd_install(args): def run_cmd_uninstall(args): """ - A function that is called when the user runs the command "uninstall" - - :param args: The arguments passed to the command + "A function that is called when the user runs the command "uninstall"." + + The first line of the function is a docstring. It's a string that describes what the function does. + It's a good idea to include a docstring for every function you write + + Args: + args (str): The arguments passed to the command + Example: + ```py + run_cmd_uninstall("package_name") + ``` + Return: + None """ try: print(notice + "Uninstalling...") @@ -471,15 +595,18 @@ def run_cmd_onlyenv(): """ It creates a virtual environment with a random name, and then creates a settings.json file for vscode + Return: + None """ + def create_name_env_auto() -> str: """ > It creates a random name for the environment :return: A string """ name_ = random.choice(["samai", "danai"]) - middle_ = random.choice("!@#$&$") + middle_ = random.choice("_#") no_ = random.randint(0, 100) return f"{name_}{middle_}{no_}" @@ -494,7 +621,7 @@ def create_name_env() -> str: ).replace(" ", "_") def is_english_only(s): - return bool(re.match("^[A-Za-z0-9_!@#$%^&*()\-+=]+$", s)) + return bool(re.match("^[A-Za-z0-9_#]+$", s)) if is_english_only(_name): _name = _name[:10] @@ -507,9 +634,18 @@ def is_english_only(s): def create_virtualenv(virtual_env_name): """ It creates a virtual environment with the name you pass to it - - :param virtual_env_name: The name of the virtual environment you want to create + + Args: + virtual_env_name (str): The name of the virtual environment you want to create. + + Example: + ```py + create_virtualenv("virtual_env_name") + ``` + Return: + None """ + if not os.path.exists(virtual_env_name): try: os.system(f"virtualenv env_{virtual_env_name}") @@ -520,10 +656,17 @@ def create_virtualenv(virtual_env_name): _name_env = create_name_env() print(f"your env name is `{bcolors.OKGREEN}{_name_env}{bcolors.ENDC}`") create_virtualenv(_name_env) - create_setting_vscode(_name_env) + dir_name_only = os.path.basename(os.getcwd()) # get name dir main + create_setting_vscode(dir_name_only) def run_cmd_clean(): + """ + It finds the directory of the environment that you're currently in, and then runs the command `conda + clean --all` in that directory + Return: + None + """ find_dir_env() @@ -531,7 +674,15 @@ def check_command(args): """ It checks the command that the user has entered and then runs the appropriate function - :param args: The arguments passed to the script + Args: + args (str): The arguments passed to the script + + Example: + ```py + check_command("new" or "install" or "uninstall" or "update" or "onlyenv") + ``` + Return: + None """ if args.__dict__["command"] == "new": run_cmd_new(args) @@ -570,6 +721,8 @@ def check_command(args): def main(): """ It takes the arguments from the command line and passes them to the create_project_all function + Return: + None """ args = setup_parse() version: str = "v0.0.11" diff --git a/mkdocs.yml b/mkdocs.yml index 0362bfc..748284a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -19,6 +19,7 @@ nav: - How-To Guides: how-to-guides.md - reference.md theme: + language: en icon: repo: fontawesome/brands/github @@ -55,10 +56,10 @@ extra: alternate: - name: English - link: / + link: /Fenv/ lang: en - name: ไทย - link: /th/ + link: /Fenv/th/ lang: th social: - icon: fontawesome/brands/github diff --git a/readme.md b/readme.md index a10b62b..62a32db 100644 --- a/readme.md +++ b/readme.md @@ -16,10 +16,20 @@ Fenv is a simple and efficient tool to help you manage your virtual environments ## Docs https://watchakorn-18k.github.io/Fenv/ -## Install +## Installer ``` pip install fenv ``` +or +``` +pip install --upgrade fenv +``` + +## Start + +```sh +fenv new +``` ## Command @@ -61,13 +71,19 @@ Fenv is a powerful tool for managing virtual environments and creating basic Pyt ## Changelog -### 0.0.11 - -- [x] change new pattern command - +### 0.0.11.5 +- [ ] added after use `fenv onlyenv` created settings then activate env one time +### 0.0.11.4 +- [x] fix bugs small +### 0.0.11.3 +- [x] fix bugs settings in .vscode +- [x] fix bugs line 609 and 624 +### 0.0.11.2 +- [x] fix bugs small +### 0.0.11.1 +- [x] change new pattern command `-onlyenv` to `onlyenv` ### 0.0.10 - -- [x] add option -onlyenv for create only virtualenv without base file all +- [x] add option `-onlyenv` for create only virtualenv without base file all - [X] add command install for install package and add module to file requirements.txt ### 0.0.9 diff --git a/setup.py b/setup.py index a81c2e7..29a7dc6 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh: long_description = "\n" + fh.read() -VERSION = '0.0.11.2' +VERSION = '0.0.11.4' DESCRIPTION = 'Generate a folder, establish a virtual environment with a single command.' LONG_DESCRIPTION = 'Generate a folder, establish a virtual environment, and simultaneously create the essential basic Python files, all with a single command'