Skip to main content

A 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.

Project description

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 -

  1. Python 3.7 or higher: Ensure you have Python installed on your system.
  2. Google Generative AI SDK: Install the google-generativeai package.
  3. 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

  1. Install Required Packages:

    pip install google-generativeai
    
  2. Set GEMINI API Key: Replace 'your api' with your actual GEMINI API key in the script.

  3. 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 is true.

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.
  • Folders:
    • Default list includes common temporary and environment directories such as __pycache__, node_modules, .git, etc.

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 -

Github - AutoAnnotate

PyPI - AutoNotater

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autonotater-0.1.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

AutoNotater-0.1.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file autonotater-0.1.2.tar.gz.

File metadata

  • Download URL: autonotater-0.1.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for autonotater-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d51a3e60f8cab46bbabb53ccc435551cc94945cda8ee02e569f1f920beb1f8b3
MD5 0759436b14bfa63d61fd17dd35570bd0
BLAKE2b-256 95cc7eda95714cf2e0c01343532bab34c83c74a570337ed27c73bbd6346c10f7

See more details on using hashes here.

File details

Details for the file AutoNotater-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: AutoNotater-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for AutoNotater-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 78ff8180bb5b76da21fd5407061b03c9717b834be17c3589822a0c3bd7e32c80
MD5 ed2091f0ab79a452e29ca56373b7e868
BLAKE2b-256 34d727828d6e164599578798144d05e58aa8e9e1033ae4d586d1b7c085d6a9d7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page