Imported Upstream version 1.2.1
[packages/binwalk.git] / binwalk / config.py
index cb1d72f..5c26254 100644 (file)
@@ -27,19 +27,22 @@ class Config:
        Valid file names under both the 'user' and 'system' keys are as follows:
 
                o BINWALK_MAGIC_FILE  - Path to the default binwalk magic file.
-               o BINCAST_MAGIC_FILE  - Path to the bincast magic file (used when -C is specified with the command line binwalk script)
-               o BINARCH_MAGIC_FILE  - Path to the binarch magic file (used when -A is specified with the command line binwalk script)
-               o EXTRACT_FILE        - Path to the extract configuration file (used when -e is specified with the command line binwalk script)
+               o BINCAST_MAGIC_FILE  - Path to the bincast magic file (used when -C is specified with the command line binwalk script).
+               o BINARCH_MAGIC_FILE  - Path to the binarch magic file (used when -A is specified with the command line binwalk script).
+               o EXTRACT_FILE        - Path to the extract configuration file (used when -e is specified with the command line binwalk script).
+               o PLUGINS             - Path to the plugins directory.
        '''
        # Release version
-       VERSION = "1.0"
+       VERSION = "1.2.1"
 
        # Sub directories
        BINWALK_USER_DIR = ".binwalk"
        BINWALK_MAGIC_DIR = "magic"
        BINWALK_CONFIG_DIR = "config"
+       BINWALK_PLUGINS_DIR = "plugins"
 
        # File names
+       PLUGINS = "plugins"
        EXTRACT_FILE = "extract.conf"
        BINWALK_MAGIC_FILE = "binwalk"
        BINCAST_MAGIC_FILE = "bincast"
@@ -61,16 +64,18 @@ class Config:
                }
 
                # Build the paths to all user-specific files
-               self.paths['user'][self.BINWALK_MAGIC_FILE] = self._user_file(self.BINWALK_MAGIC_DIR, self.BINWALK_MAGIC_FILE)
-               self.paths['user'][self.BINCAST_MAGIC_FILE] = self._user_file(self.BINWALK_MAGIC_DIR, self.BINCAST_MAGIC_FILE)
-               self.paths['user'][self.BINARCH_MAGIC_FILE] = self._user_file(self.BINWALK_MAGIC_DIR, self.BINARCH_MAGIC_FILE)
-               self.paths['user'][self.EXTRACT_FILE] = self._user_file(self.BINWALK_CONFIG_DIR, self.EXTRACT_FILE)
+               self.paths['user'][self.BINWALK_MAGIC_FILE] = self._user_path(self.BINWALK_MAGIC_DIR, self.BINWALK_MAGIC_FILE)
+               self.paths['user'][self.BINCAST_MAGIC_FILE] = self._user_path(self.BINWALK_MAGIC_DIR, self.BINCAST_MAGIC_FILE)
+               self.paths['user'][self.BINARCH_MAGIC_FILE] = self._user_path(self.BINWALK_MAGIC_DIR, self.BINARCH_MAGIC_FILE)
+               self.paths['user'][self.EXTRACT_FILE] = self._user_path(self.BINWALK_CONFIG_DIR, self.EXTRACT_FILE)
+               self.paths['user'][self.PLUGINS] = self._user_path(self.BINWALK_PLUGINS_DIR)
 
                # Build the paths to all system-wide files
-               self.paths['system'][self.BINWALK_MAGIC_FILE] = self._system_file(self.BINWALK_MAGIC_DIR, self.BINWALK_MAGIC_FILE)
-               self.paths['system'][self.BINCAST_MAGIC_FILE] = self._system_file(self.BINWALK_MAGIC_DIR, self.BINCAST_MAGIC_FILE)
-               self.paths['system'][self.BINARCH_MAGIC_FILE] = self._system_file(self.BINWALK_MAGIC_DIR, self.BINARCH_MAGIC_FILE)
-               self.paths['system'][self.EXTRACT_FILE] = self._system_file(self.BINWALK_CONFIG_DIR, self.EXTRACT_FILE)
+               self.paths['system'][self.BINWALK_MAGIC_FILE] = self._system_path(self.BINWALK_MAGIC_DIR, self.BINWALK_MAGIC_FILE)
+               self.paths['system'][self.BINCAST_MAGIC_FILE] = self._system_path(self.BINWALK_MAGIC_DIR, self.BINCAST_MAGIC_FILE)
+               self.paths['system'][self.BINARCH_MAGIC_FILE] = self._system_path(self.BINWALK_MAGIC_DIR, self.BINARCH_MAGIC_FILE)
+               self.paths['system'][self.EXTRACT_FILE] = self._system_path(self.BINWALK_CONFIG_DIR, self.EXTRACT_FILE)
+               self.paths['system'][self.PLUGINS] = self._system_path(self.BINWALK_PLUGINS_DIR)
        
        def _get_system_dir(self):
                '''
@@ -119,7 +124,7 @@ class Config:
 
                return fpath
 
-       def _user_file(self, subdir, basename):
+       def _user_path(self, subdir, basename=''):
                '''
                Gets the full path to the 'subdir/basename' file in the user binwalk directory.
 
@@ -130,7 +135,7 @@ class Config:
                '''
                return self._file_path(os.path.join(self.user_dir, self.BINWALK_USER_DIR, subdir), basename)
 
-       def _system_file(self, subdir, basename):
+       def _system_path(self, subdir, basename=''):
                '''
                Gets the full path to the 'subdir/basename' file in the system binwalk directory.