summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpsachin2013-07-31 12:20:13 +0530
committerpsachin2013-07-31 12:20:13 +0530
commit9643c51f416d32851fce6b36a9a269b02d57f21e (patch)
tree8f3254aa261fdd1a0c5e213d3876dba93cdbcf7a
parentb843fb855e7d15c2af7d5553ab0a3187680d6f56 (diff)
downloadtbc-auto-checker-9643c51f416d32851fce6b36a9a269b02d57f21e.tar.gz
tbc-auto-checker-9643c51f416d32851fce6b36a9a269b02d57f21e.tar.bz2
tbc-auto-checker-9643c51f416d32851fce6b36a9a269b02d57f21e.zip
Subject: sorting of file-names w.r.t chapter number
Description: - sorting - added usage in ReadMe.md
-rw-r--r--ReadMe.md55
-rwxr-xr-xauto.sh20
2 files changed, 73 insertions, 2 deletions
diff --git a/ReadMe.md b/ReadMe.md
index 549eb83..ecff640 100644
--- a/ReadMe.md
+++ b/ReadMe.md
@@ -1,4 +1,57 @@
# tbc-auto-checker
### Auto checker script for Scilab Textbook Companion.
-### Please visit [http://scilab.in/Textbook_Companion_Project](http://scilab.in/Textbook_Companion_Project) for more info.
+### Usage
+
+* Clone this repository
+
+```bash
+git clone https://github.com/Scilab-India/tbc-auto-checker.git
+```
+
+* Change path to this directory
+
+```bash
+cd tbc-auto-checker
+```
+
+* Place ZIP file(s) of book(s) in this directory and run the script
+
+```bash
+bash auto.sh
+```
+
+### Output
+
+* The output log files and error log files will be generated
+separately.
+
+#### text output
+
+* Text output will be stored in `output_<book-name>.log` file.
+
+#### graph output
+
+* You have to set a variable `SCI_GRAPH_PATH` to a path where you want
+all the graphs to be stored.
+
+* Graphs with text output will be stored in
+ `output_graph_<book-name>.log` file
+
+#### errors
+
+* **for text based errors**: `error_<book-name>.log`
+
+* **for graph based errors**: `error_graph_<book-name>.log`
+
+#### Warning
+
+* All output are first stored in a variable and then written to
+ respective files. You may run out of memory sometimes.
+
+#### Site
+
+Please visit
+[http://scilab.in/Textbook_Companion_Project](http://scilab.in/Textbook_Companion_Project)
+for more info.
+
diff --git a/auto.sh b/auto.sh
index be67efc..6e01b6a 100755
--- a/auto.sh
+++ b/auto.sh
@@ -52,7 +52,25 @@ function scan_sce_for_errors() {
# make a list of all .sce file(with complete path). Exclude
# scanning 'DEPENDENCIES' DIR
- SCE_FILE_LIST=$(find ${ZIPFILE} -type f -iname "*.sce" ! -path "*/DEPENDENCIES*")
+
+ # That awk command says the field separator FS is set to /; this
+ # affects the way it reads fields. The output field separator OFS
+ # is set to "."; this affects the way it prints records. This is
+ # intentionally done so that 'cut' will take "." as a field
+ # Seperator during final sort operation. The next statement says
+ # print the last column (NF is the number of fields in the record,
+ # so it also happens to be the index of the last field) as well as
+ # the whole record ($0 is the whole record); it will print them
+ # with the OFS between them. Then the list is sorted, treating _
+ # as the field separator - since we have the filename first in the
+ # record, it will sort by that. Then the cut prints only fields 3
+ # through the end, again treating "." as the field separator.
+
+ SCE_FILE_LIST=$(find ${ZIPFILE} -type f -iname "*.sce" ! \
+ -path "*/DEPENDENCIES*" | \
+ awk -vFS=/ -vOFS="." '{print $NF,$0}' | \
+ sort -n -t _ -k1 -k2 | cut -d"." -f3-)
+
SCE_FILE_COUNT=$(echo "${SCE_FILE_LIST}" | wc -l)
echo -e "Total number of .sce files(without counting DEPENDENCIES directory): ${SCE_FILE_COUNT}\n" >> ./output_${ZIPFILE}.log