Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
Darwcss
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
Darwcss
Commits
1227c318
Kaydet (Commit)
1227c318
authored
Ara 30, 2018
tarafından
Batuhan Osman TASKAYA
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
flake 8 integration
üst
7ac05275
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
14 deletions
+39
-14
Jenkinsfile
Jenkinsfile
+11
-2
darwcss.py
darwcss/darwcss.py
+28
-12
No files found.
Jenkinsfile
Dosyayı görüntüle @
1227c318
...
@@ -5,7 +5,7 @@ pipeline {
...
@@ -5,7 +5,7 @@ pipeline {
steps
{
steps
{
sh
'python -m venv .venv'
sh
'python -m venv .venv'
sh
""". .venv/bin/activate
sh
""". .venv/bin/activate
pip install pytest twine mypy
pip install pytest twine mypy
flake8 mccabe lake8-junit-repor
pip install -e ."""
pip install -e ."""
}
}
}
}
...
@@ -16,10 +16,19 @@ pipeline {
...
@@ -16,10 +16,19 @@ pipeline {
"""
"""
}
}
}
}
stage
(
'flake8'
)
{
steps
{
sh
""". .venv/bin/activate
flake8 --max-complexity 7 --output-file flake8_results.txt darwc
flake8_junit flake8_results.txt test_flake8.xml
rm flake8_results.txt
"""
}
}
stage
(
'mypy'
)
{
stage
(
'mypy'
)
{
steps
{
steps
{
sh
""". .venv/bin/activate
sh
""". .venv/bin/activate
mypy --junit-xml=test_mpy.xml darwcss/
mypy --junit-xml=test_m
y
py.xml darwcss/
"""
"""
}
}
}
}
...
...
darwcss/darwcss.py
Dosyayı görüntüle @
1227c318
from
__future__
import
annotations
from
__future__
import
annotations
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
dataclasses
import
dataclass
,
field
from
dataclasses
import
dataclass
,
field
from
typing
import
List
,
Any
,
Union
,
Optional
,
Generator
,
Dict
from
typing
import
List
,
Any
,
Union
,
Optional
,
Generator
,
Dict
,
Tuple
from
inspect
import
currentframe
from
inspect
import
currentframe
from
textwrap
import
indent
from
textwrap
import
indent
from
colorsys
import
rgb_to_hls
,
rgb_to_hsv
,
rgb_to_yiq
from
colorsys
import
rgb_to_hls
from
enum
import
Enum
def
render
(
obj
:
Any
)
->
str
:
def
render
(
obj
:
Any
)
->
str
:
...
@@ -20,26 +21,41 @@ class RenderableObject:
...
@@ -20,26 +21,41 @@ class RenderableObject:
def
__render__
(
self
)
->
str
:
def
__render__
(
self
)
->
str
:
pass
pass
def
__add__
(
self
,
other
:
RenderableObject
)
->
str
:
def
__add__
(
self
,
other
:
RenderableObject
)
->
str
:
# noqa:F821 https://github.com/PyCQA/pyflakes/issues/373
return
f
"{render(self)} {render(other)}"
return
f
"{render(self)} {render(other)}"
def
__radd__
(
self
,
other
:
RenderableObject
)
->
str
:
def
__radd__
(
self
,
other
:
RenderableObject
)
->
str
:
# noqa:F821
return
f
"{render(other)} {render(self)}"
return
f
"{render(other)} {render(self)}"
class
ColorTypes
(
Enum
):
RGB
=
0
HLS
=
1
HEX
=
2
@dataclass
@dataclass
class
ColorValue
(
RenderableObject
):
class
ColorValue
(
RenderableObject
):
red
:
int
red
:
int
green
:
int
green
:
int
blue
:
int
blue
:
int
typ
:
str
=
"rgb"
typ
:
ColorTypes
=
ColorTypes
.
RGB
def
__render__
(
self
)
->
str
:
def
__render__
(
self
)
->
str
:
return
(
if
self
.
typ
is
ColorTypes
.
RGB
:
f
"rgb({self.red}, {self.green}, {self.blue})"
return
f
"rgb({self.red}, {self.green}, {self.blue})"
if
self
.
typ
==
"rgb"
elif
self
.
typ
is
ColorTypes
.
HLS
:
else
f
"#{self.red}{self.green}{self.blue}"
return
f
"hls({self.red}, {self.green}
%
, {self.blue}
%
)"
)
elif
self
.
typ
is
ColorTypes
.
HEX
:
return
f
"#{self.red}{self.green}{self.blue}"
else
:
raise
ValueError
(
"ColorValue type must be a valid ColorTypes attribute"
)
def
to_hls
(
self
)
->
Union
[
Tuple
[
float
,
float
,
float
],
NotImplemented
]:
if
self
.
typ
is
ColorTypes
.
RGB
:
return
rgb_to_hls
(
self
.
red
,
self
.
green
,
self
.
blue
)
else
:
return
NotImplemented
@dataclass
@dataclass
...
@@ -59,7 +75,7 @@ class Style:
...
@@ -59,7 +75,7 @@ class Style:
def
__post_init__
(
self
)
->
None
:
def
__post_init__
(
self
)
->
None
:
self
.
value
=
render
(
self
.
value
)
self
.
value
=
render
(
self
.
value
)
f
=
currentframe
()
.
f_back
.
f_back
# type: ignore
f
=
currentframe
()
.
f_back
.
f_back
# type: ignore
l
,
g
=
f
.
f_locals
,
f
.
f_globals
l
,
g
=
f
.
f_locals
,
f
.
f_globals
if
l
.
get
(
"DARWCSS_AUTO"
,
g
.
get
(
"DARWCSS_AUTO"
,
False
)):
if
l
.
get
(
"DARWCSS_AUTO"
,
g
.
get
(
"DARWCSS_AUTO"
,
False
)):
try
:
try
:
...
@@ -81,7 +97,7 @@ class Selector:
...
@@ -81,7 +97,7 @@ class Selector:
def
__add__
(
self
,
other
:
Style
)
->
None
:
def
__add__
(
self
,
other
:
Style
)
->
None
:
self
.
styles
.
append
(
other
)
self
.
styles
.
append
(
other
)
def
__iadd__
(
self
,
other
:
Style
)
->
Selector
:
def
__iadd__
(
self
,
other
:
Style
)
->
Selector
:
# noqa:F821
self
+
other
self
+
other
return
self
return
self
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment