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 ( 7e9855...54cf91 )
by Gonzalo
12s
created

qtsass.importers.norm_path()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
# -*- coding: utf-8 -*-
2
# -----------------------------------------------------------------------------
3
# Copyright (c) 2015 Yann Lanthony
4
# Copyright (c) 2017-2018 Spyder Project Contributors
5
#
6
# Licensed under the terms of the MIT License
7
# (See LICENSE.txt for details)
8
# -----------------------------------------------------------------------------
9
"""Libsass importers."""
10
11
# Standard library imports
12
from __future__ import absolute_import
13
import os
14
15
# Local imports
16
from qtsass.conformers import scss_conform
17
18
19
def norm_path(*parts):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
20
    return os.path.normpath(os.path.join(*parts))
21
22
23
def qss_importer(where):
24
    """
25
    Returns a function which conforms imported qss files to valid scss to be
26
    used as an importer for sass.compile.
27
28
    :param where: Directory containing scss, css, and sass files
29
    """
30
31
    def find_file(import_file):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
32
33
        # Create partial import filename
34
        dirname, basename = os.path.split(import_file)
35
        if dirname:
36
            import_partial_file = '/'.join([dirname, '_' + basename])
37
        else:
38
            import_partial_file = '_' + basename
39
40
        # Build potential file paths for @import "import_file"
41
        potential_files = []
42
        for ext in ['', '.scss', '.css', '.sass']:
43
            full_name = import_file + ext
44
            partial_name = import_partial_file + ext
45
            potential_files.append(full_name)
46
            potential_files.append(partial_name)
47
            potential_files.append(norm_path(where, full_name))
48
            potential_files.append(norm_path(where, partial_name))
49
50
        # Return first existing potential file
51
        for potential_file in potential_files:
52
            if os.path.isfile(potential_file):
53
                return potential_file
54
55
        return None
56
57
    def import_and_conform_file(import_file):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
58
59
        real_import_file = find_file(import_file)
60
        with open(real_import_file, 'r') as f:
0 ignored issues
show
Coding Style Naming introduced by
The name f does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[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...
61
            import_str = f.read()
62
63
        return [(import_file, scss_conform(import_str))]
64
65
    return import_and_conform_file
66