Re: [Gimp-web] Proposed gimp tutorial



Hello,

Stephen is right, using Python's os.sep is much better than using
DIR-SEPARATOR.


On Mon, Feb 24, 2014 at 9:36 PM, Pat David <patdavid gmail com> wrote:

Could someone with a better grasp of the material chime in to help iron
this out so that we can possibly include it as either a tutorial or wiki
material?  I have to confess to not being familiar enough with the material
to be able to add anything meaningful beyond helping to translate to the
proper format for inclusion on wgo. :)


On Fri, Feb 21, 2014 at 6:38 PM, Stephen Kiel <snick kiel gmail com>
wrote:

 Pat,

I did look into the DIR-SEPARATOR (DIR_SEPARATOR on python?) constant. It
did not appear to be documented anywhere in the gimp docs that I could
find
with a search engine.  From an old scheme script I found posted I was
able
to find the following:

The DIR-SEPARATOR constant appears to be just a "/" on platforms where
the
OS is Linux and "\" on platforms where the OS is Windows.  The following
is
pasted from a Script-Fu Console and a Python-Fu Console (Linux).

**** Script-Fu Console*

Welcome to TinyScheme
Copyright (c) Dimitrios Souflis
Script-Fu Console - Interactive Scheme Development

(string-append "Yaba" DIR-SEPARATOR "Daba" DIR-SEPARATOR "Doo")
"Yaba/Daba/Doo"


**** PYTHON CONSOLE*

GIMP 2.8.10 Python Console
Python 2.7.5 (default, Feb 11 2014, 10:29:30)
[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)]
import os
print os.sep
/
from gimpfu import *
print DIR_SEPARATOR
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'DIR_SEPARATOR' is not defined
print DIR-SEPARATOR
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'DIR' is not defined
if DIR_SEPARATOR == "/":
...     print "YES"
...
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'DIR_SEPARATOR' is not defined


In python, os.sep does the same job that we would expect from
what we see in the scheme example except it has the following
advantages:

   1. It is documented
   2. It has a wide user base, so it should be robust
   3. It works in any python shell, so you can debug programs using wide
   range of tools.
   4. It works.

It seems like os.sep would be a much better design choice **IF** we
actually needed to determine a platform portable directory separator.  As
far as I can tell, we don't.

In the code I use python functions that take care of the separator.
e.g.
srcFile = os.path.join(srcPath, srcFile)
Python sticks in the right separator for the host OS.

From my point of view, it seems like using the DIR_SEPARATOR and manually
concatenating strings would make the code clumsy. I did not see anywhere
where knowing what the separator character was would be
an advantage.

I wanted to keep the focus of the tutorial on Automation and not get
sidetracked too much on design and architecture.  It is worth while to
note
that if you can design a block of code (like autoBase.py) that does not
use
the gimpfu library, you can run it on any python shell and use any
debugging tools at your disposal.  This is a real advantage over
debugging
in Gimp.  So I view using a gimp constant instead of a python library
function (os.sep) as kind of a mistake.

Please let me know if I missed something.


Stephen

On 2/20/2014 1:03 PM, Pat David wrote:

 Stephen,

 Just a couple of notes.  There are some concerns about the introduction
of the term "macro" in the tutorial and the sense with which it's used.

 Also, saul has asked me to relay to you: "have him look into the
DIR-SEPARATOR constant. Using it would obviate about half of his code."

 If you can take a look at DIR-SEPARATOR to see if perhaps it can help
streamline things a bit, that would be great.  I'm also hoping others
might
be able to chime in with other suggestions as well.

 There is a consideration of moving this to the wiki as opposed to wgo as
well.



On Thu, Feb 20, 2014 at 1:37 PM, Pat David <patdavid gmail com> wrote:

 Stephen,

 I've converted the tutorial to HTML to fit the website.  I've pushed it
up along with the assets, and am now just waiting on someone to poke wgo
for it to show up.  Keep an eye on the tutorials page.


On Thu, Feb 20, 2014 at 1:29 PM, Stephen Kiel <snick kiel gmail com
wrote:

Pat,
Thanks.  Let me know if there are any issues.
 Stephen
 On Feb 20, 2014 7:27 AM, "Pat David" <patdavid gmail com> wrote:

 Hi Stephen!

 You can just leave it as an ODT file.  I'll make the stylistic
changes required to fit the website HTML.

 Give me a little time and I'll make the conversion and get it up to
test.

 Thanks for the contribution!

 --
pat david
http://blog.patdavid.net




 --
pat david
http://blog.patdavid.net




 --
pat david
http://blog.patdavid.net


--
Stephen Kiel
26602 Strafford
Mission Viejo, CA 92692
Mobile/SMS (949) 702-1993
Home (949) 367-2915  snick kiel gmail comhttp://
stephenkiel.blogspot.com/




--
pat david
http://blog.patdavid.net
_______________________________________________
gimp-web-list mailing list
gimp-web-list gnome org
https://mail.gnome.org/mailman/listinfo/gimp-web-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]