Browse Source

deploy-ng: Improve file_handler API

User-defined file handlers are added to a dictionary of default handlers
(just has egg2bam for *.egg files for now). Any user-provided file
handlers for a given file type will overwrite default file handlers.

This allows users to define file handlers without having to re-add
egg2bam to the list.
Mitchell Stokes 7 years ago
parent
commit
1983382b3b
1 changed files with 8 additions and 3 deletions
  1. 8 3
      direct/src/showutil/dist.py

+ 8 - 3
direct/src/showutil/dist.py

@@ -179,6 +179,9 @@ class build_apps(setuptools.Command):
         ('build-base=', None, 'directory to build applications in'),
         ('build-base=', None, 'directory to build applications in'),
         ('requirements-path=', None, 'path to requirements.txt file for pip'),
         ('requirements-path=', None, 'path to requirements.txt file for pip'),
     ]
     ]
+    default_file_handlers = {
+        '.egg': egg2bam,
+    }
 
 
     def initialize_options(self):
     def initialize_options(self):
         self.build_base = os.path.join(os.getcwd(), 'build')
         self.build_base = os.path.join(os.getcwd(), 'build')
@@ -200,9 +203,7 @@ class build_apps(setuptools.Command):
         self.log_append = False
         self.log_append = False
         self.requirements_path = './requirements.txt'
         self.requirements_path = './requirements.txt'
         self.pypi_extra_indexes = []
         self.pypi_extra_indexes = []
-        self.file_handlers= {
-            '.egg': egg2bam,
-        }
+        self.file_handlers = {}
         self.exclude_dependencies = [
         self.exclude_dependencies = [
             # Windows
             # Windows
             'kernel32.dll', 'user32.dll', 'wsock32.dll', 'ws2_32.dll',
             'kernel32.dll', 'user32.dll', 'wsock32.dll', 'ws2_32.dll',
@@ -277,6 +278,10 @@ class build_apps(setuptools.Command):
         assert os.path.exists(self.requirements_path), 'Requirements.txt path does not exist: {}'.format(self.requirements_path)
         assert os.path.exists(self.requirements_path), 'Requirements.txt path does not exist: {}'.format(self.requirements_path)
         assert num_gui_apps + num_console_apps != 0, 'Must specify at least one app in either gui_apps or console_apps'
         assert num_gui_apps + num_console_apps != 0, 'Must specify at least one app in either gui_apps or console_apps'
 
 
+        tmp = self.default_file_handlers.copy()
+        tmp.update(self.file_handlers)
+        self.file_handlers = tmp
+
     def run(self):
     def run(self):
         if not self.platforms:
         if not self.platforms:
             platforms = [p3d.PandaSystem.get_platform()]
             platforms = [p3d.PandaSystem.get_platform()]