Esempio n. 1
0
    def test_Champaign(self):

        MapParser.newMapParser()

        isValid = False
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Champaign":
                isValid = True
                break

        self.assertTrue(isValid)
Esempio n. 2
0
    def TestChampaign(self):

        MapParser.newMapParser()

        isValid = False
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Champaign":
                isValid = True
                break

        self.assertTrue(isValid)
Esempio n. 3
0
def add_ranges(ranges, regions):
    # exit if no ranges defined
    if ranges == None: 
        return 0

    for i, opt in enumerate(ranges):
        m = re.search('^((0x)?[0-9a-fA-F]+):((0x)?[0-9a-fA-F]+)$', opt)
        if m:
            region = MapParser.Section(opt, 
                                       int(m.group(1),0), 
                                       int(m.group(3),0))
            regions[region] = {}
        else:
            print "Invalid range format:", opt
            return -1

    return 0
Esempio n. 4
0
def get_next_xml_token(scanner): 
    """ Parses next memory region from xml file

        Scans through the .xml file tracked by input XMLScannerTracker looking
        for hardware memory regions. Returns the first region found.

        Args:
            scanner: XMLScannerTracker with current tracking info

        Returns:
            None if scanner has finished file, otherwise Section containing
            info for next hardware memory regions encountered
    """
    for line in scanner.fh:
        # look for hardware section
        m = re.search('<Hardware>', line)
        if m:
            scanner.in_hw = True
            continue

        # look for hardware section end
        m = re.search('</Hardware>', line)
        if m:
            scanner.in_hw = False
            continue

        # look for bank in hw section
        if scanner.in_hw:
            m = re.search('<Bank name=\"([^\"]+)\" addr=\"([^\"]+)\" ' + \
                          'size=\"([^\"]+)\"/>', 
                          line)
            if m:
                size = m.group(3)
                size = size.replace("K", "* 1024")
                size = size.replace("M", "* 1024 * 1024")
                size = size.replace("G", "* 1024 * 1024 * 1024")
                section = MapParser.Section(m.group(1), 
                                            int(m.group(2),0), 
                                            eval(size))
                return section

    return None
Esempio n. 5
0
def get_next_map_token(scanner):
    """ Parses next section/symbol from map file

        Scans through the .map file tracked by input MapScannerTracker looking
        for Symbols defined in .map file. Returns the first symbol encountered.

        Args:
            scanner: MapScannerTracker with current tracking info

        Returns:
            Symbol object representing next symbol found. None when EOF is 
            reached
    """
    for line in scanner.fh:
        # look for memory map section
        m = re.search('^Memory Map of the image$', line)
        if m:
            scanner.in_mem_map = True
            continue

        # look for symbols (ish)
        if scanner.in_mem_map:
            m = re.search('((0x)?[0-9A-Fa-f]+)\s+((0x)?[0-9A-Fa-f]+)\s+' + \
                          '([A-Za-z]+)\s+([A-Za-z]+)\s+([0-9]+)\s+(\*\s*)?' + \
                          '([A-Za-z0-9\._]+)\s+([A-Za-z0-9_]+\.lib)', 
                          line)
            if m:
                sym = MapParser.Symbol(int(m.group(1),0), 
                                       int(m.group(3),0), 
                                       "", 
                                       m.group(10),
                                       get_segment(m.group(5), m.group(6)),
                                       m.group(9))
                return sym

    # indicate done scanning
    return None
Esempio n. 6
0
class Test(TestCase):

    MapParser.MapParser()

    def TestSeoulPop(self):
        key = 0
        info = None
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Seoul":
                info = cityinfo
                break
        self.assertEqual(info.population, 24200000)

    def TestSeoulDis(self):
        key = 0
        for item in GraphLibrary.route_list:
            if item.startportcode == 'ICN' and item.endportcode == 'TYO':
                key = item.distance
        self.assertEqual(key, 1207)

    def TestSeoulCon(self):

        key = False
        for city in GraphLibrary.Asia:
            if city == "Seoul":
                key = True
        self.assertEqual(key, True)

    def TestLACountry(self):
        key = 0
        info = None
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Los Angeles":
                info = cityinfo
                break
        self.assertEqual(info.country, "US")

    def TestLATimezone(self):
        key = 0
        info = None
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Los Angeles":
                info = cityinfo
                break
        self.assertEqual(info.timezone, -8)

    def TestParisRegion(self):
        key = 0
        info = None
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Paris":
                info = cityinfo
                break
        self.assertEqual(info.region, 3)

    def TestshortestLength(self):
        key = QueryData.shortestflight()
        self.assertEqual(key, 334)

    def TestaveragePop(self):
        key = QueryData.averagecitysize()
        self.assertEqual(key, 11796143)

    def TestremoveCity(self):

        EditRoute.removecity("Seoul")
        isValid = True
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Seoul":
                isValid = False
                break

        self.assertTrue(isValid)


# Test for assignment 2.1

    def TesteditCountry(self):

        info = None
        EditRoute.editcountry("Madrid", "America")
        isValid = True
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Madrid":
                info = cityinfo
                break

        self.assertEqual(info.country, "America")

    def TestremoveRoute(self):

        EditRoute.removeroute("Los Angeles", "San Francisco")
        isValid = True
        code = QueryData.nametocode("Los Angeles")
        code2 = QueryData.nametocode("San Francisco")

        for route in GraphLibrary.route_list:
            if route.startportcode == code and route.endportcode == code2:
                isValid = False
                break

        self.assertTrue(isValid)

    def TestaddCity(self):

        EditRoute.addcity("LOR", "Minas Tirith", "Gondor", "Europe", "-3",
                          "40", "50", "2034923", "5")

        isValid = False
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Minas Tirith":
                isValid = True
                break

        self.assertTrue(isValid)

    def TestaddRoute(self):

        code = QueryData.nametocode("Los Angeles")
        code2 = QueryData.nametocode("Seoul")
        EditRoute.addroute(code, code2, "12435")
        isValid = False

        for route in GraphLibrary.route_list:
            if route.startportcode == code and route.endportcode == code2:
                isValid = True
                break

        self.assertTrue(isValid)

    def TestChampaign(self):

        MapParser.newMapParser()

        isValid = False
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Champaign":
                isValid = True
                break

        self.assertTrue(isValid)
Esempio n. 7
0
def get_next_map_token(scanner):
    """ Parses next section/symbol from map file

        Scans through the .map file tracked by input MapScannerTracker looking
        for Symbols defined in .map file. Returns the first symbol encountered.

        Args:
            scanner: MapScannerTracker with current tracking info

        Returns:
            Symbol object representing next symbol found. None when EOF is 
            reached
    """
    for line in scanner.fh:
        # look for section header ,support for QSEE.map
        m = re.search('^([0-9a-zA-Z_]+)' + \
                      '(\s+(0x[0-9a-fA-F]+)\s+(0x[0-9a-fA-F]+))?\s*$',
        line)
        if m:
            if m.group(2) != None:
                section = MapParser.Section(m.group(1), int(m.group(3), 0),
                                            int(m.group(4), 0))
                scanner.curr_section = section
                #return (section, None)
            else:
                scanner.curr_section_name = m.group(1)
                scanner.split_line_section = True
            continue

        # handle split line header
        if scanner.split_line_section:
            m = re.search('^\s+(0x[0-9a-fA-F]*)\s+(0x[0-9a-fA-F]+)\s*$', line)
            scanner.split_line_section = False
            if m:
                section = MapParser.Section(scanner.curr_section_name,
                                            int(m.group(1), 0),
                                            int(m.group(2), 0))
                scanner.curr_section = section
                #return (section, None)
            continue

        # look for symbol
        m = re.search('^\s?\\(?(\\.?[0-9a-zA-Z_\.]+)(\s+[0-9a-zA-Z_.]+)?(\s+[a-zA-Z_]+\s?\\))?' + \
                      '(\s+(0x[0-9a-fA-F]+)\s+(0x[0-9a-fA-F]+)\s+.*?([a-zA-Z_0-9]+.lib)+\\((.*)\\))?\s*$',
                      line)
        if m and scanner.curr_section != None:
            if re.search('^debug_', m.group(1)):
                continue
            if m.group(4) != None:
                symbol = MapParser.Symbol(int(m.group(5), 0),
                                          int(m.group(6), 0), m.group(8),
                                          m.group(7),
                                          extract_segment(m.group(1)),
                                          m.group(1))
                #return (scanner.curr_section, symbol)
                scanner.split_line_symbol = False
                return symbol
            elif not "0x" in m.group(1):
                scanner.curr_symbol = m.group(1)
                scanner.split_line_symbol = True
                continue

        # handle split line symbol
        if scanner.split_line_symbol:
            m = re.search('^\s+(0x[0-9a-fA-F]+)\s+(0x[0-9a-fA-F]+)\s+.*?' + \
                          '([a-zA-Z_0-9]+.lib)+\\((.*)\\)\s*$',
                          line)
            #scanner.split_line_symbol = False
            if m:
                symbol = MapParser.Symbol(int(m.group(1), 0),
                                          int(m.group(2), 0), m.group(4),
                                          m.group(3),
                                          extract_segment(scanner.curr_symbol),
                                          scanner.curr_symbol)
                #return (scanner.curr_section, symbol)
                return symbol
            continue

        # end section on empty line
        m = re.search('^$', line)
        if m:
            scanner.split_line_section = False
            scanner.split_line_symbol = False
            scanner.curr_section = None
            scanner.curr_section_name = ''
            scanner.curr_symbol = None

        # clear split line flags if no matches
        scanner.split_line_section = False
        scanner.split_line_symbol = False

    # indicate done scanning
    #return (None, None)
    return None
Esempio n. 8
0
def main():
    # data containers
    symbols = []    # list of symbols parsed from map file
    regions = {}    # 2-level map of memory region to data segments to symbols
    segments = {}   # 2-level map of data segments to memery regions to symbols
    lib_sizes = {}  # 2-level map of lib name to segment type to size in image

    # handle command line
    usage = "usage: Mapit.py [options] <.map file>"
    parser = OptionParser(usage)

    parser.add_option("--ld", 
                      action="store", type="string", dest="ld_file",
                      help=".ld file to determine named section types from")

    parser.add_option("-x", "--xml",
                      action="store", type="string", dest="xml_file",
                      help=".xml file with HW memory regions")

    parser.add_option("-c", "--compiler",
                      action="store", type="string", dest="compiler",
                      default="GNU",
                      help="Name of compiler used to generate .map file" + \
                           "[ARM, GNU, CLANG]")

    parser.add_option("-r", "--range", action="append",
                      help="Add a memory range of interest. Format=" + \
                            "<start_address>:<size>")

    parser.add_option("-l", "--lib", action="append",
                      help="Add a lib of interest")
                      
    parser.add_option("-t", "--target",
                      action="store", type="string", dest="target",
                      help="Name of the target, e.g. 8953")

    (options, args) = parser.parse_args()

    # check that .map file has been provided
    if len(args) != 1:
        parser.print_help()
        sys.exit(1)

    # determine compiler that generated files
    compiler = get_compiler(options.compiler)
    if (compiler == None):
        sys.exit(2)

    # add any ranges added to regions
    if (add_ranges(options.range, regions)):
        sys.exit(3)

    # pull information from .map file
    MapParser.parse_map(args[0], symbols, compiler)

    # if ld file provided, extract named section types
    if (options.ld_file):
        MapParser.parse_ld(options.ld_file, None, compiler)

    # if xml file is provided, extract memory regions
    if (options.xml_file):
        MapParser.parse_xml(options.xml_file, regions, compiler)

    # fill region map with symbols from .map file
    build_maps(symbols, regions, segments, options.lib)

    # calculate data segment sizes for each lib
    calc_lib_sizes(symbols, regions, lib_sizes)
 
    # DEBUG PRINT
    #print_totals(lib_sizes)
    if (options.target) :
      print_summary(options.target, lib_sizes)
    print_libs(lib_sizes)
    print_map(regions, print_region_header)
    print_map(segments, print_segment_header)
Esempio n. 9
0
 def __init__(self, mapfile):
     self.name, self.map, self.spawn = MapParser.create_map(mapfile)
Esempio n. 10
0
class Test(TestCase):

    MapParser.MapParser()

    def TestSeoulPop(self):
        key = 0
        info = None
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Seoul":
                info = cityinfo
                break
        self.assertEqual(info.population, 24200000)

    def TestSeoulDis(self):
        key = 0
        for item in GraphLibrary.route_list:
            if item.startportcode == 'ICN' and item.endportcode == 'TYO':
                key = item.distance
        self.assertEqual(key, 1207)

    def TestSeoulCon(self):

        key = False
        for city in GraphLibrary.Asia:
            if city == "Seoul":
                key = True
        self.assertEqual(key, True)

    def TestLACountry(self):
        key = 0
        info = None
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Los Angeles":
                info = cityinfo
                break
        self.assertEqual(info.country, "US")

    def TestLATimezone(self):
        key = 0
        info = None
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Los Angeles":
                info = cityinfo
                break
        self.assertEqual(info.timezone, -8)

    def TestParisRegion(self):
        key = 0
        info = None
        for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems():
            if cityname == "Paris":
                info = cityinfo
                break
        self.assertEqual(info.region, 3)

    def TestshortestLength(self):
        key = QueryData.shortestflight()
        self.assertEqual(key, 334)

    def TestaveragePop(self):
        key = QueryData.averagecitysize()
        self.assertEqual(key, 11796143)
