-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documents examples of CLI tools. All docs pass. All tests pass. Demo …
…is the same.
- Loading branch information
Showing
5 changed files
with
158 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,20 @@ | |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Paul Ross: [email protected] | ||
""" | ||
DupeRelink.py -- Searches for HTML files that are the same, writes a single | ||
"""This can be used after CPIP has processed a directory of code. | ||
In that case there are usually multiple copies of the HTML for common header | ||
files which wastes a lot of disk space. | ||
DupeRelink.py searches for HTML files that are the same, writes a single | ||
file into a common area and deletes all the others. Then re-links all the | ||
remaining HTML files that linked to the original files to link to the file | ||
remaining HTML files that linked to the original file to link to the file | ||
in the common area. This is a space saving optimisation after CPIPMain.py | ||
has processed a directory of source files. | ||
Typically this can halve the disk space needed. | ||
It only needs a single argument, the output directory of CPIPMain.py. | ||
.. code-block:: console | ||
(CPIP36) $ python src/cpip/DupeRelink.py --help | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,28 @@ | |
# Paul Ross: [email protected] | ||
"""Provides a command line tool for finding out information on files: | ||
Help: | ||
.. code-block:: console | ||
$ python src/cpip/FileStatus.py --help | ||
Cmd: src/cpip/FileStatus.py --help | ||
Usage: FileStatus.py [options] dir | ||
Counts files and sizes. | ||
Options: | ||
--version show program's version number and exit | ||
-h, --help show this help message and exit | ||
-g GLOB, --glob=GLOB Space separated list of file match patterns. [default: | ||
*.py] | ||
-l LOGLEVEL, --loglevel=LOGLEVEL | ||
Log Level (debug=10, info=20, warning=30, error=40, | ||
critical=50) [default: 30] | ||
-r Recursive. [default: False] | ||
Example: | ||
.. code-block:: console | ||
$ python3 src/cpip/FileStatus.py -r src/cpip/ | ||
|
@@ -161,24 +183,7 @@ def write(self, theS=sys.stdout): | |
theS.write('\n') | ||
|
||
def main(): | ||
"""Prints out the status of files in a directory: | ||
.. code-block:: console | ||
$ python ../src/cpip/FileStatus.py --help | ||
Cmd: ../src/cpip/FileStatus.py --help | ||
Usage: FileStatus.py [options] dir | ||
Counts files and sizes. | ||
Options: | ||
--version show program's version number and exit | ||
-h, --help show this help message and exit | ||
-g GLOB, --glob=GLOB Space separated list of file match patterns. [default: | ||
*.py] | ||
-l LOGLEVEL, --loglevel=LOGLEVEL | ||
Log Level (debug=10, info=20, warning=30, error=40, | ||
critical=50) [default: 30] | ||
-r Recursive. [default: False] | ||
"""Main entry point. | ||
""" | ||
usage = """usage: %prog [options] dir | ||
Counts files and sizes.""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,51 @@ | |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Paul Ross: [email protected] | ||
"""Command line tool to list included file paths | ||
"""Command line tool to list included file paths. | ||
Help: | ||
.. code-block:: none | ||
Usage: IncList.py [options] files... | ||
Preprocess the files and lists included files. | ||
Options: | ||
--version show program's version number and exit | ||
-h, --help show this help message and exit | ||
-k Keep going. [default: False] | ||
-l LOGLEVEL, --loglevel=LOGLEVEL | ||
Log Level (debug=10, info=20, warning=30, error=40, | ||
critical=50) [default: 30] | ||
-n Nervous mode (do no harm). [default: False] | ||
-p Ignore pragma statements. [default: False] | ||
-I INCUSR, --usr=INCUSR | ||
Add user include search path. [default: []] | ||
-J INCSYS, --sys=INCSYS | ||
Add system include search path. [default: []] | ||
-P PREINC, --pre=PREINC | ||
Add pre-include file path. [default: []] | ||
-D DEFINES, --define=DEFINES | ||
Add macro defintions of the form name<=defintion>. | ||
These are introduced into the environment before any | ||
pre-include. [default: []] | ||
Example from the CPIP directory: | ||
.. code-block:: console | ||
(CPIP36) $ src/cpip/IncList.py -l20 -J demo/sys/ -I demo/usr/ demo/src/main.cpp | ||
2017-11-17 11:24:40,597 INFO Preprocessing TU: demo/src/main.cpp | ||
2017-11-17 11:24:40,605 INFO Preprocessing TU done. | ||
2017-11-17 11:24:40,606 INFO All done. | ||
---------------------------- Included files [3] --------------------------- | ||
demo/src/main.cpp | ||
demo/sys/system.h | ||
demo/usr/user.h | ||
------------------------------ Included files ----------------------------- | ||
CPU time = 0.009 (S) | ||
Bye, bye! | ||
""" | ||
__author__ = 'Paul Ross' | ||
__date__ = '2011-07-10' | ||
|
@@ -90,30 +134,6 @@ def preProcessForIncludes(theItu, incUsr, incSys, theDefineS, preIncS, keepGoing | |
def main(): | ||
"""Main command line entry point. Help: | ||
.. code-block:: none | ||
Usage: IncList.py [options] files... | ||
Preprocess the files and lists included files. | ||
Options: | ||
--version show program's version number and exit | ||
-h, --help show this help message and exit | ||
-k Keep going. [default: False] | ||
-l LOGLEVEL, --loglevel=LOGLEVEL | ||
Log Level (debug=10, info=20, warning=30, error=40, | ||
critical=50) [default: 30] | ||
-n Nervous mode (do no harm). [default: False] | ||
-p Ignore pragma statements. [default: False] | ||
-I INCUSR, --usr=INCUSR | ||
Add user include search path. [default: []] | ||
-J INCSYS, --sys=INCSYS | ||
Add system include search path. [default: []] | ||
-P PREINC, --pre=PREINC | ||
Add pre-include file path. [default: []] | ||
-D DEFINES, --define=DEFINES | ||
Add macro defintions of the form name<=defintion>. | ||
These are introduced into the environment before any | ||
pre-include. [default: []] | ||
""" | ||
usage = """usage: %prog [options] files... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
# | ||
# Paul Ross: [email protected] | ||
""" | ||
cpip.cpp -- Pretends to be like cpp, Will take options and a file (or stdin) | ||
cpp.py -- Pretends to be like cpp, Will take options and a file (or stdin) | ||
and process it. | ||
@author: Paul Ross | ||
|
@@ -76,6 +76,60 @@ | |
-J INCSYS, --sys INCSYS | ||
Add system include search path. [default: []] | ||
Example: | ||
.. code-block:: console | ||
(CPIP36) $ python src/cpip/cpp.py -E -J demo/sys/ -I demo/usr/ demo/src/main.cpp | ||
----------------------------- Translation unit ---------------------------- | ||
int main(char **argv, int argc) | ||
{ | ||
printf("Bonjour tout le monde\\n"); | ||
return 1; | ||
} | ||
-------------------------- END: Translation unit -------------------------- | ||
Using ``-t`` to show tokens: | ||
.. code-block:: console | ||
(CPIP36) $ python src/cpip/cpp.py -t -E -J demo/sys/ -I demo/usr/ demo/src/main.cpp | ||
----------------------------- Translation unit ---------------------------- | ||
PpToken(t="\\n", tt=whitespace, line=False, prev=False, ?=False) | ||
PpToken(t="int", tt=identifier, line=True, prev=False, ?=False) | ||
PpToken(t=" ", tt=whitespace, line=False, prev=False, ?=False) | ||
PpToken(t="main", tt=identifier, line=True, prev=False, ?=False) | ||
PpToken(t="(", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False) | ||
PpToken(t="char", tt=identifier, line=True, prev=False, ?=False) | ||
PpToken(t=" ", tt=whitespace, line=False, prev=False, ?=False) | ||
PpToken(t="*", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False) | ||
PpToken(t="*", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False) | ||
PpToken(t="argv", tt=identifier, line=True, prev=False, ?=False) | ||
PpToken(t=",", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False) | ||
PpToken(t=" ", tt=whitespace, line=False, prev=False, ?=False) | ||
PpToken(t="int", tt=identifier, line=True, prev=False, ?=False) | ||
PpToken(t=" ", tt=whitespace, line=False, prev=False, ?=False) | ||
PpToken(t="argc", tt=identifier, line=True, prev=False, ?=False) | ||
PpToken(t=")", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False) | ||
PpToken(t="\\n", tt=whitespace, line=False, prev=False, ?=False) | ||
PpToken(t="{", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False) | ||
PpToken(t="\\n", tt=whitespace, line=False, prev=False, ?=False) | ||
PpToken(t="printf", tt=identifier, line=True, prev=False, ?=False) | ||
PpToken(t="(", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False) | ||
PpToken(t=""Bonjour tout le monde\\n"", tt=string-literal, line=False, prev=False, ?=False) | ||
PpToken(t=")", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False) | ||
PpToken(t=";", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False) | ||
PpToken(t="\\n", tt=whitespace, line=False, prev=False, ?=False) | ||
PpToken(t="return", tt=identifier, line=True, prev=False, ?=False) | ||
PpToken(t=" ", tt=whitespace, line=False, prev=False, ?=False) | ||
PpToken(t="1", tt=pp-number, line=False, prev=False, ?=False) | ||
PpToken(t=";", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False) | ||
PpToken(t="\\n", tt=whitespace, line=False, prev=False, ?=False) | ||
PpToken(t="}", tt=preprocessing-op-or-punc, line=False, prev=False, ?=False) | ||
PpToken(t="\\n", tt=whitespace, line=False, prev=False, ?=False) | ||
-------------------------- END: Translation unit -------------------------- | ||
""" | ||
from __future__ import print_function | ||
|
||
|