Skip to content

[WIP] Move all PEPs into subdirectory #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 9 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
pep-0000.txt
pep-????.html
__pycache__
*.pyc
*.pyo
*~
*env
.vscode
pep-0000.txt
pep-????.html
__pycache__
*.pyc
*.pyo
*~
*env
.vscode
*.swp
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
# Not really important, but convenient.

PEP2HTML=pep2html.py
PEP2RSS=pep2rss.py
GENPEPINDEX=genpepindex.py

PEPDIR=peps
OUTPUTDIR=output

PYTHON=python

Expand All @@ -12,24 +17,23 @@ PYTHON=python
.txt.html:
@$(PYTHON) $(PEP2HTML) $<

TARGETS=$(patsubst %.txt,%.html,$(wildcard pep-????.txt)) pep-0000.html
TARGETS=$(patsubst %.txt,%.html,$(wildcard $(PEPDIR)/pep-????.txt)) $(OUTPUTDIR)/pep-0000.html

all: pep-0000.txt $(TARGETS)

$(TARGETS): pep2html.py
$(TARGETS): $(PEP2HTML)

pep-0000.txt: $(wildcard pep-????.txt) $(wildcard pep0/*.py)
$(PYTHON) genpepindex.py .
pep-0000.txt: $(wildcard $(PEPDIR)/pep-????.txt) $(wildcard $(PEPDIR)/pep0/*.py)
$(PYTHON) $(GENPEPINDEX) $(PEPDIR)

rss:
$(PYTHON) pep2rss.py .
$(PYTHON) $(PEP2RSS) $(PEPDIR)

install:
echo "Installing is not necessary anymore. It will be done in post-commit."

clean:
-rm pep-0000.txt
-rm *.html
-rm -r $(OUTPUTDIR)

update:
git pull https://github.com/python/peps.git
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Python Enhancement Proposals
The PEPs in this repo are published automatically on the web at
http://www.python.org/dev/peps/. To learn more about the purpose of
PEPs and how to go about writing a PEP, please start reading at PEP 1
(``pep-0001.txt`` in this repo). Note that PEP 0, the index PEP, is
(``peps/pep-0001.txt`` in this repo). Note that PEP 0, the index PEP, is
now automatically generated, and not committed to the repo.


Expand All @@ -28,7 +28,7 @@ Generating HTML

Do not commit changes with bad formatting. To check the formatting of
a PEP, use the Makefile. In particular, to generate HTML for PEP 999,
your source code should be in ``pep-0999.txt`` and the HTML will be
generated to ``pep-0999.html`` by the command ``make pep-0999.html``.
your source code should be in ``peps/pep-0999.txt`` and the HTML will be
generated to ``output/pep-0999.html`` by the command ``make peps/pep-0999.html``.
The default Make target generates HTML for all PEPs. If you don't have
Make, use the ``pep2html.py`` script.
16 changes: 12 additions & 4 deletions genpepindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@

from operator import attrgetter

from pep0.output import write_pep0
from pep0.pep import PEP, PEPError
from peps.pep0.output import write_pep0
from peps.pep0.pep import PEP, PEPError

PEPDIR = "peps"
OUTPUTDIR = "output"


def main(argv):
if not argv[1:]:
path = '.'
path = PEPDIR
else:
path = argv[1]

Expand Down Expand Up @@ -61,7 +64,12 @@ def main(argv):
else:
raise ValueError("argument must be a directory or file path")

with codecs.open('pep-0000.txt', 'w', encoding='UTF-8') as pep0_file:
try:
os.makedirs(OUTPUTDIR)
except OSError: # output directory alrady exists. Everything's fine...
pass

with codecs.open(os.path.join(OUTPUTDIR, 'pep-0000.txt'), 'w', encoding='UTF-8') as pep0_file:
write_pep0(peps, pep0_file)

if __name__ == "__main__":
Expand Down
13 changes: 10 additions & 3 deletions pep2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
PROGRAM = sys.argv[0]
RFCURL = 'http://www.faqs.org/rfcs/rfc%d.html'
PEPURL = 'pep-%04d.html'
PEPDIR = 'peps'
OUTPUTDIR = 'output'
PEPCVSURL = ('https://hg.python.org/peps/file/tip/pep-%04d.txt')
PEPDIRRUL = 'http://www.python.org/peps/'

Expand Down Expand Up @@ -371,7 +373,7 @@ def find_pep(pep_str):
if os.path.exists(pep_str):
return pep_str
num = int(pep_str)
return "pep-%04d.txt" % num
return os.path.join(PEPDIR, "pep-%04d.txt" % num)

def make_html(inpath, verbose=0):
input_lines = get_input_lines(inpath)
Expand All @@ -390,7 +392,7 @@ def make_html(inpath, verbose=0):
elif PEP_TYPE_DISPATCH[pep_type] == None:
pep_type_error(inpath, pep_type)
return None
outpath = os.path.splitext(inpath)[0] + ".html"
outpath = os.path.join(OUTPUTDIR, os.path.splitext(os.path.basename(inpath))[0] + ".html")
if verbose:
print(inpath, "(%s)" % pep_type, "->", outpath)
sys.stdout.flush()
Expand Down Expand Up @@ -519,6 +521,11 @@ def main(argv=None):
elif opt in ('-b', '--browse'):
browse = 1

try:
os.makedirs(OUTPUTDIR)
except OSError: # output directory alrady exists. Everything's fine...
pass

if args:
peptxt = []
html = []
Expand All @@ -534,7 +541,7 @@ def main(argv=None):
# do them all
peptxt = []
html = []
files = glob.glob("pep-*.txt")
files = glob.glob(os.path.join(PEPDIR, "pep-*.txt"))
files.sort()
for file in files:
peptxt.append(file)
Expand Down
3 changes: 2 additions & 1 deletion pep2pyramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
PEPCVSURL = 'http://hg.python.org/peps/file/tip/pep-%04d.txt'
PEPDIRURL = '/dev/peps/'
PEPURL = PEPDIRURL + 'pep-%04d'
PEPDIR = 'peps'
PEPANCHOR = '<a href="' + PEPURL + '">%i</a>'


Expand Down Expand Up @@ -499,7 +500,7 @@ def build_peps(args=None):
filenames = pep_filename_generator(args)
else:
# do them all
filenames = glob.glob("pep-*.txt")
filenames = glob.glob(os.path.join(PEPDIR, "pep-*.txt"))
filenames.sort()
for filename in filenames:
try:
Expand Down
2 changes: 1 addition & 1 deletion pep2rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def firstline_startingwith(full_path, text):
return None

# get list of peps with creation time (from "Created:" string in pep .txt)
peps = glob.glob('pep-*.txt')
peps = glob.glob('peps/pep-*.txt')
def pep_creation_dt(full_path):
created_str = firstline_startingwith(full_path, 'Created:')
# bleh, I was hoping to avoid re but some PEPs editorialize
Expand Down
Empty file added peps/__init__.py
Empty file.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading