Closed Zacharia2 closed 11 months ago
移动集合看上去是在\temp中创建了一个Source Code。然后再导入的。
HTMName、ParentTitle、Title
Begin Element #118
Source=c:\users\snowy\desktop\sm18\systems\congmingrendegerenchengzhang
Parent=116
ParentTitle=植物的记忆与藏书�?
Priority=32.31707
Begin ElementInfo #118
Title=作者简�?
Type=Topic
Status=Pending
FirstGrade=8
Ordinal=117.000000
Repetitions=0
Lapses=0
Interval=0
LastRepetition=06.11.23
AFactor=1.200
UFactor=0.000
ForgettingIndex=10
Reference=
SourceArticle=0
End ElementInfo #118
ElementColor=-16777211
AutoPlay=1
BackgroundImage=
BackgroundFile=
BackgroundStyle=Tile
Scaled=1
ReadPointComponent=0
ReadPointStart=0
ReadPointLength=0
ReadPointScrollTop=0
ComponentNo=1
Begin Component #1
Type=HTML
Cors=(100,200,9700,9300)
DisplayAt=255
Hyperlink=0
HTMName=作者简�?翁贝托·艾�? 1932年出生于意大利皮埃蒙特大区,是一位享誉世界的百科全书式的学者。身兼哲学家、历史学家、符号学家、文学批评家、作家、美学家与藏书家等多重身份,个人藏书超过三万册,出版过上百部著作,学术研究纵横古今,小说随笔睿智幽默。被誉为“当代达·芬奇”�?
HTMFile=c:\users\snowy\desktop\sm18\systems\congmingrendegerenchengzhang\elements\11\114.HTM
TestElement=0
ReadOnly=0
FullHTML=1
Style=0
End Component #1
Begin RepHist #118
End RepHist #118
End Element #118
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<h1>作者简介</h1>
<div class="picture">
<img alt="" class="normal-30" src="file:///[PrimaryStorage]ZhiWuDeJiYiYuCangShuLe/figure-3_362_542_583_1244.jpg"/>
<p class="img-note-c">翁贝托·艾柯</p>
</div>
<p class="normaltext">1932年出生于意大利皮埃蒙特大区,是一位享誉世界的百科全书式的学者。身兼哲学家、历史学家、符号学家、文学批评家、作家、美学家与藏书家等多重身份,个人藏书超过三万册,出版过上百部著作,学术研究纵横古今,小说随笔睿智幽默。被誉为“当代达·芬奇”。</p>
</body>
</html>
HTMName好像是给没有Title的元素用的。所以可以不用管。 ParentTitle、Title,源文件中有,可以替换,修复。
合并和移动合集其实只是导出源码文本到temp文件夹下,然后进行的合并和移动操作。
暂时关闭
以下是使用Python解析该文件并生成数据结构的示例代码:
def parse_file(file_path):
data = {}
with open(file_path, 'r') as file:
current_element = None
current_component = None
for line in file:
line = line.strip()
if line.startswith("Begin Element"):
element_id = line.split("#")[1].strip()
data[element_id] = {}
current_element = data[element_id]
elif line.startswith("Begin Component"):
component_id = line.split("#")[1].strip()
current_element["Component"] = {component_id: {}}
current_component = current_element["Component"][component_id]
elif line.startswith("End Element") or line.startswith("End Component"):
current_element = None
current_component = None
else:
if current_element is not None:
key, value = line.split("=")
current_element[key.strip()] = value.strip()
elif current_component is not None:
key, value = line.split("=")
current_component[key.strip()] = value.strip()
return data
file_path = "c:\\users\\snowy\\desktop\\sm18\\systems\\congmingrendegerenchengzhang"
parsed_data = parse_file(file_path)
print(parsed_data)
通过上述代码,您可以将文件路径传递给parse_file
函数,它将返回解析后的数据结构。数据结构是一个字典,其中以元素ID为键,每个元素ID关联一个包含元素属性和值的字典。如果元素中包含组件,则组件的ID将作为键,关联一个包含组件属性和值的字典。
请注意,此代码仅是一个简单示例,假设文件内容的格式和结构不变。如果文件内容存在变化或异常情况,可能需要对代码进行适当的调整和错误处理。
以下是使用缩进识别并解析该文件生成数据结构的示例代码:
def parse_file(file_path):
data = {}
with open(file_path, 'r') as file:
current_element = None
current_component = None
for line in file:
line = line.strip()
indent_level = line.count(' ')
if line.startswith("Begin Element"):
element_id = line.split("#")[1].strip()
data[element_id] = {}
current_element = data[element_id]
elif line.startswith("Begin Component"):
component_id = line.split("#")[1].strip()
current_element["Component"] = {component_id: {}}
current_component = current_element["Component"][component_id]
elif line.startswith("End Element") or line.startswith("End Component"):
current_element = None
current_component = None
else:
key, value = line.split("=")
value = value.strip()
if value.startswith("Begin"):
sub_element_type = value.split(" ")[0]
sub_element_id = value.split("#")[1].split(".")[0]
current_component[key.strip()] = {sub_element_type: {sub_element_id: {}}}
current_component = current_component[key.strip()][sub_element_type][sub_element_id]
elif indent_level == 1:
current_element[key.strip()] = value
elif current_component is not None:
current_component[key.strip()] = value
return data
file_path = "c:\\users\\snowy\\desktop\\sm18\\systems\\congmingrendegerenchengzhang"
parsed_data = parse_file(file_path)
print(parsed_data)
在上述代码中,我们使用缩进级别来识别嵌套元素和组件。缩进级别为0表示当前行是元素的属性,缩进级别为1表示当前行是元素的子元素,缩进级别为2表示当前行是组件的属性。
在识别子元素时,我们根据子元素的类型和ID创建字典,然后将其嵌套在当前组件的属性中。
请注意,如前所述,这是一个基本示例,假设文件的结构和缩进格式稳定。如果文件内容存在变化或异常情况,可能需要对代码进行适当的调整和错误处理。
其实,从源文件中,读取不到标题的,所以没戏
smkit codetitlefix
被替换为问号方块字符,然后保存后不可逆。问号方块字符是固定的码。
仅导出源码文本可以被修复