Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mat2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tails
mat2
Commits
effe68f0
Commit
effe68f0
authored
6 years ago
by
Julien (jvoisin) Voisin
Browse files
Options
Downloads
Patches
Plain Diff
The CLI shouldn't display unsupported file extensions
parent
7afff93e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.py
+10
-3
10 additions, 3 deletions
main.py
src/__init__.py
+5
-1
5 additions, 1 deletion
src/__init__.py
src/parser_factory.py
+2
-5
2 additions, 5 deletions
src/parser_factory.py
with
17 additions
and
9 deletions
main.py
+
10
−
3
View file @
effe68f0
...
...
@@ -8,7 +8,7 @@ import mimetypes
import
argparse
import
multiprocessing
from
src
import
parser_factory
from
src
import
parser_factory
,
unsupported_extensions
__version__
=
'
0.1.0
'
...
...
@@ -74,8 +74,15 @@ def show_parsers():
print
(
'
[+] Supported formats:
'
)
for
parser
in
parser_factory
.
_get_parsers
():
for
mtype
in
parser
.
mimetypes
:
extensions
=
'
,
'
.
join
(
mimetypes
.
guess_all_extensions
(
mtype
))
print
(
'
- %s (%s)
'
%
(
mtype
,
extensions
))
extensions
=
set
()
for
extension
in
mimetypes
.
guess_all_extensions
(
mtype
):
if
extension
[
1
:]
not
in
unsupported_extensions
:
# skip the dot
extensions
.
add
(
extension
)
if
not
extensions
:
# we're not supporting a single extension in the current
# mimetype, so there is not point in showing the mimetype at all
continue
print
(
'
- %s (%s)
'
%
(
mtype
,
'
,
'
.
join
(
extensions
)))
def
__get_files_recursively
(
files
):
...
...
This diff is collapsed.
Click to expand it.
src/__init__.py
+
5
−
1
View file @
effe68f0
#!/bin/env python3
\ No newline at end of file
#!/bin/env python3
# A set of extension that aren't supported, despite matching a supported mimetype
unsupported_extensions
=
set
([
'
bat
'
,
'
c
'
,
'
h
'
,
'
ksh
'
,
'
pl
'
,
'
txt
'
,
'
asc
'
,
'
text
'
,
'
pot
'
,
'
brf
'
,
'
srt
'
,
'
rdf
'
,
'
wsdl
'
,
'
xpdl
'
,
'
xsl
'
,
'
xsd
'
])
This diff is collapsed.
Click to expand it.
src/parser_factory.py
+
2
−
5
View file @
effe68f0
...
...
@@ -3,7 +3,7 @@ import mimetypes
import
importlib
import
pkgutil
from
.
import
abstract
from
.
import
abstract
,
unsupported_extensions
from
typing
import
TypeVar
...
...
@@ -27,13 +27,10 @@ def _get_parsers() -> list:
def
get_parser
(
filename
:
str
)
->
(
T
,
str
):
# A set of extension that aren't supported, despite matching a known mimetype
unknown_extensions
=
set
([
'
bat
'
,
'
c
'
,
'
h
'
,
'
ksh
'
,
'
pl
'
,
'
txt
'
,
'
asc
'
,
'
text
'
,
'
pot
'
,
'
brf
'
,
'
srt
'
,
'
rdf
'
,
'
wsdl
'
,
'
xpdl
'
,
'
xsl
'
,
'
xsd
'
])
mtype
,
_
=
mimetypes
.
guess_type
(
filename
)
_
,
extension
=
os
.
path
.
splitext
(
filename
)
if
extension
in
un
known
_extensions
:
if
extension
in
un
supported
_extensions
:
return
None
,
mtype
for
c
in
_get_parsers
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment