X-Git-Url: http://www.git.cypherpunks.ru/?p=gocheese.git;a=blobdiff_plain;f=metadata.go;h=65accbb9bef16186726411063bcb01a0d389b70b;hp=65080b506b256d82daefc230617a8f6622fd7574;hb=HEAD;hpb=60834a0713d5dcc6a9911511cb8618ce7358c824 diff --git a/metadata.go b/metadata.go index 65080b5..8959002 100644 --- a/metadata.go +++ b/metadata.go @@ -1,55 +1,95 @@ -/* -GoCheese -- Python private package repository and caching proxy -Copyright (C) 2019-2021 Sergey Matveev - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ +// GoCheese -- Python private package repository and caching proxy +// Copyright (C) 2019-2024 Sergey Matveev +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . package main -import "strings" - const ( - MetadataFile = ".metadata.rec" + MDFile = ".metadata.rec" // https://packaging.python.org/specifications/core-metadata/ - MetadataVersion = "2.1" - MetadataFieldMetadataVersion = "Metadata-Version" - MetadataFieldName = "Name" - MetadataFieldVersion = "Version" - MetadataFieldDescription = "Description" - MetadataFieldPlatform = "Platform" - MetadataFieldSupportedPlatform = "Supported-Platform" - MetadataFieldSummary = "Summary" - MetadataFieldDescriptionContentType = "Description-Content-Type" - MetadataFieldKeywords = "Keywords" - MetadataFieldHomePage = "Home-page" - MetadataFieldAuthor = "Author" - MetadataFieldAuthorEmail = "Author-email" - MetadataFieldMaintainer = "Maintainer" - MetadataFieldMaintainerEmail = "Maintainer-Email" - MetadataFieldLicense = "License" - MetadataFieldRequiresDist = "Requires-Dist" - MetadataFieldRequiresPython = "Requires-Python" - MetadataFieldRequiresExternal = "Requires-External" - MetadataFieldProjectURL = "Project-URL" - MetadataFieldProvidesExtra = "Provides-Extra" - MetadataFieldClassifier = "Classifier" + MDVersion = "2.1" + MDFieldMetadataVersion = "Metadata-Version" + MDFieldName = "Name" + MDFieldVersion = "Version" + MDFieldDescription = "Description" + MDFieldPlatform = "Platform" + MDFieldSupportedPlatform = "Supported-Platform" + MDFieldSummary = "Summary" + MDFieldDescriptionContentType = "Description-Content-Type" + MDFieldKeywords = "Keywords" + MDFieldHomePage = "Home-page" + MDFieldAuthor = "Author" + MDFieldAuthorEmail = "Author-email" + MDFieldMaintainer = "Maintainer" + MDFieldMaintainerEmail = "Maintainer-email" + MDFieldLicense = "License" + MDFieldRequiresDist = "Requires-Dist" + MDFieldRequiresPython = "Requires-Python" + MDFieldRequiresExternal = "Requires-External" + MDFieldProjectURL = "Project-URL" + MDFieldProvidesExtra = "Provides-Extra" + MDFieldClassifier = "Classifier" ) -func metadataFieldToRecField(f string) string { - return strings.ReplaceAll(f, "-", "") -} +var ( + MDFieldToRecField = map[string]string{ + MDFieldMetadataVersion: "MetadataVersion", + MDFieldName: "Name", + MDFieldVersion: "Version", + MDFieldDescription: "Description", + MDFieldPlatform: "Platform", + MDFieldSupportedPlatform: "SupportedPlatform", + MDFieldSummary: "Summary", + MDFieldDescriptionContentType: "DescriptionContentType", + MDFieldKeywords: "Keywords", + MDFieldHomePage: "HomePage", + MDFieldAuthor: "Author", + MDFieldAuthorEmail: "AuthorEmail", + MDFieldMaintainer: "Maintainer", + MDFieldMaintainerEmail: "MaintainerEmail", + MDFieldLicense: "License", + MDFieldRequiresDist: "RequiresDist", + MDFieldRequiresPython: "RequiresPython", + MDFieldRequiresExternal: "RequiresExternal", + MDFieldProjectURL: "ProjectURL", + MDFieldProvidesExtra: "ProvidesExtra", + MDFieldClassifier: "Classifier", + } + MDFormToRecField = [][2]string{ + {"name", MDFieldToRecField[MDFieldName]}, + {"version", MDFieldToRecField[MDFieldVersion]}, + {"platform", MDFieldToRecField[MDFieldPlatform]}, + {"supported_platform", MDFieldToRecField[MDFieldSupportedPlatform]}, + {"summary", MDFieldToRecField[MDFieldSummary]}, + {"description", MDFieldToRecField[MDFieldDescription]}, + {"description_content_type", MDFieldToRecField[MDFieldDescriptionContentType]}, + {"keywords", MDFieldToRecField[MDFieldKeywords]}, + {"home_page", MDFieldToRecField[MDFieldHomePage]}, + {"author", MDFieldToRecField[MDFieldAuthor]}, + {"author_email", MDFieldToRecField[MDFieldAuthorEmail]}, + {"maintainer", MDFieldToRecField[MDFieldMaintainer]}, + {"maintainer_email", MDFieldToRecField[MDFieldMaintainerEmail]}, + {"license", MDFieldToRecField[MDFieldLicense]}, + {"classifiers", MDFieldToRecField[MDFieldClassifier]}, + {"requires_dist", MDFieldToRecField[MDFieldRequiresDist]}, + {"requires_python", MDFieldToRecField[MDFieldRequiresPython]}, + {"requires_external", MDFieldToRecField[MDFieldRequiresExternal]}, + {"project_url", MDFieldToRecField[MDFieldProjectURL]}, + {"provides_extra", MDFieldToRecField[MDFieldProvidesExtra]}, + } +) // It should follow https://www.python.org/dev/peps/pep-0566/ type PkgInfo struct { @@ -108,7 +148,7 @@ type PkgReleaseInfo struct { type PkgMeta struct { Info PkgInfo `json:"info"` - LastSerial int `json:"last_serial"` + LastSerial int64 `json:"last_serial"` Releases map[string][]*PkgReleaseInfo `json:"releases"` URLs []*PkgReleaseInfo `json:"urls"` }