pimutils / pimutils/vdirsyncer

Use vdirsyncer as a Python module (from Python code)

Open
#770 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Python
Stars
1.9k
Forks
185
Avg merge
11h 49m
Merged PRs (30d)
1

Description

Environment

  • vdirsyncer==0.10.0
  • Python 3.5, 3.6, 3.7
  • OS: any

Current Behavior

We're currently running vdirsyncer from Python code via a subshell, e.g.

subprocess.run("yes | vdirsyncer -c vdirsyncer.config discover")
subprocess.run("vdirsyncer -c vdirsyncer.config sync")

This obviously entails some execution overhead from the operating system, which is unnecessary as vdirsyncer is a Python module.

Problem

However, it doesn't seem to be (easily) possible to use vdirsyncer as a Python module from within Python code.

  1. In __main__ there is app() being called like this:
from vdirsyncer.cli import app
 app()
  1. The cli module uses click, which has its own default parameters.
  2. The discover command requires interactively confirming certain actions (that's why we have yes | ... in our call in the code sample above).

Question

Is there any documented way how to run vdirsyncer from Python code, cleanly? If not yet, what should we change to get this working avoiding major refactoring?

Expected Behavior

We should be able to run vdirsyncer from within Python with code like this, (e.g.)

import vdirsyncer

syncer = vdirsyncer.discover(config='vdirsyncer.config')
syncer.sync(interactive=False)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with vdirsyncer/main.py and the vdirsyncer.cli app entry point, then trace how Click dispatches the discover and sync commands and how discover requests confirmation. Done means documenting or exposing a clean Python-callable path that accepts the configuration and supports non-interactive discovery and synchronization without subprocesses.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.