Skip to content

Commit a4110a8

Browse files
committed
Fix project_init command for bsdtar.
Closes #46.
1 parent aa80141 commit a4110a8

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

planemo/commands/cmd_project_init.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
"""
22
"""
33
import os
4+
import tempfile
5+
import shutil
46

57
import click
68

79
from planemo.cli import pass_context
810
from planemo import options
9-
from planemo.io import warn, untar_to
11+
from planemo.io import (
12+
warn,
13+
untar_to,
14+
shell
15+
)
1016

1117
SOURCE_HOST = "https://codeload.github.com"
1218
DOWNLOAD_URL = "%s/galaxyproject/planemo/tar.gz/master" % SOURCE_HOST
13-
UNTAR_FILTER = "--strip-components=3 --wildcards --no-anchored '%s/**'"
14-
UNTAR_ARGS = "-C %s -zxvf - " + UNTAR_FILTER
19+
UNTAR_FILTER = "--strip-components=2"
20+
UNTAR_ARGS = " -C %s -zxf - " + UNTAR_FILTER
1521

1622

1723
@click.command("project_init")
@@ -31,5 +37,11 @@ def cli(ctx, path, template=None, **kwds):
3137
if template is None:
3238
return
3339

34-
untar_args = UNTAR_ARGS % (path, template)
35-
untar_to(DOWNLOAD_URL, path, untar_args)
40+
tempdir = tempfile.mkdtemp()
41+
try:
42+
untar_args = UNTAR_ARGS % (tempdir)
43+
untar_to(DOWNLOAD_URL, tempdir, untar_args)
44+
shell("ls '%s'" % (tempdir))
45+
shell("mv '%s/%s'/* '%s'" % (tempdir, template, path))
46+
finally:
47+
shutil.rmtree(tempdir)

0 commit comments

Comments
 (0)