forked from aadi58002/CodeOverview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchanges.patch
More file actions
60 lines (56 loc) · 2.49 KB
/
changes.patch
File metadata and controls
60 lines (56 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
diff --git a/Files.py b/Files.py
index b640cc6..cc017fb 100755
--- a/Files.py
+++ b/Files.py
@@ -2,10 +2,9 @@
import os
import sys
import javalang
-import pprint
+import shutil
-n = len(sys.argv)
-if n != 2:
+if len(sys.argv) != 2:
exit ()
def parser(file_name) :
@@ -14,18 +13,30 @@ def parser(file_name) :
tree = javalang.parse.parse(data)
return tree
-def checkfiles (path) :
- files_list = os.listdir(path)
- for file in files_list :
- if os.path.isfile(file) and file.endswith('.java') :
- createhtml(file)
- elif os.path.isdir(file) :
- path = file
- checkfiles(path)
-
+def search_files(directory, extension):
+ extension = extension.lower()
+ for dirpath, dirnames, files in os.walk(directory):
+ for name in files:
+ if extension and name.lower().endswith(extension):
+ print(os.path.join(dirpath, name))
+ createhtml(os.path.join(dirpath, name))
+ elif not extension:
+ print(os.path.join(dirpath, name))
def createhtml(file) :
- test=parser(file)
- pprint.pprint("Hello pretty printer")
+ userhost = os.getenv("HOME")
+ cache_path = os.path.join(userhost,".cache/codeoverview")
+ cssfilepath = os.path.join(cache_path,"template.css")
+ shutil.copy("./template.css",cssfilepath)
+ file = cache_path + "/" + file
+ os.makedirs(os.path.dirname(file), exist_ok=True)
+ base = os.path.splitext(file)[0]
+ file = base + ".html"
+ htmlfilepath = os.path.join(cache_path,file)
+ # with open(htmlfilepath, 'w') as htmlfile:
+ # htmlheader = "<!DOCTYPE html>\n<html class=\"no-js\" lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta http-equiv=\"x-ua-compatible\" content=\"ie=edge\">\n<meta name=\"description\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css\" rel=\"stylesheet\" integrity=\"sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3\" crossorigin=\"anonymous\">\n<link rel=\"stylesheet\" href=\"template.css\">\n</head>"
+ # bodystart = "<body class=\"body-bg-dark\">\n<nav class=\"navbar navbar-expand-lg navbar-dark\">\n<div class=\"container-fluid\">\n<div class=\"navbar-nav me-auto mb-2 mb-lg-0\" id=\"test\">\n<div class=\"d-flex justify-content-between\">"
+ # htmlfile.writelines([htmlheader,bodystart])
+
path = sys.argv[1]
-checkfiles(path)
+search_files(path,"java")