mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-05-28 00:06:24 +00:00
refactoring
This commit is contained in:
@@ -33,7 +33,7 @@ max-line-length = 160
|
||||
|
||||
[BASIC]
|
||||
# Good variable names which should always be accepted, separated by a comma
|
||||
good-names = _, __, x, y, ws, make-html-h, make-jpeg-h
|
||||
good-names = _, __, x, y, ws, make-html-h, make-jpeg-h, make-ico-h
|
||||
|
||||
# Regular expression matching correct method names
|
||||
method-rgx = [a-z_][a-z0-9_]{2,50}$
|
||||
|
||||
@@ -46,6 +46,4 @@ C_PREPEND = textwrap.dedent("""
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
""").strip() + "\n"
|
||||
""").strip() + "\n"
|
||||
|
||||
@@ -36,8 +36,8 @@ def main() -> None:
|
||||
h_path = os.path.basename(c_path[:-2] + ".h")
|
||||
name = sys.argv[3]
|
||||
|
||||
with open(html_path, "r") as html_file:
|
||||
html = html_file.read()
|
||||
with open(html_path, "r") as file:
|
||||
html = file.read()
|
||||
|
||||
html = html.strip()
|
||||
html = html.replace("\"", "\\\"")
|
||||
@@ -51,8 +51,8 @@ def main() -> None:
|
||||
text = f"{common.C_PREPEND}\n#include \"{h_path}\"\n\n\n"
|
||||
text += f"const char *const US_HTML_{name}_PAGE = \" \\\n{html}\n\";\n"
|
||||
|
||||
with open(c_path, "w") as c_file:
|
||||
c_file.write(text)
|
||||
with open(c_path, "w") as file:
|
||||
file.write(text)
|
||||
|
||||
|
||||
# =====
|
||||
|
||||
@@ -65,28 +65,28 @@ def main() -> None:
|
||||
h_path = os.path.basename(c_path[:-2]) + ".h"
|
||||
name = sys.argv[3]
|
||||
|
||||
with open(jpeg_path, "rb") as jpeg_file:
|
||||
jpeg_data = jpeg_file.read()
|
||||
with open(jpeg_path, "rb") as file:
|
||||
data = file.read()
|
||||
|
||||
(width, height) = _get_jpeg_size(jpeg_data)
|
||||
(width, height) = _get_jpeg_size(data)
|
||||
|
||||
jpeg_data_text = "{\n\t" + ",\n\t".join(
|
||||
data_text = "{\n\t" + ",\n\t".join(
|
||||
", ".join(
|
||||
f"0x{ch:02X}"
|
||||
for ch in jpeg_data[index:index + 20]
|
||||
for ch in data[index:index + 20]
|
||||
)
|
||||
for index in range(0, len(jpeg_data), 20)
|
||||
for index in range(0, len(data), 20)
|
||||
) + ",\n}"
|
||||
|
||||
text = f"{common.C_PREPEND}\n"
|
||||
text += f"#include \"{h_path}\"\n\n\n"
|
||||
text += f"const unsigned US_{name}_JPEG_WIDTH = {width};\n"
|
||||
text += f"const unsigned US_{name}_JPEG_HEIGHT = {height};\n\n"
|
||||
text += f"const size_t US_{name}_JPEG_DATA_SIZE = {len(jpeg_data)};\n"
|
||||
text += f"const uint8_t US_{name}_JPEG_DATA[] = {jpeg_data_text};\n"
|
||||
text += f"const size_t US_{name}_JPEG_DATA_SIZE = {len(data)};\n"
|
||||
text += f"const uint8_t US_{name}_JPEG_DATA[] = {data_text};\n"
|
||||
|
||||
with open(c_path, "w") as c_file:
|
||||
c_file.write(text)
|
||||
with open(c_path, "w") as file:
|
||||
file.write(text)
|
||||
|
||||
|
||||
# =====
|
||||
|
||||
Reference in New Issue
Block a user