Skip to content
This repository has been archived by the owner on Jun 13, 2018. It is now read-only.

"gsl from" causes "Undefined expression: directory.open (...)" #41

Open
duzy opened this issue May 18, 2014 · 7 comments
Open

"gsl from" causes "Undefined expression: directory.open (...)" #41

duzy opened this issue May 18, 2014 · 7 comments

Comments

@duzy
Copy link

duzy commented May 18, 2014

Hi, I have have two functions to do code generation recursively on a directory.

But it looks like "gsl from my.filepath" has something wrong with directory.open, please help.

When I use "gsl file.slurp(...)" instead, it seems working fine.

function GenCode (dirname, filename)
    my.filepath = my.dirname + '/' + my.filename
    if regexp.match ('\(.*\)\.gsl$', my.filename, my.name)
        echo "GenCode: $(my.filepath:)"

        ######################################
        #gsl from my.filepath
        gsl file.slurp (my.filepath)
        ######################################

    elsif regexp.match ('.*~$', my.filename)
        # ignore slently...
    else
        echo "Ignored '$(my.filepath:)'"
    endif
endfunction

function GenCodeRecursively (dirname)
    echo "GenCodeRecursively: " + my.dirname
    my.dir = directory.open (my.dirname)
    for my.dir.file as f
        GenCode (my.dirname, f.name)
    endfor
    for my.dir.directory as sub
        GenCodeRecursively (my.dirname + '/' + sub.name)
    endfor
endfunction
@hintjens
Copy link
Member

Can you make a minimal test case, with a directory tree containing gsl
scripts and data, and the top level script that fails? Then zip the lot and
email it to me, at [email protected] so I can reproduce the problem and try to
fix it...? Thanks.

-Pieter

On Sun, May 18, 2014 at 5:50 AM, Duzy Chan [email protected] wrote:

Hi, I have have two functions to do code generation recursively on a
directory.

But it looks like "gsl from my.filepath" has something wrong with
directory.open, please help.

function GenCode (dirname, filename)
my.filepath = my.dirname + '/' + my.filename
if regexp.match ('(.*).gsl$', my.filename, my.name)
echo "GenCode: $(my.filepath:)"

    ######################################
    #gsl from my.filepath
    gsl file.slurp (my.filepath)
    ######################################

elsif regexp.match ('.*~$', my.filename)
    # ignore slently...
else
    echo "Ignored '$(my.filepath:)'"
endif

endfunction

function GenCodeRecursively (dirname)
echo "GenCodeRecursively: " + my.dirname
my.dir = directory.open (my.dirname)
for my.dir.file as f
GenCode (my.dirname, f.name)
endfor
for my.dir.directory as sub
GenCodeRecursively (my.dirname + '/' + sub.name)
endfor
endfunction


Reply to this email directly or view it on GitHubhttps://github.com//issues/41
.

@duzy
Copy link
Author

duzy commented May 18, 2014

Yes, sure. Now I have two versions of it that reproduce the similar errors. I'll pack my latest tree first and then revert a bit to the earlier version.

@duzy
Copy link
Author

duzy commented May 18, 2014

Hi Pieter, please check your email, it's sent :)

@hintjens
Copy link
Member

OK, so I get the same errors... that's good. No idea what the cause could
be, will debug dir.open a little...

On Sun, May 18, 2014 at 3:44 PM, Duzy Chan [email protected] wrote:

Hi Pieter, please check your email, it's sent :)


Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-43440080
.

@hintjens
Copy link
Member

directory.open is using the wrong path for some reason:

GenCodeRecursively.dir = directory.open (my.dirname, error)?
echo error?""

reports

/home/ph/Downloads/a/code/.: No such file or directory

On Sun, May 18, 2014 at 10:52 PM, Pieter Hintjens [email protected] wrote:

OK, so I get the same errors... that's good. No idea what the cause could
be, will debug dir.open a little...

On Sun, May 18, 2014 at 3:44 PM, Duzy Chan [email protected]:

Hi Pieter, please check your email, it's sent :)


Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-43440080
.

@hintjens
Copy link
Member

So there's some error in the directory open function, which is I think
confusing its file paths.

On Sun, May 18, 2014 at 11:01 PM, Pieter Hintjens [email protected] wrote:

directory.open is using the wrong path for some reason:

GenCodeRecursively.dir = directory.open (my.dirname, error)?
echo error?""

reports

/home/ph/Downloads/a/code/.: No such file or directory

On Sun, May 18, 2014 at 10:52 PM, Pieter Hintjens [email protected] wrote:

OK, so I get the same errors... that's good. No idea what the cause could
be, will debug dir.open a little...

On Sun, May 18, 2014 at 3:44 PM, Duzy Chan [email protected]:

Hi Pieter, please check your email, it's sent :)


Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-43440080
.

@duzy
Copy link
Author

duzy commented May 19, 2014

Thanks Pieter for the 'error'. The 'error' in the form of "directory.open (my.dirname, error) ?" gave much easier prompt. I think my work could become much easier when errors were like that.

Hope that we can find out the cause of the directory.open error. I was trying to go deep into the code, but I think I will need a lot of time to understand the whole.

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

No branches or pull requests

2 participants