Skip to main content

patchutils

patchutils provide utilities for making patches from directories and applying patches to directories. If you like the library and use it in your project, please consider giving us a star ⭐

Made with ❤️ by Contributers

Usage

Installation

from pip:

pip install patchutils -U

from latest repo

git clone xcodz-dot/patchutils
pip install poetry
poetry install

do not use poetry until you know how it works

API Documentation

You can check the steps to build documentation by doing this:

>>> import patchutils
>>> help(patchutils)

For your convinience all documentation is pre-built under the docs directory.

Concept

There are three things to be noted:

  • directory information
  • patch
  • update files

Directory Information

Directory Information is a simple dictionary object containing 3 fields:

  • files

    Files is a list that contain relative paths for all the files for the provided directory.

  • directories

    Directories is a list that contain relative paths for all the subdirectories for the provided directory.

  • hash

    Hash is a dictionary with key as file names and values as SHA-256 checksums for the respective files.

Here is a Sample Directory Information:

{
    "files": [
        "my_file_1.txt",
        "folder1/myfile2.txt",
        "folder2/another_folder/myfile3.txt"
    ],
    "directories": [
        "folder1",
        "folder2",
        "folder2/another_folder",
        "empty_folder"
    ],
    "hash": {
        "my_file_1.txt": "blablablablbalbalblblablblblblblblbl some sha hash blahblabla",
        "folder1/myfile2.txt": "blablablablablablablablablabla hash is in a hexdigest format",
        "folder2/another_folder/myfile3.txt": "blablablablbalbalblablg7ty913griubkeda"
    }
}

Patch

Patch is a dictionary that tells what changes have been made in comparision to two different Directory Informations. It consists of the following feilds:

  • files_added

    List of Files added in comparision to the old directory information

  • files_removed

    List of Files removed in comparision to the old directory information

  • files_modified

    List of Files modified in comparision to the old directory information

  • directories_added

    List of directories added including empty directories

  • directories_removed

    List of directories removed including all their content within them

Here is an example patch:

{
    "files_added": ["new_file.txt"],
    "files_removed": ["i_hate_python.txt"],
    "files_modified": ["why_i_like_python.txt"],
    "directories_added": ["Temp"],
    "directories_removed": [".Temp"],
    "hash": {
        "new_file.txt": "blablablablbalbalbalbblablbablablbalbblabla",
        "why_i_like_python.txt": "blablablablablablablablablalbalgialbdblablbla"
    }
}

Update Files

Update files are simple uncompressed zip archives that are made using patch. Here is a typical workflow of a server and a client requesting updates:

  • Clients gives their version number to the server.
  • Server checks the version number and loads up stored directory information for that version.
  • Server creates a patch using the latest directory information and that specific version directory information.
  • Server creates an uncompressed update file and starts streaming it to the client OR alternatively server sends the patch in json format and client starts querying the server for different files listed in the patch and applies the patch to required positions.
  • If the client recieved the update file instead of patch information then the client applies the update file to the required positions.

Alternatively to above if their is no version specifications then the workflow might look like this:

  • Client generates directory information from local filesystem and sends it to the server
  • Server creates a patch using client provided directory information and latest server directory information.
  • And from this point on the process of updating is same as in above example

Contributers


xcodz-dot

💻 📖 🚇 ⚠️ 🚧

Metadata

Release files for patchutils 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for patchutils 1.2.0
File Size Uploaded Provenance
patchutils-1.2.0.tar.gz 16.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for patchutils 1.2.0
File Interpreter ABI Platform
patchutils-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.7 kB

Release files / patchutils-1.2.0.tar.gz

Download URL patchutils-1.2.0.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9ec54459062d4ed839907e96df7506839c6313953fc188345af2477867594802
BLAKE2b-256 checksum
How to use checksums
004d5a046d93b915067df11cc860dcf30410615ad762ca322af9838410a6b2cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.8 CPython/3.10.2 Linux/5.16.14-200.fc35.x86_64

Release files / patchutils-1.2.0-py3-none-any.whl

Download URL patchutils-1.2.0-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
613a36f0d2501871aa3ade48a13f8d127e10897c75d4cfa5f6d27225b309565b
BLAKE2b-256 checksum
How to use checksums
542e9c73de79ec8c66c9946d46778e99ff6880626a7db43a80cefdb5086f38ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.8 CPython/3.10.2 Linux/5.16.14-200.fc35.x86_64

Security for patchutils 1.2.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page