Git Product home page Git Product logo

pyheck's Introduction

pyheck

PyHeck is a case conversion library (for converting strings to snake_case, camelCase etc). It is a thin wrapper around the Rust library heck.

Read the documentation.

Installation

pip install pyheck

Note: requires Python >= 3.7.

Example

>>> from pyheck import snake
>>> snake("We carry a new world here, in our hearts.")
'we_carry_a_new_world_here_in_our_hearts'

Development

Setup

  1. Install poetry
  2. Install dev dependencies:
poetry install
  1. Activate the poetry shell:
poetry shell

Testing

  1. Run maturin develop to compile the Rust code.
  2. Run make fmt, make lint, and make test.

pyheck's People

Contributors

0xflotus avatar kevinheavey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyheck's Issues

why is unicode segmentation used?

Just curious. Basically, in the context of this line:

heck = { version = "0.4.0", features = ["unicode"] }

I'm not too sure about what the unicode feature is myself, reading up on it in the heck docs now.

Currently i have some test code in rust at least:

assert_eq!("a.b.c".to_snake_case(), "a_b_c");
assert_eq!("a'b'c".to_snake_case(), "a_b_c");
assert_eq!("2this##@$@#$.23432isaTest.Thanks.To.BOB.Myf\"r'e\"'e''nd.".to_snake_case(),
                 "2this_23432isa_test_thanks_to_bob_myf_r_e_e_nd")

this appears to work without the unicode feature, i.e. with heck = "0.4.0", but when I add the unicode feature then the assert stmts seem to fail. I might be wrong, but for valid snake case it might be worth removing the . and the , in the results. Basically, in my use case I want to turn a bunch of words into valid identifier names in python -- so for ex. a_b_c = 2 would work out in my use case, but with special chars it would fail. Is it possible to just have a _ in the returned string?

Side note: also 2this is not a valid identifier in python, but I understand that's not a goal of this library for obvious reasons of course.

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.