Skip to content

Commit f07bbda

Browse files
committed
split text package up to avoid circular import issue
1 parent d5830b4 commit f07bbda

File tree

5 files changed

+138
-83
lines changed

5 files changed

+138
-83
lines changed

fileformats/application/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from fileformats.core import __version__
2-
from fileformats.text import Javascript
32

43
from .archive import Archive, Bzip, Gzip, Tar, TarGzip, Zip
54
from .document import Document, Msword, MswordX, Pdf, Postscript
@@ -505,6 +504,8 @@
505504
Yaml,
506505
)
507506

507+
from fileformats.text import Javascript # isort: skip
508+
508509
__all__ = [
509510
"__version__",
510511
"Archive",

fileformats/text/__init__.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
from .ascii import CacheManifest
2+
from .base import Text
3+
from .unicode import (
4+
N3,
5+
T140,
6+
Css,
7+
Csv,
8+
CsvSchema,
9+
Dns,
10+
Encaprtp,
11+
Fhirpath,
12+
Flexfec,
13+
Fwdred,
14+
Gff3,
15+
GrammarRefList,
16+
Hl7v2,
17+
Javascript,
18+
JcrCnd,
19+
Mizar,
20+
Parameters,
21+
Parityfec,
22+
Plain,
23+
ProvenanceNotation,
24+
Prs_Fallenstein_Rst,
25+
Prs_Lines_Tag,
26+
Prs_Prop_Logic,
27+
Raptorfec,
28+
Red,
29+
Rfc822_headers,
30+
RichText,
31+
RtpEncAescm128,
32+
Rtploopback,
33+
Rtx,
34+
Sgml,
35+
Shaclc,
36+
Shex,
37+
Spdx,
38+
Strings,
39+
TextFile,
40+
Troff,
41+
Turtle,
42+
Ulpfec,
43+
UriList,
44+
Vcard,
45+
Vtt,
46+
Wgsl,
47+
XmlExternalParsedEntity,
48+
)
49+
50+
from fileformats.application import ( # isort: skip
51+
Json,
52+
Xml,
53+
Yaml,
54+
)
55+
56+
__all__ = [
57+
"__version__",
58+
"Text",
59+
"Plain",
60+
"TextFile",
61+
"Csv",
62+
"Tsv",
63+
"Html",
64+
"Markdown",
65+
"RestructedText",
66+
"_1d_interleaved_parityfec",
67+
"CacheManifest",
68+
"Calendar",
69+
"Cql",
70+
"CqlExpression",
71+
"CqlIdentifier",
72+
"Css",
73+
"CsvSchema",
74+
"Dns",
75+
"Encaprtp",
76+
"Fhirpath",
77+
"Flexfec",
78+
"Fwdred",
79+
"Gff3",
80+
"GrammarRefList",
81+
"Hl7v2",
82+
"Javascript",
83+
"JcrCnd",
84+
"Json",
85+
"Mizar",
86+
"N3",
87+
"Parameters",
88+
"Parityfec",
89+
"ProvenanceNotation",
90+
"Prs_Fallenstein_Rst",
91+
"Prs_Lines_Tag",
92+
"Prs_Prop_Logic",
93+
"Raptorfec",
94+
"Red",
95+
"Rfc822_headers",
96+
"RichText",
97+
"RtpEncAescm128",
98+
"Rtploopback",
99+
"Rtx",
100+
"Sgml",
101+
"Shaclc",
102+
"Shex",
103+
"Spdx",
104+
"Strings",
105+
"T140",
106+
"Troff",
107+
"Turtle",
108+
"Ulpfec",
109+
"UriList",
110+
"Vcard",
111+
"Vtt",
112+
"Wgsl",
113+
"Xml",
114+
"XmlExternalParsedEntity",
115+
"Yaml",
116+
]

fileformats/text/ascii.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from fileformats.core.mixin import WithMagicNumber
2+
from fileformats.generic import BinaryFile
3+
4+
from .base import Text
5+
6+
7+
class CacheManifest(WithMagicNumber, Text, BinaryFile):
8+
""""""
9+
10+
iana_mime = "text/cache-manifest"
11+
ext = ".appcache"
12+
alternate_exts = ('"manifest"',)
13+
magic_number = b"CACHE MANIFEST"

fileformats/text/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from fileformats.generic import File
2+
3+
4+
class Text(File):
5+
"""Base class for text files"""
Lines changed: 2 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
from fileformats.core.mixin import WithMagicNumber
2-
from fileformats.generic import BinaryFile, File, UnicodeFile
1+
from fileformats.generic import UnicodeFile
32

4-
from .core import __version__
5-
6-
7-
class Text(File):
8-
"""Base class for text files"""
3+
from .base import Text
94

105

116
# General formats
@@ -51,15 +46,6 @@ class _1d_interleaved_parityfec(Text, UnicodeFile):
5146
ext = None
5247

5348

54-
class CacheManifest(WithMagicNumber, Text, BinaryFile):
55-
""""""
56-
57-
iana_mime = "text/cache-manifest"
58-
ext = ".appcache"
59-
alternate_exts = ('"manifest"',)
60-
magic_number = b"CACHE MANIFEST"
61-
62-
6349
class Calendar(Text, UnicodeFile):
6450
"""This media type is designed
6551
for widespread use by Internet calendaring and scheduling
@@ -428,69 +414,3 @@ class XmlExternalParsedEntity(Text, UnicodeFile):
428414
iana_mime = "text/xml-external-parsed-entity"
429415
ext = ".ent"
430416
alternate_exts = (None,)
431-
432-
433-
from fileformats.application import ( # noqa; These are sometimes/historically considered part of the text registry so we import them here
434-
Json,
435-
Xml,
436-
Yaml,
437-
)
438-
439-
__all__ = [
440-
"__version__",
441-
"Text",
442-
"Plain",
443-
"TextFile",
444-
"Csv",
445-
"Tsv",
446-
"Html",
447-
"Markdown",
448-
"RestructedText",
449-
"_1d_interleaved_parityfec",
450-
"CacheManifest",
451-
"Calendar",
452-
"Cql",
453-
"CqlExpression",
454-
"CqlIdentifier",
455-
"Css",
456-
"CsvSchema",
457-
"Dns",
458-
"Encaprtp",
459-
"Fhirpath",
460-
"Flexfec",
461-
"Fwdred",
462-
"Gff3",
463-
"GrammarRefList",
464-
"Hl7v2",
465-
"Javascript",
466-
"JcrCnd",
467-
"Mizar",
468-
"N3",
469-
"Parameters",
470-
"Parityfec",
471-
"ProvenanceNotation",
472-
"Prs_Fallenstein_Rst",
473-
"Prs_Lines_Tag",
474-
"Prs_Prop_Logic",
475-
"Raptorfec",
476-
"Red",
477-
"Rfc822_headers",
478-
"RichText",
479-
"RtpEncAescm128",
480-
"Rtploopback",
481-
"Rtx",
482-
"Sgml",
483-
"Shaclc",
484-
"Shex",
485-
"Spdx",
486-
"Strings",
487-
"T140",
488-
"Troff",
489-
"Turtle",
490-
"Ulpfec",
491-
"UriList",
492-
"Vcard",
493-
"Vtt",
494-
"Wgsl",
495-
"XmlExternalParsedEntity",
496-
]

0 commit comments

Comments
 (0)