Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/0.25.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
SebRut committed Feb 10, 2021
2 parents ae0021f + 7430b8d commit 042063b
Show file tree
Hide file tree
Showing 14 changed files with 213 additions and 135 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ html/
build/
pygrocy.egg-info/


.tox/
.coverage
9 changes: 7 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3.8
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.7.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
31 changes: 22 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
language: python
python:
- '3.8'
language: minimal
dist: focal

env:
global:
# Doctr deploy key for SebRut/pygrocy
- secure: "YoHepp7ZFuwmdlghnhwT7aczFamnuwTrAuOyXuhxV9bX9eqziurL5K39R04OD5hdPcbNXoVos1YbE4hBGFQpAk6ReiBqqhh+3qDw/HeEpZxRX9dISw+74Nu9kAYXNR8Ab5Zcov85IV3xvTqpawMeBpiXBuJFTbdvZbWhN1jglpR4D9VG//LaNjR/FbCH/41xzpuK3L1mSCQM3jJSSxPU7ZfkWzNvsGj1X///m3la3gR7DL1M4QC9hnzKF6KRNl0kVUuNnK8GhT66ZBGaCVDTqQeDQGTrjsCGuCsQnoydVV2XFwljZ3B6qE27ZqhehlloK2s8/go18zAuj9HpdkTx0RzeUOkxIDp9hAnAys4iGz7Ltk+sx0jGbNsv2Z8oHBgDhv6mu/0UMwD1dL83ZL3L0qWDJfDY3NZSlV0oW9ZPz5ZG8ObnnKKh4vHfp7HUpp/ElYEio7JzQit4FI7gnZRDFEAeH/NvwX8+t0SGXITyyn2U2X5Hz7TUe3laNaDe6Bq59+jebnRdTttuhyoXcMHtjm9HerqRussV+2jyTUf+ktWOFZFjavqUSj6k3iV9yKrgYwfW2+tsaOBZqEHwkRkd5DbNFLvkd0+NEBRfsJV4v51z9QdES3FlPpY/nPqORVkPCLxriCWLf+lTtYi6rtjixvvc4poFFz6WTNILwuOLqrs="
- GROCY_MODE=demo

addons:
apt:
update: true
packages:
- python3.8
- python3
- python3-pip
- python3-setuptools
- python3-wheel
- tox

services:
- docker

before_install:
- git clone --branch v2.7.1-4 https://github.com/grocy/grocy-docker.git
- git clone --branch v3.0.1-8 https://github.com/grocy/grocy-docker.git
- cd grocy-docker
- docker-compose pull
- GROCY_MODE=demo docker-compose up -d
- docker-compose up -d
- curl http://localhost
- cd ..
- pip3 install virtualenv==20.0.23 --force-reinstall

install:
- pip install -r requirements.txt
- pip install -r requirements-dev.txt
- pip install coveralls
- pip3 install -r requirements.txt
- pip3 install -r requirements-dev.txt
- pip3 install coveralls

