Esempio n. 1
0
 def test_load_conf_os_env(self, mock_args):
     Config.clear()
     Config.define_bool("VaR", False, "turn me true")
     Config.define_int("v1", 0, "var")
     Config.define_int("nm.v2", 0, "var")
     Config.load_conf()
     self.assertEqual(Config.get_var("v1"), 1)
     self.assertEqual(Config.get_var("nm.v2"), 2)
     self.assertEqual(Config.get_var("VAr"), True)
Esempio n. 2
0
 def test_define_int(self):
     Config.clear()
     # int and flat float can be assign as int
     Config.define_int("a", 5, "A test for int")
     Config.define_int("b", 5., "A test for int with a float var")
     # But not float
     with self.assertRaises(ValueError):
         Config.define_int("c", 5.5, "A test for int with a float var")
     # Can't assign twice the same variable
     with self.assertRaises(KeyError):
         Config.define_int("a", 5, "A test for int")
     self.assertDictEqual(Config.get_dict(), {'a': 5, 'b': 5})
Esempio n. 3
0
 def test_load_conf_cmd(self, mock_args):
     Config.clear()
     Config.define_bool("VaR", False, "turn me true")
     Config.define_int("v1", 1, "var")
     Config.define_int("v2", 2, "var")
     Config.define_float_list("list", [5., 6, "7."], "A test for list")
     with Config.namespace("n1"):
         Config.define_int("v1", 1, "var")
         Config.define_int("v2", 2, "var")
         Config.define_bool("V3", True, "turn me false")
     Config.load_conf()
     self.assertEqual(Config.get_var("v1"), 2)
     self.assertEqual(Config.get_var("v2"), 3)
     self.assertEqual(Config.get_var("n1.v1"), 2)
     self.assertEqual(Config.get_var("n1.v2"), 3)
     self.assertEqual(Config.get_var("n1.v3"), False)
     self.assertEqual(Config.get_var("VAr"), True)
     self.assertEqual(Config.get_var("list"), [1.0, 2.0, 3.0])
Esempio n. 4
0
 def test_namespace(self):
     Config.clear()
     Config.define_int("namespace1.test_int", 5, "A test for int")
     with Config.namespace("namespace2"):
         Config.define_int("test_int", 5, "A test for int")
         Config.define_int("subnamespace.test_int", 5, "A test for int")
         with Config.namespace("subnamespace2"):
             Config.define_int("plop", 4, "test of subnamespace")
     self.assertDictEqual(
         Config.get_dict(), {
             'namespace1': {
                 'test_int': 5
             },
             'namespace2': {
                 'test_int': 5,
                 'subnamespace': {
                     'test_int': 5
                 },
                 'subnamespace2': {
                     'plop': 4
                 }
             }
         })
Esempio n. 5
0
import flask

from distribute_config import Config

coloredlogs.install(level='DEBUG')

Config.define_str("images_path", "static/images",
                  "Path where are stored the images to annotate")
Config.define_str("human_annotations_path", "static/human_annotations",
                  "Path where are stored human annotation")
Config.define_str("model_annotations_path", "static/model_annotations",
                  "Path where are stored model annotation for helping human")
with Config.namespace("class"):
    Config.define_str_list("names", [], "name of the classes to annotate")
    Config.define_str_list("colors", [], "colors for each classes")
Config.define_int("min_height", 0,
                  "Rectangle with lower height will be displayed red")
Config.define_int("min_width", 0,
                  "Rectangle with lower width will be displayed red")

image_provider = None


class ImageProvider:
    def __init__(self):
        """class providing path of images to process
        """
        # user-provided attributes
        self.images_path = Config.get_var("images_path")
        self.human_annotations_path = Config.get_var("human_annotations_path")
        self.model_annotations_path = Config.get_var("model_annotations_path")