Exemple #1
0
 def get_contest(self, url):
     """Overridden.
     """
     contest = Contest()
     contest.url = url
     contest.id = "rosalind-problems"
     contest.name = "Rosalind problems archive"
     return contest
Exemple #2
0
 def get_contest(self, url):
     """Overridden.
     """
     contest = Contest()
     contest.url = url
     contest.id = "spoj-problems"
     contest.name = "Spoj problems archive"
     return contest
Exemple #3
0
 def get_contest(self, url):
     """Overridden.
     """
     url_path = urlparse(url).path
     assert url_path
     contest = Contest()
     contest.url = url
     tokens = SiteLocal.pattern_contest.search(url_path)
     contest.id = tokens.group('CONTEST')
     assert contest.id
     contest.name = contest.id
     return contest
Exemple #4
0
    def get_contest(self, url):
        """Overridden.
        """
        url_path = urlparse(url).path
        assert url_path
        contest = Contest()
        contest.url = url
        tokens = SiteCodeforces.pattern_contest.search(url_path)
        contest.id = tokens.group('CONTEST')

        page = SiteCodeforces._proxy.get(url)

        # Data from web:
        #   - contest name.
        if page.status_code == 200:
            t = html.fromstring(page.text)
            e = t.xpath(SiteCodeforces.xpath_contest_name)
            contest.name = (e and str(e[0])) or None

        return contest
Exemple #5
0
def _command_show(**args):
    """Displays information about:
        - configuration (application default and user specific),
        - command line arguments.

    Expects labels for arguments to be contained in "args_text" argument.
    """
    verbose = args['conf_all']['verbose']

    # Prepare labels for printing
    #  -> TERSE (opposite of verbose)
    args_labels = {
        'conf_all':       '1c --- Total config (overide 1b) .... ',
        'site_obj':       '3a --- Selected site processor ...... ',
        'contest_obj':    '3b --- Selected contest ............. ',
        'problems_objs':  '3c --- Selected problems ............ ',
    }

    #  -> VERBOSE
    if verbose:
        args_labels.update({
            'conf_global':    '1a --- App default config ........... ',
            'conf_user':      '******',
            'plugin_langs':   '2a --- Available language templates . ',
            'plugin_runners': '2b --- Available runner templates ... ',
            'plugin_sites':   '2c --- Available site processors .... ',
        })


    # Prepare application setting-and-config values for printing
    args_printable = {
        'conf_global': args['conf_global'],
        'conf_user': args['conf_user'],
        'conf_all': args['conf_all'],

        # args_printable['plugin_langs'] = ['cpp.0', 'cpp.1', 'py.0']
        'plugin_langs': args['plugin_langs'].keys(),

        # args_printable['plugin_langs'] = {'sh.0': ['cpp', 'py'],
        #                                   'sh.1': ['cpp', 'py']},
        'plugin_runners': {r: args['plugin_runners'][r].keys()
                           for r in args['plugin_runners']},

        # Prepare for TERSE or VERBOSE
        'plugin_sites': [{k: site.__dict__[k]
                          for k in ISite.get_props(verbose)}
                         for site in args['plugin_sites']],
        'site_obj': {k: args['site_obj'].__dict__[k]
                     for k in ISite.get_props(verbose)},
        'contest_obj': {k: args['contest_obj'].__dict__[k]
                        for k in Contest.get_props(verbose)},
        'problems_objs': [{k: prob.__dict__[k]
                           for k in Problem.get_props(verbose)}
                          for prob in args['problems_objs']]
    }

    #TODO display language x runner matrix

    # Construct dictionary with data to print
    data = {args_labels[key]: args_printable[key] for key in args_labels}

    # Pretty-print data
    printer = PrettyPrinter(indent=1, width=1)
    printer.pprint(data)

    return ExitStatus.OK