Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/daniel-m-campos/code-style-formatter


https://github.com/daniel-m-campos/code-style-formatter

Last synced: about 22 hours ago
JSON representation

Awesome Lists containing this project

README

        

# Code Style Formatter
A small tool for converting between snake and camel case naming conventions.

## Examples
### Snake to Camel Case
```python
# Snake case source
source = """import functools as ftools
from typing import Tuple

CONST = 42

@ftools.lru_cache
def my_func(a_var: int, b_var: str = "Hello") -> Tuple:
return [CONST + a_var * i for i in range(2)], b_var

if __name__ == "__main__":
result = my_func(1)
print(*result)
"""

# Convert using code_style_converter

import code_style_formatter as csf

dest = csf.to_camel(source)

# Print newly converted camel case source

print(dest)
"""import functools as ftools
from typing import Tuple

CONST = 42

@ftools.lru_cache
def myFunc(aVar: int, bVar: str = "Hello") -> Tuple:
return [CONST + aVar * i for i in range(2)], bVar

if __name__ == "__main__":
result = myFunc(1)
print(*result)
"""
```

### Camel to Snake Case
```python
# Camel case source
source = """import functools as ftools
from typing import Tuple

CONST = 42

@ftools.lru_cache
def myFunc(aVar: int, bVar: str = "Hello") -> Tuple:
return [CONST + aVar * i for i in range(2)], bVar

if __name__ == "__main__":
result = myFunc(1)
print(*result)

"""

# Convert using code_style_converter

import code_style_formatter as csf

dest = csf.to_snake(source)

# Print newly converted snake case source

print(dest)
"""import functools as ftools
from typing import Tuple

CONST = 42

@ftools.lru_cache
def my_func(a_var: int, b_var: str = "Hello") -> Tuple:
return [CONST + a_var * i for i in range(2)], b_var

if __name__ == "__main__":
result = my_func(1)
print(*result)
"""
```