pyron's Introduction
"""Routines for examining the README file of a Python project.""" import codecs import htmlentitydefs import re import os from pyron.exceptions import PyronError join = os.path.join README_NAMES = ('README', 'README.txt') README_MATCH = re.compile(ur'\n+(``[A-Za-z_.]+`` *-- *)?(.*)\n[=-]*\n').match DEFMAP = dict( (unichr(k), v) for (k,v) in htmlentitydefs.codepoint2name.items() ) 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 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) if match: package_name = match.group(1) description = match.group(2) body = readme[match.end():] return package_name, description, body raise format_error
pyron's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.