Skip to content

Commit

Permalink
Update template and bugfix and version increase
Browse files Browse the repository at this point in the history
  • Loading branch information
mltony committed Oct 7, 2019
1 parent c1aeb38 commit 05872a9
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
2 changes: 2 additions & 0 deletions addon/globalPlugins/audioChart.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def saveSettings(self):
def validate(self):
try:
min_value = self.minEdit.Value
min_value = float(min_value)
assert(not math.isnan(min_value))
assert(not math.isinf(min_value))
except:
Expand All @@ -126,6 +127,7 @@ def validate(self):
return False
try:
max_value = self.maxEdit.Value
max_value = float(max_value)
assert(not math.isnan(max_value))
assert(not math.isinf(max_value))
except:
Expand Down
9 changes: 7 additions & 2 deletions buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
"addon_description" : _("""AudioChart add-on for NVDA allows you to play excel time series as a continuous sound."""),
# version
"addon_version" : "1.1dev",
"addon_version" : "1.2",
# Author(s)
"addon_author" : u"Tony Malykh <[email protected]>",
# URL for the add-on documentation support
"addon_url" : "https://github.com/mltony/nvda-audio-chart",
# Documentation file name
"addon_docFileName" : "readme.html",
# Minimum NVDA version supported (e.g. "2018.3")
"addon_minimumNVDAVersion" : "2019.2.0",
# Last NVDA version supported/tested (e.g. "2018.4", ideally more recent than minimum version)
"addon_lastTestedNVDAVersion" : "2019.3.0",
# Add-on update channel (default is stable or None)
"addon_updateChannel" : None,
}


Expand All @@ -41,4 +47,3 @@
# 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.
excludedFiles = []

3 changes: 3 additions & 0 deletions manifest.ini.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ author = "{addon_author}"
url = {addon_url}
version = {addon_version}
docFileName = {addon_docFileName}
minimumNVDAVersion = {addon_minimumNVDAVersion}
lastTestedNVDAVersion = {addon_lastTestedNVDAVersion}
updateChannel = {addon_updateChannel}
39 changes: 30 additions & 9 deletions sconstruct
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import gettext
import os
import os.path
import zipfile
import sys
sys.dont_write_bytecode = True

import buildVars


def md2html(source, dest):
import markdown
lang = os.path.basename(os.path.dirname(source)).replace('_', '-')
Expand All @@ -22,7 +23,7 @@ def md2html(source, dest):
}
with codecs.open(source, "r", "utf-8") as f:
mdText = f.read()
for k, v in headerDic.iteritems():
for k, v in headerDic.items():
mdText = mdText.replace(k, v, 1)
htmlText = markdown.markdown(mdText)
with codecs.open(dest, "w", "utf-8") as f:
Expand Down Expand Up @@ -51,10 +52,25 @@ def mdTool(env):
)
env['BUILDERS']['markdown']=mdBuilder

vars = Variables()
vars.Add("version", "The version of this build", buildVars.addon_info["addon_version"])
vars.Add(BoolVariable("dev", "Whether this is a daily development version", False))
vars.Add("channel", "Update channel for this build", buildVars.addon_info["addon_updateChannel"])

env = Environment(ENV=os.environ, tools=['gettexttool', mdTool])
env = Environment(variables=vars, ENV=os.environ, tools=['gettexttool', mdTool])
env.Append(**buildVars.addon_info)

if env["dev"]:
import datetime
buildDate = datetime.datetime.now()
year, month, day = str(buildDate.year), str(buildDate.month), str(buildDate.day)
env["addon_version"] = "".join([year, month.zfill(2), day.zfill(2), "-dev"])
env["channel"] = "dev"
elif env["version"] is not None:
env["addon_version"] = env["version"]
if "channel" in env and env["channel"] is not None:
env["addon_updateChannel"] = env["channel"]

addonFile = env.File("${addon_name}-${addon_version}.nvda-addon")

def addonGenerator(target, source, env, for_signature):
Expand All @@ -67,7 +83,6 @@ def manifestGenerator(target, source, env, for_signature):
lambda target, source, env : "Generating manifest %s" % target[0])
return action


def translatedManifestGenerator(target, source, env, for_signature):
dir = os.path.abspath(os.path.join(os.path.dirname(str(source[0])), ".."))
lang = os.path.basename(dir)
Expand All @@ -90,8 +105,6 @@ def createAddonHelp(dir):
readmeTarget = env.Command(readmePath, "readme.md", Copy("$TARGET", "$SOURCE"))
env.Depends(addon, readmeTarget)



def createAddonBundleFromPath(path, dest):
""" Creates a bundle from a directory that contains an addon manifest file."""
basedir = os.path.abspath(path)
Expand All @@ -106,14 +119,21 @@ def createAddonBundleFromPath(path, dest):
return dest

def generateManifest(source, dest):
addon_info = buildVars.addon_info
addon_info["addon_version"] = env["addon_version"]
addon_info["addon_updateChannel"] = env["addon_updateChannel"]
with codecs.open(source, "r", "utf-8") as f:
manifest_template = f.read()
manifest = manifest_template.format(**buildVars.addon_info)
manifest = manifest_template.format(**addon_info)
with codecs.open(dest, "w", "utf-8") as f:
f.write(manifest)

def generateTranslatedManifest(source, language, out):
_ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[language]).ugettext
# No ugettext in Python 3.
if sys.version_info.major == 2:
_ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[language]).ugettext
else:
_ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[language]).gettext
vars = {}
for var in ("addon_summary", "addon_description"):
vars[var] = _(buildVars.addon_info[var])
Expand Down Expand Up @@ -153,7 +173,7 @@ for mdFile in env.Glob(os.path.join('addon', 'doc', '*', '*.md')):
# Pot target
i18nFiles = expandGlobs(buildVars.i18nSources)
gettextvars={
'gettext_package_bugs_address' : 'nvda-translations@freelists.org',
'gettext_package_bugs_address' : 'nvda-translations@groups.io',
'gettext_package_name' : buildVars.addon_info['addon_name'],
'gettext_package_version' : buildVars.addon_info['addon_version']
}
Expand All @@ -172,3 +192,4 @@ env.Depends(manifest, "buildVars.py")

env.Depends(addon, manifest)
env.Default(addon)
env.Clean (addon, ['.sconsign.dblite', 'addon/doc/en/'])

0 comments on commit 05872a9

Please sign in to comment.