Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Revert "Merge pull request #1597 from erikvold/661083"
Browse files Browse the repository at this point in the history
This reverts commit 2acf356, reversing
changes made to cc3242d.

Conflicts:
	python-lib/cuddlefish/prefs.py
	test/addons/l10n-manifest/locale/en-US.properties
	test/addons/l10n-manifest/package.json
  • Loading branch information
erikvold committed Jan 20, 2015
1 parent 4711314 commit 0ccba4c
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 166 deletions.
3 changes: 1 addition & 2 deletions python-lib/cuddlefish/__init__.py
Expand Up @@ -861,8 +861,7 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
jid=jid,
update_url=options.update_url,
bootstrap=True,
enable_mobile=options.enable_mobile,
harness_options=harness_options)
enable_mobile=options.enable_mobile)

if command == "xpi" and options.update_link:
if not options.update_link.startswith("https"):
Expand Down
65 changes: 12 additions & 53 deletions python-lib/cuddlefish/rdf.py
Expand Up @@ -5,8 +5,6 @@
import os
import xml.dom.minidom
import StringIO
import codecs
import glob

RDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
EM_NS = "http://www.mozilla.org/2004/em-rdf#"
Expand All @@ -22,10 +20,9 @@ def __str__(self):
# have .encoding hardwired to "ascii" and put only bytes in
# the backing store, so we can't use them here).
#
# The encoding= argument to dom.writexml() merely sets the
# XML header's encoding= attribute. It still writes unencoded
# unicode to the output file, so we have to encode it for
# real afterwards.
# The encoding= argument to dom.writexml() merely sets the XML header's
# encoding= attribute. It still writes unencoded unicode to the output file,
# so we have to encode it for real afterwards.
#
# Also see: https://bugzilla.mozilla.org/show_bug.cgi?id=567660

Expand Down Expand Up @@ -115,12 +112,7 @@ def remove(self, property):

return True;

def add_node(self, node):
top = self.dom.documentElement.getElementsByTagName("Description")[0];
top.appendChild(node)


