Skip to content

This script draws a tree (in text mode) front of a set of tabulated text file (see example).

License

Notifications You must be signed in to change notification settings

achoum/drawtree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DrawTree

By Mathieu Guillame-bert [email protected]

Description

DrawTree is a command line tool used to augment recursive lists (i.e. trees).

Example

Input:

DoAny
	EatSomeFood [extends DoAll]
		EnsureItemInInventory(x,y=Food) [extends DoAny]
			HasItemInInventory(x,y)
			GetReachableItemFromGround(x,y) [extends DoAll]
				FindReachableItemOnGround(x,y)
				Goto(x)
				Grab(x)
			GetReachableItemFromContainer(x,y) [extends DoAll]
				FindReachableItemInContainer(x,y,z)
				Goto(z)
				GrabFromContainer(x,z)
		Eat(x)
	RandomWalk

Output:

DoAny
  |
  +--EatSomeFood [extends DoAll]
  |    |
  |    +--EnsureItemInInventory(x,y=Food) [extends DoAny]
  |    |    |
  |    |    +--HasItemInInventory(x,y)
  |    |    +--GetReachableItemFromGround(x,y) [extends DoAll]
  |    |    |    |
  |    |    |    +--FindReachableItemOnGround(x,y)
  |    |    |    +--Goto(x)
  |    |    |    +--Grab(x)
  |    |    +--GetReachableItemFromContainer(x,y) [extends DoAll]
  |    |         |
  |    |         +--FindReachableItemInContainer(x,y,z)
  |    |         +--Goto(z)
  |    |         +--GrabFromContainer(x,z)
  |    +--Eat(x)
  +--RandomWalk

Command line example:

echo -e "DoAny \n\
	EatSomeFood [extends DoAll] \n\
		EnsureItemInInventory(x,y=Food) [extends DoAny] \n\
			HasItemInInventory(x,y) \n\
			GetReachableItemFromGround(x,y) [extends DoAll] \n\
				FindReachableItemOnGround(x,y) \n\
				Goto(x) \n\
				Grab(x) \n\
			GetReachableItemFromContainer(x,y) [extends DoAll] \n\
				FindReachableItemInContainer(x,y,z) \n\
				Goto(z) \n\
				GrabFromContainer(x,z) \n\
		Eat(x) \n\
	RandomWalk" | python drawtree.py

Options

There is currently command line options. Instead, the options are modifiable by editing various constants defined at the top of the script.

These options are:

  • END_BRANCH: What to print in front of the last child (default: " +--")
  • INTERM_BRANCH: What to print in front of a child (which is not the last child) (default: " +--")
  • CONTINUITY: What to print to extand a branch (default:" | ")
  • NOTHING: What to print when there is nothing (default:" ")
  • ADD_SPACE: Should we skip a blank line between a node and its first child (default:True).

About

This script draws a tree (in text mode) front of a set of tabulated text file (see example).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages