Music_wrapper type.
* lily/paper-column.cc (print): print moment too.
* scripts/mup2ly.py (cp_to_dir): remove 1.5.2 compat glue.
remove compatibility cruft.
* lily/parser.yy (score_body): \score can only begin with Music.
* lily/score-scheme.cc (LY_DEFINE): rename scorify to
make-score. Take music argument only. Move parser interaction to
Scheme.
* scm/lily-library.scm (scorify-music): new function.
* python/lilylib.py (datadir): remove 2.1 compat kludge.
(datadir): remove resource import.
(print_environment): remove get_bbox()
(cp_to_dir): remove pre 1.5.2 compat glue.
+2005-07-10 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * scm/define-music-types.scm (music-descriptions): don't use
+ Music_wrapper type.
+
+ * lily/paper-column.cc (print): print moment too.
+
+ * scripts/mup2ly.py (cp_to_dir): remove 1.5.2 compat glue.
+ remove compatibility cruft.
+
+ * lily/parser.yy (score_body): \score can only begin with Music.
+
+ * lily/score-scheme.cc (LY_DEFINE): rename scorify to
+ make-score. Take music argument only. Move parser interaction to
+ Scheme.
+
+ * scm/lily-library.scm (scorify-music): new function.
+
+ * python/lilylib.py (datadir): remove 2.1 compat kludge.
+ (datadir): remove resource import.
+ (print_environment): remove get_bbox()
+ (cp_to_dir): remove pre 1.5.2 compat glue.
+
2005-07-09 Han-Wen Nienhuys <hanwen@xs4all.nl>
* lily/include/simple-spacer.hh (Module): idem.
#ifndef MUSIC_WRAPPER_HH
#define MUSIC_WRAPPER_HH
-#include "music.hh"
-#include "pitch.hh"
+#include "lily-guile.hh"
-/** A Music that modifies an existing Music. This data structure
- corresponds to a production that takes a single Music argument,
-
- Music: STUFF Music
-*/
-class Music_wrapper : public Music
+struct Music_wrapper
{
public:
- Music_wrapper (SCM);
- VIRTUAL_COPY_CONSTRUCTOR (Music, Music_wrapper);
DECLARE_SCHEME_CALLBACK (length_callback, (SCM));
DECLARE_SCHEME_CALLBACK (start_callback, (SCM));
-
- Music *element () const;
};
#endif /* MUSIC_WRAPPER_HH */
Score (Score const &);
SCM get_music () const;
- void set_music (SCM music, SCM parser);
+ void set_music (SCM music);
SCM book_rendering (Output_def *, Output_def *, Object_key *);
};
DECLARE_UNSMOB (Score, score);
void default_rendering (SCM, SCM, SCM, SCM, SCM, SCM);
-SCM ly_music_scorify (SCM, SCM);
SCM ly_render_output (SCM, SCM);
SCM ly_run_translator (SCM, SCM, SCM);
void
Music_wrapper_iterator::construct_children ()
{
- Music *m = dynamic_cast<Music_wrapper const *> (get_music ())->element ();
- child_iter_ = unsmob_iterator (get_iterator (m));
+ Music *my_music = get_music ();
+ Music *child = unsmob_music (my_music->get_property ("element"));
+ child_iter_ = unsmob_iterator (get_iterator (child));
}
bool
#include "music-wrapper.hh"
-Music_wrapper::Music_wrapper (SCM x)
- : Music (x)
-{
- if (!ly_c_procedure_p (length_callback_))
- length_callback_ = length_callback_proc;
- if (!ly_c_procedure_p (start_callback_))
- start_callback_ = length_callback_proc;
-}
+#include "music.hh"
+
MAKE_SCHEME_CALLBACK (Music_wrapper, start_callback, 1);
SCM
return elt->get_length ().smobbed_copy ();
}
-Music *
-Music_wrapper::element () const
-{
- return unsmob_music (get_property ("element"));
-}
-
-ADD_MUSIC (Music_wrapper);
-
Moment
Music::start_mom () const
{
- SCM lst = get_property ("start-callback");
+ SCM lst = start_callback_;
if (ly_c_procedure_p (lst))
{
SCM res = scm_call_1 (lst, self_scm ());
Grob *me = unsmob_grob (p);
String r = to_string (Paper_column::get_rank (me));
+
+ Moment *mom = unsmob_moment (me->get_property ("when"));
+ String when = mom ? mom->to_string () : "?/?";
+
SCM properties = Font_interface::text_font_alist_chain (me);
SCM scm_mol = Text_interface::interpret_markup (me->get_layout ()->self_scm (),
properties,
scm_makfrom0str (r.to_str0 ()));
+ SCM when_mol = Text_interface::interpret_markup (me->get_layout ()->self_scm (),
+ properties,
+ scm_makfrom0str (when.to_str0 ()));
Stencil t = *unsmob_stencil (scm_mol);
+ t.add_at_edge (Y_AXIS, DOWN, *unsmob_stencil (when_mol), 0.1, 0.1);
t.align_to (X_AXIS, CENTER);
t.align_to (Y_AXIS, DOWN);
;
score_body:
- /**/ {
- $$ = new Score;
+ Music {
+ SCM m = $1->self_scm ();
+ scm_gc_unprotect_object (m);
+ SCM scorify = ly_lily_module_constant ("scorify-music");
+ SCM score = scm_call_2 (scorify, m, THIS->self_scm ());
+
+ // pass ownernship to C++ again.
+ scm_gc_protect_object (score);
+ $$ = unsmob_score (score);
$$->set_spot (@$);
}
| SCORE_IDENTIFIER {
| score_body object_id_setting {
$$->user_key_ = ly_scm2string ($2);
}
- | score_body Music {
- SCM m = $2->self_scm ();
- scm_gc_unprotect_object (m);
- $$->set_music (m, THIS->self_scm ());
- }
| score_body lilypond_header {
$$->header_ = $2;
}
#include "output-def.hh"
#include "global-context.hh"
-LY_DEFINE (ly_music_scorify, "ly:music-scorify",
- 2, 0, 0,
- (SCM music, SCM parser),
- "Return @var{music} with @var{texts} encapsulated in @var{score}.")
+LY_DEFINE (ly_make_score, "ly:make-score",
+ 1, 0, 0,
+ (SCM music),
+ "Return score with @var{music} encapsulated in @var{score}.")
{
Music *mus = unsmob_music (music);
SCM_ASSERT_TYPE (mus, music, SCM_ARG1, __FUNCTION__, "music");
Score *score = new Score;
- score->set_music (music, parser);
+ score->set_music (music);
SCM self = score->self_scm ();
scm_gc_unprotect_object (self);
}
void
-Score::set_music (SCM music, SCM parser)
+Score::set_music (SCM music)
{
- /* URG? */
- SCM check_funcs = ly_lily_module_constant ("toplevel-music-functions");
- for (; scm_is_pair (check_funcs); check_funcs = scm_cdr (check_funcs))
- music = scm_call_2 (scm_car (check_funcs), music, parser);
-
if (unsmob_music (music_))
{
unsmob_music (music)->origin ()->error (_ ("already have music in score"));
/*
- unfolded-repeat-iterator.cc -- implement Unfolded_repeat_iterator, Volta_repeat_iterator
-
+ unfolded-repeat-iterator.cc -- implement Unfolded_repeat_iterator
+
source file of the GNU LilyPond music typesetter
-
(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
return l;
}
-class Volta_repeat_iterator : public Sequential_iterator
-{
-public:
- DECLARE_SCHEME_CALLBACK (constructor, ());
- Volta_repeat_iterator ();
-
- void add_repeat_command (SCM);
-protected:
- virtual SCM get_music_list () const;
- virtual void next_element (bool);
- virtual void construct_children ();
- virtual void process (Moment);
-
- bool first_time_;
- int alt_count_;
- int rep_count_;
- int done_count_;
-};
-
-Volta_repeat_iterator::Volta_repeat_iterator ()
-{
- done_count_ = alt_count_ = rep_count_ = 0;
- first_time_ = true;
-}
-
-SCM
-Volta_repeat_iterator::get_music_list ()const
-{
- return scm_cons (get_music ()->get_property ("element"),
- get_music ()->get_property ("elements"));
-}
-
-void
-Volta_repeat_iterator::construct_children ()
-{
- Sequential_iterator::construct_children ();
-
- SCM alts = get_music ()->get_property ("elements");
-
- alt_count_ = scm_ilength (alts);
- rep_count_ = scm_to_int (get_music ()->get_property ("repeat-count"));
- done_count_ = 0;
-}
-
-/*
- TODO: add source information for debugging
-*/
-void
-Volta_repeat_iterator::add_repeat_command (SCM what)
-{
- SCM reps = ly_symbol2scm ("repeatCommands");
- SCM current_reps = get_outlet ()->internal_get_property (reps);
-
- Context *where = get_outlet ()->where_defined (reps);
- if (where
- && current_reps == SCM_EOL || scm_is_pair (current_reps))
- {
- current_reps = scm_cons (what, current_reps);
- where->internal_set_property (reps, current_reps);
- }
-}
-
-void
-Volta_repeat_iterator::next_element (bool side_effect)
-{
- done_count_++;
-
- Sequential_iterator::next_element (side_effect);
-
- if (side_effect)
- {
- if (alt_count_)
- {
- String repstr = to_string (rep_count_ - alt_count_ + done_count_) + ".";
- if (done_count_ > 1)
- {
- add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), SCM_BOOL_F, SCM_UNDEFINED));
-
- if (done_count_ - 1 < alt_count_)
- add_repeat_command (ly_symbol2scm ("end-repeat"));
- }
-
- if (done_count_ == 1 && alt_count_ < rep_count_)
- {
- repstr = "1.--" + to_string (rep_count_ - alt_count_ + done_count_) + ".";
- }
-
- if (done_count_ <= alt_count_)
- add_repeat_command (scm_list_n (ly_symbol2scm ("volta"),
- scm_makfrom0str (repstr.to_str0 ()), SCM_UNDEFINED));
- }
- else
- {
- add_repeat_command (ly_symbol2scm ("end-repeat"));
- }
- }
-}
-
-void
-Volta_repeat_iterator::process (Moment m)
-{
- if (first_time_)
- {
- add_repeat_command (ly_symbol2scm ("start-repeat"));
- first_time_ = false;
- }
- Sequential_iterator::process (m);
-}
-
-IMPLEMENT_CTOR_CALLBACK (Volta_repeat_iterator);
IMPLEMENT_CTOR_CALLBACK (Unfolded_repeat_iterator);
--- /dev/null
+/*
+ volta-repeat-iterator.cc -- implement Volta_repeat_iterator
+
+ source file of the GNU LilyPond music typesetter
+
+
+ (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+
+#include "music.hh"
+#include "sequential-iterator.hh"
+#include "context.hh"
+
+class Volta_repeat_iterator : public Sequential_iterator
+{
+public:
+ DECLARE_SCHEME_CALLBACK (constructor, ());
+ Volta_repeat_iterator ();
+
+ void add_repeat_command (SCM);
+protected:
+ virtual SCM get_music_list () const;
+ virtual void next_element (bool);
+ virtual void construct_children ();
+ virtual void process (Moment);
+
+ bool first_time_;
+ int alt_count_;
+ int rep_count_;
+ int done_count_;
+};
+
+Volta_repeat_iterator::Volta_repeat_iterator ()
+{
+ done_count_ = alt_count_ = rep_count_ = 0;
+ first_time_ = true;
+}
+
+SCM
+Volta_repeat_iterator::get_music_list ()const
+{
+ return scm_cons (get_music ()->get_property ("element"),
+ get_music ()->get_property ("elements"));
+}
+
+void
+Volta_repeat_iterator::construct_children ()
+{
+ Sequential_iterator::construct_children ();
+
+ SCM alts = get_music ()->get_property ("elements");
+
+ alt_count_ = scm_ilength (alts);
+ rep_count_ = scm_to_int (get_music ()->get_property ("repeat-count"));
+ done_count_ = 0;
+}
+
+/*
+ TODO: add source information for debugging
+*/
+void
+Volta_repeat_iterator::add_repeat_command (SCM what)
+{
+ SCM reps = ly_symbol2scm ("repeatCommands");
+ SCM current_reps = get_outlet ()->internal_get_property (reps);
+
+ Context *where = get_outlet ()->where_defined (reps);
+ if (where
+ && current_reps == SCM_EOL || scm_is_pair (current_reps))
+ {
+ current_reps = scm_cons (what, current_reps);
+ where->internal_set_property (reps, current_reps);
+ }
+}
+
+void
+Volta_repeat_iterator::next_element (bool side_effect)
+{
+ done_count_++;
+
+ Sequential_iterator::next_element (side_effect);
+
+ if (side_effect)
+ {
+ if (alt_count_)
+ {
+ String repstr = to_string (rep_count_ - alt_count_ + done_count_) + ".";
+ if (done_count_ > 1)
+ {
+ add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), SCM_BOOL_F, SCM_UNDEFINED));
+
+ if (done_count_ - 1 < alt_count_)
+ add_repeat_command (ly_symbol2scm ("end-repeat"));
+ }
+
+ if (done_count_ == 1 && alt_count_ < rep_count_)
+ {
+ repstr = "1.--" + to_string (rep_count_ - alt_count_ + done_count_) + ".";
+ }
+
+ if (done_count_ <= alt_count_)
+ add_repeat_command (scm_list_n (ly_symbol2scm ("volta"),
+ scm_makfrom0str (repstr.to_str0 ()), SCM_UNDEFINED));
+ }
+ else
+ {
+ add_repeat_command (ly_symbol2scm ("end-repeat"));
+ }
+ }
+}
+
+void
+Volta_repeat_iterator::process (Moment m)
+{
+ if (first_time_)
+ {
+ add_repeat_command (ly_symbol2scm ("start-repeat"));
+ first_time_ = false;
+ }
+ Sequential_iterator::process (m);
+}
+
+IMPLEMENT_CTOR_CALLBACK (Volta_repeat_iterator);
### subst: \(help_summary\|keep_temp_dir_p\|option_definitions\|original_dir\|program_name\|pseudo_filter_p\|temp_dir\|verbose_p\)
import __main__
+import getopt
+import glob
+import os
+import re
import shutil
import string
import sys
import tempfile
-import glob
################################################################
# Users of python modules should include this snippet
# If set, LILYPONDPREFIX must take prevalence
# if datadir is not set, we're doing a build and LILYPONDPREFIX
-import getopt
-import os
-import sys
datadir = '@local_lilypond_datadir@'
if not os.path.isdir (datadir):
datadir = '@lilypond_datadir@'
-# Customize these
-
-# UGH. - why? Py2exe barfs
-if __name__ == '__main__':
- import lilylib as ly
- global _;_=ly._
- global re;re = ly.re
-
- # lilylib globals
- program_name = 'unset'
- pseudo_filter_p = 0
- original_dir = os.getcwd ()
- temp_dir = os.path.join (original_dir, '%s.dir' % program_name)
- keep_temp_dir_p = 0
- verbose_p = 0
-
- help_summary = _ ("lilylib module")
-
- option_definitions = [
- ('', 'h', 'help', _ ("print this help")),
- ]
-
- from lilylib import *
-################################################################
-
-# Handle bug in Python 1.6-2.1
-#
-# there are recursion limits for some patterns in Python 1.6 til 2.1.
-# fix this by importing pre instead. Fix by Mats.
-
-
-# Ugh. py2exe barfs on conditional imports
-if float (sys.version[0:3]) <= 2.1:
- try:
- import pre
- re = pre
- del pre
- except ImportError:
- import re
-else:
- import re
-
-# Attempt to fix problems with limited stack size set by Python!
-# Sets unlimited stack size. Note that the resource module only
-# is available on UNIX.
-
-
-# Ugh. py2exe barfs on conditional imports
-try:
- import resource
- resource.setrlimit (resource.RLIMIT_STACK, (-1, -1))
-except:
- pass
localedir = '@localedir@'
try:
return (short, long)
def option_help_str (o):
- '''Transform one option description (4-tuple ) into neatly formatted string'''
+ '''Transform one option description (4-tuple) into neatly formatted string'''
sh = ' '
if o[1]:
sh = '-%s' % o[1]
map (lambda x, d=dir: shutil.copy2 (x, os.path.join (d, x)), files)
-# Python < 1.5.2 compatibility
-#
-# On most platforms, this is equivalent to
-#`normpath(join(os.getcwd()), PATH)'. *Added in Python version 1.5.2*
-
-if os.path.__dict__.has_key ('abspath'):
- abspath = os.path.abspath
-else:
- def abspath (path):
- return os.path.normpath (os.path.join (os.getcwd (), path))
-
-if os.__dict__.has_key ('makedirs'):
- makedirs = os.makedirs
-else:
- def makedirs (dir, mode=0777):
- system ('mkdir -p %s' % dir)
-
-
-
def search_exe_path (name):
p = os.environ['PATH']
exe_paths = string.split (p, ':')
for (k,v) in os.environ.items ():
sys.stderr.write ("%s=\"%s\"\n" % (k, v))
-BOUNDING_BOX_RE = '^%%BoundingBox: (-?[0-9]+) (-?[0-9]+) (-?[0-9]+) (-?[0-9]+)'
-def get_bbox (filename):
- bbox = filename + '.bbox'
- ## -sOutputFile does not work with bbox?
- cmd = 'gs -sDEVICE=bbox -q -dNOPAUSE %s -c showpage -c quit 2>%s' % \
- (filename, bbox)
- system (cmd, progress_p = 1)
- box = open (bbox).read ()
- m = re.match (BOUNDING_BOX_RE, box)
- gr = []
- if m:
- gr = map (string.atoi, m.groups ())
-
- return gr
-
def make_ps_images (ps_name, resolution = 90, papersize = "a4",
rename_page1_p = 0):
(before-line-breaking-callback . ,Paper_column::before_line_breaking)
(X-extent-callback . ,Axis_group_interface::group_extent_callback)
-; (print-function . ,Paper_column::print) (font-name . "ecrm8") (Y-extent-callback . #f)
+ ;; debugging
+;; (print-function . ,Paper_column::print) (font-size . -6) (font-name . "sans") (Y-extent-callback . #f)
(meta . ((interfaces . (paper-column-interface axis-group-interface spaceable-grob-interface item-interface ))))
))
(X-extent-callback . ,Axis_group_interface::group_extent_callback)
(before-line-breaking-callback . ,Paper_column::before_line_breaking)
(breakable . #t)
+
;; debugging stuff: print column number.
-; (print-function . ,Paper_column::print) (font-name . "ecrm8") (Y-extent-callback . #f)
+;; (print-function . ,Paper_column::print) (font-size . -6) (font-name . "sans") (Y-extent-callback . #f)
(meta . ((interfaces . (paper-column-interface axis-group-interface spaceable-grob-interface item-interface ))))
(AutoChangeMusic
. (
(description . "Used for making voices that switch between piano staves automatically.")
-
- (internal-class-name . "Music_wrapper")
+ (internal-class-name . "Music")
(iterator-ctor . ,Auto_change_iterator::constructor)
+ (start-callback . ,Music_wrapper::start_callback)
+ (length-callback . ,Music_wrapper::length_callback)
(types . (general-music music-wrapper-music auto-change-instruction))
))
(BarCheck
. (
(description . "Interpret the argument music within a specific context.")
(iterator-ctor . ,Context_specced_music_iterator::constructor)
- (internal-class-name . "Music_wrapper")
+ (length-callback . ,Music_wrapper::length_callback)
+ (start-callback . ,Music_wrapper::start_callback)
+ (internal-class-name . "Music")
(types . (context-specification general-music music-wrapper-music))
))
(GraceMusic
. (
(description . "Interpret the argument as grace notes. ")
- (internal-class-name . "Music_wrapper")
+ (internal-class-name . "Music")
(start-callback . ,Grace_music::start_callback)
(length . ,(ly:make-moment 0 1))
(iterator-ctor . ,Grace_iterator::constructor)
(QuoteMusic
. (
(description . "Quote preprocessed snippets of music. ")
- (internal-class-name . "Music_wrapper")
+ (internal-class-name . "Music")
(iterator-ctor . ,Quote_iterator::constructor)
(types . (general-music))
))
Syntax @code{\\times @var{fraction} @var{music}}, e.g.
@code{\\times 2/3 @{ ... @}} for triplets.
")
- (internal-class-name . "Music_wrapper")
+ (internal-class-name . "Music")
+ (length-callback . ,Music_wrapper::length_callback)
+ (start-callback . ,Music_wrapper::start_callback)
(iterator-ctor . ,Time_scaled_music_iterator::constructor)
(types . (time-scaled-music music-wrapper-music general-music))
))
(TransposedMusic
. (
(description . "Music that has been transposed.")
- (internal-class-name . "Music_wrapper")
+ (internal-class-name . "Music")
+ (iterator-ctor . ,Music_wrapper_iterator::constructor)
+ (start-callback . ,Music_wrapper::start_callback)
+ (length-callback . ,Music_wrapper::length_callback)
(to-relative-callback . ,Relative_octave_music::no_relative_callback)
(types . (music-wrapper-music general-music transposed-music))
))
(description . "Music that can not be converted from relative to absolute notation.
For example, transposed music.")
(to-relative-callback . ,Relative_octave_music::no_relative_callback)
- (internal-class-name . "Music_wrapper")
+ (iterator-ctor . ,Music_wrapper_iterator::constructor)
+ (length-callback . ,Music_wrapper::length_callback)
+ (internal-class-name . "Music")
(types . (music-wrapper-music general-music unrelativable-music))
))
. (
(description . "Music that was entered in relative octave notation.")
(to-relative-callback . ,Relative_octave_music::relative_callback)
- (internal-class-name . "Music_wrapper")
+ (iterator-ctor . ,Music_wrapper_iterator::constructor)
+ (length-callback . ,Music_wrapper::length_callback)
+ (start-callback . ,Music_wrapper::start_callback)
+ (internal-class-name . "Music")
(types . (music-wrapper-music general-music relative-octave-music))
))
(ScriptEvent
(ly:parser-define
parser 'toplevel-scores
(cons score (ly:parser-lookup parser 'toplevel-scores))))
-
+
+
+(define-public (scorify-music music parser)
+
+ (for-each (lambda (func)
+ (set! music (func music parser)))
+ toplevel-music-functions)
+
+; (display-scheme-music music)
+ (ly:make-score music))
+
+
(define-public (collect-music-for-book parser music)
- (collect-scores-for-book parser (ly:music-scorify music parser)))
+ (collect-scores-for-book parser (scorify-music music parser)))
;;;;;;;;;;;;;;;;
;; switch-on-debugging
(lambda (x parser) (music-map cue-substitute x))
-; (lambda (x parser) (music-map display-scheme-music x))
+
))
ly:music-mutable-properties
ly:music-name
ly:music-property
- ly:music-scorify
+ ly:make-score
ly:music-set-property!
ly:music-transpose
ly:music?
_ ("show warranty and copyright")),
]
-include_path = [ly.abspath (os.getcwd ())]
+include_path = [os.path.abspath (os.getcwd ())]
lilypond_binary = os.path.join ('@bindir@', 'lilypond')
# Only use installed binary when we are installed too.
#(set! toplevel-score-handler ly:parser-print-score)
#(set! toplevel-music-handler (lambda (p m)
(ly:parser-print-score
- p (ly:music-scorify m p))))
+ p (scorify-music m p))))
#(ly:set-option (quote no-point-and-click))
sys.exit (0)
elif o == '--include' or o == '-I':
include_path.append (os.path.join (original_dir,
- ly.abspath (a)))
+ os.path.abspath (a)))
elif o == '--output' or o == '-o':
output_name = a
elif o == '--process' or o == '-P':
#
# source file of the GNU LilyPond music typesetter
-# Handle bug in Python 1.6-2.1
-#
-# there are recursion limits for some patterns in Python 1.6 til 2.1.
-# fix this by importing pre instead. Fix by Mats.
-
-# todo: should check Python version first.
-try:
- import pre
- re = pre
- del pre
-except ImportError:
- import re
-
-# Attempt to fix problems with limited stack size set by Python!
-# Sets unlimited stack size. Note that the resource module only
-# is available on UNIX.
-try:
- import resource
- resource.setrlimit (resource.RLIMIT_STACK, (-1, -1))
-except:
- pass
-
try:
import gettext
gettext.bindtextdomain ('lilypond', localedir)
map (lambda x, d=dir: shutil.copy2 (x, os.path.join (d, x)), files)
-# Python < 1.5.2 compatibility
-#
-# On most platforms, this is equivalent to
-#`normpath(join(os.getcwd()), PATH)'. *Added in Python version 1.5.2*
-if os.path.__dict__.has_key ('abspath'):
- abspath = os.path.abspath
-else:
- def abspath (path):
- return os.path.normpath (os.path.join (os.getcwd (), path))
-
-if os.__dict__.has_key ('makedirs'):
- makedirs = os.makedirs
-else:
- def makedirs (dir, mode=0777):
- system ('mkdir -p %s' % dir)
-
-
def mkdir_p (dir, mode=0777):
if not os.path.isdir (dir):
makedirs (dir, mode)