Skip to content

Commit e62565d

Browse files
committed
Refactor and Rename pyfinder [#151740582]
1 parent cd726b1 commit e62565d

5 files changed

Lines changed: 26 additions & 34 deletions

File tree

src/python/finalize/cli/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"os"
77
"python/finalize"
88
_ "python/hooks"
9-
"python/manage_py_finder"
9+
"python/pyfinder"
1010
"time"
1111

1212
"github.com/cloudfoundry/libbuildpack"
@@ -48,7 +48,7 @@ func main() {
4848
Log: logger,
4949
Logfile: logfile,
5050
Command: &libbuildpack.Command{},
51-
ManagePyFinder: manage_py_finder.ManagePyFinder{},
51+
ManagePyFinder: pyfinder.ManagePyFinder{},
5252
}
5353

5454
if err := finalize.Run(&f); err != nil {

src/python/manage_py_finder/manage_py_finder.go

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package pyfinder
2+
3+
import (
4+
"fmt"
5+
"path/filepath"
6+
)
7+
8+
type ManagePyFinder struct{}
9+
10+
func (m ManagePyFinder) FindManagePy(dir string) (string, error) {
11+
for _, glob := range []string{"manage.py", "*/manage.py", "*/*/manage.py"} {
12+
if matches, err := filepath.Glob(filepath.Join(dir, glob)); err != nil {
13+
return "", fmt.Errorf("Finding %s: %v", glob, err)
14+
} else if len(matches) > 0 {
15+
return matches[0], nil
16+
}
17+
}
18+
19+
return "", fmt.Errorf("manage.py not found!")
20+
}

src/python/manage_py_finder/manage_py_finder_suite_test.go renamed to src/python/pyfinder/manage_py_finder_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package manage_py_finder_test
1+
package pyfinder_test
22

33
import (
44
. "github.com/onsi/ginkgo"

src/python/manage_py_finder/manage_py_finder_test.go renamed to src/python/pyfinder/manage_py_finder_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package manage_py_finder_test
1+
package pyfinder_test
22

33
import (
44
"io/ioutil"
55
"os"
66
"path/filepath"
7-
. "python/manage_py_finder"
7+
. "python/pyfinder"
88

99
. "github.com/onsi/ginkgo"
1010
. "github.com/onsi/gomega"
@@ -18,7 +18,7 @@ var _ = Describe("ManagePyFinder", func() {
1818
)
1919

2020
BeforeEach(func() {
21-
tempDir, err = ioutil.TempDir("", "manage_py_finder")
21+
tempDir, err = ioutil.TempDir("", "pyfinder")
2222
Expect(err).NotTo(HaveOccurred())
2323
finder = ManagePyFinder{}
2424
})

0 commit comments

Comments
 (0)