Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ldmlnormalize to use iterate_files #2

Open
DavidLRowe opened this issue Apr 23, 2021 · 0 comments
Open

update ldmlnormalize to use iterate_files #2

DavidLRowe opened this issue Apr 23, 2021 · 0 comments

Comments

@DavidLRowe
Copy link
Collaborator

DavidLRowe commented Apr 23, 2021

Based on a slack conversation with MH:

If the input is a directory (rather than a single file as is currently the case) ldmlnormalize would iterate the directory (using iterate_files).

add something like
if os.path.isdir(args.input): infiles = iterate_files(args.input) else: infiles = [args.infile]
for f in infiles:
ldml = Ldml(f)
ldml.normalise()
if args.outfile: ldml.saveas(args.outfile) else ldml.saveas(f)

hmm that last line needs more careful thought
likewise args.input -> args.infile
how about:
if args.outfile is None: def outfile(f) return f elif os.path.isdir(args.outfile): def outfile(f) return os.path.join(args.outfile, os.path.basename(f)) else: def outfile(f) return args.outfile
then in the loop
ldml.saveas(outfile(f))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant