KSP_PartParser.py: Added commandline options to improve functionality
KSP_PartParser.py: Added commandline options to improve functionality
in out-of-tree usage.

--- a/KSP_PartParser.py
+++ b/KSP_PartParser.py
@@ -15,6 +15,8 @@
 	

 	parser = argparse.ArgumentParser(description='Parse a KSP part file.')

 	parser.add_argument('files', metavar='FILE', type=str, nargs='+', help='The file or files to be parsed.')

+	parser.add_argument('-k', '--ksp-dir', metavar='DIR', type=str, nargs=1, help='Path to the KSP main directory.')

+	parser.add_argument('-r', '--resource-file', metavar='FILE', type=str, nargs=1, help='The ResourcesGeneric.cfg file to be used.')

 	

 	args = parser.parse_args()

 	

@@ -31,11 +33,19 @@
 		files.remove(idx)

 	files += globfiles

 	

-	partdir, _ = os.path.split(files[0])

-	KSPDir = os.sep.join((partdir, '..', '..'))

+	if args.ksp_dir is not None:

+		KSPDir = args.ksp_dir[0]

+	else:

+		partdir, _ = os.path.split(files[0])

+		KSPDir = os.sep.join((partdir, '..', '..'))

+	

+	if args.resource_file is not None:

+		resourceFile = args.resource_file[0]

+	else:

+		resourceFile = os.sep.join((KSPDir, 'Resources', 'ResourcesGeneric.cfg'))

 	

 	global resources

-	resources = Resource.createFromFile(os.sep.join((KSPDir, 'Resources', 'ResourcesGeneric.cfg')))

+	resources = Resource.createFromFile(resourceFile)

 	

 	csv_columns = OrderedDict({o.__name__: [o.HumanName] for o in Component.__subclasses__() if o is not MultiValueComponent})

 	parts = []