Re: Using the --include switch

Bram Moolenaar <[email protected]>
Newsgroups gmane.comp.tools.aap.user
Message-ID <[email protected]>
Scott Witscher wrote:

> Does the --include switch work?  The test case below gives me the
> following error.  Is this just a bug?

This just wasn't implemented yet.  You could call it a bug in the
documentation.  But it's quite simple to add:

*** Commands.py.orig	Fri Oct  3 11:32:33 2003
--- Commands.py	Fri Oct  3 11:48:41 2003
***************
*** 2365,2372 ****
      if len(args) != 1:
          recipe_error(rpstack, _(":include requires one argument"))
      args = dictlist_expand(args)
- 
      recname = args[0]["name"]
      if optiondict.get("once") and did_read_recipe(work, recname):
          msg_extra(recdict, _('Skipping recipe already read: %s"') % recname)
          return
--- 2365,2381 ----
      if len(args) != 1:
          recipe_error(rpstack, _(":include requires one argument"))
      args = dictlist_expand(args)
      recname = args[0]["name"]
+ 
+     includelist = Global.cmd_args.options.get("include")
+     if not os.path.isabs(recname) and recname[0] != '.' and includelist:
+         # Search for the recipe in the list of include directories.
+         for dir in [ "." ] + includelist:
+             n = os.path.join(dir, recname)
+             if os.path.isfile(n):
+                 recname = n
+                 break
+ 
      if optiondict.get("once") and did_read_recipe(work, recname):
          msg_extra(recdict, _('Skipping recipe already read: %s"') % recname)
          return
***************
*** 2375,2389 ****
      if ((Global.cmd_args.has_option("fetch-recipe")
              or not os.path.exists(recname))
                  and args[0].has_key("fetch")):
!         fullname = full_fname(recname)
          if not recipe_fetched.has_key(fullname):
              from VersCont import fetch_nodelist
  
              # Create a node for the recipe and fetch it.
!             node = work.get_node(recname, 0, args[0])
              if fetch_nodelist(rpstack, recdict, [ node ], 0):
                  msg_warning(recdict,
!                                    _('Could not update recipe "%s"') % recname)
  
              # Also mark it as updated when it failed, don't try again.
              recipe_fetched[fullname] = 1
--- 2384,2402 ----
      if ((Global.cmd_args.has_option("fetch-recipe")
              or not os.path.exists(recname))
                  and args[0].has_key("fetch")):
!         # Use the original recipe name, without the directory of "-I dir" added.
!         fetchname = args[0]["name"]
!         fullname = full_fname(fetchname)
          if not recipe_fetched.has_key(fullname):
              from VersCont import fetch_nodelist
  
              # Create a node for the recipe and fetch it.
!             node = work.get_node(fetchname, 0, args[0])
              if fetch_nodelist(rpstack, recdict, [ node ], 0):
                  msg_warning(recdict,
!                                  _('Could not update recipe "%s"') % fetchname)
!             else:
!                 recname = fetchname
  
              # Also mark it as updated when it failed, don't try again.
              recipe_fetched[fullname] = 1

-- 
hundred-and-one symptoms of being an internet addict:
87. Everyone you know asks why your phone line is always busy ...and
    you tell them to send an e-mail.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.