Exemplo n.º 1
0
  def snippets(self):
    unpackPackage(self.lang, self.config)

    snippets = getFileNamesInDir("temp/Snippets")
    for file in snippets:
      printGreen(file)

    removeTempDir()
Exemplo n.º 2
0
  def remove(self, name):
      if (not unpackPackage(self.lang, self.config)):
        return

      snippetsNames = getFileNamesInDir("temp/Snippets")
      if (name not in snippetsNames):
        printRed("Snippet \"" + name + "\" for language \"" + self.lang + "\" doesn't exist")
        removeTempDir()
        return

      os.remove("temp/Snippets/" + name + ".sublime-snippet")
      packPackage(self.lang, self.config)

      removeTempDir()
Exemplo n.º 3
0
  def create(self, name):
    if (not unpackPackage(self.lang, self.config)):
      return

    snippetsNames = getFileNamesInDir("temp/Snippets")
    if (name in snippetsNames):
      printRed("Snippet \"" + name + "\" for language \"" + self.lang + "\" already exists")
      removeTempDir()
      return

    snippet = "temp/Snippets/" + name + ".sublime-snippet"
    subprocess.call([self.config[PATH_TO_SUBLIME] + "/sublime_text", "-n", "-w", fs.abspath(snippet)])
    packPackage(self.lang, self.config);

    removeTempDir()
Exemplo n.º 4
0
  def add(self, file):
    if (not unpackPackage(self.lang, self.config)):
      return

    snippetsNames = getFileNamesInDir("temp/Snippets")
    if (fs.splitext(file)[0] in snippetsNames):
      printRed("Snippet \"" + name + "\" for language \"" + self.lang + "\" already exists")
      removeTempDir()
      return

    pathFrom = file
    pathTo = "temp/Snippets/" + fs.splitext(file)[0] + ".sublime-snippet"
    shutil.copyfile(pathFrom, pathTo)

    packPackage(self.lang, self.config)

    removeTempDir()