rdiff


Namerdiff JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://github.com/MohitPanchariya/rdiff
SummaryA native python implementation of the rdiff tool by librsync
upload_time2024-03-24 06:43:12
maintainerNone
docs_urlNone
authorMohit Panchariya
requires_python>=3.6
licenseNone
keywords rdiff librsync native python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            #  RDIFF

This project is an implementation of the rdiff tool of librsync used for finding
the diff of a file on a remote machine.
(https://github.com/librsync/librsync/blob/master/doc/rdiff.md). 

## Note:
This tool isn't concerned with how the signature, and delta files are
sent/received over the network. It's only concerned with working with these files
and performing the patch.

## Usage:
Assume two machines, machine A and machine B, have different versions of the same file.
Machine A wants to synchronise its file with the file present on machine B.
<br>
The following example shows the usage of rdiff on Machine A
```python
import rdiff

# create an instance of the checksum class
checksum = rdiff.signature.Checksum()

# Create an instance of the signature class, passing in the checksum object
# Optionally a blocksize can be specified, defaults to 1024 bytes
signature = rdiff.signature.Signature(checksum=checksum)

# create the signature file
# basisFilePath -> Path to the file for which signature must be generated
# sigFilePath -> Where to store the signature file
signature.createSignature(basisFilePath="path_to_file", sigFilePath="path_to_signature_file")

# This machine sends over the signature file to the remote machine
# The remote machine responds back with a delta file
# rdiff isn't concerned with how this communication over the network takes place

patcher = rdiff.patch.Patch()
# Perform a patch operation
# How the delta file is obtained from the remote machine is not a concern of rdiff
# deltaFilePath -> Path to the delta file obtained from the remote machine
# basisFilePath -> Path to the file which is to be updated
# outFilePath -> Path to store the updated file
# Note: The original file isn't modified, instead a new file is created.
patcher.patchFile(
    deltaFilePath="path_to_delta_file", basisFilePath="path_to_file", outFilePath="path_to_updated_file"
)

```
The following shows the usage of rdiff on machine B
```python
import rdiff

# create an instance of the checksum class
checksum = rdiff.signature.Checksum()

# create an instance of the delta class
delta = rdiff.delta.Delta()

# The createDelatFile method is used to create a delta file, for a given file
# against a signature file obtained from a remote machine.
# inFilePath -> Path to the updated file, the file which the remote machine wants to synchronise
# deltatFilePath -> Path to store the delta file
# sigFielPath -> Path to the signature file obtained from the remote machine.
# rdiff is not concerned with how this signature file is obtained.
# blocksize -> This should be identical to the blocksize used by the remote machine to generate the
# signature file.
delta.createDeltaFile(
    inFilePath="path_to_updated_file", deltaFilePath="path_to_delta_file",
    sigFielPath="path_to_sig_file", blockSize=1024, checksum=checksum
)

# This machine now sends the delta file to the remote machine.

```
The following is a combined example, on a single machine. The code can be extended to two remote
machines.
```python
"""
Assume there are two machines, machine A and machine B.
Machine A and machine B both have different versions of test.txt
Machine A wants to sync its file to have the same content as the file on machine B.

Machine A creates a signature file and sends it over to machine B.
Machine B uses this signature file and generates a delta file against the signature file
and sends the delta file back to machine A.

Machine A now uses this delta file to patch its file. Thereby, synchronising its file to have
the same content as the file on machine B.

The following is an example on a single machine. The same example can be extended to two
different machines connected over a network.
"""
import rdiff

checksum = rdiff.signature.Checksum()
signature = rdiff.signature.Signature(checksum=checksum, blockSize=1024)

# Machine A making the signature file
signature.createSignature(basisFilePath="path_to_file", sigFilePath="path_to_sig_file")

delta = rdiff.delta.Delta()
# Machine B creates the delta file using the signature file generated by Machine A
delta.createDeltaFile(
    inFilePath="path_to_updated_file", deltaFilePath="path_to_delta_file",
    sigFielPath="path_to_sig_file", blockSize=1024, checksum=checksum
)

patcher = rdiff.patch.Patch()
# Machine A patches its file (creates a new version of the file located at path_to_updated_file)
# using the delta file generated by Machine B
patcher.patchFile(
    deltaFilePath="path_to_delta_file", basisFilePath="path_to_file",
    outFilePath="path_to_updated_file"
)

```

## File Formats
Information on the format/structure of the different files involved can be found at:
https://github.com/MohitPanchariya/rdiff/blob/master/file_formats.md

## Further Reading
More about the rsync algorithm can be found at: https://rsync.samba.org/tech_report/tech_report.html
<br>
A detailed explanation of the rsync algorithm is present in the PhD thesis of Andrew Tridgell, specifically
chapter 3 of the thesis: https://www.samba.org/~tridge/phd_thesis.pdf

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MohitPanchariya/rdiff",
    "name": "rdiff",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "rdiff, librsync, native, python",
    "author": "Mohit Panchariya",
    "author_email": "iammohitpanchariya@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/84/68/7ed3d2cbdc1572c555e8e8f0f99dafb86b377d0750f388d9497787e02e4b/rdiff-0.2.3.tar.gz",
    "platform": null,
    "description": "#  RDIFF\r\n\r\nThis project is an implementation of the rdiff tool of librsync used for finding\r\nthe diff of a file on a remote machine.\r\n(https://github.com/librsync/librsync/blob/master/doc/rdiff.md). \r\n\r\n## Note:\r\nThis tool isn't concerned with how the signature, and delta files are\r\nsent/received over the network. It's only concerned with working with these files\r\nand performing the patch.\r\n\r\n## Usage:\r\nAssume two machines, machine A and machine B, have different versions of the same file.\r\nMachine A wants to synchronise its file with the file present on machine B.\r\n<br>\r\nThe following example shows the usage of rdiff on Machine A\r\n```python\r\nimport rdiff\r\n\r\n# create an instance of the checksum class\r\nchecksum = rdiff.signature.Checksum()\r\n\r\n# Create an instance of the signature class, passing in the checksum object\r\n# Optionally a blocksize can be specified, defaults to 1024 bytes\r\nsignature = rdiff.signature.Signature(checksum=checksum)\r\n\r\n# create the signature file\r\n# basisFilePath -> Path to the file for which signature must be generated\r\n# sigFilePath -> Where to store the signature file\r\nsignature.createSignature(basisFilePath=\"path_to_file\", sigFilePath=\"path_to_signature_file\")\r\n\r\n# This machine sends over the signature file to the remote machine\r\n# The remote machine responds back with a delta file\r\n# rdiff isn't concerned with how this communication over the network takes place\r\n\r\npatcher = rdiff.patch.Patch()\r\n# Perform a patch operation\r\n# How the delta file is obtained from the remote machine is not a concern of rdiff\r\n# deltaFilePath -> Path to the delta file obtained from the remote machine\r\n# basisFilePath -> Path to the file which is to be updated\r\n# outFilePath -> Path to store the updated file\r\n# Note: The original file isn't modified, instead a new file is created.\r\npatcher.patchFile(\r\n    deltaFilePath=\"path_to_delta_file\", basisFilePath=\"path_to_file\", outFilePath=\"path_to_updated_file\"\r\n)\r\n\r\n```\r\nThe following shows the usage of rdiff on machine B\r\n```python\r\nimport rdiff\r\n\r\n# create an instance of the checksum class\r\nchecksum = rdiff.signature.Checksum()\r\n\r\n# create an instance of the delta class\r\ndelta = rdiff.delta.Delta()\r\n\r\n# The createDelatFile method is used to create a delta file, for a given file\r\n# against a signature file obtained from a remote machine.\r\n# inFilePath -> Path to the updated file, the file which the remote machine wants to synchronise\r\n# deltatFilePath -> Path to store the delta file\r\n# sigFielPath -> Path to the signature file obtained from the remote machine.\r\n# rdiff is not concerned with how this signature file is obtained.\r\n# blocksize -> This should be identical to the blocksize used by the remote machine to generate the\r\n# signature file.\r\ndelta.createDeltaFile(\r\n    inFilePath=\"path_to_updated_file\", deltaFilePath=\"path_to_delta_file\",\r\n    sigFielPath=\"path_to_sig_file\", blockSize=1024, checksum=checksum\r\n)\r\n\r\n# This machine now sends the delta file to the remote machine.\r\n\r\n```\r\nThe following is a combined example, on a single machine. The code can be extended to two remote\r\nmachines.\r\n```python\r\n\"\"\"\r\nAssume there are two machines, machine A and machine B.\r\nMachine A and machine B both have different versions of test.txt\r\nMachine A wants to sync its file to have the same content as the file on machine B.\r\n\r\nMachine A creates a signature file and sends it over to machine B.\r\nMachine B uses this signature file and generates a delta file against the signature file\r\nand sends the delta file back to machine A.\r\n\r\nMachine A now uses this delta file to patch its file. Thereby, synchronising its file to have\r\nthe same content as the file on machine B.\r\n\r\nThe following is an example on a single machine. The same example can be extended to two\r\ndifferent machines connected over a network.\r\n\"\"\"\r\nimport rdiff\r\n\r\nchecksum = rdiff.signature.Checksum()\r\nsignature = rdiff.signature.Signature(checksum=checksum, blockSize=1024)\r\n\r\n# Machine A making the signature file\r\nsignature.createSignature(basisFilePath=\"path_to_file\", sigFilePath=\"path_to_sig_file\")\r\n\r\ndelta = rdiff.delta.Delta()\r\n# Machine B creates the delta file using the signature file generated by Machine A\r\ndelta.createDeltaFile(\r\n    inFilePath=\"path_to_updated_file\", deltaFilePath=\"path_to_delta_file\",\r\n    sigFielPath=\"path_to_sig_file\", blockSize=1024, checksum=checksum\r\n)\r\n\r\npatcher = rdiff.patch.Patch()\r\n# Machine A patches its file (creates a new version of the file located at path_to_updated_file)\r\n# using the delta file generated by Machine B\r\npatcher.patchFile(\r\n    deltaFilePath=\"path_to_delta_file\", basisFilePath=\"path_to_file\",\r\n    outFilePath=\"path_to_updated_file\"\r\n)\r\n\r\n```\r\n\r\n## File Formats\r\nInformation on the format/structure of the different files involved can be found at:\r\nhttps://github.com/MohitPanchariya/rdiff/blob/master/file_formats.md\r\n\r\n## Further Reading\r\nMore about the rsync algorithm can be found at: https://rsync.samba.org/tech_report/tech_report.html\r\n<br>\r\nA detailed explanation of the rsync algorithm is present in the PhD thesis of Andrew Tridgell, specifically\r\nchapter 3 of the thesis: https://www.samba.org/~tridge/phd_thesis.pdf\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A native python implementation of the rdiff tool by librsync",
    "version": "0.2.3",
    "project_urls": {
        "Homepage": "https://github.com/MohitPanchariya/rdiff"
    },
    "split_keywords": [
        "rdiff",
        " librsync",
        " native",
        " python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e13f505072687b170e4483a41af5e8b2d5664dd978f4e9f117d5fa97a6e5a545",
                "md5": "6ed9b05f9bcd01cd50cdae82c4c93ad4",
                "sha256": "b849e2c717f4ac5a2fbb59e6475179fd910d0ccd9fc658a3da2367312f35921e"
            },
            "downloads": -1,
            "filename": "rdiff-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6ed9b05f9bcd01cd50cdae82c4c93ad4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10295,
            "upload_time": "2024-03-24T06:43:10",
            "upload_time_iso_8601": "2024-03-24T06:43:10.733333Z",
            "url": "https://files.pythonhosted.org/packages/e1/3f/505072687b170e4483a41af5e8b2d5664dd978f4e9f117d5fa97a6e5a545/rdiff-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "84687ed3d2cbdc1572c555e8e8f0f99dafb86b377d0750f388d9497787e02e4b",
                "md5": "39959c6f2f0aa84978c6e723edf24c56",
                "sha256": "60a1f3c7ee1d745f86f924cfc1f162f84c03e994cb6269b6ce4178b62d9654f9"
            },
            "downloads": -1,
            "filename": "rdiff-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "39959c6f2f0aa84978c6e723edf24c56",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 10434,
            "upload_time": "2024-03-24T06:43:12",
            "upload_time_iso_8601": "2024-03-24T06:43:12.010180Z",
            "url": "https://files.pythonhosted.org/packages/84/68/7ed3d2cbdc1572c555e8e8f0f99dafb86b377d0750f388d9497787e02e4b/rdiff-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-24 06:43:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MohitPanchariya",
    "github_project": "rdiff",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "rdiff"
}
        
Elapsed time: 0.23499s