File dialect as one of model.DIALECT_* constants
431137
def dialect(self):
        
        if self._dialect is None:
            self._dialect = model.DIALECT_DEFAULT
            if self.header:
                source = self.header.sub_tag("SOUR")
                if source:
                    if source.value == "MYHERITAGE":
                        self._dialect = model.DIALECT_MYHERITAGE
                    elif source.value == "ALTREE":
                        self._dialect = model.DIALECT_ALTREE
                    elif source.value == "ANCESTRIS":
                        self._dialect = model.DIALECT_ANCESTRIS
        return self._dialect
1343730
def yaml?(file)
      line = open(file) { |f| line = f.gets }
      line.index "!ruby/object:Gem::Specification"
    end
375156
def constantize(str)
      str = str.to_s
      call_or_yield str do
        raise(NameError, "#{s.inspect} is not a valid constant name!") unless m = VALID_CONSTANT_NAME_REGEXP.match(str)
        Object.module_eval("::#{m[1]}", __FILE__, __LINE__)
      end
    end
1231911
def load_parameters(self, filename, ctx=mx.cpu()): # pylint: disable=arguments-differ
        
        self.lm_model.load_parameters(filename, ctx=ctx)
8054
def load_dialect_impl(self, dialect):  # type: (DefaultDialect) -> TypeEngine
        """"""
        if self.__use_json(dialect):
            return dialect.type_descriptor(self.__json_type)
        return dialect.type_descriptor(sqlalchemy.UnicodeText)
59099
def dialect_class(self, adapter):
        """"""
        if self.dialects.get(adapter):
            return self.dialects[adapter]
        try:
            class_prefix = getattr(
                __import__('db.' + adapter, globals(), locals(),
                           ['__class_prefix__']), '__class_prefix__')
            driver = self._import_class('db.' + adapter + '.dialect.' +
                                        class_prefix + 'Dialect')
        except ImportError:
            raise DBError("Must install adapter `%s` or doesn't support" %
                          (adapter))

        self.dialects[adapter] = driver
        return driver
235335
def makeHandler(self, dialect):
        """"""
        if dialect not in self.dialects:
            m = "The dialect specified, '{}', wasn't whitelisted in change_hook".format(dialect)
            log.msg(m)
            log.msg(
                "Note: if dialect is 'base' then it's possible your URL is malformed and we didn't regex it properly")
            raise ValueError(m)

        if dialect not in self._dialect_handlers:
            if dialect not in self._plugins:
                m = "The dialect specified, '{}', is not registered as a buildbot.webhook plugin".format(dialect)
                log.msg(m)
                raise ValueError(m)
            options = self.dialects[dialect]
            if isinstance(options, dict) and 'custom_class' in options:
                klass = options['custom_class']
            else:
                klass = self._plugins.get(dialect)
            self._dialect_handlers[dialect] = klass(self.master, self.dialects[dialect])

        return self._dialect_handlers[dialect]
974755
def validate_model_specification_file(file_path: str) -> str:
    """"""
    if not os.path.isfile(file_path):
        raise ConfigurationError('If you provide a model specification file, it must be a file. '
                                 f'You provided {file_path}')

    extension = file_path.split('.')[-1]
    if extension not in ['yaml', 'yml']:
        raise ConfigurationError(f'Model specification files must be in a yaml format. You provided {extension}')
    # Attempt to load
    yaml.full_load(file_path)
    return file_path