Esempio n. 11
0
__author__ = 'MyPrecious'

import RouteInfo, EditRoute, SaveFile, QueryData, MapParser, GraphLibrary

MapParser.MapParser()

s = "Type the number for corresponding options:\n" \
    "1. Get all the cities from CSAir\n" \
    "2. Get a specific information about one city\n" \
    "3. Get all kinds of stats\n" \
    "4. Get a specific route\n" \
    "5. Edit the current city's information\n" \
    "6. Add/Remove cities and routes\n" \
    "7. Save the changed list to JSON File\n" \
    "8. Calculuate the total flight\n" \
    "9. Update CSAir with new Champaign hub town\n" \
    "10. Calculate the shortest route between to cities.\n" \
    "0. Exit the program"

while True:

    print s

    i = raw_input("Enter the number.")
    i = int(i)
    if i == 1:
        cityList = QueryData.citylist()
        print "Here are the lists!"
        for city in cityList:
            print city
Esempio n. 12
0
    def start(self):
        MapParser.MapParser()
        s = "Type the number for corresponding options:\n" \
            "1. Get all the cities from CSAir\n" \
            "2. Get a specific information about one city\n" \
            "3. Get all kinds of stats\n" \
            "4. Get a specific route\n" \
            "5. Edit the current city's information\n" \
            "6. Add/Remove cities and routes\n" \
            "7. Save the changed list to JSON File\n" \
            "8. Calculuate the total flight\n" \
            "9. Update CSAir with new Champaign hub town\n" \
            "10. Calculate the shortest route between to cities.\n" \
            "0. Exit the program"

        while True:

            print s

            i = raw_input("Enter the number.")
            i = int(i)
            if i == 1:
                cityList = QueryData.citylist()
                print "Here are the lists!"
                for city in cityList:
                    print city

            elif i == 2:
                city_name = raw_input("Enter the city name.")

                valid = QueryData.getcitydata(city_name)

                if valid == False :
                    print "No such city."

            elif i == 3:
                QueryData.getstat()

            elif i == 4:
                city_code = raw_input("Enter the city code.")

                valid = QueryData.getroute(city_code)

                if valid == False :
                    print "No such code."

            elif i == 5:
                EditRoute.editnetwork()

            elif i == 6:
                EditRoute.addnetwork()

            elif i == 7:
                SaveFile.saveFile()

            elif i == 8:
                RouteInfo.routeinfo()

            elif i == 9:
                MapParser.newMapParser()

            elif i == 10:
                self.routeInfo.shortestroute()

            elif i == 0:
                print "See ya!"
                break

            else:
                print "Invalid Number!"
Esempio n. 13
0
    def start(self):
        MapParser.MapParser()
        s = "Type the number for corresponding options:\n" \
            "1. Get all the cities from CSAir\n" \
            "2. Get a specific information about one city\n" \
            "3. Get all kinds of stats\n" \
            "4. Get a specific route\n" \
            "5. Edit the current city's information\n" \
            "6. Add/Remove cities and routes\n" \
            "7. Save the changed list to JSON File\n" \
            "8. Calculuate the total flight\n" \
            "9. Update CSAir with new Champaign hub town\n" \
            "10. Calculate the shortest route between to cities.\n" \
            "0. Exit the program"

        while True:

            print s

            i = raw_input("Enter the number.")
            i = int(i)
            if i == 1:
                cityList = QueryData.citylist()
                print "Here are the lists!"
                for city in cityList:
                    print city

            elif i == 2:
                city_name = raw_input("Enter the city name.")

                valid = QueryData.getcitydata(city_name)

                if valid == False:
                    print "No such city."

            elif i == 3:
                QueryData.getstat()

            elif i == 4:
                city_code = raw_input("Enter the city code.")

                valid = QueryData.getroute(city_code)

                if valid == False:
                    print "No such code."

            elif i == 5:
                EditRoute.editnetwork()

            elif i == 6:
                EditRoute.addnetwork()

            elif i == 7:
                SaveFile.saveFile()

            elif i == 8:
                RouteInfo.routeinfo()

            elif i == 9:
                MapParser.newMapParser()

            elif i == 10:
                self.routeInfo.shortestroute()

            elif i == 0:
                print "See ya!"
                break

            else:
                print "Invalid Number!"
Esempio n. 14
0
        valid = QueryData.getroute(city_code)

        if valid == False :
            print "No such code."

    elif i == 5:
        EditRoute.editnetwork()

    elif i == 6:
        EditRoute.addnetwork()

    elif i == 7:
        SaveFile.saveFile()

    elif i == 8:
        RouteInfo.routeinfo()

    elif i == 9:
        MapParser.newMapParser()

    elif i == 10:
        RouteInfo.shortestroute()

    elif i == 0:
        print "See ya!"
        break

    else:
        print "Invalid Number!"

    def __init__(self, master):
        #Establish the width and height of the First Window
        self.width = 1100
        self.height = 600

        #Initialize the city matrix, get the number of rows of the city and the number of columns of the city
        self.city = MapParser.createMapParser()
        self.rows = len(self.city)
        self.columns = len(self.city[0])

        #This contains the actual instruction
        self.actualInstruction = ""

        #This is used to save the old coordinates of the taxi
        self.oldCoordinates = []
        self.taxiNode = 0

        #This indicates to do the animation
        self.doAnimation = False
        self.updateTime = 1000
        self.sameInstruction = False

        #List with the travel of the taxi
        self.travelList = []

        #This variable is need it for the search instruction
        self.searchIndex = 0
        self.searchList = []
        self.clientsList = []
        self.p = 0
        self.soundFilePath = "ProjectSounds/taxi_call.wav"

        #This indicates if there is an instruction executing at the time
        self.executingInstruction = False

        #This indicates not to perform again the search algorithm
        self.routeAlreadyExecute = False

        #Establish all the possible instructions
        self.travelInstruction = "pasear"
        self.searchInstruction = "buscar"
        self.showInstruction = "mostrar"
        self.animateInstruction = "animar"
        self.routeInstruction = "ruta"
        self.randomClientsInstruction = "clientes"
        self.specificClientInstruction = "cliente"
        self.parkInstruction = "parquear"

        #Create a City Graph Object
        self.cityGraph = CityObjects.createCityGraph(self.city)

        #Initialize the matrix of Labels that are going to compose the Window
        self.matrixOfLabels = self.city

        #Set all of the images
        self.taxiRightImage = Image.open("ProjectImages/taxiDerecha.png")
        self.taxiLeftImage = Image.open("ProjectImages/taxiIzquierda.png")
        self.taxiUpImage = Image.open("ProjectImages/taxiArriba.png")
        self.taxiDownImage = Image.open("ProjectImages/taxiAbajo.png")
        self.wallHorizontalImage = Image.open(
            "ProjectImages/barreraHorizontal2.png")
        self.wallVerticalImage = Image.open(
            "ProjectImages/barreraVertical2.png")
        self.streetImage = Image.open("ProjectImages/calle.png")
        self.waterImage = Image.open("ProjectImages/rio.png")
        self.clientImage = Image.open("ProjectImages/cliente1.jpg")
        self.routeImage = Image.open("ProjectImages/ruta1.png")
        self.cuadraSinIdentificacionImage = Image.open(
            "ProjectImages/cuadraSinIdentificacion.png")
        self.cuadraIdentificada = ""

        #Set the master as the root
        self.master = master
        self.widthOfEachFrame = 0
        self.heightOfEachFrame = 0

        #This is going to be the Frame with the Button and Label that shows: Calculating route or Taxi on the way!
        self.taxiStateFrame = Frame(self.master,
                                    width=self.width,
                                    height=(self.height + 50) - (self.height),
                                    background="White")
        self.taxiStateFrame.place(x=0, y=(self.height))
        self.taxiStateButton = Button(self.taxiStateFrame,
                                      text="Taxi State",
                                      width=20,
                                      height=1,
                                      bg="Black",
                                      fg='White',
                                      font=('Kalinga', '16'),
                                      relief='sunken')
        self.taxiStateButton.place(x=10, y=5)
        self.taxiStateLabel = Label(self.taxiStateFrame,
                                    width=50,
                                    height=1,
                                    bg="Black",
                                    text='Welcome to the Taxi Simulation',
                                    fg='White',
                                    font=('Kalinga', '16'),
                                    relief='sunken')
        self.taxiStateLabel.place(x=350, y=10)

        #Here, we call the function in charge of build the city
        self.buildCity()

        #This instruction is in constant review for the instruction of the console
        self.getConsoleInstruction()
