Exemplo n.º 1
0
 def run_multitrancom(self):
     import plugins.multitrancom.cleanup as cu
     import plugins.multitrancom.tags as tg
     import plugins.multitrancom.elems as el
     file = '/home/pete/bin/mclient/tests/multitrancom (saved in browser)/hello (2021-03-14).html'
     self.htm = sh.ReadTextFile(file).get()
     self.text = cu.CleanUp(self.htm).run()
     itags = tg.Tags(text=self.text, Debug=DEBUG, maxrows=self.maxrows)
     blocks = itags.run()
     blocks = el.Elems(blocks=blocks, Debug=DEBUG,
                       maxrows=self.maxrows).run()
Exemplo n.º 2
0
 def run_multitrancom(self):
     f = '[MClient] tests.Tags.run_multitrancom'
     import plugins.multitrancom.cleanup as cu
     import plugins.multitrancom.tags as tg
     ''' #NOTE: The file should be generated with
         'plugins.multitrancom.get.Get', otherwise, 'Tags' will fail
         to set 'dic' and some other types.
     '''
     #file = '/home/pete/bin/mclient/tests/multitrancom (saved in browser)/hello (Компьютерные сети) (2021-03-17).html'
     #file = '/home/pete/bin/mclient/tests/multitrancom (saved in browser)/generic drug (2021-03-17).html'
     file = '/home/pete/bin/mclient/tests/multitrancom (saved in browser)/get out of (2021-03-17).html'
     text = sh.ReadTextFile(file).get()
     text = cu.CleanUp(text).run()
     tg.Tags(text=text, Debug=DEBUG, maxrows=0).run()
Exemplo n.º 3
0
 def run_dsl(self):
     f = '[MClient] tests.Tags.run_dsl'
     import plugins.dsl.get as gt
     import plugins.dsl.cleanup as cu
     import plugins.dsl.tags as tg
     gt.PATH = sh.Home('mclient').add_config('dics')
     articles = gt.Get('account balance').run()
     blocks = []
     for iarticle in articles:
         code = cu.CleanUp(iarticle.code).run()
         code = cu.TagLike(code).run()
         blocks += tg.Tags(code=code,
                           Debug=DEBUG,
                           maxrows=0,
                           dicname=iarticle.dic).run()
Exemplo n.º 4
0
 def request(self,search='',url=''):
     self.search = search
     self.htm = gt.Get (search = search
                       ,url = url
                       ).run()
     self.text = cu.CleanUp(self.htm).run()
     itags = tg.Tags (text = self.text
                     ,Debug = self.Debug
                     ,maxrows = self.maxrows
                     )
     self.blocks = itags.run()
     self.blocks = el.Elems (blocks = self.blocks
                            ,Debug = self.Debug
                            ,maxrows = self.maxrows
                            ).run()
     return self.blocks
Exemplo n.º 5
0
 def set_blocks(self):
     f = '[MClient] plugins.multitrancom.utils.subjects.extract.StartPage.set_blocks'
     if self.Success:
         search = 'menu{}-{}'.format(self.lang1, self.lang2)
         htm = gt.Get(search=search, url=self.url).run()
         text = cu.CleanUp(htm).run()
         itags = tg.Tags(text)
         self.blocks = itags.run()
         self.blocks = Elems(self.blocks).run()
         for block in self.blocks:
             block.text = block.text.replace(sh.lg.nbspace, ' ')
             block.text = block.text.strip()
         self.blocks = [block for block in self.blocks \
                        if block.url and block.text
                       ]
         if not self.blocks:
             self.Success = False
             sh.com.rep_out(f)
     else:
         sh.com.cancel(f)