23
23
from webdriver_manager .core .http import HttpClient
24
24
from webdriver_manager .core .os_manager import OperationSystemManager
25
25
26
- __version__ = "0.0.3 "
26
+ __version__ = "0.0.5 "
27
27
28
28
DEFAULT_CACHE_DIR = os .path .join (Path .home (), ".html2print" , "chromedriver" )
29
29
@@ -40,7 +40,7 @@ def get(self, url, params=None, **kwargs) -> Response:
40
40
last_error : Optional [Exception ] = None
41
41
for attempt in range (1 , 3 ):
42
42
print ( # noqa: T201
43
- f"html2pdf : sending GET request attempt { attempt } : { url } "
43
+ f"html2print : sending GET request attempt { attempt } : { url } "
44
44
)
45
45
try :
46
46
return requests .get (url , params , timeout = (5 , 5 ), ** kwargs )
@@ -50,10 +50,10 @@ def get(self, url, params=None, **kwargs) -> Response:
50
50
last_error = read_timeout_
51
51
except Exception as exception_ :
52
52
raise AssertionError (
53
- "html2pdf : unknown exception" , exception_
53
+ "html2print : unknown exception" , exception_
54
54
) from None
55
55
print ( # noqa: T201
56
- f"html2pdf : "
56
+ f"html2print : "
57
57
f"failed to get response for URL: { url } with error: { last_error } "
58
58
)
59
59
@@ -83,24 +83,24 @@ def find_driver(self, driver: Driver):
83
83
)
84
84
if os .path .isfile (path_to_cached_chrome_driver ):
85
85
print ( # noqa: T201
86
- f"html2pdf : ChromeDriver exists in the local cache: "
86
+ f"html2print : ChromeDriver exists in the local cache: "
87
87
f"{ path_to_cached_chrome_driver } "
88
88
)
89
89
return path_to_cached_chrome_driver
90
90
print ( # noqa: T201
91
- f"html2pdf : ChromeDriver does not exist in the local cache: "
91
+ f"html2print : ChromeDriver does not exist in the local cache: "
92
92
f"{ path_to_cached_chrome_driver } "
93
93
)
94
94
path_to_downloaded_chrome_driver = super ().find_driver (driver )
95
95
if path_to_downloaded_chrome_driver is None :
96
96
print ( # noqa: T201
97
- f"html2pdf : could not get a downloaded ChromeDriver: "
97
+ f"html2print : could not get a downloaded ChromeDriver: "
98
98
f"{ path_to_cached_chrome_driver } "
99
99
)
100
100
return None
101
101
102
102
print ( # noqa: T201
103
- f"html2pdf : saving chromedriver to StrictDoc's local cache: "
103
+ f"html2print : saving chromedriver to StrictDoc's local cache: "
104
104
f"{ path_to_downloaded_chrome_driver } -> { path_to_cached_chrome_driver } "
105
105
)
106
106
Path (path_to_cached_chrome_driver_dir ).mkdir (
@@ -116,7 +116,7 @@ def get_inches_from_millimeters(mm: float) -> float:
116
116
117
117
118
118
def get_pdf_from_html (driver , url ) -> bytes :
119
- print (f"html2pdf : opening URL with ChromeDriver: { url } " ) # noqa: T201
119
+ print (f"html2print : opening URL with ChromeDriver: { url } " ) # noqa: T201
120
120
121
121
driver .get (url )
122
122
@@ -170,7 +170,7 @@ class Done(Exception):
170
170
)
171
171
sys .exit (1 )
172
172
173
- print ("html2pdf : JS logs from the print session:" ) # noqa: T201
173
+ print ("html2print : JS logs from the print session:" ) # noqa: T201
174
174
print ('"""' ) # noqa: T201
175
175
for entry in logs :
176
176
print (entry ) # noqa: T201
@@ -179,7 +179,7 @@ class Done(Exception):
179
179
#
180
180
# Execute Print command with ChromeDriver.
181
181
#
182
- print ("html2pdf : executing print command with ChromeDriver." ) # noqa: T201
182
+ print ("html2print : executing print command with ChromeDriver." ) # noqa: T201
183
183
result = driver .execute_cdp_cmd ("Page.printToPDF" , calculated_print_options )
184
184
185
185
data = base64 .b64decode (result ["data" ])
@@ -205,7 +205,7 @@ def create_webdriver(chromedriver: Optional[str], path_to_cache_dir: str):
205
205
path_to_chrome = get_chrome_driver (path_to_cache_dir )
206
206
else :
207
207
path_to_chrome = chromedriver
208
- print (f"html2pdf : ChromeDriver available at path: { path_to_chrome } " ) # noqa: T201
208
+ print (f"html2print : ChromeDriver available at path: { path_to_chrome } " ) # noqa: T201
209
209
210
210
service = Service (path_to_chrome )
211
211
@@ -223,7 +223,7 @@ def create_webdriver(chromedriver: Optional[str], path_to_cache_dir: str):
223
223
# Enable the capturing of everything in JS console.
224
224
webdriver_options .set_capability ("goog:loggingPrefs" , {"browser" : "ALL" })
225
225
226
- print ("html2pdf : creating ChromeDriver." , flush = True ) # noqa: T201
226
+ print ("html2print : creating ChromeDriver." , flush = True ) # noqa: T201
227
227
228
228
driver = webdriver .Chrome (
229
229
options = webdriver_options ,
@@ -295,7 +295,7 @@ def main():
295
295
)
296
296
297
297
path_to_chrome = get_chrome_driver (path_to_cache_dir )
298
- print (f"html2pdf : ChromeDriver available at path: { path_to_chrome } " ) # noqa: T201
298
+ print (f"html2print : ChromeDriver available at path: { path_to_chrome } " ) # noqa: T201
299
299
sys .exit (0 )
300
300
301
301
elif args .command == "print" :
@@ -310,13 +310,13 @@ def main():
310
310
311
311
@atexit .register
312
312
def exit_handler ():
313
- print ("html2pdf : exit handler: quitting the ChromeDriver." ) # noqa: T201
313
+ print ("html2print : exit handler: quitting the ChromeDriver." ) # noqa: T201
314
314
driver .quit ()
315
315
316
316
assert len (paths ) % 2 == 0 , (
317
317
f"Expecting an even number of input/output path arguments: { paths } ."
318
318
)
319
- for current_pair_idx in range (0 , 2 , len (paths )):
319
+ for current_pair_idx in range (0 , len (paths ), 2 ):
320
320
path_to_input_html = paths [current_pair_idx ]
321
321
path_to_output_pdf = paths [current_pair_idx + 1 ]
322
322
@@ -331,7 +331,7 @@ def exit_handler():
331
331
with open (path_to_output_pdf , "wb" ) as f :
332
332
f .write (pdf_bytes )
333
333
else :
334
- print ("html2pdf : unknown command." ) # noqa: T201
334
+ print ("html2print : unknown command." ) # noqa: T201
335
335
sys .exit (1 )
336
336
337
337
0 commit comments