semvec/pypi-packages huggingface dataset:
ShortDiff 0.1.3
A simple one way diff tool

# ShortDiff

This is a Python implementation of a diff algorithm.
It aims at producing one-way as-short-as-possible patch 
to go from a file to another.
This is useful to keep track of modifications in a text file without
keeping a copy of each state (this is the easy part of version control).
This produce shorter patch than any output from the GNU diff tool.
Since it is one-way only, the patch to go from A to B does not permit to
to go from B to A.

# Disclaimer

This algorithm have a time complexity of O(N\*M) (where N and M are the
number of line of each file) and is implemented in pure python.
There performances are not great.
You should probably not use it in any serious project.
I wrote it for educational purpose and I use it in a really small
scale project.

Still for educational project there are more naive version in the archive
directory. The final module is a refinment of these.

# Installation

Use pip to install it or copy this directory in a relevant place
if you know what you are doing.

`pip install ShortDiff`

# Usage

## CLI

Create a patch

```
python -m ShortDiff diff FILA_A [FILE_B]
```

Create the patch to go from A to B. If FILE_B is ommited, its content
is expected from the standard input.
Output the patch to standard output.

Apply a patch

```
python -m ShortDiff patch PATCH [FILE]
```
Apply PATCH to FILE. If FILE is ommited, apply patch to standard input.
Result is printed to standard output.

## API

Functions can be imported from the module to be used in other apps.
Useful functions include:

- `differ(old, new)`: (low level) take to arbitrary sequences and return the Levenstein distance and
  the path from one to another as a sequence of pairs (position in old, position in new).
  If the position in old is the same in two consecutive pair, it correspond to an insertion.
  If the position in new is the same in two consecutive pair, it correspond to a deletion.
  Else it correspond to an unmodified chunk.
  Path is made so to consecutive operations cannot be of the same kind (a deletion cannot be
  immediatly followed by another deletion).

- `get_chunks(old_txt, new_txt)`: (high level) generator taking two strings and compute the live diff.
  It yields 4 elements tuples `(kind, start, stop, content)`. `kind` is one of `'d'` (deletion) `'i'` (insertion)
  and `'k'` (keep/unmodified). `start` and `stop` are the line number boundaries of the chunk concerned by the 
  operations in `old_txt` for deletion and keep and in `new_txt` for insertion. `content` is the list of lines of
  the chunk.

- `create_patch(old_txt, new_txt)`: (high level) return the patch as printed by the CLI
- `apply_patch(old_txt, patch)`: (high level) return the result of applying `patch` to `old_txt`
loadsave 0.0.3
One-line loading and saving to/from various file formats (csv, wav, pkl, json)

# Datastore
### Currently supported file structures: CSV WAV JSON PICKLE
Python module which loads and saves data structures based on the file extension.

### Dependencies
* Python3 (and native libraries)
  * json
  * csv
  * wave
  * struct
  * importlib
  * os
  * pickle


### Installation
`pip install loadsave`

### Usage

```
import loadsave

data = loadsave.load(filename)
... manipulating data ...
loadsave.save(data, filename)

```
Saving data can be a bit unintuitive.
* `csv` requires data to be a list of dictionaries
* `wav` requires data to be a tuple or list of the form `(y,sr)` exactly how it would be returned by `load('example.wav')`



### Objective
This module attempts to follow a **generic procedure for reading and writing common data storage formats using only the file extension for guidance**.

The motivation here is as follows; Most of the time, the most generic approach to opening a file will work. It's may not be the most computationaly efficient way, but if loading time is not a bottleneck for your workflow, you might as well spend your time manipulating the data as opposed figuring out how to load it into python. The goal of Datastore is to make implementing these generic approaches as fast as possible. If it doesn't work, well at least you didn't waste much time. Otherwise, you just skipped a monotonous task and can get on with real work.




### Example
```
import loadsave

d = [{'id': [1,2,3,4],'otherID':[4,3,2,1]}]

# save this dict as a pickle
loadsave.save(d, 'test.pkl')
```
`'test.pkl'` can be replaced with `'test.json'`, or `'test.csv'`. Attempting to save it to `'test.wav'` will return an error, because `d` is not an acceptable format for an audio waveform.

However, if `d = [0,1,2,3,4]` you could call `loadsave.save((d,44100),'test.wav')`. `csv`s require a list of dictionaries, so trying to save _this_ as a csv will fail




### File Types
#### CSV
* This is just a wrapper for csv.DictReader() / csv.DictWritter()
* The data must be a list of dictionaries
#### WAV
* Restricted to 16-bit audio
* Can handle stereo/multi-channel waveforms
* Data must be a list or tuple of the form (waveform, samplerate), just like it is provided from `loadsave.load('example.wav')`
#### PICKLE
* This should work with any data structure in python.
#### JSON
* Can hanle `dict`, `list`, `str`, `int`, `float`, `bool`, and `None`