summaryrefslogtreecommitdiff
path: root/__init__.py
diff options
context:
space:
mode:
authorIan Clatworthy <ian.clatworthy@internode.on.net>2008-02-16 10:05:28 +1000
committerIan Clatworthy <ian.clatworthy@internode.on.net>2008-02-16 10:05:28 +1000
commit6220edd76ca399a63678068fa12d391ff8840a29 (patch)
tree2731e2716a39bdfb2010e3686f7d25427dc2ce52 /__init__.py
parent288ecf21698ac81534c08fa81b7318c3339179fd (diff)
downloadbzr-fastimport-6220edd76ca399a63678068fa12d391ff8840a29.tar.gz
custom parameters for processors
Diffstat (limited to '__init__.py')
-rw-r--r--__init__.py33
1 files changed, 26 insertions, 7 deletions
diff --git a/__init__.py b/__init__.py
index 6ca4cc7..094fa29 100644
--- a/__init__.py
+++ b/__init__.py
@@ -18,7 +18,7 @@
from bzrlib.commands import Command, register_command
-from bzrlib.option import RegistryOption
+from bzrlib.option import RegistryOption, ListOption
def test_suite():
@@ -26,6 +26,20 @@ def test_suite():
return tests.test_suite()
+def _defines_to_dict(defines):
+ """Convert a list of definition strings to a dictionary."""
+ if defines is None:
+ return None
+ result = {}
+ for define in defines:
+ kv = define.split('=', 1)
+ if len(kv) == 1:
+ result[define.strip()] = 1
+ else:
+ result[kv[0].strip()] = kv[1].strip()
+ return result
+
+
class cmd_fast_import(Command):
"""Backend for fast Bazaar data importers.
@@ -62,24 +76,29 @@ class cmd_fast_import(Command):
takes_options = ['verbose',
RegistryOption.from_kwargs('method',
'The way to process the data.',
- title='Processing Method', value_switches=True, enum_switch=False,
- generic="Import the data into any format (default)",
- info="Display information only - don't import it",
+ title='Processing Method',
+ value_switches=True, enum_switch=False,
+ safe="Import the data into any format (default).",
+ info="Display information only - don't import it.",
+ ),
+ ListOption('params', short_name='P', type=str,
+ help="Define processing specific parameters.",
),
]
aliases = ['fastimport']
- def run(self, verbose=False, method='generic'):
+ def run(self, verbose=False, method='safe', params=None):
import sys
from bzrlib import bzrdir
import parser
+ params = _defines_to_dict(params)
if method == 'info':
from bzrlib.plugins.fastimport.processors import info_processor
- proc = info_processor.InfoProcessor()
+ proc = info_processor.InfoProcessor(params=params)
else:
from bzrlib.plugins.fastimport.processors import generic_processor
control, relpath = bzrdir.BzrDir.open_containing('.')
- proc = generic_processor.GenericProcessor(control)
+ proc = generic_processor.GenericProcessor(control, params=params)
# Note: might need to pass the parser to the processor so that the
# processor can be it's error reporting with source context