"""Configuration file for Applied Computing 1 textbook.

This file was generated by running `runestone init` then deleting unused code.
"""

import os
import socket
import sys
import paver
from paver.easy import Bunch
from paver.easy import options
import paver.setuputils
import pkg_resources
from runestone import get_master_url
from runestone.server import get_dburl

paver.setuputils.install_distutils_tasks()
sys.path.append(os.getcwd())

project_name = 'ac1'
master_url = 'http://127.0.0.1:8000'
if not master_url:
  master_url = get_master_url()

# The root directory for ``runestone serve``.
serving_dir = './build/' + project_name
# The destination directory for ``runestone deploy``.
dest = './published'

options(
    sphinx=Bunch(docroot='.',),
    build=Bunch(
        builddir=serving_dir,
        sourcedir='_sources',
        outdir=serving_dir,
        confdir='.',
        template_args={
            'login_required': 'false',
            'loglevel': 10,
            'course_title': project_name,
            'python3': 'true',
            'dburl': '',
            'default_ac_lang': 'python',
            'jobe_server': 'http://jobe2.cosc.canterbury.ac.nz',
            'proxy_uri_runs': '/jobe/index.php/restapi/runs/',
            'proxy_uri_files': '/jobe/index.php/restapi/files/',
            'downloads_enabled': 'false',
            'enable_chatcodes': 'false',
            'allow_pairs': 'false',
            'dynamic_pages': True,
            'use_services': 'true',
            'basecourse': project_name,
            # If ``dynamic_pages`` is 'True', then the following values are
            # ignored, since they're provided by the server.
            'course_id': project_name,
            'appname': 'runestone',
            'course_url': master_url,
        }))

# Disable undefined-variable pylint since easy.options generates a variable
# named options.
# pylint: disable=undefined-variable
if socket.gethostname() == 'runestone-deploy':
  del options.build.template_args['jobe_server']
  del options.build.template_args['proxy_uri_runs']
  del options.build.template_args['proxy_uri_files']

version = pkg_resources.require('runestone')[0].version
options.build.template_args['runestone_version'] = version

options.build.template_args['dburl'] = get_dburl(outer=locals())
# pylint: enable=undefined-variable

# Disable import-related pylint since this import call must be at the bottom of
# the file.
# pylint: disable=g-import-not-at-top
# pylint: disable=unused-import
# pylint: disable=g-bad-import-order
from runestone import build
# pylint: enable=g-import-not-at-top
# pylint: enable=unused-import
# pylint: enable=g-bad-import-order
