comparison sat_frontends/jp/cmd_blog.py @ 3177:f4914ce9d47d

jp (blog/edit): added `--no-publish` argument.
author Goffi <goffi@goffi.org>
date Tue, 18 Feb 2020 18:17:18 +0100
parents 559a625a236b
children 46f0b388eeea
comparison
equal deleted inserted replaced
3176:4b5c77673015 3177:f4914ce9d47d
464 "-P", 464 "-P",
465 "--preview", 465 "--preview",
466 action="store_true", 466 action="store_true",
467 help=_("launch a blog preview in parallel"), 467 help=_("launch a blog preview in parallel"),
468 ) 468 )
469 self.parser.add_argument(
470 "--no-publish",
471 help=_('add "publish: False" to metadata'),
472 )
469 473
470 def buildMetadataFile(self, content_file_path, mb_data=None): 474 def buildMetadataFile(self, content_file_path, mb_data=None):
471 """Build a metadata file using json 475 """Build a metadata file using json
472 476
473 The file is named after content_file_path, with extension replaced by 477 The file is named after content_file_path, with extension replaced by
503 del mb_data[key] 507 del mb_data[key]
504 except KeyError: 508 except KeyError:
505 pass 509 pass
506 # and override metadata with command-line arguments 510 # and override metadata with command-line arguments
507 self.setMbDataFromArgs(mb_data) 511 self.setMbDataFromArgs(mb_data)
512
513 if self.args.no_publish is not None:
514 mb_data["publish"] = False
508 515
509 # then we create the file and write metadata there, as JSON dict 516 # then we create the file and write metadata there, as JSON dict
510 # XXX: if we port jp one day on Windows, O_BINARY may need to be added here 517 # XXX: if we port jp one day on Windows, O_BINARY may need to be added here
511 with os.fdopen( 518 with os.fdopen(
512 os.open(meta_file_path, os.O_RDWR | os.O_CREAT | os.O_TRUNC, 0o600), "w+b" 519 os.open(meta_file_path, os.O_RDWR | os.O_CREAT | os.O_TRUNC, 0o600), "w+b"