Import generators

        For details see
        :func:`edisgo.data.import_data.import_generators`
179178
def import_generators(self, generator_scenario=None):
        
        if generator_scenario:
            self.network.generator_scenario = generator_scenario
        data_source = 'oedb'
        import_generators(network=self.network, data_source=data_source)
1002404
def model_import(self):
        
        # non-JIT models
        for file, pair in non_jits.items():
            for cls, name in pair.items():
                themodel = importlib.import_module('andes.models.' + file)
                theclass = getattr(themodel, cls)
                self.__dict__[name] = theclass(self, name)

                group = self.__dict__[name]._group
                self.group_add(group)
                self.__dict__[group].register_model(name)

                self.devman.register_device(name)

        # import JIT models
        for file, pair in jits.items():
            for cls, name in pair.items():
                self.__dict__[name] = JIT(self, file, cls, name)
1348246
def generators():
    
    from populous import generators

    base = generators.Generator

    for name in dir(generators):
        generator = getattr(generators, name)

        if isinstance(generator, type) and issubclass(generator, base):
            name = generator.__name__
            doc = (generator.__doc__ or '').strip()

            if doc:
                click.echo("{} - {}".format(name, doc))
            else:
                click.echo(name)
623432
def disc_modules(module_name, ignore_import_errors=False):
    
    if not ignore_import_errors:
        module = import_module(module_name)
    else:
        try:
            module = import_module(module_name)
        except BaseException:
            traceback.print_exc()
            return

    yield module

    if getattr(module, '__path__', None):
        for _, name, _ in pkgutil.iter_modules(module.__path__, module_name + '.'):
            for item in disc_modules(name, ignore_import_errors=ignore_import_errors):
                yield item
209898
def generator(self,gen,*args,**kwargs):
        
        with self(*args,**kwargs):
            for i in gen:
                yield i
360288
def get_imports(project, pydefined):
    """"""
    pymodule = pydefined.get_module()
    module = module_imports.ModuleImports(project, pymodule)
    if pymodule == pydefined:
        return [stmt.import_info for stmt in module.imports]
    return module.get_used_imports(pydefined)
1072336
def get_generator(self, field):
        '''
        
        '''
        if isinstance(field, fields.AutoField):
            return None
        if self.is_inheritance_parent(field):
            return None
        if (
            field.default is not fields.NOT_PROVIDED and
            not self.overwrite_defaults and
            field.name not in self.field_values):
                return None
        kwargs = {}

        if field.name in self.field_values:
            value = self.field_values[field.name]
            if isinstance(value, generators.Generator):
                return value
            elif isinstance(value, AutoFixture):
                return generators.InstanceGenerator(autofixture=value)
            elif callable(value):
                return generators.CallableGenerator(value=value)
            return generators.StaticGenerator(value=value)

        if field.null:
            kwargs['empty_p'] = self.none_p
        if field.choices:
            return generators.ChoicesGenerator(choices=field.choices, **kwargs)
        if isinstance(field, related.ForeignKey):
            # if generate_fk is set, follow_fk is ignored.
            is_self_fk = (get_remote_field_to(field)().__class__ == self.model)
            if field.name in self.generate_fk and not is_self_fk:
                return generators.InstanceGenerator(
                    autofixture.get(
                        get_remote_field_to(field),
                        follow_fk=self.follow_fk.get_deep_links(field.name),
                        generate_fk=self.generate_fk.get_deep_links(field.name)),
                    limit_choices_to=get_remote_field(field).limit_choices_to)
            if field.name in self.follow_fk:
                selected = generators.InstanceSelector(
                    get_remote_field_to(field),
                    limit_choices_to=get_remote_field(field).limit_choices_to)
                if selected.get_value() is not None:
                    return selected
            if field.blank or field.null:
                return generators.NoneGenerator()
            if is_self_fk and not field.null:
                raise CreateInstanceError(
                    u'Cannot resolve self referencing field "%s" to "%s" without null=True' % (
                        field.name,
                        '%s.%s' % (
                            get_remote_field_to(field)._meta.app_label,
                            get_remote_field_to(field)._meta.object_name,
                        )
                ))
            raise CreateInstanceError(
                u'Cannot resolve ForeignKey "%s" to "%s". Provide either '
                u'"follow_fk" or "generate_fk" parameters.' % (
                    field.name,
                    '%s.%s' % (
                        get_remote_field_to(field)._meta.app_label,
                        get_remote_field_to(field)._meta.object_name,
                    )
            ))
        if isinstance(field, related.ManyToManyField):
            if field.name in self.generate_m2m:
                min_count, max_count = self.generate_m2m[field.name]
                return generators.MultipleInstanceGenerator(
                    autofixture.get(get_remote_field_to(field)),
                    limit_choices_to=get_remote_field(field).limit_choices_to,
                    min_count=min_count,
                    max_count=max_count,
                    **kwargs)
            if field.name in self.follow_m2m:
                min_count, max_count = self.follow_m2m[field.name]
                return generators.InstanceSelector(
                    get_remote_field_to(field),
                    limit_choices_to=get_remote_field(field).limit_choices_to,
                    min_count=min_count,
                    max_count=max_count,
                    **kwargs)
            if field.blank or field.null:
                return generators.StaticGenerator([])
            raise CreateInstanceError(
                u'Cannot assign instances of "%s" to ManyToManyField "%s". '
                u'Provide either "follow_m2m" or "generate_m2m" argument.' % (
                    '%s.%s' % (
                        get_remote_field_to(field)._meta.app_label,
                        get_remote_field_to(field)._meta.object_name,
                    ),
                    field.name,
            ))
        if isinstance(field, fields.FilePathField):
            return generators.FilePathGenerator(
                path=field.path, match=field.match, recursive=field.recursive,
                max_length=field.max_length, **kwargs)
        if isinstance(field, fields.CharField):
            if isinstance(field, fields.SlugField):
                generator = generators.SlugGenerator
            elif isinstance(field, fields.EmailField):
                return generators.EmailGenerator(
                    max_length=min(field.max_length, 30))
            elif isinstance(field, fields.URLField):
                return generators.URLGenerator(
                    max_length=min(field.max_length, 25))
            elif field.max_length > 15:
                return generators.LoremSentenceGenerator(
                    common=False,
                    max_length=field.max_length)
            else:
                generator = generators.StringGenerator
            return generator(max_length=field.max_length)
        if isinstance(field, fields.DecimalField):
            return generators.DecimalGenerator(
                decimal_places=field.decimal_places,
                max_digits=field.max_digits)
        if hasattr(fields, 'BigIntegerField'):
            if isinstance(field, fields.BigIntegerField):
                return generators.IntegerGenerator(
                    min_value=-field.MAX_BIGINT - 1,
                    max_value=field.MAX_BIGINT,
                    **kwargs)
        if isinstance(field, ImageField):
            return generators.ImageGenerator(storage=field.storage, **kwargs)
        for field_class, generator in self.field_to_generator.items():
            if isinstance(field, field_class):
                return generator(**kwargs)
        return None
