示例#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()
示例#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()
示例#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))
示例#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)
示例#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))