2018-04-13 17:42:28 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
2015-02-05 03:31:17 +00:00
|
|
|
|
|
|
|
from enum import Enum
|
|
|
|
|
|
|
|
|
|
|
|
class UsdaUriActions(Enum):
|
2018-04-21 19:47:37 +00:00
|
|
|
"""USDA API available actions"""
|
2018-10-26 06:29:16 +00:00
|
|
|
|
2015-02-05 03:31:17 +00:00
|
|
|
list = "list"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""Paginated lists of items"""
|
|
|
|
|
2015-02-05 03:31:17 +00:00
|
|
|
report = "reports"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""Food Reports version 1"""
|
|
|
|
|
2018-07-14 09:49:50 +00:00
|
|
|
v2report = "V2/reports"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""Food Reports version 2"""
|
|
|
|
|
2018-07-10 19:29:32 +00:00
|
|
|
nutrients = "nutrients"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""Nutrient Reports"""
|
2018-10-26 13:51:34 +00:00
|
|
|
|
2018-07-11 11:51:55 +00:00
|
|
|
search = "search"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""Paginated lists of items matching a query"""
|
2015-02-05 03:31:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UsdaNdbListType(Enum):
|
2018-04-21 19:47:37 +00:00
|
|
|
"""USDA API food or nutrients list settings"""
|
2018-10-26 06:29:16 +00:00
|
|
|
|
2015-02-05 03:31:17 +00:00
|
|
|
all_nutrients = "n"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""List all known nutrients."""
|
|
|
|
|
2015-02-05 03:31:17 +00:00
|
|
|
specialty_nutrients = "ns"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""
|
|
|
|
List all nutrients not included in the Standard Release database.
|
|
|
|
"""
|
|
|
|
|
2015-02-05 03:31:17 +00:00
|
|
|
standard_release_nutrients = "nr"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""
|
|
|
|
List all nutrients included in the Standard Release database.
|
|
|
|
"""
|
|
|
|
|
2015-02-05 03:31:17 +00:00
|
|
|
food = "f"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""List all food items."""
|
|
|
|
|
2018-07-13 12:37:49 +00:00
|
|
|
food_groups = "g"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""List all food groups."""
|
|
|
|
|
2018-07-13 12:37:49 +00:00
|
|
|
derivation_codes = "d"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""List all derivation codes."""
|
2015-02-05 03:31:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UsdaNdbReportType(Enum):
|
2018-07-10 19:29:32 +00:00
|
|
|
"""USDA API food report types"""
|
2018-10-26 06:29:16 +00:00
|
|
|
|
2015-02-05 03:31:17 +00:00
|
|
|
basic = "b"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""
|
|
|
|
Contains a limited set of nutrients,
|
|
|
|
like what could be found on a product packaging
|
|
|
|
"""
|
|
|
|
|
2015-02-05 03:31:17 +00:00
|
|
|
full = "f"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""Contains all the available nutrients"""
|
|
|
|
|
2018-04-13 17:42:28 +00:00
|
|
|
stats = "s"
|
2018-10-26 06:29:16 +00:00
|
|
|
"""
|
|
|
|
Added statistics data from the Standard Reference database when available.
|
|
|
|
|
|
|
|
.. note::
|
2018-10-26 13:51:34 +00:00
|
|
|
|
2018-10-26 06:29:16 +00:00
|
|
|
The stats report type is currently not fully supported by python-usda.
|
|
|
|
It is however possible to get all the returned data using raw methods
|
|
|
|
on a :class:`usda.client.UsdaClient` instance.
|
|
|
|
"""
|
2019-04-26 06:45:43 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def from_response_data(cls, value):
|
|
|
|
return {
|
|
|
|
'Basic': cls.basic,
|
|
|
|
'Full': cls.full,
|
|
|
|
'Statistics': cls.stats,
|
2019-10-23 17:53:50 +00:00
|
|
|
'b': cls.basic,
|
|
|
|
'f': cls.full,
|
|
|
|
's': cls.stats,
|
2019-04-26 06:45:43 +00:00
|
|
|
}.get(value, value)
|
2019-10-23 18:04:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UsdaNdbDataSource(Enum):
|
|
|
|
"USDA food data sources"
|
|
|
|
|
|
|
|
StandardReference = 'Standard Reference'
|
|
|
|
BrandedFoodProducts = 'Branded Food Products'
|