示例#1
0
 def _load_entries(self):
     for path in [scripter_path, os.path.expanduser("~/.scribus/scripter/")]:
         autoload_path = os.path.join(path, "autoload")
         if not os.path.exists(autoload_path):
             continue
         sys.path.insert(0, autoload_path)
         from scribusscript import load_scripts
         self.autoload_scripts = scripts = load_scripts(autoload_path)
         for sd in scripts:
             try:
                 sd.install()
             except:
                 excepthook.show_current_error(i18n("Error installing %r") % sd.name)
示例#2
0
 def _load_entries(self):
     for path in [scripter_path, os.path.expanduser("~/.scribus/scripter/")]:
         autoload_path = os.path.join(path, "autoload")
         if not os.path.exists(autoload_path):
             continue
         sys.path.insert(0, autoload_path)
         from scribusscript import load_scripts
         self.autoload_scripts = scripts = load_scripts(autoload_path)
         for sd in scripts:
             try:
                 sd.install()
             except:
                 excepthook.show_current_error(i18n("Error installing %r") % sd.name)
示例#3
0
def load_scripts(path_or_filename):
    if os.path.isdir(path_or_filename):
        path = os.path.abspath(os.path.expanduser(path_or_filename))
        extensions = ScribusScript.filetypes.keys()
        files = [os.path.join(path, name) for name in os.listdir(path) if os.path.splitext(name)[1] in extensions]
    else:
        files = [os.path.abspath(os.path.expanduser(path_or_filename))]
    scripts = []
    for filename in files:
        try:
            sd = load_filename(filename)
            scripts.append(sd)
        except:
            excepthook.show_current_error("Error loading %r" % os.path.basename(filename))
    return scripts
示例#4
0
def load_scripts(path_or_filename):
    if os.path.isdir(path_or_filename):
        path = os.path.abspath(os.path.expanduser(path_or_filename))
        extensions = ScribusScript.filetypes.keys()
        files = [ os.path.join(path, name) for name in os.listdir(path) \
                              if os.path.splitext(name)[1] in extensions ]
    else:
        files = [os.path.abspath(os.path.expanduser(path_or_filename))]
    scripts = []
    for filename in files:
        try:
            sd = load_filename(filename)
            scripts.append(sd)
        except:
            excepthook.show_current_error("Error loading %r" %
                                          os.path.basename(filename))
    return scripts
示例#5
0
 def run(self, catch_errors=True):
     """
     uses scripter_runtime to call a script
     """
     try:
         win = Scripter.activeWindow
         if win:
             win.redraw = self.redraw
         run_filename(
             self.filename, self.subroutine, extension=(self.mode == "extension"), background=self.background_mode
         )
         if win:
             win.redraw = True
             if not self.redraw:
                 win.update()
     except:
         if not catch_errors:
             raise
         excepthook.show_current_error("Error running %r" % os.path.basename(self.filename))
示例#6
0
 def run(self, catch_errors=True):
     """
     uses scripter_runtime to call a script
     """
     try:
         win = Scripter.activeWindow
         if win:
             win.redraw = self.redraw
         run_filename(self.filename,
                      self.subroutine,
                      extension=(self.mode == "extension"),
                      background=self.background_mode)
         if win:
             win.redraw = True
             if not self.redraw:
                 win.update()
     except:
         if not catch_errors:
             raise
         excepthook.show_current_error("Error running %r" %
                                       os.path.basename(self.filename))