Print headers in a highlighted style
(
username=None, message=None, priority=None, level=None, logger=None
)
| 1358 | |
| 1359 | |
| 1360 | def highlight_print( |
| 1361 | username=None, message=None, priority=None, level=None, logger=None |
| 1362 | ): |
| 1363 | """Print headers in a highlighted style""" |
| 1364 | # can add other highlighters at other priorities enriching this function |
| 1365 | |
| 1366 | # find the number of chars needed off the length of the logger message |
| 1367 | output_len = 28 + len(username) + 3 + len(message) if logger else len(message) |
| 1368 | show_logs = Settings.show_logs |
| 1369 | upper_char = None |
| 1370 | lower_char = None |
| 1371 | |
| 1372 | if priority in ["initialization", "end"]: |
| 1373 | # OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO |
| 1374 | # E.g.: Session started! |
| 1375 | # oooooooooooooooooooooooooooooooooooooooooooooooo |
| 1376 | upper_char = "O" |
| 1377 | lower_char = "o" |
| 1378 | |
| 1379 | elif priority == "login": |
| 1380 | # ................................................ |
| 1381 | # E.g.: Logged in successfully! |
| 1382 | # '''''''''''''''''''''''''''''''''''''''''''''''' |
| 1383 | upper_char = "." |
| 1384 | lower_char = "'" |
| 1385 | |
| 1386 | elif priority == "feature": # feature highlighter |
| 1387 | # ________________________________________________ |
| 1388 | # E.g.: Starting to interact by users.. |
| 1389 | # """""""""""""""""""""""""""""""""""""""""""""""" |
| 1390 | upper_char = "_" |
| 1391 | lower_char = '"' |
| 1392 | |
| 1393 | elif priority == "user iteration": |
| 1394 | # :::::::::::::::::::::::::::::::::::::::::::::::: |
| 1395 | # E.g.: User: [1/4] |
| 1396 | upper_char = ":" |
| 1397 | lower_char = None |
| 1398 | |
| 1399 | elif priority == "post iteration": |
| 1400 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1401 | # E.g.: Post: [2/10] |
| 1402 | upper_char = "~" |
| 1403 | lower_char = None |
| 1404 | |
| 1405 | elif priority == "workspace": |
| 1406 | # ._. ._. ._. ._. ._. ._. ._. ._. ._. ._. ._. ._. |
| 1407 | # E.g.: |> Workspace in use: "C:/Users/El/InstaPy" |
| 1408 | upper_char = " ._. " |
| 1409 | lower_char = None |
| 1410 | |
| 1411 | if upper_char and (show_logs or priority == "workspace"): |
| 1412 | print("{}".format(upper_char * int(ceil(output_len / len(upper_char))))) |
| 1413 | |
| 1414 | if level == "info": |
| 1415 | if logger: |
| 1416 | logger.info(message) |
| 1417 | else: |
no outgoing calls
no test coverage detected