Commits

Chris Mutel committed c405c5f

Allow specifying export folder in BW2Package

Comments (0)

Files changed (1)

bw2data/io/bw2package.py

         return data
 
     @classmethod
-    def export_ia_method(cls, name):
-        filepath = os.path.join(config.request_dir("export"),
+    def export_ia_method(cls, name, folder="export"):
+        filepath = os.path.join(config.request_dir(folder),
             ".".join(name) + ".bw2iapackage")
         with bz2.BZ2File(filepath, "w") as f:
             f.write(JsonWrapper.dumps([cls._prepare_method(name)]))
         return filepath
 
     @classmethod
-    def export_all_methods(cls):
-        filepath = os.path.join(config.request_dir("export"),
+    def export_all_methods(cls, folder="export"):
+        filepath = os.path.join(config.request_dir(folder),
             "methods.bw2iapackage")
         with bz2.BZ2File(filepath, "w") as f:
             f.write(JsonWrapper.dumps(
         return filepath
 
     @classmethod
-    def export_database(cls, name, include_dependencies):
+    def export_database(cls, name, include_dependencies=False, **kwargs):
         assert name in databases, "Can't find this database"
+
+        extra_string = kwargs.get("extra_string", "")
+        folder = kwargs.get("folder", "export")
+
         if include_dependencies:
             for dependency in databases[name]["depends"]:
                 assert dependency in databases, \
                     "Can't find dependent database %s" % dependency
             to_export = [name] + databases[name]["depends"]
-            filename = name + ".fat.bw2package"
+            filename = name + extra_string + ".fat.bw2package"
         else:
             to_export = [name]
-            filename = name + ".bw2package"
-        filepath = os.path.join(config.request_dir("export"), filename)
+            filename = name + extra_string + ".bw2package"
+        filepath = os.path.join(config.request_dir(folder), filename)
         with bz2.BZ2File(filepath, "w") as f:
             f.write(JsonWrapper.dumps({db_name: {
                 "metadata": databases[db_name],
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.