cparse

Current version: 0.0.2
Github
PyPi

Installation

Use pip via PyPi:

pip install cparse

Or clone the repository:

git clone git://github.com/luciancooper/cparse.git
cd cparse
python setup.py install

Usage

cparse is a command line tool. There are currently 6 subcommands:

ls list files in directory
tree print file tree
stat directory filetype stats
py python code parsing
html html link parsing
css css code parsing

ls

The ls command lists the files in a directory

Usage

cparse ls [-r] [-n <depth>] [-d | -f] [-a] [-lim <count>] [-fmt <format>]
          [-exc <path>] [-inc <path>]
          [-wc <pattern>] [-grep <regexp>] [-ft <filetype>]
          [-m | -M | -c | -C | -b | -B | -i | -I | -g | -G] <path>

Positional Arguments

<path> root directory

Optional Arguments

-r list files recursively
-n <depth> max depth if recursive flag is specified
-d dirs only flag
-f files only flag
-a include hidden files
-lim <count> maximum items to list in output
-fmt <format> display format for listed items

Sorting Flags

Control the order in which files are listed. Only one of the following flags can be specified.

-m sort by modified time (most recent first)
-M sort by modified time (least recent first)
-c sort by created time (newest first)
-C sort by created time (oldest first)
-b sort by size (largest first)
-B sort by size (smallest first)
-i sort by inode (descending)
-I sort by inode (ascending)
-g group files by file extension (descending)
-G group files by file extension (ascending)

Pruning Arguments

Control which sub directories to include when recursive flag is specified. These arguments can be specified multiple times.

-exc <path> sub paths to exclude
-inc <path> sub paths to include

Filtering Arguments

Apply filters to control which files are listed.

-wc <pattern> wild card pattern
-grep <regular-expression> regular expression to match
-ft <file-extension> file type filter

tree

The tree command prints file trees

Usage

cparse tree [-d | -f] [-a] [-n <depth>] [-fmt <format>]
            [-exc <path>] [-inc <path>]
            [-wc <pattern>] [-grep <regular-expression>] [-ft <file-extension>]
            [-m | -M | -c | -C | -b | -B | -i | -I | -g | -G] <path>

Positional Arguments

<path> tree root directory

Optional Arguments

-d dirs only flag
-f files only flag (ignore empty directories)
-a include hidden files
-n <depth> max tree depth
-fmt <format> display format for tree nodes

Sorting Flags

Control the order in which files are listed within each branch of the tree. Only one of the following flags can be specified.

-m sort by modified time (most recent first)
-M sort by modified time (least recent first)
-c sort by created time (newest first)
-C sort by created time (oldest first)
-b sort by size (largest first)
-B sort by size (smallest first)
-i sort by inode (descending)
-I sort by inode (ascending)
-g group files by file extension (descending)
-G group files by file extension (ascending)

Pruning Arguments:

Control which sub directories to include in tree. These arguments can be specified multiple times.

-exc <path> sub paths to exclude from tree
-inc <path> sub paths to include in tree

Filtering Arguments

Apply filters to control which files are included in the tree.

-wc <pattern> wild card pattern
-grep <regular-expression> regular expression to match
-ft <file-extension> file type filter

stat

The stat command produces a table displaying directory filetype proportions

Usage

cparse stat [-a] <path>

Positional Arguments

<path> root directory

Optional Arguments

-a include hidden files

py

The py command parses python code files

Usage

cparse py <path>

Positional Arguments

<path> either a directory to search for .py files in, or a .py file

html

The html command parses the links in html files

Usage

cparse html <path>

Positional Arguments

<path> either a directory to search for html files in, or a html file

css

The css command parses css code

Usage

cparse css [-g] [-c] [-s] <path>

Positional Arguments

<path> a css file to parse

Optional Arguments

-g group identical selector property blocks
-c condense redundancies within property blocks
-s stack matching selectors in output