Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: psf/black@stable
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- run: pip install ruff
- run: ruff check .
- run: ruff format --check .
29 changes: 12 additions & 17 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
Expand All @@ -9,23 +6,21 @@ on:

jobs:
deploy:

runs-on: ubuntu-latest
name: upload release to PyPI
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Install build dependencies
run: python -m pip install --upgrade pip build
- name: Build package
run: python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
21 changes: 0 additions & 21 deletions .github/workflows/run-codecov.yml

This file was deleted.

20 changes: 7 additions & 13 deletions .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Run pytests

on:
push:
branches: [dev]
branches: [master, dev]
pull_request:
branches: [master]

Expand All @@ -11,25 +11,19 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.6, 3.9]
python-version: ["3.8", "3.14"]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install dev dependencies
run: if [ -f requirements/requirements-dev.txt ]; then pip install -r requirements/requirements-dev.txt; fi

- name: Install test dependencies
run: if [ -f requirements/requirements-test.txt ]; then pip install -r requirements/requirements-test.txt; fi

- name: Install attmap
run: python -m pip install .
- name: Install package with test dependencies
run: python -m pip install ".[test]"

- name: Run pytest tests
run: pytest tests --cov=./ --cov-report=xml
run: pytest tests
21 changes: 0 additions & 21 deletions .pre-commit-config.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

56 changes: 52 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,56 @@
# attmap

[![Build Status](https://travis-ci.org/pepkit/attmap.svg?branch=master)](https://travis-ci.org/pepkit/attmap)
[![Coverage Status](https://coveralls.io/repos/github/pepkit/attmap/badge.svg?branch=master)](https://coveralls.io/github/pepkit/attmap?branch=master)
[![Run pytests](https://github.com/pepkit/attmap/actions/workflows/run-pytest.yml/badge.svg)](https://github.com/pepkit/attmap/actions/workflows/run-pytest.yml)

Key-value Mapping supporting nesting and attribute-style access
Key-value Mapping supporting nesting and attribute-style access.

Originally motivated by and designed for the [pepkit family projects](https://pepkit.github.io/).
**Note:** This package is no longer actively developed. Consider using plain dicts or dataclasses for new projects.

Originally designed for the [pepkit family projects](https://pepkit.github.io/).

## Install

```
pip install attmap
```

## Class hierarchy

- `AttMapLike` (abstract base)
- `AttMap` — dict-backed mapping with dot notation access
- `OrdAttMap` — insertion-ordered (extends `OrderedDict`)
- `PathExAttMap` — expands environment variables in path-like string values
- `EchoAttMap` — returns the key itself when a value is not set

## Customizing subclasses

### Excluding keys from text representation

Override `_excl_from_repr` in a subclass:

```python
def _excl_from_repr(self, k, cls):
protected = ["reserved_metadata", "REZKEY"]
return k in protected
```

### Excluding class name from repr

Override `__repr__` using the `exclude_class_list` argument to `_render`:

```python
def __repr__(self):
return self._render(
self._simplify_keyvalue(self._data_for_repr(), self._new_empty_basic_map),
exclude_class_list="YacAttMap",
)
```

### Excluding classes from `to_dict` conversion

Override `_excl_classes_from_todict`:

```python
def _excl_classes_from_todict(self):
return (pandas.DataFrame, ClassToExclude)
```
3 changes: 1 addition & 2 deletions attmap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
""" Package-scope definitions """
"""Dot notation support for Mappings."""

from ._att_map_like import AttMapLike
from ._version import __version__
from .attmap import AttMap
from .attmap_echo import *
from .helpers import *
Expand Down
Loading