Code Duplication    Length = 27-32 lines in 2 locations

sdoc/SDoc.py 2 locations

@@ 327-358 (lines=32) @@
324
        interpreter2 = SDoc2Interpreter()
325
        interpreter2.process(temp_filename)
326
327
        sdoc2.node_store.number_numerable()
328
329
        output = sys.stdout.getvalue().strip()
330
        sys.stdout = old_stdout
331
332
        with open(temp_filename, 'rt') as fd:
333
            doc2 = fd.read()
334
335
        os.unlink(temp_filename)
336
337
        return output, doc2
338
339
    # ------------------------------------------------------------------------------------------------------------------
340
    def main(self):
341
        """
342
        The main function the SDoc program.
343
        """
344
        self._read_config_file()
345
346
        self._create_node_store()
347
348
        self._import_nodes()
349
350
        self._import_formatters()
351
352
        self._run_sdoc()
353
354
        if self._errors:
355
            print()
356
            print('The were {0:d} errors in total'.format(self._errors))
357
358
        exit(self._errors)
359
360
# ----------------------------------------------------------------------------------------------------------------------
361
@@ 298-324 (lines=27) @@
295
        output = sys.stdout.getvalue().strip()
296
        sys.stdout = old_stdout
297
298
        with open(temp_filename, 'rt') as fd:
299
            doc2 = fd.read()
300
301
        os.unlink(temp_filename)
302
303
        return output, doc2
304
305
    # ------------------------------------------------------------------------------------------------------------------
306
    def test_sdoc2(self, main_filename):
307
        """
308
        Parses a SDoc document and returns a tuple with the stdout and the resulting SDoc2 document.
309
310
        :param str main_filename: The name of the file with then main SDoc1 document.
311
312
        :rtype: (str,str)
313
        """
314
        self._create_node_store()
315
        self._import_nodes()
316
        self._import_formatters()
317
318
        old_stdout, sys.stdout = sys.stdout, StringIO()
319
320
        temp_filename = main_filename + '.sdoc2'
321
        interpreter1 = SDoc1Interpreter()
322
        interpreter1.process(main_filename, temp_filename)
323
324
        interpreter2 = SDoc2Interpreter()
325
        interpreter2.process(temp_filename)
326
327
        sdoc2.node_store.number_numerable()