Exemplo n.º 1
0
 def getConfigFileHandle(cls, confdir, mode, url):
     """Get a file handle to data in the project's configuration directory.
     
     Files within the configuration directory should be based on the major
     mode name, and optionally for added specificity can append a filename
     extension.
     
     For instance, the template system used for projects uses the
     "$PROJROOT/.peppy- project/templates" directory by default, where
     $PROJROOT is the root directory of the project.  Within that templates
     directory, the file "Python" is the default for python files, but
     "Python.pyx" could be used as a default for pyrex files.
     
     @param confdir: pathname of configuration directory
     @param mode: major mode instance
     @param url: url of file that is being created
     
     @return: file-like object to read the data, or None if not found
     """
     filename = vfs.get_filename(url)
     names = []
     if "." in filename:
         ext = filename.split(".")[-1]
         names.append(confdir.resolve2("%s.%s" % (mode.keyword, ext)))
     names.append(confdir.resolve2(mode.keyword))
     for configname in names:
         try:
             cls.dprint("Trying to load file %s" % configname)
             fh = vfs.open(configname)
             return fh
         except:
             pass
     return None
Exemplo n.º 2
0
 def getConfigFileHandle(cls, confdir, mode, url):
     """Get a file handle to data in the project's configuration directory.
     
     Files within the configuration directory should be based on the major
     mode name, and optionally for added specificity can append a filename
     extension.
     
     For instance, the template system used for projects uses the
     "$PROJROOT/.peppy- project/templates" directory by default, where
     $PROJROOT is the root directory of the project.  Within that templates
     directory, the file "Python" is the default for python files, but
     "Python.pyx" could be used as a default for pyrex files.
     
     @param confdir: pathname of configuration directory
     @param mode: major mode instance
     @param url: url of file that is being created
     
     @return: file-like object to read the data, or None if not found
     """
     filename = vfs.get_filename(url)
     names = []
     if '.' in filename:
         ext = filename.split('.')[-1]
         names.append(confdir.resolve2("%s.%s" % (mode.keyword, ext)))
     names.append(confdir.resolve2(mode.keyword))
     for configname in names:
         try:
             cls.dprint("Trying to load file %s" % configname)
             fh = vfs.open(configname)
             return fh
         except:
             pass
     return None
Exemplo n.º 3
0
 def calculateFilename(self, url):
     dirname = vfs.get_dirname(url)
     filename = vfs.get_filename(url)
     filename = "%s~" % filename
     return dirname.resolve2(filename)
Exemplo n.º 4
0
 def getFilename(self, original_url):
     if self.classprefs.use_autosave and self.isFilesystemSchemeAllowed(original_url):
         dirname = vfs.get_dirname(original_url)
         filename = vfs.get_filename(original_url)
         filename = "%%23%s%%23" % filename
         return dirname.resolve2(filename)