1
# This file is part of Checkbox.
3
# Copyright 2015 Canonical Ltd.
5
# Maciej Kisielewski <maciej.kisielewski@canonical.com>
7
# Checkbox is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License version 3,
9
# as published by the Free Software Foundation.
11
# Checkbox is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
23
def obj_to_file(obj, consumer_name, filename):
25
Stringify object, write it to file and return path to the file.
28
Object to be stringified
30
Name of the app that will consume the generated file
32
Name of the file to write to (just the basename)
34
Path to the written file
37
dir_path = os.path.join(os.environ['XDG_RUNTIME_DIR'], consumer_name)
38
if not os.path.exists(dir_path):
40
out_path = os.path.join(dir_path, filename)
41
with open(out_path, "wt") as f: