:param fnames:
        list of source model files
    :param converter:
        a SourceConverter instance
    :param monitor:
        a :class:`openquake.performance.Monitor` instance
    :yields:
        SourceModel instances
545249
def read_source_models(fnames, converter, monitor):
    
    for fname in fnames:
        if fname.endswith(('.xml', '.nrml')):
            sm = to_python(fname, converter)
        elif fname.endswith('.hdf5'):
            sm = sourceconverter.to_python(fname, converter)
        else:
            raise ValueError('Unrecognized extension in %s' % fname)
        sm.fname = fname
        yield sm
1185048
def add_converter(cls, klass, conv, score=0):
        
        if isinstance(klass, str):
            klass = import_name(klass)
        item = klass, conv, score
        cls.converters.append(item)
        cls.converters.sort(key=lambda x: x[0])
        return cls
1269040
def _init_converters(types_map):
    """"""
    global _converters
    _converters = {}
    for i in _DEFAULT_CONVERTERS:
        const_val = types_map[i]
        _converters[const_val] = _DEFAULT_CONVERTERS[i]
3039
def watched_file_handler(name, logname, filename, mode='a', encoding=None,
                         delay=False):
    

    return wrap_log_handler(logging.handlers.WatchedFileHandler(
        filename, mode=mode, encoding=encoding, delay=delay))
1159414
def file_contigs(ref_file, config=None):
    
    ContigInfo = collections.namedtuple("ContigInfo", "name size")
    with open(fasta_idx(ref_file, config)) as in_handle:
        for line in (l for l in in_handle if l.strip()):
            name, size = line.split()[:2]
            yield ContigInfo(name, int(size))
955172
def detect_converters(pattern: str,
                      converter_dict: Dict[str, Callable],
                      default: Callable = str):
    
    converters = {}
    for matched in VARS_PT.finditer(pattern):
        matchdict = matched.groupdict()
        varname = matchdict['varname']
        converter = matchdict['converter']
        converters[varname] = converter_dict.get(converter, default)
    return converters
36684
def _generate_filenames(sources):
    
    for source in sources:
        if os.path.isdir(source):
            for path, dirlist, filelist in os.walk(source):
                for fname in filelist:
                    if GenericFilePath.is_compressed(fname):
                        if VERBOSE:
                            print("Skipping compressed file: {}".format(os.path.abspath(fname)))
                        continue
                    else:
                        yield os.path.join(path, fname)

        elif os.path.isfile(source):
            yield source

        elif source.isdigit():
            analysis_id = "AN{}".format(source.zfill(6))
            url = MWREST.format(analysis_id)
            yield url

        elif GenericFilePath.is_url(source):
            yield source

        else:
            raise TypeError("Unknown file source.")
1069277
def in_file(self, filename: str) -> Iterator[FunctionDesc]:
        
        yield from self.__filename_to_functions.get(filename, [])
73755
def _setup_converter_graph(self, converter_list, prune_converters):
        '''
        
        '''
        for converter in converter_list:
            if prune_converters:
                try:
                    converter.configure()
                except ConverterUnavailable as e:
                    log.warning('%s unavailable: %s' %
                                (converter.__class__.__name__, str(e)))
                    continue

            for in_ in converter.inputs:
                for out in converter.outputs:
                    self.dgraph.add_edge(in_, out, converter.cost)
                    self.converters[(in_, out)] = converter

            if hasattr(converter, 'direct_outputs'):
                self._setup_direct_converter(converter)
1216458
private static FileMonitor createFileMonitor(String [] args)
   throws Exception
   {
        String usage= " Usage: [-pollingInterval <timems>]? [-observer <class>]* [-monitor <dir>:<filter>:<ignoreCurrentContentBoolean>]*";

      if(args == null || args.length < 2 )
         throw new IllegalArgumentException(usage);
      
      FileMonitor fileMonitor =new FileMonitor();
      
      String [] arrayString = null;
      SubjectObserver<FileEvent> observer = null;
      for(int i=0; i < args.length;i++)
      {
         if("-monitor".equals(args[i]))
         {
            if(i+1 >= args.length)
            {
               throw new IllegalArgumentException("directory:filter specified -monitor argument "+usage);
            }
            
            arrayString = args[i+1].split(":");
            if(arrayString.length != 3)
               throw new IllegalArgumentException(args[i+1]+usage );
            
            fileMonitor.monitor(arrayString[0],arrayString[1],Boolean.valueOf(arrayString[2]).booleanValue());

            i = i+1;
         }
         else if("-pollingInterval".equals(args[i]))
         {
            if(i+1 >= args.length)
            {
               throw new IllegalArgumentException("no time specified -pollingInterval argument "+usage);
            }
            
            fileMonitor.setPollingInterval(Long.parseLong(args[i+1]));
            i = i+1;
         }
         else if("-observer".equals(args[i]))
         {
            if(i+1 >= args.length)
            {
               throw new IllegalArgumentException("no observer specific in -observer argument "+usage);
            }
               
            //fileMonitor.addObserver((Observer)Class.forName(args[i+1]).newInstance());
            observer = ClassPath.newInstance(args[i+1]);
            fileMonitor.add(observer);
            i = i+1;
         }
       }//end for
      return fileMonitor;
   }
98051
def output(self):
        
        if len(self.files) < 1:
            raise Exception('Converter#output: No files to convert')
        return self.template.render(self.files)
18345
def channel(self, name):
        
        enc_name = _converters[type(name)](name)
        if (enc_name, False) not in self._refs:
            ch = _Sender(self, enc_name,
                         is_pattern=False)
            self._refs[(enc_name, False)] = ch
            return ch
        return self._refs[(enc_name, False)]
187470
def monitor(name, callback):
    '''
     
    '''
    global _monitor 
    if not exists(name):
        raise ContainerNotExists("The container (%s) does not exist!" % name)
    if _monitor:
        if _monitor.is_monitored(name):
            raise Exception("You are already monitoring this container (%s)" % name)
    else:
        _monitor = _LXCMonitor()
        logging.info("Starting LXC Monitor")
        _monitor.start()
        def kill_handler(sg, fr):
            stop_monitor()
        signal.signal(signal.SIGTERM, kill_handler)
        signal.signal(signal.SIGINT, kill_handler)
    _monitor.add_monitor(name, callback)
603222
@SuppressWarnings("all")
  private void registerConvertersFromFileSystem(String converterClassResourceName, URL converterClassResourceLocation) {

    try {

      File convertersPackagePath = new File(converterClassResourceLocation.toURI()).getParentFile();

      Assert.isTrue(convertersPackagePath.isDirectory(),
          "Directory for Converters package [%s] does not exist", convertersPackagePath.getAbsolutePath());

      for (File classFile : convertersPackagePath.listFiles(new FileExtensionFilter(CLASS_FILE_EXTENSION))) {

        String converterClassName = CONVERTERS_PACKAGE.getName()
            .concat(StringUtils.DOT_SEPARATOR).concat(FileUtils.getName(classFile));

        register(converterClassName);
      }
    }
    catch (URISyntaxException cause) {
      throw newRuntimeException(cause, "Failed to create File reference to directory [%s] of Converters package",
          converterClassResourceName.substring(0, converterClassResourceName.lastIndexOf(File.separator) + 1));
    }
  }
917060
def generate_dumper(self, mapfile, names):
        
        return self.build_template(mapfile, names, self._dumpdata_template)
655707
public static <A, B, C, D> Converter<Example<A, B>, Example<C, D>> converter(
      Converter<A, C> inputConverter, Converter<B, D> outputConverter) {
    return new ExampleConverter<A, B, C, D>(inputConverter, outputConverter);
  }
321147
def reload_sources(self, names):
        

        try:
            self.like.logLike.loadSourceMaps(names, True, True)
            # loadSourceMaps doesn't overwrite the header so we need
            # to ignore EXPSCALE by setting check_header=False
            self._scale_srcmap(self._src_expscale, check_header=False,
                               names=names)
        except:
            for name in names:
                self.reload_source(name)