def gen_manifest(template_root_dir, target_cfg, jid, harness_options={},
def gen_manifest(template_root_dir, target_cfg, jid,
update_url=None, bootstrap=True, enable_mobile=False):
install_rdf = os.path.join(template_root_dir, "install.rdf")
manifest = RDFManifest(install_rdf)
Expand All @@ -129,51 +121,13 @@ def gen_manifest(template_root_dir, target_cfg, jid, harness_options={},
manifest.set("em:id", jid)
manifest.set("em:version",
target_cfg.get('version', '1.0'))

if "locale" in harness_options:
# addon_title -> <em:name>
# addon_author -> <em:creator>
# addon_description -> <em:description>
# addon_homepageURL -> <em:homepageURL>
localizable_in = ["title", "author", "description", "homepage"]
localized_out = ["name", "creator", "description", "homepageURL"]
for lang in harness_options["locale"]:
desc = dom.createElement("Description")

for value_in in localizable_in:
key_in = "extensions." + target_cfg.get("id", "") + "." + value_in
tag_out = localized_out[localizable_in.index(value_in)]

if key_in in harness_options["locale"][lang]:
elem = dom.createElement("em:" + tag_out)
elem_value = harness_options["locale"][lang][key_in]
elem.appendChild(dom.createTextNode(elem_value))
desc.appendChild(elem)

# Don't add language if no localizeable field was localized
if desc.hasChildNodes():
locale = dom.createElement("em:locale")
locale.appendChild(dom.createTextNode(lang))
desc.appendChild(locale)

localized = dom.createElement("em:localized")
localized.appendChild(desc)
manifest.add_node(localized)

manifest.set("em:name",
target_cfg.get('title', target_cfg.get('fullName', target_cfg['name'])))
manifest.set("em:description",
target_cfg.get("description", ""))
manifest.set("em:creator",
target_cfg.get("author", ""))

if target_cfg.get("homepage"):
manifest.set("em:homepageURL", target_cfg.get("homepage"))
else:
manifest.remove("em:homepageURL")

manifest.set("em:bootstrap", str(bootstrap).lower())

# XPIs remain packed by default, but package.json can override that. The
# RDF format accepts "true" as True, anything else as False. We expect
# booleans in the .json file, not strings.
Expand All @@ -182,7 +136,7 @@ def gen_manifest(template_root_dir, target_cfg, jid, harness_options={},
for translator in target_cfg.get("translators", [ ]):
elem = dom.createElement("em:translator");
elem.appendChild(dom.createTextNode(translator))
manifest.add_node(elem)
dom.documentElement.getElementsByTagName("Description")[0].appendChild(elem)

for developer in target_cfg.get("developers", [ ]):
elem = dom.createElement("em:developer");
Expand All @@ -192,7 +146,7 @@ def gen_manifest(template_root_dir, target_cfg, jid, harness_options={},
for contributor in target_cfg.get("contributors", [ ]):
elem = dom.createElement("em:contributor");
elem.appendChild(dom.createTextNode(contributor))
manifest.add_node(elem)
dom.documentElement.getElementsByTagName("Description")[0].appendChild(elem)

if update_url:
manifest.set("em:updateURL", update_url)
Expand All @@ -215,7 +169,7 @@ def gen_manifest(template_root_dir, target_cfg, jid, harness_options={},

if enable_mobile:
target_app = dom.createElement("em:targetApplication")
manifest.add_node(target_app)
dom.documentElement.getElementsByTagName("Description")[0].appendChild(target_app)

ta_desc = dom.createElement("Description")
target_app.appendChild(ta_desc)
Expand All @@ -232,6 +186,11 @@ def gen_manifest(template_root_dir, target_cfg, jid, harness_options={},
elem.appendChild(dom.createTextNode("30.0a1"))
ta_desc.appendChild(elem)

if target_cfg.get("homepage"):
manifest.set("em:homepageURL", target_cfg.get("homepage"))
else:
manifest.remove("em:homepageURL")

return manifest

if __name__ == "__main__":
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Empty file modified python-lib/cuddlefish/tests/test_linker.py 100644 → 100755
Empty file.
48 changes: 1 addition & 47 deletions python-lib/cuddlefish/tests/test_rdf.py
Expand Up @@ -6,7 +6,7 @@
import xml.dom.minidom
import os.path

from cuddlefish import rdf, packaging, property_parser
from cuddlefish import rdf, packaging

parent = os.path.dirname
test_dir = parent(os.path.abspath(__file__))
Expand Down Expand Up @@ -49,52 +49,6 @@ def testTitle(self):
self.failUnlessEqual(m.get('em:name'), 'a long ' + n)
self.failUnlessIn('<em:name>a long ' + n + '</em:name>', str(m), n)

def testLocalization(self):
# addon_title -> <em:name>
# addon_author -> <em:creator>
# addon_description -> <em:description>
# addon_homepageURL -> <em:homepageURL>
localizable_in = ["title", "author", "description", "homepage"]
localized_out = ["name", "creator", "description", "homepageURL"]

basedir = os.path.join(test_dir, "bug-661083-files/packages")
for n in ["noLocalization", "twoLanguages"]:
harness_options = { "locale" : {} }
pkgdir = os.path.join(basedir, n)
localedir = os.path.join(pkgdir, "locale")
files = os.listdir(localedir)

for file in files:
filepath = os.path.join(localedir, file)
if os.path.isfile(filepath) and file.endswith(".properties"):
language = file[:-len(".properties")]
try:
parsed_file = property_parser.parse_file(filepath)
except property_parser.MalformedLocaleFileError, msg:
self.fail(msg)

harness_options["locale"][language] = parsed_file

cfg = packaging.get_config_in_dir(pkgdir)
m = rdf.gen_manifest(template_dir, cfg, 'JID', harness_options)

if n == "noLocalization":
self.failIf("<em:locale>" in str(m))
continue

for lang in harness_options["locale"]:
rdfstr = str(m)
node = "<em:locale>" + lang + "</em:locale>"
self.failUnlessIn(node, rdfstr, n)

for value_in in localizable_in:
key_in = "extensions." + m.get('em:id') + "." + value_in
tag_out = localized_out[localizable_in.index(value_in)]
if key_in in harness_options["locale"][lang]:
# E.g. "<em:creator>author-en-US</em:creator>"
node = "<em:" + tag_out + ">" + value_in + "-" + lang \
+ "</em:" + tag_out + ">"
self.failUnlessIn(node , rdfstr, n)

if __name__ == '__main__':
unittest.main()
4 changes: 0 additions & 4 deletions test/addons/l10n-manifest/locale/en-US.properties

This file was deleted.

17 changes: 0 additions & 17 deletions test/addons/l10n-manifest/main.js

This file was deleted.

11 changes: 0 additions & 11 deletions test/addons/l10n-manifest/package.json

This file was deleted.

0 comments on commit 0ccba4c

Please sign in to comment.