Skip to content

Commit

Permalink
chore: move KNOWN_FILE_EXTENSIONS to config
Browse files Browse the repository at this point in the history
  • Loading branch information
5j9 committed Nov 7, 2023
1 parent e6fb49e commit bff9d8f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 39 deletions.
40 changes: 40 additions & 0 deletions wikitextparser/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,43 @@ def regex_pattern(words: _Iterable[str]) -> bytes:
'ucfirst',
'urlencode',
}


# https://github.com/wikimedia/mediawiki/blob/de18cff244e8fab2e1ab2470c3b444e76b305e12/includes/libs/mime/MimeAnalyzer.php#L425
KNOWN_FILE_EXTENSIONS = {
'bmp',
'djvu',
'gif',
'iff',
'jb2',
'jp2',
'jpc',
'jpeg',
'jpg',
'jpx',
'mid',
'mka',
'mkv',
'mp3',
'oga',
'ogg',
'ogv',
'ogx',
'opus',
'pdf',
'png',
'psd',
'spx',
'stl',
'svg',
'swc',
'swf',
'tif',
'tiff',
'wbmp',
'webm',
'webp',
'wmf',
'xbm',
'xcf',
}
40 changes: 1 addition & 39 deletions wikitextparser/_wikitext.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
_parsable_tag_extensions,
_tag_extensions,
regex_pattern,
KNOWN_FILE_EXTENSIONS,
)
from ._spans import (
BARE_EXTERNAL_LINK,
Expand Down Expand Up @@ -154,45 +155,6 @@

WS = '\r\n\t '

# https://github.com/wikimedia/mediawiki/blob/de18cff244e8fab2e1ab2470c3b444e76b305e12/includes/libs/mime/MimeAnalyzer.php#L425
KNOWN_FILE_EXTENSIONS = {
'bmp',
'djvu',
'gif',
'iff',
'jb2',
'jp2',
'jpc',
'jpeg',
'jpg',
'jpx',
'mid',
'mka',
'mkv',
'mp3',
'oga',
'ogg',
'ogv',
'ogx',
'opus',
'pdf',
'png',
'psd',
'spx',
'stl',
'svg',
'swc',
'swf',
'tif',
'tiff',
'wbmp',
'webm',
'webp',
'wmf',
'xbm',
'xcf',
}


class DeadIndexError(TypeError):
pass
Expand Down

0 comments on commit bff9d8f

Please sign in to comment.