Skip to content

Commit d3cbd02

Browse files
authored
Merge pull request #1 from Lethja/output
Added output file pattern matching
2 parents ff1fc31 + e675005 commit d3cbd02

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

animDump.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -696,22 +696,36 @@ def __call__(self, parser, namespace, values, option_string=None):
696696
def output_filename(input_filename):
697697
if args.outputfile_pattern is None:
698698
return input_filename
699+
699700
input_path = Path(input_filename)
700-
return f"{args.outputfile_pattern}{{suffix}}".format(input_path.stem, suffix=input_path.suffix)
701+
output_path = Path(args.outputfile_pattern
702+
.replace("%n", input_path.stem)
703+
.replace("%p", str(input_path.parent.resolve()))
704+
.replace("%%", "%")).with_suffix(input_path.suffix)
705+
706+
return str(output_path)
701707

702708

703709
if __name__ == '__main__':
704710

705711
parser = argparse.ArgumentParser(
706712
description='Manipulate Secondlife .anim files',
707-
fromfile_prefix_chars='@')
713+
fromfile_prefix_chars='@', formatter_class=argparse.RawDescriptionHelpFormatter,
714+
epilog="""
715+
output file pattern flags:
716+
%n: input file name
717+
%p: input file directory
718+
%%: literal '%'
719+
file extensions will be appended automatically
720+
""")
721+
708722
parser.add_argument('files', nargs='+', help='anim files to dump or process')
709723
parser.add_argument('--verbose', '-v', action='count', default=0)
710724
parser.add_argument('--no-sort', '-U', action='store_false', dest='sort',
711725
help="when printing joints with -v, show in file order rather than abc order")
712726
parser.add_argument('--markdown', '--md', action='store_true', help="output in markdown table")
713-
parser.add_argument('--outputfile-pattern', '-o')
714-
727+
parser.add_argument('--outputfile-pattern', '-o',
728+
help='Output anim file path/name, see \'output file pattern flags\' below for details')
715729
parser.add_argument('--time-scale', '--tscale', '--speed', '-s', action=AppendObjectAction,
716730
dest='actions', func=SpeedAnimation, nargs=1, type=float,
717731
help = "Adjust duration by the given factor eg 2.0 for half-speed/double duration, or 0.5 for double speed/half duration")

0 commit comments

Comments
 (0)