示例#1
0
文件: jar.py 项目: paulmadore/luckyde
    def finalizeJar(self, jarPath, chromebasepath, register, doZip=True):
        """Helper method to write out the chrome registration entries to
         jarfile.manifest or chrome.manifest, or both.

        The actual file processing is done in updateManifest.
        """

        # rewrite the manifest, if entries given
        if not register:
            return

        chromeManifest = os.path.join(os.path.dirname(jarPath), "..", "chrome.manifest")

        if self.useJarfileManifest:
            self.updateManifest(jarPath + ".manifest", chromebasepath.format(""), register)
            addEntriesToListFile(chromeManifest, ["manifest chrome/{0}.manifest".format(os.path.basename(jarPath))])
        if self.useChromeManifest:
            self.updateManifest(chromeManifest, chromebasepath.format("chrome/"), register)

        # If requested, add a root chrome manifest entry (assumed to be in the parent directory
        # of chromeManifest) with the application specific id. In cases where we're building
        # lang packs, the root manifest must know about application sub directories.

        if self.rootManifestAppId:
            rootChromeManifest = os.path.join(
                os.path.normpath(os.path.dirname(chromeManifest)), "..", "chrome.manifest"
            )
            rootChromeManifest = os.path.normpath(rootChromeManifest)
            chromeDir = os.path.basename(os.path.dirname(os.path.normpath(chromeManifest)))
            logging.info("adding '%s' entry to root chrome manifest appid=%s" % (chromeDir, self.rootManifestAppId))
            addEntriesToListFile(
                rootChromeManifest, ["manifest %s/chrome.manifest application=%s" % (chromeDir, self.rootManifestAppId)]
            )
示例#2
0
 def updateManifest(self, manifestPath, chromebasepath, register):
     '''updateManifest replaces the % in the chrome registration entries
     with the given chrome base path, and updates the given manifest file.
     '''
     myregister = dict.fromkeys(map(lambda s: s.replace('%',
         chromebasepath), register))
     addEntriesToListFile(manifestPath, myregister.iterkeys())
示例#3
0
 def test_add_multiple(self):
   """Test that attempting to add the same entry multiple times results in
   only one entry being added."""
   testfile = os.path.join(self.tmpdir, "test.list")
   addEntriesToListFile(testfile, ["a","b","a","a","b"])
   self.assertFileContains(testfile, ["a","b"])
   addEntriesToListFile(testfile, ["c","a","c","b","c"])
   self.assertFileContains(testfile, ["a","b","c"])
示例#4
0
 def test_append_some(self):
   "Test adding new entries mixed with existing entries."
   testfile = os.path.join(self.tmpdir, "test.list")
   l = ["a", "b", "c"]
   addEntriesToListFile(testfile, l)
   self.assertFileContains(testfile, l)
   addEntriesToListFile(testfile, ["a", "x", "c", "z"])
   self.assertFileContains(testfile, ["a", "b", "c", "x", "z"])
示例#5
0
 def test_add_multiple(self):
     """Test that attempting to add the same entry multiple times results in
     only one entry being added."""
     testfile = os.path.join(self.tmpdir, "test.list")
     addEntriesToListFile(testfile, ["a", "b", "a", "a", "b"])
     self.assertFileContains(testfile, ["a", "b"])
     addEntriesToListFile(testfile, ["c", "a", "c", "b", "c"])
     self.assertFileContains(testfile, ["a", "b", "c"])
示例#6
0
 def test_basic(self):
   "Test that addEntriesToListFile works when file doesn't exist."
   testfile = os.path.join(self.tmpdir, "test.list")
   l = ["a", "b", "c"]
   addEntriesToListFile(testfile, l)
   self.assertFileContains(testfile, l)
   # ensure that attempting to add the same entries again doesn't change it
   addEntriesToListFile(testfile, l)
   self.assertFileContains(testfile, l)
示例#7
0
 def test_append(self):
   "Test adding new entries."
   testfile = os.path.join(self.tmpdir, "test.list")
   l = ["a", "b", "c"]
   addEntriesToListFile(testfile, l)
   self.assertFileContains(testfile, l)
   l2 = ["x","y","z"]
   addEntriesToListFile(testfile, l2)
   l.extend(l2)
   self.assertFileContains(testfile, l)
