client

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const ErrorNeedContestID = "You have to specify the Contest ID"

ErrorNeedContestID error

View Source
const ErrorNeedGroupID = "You have to specify the Group ID"

ErrorNeedGroupID error

View Source
const ErrorNeedGymID = "You have to specify the Gym ID"

ErrorNeedGymID error

View Source
const ErrorNeedProblemID = "You have to specify the Problem ID"

ErrorNeedProblemID error

View Source
const ErrorNeedSubmissionID = "You have to specify the Submission ID"

ErrorNeedSubmissionID error

View Source
const ErrorNotSupportAcmsguru = "Not support acmsguru"

ErrorNotSupportAcmsguru error

View Source
const ErrorSkip = "Exists, skip"

ErrorSkip error

View Source
const ErrorTooManyRequest = "Too many requests"

ErrorTooManyRequest error

View Source
const ErrorUnknownType = "Unknown Type"

ErrorUnknownType error

Variables

View Source
var ErrorNotLogged = "Not logged in"

ErrorNotLogged not logged in

View Source
var Langs = map[string]string{
	"43": "GNU GCC C11 5.1.0",
	"50": "GNU G++14 6.4.0",
	"54": "GNU G++17 7.3.0",
	"89": "GNU G++20 13.2 (64 bit, winlibs)",
	"65": "C# 8, .NET Core 3.1",
	"79": "C# 10, .NET SDK 6.0",
	"9":  "C# Mono 6.8",
	"28": "D DMD32 v2.105.0",
	"32": "Go 1.19.5",
	"12": "Haskell GHC 8.10.1",
	"87": "Java 21 64bit",
	"36": "Java 8 32bit",
	"83": "Kotlin 1.7.20",
	"88": "Kotlin 1.9.21",
	"19": "OCaml 4.02.1",
	"3":  "Delphi 7",
	"4":  "Free Pascal 3.2.2",
	"51": "PascalABC.NET 3.8.3",
	"13": "Perl 5.20.1",
	"6":  "PHP 8.1.7",
	"7":  "Python 2.7.18",
	"31": "Python 3.8.10",
	"40": "PyPy 2.7.13 (7.3.0)",
	"41": "PyPy 3.6.9 (7.3.0)",
	"70": "PyPy 3.9.10 (7.3.9, 64bit)",
	"67": "Ruby 3.2.2",
	"75": "Rust 1.75.0 (2021)",
	"55": "Node.js 15.8.0 (64bit)",
	"20": "Scala 2.12.8",
	"34": "JavaScript V8 4.8.0",
}

Langs generated by ```py import re # For regular expression matching

html_fragment = """ # Paste your HTML fragment in place of this multi-line string """

# Regular expression to match <option> tags option_pattern = r'<option value="(\d+)">(.*?)</option>'

results = [] for match in re.finditer(option_pattern, html_fragment):

value = match.group(1)
inner_text = match.group(2)
results.append(f'"{value}": "{inner_text}",')

# Print the formatted list print('\n'.join(results)) ```

View Source
var LangsExt = map[string]string{
	"GNU C11":               "c",
	"Clang++17 Diagnostics": "cpp",
	"GNU C++0x":             "cpp",
	"GNU C++":               "cpp",
	"GNU C++11":             "cpp",
	"GNU C++14":             "cpp",
	"GNU C++17":             "cpp",
	"GNU C++20":             "cpp",
	"MS C++":                "cpp",
	"MS C++ 2017":           "cpp",
	"Mono C#":               "cs",
	"D":                     "d",
	"Go":                    "go",
	"Haskell":               "hs",
	"Kotlin":                "kt",
	"Ocaml":                 "ml",
	"Delphi":                "pas",
	"FPC":                   "pas",
	"PascalABC.NET":         "pas",
	"Perl":                  "pl",
	"PHP":                   "php",
	"Python 2":              "py",
	"Python 3":              "py",
	"PyPy 2":                "py",
	"PyPy 3":                "py",
	"Ruby":                  "rb",
	"Rust":                  "rs",
	"JavaScript":            "js",
	"Node.js":               "js",
	"Q#":                    "qs",
	"Java":                  "java",
	"Java 6":                "java",
	"Java 7":                "java",
	"Java 8":                "java",
	"Java 9":                "java",
	"Java 10":               "java",
	"Java 11":               "java",
	"Tcl":                   "tcl",
	"F#":                    "fs",
	"Befunge":               "bf",
	"Pike":                  "pike",
	"Io":                    "io",
	"Factor":                "factor",
	"Cobol":                 "cbl",
	"Secret_171":            "secret_171",
	"Ada":                   "adb",
	"FALSE":                 "f",
	"":                      "txt",
}

LangsExt language's ext

View Source
var ProblemTypes = [...]string{
	"contest",
	"gym",
	"group",
	"acmsguru",
}

