-
Notifications
You must be signed in to change notification settings - Fork 0
/
clickables.py
executable file
·54 lines (43 loc) · 1.24 KB
/
clickables.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! /bin/env python
# -*- encoding: utf-8 -*-
import json
import logging
import os
import pprint
import re
import subprocess
import sys
try: # py3
from shlex import quote
except ImportError: # py2
from pipes import quote
import click
import yaml
import clickable.utils
import clickable.sphinx
import clickable.coloredlogs
import clickable.syncing
clickable.coloredlogs.bootstrap()
logger = logging.getLogger('clickable')
@click.group()
@click.pass_context
def main(ctx):
ctx.obj = {}
path_resolver = clickable.utils.PathResolver(sys.modules[__name__])
ctx.obj['path_resolver'] = path_resolver
ctx.obj['project_root'] = \
os.path.normpath(os.path.dirname(sys.modules[__name__].__file__))
conf_path = os.path.join(ctx.obj['project_root'], 'clickables.yml')
if os.path.isfile(conf_path):
with open(conf_path) as f:
configuration = yaml.safe_load(f)
ctx.obj.update(configuration)
logger.info('loaded configuration: \n{}'.format(pprint.pformat(ctx.obj)))
pass
@main.group()
@click.pass_context
def sphinx(ctx):
pass
sphinx_provider = lambda ctx: ctx.obj['sphinx']
path_provider = lambda ctx: ctx.obj['path_resolver']
clickable.sphinx.sphinx_click_group(sphinx, sphinx_provider)