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__ (self, directory, subdir, fileName, mode)
 
def formatByte (self, byte)
 
def writeBytes (self, data, outputFile)
 
def convertToBytes (self, outputFile)
 

Static Public Member Functions

def factory (directory, subdir, fname)
 

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  def __init__(self,directory,subdir,fileName,mode):
24  self.directory = directory
25  self.subdir = subdir
26  self.fileName = fileName
27  filePath = join(directory,subdir,fileName)
28  self.fileSize = stat(filePath).st_size
29  self.bareName = fileName.replace('.','_')
30  self.inputFile = open(filePath,mode)
31 
int open(const char *, int)
Opens a file descriptor.
def __init__(self, directory, subdir, fileName, mode)
Definition: res2cc_cmd.py:23

Member Function Documentation

def res2cc_cmd.File.convertToBytes (   self,
  outputFile 
)

Definition at line 48 of file res2cc_cmd.py.

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

Definition at line 56 of file res2cc_cmd.py.

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

Definition at line 32 of file res2cc_cmd.py.

32  def formatByte(self,byte):
33  if isinstance(byte,int):
34  return "%02x" % byte
35  else:
36  return format(ord(byte),'02x')
37 
def formatByte(self, byte)
Definition: res2cc_cmd.py:32
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
def res2cc_cmd.File.writeBytes (   self,
  data,
  outputFile 
)

Definition at line 38 of file res2cc_cmd.py.

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

Member Data Documentation

res2cc_cmd.File.bareName

Definition at line 29 of file res2cc_cmd.py.

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.

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.


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