ProblemTypes problem types

Functions

func Init added in v0.9.0

func Init(path, host, proxy string)

Init initialize

Types

type Client

type Client struct {
	Jar            *cookiejar.Jar `json:"cookies"`
	Handle         string         `json:"handle"`
	HandleOrEmail  string         `json:"handle_or_email"`
	Password       string         `json:"password"`
	Ftaa           string         `json:"ftaa"`
	Bfaa           string         `json:"bfaa"`
	LastSubmission *Info          `json:"last_submission"`
	// contains filtered or unexported fields
}

Client codeforces client

var Instance *Client

Instance global client

func (*Client) Clone added in v0.7.0

func (c *Client) Clone(handle, rootPath string, ac bool) (err error)

Clone all ac codes of all contests

func (*Client) ConfigLogin added in v0.9.0

func (c *Client) ConfigLogin() (err error)

ConfigLogin configure handle and password

func (*Client) DecryptPassword added in v0.9.0

func (c *Client) DecryptPassword() (string, error)

DecryptPassword get real password

func (*Client) Login

func (c *Client) Login() (err error)

Login codeforces with handler and password

func (*Client) Parse added in v1.0.0

func (c *Client) Parse(info Info) (problems []string, paths []string, err error)

Parse parse

func (*Client) ParseProblem

func (c *Client) ParseProblem(URL, path string, mu *sync.Mutex) (samples int, standardIO bool, err error)

ParseProblem parse problem to path. mu can be nil

func (*Client) Pull added in v1.0.0

func (c *Client) Pull(info Info, rootPath string, ac bool) (err error)

Pull pull all latest codes or ac codes

func (*Client) PullCode added in v0.4.0

func (c *Client) PullCode(URL, path, ext string, rename bool) (filename string, err error)

PullCode pull problem's code to path

func (*Client) RaceContest added in v0.3.0

func (c *Client) RaceContest(info Info) (err error)

RaceContest wait for contest starting

func (*Client) Statis added in v1.0.0

func (c *Client) Statis(info Info) (problems []StatisInfo, err error)

Statis get statis

func (*Client) Submit added in v1.0.0

func (c *Client) Submit(info Info, langID, source string) (err error)

Submit submit (block while pending)

func (*Client) WatchSubmission added in v0.2.0

func (c *Client) WatchSubmission(info Info, n int, line bool) (submissions []Submission, err error)

WatchSubmission n is the number of submissions

type Info added in v1.0.0

type Info struct {
	ProblemType  string `json:"problem_type"`
	ContestID    string `json:"contest_id"`
	GroupID      string `json:"group_id"`
	ProblemID    string `json:"problem_id"`
	SubmissionID string `json:"submission_id"`
	RootPath     string
}

Info information

func (*Info) Hint added in v1.0.0

func (info *Info) Hint() string

Hint hint text

func (*Info) MySubmissionURL added in v1.0.0

func (info *Info) MySubmissionURL(host string) (string, error)

MySubmissionURL parse submission url

func (*Info) OpenURL added in v1.0.0

func (info *Info) OpenURL(host string) (string, error)

OpenURL open url

func (*Info) Path added in v1.0.0

func (info *Info) Path() string

Path path

func (*Info) ProblemSetURL added in v1.0.0

func (info *Info) ProblemSetURL(host string) (string, error)

ProblemSetURL parse problem set url

func (*Info) ProblemURL added in v1.0.0

func (info *Info) ProblemURL(host string) (string, error)

ProblemURL parse problem url

func (*Info) StandingsURL added in v1.0.0

func (info *Info) StandingsURL(host string) (string, error)

StandingsURL parse standings url

func (*Info) SubmissionURL added in v1.0.0

func (info *Info) SubmissionURL(host string) (string, error)

SubmissionURL parse submission url

func (*Info) SubmitURL added in v1.0.0

func (info *Info) SubmitURL(host string) (string, error)

SubmitURL submit url

type StatisInfo

type StatisInfo struct {
	ID     string
	Name   string
	IO     string
	Limit  string
	Passed string
	State  string
}

StatisInfo statis information

type Submission added in v0.2.0

type Submission struct {
	// contains filtered or unexported fields
}

Submission submit state

func (*Submission) ParseID added in v0.2.0

func (s *Submission) ParseID() string

ParseID formatter

func (*Submission) ParseMemory added in v0.2.0

func (s *Submission) ParseMemory() string

ParseMemory formatter

func (*Submission) ParseProblemIndex added in v0.8.0

func (s *Submission) ParseProblemIndex() string

ParseProblemIndex get problem's index

func (*Submission) ParseStatus added in v0.2.0

func (s *Submission) ParseStatus() string

ParseStatus with color

func (*Submission) ParseTime added in v0.2.0

func (s *Submission) ParseTime() string

ParseTime formatter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL