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.
Passed
Pull Request — master (#23)
by
unknown
01:11
created

qtsass.cli.create_parser()   A

Complexity

Conditions 1

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 1
nop 0
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
# -----------------------------------------------------------------------------
4
# Copyright (c) 2015 Yann Lanthony
5
# Copyright (c) 2017-2018 Spyder Project Contributors
6
#
7
# Licensed under the terms of the MIT License
8
# (See LICENSE.txt for details)
9
# -----------------------------------------------------------------------------
10
"""qtsass command line interface."""
11
12
# Standard library imports
13
from __future__ import absolute_import, print_function
14
import argparse
15
import os
16
import sys
17
import time
18
import logging
19
import signal
0 ignored issues
show
Unused Code introduced by
The import signal seems to be unused.
Loading history...
20
21
# Local imports
22
from qtsass.api import compile, compile_filename, compile_dirname, watch
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in compile.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
23
24
25
logging.basicConfig(level=logging.DEBUG)
26
_log = logging.getLogger(__name__)
0 ignored issues
show
Coding Style Naming introduced by
The name _log does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
27
28
29
def create_parser():
30
    """Create qtsass's cli parser."""
31
32
    parser = argparse.ArgumentParser(
33
        prog='QtSASS',
34
        description='Compile a Qt compliant CSS file from a SASS stylesheet.',
35
    )
36
    parser.add_argument('input', type=str, help='The SASS stylesheet file.')
37
    parser.add_argument(
38
        '-o',
39
        '--output',
40
        type=str,
41
        help='The path of the generated Qt compliant CSS file.'
42
    )
43
    parser.add_argument(
44
        '-w',
45
        '--watch',
46
        action='store_true',
47
        help='If set, recompile when the source file changes.'
48
    )
49
    return parser
50
51
52
def main(args):
53
    """qtsass's cli entry point."""
54
55
    args = create_parser().parse_args(args)
56
    file_mode = os.path.isfile(args.input)
57
    dir_mode = os.path.isdir(args.input)
58
59
    if file_mode and not args.output:
60
        css = compile(args.input)
61
        print(css)
62
        sys.exit(0)
63
64
    elif file_mode:
65
        compile_filename(args.input, args.output)
66
67
    elif dir_mode and not args.output:
68
        print('Error: missing required option: -o/--output')
69
        sys.exit(1)
70
71
    elif dir_mode:
72
        compile_dirname(args.input, args.output)
73
74
    else:
75
        print('Error: input must be a file or a directory')
76
        sys.exit(1)
77
78
    if args.watch:
79
        _log.info('qtsass is watching {}...'.format(args.input))
0 ignored issues
show
introduced by
Use formatting in logging functions and pass the parameters as arguments
Loading history...
80
        observer = watch(args.input, args.output)
81
        observer.start()
82
        try:
83
            while True:
84
                time.sleep(1)
85
        except KeyboardInterrupt:
86
            observer.stop()
87
        observer.join()
88
        sys.exit(0)
89