Example #1
0
from __future__ import absolute_import

import shutil
import sys

sys.path = ['..', '.'] + sys.path

import unittest
import clickfig
from clickfig import exception

cfg_ini = clickfig.Config([{
    "level": "local",
    "name": "./ini/test.ini"
}, {
    "level": "global",
    "name": "./ini/test_global.ini"
}])

cfg_json = clickfig.Config([{
    "level": "local",
    "name": "./json/test.json"
}, {
    "level": "global",
    "name": "./json/test_global.json"
}])

cfg_python = clickfig.Config([{
    "level": "local",
    "name": "./py/_test.py"
}, {
Example #2
0
import sys
import click
sys.path = ['../..'] + sys.path

import clickfig

cfg = clickfig.Config("./test.json")


@click.group()
def main():
    pass


clickfig.attach(main, cfg)
main()
if __name__ == "__main__":
    main()
Example #3
0
import sys
import click
sys.path = ['../..'] + sys.path

import clickfig

cfg = clickfig.Config("./test.ini")


@click.group()
def main():
    pass


clickfig.attach(main, cfg)

if __name__ == "__main__":
    main()
Example #4
0
to contact and run jobs on a server. The config options are used in multiple commands.
"""
from __future__ import absolute_import, print_function

import sys
from random import random
from time import sleep

import click
from six.moves import urllib

sys.path = ['../..'] + sys.path

import clickfig

cfg = clickfig.Config("./server.ini")


def get_url(username=None, password=None):
    """
    This isn't part of the CLI application per se,
    but it does something that's accomplished in more
    than one function below: namely, grabbing the pieces
    of the fake server URL and putting them together.

    So, it's here for DRY purposes.
    :param str|None username: A username that overrides the one given in the config file.
    :param str|None password: A password that overrides the one given in the config file.
    :return: The URL with login info included (and URL-escaped).
    :rtype: str
    """
Example #5
0
from __future__ import absolute_import
import sys

sys.path = ['..', '.'] + sys.path

import unittest
import clickfig
from clickfig import exception

import os

cfg_ini = clickfig.Config([{"name": "./default_test_unset.ini", "default": "./ini/default.ini"}],
                          verbose=False)
cfg_json = clickfig.Config([{"name": "./default_test_unset.json", "default": "./json/default.json"}],
                           verbose=True)


class TestUnset(unittest.TestCase):
    def test_ini(self):
        cfg_ini.unset("first.foo")

        with self.assertRaises(exception.KeyNotFoundException):
            cfg_ini.read(key="first.foo")

    def test_json(self):

        cfg_json.unset("second.blarg")

        with self.assertRaises(exception.KeyNotFoundException):
            cfg_json.read("key=second.blarg")