fsltool

Fsltool is a command-line tool for File Selection Language. It takes the root directory and one or more rule files as parameter and outputs a list of files. Optionally, it can print statistics about the files included.

Usage

usage: fsltool.py [options] <source-filenames>

options:
  -h, --help            show this help message and exit
  --ast                 Print Abstract Syntax Tree only, don't run interpreter
  -d                    Print detailed information
  -l                    Print reLative filename instead of absolute
  --lexer               Print lexer output only, don't run interpreter
  -o OUTFILE            Write file list into file instead of stdout
  -q                    Surround file name with quote marks
  -r ROOTDIR            Root directory for relative filenames [.]
  --reldir=PRINTING_RELATIVE_DIR
                        With -l, print filenames relative to this directory
                        instead of "."
  -s                    Print statistics about the files included
  -t STATS_LIMIT        Threshold in bytes for -s to print directory stats at
                        scan time [1]

Example, basic

In the following example, fsltool.py was run in the FSL directory with ../doc as root directory for relative glob patterns. The only rule in rule.fsl is *. The files are printed relative to the ../ directory (-l and --reldir options).

[~/src/python/fsl/fsl] python fsltool.py -r ../doc -l --reldir ../ rule.fsl
doc/devel/architecture.dia
doc/devel/ast.dia
doc/devel/desing.txt
doc/devel/frontend.dia
doc/devel/interpreter.dia
doc/fsl.css
doc/fsltool.html
doc/fsltool.html.bak
doc/grammar.txt
doc/index.html
doc/language.html
doc/todo.txt

Example, statistics

In the following example, fsltool.py was run with the FSL directory . as root directory and the statistics option -s on. With -s, fsltool doesn't print filenames (except with -o).

[~/src/python/fsl/fsl] python fsltool.py rule.fsl -l -s
   3 files,    343 B test/fsltool_files
  52 files,   5.4 KB test/interpreter_files
  20 files,    818 B test/lexer_files
   1 files,  22.7 KB test/old
   3 files,    125 B test/testdir/dir xyz
   2 files,    120 B test/testdir/dir1/dir2/dir3
   3 files,    130 B test/testdir/dir1/dir2
   5 files,    275 B test/testdir/dir1
  16 files,    850 B test/testdir
 119 files, 153.5 KB test
 158 files, 327.2 KB .

TOTAL   :   158 files, 327.2 KB, avg size   2.1 KB

*.py    :    32 files, 176.2 KB, avg size   5.5 KB, 54%
*.pyc   :    26 files, 141.7 KB, avg size   5.4 KB, 43%
*.      :    91 files,   8.0 KB, avg size     89 B,  2%
*.txt   :     2 files,   1.0 KB, avg size    508 B,  0%
*.sh    :     2 files,    244 B, avg size    122 B,  0%
*.bak   :     1 files,     85 B, avg size     85 B,  0%
*.exe   :     1 files,     30 B, avg size     30 B,  0%
*.fst   :     1 files,      9 B, avg size      9 B,  0%
*.fsl   :     1 files,      1 B, avg size      1 B,  0%
*.hidden:     1 files,      0 B, avg size      0 B,  0%

* Directories *
 39 files, 173.7 KB, 53% .
 27 files, 123.4 KB, 38% test
  1 files,  22.7 KB,  7% test/old
 52 files,   5.4 KB,  2% test/interpreter_files
 20 files,    818 B,  0% test/lexer_files
  8 files,    450 B,  0% test/testdir
  3 files,    343 B,  0% test/fsltool_files
  2 files,    145 B,  0% test/testdir/dir1
  3 files,    125 B,  0% test/testdir/dir xyz
  2 files,    120 B,  0% test/testdir/dir1/dir2/dir3

* Files *
37.5 KB  test/test_interpreter.py
32.0 KB  test/test_interpreter.pyc
22.7 KB  test/old/test_interpreter_old.py
15.4 KB  fslparser.py
12.7 KB  Interpreter.py
11.0 KB  AST.pyc
10.8 KB  fslparser.pyc
10.8 KB  Interpreter.pyc
9.0 KB   fsltool.py
8.5 KB   AST.py


Up: FSL index
Updated 2005-08-21