1288289
def set_dialect(dialect):
    '''
    '''
    global mavlink, current_dialect
    from .generator import mavparse
    if 'MAVLINK20' in os.environ:
        wire_protocol = mavparse.PROTOCOL_2_0
        modname = "pymavlink.dialects.v20." + dialect
    elif mavlink is None or mavlink.WIRE_PROTOCOL_VERSION == "1.0" or not 'MAVLINK09' in os.environ:
        wire_protocol = mavparse.PROTOCOL_1_0
        modname = "pymavlink.dialects.v10." + dialect
    else:
        wire_protocol = mavparse.PROTOCOL_0_9
        modname = "pymavlink.dialects.v09." + dialect

    try:
        mod = __import__(modname)
    except Exception:
        # auto-generate the dialect module
        from .generator.mavgen import mavgen_python_dialect
        mavgen_python_dialect(dialect, wire_protocol)
        mod = __import__(modname)
    components = modname.split('.')
    for comp in components[1:]:
        mod = getattr(mod, comp)
    current_dialect = dialect
    mavlink = mod
779248
def get_dialect_name(mixed: Union[SQLCompiler, Engine, Dialect]) -> str:
    
    dialect = get_dialect(mixed)
    # noinspection PyUnresolvedReferences
    return dialect.name
394685
def model_export(model, file_name, repo=None):
    
    with codecs.open(file_name, 'w', encoding="utf-8") as f:
        model_export_to_file(f, model, repo)
1043700
def _dialect(self, filepath):
        
        with open(filepath, self.read_mode) as csvfile:
            sample = csvfile.read(1024)
            dialect = csv.Sniffer().sniff(sample)
            if self.has_header == None:
                # detect header if header not specified
                self.has_header = csv.Sniffer().has_header(sample)
            csvfile.seek(0)
        return dialect
20088
def inject_params(model_name: str) -> ListenerParams:
    """"""
    params_file = model_name + '.params'
    try:
        with open(params_file) as f:
            pr.__dict__.update(compatibility_params, **json.load(f))
    except (OSError, ValueError, TypeError):
        if isfile(model_name):
            print('Warning: Failed to load parameters from ' + params_file)
    return pr
1052045
def from_file(cls, path, encoding, dialect, fields, converters, field_index):
        """"""

        return cls(open(path, 'r', encoding=encoding), dialect, fields, converters, field_index)
742756
def load_replacement_patterns(self):
        """"""
        filename = self.dictionary + '.py'
        models = self.language + '_models_cltk'
        rel_path = os.path.join('~/cltk_data',
                                self.language,
                                'model',
                                models,
                                'semantics',
                                filename)
        path = os.path.expanduser(rel_path)
        logger.info('Loading lemmata or synonyms. This may take a minute.')
        loader = importlib.machinery.SourceFileLoader(filename, path)
        module = types.ModuleType(loader.name)
        loader.exec_module(module)
        return module.DICTIONARY
871966
def save(self, filename):
        
        import dill

        tmpmodelparams = self.modelparams.copy()
        # fv_extern_src = None
        fv_extern_name = None
        # try:
        #     fv_extern_src = dill.source.getsource(tmpmodelparams['fv_extern'])
        #     tmpmodelparams.pop('fv_extern')
        # except:
        #     pass

        # fv_extern_name = dill.source.getname(tmpmodelparams['fv_extern'])
        if "fv_extern" in tmpmodelparams:
            tmpmodelparams.pop("fv_extern")

        sv = {
            "modelparams": tmpmodelparams,
            "mdl": self.mdl,
            # 'fv_extern_src': fv_extern_src,
            # 'fv_extern_src_name': fv_extern_src_name,
            # 'fv_extern_name': fv_extern_src_name,
            #
        }
        sss = dill.dumps(self.modelparams)
        logger.debug("pickled " + str(sss))

        dill.dump(sv, open(filename, "wb"))
446034
def _update_settings(self, dialect):
        """"""

        # the first parameter is the dialect itself --> ignore
        for parameter in self.csv_params[2:]:
            pname, ptype, plabel, phelp = parameter

            widget = self._widget_from_p(pname, ptype)

            if ptype is types.TupleType:
                ptype = types.ObjectType

            digest = Digest(acceptable_types=[ptype])

            if pname == 'self.has_header':
                if self.has_header is not None:
                    widget.SetValue(digest(self.has_header))
            else:
                value = getattr(dialect, pname)
                widget.SetValue(digest(value))