def infer(self, pattern=False):
<EOL>if pattern:<EOL><INDENT>if not self.__base_path:<EOL><INDENT>message = '<STR_LIT>'<EOL>raise exceptions.DataPackageException(message)<EOL><DEDENT>options = {'<STR_LIT>': True} if '<STR_LIT>' in pattern else {}<EOL>for path in glob.glob(os.path.join(self.__base_path, pattern), **options):<EOL><INDENT>self.add_resource({'<STR_LIT:path>': os.path.relpath(path, self.__base_path)})<EOL><DEDENT><DEDENT>for index, resource in enumerate(self.resources):<EOL><INDENT>descriptor = resource.infer()<EOL>self.__current_descriptor['<STR_LIT>'][index] = descriptor<EOL>self.__build()<EOL><DEDENT>if self.__next_descriptor['<STR_LIT>'] == config.DEFAULT_DATA_PACKAGE_PROFILE:<EOL><INDENT>if self.resources and all(map(lambda resource: resource.tabular, self.resources)):<EOL><INDENT>self.__current_descriptor['<STR_LIT>'] = '<STR_LIT>'<EOL>self.__build()<EOL><DEDENT><DEDENT>return self.__current_descriptor<EOL>
https://github.com/frictionlessdata/datapackage-py#package