Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sam ls --script #571

Closed
fabiencastan opened this issue Aug 8, 2016 · 9 comments
Closed

sam ls --script #571

fabiencastan opened this issue Aug 8, 2016 · 9 comments

Comments

@fabiencastan
Copy link
Member

fabiencastan commented Aug 8, 2016

> sam ls -R --script
./folder    
|__ ./file.####.exr     [1:596] 596 files

Instead of

> sam ls -R --script
./folder/file.####.exr  [1:596] 596 files

--relative-path has no impact.

> sam ls * --script
./file.####.exr     [1:596] 596 files
./file.####.exr     [1:596] 596 files

In that case the folder is not printed.

Tested with v0.13.0.

@cchampet
Copy link
Member

cchampet commented Aug 18, 2016

After this PR:

sam ls dir -R --script
folder    
file.####.exr     [1:596] 596 files
sam ls dir -R --script --relative-path
folder    
folder/file.####.exr     [1:596] 596 files

Still a problem with the --relative-path option when there is no 'dir' indicated in the command line.

@fabiencastan
Copy link
Member Author

great

@cchampet
Copy link
Member

And the bug of the relative-path explained above is fixed with the following commit: e5b8a06

@fabiencastan
Copy link
Member Author

Does it still work if the user provides "." in input?
Or maybe we need to apply os.path.abspath on the input?

@cchampet
Copy link
Member

It still works if the user provides "." in input.
os.path.abspath('.') and os.getcwd() produce the same result so it does not change anything.

@fabiencastan
Copy link
Member Author

fabiencastan commented Aug 18, 2016

No, I mean:

        # translate user inputs to a list of InputToBrowse
        inputsToBrowse = []
        for inputPath in args.inputs:
            # if the input is a directory, add it and continue
            if os.path.isdir(inputPath):
                inputsToBrowse.append(InputToBrowse(inputPath)) ///<< here the input from the user can be "."
                continue
            # else split the input to a path and a filename
            subPath = os.path.dirname(inputPath)
            if not subPath:
                subPath = '.'
            filename = os.path.basename(inputPath)
            # add the path and the filename as an expression
            inputToBrowse = InputToBrowse(subPath) ///<< here subPath can be "."
            inputToBrowse.addFilter(filename)
            inputsToBrowse.append(inputToBrowse)
        # if no user input, will browse in the current working directory
        if not inputsToBrowse:
            inputsToBrowse.append(InputToBrowse('.')) ///<< here you replaced "." by "os.getcwd()"

@cchampet
Copy link
Member

I think we should keep the relative path given by the user, since the way we implement the --relative-path uses the Item.getFolder() method.

If the browse is done with an absolute path, the Item.getFolder() will return an absolute path. Else, it will return a relative path which can be used to display the item.

@fabiencastan
Copy link
Member Author

Ok, my point was just to ensure that these 2 command lines give the same results:
sam ls -R --script --relative-path
sam ls . -R --script --relative-path

@cchampet
Copy link
Member

Ok I understand. It seems to be the case with my tests.
So if there is no input in the command line (sam ls -R --script --relative-path), we browse the current folder with '.' as argument, and we have the same result as sam ls . -R --script --relative-path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants