#! python
# Usage python getver.py <filename> <majortag> <minortag>
import sys
# Define error result
majerr="x"
minerr="x"
# Check args
if len(sys.argv)<4:
	# Bad arg count
	print(majerr + "." + minerr)
	sys.exit(1)
# Get first arg	
filename=sys.argv[1]
majortag=sys.argv[2]
minortag=sys.argv[3]
# Opening file
try:
	fs = open(filename, 'rt')
except IOError:
	# Could not open file !
	print(majerr + "." + minerr)
	sys.exit(1)
# Search pattern line by line
major=""
minor=""
for line in fs:
	if not major:
		major=line.partition(majortag)[2].strip()
	elif not minor:
		minor=line.partition(minortag)[2].strip()
	else:
		break
fs.close()
# Check error and/or remove line comments
if not major:
	major=majerr
else:
	major=major.partition("//")[0].strip();
if not minor:
	minor=minerr
else:
	minor=minor.partition("//")[0].strip();
# Output
print(major + "." + minor)
# Exit
sys.exit(0)