Back to index

python3.2  3.2.2
Functions
fixheader Namespace Reference

Functions

def main
def process

Function Documentation

def fixheader.main ( void  )

Definition at line 7 of file fixheader.py.

00007 
00008 def main():
00009     args = sys.argv[1:]
00010     for filename in args:
00011         process(filename)

Here is the call graph for this function:

Here is the caller graph for this function:

def fixheader.process (   filename)

Definition at line 12 of file fixheader.py.

00012 
00013 def process(filename):
00014     try:
00015         f = open(filename, 'r')
00016     except IOError as msg:
00017         sys.stderr.write('%s: can\'t open: %s\n' % (filename, str(msg)))
00018         return
00019     data = f.read()
00020     f.close()
00021     if data[:2] != '/*':
00022         sys.stderr.write('%s does not begin with C comment\n' % filename)
00023         return
00024     try:
00025         f = open(filename, 'w')
00026     except IOError as msg:
00027         sys.stderr.write('%s: can\'t write: %s\n' % (filename, str(msg)))
00028         return
00029     sys.stderr.write('Processing %s ...\n' % filename)
00030     magic = 'Py_'
00031     for c in filename:
00032         if ord(c)<=0x80 and c.isalnum():
00033             magic = magic + c.upper()
00034         else: magic = magic + '_'
00035     sys.stdout = f
00036     print('#ifndef', magic)
00037     print('#define', magic)
00038     print('#ifdef __cplusplus')
00039     print('extern "C" {')
00040     print('#endif')
00041     print()
00042     f.write(data)
00043     print()
00044     print('#ifdef __cplusplus')
00045     print('}')
00046     print('#endif')
00047     print('#endif /*', '!'+magic, '*/')

Here is the call graph for this function:

Here is the caller graph for this function: