fixed tinydb error

This commit is contained in:
Hayden 2021-01-12 18:43:17 -09:00
commit f5e64b425b
22 changed files with 924 additions and 133 deletions

588
.pylintrc Normal file
View file

@ -0,0 +1,588 @@
[MASTER]
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=
# Specify a score threshold to be exceeded before program exits with error.
fail-under=10.0
# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS
# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use.
jobs=1
# Control the amount of potential inferred values when inferring a single
# object. This can help the performance when dealing with large functions or
# complex, nested conditions.
limit-inference-results=100
# List of plugins (as comma separated values of python module names) to load,
# usually to register additional checkers.
load-plugins=
# Pickle collected data for later comparisons.
persistent=yes
# When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages.
suggestion-mode=yes
# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no
[MESSAGES CONTROL]
# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.
confidence=
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once). You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=print-statement,
parameter-unpacking,
unpacking-in-except,
old-raise-syntax,
backtick,
long-suffix,
old-ne-operator,
old-octal-literal,
import-star-module-level,
non-ascii-bytes-literal,
raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
apply-builtin,
basestring-builtin,
buffer-builtin,
cmp-builtin,
coerce-builtin,
execfile-builtin,
file-builtin,
long-builtin,
raw_input-builtin,
reduce-builtin,
standarderror-builtin,
unicode-builtin,
xrange-builtin,
coerce-method,
delslice-method,
getslice-method,
setslice-method,
no-absolute-import,
old-division,
dict-iter-method,
dict-view-method,
next-method-called,
metaclass-assignment,
indexing-exception,
raising-string,
reload-builtin,
oct-method,
hex-method,
nonzero-method,
cmp-method,
input-builtin,
round-builtin,
intern-builtin,
unichr-builtin,
map-builtin-not-iterating,
zip-builtin-not-iterating,
range-builtin-not-iterating,
filter-builtin-not-iterating,
using-cmp-argument,
eq-without-hash,
div-method,
idiv-method,
rdiv-method,
exception-message-attribute,
invalid-str-codec,
sys-max-int,
bad-python3-import,
deprecated-string-function,
deprecated-str-translate-call,
deprecated-itertools-function,
deprecated-types-field,
next-method-defined,
dict-items-not-iterating,
dict-keys-not-iterating,
dict-values-not-iterating,
deprecated-operator-function,
deprecated-urllib-function,
xreadlines-attribute,
deprecated-sys-function,
exception-escape,
comprehension-escape
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=c-extension-no-member
[REPORTS]
# Python expression which should return a score less than or equal to 10. You
# have access to the variables 'error', 'warning', 'refactor', and 'convention'
# which contain the number of messages in each category, as well as 'statement'
# which is the total number of statements analyzed. This score is used by the
# global evaluation report (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details.
#msg-template=
# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio). You can also give a reporter class, e.g.
# mypackage.mymodule.MyReporterClass.
output-format=text
# Tells whether to display a full report or only the messages.
reports=no
# Activate the evaluation score.
score=yes
[REFACTORING]
# Maximum number of nested blocks for function / method body
max-nested-blocks=5
# Complete name of functions that never returns. When checking for
# inconsistent-return-statements if a never returning function is called then
# it will be considered as an explicit return statement and no message will be
# printed.
never-returning-functions=sys.exit
[STRING]
# This flag controls whether inconsistent-quotes generates a warning when the
# character used as a quote delimiter is used inconsistently within a module.
check-quote-consistency=no
# This flag controls whether the implicit-str-concat should generate a warning
# on implicit string concatenation in sequences defined over several lines.
check-str-concat-over-line-jumps=no
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
notes=FIXME,
XXX,
TODO
# Regular expression of note tags to take in consideration.
#notes-rgx=
[SPELLING]
# Limits count of emitted suggestions for spelling mistakes.
max-spelling-suggestions=4
# Spelling dictionary name. Available dictionaries: none. To make it work,
# install the python-enchant package.
spelling-dict=
# List of comma separated words that should not be checked.
spelling-ignore-words=
# A path to a file that contains the private dictionary; one word per line.
spelling-private-dict-file=
# Tells whether to store unknown words to the private dictionary (see the
# --spelling-private-dict-file option) instead of raising a message.
spelling-store-unknown-words=no
[BASIC]
# Naming style matching correct argument names.
argument-naming-style=snake_case
# Regular expression matching correct argument names. Overrides argument-
# naming-style.
#argument-rgx=
# Naming style matching correct attribute names.
attr-naming-style=snake_case
# Regular expression matching correct attribute names. Overrides attr-naming-
# style.
#attr-rgx=
# Bad variable names which should always be refused, separated by a comma.
bad-names=foo,
bar,
baz,
toto,
tutu,
tata
# Bad variable names regexes, separated by a comma. If names match any regex,
# they will always be refused
bad-names-rgxs=
# Naming style matching correct class attribute names.
class-attribute-naming-style=any
# Regular expression matching correct class attribute names. Overrides class-
# attribute-naming-style.
#class-attribute-rgx=
# Naming style matching correct class names.
class-naming-style=PascalCase
# Regular expression matching correct class names. Overrides class-naming-
# style.
#class-rgx=
# Naming style matching correct constant names.
const-naming-style=UPPER_CASE
# Regular expression matching correct constant names. Overrides const-naming-
# style.
#const-rgx=
# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1
# Naming style matching correct function names.
function-naming-style=snake_case
# Regular expression matching correct function names. Overrides function-
# naming-style.
#function-rgx=
# Good variable names which should always be accepted, separated by a comma.
good-names=i,
j,
k,
ex,
Run,
_
# Good variable names regexes, separated by a comma. If names match any regex,
# they will always be accepted
good-names-rgxs=
# Include a hint for the correct naming format with invalid-name.
include-naming-hint=no
# Naming style matching correct inline iteration names.
inlinevar-naming-style=any
# Regular expression matching correct inline iteration names. Overrides
# inlinevar-naming-style.
#inlinevar-rgx=
# Naming style matching correct method names.
method-naming-style=snake_case
# Regular expression matching correct method names. Overrides method-naming-
# style.
#method-rgx=
# Naming style matching correct module names.
module-naming-style=snake_case
# Regular expression matching correct module names. Overrides module-naming-
# style.
#module-rgx=
# Colon-delimited sets of names that determine each other's naming style when
# the name regexes allow several styles.
name-group=
# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_
# List of decorators that produce properties, such as abc.abstractproperty. Add
# to this list to register other decorators that produce valid properties.
# These decorators are taken in consideration only for invalid-name.
property-classes=abc.abstractproperty
# Naming style matching correct variable names.
variable-naming-style=snake_case
# Regular expression matching correct variable names. Overrides variable-
# naming-style.
#variable-rgx=
[LOGGING]
# The type of string formatting that logging methods do. `old` means using %
# formatting, `new` is for `{}` formatting.
logging-format-style=old
# Logging modules to check that the string format arguments are in logging
# function parameter format.
logging-modules=logging
[VARIABLES]
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid defining new builtins when possible.
additional-builtins=
# Tells whether unused global variables should be treated as a violation.
allow-global-unused-variables=yes
# List of strings which can identify a callback function by name. A callback
# name must start or end with one of those strings.
callbacks=cb_,
_cb
# A regular expression matching the name of dummy variables (i.e. expected to
# not be used).
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
# Argument names that match this expression will be ignored. Default to name
# with leading underscore.
ignored-argument-names=_.*|^ignored_|^unused_
# Tells whether we should check for unused import in __init__ files.
init-import=no
# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
[TYPECHECK]
# List of decorators that produce context managers, such as
# contextlib.contextmanager. Add to this list to register other decorators that
# produce valid context managers.
contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=pydantic.*
# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes
# Tells whether to warn about missing members when the owner of the attribute
# is inferred to be None.
ignore-none=yes
# This flag controls whether pylint should warn about no-member and similar
# checks whenever an opaque object is returned when inferring. The inference
# can return multiple potential results while evaluating a Python object, but
# some branches might not be evaluated, which results in partial inference. In
# that case, it might be useful to still emit no-member and other checks for
# the rest of the inferred objects.
ignore-on-opaque-inference=yes
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis). It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=
# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
missing-member-hint=yes
# The minimum edit distance a name should have in order to be considered a
# similar match for a missing member name.
missing-member-hint-distance=1
# The total number of similar names that should be taken in consideration when
# showing a hint for a missing member.
missing-member-max-choices=1
# List of decorators that change the signature of a decorated function.
signature-mutators=
[FORMAT]
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
expected-line-ending-format=
# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
indent-string=' '
# Maximum number of characters on a single line.
max-line-length=100
# Maximum number of lines in a module.
max-module-lines=1000
# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
# Allow the body of an if to be on the same line as the test if there is no
# else.
single-line-if-stmt=no
[SIMILARITIES]
# Ignore comments when computing similarities.
ignore-comments=yes
# Ignore docstrings when computing similarities.
ignore-docstrings=yes
w54
# Ignore imports when computing similarities.
ignore-imports=no
# Minimum lines number of a similarity.
min-similarity-lines=4
[DESIGN]
# Maximum number of arguments for function / method.
max-args=5
# Maximum number of attributes for a class (see R0902).
max-attributes=7
# Maximum number of boolean expressions in an if statement (see R0916).
max-bool-expr=5
# Maximum number of branch for function / method body.
max-branches=12
# Maximum number of locals for function / method body.
max-locals=15
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
# Maximum number of return / yield for function / method body.
max-returns=6
# Maximum number of statements in function / method body.
max-statements=50
# Minimum number of public methods for a class (see R0903).
min-public-methods=2
[IMPORTS]
# List of modules that can be imported at any level, not just the top level
# one.
allow-any-import-level=
# Allow wildcard imports from modules that define __all__.
allow-wildcard-with-all=no
# Analyse import fallback blocks. This can be used to support both Python 2 and
# 3 compatible code, which means that the block might have code that exists
# only in one or another interpreter, leading to false positives when analysed.
analyse-fallback-blocks=no
# Deprecated modules which should not be used, separated by a comma.
deprecated-modules=optparse,tkinter.tix
# Create a graph of external dependencies in the given file (report RP0402 must
# not be disabled).
ext-import-graph=
# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled).
import-graph=
# Create a graph of internal dependencies in the given file (report RP0402 must
# not be disabled).
int-import-graph=
# Force import order to recognize a module as part of the standard
# compatibility libraries.
known-standard-library=
# Force import order to recognize a module as part of a third party library.
known-third-party=enchant
# Couples of modules and preferred modules, separated by a comma.
preferred-modules=
[CLASSES]
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,
__new__,
setUp,
__post_init__
# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,
_fields,
_replace,
_source,
_make
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=cls
[EXCEPTIONS]
# Exceptions that will emit a warning when being caught. Defaults to
# "BaseException, Exception".
overgeneral-exceptions=BaseException,
Exception

