ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/DII_Kreator.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
File size: 2727 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
1 ninoborges 8 ## DII_Kreator.py
2     ## This is going to be a program that will create a summaito DII file from a dir of files (tiff and txt).
3     ## It will traverse subfolders and preserve them in the file. It should also give you the option of where to
4     ## start the @I line.
5     ## EBorges
6     ## 02.05.04
7    
8     import os
9     # "Old Way"
10     import FreeImagePy
11     # "new way"
12     #import FreeImagePy as FIPY
13     from FixBatesRange_func import SeperateAlpha
14    
15     def AddEntry(args,dirName, fileNames):
16     """This function should NOT be Changed! It is required by other programs.
17     REQUIRES: List of extension,newDII,delimeterDir packed in args."""
18     output = open(args[1],'a')
19     FIPY = FreeImagePy.freeimage()
20     #print args
21     #print dirName
22     #print fileNames
23     for file in fileNames:
24     if os.path.splitext(file)[1].upper() == args[0].upper():
25     #if os.path.splitext(file)[1] == '.txt':
26     ##if os.path.splitext(file)[1] == '.TIF':
27     #if os.path.splitext(file)[1] == '.PDF':
28     # Prefix is no more
29     #begBates = args[0] + os.path.splitext(file)[0]
30     begBates = os.path.splitext(file)[0]
31     print dirName
32     if args[3] == "Y":
33     # This is sup to be the New way but it dosent close the file
34     #F = FIPY.Image(dirName + "\\" + file)
35     #pageCount = F.getNumPages()
36     # "Old way" which works
37     image = FIPY.openMulti(dirName + "\\" + file)
38     pageCount = FIPY.GetPageCount(image)
39     endDocAlpha, endDocInt = SeperateAlpha(begBates)
40     output.write("@C EndDoc# %s\n"% (endDocAlpha + str(endDocInt + pageCount -1)))
41     output.write("@C Pgcount %d\n"% pageCount)
42     #del F
43     FIPY.CloseMultiBitmap(image)
44     pathAndFile = dirName.split(args[2])[1] + '\\' + file
45     #pathAndFile = dirName.split('temp\\')[1] + '\\' + file
46     ##pathAndFile = dirName.split('images\\')[1] + '\\' + file
47     #pathAndFile = dirName.split('Images')[1] + '\\' + file
48     output.write("@T %s\n"%begBates.upper())
49     output.write("@D @I\n")
50     output.write("%s\n"%pathAndFile)
51     output.write("\n")
52     output.close()
53     FIPY.DeInitialise()
54    
55    
56    
57     if __name__ == "__main__":
58     startDir = r"\\mwcase01\images3\Prod\BAD_LP-001_C_1-22-07"
59     #startDir = r"c:\temp\carry"
60     delimeterDir,nul = os.path.split(startDir)
61     fileIntroSpectFlag = "Y"
62     #prefix = ""
63     extension = ".TIF"
64     newDII = startDir + r'\newDII.DII'
65     args = [extension,newDII,delimeterDir, fileIntroSpectFlag]
66     os.path.walk(startDir,AddEntry,args)