Created
          April 21, 2011 15:56 
        
      - 
      
- 
        Save donghee/934828 to your computer and use it in GitHub Desktop. 
    Signature Survey in python
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/python | |
| # Signature Survey Python version | |
| # http://c2.com/doc/SignatureSurvey/ | |
| # 2011, Donghee Park | |
| import sys | |
| import re | |
| re_def = re.compile("def (.*):$") | |
| re_class = re.compile("^class (.*):$") | |
| for line in sys.stdin: | |
| if (r'"""' in line.strip()[0:3]) or ('\n' == line): | |
| continue | |
| if 'import ' in line: | |
| sys.stdout.write('i') | |
| continue | |
| if ' def ' in line: | |
| sys.stdout.write('\n') | |
| sys.stdout.write(' ') | |
| sys.stdout.write(re_def.findall(line)[0]) | |
| continue | |
| if 'class ' in line: | |
| sys.stdout.write('\n') | |
| sys.stdout.write(re_class.findall(line)[0]) | |
| continue | |
| if 'def ' in line: | |
| sys.stdout.write('\n') | |
| sys.stdout.write(re_def.findall(line)[0]) | |
| continue | |
| if ':\n' in line: | |
| sys.stdout.write(':') | |
| continue | |
| if not '#' in line: | |
| sys.stdout.write(';') | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment