Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EO Time Series Viewer
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin Jakimow
EO Time Series Viewer
Commits
1894a37c
Commit
1894a37c
authored
8 years ago
by
benjamin.jakimow@geo.hu-berlin.de
Browse files
Options
Downloads
Patches
Plain Diff
png2qrc keeps alias and merges png's from qrc + icon directoy
parent
2fdb52f8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
make/make.py
+65
-26
65 additions, 26 deletions
make/make.py
with
65 additions
and
26 deletions
make/make.py
+
65
−
26
View file @
1894a37c
...
@@ -158,6 +158,7 @@ def svg2png(pathDir, overwrite=False, mode='INKSCAPE'):
...
@@ -158,6 +158,7 @@ def svg2png(pathDir, overwrite=False, mode='INKSCAPE'):
svgs
=
file_search
(
pathDir
,
'
*.svg
'
)
svgs
=
file_search
(
pathDir
,
'
*.svg
'
)
app
=
QApplication
([],
True
)
app
=
QApplication
([],
True
)
buggySvg
=
[]
for
pathSvg
in
svgs
:
for
pathSvg
in
svgs
:
dn
=
os
.
path
.
dirname
(
pathSvg
)
dn
=
os
.
path
.
dirname
(
pathSvg
)
...
@@ -218,12 +219,23 @@ def svg2png(pathDir, overwrite=False, mode='INKSCAPE'):
...
@@ -218,12 +219,23 @@ def svg2png(pathDir, overwrite=False, mode='INKSCAPE'):
cmd
=
[
jp
(
dirInkscape
,
'
inkscape
'
)]
cmd
=
[
jp
(
dirInkscape
,
'
inkscape
'
)]
cmd
.
append
(
'
--file={}
'
.
format
(
pathSvg
))
cmd
.
append
(
'
--file={}
'
.
format
(
pathSvg
))
cmd
.
append
(
'
--export-png={}
'
.
format
(
pathPng
))
cmd
.
append
(
'
--export-png={}
'
.
format
(
pathPng
))
subprocess
.
call
(
cmd
)
from
subprocess
import
PIPE
p
=
subprocess
.
Popen
(
cmd
,
stdin
=
PIPE
,
stdout
=
PIPE
,
stderr
=
PIPE
)
s
=
""
output
,
err
=
p
.
communicate
()
rc
=
p
.
returncode
print
(
'
Saved {}
'
.
format
(
pathPng
))
if
err
!=
''
:
buggySvg
.
append
((
pathSvg
,
err
))
if
len
(
buggySvg
)
>
0
:
six
.
_print
(
'
SVG Errors
'
)
for
t
in
buggySvg
:
pathSvg
,
error
=
t
six
.
_print
(
pathSvg
,
error
,
file
=
sys
.
stderr
)
s
=
""
def
png2qrc
(
icondir
,
pathQrc
,
pngprefix
=
'
timeseriesviewer
/png
'
):
def
png2qrc
(
icondir
,
pathQrc
,
pngprefix
=
'
timeseriesviewer
'
):
pathQrc
=
os
.
path
.
abspath
(
pathQrc
)
pathQrc
=
os
.
path
.
abspath
(
pathQrc
)
dirQrc
=
os
.
path
.
dirname
(
pathQrc
)
dirQrc
=
os
.
path
.
dirname
(
pathQrc
)
app
=
QApplication
([])
app
=
QApplication
([])
...
@@ -231,37 +243,59 @@ def png2qrc(icondir, pathQrc, pngprefix='timeseriesviewer/png'):
...
@@ -231,37 +243,59 @@ def png2qrc(icondir, pathQrc, pngprefix='timeseriesviewer/png'):
doc
=
QDomDocument
()
doc
=
QDomDocument
()
doc
.
setContent
(
QFile
(
pathQrc
))
doc
.
setContent
(
QFile
(
pathQrc
))
query
=
QXmlQuery
()
pngFiles
=
set
()
#query.setQuery("doc('{}')/RCC/qresource/file".format(pathQrc))
fileAttributes
=
{}
query
.
setQuery
(
"
doc(
'
{}
'
)/RCC/qresource[@prefix=
\"
{}
\"
]/file
"
.
format
(
pathQrc
,
pngprefix
))
#add files already included in QRC
query
.
setQuery
(
"
for $x in doc(
'
{}
'
)/RCC/qresource[@prefix=
\"
{}
\"
] return data($x)
"
.
format
(
pathQrc
,
pngprefix
))
assert
query
.
isValid
()
fileNodes
=
doc
.
elementsByTagName
(
'
file
'
)
#elem = doc.elementsByTagName('qresource')print
for
i
in
range
(
fileNodes
.
count
()):
pngFiles
=
[
r
.
strip
()
for
r
in
str
(
query
.
evaluateToString
()).
split
(
'
\n
'
)]
fileNode
=
fileNodes
.
item
(
i
).
toElement
()
pngFiles
=
set
([
f
for
f
in
pngFiles
if
os
.
path
.
isfile
(
jp
(
dirQrc
,
f
))])
file
=
str
(
fileNode
.
childNodes
().
item
(
0
).
nodeValue
())
if
file
.
lower
().
endswith
(
'
.png
'
):
pngFiles
.
add
(
file
)
if
fileNode
.
hasAttributes
():
attributes
=
{}
for
i
in
range
(
fileNode
.
attributes
().
count
()):
attr
=
fileNode
.
attributes
().
item
(
i
).
toAttr
()
attributes
[
str
(
attr
.
name
())]
=
str
(
attr
.
value
())
fileAttributes
[
file
]
=
attributes
#add new pngs in icondir
for
f
in
file_search
(
icondir
,
'
*.png
'
):
for
f
in
file_search
(
icondir
,
'
*.png
'
):
xmlPath
=
os
.
path
.
relpath
(
f
,
dirQrc
).
replace
(
'
\\
'
,
'
/
'
)
file
=
os
.
path
.
relpath
(
f
,
dirQrc
).
replace
(
'
\\
'
,
'
/
'
)
pngFiles
.
add
(
xmlPath
)
pngFiles
.
add
(
file
)
pngFiles
=
sorted
(
list
(
pngFiles
))
pngFiles
=
sorted
(
list
(
pngFiles
))
def
getResourcePrefixNodes
(
prefix
):
def
elementsByTagAndProperties
(
elementName
,
attributeProperties
,
rootNode
=
None
):
resourceNodes
=
doc
.
elementsByTagName
(
'
qresource
'
)
assert
isinstance
(
elementName
,
str
)
assert
isinstance
(
attributeProperties
,
dict
)
if
rootNode
is
None
:
rootNode
=
doc
resourceNodes
=
rootNode
.
elementsByTagName
(
elementName
)
nodeList
=
[]
nodeList
=
[]
for
i
in
range
(
resourceNodes
.
count
()):
for
i
in
range
(
resourceNodes
.
count
()):
resourceNode
=
resourceNodes
.
item
(
i
).
toElement
()
resourceNode
=
resourceNodes
.
item
(
i
).
toElement
()
if
resourceNode
.
hasAttribute
(
'
prefix
'
)
and
resourceNode
.
attribute
(
'
prefix
'
)
==
prefix
:
for
aName
,
aValue
in
attributeProperties
.
items
():
nodeList
.
append
(
resourceNode
)
if
resourceNode
.
hasAttribute
(
aName
):
if
aValue
!=
None
:
assert
isinstance
(
aValue
,
str
)
if
str
(
resourceNode
.
attribute
(
aName
))
==
aValue
:
nodeList
.
append
(
resourceNode
)
else
:
nodeList
.
append
(
resourceNode
)
return
nodeList
return
nodeList
resourceNode
=
getResourcePrefixNodes
(
pngprefix
)
resourceNode
s
=
elementsByTagAndProperties
(
'
qresource
'
,
{
'
prefix
'
:
pngprefix
}
)
if
len
(
resourceNode
)
>
0
:
if
len
(
resourceNode
s
)
==
1
:
resourceNode
=
resourceNode
[
0
]
resourceNode
=
resourceNode
s
[
0
]
el
se
:
el
if
len
(
resourceNodes
)
==
0
:
resourceNode
=
doc
.
createElement
(
'
qresource
'
)
resourceNode
=
doc
.
createElement
(
'
qresource
'
)
resourceNode
.
setAttribute
(
'
prefix
'
,
pngprefix
)
resourceNode
.
setAttribute
(
'
prefix
'
,
pngprefix
)
else
:
raise
NotImplementedError
()
#remove childs, as we have all stored in list pngFiles
#remove childs, as we have all stored in list pngFiles
childs
=
resourceNode
.
childNodes
()
childs
=
resourceNode
.
childNodes
()
...
@@ -271,7 +305,13 @@ def png2qrc(icondir, pathQrc, pngprefix='timeseriesviewer/png'):
...
@@ -271,7 +305,13 @@ def png2qrc(icondir, pathQrc, pngprefix='timeseriesviewer/png'):
#insert new childs
#insert new childs
for
pngFile
in
pngFiles
:
for
pngFile
in
pngFiles
:
node
=
doc
.
createElement
(
'
file
'
)
node
=
doc
.
createElement
(
'
file
'
)
attributes
=
fileAttributes
.
get
(
pngFile
)
if
attributes
:
for
k
,
v
in
attributes
.
items
():
node
.
setAttribute
(
k
,
v
)
s
=
2
node
.
appendChild
(
doc
.
createTextNode
(
pngFile
))
node
.
appendChild
(
doc
.
createTextNode
(
pngFile
))
resourceNode
.
appendChild
(
node
)
resourceNode
.
appendChild
(
node
)
...
@@ -320,10 +360,9 @@ if __name__ == '__main__':
...
@@ -320,10 +360,9 @@ if __name__ == '__main__':
if
True
:
if
True
:
#convert SVG to PNG and link them into the resource file
#convert SVG to PNG and link them into the resource file
svg2png
(
icondir
,
overwrite
=
False
)
#svg2png(icondir, overwrite=True)
#add png icons to qrc file
#add png icons to qrc file
#
png2qrc(icondir, pathQrc)
png2qrc
(
icondir
,
pathQrc
)
if
True
:
if
True
:
make
(
DIR_UI
)
make
(
DIR_UI
)
print
(
'
Done
'
)
print
(
'
Done
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment