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
9563e8ab
Kaydet (Commit)
9563e8ab
authored
Ara 30, 2018
tarafından
Batuhan Osman TASKAYA
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
type annoations, mypy integration
üst
c7c1e699
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
17 deletions
+26
-17
Jenkinsfile
Jenkinsfile
+9
-1
darwcss.py
darwcss/darwcss.py
+17
-16
No files found.
Jenkinsfile
Dosyayı görüntüle @
9563e8ab
...
...
@@ -5,7 +5,7 @@ pipeline {
steps
{
sh
'python -m venv .venv'
sh
""". .venv/bin/activate
pip install pytest twine
pip install pytest twine
mypy
pip install -e ."""
}
}
...
...
@@ -16,6 +16,13 @@ pipeline {
"""
}
}
stage
(
'mypy'
)
{
steps
{
sh
""". .venv/bin/activate
mypy --junit-xml=test_annotations.xml darwcss/
"""
}
}
stage
(
'build'
)
{
steps
{
sh
""". .venv/bin/activate
...
...
@@ -47,6 +54,7 @@ pipeline {
post
{
always
{
junit
'test_results.xml'
junit
'test_annotations.xml'
}
}
}
darwcss/darwcss.py
Dosyayı görüntüle @
9563e8ab
from
__future__
import
annotations
from
contextlib
import
contextmanager
from
dataclasses
import
dataclass
,
field
from
typing
import
List
,
Any
,
Union
from
typing
import
List
,
Any
,
Union
,
Optional
,
Generator
,
Dict
from
inspect
import
currentframe
from
textwrap
import
indent
from
colorsys
import
rgb_to_hls
,
rgb_to_hsv
,
rgb_to_yiq
def
render
(
obj
)
:
def
render
(
obj
:
Any
)
->
str
:
if
hasattr
(
obj
,
"__render__"
):
return
obj
.
__render__
()
elif
obj
is
None
:
...
...
@@ -16,13 +17,13 @@ def render(obj):
class
RenderableObject
:
def
__render__
(
self
):
def
__render__
(
self
)
->
str
:
pass
def
__add__
(
self
,
other
)
:
def
__add__
(
self
,
other
:
RenderableObject
)
->
str
:
return
f
"{render(self)} {render(other)}"
def
__radd__
(
self
,
other
)
:
def
__radd__
(
self
,
other
:
RenderableObject
)
->
str
:
return
f
"{render(other)} {render(self)}"
...
...
@@ -33,7 +34,7 @@ class ColorValue(RenderableObject):
blue
:
int
typ
:
str
=
"rgb"
def
__render__
(
self
):
def
__render__
(
self
)
->
str
:
return
(
f
"rgb({self.red}, {self.green}, {self.blue})"
if
self
.
typ
==
"rgb"
...
...
@@ -46,7 +47,7 @@ class NumericValue(RenderableObject):
value
:
Union
[
float
,
int
]
unit
:
str
def
__render__
(
self
):
def
__render__
(
self
)
->
str
:
return
f
"{self.value}{self.unit}"
...
...
@@ -56,9 +57,9 @@ class Style:
value
:
Any
important
:
bool
=
False
def
__post_init__
(
self
):
def
__post_init__
(
self
)
->
None
:
self
.
value
=
render
(
self
.
value
)
f
=
currentframe
()
.
f_back
.
f_back
f
=
currentframe
()
.
f_back
.
f_back
# type: ignore
l
,
g
=
f
.
f_locals
,
f
.
f_globals
if
l
.
get
(
"DARWCSS_AUTO"
,
g
.
get
(
"DARWCSS_AUTO"
,
False
)):
try
:
...
...
@@ -77,23 +78,23 @@ class Selector:
area
:
str
styles
:
List
[
Style
]
=
field
(
default_factory
=
list
)
def
__add__
(
self
,
other
)
:
def
__add__
(
self
,
other
:
Style
)
->
None
:
self
.
styles
.
append
(
other
)
def
__iadd__
(
self
,
other
)
:
def
__iadd__
(
self
,
other
:
Style
)
->
Selector
:
self
+
other
return
self
def
append
(
self
,
other
)
:
def
append
(
self
,
other
:
Style
)
->
None
:
self
.
styles
.
append
(
other
)
class
CSS
:
def
__init__
(
self
,
conf
=
None
)
:
self
.
selectors
=
[]
def
__init__
(
self
,
conf
:
Optional
[
Dict
]
=
None
)
->
None
:
self
.
selectors
:
List
[
Selector
]
=
[]
self
.
conf
=
conf
or
{}
def
render
(
self
):
def
render
(
self
)
->
str
:
css
=
""
for
selector
in
self
.
selectors
:
rules
=
""
...
...
@@ -103,7 +104,7 @@ class CSS:
return
css
@contextmanager
def
selector
(
self
,
area
)
:
def
selector
(
self
,
area
:
str
)
->
Generator
[
Selector
,
None
,
None
]
:
selector
=
Selector
(
area
)
try
:
yield
selector
...
...
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