semvec/pypi-packages huggingface dataset:
pretty-simple-namespace 0.1.1
A pretty printer for SimpleNamespace
Requires Python: >=3.7,<4.0

# Pretty SimpleNamespace

<!-- pypiwarn -->

<br>

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**

- [What is it?](#what-is-it)
- [Why create it?](#why-create-it)
- [Simple usage](#simple-usage)
- [Features](#features)
- [Limitations](#limitations)
- [Related projects](#related-projects)
- [Api](#api)
- [Test](#test)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

<br>

### What is it?

- A stringifier and formatter for SimpleNamespace which attempts to make the
  data as readable as possible.

<br>

### Why create it?

- I use SimpleNamespace often to hold state and needed a way to print it out for
  debugging purposes.

<br>

### Simple usage

```py
from pretty_simple_namespace import pprint
from types import SimpleNamespace as o

joe = o(
    name={"first": "joe", "last": "schmo"},
    age=30,
    favoriteFoods=["apples", "steak"],
)

pprint(joe)
# prints
# {
#   name: {
#     first: 'joe'
#     last: 'schmo'
#   }
#   age: 30
#   favoriteFoods: [
#     'apples'
#     'steak'
#   ]
# }
```

<br>

### Features
- handles recursive structures by tracking and printing references nicely
- recurses into types `list`, `dict` and `SimpleNamespace` for now
- has special-case printing for types `bool`, `str`, `callable` and `None`
  - booleans and None are printed lowercase
  - strings are wrapped in single quotes
  - callable appends `()` e.g. `myMethod()`.  Arguments aren't represented
- all other types are printed by wrapping it in `str` e.g. `str(userDefinedType)`

<br>

### Limitations
- multi-line strings look ugly
- doesn't have a way to recurse into structures other than what's listed above

<br>

### Related projects

- [tedent](https://github.com/olsonpm/py_tedent)

<br>

### Api

#### format(something, indent=2) => str
- formats `something` to a string as seen in [Simple usage](#simple-usage)

#### pprint(something, indent=2) => None
- just prints the formated `something`

#### wrapWith(\*, indent) => [Wrapped module](#wrapped-module)
- use this when you want to call `format` or `pprint` with a different default
  indent value so you don't have to pass it manually all the time.

  e.g.
  ```py
  from pretty_simple_namespace import wrapWith

  pprint = wrapWith(indent=4).pprint
  pprint(o(tabbed4spaces=True))
  # {
  #     tabbed4spaces: true
  # }
  ```

#### Wrapped module
- just an instance of SimpleNamespace with two attributes `format` and `pprint`.

<br>

### Test

```sh
#
# you must have poetry installed
#
$ poetry shell
$ poetry install
$ python runTests.py
```
is-git-repo-clean 0.3.6
A simple function to test whether your git repo is clean
Requires Python: >=3.7,<4.0

## Is Git Repo Clean

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**

- [Intro](#intro)
    - [What is it?](#what-is-it)
    - [Why create it?](#why-create-it)
- [Install](#install)
- [Usage](#usage)
    - [programmatic](#programmatic)
    - [cli](#cli)
- [Api](#api)
    - [`check` async (dir=os.getcwd()) => bool](#check-async-dirosgetcwd--bool)
    - [`checkSync` (dir=os.getcwd()) => bool](#checksync-dirosgetcwd--bool)
    - [`version`](#version)
- [Test](#test)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

<br>

### Intro

#### What is it?

A simple function that tests whether your git repo is clean.

by *clean* I mean it has:
- no untracked files
- no staged changes
- no unstaged changes

Installing this also exposes a cli command `is-git-repo-clean`


#### Why create it?

I wanted to write a build script that would exit early if the git repo
wasn't clean

<br>

### Install

```sh
$ pip install is_git_repo_clean
```

<br>

### Usage

#### programmatic

```python
import is_git_repo_clean


async def isCleanAsync(pathToGitRepo = None):
  # async by default
   return await is_git_repo_clean.check(pathToGitRepo)


def isCleanSync(pathToGitRepo = None):
  # sync available
  return is_git_repo_clean.checkSync(pathToGitRepo)
```

#### cli

```sh
$ is-git-repo-clean --help

Usage
  is-git-repo-clean [--dir <path>] [--silent]
  is-git-repo-clean --help
  is-git-repo-clean --version

Options
  dir:      path to the git repo to test.  Defaults to `os.getcwd()`
  silent:   disables output
  help:     print this
  version:  prints the version of this tool

Returns
  <exit code>: <output>

  0: yes
  1: no
  2: <invalid arg message>
  3: dir is not a git repository
  4: unexpected error occurred <error>
```

<br>

### Api

`is_git_repo_clean` exports the following


#### `check` async (dir=os.getcwd()) => bool
 - an asynchronous function that returns whether the git repo is clean


#### `checkSync` (dir=os.getcwd()) => bool
 - a synchronous function that returns whether the git repo is clean


#### `version`

<br>

### Test

```sh
hub clone olsonpm/py_is-git-repo-clean
cd py_is-git-repo-clean
python runTests.py
```
all-purpose-set 0.1.10
A set that works with both hashable and non-hashable elements
Requires Python: >=3.7,<4.0

# All Purpose Set

<!-- pypiwarn -->

<br>

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**

- [What is it?](#what-is-it)
- [Why create it?](#why-create-it)
- [Simple usage](#simple-usage)
- [See also](#see-also)
- [Api](#api)
- [Test](#test)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

<br>

### What is it?

- A set which doesn't require hashable contents

<br>

### Why create it?

- I often have a need to store non-hashable contents in a set.  For example
  storing a dict isn't possible with the builtin set.

  ```py
  # doesn't work
  someDict = { "key": "value" }
  someSet = { someDict }
  ```

<br>

### Simple usage

```py
from all_purpose_set import ApSet

someDict = { "key": "value" }
someSet = ApSet([someDict])

print(someDict in someSet) # prints True
```

<br>

### See also

- [All Purpose Dict](https://github.com/olsonpm/py_all-purpose-dict)

<br>

### Api

*Note: This api is young and subject to change quite a bit.  There also may be
functionality present in the builtin set which this set doesn't cover.  I'm
willing to add it so please just raise a github issue or PR with details.*

#### class ApSet([a list])
- all methods return `self` unless specified otherwise
- iterates in the order of insertion
- currently the internal methods implemented are
  - \_\_contains\_\_
  - \_\_iter\_\_
  - \_\_len\_\_

##### add(something)

##### clear()

##### has(something) => bool
- a function alternative to `key in aSet`

##### remove(something)
- raises a `KeyError` if the element doesn't exist

<br>

### Test

```sh
#
# you must have poetry installed
#
$ poetry shell
$ poetry install
$ python runTests.py
```
all-purpose-dict 0.2.4
A dict that works with both hashable and non-hashable keys
Requires Python: >=3.7,<4.0

# All Purpose Dict

<!-- pypiwarn -->

<br>

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**

- [What is it?](#what-is-it)
- [Why create it?](#why-create-it)
- [Simple usage](#simple-usage)
- [See Also](#see-also)
- [Api](#api)
- [Test](#test)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

<br>

### What is it?

- A dict which doesn't require hashable keys

<br>

### Why create it?

- I often have a need to store non-hashable keys in a dict.  For example storing
  a dict as a key isn't possible with the builtin dict.

  ```py
  # doesn't work
  someDict = { "key": "value" }
  anotherDict = { someDict: "anotherValue" }
  ```

<br>

### Simple usage

```py
from all_purpose_dict import ApDict

someDict = { "key": "value" }
anotherDict = ApDict([(someDict, "anotherValue")])

print(someDict in anotherDict) # prints True
```

<br>

### See Also

- [All Purpose Set](https://github.com/olsonpm/py_all-purpose-set)

<br>

### Api

*Note: This api is young and subject to change quite a bit.  There also may be
functionality present in the builtin dict which ApDict doesn't cover.  I'm
willing to add it so please just raise a github issue or PR with details.*

#### class ApDict([a list of pairs])
- 'pairs' may be either a list or tuple with a length of 2
- all methods return `self` unless specified otherwise
- iterates in the order of insertion
- views are not implemented because I don't have a need for them. Instead I
  expose `keysIterator` and `valuesIterator`.  If you need views then raise a
  github issue.
- the internal methods implemented are
  - \_\_contains\_\_
  - \_\_delitem\_\_
  - \_\_getitem\_\_
  - \_\_iter\_\_
  - \_\_len\_\_
  - \_\_setitem\_\_

##### clear()

##### delete(key)
- a function alternative to `del aDict[key]`

##### get(key, default=None) => value
- get the value for key if key is in the dictionary, else default.
- *note: this never raises a KeyError.*

##### has(key) => bool
- a function alternative to `key in aDict`

##### getKeysIterator() => ApDictKeysIterator

##### set(key, value)
- a function alternative to `aDict[key] = val`

##### getValuesIterator() => ApDictValuesIterator

<br>

### Test

```sh
#
# you must have poetry installed
#
$ poetry shell
$ poetry install
$ python runTests.py
```