https://github.com/aidinhamedi/python-check-arg
The check_arg function is a handy Python code snippet that checks if a specific argument exists in a list of arguments. It's a reusable piece of code that you can easily integrate into your projects.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.5%) to scientific vocabulary
Keywords
Repository
The check_arg function is a handy Python code snippet that checks if a specific argument exists in a list of arguments. It's a reusable piece of code that you can easily integrate into your projects.
Basic Info
Statistics
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
Python-check-arg
The check_arg function is a handy Python code snippet that checks if a specific argument exists in a list of arguments. It's a reusable piece of code that you can easily integrate into your projects.
Function Signature
python
def check_arg(arg_list: list, arg_str: str, return_arg: bool = False, bool_OUTPUT_ONLY: bool = False):
Parameters
arg_list(list): A list of arguments.arg_str(str): The argument to check for.return_arg(bool, optional): If True, returns the string after the argument if it exists. Defaults to False.bool_OUTPUT_ONLY(bool, optional): If True, only boolean values are returned. If False, specific error codes are returned in case of errors. Defaults to False.
Returns
bool/str: Returns True if the argument exists andreturn_argis False. Returns the string after the argument ifreturn_argis True and the argument exists. Returns specific error codes in case of errors, unlessbool_OUTPUT_ONLYis True.
Error Codes
- '![IER:01]': Returned when the provided argument list is empty or contains only 'none' or ''.
- '![IER:02]': Returned when the argument to check for is an empty string.
- '![IER:03]': Returned when the argument is found in the argument list, but there is no string after the argument and
return_argis set to True. - '![IER:04]': Returned when the argument is not found in the argument list.
Note: If the bool_OUTPUT_ONLY parameter is set to True, the function will return False instead of these error codes.
Usage Examples
```python
Example 1: Check if '-v' exists in the argument list
args = ['-v', '-f', 'file.txt'] print(check_arg(args, 'v')) # Returns: True
Example 2: Get the string after '-z' in the argument list
args = ['-v', '-f', '-z12'] print(checkarg(args, 'z', returnarg=True)) # Returns: '12'
Example 3: Check for an argument that doesn't exist in the list
args = ['-v', '-f', 'file.txt'] print(checkarg(args, 'x')) # Returns: '![IER:04]' or False if boolOUTPUT_ONLY is True ```
Feel free to copy this code snippet and use it in your projects. If you find any issues or have any suggestions for improvements, please open an issue or submit a pull request.
Owner
- Name: Aidin
- Login: AidinHamedi
- Kind: user
- Repositories: 1
- Profile: https://github.com/AidinHamedi
Segmentation fault
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: 7 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0