4 The Blender.sys submodule.
9 B{New}: L{exists}, L{makename}.
11 This module provides a minimal set of helper functions and data. Its purpose
12 is to avoid the need for the standard Python module 'os', in special 'os.path',
13 though it is only meant for the simplest cases.
20 def f(name): # file selector callback
24 Blender.Window.FileSelector(f)
27 print 'basename:', Blender.sys.basename(filename)
28 print 'dirname:', Blender.sys.dirname(filename)
29 print 'splitext:', Blender.sys.splitext(filename)
31 # what would basename(splitext(filename)[0]) print?
34 @var sep: the platform-specific dir separator for this Blender: '/'
35 everywhere, except on Win systems, that use '\\'.
37 @var dirsep: same as L{sep}.
38 @type progname: string
39 @var progname: the Blender executable (argv[0]).
41 @attention: The module is called sys, not Sys.
46 Get the base name (filename stripped from dir info) of 'path'.
48 @param path: a path name
50 @return: the base name
55 Get the dir name (dir path stripped from filename) of 'path'.
57 @param path: a path name
64 Split 'path' into (root, ext), where 'ext' is a file extension.
66 @param path: a path name
67 @rtype: list with two strings
71 def makename (path = "Blender.Get('filename')", ext = "", strip = 0):
73 Remove extension from 'path', append extension 'ext' (if given)
74 to the result and return it. If 'strip' is non-zero, also remove
79 from Blender.sys import *
80 print makename('/path/to/myfile.txt','.abc', 1) # returns 'myfile.abc'
82 print makename('/path/to/myfile.obj', '-01.obj') # '/path/to/myfile-01.obj'
84 print makename('/path/to/myfile.txt', strip = 1) # 'myfile'
87 print makename(ext = '.txt')
89 print sys.splitext(Blender.Get('filename'))[0]) + '.txt'
92 @param path: a path name or Blender.Get('filename'), if not given.
94 @param ext: an extension to append. For flexibility, a dot ('.') is
95 not automatically included.
97 @return: the resulting string
102 Tell if the given pathname (file or dir) exists.
104 @return: 1 if 'path' exists, 0 otherwise.
109 Get the current time in seconds since a fixed value. Successive calls to
110 this function are garanteed to return values greater than the previous call.
112 @return: the elapsed time in seconds.