AutoAnnotate - An AI Powered Comment Writer
Overview
This Python script processes all the files in a source directory, adds comments to the code using Google's Generative AI model (Gemini), and saves the processed files to a specified destination directory. It also supports excluding certain file types and directories, including hidden directories.
Prerequisites
Using Script Directly -
- Python 3.7 or higher: Ensure you have Python installed on your system.
- Google Generative AI SDK: Install the
google-generativeaipackage. - GEMINI API Key: You need a GEMINI API key to use the Generative AI model if default one is unavailable.
Setup
You can get the script by going to Releases Section in the Github repositor
-
Install Required Packages:
pip install google-generativeai
-
Set GEMINI API Key: Replace
'your api'with your actual GEMINI API key in the script. -
Exclusion Lists:
extension_exclusion_list.txt: Contains file extensions to exclude.folder_exclusion_list.txt: Contains folder names to exclude. If these files do not exist, the script will prompt you to create default lists.
Installing via pip -
pip install AutoNotater
Usage
The script can be run from the command line with various options:
[ If using the script ]
python WriteComments.py [--src SRC_DIRECTORY] [--out DST_DIRECTORY] [--excludeHiddenDirs true|false]
or
[ If installed by pip ]
AutoNotater [--src SRC_DIRECTORY] [--out DST_DIRECTORY] [--excludeHiddenDirs true|false]
Using it without any arguments will prompt you to generate exclusion lists if they aren't in current directory. It is recommended to generate them.
After that it will create a new "Generated" folder and start going through each file in the current directory and start putting modified files with comments in the Generated Folder.
Options
--src: Sets the source directory. Default is the current directory (./).--out: Sets the destination directory. Default is./Generated.--excludeHiddenDirs: Exclude hidden directories. Default istrue.
Example
To process files from a source directory (./source) and save them to a destination directory (./output) while excluding hidden directories:
[ If using the script ]
python script.py --src ./source --out ./output --excludeHiddenDirs true
or
[ If installed by pip ]
AutoNotater --src ./source --out ./output --excludeHiddenDirs true
Exclusion Lists
The script supports exclusion lists for file extensions and folder names:
- File Extensions:
- Default list includes common binary and non-code file extensions such as
.ico,.jpg,.pdf, etc.
- Default list includes common binary and non-code file extensions such as
- Folders:
- Default list includes common temporary and environment directories such as
__pycache__,node_modules,.git, etc.
- Default list includes common temporary and environment directories such as
These lists are stored in extension_exclusion_list.txt and folder_exclusion_list.txt, respectively. If these files do not exist, the script will prompt to create them with default values.
Note
- Ensure that the destination directory is different from the source directory to avoid infinite loops and potential data loss.
- The script assumes that the content in files is UTF-8 encoded.
Contribution
It would be a great help if you contribute to the code of the script. It will also be helpful for everyone if you add folder names and file extensions in the exclusion list.
Contact
For issues, please open a ticket on the project's GitHub repository -
Metadata
Release files for AutoNotater 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| autonotater-0.1.2.tar.gz | 6.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| AutoNotater-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.7 kB
Release files / autonotater-0.1.2.tar.gz
| Download URL | autonotater-0.1.2.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d51a3e60f8cab46bbabb53ccc435551cc94945cda8ee02e569f1f920beb1f8b3
|
|
BLAKE2b-256 checksum How to use checksums |
95cc7eda95714cf2e0c01343532bab34c83c74a570337ed27c73bbd6346c10f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Release files / AutoNotater-0.1.2-py3-none-any.whl
| Download URL | AutoNotater-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78ff8180bb5b76da21fd5407061b03c9717b834be17c3589822a0c3bd7e32c80
|
|
BLAKE2b-256 checksum How to use checksums |
34d727828d6e164599578798144d05e58aa8e9e1033ae4d586d1b7c085d6a9d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Security for AutoNotater 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.