[nvda-addons] Re: commit/goldwave: josephsl: Upgrade to new template with docfilename added.

  • From: "Joseph Lee" <joseph.lee22590@xxxxxxxxx>
  • To: <nvda-addons@xxxxxxxxxxxxx>
  • Date: Fri, 5 Sep 2014 06:25:24 -0700

Hi folks,
Here's what you need to do to upgrade to the newly modified template:
1. Modify buildVars.py and go through addon info dictionary. You need to
replace "addon-" with "addon_" to avoid key errors during compilation, and
add "addon_docFileName" attribute.
2. Delete dochandler.py from i18n sources and the file itself from the
add-on, as it is no longer needed.
3. Copy the rest of the new template files except readme.md and buildVars.py
into your add-on folder and try recompiling your add-on.
Good luck.
Cheers,
Joseph
-----Original Message-----
From: nvda-addons-commits-bounce@xxxxxxxxxxxxx
[mailto:nvda-addons-commits-bounce@xxxxxxxxxxxxx] On Behalf Of
commits-noreply@xxxxxxxxxxxxx
Sent: Friday, September 5, 2014 6:19 AM
To: nvda-addons-commits@xxxxxxxxxxxxx
Subject: commit/goldwave: josephsl: Upgrade to new template with docfilename
added.

1 new commit in goldwave:

https://bitbucket.org/nvdaaddonteam/goldwave/commits/5970736a9151/
Changeset:   5970736a9151
Branch:      t2694
User:        josephsl
Date:        2014-09-05 15:18:55
Summary:     Upgrade to new template with docfilename added.

Affected #:  5 files

diff --git a/buildVars.py b/buildVars.py index fec357c..5f6cd91 100755
--- a/buildVars.py
+++ b/buildVars.py
@@ -11,21 +11,21 @@ addon_info = {
        # for previously unpublished addons, please follow the community
guidelines at:
        # https://bitbucket.org/nvdaaddonteam/todo/raw/master/guideLines.txt
        # add-on Name, internal for nvda
-       "addon-name" : "goldwave",
+       "addon_name" : "goldwave",
        # Add-on summary, usually the user visible name of the addon.
        # Translators: Summary for this add-on to be shown on installation
and add-on information.
-       "addon-summary" : _("GoldWave"),
+       "addon_summary" : _("GoldWave"),
        # Add-on description
        # Translators: Long description to be shown for this add-on on
add-on information from add-ons manager
-       "addon-description" : _("An add-on for enhancing access and usage of
the Goldwave audio editor."),
+       "addon_description" : _("An add-on for enhancing access and usage of

+the Goldwave audio editor."),
        # version
-       "addon-version" : "2.0-dev",
+       "addon_version" : "2.0-dev",
        # Author(s)
-       "addon-author" : u"Joseph Lee <joseph.lee22590@xxxxxxxxx>, David
Parduhn <xkill85@xxxxxxx>, Mesar Hameed <mhameed@xxxxxxxxxxxxx>",
+       "addon_author" : u"Joseph Lee <joseph.lee22590@xxxxxxxxx>, David 
+Parduhn <xkill85@xxxxxxx>, Mesar Hameed <mhameed@xxxxxxxxxxxxx>",
        # URL for the add-on documentation support
-       "addon-url" : 'http://addons.nvda-project.org',
+       "addon_url" : 'http://addons.nvda-project.org',
        # File name for the add-on help file.
-       "addon-docFileName" : "readme.html"
+       "addon_docFileName" : "readme.html"
 }
 
 
@@ -36,7 +36,7 @@ import os.path
 pythonSources = [os.path.join("addon", "appModules", "*.py"),]
 
 # Files that contain strings for translation. Usually your python sources
-i18nSources = pythonSources + ["buildVars.py", "docHandler.py"]
+i18nSources = pythonSources + ["buildVars.py"]
 
 # Files that will be ignored when building the nvda-addon file  # Paths are
relative to the addon directory, not to the root directory of your addon
sources.

diff --git a/docHandler.py b/docHandler.py deleted file mode 100755 index
b514fe4..0000000
--- a/docHandler.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# -*- coding: UTF-8 -*-
-
-# docHandler: module for managing addons documentation -# See:
http://community.nvda-project.org/ticket/2694
-
-import os
-import languageHandler
-import addonHandler
-import globalPluginHandler
-import gui
-import wx
-
-addonHandler.initTranslation()
-
-_addonDir = os.path.join(os.path.dirname(__file__), "..").decode("mbcs") #
The root of an addon folder -_docFileName = "readme.html" # The name of an
addon documentation file -_curAddon = addonHandler.Addon(_addonDir) # Addon
instance -_addonSummary = _curAddon.manifest['summary'] -_addonVersion =
_curAddon.manifest['version'] -_addonName = _curAddon.manifest['name']
-
-def getDocFolder(addonDir=_addonDir):
-       langs = [languageHandler.getLanguage(), "en"]
-       for lang in langs:
-               docFolder = os.path.join(addonDir, "doc", lang)
-               if os.path.isdir(docFolder):
-                       return docFolder
-               if "_" in lang:
-                       tryLang = lang.split("_")[0]
-                       docFolder = os.path.join(addonDir, "doc", tryLang)
-                       if os.path.isdir(docFolder):
-                               return docFolder
-                       if tryLang == "en":
-                               break
-               if lang == "en":
-                       break
-       return None
-
-def getDocPath(docFileName=_docFileName):
-       docPath = getDocFolder()
-       if docPath is not None:
-               docFile = os.path.join(docPath, docFileName)
-               if os.path.isfile(docFile):
-                       docPath = docFile
-       return docPath
-
-def openDocPath():
-       try:
-               os.startfile(getDocPath())
-       except WindowsError:
-               pass
-
-class GlobalPlugin(globalPluginHandler.GlobalPlugin):
-
-       def __init__(self):
-               super(globalPluginHandler.GlobalPlugin, self).__init__()
-               self.help = gui.mainFrame.sysTrayIcon.helpMenu
-               self.helpItem = self.help.Append(wx.ID_ANY, u"{summary}
{version}".format(summary=_addonSummary, version=_addonVersion), _addonName)
-               gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.onHelp,
self.helpItem)
-
-       def onHelp(self, evt):
-               openDocPath()
-
-       def terminate(self):
-               try:
-                       self.help.RemoveItem(self.helpItem)
-               except wx.PyDeadObjectError:
-                       pass

diff --git a/manifest-translated.ini.tpl b/manifest-translated.ini.tpl index
4750635..c06aa84 100755
--- a/manifest-translated.ini.tpl
+++ b/manifest-translated.ini.tpl
@@ -1,2 +1,2 @@
-summary = "{addon-summary}"
-description = """{addon-description}"""
+summary = "{addon_summary}"
+description = """{addon_description}"""

diff --git a/manifest.ini.tpl b/manifest.ini.tpl index 29d6b58..7de43bf
100755
--- a/manifest.ini.tpl
+++ b/manifest.ini.tpl
@@ -1,7 +1,7 @@
-name = {addon-name}
-summary = "{addon-summary}"
-description = """{addon-description}"""
-author = "{addon-author}"
-url = {addon-url}
-version = {addon-version}
-docFileName = {addon-docFileName}
+name = {addon_name}
+summary = "{addon_summary}"
+description = """{addon_description}"""
+author = "{addon_author}"
+url = {addon_url}
+version = {addon_version}
+docFileName = {addon_docFileName}

diff --git a/sconstruct b/sconstruct
index 1d54d6e..e875b28 100755
--- a/sconstruct
+++ b/sconstruct
@@ -1,5 +1,5 @@
 # NVDA add-on template  SCONSTRUCT file -#Copyright (C) 2012 Rui Batista
<ruiandrebatista@xxxxxxxxx>
+#Copyright (C) 2012, 2014 Rui Batista <ruiandrebatista@xxxxxxxxx>
 #This file is covered by the GNU General Public License.
 #See the file COPYING.txt for more details.
 
@@ -8,7 +8,6 @@ import gettext
 import os
 import os.path
 import zipfile
-import configobj
 
 import buildVars
 
@@ -16,7 +15,7 @@ import buildVars
 def md2html(source, dest):
        import markdown
        lang = os.path.basename(os.path.dirname(source)).replace('_', '-')
-       title="{addonSummary}
{addonVersion}".format(addonSummary=buildVars.addon_info["addon-summary"],
addonVersion=buildVars.addon_info["addon-version"])
+       title="{addonSummary} 
+{addonVersion}".format(addonSummary=buildVars.addon_info["addon_summary
+"], addonVersion=buildVars.addon_info["addon_version"])
        headerDic = {
                "[[!meta title=\"": "# ",
                "\"]]": " #",
@@ -52,10 +51,11 @@ def mdTool(env):
        )
        env['BUILDERS']['markdown']=mdBuilder
 
-env = Environment(ENV=os.environ, tools=[mdTool])
 
+env = Environment(ENV=os.environ, tools=['gettexttool', mdTool])
+env.Append(**buildVars.addon_info)
 
-addonFile =
env.File("{addon-name}-{addon-version}.nvda-addon".format(**buildVars.addon_
info))
+addonFile = env.File("${addon_name}-${addon_version}.nvda-addon")
 
 def addonGenerator(target, source, env, for_signature):
        action = env.Action(lambda target, source, env :
createAddonBundleFromPath(source[0].abspath, target[0].abspath) and None, @@
-79,31 +79,7 @@ env['BUILDERS']['NVDAAddon'] =
Builder(generator=addonGenerator)  env['BUILDERS']['NVDAManifest'] =
Builder(generator=manifestGenerator)
 env['BUILDERS']['NVDATranslatedManifest'] =
Builder(generator=translatedManifestGenerator)
 
-env['BUILDERS']['gettextMoFile']=env.Builder(
-       action=env.Action(["msgfmt -o $TARGETS $SOURCES"], lambda t, s, e :
"Compiling translation %s" % s[0]),
-       suffix=".mo",
-       src_suffix=".po"
-)
-
-env['BUILDERS']['gettextPotFile']=env.Builder(
-       action=env.Action(["xgettext --msgid-bugs-address='%s'
--package-name='%s' --package-version='%s' -c -o $TARGETS $SOURCES" %
-               ("nvda-translations@xxxxxxxxxxxxx",
buildVars.addon_info['addon-name'], buildVars.addon_info['addon-version'])
-       ], lambda t, s, e : "Generating pot file %s" % t[0]),
-       suffix=".pot")
-env['BUILDERS']['gettextMergePotFile']=env.Builder(
-       action=env.Action(["xgettext --msgid-bugs-address='%s'
--package-name='%s' --package-version='%s' --omit-header --no-location -c -o
$TARGETS $SOURCES" %
-               ("nvda-translations@xxxxxxxxxxxxx",
buildVars.addon_info['addon-name'], buildVars.addon_info['addon-version'])
-       ], lambda t, s, e : "Generating pot file %s" % t[0]),
-       suffix=".pot")
-
 def createAddonHelp(dir):
-       if not os.path.isfile("docHandler.py"):
-               return
-       plugindir = os.path.join(dir, "globalPlugins")
-       docFilename =
"{addonName}_docHandler.py".format(addonName=buildVars.addon_info["addon-nam
e"])
-       docPath = os.path.join(plugindir, docFilename)
-       docFileTarget = env.Command(docPath, "docHandler.py",
Copy("$TARGET", "$SOURCE"))
-       env.Depends(addon, docFileTarget)
        docsDir = os.path.join(dir, "doc")
        if os.path.isfile("style.css"):
                cssPath = os.path.join(docsDir, "style.css") @@ -139,7
+115,7 @@ def generateManifest(source, dest):
 def generateTranslatedManifest(source, language, out):
        _ = gettext.translation("nvda", localedir=os.path.join("addon",
"locale"), languages=[language]).ugettext
        vars = {}
-       for var in ("addon-summary", "addon-description"):
+       for var in ("addon_summary", "addon_description"):
                vars[var] = _(buildVars.addon_info[var])
        with codecs.open(source, "r", "utf-8") as f:
                manifest_template = f.read()
@@ -176,10 +152,16 @@ for mdFile in env.Glob(os.path.join('addon', 'doc',
'*', '*.md')):
 
 # Pot target
 i18nFiles = expandGlobs(buildVars.i18nSources)
-pot = env.gettextPotFile("%s.pot" %
"{addon-name}".format(**buildVars.addon_info), i18nFiles)
+gettextvars={
+               'gettext_package_bugs_address' :
'nvda-translations@xxxxxxxxxxxxx',
+               'gettext_package_name' : buildVars.addon_info['addon_name'],
+               'gettext_package_version' :
buildVars.addon_info['addon_version']
+       }
+
+pot = env.gettextPotFile("${addon_name}.pot", i18nFiles, **gettextvars)
 env.Alias('pot', pot)
 env.Depends(pot, i18nFiles)
-mergePot = env.gettextMergePotFile("%s-merge.pot" %
"{addon-name}".format(**buildVars.addon_info), i18nFiles)
+mergePot = env.gettextMergePotFile("${addon_name}-merge.pot", 
+i18nFiles, **gettextvars)
 env.Alias('mergePot', mergePot)
 env.Depends(mergePot, i18nFiles)

Repository URL: https://bitbucket.org/nvdaaddonteam/goldwave/

--

This is a commit notification from bitbucket.org. You are receiving this
because you have the service enabled, addressing the recipient of this
email.

----------------------------------------------------------------

NVDA add-ons Central: A list for discussing NVDA add-ons

To post a message, send an email to nvda-addons@xxxxxxxxxxxxx.

To unsubscribe, send an email with the subject line of "unsubscribe" (without 
quotes) to nvda-addons-request@xxxxxxxxxxxxx.

If you have questions for list moderators, please send a message to 
nvda-addons-moderators@xxxxxxxxxxxxx.

Community addons can be found here: http://addons.nvda-project.org

Other related posts:

  • » [nvda-addons] Re: commit/goldwave: josephsl: Upgrade to new template with docfilename added. - Joseph Lee