Skip to content

Commit

Permalink
#37: Implement flags method on metaclass to allow easier generation o…
Browse files Browse the repository at this point in the history
…f namespaced flags. Updated FlagsChain and Flags to reflect changes
  • Loading branch information
OOPMan committed Mar 27, 2017
1 parent 7763a68 commit c899e83
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions rightshift/chains.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from copy import copy
from copy import deepcopy

from rightshift import Chain, ChainTransformer, TransformationException

from rightshift.magic import IndexOrAccessToInstantiate

__author__ = 'adam.jorgensen.za@gmail.com'
Expand All @@ -16,11 +18,11 @@ def __init__(self, flags, left):
super(FlagsChain, self).__init__(left, None)
self.flags = flags

def __call__(self, value, **flags):
def __call__(self, value, flags):
"""
TODO: Document
"""
use_flags = copy(self.flags)
use_flags = deepcopy(self.flags)
use_flags.update(flags)
return self.left(value, **use_flags)

Expand Down Expand Up @@ -53,10 +55,13 @@ class Flags(ChainTransformer):
f = flags(x=1) > a >> b >> c
"""
def __init__(self, **flags):
# TODO: Allow namespace flags more easily
def __init__(self, *flag_dicts, **flags):
"""
TODO: Document
"""
for flag_dict in flag_dicts:
flags.update(flag_dict)
self.flags = flags

def __call__(self, left):
Expand Down

0 comments on commit c899e83

Please sign in to comment.