Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-24 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Steven D'Aprano
wrote:

 Putting preferences files in the user's top level directory is horribly
 inconvenient for the user.

There is a way around this: redefine the HOME environment variable to be the
directory where you want the dotfiles to end up.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-24 Thread Paul McNett

Steven D'Aprano wrote:

On Sun, 19 Oct 2008 20:50:46 +0200, Stef Mientki wrote:


Duncan, in windows it's begin to become less common to store settings in
DocsSettings,
because these directories are destroyed by roaming profiles 


The directories aren't destroyed by roaming profiles. When the user logs 
out, they get copied to the server. When they log in at a different 
machine, they get copied to the workstation.


So configuration information saved in c:\Documents and 
Settings\pmcnett\Application Data\My Application gets conveniently 
migrated from machine to machine where I happen to login.


A really nice feature.



Isn't *everything* destroyed by roaming profiles? *wink*


I've heard such bashing of roaming profiles but I've never had anything 
but love for them. That is, until people go and start saving their 
movies and pictures in My Documents. Which is why I set their home 
directory to a server share and have them save their docs there.



Seriously, I don't know anyone who has anything nice to say about roaming 
profiles.


I loathe Windows, but roaming profiles was one thing they did (mostly) 
right. I couldn't be happy in a world that didn't include roaming profiles.


Perhaps I'm not seeing the worst of it as I use Samba on Linux as the PDC?

Anyway, on Windows user configuration information should go in the 
user's Application Data directory. If you don't want it to roam, you can 
instead put it in the (hidden) Local Settings/Application Data directory.


Paul
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-23 Thread Robert Brown
Stef Mientki [EMAIL PROTECTED] writes:

 I (again) wonder what's the perfect way to store, OS-independent, filepaths ?
 I can think of something like:
 - use a relative path if drive is identical to the application (I'm still a
 Windows guy)
 - use some kind of OS-dependent translation table if on another drive
 - use ? if on a network drive

There is no perfect solution, since file names and semantics differ from one
operating system to the next.  Genera, the Lisp Machine operating system, has
facilities to abstract over the details of the file systems in use in the
1980s: Multics, ITS, TOPS-20, VMS, Unix, etc.  Many of the concepts were
incorporated into the Common Lisp standard.  Here are a couple of references:

  http://gigamonkeys.com/book/files-and-file-io.html#filenames
  http://www.lispworks.com/documentation/HyperSpec/Body/19_.htm

The system described is not simple.  Briefly, there's a machine-independent
way (logical pathnames) to specify file names that a program can use to
manipulate the files it knows about.  There's no guarantee that you can access
an arbitrary file with these names.  However, there's also the concept of a
machine-specific file namestring.  Users can type in these machine-specific
namestrings, allowing the code to access arbitrary files.

Both types of pathnames can be manipulated via an API to derive other file
names.  Here's how I create a pathname that refers to a subdirectory of my
home directory:

  (merge-pathnames
(make-pathname :directory '(:relative .sbcl systems))
(user-homedir-pathname))

The code should work so long as the target file system supports
subdirectories, as Windows and Unix do.

bob
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-22 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Ross Ridge wrote:

 Ross Ridge wrote:

 As opposed to the file system being the single point failure?
 
 Lawrence D'Oliveiro  [EMAIL PROTECTED] wrote:
The file system is involved regardless. But leaving out an additional
layer of failure on top of it does make things more robust, yes.
 
 No, that doesn't follow.  Having TCP as layer on top of IP doesn't make
 the Internet less robust even though it's additional point of failure.

Which is a vacuous example.

 For the matter, settings files also have an additional layer of failure
 in the code that intreprets and updates the setting files.

See, it's clear you're too accustomed to the Windows mentality:
under settings files you're subsuming system config files, read-only
shared data, writeable data and per-user prefs--a whole bunch of things.
Recognize the distinction between these, and the fact that they need to be
kept distinct, and you can see how your assertions no longer hold up.

The file system already has provisions for simultaneous access by multiple
processes, journalling, integrity checking etc; implementing a registry
on top of this means reinventing a whole separate API and architecture
that has to provide this sort of thing, or leave it out and suffer the
well-known consequences.
 
 If settings files benefit from those provisions of the filesystem then
 so does the registry.  If the registry needs additional provisions so
 do settings files for the same reasons.

Quite different reasons, as I pointed out above.

Plus the fact that the Windows Registry is actually a munging together of
things that are kept in quite separate places in Unix/Linux: system config
files versus shared read-only data versus writable data versus user prefs
etc. Putting all these things together just makes it more likely that
somebody will clobber something it didn't mean to.
 
 Nope.  Microsoft implemented the registry because users were clobbering
 things they weren't ment to, and it succeded in making it a less likely
 occurence.

http://www.google.co.nz/search?q=registry+damage+prone
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-22 Thread Steven D'Aprano
On Tue, 21 Oct 2008 10:00:35 -0500, Grant Edwards wrote:

 It is true that all kinds of programs will create .app files in your
 home dir which is not very polite.
 
 It _is_ polite.  Polite means following the established rules and doing
 what's expected of you.  That's exactly what is expected of applications
 under Unix.

In medieval Russia, the Rus vikings (from whom modern Russia gets its 
name) used to live in communal log huts. In the morning, a slave would 
bring along a great big steaming bowl of water for the Rus to wash their 
faces in. *One* bowl. The first person would wash his face, blow his nose 
and spit in the bowl, then pass it on to the next person, who would 
repeat all down the line.

This was the established social rules and everybody did what was expected 
of them. It was also as rude as hell, and not just because rude also 
means unpolished, uncultured. 

Putting preferences files in the user's top level directory is horribly 
inconvenient for the user. It clutters their home directory. The old-time 
Unix people recognised this, and made the files hidden so that their mess 
wasn't visible. It certainly wasn't to protect the user from themselves, 
because their users were other old-time Unix geeks who not only were 
comfortable editing config files but expected to be able to. No, the only 
reason for hiding the config files was because otherwise the user's home 
directory would be too messy.

But of course all that means is that you avoid the mess so long as you 
don't look at it. I have 125 dot files in my home directory. They include 
temporary files from programs I haven't run in months, settings from 
applications I haven't even heard of (where the hell did 
.parallelrealities come from?), log files, lock files and other dross 
that has no place scattered across my home directory. Half of these files 
contain important data which users will invariably miss when making 
backups, and half of them are junk that don't need to be copied when 
making backups (e.g. .thumbnails, .Trash), but there's no easy way to 
include some while excluding others.

It may be expected, but it is still inconsiderate and just plain 
*stupid*. A thirty year old stupidity is still a stupidity.

It would have been easy to avoid this: just copy the relevant bits of 
the / directory hierarchy in the user's home directory. Global settings 
go in /etc and per user settings go in ~/etc. Global temp files go into /
tmp and per user temp files go into ~/tmp. And so forth. Nice, neat and 
perfectly easy to implement and easy to deal with.



-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-22 Thread Joe Strout

On Oct 22, 2008, at 10:00 PM, Steven D'Aprano wrote:


It would have been easy to avoid this: just copy the relevant bits of
the / directory hierarchy in the user's home directory. Global  
settings
go in /etc and per user settings go in ~/etc. Global temp files go  
into /
tmp and per user temp files go into ~/tmp. And so forth. Nice, neat  
and

perfectly easy to implement and easy to deal with.


I agree with you wholeheartedly on this one.

FYI, I think what you're looking for is a Mac.  It's a Unix system,  
and has /etc, but that's pretty much only there for compatibility with  
other Unices -- well-behaved Mac apps put global settings (and so on)  
in the appropriate subfolder under /Library, with per user data in the  
appropriate subfolder under ~/Library.


Cheers,
- Joe





--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-21 Thread Roel Schroeven

Steven D'Aprano schreef:

On Mon, 20 Oct 2008 10:20:06 +, Duncan Booth wrote:


Steven D'Aprano [EMAIL PROTECTED] wrote:


On Sun, 19 Oct 2008 15:40:32 +, Duncan Booth wrote:


Steven D'Aprano [EMAIL PROTECTED] wrote:


In Linux, config files should go into:

~/.appname/ or /etc/appname/

In Windows (which versions?) then should go into the Documents And
Settings folder, where ever that is.

There's no single string which can represent both of these
conventions!

The first of those should do nicely for both Linux and Windows:


os.path.normpath(os.path.expanduser('~/.appname'))

'C:\\Documents and Settings\\Duncan\\.appname'


Except Windows users will be wondering why they have a directory
starting with '.' in their home directory. Dot to make files hidden is
not AFAIK supported by Windows.


The leading dot doesn't make the files hidden on Windows, but there's no
reason why you can't create files/folders with a leading dot and many
programs do just that. On the machine I'm on right now, 'dir .*' shows
me:

[snip]

And 75% [1] of average Windows users will either delete the file, move it 
to a more convenient[2] location, or edit the file name to remove the dot.


I don't think so: the average Windows user will never even see the files 
in that directory; they only see the files in the 'Desktop' and 'My 
Documents' folders.


--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

Roel Schroeven
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-21 Thread Laszlo Nagy



However, the normal place to store settings on Windows is in the registry.



Which becomes a single point of failure for the whole system.
  

LOL :-)

BTW famous big popular programs like firefox and thunderbird will store 
their configuration data under Documents and Settings\Application 
data. I believe this is the standard place to store application 
configuration data. And inside that directory, you should be able to use 
whatever file name you want, beginning with a dot or not.


Users who like to go inside Documents and Settings\Application data 
and delete things without knowing what they do deserve to have a 
malfunctioning system for sure.


BTW it would be nice to have a standard 'Application data like 
directory under UNIX. It is true that all kinds of programs will create 
.app files in your home dir which is not very polite.


 Laszlo

--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-21 Thread Steven D'Aprano
On Tue, 21 Oct 2008 11:32:14 +0200, Laszlo Nagy wrote:

 Users who like to go inside Documents and Settings\Application data
 and delete things without knowing what they do deserve to have a
 malfunctioning system for sure.

The worst consequence from deleting a settings file should be to revert 
to factory defaults (which, admittedly, may mean the software can't do 
anything useful until you configure it). It should NEVER be malfunction 
or data loss.

Of course, that's in principle. In practice, most software is 
insufficiently defensive to work that way. In the Real World, deleting 
settings files can have any consequence from nothing at all to serious 
meltdown.

But as a matter of principle, users should be able to delete settings 
files and lose nothing more than, well, settings. That's why it's a 
SETTINGS file, not a DATA file. Settings should be information that can 
be easily regenerated if lost. Anything that can't easily be regenerated, 
like address books and bookmarks, are documents, not settings. Any 
program which hides such documents in a hidden settings directory where 
users can't easily make backup copies is a badly behaved program.


 BTW it would be nice to have a standard 'Application data like
 directory under UNIX. It is true that all kinds of programs will create
 .app files in your home dir which is not very polite.

Agreed, except I hope that when it eventually happens, the name won't 
have a space in it, and it especially won't include the word My (as in 
My Settings, My Preferences, or My Application Data).


-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-21 Thread Ross Ridge
Ross Ridge wrote:
 However, the normal place to store settings on Windows is in the registry.

Lawrence D'Oliveiro  [EMAIL PROTECTED] wrote:
 Which becomes a single point of failure for the whole system.

As opposed to the file system being the single point failure?

Ross Ridge

-- 
 l/  //   Ross Ridge -- The Great HTMU
[oo][oo]  [EMAIL PROTECTED]
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //   
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-21 Thread Grant Edwards
On 2008-10-21, Laszlo Nagy [EMAIL PROTECTED] wrote:

 However, the normal place to store settings on Windows is in the registry.
 

 Which becomes a single point of failure for the whole system.
   
 LOL :-)

 BTW famous big popular programs like firefox and thunderbird
 will store their configuration data under Documents and
 Settings\Application data. I believe this is the standard
 place to store application configuration data. And inside that
 directory, you should be able to use whatever file name you
 want, beginning with a dot or not.

 Users who like to go inside Documents and
 Settings\Application data and delete things without knowing
 what they do deserve to have a malfunctioning system for sure.

 BTW it would be nice to have a standard 'Application data
 like directory under UNIX.