View file

@ -1,6 +1,6 @@
{
"python.formatting.provider": "black",
"python.pythonPath": "venv/bin/python",
"python.pythonPath": "/home/hayden/projects/mealie/.venv/bin/python3",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.autoComplete.extraPaths": ["mealie", "mealie/mealie"],
@ -8,8 +8,9 @@
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.cwd": "./mealie/tests",
"python.testing.pytestEnabled": true,
"cSpell.enableFiletypes": ["!javascript", "!python"],
"python.testing.pytestArgs": ["mealie/test/"]
"python.testing.pytestArgs": [
"mealie"
]
}

View file

@ -2,8 +2,7 @@ import uvicorn
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
import startup
from global_scheduler import start_scheduler
import utils.startup as startup
from routes import (
backup_routes,
meal_routes,
@ -13,8 +12,8 @@ from routes import (
static_routes,
user_routes,
)
from services.settings_services import Colors, SiteTheme
from settings import PORT, PRODUCTION, WEB_PATH, docs_url, redoc_url
from utils.api_docs import generate_api_docs
from utils.logger import logger
startup.pre_start()
@ -49,13 +48,9 @@ def invalid_api():
app.include_router(static_routes.router)
# Generate API Documentation
if not PRODUCTION:
startup.generate_api_docs(app)
generate_api_docs(app)
if __name__ == "__main__":
logger.info("-----SYSTEM STARTUP-----")

1
mealie/data/db/db.json Normal file

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
{"_default": {"3": {"name": "Chicken and Rice With Leeks and Salsa Verde", "description": "This one-skillet dinner gets deep oniony flavor from lots of leeks cooked down to jammy tenderness.", "image": "chicken-and-rice-with-leeks-and-salsa-verde.jpg", "recipeYield": "4 Servings", "recipeIngredient": ["1\u00bd lb. skinless, boneless chicken thighs (4\u20138 depending on size)", "Kosher salt, freshly ground pepper", "3 Tbsp. unsalted butter, divided", "2 large or 3 medium leeks, white and pale green parts only, halved lengthwise, thinly sliced", "Zest and juice of 1 lemon, divided", "1\u00bd cups long-grain white rice, rinsed until water runs clear", "2\u00be cups low-sodium chicken broth", "1 oil-packed anchovy fillet", "2 garlic cloves", "1 Tbsp. drained capers", "Crushed red pepper flakes", "1 cup tender herb leaves (such as parsley, cilantro, and/or mint)", "4\u20135 Tbsp. extra-virgin olive oil"], "recipeInstructions": [{"text": "Season chicken with salt and pepper. Melt 2 Tbsp. butter in a large high-sided skillet over medium-high heat. Add leeks and half of lemon zest, season with salt and pepper, and mix to coat leeks in butter. Reduce heat to medium-low, cover, and cook, stirring occasionally, until leeks are somewhat tender, about 5 minutes. Remove lid, increase heat to medium-high, and cook, stirring occasionally, until tender and just starting to take on color, about 3 minutes. Add rice and cook, stirring often, 3 minutes, then add broth, scraping up any browned bits. Tuck short sides of each chicken thigh underneath so they are touching and nestle seam side down into rice mixture. Bring to a simmer. Cover, reduce heat to medium-low, and cook until rice is tender and chicken is cooked through, about 20 minutes. Remove from heat. Cut remaining 1 Tbsp. butter into small pieces and scatter over mixture. Re-cover and let sit 10 minutes."}, {"text": "Meanwhile, pulse anchovy, garlic, capers, a few pinches of red pepper flakes, and remaining lemon zest in a food processor until finely chopped. Add herbs; process until a paste forms. With motor running, gradually stream in oil until loosened to a thick sauce. Add half of lemon juice; season salsa verde with salt."}, {"text": "Drizzle remaining lemon juice over chicken and rice. Serve with salsa verde."}], "totalTime": "None", "slug": "chicken-and-rice-with-leeks-and-salsa-verde", "categories": [], "tags": [], "dateAdded": null, "notes": [], "rating": null, "orgURL": "https://www.bonappetit.com/recipe/chicken-and-rice-with-leeks-and-salsa-verde", "extras": {}}}}

View file

@ -1,33 +1,25 @@
{
"@context": "http://schema.org",
"@type": "Recipe",
"articleBody": "Leftover rice is ideal for this dish (and a great way to use up any takeout that\u2019s hanging around), since fully chilled rice tends to be drier and will become crispier and browner in the skillet. To get the best texture, evenly distribute the rice in your pan and gently press down to flatten it out like a pancake. Don\u2019t touch until you hear it crackle! Finish with a sunny-side-up egg\u2014or poach it if you don't mind the stovetop fuss. This recipe is part of the 2021\u00a0Feel Good Food Plan, our eight-day dinner plan for starting the year off right.",
"alternativeHeadline": "To get the best texture, evenly distribute the rice in your pan and gently press down to flatten it. Don\u2019t touch until you hear it crackle!",
"dateModified": "2021-01-11 23:25:22.997000",
"datePublished": "2021-01-01 06:00:00",
"articleBody": "At her L.A. bakery Friends and Family, Roxana Jullapat bakes these blondies in a round cake pan, which ensures that each slice has a chewy, toasted edge and a soft center. \u201cThis caramel-flavored treat demonstrates the powerful pairing of brown butter and barley,\u201d Roxana writes in her cookbook Mother Grains (out April 2021). Barley flour gives baked goods a silky, chewy texture, dense crumb, and butterscotch-y flavor. Want to experiment? Make these with 3\u20444 cup (80 g) einkorn flour in place of the barley flour for an even chewier blondie.",
"alternativeHeadline": "Barley flour gives these blondies a chewy texture and butterscotch-like flavor.",
"dateModified": "2021-01-11 14:23:12.455000",
"datePublished": "2021-01-12 04:00:00",
"keywords": [
"recipes",
"healthyish",
"salad",
"ginger",
"garlic",
"orange",
"oil",
"soy sauce",
"lemon juice",
"sesame oil",
"macadamia nut",
"vanilla",
"butter",
"flour",
"barley",
"kosher salt",
"broccoli",
"brown rice",
"brown sugar",
"egg",
"celery",
"cilantro",
"mint",
"feel good food plan 2021",
"feel good food plan",
"vanilla extract",
"web"
],
"thumbnailUrl": "https://assets.bonappetit.com/photos/5fdbe70a84d333dd1dcc7900/1:1/w_1698,h_1698,c_limit/BA1220feelgoodalt.jpg",
"thumbnailUrl": "https://assets.bonappetit.com/photos/5ff4b06a2f7e5df08337ef60/1:1/w_1005,h_1005,c_limit/Mother-Grains-Macadamia-and-Brown-Butter-Blondies.jpg",
"publisher": {
"@context": "https://schema.org",
"@type": "Organization",
@ -51,68 +43,49 @@
"author": [
{
"@type": "Person",
"name": "Devonn Francis",
"sameAs": "https://bon-appetit.com/contributor/devonn-francis/"
"name": "Roxana Jullapat",
"sameAs": "https://bon-appetit.com/contributor/roxana-jullapat/"
}
],
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": 4.33,
"ratingCount": 33
},
"description": "To get the best texture, evenly distribute the rice in your pan and gently press down to flatten it. Don\u2019t touch until you hear it crackle! ",
"image": "crispy-rice-with-ginger-citrus-celery-salad.jpg",
"headline": "Crispy Rice With Ginger-Citrus Celery Salad",
"name": "Crispy Rice With Ginger-Citrus Celery Salad",
"description": "Barley flour gives these blondies a chewy texture and butterscotch-like flavor.",
"image": "macadamia-and-brown-butter-blondies.jpg",
"headline": "Macadamia and Brown Butter Blondies",
"name": "Macadamia and Brown Butter Blondies",
"recipeIngredient": [
"1 2\" piece ginger, peeled, finely grated",
"1 small garlic clove, finely grated",
"Juice of 1 orange",
"2 tbsp. vegetable oil",
"1Tbsp. coconut aminos or low-sodium soy sauce",
"1 Tbsp. fresh lemon juice",
"\u00bc tsp. toasted sesame oil",
"Kosher salt",
"1 medium head of broccoli",
"6 Tbsp. (or more) vegetable oil, divided",
"Kosher salt",
"2 cups chilled cooked brown rice",
"4 large eggs",
"3 celery stalks, thinly sliced on a steep diagonal",
"\u00bd cup cilantro leaves with tender stems",
"\u00bd cup mint leaves",
"Crushed red pepper flakes (for serving)"
"Nonstick vegetable oil spray",
"\u00bd cup (65 g) whole raw or toasted macadamia nuts",
"\u00bd vanilla bean, split lengthwise",
"18 Tbsp. unsalted butter",
"\u00be cup plus 2 Tbsp. (105 g) all-purpose flour",
"\u00be cup (85 g) barley flour",
"1\u00be tsp. baking powder",
"1\u00bd tsp. Diamond Crystal or \u00be tsp. Morton kosher salt",
"1 cup plus 7 Tbsp. (packed; 285 g) dark brown sugar",
"2 large eggs",
"1 tsp. vanilla extract",
"2 pints ice cream of choice (optional)"
],
"recipeInstructions": [
{
"text": "Whisk ginger, garlic, orange juice, vegetable oil, coconut aminos, lemon juice, and sesame oil in a small bowl; season with salt and set aside."
"text": "Preheat oven to 350\u00b0. Lightly coat a 9\"-diameter cake pan with nonstick spray and line bottom with a parchment paper round. If using raw macadamia nuts, toast on a rimmed baking sheet, tossing once, until golden, 8\u201310 minutes. Let cool, then coarsely chop."
},
{
"text": "Trim about \u00bd\" from woody end of broccoli stem. Peel tough outer layer from stem. Cut florets from stems and thinly slice stems about \u00bd\" thick. Break florets apart with your hands into 1\"\u20131\u00bd\" pieces."
"text": "Scrape vanilla seeds into a small saucepan; add pod and butter. Set over medium-low heat and cook, stirring occasionally, until butter foams, then browns, 6\u20138 minutes. Transfer to a medium bowl, scraping in all of the browned bits. Using tongs, remove and discard vanilla pod."
},
{
"text": "Heat 2 Tbsp. oil in a large nonstick skillet over medium. Working in 2 batches if needed, arrange broccoli in a single layer and cook, tossing occasionally, until broccoli is bright green and lightly charred around the edges, about\u00a03 minutes. Transfer to a large plate."
"text": "Whisk all-purpose and barley flours, baking powder, and salt in another medium bowl. Add brown sugar to brown butter and stir to combine. Add eggs one at a time, stirring well after each addition. Stir in dry ingredients, then vanilla extract and nuts. Scrape batter into prepared pan; smooth top."
},
{
"text": "Pour 2 Tbsp. oil into same pan and heat over medium-high. Once you see the first wisp of smoke, add rice and season lightly with salt. Using a spatula or spoon, press rice evenly into pan like a pancake. Rice will begin to crackle, but don\u2019t fuss with it. When the crackling has died down almost completely, about\u00a03 minutes, break rice into large pieces and turn over."
"text": "Bake blondies, rotating halfway through, until top is golden brown and a tester inserted into the center comes out clean, 40\u201345 minutes. Let cool."
},
{
"text": "Add broccoli back to pan and give everything a toss to combine. Cook, tossing occasionally and adding another\u00a01 Tbsp. oil if pan looks dry, until broccoli is tender and rice is warmed through and very crisp, about 5 minutes. Transfer mixture to a platter or divide among plates and set aside."
},
{
"text": "Wipe out skillet; heat remaining\u00a02 Tbsp. oil over medium-high. Crack eggs into skillet; season with salt. Oil should bubble around eggs right away. Cook, rotating skillet occasionally, until whites are golden brown and crisp at the edges and set around the yolk (which should be runny), about 2 minutes."
},
{
"text": "Toss celery, cilantro, and mint with\u00a03 Tbsp. reserved dressing and a pinch of salt in a medium bowl to combine."
},
{
"text": "Scatter celery salad over fried rice; top with fried eggs and sprinkle with red pepper flakes. Serve extra dressing alongside."
"text": "Turn out blondies, remove parchment, and cut into 12 wedges. Serve each with a scoop of ice cream if desired."
}
],
"recipeYield": "4 servings",
"url": "https://www.bonappetit.com/recipe/crispy-rice-with-ginger-citrus-celery-salad",
"slug": "crispy-rice-with-ginger-citrus-celery-salad",
"orgURL": "https://www.bonappetit.com/recipe/crispy-rice-with-ginger-citrus-celery-salad",
"recipeYield": "Makes 12",
"url": "https://www.bonappetit.com/recipe/macadamia-and-brown-butter-blondies",
"slug": "macadamia-and-brown-butter-blondies",
"orgURL": "https://www.bonappetit.com/recipe/macadamia-and-brown-butter-blondies",
"categories": [],
"tags": [],
"dateAdded": null,

View file

@ -12,10 +12,8 @@ class BaseDocument:
self.store: StoreBase
self.document: mongoengine.Document
@staticmethod
def _unpack_mongo(
document,
) -> dict: # TODO: Probably Put a version in each class to speed up reads?
@staticmethod # TODO: Probably Put a version in each class to speed up reads?
def _unpack_mongo(document) -> dict:
document = json.loads(document.to_json())
del document["_id"]

View file

@ -10,6 +10,7 @@ class _Themes(BaseDocument):
self.primary_key = "name"
if USE_TINYDB:
self.store = tiny_db.themes
else:
self.document = SiteThemeDocument
def save_new(self, theme_data: dict) -> None:

View file

@ -17,7 +17,7 @@ class StoreBase:
)
else:
self.store.insert(document)
return document["slug"]
return document
def delete(self, document_primary_key: str):
self.store.remove(where(self.primary_key) == document_primary_key)

View file

@ -1,32 +1,68 @@
from datetime import date, datetime
from db.tinydb.baseclass import StoreBase
from settings import TINYDB_DIR
from tinydb_serialization import SerializationMiddleware, Serializer
from tinydb import TinyDB
class DateSerializer(Serializer):
OBJ_CLASS = date # The class handles date objects
def encode(self, obj):
"""
Serialize the naive date object without conversion.
"""
return obj.strftime("%Y%m%d")
def decode(self, s):
"""
Return the serialization as a date object.
"""
return datetime.strptime(s, "%Y%m%d").date()
class DateTimeSerializer(Serializer):
OBJ_CLASS = datetime # The class this serializer handles
def encode(self, obj):
return obj.strftime("%Y-%m-%dT%H:%M:%S")
def decode(self, s):
return datetime.strptime(s, "%Y-%m-%dT%H:%M:%S")
serialization = SerializationMiddleware()
serialization.register_serializer(DateTimeSerializer(), "TinyDateTime")
serialization.register_serializer(DateSerializer(), "TinyDate")
class TinyDatabase:
def __init__(self) -> None:
self.recipes = self._Recipes()
self.meals = self._Meals()
self.settings = self._Settings()
self.themes = self._Themes()
self.db = TinyDB(TINYDB_DIR.joinpath("db.json"), storage=serialization)
self.recipes = self._Recipes(self.db)
self.meals = self._Meals(self.db)
self.settings = self._Settings(self.db)
self.themes = self._Themes(self.db)
class _Recipes(StoreBase):
def __init__(self) -> None:
def __init__(self, db) -> None:
self.primary_key = "slug"
self.store = TinyDB(TINYDB_DIR.joinpath("recipes.json"))
self.store = db.table("recipes")
class _Meals(StoreBase):
def __init__(self) -> None:
def __init__(self, db) -> None:
self.primary_key = "uid"
self.store = TinyDB(TINYDB_DIR.joinpath("meals.json"))
self.store = db.table("meals")
class _Settings(StoreBase):
def __init__(self) -> None:
def __init__(self, db) -> None:
self.primary_key = "name"
self.store = TinyDB(TINYDB_DIR.joinpath("settings.json"))
self.store = db.table("settings")
class _Themes(StoreBase):
def __init__(self) -> None:
def __init__(self, db) -> None:
self.primary_key = "name"
self._store = TinyDB(TINYDB_DIR.joinpath("themes.json"))
self.store = db.table("themes")

View file

@ -40,11 +40,12 @@ def export_database(data: BackupJob):
)
def import_database(file_name: str):
""" Import a database backup file generated from Mealie. """
import_db = ImportDatabase(
zip_archive=file_name,
import_recipes=True,
import_settings=True,
import_themes=True,
import_settings=False,
import_themes=False,
)
imported = import_db.run()