script:
- coverage run --source=pygrocy setup.py test
- tox
- set -e
- pdoc3 --html pygrocy

Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [v0.25.0](https://github.com/SebRut/pygrocy/tree/v0.25.0) (2021-02-10)

[Full Changelog](https://github.com/SebRut/pygrocy/compare/v0.24.1...v0.25.0)

**Merged pull requests:**

- Grocy 3.0.0+ support [\#146](https://github.com/SebRut/pygrocy/pull/146) ([SebRut](https://github.com/SebRut))
- Update iso8601 requirement from ~=0.1.13 to ~=0.1.14 [\#144](https://github.com/SebRut/pygrocy/pull/144) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
- use tox [\#143](https://github.com/SebRut/pygrocy/pull/143) ([SebRut](https://github.com/SebRut))
- Update coveralls requirement from ~=2.1.2 to ~=3.0.0 [\#142](https://github.com/SebRut/pygrocy/pull/142) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
- Update pdoc3 requirement from ~=0.9.1 to ~=0.9.2 [\#141](https://github.com/SebRut/pygrocy/pull/141) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))

## [v0.24.1](https://github.com/SebRut/pygrocy/tree/v0.24.1) (2020-11-16)

[Full Changelog](https://github.com/SebRut/pygrocy/compare/v0.24.0...v0.24.1)
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![PyPI](https://img.shields.io/pypi/v/pygrocy.svg)](https://pypi.org/project/pygrocy/)
[![Coverage Status](https://coveralls.io/repos/github/SebRut/pygrocy/badge.svg?branch=master)](https://coveralls.io/github/SebRut/pygrocy?branch=master)
[![CodeFactor](https://www.codefactor.io/repository/github/sebrut/pygrocy/badge)](https://www.codefactor.io/repository/github/sebrut/pygrocy)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSebRut%2Fpygrocy.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FSebRut%2Fpygrocy?ref=badge_shield)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)

[Documentation](https://sebrut.github.io/pygrocy/)
Expand Down Expand Up @@ -44,6 +43,3 @@ You can setup url, port and ssl in test/test_const.py
docker-compose up -d
curl -kX GET https://localhost
```

## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSebRut%2Fpygrocy.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FSebRut%2Fpygrocy?ref=badge_large)
4 changes: 2 additions & 2 deletions pygrocy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
The pygrocy module
"""
from .grocy import Grocy
from .grocy_api_client import TransactionType
from .grocy import Grocy # noqa: F401
from .grocy_api_client import TransactionType # noqa: F401

name = "pygrocy"
23 changes: 17 additions & 6 deletions pygrocy/data_models/product.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from datetime import datetime
from typing import List

from pygrocy.base import DataModel
from pygrocy.grocy_api_client import CurrentStockResponse, MissingProductResponse, ProductDetailsResponse, \
GrocyApiClient, LocationData, ShoppingListItem
from pygrocy.grocy_api_client import (
CurrentStockResponse,
GrocyApiClient,
LocationData,
MissingProductResponse,
ProductBarcode,
ProductDetailsResponse,
ShoppingListItem,
)


class Product(DataModel):
Expand Down Expand Up @@ -33,7 +41,6 @@ def _init_from_CurrentStockResponse(self, response: CurrentStockResponse):
self._best_before_date = response.best_before_date
if response.product:
self._name = response.product.name
self._barcodes = response.product.barcodes
self._product_group_id = response.product.product_group_id

def _init_from_MissingProductResponse(self, response: MissingProductResponse):
Expand All @@ -47,13 +54,13 @@ def _init_from_ProductDetailsResponse(self, response: ProductDetailsResponse):
self._available_amount = response.stock_amount
self._best_before_date = response.next_best_before_date
self._name = response.product.name
self._barcodes = response.product.barcodes
self._barcodes = response.barcodes

def get_details(self, api_client: GrocyApiClient):
details = api_client.get_product(self.id)
if details:
self._name = details.product.name
self._barcodes = details.product.barcodes
self._barcodes = details.barcodes
self._product_group_id = details.product.product_group_id

@property
Expand All @@ -78,6 +85,10 @@ def best_before_date(self) -> datetime:

@property
def barcodes(self) -> List[str]:
return [barcode.barcode for barcode in self.product_barcodes]

@property
def product_barcodes(self) -> List[ProductBarcode]:
return self._barcodes

@property
Expand Down Expand Up @@ -138,4 +149,4 @@ def note(self) -> str:

@property
def product(self) -> Product:
return self._product
return self._product
78 changes: 44 additions & 34 deletions pygrocy/grocy.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
from datetime import datetime
from enum import Enum
from typing import List, Dict
from typing import List

from .base import DataModel
import deprecation

from .base import DataModel # noqa: F401
from .data_models.chore import Chore
from .data_models.meal_items import RecipeItem, MealPlanItem
from .data_models.product import Product, Group, ShoppingListProduct
from .data_models.meal_items import MealPlanItem, RecipeItem
from .data_models.product import Group, Product, ShoppingListProduct
from .data_models.task import Task
from .data_models.user import User
from .grocy_api_client import (
DEFAULT_PORT_NUMBER,
ChoreDetailsResponse,
CurrentChoreResponse,
CurrentStockResponse,
GrocyApiClient,
LocationData,
MissingProductResponse,
ProductDetailsResponse,
MealPlanResponse,
RecipeDetailsResponse,
ShoppingListItem,
TransactionType,
UserDto,
TaskResponse,
)
from .data_models.user import User # noqa: F401
from .grocy_api_client import ChoreDetailsResponse # noqa: F401
from .grocy_api_client import CurrentChoreResponse # noqa: F401
from .grocy_api_client import CurrentStockResponse # noqa: F401
from .grocy_api_client import LocationData # noqa: F401
from .grocy_api_client import MealPlanResponse # noqa: F401
from .grocy_api_client import MissingProductResponse # noqa: F401
from .grocy_api_client import ProductDetailsResponse # noqa: F401
from .grocy_api_client import RecipeDetailsResponse # noqa: F401
from .grocy_api_client import ShoppingListItem # noqa: F401
from .grocy_api_client import TaskResponse # noqa: F401
from .grocy_api_client import UserDto # noqa: F401
from .grocy_api_client import DEFAULT_PORT_NUMBER, GrocyApiClient, TransactionType


class Grocy(object):
Expand All @@ -37,32 +34,45 @@ def stock(self) -> List[Product]:
stock = [Product(resp) for resp in raw_stock]
return stock

@deprecation.deprecated(details="Use due_products instead")
def expiring_products(self, get_details: bool = False) -> List[Product]:
raw_expiring_product = self._api_client.get_volatile_stock().expiring_products
expiring_product = [Product(resp) for resp in raw_expiring_product]
return self.due_products(get_details)

def due_products(self, get_details: bool = False) -> List[Product]:
raw_due_prodcuts = self._api_client.get_volatile_stock().due_products
due_products = [Product(resp) for resp in raw_due_prodcuts]

if get_details:
for item in due_products:
item.get_details(self._api_client)
return due_products

def overdue_products(self, get_details: bool = False) -> List[Product]:
raw_overdue_products = self._api_client.get_volatile_stock().overdue_products
overdue_products = [Product(resp) for resp in raw_overdue_products]

if get_details:
for item in expiring_product:
for item in overdue_products:
item.get_details(self._api_client)
return expiring_product
return overdue_products

def expired_products(self, get_details: bool = False) -> List[Product]:
raw_expired_product = self._api_client.get_volatile_stock().expired_products
expired_product = [Product(resp) for resp in raw_expired_product]
raw_expired_products = self._api_client.get_volatile_stock().expired_products
expired_products = [Product(resp) for resp in raw_expired_products]

if get_details:
for item in expired_product:
for item in expired_products:
item.get_details(self._api_client)
return expired_product
return expired_products

def missing_products(self, get_details: bool = False) -> List[Product]:
raw_missing_product = self._api_client.get_volatile_stock().missing_products
missing_product = [Product(resp) for resp in raw_missing_product]
raw_missing_products = self._api_client.get_volatile_stock().missing_products
missing_products = [Product(resp) for resp in raw_missing_products]

if get_details:
for item in missing_product:
for item in missing_products:
item.get_details(self._api_client)
return missing_product
return missing_products

def product(self, product_id: int) -> Product:
resp = self._api_client.get_product(product_id)
Expand Down
Loading

0 comments on commit 042063b

Please sign in to comment.