Feature: Return the absolute path (additional files) · rfc-st/humble@88a4e5e (original) (raw)

`@@ -48,6 +48,7 @@

`

48

48

`from urllib.parse import urlparse

`

49

49

`from subprocess import PIPE, Popen

`

50

50

`from os import linesep, path, remove

`

``

51

`+

from os.path import dirname, abspath

`

51

52

`from collections import Counter, defaultdict

`

52

53

`from argparse import ArgumentParser, RawDescriptionHelpFormatter

`

53

54

`import re

`

90

91

`'lic_es.txt')

`

91

92

`# https://data.iana.org/TLD/tlds-alpha-by-domain.txt

`

92

93

`NON_RU_TLD = ('CYMRU', 'GURU', 'PRU')

`

``

94

`+

OS_PATH = dirname(abspath(file))

`

93

95

`RE_PATTERN = (r'[(.*?)]',

`

94

96

` (r'^(?:\d{1,3}.){3}\d{1,3}$|'

`

95

97

`r'^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$'),

`

`@@ -115,7 +117,7 @@

`

115

117

`URL_STRING = ('rfc-st', ' URL : ', 'caniuse')

`

116

118

``

117

119

`current_time = datetime.now().strftime("%Y/%m/%d - %H:%M:%S")

`

118

``

`-

local_version = datetime.strptime('2024-09-21', '%Y-%m-%d').date()

`

``

120

`+

local_version = datetime.strptime('2024-09-27', '%Y-%m-%d').date()

`

119

121

``

120

122

``

121

123

`class SSLContextAdapter(requests.adapters.HTTPAdapter):

`

`@@ -157,7 +159,7 @@ def check_updates(local_version):

`

157

159

`def fng_statistics_top():

`

158

160

`print(f"\n{STYLE[0]}{get_detail('[fng_stats]', replace=True)}\

`

159

161

`{STYLE[4]}{get_detail('[fng_source]', replace=True)}\n")

`

160

``

`-

with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',

`

``

162

`+

with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',

`

161

163

`encoding='utf8') as fng_f:

`

162

164

`fng_lines = fng_f.readlines()

`

163

165

`fng_incl = sum(1 for _ in islice(fng_lines, SLICE_INT[0], None))

`

`@@ -186,7 +188,7 @@ def fng_statistics_top_result(fng_top_groups, fng_incl):

`

186

188

`def fng_statistics_term(fng_term):

`

187

189

`print(f"\n{STYLE[0]}{get_detail('[fng_stats]', replace=True)}\

`

188

190

`{STYLE[4]}{get_detail('[fng_source]', replace=True)}\n")

`

189

``

`-

with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',

`

``

191

`+

with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',

`

190

192

`encoding='utf8') as fng_source:

`

191

193

`fng_lines = fng_source.readlines()

`

192

194

`fng_incl = list(islice(fng_lines, SLICE_INT[0], None))

`

`@@ -227,7 +229,7 @@ def fng_statistics_term_sorted(fng_incl, fng_term, fng_groups):

`

227

229

``

228

230

`def print_grades_guide(args):

`

229

231

`grade_l10n = HUMBLE_FILES[11] if args.lang == 'es' else HUMBLE_FILES[10]

`

230

``

`-

with open(path.join(HUMBLE_DIRS[1], grade_l10n), 'r',

`

``

232

`+

with open(path.join(OS_PATH, HUMBLE_DIRS[1], grade_l10n), 'r',

`

231

233

`encoding='utf8') as grades_source:

`

232

234

`for line in islice(grades_source, SLICE_INT[3], None):

`

233

235

`print(f" {STYLE[0]}{line}" if line.startswith('[') else f"\

`

`@@ -237,7 +239,7 @@ def print_grades_guide(args):

`

237

239

``

238

240

`def print_license(args):

`

239

241

`license_l10n = HUMBLE_FILES[13] if args.lang == 'es' else HUMBLE_FILES[12]

`

240

``

`-

with open(path.join(HUMBLE_DIRS[1], license_l10n), 'r',

`

``

242

`+

with open(path.join(OS_PATH, HUMBLE_DIRS[1], license_l10n), 'r',

`

