1 |
hwoarang 09/02/26 11:50:50 |
2 |
|
3 |
Added: tempdir.patch |
4 |
Log: |
5 |
Initial import of chm2pdf program. Fixes bug #205208 |
6 |
(Portage version: 2.2_rc23/cvs/Linux x86_64) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 app-text/chm2pdf/files/tempdir.patch |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-text/chm2pdf/files/tempdir.patch?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-text/chm2pdf/files/tempdir.patch?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: tempdir.patch |
15 |
=================================================================== |
16 |
--- chm2pdf-0.9.1.orig/chm2pdf 2008-07-09 12:42:26.000000000 +0200 |
17 |
+++ chm2pdf-0.9.1/chm2pdf 2009-02-25 20:58:53.000000000 +0100 |
18 |
@@ -27,6 +27,8 @@ |
19 |
import os, os.path |
20 |
import re, glob |
21 |
import getopt |
22 |
+import tempfile |
23 |
+import shutil |
24 |
# from BeautifulSoup import BeautifulSoup |
25 |
|
26 |
global version |
27 |
@@ -39,8 +41,8 @@ |
28 |
global filename #the input filename |
29 |
|
30 |
version = '0.9.1' |
31 |
-CHM2PDF_TEMP_WORK_DIR='/tmp/chm2pdf/work' |
32 |
-CHM2PDF_TEMP_ORIG_DIR='/tmp/chm2pdf/orig' |
33 |
+CHM2PDF_TEMP_WORK_DIR=tempfile.mkdtemp() |
34 |
+CHM2PDF_TEMP_ORIG_DIR=tempfile.mkdtemp() |
35 |
|
36 |
|
37 |
|
38 |
@@ -299,16 +301,6 @@ |
39 |
# ########################### File extraction and correction: START ############################ |
40 |
# |
41 |
if options['dontextract'] == '': |
42 |
- |
43 |
- try: |
44 |
- os.mkdir(CHM2PDF_TEMP_WORK_DIR) |
45 |
- except OSError: # The directory already exists. |
46 |
- pass |
47 |
- |
48 |
- try: |
49 |
- os.mkdir(CHM2PDF_TEMP_ORIG_DIR) |
50 |
- except OSError: # The directory already exists. |
51 |
- pass |
52 |
|
53 |
try: |
54 |
os.mkdir(CHM2PDF_ORIG_DIR) |
55 |
@@ -620,7 +612,7 @@ |
56 |
print '\t--continuous\n\t\tSpecifies that the HTML sources are unstructured (plain web pages).\n\t\tNo page breaks are inserted between each file or URL in the output.' |
57 |
print '\t--cookies \'name="value with space"; name=value\'\n\t\t' |
58 |
print '\t--datadir directory\n\t\tSpecifies the location of the HTMLDOC data files, usually /usr/share/htmldoc or C:\Program Files\HTMLDOC ' |
59 |
- print "\t--dontextract \n\t\tIf given, %s will not extract the HTML files from the given CHM file, but will use previously extracted copies from the temporary directory " %name + '(i.e. ' + CHM2PDF_TEMP_ORIG_DIR + ' and ' + CHM2PDF_TEMP_WORK_DIR + '). Usually you will use this option after you have used the \'--extract-only\' option to extract the files in order to correct them manually (in ' + CHM2PDF_TEMP_WORK_DIR + '). After the correction, a call with \'--dontextract\' will not overwrite your changes, but will use the corrected files instead.' |
60 |
+# print "\t--dontextract \n\t\tIf given, %s will not extract the HTML files from the given CHM file, but will use previously extracted copies from the temporary directory " %name + '(i.e. ' + CHM2PDF_TEMP_ORIG_DIR + ' and ' + CHM2PDF_TEMP_WORK_DIR + '). Usually you will use this option after you have used the \'--extract-only\' option to extract the files in order to correct them manually (in ' + CHM2PDF_TEMP_WORK_DIR + '). After the correction, a call with \'--dontextract\' will not overwrite your changes, but will use the corrected files instead.' |
61 |
print '\t--duplex\n\t\tSpecifies that the output should be formatted for double-sided printing.' |
62 |
print '\t--effectduration {0.1..10.0}\n\t\tSpecifies the duration in seconds of PDF page transition effects.' |
63 |
print '\t--embedfonts\n\t\tSpecifies that fonts should be embedded in PDF output.' |
64 |
@@ -1084,13 +1076,6 @@ |
65 |
print 'CHM file "' + filename + '" not found!' |
66 |
return |
67 |
|
68 |
- #remove temporary files |
69 |
- if options['dontextract'] == '': |
70 |
- if options['verbose']=='--verbose' and options['verbositylevel']=='high': |
71 |
- print 'Removing any previous temporary files...' |
72 |
- os.system('rm -r '+CHM2PDF_ORIG_DIR+'/*') |
73 |
- os.system('rm -r '+CHM2PDF_WORK_DIR+'/*') |
74 |
- |
75 |
cfile = chm.CHMFile() |
76 |
cfile.LoadCHM(filename) |
77 |
|
78 |
@@ -1105,6 +1090,8 @@ |
79 |
os.system('extract_chmLib ' + filename + ' ' + CHM2PDF_ORIG_DIR + '&> /dev/null') |
80 |
|
81 |
convert_to_pdf(cfile, filename, outputfilename, options) |
82 |
+ shutil.rmtree(CHM2PDF_TEMP_WORK_DIR) |
83 |
+ shutil.rmtree(CHM2PDF_TEMP_ORIG_DIR) |
84 |
|
85 |
|
86 |
if __name__ == '__main__': |