Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
c82da85e
Commit
c82da85e
authored
Apr 24, 2013
by
Gary Hodgson
Committed by
Guillaume Seguin
May 30, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formatting of code
parent
a5281465
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
20 additions
and
20 deletions
+20
-20
__init__.py
printrun/cairosvg/__init__.py
+5
-5
parser.py
printrun/cairosvg/parser.py
+3
-3
__init__.py
printrun/cairosvg/surface/__init__.py
+2
-2
colors.py
printrun/cairosvg/surface/colors.py
+1
-1
defs.py
printrun/cairosvg/surface/defs.py
+3
-3
helpers.py
printrun/cairosvg/surface/helpers.py
+2
-2
image.py
printrun/cairosvg/surface/image.py
+2
-2
shapes.py
printrun/cairosvg/surface/shapes.py
+1
-1
units.py
printrun/cairosvg/surface/units.py
+1
-1
No files found.
printrun/cairosvg/__init__.py
View file @
c82da85e
...
...
@@ -29,7 +29,7 @@ from . import surface
VERSION
=
'0.4.4'
SURFACES
=
{
'SVG'
:
surface
.
SVGSurface
,
# Tell us if you actually use this one!
'SVG'
:
surface
.
SVGSurface
,
# Tell us if you actually use this one!
'PNG'
:
surface
.
PNGSurface
,
'PDF'
:
surface
.
PDFSurface
,
'PS'
:
surface
.
PSSurface
}
...
...
@@ -52,14 +52,14 @@ def main():
"""Entry-point of the executable."""
# Get command-line options
option_parser
=
optparse
.
OptionParser
(
usage
=
"usage:
%
prog filename [options]"
,
version
=
VERSION
)
usage
=
"usage:
%
prog filename [options]"
,
version
=
VERSION
)
option_parser
.
add_option
(
"-f"
,
"--format"
,
help
=
"output format"
)
"-f"
,
"--format"
,
help
=
"output format"
)
option_parser
.
add_option
(
"-d"
,
"--dpi"
,
help
=
"svg resolution"
,
default
=
96
)
"-d"
,
"--dpi"
,
help
=
"svg resolution"
,
default
=
96
)
option_parser
.
add_option
(
"-o"
,
"--output"
,
default
=
""
,
help
=
"output filename"
)
default
=
""
,
help
=
"output filename"
)
options
,
args
=
option_parser
.
parse_args
()
# Print help if no argument is given
...
...
printrun/cairosvg/parser.py
View file @
c82da85e
...
...
@@ -79,7 +79,7 @@ def remove_svg_namespace(tree):
class
Node
(
dict
):
"""SVG node with dict-like properties and children."""
def
__init__
(
self
,
node
,
parent
=
None
):
def
__init__
(
self
,
node
,
parent
=
None
):
"""Create the Node from ElementTree ``node``, with ``parent`` Node."""
super
(
Node
,
self
)
.
__init__
()
self
.
children
=
()
...
...
@@ -145,11 +145,11 @@ class Node(dict):
children
=
[]
for
child
in
node
:
children
.
append
(
Node
(
child
,
parent
=
self
))
children
.
append
(
Node
(
child
,
parent
=
self
))
if
child
.
tail
:
anonymous
=
ElementTree
.
Element
(
'tspan'
)
anonymous
.
text
=
child
.
tail
children
.
append
(
Node
(
anonymous
,
parent
=
self
))
children
.
append
(
Node
(
anonymous
,
parent
=
self
))
return
list
(
children
)
...
...
printrun/cairosvg/surface/__init__.py
View file @
c82da85e
...
...
@@ -50,7 +50,7 @@ class Surface(object):
surface_class
=
None
@
classmethod
def
convert
(
cls
,
bytestring
=
None
,
**
kwargs
):
def
convert
(
cls
,
bytestring
=
None
,
**
kwargs
):
"""Convert a SVG document to the format for this class.
Specify the input by passing one of these:
...
...
@@ -172,7 +172,7 @@ class Surface(object):
"""Draw the root ``node``."""
self
.
draw
(
node
)
def
draw
(
self
,
node
,
stroke_and_fill
=
True
):
def
draw
(
self
,
node
,
stroke_and_fill
=
True
):
"""Draw ``node`` and its children."""
old_font_size
=
self
.
font_size
self
.
font_size
=
size
(
self
,
node
.
get
(
"font-size"
,
"12pt"
))
...
...
printrun/cairosvg/surface/colors.py
View file @
c82da85e
...
...
@@ -200,7 +200,7 @@ COLORS = {
"windowtext"
:
"#000000"
}
def
color
(
string
=
None
,
opacity
=
1
):
def
color
(
string
=
None
,
opacity
=
1
):
"""Replace ``string`` representing a color by a RGBA tuple."""
if
not
string
or
string
in
(
"none"
,
"transparent"
):
return
(
0
,
0
,
0
,
0
)
...
...
printrun/cairosvg/surface/defs.py
View file @
c82da85e
...
...
@@ -107,7 +107,7 @@ def draw_gradient(surface, node, name):
if
gradient_node
.
get
(
"gradientUnits"
)
!=
"userSpaceOnUse"
:
gradient_pattern
.
set_matrix
(
cairo
.
Matrix
(
1
/
width
,
0
,
0
,
1
/
height
,
-
x
/
width
,
-
y
/
height
))
1
/
width
,
0
,
0
,
1
/
height
,
-
x
/
width
,
-
y
/
height
))
gradient_pattern
.
set_extend
(
getattr
(
cairo
,
"EXTEND_
%
s"
%
node
.
get
(
"spreadMethod"
,
"pad"
)
.
upper
()))
...
...
@@ -141,7 +141,7 @@ def draw_pattern(surface, name):
surface
.
context
.
set_source
(
pattern_pattern
)
def
draw_marker
(
surface
,
node
,
position
=
"mid"
):
def
draw_marker
(
surface
,
node
,
position
=
"mid"
):
"""Draw a marker."""
# TODO: manage markers for other tags than path
if
position
==
"start"
:
...
...
@@ -229,7 +229,7 @@ def use(surface, node):
del
node
[
"viewBox"
]
href
=
node
.
get
(
"{http://www.w3.org/1999/xlink}href"
)
url
=
list
(
urls
(
href
))[
0
]
tree
=
Tree
(
url
=
url
,
parent
=
node
)
tree
=
Tree
(
url
=
url
,
parent
=
node
)
surface
.
set_context_size
(
*
node_format
(
surface
,
tree
))
surface
.
draw
(
tree
)
surface
.
context
.
restore
()
...
...
printrun/cairosvg/surface/helpers.py
View file @
c82da85e
...
...
@@ -68,7 +68,7 @@ def node_format(surface, node):
return
width
,
height
,
viewbox
def
normalize
(
string
=
None
):
def
normalize
(
string
=
None
):
"""Normalize a string corresponding to an array of various values."""
string
=
string
.
replace
(
"-"
,
" -"
)
string
=
string
.
replace
(
","
,
" "
)
...
...
@@ -91,7 +91,7 @@ def normalize(string=None):
return
string
.
strip
()
def
point
(
surface
,
string
=
None
):
def
point
(
surface
,
string
=
None
):
"""Return ``(x, y, trailing_text)`` from ``string``."""
if
not
string
:
return
(
0
,
0
,
""
)
...
...
printrun/cairosvg/surface/image.py
View file @
c82da85e
...
...
@@ -56,7 +56,7 @@ def open_data_url(url):
if
header
:
semi
=
header
.
rfind
(
";"
)
if
semi
>=
0
and
"="
not
in
header
[
semi
:]:
encoding
=
header
[
semi
+
1
:]
encoding
=
header
[
semi
+
1
:]
else
:
encoding
=
""
else
:
...
...
@@ -110,7 +110,7 @@ def image(surface, node):
del
node
[
"y"
]
if
"viewBox"
in
node
:
del
node
[
"viewBox"
]
tree
=
Tree
(
bytestring
=
image_bytes
)
tree
=
Tree
(
bytestring
=
image_bytes
)
tree_width
,
tree_height
,
viewbox
=
node_format
(
surface
,
tree
)
if
not
tree_width
or
not
tree_height
:
tree_width
=
tree
[
"width"
]
=
width
...
...
printrun/cairosvg/surface/shapes.py
View file @
c82da85e
...
...
@@ -49,7 +49,7 @@ def ellipse(surface, node):
surface
.
context
.
scale
(
1
,
ratio
)
surface
.
context
.
arc
(
size
(
surface
,
node
.
get
(
"x"
),
"x"
)
+
size
(
surface
,
node
.
get
(
"cx"
),
"x"
),
(
size
(
surface
,
node
.
get
(
"y"
),
"y"
)
+
(
size
(
surface
,
node
.
get
(
"y"
),
"y"
)
+
size
(
surface
,
node
.
get
(
"cy"
),
"y"
))
/
ratio
,
size
(
surface
,
node
.
get
(
"rx"
),
"x"
),
0
,
2
*
pi
)
surface
.
context
.
restore
()
...
...
printrun/cairosvg/surface/units.py
View file @
c82da85e
...
...
@@ -30,7 +30,7 @@ UNITS = {
"px"
:
None
}
def
size
(
surface
,
string
,
reference
=
"xy"
):
def
size
(
surface
,
string
,
reference
=
"xy"
):
"""Replace a ``string`` with units by a float value.
If ``reference`` is a float, it is used as reference for percentages. If it
...
...
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