Exemplo n.º 1
0
 def __call__(self):
     if self.__parent__:
         if hasattr(self, '_from_root'):
             if not self._from_root:
                     raise RuntimeError(u"Directory called but not on "
                                         "virtual root.")
     if IRoot.providedBy(self):
         setattr(self, '_from_root', True)
     if IDirectory.providedBy(self):
         self._mkdir()
     for name, target in self.items():
         if IDirectory.providedBy(target):
             target()
         elif IFile.providedBy(target):
             if self.backup and os.path.exists(target.abspath):
                 shutil.copyfile(target.abspath, target.abspath + '.bak')
             target()
     if IRoot.providedBy(self):
         setattr(self, '_from_root', False)
Exemplo n.º 2
0
 def __setitem__(self, key, val):
     if not IXMLNode.providedBy(val) or not IRoot.providedBy(val):
         raise ValueError(u"Could only contain complete XML trees.")
     noLongerProvides(val, IRoot)
     OrderedNode.__setitem__(self, key, val)
Exemplo n.º 3
0
 def __call__(self):
     if not IRoot.providedBy(self):
         raise RuntimeError(u"Called on nonroot")
     with open(self.outpath, "wb") as file:
         file.write("<?xml version=\"1.0\" encoding=\"%s\"?>\n" % 'UTF-8')
         file.write(etree.tostring(self.element, pretty_print=True))