View file

@ -1,7 +1,7 @@
from fastapi import APIRouter, HTTPException
from global_scheduler import scheduler
from services.scheduler_services import post_webhooks
from services.settings_services import SiteSettings, SiteTheme
from utils.global_scheduler import scheduler
from utils.snackbar import SnackResponse
router = APIRouter()

View file

@ -74,6 +74,11 @@ class ImportDatabase:
recipe_dict = json.loads(f.read())
recipe_dict = ImportDatabase._recipe_migration(recipe_dict)
recipe_obj = Recipe(**recipe_dict)
recipe_obj.save_to_db()
successful_imports.append(recipe.stem)
logger.info(f"Imported: {recipe.stem}")
try:
recipe_obj = Recipe(**recipe_dict)
recipe_obj.save_to_db()

View file

@ -115,8 +115,9 @@ class Recipe(BaseModel):
pass
recipe_doc = db.recipes.save_new(recipe_dict)
recipe = Recipe(**recipe_doc)
return recipe_doc.slug
return recipe.slug
@staticmethod
def delete(recipe_slug: str) -> str:

View file

@ -1,9 +1,7 @@
import json
from typing import List, Optional
from db.database import db
from pydantic import BaseModel
from startup import USE_TINYDB
from utils.logger import logger
@ -86,17 +84,6 @@ class SiteTheme(BaseModel):
return cls(name=name, colors=colors)
@staticmethod
def _unpack_doc(document):
if USE_TINYDB:
theme_colors = SiteTheme(**document)
else:
document = json.loads(document.to_json())
del document["_id"]
theme_colors = SiteTheme(**document)
return theme_colors
@staticmethod
def get_all():
all_themes = db.themes.get_all()

View file

@ -5,11 +5,13 @@ import dotenv
CWD = Path(__file__).parent
# Register ENV
ENV = CWD.joinpath(".env")
dotenv.load_dotenv(ENV)
# Helpful Globals
BASE_DIR = CWD
DATA_DIR = CWD.joinpath("data")
WEB_PATH = CWD.joinpath("dist")
IMG_DIR = DATA_DIR.joinpath("img")
@ -45,13 +47,15 @@ else:
# DATABASE ENV
DATABASE_TYPE = os.getenv("db_type", "mongo") # mongo, tinydb
USE_TINYDB = False
USE_MONGO = False
DATABASE_TYPE = os.getenv("db_type", "tinydb") # mongo, tinydb
if DATABASE_TYPE == "tinydb":
USE_TINYDB = True
USE_MONGO = False
elif DATABASE_TYPE == "mongo":
USE_MONGO = True
USE_TINYDB = False
else:
raise Exception(
"Unable to determine database type. Acceptible options are 'mongo' or 'sqlite' "

View file

@ -1,17 +1,6 @@
import json
from pathlib import Path
from settings import REQUIRED_DIRS
CWD = Path(__file__).parent
def pre_start():
ensure_dirs()
def ensure_dirs():
for dir in REQUIRED_DIRS:
dir.mkdir(parents=True, exist_ok=True)
from settings import BASE_DIR
"""Script to export the ReDoc documentation page into a standalone HTML file."""
@ -42,14 +31,10 @@ HTML_TEMPLATE = """<!DOCTYPE html>
</html>
"""
out_path = CWD.joinpath("temp", "index.html")
out_path = BASE_DIR.joinpath("temp", "index.html")
def generate_api_docs(app):
with open(out_path, "w") as fd:
out_path.parent.mkdir(exist_ok=True)
print(HTML_TEMPLATE % json.dumps(app.openapi()), file=fd)
if __name__ == "__main__":
pass

18
mealie/utils/startup.py Normal file
View file

@ -0,0 +1,18 @@
from pathlib import Path
from settings import REQUIRED_DIRS
CWD = Path(__file__).parent
def pre_start():
ensure_dirs()
def ensure_dirs():
for dir in REQUIRED_DIRS:
dir.mkdir(parents=True, exist_ok=True)
if __name__ == "__main__":
pass

80
poetry.lock generated Normal file
View file

@ -0,0 +1,80 @@
[[package]]
name = "fastapi"
version = "0.63.0"
description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
category = "main"
optional = false
python-versions = ">=3.6"
[package.dependencies]
pydantic = ">=1.0.0,<2.0.0"
starlette = "0.13.6"
[package.extras]
all = ["requests (>=2.24.0,<3.0.0)", "aiofiles (>=0.5.0,<0.6.0)", "jinja2 (>=2.11.2,<3.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "itsdangerous (>=1.1.0,<2.0.0)", "pyyaml (>=5.3.1,<6.0.0)", "graphene (>=2.1.8,<3.0.0)", "ujson (>=3.0.0,<4.0.0)", "orjson (>=3.2.1,<4.0.0)", "email_validator (>=1.1.1,<2.0.0)", "uvicorn[standard] (>=0.12.0,<0.14.0)", "async_exit_stack (>=1.0.1,<2.0.0)", "async_generator (>=1.10,<2.0.0)"]
dev = ["python-jose[cryptography] (>=3.1.0,<4.0.0)", "passlib[bcrypt] (>=1.7.2,<2.0.0)", "autoflake (>=1.3.1,<2.0.0)", "flake8 (>=3.8.3,<4.0.0)", "uvicorn[standard] (>=0.12.0,<0.14.0)", "graphene (>=2.1.8,<3.0.0)"]
doc = ["mkdocs (>=1.1.2,<2.0.0)", "mkdocs-material (>=6.1.4,<7.0.0)", "markdown-include (>=0.5.1,<0.6.0)", "mkdocs-markdownextradata-plugin (>=0.1.7,<0.2.0)", "typer-cli (>=0.0.9,<0.0.10)", "pyyaml (>=5.3.1,<6.0.0)"]
test = ["pytest (==5.4.3)", "pytest-cov (==2.10.0)", "pytest-asyncio (>=0.14.0,<0.15.0)", "mypy (==0.790)", "flake8 (>=3.8.3,<4.0.0)", "black (==20.8b1)", "isort (>=5.0.6,<6.0.0)", "requests (>=2.24.0,<3.0.0)", "httpx (>=0.14.0,<0.15.0)", "email_validator (>=1.1.1,<2.0.0)", "sqlalchemy (>=1.3.18,<2.0.0)", "peewee (>=3.13.3,<4.0.0)", "databases[sqlite] (>=0.3.2,<0.4.0)", "orjson (>=3.2.1,<4.0.0)", "async_exit_stack (>=1.0.1,<2.0.0)", "async_generator (>=1.10,<2.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "aiofiles (>=0.5.0,<0.6.0)", "flask (>=1.1.2,<2.0.0)"]
[[package]]
name = "pydantic"
version = "1.7.3"
description = "Data validation and settings management using python 3.6 type hinting"
category = "main"
optional = false
python-versions = ">=3.6"
[package.extras]
dotenv = ["python-dotenv (>=0.10.4)"]
email = ["email-validator (>=1.0.3)"]
typing_extensions = ["typing-extensions (>=3.7.2)"]
[[package]]
name = "starlette"
version = "0.13.6"
description = "The little ASGI library that shines."
category = "main"
optional = false
python-versions = ">=3.6"
[package.extras]
full = ["aiofiles", "graphene", "itsdangerous", "jinja2", "python-multipart", "pyyaml", "requests", "ujson"]
[metadata]
lock-version = "1.1"
python-versions = "^3.8"
content-hash = "fd85f1208985afed8ec0a1322873546cc1c1eb44f0f443225647806e9f6eead0"
[metadata.files]
fastapi = [
{file = "fastapi-0.63.0-py3-none-any.whl", hash = "sha256:98d8ea9591d8512fdadf255d2a8fa56515cdd8624dca4af369da73727409508e"},
{file = "fastapi-0.63.0.tar.gz", hash = "sha256:63c4592f5ef3edf30afa9a44fa7c6b7ccb20e0d3f68cd9eba07b44d552058dcb"},
]
pydantic = [
{file = "pydantic-1.7.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:c59ea046aea25be14dc22d69c97bee629e6d48d2b2ecb724d7fe8806bf5f61cd"},
{file = "pydantic-1.7.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:a4143c8d0c456a093387b96e0f5ee941a950992904d88bc816b4f0e72c9a0009"},
{file = "pydantic-1.7.3-cp36-cp36m-manylinux2014_i686.whl", hash = "sha256:d8df4b9090b595511906fa48deda47af04e7d092318bfb291f4d45dfb6bb2127"},
{file = "pydantic-1.7.3-cp36-cp36m-manylinux2014_x86_64.whl", hash = "sha256:514b473d264671a5c672dfb28bdfe1bf1afd390f6b206aa2ec9fed7fc592c48e"},
{file = "pydantic-1.7.3-cp36-cp36m-win_amd64.whl", hash = "sha256:dba5c1f0a3aeea5083e75db9660935da90216f8a81b6d68e67f54e135ed5eb23"},
{file = "pydantic-1.7.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:59e45f3b694b05a69032a0d603c32d453a23f0de80844fb14d55ab0c6c78ff2f"},
{file = "pydantic-1.7.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:5b24e8a572e4b4c18f614004dda8c9f2c07328cb5b6e314d6e1bbd536cb1a6c1"},
{file = "pydantic-1.7.3-cp37-cp37m-manylinux2014_i686.whl", hash = "sha256:b2b054d095b6431cdda2f852a6d2f0fdec77686b305c57961b4c5dd6d863bf3c"},
{file = "pydantic-1.7.3-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:025bf13ce27990acc059d0c5be46f416fc9b293f45363b3d19855165fee1874f"},
{file = "pydantic-1.7.3-cp37-cp37m-win_amd64.whl", hash = "sha256:6e3874aa7e8babd37b40c4504e3a94cc2023696ced5a0500949f3347664ff8e2"},
{file = "pydantic-1.7.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e682f6442ebe4e50cb5e1cfde7dda6766fb586631c3e5569f6aa1951fd1a76ef"},
{file = "pydantic-1.7.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:185e18134bec5ef43351149fe34fda4758e53d05bb8ea4d5928f0720997b79ef"},
{file = "pydantic-1.7.3-cp38-cp38-manylinux2014_i686.whl", hash = "sha256:f5b06f5099e163295b8ff5b1b71132ecf5866cc6e7f586d78d7d3fd6e8084608"},
{file = "pydantic-1.7.3-cp38-cp38-manylinux2014_x86_64.whl", hash = "sha256:24ca47365be2a5a3cc3f4a26dcc755bcdc9f0036f55dcedbd55663662ba145ec"},
{file = "pydantic-1.7.3-cp38-cp38-win_amd64.whl", hash = "sha256:d1fe3f0df8ac0f3a9792666c69a7cd70530f329036426d06b4f899c025aca74e"},
{file = "pydantic-1.7.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f6864844b039805add62ebe8a8c676286340ba0c6d043ae5dea24114b82a319e"},
{file = "pydantic-1.7.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:ecb54491f98544c12c66ff3d15e701612fc388161fd455242447083350904730"},
{file = "pydantic-1.7.3-cp39-cp39-manylinux2014_i686.whl", hash = "sha256:ffd180ebd5dd2a9ac0da4e8b995c9c99e7c74c31f985ba090ee01d681b1c4b95"},
{file = "pydantic-1.7.3-cp39-cp39-manylinux2014_x86_64.whl", hash = "sha256:8d72e814c7821125b16f1553124d12faba88e85405b0864328899aceaad7282b"},
{file = "pydantic-1.7.3-cp39-cp39-win_amd64.whl", hash = "sha256:475f2fa134cf272d6631072554f845d0630907fce053926ff634cc6bc45bf1af"},
{file = "pydantic-1.7.3-py3-none-any.whl", hash = "sha256:38be427ea01a78206bcaf9a56f835784afcba9e5b88fbdce33bbbfbcd7841229"},
{file = "pydantic-1.7.3.tar.gz", hash = "sha256:213125b7e9e64713d16d988d10997dabc6a1f73f3991e1ff8e35ebb1409c7dc9"},
]
starlette = [
{file = "starlette-0.13.6-py3-none-any.whl", hash = "sha256:bd2ffe5e37fb75d014728511f8e68ebf2c80b0fa3d04ca1479f4dc752ae31ac9"},
{file = "starlette-0.13.6.tar.gz", hash = "sha256:ebe8ee08d9be96a3c9f31b2cb2a24dbdf845247b745664bd8a3f9bd0c977fdbc"},
]

2
poetry.toml Normal file
View file

@ -0,0 +1,2 @@
[virtualenvs]
in-project = true

116
pyproject.toml Normal file
View file

@ -0,0 +1,116 @@
[tool.poetry]
name = "mealie"
version = "0.1.0"
description = "Recipe Manager"
authors = ["Hayden <hay-kot@pm.me>"]
license = "MIT"
[tool.poetry.dependencies]
python = "^3.8"
fastapi = "0.61.1"
aiofiles = "0.5.0"
aniso8601 = "7.0.0"
appdirs = "1.4.4"
APScheduler = "3.6.3"
astroid = "2.4.2"
async-exit-stack = "1.0.1"
async_generator = "1.10"
attrs = "20.3.0"
beautifulsoup4 = "4.9.1"
black = "20.8b1"
certifi = "2020.6.20"
chardet = "3.0.4"
click = "7.1.2"
colorama = "0.4.3"
decorator = "4.4.2"
dnspython = "2.0.0"
email-validator = "1.1.1"
extruct = "0.10.0"
fastapi-login = "1.5.1"
future = "0.18.2"
gitdb = "4.0.5"
GitPython = "3.1.11"
graphene = "2.1.8"
graphql-core = "2.3.2"
graphql-relay = "2.0.1"
h11 = "0.9.0"
html-text = "0.5.2"
html5lib = "1.1"
httptools = "0.1.1"
idna = "2.10"
iniconfig = "1.1.1"
isodate = "0.6.0"
isort = "5.4.2"
itsdangerous = "1.1.0"
Jinja2 = "2.11.2"
joblib = "1.0.0"
jstyleson = "0.0.2"
lazy-object-proxy = "1.4.3"
livereload = "2.6.3"
lunr = "0.5.8"
lxml = "4.6.2"
Markdown = "3.3.3"
MarkupSafe = "1.1.1"
mccabe = "0.6.1"
mf2py = "1.1.2"
mkdocs = "1.1.2"
mkdocs-material = "6.1.7"
mkdocs-material-extensions = "1.0.1"
mongoengine = "0.21.0"
mypy-extensions = "0.4.3"
nltk = "3.5"
packaging = "20.8"
passlib = "1.7.4"
pathspec = "0.8.0"
pdfkit = "0.6.1"
pip-chill = "1.0.0"
pluggy = "0.13.1"
promise = "2.3"
py = "1.10.0"
pydantic = "1.6.1"
Pygments = "2.7.3"
PyJWT = "1.7.1"
pylint = "2.6.0"
pymdown-extensions = "8.0.1"
pymongo = "3.11.1"
pyparsing = "2.4.7"
pytest = "6.2.1"
python-dateutil = "2.8.1"
python-dotenv = "0.15.0"
python-multipart = "0.0.5"
python-slugify = "4.0.1"
pytz = "2020.4"
PyYAML = "5.3.1"
rdflib = "4.2.2"
rdflib-jsonld = "0.5.0"
regex = "2020.7.14"
requests = "2.24.0"
Rx = "1.6.1"
scrape-schema-recipe = "0.1.1"
six = "1.15.0"
smmap = "3.0.4"
soupsieve = "2.0.1"
SQLAlchemy = "1.3.22"
starlette = "0.13.6"
text-unidecode = "1.3"
toml = "0.10.1"
tornado = "6.1"
tqdm = "4.54.1"
typed-ast = "1.4.1"
typing-extensions = "3.7.4.3"
tzlocal = "2.1"
ujson = "3.1.0"
urllib3 = "1.25.10"
uvicorn = "0.11.8"
uvloop = "0.14.0"
validators = "0.18.0"
w3lib = "1.22.0"
webencodings = "0.5.1"
websockets = "8.1"
wrapt = "1.12.1"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"