Example #1
0
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]
Example #2
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 <*****@*****.**>"')
Example #3
0
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)
Example #4
0
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
Example #5
0
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))
Example #6
0
 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)
Example #7
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))
Example #8
0
    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)