Esempio n. 1
0
def touch_file(filename):
    """
    Like mkdir -p && touch
    """
    sysutils.mkdirp_writable(os.path.dirname(filename))
    if not os.path.exists(filename):
        open(filename, 'a').close()
Esempio n. 2
0
def touch_file(filename):
    """
    Like mkdir -p && touch
    """
    sysutils.mkdirp_writable(os.path.dirname(filename))
    if not os.path.exists(filename):
        open(filename, 'a').close()
Esempio n. 3
0
 def save(self, newdata=None):
     " Write the contents of the data cache to the file. "
     if newdata is not None:
         assert isinstance(newdata, dict)
         self.data = newdata
     fpath = os.path.split(self._filename)[0]
     if len(fpath):
         sysutils.mkdirp_writable(fpath)
     open(self._filename, 'w').write(yaml.dump(self.data, default_flow_style=False))
Esempio n. 4
0
 def save(self, newdata=None):
     " Write the contents of the data cache to the file. "
     if newdata is not None:
         assert isinstance(newdata, dict)
         self.data = newdata
     fpath = os.path.split(self._filename)[0]
     if len(fpath):
         sysutils.mkdirp_writable(fpath)
     with open(self._filename, 'w') as fn:
         self.yaml.dump(self.data, fn)
Esempio n. 5
0
 def save(self, newdata=None):
     " Write the contents of the data cache to the file. "
     if newdata is not None:
         assert isinstance(newdata, dict)
         self.data = newdata
     fpath = os.path.split(self._filename)[0]
     if len(fpath):
         sysutils.mkdirp_writable(fpath)
     open(self._filename,
          'w').write(yaml.dump(self.data, default_flow_style=False))