comparison frontends/src/jp/cmd_blog.py @ 1906:58f25b274536

jp (blog/edit): removed meta_file_path non existence check, as it is now re-used if it exists
author Goffi <goffi@goffi.org>
date Thu, 10 Mar 2016 19:13:42 +0100
parents e0bfdd379e8d
children c38bcc0343b6
comparison
equal deleted inserted replaced
1905:e0bfdd379e8d 1906:58f25b274536
191 if self.args.title is not None: 191 if self.args.title is not None:
192 mb_data['title'] = self.args.title 192 mb_data['title'] = self.args.title
193 193
194 # then we create the file and write metadata there, as JSON dict 194 # then we create the file and write metadata there, as JSON dict
195 # XXX: if we port jp one day on Windows, O_BINARY may need to be added here 195 # XXX: if we port jp one day on Windows, O_BINARY may need to be added here
196 if os.path.exists(meta_file_path):
197 self.disp(u"metadata file {} already exists, this should not happen! Cancelling...", error=True)
198 with os.fdopen(os.open(meta_file_path, os.O_RDWR | os.O_CREAT ,0o600), 'w+b') as f: 196 with os.fdopen(os.open(meta_file_path, os.O_RDWR | os.O_CREAT ,0o600), 'w+b') as f:
199 # we need to use an intermediate unicode buffer to write to the file unicode without escaping characters 197 # we need to use an intermediate unicode buffer to write to the file unicode without escaping characters
200 unicode_dump = json.dumps(mb_data, ensure_ascii=False, indent=4, separators=(',', ': '), sort_keys=True) 198 unicode_dump = json.dumps(mb_data, ensure_ascii=False, indent=4, separators=(',', ': '), sort_keys=True)
201 f.write(unicode_dump.encode('utf-8')) 199 f.write(unicode_dump.encode('utf-8'))
202 200