rask  Check-in [de2698ffae]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:de2698ffaeb358bb40171f659d31e387ce8aeef2
Date: 2017-03-17 08:27:25
User: umgeher
Comment:merge from v/0.1.2
Tags And Properties
  • branch=rask/master inherited from [e712659d71]
  • sym-rask/master inherited from [e712659d71]
Context
2017-03-19
04:42
[832274bde4] Leaf: v/0.1.3 (user: umgeher, tags: rask/master)
03:25
[ede5b0aa98] Create new branch named "rask/f/utcode-seek" (user: umgeher, tags: rask/f/utcode-seek)
02:11
[02ba216c9f] merge from master (user: umgeher, tags: rask/f/tui)
2017-03-17
08:27
[de2698ffae] merge from v/0.1.2 (user: umgeher, tags: rask/master)
08:19
[fe0efeb196] Leaf: version stuff (user: umgeher, tags: rask/v/0.1.2)
07:12
[babe44a242] merge from v/0.1.1 (user: umgeher, tags: rask/master)
Changes

Changes to rask/README.md.

1
2
3
4
5
6

7
8
9
10
11
12
13
# Rask

## Changelog

|Version|Description|
|----|----|

|0.1.1|riak parser has now float schema|
|0.1.0|rask_raid project is merged to rask project|
|0.0.120|riak sets in dict to map and map to dict parsers|
|0.0.119|pdbpp as default pdb. dict to map and map to dict from parser.riak imported|
|0.0.118|wrong namespace fixed|
|0.0.117|dict to map of riak tools fixed|
|0.0.116|riak schema parser|






>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Rask

## Changelog

|Version|Description|
|----|----|
|0.1.2|riak parser has now utcode schema, and all recipes are async|
|0.1.1|riak parser has now float schema|
|0.1.0|rask_raid project is merged to rask project|
|0.0.120|riak sets in dict to map and map to dict parsers|
|0.0.119|pdbpp as default pdb. dict to map and map to dict from parser.riak imported|
|0.0.118|wrong namespace fixed|
|0.0.117|dict to map of riak tools fixed|
|0.0.116|riak schema parser|

Changes to rask/rask/parser/riak/dict_to_map.py.

1
2

3
4
5
6
7
8
9
..
13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63










64
65
66
67
68
69
70
71
72
73
74
75
76











77
78
79
80
81

82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from base64 import b64encode
from rask.base import Base


__all__ = ['DictToMap']

class DictToMap(Base):
    @property
    def recipes(self):
        try:
................................................................................
                'bool':self.__recipe_bool,
                'float':self.__recipe_str,
                'int':self.__recipe_str,
                'set':self.__recipe_set,
                'set+':self.__recipe_set_add,
                'set-':self.__recipe_set_discard,
                'str':self.__recipe_str,
                'unicode':self.__recipe_unicode

            }
        except:
            raise
        return self.__recipes

    def __recipe_bool(self,key,data,record,schema):
        try:
            assert data[key]
        except AssertionError:
            record.flags[key].disable()
        except:
            raise
        else:
            record.flags[key].enable()
        return record

    def __recipe_set(self,key,data,record,schema):
        for v in data[key]:
            try:
                assert 'set%s' % v[0] in self.recipes
            except (AssertionError,IndexError):
                pass
            except:
                raise
            else:
                record = self.recipes['set%s' % v[0]](key,v,record)
        return record

    def __recipe_set_add(self,key,value,record):
        record.sets[key].add(str(value[1:]))
        return record

    def __recipe_set_discard(self,key,value,record):
        record.sets[key].discard(str(value[1:]))
        return record

    def __recipe_str(self,key,data,record,schema):
        record.registers[key].assign(str(data[key]))
        return record

    def __recipe_unicode(self,key,data,record,schema):
        record.registers[key].assign(b64encode(data[key]))
        return record











    def consume(self,data,record,schema,i,future):
        try:
            key = i.next()
            assert schema[key]['recipe'] in self.recipes
        except (AssertionError,KeyError):
            pass
        except StopIteration:
            future.set_result(record)
            return True
        except:
            raise
        else:











            record = self.recipes[schema[key]['recipe']](
                key=key,
                data=data,
                record=record,
                schema=schema

            )

        return self.ioengine.loop.add_callback(
            self.consume,
            data=data,
            record=record,
            schema=schema,
            i=i,
            future=future
        )

    def process(self,data,record,schema,future):
        return self.ioengine.loop.add_callback(
            self.consume,
            data=data,
            record=record,
            schema=schema,
            i=iter(data),
            future=future
        )


>







 







|
>





|








|

|









|









|

|

|

|
>
>
>
>
>
>
>
>
>
>













>
>
>
>
>
>
>
>
>
>
>
|



|
>


<
|
<
<
<
<
<
|
<









1
2
3
4
5
6
7
8
9
10
..
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

108





109

110
111
112
113
114
115
116
117
118
from base64 import b64encode
from rask.base import Base
from rask.options import options

__all__ = ['DictToMap']

class DictToMap(Base):
    @property
    def recipes(self):
        try:
................................................................................
                'bool':self.__recipe_bool,
                'float':self.__recipe_str,
                'int':self.__recipe_str,
                'set':self.__recipe_set,
                'set+':self.__recipe_set_add,
                'set-':self.__recipe_set_discard,
                'str':self.__recipe_str,
                'unicode':self.__recipe_unicode,
                'utcode':self.__recipe_utcode
            }
        except:
            raise
        return self.__recipes

    def __recipe_bool(self,key,data,record,schema,future):
        try:
            assert data[key]
        except AssertionError:
            record.flags[key].disable()
        except:
            raise
        else:
            record.flags[key].enable()
        return future.set_result(record)

    def __recipe_set(self,key,data,record,schema,future):
        for v in data[key]:
            try:
                assert 'set%s' % v[0] in self.recipes
            except (AssertionError,IndexError):
                pass
            except:
                raise
            else:
                record = self.recipes['set%s' % v[0]](key,v,record)
        return future.set_result(record)

    def __recipe_set_add(self,key,value,record):
        record.sets[key].add(str(value[1:]))
        return record

    def __recipe_set_discard(self,key,value,record):
        record.sets[key].discard(str(value[1:]))
        return record

    def __recipe_str(self,key,data,record,schema,future):
        record.registers[key].assign(str(data[key]))
        return future.set_result(record)

    def __recipe_unicode(self,key,data,record,schema,future):
        record.registers[key].assign(b64encode(data[key]))
        return future.set_result(record)

    def __recipe_utcode(self,key,data,record,schema,future):
        def on_encode(_):
            record.registers[key].assign(_.result())
            return future.set_result(record)
        
        return options.utcode.encode(
            data[key],
            future=self.ioengine.future(on_encode)
        )

    def consume(self,data,record,schema,i,future):
        try:
            key = i.next()
            assert schema[key]['recipe'] in self.recipes
        except (AssertionError,KeyError):
            pass
        except StopIteration:
            future.set_result(record)
            return True
        except:
            raise
        else:
            def on_recipe(_):
                return self.ioengine.loop.add_callback(
                    self.consume,
                    data=data,
                    record=_.result(),
                    schema=schema,
                    i=i,
                    future=future
                )
            
            self.ioengine.loop.add_callback(
                self.recipes[schema[key]['recipe']],
                key=key,
                data=data,
                record=record,
                schema=schema,
                future=self.ioengine.future(on_recipe)
            )


        return None





    

    def process(self,data,record,schema,future):
        return self.ioengine.loop.add_callback(
            self.consume,
            data=data,
            record=record,
            schema=schema,
            i=iter(data),
            future=future
        )

Changes to rask/rask/parser/riak/map_to_dict.py.

1
2

3
4
5
6
7
8
9
..
11
12
13
14
15
16
17
18

19
20
21
22
23
24

25
26

27

28
29

30

31
32

33

34
35

36

37
38

39

40
41







42
43
44
45
46
47
48
49
50
51
52
53

54
55
56
57
58
59
60
61
62
63
64
65
66
67








68
69
70
71
72
73
74
75
76
77
78
79
from base64 import b64decode
from rask.base import Base


__all__ = ['MapToDict']

class MapToDict(Base):
    @property
    def recipes(self):
        try:
................................................................................
        except (AssertionError,AttributeError):
            self.__recipes = {
                'bool':self.__recipe_bool,
                'float':self.__recipe_float,
                'int':self.__recipe_int,
                'set':self.__recipe_set,
                'str':self.__recipe_str,
                'unicode':self.__recipe_unicode

            }
        except:
            raise
        return self.__recipes

    def __recipe_bool(self,key,record,schema):

        return record.flags[key].value


    def __recipe_float(self,key,record,schema):

        return float(record.registers[key].value or 0)


    def __recipe_int(self,key,record,schema):

        return int(record.registers[key].value or 0)


    def __recipe_set(self,key,record,schema):

        return list(record.sets[key].value)


    def __recipe_str(self,key,record,schema):

        return str(record.registers[key].value)


    def __recipe_unicode(self,key,record,schema):

        return b64decode(record.registers[key].value)








    def consume(self,result,record,schema,i,future):
        try:
            key = i.next()
            assert schema[key]['recipe'] in self.recipes
        except (AssertionError,KeyError):
            pass
        except StopIteration:
            future.set_result(result)
            return True
        except:
            raise
        else:

            result[key] = self.recipes[schema[key]['recipe']](
                key=key,
                record=record,
                schema=schema[key]
            )

        self.ioengine.loop.add_callback(
            self.consume,
            result=result,
            record=record,
            schema=schema,
            i=i,
            future=future
        )








        return None

    def process(self,record,schema,future):
        self.ioengine.loop.add_callback(
            self.consume,
            result={},
            record=record,
            schema=schema,
            i=iter(schema),
            future=future
        )
        return True


>







 







|
>





|
>
|
|
>
|
>
|
|
>
|
>
|
|
>
|
>
|
|
>
|
>
|
|
>
|
>
|
|
>
>
>
>
>
>
>












>
|
<
<
<
<
<
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>












1
2
3
4
5
6
7
8
9
10
..
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75





76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from base64 import b64decode
from rask.base import Base
from rask.options import options

__all__ = ['MapToDict']

class MapToDict(Base):
    @property
    def recipes(self):
        try:
................................................................................
        except (AssertionError,AttributeError):
            self.__recipes = {
                'bool':self.__recipe_bool,
                'float':self.__recipe_float,
                'int':self.__recipe_int,
                'set':self.__recipe_set,
                'str':self.__recipe_str,
                'unicode':self.__recipe_unicode,
                'utcode':self.__recipe_utcode
            }
        except:
            raise
        return self.__recipes

    def __recipe_bool(self,key,record,schema,future):
        return future.set_result(
            record.flags[key].value
        )

    def __recipe_float(self,key,record,schema,future):
        return future.set_result(
            float(record.registers[key].value or 0)
        )

    def __recipe_int(self,key,record,schema,future):
        return future.set_result(
            int(record.registers[key].value or 0)
        )

    def __recipe_set(self,key,record,schema,future):
        return future.set_result(
            list(record.sets[key].value)
        )

    def __recipe_str(self,key,record,schema,future):
        return future.set_result(
            str(record.registers[key].value)
        )

    def __recipe_unicode(self,key,record,schema,future):
        return future.set_result(
            b64decode(record.registers[key].value)
        )

    def __recipe_utcode(self,key,record,schema,future):
        return options.utcode.decode(
            record.registers[key].value,
            future=future
        )
    
    def consume(self,result,record,schema,i,future):
        try:
            key = i.next()
            assert schema[key]['recipe'] in self.recipes
        except (AssertionError,KeyError):
            pass
        except StopIteration:
            future.set_result(result)
            return True
        except:
            raise
        else:
            def on_recipe(_):
                result[key] = _.result()





                return self.ioengine.loop.add_callback(
                    self.consume,
                    result=result,
                    record=record,
                    schema=schema,
                    i=i,
                    future=future
                )

            self.ioengine.loop.add_callback(
                self.recipes[schema[key]['recipe']],
                key=key,
                record=record,
                schema=schema[key],
                future=self.ioengine.future(on_recipe)
            )
        return None

    def process(self,record,schema,future):
        self.ioengine.loop.add_callback(
            self.consume,
            result={},
            record=record,
            schema=schema,
            i=iter(schema),
            future=future
        )
        return True

Changes to rask/setup.py.

13
14
15
16
17
18
19
20
21
    ],
    license='http://code.umgeher.org/fossil.cgi/rask/artifact/3b9a146264aed1f5',
    maintainer='Umgeher Torgersen',
    maintainer_email='me@umgeher.org',
    name='rask',
    packages=find_packages(),
    url='http://code.umgeher.org/rask',
    version="0.1.1"
)







|

13
14
15
16
17
18
19
20
21
    ],
    license='http://code.umgeher.org/fossil.cgi/rask/artifact/3b9a146264aed1f5',
    maintainer='Umgeher Torgersen',
    maintainer_email='me@umgeher.org',
    name='rask',
    packages=find_packages(),
    url='http://code.umgeher.org/rask',
    version="0.1.2"
)