Code Monkey home page Code Monkey logo

bracex's People

Contributors

facelessuser avatar moreati avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

bracex's Issues

Create shortcut for raising limit exception

Currently, when expanding, the limit isn't identified until most of the expansion is done, so we can actually hang regardless, we just don't return everything and fail.

We can shortcut this when expanding numbers {1..100} and characters {a..d} as we can calculate expansion without actually doing it.

Better iterator return

The whole point of an iterator, in the sense we are using it, is to provide the next without having to calculate everything. Unfortunately, we currently unpack everything on the first so that we can tell how many empty entries we have at the tail (we trim trailing empty entries I believe).

Feature proposal/offer: command line interface

I've been seeking a command x, like seq but doing brace expansion. It could be used like

x "{a..z}/{a..z}/{a..z}/{a..z}/{a..z}/{a..z}" | xargs -d $'\n' mkdir -p

I've not found a satisfactory x, so I'd like to offer a PR allowing python -m bracex to serve as x. Would you be interested?

I imagine the major elements would be

  • a new __main__.py wrapping bracex.iexpand()
  • minimal argument parsing using argparse
  • updates to documentation
  • additional tests to maintain code coverage

I totally understand if the answer is no, so please don't feel pressured. I know every new feature creates support costs. As plan B I could release a separate package that wraps bracex, keeping a loose coupling.

Thanks for your consideration, Alex

feature request: add static types

It should be really easy to add static types to at least the public API, and would help remove some type ignores in cibuildwheel. I'd be happy to contribute the static types for the public API if you'd like me to, but I'd need to know if you want a .pyi file, or inline types. If you want to add full static type checking internally too, inline types are preferable. If not, then it could be done either way. (I think the public API is basically two functions).

this string is expanded with {} preserved

๐Ÿ import bracex
๐Ÿ bracex.expand('{cautious_memory.{cogs.{permissions,wiki,watch_lists}.{db,commands},api,meta},jishaku,bot_bin.{misc,debug,sql,stats}}')
['cautious_memory.{cogs.permissions.db}', 'cautious_memory.{cogs.permissions.commands}', 'cautious_memory.{cogs.wiki.db}', 'cautious_memory.{cogs.wiki.commands}', 'cautious_memory.{cogs.watch_lists.db}', 'cautious_memory.{cogs.watch_lists.commands}', 'cautious_memory.{cogs.api}', 'cautious_memory.{cogs.meta}', 'jishaku', 'bot_bin.misc', 'bot_bin.debug', 'bot_bin.sql', 'bot_bin.stats']
๐Ÿ bracex.__version__
'1.3'

Expected

That, but without the {} in the return value

CI: N818 exception name 'ExpansionLimitException' should be named with an Error suffix

The lint task fails, with the following complaint

lint installed: flake8==3.9.2,flake8-builtins==1.5.3,flake8-docstrings==1.6.0,flake8-mutable==1.2.0,flake8-polyfill==1.0.2,mccabe==0.6.1,pep8-naming==0.12.1,pycodestyle==2.7.0,pydocstyle==6.1.1,pyflakes==2.3.1,snowballstemmer==2.1.0
llint run-test-pre: PYTHONHASHSEED='2341193631'
lint run-test: commands[0] | /home/alex/src/bracex/.tox/lint/bin/flake8 .
./bracex/__init__.py:37:8: N818 exception name 'ExpansionLimitException' should be named with an Error suffix
ERROR: InvocationError for command /home/alex/src/bracex/.tox/lint/bin/flake8 . (exited with code 1)

It could be remedied by renaming the exception, or overriding this lint check. The latter is probably preferable, in the interest of API stability,

Add expansion limit and option to configure it

Currently, someone could feed in a pattern of {1..100000000}, and that would not go well. If you are using bracket expansion, and exposing it to external users, this may be very undesirable. By default, we will limit expansion to 1000 strings, but you will be able to alter this higher, lower, or even disable it via an option.

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.