import anuga
from anuga import indent
#from anuga.validation_utilities.parameters import alg
#from anuga.validation_utilities.parameters import cfl


args = anuga.get_args()
alg = args.alg
np = args.np
verbose = args.verbose

#---------------------------------
# Get the current svn revision
#---------------------------------
timestamp = time.asctime()
major_revision = anuga.get_version()
try:
    # This fails if using git for version control
    minor_revision = anuga.get_revision_number()
except:
    try:
        # This works when using git on unix
        minor_revision = os.popen("git show-ref --head -s | head -n1").read().strip()
    except:
        # This is a fallback position
        minor_revision = 'unknown'


#----------------------------------
# Now it is ok to create the latex 
# macro file with run parameters
import anuga
from anuga import indent
#from anuga.validation_utilities.parameters import alg
#from anuga.validation_utilities.parameters import cfl


args = anuga.get_args()
alg = args.alg
np = args.np
verbose = args.verbose

#---------------------------------
# Get the current svn revision
#---------------------------------
timestamp = time.asctime()
major_revision = anuga.get_version()
try:
    # This fails if using git for version control
    minor_revision = anuga.get_revision_number()
except:
    try:
        # This works when using git on unix
        minor_revision = os.popen("git show-ref --head -s | head -n1").read().strip()
    except:
        # This is a fallback position
        minor_revision = 'unknown'


#----------------------------------
# Now it is ok to create the latex 
# macro file with run parameters

do_html = False       
if len(argv) > 1:
    if argv[1] == '--no_html':
        do_html = False
    else:
        msg = 'Unknown option: %s' %argv[1]
        raise Exception(msg)

# Update version info
fid = open('version.tex')
lines = []
for line in fid.readlines():
    if line.startswith('\\release'):
        line = '\\release{%s}\n' %(get_version())
            
    lines.append(line)
fid.close()

fid = open('version.tex', 'w')
fid.writelines(lines)
fid.close()

print 'Updated version info:'
for line in lines:    
    print line.strip()

for texfile in texfiles:
    print 'Processing %s' %texfile
    # Compile with LaTeX, makeindex etc