Metadata-Version: 2.4
Name: sets-operation-over-files
Version: 0.1.3
Summary: Set operate over files which contains set of lines
Author-email: weaming <garden.yuen@gmail.com>
Project-URL: Bug Reports, https://github.com/weaming/sets
Project-URL: Source, https://github.com/weaming/sets
Keywords: set,cli
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# Sets

Set operations over files where each line is an element.

`pip3 install -U sets-operation-over-files`

```
$ sets 'set_a | set_b' -s
a
b
c
d
e
f
g
h
i
j
```

## Usage

An expression supports `|` (union), `&` (intersection), `-` (difference),
`^` (symmetric difference), `and`/`or`, and parentheses:

```
$ sets 'set_a & set_b'
```

File names can be quoted to allow spaces and special characters:
`sets "'my list.txt' | other"`. Output keeps the left operand's line order;
`-s` sorts it.

## How it works

The expression is parsed into an AST instead of string-replaced. Identifiers
and quoted strings are rewritten to file reads — `set_a & set_b`
becomes `s('set_a') & s('set_b')` — then evaluated with only the
`s` function exposed and builtins disabled.

A whitelist guard rejects any node outside set-expression syntax (`Attribute`,
`Lambda`, `Subscript`, ...), so the expression cannot run arbitrary code.
Files are read into an order-preserving set (`OrderedSet`), so results keep
the left operand's line order across runs.
