Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions plantuml.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def deflate_and_encode(plantuml_text):

class PlantUML(object):
"""Connection to a PlantUML server with optional authentication.

All parameters are optional.

:param str url: URL to the PlantUML server image CGI. defaults to
http://www.plantuml.com/plantuml/img/
:param dict basic_auth: This is if the plantuml server requires basic HTTP
Expand All @@ -91,7 +91,7 @@ class PlantUML(object):
httplib2.Http() constructor.
:param dict request_opts: Extra options to be passed off to the
httplib2.Http().request() call.

"""

def __init__(self, url, basic_auth={}, form_auth={},
Expand Down Expand Up @@ -152,15 +152,15 @@ def __init__(self, url, basic_auth={}, form_auth={},
def get_url(self, plantuml_text):
"""Return the server URL for the image.
You can use this URL in an IMG HTML tag.

:param str plantuml_text: The plantuml markup to render
:returns: the plantuml server image URL
"""
return self.url + deflate_and_encode(plantuml_text)

def processes(self, plantuml_text):
"""Processes the plantuml text into the raw PNG image data.

:param str plantuml_text: The plantuml markup to render
:returns: the raw image data
"""
Expand All @@ -176,7 +176,7 @@ def processes(self, plantuml_text):
def processes_file(self, filename, outfile=None, errorfile=None, directory=''):
"""Take a filename of a file containing plantuml text and processes
it into a .png image.

:param str filename: Text file containing plantuml markup
:param str outfile: Filename to write the output image to. If not
supplied, then it will be the input filename with the
Expand All @@ -198,7 +198,7 @@ def processes_file(self, filename, outfile=None, errorfile=None, directory=''):
try:
content = self.processes(data)
except PlantUMLHTTPError as e:
err = open(path.join(directory, errorfile), 'w')
err = open(path.join(directory, errorfile), 'wb')
err.write(e.content)
err.close()
return False
Expand Down