# add2winpath
Adds/removes folders to the PATH on Windows (Current User/All Users). It doesn't spoil paths with variables (e.g. %windir%\system32)
### pip install add2winpath
### Tested against Windows 10 / Python 3.10 / Anaconda
## Usage
```python
# Adds "folders" to the path (beginning) and removes "remove_from_path",
# the function doesn't mess around with file paths containing variables like "%windir%\system32"
from add2winpath import add_to_path_all_users,add_to_path_current_user,get_all_subfolders_from_folder
cva0 = add_to_path_current_user(
folders=[
"c:\\cygwin\\bin",r"C:\baba ''bubu"
],
remove_from_path=["c:\\cygwin"],
beginning=True,
)
cva1 = add_to_path_all_users(
folders=["c:\\cygwin\\bin", "c:\\cygwin"],
remove_from_path=["c:\cygwin3"],
beginning=True,
)
allsubfolders = get_all_subfolders_from_folder(
folders=[r"C:\cygwin\var\lib\rebase"]
) # list of all subfolders
```
## add_to_path_all_users
```python
add_to_path_all_users(folders: Union[str, List[str]], remove_from_path: Union[str, List[str]], beginning: bool = False) -> str
Adds the specified folders to the PATH environment variable for all users on the system.
Args:
folders (Union[str, List[str]]): A string or list of strings representing the folders to be added to the PATH.
remove_from_path (Union[str, List[str]]): A string or list of strings representing the folders to be removed from the PATH.
beginning (bool, optional): A boolean indicating whether the folders should be added to the beginning or end of the PATH. Defaults to False.
Returns:
str: A string representing the registry script that was executed to update the PATH environment variable.
```
## add_to_path_current_user
```python
add_to_path_current_user(folders: Union[str, List[str]], remove_from_path: Union[str, List[str]], beginning: bool = False) -> str
Adds the specified folders to the PATH environment variable of the current user.
Args:
folders (Union[str, List[str]]): The folder(s) to be added to the PATH environment variable.
remove_from_path (Union[str, List[str]]): The folder(s) to be removed from the PATH environment variable.
beginning (bool, optional): If True, the specified folders will be added to the beginning of the PATH variable.
If False, the specified folders will be added to the end of the PATH variable. Defaults to False.
Returns:
str: The string representation of the registry key that was added to the Windows registry.
```
## get_all_subfolders_from_folder
```python
get_all_subfolders_from_folder(folders: Union[str, List[str]]) -> List[str]
Returns a sorted list of unique subfolder names contained within the specified folder(s).
Args:
folders (Union[str, List[str]]): A string representing the path(s) to the folder(s) to search for subfolders.
Returns:
List[str]: A sorted list of unique subfolder names contained within the specified folder(s).
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/add2winpath",
"name": "add2winpath",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "path,windows,add,remove",
"author": "Johannes Fischer",
"author_email": "<aulasparticularesdealemaosp@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/0f/61/1fba9f65270a4826a676ff78599ed2bcf42075d953722e69b0a09c7eb23a/add2winpath-0.10.tar.gz",
"platform": null,
"description": "\r\n# add2winpath\r\n\r\n\r\n\r\nAdds/removes folders to the PATH on Windows (Current User/All Users). It doesn't spoil paths with variables (e.g. %windir%\\system32)\r\n\r\n\r\n\r\n### pip install add2winpath\r\n\r\n\r\n\r\n### Tested against Windows 10 / Python 3.10 / Anaconda \r\n\r\n\r\n\r\n## Usage\r\n\r\n\r\n\r\n```python\r\n\r\n# Adds \"folders\" to the path (beginning) and removes \"remove_from_path\",\r\n\r\n# the function doesn't mess around with file paths containing variables like \"%windir%\\system32\"\r\n\r\n\r\n\r\nfrom add2winpath import add_to_path_all_users,add_to_path_current_user,get_all_subfolders_from_folder\r\n\r\ncva0 = add_to_path_current_user(\r\n\r\n folders=[\r\n\r\n \"c:\\\\cygwin\\\\bin\",r\"C:\\baba ''bubu\"\r\n\r\n ],\r\n\r\n remove_from_path=[\"c:\\\\cygwin\"],\r\n\r\n beginning=True,\r\n\r\n)\r\n\r\ncva1 = add_to_path_all_users(\r\n\r\n folders=[\"c:\\\\cygwin\\\\bin\", \"c:\\\\cygwin\"],\r\n\r\n remove_from_path=[\"c:\\cygwin3\"],\r\n\r\n beginning=True,\r\n\r\n)\r\n\r\nallsubfolders = get_all_subfolders_from_folder(\r\n\r\n folders=[r\"C:\\cygwin\\var\\lib\\rebase\"]\r\n\r\n) # list of all subfolders\r\n\r\n\r\n\r\n```\r\n\r\n\r\n\r\n## add_to_path_all_users\r\n\r\n\r\n\r\n```python\r\n\r\nadd_to_path_all_users(folders: Union[str, List[str]], remove_from_path: Union[str, List[str]], beginning: bool = False) -> str\r\n\r\n Adds the specified folders to the PATH environment variable for all users on the system.\r\n\r\n \r\n\r\n Args:\r\n\r\n folders (Union[str, List[str]]): A string or list of strings representing the folders to be added to the PATH.\r\n\r\n remove_from_path (Union[str, List[str]]): A string or list of strings representing the folders to be removed from the PATH.\r\n\r\n beginning (bool, optional): A boolean indicating whether the folders should be added to the beginning or end of the PATH. Defaults to False.\r\n\r\n \r\n\r\n Returns:\r\n\r\n str: A string representing the registry script that was executed to update the PATH environment variable.\r\n\r\n\r\n\r\n```\r\n\r\n## add_to_path_current_user\r\n\r\n\r\n\r\n\r\n\r\n```python\r\n\r\nadd_to_path_current_user(folders: Union[str, List[str]], remove_from_path: Union[str, List[str]], beginning: bool = False) -> str\r\n\r\n Adds the specified folders to the PATH environment variable of the current user.\r\n\r\n \r\n\r\n Args:\r\n\r\n folders (Union[str, List[str]]): The folder(s) to be added to the PATH environment variable.\r\n\r\n remove_from_path (Union[str, List[str]]): The folder(s) to be removed from the PATH environment variable.\r\n\r\n beginning (bool, optional): If True, the specified folders will be added to the beginning of the PATH variable.\r\n\r\n If False, the specified folders will be added to the end of the PATH variable. Defaults to False.\r\n\r\n \r\n\r\n Returns:\r\n\r\n str: The string representation of the registry key that was added to the Windows registry.\r\n\r\n```\r\n\r\n\r\n\r\n\r\n\r\n## get_all_subfolders_from_folder\r\n\r\n\r\n\r\n\r\n\r\n```python\r\n\r\n\t\r\n\r\nget_all_subfolders_from_folder(folders: Union[str, List[str]]) -> List[str]\r\n\r\n Returns a sorted list of unique subfolder names contained within the specified folder(s).\r\n\r\n \r\n\r\n Args:\r\n\r\n folders (Union[str, List[str]]): A string representing the path(s) to the folder(s) to search for subfolders.\r\n\r\n \r\n\r\n Returns:\r\n\r\n List[str]: A sorted list of unique subfolder names contained within the specified folder(s).\r\n\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Adds/removes folders to the PATH on Windows (Current User/All Users). It doesn't spoil paths with variables (e.g. %windir%\\system32)",
"version": "0.10",
"split_keywords": [
"path",
"windows",
"add",
"remove"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d2df8a2ec2afdee99976b8ca15c8337ce402c581c6add866b0e72f5b7e7a95a7",
"md5": "40c9280805f6e77db8c7ab2b4568ccad",
"sha256": "0942089a1a6fe255a372d058f7a8c5db7d8fa378dc529ffd82840d82d644aef3"
},
"downloads": -1,
"filename": "add2winpath-0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "40c9280805f6e77db8c7ab2b4568ccad",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8145,
"upload_time": "2023-04-04T06:35:23",
"upload_time_iso_8601": "2023-04-04T06:35:23.544530Z",
"url": "https://files.pythonhosted.org/packages/d2/df/8a2ec2afdee99976b8ca15c8337ce402c581c6add866b0e72f5b7e7a95a7/add2winpath-0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0f611fba9f65270a4826a676ff78599ed2bcf42075d953722e69b0a09c7eb23a",
"md5": "43328b2290567c316c3cf0296e032e4d",
"sha256": "76c1c37fa51aa85c891408add449bb1952371b2666d1555e370276787653831c"
},
"downloads": -1,
"filename": "add2winpath-0.10.tar.gz",
"has_sig": false,
"md5_digest": "43328b2290567c316c3cf0296e032e4d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6034,
"upload_time": "2023-04-04T06:35:25",
"upload_time_iso_8601": "2023-04-04T06:35:25.640214Z",
"url": "https://files.pythonhosted.org/packages/0f/61/1fba9f65270a4826a676ff78599ed2bcf42075d953722e69b0a09c7eb23a/add2winpath-0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-04 06:35:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "hansalemaos",
"github_project": "add2winpath",
"lcname": "add2winpath"
}