Merge lp:~dholbach/help-app/1434415 into lp:help-app

Proposed by Daniel Holbach
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 125
Merged at revision: 123
Proposed branch: lp:~dholbach/help-app/1434415
Merge into: lp:help-app
Diff against target: 216 lines (+72/-33)
7 files modified
internals/pelicanconf.py (+2/-1)
internals/tests/test_files.py (+1/-1)
internals/tests/test_markdown.py (+24/-0)
internals/tests/test_translations.py (+2/-3)
internals/translations/build.py (+4/-2)
internals/translations/utils.py (+38/-25)
po/help.pot (+1/-1)
To merge this branch: bzr merge lp:~dholbach/help-app/1434415
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+253844@code.launchpad.net

Commit message

Fix utopic build

Description of the change

Fix utopic build

To post a comment you must log in.
lp:~dholbach/help-app/1434415 updated
122. By Daniel Holbach

add more tests

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

FAILED: Continuous integration, rev:122
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~dholbach/help-app/1434415/+merge/253844/+edit-commit-message

http://91.189.93.70:8080/job/help-app-ci/1/
Executed test runs:
    FAILURE: http://91.189.93.70:8080/job/help-app-utopic-amd64-ci/1/console
    FAILURE: http://91.189.93.70:8080/job/help-app-vivid-amd64-ci/1/console

Click here to trigger a rebuild:
http://91.189.93.70:8080/job/help-app-ci/1/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
lp:~dholbach/help-app/1434415 updated
123. By Daniel Holbach

merge from trunk, update .pot

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

A couple small comments.

review: Needs Information
lp:~dholbach/help-app/1434415 updated
124. By Daniel Holbach

merge trunk

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
lp:~dholbach/help-app/1434415 updated
125. By Daniel Holbach

