Repository navigation
format: eml - mail messages with real files attached, and the names readers disagree about #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
20368cd
format: every format names its media type, from the IANA registry
donislawdev bca8e14
format: a container names its members, so a container need not be an …
donislawdev 42df317
eml: the generator - text, html or both, attachments in base64, names…
donislawdev 8a55c47
eml: the oracle, the structural check, the guards, and the window's w…
donislawdev 3ec90e1
eml: a refusal of size that speaks of attached files only when there …
donislawdev 55a7a62
eml: golden values, the preset grows by one, the site and the README …
donislawdev dccafd9
window: a kind for mail, under which eml stands with the toolkit's en…
donislawdev fd02c50
format: the descriptor back to sixteen fields - a container is the na…
donislawdev 829800c
format: the refusal of a container inside itself speaks of files, now…
donislawdev cd50495
eml: review of #173 - a lockfile for mailparser, the contents refusal…
donislawdev a43f747
ci: mailparser without a committed lockfile again - the licence gate …
donislawdev e1dd52c
eml: a text format, and the picture guard's sample address under a na…
donislawdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| package format | ||
|
|
||
| import ( | ||
| "sort" | ||
| "strings" | ||
|
|
||
| "github.com/donislawdev/TestingFilesGenerator/internal/core" | ||
| ) | ||
|
|
||
| // What a container is, apart from the format it writes: how it names its | ||
| // contents, and the three ways asking a format for contents can be refused. | ||
| // Split out of format.go on 2026-10-07, when eml - the first container that is | ||
| // not an archive - pushed that file past the size the shape guard allows. | ||
|
|
||
| // Members is how a container names the settings for contents of one format. | ||
| type Members struct { | ||
| Count, Format, Size string | ||
| } | ||
|
|
||
| // NotAContainerError is contains asked of a format that holds nothing. | ||
| type NotAContainerError struct { | ||
| Format string | ||
| Containers []string | ||
| } | ||
|
|
||
| // What happened, what can do it instead, and what to do about it. | ||
| func (e *NotAContainerError) What() string { return e.what().String() } | ||
|
|
||
| func (e *NotAContainerError) what() core.Said { | ||
| return core.Says("format.NotAContainer", "%s holds no other files, so it cannot take contains", core.A("Format", e.Format)) | ||
| } | ||
|
|
||
| func (e *NotAContainerError) Why() string { return e.why().String() } | ||
|
|
||
| func (e *NotAContainerError) why() core.Said { | ||
| return core.Says("format.NotAContainerWhy", "the formats that can are %s", core.A("Containers", strings.Join(e.Containers, ", "))) | ||
| } | ||
|
|
||
| func (e *NotAContainerError) Instead() string { return e.instead().String() } | ||
|
|
||
| func (e *NotAContainerError) instead() core.Said { | ||
| return core.Says("format.NotAContainerFix", "Drop contains, or change the format") | ||
| } | ||
|
|
||
| // Parts is what happened, why and what to do instead, for a reader that lays | ||
| // them out apart and in its own language. | ||
| func (e *NotAContainerError) Parts() (what, why, instead core.Said) { | ||
| return e.what(), e.why(), e.instead() | ||
| } | ||
|
|
||
| func (e *NotAContainerError) Error() string { return e.Said().String() } | ||
|
|
||
| // Said is the whole refusal, for a window that says it in its own language. | ||
| func (e *NotAContainerError) Said() core.Said { | ||
| return core.Says("format.NotAContainerWhole", "%s - %s. %s", core.A("What", e.what()), core.A("Why", e.why()), core.A("Fix", e.instead())) | ||
| } | ||
|
|
||
| // ContentsConflictError is contains stated beside format properties saying the | ||
| // same thing. Picking one would build a container holding something other than | ||
| // what the recipe says, and the recipe is what somebody reads in a review. | ||
| // | ||
| // It speaks of files rather than of an archive since a mail message became a | ||
| // container (review of #173). | ||
| type ContentsConflictError struct { | ||
| Format string | ||
| Keys []string | ||
| } | ||
|
|
||
| func (e *ContentsConflictError) Error() string { return e.Said().String() } | ||
|
|
||
| // Said is the refusal, for a window that says it in its own language. | ||
| func (e *ContentsConflictError) Said() core.Said { | ||
| if len(e.Keys) == 1 { | ||
| return core.Says("format.ContentsConflictOne", | ||
| "%s: contains and the %s property both say which files it holds. Keep contains and drop the property, or the other way round", | ||
| core.A("Format", e.Format), core.A("Key", e.Keys[0])) | ||
| } | ||
| return core.Says("format.ContentsConflict", | ||
| "%s: contains and the %s properties both say which files it holds. Keep contains and drop the properties, or the other way round", | ||
| core.A("Format", e.Format), core.A("Keys", strings.Join(e.Keys, ", "))) | ||
| } | ||
|
|
||
| // NestingUnsupportedError is a container asked to hold its own format. | ||
| // | ||
| // A legitimate test case that needs a depth limit before it is allowed, and | ||
| // there is none yet. It says that rather than pretending the format is unknown. | ||
| type NestingUnsupportedError struct { | ||
| Format string | ||
| } | ||
|
|
||
| func (e *NestingUnsupportedError) Error() string { return e.Said().String() } | ||
|
|
||
| // Said is the refusal, for a window that says it in its own language. | ||
| func (e *NestingUnsupportedError) Said() core.Said { | ||
| return core.Says("format.NestingUnsupported", | ||
| "%s cannot hold %s yet - a file inside a file of its own format needs a depth limit first. Hold a different format, or make the inner file its own target", | ||
| core.A("Format", e.Format), core.A("Inner", e.Format)) | ||
| } | ||
|
|
||
| // Containers lists the formats that accept contains, for a message that tells | ||
| // somebody what to write instead. | ||
| func Containers() []string { | ||
| mu.RLock() | ||
| defer mu.RUnlock() | ||
| var out []string | ||
| for id, d := range registry { | ||
| if d.Container != nil { | ||
| out = append(out, id) | ||
| } | ||
| } | ||
| sort.Strings(out) | ||
| return out | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.