241

243

`encoding='utf8') as license_source:

`

242

244

`for line in license_source:

`

243

245

`print(f" {STYLE[0]}{line}" if line.startswith('[') else f"\

`

`@@ -247,7 +249,7 @@ def print_license(args):

`

247

249

``

248

250

`def print_security_guides():

`

249

251

`print_detail('[security_guides]')

`

250

``

`-

with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[3]), 'r',

`

``

252

`+

with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[3]), 'r',

`

251

253

`encoding='utf8') as guides_source:

`

252

254

`for line in islice(guides_source, SLICE_INT[3], None):

`

253

255

`print(f" {STYLE[0]}{line}" if line.startswith('[') else f"\

`

`@@ -283,8 +285,8 @@ def testssl_analysis(testssl_command):

`

283

285

``

284

286

``

285

287

`def get_l10n_content():

`

286

``

`-

l10n_path = path.join(HUMBLE_DIRS[1], HUMBLE_FILES[4] if args.lang == 'es'

`

287

``

`-

else HUMBLE_FILES[5])

`

``

288

`+

l10n_path = path.join(OS_PATH, HUMBLE_DIRS[1], HUMBLE_FILES[4]

`

``

289

`+

if args.lang == 'es' else HUMBLE_FILES[5])

`

288

290

`with open(l10n_path, 'r', encoding='utf8') as l10n_source:

`

289

291

`return l10n_source.readlines()

`

290

292

``

`@@ -790,15 +792,15 @@ def print_error_detail(id_mode):

`

790

792

``

791

793

``

792

794

`def get_epilog_content(id_mode):

`

793

``

`-

epilog_file_path = path.join(HUMBLE_DIRS[1], HUMBLE_FILES[5])

`

``

795

`+

epilog_file_path = path.join(OS_PATH, HUMBLE_DIRS[1], HUMBLE_FILES[5])

`

794

796

`with open(epilog_file_path, 'r', encoding='utf8') as epilog_source:

`

795

797

`epilog_lines = epilog_source.readlines()

`

796

798

`epilog_idx = epilog_lines.index(id_mode + '\n')

`

797

799

`return ''.join(epilog_lines[epilog_idx+1:epilog_idx+12])

`

798

800

``

799

801

``

800

802

`def get_fingerprint_headers():

`

801

``

`-

with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',

`

``

803

`+

with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',

`

802

804

`encoding='utf8') as fng_source:

`

803

805

`l_fng_ex = [line.strip() for line in

`

804

806

`islice(fng_source, SLICE_INT[0], None) if line.strip()]

`

`@@ -943,7 +945,7 @@ def nourl_user_agent(user_agent_id):

`

943

945

``

944

946

``

945

947

`def get_user_agent(user_agent_id):

`

946

``

`-

with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[6]), 'r',

`

``

948

`+

with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[6]), 'r',

`

947

949

`encoding='utf8') as ua_source:

`

948

950

`user_agents = [line.strip() for line in islice(ua_source, SLICE_INT[1],

`

949

951

`None)]

`

`@@ -966,7 +968,8 @@ def print_user_agents(user_agents):

`

966

968

``

967

969

`def get_insecure_checks():

`

968

970

`headers_name = set()

`

969

``

`-

with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[7]), "r") as ins_source:

`

``

971

`+

with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[7]), "r") as \

`

``

972

`+

ins_source:

`

970

973

`insecure_checks = islice(ins_source, SLICE_INT[2], None)

`

971

974

`for line in insecure_checks:

`

972

975

`insecure_header = line.split(':')[0]

`

`@@ -1147,7 +1150,8 @@ def set_pdf_color(pdf, line):

`

1147

1150

``

1148

1151

``

1149

1152

`def generate_html():

`

1150

``

`-

copyfile(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[8]), final_filename)

`

``

1153

`+

copyfile(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[8]),

`

``

1154

`+

final_filename)

`

1151

1155

`html_replace = {"html_title": get_detail('[pdf_meta_subject]'),

`

1152

1156

`"html_desc": get_detail('[pdf_meta_title]'),

`

1153

1157

`"html_keywords": get_detail('[pdf_meta_keywords]'),

`