Giter Club home page Giter Club logo

rightshift's People

Contributors

oopman avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

rightshift's Issues

Add call to rightshift.chains

Example:

# Current syntax
f = attr.lower
f(data)() == data.lower()

f = attr.join
f(['1','2'])('#') == '1#2'

# Proposed syntax
f = attr.lower >> call
f(data) == data.lower()

f = attr.join >> call('#')
f(['1','2']) == '1#2'

Enhance handling of tuples/lists/dicts/attributes in rightshift.matchers

Currently rightshift.matchers does not have a good way of handling matching on objects that contain other objects.

In order to improve on this we should implement item_is and attr_is. These matchers will combine the functionality of the value_is matcher with the value extraction functionality of the item and attr extractors found in rightshift.extractors

Allow non-Transformer instances and be used with RightShift

It would be useful if normal python values could be mixed in to tupling and detupling expressions. This could be done by wrapping them in a special Value transform. Values can be created by implementing rand and ror on the base Transformer class.

Similarly, it would be useful if the Tupling class could understand normal Python tuples and use them as Tupling instances.

Introduce global configurability

RIght now various Transformers accept flags and have default values for these flags.

It would be useful if there was a way to change the default value of a given flag.

Compile Mode

It would be nice if RightShift were usable in the real world, maybe through some compile mode which converts the chains into more basic code.

Add feed / => operator

Transformer instances should accept allow usage of the => operator in the following form as a means of calling the transformer with an input:

f = a >> b
o = "test" >= f

Migrate from __rXYZ__ methods to the non-reverse forms

Currently rrshift, rand and ror are used in the code to implement the basic behaviour of RightShift.

rshift, and and or should be used rather as it will reduce the complexity of the code, as well as obviating the need for mountains of anonymous classes.

Implement rightshift.matchers

The matchers module will provide Transforms that determine whether the value they are called with matches a given condition, returning True or False in either scenario.

Beyond this, these Transforms will also implement different boolean behaviour for the & and | operators.

Finally, these Transforms should also transform TransformerExceptions to False values.

Add more transformers for interaction with collections

Transformers that should be added include:

  • head
  • last
  • tail
  • take
  • takeRight
  • takeWhile
  • drop
  • dropRight
  • dropWhile
  • partition
  • contains
  • containsSlice
  • endsWith
  • startsWith
  • filter
  • find
  • map
  • flatMap
  • flatten
  • fold
  • foldLeft
  • foldRight
  • groupBy
  • grouped
  • indexOf
  • indexOfSlice
  • length
  • join
  • reduce
  • reduceLeft
  • reduceRight
  • reverse
  • slice
  • sortBy
  • splitAt
  • sum
  • zip
  • unzip
  • union

This list draws on the methods available to Seq descendants in Scala

Enhance rightshift.breakers

Currently break_if and break_if_not need to be instantiated with a single matcher. This limits their flexibility. Altering them to accept any Transformer will enable much richer behaviour.

Implement rightshift.breakers

Breakers are a Transform that raise a TransformerException in order to terminate processing of the Transform chain.

They are used to implement break-out behaviour for chains.

Add render function

The render function should be called with a chain and produces a string representation of the flow of that chain

Flags don't make sense

The way Flags are currently used doesn't make a whole lot of sense.

The general style with RightShift is x >> y >> z indicating pass output from x as input to y, pass output from y as input to z.

However, the above with a Flag applied looks like x >> y >> z >> flags(blah=True) The way this behaves, however, is such that the arguments supplied to flags are made available as kwargs when to the x, y and z functions when they are called.

This is somewhat at odds with the manner in which RightShift functions. It would probably be better if flags the example looked like flags(blah=True) >> x >> y >> z

Add rightshift.operations module

RightShift will be more useful if it is able to perform operations.

For example, the augmented arithmetic operations:

f = item['x'] >> add(5)
f = item['x'] >> (operand *= 5)

Implement an obj Extractor in rightshift.extractors

The rightshift.extractors module should implement an additional Extractor named Obj which combines the functionality of the Item and Attr Extractors in order to provide an Extractor that behaves as per standard Python object access principles.

Additionally, a Matcher hybrid version will need to be added to the rightshift.matchers.

Fix attribute behaviour for attr and obj extractors

Currently these extractors fail to work correctly if the attribute being referenced exists on the extractor itself. E.g. __class__ and so forth.

This should be fixable by use __getattribute__ rather than __getattr__, although there will be some complexity involved due to the sneaky tricks used by the item, attr and obj extractors.

Implement Breaker Comparisons

The rightshift.breakers module should extend the Comparisons found in rightshift.matchers in order to implement Comparisons that automatically are wrapped within Breakers.

Enhance rightshift.breakers

Additions:

  • Breaker base class that overrides and and or in order to allow break_if(x & y) to be equivalent to break_if(x) & break_if(y)
  • Breaker versions of the Comparisons from rightshift.matchers in order to allow for common use-cases to be simplified.

Implement default(x) Transform

The default Transform should function as per the following example:

f = item[0] >> default(None)

f([]) == None

f([1] == 1

In order to match this requirement the default Transform will probably need to implement a custom Chain class which intercepts any TransformerExceptions and returns the default value in their place.

Optimise

The current code is not written with any kind of performance in mind. As such, it's probably a little bit heavy and could do with some paring down. In particular, the chains implementation could probably be improved.

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.