示例#8
0
文件: jar.py 项目: Floflis/gecko-b2g
    def finalizeJar(self,
                    jardir,
                    jarbase,
                    jarname,
                    chromebasepath,
                    register,
                    doZip=True):
        """Helper method to write out the chrome registration entries to
         jarfile.manifest or chrome.manifest, or both.

        The actual file processing is done in updateManifest.
        """

        # rewrite the manifest, if entries given
        if not register:
            return

        chromeManifest = os.path.join(jardir, jarbase, "chrome.manifest")

        if self.useJarfileManifest:
            self.updateManifest(
                os.path.join(jardir, jarbase, jarname + ".manifest"),
                chromebasepath.format(""),
                register,
            )
            if jarname != "chrome":
                addEntriesToListFile(chromeManifest,
                                     ["manifest {0}.manifest".format(jarname)])
        if self.useChromeManifest:
            chromebase = os.path.dirname(jarname) + "/"
            self.updateManifest(chromeManifest,
                                chromebasepath.format(chromebase), register)

        # If requested, add a root chrome manifest entry (assumed to be in the parent directory
        # of chromeManifest) with the application specific id. In cases where we're building
        # lang packs, the root manifest must know about application sub directories.

        if self.rootManifestAppId:
            rootChromeManifest = os.path.join(
                os.path.normpath(os.path.dirname(chromeManifest)),
                "..",
                "chrome.manifest",
            )
            rootChromeManifest = os.path.normpath(rootChromeManifest)
            chromeDir = os.path.basename(
                os.path.dirname(os.path.normpath(chromeManifest)))
            logging.info("adding '%s' entry to root chrome manifest appid=%s" %
                         (chromeDir, self.rootManifestAppId))
            addEntriesToListFile(
                rootChromeManifest,
                [
                    "manifest %s/chrome.manifest application=%s" %
                    (chromeDir, self.rootManifestAppId)
                ],
            )
示例#9
0
    def finalizeJar(self, jardir, jarbase, jarname, chromebasepath, register, doZip=True):
        '''Helper method to write out the chrome registration entries to
         jarfile.manifest or chrome.manifest, or both.

        The actual file processing is done in updateManifest.
        '''

        # rewrite the manifest, if entries given
        if not register:
            return

        chromeManifest = os.path.join(jardir, jarbase, 'chrome.manifest')

        if self.useJarfileManifest:
            self.updateManifest(os.path.join(jardir, jarbase,
                                             jarname + '.manifest'),
                                chromebasepath.format(''), register)
            if jarname != 'chrome':
                addEntriesToListFile(chromeManifest,
                                     ['manifest {0}.manifest'.format(jarname)])
        if self.useChromeManifest:
            chromebase = os.path.dirname(jarname) + '/'
            self.updateManifest(chromeManifest,
                                chromebasepath.format(chromebase), register)

        # If requested, add a root chrome manifest entry (assumed to be in the parent directory
        # of chromeManifest) with the application specific id. In cases where we're building
        # lang packs, the root manifest must know about application sub directories.

        if self.rootManifestAppId:
            rootChromeManifest = \
                os.path.join(os.path.normpath(os.path.dirname(chromeManifest)),
                             '..', 'chrome.manifest')
            rootChromeManifest = os.path.normpath(rootChromeManifest)
            chromeDir = \
                os.path.basename(os.path.dirname(os.path.normpath(chromeManifest)))
            logging.info("adding '%s' entry to root chrome manifest appid=%s"
                          % (chromeDir, self.rootManifestAppId))
            addEntriesToListFile(rootChromeManifest,
                                 ['manifest %s/chrome.manifest application=%s'
                                  % (chromeDir,
                                 self.rootManifestAppId)])
示例#10
0
    def finalizeJar(self, jarPath, chromebasepath, register, doZip=True):
        '''Helper method to write out the chrome registration entries to
         jarfile.manifest or chrome.manifest, or both.

        The actual file processing is done in updateManifest.
        '''

        # rewrite the manifest, if entries given
        if not register:
            return

        chromeManifest = os.path.join(os.path.dirname(jarPath), '..',
                                      'chrome.manifest')

        if self.useJarfileManifest:
            self.updateManifest(jarPath + '.manifest',
                                chromebasepath.format(''), register)
            addEntriesToListFile(chromeManifest, [
                'manifest chrome/{0}.manifest'.format(
                    os.path.basename(jarPath))
            ])
        if self.useChromeManifest:
            self.updateManifest(chromeManifest,
                                chromebasepath.format('chrome/'), register)

        # If requested, add a root chrome manifest entry (assumed to be in the parent directory
        # of chromeManifest) with the application specific id. In cases where we're building
        # lang packs, the root manifest must know about application sub directories.

        if self.rootManifestAppId:
            rootChromeManifest = \
                os.path.join(os.path.normpath(os.path.dirname(chromeManifest)),
                             '..', 'chrome.manifest')
            rootChromeManifest = os.path.normpath(rootChromeManifest)
            chromeDir = \
                os.path.basename(os.path.dirname(os.path.normpath(chromeManifest)))
            logging.info("adding '%s' entry to root chrome manifest appid=%s" %
                         (chromeDir, self.rootManifestAppId))
            addEntriesToListFile(rootChromeManifest, [
                'manifest %s/chrome.manifest application=%s' %
                (chromeDir, self.rootManifestAppId)
            ])
示例#11
0
def addStringToListFile(manifestFile, manifestString, chromeSet):
    checkChromeFile(chromeSet, manifestFile)
    ensureDirFor(manifestFile)
    addEntriesToListFile(manifestFile, [manifestString])