The standard is to create either a .appname file or .appname
directory in the user's home directory.

 It is true that all kinds of programs will create .app files
 in your home dir which is not very polite.

It _is_ polite.  Polite means following the established rules
and doing what's expected of you.  That's exactly what is
expected of applications under Unix.

-- 
Grant Edwards   grante Yow! I wonder if I ought
  at   to tell them about my
   visi.comPREVIOUS LIFE as a COMPLETE
   STRANGER?
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-21 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Ross Ridge wrote:

 Lawrence D'Oliveiro  [EMAIL PROTECTED] wrote:

 Ross Ridge wrote:

 However, the normal place to store settings on Windows is in the
 registry.

 Which becomes a single point of failure for the whole system.
 
 As opposed to the file system being the single point failure?

The file system is involved regardless. But leaving out an additional layer
of failure on top of it does make things more robust, yes. The file system
already has provisions for simultaneous access by multiple processes,
journalling, integrity checking etc; implementing a registry on top of
this means reinventing a whole separate API and architecture that has to
provide this sort of thing, or leave it out and suffer the well-known
consequences.

Plus the fact that the Windows Registry is actually a munging together of
things that are kept in quite separate places in Unix/Linux: system config
files versus shared read-only data versus writable data versus user prefs
etc. Putting all these things together just makes it more likely that
somebody will clobber something it didn't mean to.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-21 Thread Ross Ridge
Ross Ridge wrote:
 As opposed to the file system being the single point failure?

Lawrence D'Oliveiro  [EMAIL PROTECTED] wrote:
The file system is involved regardless. But leaving out an additional
layer of failure on top of it does make things more robust, yes.

No, that doesn't follow.  Having TCP as layer on top of IP doesn't make
the Internet less robust even though it's additional point of failure.
For the matter, settings files also have an additional layer of failure
in the code that intreprets and updates the setting files.

The file system already has provisions for simultaneous access by multiple
processes, journalling, integrity checking etc; implementing a registry
on top of this means reinventing a whole separate API and architecture
that has to provide this sort of thing, or leave it out and suffer the
well-known consequences.

If settings files benefit from those provisions of the filesystem then
so does the registry.  If the registry needs additional provisions so
do settings files for the same reasons.

Plus the fact that the Windows Registry is actually a munging together of
things that are kept in quite separate places in Unix/Linux: system config
files versus shared read-only data versus writable data versus user prefs
etc. Putting all these things together just makes it more likely that
somebody will clobber something it didn't mean to.

Nope.  Microsoft implemented the registry because users were clobbering
things they weren't ment to, and it succeded in making it a less likely
occurence.

Ross Ridge

-- 
 l/  //   Ross Ridge -- The Great HTMU
[oo][oo]  [EMAIL PROTECTED]
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //   
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Duncan Booth
Steven D'Aprano [EMAIL PROTECTED] wrote:

 On Sun, 19 Oct 2008 15:40:32 +, Duncan Booth wrote:
 
 Steven D'Aprano [EMAIL PROTECTED] wrote:
 
 In Linux, config files should go into:
 
 ~/.appname/ or /etc/appname/
 
 In Windows (which versions?) then should go into the Documents And
 Settings folder, where ever that is.
 
 There's no single string which can represent both of these
 conventions! 
 
 The first of those should do nicely for both Linux and Windows:
 
 os.path.normpath(os.path.expanduser('~/.appname'))
 'C:\\Documents and Settings\\Duncan\\.appname'
 
 
 Except Windows users will be wondering why they have a directory
 starting with '.' in their home directory. Dot to make files hidden is
 not AFAIK supported by Windows.
 
The leading dot doesn't make the files hidden on Windows, but there's no 
reason why you can't create files/folders with a leading dot and many 
programs do just that. On the machine I'm on right now, 'dir .*' shows me:

 Directory of C:\Documents and Settings\Duncan

