Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pdf-miner
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Qin Kaijie
pdf-miner
Commits
17645527
Commit
17645527
authored
Apr 10, 2024
by
kernel.h@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构AbsReaderWriter
parent
c3b8f6d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
AbsReaderWriter.py
magic_pdf/io/AbsReaderWriter.py
+19
-7
No files found.
magic_pdf/io/AbsReaderWriter.py
View file @
17645527
...
@@ -5,18 +5,30 @@ class AbsReaderWriter(ABC):
...
@@ -5,18 +5,30 @@ class AbsReaderWriter(ABC):
"""
"""
同时支持二进制和文本读写的抽象类
同时支持二进制和文本读写的抽象类
"""
"""
MODE_TXT
=
"text"
MODE_BIN
=
"binary"
def
__init__
(
self
):
def
__init__
(
self
,
parent_path
):
# 初始化代码可以在这里添加,如果需要的话
# 初始化代码可以在这里添加,如果需要的话
pass
self
.
parent_path
=
parent_path
# 对于本地目录是父目录,对于s3是会写到这个apth下。
@
abstractmethod
@
abstractmethod
def
read
(
self
,
path
:
str
,
mode
=
"text"
):
def
read
(
self
,
path
:
str
,
mode
=
"text"
):
pass
"""
无论对于本地还是s3的路径,检查如果path是绝对路径,那么就不再 拼接parent_path, 如果是相对路径就拼接parent_path
"""
raise
NotImplementedError
@
abstractmethod
@
abstractmethod
def
write
(
self
,
content
:
str
,
path
:
str
,
mode
=
"text"
):
def
write
(
self
,
content
:
str
,
path
:
str
,
mode
=
MODE_TXT
):
pass
"""
无论对于本地还是s3的路径,检查如果path是绝对路径,那么就不再 拼接parent_path, 如果是相对路径就拼接parent_path
"""
raise
NotImplementedError
@
abstractmethod
def
read_jsonl
(
self
,
path
:
str
,
byte_start
=
0
,
byte_end
=
None
,
encoding
=
'utf-8'
):
"""
无论对于本地还是s3的路径,检查如果path是绝对路径,那么就不再 拼接parent_path, 如果是相对路径就拼接parent_path
"""
raise
NotImplementedError
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment