mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
HASPmota use endswith (#20914)
This commit is contained in:
parent
bc9fd3cd92
commit
8ff9fffa0a
File diff suppressed because it is too large
Load Diff
@ -163,7 +163,8 @@ class lvh_root
|
|||||||
# I.e. ends with `color` (to not conflict with attributes containing `color_<x>`)
|
# I.e. ends with `color` (to not conflict with attributes containing `color_<x>`)
|
||||||
#################################################################################
|
#################################################################################
|
||||||
def is_color_attribute(t)
|
def is_color_attribute(t)
|
||||||
return self._page._oh.re_color_suffix.search(str(t))
|
import string
|
||||||
|
return string.endswith(str(t), "color")
|
||||||
end
|
end
|
||||||
|
|
||||||
#- remove trailing NULL chars from a bytes buffer before converting to string -#
|
#- remove trailing NULL chars from a bytes buffer before converting to string -#
|
||||||
@ -199,7 +200,6 @@ class lvh_root
|
|||||||
# parse_hex(string) -> int
|
# parse_hex(string) -> int
|
||||||
# skip any `#` prefix, or `0x` and `0X` prefix
|
# skip any `#` prefix, or `0x` and `0X` prefix
|
||||||
import string
|
import string
|
||||||
s = string.toupper(s) # turn to uppercase
|
|
||||||
var val = 0
|
var val = 0
|
||||||
for i:0..size(s)-1
|
for i:0..size(s)-1
|
||||||
var c = s[i]
|
var c = s[i]
|
||||||
@ -209,6 +209,8 @@ class lvh_root
|
|||||||
|
|
||||||
if c >= "A" && c <= "F"
|
if c >= "A" && c <= "F"
|
||||||
val = (val << 4) | string.byte(c) - 55
|
val = (val << 4) | string.byte(c) - 55
|
||||||
|
elif c >= "a" && c <= "f"
|
||||||
|
val = (val << 4) | string.byte(c) - 87
|
||||||
elif c >= "0" && c <= "9"
|
elif c >= "0" && c <= "9"
|
||||||
val = (val << 4) | string.byte(c) - 48
|
val = (val << 4) | string.byte(c) - 48
|
||||||
end
|
end
|
||||||
@ -257,7 +259,6 @@ class lvh_root
|
|||||||
end
|
end
|
||||||
elif type(t) == 'string'
|
elif type(t) == 'string'
|
||||||
import string
|
import string
|
||||||
import re
|
|
||||||
# look for 'A:name.font' style font file name
|
# look for 'A:name.font' style font file name
|
||||||
var drive_split = string.split(t, ':', 1)
|
var drive_split = string.split(t, ':', 1)
|
||||||
var fn_split = string.split(t, '-')
|
var fn_split = string.split(t, '-')
|
||||||
@ -271,7 +272,7 @@ class lvh_root
|
|||||||
sz = int(fn_split[-1])
|
sz = int(fn_split[-1])
|
||||||
name = fn_split[0..-2].concat('-') # rebuild the font name
|
name = fn_split[0..-2].concat('-') # rebuild the font name
|
||||||
end
|
end
|
||||||
if re.match(".*\\.ttf$", name)
|
if string.endswith(name, ".ttf", true)
|
||||||
# ttf font
|
# ttf font
|
||||||
name = string.split(name, ':')[-1] # remove A: if any
|
name = string.split(name, ':')[-1] # remove A: if any
|
||||||
is_ttf = true
|
is_ttf = true
|
||||||
@ -1973,7 +1974,6 @@ class HASPmota
|
|||||||
var lvh_page_cur_idx # (int) current page index number
|
var lvh_page_cur_idx # (int) current page index number
|
||||||
# regex patterns
|
# regex patterns
|
||||||
var re_page_target # compiled regex for action `p<number>`
|
var re_page_target # compiled regex for action `p<number>`
|
||||||
var re_color_suffix # compiled regex for detecting a color
|
|
||||||
# specific event_cb handling for less memory usage since we are registering a lot of callbacks
|
# specific event_cb handling for less memory usage since we are registering a lot of callbacks
|
||||||
var event # try to keep the event object around and reuse it
|
var event # try to keep the event object around and reuse it
|
||||||
var event_cb # the low-level callback for the closure to be registered
|
var event_cb # the low-level callback for the closure to be registered
|
||||||
@ -2018,7 +2018,6 @@ class HASPmota
|
|||||||
self.fix_lv_version()
|
self.fix_lv_version()
|
||||||
import re
|
import re
|
||||||
self.re_page_target = re.compile("p\\d+")
|
self.re_page_target = re.compile("p\\d+")
|
||||||
self.re_color_suffix = re.compile("color$")
|
|
||||||
# nothing to put here up to now
|
# nothing to put here up to now
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user