semvec/pypi-packages huggingface dataset:
thrift-parser 1.0.7
a thrift parser (antlr4)
License: MIT
Requires Python: >=3.7

# thrift-parser

```bash
pip install thrift-parser
```

`Thrift.g4` is from https://github.com/antlr/grammars-v4


## parse

```python
from thrift_parser import parse_file

lexer, tokens, parser, document = parse_file('tutorial.thrift')
```
or smiple

```python
from thrift_parser import ThriftData

thrift_data = ThriftData.from_file('tutorial.thrift')

print(thrift_data.tokens[0].text)
print(thrift_data.document.children)
```

or you can try antlr's way

```python
from antlr4 import FileStream
from antlr4 import CommonTokenStream
from antlr4 import ParserRuleContext

from thrift_parser.ThriftLexer import ThriftLexer
from thrift_parser.ThriftParser import ThriftParser


def main(file):
    input_stream = FileStream(file, encoding='utf8')
    lexer = ThriftLexer(input_stream)
    stream = CommonTokenStream(lexer)
    parser = ThriftParser(stream)
    ctx = ParserRuleContext()

    parser.enterRule(ctx, 0, 0)
    document = parser.document()
    return document

```


# Why ?

python thrift parser --> thrift-fmt --> auto format my thrift files in one style


# TODO

1. more ast operate, fake_token, fake_context
2. other language?
django-simple-vite 1.0.0
A simple Django app to integrate Vite.js easily in your Django project.
License: MIT
Keywords: django,vitejs

# django-simple-vite

A simple Django app to integrate Vite.js easily in your Django project.


## Install:

```
pip install django-simple-vite
```

Then add `simple_vite` to `INSTALLED_APPS` in Django settings.

```
INSTALLED_APPS = [
    ...
    'simple_vite',
    ...
]
```

## Settings:

During development, set `VITE_SERVER_URL` in Django settings, pointing to the Vite.js development server, e.g.:

```
VITE_SERVER_URL = 'http://localhost:3000'
```

When in production, you don't need to set `VITE_SERVER_URL`, because the compiled assets produced by Vite.js will be served as regular static files.

## Usage:
------

Create an app that will contain your Vite.js powered frontend:

```
./manage.py startapp frontend
```

Inside your app, create a `vite_src` directory (the name is arbitrary). This directory will contain your Javascript sources, that will be compiled by Vite.js.

In the `vite_src` directory, create a `vite.config.js` file, with this content:

```
const { resolve } = require('path');

export default {
    build: {
        manifest: true, // adds a manifest.json
        rollupOptions: {
            input: [
              // Use main.js file as entrypoint for your JS app.
              resolve(__dirname, './main.js'),
            ]
        },
        // Puts the Vite.js manifest.json in
        // PROJECT_ROOT/frontend/static/
        outDir:  '../static',
        // puts compiled asset files (js, css) in
        // PROJECT_ROOT/frontend/static/frontend
        assetsDir:  'frontend',
    },
    plugins: [],
    server: {
        // This port should match with VITE_SERVER_URL Django setting.
        port: 3000,
        open: false,
    }
};
```

In the `vite_src` directory, create a `main.js` file, that will serve as entry point for your app, with this content:

```
// Add this at the beginning of your app entry.
import 'vite/modulepreload-polyfill';
import 'main.css';

console.log("hello world");
```

`main.css` is a CSS file that will be imported by Vite and used by your application.

Install Vite.js in your `vite_src` directory:

```
yarn add vite
```

Add a couple of script in your `package.json`:

```
{
  "dependencies": {
    "vite": "^4.1.4"
  },
  "scripts": {
    "dev": "vite",
    "build": "vite build"
  }
}
```

Launch Vite.js server:

```
yarn dev
```

Create a Django template `index.html` that will hold the HTML markup used by your application, save it inside your `frontend` Django app in a subdirectory `templates/frontend/`.

```
{% load vite %}

<html>
<head>
    {% vite_styles 'main.js' %}
</head>
<body>
    <h1>Hello world</h1>

    {% vite_scripts 'main.js' %}
</body>

</html>
```

Now create a Django URLConf that will serve the above template, and you'll see a basic Vite.js powered web app, with Hot Module Replacement (HMR) enabled!