forked from UWPCE-PythonCert/ProgrammingInPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (30 loc) · 873 Bytes
/
Copy pathmain.py
File metadata and controls
39 lines (30 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
"""
here is a simple main() module -- to demonstrate setuptools entrypoints
"""
import sys, os
import capital_mod
help = """
capitalize script
capitalize file_to_process [output_file_name]
capitalizes (title case) each line in a passed in file
"""
def main():
"""
startup function for running a capitalize as a script
"""
try:
infilename = sys.argv[1]
except IndexError:
print("you need to pass in a file name to process")
print(help)
sys.exit()
try:
outfilename = sys.argv[2]
except IndexError:
root, ext = os.path.splitext(infilename)
outfilename = root + "_cap" + ext
# do the real work:
print("Capitalizing: %s and storing it in %s"%(infilename, outfilename))
capital_mod.capitalize(infilename, outfilename)
print("I'm done")