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 functions.""" |
10
|
|
|
|
11
|
|
|
# Third party imports |
12
|
|
|
import sass |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
def rgba(r, g, b, a): |
|
|
|
|
16
|
|
|
result = 'rgba({}, {}, {}, {}%)' |
17
|
|
|
if isinstance(r, sass.SassNumber): |
18
|
|
|
return result.format( |
19
|
|
|
int(r.value), |
20
|
|
|
int(g.value), |
21
|
|
|
int(b.value), |
22
|
|
|
int(a.value * 100) |
23
|
|
|
) |
24
|
|
|
elif isinstance(r, float): |
25
|
|
|
return result.format(int(r), int(g), int(b), int(a * 100)) |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
def rgba_from_color(color): |
29
|
|
|
""" |
30
|
|
|
Conform rgba |
31
|
|
|
|
32
|
|
|
:type color: sass.SassColor |
33
|
|
|
""" |
34
|
|
|
return rgba(color.r, color.g, color.b, color.a) |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
def qlineargradient(x1, y1, x2, y2, stops): |
|
|
|
|
38
|
|
|
""" |
39
|
|
|
Implementation of qss qlineargradient function for scss. |
40
|
|
|
|
41
|
|
|
:type x1: sass.SassNumber |
42
|
|
|
:type y1: sass.SassNumber |
43
|
|
|
:type x2: sass.SassNumber |
44
|
|
|
:type y2: sass.SassNumber |
45
|
|
|
:type stops: sass.SassList |
46
|
|
|
:return: |
47
|
|
|
""" |
48
|
|
|
stops_str = '' |
49
|
|
|
for stop in stops[0]: |
50
|
|
|
pos, color = stop[0] |
51
|
|
|
stops_str += ' stop: {} {}'.format(pos.value, rgba_from_color(color)) |
52
|
|
|
|
53
|
|
|
return 'qlineargradient(x1: {}, y1: {}, x2: {}, y2: {},{})'.format( |
54
|
|
|
x1.value, |
55
|
|
|
y1.value, |
56
|
|
|
x2.value, |
57
|
|
|
y2.value, |
58
|
|
|
stops_str.rstrip(',') |
59
|
|
|
) |
60
|
|
|
|
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.