'Touch a file (aka create empty), if it doesn\'t exist'

def create(self, obj, **kwargs):

    if (not self.exists(obj, **kwargs)):
        extra_dir = kwargs.get('extra_dir', None)
        extra_dir_at_root = kwargs.get('extra_dir_at_root', False)
        dir_only = kwargs.get('dir_only', False)
        alt_name = kwargs.get('alt_name', None)
        rel_path = os.path.join(*directory_hash_id(obj.id))
        if (extra_dir is not None):
            if extra_dir_at_root:
                rel_path = os.path.join(extra_dir, rel_path)
            else:
                rel_path = os.path.join(rel_path, extra_dir)
        cache_dir = os.path.join(self.staging_path, rel_path)
        if (not os.path.exists(cache_dir)):
            os.makedirs(cache_dir)
        if dir_only:
            self.pithos.upload_from_string(rel_path, '', content_type='application/directory')
        else:
            rel_path = os.path.join(rel_path, (alt_name if alt_name else 'dataset_{0}.dat'.format(obj.id)))
            new_file = os.path.join(self.staging_path, rel_path)
            open(new_file, 'w').close()
            self.pithos.upload_from_string(rel_path, '')
