Exemple #1
0
    def testDialog(self):
        dlg = rc.Dialog(
            StringIO.StringIO('''\
IDD_SIDEBAR_RSS_PANEL_PROPPAGE DIALOGEX 0, 0, 239, 221
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    PUSHBUTTON      "Add &URL",IDC_SIDEBAR_RSS_ADD_URL,182,53,57,14
    EDITTEXT        IDC_SIDEBAR_RSS_NEW_URL,0,53,178,15,ES_AUTOHSCROLL
    PUSHBUTTON      "&Remove",IDC_SIDEBAR_RSS_REMOVE,183,200,56,14
    PUSHBUTTON      "&Edit",IDC_SIDEBAR_RSS_EDIT,123,200,56,14
    CONTROL         "&Automatically add commonly viewed clips",
                    IDC_SIDEBAR_RSS_AUTO_ADD,"Button",BS_AUTOCHECKBOX |
                    BS_MULTILINE | WS_TABSTOP,0,200,120,17
    PUSHBUTTON      "",IDC_SIDEBAR_RSS_HIDDEN,179,208,6,6,NOT WS_VISIBLE
    LTEXT           "You can display clips from blogs, news sites, and other online sources.",
                    IDC_STATIC,0,0,239,10
    LISTBOX         IDC_SIDEBAR_DISPLAYED_FEED_LIST,0,69,239,127,LBS_SORT |
                    LBS_OWNERDRAWFIXED | LBS_HASSTRINGS |
                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL |
                    WS_TABSTOP
    LTEXT           "Add a clip from a recently viewed website by clicking Add Recent Clips.",
                    IDC_STATIC,0,13,141,19
    LTEXT           "Or, if you know a site supports RSS or Atom, you can enter the RSS or Atom URL below and add it to your list of Web Clips.",
                    IDC_STATIC,0,33,239,18
    PUSHBUTTON      "Add Recent &Clips (10)...",
                    IDC_SIDEBAR_RSS_ADD_RECENT_CLIPS,146,14,93,14
END'''), 'IDD_SIDEBAR_RSS_PANEL_PROPPAGE')
        dlg.SetUberClique(self.uq)
        dlg.Parse()

        warnings = shortcuts.GenerateDuplicateShortcutsWarnings(
            self.uq, 'PROJECT')
        self.failUnless(len(warnings) == 0)
  def testAmpersandEscaping(self):
    c = self.uq.MakeClique(tclib.Message(text="Hello &there"))
    c.AddToShortcutGroup('group_name')
    c = self.uq.MakeClique(tclib.Message(text="S&&T are the &letters S and T"))
    c.AddToShortcutGroup('group_name')

    warnings = shortcuts.GenerateDuplicateShortcutsWarnings(self.uq, 'PROJECT')
    self.failUnless(len(warnings) == 0)
  def testFunctionality(self):
    c = self.uq.MakeClique(tclib.Message(text="Hello &there"))
    c.AddToShortcutGroup('group_name')
    c = self.uq.MakeClique(tclib.Message(text="Howdie &there partner"))
    c.AddToShortcutGroup('group_name')

    warnings = shortcuts.GenerateDuplicateShortcutsWarnings(self.uq, 'PROJECT')
    self.failUnless(warnings)
Exemple #4
0
  def Process(self):
    # Update filenames with those provided by SCons if we're being invoked
    # from SCons.  The list of SCons targets also includes all <structure>
    # node outputs, but it starts with our output files, in the order they
    # occur in the .grd
    if self.scons_targets:
      assert len(self.scons_targets) >= len(self.res.GetOutputFiles())
      outfiles = self.res.GetOutputFiles()
      for ix in range(len(outfiles)):
        outfiles[ix].output_filename = os.path.abspath(
          self.scons_targets[ix])
    else:
      for output in self.res.GetOutputFiles():
        output.output_filename = os.path.abspath(os.path.join(
          self.output_directory, output.GetOutputFilename()))

    # If there are whitelisted names, tag the tree once up front, this way
    # while looping through the actual output, it is just an attribute check.
    if self.whitelist_names:
      self.AddWhitelistTags(self.res, self.whitelist_names)

    for output in self.res.GetOutputFiles():
      self.VerboseOut('Creating %s...' % output.GetOutputFilename())

      # Set the context, for conditional inclusion of resources
      self.res.SetOutputLanguage(output.GetLanguage())
      self.res.SetOutputContext(output.GetContext())
      self.res.SetFallbackToDefaultLayout(output.GetFallbackToDefaultLayout())
      self.res.SetDefines(self.defines)

      # Assign IDs only once to ensure that all outputs use the same IDs.
      if self.res.GetIdMap() is None:
        self.res.InitializeIds()

      # Make the output directory if it doesn't exist.
      self.MakeDirectoriesTo(output.GetOutputFilename())

      # Write the results to a temporary file and only overwrite the original
      # if the file changed.  This avoids unnecessary rebuilds.
      outfile = self.fo_create(output.GetOutputFilename() + '.tmp', 'wb')

      if output.GetType() != 'data_package':
        encoding = self._EncodingForOutputType(output.GetType())
        outfile = util.WrapOutputStream(outfile, encoding)

      # Iterate in-order through entire resource tree, calling formatters on
      # the entry into a node and on exit out of it.
      with outfile:
        self.ProcessNode(self.res, output, outfile)

      # Now copy from the temp file back to the real output, but on Windows,
      # only if the real output doesn't exist or the contents of the file
      # changed.  This prevents identical headers from being written and .cc
      # files from recompiling (which is painful on Windows).
      if not os.path.exists(output.GetOutputFilename()):
        os.rename(output.GetOutputFilename() + '.tmp',
                  output.GetOutputFilename())
      else:
        # CHROMIUM SPECIFIC CHANGE.
        # This clashes with gyp + vstudio, which expect the output timestamp
        # to change on a rebuild, even if nothing has changed, so only do
        # it when opted in.
        if not self.write_only_new:
          write_file = True
        else:
          files_match = filecmp.cmp(output.GetOutputFilename(),
              output.GetOutputFilename() + '.tmp')
          write_file = not files_match
        if write_file:
          shutil.copy2(output.GetOutputFilename() + '.tmp',
                       output.GetOutputFilename())
        os.remove(output.GetOutputFilename() + '.tmp')

      self.VerboseOut(' done.\n')

    # Print warnings if there are any duplicate shortcuts.
    warnings = shortcuts.GenerateDuplicateShortcutsWarnings(
        self.res.UberClique(), self.res.GetTcProject())
    if warnings:
      print '\n'.join(warnings)

    # Print out any fallback warnings, and missing translation errors, and
    # exit with an error code if there are missing translations in a non-pseudo
    # and non-official build.
    warnings = (self.res.UberClique().MissingTranslationsReport().
        encode('ascii', 'replace'))
    if warnings:
      self.VerboseOut(warnings)
    if self.res.UberClique().HasMissingTranslations():
      print self.res.UberClique().missing_translations_
      sys.exit(-1)
  def Process(self):
    # Update filenames with those provided by SCons if we're being invoked
    # from SCons.  The list of SCons targets also includes all <structure>
    # node outputs, but it starts with our output files, in the order they
    # occur in the .grd
    if self.scons_targets:
      assert len(self.scons_targets) >= len(self.res.GetOutputFiles())
      outfiles = self.res.GetOutputFiles()
      for ix in range(len(outfiles)):
        outfiles[ix].output_filename = os.path.abspath(
          self.scons_targets[ix])
    else:
      for output in self.res.GetOutputFiles():
        output.output_filename = os.path.abspath(os.path.join(
          self.output_directory, output.GetFilename()))

    # If there are whitelisted names, tag the tree once up front, this way
    # while looping through the actual output, it is just an attribute check.
    if self.whitelist_names:
      self.AddWhitelistTags(self.res, self.whitelist_names)

    for output in self.res.GetOutputFiles():
      self.VerboseOut('Creating %s...' % output.GetFilename())

      # Microsoft's RC compiler can only deal with single-byte or double-byte
      # files (no UTF-8), so we make all RC files UTF-16 to support all
      # character sets.
      if output.GetType() in ('rc_header', 'resource_map_header',
          'resource_map_source', 'resource_file_map_source'):
        encoding = 'cp1252'
      elif output.GetType() in ('android', 'c_format', 'js_map_format', 'plist',
                                'plist_strings', 'doc', 'json'):
        encoding = 'utf_8'
      elif output.GetType() in ('chrome_messages_json'):
        # Chrome Web Store currently expects BOM for UTF-8 files :-(
        encoding = 'utf-8-sig'
      else:
        # TODO(gfeher) modify here to set utf-8 encoding for admx/adml
        encoding = 'utf_16'

      # Set the context, for conditional inclusion of resources
      self.res.SetOutputLanguage(output.GetLanguage())
      self.res.SetOutputContext(output.GetContext())
      self.res.SetDefines(self.defines)

      # Make the output directory if it doesn't exist.
      self.MakeDirectoriesTo(output.GetOutputFilename())

      # Write the results to a temporary file and only overwrite the original
      # if the file changed.  This avoids unnecessary rebuilds.
      outfile = self.fo_create(output.GetOutputFilename() + '.tmp', 'wb')

      if output.GetType() != 'data_package':
        outfile = util.WrapOutputStream(outfile, encoding)

      # Iterate in-order through entire resource tree, calling formatters on
      # the entry into a node and on exit out of it.
      with outfile:
        self.ProcessNode(self.res, output, outfile)

      # Now copy from the temp file back to the real output, but on Windows,
      # only if the real output doesn't exist or the contents of the file
      # changed.  This prevents identical headers from being written and .cc
      # files from recompiling (which is painful on Windows).
      if not os.path.exists(output.GetOutputFilename()):
        os.rename(output.GetOutputFilename() + '.tmp',
                  output.GetOutputFilename())
      else:
        # CHROMIUM SPECIFIC CHANGE.
        # This clashes with gyp + vstudio, which expect the output timestamp
        # to change on a rebuild, even if nothing has changed.
        #files_match = filecmp.cmp(output.GetOutputFilename(),
        #    output.GetOutputFilename() + '.tmp')
        #if (output.GetType() != 'rc_header' or not files_match
        #    or sys.platform != 'win32'):
        shutil.copy2(output.GetOutputFilename() + '.tmp',
                     output.GetOutputFilename())
        os.remove(output.GetOutputFilename() + '.tmp')

      self.VerboseOut(' done.\n')

    # Print warnings if there are any duplicate shortcuts.
    warnings = shortcuts.GenerateDuplicateShortcutsWarnings(
        self.res.UberClique(), self.res.GetTcProject())
    if warnings:
      print '\n'.join(warnings)

    # Print out any fallback warnings, and missing translation errors, and
    # exit with an error code if there are missing translations in a non-pseudo
    # and non-official build.
    warnings = (self.res.UberClique().MissingTranslationsReport().
        encode('ascii', 'replace'))
    if warnings:
      self.VerboseOut(warnings)
    if self.res.UberClique().HasMissingTranslations():
      print self.res.UberClique().missing_translations_
      sys.exit(-1)
Exemple #6
0
    def Process(self):
        for output in self.res.GetOutputFiles():
            output.output_filename = os.path.abspath(
                os.path.join(self.output_directory,
                             output.GetOutputFilename()))

        # If there are allowlisted names, tag the tree once up front, this way
        # while looping through the actual output, it is just an attribute check.
        if self.allowlist_names:
            self.AddAllowlistTags(self.res, self.allowlist_names)

        for output in self.res.GetOutputFiles():
            self.VerboseOut('Creating %s...' % output.GetOutputFilename())

            # Set the context, for conditional inclusion of resources
            self.res.SetOutputLanguage(output.GetLanguage())
            self.res.SetOutputContext(output.GetContext())
            self.res.SetFallbackToDefaultLayout(
                output.GetFallbackToDefaultLayout())
            self.res.SetDefines(self.defines)

            # Assign IDs only once to ensure that all outputs use the same IDs.
            if self.res.GetIdMap() is None:
                self.res.InitializeIds()

            # Make the output directory if it doesn't exist.
            self.MakeDirectoriesTo(output.GetOutputFilename())

            # Write the results to a temporary file and only overwrite the original
            # if the file changed.  This avoids unnecessary rebuilds.
            out_filename = output.GetOutputFilename()
            tmp_filename = out_filename + '.tmp'
            tmpfile = self.fo_create(tmp_filename, 'wb')

            output_type = output.GetType()
            if output_type != 'data_package':
                encoding = self._EncodingForOutputType(output_type)
                tmpfile = util.WrapOutputStream(tmpfile, encoding)

            # Iterate in-order through entire resource tree, calling formatters on
            # the entry into a node and on exit out of it.
            with tmpfile:
                self.ProcessNode(self.res, output, tmpfile)

            if output_type == 'chrome_messages_json_gzip':
                gz_filename = tmp_filename + '.gz'
                with open(tmp_filename,
                          'rb') as tmpfile, open(gz_filename, 'wb') as f:
                    with gzip.GzipFile(filename='',
                                       mode='wb',
                                       fileobj=f,
                                       mtime=0) as fgz:
                        shutil.copyfileobj(tmpfile, fgz)
                os.remove(tmp_filename)
                tmp_filename = gz_filename

            # Now copy from the temp file back to the real output, but on Windows,
            # only if the real output doesn't exist or the contents of the file
            # changed.  This prevents identical headers from being written and .cc
            # files from recompiling (which is painful on Windows).
            if not os.path.exists(out_filename):
                os.rename(tmp_filename, out_filename)
            else:
                # CHROMIUM SPECIFIC CHANGE.
                # This clashes with gyp + vstudio, which expect the output timestamp
                # to change on a rebuild, even if nothing has changed, so only do
                # it when opted in.
                if not self.write_only_new:
                    write_file = True
                else:
                    files_match = filecmp.cmp(out_filename, tmp_filename)
                    write_file = not files_match
                if write_file:
                    shutil.copy2(tmp_filename, out_filename)
                os.remove(tmp_filename)

            self.VerboseOut(' done.\n')

        # Print warnings if there are any duplicate shortcuts.
        warnings = shortcuts.GenerateDuplicateShortcutsWarnings(
            self.res.UberClique(), self.res.GetTcProject())
        if warnings:
            print('\n'.join(warnings))

        # Print out any fallback warnings, and missing translation errors, and
        # exit with an error code if there are missing translations in a non-pseudo
        # and non-official build.
        warnings = self.res.UberClique().MissingTranslationsReport()
        if warnings:
            self.VerboseOut(warnings)
        if self.res.UberClique().HasMissingTranslations():
            print(self.res.UberClique().missing_translations_)
            sys.exit(-1)
