Exemple #1
0
def get_api_from_file(filename):
    """
        @filename - source file to parse and extract API symbols
        @return - string - API definition

        Extract API symbols from a source file.
    """
    lex = None

# start language definitions - sorted by lang name

    if filename.lower().endswith('.java'):
        lex = lexers.JavaLexer()
        lex.add_filter(filters.JavaAPIFilter())
    elif filename.lower().endswith('.php'):
        lex = lexers.PhpLexer(startinline=True)
        lex.add_filter(filters.PHPAPIFilter())
    elif filename.lower().endswith('.py'):
        lex = lexers.PythonLexer()
        lex.add_filter(filters.PythonAPIFilter())


# end language definitions

    if lex:
        code = open(filename, 'r').read()
        return highlight(code, lex, NullFormatter())+"\n"
    else:
        return None
Exemple #2
0
    def handle(self, *args, **options):

        try:
            from pygments import lexers
        except ImportError:
            self.stdout.write("This command requires Pygments package.")
            self.stdout.write("Please install it with:\n\n")
            self.stdout.write("  pip install Pygments\n\n")
            return

        # Invocation examples
        _process("bash_curl", lexers.BashLexer())
        _process("bash_wget", lexers.BashLexer())
        _process("browser", lexers.JavascriptLexer())
        _process("crontab", lexers.BashLexer())
        _process("node", lexers.JavascriptLexer())
        _process("python_urllib2", lexers.PythonLexer())
        _process("python_requests", lexers.PythonLexer())
        _process("php", lexers.PhpLexer())
        _process("powershell", lexers.shell.PowerShellLexer())
        _process("powershell_inline", lexers.shell.BashLexer())
        _process("ruby", lexers.RubyLexer())

        # API examples
        _process("list_checks_request", lexers.BashLexer())
        _process("list_checks_response", lexers.JsonLexer())
        _process("create_check_request_a", lexers.BashLexer())
        _process("create_check_request_b", lexers.BashLexer())
        _process("update_check_request_a", lexers.BashLexer())
        _process("update_check_request_b", lexers.BashLexer())
        _process("create_check_response", lexers.JsonLexer())
        _process("pause_check_request", lexers.BashLexer())
        _process("pause_check_response", lexers.JsonLexer())
        _process("delete_check_request", lexers.BashLexer())
Exemple #3
0
 def handle(self, *args, **options):
     _process("bash.txt", "bash.html", lexers.BashLexer())
     _process("browser.txt", "browser.html", lexers.JavascriptLexer())
     _process("crontab.txt", "crontab.html", lexers.BashLexer())
     _process("python.txt", "python.html", lexers.PythonLexer())
     _process("php.txt", "php.html", lexers.PhpLexer())
     _process("node.txt", "node.html", lexers.JavascriptLexer())
Exemple #4
0
    def handle(self, *args, **options):

        try:
            from pygments import lexers
        except ImportError:
            self.stdout.write("This command requires the Pygments package.")
            self.stdout.write("Please install it with:\n\n")
            self.stdout.write("  pip install Pygments\n\n")
            return

        # Invocation examples
        _process("bash_curl", lexers.BashLexer())
        _process("bash_wget", lexers.BashLexer())
        _process("browser", lexers.JavascriptLexer())
        _process("crontab", lexers.BashLexer())
        _process("cs", lexers.CSharpLexer())
        _process("node", lexers.JavascriptLexer())
        _process("go", lexers.GoLexer())
        _process("python_urllib2", lexers.PythonLexer())
        _process("python_requests", lexers.PythonLexer())
        _process("python_requests_fail", lexers.PythonLexer())
        _process("python_requests_start", lexers.PythonLexer())
        _process("python_requests_payload", lexers.PythonLexer())
        _process("php", lexers.PhpLexer())
        _process("powershell", lexers.shell.PowerShellLexer())
        _process("powershell_inline", lexers.shell.BashLexer())
        _process("ruby", lexers.RubyLexer())
Exemple #5
0
    def handle(self, *args, **options):

        try:
            from pygments import lexers
        except ImportError:
            self.stdout.write("This command requires Pygments package.")
            self.stdout.write("Please install it with:\n\n")
            self.stdout.write("  pip install Pygments\n\n")
            return

        _process("bash.txt", "bash.html", lexers.BashLexer())
        _process("browser.txt", "browser.html", lexers.JavascriptLexer())
        _process("crontab.txt", "crontab.html", lexers.BashLexer())
        _process("python.txt", "python.html", lexers.PythonLexer())
        _process("php.txt", "php.html", lexers.PhpLexer())
        _process("powershell.txt", "powershell.html",
                 lexers.shell.PowerShellLexer())
        _process("node.txt", "node.html", lexers.JavascriptLexer())