Prepare public release with MIT license and private user storage
This commit is contained in:
parent
41772b4d1a
commit
eb8932134a
12 changed files with 175 additions and 26 deletions
|
|
@ -12,6 +12,7 @@ import click
|
|||
import requests
|
||||
|
||||
from .grocy import Grocy, imported_products
|
||||
from .paths import config_file, archive_directory, journal_file
|
||||
from .history import private_json
|
||||
from .product_metadata import read_metadata, replace_metadata
|
||||
|
||||
|
|
@ -166,8 +167,8 @@ def apply_match(client, product, candidate, barcodes):
|
|||
|
||||
|
||||
@click.command()
|
||||
@click.option('--config', type=click.Path(path_type=Path), default=Path('config.toml'))
|
||||
@click.option('--cache', type=click.Path(path_type=Path), default=Path('history/openfoodfacts'))
|
||||
@click.option('--config', type=click.Path(path_type=Path), default=config_file, show_default='~/.config/ocado-grocy/config.toml')
|
||||
@click.option('--cache', type=click.Path(path_type=Path), default=lambda: archive_directory() / 'openfoodfacts', show_default='archive/openfoodfacts')
|
||||
@click.option('--contact', help='Contact for the Open Food Facts User-Agent; defaults to config [openfoodfacts].contact.')
|
||||
@click.option('--refresh-cache', is_flag=True, help='Fetch fresh OFF responses, replacing cached responses.')
|
||||
@click.option('--apply', is_flag=True, help='Apply unambiguous matches and explicitly reviewed mappings.')
|
||||
|
|
@ -184,7 +185,7 @@ def main(config, cache, contact, refresh_cache, apply, offline, mapping, limit,
|
|||
if refresh_cache and offline:
|
||||
raise click.UsageError('--refresh-cache cannot be combined with --offline')
|
||||
client = Grocy(**settings['grocy'])
|
||||
state = config.parent / settings.get('import', {}).get('state_file', 'imports.sqlite3')
|
||||
state = journal_file(settings, config)
|
||||
products = imported_products(client, state, order_ids)
|
||||
mappings = json.loads(mapping.read_text()) if mapping else {}
|
||||
return run_openfoodfacts(client, products, cache, contact, apply=apply, offline=offline,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue