MCPcopy Create free account
hub / github.com/smacke/ffsubsync / validate_file_permissions

Function validate_file_permissions

ffsubsync/ffsubsync.py:563–600  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

561
562
563def validate_file_permissions(args: argparse.Namespace) -> None:
564 error_string_template = (
565 "unable to {action} {file}; "
566 "try ensuring file exists and has correct permissions"
567 )
568 if (
569 args.reference is not None
570 and not is_remote_url(args.reference) # ffmpeg streams URLs directly; no local file to check
571 and not os.access(args.reference, os.R_OK)
572 ):
573 raise ValueError(
574 error_string_template.format(action="read reference", file=args.reference)
575 )
576 if args.srtin:
577 for srtin in args.srtin:
578 if srtin is not None and not os.access(srtin, os.R_OK):
579 raise ValueError(
580 error_string_template.format(
581 action="read input subtitles", file=srtin
582 )
583 )
584 if (
585 args.srtout is not None
586 and os.path.exists(args.srtout)
587 and not os.access(args.srtout, os.W_OK)
588 ):
589 raise ValueError(
590 error_string_template.format(
591 action="write output subtitles", file=args.srtout
592 )
593 )
594 if args.make_test_case or args.serialize_speech:
595 npy_savename = os.path.splitext(args.reference)[0] + ".npz"
596 if os.path.exists(npy_savename) and not os.access(npy_savename, os.W_OK):
597 raise ValueError(
598 "unable to write test case file archive %s (try checking permissions)"
599 % npy_savename
600 )
601
602
603def _setup_logging(

Calls 1

is_remote_urlFunction · 0.90