My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
res2cc_cmd.File Class Reference
Inheritance diagram for res2cc_cmd.File:
res2cc_cmd.CSSFile res2cc_cmd.LumaFile res2cc_cmd.LumFile res2cc_cmd.VerbatimFile

Public Member Functions

def __init__
 
def formatByte
 
def writeBytes
 
def convertToBytes
 

Static Public Member Functions

def factory
 

Public Attributes

 directory
 
 subdir
 
 fileName
 
 fileSize
 
 bareName
 
 inputFile
 

Detailed Description

Definition at line 22 of file res2cc_cmd.py.

Constructor & Destructor Documentation

def res2cc_cmd.File.__init__ (   self,
  directory,
  subdir,
  fileName,
  mode 
)

Definition at line 23 of file res2cc_cmd.py.

23 
24  def __init__(self,directory,subdir,fileName,mode):
25  self.directory = directory
26  self.subdir = subdir
27  self.fileName = fileName
28  filePath = join(directory,subdir,fileName)
29  self.fileSize = stat(filePath).st_size
30  self.bareName = fileName.replace('.','_')
31  self.inputFile = open(filePath,mode)

Member Function Documentation

def res2cc_cmd.File.convertToBytes (   self,
  outputFile 
)

Definition at line 48 of file res2cc_cmd.py.

References split(), and res2cc_cmd.File.writeBytes().

Referenced by res2cc_cmd.LumFile.writeContents(), and res2cc_cmd.LumaFile.writeContents().

48 
49  def convertToBytes(self,outputFile):
50  lines = [x for x in self.inputFile.readlines() if not x.startswith('#')]
51  w,h = (int(x) for x in lines[0].split())
52  data = "".join(map(chr,[int(w>>8),int(w&0xFF),int(h>>8),int(h&0xFF)]+
53  [int(x) for line in lines[1:] for x in line.split()]))
54  self.writeBytes(data,outputFile)
def res2cc_cmd.File.factory (   directory,
  subdir,
  fname 
)
static

Definition at line 56 of file res2cc_cmd.py.

56 
57  def factory(directory,subdir,fname):
58  ext = splitext(fname)[1]
59  if ext=='.lum': return LumFile(directory,subdir,fname)
60  if ext=='.luma': return LumaFile(directory,subdir,fname)
61  if ext=='.css': return CSSFile(directory,subdir,fname)
62  return VerbatimFile(directory,subdir,fname)
def res2cc_cmd.File.formatByte (   self,
  byte 
)

Definition at line 32 of file res2cc_cmd.py.

Referenced by res2cc_cmd.File.writeBytes().

32 
33  def formatByte(self,byte):
34  if isinstance(byte,int):
35  return "%02x" % byte
36  else:
37  return format(ord(byte),'02x')
def res2cc_cmd.File.writeBytes (   self,
  data,
  outputFile 
)

Definition at line 38 of file res2cc_cmd.py.

References res2cc_cmd.File.bareName, and res2cc_cmd.File.formatByte().

Referenced by res2cc_cmd.File.convertToBytes(), res2cc_cmd.VerbatimFile.writeContents(), and res2cc_cmd.CSSFile.writeContents().

38 
39  def writeBytes(self,data,outputFile):
40  bytes_per_line=16
41  print("static const unsigned char %s_data[] = " % self.bareName,file=outputFile)
42  print("{",file=outputFile)
43  lines = [data[x:x+bytes_per_line] for x in range(0,len(data),bytes_per_line)]
44  linesAsString = ',\n '.join([', '.join(['0x'+self.formatByte(byte) for byte in line]) for line in lines])
45  print(' %s' % linesAsString,file=outputFile)
46  print("};",file=outputFile)
47  print("const int %s_len = %d;\n" % (self.bareName,len(data)),file=outputFile)

Member Data Documentation

res2cc_cmd.File.bareName

Definition at line 29 of file res2cc_cmd.py.

Referenced by res2cc_cmd.File.writeBytes(), res2cc_cmd.VerbatimFile.writeDirEntry(), res2cc_cmd.CSSFile.writeDirEntry(), res2cc_cmd.LumFile.writeDirEntry(), and res2cc_cmd.LumaFile.writeDirEntry().

res2cc_cmd.File.directory

Definition at line 24 of file res2cc_cmd.py.

res2cc_cmd.File.fileName

Definition at line 26 of file res2cc_cmd.py.

Referenced by res2cc_cmd.VerbatimFile.writeDirEntry(), res2cc_cmd.CSSFile.writeDirEntry(), res2cc_cmd.LumFile.writeDirEntry(), and res2cc_cmd.LumaFile.writeDirEntry().

res2cc_cmd.File.fileSize

Definition at line 28 of file res2cc_cmd.py.

res2cc_cmd.File.inputFile

Definition at line 30 of file res2cc_cmd.py.

res2cc_cmd.File.subdir

Definition at line 25 of file res2cc_cmd.py.

Referenced by res2cc_cmd.VerbatimFile.writeDirEntry(), res2cc_cmd.CSSFile.writeDirEntry(), res2cc_cmd.LumFile.writeDirEntry(), and res2cc_cmd.LumaFile.writeDirEntry().


The documentation for this class was generated from the following file: