[GitHub] [airflow] uranusjr commented on a change in pull request #21538: py files doesn't have to be checked is_zipfiles in process_files

2022-02-13 Thread GitBox


uranusjr commented on a change in pull request #21538:
URL: https://github.com/apache/airflow/pull/21538#discussion_r805299701



##
File path: airflow/models/dagbag.py
##
@@ -284,7 +284,10 @@ def process_file(self, filepath, only_if_updated=True, 
safe_mode=True):
 self.log.exception(e)
 return []
 
-if not zipfile.is_zipfile(filepath):
+_, file_ext = os.path.splitext(os.path.split(filepath)[-1])
+is_zipfile = file_ext != '.py' and zipfile.is_zipfile(filepath)
+
+if not is_zipfile:

Review comment:
   If you don’t need the first part of the filename, it’s easier to simply
   
   ```python
   if not filepath.endswith(".py") and zipfile.is_zipfile(filepath):
   ```

##
File path: airflow/models/dagbag.py
##
@@ -284,7 +284,10 @@ def process_file(self, filepath, only_if_updated=True, 
safe_mode=True):
 self.log.exception(e)
 return []
 
-if not zipfile.is_zipfile(filepath):
+_, file_ext = os.path.splitext(os.path.split(filepath)[-1])
+is_zipfile = file_ext != '.py' and zipfile.is_zipfile(filepath)
+
+if not is_zipfile:

Review comment:
   If you don’t need the first part of the filename, it’s easier (and 
actually faster) to simply
   
   ```python
   if not filepath.endswith(".py") and zipfile.is_zipfile(filepath):
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [airflow] uranusjr commented on a change in pull request #21538: py files doesn't have to be checked is_zipfiles in process_files

2022-02-13 Thread GitBox


uranusjr commented on a change in pull request #21538:
URL: https://github.com/apache/airflow/pull/21538#discussion_r805299701



##
File path: airflow/models/dagbag.py
##
@@ -284,7 +284,10 @@ def process_file(self, filepath, only_if_updated=True, 
safe_mode=True):
 self.log.exception(e)
 return []
 
-if not zipfile.is_zipfile(filepath):
+_, file_ext = os.path.splitext(os.path.split(filepath)[-1])
+is_zipfile = file_ext != '.py' and zipfile.is_zipfile(filepath)
+
+if not is_zipfile:

Review comment:
   If you don’t need the first part of the filename, it’s easier (and 
actually faster) to simply
   
   ```python
   if not filepath.endswith(".py") and zipfile.is_zipfile(filepath):
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [airflow] uranusjr commented on a change in pull request #21538: py files doesn't have to be checked is_zipfiles in process_files

2022-02-13 Thread GitBox


uranusjr commented on a change in pull request #21538:
URL: https://github.com/apache/airflow/pull/21538#discussion_r805299701



##
File path: airflow/models/dagbag.py
##
@@ -284,7 +284,10 @@ def process_file(self, filepath, only_if_updated=True, 
safe_mode=True):
 self.log.exception(e)
 return []
 
-if not zipfile.is_zipfile(filepath):
+_, file_ext = os.path.splitext(os.path.split(filepath)[-1])
+is_zipfile = file_ext != '.py' and zipfile.is_zipfile(filepath)
+
+if not is_zipfile:

Review comment:
   If you don’t need the first part of the filename, it’s easier to simply
   
   ```python
   if not filepath.endswith(".py") and zipfile.is_zipfile(filepath):
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org