Back to index

python3.2  3.2.2
Functions | Variables
checkpyc Namespace Reference

Functions

def main
def get_long

Variables

tuple cache_from_source

Function Documentation

def checkpyc.get_long (   s)

Definition at line 62 of file checkpyc.py.

00062 
00063 def get_long(s):
00064     if len(s) != 4:
00065         return -1
00066     return s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24)
00067 

Here is the call graph for this function:

Here is the caller graph for this function:

def checkpyc.main ( void  )

Definition at line 15 of file checkpyc.py.

00015 
00016 def main():
00017     if len(sys.argv) > 1:
00018         verbose = (sys.argv[1] == '-v')
00019         silent = (sys.argv[1] == '-s')
00020     else:
00021         verbose = silent = False
00022     MAGIC = imp.get_magic()
00023     if not silent:
00024         print('Using MAGIC word', repr(MAGIC))
00025     for dirname in sys.path:
00026         try:
00027             names = os.listdir(dirname)
00028         except os.error:
00029             print('Cannot list directory', repr(dirname))
00030             continue
00031         if not silent:
00032             print('Checking ', repr(dirname), '...')
00033         for name in sorted(names):
00034             if name.endswith('.py'):
00035                 name = os.path.join(dirname, name)
00036                 try:
00037                     st = os.stat(name)
00038                 except os.error:
00039                     print('Cannot stat', repr(name))
00040                     continue
00041                 if verbose:
00042                     print('Check', repr(name), '...')
00043                 name_c = cache_from_source(name)
00044                 try:
00045                     with open(name_c, 'rb') as f:
00046                         magic_str = f.read(4)
00047                         mtime_str = f.read(4)
00048                 except IOError:
00049                     print('Cannot open', repr(name_c))
00050                     continue
00051                 if magic_str != MAGIC:
00052                     print('Bad MAGIC word in ".pyc" file', end=' ')
00053                     print(repr(name_c))
00054                     continue
00055                 mtime = get_long(mtime_str)
00056                 if mtime in {0, -1}:
00057                     print('Bad ".pyc" file', repr(name_c))
00058                 elif mtime != st[ST_MTIME]:
00059                     print('Out-of-date ".pyc" file', end=' ')
00060                     print(repr(name_c))
00061 

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
00001 (imp.cache_from_source if hasattr(imp, 'get_tag') else
00002                      lambda path: path + 'c')

Definition at line 11 of file checkpyc.py.