def save(slug, item=None):
  catalog_path = util.checkBaseline()
  xml_tree = ET.parse(catalog_path)
  root = xml_tree.getroot()
  new_elem = None
  content = None
  oldFilepath = None
  if slug != 'post' and slug != 'page':
    if item == None:
      raise Exception('Argument cannot be None')
    if slug != item['name']:
      if findElement(xml_tree, item['name']):
        return False  # Name collision
    # Update old element (delete and recreate)
    element = findElement(xml_tree, slug)
    if element:
      welement = util.ETWrap(element)
      os.remove(welement.filepath)
      root.remove(element)
    new_elem = ET.Element(item['type'])
    updateElem(new_elem, item)
    content = item['content']
  else: # Create new element
    new_elem = newElem(slug)
  root.append(new_elem)
  xml_tree.write(catalog_path, 'UTF-8')
  writeContentFile(toContentElement(new_elem, content))
  return True
Write an item to the filesystem (both catalog and content file).
dataset/ETHPy150Open DeanCutlet/filestack/views.py/save