pathvar


Namepathvar JSON
Version 1.0.1 PyPI version JSON
download
home_page
SummaryInteracting with PATH variable from Linux BASH command line.
upload_time2023-05-28 12:35:05
maintainer
docs_urlNone
author
requires_python>=3.10
license
keywords path command line linux terminal environment variable system os
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pathvar

### Video Demo:  https://youtu.be/THzJUZlqiI0x
### Description:

My final project for **CS50P**: "*CS50 Introduction to Programming with Python*".

![Screenshot of the utility's help option output.](./assets/images/pathvar_screen.png)

This tool meant to facilitate the interaction with the system's PATH environment variable (Linux BASH shell only).

- To get the work done correctly do the following: 
    * Read the 'help' instruction well 
    * Be careful about the paths you input (with some options) 
    * Separate between multiple paths with a single colon ':'

NOTE: This program saves the new modified PATH's value in '~/.bash_profile' file,
and if this file not exists creates a new one, 
and eventually source the '~/.bashrc' and '~/.profile' if any of them exists.

---

### Usage:

    project.py [-h] [-s] [-e] [-a] [-p] [-d] [-q] [--remove-all-paths] [-v]

### Options:

- **_-h, --help_**
    * show this help message and exit
- **_-s, --show_**
    * shows the current value of the 'PATH' (default)
- **_-e, --eliminate-duplicates_**
    * eliminates any duplicates in the value of the 'PATH' (Included with any modifications)
- **_-a , --append_**
    * appends any number of paths to the current value of the 'PATH' (which are must be given as a
                        single string separated with ':' between every two paths and without any spaces)
- **_-p , --push_**
    * pushes any number of paths at the beginning of the current value of 'PATH' (which are must be
                        given as a single string separated with ':' between every two paths and without any spaces)
- **_-d , --delete_**
    * deletes from 'PATH' any number of paths (which are must be given as a single string separated
                        with ':' between every two paths and without any spaces)
- **_-q , --query_**
    * checks whether the given path is in the current 'PATH'
- **_--remove-all-paths_**
    * removes all paths in the current 'PATH' (NOT RECOMMENDED)
- **_-v, --version_**
    * show program's version number and exit

---

### Code design:
*The entire program is designed using the Functional Programming Paradigm and all application's logic included in one file: 'project.py'.*

### Code documentation:

#### Contents:

* [pathvar.project module](#pathvarproject-module)


    * [`add_args()`](#pathvarprojectadd_argsparser_obj-argumentparser)


    * [`get_path()`](#pathvarprojectget_path)


    * [`is_there_path()`](#pathvarprojectis_there_pathcurrent_path-str-given_path-str)


    * [`main()`](#pathvarprojectmain)


    * [`parse_args_and_modify_path_str()`](#pathvarprojectparse_args_and_modify_path_strparser_obj-argumentparser-current_path-str)


    * [`path_duplicates_eliminator()`](#pathvarprojectpath_duplicates_eliminators-str)


    * [`path_remover()`](#pathvarprojectpath_removercurrent_path-str-given_paths-str)


    * [`print_msg()`](#pathvarprojectprint_msgtitle-str-msg-str)


    * [`run_command_verbosely()`](#pathvarprojectrun_command_verboselycmd-str)


    * [`update_path()`](#pathvarprojectupdate_pathnew_path_value-str)

### pathvar.project module

#### pathvar.project.add_args(parser_obj: ArgumentParser)
*Adding CL arguments to and ArgumentParser object*

*Manipulate the inputted ArgumentParser object 
by adding the needed command line arguments to it
with all the specifications for each of the arguments
(i.e. argument name, action, help, …).*


* **Parameters**

    **parser_obj** (*argparse.ArgumentParser*) – parser object for parsing the command line arguments


* **Returns**

    None


* **Return type**

    None


#### pathvar.project.get_path()
*A simple function to get the current PATH*

*Get the current PATH environment variable
using the command meant for that 
depending on the kind of the operating system that pathvar running on.*

* **Returns**

    The value of the PATH variable


* **Return type**

    str


#### pathvar.project.is_there_path(current_path: str, given_path: str)
*Check whether the ‘given_path’ is in ‘current_path’*

*Return True if the ‘given_path’ is in ‘current_path’
Otherwise, return false.*


* **Parameters**

    
    * **current_path** (*str*) – The value inside the PATH environment variable


    * **given_paths** (*str*) – The paths that the user want it to be deleted



* **Returns**

    True/False, based on whether the ‘given_path’ is in ‘current_path’



* **Return type**

    bool


#### pathvar.project.main()
*pathvar main function*

*The Logic of the entire ‘pathvar’ program.*


* **Returns**

    Nothing, just execute the logic of the entire program.



* **Return type**

    None


#### pathvar.project.parse_args_and_modify_path_str(parser_obj: ArgumentParser, current_path: str)
*Parsing the command line arguments*

*Using ‘argparse’ library this function will consume an ‘ArgumentParser’ object
in order to parse the arguments and handle the chosen option/s.*


* **Parameters**

    **parser_obj** (*argparse.ArgumentParser*) – parser object for parsing the command line arguments



* **Returns**

    None



* **Return type**

    None



#### pathvar.project.path_duplicates_eliminator(s: str)
*Remove any duplicates in a PATH variable*

*This function removes any duplicated paths from a PATH variable.
It looks for duplicated paths.*


* **Parameters**

    **s** (*str*) – The value of the PATH environment variable



* **Returns**

    The same input of the PATH value without any duplicates



* **Return type**

    str


#### pathvar.project.path_remover(current_path: str, given_paths: str)
*Delete the given path/s from the current PATH*

*return copy of the ‘current_path’ 
without and value included in the ‘given_paths’*


* **Parameters**

    
    * **current_path** (*str*) – The value inside the PATH environment variable


    * **given_paths** (*str*) – The paths that the user want it to be deleted



* **Returns**

    A copy from the current path without any given path



* **Return type**

    str


#### pathvar.project.print_msg(title: str, msg: str)
*Print message to the user*

*This function will print a message to the user
in form of message title and message body*


* **Parameters**

    
    * **title** (*str*) – The title of the message


    * **msg** (*str*) – The body of the message



* **Returns**

    Nothing, just the print side effect



* **Return type**

    None


#### pathvar.project.run_command_verbosely(cmd: str)
*Run a given command in subprocess*

*Run the given command in subprocess 
and print and ‘stdout’ or ‘stderr’*


* **Parameters**

    **cmd** (*str*) – Command to run


#### pathvar.project.update_path(new_path_value: str)
*Run a command to update the PATH variable*

*Run the needed commands for updating the PATH environment variable
based on the current operating system and print any ‘stdout’ or ‘stderr’*


* **Parameters**

    **new_path_value** (*str*) – The new value in order to set the PATH variable to it

---

### License:
<h6 align="center">Copyright (c) 2023 Hussein Mahmoud Kandil - MIT<h6>

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pathvar",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "path,command line,linux,terminal,environment variable,system,os",
    "author": "",
    "author_email": "Hussine Mahmoud Kandil <hussein.mahmoud.s7s@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/78/0a/8b8657030d8b2967b9ca880cd28c2ddccfdcf39c7ed77d24b253a4144e7e/pathvar-1.0.1.tar.gz",
    "platform": null,
    "description": "# pathvar\n\n### Video Demo:  https://youtu.be/THzJUZlqiI0x\n### Description:\n\nMy final project for **CS50P**: \"*CS50 Introduction to Programming with Python*\".\n\n![Screenshot of the utility's help option output.](./assets/images/pathvar_screen.png)\n\nThis tool meant to facilitate the interaction with the system's PATH environment variable (Linux BASH shell only).\n\n- To get the work done correctly do the following: \n    * Read the 'help' instruction well \n    * Be careful about the paths you input (with some options) \n    * Separate between multiple paths with a single colon ':'\n\nNOTE: This program saves the new modified PATH's value in '~/.bash_profile' file,\nand if this file not exists creates a new one, \nand eventually source the '~/.bashrc' and '~/.profile' if any of them exists.\n\n---\n\n### Usage:\n\n    project.py [-h] [-s] [-e] [-a] [-p] [-d] [-q] [--remove-all-paths] [-v]\n\n### Options:\n\n- **_-h, --help_**\n    * show this help message and exit\n- **_-s, --show_**\n    * shows the current value of the 'PATH' (default)\n- **_-e, --eliminate-duplicates_**\n    * eliminates any duplicates in the value of the 'PATH' (Included with any modifications)\n- **_-a , --append_**\n    * appends any number of paths to the current value of the 'PATH' (which are must be given as a\n                        single string separated with ':' between every two paths and without any spaces)\n- **_-p , --push_**\n    * pushes any number of paths at the beginning of the current value of 'PATH' (which are must be\n                        given as a single string separated with ':' between every two paths and without any spaces)\n- **_-d , --delete_**\n    * deletes from 'PATH' any number of paths (which are must be given as a single string separated\n                        with ':' between every two paths and without any spaces)\n- **_-q , --query_**\n    * checks whether the given path is in the current 'PATH'\n- **_--remove-all-paths_**\n    * removes all paths in the current 'PATH' (NOT RECOMMENDED)\n- **_-v, --version_**\n    * show program's version number and exit\n\n---\n\n### Code design:\n*The entire program is designed using the Functional Programming Paradigm and all application's logic included in one file: 'project.py'.*\n\n### Code documentation:\n\n#### Contents:\n\n* [pathvar.project module](#pathvarproject-module)\n\n\n    * [`add_args()`](#pathvarprojectadd_argsparser_obj-argumentparser)\n\n\n    * [`get_path()`](#pathvarprojectget_path)\n\n\n    * [`is_there_path()`](#pathvarprojectis_there_pathcurrent_path-str-given_path-str)\n\n\n    * [`main()`](#pathvarprojectmain)\n\n\n    * [`parse_args_and_modify_path_str()`](#pathvarprojectparse_args_and_modify_path_strparser_obj-argumentparser-current_path-str)\n\n\n    * [`path_duplicates_eliminator()`](#pathvarprojectpath_duplicates_eliminators-str)\n\n\n    * [`path_remover()`](#pathvarprojectpath_removercurrent_path-str-given_paths-str)\n\n\n    * [`print_msg()`](#pathvarprojectprint_msgtitle-str-msg-str)\n\n\n    * [`run_command_verbosely()`](#pathvarprojectrun_command_verboselycmd-str)\n\n\n    * [`update_path()`](#pathvarprojectupdate_pathnew_path_value-str)\n\n### pathvar.project module\n\n#### pathvar.project.add_args(parser_obj: ArgumentParser)\n*Adding CL arguments to and ArgumentParser object*\n\n*Manipulate the inputted ArgumentParser object \nby adding the needed command line arguments to it\nwith all the specifications for each of the arguments\n(i.e. argument name, action, help, \u2026).*\n\n\n* **Parameters**\n\n    **parser_obj** (*argparse.ArgumentParser*) \u2013 parser object for parsing the command line arguments\n\n\n* **Returns**\n\n    None\n\n\n* **Return type**\n\n    None\n\n\n#### pathvar.project.get_path()\n*A simple function to get the current PATH*\n\n*Get the current PATH environment variable\nusing the command meant for that \ndepending on the kind of the operating system that pathvar running on.*\n\n* **Returns**\n\n    The value of the PATH variable\n\n\n* **Return type**\n\n    str\n\n\n#### pathvar.project.is_there_path(current_path: str, given_path: str)\n*Check whether the \u2018given_path\u2019 is in \u2018current_path\u2019*\n\n*Return True if the \u2018given_path\u2019 is in \u2018current_path\u2019\nOtherwise, return false.*\n\n\n* **Parameters**\n\n    \n    * **current_path** (*str*) \u2013 The value inside the PATH environment variable\n\n\n    * **given_paths** (*str*) \u2013 The paths that the user want it to be deleted\n\n\n\n* **Returns**\n\n    True/False, based on whether the \u2018given_path\u2019 is in \u2018current_path\u2019\n\n\n\n* **Return type**\n\n    bool\n\n\n#### pathvar.project.main()\n*pathvar main function*\n\n*The Logic of the entire \u2018pathvar\u2019 program.*\n\n\n* **Returns**\n\n    Nothing, just execute the logic of the entire program.\n\n\n\n* **Return type**\n\n    None\n\n\n#### pathvar.project.parse_args_and_modify_path_str(parser_obj: ArgumentParser, current_path: str)\n*Parsing the command line arguments*\n\n*Using \u2018argparse\u2019 library this function will consume an \u2018ArgumentParser\u2019 object\nin order to parse the arguments and handle the chosen option/s.*\n\n\n* **Parameters**\n\n    **parser_obj** (*argparse.ArgumentParser*) \u2013 parser object for parsing the command line arguments\n\n\n\n* **Returns**\n\n    None\n\n\n\n* **Return type**\n\n    None\n\n\n\n#### pathvar.project.path_duplicates_eliminator(s: str)\n*Remove any duplicates in a PATH variable*\n\n*This function removes any duplicated paths from a PATH variable.\nIt looks for duplicated paths.*\n\n\n* **Parameters**\n\n    **s** (*str*) \u2013 The value of the PATH environment variable\n\n\n\n* **Returns**\n\n    The same input of the PATH value without any duplicates\n\n\n\n* **Return type**\n\n    str\n\n\n#### pathvar.project.path_remover(current_path: str, given_paths: str)\n*Delete the given path/s from the current PATH*\n\n*return copy of the \u2018current_path\u2019 \nwithout and value included in the \u2018given_paths\u2019*\n\n\n* **Parameters**\n\n    \n    * **current_path** (*str*) \u2013 The value inside the PATH environment variable\n\n\n    * **given_paths** (*str*) \u2013 The paths that the user want it to be deleted\n\n\n\n* **Returns**\n\n    A copy from the current path without any given path\n\n\n\n* **Return type**\n\n    str\n\n\n#### pathvar.project.print_msg(title: str, msg: str)\n*Print message to the user*\n\n*This function will print a message to the user\nin form of message title and message body*\n\n\n* **Parameters**\n\n    \n    * **title** (*str*) \u2013 The title of the message\n\n\n    * **msg** (*str*) \u2013 The body of the message\n\n\n\n* **Returns**\n\n    Nothing, just the print side effect\n\n\n\n* **Return type**\n\n    None\n\n\n#### pathvar.project.run_command_verbosely(cmd: str)\n*Run a given command in subprocess*\n\n*Run the given command in subprocess \nand print and \u2018stdout\u2019 or \u2018stderr\u2019*\n\n\n* **Parameters**\n\n    **cmd** (*str*) \u2013 Command to run\n\n\n#### pathvar.project.update_path(new_path_value: str)\n*Run a command to update the PATH variable*\n\n*Run the needed commands for updating the PATH environment variable\nbased on the current operating system and print any \u2018stdout\u2019 or \u2018stderr\u2019*\n\n\n* **Parameters**\n\n    **new_path_value** (*str*) \u2013 The new value in order to set the PATH variable to it\n\n---\n\n### License:\n<h6 align=\"center\">Copyright (c) 2023 Hussein Mahmoud Kandil - MIT<h6>\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Interacting with PATH variable from Linux BASH command line.",
    "version": "1.0.1",
    "project_urls": {
        "Repository": "https://github.com/hussein-m-kandil/pathvar/"
    },
    "split_keywords": [
        "path",
        "command line",
        "linux",
        "terminal",
        "environment variable",
        "system",
        "os"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd25a4261395da298b56582c7ac3fd075ee03febfa2517410e539077b021de8f",
                "md5": "a23f26a3a4cdf186670bf24808d83f96",
                "sha256": "8d8317ba51e654fdd2567e48589780bffb484a92d83a59ade15f96098f1f7105"
            },
            "downloads": -1,
            "filename": "pathvar-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a23f26a3a4cdf186670bf24808d83f96",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 8480,
            "upload_time": "2023-05-28T12:35:04",
            "upload_time_iso_8601": "2023-05-28T12:35:04.232942Z",
            "url": "https://files.pythonhosted.org/packages/bd/25/a4261395da298b56582c7ac3fd075ee03febfa2517410e539077b021de8f/pathvar-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "780a8b8657030d8b2967b9ca880cd28c2ddccfdcf39c7ed77d24b253a4144e7e",
                "md5": "e30dd2e73175ede71add9aad17f1422f",
                "sha256": "350b6c27779457fda5c2c155c46ac901d26e6a7467854108bda5b0fd0a3c6ac4"
            },
            "downloads": -1,
            "filename": "pathvar-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "e30dd2e73175ede71add9aad17f1422f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 9102,
            "upload_time": "2023-05-28T12:35:05",
            "upload_time_iso_8601": "2023-05-28T12:35:05.782381Z",
            "url": "https://files.pythonhosted.org/packages/78/0a/8b8657030d8b2967b9ca880cd28c2ddccfdcf39c7ed77d24b253a4144e7e/pathvar-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-28 12:35:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hussein-m-kandil",
    "github_project": "pathvar",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pathvar"
}
        
Elapsed time: 0.15564s