Merge lp:~james-w/linaro-image-tools/fix-package-regex into lp:linaro-image-tools/11.11

Proposed by James Westby
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: 142
Merged at revision: 81
Proposed branch: lp:~james-w/linaro-image-tools/fix-package-regex
Merge into: lp:linaro-image-tools/11.11
Prerequisite: lp:~james-w/linaro-image-tools/add-other-relations-to-packages-file
Diff against target: 91 lines (+27/-12)
4 files modified
hwpack/config.py (+1/-1)
hwpack/tests/test_config.py (+8/-0)
hwpack/tests/test_script.py (+8/-4)
linaro-hwpack-create (+10/-7)
To merge this branch: bzr merge lp:~james-w/linaro-image-tools/fix-package-regex
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle (community) Approve
Zygmunt Krynicki (community) Needs Information
Review via email: mp+35285@code.launchpad.net

Description of the change

Hi,

A small change to correct a typo in the name regex that was being
used.

Thanks,

James

To post a comment you must log in.
141. By James Westby

Merged add-other-relations-to-packages-file into fix-package-regex.

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

9 + NAME_REGEX = "[a-z0-9][a-z0-9+-.]+$"
                                        ^
This seems wrong:
Look at the part underlined with ^, it is a range expression from '+' to '.'
Is that what you wanted?

review: Needs Information
Revision history for this message
James Westby (james-w) wrote :

Good catch, thanks!

It happens to pass the test as "-" is one of the characters
between "+" and "." in ASCII/unicode.

Thanks,

James

142. By James Westby

Specify a literal "-" in the regex. Thanks Zygmunt.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Looks fine. I think I'd double up the backslash or use a r'..' string, but it's not required.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hwpack/config.py'
--- hwpack/config.py 2010-09-02 19:12:53 +0000
+++ hwpack/config.py 2010-09-13 21:19:07 +0000
@@ -11,7 +11,7 @@
1111
12 MAIN_SECTION = "hwpack"12 MAIN_SECTION = "hwpack"
13 NAME_KEY = "name"13 NAME_KEY = "name"
14 NAME_REGEX = "[a-z0-9][a-z0-9+0.]+"14 NAME_REGEX = "[a-z0-9][a-z0-9+\-.]+$"
15 INCLUDE_DEBS_KEY = "include-debs"15 INCLUDE_DEBS_KEY = "include-debs"
16 SUPPORT_KEY = "support"16 SUPPORT_KEY = "support"
17 SOURCES_ENTRY_KEY = "sources-entry"17 SOURCES_ENTRY_KEY = "sources-entry"
1818
=== modified file 'hwpack/tests/test_config.py'
--- hwpack/tests/test_config.py 2010-09-02 19:08:32 +0000
+++ hwpack/tests/test_config.py 2010-09-13 21:19:07 +0000
@@ -132,6 +132,14 @@
132 + "\n[ubuntu]\nsources-entry = foo bar\n")132 + "\n[ubuntu]\nsources-entry = foo bar\n")
133 self.assertEqual(None, config.validate())133 self.assertEqual(None, config.validate())
134134
135 def test_validate_valid_config_with_dash_in_package_name(self):
136 config = self.get_config(
137 "[hwpack]\nname = ahwpack\n"
138 "packages = u-boot\n"
139 "architectures = armel\n\n"
140 "[ubuntu]\nsources-entry = foo bar\n")
141 self.assertEqual(None, config.validate())
142
135 def test_name(self):143 def test_name(self):
136 config = self.get_config(144 config = self.get_config(
137 "[hwpack]\nname = ahwpack\npackages = foo\n"145 "[hwpack]\nname = ahwpack\npackages = foo\n"
138146
=== modified file 'hwpack/tests/test_script.py'
--- hwpack/tests/test_script.py 2010-09-13 21:19:07 +0000
+++ hwpack/tests/test_script.py 2010-09-13 21:19:07 +0000
@@ -55,13 +55,17 @@
55 self.assertEqual("", stdout)55 self.assertEqual("", stdout)
5656
57 def test_errors_on_missing_configfile_argument(self):57 def test_errors_on_missing_configfile_argument(self):
58 stdout, stderr = self.run_script([], expected_returncode=1)58 stdout, stderr = self.run_script([], expected_returncode=2)
59 self.assertEqual("Requires arguments CONFIG_FILE VERSION\n", stderr)59 self.assertEqual(
60 "usage: linaro-hwpack-create [-h] CONFIG_FILE VERSION\n"
61 "linaro-hwpack-create: error: too few arguments\n", stderr)
60 self.assertEqual("", stdout)62 self.assertEqual("", stdout)
6163
62 def test_errors_on_missing_version_argument(self):64 def test_errors_on_missing_version_argument(self):
63 stdout, stderr = self.run_script(["somefile"], expected_returncode=1)65 stdout, stderr = self.run_script(["somefile"], expected_returncode=2)
64 self.assertEqual("Requires arguments CONFIG_FILE VERSION\n", stderr)66 self.assertEqual(
67 "usage: linaro-hwpack-create [-h] CONFIG_FILE VERSION\n"
68 "linaro-hwpack-create: error: too few arguments\n", stderr)
65 self.assertEqual("", stdout)69 self.assertEqual("", stdout)
6670
67 def test_builds_a_hwpack(self):71 def test_builds_a_hwpack(self):
6872
=== modified file 'linaro-hwpack-create'
--- linaro-hwpack-create 2010-09-13 21:19:07 +0000
+++ linaro-hwpack-create 2010-09-13 21:19:07 +0000
@@ -1,19 +1,22 @@
1#!/usr/bin/python1#!/usr/bin/python
22
3from optparse import OptionParser3import argparse
4import sys4import sys
55
6from hwpack.builder import ConfigFileMissing, HardwarePackBuilder6from hwpack.builder import ConfigFileMissing, HardwarePackBuilder
77
88
9if __name__ == '__main__':9if __name__ == '__main__':
10 parser = OptionParser()10 parser = argparse.ArgumentParser()
11 opts, args = parser.parse_args()11 parser.add_argument(
12 if len(args) < 2:12 "CONFIG_FILE",
13 sys.stderr.write("Requires arguments CONFIG_FILE VERSION\n")13 help="The configuration file to take the hardware pack information "
14 sys.exit(1)14 "from.")
15 parser.add_argument(
16 "VERSION", help="The version of the hardware pack to create.")
17 args = parser.parse_args()
15 try:18 try:
16 builder = HardwarePackBuilder(args[0], args[1])19 builder = HardwarePackBuilder(args.CONFIG_FILE, args.VERSION)
17 except ConfigFileMissing, e:20 except ConfigFileMissing, e:
18 sys.stderr.write(str(e) + "\n")21 sys.stderr.write(str(e) + "\n")
19 sys.exit(1)22 sys.exit(1)

Subscribers

People subscribed via source and target branches