zrb 1.8.0__py3-none-any.whl → 1.8.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -203,15 +203,4 @@ def _read_txt_content(file_path: str, file_reader: list[RAGFileReader]):
203
203
  for reader in file_reader:
204
204
  if reader.is_match(file_path):
205
205
  return reader.read(file_path)
206
- if file_path.lower().endswith(".pdf"):
207
- return _read_pdf(file_path)
208
206
  return read_file(file_path)
209
-
210
-
211
- def _read_pdf(file_path: str) -> str:
212
- import pdfplumber
213
-
214
- with pdfplumber.open(file_path) as pdf:
215
- return "\n".join(
216
- page.extract_text() for page in pdf.pages if page.extract_text()
217
- )
zrb/util/file.py CHANGED
@@ -12,15 +12,33 @@ def read_file(file_path: str, replace_map: dict[str, str] = {}) -> str:
12
12
  Returns:
13
13
  The content of the file with replacements applied.
14
14
  """
15
- with open(
16
- os.path.abspath(os.path.expanduser(file_path)), "r", encoding="utf-8"
17
- ) as f:
18
- content = f.read()
15
+ abs_file_path = os.path.abspath(os.path.expanduser(file_path))
16
+ is_pdf = abs_file_path.lower().endswith(".pdf")
17
+ content = (
18
+ _read_pdf_file_content(abs_file_path)
19
+ if is_pdf
20
+ else _read_text_file_content(abs_file_path)
21
+ )
19
22
  for key, val in replace_map.items():
20
23
  content = content.replace(key, val)
21
24
  return content
22
25
 
23
26
 
27
+ def _read_text_file_content(file_path: str) -> str:
28
+ with open(file_path, "r", encoding="utf-8") as f:
29
+ content = f.read()
30
+ return content
31
+
32
+
33
+ def _read_pdf_file_content(file_path: str) -> str:
34
+ import pdfplumber
35
+
36
+ with pdfplumber.open(file_path) as pdf:
37
+ return "\n".join(
38
+ page.extract_text() for page in pdf.pages if page.extract_text()
39
+ )
40
+
41
+
24
42
  def read_file_with_line_numbers(
25
43
  file_path: str, replace_map: dict[str, str] = {}
26
44
  ) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zrb
3
- Version: 1.8.0
3
+ Version: 1.8.1
4
4
  Summary: Your Automation Powerhouse
5
5
  Home-page: https://github.com/state-alchemists/zrb
6
6
  License: AGPL-3.0-or-later
@@ -18,7 +18,7 @@ zrb/builtin/llm/tool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
18
18
  zrb/builtin/llm/tool/api.py,sha256=yR9I0ZsI96OeQl9pgwORMASVuXsAL0a89D_iPS4C8Dc,1699
19
19
  zrb/builtin/llm/tool/cli.py,sha256=_CNEmEc6K2Z0i9ppYeM7jGpqaEdT3uxaWQatmxP3jKE,858
20
20
  zrb/builtin/llm/tool/file.py,sha256=nCY74VtruTr9LgAq5mroSr4zF0g6LA_uXMI5sh9c8OE,17909
21
- zrb/builtin/llm/tool/rag.py,sha256=VUyRBvnSeDf8T_lKY--c5HVTfccNgiEJU3QpwssJF8E,8182
21
+ zrb/builtin/llm/tool/rag.py,sha256=yqx7vXXyrOCJjhQJl4s0TnLL-2uQUTuKRnkWlSQBW0M,7883
22
22
  zrb/builtin/llm/tool/sub_agent.py,sha256=7n14KzUSFe5Bjf2lpluKlLyL-b1Mehj2QekkuDzo0ik,5091
23
23
  zrb/builtin/llm/tool/web.py,sha256=pXRLhcB_Y6z-2w4C4WezH8n-pg3PSMgt_bwn3aaqi6g,5479
24
24
  zrb/builtin/md5.py,sha256=690RV2LbW7wQeTFxY-lmmqTSVEEZv3XZbjEUW1Q3XpE,1480
@@ -374,7 +374,7 @@ zrb/util/codemod/modify_function_call.py,sha256=wbyoRRsM4V9fPYkT5kHN0zpBetpRDq2S
374
374
  zrb/util/codemod/modify_method.py,sha256=5fioXjqNQmrf4CV2qlTZHpViF9PMnNer4FvuKam7byo,6344
375
375
  zrb/util/codemod/modify_module.py,sha256=2mzi_NxJ-kNFo5G0U_Rqb3JoYQl1s6Izt7b_wAl10F0,715
376
376
  zrb/util/cron.py,sha256=UWqqhhM7DDTPx6wjCIdBndnVh3NRu-sdKazp8aZkXh8,3833
377
- zrb/util/file.py,sha256=Y5pRJxkpshyELxsv8qw_gp1qM5OXgeDwYXqt7Y6Lqu8,2242
377
+ zrb/util/file.py,sha256=jygiPSXx2DqaUH5o9P6AKt2nyfynGfvH5mFfeIKrp_w,2754
378
378
  zrb/util/git.py,sha256=gS_Y9sQgJbY0PfgSQiowLvV3Nf0y9C8nT3j6z6oEsG8,8186
379
379
  zrb/util/git_subtree.py,sha256=E_UB5OIgm8WkHL9beifRxpZ25_BB9p1H578OhLZTgRU,4611
380
380
  zrb/util/group.py,sha256=T82yr3qg9I5k10VPXkMyrIRIqyfzadSH813bqzwKEPI,4718
@@ -388,7 +388,7 @@ zrb/util/string/name.py,sha256=SXEfxJ1-tDOzHqmSV8kvepRVyMqs2XdV_vyoh_9XUu0,1584
388
388
  zrb/util/todo.py,sha256=VGISej2KQZERpornK-8X7bysp4JydMrMUTnG8B0-liI,20708
389
389
  zrb/xcom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
390
390
  zrb/xcom/xcom.py,sha256=o79rxR9wphnShrcIushA0Qt71d_p3ZTxjNf7x9hJB78,1571
391
- zrb-1.8.0.dist-info/METADATA,sha256=UO-2C_syFn5vfZHq_IBrPT4Zgw3QFSJAzWOw1yx5Fng,8385
392
- zrb-1.8.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
393
- zrb-1.8.0.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
394
- zrb-1.8.0.dist-info/RECORD,,
391
+ zrb-1.8.1.dist-info/METADATA,sha256=L91yqIYnkr0gJ1x41_eMx5pbIlIXLuH-zvVIJCMb43E,8385
392
+ zrb-1.8.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
393
+ zrb-1.8.1.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
394
+ zrb-1.8.1.dist-info/RECORD,,
File without changes