def test_41(): fmfser = fmf.FMF_Serializer('Test Case 4.1, all options.', 'Andreas Riegg', 'Planet Earth', ('reference item 1', 'Reference value 1'), ('reference item 2', 'Reference value 2'), *KEYVALUEREFERENCEITEMS, referenceitem5='Reference value 5', referenceitem6='Reference value 6', **DICTREFERENCEITEMS) print(fmfser.header()) print(fmfser.arbitrarySection("section", *ARBITRARYKEYVALUEITEMS)) print(fmfser.tableSection(*KEYVALUETABLEITEMS)) # Table T1 print(fmfser.dataSection("T1", *DATAITEMS_T1)) print( fmfser.comment( "{0[0][1]:<9s}{0[1][1]:<10s}{0[2][1]:<10s}".format(DATAITEMS_T1))) for i in range(10): print("{0:<10d}{1:<10d}{2:<10d}".format(i, i**2, i**3)) # Table T2 print(fmfser.dataSection("T2", *DATAITEMS_T2)) print(fmfser.comment("{0[0][1]:<9s}{0[1][1]:<10s}".format(DATAITEMS_T2))) for i in range(10): print("{0:<15d}{1:<15d}".format(i, i**i))
def test_10(): fmfser = fmf.FMF_Serializer( 'Test Case 1.1, default fmf with minimum info and without tables.', 'Andreas Riegg', 'Planet Earth') print(fmfser.header()) print(fmfser.dataSection(None, *DATAITEMS)) print( fmfser.comment( "{0[0][1]:<9s}{0[1][1]:<10s}{0[2][1]:<10s}".format(DATAITEMS))) for i in range(10): print("{0:<10d}{1:<10d}{2:<10d}".format(i, i**2, i**3))
def test_15(): fmfser = fmf.FMF_Serializer( 'Test Case 1.5, more info and without tables, dictionary arguments.', 'Andreas Riegg', 'Planet Earth', **DICTREFERENCEITEMS) print(fmfser.header()) print(fmfser.dataSection(None, *DATAITEMS)) print( fmfser.comment( "{0[0][1]:<9s}{0[1][1]:<10s}{0[2][1]:<10s}".format(DATAITEMS))) for i in range(10): print("{0:<10d}{1:<10d}{2:<10d}".format(i, i**2, i**4))
def test_22(): fmfser = fmf.FMF_Serializer( 'Test Case 2.2, additional arbitrary section and without tables, dictionary arguments.', 'Andreas Riegg', 'Planet Earth') print(fmfser.header()) print(fmfser.arbitrarySection("section", **ARBITRARYDICTITEMS)) print(fmfser.dataSection(*DATAITEMS)) print( fmfser.comment( "{0[0][1]:<9s}{0[1][1]:<10s}{0[2][1]:<10s}".format(DATAITEMS))) for i in range(10): print("{0:<10d}{1:<10d}{2:<10d}".format(i, i / 2, i / 3))
def test_12(): fmfser = fmf.FMF_Serializer( 'Test Case 1.2, more info and without tables, positional arguments.', 'Andreas Riegg', 'Planet Earth', ('reference item 1', 'Reference value 1'), ('reference item 2', 'Reference value 2')) print(fmfser.header()) print(fmfser.dataSection(None, *DATAITEMS)) print( fmfser.comment( "{0[0][1]:<9s}{0[1][1]:<10s}{0[2][1]:<10s}".format(DATAITEMS))) for i in range(10): print("{0:<10d}{1:<10d}{2:<10d}".format(i, i**2, i**4))
def test_14(): fmfser = fmf.FMF_Serializer( 'Test Case 1.4, more info and without tables, keyword arguments.', 'Andreas Riegg', 'Planet Earth', referenceitem5='Reference value 5', referenceitem6='Reference value 6') print(fmfser.header()) print(fmfser.dataSection(None, *DATAITEMS)) print( fmfser.comment( "{0[0][1]:<9s}{0[1][1]:<10s}{0[2][1]:<10s}".format(DATAITEMS))) for i in range(10): print("{0:<10d}{1:<10d}{2:<10d}".format(i, i**2, i**4))
def test_16(): fmfser = fmf.FMF_Serializer('Test Case 1.6, more info, mixed arguments.', 'Andreas Riegg', 'Planet Earth', ('reference item 1', 'Reference value 1'), ('reference item 2', 'Reference value 2'), *KEYVALUEREFERENCEITEMS, referenceitem5='Reference value 5', referenceitem6='Reference value 6', **DICTREFERENCEITEMS) print(fmfser.header()) print(fmfser.dataSection(None, *DATAITEMS)) print( fmfser.comment( "{0[0][1]:<9s}{0[1][1]:<10s}{0[2][1]:<10s}".format(DATAITEMS))) for i in range(10): print("{0:<10d}{1:<10d}{2:<10d}".format(i, i**2, i**4))
def test_32(): fmfser = fmf.FMF_Serializer( 'Test Case 3.2, minimum info with tables, dictionary arguments.', 'Andreas Riegg', 'Planet Earth') print(fmfser.header()) print(fmfser.tableSection(**DICTTABLEITEMS)) # Table T1 print(fmfser.dataSection("T1", *DATAITEMS_T1)) print( fmfser.comment( "{0[0][1]:<9s}{0[1][1]:<10s}{0[2][1]:<10s}".format(DATAITEMS_T1))) for i in range(10): print("{0:<10d}{1:<10d}{2:<10d}".format(i, i**2, i**3)) # Table T2 print(fmfser.dataSection("T2", *DATAITEMS_T2)) print(fmfser.comment("{0[0][1]:<9s}{0[1][1]:<10s}".format(DATAITEMS_T2))) for i in range(10): print("{0:<15d}{1:<15d}".format(i, i**i))
def __init__(self, outfile, title, creator, place, *additionalKeyValueItems, **additionalDictItems): if 'fmf' in additionalDictItems: if additionalDictItems['fmf'] == '1.0': constructor = fmf.FMF_10_Serializer elif additionalDictItems['fmf'] == '1.1': constructor = fmf.FMF_11_Serializer else: constructor = fmf.FMF_Serializer del additionalDictItems['fmf'] self._serializer = constructor(title, creator, place, *additionalKeyValueItems, **additionalDictItems) else: self._serializer = fmf.FMF_Serializer(title, creator, place, *additionalKeyValueItems, **additionalDictItems) self._file = outfile print(self._serializer.header(), file=self._file)