villebro commented on a change in pull request #9825:
URL:
https://github.com/apache/incubator-superset/pull/9825#discussion_r440597170
##########
File path: setup.py
##########
@@ -109,6 +109,7 @@ def get_git_sha():
"sqlalchemy-utils>=0.33.2,<0.36.5",
"sqlparse>=0.3.0, <0.4",
"wtforms-json",
+ "xlrd>=1.2.0",
Review comment:
Let's make this dependency optional by placing it in `setup.py` under
`extras_require`, something like
```
extras_require={
"excel": ["xlrd>=1.2.0,xlrd<1.3"],
}
```
##########
File path: superset/views/database/forms.py
##########
@@ -94,11 +94,11 @@ def at_least_one_schema_is_allowed(database: Database) ->
bool:
validators=[
FileRequired(),
FileAllowed(
- config["ALLOWED_EXTENSIONS"],
+ config["CSV_EXTENSIONS"],
Review comment:
I think you also need to do an intersection here, as someone might have
removed e.g. `tsv` from `ALLOWED_EXTENSIONS`
##########
File path: superset/app.py
##########
@@ -327,15 +332,30 @@ def init_views(self) -> None:
category="SQL Lab",
category_label=__("SQL Lab"),
)
- appbuilder.add_link(
- "Upload a CSV",
- label=__("Upload a CSV"),
- href="/csvtodatabaseview/form",
- icon="fa-upload",
- category="Sources",
- category_label=__("Sources"),
- category_icon="fa-wrench",
- )
+ if self.config["CSV_EXTENSIONS"].intersection(
+ self.config["ALLOWED_EXTENSIONS"]
+ ):
+ appbuilder.add_link(
+ "Upload a CSV",
+ label=__("Upload a CSV"),
+ href="/csvtodatabaseview/form",
+ icon="fa-upload",
+ category="Sources",
+ category_label=__("Sources"),
+ category_icon="fa-wrench",
+ )
+ if self.config["EXCEL_EXTENSIONS"].intersection(
+ self.config["ALLOWED_EXTENSIONS"]
+ ):
Review comment:
Let's also add a check to see if the `xlrd` package is available here:
```python
try:
import xlrd
if ...:
```
Doing this the menu will not be added unless the `xlrd` package is installed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]