GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( cc823b...3d112a )
by PyJobs
9s
created

AppContextCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 44
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A get_parser() 0 7 1
A take_action() 0 5 1
A _get_initialized_app_context() 0 21 1
A __init__() 0 4 1
1
# -*- coding: utf-8 -*-
2
import os
3
import sys
4
5
from gearbox.command import Command
6
from paste.deploy import loadapp
7
from webtest import TestApp
8
9
10
class BaseCommand(Command):
11
    pass
12
13
14
class AppContextCommand(BaseCommand):
15
    """
16
    Command who initialize app context at beginning of take_action method.
17
    """
18
    def __init__(self, *args, **kwargs):
19
        super(AppContextCommand, self).__init__(*args, **kwargs)
20
        self._wsgi_app = None
21
        self._test_app = None
22
23
    @staticmethod
24
    def _get_initialized_app_context(parsed_args):
25
        """
26
        :param parsed_args: parsed args (eg. from take_action)
27
        :return: (wsgi_app, test_app)
28
        """
29
        config_file = parsed_args.config_file
30
        config_name = 'config:%s' % config_file
31
        here_dir = os.getcwd()
32
33
        # Load locals and populate with objects for use in shell
34
        sys.path.insert(0, here_dir)
35
36
        # Load the wsgi app first so that everything is initialized right
37
        wsgi_app = loadapp(config_name, relative_to=here_dir)
38
        test_app = TestApp(wsgi_app)
39
40
        # Make available the tg.request and other global variables
41
        tresponse = test_app.get('/_test_vars')
42
43
        return wsgi_app, test_app
44
45
    def take_action(self, parsed_args):
46
        super(AppContextCommand, self).take_action(parsed_args)
47
        wsgi_app, test_app = self._get_initialized_app_context(parsed_args)
48
        self._wsgi_app = wsgi_app
49
        self._test_app = test_app
50
51
    def get_parser(self, prog_name):
52
        parser = super(AppContextCommand, self).get_parser(prog_name)
53
54
        parser.add_argument("-c", "--config",
55
                            help='application config file to read (default: development.ini)',
56
                            dest='config_file', default="development.ini")
57
        return parser
58