Ejemplo n.º 1
0
    def expandFileName(self, fileName):
        """
        Replaces placeholders inside the given filename and returns the result. The placeholders are based on the
        current state of the session.

        These are the currently supported placeholders:

        - {{locale}}: Name of current locale e.g. de_DE
        - {{permutation}}: SHA1 checksum of current permutation
        - {{id}}: SHA1 checksum based on permutation and repository branch/revision

        """

        if "{{destination}}" in fileName:
            fileName = fileName.replace("{{destination}}", self.getDestinationPath())

        if self.__permutation:
            if "{{permutation}}" in fileName:
                fileName = fileName.replace("{{permutation}}", self.__permutation.getChecksum())

            if "{{id}}" in fileName:
                buildId = "%s@%s" % (self.__permutation.getKey(), self.__session.getMain().getRevision())
                buildHash = Util.generateChecksum(buildId)
                fileName = fileName.replace("{{id}}", buildHash)

            if "{{locale}}" in fileName:
                locale = self.__permutation.get("locale")
                fileName = fileName.replace("{{locale}}", locale)

        elif "{{id}}" in fileName:
            fileName = fileName.replace("{{id}}", "none@%s" % (self.__session.getMain().getRevision()))

        return fileName
Ejemplo n.º 2
0
    def __init__(self):

        atexit.register(self.close)

        # Behaves like Date.now() in JavaScript: UTC date in milliseconds
        self.__timeStamp = int(round(time.time() * 1000))
        self.__timeHash = Util.generateChecksum(str(self.__timeStamp))

        self.__projects = []
        self.__fields = {}
        self.__translationBundles = {}
Ejemplo n.º 3
0
    def expandFileName(self, fileName):
        """
        Replaces placeholders inside the given filename and returns the result. The placeholders are based on the
        current state of the session.

        These are the currently supported placeholders:

        - {{locale}}: Name of current locale e.g. de_DE
        - {{permutation}}: SHA1 checksum of current permutation
        - {{id}}: SHA1 checksum based on permutation and repository branch/revision

        """

        if "{{destination}}" in fileName:
            fileName = fileName.replace("{{destination}}",
                                        self.getDestinationPath())

        if self.__permutation:
            if "{{permutation}}" in fileName:
                fileName = fileName.replace("{{permutation}}",
                                            self.__permutation.getChecksum())

            if "{{id}}" in fileName:
                buildId = "%s@%s" % (self.__permutation.getKey(),
                                     self.__session.getMain().getRevision())
                buildHash = Util.generateChecksum(buildId)
                fileName = fileName.replace("{{id}}", buildHash)

            if "{{locale}}" in fileName:
                locale = self.__permutation.get("locale")
                fileName = fileName.replace("{{locale}}", locale)

        elif "{{id}}" in fileName:
            fileName = fileName.replace(
                "{{id}}", "none@%s" % (self.__session.getMain().getRevision()))

        return fileName
Ejemplo n.º 4
0
def getTargetFolder(url, version=None):
    """
    Returns the target folder name based on the URL and version using SHA1 checksums.

    :param url: URL to the repository
    :type url: string
    :param version: Version to use
    :type url: string

    """

    if Git.isUrl(url):

        version = Git.expandVersion(version)

        folder = url[url.rindex("/") + 1:]
        if folder.endswith(".git"):
            folder = folder[:-4]

        identifier = "%s@%s" % (url, version)
        version = version[version.rindex("/") + 1:]

    hash = Util.generateChecksum(identifier)
    return "%s-%s-%s" % (folder, version, hash)
Ejemplo n.º 5
0
def getTargetFolder(url, version=None):
    """
    Returns the target folder name based on the URL and version using SHA1 checksums.

    :param url: URL to the repository
    :type url: string
    :param version: Version to use
    :type url: string

    """

    if Git.isUrl(url):

        version = Git.expandVersion(version)

        folder = url[url.rindex("/") + 1:]
        if folder.endswith(".git"):
            folder = folder[:-4]

        identifier = "%s@%s" % (url, version)
        version = version[version.rindex("/") + 1:]

    hash = Util.generateChecksum(identifier)
    return "%s-%s-%s" % (folder, version, hash)
