# -*- coding: utf8 -*-
''' Crawler's core '''

'''
Copyright (c) 2013 GERODEL Quentin (aka Swizz540)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'''

@@ -1118,12 +1118,1176 @@
 FTWARE.%0A'''%0A
+%0Afrom random import sample, randint, choice%0Afrom string import hexdigits%0Afrom lang import write_message, language%0A%0Aclass Core:%0A    ''' A simple core uses in multithread mode '''%0A%0A    def __init__(self, lang):%0A        ''' Set the uuid and language of this core '''%0A        self.uuid = '%25s_%25s' %25 (lang.upper(), ''.join(sample(hexdigits, 13)))%0A        self.lang = lang%0A%0A    def _get_items(self):%0A        ''' Get the usable item list '''%0A        available_items = language%5Bself.lang%5D%5B'items'%5D%0A%0A        items_number = randint(1,3)%0A        allowed_item = sample(available_items, items_number)%0A%0A        return items_number, allowed_item%0A%0A    def _get_sentence(self):%0A        ''' Get the target sentence '''%0A        available_sentence = language%5Bself.lang%5D%5B'sentences'%5D%0A%0A        final_sentence = choice(available_sentence)%0A%0A        return final_sentence%0A%0A    def send_message(self):%0A        ''' Return the sended message '''%0A%0A        sentence = self._get_sentence()%0A        items_number, items_list= self._get_items()%0A%0A        return write_message(self.lang, sentence, items_list)%0A%0A%0A#Main use%0Aif __name__ == '__main__':%0A    this = Core('fr')%0A    print this.send_message()%0A

Implement core manager