Top

art_export module

mport traceback
rom art import ART_DIR
lass ArtExporter:
   
   """
   Class for exporting an Art into a non-Playscii format.
   Export logic happens in run_export; exporter authors simply extend this
   class, override run_export and the class properties below.
   """
   
   format_name = 'ERROR - ArtExporter.format_name'
   "User-visible name for this format, shown in export chooser."
   format_description = "ERROR - ArtExporter.format_description"
   "String (can be triple-quoted) describing format, shown in export chooser."
   file_extension = ''
   "Extension to give the exported file, sans dot."
   options_dialog_class = None
   "UIDialog subclass exposing export options to user."
   
   def __init__(self, app, out_filename, options={}):
       self.app = app
       self.art = self.app.ui.active_art
       # add file extension to output filename if not present
       if self.file_extension and not out_filename.endswith('.%s' % self.file_extension):
           out_filename += '.%s' % self.file_extension
       # output filename in documents/art dir
       if not out_filename.startswith(self.app.documents_dir + ART_DIR):
           out_filename = self.app.documents_dir + ART_DIR + out_filename
       self.success = False
       "Set True on successful export."
       # remove any cursor-hover changes to art in memory
       for edit in self.app.cursor.preview_edits:
           edit.undo()
       try:
           if self.run_export(out_filename, options):
               self.success = True
           else:
               classname = self.__class__.__name__
               self.app.log('%s failed to export %s' % (classname, out_filename))
       except:
           for line in traceback.format_exc().split('\n'):
               self.app.log(line)
       # store last used export options for "Export last"
       self.app.last_export_options = options
   
   def run_export(self, out_filename, options):
       """
       Contains the actual export logic. Write data based on current art,
       return success.
       """
       return False

Module variables

var ART_DIR

Classes

class ArtExporter

Class for exporting an Art into a non-Playscii format. Export logic happens in run_export; exporter authors simply extend this class, override run_export and the class properties below.

class ArtExporter:
    
    """
    Class for exporting an Art into a non-Playscii format.
    Export logic happens in run_export; exporter authors simply extend this
    class, override run_export and the class properties below.
    """
    
    format_name = 'ERROR - ArtExporter.format_name'
    "User-visible name for this format, shown in export chooser."
    format_description = "ERROR - ArtExporter.format_description"
    "String (can be triple-quoted) describing format, shown in export chooser."
    file_extension = ''
    "Extension to give the exported file, sans dot."
    options_dialog_class = None
    "UIDialog subclass exposing export options to user."
    
    def __init__(self, app, out_filename, options={}):
        self.app = app
        self.art = self.app.ui.active_art
        # add file extension to output filename if not present
        if self.file_extension and not out_filename.endswith('.%s' % self.file_extension):
            out_filename += '.%s' % self.file_extension
        # output filename in documents/art dir
        if not out_filename.startswith(self.app.documents_dir + ART_DIR):
            out_filename = self.app.documents_dir + ART_DIR + out_filename
        self.success = False
        "Set True on successful export."
        # remove any cursor-hover changes to art in memory
        for edit in self.app.cursor.preview_edits:
            edit.undo()
        try:
            if self.run_export(out_filename, options):
                self.success = True
            else:
                classname = self.__class__.__name__
                self.app.log('%s failed to export %s' % (classname, out_filename))
        except:
            for line in traceback.format_exc().split('\n'):
                self.app.log(line)
        # store last used export options for "Export last"
        self.app.last_export_options = options
    
    def run_export(self, out_filename, options):
        """
        Contains the actual export logic. Write data based on current art,
        return success.
        """
        return False

Ancestors (in MRO)

Class variables

var file_extension

Extension to give the exported file, sans dot.

var format_description

String (can be triple-quoted) describing format, shown in export chooser.

var format_name

User-visible name for this format, shown in export chooser.

var options_dialog_class

UIDialog subclass exposing export options to user.

Static methods

def __init__(

self, app, out_filename, options={})

Initialize self. See help(type(self)) for accurate signature.

def __init__(self, app, out_filename, options={}):
    self.app = app
    self.art = self.app.ui.active_art
    # add file extension to output filename if not present
    if self.file_extension and not out_filename.endswith('.%s' % self.file_extension):
        out_filename += '.%s' % self.file_extension
    # output filename in documents/art dir
    if not out_filename.startswith(self.app.documents_dir + ART_DIR):
        out_filename = self.app.documents_dir + ART_DIR + out_filename
    self.success = False
    "Set True on successful export."
    # remove any cursor-hover changes to art in memory
    for edit in self.app.cursor.preview_edits:
        edit.undo()
    try:
        if self.run_export(out_filename, options):
            self.success = True
        else:
            classname = self.__class__.__name__
            self.app.log('%s failed to export %s' % (classname, out_filename))
    except:
        for line in traceback.format_exc().split('\n'):
            self.app.log(line)
    # store last used export options for "Export last"
    self.app.last_export_options = options

def run_export(

self, out_filename, options)

Contains the actual export logic. Write data based on current art, return success.

def run_export(self, out_filename, options):
    """
    Contains the actual export logic. Write data based on current art,
    return success.
    """
    return False

Instance variables

var app

var art

var success

Set True on successful export.