Esempio n. 16
0
def get_next_map_token(scanner):
    """ Parses next section/symbol from map file

        Scans through the .map file tracked by input MapScannerTracker looking
        for Symbols defined in .map file. Returns the first symbol encountered.

        Args:
            scanner: MapScannerTracker with current tracking info

        Returns:
            Symbol object representing next symbol found. None when EOF is 
            reached
    """
    for line in scanner.fh:
        # look for section header
        m = re.search('^([0-9_A-Z]+)'+\
                      '(\s+(0x[0-9a-fA-F]+)\s+(0x[0-9a-fA-F]+)\s+(#)\s+([a-zA-Z]+:)' + \
                      '\s+(0x[0-9a-fA-F,]+)\s+([a-zA-Z:]+)\s+(0x[0-9a-fA-F]+))?\s*$',
                      line)
        if m:
            if m.group(2) != None:
                section = MapParser.Section(m.group(1), int(m.group(3), 0),
                                            int(m.group(4), 0))
                scanner.curr_section = section
                #return (section, None)
            else:
                scanner.curr_section_name = m.group(1)
                scanner.split_line_section = True
            continue

        # handle split line header
        if scanner.split_line_section:
            m = re.search('^\s+(0x[0-9a-fA-F]*)\s+(0x[0-9a-fA-F]+)\s*$', line)
            scanner.split_line_section = False
            if m:
                section = MapParser.Section(scanner.curr_section_name,
                                            int(m.group(1), 0),
                                            int(m.group(2), 0))
                scanner.curr_section = section
                #return (section, None)
            continue

        # look for COMMON symbol

        m = re.search('^([\*\.a-zA-Z0-9_]+)(\([\a-zA-Z\s]+\))(\s+(0x' + \
                      '[0-9a-fA-F]+)\s+.*?([^\\\\/]+\\.lib)\\((.*)\\)(\s+[#A-Z_,\|0-9]+))?\s*$',
                      line)
        if m:
            if scanner.curr_section != None:
                if m.group(2) == "(COMMON )":
                    scanner.split_line_symbol = True
                    scanner.curr_symbol = "COMMON"
                else:
                    scanner.split_line_symbol = False
                    scanner.curr_symbol = None
                continue

        # handle split line symbol
        if scanner.split_line_symbol:
            m = re.search('^\s+(0x[0-9a-fA-F]+)\s+(0x[0-9a-fA-F]+)\s+.*?' + \
                          '([^\\\\/]+\\.lib)\\((.*)\\)(\s+[#A-Z_,\|0-9]+)\s*$',
                          line)
            if m:
                symbol = MapParser.Symbol(int(m.group(1), 0),
                                          int(m.group(2), 0), m.group(4),
                                          m.group(3),
                                          extract_segment(scanner.curr_symbol),
                                          scanner.curr_symbol,
                                          scanner.curr_section)
                return symbol
            continue
        # look for other symbol
        m = re.search('^([\.a-zA-Z0-9_]+)(\s+(0x[0-9a-fA-F]+)\s+(0x' + \
                      '[0-9a-fA-F]+)\s+.*?([^\\\\/]+\\.lib)\\((.*)\\))(\s+[#A-Z_,\|0-9]*)\s*$',
                      line)
        if m and scanner.curr_section != None:
            scanner.curr_symbol = m.group(1)
            if m.group(2) != None:
                symbol = MapParser.Symbol(int(m.group(3), 0),
                                          int(m.group(4), 0), m.group(6),
                                          m.group(5),
                                          extract_segment(m.group(1)),
                                          m.group(1), scanner.curr_section)
                return symbol
            else:
                scanner.split_line_symbol = True
            continue

        # handle split line symbol
        if scanner.split_line_symbol:
            m = re.search('^\s+(0x[0-9a-fA-F]+)\s+(0x[0-9a-fA-F]+)\s+.*?' + \
                          '([^\\\\/]+\\.lib)\\((.*)\\)\s*$',
                          line)
            scanner.split_line_symbol = False
            if m:
                symbol = MapParser.Symbol(int(m.group(1), 0),
                                          int(m.group(2), 0), m.group(4),
                                          m.group(3),
                                          extract_segment(scanner.curr_symbol),
                                          scanner.curr_symbol,
                                          scanner.curr_section)
                #return (scanner.curr_section, symbol)
                return symbol
            continue

        # end section on empty line
        m = re.search('^$', line)
        if m:
            scanner.split_line_section = False
            scanner.split_line_symbol = False
            scanner.curr_section = None
            scanner.curr_section_name = ''
            scanner.curr_symbol = None

        # clear split line flags if no matches
        scanner.split_line_section = False
        scanner.split_line_symbol = False

    # indicate done scanning
    #return (None, None)
    return None
