Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 2c8ff4b

Browse files
authored
Fix string literal imports w/ periods (#377)
1 parent 50cbc8b commit 2c8ff4b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tools/grumprun

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,20 @@ def main(args):
9393
# Make sure traceback is available in all Python binaries.
9494
names.add('traceback')
9595
go_main = os.path.join(workdir, 'main.go')
96-
package = '__python__/' + modname.replace('.', '/')
97-
imports = ''.join('\t_ "__python__/' + name.replace('.', '/') + '"\n'
98-
for name in names)
96+
package = _package_name(modname)
97+
imports = ''.join('\t_ "' + _package_name(name) + '"\n' for name in names)
9998
with open(go_main, 'w') as f:
10099
f.write(module_tmpl.substitute(package=package, imports=imports))
101100
return subprocess.Popen('go run ' + go_main, shell=True).wait()
102101
finally:
103102
shutil.rmtree(workdir)
104103

105104

105+
def _package_name(modname):
106+
if modname.startswith('__go__/'):
107+
return '__python__/' + modname
108+
return '__python__/' + modname.replace('.', '/')
109+
110+
106111
if __name__ == '__main__':
107112
sys.exit(main(parser.parse_args()))

0 commit comments

Comments
 (0)