(FSPath / 'foo.bar.zot') extension = 'bar.zot'

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

(FSPath / 'foo.bar.zot') extension = 'bar.zot'

Tony Garnock-Jones-5
Hi all,


Currently:

     (FSPath / 'foo.bar.zot') extension = 'bar.zot'

Should it be? I expected it to equal 'zot'.

For reference, in python3:

     os.path.splitext('foo.bar.zot') == ('foo.bar', '.zot')

and in racket

     (equal? (path-get-extension "foo.bar.zot") #".zot")


Tony


Reply | Threaded
Open this post in threaded view
|

Re: (FSPath / 'foo.bar.zot') extension = 'bar.zot'

Christoph Thiede

Good catch! That's clearly a bug IMO. #extension should use #copyAfterLast: rather than #copyAfter:.

On the other, FSReferenceTest >> #testBaseAndExtension explicitly defines a test where it says:

"Note that the extension of a complex extension starts from the first period up until the end"


So why is Squeak-FileSystem neglecting the common standards in this case?

Best,
Christoph

Von: Squeak-dev <[hidden email]> im Auftrag von Tony Garnock-Jones <[hidden email]>
Gesendet: Donnerstag, 5. November 2020 19:31:44
An: The general-purpose Squeak developers list
Betreff: [squeak-dev] (FSPath / 'foo.bar.zot') extension = 'bar.zot'
 
Hi all,


Currently:

     (FSPath / 'foo.bar.zot') extension = 'bar.zot'

Should it be? I expected it to equal 'zot'.

For reference, in python3:

     os.path.splitext('foo.bar.zot') == ('foo.bar', '.zot')

and in racket

     (equal? (path-get-extension "foo.bar.zot") #".zot")


Tony




Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: (FSPath / 'foo.bar.zot') extension = 'bar.zot'

timrowledge
In reply to this post by Tony Garnock-Jones-5


> On 2020-11-05, at 10:31 AM, Tony Garnock-Jones <[hidden email]> wrote:
>
> Hi all,
>
>
> Currently:
>
>     (FSPath / 'foo.bar.zot') extension = 'bar.zot'
>
> Should it be? I expected it to equal 'zot'.

For the 'normal' FileDirectory stuff in the image, the extension would work ok here. I'm not familiar with FSPath - that's the package Colin Putney wrote a while back?


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
I came, I saw, I deleted all your files.



Reply | Threaded
Open this post in threaded view
|

Re: (FSPath / 'foo.bar.zot') extension = 'bar.zot'

Tony Garnock-Jones-5
In reply to this post by Christoph Thiede

On 11/5/20 7:41 PM, Thiede, Christoph wrote:

Good catch! That's clearly a bug IMO. #extension should use #copyAfterLast: rather than #copyAfter:.

On the other, FSReferenceTest >> #testBaseAndExtension explicitly defines a test where it says:

"Note that the extension of a complex extension starts from the first period up until the end"


Worse, it's inconsistent with #withExtension: -


((FSPath / 'foo.bar.zot') withExtension: 'zaz') = (FSPath / 'foo.bar.zaz')


!!!


On 11/5/20 7:43 PM, tim Rowledge wrote:
For the 'normal' FileDirectory stuff in the image, the extension would work ok here. I'm not familiar with FSPath - that's the package Colin Putney wrote a while back?


This is part of package FS-Core that the Squeak config wizard loads as part of the Git support.


Tony




Reply | Threaded
Open this post in threaded view
|

Re: (FSPath / 'foo.bar.zot') extension = 'bar.zot'

David T. Lewis
In reply to this post by Christoph Thiede
On Thu, Nov 05, 2020 at 06:41:14PM +0000, Thiede, Christoph wrote:
> Good catch! That's clearly a bug IMO. #extension should use #copyAfterLast: rather than #copyAfter:.
>
> On the other, FSReferenceTest >> #testBaseAndExtension explicitly defines a test where it says:
>
> "Note that the extension of a complex extension starts from the first period up until the end"
>

The underlying problem appears to be that someone neglected to write
a test for #extension.

The testBaseAndExtension test appears to be a later addition, and it may
be that the test simply documents an existing bug, so the test itself
may be wrong.

I am attaching a proposed test based on Tony's example.

Dave




FSPathTest-testExtension.st (259 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: (FSPath / 'foo.bar.zot') extension = 'bar.zot'

David T. Lewis
In reply to this post by timrowledge
On Thu, Nov 05, 2020 at 10:43:02AM -0800, tim Rowledge wrote:

>
>
> > On 2020-11-05, at 10:31 AM, Tony Garnock-Jones <[hidden email]> wrote:
> >
> > Hi all,
> >
> >
> > Currently:
> >
> >     (FSPath / 'foo.bar.zot') extension = 'bar.zot'
> >
> > Should it be? I expected it to equal 'zot'.
>
> For the 'normal' FileDirectory stuff in the image, the extension would work ok here. I'm not familiar with FSPath - that's the package Colin Putney wrote a while back?
>

Yes (although the version history seems to show other authors). It gets
pulled in along with the git tools.

It is on GitHub at https://github.com/squeak-smalltalk/squeak-filesystem
which is based on the earlier work at http://www.squeaksource.com/fs

Dave


Reply | Threaded
Open this post in threaded view
|

Re: (FSPath / 'foo.bar.zot') extension = 'bar.zot'

Jakob Reschke
In reply to this post by Christoph Thiede
Am Do., 5. Nov. 2020 um 19:41 Uhr schrieb Thiede, Christoph
<[hidden email]>:
>
> Good catch! That's clearly a bug IMO. #extension should use #copyAfterLast: rather than #copyAfter:.
>

Pharo has it like this as well, so it is also an unnecessary incompatibility:

extension
    "Return the extension of path basename i.e., /foo/gloops.taz
extension is 'taz'"
    ^ self basename copyAfterLast: self extensionDelimiter

>
> On the other, FSReferenceTest >> #testBaseAndExtension explicitly defines a test where it says:
>
> "Note that the extension of a complex extension starts from the first period up until the end"
>

The original author might either have just documented that status quo,
or thought of something like .tar.gz. Again Pharo has changed this to
"Note that the extension of a complex extension starts after the last
extension delimiter".

Reply | Threaded
Open this post in threaded view
|

Re: (FSPath / 'foo.bar.zot') extension = 'bar.zot'

Christoph Thiede

I am attaching a proposed test based on Tony's example.


+1! Are there any objections or shall we integrate this change into Squeak-FileSystem?

Best,
Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Jakob Reschke <[hidden email]>
Gesendet: Freitag, 6. November 2020 12:31:03
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] (FSPath / 'foo.bar.zot') extension = 'bar.zot'
 
Am Do., 5. Nov. 2020 um 19:41 Uhr schrieb Thiede, Christoph
<[hidden email]>:
>
> Good catch! That's clearly a bug IMO. #extension should use #copyAfterLast: rather than #copyAfter:.
>

Pharo has it like this as well, so it is also an unnecessary incompatibility:

extension
    "Return the extension of path basename i.e., /foo/gloops.taz
extension is 'taz'"
    ^ self basename copyAfterLast: self extensionDelimiter

>
> On the other, FSReferenceTest >> #testBaseAndExtension explicitly defines a test where it says:
>
> "Note that the extension of a complex extension starts from the first period up until the end"
>

The original author might either have just documented that status quo,
or thought of something like .tar.gz. Again Pharo has changed this to
"Note that the extension of a complex extension starts after the last
extension delimiter".



Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: (FSPath / 'foo.bar.zot') extension = 'bar.zot'

Jakob Reschke
Am Sa., 7. Nov. 2020 um 13:54 Uhr schrieb Thiede, Christoph
<[hidden email]>:
>
> Are there any objections or shall we integrate this change into Squeak-FileSystem?
>

In my opinion, go ahead, but check and at least post the senders that
need to be changed, please.

Reply | Threaded
Open this post in threaded view
|

Re: (FSPath / 'foo.bar.zot') extension = 'bar.zot'

Tony Garnock-Jones-5
On 11/7/20 3:54 PM, Jakob Reschke wrote:
> Am Sa., 7. Nov. 2020 um 13:54 Uhr schrieb Thiede, Christoph
> <[hidden email]>:
>> Are there any objections or shall we integrate this change into Squeak-FileSystem?
>
> In my opinion, go ahead, but check and at least post the senders that
> need to be changed, please.

I don't see any senders (that need changing) at all in my current
trunk-ish image. Are there external packages that need to be looked at
or is it good enough to have trunk be OK for the change?

Tony

Reply | Threaded
Open this post in threaded view
|

Re: (FSPath / 'foo.bar.zot') extension = 'bar.zot'

Jakob Reschke
Trunk and FileSystem-Git + Squot. Christoph probably has these loaded anyway.

Am Mo., 9. Nov. 2020 um 13:38 Uhr schrieb Tony Garnock-Jones
<[hidden email]>:

>
> On 11/7/20 3:54 PM, Jakob Reschke wrote:
> > Am Sa., 7. Nov. 2020 um 13:54 Uhr schrieb Thiede, Christoph
> > <[hidden email]>:
> >> Are there any objections or shall we integrate this change into Squeak-FileSystem?
> >
> > In my opinion, go ahead, but check and at least post the senders that
> > need to be changed, please.
>
> I don't see any senders (that need changing) at all in my current
> trunk-ish image. Are there external packages that need to be looked at
> or is it good enough to have trunk be OK for the change?
>
> Tony

Reply | Threaded
Open this post in threaded view
|

Re: (FSPath / 'foo.bar.zot') extension = 'bar.zot'

Tony Garnock-Jones-5
On 11/11/20 11:16 AM, Jakob Reschke wrote:
> Trunk and FileSystem-Git + Squot. Christoph probably has these loaded anyway.

The versions of those I have loaded are the ones installed by the
configuration wizard (ie master of Squot and its support libraries) -
and there are no interesting senders of #extension there.

So I think we're probably OK to make the change!

Tony

Reply | Threaded
Open this post in threaded view
|

Re: (FSPath / 'foo.bar.zot') extension = 'bar.zot'

Christoph Thiede

Alright, Tony, will you submit a PR, or shall I do that? :-)


Best,
Christoph

Von: Squeak-dev <[hidden email]> im Auftrag von Tony Garnock-Jones <[hidden email]>
Gesendet: Mittwoch, 11. November 2020 19:25:59
An: Jakob Reschke
Cc: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] (FSPath / 'foo.bar.zot') extension = 'bar.zot'
 
On 11/11/20 11:16 AM, Jakob Reschke wrote:
> Trunk and FileSystem-Git + Squot. Christoph probably has these loaded anyway.

The versions of those I have loaded are the ones installed by the
configuration wizard (ie master of Squot and its support libraries) -
and there are no interesting senders of #extension there.

So I think we're probably OK to make the change!

Tony



Carpe Squeak!