Check whether a corpus is available for import.
        :type corpus_name: str
        :param corpus_name: Name of available corpus.
        :rtype : str
189181
def _get_corpus_properties(self, corpus_name):
        
        try:
            # corpora = LANGUAGE_CORPORA[self.language]
            corpora = self.all_corpora
        except NameError as name_error:
            msg = 'Corpus not available for language ' \
                  '"%s": %s' % (self.language, name_error)
            logger.error(msg)
            raise CorpusImportError(msg)
        for corpus_properties in corpora:
            if corpus_properties['name'] == corpus_name:
                return corpus_properties
        msg = 'Corpus "%s" not available for the ' \
              '"%s" language.' % (corpus_name, self.language)
        logger.error(msg)
        raise CorpusImportError(msg)
320602
def available(self, request, *args, **kwargs):
        
        packs = []
        for pack_name in get_available_pack_names():
            packs.append(pack_name)
        return Response(packs)
1234039
def field_name_exist(self, field_name):
        

        fields = self.class_item.get_fields()
        for f in fields:
            if f.name == field_name:
                return True
        return False
1360933
def available(self, context):
	
		
		
		try:
			if self.__available is None:
				status_code, msg = self.__endpoint.get("")
				self.__available = status_code == 200
		except:
			self.__available = False
			
		return self.__available
156984
def getLabelByName(self, name):
        
        name = name.lower()
        if name in self.stimLabels:
            return self.stimLabels[name]
        else:
            return None
1037270
def _try_import(module_name):
  """"""
  try:
    mod = importlib.import_module(module_name)
    return mod
  except ImportError:
    err_msg = ("Tried importing %s but failed. See setup.py extras_require. "
               "The dataset you are trying to use may have additional "
               "dependencies.")
    utils.reraise(err_msg)
1233397
def _check_distributed_corpora_file(self):
        
        if self.testing:
            distributed_corpora_fp = os.path.expanduser('~/cltk_data/test_distributed_corpora.yaml')
        else:
            distributed_corpora_fp = os.path.expanduser('~/cltk_data/distributed_corpora.yaml')

        try:
            with open(distributed_corpora_fp) as file_open:
                corpora_dict = yaml.safe_load(file_open)
        except FileNotFoundError:
            logger.info('`~/cltk_data/distributed_corpora.yaml` file not found.')
            return []
        except yaml.parser.ParserError as parse_err:
            logger.debug('Yaml parsing error: %s' % parse_err)
            return []

        user_defined_corpora = []
        for corpus_name in corpora_dict:
            about = corpora_dict[corpus_name]

            if about['language'].lower() == self.language:
                user_defined_corpus = dict()
                # user_defined_corpus['git_remote'] = about['git_remote']
                user_defined_corpus['origin'] = about['origin']
                user_defined_corpus['type'] = about['type']
                user_defined_corpus['name'] = corpus_name
                user_defined_corpora.append(user_defined_corpus)

        return user_defined_corpora
1123306
def has_module (name, without_error=True):
    
    try:
        importlib.import_module(name)
        return True
    except ImportError:
        return False
    except Exception:
        # some modules raise errors when intitializing
        return not without_error
648229
def get_callable_name(c):
    
    if hasattr(c, 'name'):
        return six.text_type(c.name)
    elif hasattr(c, '__name__'):
        return six.text_type(c.__name__) + u'()'
    else:
        return six.text_type(c)
861691
def available(self, context):
	
		
		
		try:
			if self.__available is None:
				encoded_name = urllib.parse.quote_plus(self.__name)
				status_code, msg = self.__endpoint.get(
					"/resources/custom-resource/{}".format(encoded_name)
				)
				self.__available = status_code == 200
		except:
			self.__available = False
			
		return self.__available
1137388
def validate(self, corpus):
        
        invalid_utterances = {}

        for utterance in corpus.utterances.values():
            if self.label_list_idx in utterance.label_lists.keys():
                ll = utterance.label_lists[self.label_list_idx]

                if len(ll) < self.min_number_of_labels:
                    invalid_utterances[utterance.idx] = 'Only {} labels'.format(len(ll))
            else:
                invalid_utterances[utterance.idx] = 'No label-list {}'.format(self.label_list_idx)

        passed = len(invalid_utterances) <= 0
        info = {
            'Min. number of labels': str(self.min_number_of_labels),
            'Label-List ID': self.label_list_idx
        }

        return base.InvalidUtterancesResult(passed, invalid_utterances, name=self.name(), info=info)
411677
def find_imports_and_track_names(filename, warn_about_duplicates=False,
                                 verbose=False):
    
    with open(filename) as f:
        root = ast.parse(f.read(), filename)
    visitor = ImportFinderAndNameTracker(filename)
    visitor.warn_about_duplicates = warn_about_duplicates
    visitor.verbose = verbose
    visitor.visit(root)
    visitor.leaveAllScopes()
    return visitor.imports, visitor.unused_names
635973
def available(name):
    '''
    
    '''
    path = '/etc/rc.d/{0}'.format(name)
    return os.path.isfile(path) and os.access(path, os.X_OK)
752496
def is_text_extractor_available(extension: str) -> bool:
    
    if extension is not None:
        extension = extension.lower()
    info = ext_map.get(extension)
    if info is None:
        return False
    availability = info[AVAILABILITY]
    if type(availability) == bool:
        return availability
    elif callable(availability):
        return availability()
    else:
        raise ValueError(
            "Bad information object for extension: {}".format(extension))
1296361
def import_class(self, import_name):
        
        module_name, class_name = import_name.rsplit(".", 1)
        mod = import_module(module_name)
        check_class = getattr(mod, class_name)
        self.mapping[check_class.name] = check_class
        logger.info("successfully loaded class %s", check_class)
        return check_class
348483
def _gst_available():
    
    try:
        import gi
    except ImportError:
        return False

    try:
        gi.require_version('Gst', '1.0')
    except (ValueError, AttributeError):
        return False

    try:
        from gi.repository import Gst  # noqa
    except ImportError:
        return False

    return True
1200463
def available(self, context):
	
		
		
		if self.__available is None:
			avail = False
			name = context.resolve(self.__name)
			for box in self.__box_list():
				if box["name"] == name and box["version"] == "0":
					avail = True
					break
			self.__available = avail
		return self.__available