def _build_stack_commands(stack_data: StackData, prefix):
    # TODO could do check: if path of codeuri refers to something local, use this.
    #   else use python commands: create_change_set -> wait -> execute_change_set
    return List(
        f'aws cloudformation package --template-file {stack_data.template_name} --s3-bucket "{stack_data.bucket}" --s3-prefix "{prefix}" --output-template-file outputSamTemplate.yaml',
        f'aws cloudformation deploy --template-file outputSamTemplate.yaml --stack-name {stack_data.stack_name} --capabilities CAPABILITY_IAM',
        'rm outputSamTemplate.yaml')  # use path for this?
Beispiel #2
0
def read_rest(file, data):
    # file, data = file_data[0], file_data[1]
    txt = file.readline().rstrip()
    if txt:
        row = float * List(*txt.split("\t"))
        return Just(data + [list(row)]) >> read_rest(file)
    return Just(data)
def moveKnight(pos: KnightPos) -> L[KnightPos]:
    c = pos[0]
    r = pos[1]

    possPos = List((c+2,r-1),(c+2,r+1),(c-2,r-1),(c-2,r+1),(c+1,r-2),(c+1,r+2),(c-1,r-2),(c-1,r+2))

    return filter(lambda cr: cr[0] in range(1, 9) and cr[1] in range(1,9), possPos)
Beispiel #4
0
 def testMonadComparisonExceptionWithNothing(self):
     self.givenMonads(List(1, 2, 3), Reader(7))
     self.ensureComparisonRaisesException()
Beispiel #5
0
 def testInequalityOfIdenticalTypes(self):
     self.givenMonads(List(1, 2, 3), List(4, 5, 6))
     self.ensureMonadsAreNotEqual()
Beispiel #6
0
 def testEqualityOfIdenticalTypes(self):
     self.givenMonads(List(1, 2, 3), List(1, 2, 3))
     self.ensureMonadsAreEqual()
Beispiel #7
0
 def monad_function_g(self, x):
     return List(x * 5, x / 2)
Beispiel #8
0
def _find_all_new(condition, location: Path):
    return List(*[x for x in location.iterdir() if condition(x)])
Beispiel #9
0
 def test_mplus(self):
     self.givenMonoids(List(1, 2, 3), List(2, 3, 4))
     self.ensure_mconcat_equals(List(1, 2, 3, 2, 3, 4))
Beispiel #10
0
 def test_left_identity(self):
     self.givenMonoid(List(1, 2, 3))
     self.ensure_zero_plus_monoid_equals(List(1, 2, 3))
Beispiel #11
0
def positive_and_negative(x):
    return List(x, -x)
Beispiel #12
0
def add_and_sub(x, y):
    return List(y + x, y - x)
Beispiel #13
0
        yield fib1


for fib in fibonacci(20):
    print(fib, end=' ')
print()


#monade
def positive_and_negative(x):
    return List(x, -x)


positive_and_negative(9)

x = List(9)
x >> positive_and_negative

x = List(1, 2)
x >> positive_and_negative


@curry
def add_and_sub(x, y):
    return List(y + x, y - x)


List(2) >> positive_and_negative >> add_and_sub(3, 4)

#data structure
user = {
Beispiel #14
0
"""
fp_task4
just_nothing_list

"""

from pymonad import Just, List, Nothing, curry


@curry
def add(x, y):
    return x + y


@curry
def add10(x):
    return add() * Just(10) & x


print(add10(List(12, 56, 0, 3)))
print(add10(Just(8)))
print(add10()(Nothing))
def in3(pos: KnightPos) -> L[KnightPos]:
    return List(pos) >> moveKnight >> moveKnight >> moveKnight
Beispiel #16
0
 def testUnitOnList(self):
     self.assertEqual(List.unit(8), List(8))
     self.assertEqual(unit(List, 8), List(8))
Beispiel #17
0
def _create_zip(directory: Path):
    result = _ignore_common(
        directory
    ) >> _create_dist_and_copy_files >> _run_pip_install >> _run_zip
    return List(result.value) if type(result) == Left else List(
        f'Created zip for {result.value}')
Beispiel #18
0
 def test_mzero(self):
     self.givenMonoid(List)
     self.get_mzero()
     self.ensure_mzero_is(List())
Beispiel #19
0
def execute_shell_command(command: str):
    # not perfect because execute shell command can throw exceptions
    subprocess.run([command], shell=True)
    return List(f'Ran command {command}')
Beispiel #20
0
 def test_associativity(self):
     self.givenMonoids(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9))
     self.ensure_associativity()
Beispiel #21
0
 def monad_function_f(self, x):
     return List(-x, x)
Beispiel #22
0
from pymonad import Just, List, Nothing, curry


@curry
def add(x, y):
    return x + y


def add10(x):
    return add * Just(10) & x


print(add10(List(1, 2, 3, 4, 5, 6)))
print(add10(Just(33)))
Beispiel #23
0
def remove_dir(directory: Path):
    try:
        rmtree(directory)
        return List(f'Deleted directory {directory}')
    except FileNotFoundError:
        return List(f'No delete needed for {directory} - does not exist')