def find_readme(directory): """Find under which name a project keeps its README file.""" candidates = [join(directory, name) for name in README_NAMES] candidates = filter(os.path.isfile, candidates) if not candidates: raise PyronError('your project must include either %s' % ' or '.join(README_NAMES)) if len(candidates) > 1: raise PyronError('your project cannot supply both %s' % ' and '.join(candidates)) return candidates[0]
def parse_author(self): field = self.config.get('package', 'author') self.author, self.author_email = email.utils.parseaddr(field) if not self.author: raise PyronError( 'the "author" defined in your "pyron.ini" must include both' ' a name and an email address, like "Ed <*****@*****.**>"')
def add(dist): """Add a Pyron project to our installation.""" project_paths = pth_load() if dist.location in project_paths: raise PyronError('already installed: ' + dist.location) project_paths.append(dist.location) add_scripts(dist) pth_save(project_paths)
def read_pyron_ini(path): """Read a project's ``pyron.ini``, returning a ConfigParser.""" try: f = open(path) except IOError: raise PyronError('cannot open file: %s' % (path, )) config = RawConfigParser() try: config.readfp(f) except IOError: raise PyronError('cannot read file: %s' % (path, )) except MissingSectionHeaderError: raise PyronError('%s has no section named [package]' % (path, )) finally: f.close() return config
def parse_project_init(init_path): """Parse a package-wide __init__.py module for information.""" try: f = open(init_path) except IOError, e: raise PyronError('cannot open %s: %s' % (init_path, e.strerror))
def format_error(): return PyronError( 'the beginning of your %s must look like (the package name can' ' omitted):\n\n``package`` -- brief description\n' '================================\n\n' % path)
def inspect_readme(path): """Look in a README file for a package name and description.""" try: f = codecs.open(path, 'U', 'ascii') except IOError, e: raise PyronError('cannot open %s: %s' % (path, e.strerror))
if len(candidates) > 1: raise PyronError('your project cannot supply both %s' % ' and '.join(candidates)) return candidates[0] def inspect_readme(path): """Look in a README file for a package name and description.""" try: f = codecs.open(path, 'U', 'ascii') except IOError, e: raise PyronError('cannot open %s: %s' % (path, e.strerror)) try: readme = f.read() except IOError, e: raise PyronError('cannot read %s: %s' % (path, e.strerror)) except UnicodeDecodeError: raise PyronError( 'because of the limitations of setuptools and the Python' ' Package Index, your %s file must contain Restructured Text' ' consisting only of ASCII characters' % path) finally: f.close() def format_error(): return PyronError( 'the beginning of your %s must look like (the package name can' ' omitted):\n\n``package`` -- brief description\n' '================================\n\n' % path) match = README_MATCH(readme)