1
1
import os
2
2
import re
3
3
4
- from settings import ENDPOINTS_DIR
5
-
4
+ ENDPOINTS_DIR = "<SITE-API/API/Endpoints PATH>"
6
5
DOCUMENTATION_DIR = os .path .join (os .path .dirname (__file__ ), "../source/includes" )
7
6
8
- def get_all_endpoints ():
7
+ def get_all_endpoints (with_disabled = False ):
9
8
endpoints = []
10
9
for root , dirs , files in os .walk (ENDPOINTS_DIR ):
11
10
for file in files :
12
- with open (os .path .join (root , file ), 'r' ) as f :
13
- if re .search (r"public bool \$api_disabled = true;" , f .read ()):
14
- continue
11
+ if not with_disabled :
12
+ with open (os .path .join (root , file ), 'r' ) as f :
13
+ if re .search (r"public *bool *\$api_disabled *= true;" , f .read ()):
14
+ continue
15
15
16
16
endpoints .append (root .split (ENDPOINTS_DIR )[1 ] + "/" + file [:- 4 ])
17
17
@@ -25,12 +25,12 @@ def get_all_documented_endpoints():
25
25
file_cat = file [1 :- 3 ]
26
26
with open (os .path .join (DOCUMENTATION_DIR , file ), 'r' ) as f :
27
27
for line in f .readlines ():
28
- match = re .match (r"curl https:\/\/api\.simplyprint\.io\/\{id\}(.*?)(\?| \\).*$" , line )
28
+ match = re .match (r"(?: curl)?.* https:\/\/api\.simplyprint\.io\/\{id\}(.*?)(\?| \\).*$" , line )
29
29
30
30
if not match :
31
31
continue
32
32
33
- endpoints .append (match .group (1 ))
33
+ endpoints .append (match .group (1 ). replace ( " \" " , "" ) )
34
34
35
35
endpoints .sort ()
36
36
return endpoints
0 commit comments