This repository has been archived on 2022-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
python-usda/usda/enums.py

102 lines
2.2 KiB
Python
Raw Normal View History

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"""
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):
"""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"
2019-10-23 18:14:44 +00:00
"""
Contains all the available nutrients.
Only available on Standard Reference items.
"""
2018-10-26 06:29:16 +00:00
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,
'b': cls.basic,
'f': cls.full,
's': cls.stats,
2019-04-26 06:45:43 +00:00
}.get(value, value)
class UsdaNdbDataSource(Enum):
"USDA food data sources"
StandardReference = 'Standard Reference'
2019-10-23 18:14:44 +00:00
"""
Nutritional information for generic food items.
"""
BrandedFoodProducts = 'Branded Food Products'
2019-10-23 18:14:44 +00:00
"""
Nutritional information provided to the USDA by the food industry.
"""