Skip to content

Commit e1fe95c

Browse files
committed
Move all PEPs into subdirectory. Closes #10
This change moves all PEPs into the `peps/` subdirectory. The HTML files generated by `pep2html.py` will be located in `output/`. The `make` to convert a single PEP to HTML change slightly **if** you specify the path. It's still the when specifying the id. From: `make pep-0020.txt` To: `make peps/pep-0020.txt` ... just use tab completion ;)
1 parent 92b5b19 commit e1fe95c

File tree

442 files changed

+42
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

442 files changed

+42
-26
lines changed

.gitignore

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
pep-0000.txt
2-
pep-????.html
3-
__pycache__
4-
*.pyc
5-
*.pyo
6-
*~
7-
*env
8-
.vscode
1+
pep-0000.txt
2+
pep-????.html
3+
__pycache__
4+
*.pyc
5+
*.pyo
6+
*~
7+
*env
8+
.vscode
9+
*.swp

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,23 @@ PYTHON=python
1212
.txt.html:
1313
@$(PYTHON) $(PEP2HTML) $<
1414

15-
TARGETS=$(patsubst %.txt,%.html,$(wildcard pep-????.txt)) pep-0000.html
15+
TARGETS=$(patsubst %.txt,%.html,$(wildcard peps/pep-????.txt)) output/pep-0000.html
1616

1717
all: pep-0000.txt $(TARGETS)
1818

1919
$(TARGETS): pep2html.py
2020

21-
pep-0000.txt: $(wildcard pep-????.txt) $(wildcard pep0/*.py)
22-
$(PYTHON) genpepindex.py .
21+
pep-0000.txt: $(wildcard peps/pep-????.txt) $(wildcard pep0/*.py)
22+
$(PYTHON) genpepindex.py peps/
2323

2424
rss:
25-
$(PYTHON) pep2rss.py .
25+
$(PYTHON) pep2rss.py peps/
2626

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

3030
clean:
31-
-rm pep-0000.txt
32-
-rm *.html
31+
-rm -r output/
3332

3433
update:
3534
git pull https://github.com/python/peps.git

README.rst

Lines changed: 3 additions & 3 deletions

genpepindex.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323

2424
from operator import attrgetter
2525

26-
from pep0.output import write_pep0
27-
from pep0.pep import PEP, PEPError
26+
from peps.pep0.output import write_pep0
27+
from peps.pep0.pep import PEP, PEPError
28+
29+
PEPDIR = "peps"
30+
OUTPUTDIR = "output"
2831

2932

3033
def main(argv):
3134
if not argv[1:]:
32-
path = '.'
35+
path = PEPDIR
3336
else:
3437
path = argv[1]
3538

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

64-
with codecs.open('pep-0000.txt', 'w', encoding='UTF-8') as pep0_file:
67+
try:
68+
os.makedirs(OUTPUTDIR)
69+
except OSError: # output directory alrady exists. Everything's fine...
70+
pass
71+
72+
with codecs.open(os.path.join(OUTPUTDIR, 'pep-0000.txt'), 'w', encoding='UTF-8') as pep0_file:
6573
write_pep0(peps, pep0_file)
6674

6775
if __name__ == "__main__":

pep2html.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
PROGRAM = sys.argv[0]
5757
RFCURL = 'http://www.faqs.org/rfcs/rfc%d.html'
5858
PEPURL = 'pep-%04d.html'
59+
PEPDIR = 'peps'
60+
OUTPUTDIR = 'output'
5961
PEPCVSURL = ('https://hg.python.org/peps/file/tip/pep-%04d.txt')
6062
PEPDIRRUL = 'http://www.python.org/peps/'
6163

@@ -371,7 +373,7 @@ def find_pep(pep_str):
371373
if os.path.exists(pep_str):
372374
return pep_str
373375
num = int(pep_str)
374-
return "pep-%04d.txt" % num
376+
return os.path.join(PEPDIR, "pep-%04d.txt" % num)
375377

376378
def make_html(inpath, verbose=0):
377379
input_lines = get_input_lines(inpath)
@@ -390,7 +392,7 @@ def make_html(inpath, verbose=0):
390392
elif PEP_TYPE_DISPATCH[pep_type] == None:
391393
pep_type_error(inpath, pep_type)
392394
return None
393-
outpath = os.path.splitext(inpath)[0] + ".html"
395+
outpath = os.path.join(OUTPUTDIR, os.path.splitext(os.path.basename(inpath))[0] + ".html")
394396
if verbose:
395397
print(inpath, "(%s)" % pep_type, "->", outpath)
396398
sys.stdout.flush()
@@ -519,6 +521,11 @@ def main(argv=None):
519521
elif opt in ('-b', '--browse'):
520522
browse = 1
521523

524+
try:
525+
os.makedirs(OUTPUTDIR)
526+
except OSError: # output directory alrady exists. Everything's fine...
527+
pass
528+
522529
if args:
523530
peptxt = []
524531
html = []
@@ -534,7 +541,7 @@ def main(argv=None):
534541
# do them all
535542
peptxt = []
536543
html = []
537-
files = glob.glob("pep-*.txt")
544+
files = glob.glob(os.path.join(PEPDIR, "pep-*.txt"))
538545
files.sort()
539546
for file in files:
540547
peptxt.append(file)

pep2pyramid.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
PEPCVSURL = 'http://hg.python.org/peps/file/tip/pep-%04d.txt'
4747
PEPDIRURL = '/dev/peps/'
4848
PEPURL = PEPDIRURL + 'pep-%04d'
49+
PEPDIR = 'peps'
4950
PEPANCHOR = '<a href="' + PEPURL + '">%i</a>'
5051

5152

@@ -499,7 +500,7 @@ def build_peps(args=None):
499500
filenames = pep_filename_generator(args)
500501
else:
501502
# do them all
502-
filenames = glob.glob("pep-*.txt")
503+
filenames = glob.glob(os.path.join(PEPDIR, "pep-*.txt"))
503504
filenames.sort()
504505
for filename in filenames:
505506
try:

pep2rss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def firstline_startingwith(full_path, text):
1616
return None
1717

1818
# get list of peps with creation time (from "Created:" string in pep .txt)
19-
peps = glob.glob('pep-*.txt')
19+
peps = glob.glob('peps/pep-*.txt')
2020
def pep_creation_dt(full_path):
2121
created_str = firstline_startingwith(full_path, 'Created:')
2222
# bleh, I was hoping to avoid re but some PEPs editorialize

peps/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)