Exemple #7
0
  def Process(self):
    # Update filenames with those provided by SCons if we're being invoked
    # from SCons.  The list of SCons targets also includes all <structure>
    # node outputs, but it starts with our output files, in the order they
    # occur in the .grd
    if self.scons_targets:
      assert len(self.scons_targets) >= len(self.res.GetOutputFiles())
      outfiles = self.res.GetOutputFiles()
      for ix in range(len(outfiles)):
        outfiles[ix].output_filename = os.path.abspath(
          self.scons_targets[ix])
    else:
      for output in self.res.GetOutputFiles():
        output.output_filename = os.path.abspath(os.path.join(
          self.output_directory, output.GetFilename()))

    for output in self.res.GetOutputFiles():
      self.VerboseOut('Creating %s...' % output.GetFilename())

      # Microsoft's RC compiler can only deal with single-byte or double-byte
      # files (no UTF-8), so we make all RC files UTF-16 to support all
      # character sets.
      if output.GetType() in ('rc_header', 'resource_map_header',
                              'resource_map_source'):
        encoding = 'cp1252'
      elif output.GetType() == 'js_map_format':
        encoding = 'utf_8'
      else:
        encoding = 'utf_16'

      # Make the output directory if it doesn't exist.
      outdir = os.path.split(output.GetOutputFilename())[0]
      if not os.path.exists(outdir):
        os.makedirs(outdir)
      # Write the results to a temporary file and only overwrite the original
      # if the file changed.  This avoids unnecessary rebuilds.
      outfile = self.fo_create(output.GetOutputFilename() + '.tmp', 'wb')

      if output.GetType() != 'data_package':
        outfile = util.WrapOutputStream(outfile, encoding)

      # Set the context, for conditional inclusion of resources
      self.res.SetOutputContext(output.GetLanguage(), self.defines)

      # TODO(joi) Handle this more gracefully
      import grit.format.rc_header
      grit.format.rc_header.Item.ids_ = {}

      # Iterate in-order through entire resource tree, calling formatters on
      # the entry into a node and on exit out of it.
      self.ProcessNode(self.res, output, outfile)
      outfile.close()

      # Now copy from the temp file back to the real output, but on Windows,
      # only if the real output doesn't exist or the contents of the file
      # changed.  This prevents identical headers from being written and .cc
      # files from recompiling (which is painful on Windows).
      if not os.path.exists(output.GetOutputFilename()):
        os.rename(output.GetOutputFilename() + '.tmp',
                  output.GetOutputFilename())
      else:
        # CHROMIUM SPECIFIC CHANGE.
        # This clashes with gyp + vstudio, which expect the output timestamp
        # to change on a rebuild, even if nothing has changed.
        #files_match = filecmp.cmp(output.GetOutputFilename(),
        #    output.GetOutputFilename() + '.tmp')
        #if (output.GetType() != 'rc_header' or not files_match
        #    or sys.platform != 'win32'):
        shutil.copy2(output.GetOutputFilename() + '.tmp',
                     output.GetOutputFilename())
        os.remove(output.GetOutputFilename() + '.tmp')

      self.VerboseOut(' done.\n')

    # Print warnings if there are any duplicate shortcuts.
    warnings = shortcuts.GenerateDuplicateShortcutsWarnings(
        self.res.UberClique(), self.res.GetTcProject())
    if warnings:
      print '\n'.join(warnings)

    # Print out any fallback warnings, and missing translation errors, and
    # exit with an error code if there are missing translations in a non-pseudo
    # build
    warnings = (self.res.UberClique().MissingTranslationsReport().
        encode('ascii', 'replace'))
    if warnings:
      print warnings
    if self.res.UberClique().HasMissingTranslations():
      sys.exit(-1)