Skip to content

Commit e8833b5

Browse files
authored
Merge pull request #2209 from boegel/escape_formatting_char
fix crash during module generation when '%' character is used in description
2 parents 4825b5b + c3c355f commit e8833b5

15 files changed

Lines changed: 34 additions & 30 deletions

easybuild/tools/module_generator.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,15 @@ def get_description(self, conflict=True):
424424
"""
425425
Generate a description.
426426
"""
427-
lines = [
427+
txt = '\n'.join([
428428
"proc ModulesHelp { } {",
429429
" puts stderr {%s" % self._generate_help_text(),
430430
" }",
431431
'}',
432432
'',
433+
])
434+
435+
lines = [
433436
'%(whatis_lines)s',
434437
'',
435438
"set root %(installdir)s",
@@ -447,10 +450,9 @@ def get_description(self, conflict=True):
447450
# - 'conflict Compiler/GCC/4.8.2/OpenMPI' for 'Compiler/GCC/4.8.2/OpenMPI/1.6.4'
448451
lines.extend(['', "conflict %s" % os.path.dirname(self.app.short_mod_name)])
449452

450-
txt = '\n'.join(lines + ['']) % {
453+
txt += '\n'.join([''] + lines + ['']) % {
451454
'name': self.app.name,
452455
'version': self.app.version,
453-
'description': self.app.cfg['description'],
454456
'whatis_lines': '\n'.join(["module-whatis {%s}" % line for line in self._generate_whatis_lines()]),
455457
'installdir': self.app.installdir,
456458
}
@@ -672,10 +674,13 @@ def get_description(self, conflict=True):
672674
"""
673675
Generate a description.
674676
"""
675-
lines = [
677+
txt = '\n'.join([
676678
'help([[%s' % self._generate_help_text(),
677679
']])',
678680
'',
681+
])
682+
683+
lines = [
679684
"%(whatis_lines)s",
680685
'',
681686
'local root = "%(installdir)s"',
@@ -688,10 +693,9 @@ def get_description(self, conflict=True):
688693
# conflict on 'name' part of module name (excluding version part at the end)
689694
lines.extend(['', 'conflict("%s")' % os.path.dirname(self.app.short_mod_name)])
690695

691-
txt = '\n'.join(lines + ['']) % {
696+
txt += '\n'.join([''] + lines + ['']) % {
692697
'name': self.app.name,
693698
'version': self.app.version,
694-
'description': self.app.cfg['description'],
695699
'whatis_lines': '\n'.join(["whatis([[%s]])" % line for line in self._generate_whatis_lines()]),
696700
'installdir': self.app.installdir,
697701
'homepage': self.app.cfg['homepage'],

test/framework/docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def test_list_software(self):
237237
expected = [
238238
'* toy',
239239
'',
240-
'Toy C program.',
240+
'Toy C program, 100% toy.',
241241
'',
242242
'homepage: http://hpcugent.github.com/easybuild',
243243
'',
@@ -256,7 +256,7 @@ def test_list_software(self):
256256
'*toy*',
257257
'+++++',
258258
'',
259-
'Toy C program.',
259+
'Toy C program, 100% toy.',
260260
'',
261261
'*homepage*: http://hpcugent.github.com/easybuild',
262262
'',

test/framework/easyconfig.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def test_exts_list(self):
313313
' "patches": ["toy-0.0.eb"],', # dummy patch to avoid downloading fail
314314
' "checksums": [',
315315
' "9e9485921c6afe15f62aedfead2c8f6e",', # MD5 checksum for source (gzip-1.4.eb)
316-
' "fad34da3432ee2fd4d6554b86c8df4bf",', # MD5 checksum for patch (toy-0.0.eb)
316+
' "8ebc2c32692be9ee61eadc5d650cd288",', # MD5 checksum for patch (toy-0.0.eb)
317317
' ],',
318318
' }),',
319319
']',
@@ -979,7 +979,7 @@ def test_fetch_parameters_from_easyconfig(self):
979979
self.assertEqual(name, correct_name)
980980
self.assertEqual(easyblock, correct_easyblock)
981981

982-
self.assertEqual(fetch_parameters_from_easyconfig(read_file(toy_ec_file), ['description'])[0], "Toy C program.")
982+
self.assertEqual(fetch_parameters_from_easyconfig(read_file(toy_ec_file), ['description'])[0], "Toy C program, 100% toy.")
983983

984984
res = fetch_parameters_from_easyconfig("easyblock = 'ConfigureMake' # test comment", ['easyblock'])
985985
self.assertEqual(res, ['ConfigureMake'])
@@ -1313,7 +1313,7 @@ def test_update(self):
13131313
self.assertEqual(ec['unpack_options'].strip(), '--strip-components=1')
13141314

13151315
ec.update('description', "- just a test")
1316-
self.assertEqual(ec['description'].strip(), "Toy C program. - just a test")
1316+
self.assertEqual(ec['description'].strip(), "Toy C program, 100% toy. - just a test")
13171317

13181318
# spaces in between multiple updates for stirng values
13191319
ec.update('configopts', 'CC="$CC"')

test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-deps.eb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version = '0.0'
33
versionsuffix = '-deps'
44

55
homepage = 'http://hpcugent.github.com/easybuild'
6-
description = "Toy C program."
6+
description = "Toy C program, 100% toy."
77

88
toolchain = {'name': 'dummy', 'version': 'dummy'}
99

test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-gompi-1.3.12-test.eb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version = '0.0'
33
versionsuffix = '-test'
44

55
homepage = 'http://hpcugent.github.com/easybuild'
6-
description = "Toy C program."
6+
description = "Toy C program, 100% toy."
77

88
toolchain = {'name': 'gompi', 'version': '1.3.12'}
99
toolchainopts = {'pic': True, 'opt': True, 'optarch': True}

test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-iter.eb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version = '0.0'
33
versionsuffix = '-iter'
44

55
homepage = 'http://hpcugent.github.com/easybuild'
6-
description = "Toy C program."
6+
description = "Toy C program, 100% toy."
77

88
toolchain = {'name': 'dummy', 'version': 'dummy'}
99

test/framework/easyconfigs/test_ecs/t/toy/toy-0.0-multiple.eb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = '0.0'
44
versionsuffix = '-multiple'
55

66
homepage = 'http://hpcugent.github.com/easybuild'
7-
description = "Toy C program."
7+
description = "Toy C program, 100% toy."
88

99
toolchain = {'name': 'dummy', 'version': 'dummy'}
1010

test/framework/easyconfigs/test_ecs/t/toy/toy-0.0.eb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = 'toy'
22
version = '0.0'
33

44
homepage = 'http://hpcugent.github.com/easybuild'
5-
description = "Toy C program."
5+
description = "Toy C program, 100% toy."
66

77
toolchain = {'name': 'dummy', 'version': 'dummy'}
88

test/framework/easyconfigs/v2.0/toy-with-sections.eb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ docstring test
88
name = "toy"
99

1010
homepage = 'http://hpcugent.github.com/easybuild'
11-
description = "Toy C program."
11+
description = "Toy C program, 100% toy."
1212
docurls = ["https://github.com/hpcugent/easybuild/wiki"]
1313

1414
software_license = GPLv2

test/framework/easyconfigs/v2.0/toy.eb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ docstring test
88
name = "toy"
99

1010
homepage = 'http://hpcugent.github.com/easybuild'
11-
description = "Toy C program."
11+
description = "Toy C program, 100% toy."
1212
docurls = ["https://github.com/hpcugent/easybuild/wiki"]
1313

1414
software_license = GPLv2

0 commit comments

Comments
 (0)