18/10/2008  15:48DIR  .
18/10/2008  15:48DIR  ..
22/09/2008  20:2845 .appcfg_nag
30/07/2004  09:28   244 .bashrc
18/01/2007  10:50 6,783 .bash_history
11/06/2006  12:30DIR  .borland
06/04/2004  15:43   365 .emacs-places
11/03/2004  12:34DIR  .emacs.d
08/01/2007  19:3530,390 .fonts.cache-1
03/05/2008  18:07DIR  .gimp-2.0
14/01/2005  14:34DIR  .idlerc
11/06/2006  12:36DIR  .jbuilder2005
27/06/2005  12:44 3 .leoID.txt
11/06/2006  12:43DIR  .Nokia
11/06/2006  12:36DIR  .primetime2005
11/06/2006  12:13DIR  .qualitycentral
04/02/2004  12:24DIR  .ssh
12/08/2004  14:30DIR  .thumbnails
30/07/2004  14:1149 .Xauthority
29/07/2004  16:2512 .Xdefaults
29/07/2004  14:36DIR  .xemacs
17/08/2006  09:19 2,869 .XWinrc

not to mention the thousands of .svn folders scattered across the rest of 
the system.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Ross Ridge
Stef Mientki wrote:
Duncan, in windows it's begin to become less common to store settings in
DocsSettings,
because these directories are destroyed by roaming profiles (a big
reason why I can't run Picassa ;-(
It's more common to follow the portable apps approach, store them in the
application directory.

Steven D'Aprano  [EMAIL PROTECTED] wrote:
What do you do when users don't have write permission for the application 
directory?

Use the application data directory (if you want it to roam), or the
local application data directory (if not).  However, the normal place
to store settings on Windows is in the registry.

Ross Ridge

-- 
 l/  //   Ross Ridge -- The Great HTMU
[oo][oo]  [EMAIL PROTECTED]
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //   
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Steven D'Aprano
On Sun, 19 Oct 2008 20:50:46 +0200, Stef Mientki wrote:

 Duncan, in windows it's begin to become less common to store settings in
 DocsSettings,
 because these directories are destroyed by roaming profiles (a big
 reason why I can't run Picassa ;-(
 It's more common to follow the portable apps approach, store them in the
 application directory.

What do you do when users don't have write permission for the application 
directory?


-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Steven D'Aprano
On Mon, 20 Oct 2008 10:20:06 +, Duncan Booth wrote:

 Steven D'Aprano [EMAIL PROTECTED] wrote:
 
 On Sun, 19 Oct 2008 15:40:32 +, Duncan Booth wrote:
 
 Steven D'Aprano [EMAIL PROTECTED] wrote:
 
 In Linux, config files should go into:
 
 ~/.appname/ or /etc/appname/
 
 In Windows (which versions?) then should go into the Documents And
 Settings folder, where ever that is.
 
 There's no single string which can represent both of these
 conventions!
 
 The first of those should do nicely for both Linux and Windows:
 
 os.path.normpath(os.path.expanduser('~/.appname'))
 'C:\\Documents and Settings\\Duncan\\.appname'
 
 
 Except Windows users will be wondering why they have a directory
 starting with '.' in their home directory. Dot to make files hidden is
 not AFAIK supported by Windows.
 
 The leading dot doesn't make the files hidden on Windows, but there's no
 reason why you can't create files/folders with a leading dot and many
 programs do just that. On the machine I'm on right now, 'dir .*' shows
 me:
[snip]

And 75% [1] of average Windows users will either delete the file, move it 
to a more convenient[2] location, or edit the file name to remove the dot.

I'm not saying you can't use files with a leading period under Windows. 
You can name all your config files using Morse code if you want. I'm 
saying it breaks the expected Windows file location guidelines, and it 
displays a shameful lack of care by the programmer. Windows users are 
more forgiving of badly behaved programs than Macintosh users, but even 
so, it's pretty shoddy to ignore a platform's standard file locations. 
Unix/Linux coders would rightly be annoyed if some tool created a 
directory /Program Files instead of using the appropriate /bin 
directory. This is no different.





[1] Based on my experience of the typical Windows user. YMMV.

[2] And they are right to do so. Programs that dump config files and 
directories, hidden or not, in the top level of the user's home directory 
are incredibly rude. It may have been a Unix standard for as long as 
there has been a Unix, but it's still the programming equivalent of 
coming into somebody's house and throwing your tools all over their 
living room floor.



-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Cousin Stanley

 [2] And they are right to do so. Programs that dump config files and 
 directories, hidden or not, in the top level of the user's home directory 
 are incredibly rude. It may have been a Unix standard for as long as 
 there has been a Unix, but it's still the programming equivalent of 
 coming into somebody's house and throwing your tools all over their 
 living room floor.

  Personally, I feel the same way about dumping files
  into the python  site-package  directory 

  For example, I've never understood why kde and qt packages
  don't use a sub-dir to house their  .so  libs 

  Moving the  .egg-info  files into sub-dirs or their own tree
  would also clean up the  site-packages  dir 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Bruno Desthuilliers

Eric Wertman a écrit :

I (again) wonder what's the perfect way to store, OS-independent,
filepaths ?


I'm in agreement that perfect probably isn't applicable.  If I were
doing this myself, I might store the information in a tuple:

base = 'some root structure ('/' or 'C')


make it C:\


path = ['some','set','of','path','names']
filename = 'somefile.ext'

pathdata = (root,path,filename)

and write a couple of simple functions to reconstruct them based on the os.


like, err, os.path.join ?
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Stef Mientki

Bruno Desthuilliers wrote:

Eric Wertman a écrit :

I (again) wonder what's the perfect way to store, OS-independent,
filepaths ?


I'm in agreement that perfect probably isn't applicable.  If I were
doing this myself, I might store the information in a tuple:

base = 'some root structure ('/' or 'C')


make it C:\

wouldn't  C:/  be more universal and therefor better ?



path = ['some','set','of','path','names']
filename = 'somefile.ext'

pathdata = (root,path,filename)

and write a couple of simple functions to reconstruct them based on 
the os.


like, err, os.path.join ?
Yes (because these functions don't function correctly with i.e pdb, 
which might be due to bugs in pdb).

cheers,
Stef

--
http://mail.python.org/mailman/listinfo/python-list


--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Steven D'Aprano
On Mon, 20 Oct 2008 23:56:22 +0200, Stef Mientki wrote:

 Bruno Desthuilliers wrote:
 Eric Wertman a écrit :
 I (again) wonder what's the perfect way to store, OS-independent,
 filepaths ?

 I'm in agreement that perfect probably isn't applicable.  If I were
 doing this myself, I might store the information in a tuple:

 base = 'some root structure ('/' or 'C')

 make it C:\
 wouldn't  C:/  be more universal and therefor better ?


Do you really think there are Linux or Mac systems with a C: drive?

This whole question is based on the ludicrous assumption that general 
file system paths can be platform-independent. That's a bit like trying 
to write code that is programming language-independent.


-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Eric Wertman
 Do you really think there are Linux or Mac systems with a C: drive?

 This whole question is based on the ludicrous assumption that general
 file system paths can be platform-independent. That's a bit like trying
 to write code that is programming language-independent.


That's sort of where I was going originally... just pick a way to
store the path elements and write some simple functions (yes, many of
them will just be os.path calls) to reconstruct them based on the
actual needs of the application.  If your root element is in
ascii.letters  then it's most likely windows machine, so adding a ':'
and using os.path.join would be appropriate in the function.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Stef
Mientki wrote:

 I (again) wonder what's the perfect way to store, OS-independent,
 filepaths ?

URLs beginning file://.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Ross Ridge wrote:

 However, the normal place to store settings on Windows is in the registry.

Which becomes a single point of failure for the whole system.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Steven D'Aprano
wrote:

 Do you really think there are Linux or Mac systems with a C: drive?

And what about files on Dimdows systems kept on a drive other than C?

 This whole question is based on the ludicrous assumption that general
 file system paths can be platform-independent.

There is supposed to be a POSIX-compliant layer somewhere underneath all the
Dimdows crud. You could write to that.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], Steven D'Aprano
wrote:

 And 75% [1] of average Windows users will either delete the file, move it
 to a more convenient[2] location, or edit the file name to remove the dot.

Doesn't seem very likely to me. Experienced Dimdows users would well know
that stuffing around with files they don't understand is liable to break
some application or another, so they shouldn't do it.

 [2] And they are right to do so. Programs that dump config files and
 directories, hidden or not, in the top level of the user's home directory
 are incredibly rude. It may have been a Unix standard for as long as
 there has been a Unix, but it's still the programming equivalent of
 coming into somebody's house and throwing your tools all over their
 living room floor.

Hmm, actually you have a point there. There's also the security issue, in
that other users can tell what apps you've been using based on the dotfiles
present in your home directory.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-19 Thread [EMAIL PROTECTED]
On Oct 19, 8:35 am, Stef Mientki [EMAIL PROTECTED] wrote:
 I (again) wonder what's the perfect way to store, OS-independent,
 filepaths ?

I don't think there is any such thing.  What problem are you trying to
solve?
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-19 Thread Steven D'Aprano
On Sun, 19 Oct 2008 14:35:01 +0200, Stef Mientki wrote:

 hello,
 
 I (again) wonder what's the perfect way to store, OS-independent,
 filepaths ?

Perfect? I can't imagine any scheme which will work on every imaginable 
OS, past present and future.

However, in practice I think there are two common forms still in use: 
Posix paths, and Windows paths. I believe that OS/2 can deal with Windows 
pathnames, and Mac OS X uses Posix paths (I think...). If you have to 
support Classic Mac OS or other non-Posix systems, then your life will 
become interesting and complicated.

And let's not even consider Unicode issues...

You might find this page useful:
http://en.wikipedia.org/wiki/Path_(computing)

Note that raw strings are for regular expressions, not Windows paths. Raw 
strings can't end in a backslash, so you can't do this:

r'C:\My Documents\'

Instead, you can avoid having to escape backslashes by taking advantage 
of the fact that Windows will accept forward slashes as well as 
backslashes as path separators, and write 'C:/My Documents/' instead.

I assume you're familiar with the path-manipulation utilities in os.path?

 import os
 os.path.splitdrive('C://My Documents/My File.txt')
('C:', 'My Documents\\My File.txt')

I had to fake the above output because I'm not running Windows, so excuse 
me if I got it wrong.

But honestly, I think your biggest problem isn't finding a platform-
independent way of storing paths, but simply translating between each 
OS's conventions on where files should be stored.

In Linux, config files should go into:

~/.appname/ or /etc/appname/

In Windows (which versions?) then should go into the Documents And 
Settings folder, where ever that is.

There's no single string which can represent both of these conventions!



-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-19 Thread Duncan Booth
Steven D'Aprano [EMAIL PROTECTED] wrote:

 In Linux, config files should go into:
 
 ~/.appname/ or /etc/appname/
 
 In Windows (which versions?) then should go into the Documents And 
 Settings folder, where ever that is.
 
 There's no single string which can represent both of these conventions!

The first of those should do nicely for both Linux and Windows:

 os.path.normpath(os.path.expanduser('~/.appname'))
'C:\\Documents and Settings\\Duncan\\.appname'
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-19 Thread Duncan Booth
Steven D'Aprano [EMAIL PROTECTED] wrote:

 import os
 os.path.splitdrive('C://My Documents/My File.txt')
 ('C:', 'My Documents\\My File.txt')
 
 I had to fake the above output because I'm not running Windows, so
 excuse me if I got it wrong.

Not that it matters, but:

 os.path.splitdrive('C://My Documents/My File.txt')
('C:', '//My Documents/My File.txt')
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-19 Thread Grant Edwards
On 2008-10-19, Stef Mientki [EMAIL PROTECTED] wrote:

 I (again) wonder what's the perfect way to store, OS-independent, 
 filepaths ?

The question appears to me to be meaningless. File paths are
not OS independant, so an OS-independant way to store them
doesn't seem to be a useful thing to talk about.

-- 
Grant

--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-19 Thread Eric Wertman
 I (again) wonder what's the perfect way to store, OS-independent,
 filepaths ?

I'm in agreement that perfect probably isn't applicable.  If I were
doing this myself, I might store the information in a tuple:

base = 'some root structure ('/' or 'C')
path = ['some','set','of','path','names']
filename = 'somefile.ext'

pathdata = (root,path,filename)

and write a couple of simple functions to reconstruct them based on the os.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-19 Thread Stef Mientki

Eric Wertman wrote:

I (again) wonder what's the perfect way to store, OS-independent,
filepaths ?
  


I'm in agreement that perfect probably isn't applicable.  If I were
doing this myself, I might store the information in a tuple:

base = 'some root structure ('/' or 'C')
path = ['some','set','of','path','names']
filename = 'somefile.ext'

pathdata = (root,path,filename)

and write a couple of simple functions to reconstruct them based on the os.
  

Eric, I like your idea.
It looks like a workable technique,
the user should initial define the roots once and everything works.
It should even work for network drives and websites.

Duncan, in windows it's begin to become less common to store settings in 
DocsSettings,
because these directories are destroyed by roaming profiles (a big 
reason why I can't run Picassa ;-(
It's more common to follow the portable apps approach, store them in the 
application directory.


Drobinow, I want to distribute an application with a large number of 
docs and examples.
Now for this application I can put everything in subpaths of the 
main-application,
but you triggered me to put a warning in my code if I go outside the 
application path.

Another application I've in mind, is a data manager (now written in Delpi),
in which I organize all my information: docs, websites, measurement data 
etc.


Others, thank you for the ideas, you learende me some new os.path functions.

cheers,
Stef


--
http://mail.python.org/mailman/listinfo/python-list
  


--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-19 Thread Aaron Brady
Duncan Booth wrote:

 Steven D'Aprano [EMAIL PROTECTED] wrote:

 In Linux, config files should go into:
 
 ~/.appname/ or /etc/appname/
 
 In Windows (which versions?) then should go into the Documents And 
 Settings folder, where ever that is.
 
 There's no single string which can represent both of these conventions!

 The first of those should do nicely for both Linux and Windows:

 os.path.normpath(os.path.expanduser('~/.appname'))
 'C:\\Documents and Settings\\Duncan\\.appname'

A tuple of path elements, I would think.

 a= ( 'c:', 'windows', 'system' )
 a= ( '~', 'usr', 'bin' )
 a= ( '..', 'src' )

You'll want a subclass too, which has a file for the last name, instead 
of just folders.

 a= ( 'c:', 'python', 'python.exe' )

If '..' and '~' aren't universally, recognized, you'll want special
flags.

 DirUp= type( 'DirUp', (object,), { '__repr__': ( lambda self: 'DirUp' ) } 
 )()
 a= ( DirUp, 'src' )
 a
(DirUp, 'src')

As for rendering them, 'win', 'unix', and 'mac' could be methods.


--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-19 Thread Steven D'Aprano
On Sun, 19 Oct 2008 15:40:32 +, Duncan Booth wrote:

 Steven D'Aprano [EMAIL PROTECTED] wrote:
 
 In Linux, config files should go into:
 
 ~/.appname/ or /etc/appname/
 
 In Windows (which versions?) then should go into the Documents And
 Settings folder, where ever that is.
 
 There's no single string which can represent both of these conventions!
 
 The first of those should do nicely for both Linux and Windows:
 
 os.path.normpath(os.path.expanduser('~/.appname'))
 'C:\\Documents and Settings\\Duncan\\.appname'


Except Windows users will be wondering why they have a directory starting 
with '.' in their home directory. Dot to make files hidden is not AFAIK 
supported by Windows.



-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-19 Thread Steven D'Aprano
On Sun, 19 Oct 2008 20:50:46 +0200, Stef Mientki wrote:

 Duncan, in windows it's begin to become less common to store settings in
 DocsSettings,
 because these directories are destroyed by roaming profiles 

Isn't *everything* destroyed by roaming profiles? *wink*

Seriously, I don't know anyone who has anything nice to say about roaming 
profiles.


 (a big
 reason why I can't run Picassa ;-(
 It's more common to follow the portable apps approach, store them in the
 application directory.

User config files in a global directory? That bites.


 
-- 
Steven
--
http://mail.python.org/mailman/listinfo/python-list