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
|
|
@ -14,6 +14,7 @@ import click
|
|||
from lxml import html
|
||||
|
||||
from .grocy import Grocy, Journal, import_receipt, refresh_imported_products, align_recorded_lines
|
||||
from .paths import config_file, archive_directory, browser_directory, journal_file
|
||||
from .pantry import classify
|
||||
from .receipt import ImportError, parse_document, parse_ocado_order, receipt_date
|
||||
|
||||
|
|
@ -228,9 +229,7 @@ def run_import(receipts, config, config_path, archive, dry_run, failures, echo=p
|
|||
if not url or not key:
|
||||
raise ImportError("Configure Grocy URL and API key before importing")
|
||||
api = Grocy(url,key)
|
||||
state = Path(settings.get("state_file", "imports.sqlite3"))
|
||||
if not state.is_absolute():
|
||||
state = config_path.resolve().parent / state
|
||||
state = journal_file(config, config_path)
|
||||
journal = Journal(state)
|
||||
for receipt in receipts:
|
||||
if not dry_run:
|
||||
|
|
@ -266,9 +265,9 @@ def run_import(receipts, config, config_path, archive, dry_run, failures, echo=p
|
|||
|
||||
|
||||
@click.command(context_settings={"help_option_names":["-h","--help"]})
|
||||
@click.option("--config", "config_path", type=click.Path(path_type=Path,dir_okay=False),default="config.toml",show_default=True)
|
||||
@click.option("--profile", type=click.Path(path_type=Path,file_okay=False),default=".ocado-browser",show_default=True)
|
||||
@click.option("--archive", type=click.Path(path_type=Path,file_okay=False),default="history",show_default=True)
|
||||
@click.option("--config", "config_path", type=click.Path(path_type=Path,dir_okay=False),default=config_file,show_default="~/.config/ocado-grocy/config.toml")
|
||||
@click.option("--profile", type=click.Path(path_type=Path,file_okay=False),default=browser_directory,show_default="~/.local/state/ocado-grocy/browser")
|
||||
@click.option("--archive", type=click.Path(path_type=Path,file_okay=False),default=archive_directory,show_default="~/.local/share/ocado-grocy/history")
|
||||
@click.option("--since", help="Only orders delivered on or after YYYY-MM-DD.")
|
||||
@click.option("--limit", type=click.IntRange(min=1),help="Process at most this many new delivered orders (or explicitly selected orders).")
|
||||
@click.option("--dry-run", is_flag=True,help="Download and report selections without writing to Grocy.")
|
||||
|
|
@ -296,9 +295,7 @@ def main(config_path,profile,archive,since,limit,dry_run,cached,login_only,login
|
|||
connection = config.get('grocy', {})
|
||||
server = Grocy(os.environ.get('GROCY_URL', connection.get('url', '')),
|
||||
os.environ.get('GROCY_API_KEY', connection.get('api_key', ''))).url
|
||||
state = Path(config.get('import', {}).get('state_file', 'imports.sqlite3'))
|
||||
if not state.is_absolute():
|
||||
state = config_path.resolve().parent / state
|
||||
state = journal_file(config, config_path)
|
||||
completed = completed_orders(state, server, archive, config)
|
||||
if not dry_run and not login_only:
|
||||
mark_orders(state, server, completed, 'complete')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue