Giter Club home page Giter Club logo

codetype's Introduction

codetype Build Status Python Support

codetype is a Python library and command-line tool for identifying the language of source code snippets and files. It's fast, simple and accurate. You can test it out here.

See my blog post for more information.

Installation

Using pip
pip install codetype
From source
$ git clone https://github.com/jdkato/codetype.git
$ cd codetype
$ python setup.py install

Usage

Python
>>> from codetype import identify
>>> identify('fibs = 0 : 1 : zipWith (+) fibs (tail fibs)')
'Haskell'
>>> identify('from math import fabs')
'Python'
>>> src = """
class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}"""
>>> identify(src)
'Java'
>>> identify('/path/to/ruby/file.txt')
'Ruby'
CLI
usage: codetype [-h] [--version] [-v] [-m MAX] [-o ONLY [ONLY ...]] file

A source code identification tool.

positional arguments:
  file                  path to unknown source code

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -v, --verbose         use verbose output
  -m MAX, --max MAX     max number of languages to return
  -o ONLY [ONLY ...], --only ONLY [ONLY ...]
                        test only the specified formats

Language Support

AppleScript, C#, C++, C, D, Go, Haskell, Java, JavaScript, Julia, Lua, OCaml, Objective-C, Perl, PHP, Python, R, Ruby, Rust, Scala & Swift

Testing

$ python run.py dev -t

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.