Exemplo n.º 1
0
    def test5(self):
        """Test Decorator With Nested Context Managers"""
        @debug
        @animated('with args')
        def _with_args(*args):
            time.sleep(1)
            return args

        with animated('layer-01'):
            with animated('layer-02'):
                with animated('level-03'):
                    level1 = _with_args(*self.args)
                level2 = _with_args(*self.args)

        for level in (level1, level2):
            self.assertEqual(level, self.args, 'need returns the same I/O')
Exemplo n.º 2
0
    def test5(self):
        """Test Decorator With Nested Context Managers"""
        @debug
        @animated('with args')
        def _with_args(*args):
            time.sleep(1)
            return args

        with animated('layer-01'):
            with animated('layer-02'):
                with animated('level-03'):
                    level1 = _with_args(*self.args)
                level2 = _with_args(*self.args)

        for level in (level1, level2):
            self.assertEqual(level, self.args, 'need returns the same I/O')
Exemplo n.º 3
0
    def test_decorator_with_nested_context_managers(self):
        @debug
        @animated('with args')
        def with_args(*args):
            time.sleep(0.5)
            return args

        with animated('level1'):
            with animated('level2'):
                with animated('level3'):
                    x = with_args(*self.args)
                y = with_args(*self.args)
            z = with_args(*self.args)

        for i in (x, y, z):
            self.assertEqual(x, self.args, 'need returns the same I/O')
Exemplo n.º 4
0
    def test_decorator_with_nested_context_managers(self):

        @debug
        @animated('with args')
        def with_args(*args):
            time.sleep(0.5)
            return args

        with animated('level1'):
            with animated('level2'):
                with animated('level3'):
                    x = with_args(*self.args)
                y = with_args(*self.args)
            z = with_args(*self.args)

        for i in (x, y, z):
            self.assertEqual(x, self.args, 'need returns the same I/O')
Exemplo n.º 5
0
    def test_decorator_with_context_manager(self):
        @debug
        @animated
        def animation(*args):
            time.sleep(1)

        with animated('testing something'):
            self.assertIsNone(animation(*self.args),
                              'need returns the same I/O')
Exemplo n.º 6
0
    def test_decorator_with_context_manager(self):
        @debug
        @animated
        def animation(*args):
            time.sleep(1)

        with animated('testing something'):
            self.assertIsNone(animation(*self.args),
                              'need returns the same I/O')
Exemplo n.º 7
0
    def test4(self):
        """Test Decorator With Context Manager"""
        @debug
        @animated
        def _animation(*args):  # pylint: disable=unused-argument
            time.sleep(1)

        with animated('testing something'):
            self.assertIsNone(_animation(*self.args),
                              'need returns the same I/O')
Exemplo n.º 8
0
    def test4(self):
        """Test Decorator With Context Manager"""
        @debug
        @animated
        def _animation(*args):  # pylint: disable=unused-argument
            time.sleep(1)

        with animated('testing something'):
            self.assertIsNone(_animation(*self.args),
                              'need returns the same I/O')
Exemplo n.º 9
0
def Crawl():
    try:
        res = {}

        db = TinyDB(os.path.join(__dir, 'oiprog.json'))
        Config = Query()

        for site in sites:
            data = db.search(Config[site['name']].exists())[0][site['name']]
            if (data['display']):
                with dc.animated(msg[site['name']]):
                    res[site['name']] = site['lib'].get()

        return res
    except Exception as e:
        error(e, debug=False)
        return
Exemplo n.º 10
0
def plot_save(output_dataframe,
              basename,
              options,
              x_label='Stack allocation',
              y_label='Operations in execution by time'):
    verbose = False
    if 'verbose' in options and options.verbose:
        verbose = True
    if options.show_graph:
        if verbose:
            print(":: showing graph")
        with animated("ploting the graph"):
            show(output_dataframe, basename, x_label, y_label)
    if options.save_graph:
        figurename = basename + '.jpg'
        save(output_dataframe, figurename, x_label, y_label)
        if verbose:
            print(":: saved graph on: {}".format(figurename))
    if verbose:
        print(output_dataframe)
Exemplo n.º 11
0
def save(output_dataframe, basename, verbose=False):
    with animated("saving output on csv"):
        csvname = basename + '.csv'
        output_dataframe.to_csv(csvname, index=False)
        if verbose:
            print(":: saved csv at {}".format(csvname))