2
0
Эх сурвалжийг харах

create config file on archivebox init

Nick Sweeting 6 жил өмнө
parent
commit
c43a0e58df

+ 0 - 1
archivebox/core/urls.py

@@ -1,5 +1,4 @@
 from django.contrib import admin
 from django.contrib import admin
-from django.utils.translation import ugettext_lazy
 
 
 from django.urls import path, include
 from django.urls import path, include
 from django.conf import settings
 from django.conf import settings

+ 12 - 9
archivebox/legacy/config.py

@@ -136,19 +136,19 @@ ROBOTS_TXT_FILENAME = 'robots.txt'
 FAVICON_FILENAME = 'favicon.ico'
 FAVICON_FILENAME = 'favicon.ico'
 CONFIG_FILENAME = 'ArchiveBox.conf'
 CONFIG_FILENAME = 'ArchiveBox.conf'
 
 
-CONFIG_HEADER = """
-# This is the default config file for new ArchiveBox projects.
-# Add your archive collection config here in INI format.
+CONFIG_HEADER = (
+"""# This is the config file for your ArchiveBox collection.
+#
+# You can add options here manually in INI format, or automatically by running:
+#    archivebox config --set KEY=VALUE
 # 
 # 
-# After updating your config, make sure to update your archive by running:
+# If you modify this file manually, make sure to update your archive after by running:
 #    archivebox init
 #    archivebox init
 #
 #
-# The example default configuration file can be found at:
-#    ArchiveBox/etc/Archivebox.conf.default
-#
-# See the list of all the possible options. documentation, and examples here:
+# A list of all possible config with documentation and examples can be found here:
 #    https://github.com/pirate/ArchiveBox/wiki/Configuration
 #    https://github.com/pirate/ArchiveBox/wiki/Configuration
-"""
+
+""")
 
 
 
 
 DERIVED_CONFIG_DEFAULTS: ConfigDefaultDict = {
 DERIVED_CONFIG_DEFAULTS: ConfigDefaultDict = {
@@ -294,6 +294,9 @@ def write_config_file(config: Dict[str, str], out_dir: str=None) -> ConfigDict:
         with open(config_path, 'w+') as f:
         with open(config_path, 'w+') as f:
             f.write(CONFIG_HEADER)
             f.write(CONFIG_HEADER)
 
 
+    if not config:
+        return {}
+
     config_file = ConfigParser()
     config_file = ConfigParser()
     config_file.optionxform = str
     config_file.optionxform = str
     config_file.read(config_path)
     config_file.read(config_path)

+ 5 - 0
archivebox/legacy/main.py

@@ -34,6 +34,7 @@ from .config import (
     SOURCES_DIR,
     SOURCES_DIR,
     ARCHIVE_DIR,
     ARCHIVE_DIR,
     LOGS_DIR,
     LOGS_DIR,
+    CONFIG_FILE,
     ARCHIVE_DIR_NAME,
     ARCHIVE_DIR_NAME,
     SOURCES_DIR_NAME,
     SOURCES_DIR_NAME,
     LOGS_DIR_NAME,
     LOGS_DIR_NAME,
@@ -46,6 +47,7 @@ from .config import (
     check_dependencies,
     check_dependencies,
     check_data_folder,
     check_data_folder,
     setup_django,
     setup_django,
+    write_config_file,
 )
 )
 from .logs import (
 from .logs import (
     log_archiving_started,
     log_archiving_started,
@@ -115,6 +117,9 @@ def init():
 
 
     os.makedirs(LOGS_DIR, exist_ok=True)
     os.makedirs(LOGS_DIR, exist_ok=True)
     print(f'    √ {LOGS_DIR}')
     print(f'    √ {LOGS_DIR}')
+
+    write_config_file({}, out_dir=OUTPUT_DIR)
+    print(f'    √ {CONFIG_FILE}')
     
     
     if os.path.exists(os.path.join(OUTPUT_DIR, SQL_INDEX_FILENAME)):
     if os.path.exists(os.path.join(OUTPUT_DIR, SQL_INDEX_FILENAME)):
         print('\n{green}[*] Verifying main SQL index and running migrations...{reset}'.format(**ANSI))
         print('\n{green}[*] Verifying main SQL index and running migrations...{reset}'.format(**ANSI))