Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if args.output_format is None:
outpath = path
output_format = subs.format
else:
ext = get_file_extension(args.output_format)
outpath = change_ext(path, ext)
output_format = args.output_format
if args.output_dir is not None:
_, filename = op.split(outpath)
outpath = op.join(args.output_dir, filename)
with open(outpath, "w", encoding=args.output_enc) as outfile:
subs.to_file(outfile, output_format, args.fps)
else:
if PY3:
infile = io.TextIOWrapper(sys.stdin.buffer, args.input_enc)
outfile = io.TextIOWrapper(sys.stdout.buffer, args.output_enc)
else:
infile = io.TextIOWrapper(sys.stdin, args.input_enc)
outfile = io.TextIOWrapper(sys.stdout, args.output_enc)
subs = SSAFile.from_file(infile, args.input_format, args.fps)
self.process(subs, args)
output_format = args.output_format or subs.format
subs.to_file(outfile, output_format, args.fps)
return (0 if errors == 0 else 1)
def __repr__(self):
s = "".format(
self=self, start=ms_to_str(self.start), end=ms_to_str(self.end))
if not PY3: s = s.encode("utf-8")
return s
def __repr__(self):
s = "
def to_file(cls, subs, fp, format_, **kwargs):
data = {
"info": dict(**subs.info),
"styles": {name: sty.as_dict() for name, sty in subs.styles.items()},
"events": [ev.as_dict() for ev in subs.events]
}
if PY3:
json.dump(data, fp)
else:
text = json.dumps(data, fp)
fp.write(unicode(text))
def __repr__(self):
if self.events:
max_time = max(ev.end for ev in self)
s = "" % \
(len(self), len(self.styles), ms_to_str(max_time))
else:
s = "" % len(self.styles)
if not PY3: s = s.encode("utf-8")
return s