merged lp:~dholbach/help-app/pep8-fixes

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'internals/local'
2=== added file 'internals/local/__init__.py'
3=== renamed file 'internals/q-and-a.py' => 'internals/local/q-and-a.py'
4=== modified file 'internals/pelicanconf.py'
5--- internals/pelicanconf.py 2015-03-19 14:23:27 +0000
6+++ internals/pelicanconf.py 2015-03-25 07:39:44 +0000
7@@ -8,6 +8,7 @@
8
9 TOP_LEVEL_DIR = '../'
10 PATH = TOP_LEVEL_DIR+'content/'
11+INTERNALS_DIR = TOP_LEVEL_DIR+'internals/'
12 TRANSLATIONS_DIR = TOP_LEVEL_DIR+'po/'
13
14 TIMEZONE = 'Europe/Paris'
15@@ -46,7 +47,7 @@
16 TAG_SAVE_AS = ''
17 THEME = TOP_LEVEL_DIR+'static/themes/app/'
18
19-MD_EXTENSIONS = ['q-and-a', 'attr_list', 'toc']
20+MD_EXTENSIONS = ['local.q-and-a', 'attr_list', 'toc']
21
22 META_TAGS = [
23 '[TOC]',
24
25=== modified file 'internals/tests/test_files.py'
26--- internals/tests/test_files.py 2015-03-19 13:37:00 +0000
27+++ internals/tests/test_files.py 2015-03-25 07:39:44 +0000
28@@ -26,6 +26,6 @@
29
30 def test_markdown_files(self):
31 fns = self.translations.documents.find_docs()
32- checked_fns = [utils.verify_markdown_file(fn)
33+ checked_fns = [utils.verify_file_type(fn)
34 for fn in fns]
35 self.assertEqual(len(fns), checked_fns.count(True))
36
37=== added file 'internals/tests/test_markdown.py'
38--- internals/tests/test_markdown.py 1970-01-01 00:00:00 +0000
39+++ internals/tests/test_markdown.py 2015-03-25 07:39:44 +0000
40@@ -0,0 +1,24 @@
41+from unittest import TestCase
42+
43+from translations.build import Documents
44+from translations import utils
45+from pelicanconf import MD_EXTENSIONS
46+
47+
48+class HelpTestCase(TestCase):
49+ def __init__(self, *args):
50+ TestCase.__init__(self, *args)
51+
52+ def test_load_extensions(self):
53+ md = utils.Markdown()
54+ for ext in MD_EXTENSIONS:
55+ self.assertTrue(ext in md.md.treeprocessors or
56+ ext in [q.__module__ for q
57+ in md.md.registeredExtensions])
58+
59+ def test_convert_all_docs(self):
60+ md = utils.Markdown()
61+ docs = Documents()
62+ self.assertEqual(len(docs.docs),
63+ len([md.can_convert_md_file(fn) for fn
64+ in docs.docs]))
65
66=== modified file 'internals/tests/test_translations.py'
67--- internals/tests/test_translations.py 2015-03-24 12:45:06 +0000
68+++ internals/tests/test_translations.py 2015-03-25 07:39:44 +0000
69@@ -34,11 +34,10 @@
70
71 def test_markup_in_po_or_pot_files(self):
72 po = self.translations.po
73- files = [ po.pot_file_ob ]
74+ files = [po.pot_file_ob]
75 for po_fn in po.langs:
76 po.load_pofile(po_fn)
77- files += [ po.langs[po_fn]['pofile'] ]
78+ files += [po.langs[po_fn]['pofile']]
79 for po_file in files:
80 for tag in HIDE_FROM_POT:
81 self.assertEqual(po_file.find_in_msgid(tag), [])
82-
83
84=== modified file 'internals/translations/build.py'
85--- internals/translations/build.py 2015-03-24 10:59:36 +0000
86+++ internals/translations/build.py 2015-03-25 07:39:44 +0000
87@@ -9,10 +9,11 @@
88 from translations.utils import (
89 find_bcp47_code,
90 full_path,
91+ Markdown,
92 normalise_path,
93 require,
94 use_top_level_dir,
95- verify_markdown_file,
96+ verify_file_type,
97 )
98
99 from translations.po4a import PO4A
100@@ -233,8 +234,9 @@
101
102 class Documents(object):
103 def __init__(self):
104+ md = Markdown()
105 self.docs = [fn for fn in self.find_docs()
106- if verify_markdown_file(fn)]
107+ if verify_file_type(fn) and md.can_convert_md_file(fn)]
108
109 def find_docs(self):
110 docs = []
111
112=== modified file 'internals/translations/utils.py'
113--- internals/translations/utils.py 2015-03-19 13:22:42 +0000
114+++ internals/translations/utils.py 2015-03-25 07:39:44 +0000
115@@ -1,4 +1,3 @@
116-import codecs
117 import os
118 import sys
119 import tempfile
120@@ -20,7 +19,9 @@
121 require('python3-markdown')
122
123 from pelicanconf import (
124+ INTERNALS_DIR,
125 MD_EXTENSIONS,
126+ PATH,
127 TOP_LEVEL_DIR,
128 )
129
130@@ -44,37 +45,49 @@
131 return os.path.abspath(os.path.join(TOP_LEVEL_DIR, path))
132
133
134-def use_top_level_dir():
135+def use_path(path):
136 pwd = os.getcwd()
137- os.chdir(TOP_LEVEL_DIR)
138+ os.chdir(path)
139 return pwd
140
141
142-def _temp_write_markdown(fn):
143- (ret, tmp) = tempfile.mkstemp()
144- length = 0
145- ret = True
146- try:
147- markdown.markdownFromFile(fn, extensions=MD_EXTENSIONS, output=tmp)
148- except:
149- print('Could not convert "%s" into Markdown.' % fn)
150- ret = False
151- if ret:
152- length = len(codecs.open(tmp, 'r', 'utf-8').read())
153- os.remove(tmp)
154- return (ret, length)
155-
156-
157-def verify_markdown_file(fn):
158+def use_top_level_dir():
159+ return use_path(TOP_LEVEL_DIR)
160+
161+
162+def use_docs_path():
163+ return use_path(PATH)
164+
165+
166+def use_internals_dir():
167+ return use_path(INTERNALS_DIR)
168+
169+
170+class Markdown(object):
171+ def __init__(self):
172+ pwd = use_internals_dir()
173+ try:
174+ self.md = markdown.Markdown(extensions=MD_EXTENSIONS)
175+ except ImportError:
176+ os.chdir(pwd)
177+ print('Could not load all markdown extensions.')
178+ sys.exit(1)
179+ os.chdir(pwd)
180+
181+ def can_convert_md_file(self, fn):
182+ (ret, tmp) = tempfile.mkstemp()
183+ pwd = use_top_level_dir()
184+ res = self.md.convertFile(fn, tmp, 'utf-8')
185+ os.remove(tmp)
186+ os.chdir(pwd)
187+ return len(res.lines) > 0
188+
189+
190+def verify_file_type(fn):
191 ms = magic.open(magic.MAGIC_NONE)
192 ms.load()
193 fn = full_path(fn)
194- if ms.file(fn) not in MD_MAGIC_FILE_TYPES:
195- return False
196- (ret, length) = _temp_write_markdown(fn)
197- if not length:
198- return False
199- return ret
200+ return ms.file(fn) in MD_MAGIC_FILE_TYPES
201
202
203 def find_bcp47_code(gettext_code):
204
205=== modified file 'po/help.pot'
206--- po/help.pot 2015-03-24 08:35:50 +0000
207+++ po/help.pot 2015-03-25 07:39:44 +0000
208@@ -7,7 +7,7 @@
209 msgid ""
210 msgstr ""
211 "Project-Id-Version: PACKAGE VERSION\n"
212-"POT-Creation-Date: 2015-03-24 09:35+0100\n"
213+"POT-Creation-Date: 2015-03-24 14:13+0100\n"
214 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
215 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
216 "Language-Team: LANGUAGE <LL@li.org>\n"

Subscribers

People subscribed via source and target branches