1234052
def import_config(config_path):
    
    if not os.path.isfile(config_path):
        raise ConfigBuilderError(
                'Could not find config file: ' + config_path)
    loader = importlib.machinery.SourceFileLoader(config_path, config_path)
    module = loader.load_module()

    if not hasattr(module, 'config') or not isinstance(module.config, Config):
        raise ConfigBuilderError(
            'Could not load config file "{}": config files must contain '
            'a variable called "config" that is '
            'assigned to a Config object.'.format(config_path))
    return module.config
764477
def import(source_adapter)
      Adapters::Sync::Synchronizer.new(self, source_adapter, raise: true).call
    end
240983
def find_field_generators(obj):
    

    cls_dict = obj.__class__.__dict__
    obj_dict = obj.__dict__
    #debug_print_dict(cls_dict, 'cls_dict')
    #debug_print_dict(obj_dict, 'obj_dict')

    field_gens = {}
    add_field_generators(field_gens, cls_dict)
    add_field_generators(field_gens, obj_dict)

    return field_gens
796679
def __recursive_import(module_name):
    
    names = module_name.split(".")
    path = None
    module = None
    while len(names) > 0:
        if module:
            path = module.__path__
        name = names.pop(0)
        (module_file, pathname, description) = imp.find_module(name, path)
        module = imp.load_module(name, module_file, pathname, description)
    return module
104263
def all_generators(self):
        
        for arg_gen in self.arg_gens:
            yield arg_gen

        for kwarg_gen in self.kwarg_gens.values():
            yield kwarg_gen
243464
def import_keys(keydata)
      err = GPGME::gpgme_op_import(self, keydata)
      exc = GPGME::error_to_exception(err)
      raise exc if exc
    end
105005
function importGenerator( array $current_import ) : \Generator {
		yield 10 => __( 'Opening EPUB file', 'pressbooks' );
		$this->setCurrentZip( $current_import['file'] );

		$xml = $this->getOpf();
		$match_ids = array_flip( array_keys( $current_import['chapters'] ) );
		$chapter_parent = $this->getChapterParent();

		yield 30 => __( 'Reading metadata', 'pressbooks' );
		$this->parseMetadata( $xml );

		yield from $this->parseManifestGenerator( $xml, $match_ids, $chapter_parent, $current_import );

		// Done
		yield 95 => __( 'Deleting temporary files', 'pressbooks' );
		if ( ! $this->revokeCurrentImport() ) {
			throw new \Exception();
		}
	}
229223
def extra_configuration_collection(self, configuration):
        """"""
        configuration["__imported__"] = {}
        configuration["__registered__"] = {}
        configuration["__active_modules__"] = {}

        def make_converter(name, spec):
            def converter(p, v):
                log.info("Converting %s", p)
                meta = Meta(p.configuration, [(name, "")])
                configuration.converters.started(p)
                return spec.normalise(meta, v)
            return converter
        configuration.install_converters(DashMatConverters(), make_converter)

        if "modules" in configuration:
            for module_name, module_options in list(configuration["modules"].items()):
                if "import_path" in module_options:
                    module = module_import_spec(Module).normalise(Meta(configuration, []).at("modules").at(module_name), module_options["import_path"])
                    import_path = "{0}:{1}".format(module.module_path, module.__name__)
                    self.activate_module(module_name, import_path, module, configuration)
                    configuration[["modules", module_name, "import_path"]] = module
313415
def _get_generator_plugins(cls):
        

        if not hasattr(cls, 'suite_generators'):
            gens = working_set.iter_entry_points('compliance_checker.generators')
            cls.suite_generators = [x.resolve() for x in gens]

        return cls.suite_generators
193651
def get_imported_modules(self, module):
    """"""
    for name, member in inspect.getmembers(module):
      if inspect.ismodule(member):
        yield name, member