logo

wsd filter

← Back to Filter List

wsd


Dexy filter to use WebSequenceDiagrams.com

Aliases for this filter

  • wsd

Converts from file formats:

  • .wsd

To file formats:

  • .png
  • .svg
  • .img
  • .pdf

Available settings:

SettingDescriptionDefault
add-new-filesBoolean or list of extensions/patterns to match.False
added-in-versionDexy version when this filter was first available.1.0.13
additional-doc-filtersFilters to apply to additional documents created as side effects.{}
additional-doc-settingsSettings to apply to additional documents created as side effects.{}
api-key-nameThe name of this APIwsd
api-urlThe url of the API endpoint.http://www.websequencediagrams.com/
data-typeAlias of custom data class to use to store filter output.generic
document-api-config-fileFilename to store config for a file (can only have 1 per directory, dexy looks for suffix format first.None
document-api-config-postfixSuffix to attach to content filename to indicate this is the config for that file.-config.json
examplesTemplates which should be used as examples for this filter.[]
exclude-add-new-filesList of patterns to skip even if they match add-new-files.[]
exclude-new-files-from-dirList of directories to skip when adding new files.[]
extFile extension to output.None
extension-mapDictionary mapping input extensions to default output extensions.None
helpHelpstring for plugin.Dexy filter to use WebSequenceDiagrams.com
input-extensionsList of extensions which this filter can accept as input.['.wsd']
keep-originalsWhether, if additional-doc-filters are specified, the original unmodified docs should also be added.False
keyYour WebSequenceDiagrams API Key if you have oneNone
master-api-key-fileMaster API key file for user.~/.dexyapis
mkdirA directory which should be created in working dir.None
mkdirsA list of directories which should be created in working dir.[]
nodocWhether filter should be excluded from documentation.False
outputWhether to output results of this filter by default by reporters such as 'output' or 'website'.True
output-extensionsList of extensions which this filter can produce as output.['.png', '.svg', '.img', '.pdf']
override-workspace-exclude-filtersIf True, document will be populated to other workspaces ignoring workspace-exclude-filters.False
preserve-prior-data-classWhether output data class should be set to match the input data class.False
project-api-key-fileAPI key file for project..dexyapis
require-outputShould dexy raise an exception if no output is produced by this filter?True
styleStyle to use, e.g. 'patent' or 'napkin'default
tagsTags which describe the filter.[]
variablesA dictionary of variable names and values to make available to this filter.{}
varsA dictionary of variable names and values to make available to this filter.{}
versionVersion of the WebSequenceDiagrams API to address1
workspace-exclude-filtersFilters whose output should be excluded from workspace.['pyg']
workspace-includesIf set to a list of filenames or extensions, only these will be populated to working dir.None
Filter Source Code
class WebSequenceDiagrams(ApiFilter):
    """
    Dexy filter to use WebSequenceDiagrams.com
    """
    aliases = ["wsd"]
    _settings = {
        "version": ("Version of the WebSequenceDiagrams API to address", "1"),
        "style": ("Style to use, e.g. 'patent' or 'napkin'", "default"),
        "key": ("Your WebSequenceDiagrams API Key if you have one", None),
        "api-url": "http://www.websequencediagrams.com/",
        "output-extensions": ['.png', '.svg', '.img', '.pdf'],
        "input-extensions": ['.wsd'],
        "output": True,
        'api-key-name': "wsd",
        "added-in-version": "1.0.13",

    }
    _unset = ['api-username', 'api-password']

    def process(self):
        request = {}
        settings = self.setting_values()
        request["message"] = self.input_data
        request["style"] = settings["style"]
        request["apiVersion"] = settings["version"]
        key = None
        try:
            key = settings["key"] or self.read_param("key")
        except KeyError:
            pass
        if key:
            request["apikey"] = key
            self.log_debug("Using key to access WebSequenceDiagrams")
        else:
            self.log_debug("Accessing WebSequenceDiagrams without API key")

        resource = urllib.parse.urlencode(request)
        self.log_debug("Fetching from WebSequenceDiagrams")
        response = urllib.urlopen(settings["api-url"]+"index.php", resource)
        line = response.readline()
        response.close()

        expr = re.compile("(\?(img|pdf|png|svg)=[a-zA-Z0-9]+)")
        match = expr.search(line)

        if match is None:
            self.log_error("Problem fetching from WebSequenceDiagrams")
            raise UserFeedback("Invalid response from server.")

        self.log_debug("Writing WebSequenceDiagrams result to {0}".format(
            self.output_filepath()))

        response = urllib.urlopen(settings["api-url"] + match.group(0))
        self.output_data.set_data(response.read())
        self.output_data.save()
        response.close()

Content © 2020 Dr. Ana Nelson | Site Design © Copyright 2011 Andre Gagnon | All Rights Reserved.