Added command interface

This commit is contained in:
Jamie Hardt
2019-10-07 19:33:39 -07:00
parent 786ea39024
commit fd64c2a188
3 changed files with 29 additions and 4 deletions

23
ptulsconv/__main__.py Normal file
View File

@@ -0,0 +1,23 @@
from ptulsconv.commands import convert
from optparse import OptionParser
import sys
parser = OptionParser()
parser.add_option('-t','--timecode', dest='convert_times', default=False, action='store_true',
help="Include timecode converted to seconds in output.")
parser.add_option('-z','--offset', dest='apply_start_offset', default=False, action='store_true',
help='Apply session start offset to converted start and finish timecodes on '
'clips and markers. Implies -t.')
parser.usage = "ptulsconv [-tz] TEXT_EXPORT.txt"
if __name__ == "__main__":
(options, args) = parser.parse_args(sys.argv)
if len(args) < 2:
print("Error: No input file",file=sys.stderr)
parser.print_help(sys.stderr)
exit(-1)
convert(input_file=args[1],
convert_times=(options.convert_times or options.apply_start_offset),
apply_session_start=options.apply_start_offset,
output=sys.stdout)

View File

@@ -16,6 +16,3 @@ def convert(input_file, convert_times, apply_session_start, output=sys.stdout):
json.dump(parsed, output)

View File

@@ -24,5 +24,10 @@ setup(name='ptulsconv',
"Programming Language :: Python :: 3.7"],
packages=['ptulsconv'],
keywords='text-processing parsers film tv editing editorial',
install_requires=['parsimonious', 'timecode']
install_requires=['parsimonious', 'timecode'],
entry_points={
'console_scripts': [
'ptulsconv = ptulsconv.__main__:main'
]
}
)