Kara-Moon Forum
April 19, 2024, 08:51:59 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: You can go back to the main site here: Kara-Moon site
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: SongPath and FilePath variables  (Read 3705 times)
bvdp
Kara-Moon Master
****
Posts: 1437


WWW
« on: July 25, 2019, 06:30:03 PM »

I've added 2 variables:

   $SongPath -- the absolute path name of the song (from the command line)
   $FilePath -- abs path of the current file being processed (could be a lib/include file)

These can be handy if you want to have test code in a library file. So, in the lib file:

   bunch of settings
   defgroove SOMETHING

    if eq $SongPath $FilePath
       do test code
    endif


To add to an existing mma just do the following:

  1. to the top macro.py in the list of includes:
      from os import path

   2. Around line 112 add:
     
        elif s == 'FILEPATH':
            if gbl.inpath.fname == 1:
                return "STDIN"
            else:
                return path.abspath(gbl.inpath.fname)

        elif s == 'SONGPATH':
            if gbl.infile == 1:
                return "STDIN"
            else:
                return path.abspath(gbl.infile)
       

thanks sciurius for this. I think that a new mma-19.x is closer than I thought Smiley At least a devel version Smiley

   
   
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #1 on: July 25, 2019, 07:01:59 PM »

May I suggest to return "-" instead of "STDIN" for standard input?
Logged
bvdp
Kara-Moon Master
****
Posts: 1437


WWW
« Reply #2 on: July 25, 2019, 10:45:00 PM »

either works for me. STDIN "could" be a filename ...

If my memory serves, the file '-' is also possible, but probably not. Hard to create Smiley

So, in that case I think that we'll change all 3 (FILENAME, SONGPATH and FILEPATH) to '-' if it's coming from stdin. Easy Smiley
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #3 on: July 26, 2019, 07:25:41 AM »

A file with name "-" is easy to create, try 'touch ./-'.
If it is really matters, returning an empty string would be best.
Logged
bvdp
Kara-Moon Master
****
Posts: 1437


WWW
« Reply #4 on: July 26, 2019, 04:07:15 PM »

Empty is better, I think.
Logged

My online life: http://www.mellowood.ca
bvdp
Kara-Moon Master
****
Posts: 1437


WWW
« Reply #5 on: July 27, 2019, 10:03:51 PM »

So, that's done Smiley

Added are $_SongPath, $_FilePath and $_FileName (that was there all along, but not documented). They all return '' if input is coming from stdin.

Also, have added $_Env(..) which returns the value of an env (shell) variable. If the variable doesn't exist or if it has no value a empty string is returned.
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #6 on: July 28, 2019, 09:17:24 AM »

Good work! Thanks!

Time to roll out a devel version so we can sync sources for future development?
Logged
bvdp
Kara-Moon Master
****
Posts: 1437


WWW
« Reply #7 on: July 28, 2019, 04:27:23 PM »

Yes it is. I just want to integrate you pluginUtils patch! On my list for today.
Logged

My online life: http://www.mellowood.ca
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.057 seconds with 19 queries.