Skip to content

Commit

Permalink
Merge pull request #142 from sparkmicro/1.0.0rc
Browse files Browse the repository at this point in the history
1.0.0rc
  • Loading branch information
eeintech authored Mar 29, 2023
2 parents cdb24b5 + 8e22d99 commit 211b349
Show file tree
Hide file tree
Showing 44 changed files with 796 additions and 1,894 deletions.
62 changes: 20 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Ki-nTree
### Fast part creation in [KiCad](https://kicad.org/) and [InvenTree](https://inventree.readthedocs.io/)
# <img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/logo.png" width="auto" height="auto"> Ki-nTree
### Fast part creation in [KiCad](https://kicad.org/) and [InvenTree](https://inventree.org/)
[![License: GPL v3.0](https://img.shields.io/badge/license-GPL_v3.0-green.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Python Versions](https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/python_versions.svg)](https://www.python.org/)
[![PyPI](https://img.shields.io/pypi/v/kintree)](https://pypi.org/project/kintree/)
Expand All @@ -8,17 +8,15 @@

## New version (1.0) is coming soon!

To install the beta release:
To install the release candidate:
``` shell
pip install --pre -U kintree
```

<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/kintree_v1_preview.png" width="auto" height="auto">
<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/kintree_v1_example.png" width="auto" height="auto">

## Demo Videos :fast_forward: [Full Demo](https://youtu.be/haSAu926BOI) :fast_forward: [KiCad Demo](https://youtu.be/NSMfCCD0uVw)

<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/kintree_example.png" width="auto" height="auto">

## Introduction
Ki-nTree (pronounced "Key Entry" or "Key 'n' Tree") aims to:
* automate part creation of KiCad library parts
Expand All @@ -27,15 +25,18 @@ Ki-nTree (pronounced "Key Entry" or "Key 'n' Tree") aims to:

Ki-nTree works with:
- [Digi-Key](https://developer.digikey.com/), [Mouser](https://www.mouser.com/api-hub/), [Element14](https://partner.element14.com/docs) and [LCSC](https://lcsc.com/) **enormous** part databases and free APIs
- the awesome open-source [Digi-Key API python library](https://github.com/peeter123/digikey-api) built and maintained by [@peeter123](https://github.com/peeter123)
- the awesome open-source [InvenTree Inventory Management System](https://github.com/inventree/inventree) built and maintained by [@SchrodingersGat](https://github.com/SchrodingersGat) and [@matmair](https://github.com/matmair)
- the reliable and SCM-friendly KiCad file parser [KiUtils](https://github.com/mvnmgrx/kiutils) built and maintained by [@mvnmgrx](https://github.com/mvnmgrx)
- the amazing [Digi-Key API python library](https://github.com/peeter123/digikey-api) built and maintained by [@peeter123](https://github.com/peeter123)
- the [Mouser Python API](https://github.com/sparkmicro/mouser-api/) built and maintained by [@eeintech](https://github.com/eeintech)
- the awesome open-source [InvenTree Inventory Management System](https://github.com/inventree/inventree) built and maintained by [@SchrodingersGat](https://github.com/SchrodingersGat)
- [KiCad](https://www.kicad.org/) (of course!) and their open-source [library utils](https://gitlab.com/kicad/libraries/kicad-library-utils)

> **Important Note**
>
> Because of limited maintenance bandwidth, Ki-nTree versions `0.5.x` and newer will only support KiCad version **6**.
> To keep using Ki-nTree with KiCad version **5**, use older `0.4.x` versions (`pip install kintree==0.4.8`).
> Ki-nTree version `1.0.x` and forward support KiCad versions **6 and up**.
>
> Ki-nTree versions `0.5.x` and `0.6.x` only support KiCad version **6** (`pip install kintree==0.6.6`).
>
> To use with KiCad version **5**, use older Ki-nTree `0.4.x` versions (`pip install kintree==0.4.8`).
Ki-nTree was developped by [@eeintech](https://github.com/eeintech) for [SPARK Microsystems](https://www.sparkmicro.com/), who generously accepted to make it open-source!

Expand Down Expand Up @@ -92,8 +93,6 @@ Ki-nTree is [available on Arch Linux's AUR](https://aur.archlinux.org/packages/p

### Usage Instructions

> :warning: Warning: **KiCad library writer is still in development**: Make sure to open KiCad libraries inside the symbol editor and save them after adding symbols.
#### Before Starting

If you intend to use Ki-nTree with InvenTree, this tool offers to setup the InvenTree category tree with a simple script that you can run as follow:
Expand All @@ -110,7 +109,7 @@ If the InvenTree category tree is **not setup** before starting to use Ki-nTree,

Configuration files are stored in the folder pointed by the `Configuration Files Folder` path in the "User Settings" window:

<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/settings_user_cache.png" width="600" height="auto">
<img src="https://raw.githubusercontent.com/sparkmicro/Ki-nTree/main/images/doc/kintree_v1_settings_user.png" width="600" height="auto">


<details>
Expand All @@ -137,7 +136,7 @@ Below is a summary table of the different configuration files, their function an
| `digikey_categories.yaml` | Mapping between InvenTree categories and Digi-Key categories | :heavy_check_mark: |
| `digikey_parameters.yaml` | Mapping between InvenTree parameters and Digi-Key parameters/attributes | :x: |

> In versions `0.6.x` and older, Ki-nTree only supports matching between InvenTree and Digi-Key categories and parameters/attibutes (help wanted!)
> Ki-nTree only supports matching between InvenTree and Digi-Key categories and parameters/attibutes (help wanted!)
</p>
</details>
Expand Down Expand Up @@ -230,7 +229,7 @@ git clone https://github.com/sparkmicro/Ki-nTree
poetry install
Installing dependencies from lock file
...
Installing the current project: kintree (0.4.99)
Installing the current project: kintree (1.0.99)
```
> Note: the version is not accurate (placeholder only)

Expand All @@ -249,11 +248,11 @@ $ python -m kintree_gui
1. Make sure you followed the previous installation steps, then run:
``` bash
$ poetry build
Building kintree (0.6.99)
Building kintree (1.0.99)
- Building sdist
- Built kintree-0.6.99.tar.gz
- Built kintree-1.0.99.tar.gz
- Building wheel
- Built kintree-0.6.99-py3-none-any.whl
- Built kintree-1.0.99-py3-none-any.whl
```
2. Exit the virtual environment (`Ctrl + D` on Linux; you can also close the
terminal and reopen it in the same folder).
Expand All @@ -262,36 +261,15 @@ Building kintree (0.6.99)
step. For example:

```bash
pip install dist/kintree-0.6.99-py3-none-any.whl
pip install dist/kintree-1.0.99-py3-none-any.whl
```

3. You can now start Ki-nTree by typing `kintree` in the terminal, provided
that your python dist path is a part of your `$PATH`.

## Roadmap

> Priority goes to implementing new features over GUI improvements
> Open to new ideas and pull requests :smiley:

#### Versions 1.0.x or later
(Strikethrough items are supported in V1.0.0 beta1 release)

##### New Features
~~- Revamp category selection based on hierarchical structure from InvenTree ([reference](https://github.com/sparkmicro/Ki-nTree/issues/87))~~
~~- Allow user to decide the category code to use for IPN~~
~~- Enable option to download and save PDF files locally/to internal server storage~~

##### Improvements
~~- Optimize the category search ([reference](https://github.com/sparkmicro/Ki-nTree/issues/104))~~
~~- Migrate KiCad library management to [KiUtils](https://github.com/mvnmgrx/kiutils) ([reference](https://github.com/sparkmicro/Ki-nTree/issues/119))~~
- Add support for KiCad V7 ([reference](https://github.com/sparkmicro/Ki-nTree/issues/120))

##### GUI
~~- Migrate to [Flet](https://github.com/flet-dev/flet) ([reference](https://github.com/sparkmicro/Ki-nTree/issues/37))~~

## License
The Ki-nTree source code is licensed under the [GPL3.0 license](https://github.com/sparkmicro/Ki-nTree/blob/main/LICENSE) as it uses source code under that license:
* https://gitlab.com/kicad/libraries/kicad-library-utils
* https://github.com/mvnmgrx/kiutils
* https://github.com/peeter123/digikey-api

The [KiCad templates](https://github.com/sparkmicro/Ki-nTree/tree/main/kintree/kicad/templates) are licensed under the [Creative Commons CC0 1.0 license](https://github.com/sparkmicro/Ki-nTree/blob/main/kintree/kicad/templates/LICENSE) which means that "you can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission" ([reference](https://creativecommons.org/publicdomain/zero/1.0/)).
Binary file removed images/doc/inventree_example.png
Binary file not shown.
Binary file removed images/doc/kicad_example.png
Binary file not shown.
Binary file removed images/doc/kintree_example.png
Binary file not shown.
Binary file removed images/doc/kintree_gui_example.png
Binary file not shown.
Binary file added images/doc/kintree_v1_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/doc/kintree_v1_preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/doc/kintree_v1_search_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/doc/kintree_v1_settings_user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/doc/settings_user_cache.png
Binary file not shown.
Binary file added images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 12 additions & 5 deletions kintree/database/inventree_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,13 @@ def translate_form_to_inventree(part_info: dict, category_tree: list, is_custom=
inventree_part['image'] = part_info['image'].replace(' ', '%20')

# Load parameters map
parameter_map = config_interface.load_category_parameters(category=category_tree[0],
supplier_config_path=settings.CONFIG_SUPPLIER_PARAMETERS, )
if category_tree:
parameter_map = config_interface.load_category_parameters(
category=category_tree[0],
supplier_config_path=settings.CONFIG_SUPPLIER_PARAMETERS,
)
else:
cprint('[INFO]\tWarning: Parameter map not loaded (no category selected)', silent=settings.SILENT)

if not is_custom:
# Add Parameters
Expand All @@ -270,9 +275,11 @@ def translate_form_to_inventree(part_info: dict, category_tree: list, is_custom=
if inventree_param not in inventree_part['parameters'].keys():
if supplier_param != 'Manufacturer Part Number':
try:
parameter_value = part_tools.clean_parameter_value(category=category_tree[0],
name=supplier_param,
value=part_info['parameters'][supplier_param])
parameter_value = part_tools.clean_parameter_value(
category=category_tree[0],
name=supplier_param,
value=part_info['parameters'][supplier_param],
)
inventree_part['parameters'][inventree_param] = parameter_value
except:
cprint(f'[INFO]\tWarning: Parameter "{supplier_param}" not found in supplier data', silent=settings.SILENT)
Expand Down
16 changes: 14 additions & 2 deletions kintree/gui/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,18 +1238,30 @@ def create_part(self, e=None):

# KiCad data processing
if settings.ENABLE_KICAD and not settings.ENABLE_ALTERNATE:
# Store "pseudo-category" as re-used in multiple places
pseudo_category = symbol.split(':')[0]
# Translate part info if InvenTree not enabled
if not settings.ENABLE_INVENTREE:
part_info = inventree_interface.translate_form_to_inventree(
part_info=part_info,
category_tree=[pseudo_category],
is_custom=custom,
)
# Also add datasheet URL as part page URL
part_info['inventree_url'] = part_info['datasheet']
part_info['Symbol'] = symbol
part_info['Template'] = template.split('/')
part_info['Footprint'] = footprint

symbol_library_path = os.path.join(
settings.KICAD_SETTINGS['KICAD_SYMBOLS_PATH'],
f'{symbol.split(":")[0]}.kicad_sym',
f'{pseudo_category}.kicad_sym',
)

# Reset progress
progress.CREATE_PART_PROGRESS = 0
# Create part
# Add part symbol to KiCAD
cprint('\n[MAIN]\tAdding part to KiCad', silent=settings.SILENT)
kicad_success, kicad_new_part = kicad_interface.inventree_to_kicad(
part_data=part_info,
library_path=symbol_library_path,
Expand Down
Loading

0 comments on commit 211b349

Please sign in to comment.