Skip to content

Commit

Permalink
Fix string literal imports w/ periods (google#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
trotterdylan authored Aug 22, 2017
1 parent 50cbc8b commit 2c8ff4b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tools/grumprun
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,20 @@ def main(args):
# Make sure traceback is available in all Python binaries.
names.add('traceback')
go_main = os.path.join(workdir, 'main.go')
package = '__python__/' + modname.replace('.', '/')
imports = ''.join('\t_ "__python__/' + name.replace('.', '/') + '"\n'
for name in names)
package = _package_name(modname)
imports = ''.join('\t_ "' + _package_name(name) + '"\n' for name in names)
with open(go_main, 'w') as f:
f.write(module_tmpl.substitute(package=package, imports=imports))
return subprocess.Popen('go run ' + go_main, shell=True).wait()
finally:
shutil.rmtree(workdir)


def _package_name(modname):
if modname.startswith('__go__/'):
return '__python__/' + modname
return '__python__/' + modname.replace('.', '/')


if __name__ == '__main__':
sys.exit(main(parser.parse_args()))

0 comments on commit 2c8ff4b

Please sign in to comment.