Esempio n. 17
0
    def __init__(self, master):
        #Establish the width and height of the First Window
        self.width = 1100
        self.height = 600

        #Initialize the city matrix, get the number of rows of the city and the number of columns of the city
        self.city = MapParser.createMapParser()
        self.rows = len(self.city)
        self.columns = len(self.city[0])

        #This is used to save the old coordinates of the taxi
        self.oldCoordinates = []
        self.taxiNode = 0

        #Create a City Graph Object
        self.cityGraph = CityObjects.createCityGraph(self.city)

        #Initialize the matrix of Labels that are going to compose the Window
        self.matrixOfLabels = self.city

        #Set all of the images
        self.taxiRightImage = Image.open("ProjectImages/taxiDerecha.png")
        self.taxiLeftImage = Image.open("ProjectImages/taxiIzquierda.png")
        self.taxiUpImage = Image.open("ProjectImages/taxiArriba.png")
        self.taxiDownImage = Image.open("ProjectImages/taxiAbajo.png")
        self.wallHorizontalImage = Image.open(
            "ProjectImages/barreraHorizontal2.png")
        self.wallVerticalImage = Image.open(
            "ProjectImages/barreraVertical2.png")
        self.streetImage = Image.open("ProjectImages/calle.png")
        self.waterImage = Image.open("ProjectImages/rio.png")
        self.clientImage = Image.open("ProjectImages/cliente1.jpg")
        self.routeImage = Image.open("ProjectImages/ruta1.png")
        self.cuadraSinIdentificacionImage = Image.open(
            "ProjectImages/cuadraSinIdentificacion.png")
        self.cuadraIdentificada = ""

        #Set the master as the root
        self.master = master
        self.widthOfEachFrame = 0
        self.heightOfEachFrame = 0

        #This is going to be the Frame with the Button and Label that shows: Calculating route or Taxi on the way!
        self.taxiStateFrame = Frame(self.master,
                                    width=self.width,
                                    height=(self.height + 50) - (self.height),
                                    background="White")
        self.taxiStateFrame.place(x=0, y=(self.height))
        self.taxiStateButton = Button(self.taxiStateFrame,
                                      text="Taxi State",
                                      width=20,
                                      height=1,
                                      bg="Black",
                                      fg='White',
                                      font=('Kalinga', '16'),
                                      relief='sunken')
        self.taxiStateButton.place(x=10, y=5)
        self.taxiStateLabel = Label(self.taxiStateFrame,
                                    width=50,
                                    height=1,
                                    bg="Black",
                                    text='Welcome to the Taxi Simulation',
                                    fg='White',
                                    font=('Kalinga', '16'),
                                    relief='sunken')
        self.taxiStateLabel.place(x=350, y=10)

        #Here, we call the function in charge of build the city
        self.buildCity()
Esempio n. 18
0
__author__ = 'MyPrecious'

import MapParser
import QueryData

MapParser.MapParser()

s = "Type the number for corresponding options:\n" \
    "1. Get all the cities from CSAir\n" \
    "2. Get a specific information about one city\n" \
    "3. Get all kinds of stats\n" \
    "4. Get a specific route\n" \
    "5. Exit the program"

while True:

    print s

    i = raw_input("Enter the number.")
    i = int(i)
    if i == 1:
        cityList = QueryData.citylist()
        print "Here are the lists!"
        for city in cityList:
            print city

    elif i == 2:
        city_name = raw_input("Enter the city name.")

        valid = QueryData.getcitydata(city_name)