コード例 #1
0
ファイル: pyalmanac.py プロジェクト: FrankKooij/Pyalmanac
import suntables 
import os


##Main###
year =  raw_input("Please enter the year you want to create the nautical almanac for:\n ")
s =  raw_input("""Do you want to create the full tables or just tables for the sun?:\n
1	Full nautical almanac
2	Just tables for the sun
""")
if s == "2":
	print "Creating the sun tables only. \n The year %s" %year
	print "Please wait this can take a while."
	filename = "sunalmanac%s.tex" %year
	outfile = open(filename, 'w')
	outfile.write(suntables.almanac(year))
	outfile.close()
	command = 'pdflatex %s' %filename
	os.system(command)
	print "finished"
	os.remove("sunalmanac%s.log" %year)
	os.remove("sunalmanac%s.aux" %year)
	os.remove(filename)
elif s == "1":
	print "Creating the nautical almanac for the year %s" %year
	print "Please wait this can take a while."
	filename = "almanac%s.tex" %year
	outfile = open(filename, 'w')
	outfile.write(tables.almanac(year))
	outfile.close()
	command = 'pdflatex %s' %filename
コード例 #2
0
            os.remove(filename)
            if os.path.isfile("almanac{}{}.log".format(ff, year + DecFmt)):
                os.remove("almanac{}{}.log".format(ff, year + DecFmt))
            if os.path.isfile("almanac{}{}.aux".format(ff, year + DecFmt)):
                os.remove("almanac{}{}.aux".format(ff, year + DecFmt))
##        config.closeLOG()

    elif s == '2':
        for yearint in range(int(yearfr), int(yearto) + 1):
            year = "{:4d}".format(yearint)  # year = "%4d" %yearint
            msg = "\nCreating the sun tables only for the year {}".format(year)
            print(msg)
            first_day = datetime.date(yearint, 1, 1)
            filename = "sunalmanac{}{}.tex".format(ff, year + DecFmt)
            outfile = open(filename, 'w')
            outfile.write(suntables.almanac(first_day, 25))
            outfile.close()
            command = 'pdflatex {}'.format(filename)
            os.system(command)
            print("finished creating sun tables for {}".format(year))
            os.remove(filename)
            if os.path.isfile("sunalmanac{}{}.log".format(ff, year + DecFmt)):
                os.remove("sunalmanac{}{}.log".format(ff, year + DecFmt))
            if os.path.isfile("sunalmanac{}{}.aux".format(ff, year + DecFmt)):
                os.remove("sunalmanac{}{}.aux".format(ff, year + DecFmt))

    elif s == '3':
        ##        config.init()		# initialize log file
        start = time.time()
        msg = "\nCreating nautical almanac tables - from {}".format(sdmy)
        print(msg)
コード例 #3
0
    print ""

    year = raw_input(
        "Please enter the year you want to create the nautical almanac for:\n "
    )
    s = raw_input(
        """Do you want to create the full tables or just tables for the sun?:\n
	1	Full nautical almanac
	2	Just tables for the sun
	""")
    if s == "2":
        print "Creating the sun tables only. \n The year %s" % year
        print "Please wait this can take a while."
        filename = "sunalmanac%s.tex" % year
        outfile = open(filename, 'w')
        outfile.write(suntables.almanac(year))
        outfile.close()
        command = 'pdflatex %s' % filename
        os.system(command)
        print "finished"
        os.remove("sunalmanac%s.log" % year)
        os.remove("sunalmanac%s.aux" % year)
        os.remove(filename)
    elif s == "1":
        print "Creating the nautical almanac for the year %s" % year
        print "Please wait this can take a while."
        filename = "almanac%s.tex" % year
        outfile = open(filename, 'w')
        outfile.write(tables.almanac(year))
        outfile.close()
        command = 'pdflatex %s' % filename