Skip to content

Commit

Permalink
the registered spliter can now be called using the cmd_def
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Blanca committed Dec 22, 2009
1 parent 1849b09 commit 526dc89
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
17 changes: 13 additions & 4 deletions psubprocess/prunner.py
Expand Up @@ -51,7 +51,7 @@
from psubprocess.streams import get_streams_from_cmd, STDOUT, STDERR, STDIN
from psubprocess.condor_runner import call
from psubprocess import condor_runner
from psubprocess.splitters import (create_file_splitter_with_re,
from psubprocess.splitters import (get_splitter,
create_non_splitter_splitter)
from psubprocess.utils import NamedTemporaryDir, copy_file_mode
from psubprocess.cmd_def_from_cmd import get_cmd_def_from_cmd
Expand Down Expand Up @@ -101,7 +101,14 @@ def __init__(self, cmd, cmd_def=None, runner=None, runner_conf=None,
if runner is None:
runner = StdPopen
#is the cmd_def set in the command?
cmd, cmd_def = get_cmd_def_from_cmd(cmd)
cmd, cmd_cmd_def = get_cmd_def_from_cmd(cmd)

if cmd_cmd_def:
cmd_def = cmd_cmd_def
elif cmd_def:
cmd_def = cmd_def
else:
cmd_def = []

if not cmd_def and stdin is not None:
raise ValueError('No cmd_def given but stdin present')
Expand Down Expand Up @@ -284,9 +291,11 @@ def to_be_split_first(stream1, stream2):
raise ValueError(msg)
else:
splitter = stream['splitter']
#the splitter can be a re, in that case with create the function
#if the splitter is a function we assume that it will know how to
#split the given file, otherwise should be a registered type of
#splitter or a regular expression
if '__call__' not in dir(splitter):
splitter = create_file_splitter_with_re(splitter)
splitter = get_splitter(splitter)
#we split the input files in the splits, every file will be in one
#of the given work_dirs
#the stream can have fname or fhands
Expand Down
8 changes: 8 additions & 0 deletions psubprocess/splitters.py
Expand Up @@ -169,6 +169,14 @@ def create_file_splitter_with_re(expression):
'''
return _create_file_splitter(kind='re', expression=expression)

def get_splitter(expression):
'''If the expression is a known splitter kind it returns it, otherwise it
creates a regular expression based splitter'''
if expression == 'fastq':
return fastq_splitter
else:
return create_file_splitter_with_re(expression)

def create_non_splitter_splitter(copy_files=False):
'''It creates an splitter function that will not split the given file.
Expand Down

0 comments on commit 526dc89

Please sign in to comment.