{{# This template lists all paths in the given directory
    (or the download directory) NOT loaded into the client.

    Use it like this:
        rtcontrol -qO orphans.txt.default // -Ddir=$PWD
}}{{py:
global os, config, checked_dir, entries
from pyrocore import config
from pyrocore.util import os

checked_dir = getattr(config, 'dir', proxy.directory.default())
checked_dir = os.path.realpath(checked_dir.rstrip(os.sep)) + os.sep

# List all non-symlinked entries in given directory
entries = set(i.decode('utf8')
    for i in os.listdir(checked_dir)
    if not os.path.islink(os.path.join(checked_dir, i)))

# From that list, remove anything loaded in the client
entries -= set(os.path.basename(d.realpath)
    for d in matches 
    if d.realpath.startswith(checked_dir))
}}{{for i in sorted(entries)}}{{#
    }}{{checked_dir}}{{i}}
{{endfor}}
