Metadata-Version: 2.5
Name: utcw
Version: 0.0.1
Summary: Shared utilities for the two-letter packages
Project-URL: Homepage, https://github.com/t-c-w/utcw
Project-URL: Repository, https://github.com/t-c-w/utcw
Author: t-c-w
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: collections,dataframe,strings,utils
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: beautifulsoup4
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: unidecode
Provides-Extra: dev
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# utcw

Shared utilities for the two-letter packages.

```bash
pip install utcw
```

`utcw` holds the common code that several of the two-letter packages (`fg`, `iy`,
`kw`, `lh`, `nh`, `ow`, `xl`, `ya`, `yf`, `ys`, `yw`, `yx`, `yz`, `zr`) depend on.
Those packages previously reached for this code through a toolbox that was never
published, which meant they could be installed but not imported. `utcw` gives that
code a real home on PyPI.

## Layout

Modules are grouped by what they operate on:

| module | what's in it |
|---|---|
| `utcw.pcoll` | order-conserving set operations (`intersect`, `union`, `setdiff`, `reorder_as`, `contains`) and an `OrderedSet` |
| `utcw.pstr` | string transforms (`lower`, `strip`, `toascii`, `to_unicode_or_bust`) and `to.file` |
| `utcw.pdict` | dict manipulation (`rollout`) |
| `utcw.util.ulist` | list helpers (`ascertain_list`, `to_str`, `all_true`) |
| `utcw.pfile` | filename manipulation (`files_of_folder`, `replace_folder_and_ext`) and `to.string` |
| `utcw.pgenerator` | generator helpers (`last_element`) |
| `utcw.daf` | pandas dataframe helpers — `ch` (change), `check`, `get`, `manip`, `dup_diag` |
| `utcw.parse` | HTML/soup parsing (`x_to_soup`, `open_in_firefox`) |
| `utcw.aw` | adwords dataframe manipulation (`add_col`, `order_words`, `strip_kw`) |
| `utcw.dacc.es` | elasticsearch query/retrieval helpers |
| `utcw.util` | `var` (type predicates), `pfunc` (signature filtering), `counter` |

## Examples

```python
>>> from utcw.pcoll.order_conserving import intersect, setdiff
>>> intersect([1, 2, 3, 4], [3, 1])
[1, 3]
>>> setdiff([1, 2, 3], [2])
[1, 3]

>>> from utcw.pstr.trans import toascii, strip
>>> toascii('café crème')
'cafe creme'
>>> strip('  a   b  ')
'a b'

>>> from utcw.pdict.manip import rollout
>>> rollout({'a': [{'x': 1}, {'x': 2}], 'b': 'B'}, 'a')
[{'a.x': 1, 'b': 'B'}, {'a.x': 2, 'b': 'B'}]
```

```python
>>> import pandas as pd
>>> from utcw.daf.get import rows_with_col_values_in
>>> df = pd.DataFrame({'a': [1, 2, 3], 'b': list('xyz')})
>>> rows_with_col_values_in(df, 'a', [1, 3])['b'].tolist()
['x', 'z']
```

## Notes

This is vendored code, extracted as the transitive closure of what the two-letter
packages actually reference — not a curated library. It is published so those
packages can declare a real dependency instead of an unsatisfiable one. Expect
the API to be stable (nothing new depends on it) rather than polished.

Two Python-2-era breakages were repaired during extraction: `utcw.pfile.to.string`
used the removed `file()` builtin, and `utcw.parse.util.x_to_soup` reached it
through a module-level name that no longer resolved.
