# Path: foos/ui/ui.py
# def registerMenu(f):
#     menuGenerators.append(f)


import time
import logging
import json
import random
import os
import glob
import shutil
import foos.config as config
from foos.ui.ui import registerMenu
    def write_results(self, match):
        fname = self._get_result_file_for(match)
        with open(fname, 'w') as f:
            json.dump(match, f, indent=2)

    def get_result_files(self):
        pattern = os.path.join(league_results_dir, 'result_*.json')
        return glob.glob(pattern)

    def _get_result_file_for(self, match):
        return os.path.join(league_results_dir,
                            'result_%d.json' % match.get('id', random.randint(0, 10000)))

    def mark_result_as_processed(self, name):
        target = os.path.join(processed_dir, os.path.basename(name))
        shutil.move(name, target)

diskbackend = DiskBackend()


class Plugin:
    def __init__(self, bus):
        self.bus = bus
        self.bus.subscribe_map({"start_competition": self.start_competition,
                                "win_game": self.win_game,
                                "cancel_competition": self.cancel_competition},
                               thread=True)
        self.current_game = 0
        self.match = None
        self.backend = diskbackend

# Path: foos/ui/ui.py
# def registerMenu(f):
#     menuGenerators.append(f)


# Path: plugins/league.py
import time
import logging
import json
import random
import os
import glob
import shutil
import foos.config as config
from foos.ui.ui import registerMenu

    def write_results(self, match):
        fname = self._get_result_file_for(match)
        with open(fname, 'w') as f:
            json.dump(match, f, indent=2)

    def get_result_files(self):
        pattern = os.path.join(league_results_dir, 'result_*.json')
        return glob.glob(pattern)

    def _get_result_file_for(self, match):
        return os.path.join(league_results_dir,
                            'result_%d.json' % match.get('id', random.randint(0, 10000)))

    def mark_result_as_processed(self, name):
        target = os.path.join(processed_dir, os.path.basename(name))
        shutil.move(name, target)

diskbackend = DiskBackend()


class Plugin:
    def __init__(self, bus):
        self.bus = bus
        self.bus.subscribe_map({"start_competition": self.start_competition,
                                "win_game": self.win_game,
                                "cancel_competition": self.cancel_competition},
                               thread=True)
        self.current_game = 0
        self.match = None
        self.backend = diskbackend

        registerMenu(self.get_menu_entries)