Ejemplo n.º 6
0
    def __init__(self, session):

        Console.info("Initializing profile...")
        Console.indent()

        # Reference to global session object
        self.__session = session

        # Initialize data instance
        self.__data = {}

        # Set default values (which require serialization)
        self.setJsOutputFolder("js")
        self.setCssOutputFolder("css")
        self.setAssetOutputFolder("asset")
        self.setTemplateOutputFolder("tmpl")

        self.setCompressionLevel(0)
        self.setFormattingLevel(100)

        # Initialize file manager
        fileManager = self.__fileManager = FileManager.FileManager(self)

        # Enforce scan of projects
        session.scan()

        # Part registry holds information about all parts of the application to build
        self.__parts = {}

        # Copy fields and commands from session
        # This happens to have local access to all of them + being able to add and tweak data locally
        self.__fields = copy.copy(session.getFields())
        self.__commands = copy.copy(session.getCommands())

        # Behaves like Date.now() in JavaScript: UTC date in milliseconds
        self.__timeStamp = int(round(time.time() * 1000))
        self.__timeHash = Util.generateChecksum(str(self.__timeStamp))

        # No further steps when session has no projects e.g. during "distclean"
        if not session.getProjects():
            return

        # Initialize asset manager
        Console.info("Initializing asset manager...")
        Console.indent()
        assetManager = self.__assetManager = AssetManager.AssetManager(self)

        # Registering assets
        for project in self.getProjects():
            assetManager.addProject(project)

        # Enable sprite sheets and image animations
        assetManager.processSprites()
        assetManager.processAnimations()

        Console.outdent()

        # Registering commands
        Console.info("Registering commands...")

        self.addCommand("asset.url",
                        lambda fileId: assetManager.getAssetUrl(fileId), "url")
        self.addCommand("asset.width",
                        lambda fileId: assetManager.getAssetWidth(fileId),
                        "px")
        self.addCommand("asset.height",
                        lambda fileId: assetManager.getAssetHeight(fileId),
                        "px")

        self.addCommand("sprite.url",
                        lambda fileId: assetManager.getSpriteUrl(fileId),
                        "url")
        self.addCommand("sprite.left",
                        lambda fileId: assetManager.getSpriteLeft(fileId),
                        "px")
        self.addCommand("sprite.top",
                        lambda fileId: assetManager.getSpriteTop(fileId), "px")
        self.addCommand("sprite.width",
                        lambda fileId: assetManager.getSpriteWidth(fileId),
                        "px")
        self.addCommand("sprite.height",
                        lambda fileId: assetManager.getSpriteHeight(fileId),
                        "px")

        self.addCommand(
            "animation.columns",
            lambda fileId: assetManager.getAnimationColumns(fileId), "number")
        self.addCommand("animation.rows",
                        lambda fileId: assetManager.getAnimationRows(fileId),
                        "number")
        self.addCommand("animation.frames",
                        lambda fileId: assetManager.getAnimationFrames(fileId),
                        "number")

        Console.outdent()
Ejemplo n.º 7
0
 def __init__(self, combination):
     
     self.__combination = combination
     self.__key = self.__buildKey(combination)
     self.__checksum = Util.generateChecksum(self.__key)
Ejemplo n.º 8
0
    def __init__(self, session):

        Console.info("Initializing profile...")
        Console.indent()

        # Reference to global session object
        self.__session = session

        # Initialize data instance
        self.__data = {}


        # Set default values (which require serialization)
        self.setJsOutputFolder("js")
        self.setCssOutputFolder("css")
        self.setAssetOutputFolder("asset")
        self.setTemplateOutputFolder("tmpl")

        self.setCompressionLevel(0)
        self.setFormattingLevel(100)


        # Initialize file manager
        fileManager = self.__fileManager = FileManager.FileManager(self)

        # Enforce scan of projects
        session.scan()

        # Part registry holds information about all parts of the application to build
        self.__parts = {}

        # Copy fields and commands from session
        # This happens to have local access to all of them + being able to add and tweak data locally
        self.__fields = copy.copy(session.getFields())
        self.__commands = copy.copy(session.getCommands())

        # Behaves like Date.now() in JavaScript: UTC date in milliseconds
        self.__timeStamp = int(round(time.time() * 1000))
        self.__timeHash = Util.generateChecksum(str(self.__timeStamp))

        # No further steps when session has no projects e.g. during "distclean"
        if not session.getProjects():
            return

        # Initialize asset manager
        Console.info("Initializing asset manager...")
        Console.indent()
        assetManager = self.__assetManager = AssetManager.AssetManager(self)

        # Registering assets
        for project in self.getProjects():
            assetManager.addProject(project)

        # Enable sprite sheets and image animations
        assetManager.processSprites()
        assetManager.processAnimations()

        Console.outdent()

        # Registering commands
        Console.info("Registering commands...")

        self.addCommand("asset.url", lambda fileId: assetManager.getAssetUrl(fileId), "url")
        self.addCommand("asset.width", lambda fileId: assetManager.getAssetWidth(fileId), "px")
        self.addCommand("asset.height", lambda fileId: assetManager.getAssetHeight(fileId), "px")

        self.addCommand("sprite.url", lambda fileId: assetManager.getSpriteUrl(fileId), "url")
        self.addCommand("sprite.left", lambda fileId: assetManager.getSpriteLeft(fileId), "px")
        self.addCommand("sprite.top", lambda fileId: assetManager.getSpriteTop(fileId), "px")
        self.addCommand("sprite.width", lambda fileId: assetManager.getSpriteWidth(fileId), "px")
        self.addCommand("sprite.height", lambda fileId: assetManager.getSpriteHeight(fileId), "px")

        self.addCommand("animation.columns", lambda fileId: assetManager.getAnimationColumns(fileId), "number")
        self.addCommand("animation.rows", lambda fileId: assetManager.getAnimationRows(fileId), "number")
        self.addCommand("animation.frames", lambda fileId: assetManager.getAnimationFrames(fileId), "number")

        Console.outdent()
Ejemplo n.º 9
0
    def __init__(self, combination):

        self.__combination = combination
        self.__key = self.__buildKey(combination)
        self.__checksum = Util.generateChecksum(self.__key)