Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/gutextract.py
diff options
context:
space:
mode:
authorJames Simmons <jim@localhost.simmons>2009-05-17 01:39:38 (GMT)
committer James Simmons <jim@localhost.simmons>2009-05-17 01:39:38 (GMT)
commitb1dff4db9f276115f5070d6d32870016b9137995 (patch)
treedaf178638080b642dca82cc0081ee3d4c20d2b9c /gutextract.py
parent31da2c006d068a1121974fe23806b5ffaa47d45a (diff)
modified: MANIFEST
modified: ReadEtextsActivity.py new file: gutextract.py modified: readtoolbar.py
Diffstat (limited to 'gutextract.py')
-rwxr-xr-xgutextract.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/gutextract.py b/gutextract.py
new file mode 100755
index 0000000..9bcdd15
--- /dev/null
+++ b/gutextract.py
@@ -0,0 +1,62 @@
+#! /usr/bin/env python
+
+# Copyright (C) 2008 James D. Simmons
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import getopt
+import sys
+
+# This is a script to take the file GUTINDEX.ALL, the offline book catalog of Project Gutenberg,
+# and reformat it for use by Read Etexts. After the file gutoutput.txt is created it should be sorted
+# to create bookcatalog.txt.
+
+def main(file_path):
+
+ gut_file = open(file_path,"r")
+ out = open("gutoutput.txt", 'w')
+
+ while gut_file:
+ line = gut_file.readline()
+ if not line:
+ break
+ if len(line) > 78:
+ if line[77].isdigit() and line.find("Audio:") < 0 and line[59] != '[':
+ i = 73
+ path = ''
+ name = ''
+ while i < 77:
+ if line[i] != ' ':
+ path = path + '/' + line[i]
+ name = name + line[i]
+ i = i + 1
+ name = name + line[77]
+ path = path + '/' + name + '/' + name
+ line = line[0:73]
+ line = line.rstrip()
+ line = line.replace(', by ', '|')
+ out.write(line + '|' + path + '\n')
+ gut_file.close()
+ out.close()
+ print "All done!"
+
+if __name__ == "__main__":
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "")
+ main(args[0])
+ except getopt.error, msg:
+ print msg
+ print "This program has no options"
+ sys.exit(2)