· 5 years ago · Apr 27, 2020, 09:48 PM
1# import pipreqs
2import os
3import re
4import json
5
6urls = {
7 "test" : "%5BHSD%5D%20HSD%20DMA%20Competitive%20Advantage%20Table",
8 "adhoc_jobs" : "Ad-hoc-and-One-off-production-Tables",
9 "gv_tables" : "Gv-Prod-Tables-with-Extended-Retention-Policies",
10 "recurring_jobs" : "Recurring-Production-Jobs"
11}
12
13OAUTH_TOKEN = "GcVjLRaH64tei1AuQTNr"
14APIDICT = { 'data-science' : 1712, 'skynet' : 5253 }
15REGEX = r"^(\|[^\n]+\|\r?\n)((?:\|:?[-]+:?)+\|)(\n(?:\|[^\n]+\|\r?\n?)*)?$"
16
17def curl(pageKey):
18 # outFile = pageKey + ".txt"
19 url = urls[pageKey]
20
21 cmdString = (
22 "curl --header \"PRIVATE-TOKEN: " + OAUTH_TOKEN + "\" "
23 + "https://gitlab.spectrumxg.com/api/v4/projects/"
24 + str(APIDICT['skynet']) + "/wikis/" + url
25 )
26
27 contentJson = os.popen(cmdString).read()
28 return json.loads(contentJson)
29
30
31res = curl("gv_tables")
32
33S = res["content"].replace('\\n', '\n')
34
35matches = re.findall(REGEX, S, flags=re.MULTILINE)
36
37if len(matches) > 0:
38 print("Success")
39else:
40 print("Failure")