Beispiel #1
0
    def load(self):
        """
        Loads all modules which are listed in the readme.txt files of
        the sub-directories specified in the constructor's types
        argument.

        @return the list of Module instances
        """
        re_EmptyLine = re.compile("^\\s*(|#.*)$")
        # Note: the name of the module may be alphanumeric characters
        # [a-zA-Z0-9_] = \w plus dot '.', dash '-' and slash '/' (to
        # be able to add modules like 'lingogi/share/net').
        # The optional tag-name may be alphanumeric characters
        # [a-zA-Z0-9_] = \w plus dot '.' and dash '-' (no slash);
        # other characters are not allowed:
        re_ModuleLine = re.compile("^"+
                                   # the name of the module
                                   "([\\w\.\/-]+)" +
                                   # followed by optional tag-name
                                   "(?:\\s+([\\w\.-]+))?",
                                   re.IGNORECASE)
        for type in self.__types:
            readme_txt = os.path.join(self.__sourceRoot, type, "readme.txt")
            if util.fileTracker.addInput(readme_txt):
                try:
                    f = None
                    f = open(readme_txt)
                    for nr,text in enumerate(f):
                        line = util.Line(readme_txt, nr+1, text)
                        if re_EmptyLine.match(str(line)): continue
                        match = re_ModuleLine.match(str(line))
                        if match:
                            module = Module(self.__sourceRoot, self.__outputRoot, type,
                                            name=match.group(1),
                                            version=match.group(2))
                            self.__modules.append(module)
                        else:
                            self.addError(line, "warning unrecognized line '%s'" % str(line))
                finally:
                    if f: f.close()
        return self.__modules
Beispiel #2
0
    def generateSourcesSetup(self, verify_sources=True):
        """
        Generates the files sources.all, sources.nopch, sources.pch,
        sources.pch_system_includes and sources.pch_jumbo in both
        modules/hardcore/setup/plain/sources and
        modules/hardcore/setup/jumbo/sources. It also generates the
        jumbo compile units of all modules.
        @return True if any of the generated files has changed and
          False if none has changed.
        """
        changed = False
        self.__plain_sources = module_sources.SourcesSet()
        self.__jumbo_sources = module_sources.SourcesSet()
        for module in self.__modules:
            if util.fileTracker.addInput(module.getSourcesFile()):
                sources = module.getModuleSources()
                changed = sources.generateJumboCompileUnits(self.__sourceRoot, self.__outputRoot) or changed
                self.__plain_sources.extend(sources.plain_sources(),
                                            module.type(), module.name())
                self.__jumbo_sources.extend(sources.jumbo_sources(),
                                            module.type(), module.name())

        # verify that all files exist:
        if verify_sources:
            for filename in set(self.__plain_sources.all()) | set(self.__jumbo_sources.all()):
                if not os.path.exists(os.path.join(self.__sourceRoot, filename)) and not os.path.exists(os.path.join(self.__outputRoot, filename)):
                    self.addError(util.Line("", 0), "file '%s' not found" % filename)

        hardcoreDir = os.path.join(self.__outputRoot, 'modules', 'hardcore')
        plainDir = os.path.join(hardcoreDir, 'setup', 'plain', 'sources')
        jumboDir = os.path.join(hardcoreDir, 'setup', 'jumbo', 'sources')
        sources = ['all', 'nocph', 'pch', 'pch_system_includes', 'pch_jumbo']
        changed = self.__plain_sources.generateSourcesListFiles(plainDir) or changed
        util.updateModuleGenerated(hardcoreDir,
                                   map(lambda s: '/'.join(['setup', 'plain', 'sources', "sources.%s" % s]), sources))
        changed = self.__jumbo_sources.generateSourcesListFiles(jumboDir) or changed
        util.updateModuleGenerated(hardcoreDir,
                                   map(lambda s: '/'.join(['setup', 'jumbo', 'sources', "sources.%s" % s]), sources))

        return changed
Beispiel #3
0
                self.error_value = 2

            if self.generateTables():
                self.error_value = 2

            if self.regenerateSVGpresentationAttrs() == 2:
                self.error_value = 2
        except MarkupParserError, mpe:
            logmessage("  FATAL: bad markup at line %d, column %d! %s." %
                       (mpe.line_num, mpe.col_num, mpe.error_msg))
            self.addError(util.Line(mpe.file_name, mpe.line_num),
                          "FATAL: bad markup!\n%s" % mpe.error_msg)
            self.error_value = 1
        except HashTestingError, hte:
            logmessage("  FATAL: testing hashing failed!%s" % hte.error_msg)
            self.addError(util.Line(hte.file_name, 1),
                          "FATAL: hash tuning failed!\n%s" % hte.error_msg)
            self.error_value = 1

        self.printWarningsAndErrors()
        return self.error_value


class ParseMarkupNames(basesetup.SetupOperation):
    def __init__(self, bigendian):
        if bigendian:
            self.bigendian = True
        else:
            self.bigendian = sys.byteorder == "big"
        basesetup.SetupOperation.__init__(self, message="markup names")
 def test_two_line(self):
     line1 = util.Line(0, 0, 1, 1, 'Testfile.jpg')
     line2 = util.Line(0, 0, 0, 0, 'Testfile.jpg')
     lines = [line1, line2]
     self.assertEqual(util.sortByAngle(lines, 5), [[line1], [line2]])
 def test_single_line(self):
     line = util.Line(0, 0, 1, 1, 'Testfile.jpg')
     lines = [line]
     self.assertEqual(util.sortByAngle(lines, 5), [[line]])
Beispiel #6
0
import random
import players

#game_window
game_window = pyglet.window.Window(1000, 563)  #16:9 screen
SCREEN_W = game_window.width
SCREEN_H = game_window.height
OFF_SCREEN_R = 1100
FLOAT_H = 100
WALK_H = 63

#determine number of players
num_players = 6

#create the spots for player positions on the screen
spots = util.Line(screen_w=SCREEN_W, num_players=num_players)
spots.line_up()

#setup resource dirs
resource_dir = "./resources"
pyglet.resource.path = [resource_dir]
pyglet.resource.reindex()

#setup images
game_objects = []
main_batch = pyglet.graphics.Batch()
background_img = pyglet.resource.image("quiz1.png")
background = pyglet.sprite.Sprite(img=background_img, batch=main_batch)

#fire_light
fire_light_img = pyglet.resource.image("fire_light1.png")
Beispiel #7
0
    def load(self, filename):
        """
        Loads the file 'module.sources' from the specified path and
        parses its content.

        @param filename is the path and filename to the
          'module.sources' file to load.
        """
        self.__jumbo_compile_units = {}
        try:
            f = None
            f = open(filename, "rU")
            util.fileTracker.addInput(filename)
            current_options = None
            # regular expression to match a single line which only
            # contains the options for the following source files:
            re_Options = re.compile("^\\s*#\\s*\[(.*?)\]")
            # regular expression to match a single line which contains
            # the name of a source file with an optional set of
            # options for this file:
            re_Source = re.compile("^([\\w./-]+)\\s*(#.*)?$")
            for nr, text in enumerate(f):
                line = util.Line(filename, nr + 1, text)
                if line.isEmptyOrWhitespace(): continue  # ignore empty lines

                match = re_Options.match(str(line))
                if match:
                    # This line contains options for the source files
                    # on the next lines
                    current_options = self.parseOptions(match.group(1))
                    continue

                match = re_Source.match(str(line))
                if match:
                    # This line contains a new source file
                    source = match.group(1)
                    if current_options is not None:
                        source_options = current_options.copy()
                    else:
                        source_options = None
                    comment = match.group(2)
                    if comment is not None:
                        match = re_Options.match(comment)
                        if match:
                            new_options = self.parseOptions(match.group(1))
                            if source_options is None:
                                source_options = new_options
                            else:
                                source_options.update(new_options)

                    if source_options is not None and len(source_options) > 0:
                        self.__source_options[source] = source_options

                    pch = self.pch(source)
                    system_includes = self.system_includes(source)
                    jumbo = self.jumbo(source)
                    components = self.components(source)
                    self.__plain_sources.addSourceFile(
                        source,
                        pch=pch,
                        system_includes=system_includes,
                        # Note: for a plain compile, jumbo is always disabled
                        jumbo=False,
                        components=components)
                    if jumbo == "0" or components is not None:
                        # Note: files with a component can not be in the jumbo compile (component information would be lost)
                        self.__jumbo_sources.addSourceFile(
                            source,
                            pch=pch,
                            system_includes=system_includes,
                            jumbo=False,
                            components=components)
                    elif jumbo in self.__jumbo_compile_units:
                        # if the jumbo-unit exists, add the
                        # source-file to the jumbo-unit, but the
                        # jumbo-unit was already added to
                        # self.__jumbo_sources
                        jumbo_unit = self.__jumbo_compile_units[jumbo]
                        if (pch != jumbo_unit.pch() or system_includes !=
                                jumbo_unit.system_includes()):
                            self.addError(
                                line,
                                "the source-file %s must have the same 'pch' and 'system_includes' option as the other files in its jumbo-compile-unit"
                                % source)
                        else:
                            jumbo_unit.addSourceFile(source, source_options)

                    else:
                        # this is a new jumbo compile unit, so create
                        # a new JumboCompileUnit instance and add it
                        # to self.__jumbo_sources
                        if jumbo == "1":
                            # Note: the module name may contain
                            # slashes (e.g. "lingogi/share/net"), so
                            # convert them to underscores:
                            jumbo_name = "%s_jumbo.cpp" % self.__module_name.replace(
                                "/", "_")
                        else:
                            jumbo_name = jumbo
                        jumbo_unit = JumboCompileUnit(
                            type=self.__type,
                            module=self.__module_name,
                            name=jumbo_name,
                            pch=pch,
                            system_includes=system_includes)
                        jumbo_unit.addSourceFile(source, source_options)
                        self.__jumbo_compile_units[jumbo] = jumbo_unit
                        self.__jumbo_sources.addSourceFile(
                            jumbo_name,
                            pch=pch,
                            system_includes=system_includes,
                            jumbo=True)

                elif line.isComment():
                    continue  # ignore empty lines
                else:
                    self.addWarning(line, "unrecognized line '%s'" % str(line))
        finally:
            if f: f.close()
        return self.__plain_sources.all()