Coder Social home page Coder Social logo

paul-wolf / strgen Goto Github PK

View Code? Open in Web Editor NEW
34.0 3.0 2.0 215 KB

A Python module for a template language that generates randomized data

License: BSD 3-Clause "New" or "Revised" License

Python 99.88% Shell 0.12%
python character-set regular-expression template-language random random-generation randomizer random-string string-generator

strgen's Introduction

Working on

  • Transactional web sites with lots of moving parts including microservices, diverse storage requirements, analytics, real-time bidding and automated buying systems.

  • Geospatial computation with Pandas for analysing commercial data.

  • General Python standards and how to apply good practices to get better, more maintainable code.

  • Better protocols for web frameworks.

  • Web site accessibility according to WCAG 2.1

Some articles I've authored:

Python Coding Guidelines

This is a set of guidelines to make Python code more readable, easier to maintain and easier to reuse.

Simple Rules for Class Design

A formula that can be applied almost mechanically to simplify class design in Python, making your code easier to read, change and test.

Modern Python Logging

This is an opinionated view of how logging should be done for Python applications.

Djaq: A Different Concept for Django Queries

Djaq - pronounced "Jack" - provides an instant remote API to your Django models data with a powerful query language. No server-side code beyond two lines of config is required. You don't write backend classes, serializers or any other code to be able to immediately get whatever data you want to the client. And it is blazing fast.

Modern Django Settings

Some good practices for Django settings for medium to larger projects.

A More Practical REST

The REST pattern for writing APIs has a lot of traction and is the basis for many public APIs. It does, however, have some serious problems. This article proposes some changes to the principles underlying REST to make it a better convention.

strgen's People

Contributors

amotl avatar paul-wolf avatar paulwolf-bitposter avatar scompt avatar wojtekwanczyk 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

Watchers

 avatar  avatar  avatar

strgen's Issues

missing return statement in last() function

Hi, please check the last() function in your code, as following:

def last(self):
if self.index == 0:
return None
self.pattern[self.index-1]

Notice that the last line should start with a "return" keyword... I think.

Thanks
Yifan

"No Attribute"

AttributeError: module 'strgen' has no attribute 'StringGenerator'

Let user provide random class

Currently, strgen tries to use SystemRandom and falls back to Random. Let the user provide the random source class.

StringGenerator 0.3.0 does not successfully install with pip

On Windows 10 with Python 3.6.1, "pip install StringGenerator" gets the following error:

C:\Users\Don\Documents\test>pip install StringGenerator
Collecting StringGenerator
Using cached https://files.pythonhosted.org/packages/71/31/97eeae37a7d1322d9bd12f73406afa522dfb1e6303e3f6504717e6c2f528/StringGenerator-0.3.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Don\AppData\Local\Temp\pip-install-2rxfgnzn\StringGenerator\setup.py", line 7, in
long_description = file.read()
File "c:\users\don\documents\test\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 1264: character maps to

As a workaround, one can force pip to use the earlier version of StringGenerator, which successfully installs:

C:\Users\Don\Documents\test>pip install StringGenerator==0.2.1
Collecting StringGenerator==0.2.1
Installing collected packages: StringGenerator
Successfully installed StringGenerator-0.2.1

Set seed

I didn’t see a way to set the seed ? This should be easy to implement since the module uses random, and it would be a great improvement for reproducibility.

Missing period in __init__.py ? Python 3.4.3 64bit, Windows

I received an import error whenever I tried to "import strgen" or "from strgen import StringGenerator". To resolve, edit init.py in the strgen directory. All that's needed is a period in front of string_generator, as below:

from .string_generator import StringGenerator

Add variable feature

Add feature for variables randomly chosen from dictionary:

$(firstname)$(lastname)

u'string' prefixes on 3.0 - 3.2

As per: https://groups.google.com/forum/#!topic/comp.lang.python/Ns5n80VP0cU

"The implication of a simple reading of this statement is that your
code should run on 2.6, 2.7, 3.0, 3.1, 3.2, and 3.3, and hasn't been
tested on 3.4. But I eyeballed your code, and I'm seeing a lot of
u'string' prefixes, which aren't supported on 3.0-3.2 (they were
reinstated in 3.3 as per PEP 414), so a more likely version set would
be 2.6+, 3.3+. What's the actual version support? "

Need to test 3.0-3.2.

Use more regex-ish range specifier for quantifier

Quantifiers are like this:

[\w]{6:8}

The colon is influenced by Python, but it should have used comma as in regex.

We might add both comma and hyphen as alternatives for specifying range while retaining colon for backwards compatibility.

Providing a backslash within range does work

According to the documentation you should provide three backslashes for this. I've tried various combination and none seem to work here is the test code.

rex_arg = r'\'
rex_word = StringGenerator(rex_arg).render()
print('rex1', rex_word)
rex_arg = r'[\]'
rex_word = StringGenerator(rex_arg).render()
print('rex2', rex_word)

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.