99
1010
1111def parse_args ():
12- """ Parse command line arguments. """
12+ """Parse command line arguments."""
1313 parser = argparse .ArgumentParser (description = "Write properties to a file." )
14- parser .add_argument ("directive" , type = str , help = "Directive: SET, APPEND, or DEFINE" ,
15- choices = ["SET" , "DEFINE" , "APPEND" ])
16- parser .add_argument ("values" , type = str , nargs = "+" , help = "Value(s) to write to property call" )
17- parser .add_argument ("--file" , type = Path , help = "File to write the property to" , default = None )
18- parser .add_argument ("--append" , action = "store_true" , help = "Append to the file instead of overwriting" ,
19- default = False )
14+ parser .add_argument (
15+ "directive" ,
16+ type = str ,
17+ help = "Directive: SET, APPEND, or DEFINE" ,
18+ choices = ["SET" , "DEFINE" , "APPEND" ],
19+ )
20+ parser .add_argument (
21+ "values" , type = str , nargs = "+" , help = "Value(s) to write to property call"
22+ )
23+ parser .add_argument (
24+ "--file" , type = Path , help = "File to write the property to" , default = None
25+ )
26+ parser .add_argument (
27+ "--append" ,
28+ action = "store_true" ,
29+ help = "Append to the file instead of overwriting" ,
30+ default = False ,
31+ )
2032
2133 parsed = parser .parse_args ()
22- parsed .file = sys .stdout if parsed .file is None else open (parsed .file , "a" if parsed .append else "w" )
34+ parsed .file = (
35+ sys .stdout
36+ if parsed .file is None
37+ else open (parsed .file , "a" if parsed .append else "w" )
38+ )
2339 return parsed
2440
41+
2542def main ():
26- """ Main function to handle command line arguments and write properties. """
43+ """Main function to handle command line arguments and write properties."""
2744 args = parse_args ()
2845 format_string = SET if args .directive == "SET" else DEFINE
2946 print (format_string .format (" " .join (args .values )), file = args .file )
3047
48+
3149if __name__ == "__main__" :
32- main ()
50+ main ()
0 commit comments