code-updater


Namecode-updater JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/joonheeu/code-updater
SummaryA Python-based tool for updating, inserting, or deleting lines in project files.
upload_time2024-09-03 13:38:29
maintainerNone
docs_urlNone
authorDaniel
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CodeUpdater

[🇺🇸English](README.md) | [🇰🇷한국어](README_ko.md)

**CodeUpdater** is a Python-based tool designed to automate the process of updating, inserting, or deleting lines in multiple files within a project directory based on a specified JSON configuration.

## Table of Contents

- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [JSON Configuration](#json-configuration)
- [Example](#example)
- [Logging](#logging)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)

## Features

- **Update**: Replace specific lines in a file with new content.
- **Insert**: Insert new lines at a specific position in a file, pushing existing lines downward.
- **Delete**: Remove specific lines from a file.

## Installation

To install CodeUpdater, you can use `pip`. Run the following command:

```bash
pip install code-updater
```

Or, if you are developing or want to install it from a local copy:

1. Clone the repository to your local machine:

   ```bash
   git clone https://github.com/joonheeu/code-updater.git
   cd code-updater
   ```

2. Install the package locally:

   ```bash
   pip install .
   ```

## Usage

To use `CodeUpdater`, ensure that you have Python installed. Then, create an `updates.json` file in the root directory of your project, and structure it according to the configuration described below.

You can run the script using the following command:

```bash
cup [OPTIONS] {project_root_path}
```

Replace `{project_root_path}` with the root directory of your project where the files are located.

### Options

- `-h`, `--help`: Show the help message and exit.
- `-V`, `--version`: Show the current version of `CodeUpdater` and exit.

## JSON Configuration

The JSON file should describe the operations you want to perform. Below is the structure of the JSON file:

```json
[
  {
    "path": "src/example.py",
    "line": 42,
    "type": "update",  # Type of operation: "update", "insert", or "delete"
    "replace": [
      "new line 42 content",
      "new line 43 content"
    ]
  }
]
```

### Type

- **update**: Replaces the lines starting from the specified line number with the provided content in the "replace" list.
- **insert**: Inserts the lines from the "replace" list starting at the specified line number, shifting existing lines downward.
- **delete**: Removes the line specified by the line number. The "replace" field is not needed for this operation.

### Example

Here’s an example configuration:

```json
[
  {
    "path": "src/example.py",
    "line": 42,
    "type": "update",
    "replace": [
      "updated line 42 content",
      "updated line 43 content"
    ]
  },
  {
    "path": "src/example.py",
    "line": 10,
    "type": "insert",
    "replace": [
      "inserted line 10 content",
      "inserted line 11 content"
    ]
  },
  {
    "path": "src/example.py",
    "line": 15,
    "type": "delete"
  }
]
```

In this example:
- The lines at 42 and 43 in `src/example.py` will be updated.
- New lines will be inserted at line 10, and existing lines will be shifted downward.
- The line at 15 will be deleted.

## Logging

The tool generates logs in the `logs/` directory inside the specified project root. Each log file is timestamped and details the changes made to the files. The log includes both the original and the updated content for comparison.

## Contributing

Contributions are welcome! Please fork the repository and submit a pull request. If you find any issues or have suggestions, feel free to open an issue on GitHub.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Contact

**Author:** Daniel  
**Email:** [daniel@udit.one](mailto:daniel@udit.one)  
**Company:** UDIT

For more details, visit the GitHub repository: [CodeUpdater](https://github.com/joonheeu/code-updater)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/joonheeu/code-updater",
    "name": "code-updater",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Daniel",
    "author_email": "daniel@udit.one",
    "download_url": "https://files.pythonhosted.org/packages/15/c8/3b5f5dc0cb2cd6de48eda1cc220e15b3e052e81bbbe6a6db551b067fe40a/code_updater-0.1.0.tar.gz",
    "platform": null,
    "description": "# CodeUpdater\n\n[\ud83c\uddfa\ud83c\uddf8English](README.md) | [\ud83c\uddf0\ud83c\uddf7\ud55c\uad6d\uc5b4](README_ko.md)\n\n**CodeUpdater** is a Python-based tool designed to automate the process of updating, inserting, or deleting lines in multiple files within a project directory based on a specified JSON configuration.\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n- [JSON Configuration](#json-configuration)\n- [Example](#example)\n- [Logging](#logging)\n- [Contributing](#contributing)\n- [License](#license)\n- [Contact](#contact)\n\n## Features\n\n- **Update**: Replace specific lines in a file with new content.\n- **Insert**: Insert new lines at a specific position in a file, pushing existing lines downward.\n- **Delete**: Remove specific lines from a file.\n\n## Installation\n\nTo install CodeUpdater, you can use `pip`. Run the following command:\n\n```bash\npip install code-updater\n```\n\nOr, if you are developing or want to install it from a local copy:\n\n1. Clone the repository to your local machine:\n\n   ```bash\n   git clone https://github.com/joonheeu/code-updater.git\n   cd code-updater\n   ```\n\n2. Install the package locally:\n\n   ```bash\n   pip install .\n   ```\n\n## Usage\n\nTo use `CodeUpdater`, ensure that you have Python installed. Then, create an `updates.json` file in the root directory of your project, and structure it according to the configuration described below.\n\nYou can run the script using the following command:\n\n```bash\ncup [OPTIONS] {project_root_path}\n```\n\nReplace `{project_root_path}` with the root directory of your project where the files are located.\n\n### Options\n\n- `-h`, `--help`: Show the help message and exit.\n- `-V`, `--version`: Show the current version of `CodeUpdater` and exit.\n\n## JSON Configuration\n\nThe JSON file should describe the operations you want to perform. Below is the structure of the JSON file:\n\n```json\n[\n  {\n    \"path\": \"src/example.py\",\n    \"line\": 42,\n    \"type\": \"update\",  # Type of operation: \"update\", \"insert\", or \"delete\"\n    \"replace\": [\n      \"new line 42 content\",\n      \"new line 43 content\"\n    ]\n  }\n]\n```\n\n### Type\n\n- **update**: Replaces the lines starting from the specified line number with the provided content in the \"replace\" list.\n- **insert**: Inserts the lines from the \"replace\" list starting at the specified line number, shifting existing lines downward.\n- **delete**: Removes the line specified by the line number. The \"replace\" field is not needed for this operation.\n\n### Example\n\nHere\u2019s an example configuration:\n\n```json\n[\n  {\n    \"path\": \"src/example.py\",\n    \"line\": 42,\n    \"type\": \"update\",\n    \"replace\": [\n      \"updated line 42 content\",\n      \"updated line 43 content\"\n    ]\n  },\n  {\n    \"path\": \"src/example.py\",\n    \"line\": 10,\n    \"type\": \"insert\",\n    \"replace\": [\n      \"inserted line 10 content\",\n      \"inserted line 11 content\"\n    ]\n  },\n  {\n    \"path\": \"src/example.py\",\n    \"line\": 15,\n    \"type\": \"delete\"\n  }\n]\n```\n\nIn this example:\n- The lines at 42 and 43 in `src/example.py` will be updated.\n- New lines will be inserted at line 10, and existing lines will be shifted downward.\n- The line at 15 will be deleted.\n\n## Logging\n\nThe tool generates logs in the `logs/` directory inside the specified project root. Each log file is timestamped and details the changes made to the files. The log includes both the original and the updated content for comparison.\n\n## Contributing\n\nContributions are welcome! Please fork the repository and submit a pull request. If you find any issues or have suggestions, feel free to open an issue on GitHub.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Contact\n\n**Author:** Daniel  \n**Email:** [daniel@udit.one](mailto:daniel@udit.one)  \n**Company:** UDIT\n\nFor more details, visit the GitHub repository: [CodeUpdater](https://github.com/joonheeu/code-updater)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python-based tool for updating, inserting, or deleting lines in project files.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/joonheeu/code-updater"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c6a91456d7494ca32f62cde91ad3cb8f9574c3cd1c60569b9d40bc11a03ecc49",
                "md5": "d5f92c8a25d781326225efb02ab5d207",
                "sha256": "e377beac49715570ba7b6fb0d35a6fa179fd79ecda0e4d5c119ca6e24f48a0b0"
            },
            "downloads": -1,
            "filename": "code_updater-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d5f92c8a25d781326225efb02ab5d207",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6702,
            "upload_time": "2024-09-03T13:38:27",
            "upload_time_iso_8601": "2024-09-03T13:38:27.765984Z",
            "url": "https://files.pythonhosted.org/packages/c6/a9/1456d7494ca32f62cde91ad3cb8f9574c3cd1c60569b9d40bc11a03ecc49/code_updater-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "15c83b5f5dc0cb2cd6de48eda1cc220e15b3e052e81bbbe6a6db551b067fe40a",
                "md5": "3714dd3ba3e1a29896ee9f0578818d2e",
                "sha256": "bb86d3167fd14fd6d7277ee9f7bc27310772a6406f303d7c8127fc32f2b86a61"
            },
            "downloads": -1,
            "filename": "code_updater-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3714dd3ba3e1a29896ee9f0578818d2e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 5983,
            "upload_time": "2024-09-03T13:38:29",
            "upload_time_iso_8601": "2024-09-03T13:38:29.659279Z",
            "url": "https://files.pythonhosted.org/packages/15/c8/3b5f5dc0cb2cd6de48eda1cc220e15b3e052e81bbbe6a6db551b067fe40a/code_updater-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-03 13:38:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "joonheeu",
    "github_project": "code-updater",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "code-updater"
}
        
Elapsed time: 2.01844s